@Override
  protected void updateShape() {
    getRectangularShape().setFrameFromDiagonal(topLeft.getPosition(), bottomRight.getPosition());

    // call super method after shape has been updated
    super.updateShape();
  }
  @Override
  public boolean saveToXML(Node node) {
    if (!super.saveToXML(node)) return false;

    topLeft.saveToXML(XMLUtil.setElement(node, ID_TOPLEFT));
    bottomRight.saveToXML(XMLUtil.setElement(node, ID_BOTTOMRIGHT));

    return true;
  }
 public void setBounds2D(Rectangle2D bounds) {
   beginUpdate();
   try {
     // set anchors (only 2 significants anchors need to be adjusted)
     topLeft.setPosition(bounds.getMinX(), bounds.getMinY());
     bottomRight.setPosition(bounds.getMaxX(), bounds.getMaxY());
   } finally {
     endUpdate();
   }
 }
Example #4
0
  public ROI2DPath(Path2D path) {
    super(path);

    // add path points to the control point list
    controlPoints.addAll(ShapeUtil.getAnchorsFromShape(path));

    // add listeners
    for (Anchor2D pt : controlPoints) pt.addListener(this);

    setName("Path2D");
  }
Example #5
0
  @Override
  public boolean saveToXML(Node node) {
    if (!super.saveToXML(node)) return false;

    final Element points = XMLUtil.setElement(node, ID_POINTS);
    for (Anchor2D pt : controlPoints) pt.saveToXML(XMLUtil.addElement(points, ID_POINT));

    XMLUtil.setElementIntValue(node, ID_WINDING, getPath().getWindingRule());

    return true;
  }
 @Override
 public void translate(double dx, double dy) {
   beginUpdate();
   try {
     // translate (only 2 significants anchors need to be adjusted)
     topLeft.translate(dx, dy);
     bottomRight.translate(dx, dy);
   } finally {
     endUpdate();
   }
 }
  @Override
  public boolean loadFromXML(Node node) {
    beginUpdate();
    try {
      if (!super.loadFromXML(node)) return false;

      topLeft.loadFromXML(XMLUtil.getElement(node, ID_TOPLEFT));
      bottomRight.loadFromXML(XMLUtil.getElement(node, ID_BOTTOMRIGHT));
    } finally {
      endUpdate();
    }

    return true;
  }
  @Override
  public void positionChanged(Anchor2D source) {
    // adjust dependents anchors
    if (source == topLeft) {
      bottomLeft.setX(topLeft.getX());
      topRight.setY(topLeft.getY());
    } else if (source == topRight) {
      bottomRight.setX(topRight.getX());
      topLeft.setY(topRight.getY());
    } else if (source == bottomLeft) {
      topLeft.setX(bottomLeft.getX());
      bottomRight.setY(bottomLeft.getY());
    } else if (source == bottomRight) {
      topRight.setX(bottomRight.getX());
      bottomLeft.setY(bottomRight.getY());
    }

    super.positionChanged(source);
  }