Esempio n. 1
0
  @Override
  public void draw(Canvas canvas, Paint paint) {
    paint.setStyle(Paint.Style.FILL);
    canvas.drawCircle(point.getX(), point.getY(), radius, paint);

    BaseHelper.drawTextWithShadow(canvas, label, point.getX() + radius, point.getY() + radius / 2);
  }
Esempio n. 2
0
 public boolean isTouched(Point point) {
   boolean betweenDelta =
       (this.point.getX() < (point.getX() + delta.getX()))
           && (this.point.getX() > (point.getX() - delta.getX()));
   if (betweenDelta) {
     boolean betweenDelta2 =
         (this.point.getY() < (point.getY() + delta.getY()))
             && (this.point.getY() > (point.getY() - delta.getY()));
     if (betweenDelta2) {
       setPoint(lastTouchCoordinates, point);
       return true;
     }
   }
   return false;
 }
Esempio n. 3
0
  @Override
  public boolean onTouch(View view, MotionEvent motionEvent) {

    switch (motionEvent.getAction()) {
      case MotionEvent.ACTION_DOWN:
        downCoordinates.setX(motionEvent.getX());
        downCoordinates.setY(motionEvent.getY());

        touchCoordinates.setX(motionEvent.getX());
        touchCoordinates.setY(motionEvent.getY());

        if (createFigureMode) {
          CreateNewFigureInCreateFigureMode(motionEvent);
        }

        isLongClick = true;
        moveTouchedFigureToFirstPosition();

        break;
      case MotionEvent.ACTION_MOVE:
        touchCoordinates.setX(motionEvent.getX());
        touchCoordinates.setY(motionEvent.getY());
        if ((!downCoordinates.nearlyEquals(touchCoordinates)) && isLongClick) {
          isLongClick = false;
        }

        if (isTouchedShape) {
          shapes.get(FIRST_SHAPE_IN_LIST).move(touchCoordinates);
          getFigureTouchedWithFirstFigure();
          for (ShapeList shape : shapes) {
            shape.setFigureThatItWillNotBeOutsideTheScreen(getWidth(), getHeight());
          }
        }
        break;
      case MotionEvent.ACTION_UP:
        for (ShapeList s : shapes) {
          s.refreshCoordinates();
        }
        ShapeList figureTouchedWithFirstFigure = getFigureTouchedWithFirstFigure();
        if (figureTouchedWithFirstFigure != null) {
          mergeShapeLists(shapes.get(FIRST_SHAPE_IN_LIST), figureTouchedWithFirstFigure);
          thereAreTouchedFigures = false;
        }
        break;

      default:
        break;
    }
    invalidate();
    return false;
  }
Esempio n. 4
0
 @Override
 public void move(Point touchCoordinates, boolean onlyMove) {
   setPoint(
       deltaTouchCoordinates,
       lastTouchCoordinates.getX() - touchCoordinates.getX(),
       lastTouchCoordinates.getY() - touchCoordinates.getY());
   setPoint(
       this.point,
       this.point.getX() - deltaTouchCoordinates.getX(),
       this.point.getY() - deltaTouchCoordinates.getY());
   setPoint(lastTouchCoordinates, touchCoordinates);
 }
Esempio n. 5
0
 @Override
 public void changeCoordinatesToDelta(Point delta) {
   point.setX(point.getX() - delta.getX());
   point.setY(point.getY() - delta.getY());
 }
Esempio n. 6
0
 @Override
 public String toString() {
   return "Dot " + label + " - x:" + Math.round(point.getX()) + ", y:" + Math.round(point.getY());
 }