コード例 #1
0
ファイル: WhiteboardShapeLine.java プロジェクト: onsip/jitsi
  /**
   * Translates a point from the shape.
   *
   * @param deltaX x coordinate
   * @param deltaY y coordinate
   */
  public void translateSelectedPoint(double deltaX, double deltaY) {
    if (getModifyPoint() == null) return;

    if (getModifyPoint().equals(startPoint)) {
      startPoint.setX(startPoint.getX() + deltaX);
      startPoint.setY(startPoint.getY() + deltaY);

      this.setModifyPoint(startPoint);
    } else if (getModifyPoint().equals(endPoint)) {
      endPoint.setX(endPoint.getX() + deltaX);
      endPoint.setY(endPoint.getY() + deltaY);

      this.setModifyPoint(endPoint);
    }
  }
コード例 #2
0
  /**
   * WhiteboardShapeRect constructor.
   *
   * @param id String that uniquely identifies this WhiteboardShapeRect
   * @param thickness number of pixels that this object (or its border) should be thick
   * @param color WhiteboardShapeRect's color (or rather it's border)
   * @param point coordinates of this object.
   * @param width width value of this object (in pixel)
   * @param height height value of this object (in pixel)
   * @param fill True is filled, false is unfilled
   * @param transform 2D affine transformation
   */
  public WhiteboardShapeRect(
      String id,
      int thickness,
      Color color,
      WhiteboardPoint point,
      double width,
      double height,
      boolean fill,
      AffineTransform transform) {
    super(id);

    Point2D v0 = new Point2D.Double(point.getX(), point.getY());
    Point2D w0 = transform.transform(v0, null);

    double x = w0.getX();
    double y = w0.getY();

    point.setX(x);
    point.setY(y);

    Point2D v1 = new Point2D.Double(x + width, y + height);
    Point2D w1 = transform.transform(v1, null);

    double transformedWidth = w1.getX() - x;
    double transformedHeight = w1.getY() - y;

    this.initShape(thickness, color, point, transformedWidth, transformedHeight, fill);
  }
コード例 #3
0
  /**
   * Translates a point from the shape.
   *
   * @param p point position
   * @param deltaX x coordinate
   * @param deltaY y coordinate
   */
  public void translateSelectedPoint(double deltaX, double deltaY) {
    WhiteboardPoint modifyPoint = getModifyPoint();

    if (modifyPoint == null) return;

    double x = point.getX();
    double y = point.getY();

    if (modifyPoint.getX() == x && modifyPoint.getY() == y) {
      this.point.setX(x + deltaX);
      this.point.setY(y + deltaY);
      this.width -= deltaX;
      this.height -= deltaY;

      modifyPoint.setX(x + deltaX);
      modifyPoint.setY(y + deltaY);
    } else if (modifyPoint.getX() == x + width && modifyPoint.getY() == y) {
      this.point.setY(y + deltaY);
      this.width += deltaX;
      this.height -= deltaY;

      modifyPoint.setX(x + width);
      modifyPoint.setY(y + deltaY);
    } else if (modifyPoint.getX() == x && modifyPoint.getY() == y + height) {
      this.point.setX(x + deltaX);
      this.width -= deltaX;
      this.height += deltaY;

      modifyPoint.setX(x + deltaX);
      modifyPoint.setY(y + height);
    } else if (modifyPoint.getX() == x + width && modifyPoint.getY() == y + height) {
      this.width += deltaX;
      this.height += deltaY;

      modifyPoint.setX(x + width);
      modifyPoint.setY(y + height);
    }

    this.setModifyPoint(modifyPoint);
    this.recalculateSelectionPoints();
  }