/** * @return ellipse described on content */ private Ellipse2D createEllipse() { Rectangle2D contentBounds = getContent().getBounds(); double width = Math.sqrt(contentBounds.getWidth() * contentBounds.getWidth() + aspectRatio * aspectRatio * contentBounds.getHeight() * contentBounds.getHeight()); double height = width / aspectRatio; return new Ellipse2D.Double(0,0,width, height); }
private void updateOffsetPoint() { Rectangle2D selfBounds = getBounds(); Rectangle2D contentBounds = content.getBounds(); offset = new Point2D.Double( selfBounds.getX() + (selfBounds.getWidth() - contentBounds.getWidth())/2, selfBounds.getY() + (selfBounds.getHeight() - contentBounds.getHeight())/2 ); }
/** * Checks whether a point contained in the element * @param point * @return true if the point contains in item otherwise false */ public boolean contains(Point2D point) { return getBounds().contains(point); }
@Override public Rectangle2D getBounds() { Point2D location = getLocation(); Rectangle2D contentBounds = getContent().getBounds(); return new Rectangle2D.Double(location.getX(), location.getY(), contentBounds.getWidth(), contentBounds.getHeight()); }