示例#1
0
  @Override
  public boolean onTouchEvent(MotionEvent event) {
    float x = event.getX();
    float y = event.getY() + this.getScrollY();

    int size = GlobalVariables.getInstance().getSizecolor();
    int colll = GlobalVariables.getInstance().getColor();
    Brush.getPen().reset(colll, size);

    switch (event.getAction()) {
      case MotionEvent.ACTION_DOWN:
        fingerDown(x, y);
        invalidate();
        break;
      case MotionEvent.ACTION_MOVE:
        fingerMove(x, y);
        invalidate();
        break;
      case MotionEvent.ACTION_UP:
        fingerUp(x, y);
        invalidate();
        break;
    }
    return true;
  }
示例#2
0
 public File GetDraftFilePath() {
   GlobalVariables global = GlobalVariables.getInstance();
   String fullPath =
       GlobalVariables.getInstance().getUserHomePath()
           + "userdata/"
           + global.getSubject()
           + "/"
           + global.getCollectname()
           + global.getDirectory()
           + "/UserPaint/";
   fullPath += Integer.toString(((CheckContext) context).GetCurrentPage());
   fullPath += ".png";
   File f = new File(fullPath);
   return f;
 }
示例#3
0
  private void saveToSdcard() {
    GlobalVariables g = GlobalVariables.getInstance();
    String fullPath =
        g.getUserHomePath()
            + "userdata/"
            + g.getSubject()
            + "/"
            + g.getCollectname()
            + g.getDirectory()
            + "/UserPaint/"
            + Integer.toString(((CheckContext) context).GetCurrentPage())
            + ".png";

    File f = new File(fullPath);
    if (!f.getParentFile().exists()) {
      f.getParentFile().mkdirs();
    }

    if (bitmap != null) {
      try {
        AsyncTask at = new SaveBitmapAsyncTask(Bitmap.createBitmap(bitmap), fullPath);
        at.execute(new Object[] {});
      } catch (Exception e) {
        Toast.makeText(
                context,
                getResources().getString(R.string.tip_sava_failed) + fullPath,
                Toast.LENGTH_SHORT)
            .show();
        e.printStackTrace();
      }
    }
  }
示例#4
0
 public void fingerUp(float x, float y, Canvas canvas) {
   // 设置光标位置
   if (GlobalVariables.getInstance().isMoveCursor()) {
     doXY((int) x, (int) y);
     pathDrawing.resetLimit();
     return;
   }
   pathDrawing.fingerUp(x, y, canvasSrc);
   startTimer();
   setCanvasBuffer(canvas);
 }
示例#5
0
 public void fingerMove(float x, float y, Canvas canvas) {
   float dx = x - x1;
   float dy = y - y1;
   if (Math.abs(dx) > 15 || Math.abs(dy) > 15) {
     GlobalVariables.getInstance().setMoveCursor(false);
     pathDrawing.fingerMove(x, y, canvas);
     l = pathDrawing.getLeftLimit();
     r = pathDrawing.getRightLimit();
     t = pathDrawing.getTopLimit();
     b = pathDrawing.getBottomLimit();
   }
 }
示例#6
0
        @Override
        public void run() {
          long currentMilliseconds = System.currentTimeMillis();
          secondsPassed = (secondsPassed + 0x1);
          timer.postAtTime(this, currentMilliseconds);
          timer.postDelayed(updateTimeElasped, 2000);
          CopyDrawImage(canvasDst);
          if (canvasBuffer != null) {

            canvasBuffer.drawBitmap(bitmapDst, 0.0f, 0.0f, null);
            drawWordLines(canvasBuffer);
          }
          stopTimer();
          try {
            view.invalidate();
            GlobalVariables.getInstance().setMoveCursor(true);
            return;
          } catch (Exception e) {
            e.printStackTrace();
          }
        }
 @Override
 protected String getsavepath(String name, String subject) {
   File f = new File(GlobalVariables.getInstance().getMediaPath() + subject);
   if (!f.exists()) {
     f.mkdirs();
   } else {
     File[] fs = f.listFiles();
     int fsLength = fs.length;
     while (fsLength > 5) {
       File del = fs[0];
       for (int i = 1; i < fs.length; i++) {
         if (fs[i].lastModified() < del.lastModified()) {
           del = fs[i];
         }
       }
       del.delete();
       fsLength--;
     }
   }
   return f.getAbsolutePath();
 }