use of com.joliciel.jochre.graphics.RectangleImpl in project jochre by urieli.
the class ShapeSequence method getRectangleInGroup.
/**
* Return the rectangle enclosing this shape sequence in a particular group.
*/
public Rectangle getRectangleInGroup(GroupOfShapes group) {
boolean haveShapes = false;
RectangleImpl rectangle = new RectangleImpl(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE);
for (ShapeInSequence shapeInSequence : this) {
Shape shape = shapeInSequence.getShape();
if (shape.getGroup().equals(group)) {
haveShapes = true;
if (shape.getLeft() < rectangle.getLeft())
rectangle.setLeft(shape.getLeft());
if (shape.getTop() < rectangle.getTop())
rectangle.setTop(shape.getTop());
if (shape.getRight() > rectangle.getRight())
rectangle.setRight(shape.getRight());
if (shape.getBottom() > rectangle.getBottom())
rectangle.setBottom(shape.getBottom());
}
}
if (!haveShapes)
rectangle = null;
return rectangle;
}
Aggregations