Class EllipseItem

All Implemented Interfaces:
IFeedbackProvider, IDrawable, EventListener

public class EllipseItem extends PolygonItem
An ellipse item represented internally as a Path2D polygonal approximation.

Key invariants:

  • The ellipse center is the item's focus (world coordinates).
  • Width/height are stored as full extents in world units.
  • Selection handles are the four cardinal points of the ellipse in its rotated frame (top/right/bottom/left).

Resize correctness after rotation depends on using the same azimuth convention everywhere. In this codebase, azimuth behaves like a compass bearing: 0° = north (+y), 90° = east (+x), increasing clockwise. That convention is used by WorldGraphicsUtils.project(Point2D.Double, double, double, Point2D.Double).

  • Constructor Details

    • EllipseItem

      public EllipseItem(Layer layer, double w, double h, double azimuth, Point2D.Double center)
      Create an ellipse.
      Parameters:
      layer - the z layer this item is on.
      w - full width in world units (clamped to MIN_SIZE).
      h - full height in world units (clamped to MIN_SIZE).
      azimuth - rotation in degrees, using the application's compass/bearing convention.
      center - ellipse center in world coordinates (copied). If null, the ellipse path is null until focus is set and rebuildPath() is called.
  • Method Details

    • reshape

      protected void reshape()
      Ellipse-specific reshape: update width/height based on which selection handle is dragged.

      Handles are:

      • 0 = top
      • 1 = right
      • 2 = bottom
      • 3 = left

      Important implementation details for stable dragging after rotation:

      Overrides:
      reshape in class PolygonItem
    • getSelectionPoints

      public Point[] getSelectionPoints(IContainer container)
      Return the four selection handles in local (screen) coordinates.
      Overrides:
      getSelectionPoints in class AItem
      Parameters:
      container - the container for world→local conversion.
      Returns:
      a 4-element array of local points, or null if unavailable.
    • setSize

      public void setSize(double w, double h)
      Programmatically set ellipse size (full extents), clamped to MIN_SIZE.
      Parameters:
      w - new full width in world units.
      h - new full height in world units.
    • getWidthWorld

      public double getWidthWorld()
      Returns:
      full width in world units.
    • getHeightWorld

      public double getHeightWorld()
      Returns:
      full height in world units.