Exemple #1
0
  public GraphSfView(Context context) {
    super(context);
    mCanvasAdapter = new CanvasAdapter(this);
    mViewAdapter = new ViewAdapter();
    mCoreView = new GiCoreView(null);
    mCoreView.createView(mViewAdapter, 0);

    DisplayMetrics dm = context.getApplicationContext().getResources().getDisplayMetrics();
    GiCoreView.setScreenDpi(dm.densityDpi);

    getHolder().addCallback(new SurfaceCallback());

    this.setOnTouchListener(
        new OnTouchListener() {
          public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
              mCoreView.onGesture(
                  mViewAdapter,
                  GiGestureType.kGiGesturePan,
                  GiGestureState.kGiGestureBegan,
                  event.getX(),
                  event.getY());
            } else if (event.getAction() == MotionEvent.ACTION_UP) {
              mCoreView.onGesture(
                  mViewAdapter,
                  GiGestureType.kGiGesturePan,
                  GiGestureState.kGiGestureEnded,
                  event.getX(),
                  event.getY());
              showTime();
            } else if (mDynDrawView != null
                && event.getEventTime() > mDynDrawView.getEndPaintTime()) {
              mCoreView.onGesture(
                  mViewAdapter,
                  GiGestureType.kGiGesturePan,
                  GiGestureState.kGiGestureMoved,
                  event.getX(),
                  event.getY());
              showTime();
            } else if (mDynDrawView == null && event.getEventTime() > mEndPaintTime) {
              mCoreView.onGesture(
                  mViewAdapter,
                  GiGestureType.kGiGesturePan,
                  GiGestureState.kGiGestureMoved,
                  event.getX(),
                  event.getY());
              showTime();
            }
            return true;
          }
        });
  }
Exemple #2
0
 public void drawShapes(Canvas canvas) {
   if (mCanvasAdapter.beginPaint(canvas)) {
     if (getBackground() == null) {
       if (mBkColor == Color.TRANSPARENT) canvas.drawColor(mBkColor, Mode.CLEAR);
       else canvas.drawColor(mBkColor);
     } else {
       getBackground().draw(canvas);
     }
     mCoreView.drawAll(mViewAdapter, mCanvasAdapter);
     if (mDynDrawView == null) {
       mCoreView.dynDraw(mViewAdapter, mCanvasAdapter);
     }
     mCanvasAdapter.endPaint();
   }
 }
Exemple #3
0
 @Override
 protected void onDetachedFromWindow() {
   if (mDynDrawView != null) {
     mDynDrawView.setCoreView(null, null);
     mDynDrawView = null;
   }
   if (mViewAdapter != null) {
     mViewAdapter.delete();
     mViewAdapter = null;
   }
   if (mCoreView != null) {
     mCoreView.delete();
     mCoreView = null;
   }
   if (mCanvasAdapter != null) {
     mCanvasAdapter.delete();
     mCanvasAdapter = null;
   }
   super.onDetachedFromWindow();
 }