Class AItem
- All Implemented Interfaces:
IFeedbackProvider,IDrawable,EventListener
- Direct Known Subclasses:
AMapItem,LineItem,PathBasedItem,PointItem
IContainer.
Role in the MDI item model
An AItem is the fundamental unit of interactive content in MDI. It
lives on a Layer, which in turn belongs to an IContainer.
Items are drawn by the container's rendering pipeline, hit-tested by the
interaction layer, and can be dragged, resized, rotated, selected, or deleted
according to a set of independently-controllable behavior flags.
Drawing pipeline
The public entry point for drawing is draw(Graphics2D, IContainer),
which is called by the container. Subclasses must not override
draw; instead they implement the two abstract methods:
drawItem(Graphics2D, IContainer)— performs the actual rendering of the item's geometry.shouldDraw(Graphics2D, IContainer)— returnstrueif the item should be drawn at all (e.g. it intersects the visible area).
Behavior flags and the lock
Each interactive behavior (dragging, resizing, rotating, deleting) is
individually controlled by a boolean flag. However, the _locked flag
is a master override: when true it suppresses dragging, resizing,
rotating, and deleting regardless of the individual flags. Locking
does not suppress visibility or selection display.
Items are locked by default (_locked = true). Call
setLocked(false) or supply
LOCKED=false in the constructor key-value pairs
to make an item interactive.
Property-based construction
The constructor accepts an optional varargs list of alternating
PropertyUtils key/value pairs. These are parsed and applied by
applyProperties(Properties), which covers behavior flags, style
attributes, and display name. Subclasses that need geometry parameters should
override applyGeometryProperties(Properties).
Geometry
AItem provides three geometry fields that subclasses may use:
_path— a world-coordinatePath2D.Doublefor polygon-like items._line— a world-coordinateLine2D.Doublefor line items._focus— a world-coordinatePoint2D.Doublethat represents the item's conceptual center.
Modification lifecycle
setModification(ItemModification)— attaches the context.startModification()— classifies the operation.modify()— called repeatedly during the gesture.stopModification()— finalises, notifies, clears.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanWhether this item can be connected to other items.protected booleanWhether this item can be deleted.protected booleanWhether the item's cached rendering data is stale.protected StringHuman-readable display name for feedback and menus.protected booleanWhether this item responds to double-click.protected booleanWhether this item can be dragged.protected booleanWhether this item is enabled (responds to interaction).protected Point2D.DoubleWorld-coordinate focus — typically the centroid or anchor.protected static final ColorSemi-transparent grey fill for the focus-point indicator.protected PolygonThe screen polygon from the most recentdrawItem(java.awt.Graphics2D, edu.cnu.mdi.container.IContainer)call.protected LayerThe layer this item lives on.protected Line2D.DoubleWorld-coordinate line for line items; may benull.protected booleanMaster lock flag.protected ItemModificationActive modification during a drag/resize/rotate gesture.protected Path2D.DoubleWorld-coordinate path for polygon-like items; may benull.protected JPopupMenuRight-click popup menu; created lazily bycreatePopupMenu().protected booleanWhether this item can be resized.protected ResizePolicyResize policy applied during interactive resizing.protected booleanWhether this item responds to right-click.protected booleanWhether this item can be rotated.protected booleanWhether this item can be selected.protected booleanWhether this item is currently selected.protected IStyledThe drawing style (colors, line style, symbol type, etc.).protected booleanWhether this item can be styled via the style editor.protected booleanWhether this item is rendered.protected static IconIcon rendered inside the rotation handle when the item is selected.protected static final intPixel size of the rotation-handle hit rectangle.protected static final intHalf ofRPSIZE.protected static final intPixel size of each selection-handle hit rectangle.protected static final intHalf ofSPSIZE. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanGives an item a final chance to accept or reject an interactive modification.protected voidApply geometry-specific properties fromprops.protected voidapplyProperties(Properties props) Apply a set of properties to this item's behavior flags, style, name, and geometry.protected voidapplyStyleProperties(Properties props) Apply style-related properties fromprops.booleancontains(IContainer container, Point screenPoint) Test whether this item, as rendered, contains the given screen point.protected JPopupMenuBuild the basic popup menu for this item.voiddoubleClicked(MouseEvent mouseEvent) Called when this item receives a double-click.voiddraw(Graphics2D g2, IContainer container) Draw this item onto the container.abstract voiddrawItem(Graphics2D g2, IContainer container) Perform the actual rendering of this item's geometry.voiddrawSelections(Graphics2D g2, IContainer container) Draw selection handles and the focus indicator for this item.booleanenclosed(IContainer container, Rectangle r) Test whether a rubber-band rectangle completely encloses this item.booleanIdentity-based equality: twoAItemreferences are equal only when they are the same object.protected voidfocusFill(Graphics2D g2, IContainer container) Draw a small filled square at the item's focus point.voidNotify the item that its geometry has changed.doubleReturn the rotation angle in degrees, range(-180, 180].getBounds(IContainer container) Return the screen-coordinate bounding rectangle of this item.Return theIContainerthat hosts this item's layer.voidgetFeedbackStrings(IContainer container, Point pp, Point2D.Double wp, List<String> feedbackStrings) Populate the feedback string list with information about this item.getFocus()Return the world-coordinate focus of this item.getFocusPoint(IContainer container) Return the screen-coordinate location of the focus, ornullif the focus is not set.getLayer()Return theLayeron which this item lives.getLine()getPath()Return this item's popup menu, creating it lazily on first call.getRotatePoint(IContainer container) Return the screen-coordinate rotation handle point, ornullif the item does not support rotation.Point[]getSelectionPoints(IContainer container) Return the selection handles for this item in screen coordinates.getStyle()Return this item's style object.getView()Return theBaseViewthat owns the container hosting this item, ornullif unavailable.abstract Rectangle2D.DoubleReturn the world-coordinate bounding rectangle of this item.inthashCode()protected booleaninASelectRect(IContainer container, Point screenPoint) Test whether the screen point falls inside any selection or rotation handle rectangle.booleaninRotatePoint(IContainer container, Point screenPoint) Test whether the screen point falls inside the rotation-handle rectangle.intinSelectPoint(IContainer container, Point screenPoint, boolean checkResizable) Return the index of the selection handle whose hit-test rectangle contains the given screen point, or-1if none does.booleanbooleanReturntrueif this item can be deleted.booleanisDirty()Returntrueif this item's cached rendering data is stale.booleanbooleanReturntrueif this item can be dragged.booleanWhether this drawable is currently enabled.booleanisLocked()Returntrueif this item is locked.booleanReturntrueif this item can be resized.booleanbooleanReturntrueif this item can be rotated.booleanbooleanbooleanbooleanReturntrueif this item is "trackable" — that is, eligible to receive drag, resize, or rotate gestures from the interaction layer.booleanWhether this drawable is currently visible.voidCalled whenacceptModification(GestureContext)rejects a modification.abstract voidmodify()Update this item's geometry in response to a mouse movement during an active modification.voidprepareForPopup(Point pp) Show this item's popup menu at the given screen point.voidPrepare this item for removal from its layer.voidsetAzimuth(double azimuth) Set the rotation angle, normalising the value to(-180, 180].voidsetConnectable(boolean connectable) voidsetDeletable(boolean deletable) voidsetDirty(boolean dirty) Set the dirty flag.voidsetDisplayName(String name) voidsetDoubleClickable(boolean doubleClickable) voidsetDraggable(boolean draggable) voidsetEnabled(boolean enabled) Set whether this drawable is enabled.voidsetFillFocus(boolean fillFocus) Return whether the focus indicator is drawn when selected.voidSet the world-coordinate focus of this item.voidsetLocked(boolean locked) voidsetModification(ItemModification itemModification) Attach a modification context to begin an interactive gesture.voidsetResizable(boolean resizable) voidsetResizePolicy(ResizePolicy policy) voidsetRightClickable(boolean rightClickable) voidsetRotatable(boolean rotatable) voidsetSelectable(boolean selectable) voidsetSelected(boolean selected) Set the selected state of this item and request a container refresh.voidReplace the drawing style for this item.voidsetStyleEditable(boolean styleEditable) voidsetVisible(boolean visible) Set whether this drawable should be visible.abstract booleanshouldDraw(Graphics2D g2, IContainer container) Returntrueif this item should be drawn on the current frame.voidClassify and begin a drag, resize, or rotate modification.voidFinalise the current modification, notify layer listeners, and clear the modification record.voidtranslateLocal(int dx, int dy) Translate this item by(dx, dy)in screen (pixel) coordinates.abstract voidtranslateWorld(double dx, double dy) Translate this item by(dx, dy)in world coordinates.protected voidHook called when geometry changes and the focus should be recomputed.
-
Field Details
-
_FOCUSFILL
Semi-transparent grey fill for the focus-point indicator. -
SPSIZE
protected static final int SPSIZEPixel size of each selection-handle hit rectangle.- See Also:
-
SPSIZE2
protected static final int SPSIZE2Half ofSPSIZE.- See Also:
-
RPSIZE
protected static final int RPSIZEPixel size of the rotation-handle hit rectangle.- See Also:
-
RPSIZE2
protected static final int RPSIZE2Half ofRPSIZE.- See Also:
-
rotateIcon
Icon rendered inside the rotation handle when the item is selected. -
_path
World-coordinate path for polygon-like items; may benull. -
_line
World-coordinate line for line items; may benull. -
_focus
World-coordinate focus — typically the centroid or anchor. Drawn as a small square when the item is selected. -
_layer
The layer this item lives on. Set at construction; nulled byprepareForRemoval(). -
_style
The drawing style (colors, line style, symbol type, etc.). Nevernullunder normal operation; may benullafterprepareForRemoval().- See Also:
-
_resizePolicy
Resize policy applied during interactive resizing. -
_visible
protected boolean _visibleWhether this item is rendered. -
_draggable
protected boolean _draggableWhether this item can be dragged. Suppressed by_locked. -
_rotatable
protected boolean _rotatableWhether this item can be rotated. Suppressed by_locked. -
_styleEditable
protected boolean _styleEditableWhether this item can be styled via the style editor. -
_rightClickable
protected boolean _rightClickableWhether this item responds to right-click. -
_selectable
protected boolean _selectableWhether this item can be selected. -
_connectable
protected boolean _connectableWhether this item can be connected to other items. -
_doubleClickable
protected boolean _doubleClickableWhether this item responds to double-click. -
_locked
protected boolean _lockedMaster lock flag. Whentruedrag, resize, rotate, and delete are all suppressed, regardless of the individual flags.Default is
true. -
_resizable
protected boolean _resizableWhether this item can be resized. Suppressed by_locked.This field is
protected(notprivate) so that subclasses can read the raw flag value independently of the lock — for example, to include it in a serialised representation. The effective resizability is always exposed throughisResizable(), which also checks_locked. -
_deletable
protected boolean _deletableWhether this item can be deleted. Suppressed by_locked. -
_selected
protected boolean _selectedWhether this item is currently selected. -
_enabled
protected boolean _enabledWhether this item is enabled (responds to interaction). -
_dirty
protected boolean _dirtyWhether the item's cached rendering data is stale. Setting this totruealso clears_lastDrawnPolygon. -
_lastDrawnPolygon
The screen polygon from the most recentdrawItem(java.awt.Graphics2D, edu.cnu.mdi.container.IContainer)call.nullwhen dirty or not yet drawn. Used for hit-testing and rubber-band selection. -
_modification
Active modification during a drag/resize/rotate gesture. -
_displayName
Human-readable display name for feedback and menus. -
_popupMenu
Right-click popup menu; created lazily bycreatePopupMenu().
-
-
Constructor Details
-
AItem
Construct an item on the given layer, optionally configuring it from property key-value pairs, and immediately register it.Registration adds the item to its layer (firing an
ItemChangeType.ADDEDevent) and registers it as a feedback provider with the container's feedback control. Registration happens inside the constructor so that callers — including factory methods such as those inCreationSupport— do not need to take any extra step after construction.Construction-time event caveat
Because registration fires the
ADDEDevent before any subclass constructor body has run, a listener that immediately queries the item's geometry onADDEDwill see only the state thatapplyProperties(java.util.Properties)has set — not any geometry a subclass sets aftersuper()returns. In practice, MDI listeners that care about geometry wait for a subsequent draw or modification event, so this has not been a problem. If a future listener does need to read geometry onADDED, the creation call-site should set geometry before adding the listener, or the listener should guard against uninitialized state.- Parameters:
layer- the layer to add this item to; must not benullkeyVals- optional alternatingPropertyUtilskey/value pairs (may be empty ornull)- Throws:
IllegalArgumentException- iflayerisnull
-
-
Method Details
-
applyProperties
Apply a set of properties to this item's behavior flags, style, name, and geometry.Called from the Phase-1 constructor. May also be called later to reconfigure the item. Order: flags → name → style → geometry.
- Parameters:
props- properties to apply; a no-op ifnull
-
applyStyleProperties
Apply style-related properties fromprops.Each property is applied only when the key is present; missing keys leave the current style unchanged. Subclasses that support additional style properties should override this method and call
super.applyStyleProperties(props)first.- Parameters:
props- the properties to read; must not benull
-
applyGeometryProperties
Apply geometry-specific properties fromprops.Default implementation is a no-op. Subclasses with geometric constructor parameters (radius, width, endpoint coordinates, etc.) should override this rather than adding constructor parameters.
- Parameters:
props- the properties to read; nevernull
-
draw
Draw this item onto the container.This is the method called by the container's rendering pipeline. Subclasses must not override it; implement
drawItem(Graphics2D, IContainer)instead.Steps performed:
- Skip if
_visibleisfalse. - Call
shouldDraw(java.awt.Graphics2D, edu.cnu.mdi.container.IContainer)— skipdrawItem(java.awt.Graphics2D, edu.cnu.mdi.container.IContainer)iffalse. - Install any special clip from the owning
BaseView. - Save and restore the
StrokearounddrawItem(java.awt.Graphics2D, edu.cnu.mdi.container.IContainer). - Call
drawSelections(java.awt.Graphics2D, edu.cnu.mdi.container.IContainer)unconditionally (selected items need handles even when scrolled partially out of view).
- Skip if
-
drawItem
Perform the actual rendering of this item's geometry.Called by
draw(java.awt.Graphics2D, edu.cnu.mdi.container.IContainer)after visibility and clip setup. The stroke is saved and restored bydraw, so subclasses may freely change the stroke without cleanup.- Parameters:
g2- the graphics contextcontainer- the container being rendered
-
shouldDraw
Returntrueif this item should be drawn on the current frame.This is a secondary visibility check beyond the simple
_visibleflag. A typical implementation checks whether the item's screen bounds intersect the current clip rectangle.- Parameters:
g2- the graphics context (may be used to read clip bounds)container- the container being rendered- Returns:
trueifdrawItem(java.awt.Graphics2D, edu.cnu.mdi.container.IContainer)should be called
-
drawSelections
Draw selection handles and the focus indicator for this item.Called unconditionally by
draw(java.awt.Graphics2D, edu.cnu.mdi.container.IContainer)whenever the item is visible, even whenshouldDraw(java.awt.Graphics2D, edu.cnu.mdi.container.IContainer)returnedfalse, so handles remain visible for selected items that are partially scrolled out of view.When selected, draws:
- A white oval at each selection point.
- A yellow rotation-handle oval plus
rotateIcon, if rotatable. - The focus indicator via
focusFill(java.awt.Graphics2D, edu.cnu.mdi.container.IContainer).
- Parameters:
g2- the graphics contextcontainer- the container being rendered
-
setFillFocus
public void setFillFocus(boolean fillFocus) Return whether the focus indicator is drawn when selected. -
focusFill
Draw a small filled square at the item's focus point.Only drawn when
getFocus()returns a non-null point. The indicator is a 6×6 pixel square filled with_FOCUSFILL.- Parameters:
g2- the graphics contextcontainer- the container being rendered
-
contains
Test whether this item, as rendered, contains the given screen point.Priority order:
_lastDrawnPolygon— exact hit test.getBounds(IContainer)— axis-aligned bounding rectangle.inASelectRect(edu.cnu.mdi.container.IContainer, java.awt.Point)— selection/rotation handle rectangles.
- Parameters:
container- the container rendering this itemscreenPoint- the pixel point to test- Returns:
trueif the item containsscreenPoint
-
inASelectRect
Test whether the screen point falls inside any selection or rotation handle rectangle.- Parameters:
container- the container rendering this itemscreenPoint- the pixel point to test- Returns:
trueif the point is inside any handle rectangle
-
inRotatePoint
Test whether the screen point falls inside the rotation-handle rectangle.Returns
falseimmediately if the item is not rotatable or not selected.- Parameters:
container- the container rendering this itemscreenPoint- the pixel point to test- Returns:
trueif the point is inside the rotation handle
-
inSelectPoint
Return the index of the selection handle whose hit-test rectangle contains the given screen point, or-1if none does.Returns
-1immediately if the item is not selected, or ifcheckResizableistrueand the item is not resizable.- Parameters:
container- the container rendering this itemscreenPoint- the pixel point to testcheckResizable- iftrue, skip the test when not resizable- Returns:
- the zero-based handle index, or
-1
-
enclosed
Test whether a rubber-band rectangle completely encloses this item.The default implementation uses the cached screen polygon if available, otherwise the bounding rectangle. Subclasses with non-rectangular shapes may override for a more precise test.
- Parameters:
container- the rendering containerr- the rubber-band rectangle in screen coordinates- Returns:
trueifrcompletely contains this item
-
getBounds
Return the screen-coordinate bounding rectangle of this item.The default implementation returns
null. Subclasses should override to return a meaningful bounding box used for hit-testing and rubber-band selection.- Parameters:
container- the container rendering this item- Returns:
- the pixel bounding rectangle, or
nullif unavailable
-
getWorldBounds
Return the world-coordinate bounding rectangle of this item.- Returns:
- the world-coordinate bounding rectangle
-
getSelectionPoints
Return the selection handles for this item in screen coordinates.The default uses the vertices of
_lastDrawnPolygonif available, otherwise the four corners ofgetBounds(edu.cnu.mdi.container.IContainer).- Parameters:
container- the container rendering this item- Returns:
- array of handle points, or
nullif bounds are unavailable
-
getRotatePoint
Return the screen-coordinate rotation handle point, ornullif the item does not support rotation.- Parameters:
container- the container rendering this item- Returns:
- the rotation handle point, or
null
-
getLastDrawnPolygon
- Returns:
- the last drawn polygon, or
null
-
getPath
- Returns:
- the world-coordinate path, or
null
-
getLine
- Returns:
- the world-coordinate line, or
null
-
getFocus
Return the world-coordinate focus of this item.The focus is the item's conceptual center: for point items it is their location; for polygon items it is typically the centroid. Returns
nullif no focus has been set.- Returns:
- the world-coordinate focus, or
null
-
setFocus
Set the world-coordinate focus of this item.- Parameters:
wp- the new focus; may benullto clear
-
getFocusPoint
Return the screen-coordinate location of the focus, ornullif the focus is not set.- Parameters:
container- the container (used for world-to-screen transform)- Returns:
- the pixel location of the focus, or
null
-
updateFocus
protected void updateFocus()Hook called when geometry changes and the focus should be recomputed. The default implementation is a no-op. -
geometryChanged
public void geometryChanged()Notify the item that its geometry has changed. Recomputes the focus and marks the item dirty. -
translateWorld
public abstract void translateWorld(double dx, double dy) Translate this item by(dx, dy)in world coordinates.- Parameters:
dx- the world-coordinate offset along the X axisdy- the world-coordinate offset along the Y axis
-
translateLocal
public void translateLocal(int dx, int dy) Translate this item by(dx, dy)in screen (pixel) coordinates.Pixel deltas are converted to world deltas via the container transform, then delegated to
translateWorld(double, double).- Parameters:
dx- horizontal pixel offset (positive = right)dy- vertical pixel offset (positive = down)
-
acceptModification
Gives an item a final chance to accept or reject an interactive modification.The default implementation accepts all modifications. Subclasses may override this to enforce domain constraints after a drag, resize, or rotation gesture. For example, a map-native radar item can reject a drag that leaves a ground-based radar over water.
This method is called near the end of the tool-handler gesture, before
stopModification()clears the active modification context.- Parameters:
gc- the gesture context for the interaction- Returns:
trueto keep the modified state;falseto reject it
-
modificationRejected
Called whenacceptModification(GestureContext)rejects a modification.The default implementation does nothing. Subclasses that reject modifications should usually restore their pre-gesture geometry here.
- Parameters:
gc- the gesture context for the rejected interaction
-
setModification
Attach a modification context to begin an interactive gesture.- Parameters:
itemModification- the modification context;nullto cancel
-
getItemModification
- Returns:
- the active modification context, or
null
-
startModification
public void startModification()Classify and begin a drag, resize, or rotate modification.Priority: rotate (if start point is in rotation handle) → resize (if start point is in a selection handle) → drag (otherwise).
This method is a no-op if
_modificationisnull. -
modify
public abstract void modify()Update this item's geometry in response to a mouse movement during an active modification.Called repeatedly while the user is dragging, resizing, or rotating. The current mouse position is available through
_modification. -
stopModification
public void stopModification()Finalise the current modification, notify layer listeners, and clear the modification record.Fires
ItemChangeType.MOVED,ItemChangeType.ROTATED, orItemChangeType.RESIZEDdepending on the modification type. This method is a no-op if_modificationisnull. -
isVisible
public boolean isVisible()Description copied from interface:IDrawableWhether this drawable is currently visible.Callers should respect this flag and skip drawing when it returns
false. Default istrue. -
setVisible
public void setVisible(boolean visible) Description copied from interface:IDrawableSet whether this drawable should be visible.The default implementation ignores the flag. Implementations that track visibility should override this together with
IDrawable.isVisible().- Specified by:
setVisiblein interfaceIDrawable- Parameters:
visible-trueto make the item visible
-
isDraggable
public boolean isDraggable()Returntrueif this item can be dragged. Returnsfalsewhen locked, regardless of the drag flag.- Returns:
- effective draggability
-
setDraggable
public void setDraggable(boolean draggable) - Parameters:
draggable-trueto allow dragging
-
isDeletable
public boolean isDeletable()Returntrueif this item can be deleted. Returnsfalsewhen locked.- Returns:
- effective deletability
-
setDeletable
public void setDeletable(boolean deletable) - Parameters:
deletable-trueto allow deletion
-
isResizable
public boolean isResizable()Returntrueif this item can be resized. Returnsfalsewhen locked.- Returns:
- effective resizability
-
setResizable
public void setResizable(boolean resizable) - Parameters:
resizable-trueto allow resizing
-
isRotatable
public boolean isRotatable()Returntrueif this item can be rotated. Returnsfalsewhen locked.- Returns:
- effective rotatability
-
setRotatable
public void setRotatable(boolean rotatable) - Parameters:
rotatable-trueto allow rotation
-
isStyleEditable
public boolean isStyleEditable()- Returns:
trueif this item can be styled via the style editor
-
setStyleEditable
public void setStyleEditable(boolean styleEditable) - Parameters:
styleEditable-trueto allow styling via the style editor
-
isConnectable
public boolean isConnectable()- Returns:
trueif this item can be connected to other items
-
setConnectable
public void setConnectable(boolean connectable) - Parameters:
connectable-trueto allow connections
-
isDoubleClickable
public boolean isDoubleClickable()- Returns:
trueif this item responds to double-click
-
setDoubleClickable
public void setDoubleClickable(boolean doubleClickable) - Parameters:
doubleClickable-trueto enable double-click
-
isSelectable
public boolean isSelectable()- Returns:
trueif this item can be selected
-
setSelectable
public void setSelectable(boolean selectable) - Parameters:
selectable-trueto allow selection
-
isLocked
public boolean isLocked()Returntrueif this item is locked.A locked item ignores drag, resize, rotate, and delete operations regardless of its individual flags. Items are locked by default.
- Returns:
trueif locked
-
setLocked
public void setLocked(boolean locked) - Parameters:
locked-trueto lock the item
-
isRightClickable
public boolean isRightClickable()- Returns:
trueif this item responds to right-click
-
setRightClickable
public void setRightClickable(boolean rightClickable) - Parameters:
rightClickable-trueto enable right-click
-
isSelected
public boolean isSelected()- Returns:
trueif this item is currently selected
-
setSelected
public void setSelected(boolean selected) Set the selected state of this item and request a container refresh.- Parameters:
selected-trueto select the item
-
isEnabled
public boolean isEnabled()Description copied from interface:IDrawableWhether this drawable is currently enabled."Enabled" can be used by callers to decide, for example, whether to process interaction or feedback for this drawable. Default is
true. -
setEnabled
public void setEnabled(boolean enabled) Description copied from interface:IDrawableSet whether this drawable is enabled.The default implementation ignores the flag. Implementations that track enabled state should override this together with
IDrawable.isEnabled().- Specified by:
setEnabledin interfaceIDrawable- Parameters:
enabled-trueto enable the item
-
isDirty
public boolean isDirty()Returntrueif this item's cached rendering data is stale.- Returns:
- the dirty flag
-
setDirty
public void setDirty(boolean dirty) Set the dirty flag. Setting totruealso clears_lastDrawnPolygon. -
isTrackable
public boolean isTrackable()Returntrueif this item is "trackable" — that is, eligible to receive drag, resize, or rotate gestures from the interaction layer.An item is trackable only when it is unlocked, enabled, and at least one of
_draggable,_rotatable, or_resizableistrue. The interaction layer uses this as a fast pre-check before performing the more expensive hit-test against individual selection and rotation handles.- Returns:
trueif the item should be tracked during mouse gestures
-
getStyle
Return this item's style object.- Returns:
- the style; may be
nullafterprepareForRemoval()
-
setStyle
Replace the drawing style for this item.Passing
nullis accepted but will causeNullPointerExceptions in the drawing pipeline unlessgetStyleSafe()is used for all subsequent style accesses.- Parameters:
style- the new style;nullis technically permitted but discouraged
-
getStyleSafe
Return this item's style, recreating it as a defaultStyledinstance if_styleisnull.Used internally (e.g. in
applyStyleProperties(java.util.Properties)) to guard against the style having been cleared byprepareForRemoval(). PrefergetStyle()in normal usage.- Returns:
- the style object; never
null
-
getAzimuth
public double getAzimuth()Return the rotation angle in degrees, range(-180, 180].- Returns:
- the azimuth in degrees
-
setAzimuth
public void setAzimuth(double azimuth) Set the rotation angle, normalising the value to(-180, 180].- Parameters:
azimuth- the new azimuth in degrees
-
getDisplayName
- Returns:
- the human-readable display name
-
setDisplayName
- Parameters:
name- the new display name
-
getResizePolicy
- Returns:
- the resize policy
-
setResizePolicy
- Parameters:
policy- the new resize policy
-
getContainer
Return theIContainerthat hosts this item's layer.- Returns:
- the container; may be
nullafterprepareForRemoval()
-
getLayer
Return theLayeron which this item lives.- Returns:
- the layer; may be
nullafterprepareForRemoval()
-
getView
Return theBaseViewthat owns the container hosting this item, ornullif unavailable.- Returns:
- the owning view, or
null
-
getPopupMenu
Return this item's popup menu, creating it lazily on first call.- Returns:
- the popup menu; never
null
-
createPopupMenu
Build the basic popup menu for this item.The default menu contains an item-ordering sub-menu and a "Locked" checkbox. Subclasses may override and call
super.createPopupMenu()before adding their own items.- Returns:
- the newly created popup menu
-
prepareForPopup
Show this item's popup menu at the given screen point.- Parameters:
pp- the screen point; must not benull
-
doubleClicked
Called when this item receives a double-click. The default implementation is a no-op.- Parameters:
mouseEvent- the double-click event
-
getFeedbackStrings
public void getFeedbackStrings(IContainer container, Point pp, Point2D.Double wp, List<String> feedbackStrings) Populate the feedback string list with information about this item. The default implementation is a no-op.- Specified by:
getFeedbackStringsin interfaceIFeedbackProvider- Parameters:
container- the container rendering this itempp- the current mouse position in screen coordinateswp- the corresponding world-coordinate positionfeedbackStrings- the list to add strings to
-
equals
Identity-based equality: twoAItemreferences are equal only when they are the same object. -
hashCode
public int hashCode() -
prepareForRemoval
public void prepareForRemoval()Prepare this item for removal from its layer.Performs two operations:
- Feedback de-registration. The item unregisters itself from the
container's
FeedbackControlso that it is no longer polled after removal. The container reference is captured before_layeris nulled. - Reference nulling. Heavyweight references are set to
nullto assist garbage collection and to cause fast, obviousNullPointerExceptions if the item is used after removal.
Subclasses holding additional heavyweight references should override this method, null those fields, and call
super.prepareForRemoval()either first or last.- Specified by:
prepareForRemovalin interfaceIDrawable
- Feedback de-registration. The item unregisters itself from the
container's
-