Package edu.cnu.mdi.item
Class EllipseItem
java.lang.Object
edu.cnu.mdi.item.AItem
edu.cnu.mdi.item.PathBasedItem
edu.cnu.mdi.item.PolygonItem
edu.cnu.mdi.item.EllipseItem
- All Implemented Interfaces:
IFeedbackProvider,IDrawable,EventListener
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).
-
Field Summary
Fields inherited from class edu.cnu.mdi.item.AItem
_connectable, _deletable, _dirty, _displayName, _doubleClickable, _draggable, _enabled, _focus, _FOCUSFILL, _lastDrawnPolygon, _layer, _line, _locked, _modification, _path, _popupMenu, _resizable, _resizePolicy, _rightClickable, _rotatable, _selectable, _selected, _style, _styleEditable, _visible, rotateIcon, RPSIZE, RPSIZE2, SPSIZE, SPSIZE2 -
Constructor Summary
ConstructorsConstructorDescriptionEllipseItem(Layer layer, double w, double h, double azimuth, Point2D.Double center) Create an ellipse. -
Method Summary
Modifier and TypeMethodDescriptiondoublePoint[]getSelectionPoints(IContainer container) Return the four selection handles in local (screen) coordinates.doubleprotected voidreshape()Ellipse-specific reshape: update width/height based on which selection handle is dragged.voidsetSize(double w, double h) Programmatically set ellipse size (full extents), clamped toMIN_SIZE.Methods inherited from class edu.cnu.mdi.item.PolygonItem
setPathMethods inherited from class edu.cnu.mdi.item.PathBasedItem
contains, drawItem, getBounds, getRotatePoint, getWorldBounds, modify, rotate, scale, shouldDraw, singlePointBounds, threePointAngle, translateWorld, updateFocusMethods inherited from class edu.cnu.mdi.item.AItem
acceptModification, applyGeometryProperties, applyProperties, applyStyleProperties, createPopupMenu, doubleClicked, draw, drawSelections, enclosed, equals, focusFill, geometryChanged, getAzimuth, getContainer, getDisplayName, getFeedbackStrings, getFocus, getFocusPoint, getItemModification, getLastDrawnPolygon, getLayer, getLine, getPath, getPopupMenu, getResizePolicy, getStyle, getStyleSafe, getView, hashCode, inASelectRect, inRotatePoint, inSelectPoint, isConnectable, isDeletable, isDirty, isDoubleClickable, isDraggable, isEnabled, isLocked, isResizable, isRightClickable, isRotatable, isSelectable, isSelected, isStyleEditable, isTrackable, isVisible, modificationRejected, prepareForPopup, prepareForRemoval, setAzimuth, setConnectable, setDeletable, setDirty, setDisplayName, setDoubleClickable, setDraggable, setEnabled, setFillFocus, setFocus, setLocked, setModification, setResizable, setResizePolicy, setRightClickable, setRotatable, setSelectable, setSelected, setStyle, setStyleEditable, setVisible, startModification, stopModification, translateLocal
-
Constructor Details
-
EllipseItem
Create an ellipse.- Parameters:
layer- the z layer this item is on.w- full width in world units (clamped toMIN_SIZE).h- full height in world units (clamped toMIN_SIZE).azimuth- rotation in degrees, using the application's compass/bearing convention.center- ellipse center in world coordinates (copied). Ifnull, the ellipse path is null until focus is set andrebuildPath()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:
- Use the start focus as the center for the entire drag to avoid drift.
- Project into ellipse-local coordinates using the same bearing
azimuth convention as
WorldGraphicsUtils.project(java.awt.geom.Point2D.Double, double, double, java.awt.geom.Point2D.Double).
- Overrides:
reshapein classPolygonItem
-
getSelectionPoints
Return the four selection handles in local (screen) coordinates.- Overrides:
getSelectionPointsin classAItem- Parameters:
container- the container for world→local conversion.- Returns:
- a 4-element array of local points, or
nullif unavailable.
-
setSize
public void setSize(double w, double h) Programmatically set ellipse size (full extents), clamped toMIN_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.
-