Package edu.cnu.mdi.item
Class LineItem
java.lang.Object
edu.cnu.mdi.item.AItem
edu.cnu.mdi.item.LineItem
- All Implemented Interfaces:
IFeedbackProvider,IDrawable,EventListener
A simple
AItem representing a world-coordinate line segment.
The line geometry is stored in AItem._line (world coordinates). Rendering
and hit-testing are performed in screen space via the supplied
IContainer transforms.
This item supports ItemModificationType DRAG and ItemModificationType RESIZE modifications. Rotation is currently a no-op (consistent with the prior implementation).
-
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
ConstructorsConstructorDescriptionLineItem(Layer layer, Point2D.Double wp0, Point2D.Double wp1) Create a world line object.LineItem(Layer layer, Point2D.Double wp0, Point2D.Double wp1, Object... keyVals) Create a world line object. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontains(IContainer container, Point screenPoint) Check whether the (rendered) item contains the given screen point.voiddrawItem(Graphics2D g2, IContainer container) Custom drawer for the item.Point[]getSelectionPoints(IContainer container) Obtain the selection points used to indicate this item is selected.Get the world bounding rectangle of the item.voidmodify()A modification such as a drag, resize or rotate is continuing.booleanshouldDraw(Graphics2D g2, IContainer container) Checks whether the item should be drawn.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.Methods inherited from class edu.cnu.mdi.item.AItem
acceptModification, applyGeometryProperties, applyProperties, applyStyleProperties, createPopupMenu, doubleClicked, draw, drawSelections, enclosed, equals, focusFill, geometryChanged, getAzimuth, getBounds, getContainer, getDisplayName, getFeedbackStrings, getFocus, getFocusPoint, getItemModification, getLastDrawnPolygon, getLayer, getLine, getPath, getPopupMenu, getResizePolicy, getRotatePoint, 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
-
LineItem
Create a world line object.- Parameters:
layer- the layer this item is on.wp0- start of the line.wp1- end of the line of the line.
-
LineItem
Create a world line object.- Parameters:
layer- the layer this item is on.wp0- start of the line.wp1- end of the line of the line.keyVals- optional key-value pairs to set on the item. For example, you could use this to set the display name, style, or other properties at construction time. The keys should be from the set of standard keys defined in PropertyUtils, or any custom keys recognized by this item or its style.
-
-
Method Details
-
contains
Check whether the (rendered) item contains the given screen point. -
drawItem
Custom drawer for the item. -
shouldDraw
Checks whether the item should be drawn. This is an additional check, beyond the simple visibility flag check. For example, it might check whether the item intersects the area being drawn.- Specified by:
shouldDrawin classAItem- Parameters:
g2- the graphics context.container- the graphical container being rendered.- Returns:
trueif the item passes any and all tests, and should be drawn.
-
getSelectionPoints
Obtain the selection points used to indicate this item is selected.- Overrides:
getSelectionPointsin classAItem- Parameters:
container- the container rendering this item- Returns:
- the selection points used to indicate this item is selected.
-
modify
public void modify()A modification such as a drag, resize or rotate is continuing. -
updateFocus
protected void updateFocus()Description copied from class:AItemHook called when geometry changes and the focus should be recomputed. The default implementation is a no-op.- Overrides:
updateFocusin classAItem
-
getWorldBounds
Get the world bounding rectangle of the item.- Specified by:
getWorldBoundsin classAItem- Returns:
- the world box containing the item.
-
translateWorld
public void translateWorld(double dx, double dy) Description copied from class:AItemTranslate this item by(dx, dy)in world coordinates.- Specified by:
translateWorldin classAItem- Parameters:
dx- the world-coordinate offset along the X axisdy- the world-coordinate offset along the Y axis
-