Class TLcdGXYShapeListPainter
- All Implemented Interfaces:
ILcdCloneable,ILcdDeepCloneable,ILcdPropertyChangeSource,ILcdGXYEditor,ILcdGXYEditorProvider,ILcdGXYPainter,ILcdGXYPainterProvider,ILcdGXYPathPainter,Serializable,Cloneable
- Direct Known Subclasses:
TLcdGXYAreaShapeListPainter,TLcdGXYPointShapeListPainter,TLcdGXYPolylineShapeListPainter,TLcdGXYRoutePainter
ILcdShapeList objects and enables visual editing of
ILcdShapeList objects in an ILcdGXYView.
Painting an ILcdShapeList
Body
This painter provides support for painting an ILcdShapeList object. For each shape of the
shape list, a painter is retrieved via the method retrieveShapePainter.
The retrieved painter is then used to paint the corresponding ILcdShape object.
In theory, calling this painter recursively would cause problems, since the
method setObject(Object) is then called repeatedly inside the
recursion, each time overwriting the higher level shape lists. However, this
implementation takes care of this case, by storing and restoring the shape
lists whenever necessary.
Handles
This painter does not define a handle for ILcdShapeList objects. However, the handles for
each individual ILcdShape object are defined by the corresponding painter for that shape.
Snap targets
This painter will process all ILcdShape objects in the ILcdShapeList object
and tries to retrieve a snap target for each shape using the corresponding painter. The first snap target
that is found, is used as snap target for this TLcdGXYShapeListPainter.
Styling options
The visualization of the ILcdShapeList object is governed by the painter provider set to
this painter. The painter provider is responsible for providing
a painter to be used for painting each of the individual ILcdShape
objects contained in the ILcdShapeList object. Note that this implementation assumes that
a painter can be provided for each shape of the shape list.
Locating an ILcdShapeList in a view
Anchor point of an ILcdShapeList
When the ILcdShapeList object only contains one ILcdShape object, the anchor
point of that object is used as anchor point for the shape list. If more ILcdShape objects
are available, the center point of the bounds, calculated by boundsSFCT, is used.
When is an ILcdShapeList touched
The ILcdShapeList object is touched when one of the ILcdShape objects in the
shape list is touched.
Visually editing and creating an ILcdShapeList
Modifying an ILcdShapeList
Depending on the editTouchedOnly property, all shape objects of the shape
list need to be edited or only the touched objects. An exception to this is when a handle is edited:
this only affects the objects whose handle is touched.
For every shape object that has to be edited, an
editor is retrieved via the method retrieveShapeEditor. The retrieved editor
is then used to edit the corresponding ILcdShape object.
Similarly to the painter provider, the editor provider is responsible
for providing an editor to be used for editing the individual ILcdShape
objects contained in the ILcdShapeList object. Note that this implementation assumes that an
editor can be provided for each shape of the shape list.
Creating an ILcdShapeList
When initializing an ILcdShapeList object via interaction through the view, only the last shape
object is edited. The number of user interactions required to complete the initialization is defined by the
editor corresponding to the last ILcdShape object.
Accepted snap targets
This painter accepts a snap target if at least one of the shape editors returned by the shape editor provider accepts the snap target.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intConstant value indicating that the anchor point should be the anchor point of the first possible shape in the shape list.static final intConstant value indicating that the anchor point should be chosen as the focus point of the shape list.protected ILcdGXYEditorProviderThe editor provider to retrieve editors for the objects inside theILcdShapeListobject.protected ILcdGXYPainterProviderThe painter provider to retrieve painters for the objects inside theILcdShapeListobject.static final intConstant value indicating that the anchor point should be chosen in the middle of the bounds, calculated byboundsSFCT.static final intConstant value indicating that the anchor point should be chosen as the anchor point of the only shape in the shape list.Fields inherited from class com.luciad.view.gxy.ALcdGXYPainter
defaultCreationFillStyle, defaultCreationLineStyle, defaultFillStyle, defaultLineStyle, fWorkBoundsFields inherited from interface com.luciad.view.gxy.ILcdGXYEditor
CREATING, END_CREATION, RESHAPED, START_CREATION, TRANSLATEDFields inherited from interface com.luciad.view.gxy.ILcdGXYPainter
BODY, CREATING, DEFAULT, HANDLES, RESHAPING, SELECTED, SNAPS, TRANSLATING -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a defaultTLcdGXYShapeListPainterand sets the display name to "ShapeList".TLcdGXYShapeListPainter(ILcdGXYPainterProvider aShapeGXYPainterProvider) Constructs a defaultTLcdGXYShapeListPainterwith the specified painter provider and sets the display name to "ShapeList". -
Method Summary
Modifier and TypeMethodDescriptionbooleanacceptSnapTarget(Graphics aGraphics, ILcdGXYContext aGXYContext) Determines whether a snap target should be accepted or not.voidanchorPointSFCT(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext, Point aPointSFCT) Moves the specifiedaPointSFCTto the anchor point of theILcdShapeListobject.booleanappendAWTPath(ILcdGXYContext aGXYContext, int aRenderMode, ILcdAWTPath aAWTPathSFCT) Appends a discretized representation in view coordinates to the given path.booleanappendGeneralPath(ILcdGXYContext aGXYContext, int aRenderMode, ILcdGeneralPath aGeneralPathSFCT) Appends a discretized representation in world coordinates to the given path.voidboundsSFCT(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext, ILcd2DEditableBounds aBoundsSFCT) Sets the supplied bounds (in view coordinates, pixels) so that it encompasses the representation of the object in the given mode taking into account the given context.clone()MakesObject.clone()public.Returns a deep clone of this Object.booleanedit(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext) This implementation edits, depending on theeditTouchedOnlyproperty, allILcdShapeobjects of theILcdShapeListobject are edited or only the touched object.protected booleaneditShape(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext, ILcdGXYEditor aGXYEditor, ILcdShapeList aShapeList, int aIndex) Edits the shape at the specified index in aShapeList.intReturns the location of the anchor point (by default: ONE_SHAPE_ANCHOR_POINT).intReturns the number of user interactions required to complete the initialization of theILcdShapeListobject set to this editor.getCursor(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext) Returns aCursorthat clarifies the render mode and context this painter is operating in.getGXYEditor(Object aObject) Returns this instance as editor for editing the specifiedObject.final ObjectReturns the object that can currently be painted or edited by this painter/editor.Returns the editor provider used to provide an editor for each shape inside the shape list.Returns the painter provider used to provide a painter for each shape inside the shape list.final booleanReturns whether only the touched shape objects should be edited or all of them.booleanisTouched(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext) Returns whether one of theILcdShapeobjects inside theILcdShapeListobject is touched.voidpaint(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext) Displays the representation of the object in the given mode on the Graphics passed, taking into account the context passed.protected ILcdGXYEditorretrieveShapeEditor(ILcdShapeList aShapeList, int aShapeIndex) Returns the editor for the shape at the given index in theILcdShapeListobject.protected ILcdGXYPainterretrieveShapePainter(ILcdShapeList aShapeList, int aShapeIndex) Returns the painter for the shape at the given index in theILcdShapeListobject.voidsetAnchorPointLocation(int aAnchorPointLocation) Sets the preferred anchor point location.final voidsetEditTouchedOnly(boolean aEditTouchedOnly) Determines whether only the touchedILcdShapeobjects in theILcdShapeListobject are edited or whether all shape objects should be edited.voidSets the object to paint and edit.voidsetShapeGXYEditorProvider(ILcdGXYEditorProvider aShapeGXYEditorProvider) Sets the editor provider used to provide an editor for each shape inside the shape list.voidsetShapeGXYPainterProvider(ILcdGXYPainterProvider aShapeGXYPainterProvider) Sets the painter provider used to provide a painter for each shape inside the shape list.snapTarget(Graphics aGraphics, ILcdGXYContext aGXYContext) Returns the first snap target that was found by the painters of the shapes inside theILcdShapeListobject.booleansupportSnap(Graphics aGraphics, ILcdGXYContext aGXYContext) Supports snapping when at least one of the painters of the shapes inside theILcdShapeListobject supports snapping.Methods inherited from class com.luciad.view.gxy.ALcdGXYPainter
addPropertyChangeListener, firePropertyChangeEvent, firePropertyChangeEvent, getDisplayName, getGXYPainter, isTraceOn, removePropertyChangeListener, setClassTraceOn, setDisplayName, setTraceOnMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.luciad.view.gxy.ILcdGXYEditor
getDisplayNameMethods inherited from interface com.luciad.view.gxy.ILcdGXYPainter
getDisplayNameMethods inherited from interface com.luciad.util.ILcdPropertyChangeSource
addPropertyChangeListener, removePropertyChangeListener
-
Field Details
-
MIDDLE_OF_BOUNDS
public static final int MIDDLE_OF_BOUNDSConstant value indicating that the anchor point should be chosen in the middle of the bounds, calculated byboundsSFCT.- See Also:
-
FOCUS_POINT
public static final int FOCUS_POINTConstant value indicating that the anchor point should be chosen as the focus point of the shape list. If this point cannot be retrieved, the middle of the bounds are returned.- See Also:
-
ONE_SHAPE_ANCHOR_POINT
public static final int ONE_SHAPE_ANCHOR_POINTConstant value indicating that the anchor point should be chosen as the anchor point of the only shape in the shape list. If the shape list contains more than one shape, or if the only shape cannot provide an anchor point, the middle of the bounds are returned.- See Also:
-
FIRST_POSSIBLE_SHAPE_ANCHOR_POINT
public static final int FIRST_POSSIBLE_SHAPE_ANCHOR_POINTConstant value indicating that the anchor point should be the anchor point of the first possible shape in the shape list. If the first shape can't provide an anchor point, the second shape is used, and so on... If no shape in the shape list can provide an anchor point, the middle of the bounds are used.- See Also:
-
fShapeGXYPainterProvider
The painter provider to retrieve painters for the objects inside theILcdShapeListobject. -
fShapeGXYEditorProvider
The editor provider to retrieve editors for the objects inside theILcdShapeListobject.
-
-
Constructor Details
-
TLcdGXYShapeListPainter
public TLcdGXYShapeListPainter()Constructs a defaultTLcdGXYShapeListPainterand sets the display name to "ShapeList". The painter provider and the editor provider are not initialized and are required to be set using the methodssetShapeGXYPainterProvider(com.luciad.view.gxy.ILcdGXYPainterProvider)andsetShapeGXYEditorProvider(com.luciad.view.gxy.ILcdGXYEditorProvider)respectively.- See Also:
-
TLcdGXYShapeListPainter
Constructs a defaultTLcdGXYShapeListPainterwith the specified painter provider and sets the display name to "ShapeList". The editor provider is not initialized and is required to be set using the methodsetShapeGXYEditorProvider(com.luciad.view.gxy.ILcdGXYEditorProvider).- Parameters:
aShapeGXYPainterProvider- the painter provider for theILcdShapeobjects inside theILcdShapeListobject.- See Also:
-
-
Method Details
-
setShapeGXYPainterProvider
Sets the painter provider used to provide a painter for each shape inside the shape list.- Parameters:
aShapeGXYPainterProvider- the painter provider for theILcdShapeobjects inside theILcdShapeListobject.- See Also:
-
getShapeGXYPainterProvider
Returns the painter provider used to provide a painter for each shape inside the shape list.- Returns:
- the painter provider used to provide a painter for each shape inside the shape list.
- See Also:
-
retrieveShapePainter
Returns the painter for the shape at the given index in theILcdShapeListobject.- Parameters:
aShapeList- The shape list containing the shape.aShapeIndex- The index of the shape within the shape list.- Returns:
- the painter for the shape at the given index in the
ILcdShapeListobject.
-
setObject
Sets the object to paint and edit. The object should be an instance of
ILcdShapeListfor painting and editing. When the object does not implement theILcdShapeListinterface, anIllegalArgumentExceptionwill be thrown.- Specified by:
setObjectin interfaceILcdGXYEditor- Specified by:
setObjectin interfaceILcdGXYPainter- Parameters:
aObject- The object to paint and edit.- Throws:
IllegalArgumentException- when the object does not implementILcdShapeList.- See Also:
-
getObject
Returns the object that can currently be painted or edited by this painter/editor.- Specified by:
getObjectin interfaceILcdGXYEditor- Specified by:
getObjectin interfaceILcdGXYPainter- Returns:
- the object that can currently be painted or edited by this painter/editor.
- See Also:
-
setEditTouchedOnly
public final void setEditTouchedOnly(boolean aEditTouchedOnly) Determines whether only the touchedILcdShapeobjects in theILcdShapeListobject are edited or whether all shape objects should be edited. By default, this property is set tofalse.- Parameters:
aEditTouchedOnly- a flag indicating whether only the touched shapes are edited or all shapes.- See Also:
-
isEditTouchedOnly
public final boolean isEditTouchedOnly()Returns whether only the touched shape objects should be edited or all of them.- Returns:
- whether only the touched shape objects should be edited or all of them.
- See Also:
-
getAnchorPointLocation
public int getAnchorPointLocation()Returns the location of the anchor point (by default: ONE_SHAPE_ANCHOR_POINT).- Returns:
- one of
MIDDLE_OF_BOUNDS,FOCUS_POINT,ONE_SHAPE_ANCHOR_POINT,FIRST_POSSIBLE_SHAPE_ANCHOR_POINT
-
setAnchorPointLocation
public void setAnchorPointLocation(int aAnchorPointLocation) Sets the preferred anchor point location.- Parameters:
aAnchorPointLocation- one ofMIDDLE_OF_BOUNDS,ONE_SHAPE_ANCHOR_POINT,FOCUS_POINT,FIRST_POSSIBLE_SHAPE_ANCHOR_POINT
-
paint
Displays the representation of the object in the given mode on the Graphics passed, taking into account the context passed.This implementation will retrieve a painter for all
ILcdShapeobjects inside theILcdShapeListobject using theretrieveShapePaintermethod and will use that painter to paint the corresponding shape.- Specified by:
paintin interfaceILcdGXYPainter- Parameters:
aGraphics- The graphics to paint the object on.aRenderMode- The mode to render the object in.aGXYContext- The context to render the object in.
-
isTouched
Returns whether one of theILcdShapeobjects inside theILcdShapeListobject is touched.- Specified by:
isTouchedin interfaceILcdGXYPainter- Parameters:
aGraphics- The graphics to paint the object on.aRenderMode- The mode to render the object in.aGXYContext- The context in which the object is rendered.- Returns:
- whether one of the
ILcdShapeobjects inside theILcdShapeListobject is touched. - See Also:
-
anchorPointSFCT
public void anchorPointSFCT(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext, Point aPointSFCT) throws TLcdNoBoundsException Moves the specified
aPointSFCTto the anchor point of theILcdShapeListobject. SeegetAnchorPointLocation()on how the anchor point is calculated.- Specified by:
anchorPointSFCTin interfaceILcdGXYPainter- Overrides:
anchorPointSFCTin classALcdGXYPainter- Parameters:
aGraphics- The graphics to paint the object on.aRenderMode- The mode to render the object in.aGXYContext- The context to render the object in.aPointSFCT- The point that needs to be updated.- Throws:
TLcdNoBoundsException- if theILcdShapeListobject doesn't have a valid anchor point, e.g. if it is always invisible in the current projection.- See Also:
-
supportSnap
Supports snapping when at least one of the painters of the shapes inside the
ILcdShapeListobject supports snapping.- Specified by:
supportSnapin interfaceILcdGXYPainter- Overrides:
supportSnapin classALcdGXYPainter- Parameters:
aGraphics- the graphics on which is worked.aGXYContext- the context of the snapping.- Returns:
trueif one of the painters for the shapes inside theILcdShapeListobject supports snapping,falseotherwise.
-
snapTarget
Returns the first snap target that was found by the painters of the shapes inside the
ILcdShapeListobject. If no point was touched,nullwill be returned.- Specified by:
snapTargetin interfaceILcdGXYPainter- Overrides:
snapTargetin classALcdGXYPainter- Parameters:
aGraphics- the graphics on which is worked.aGXYContext- the context of the snapping.- Returns:
- the first snap target that was found by the painters of the shapes inside the
ILcdShapeListobject,nullotherwise. - See Also:
-
boundsSFCT
public void boundsSFCT(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext, ILcd2DEditableBounds aBoundsSFCT) throws TLcdNoBoundsException Sets the supplied bounds (in view coordinates, pixels) so that it encompasses the representation of the object in the given mode taking into account the given context.If this method returns without exception the bounds argument must encompass the representation of the object. A point outside the bounds will not be contained within the painted object.
The bounds returned in this method can be seen as the equivalent in the view space of the bounds in the model space for
ILcdBoundedobjects.- Specified by:
boundsSFCTin interfaceILcdGXYPainter- Parameters:
aGraphics- The graphics to paint the object on.aRenderMode- The mode to render the object in.aGXYContext- The context to render the object in.aBoundsSFCT- The bounds to update.- Throws:
TLcdNoBoundsException- if no bounds can be determined for the representation of the object. This can happen when the object does not have a representation in the given context, for example when it is located in a part of the world which is not visible in the current view.- See Also:
-
getCursor
Returns aCursorthat clarifies the render mode and context this painter is operating in. When no specificCursoris required,nullis returned.- Specified by:
getCursorin interfaceILcdGXYPainter- Overrides:
getCursorin classALcdGXYPainter- Parameters:
aGraphics- The graphics on which the object is painted.aRenderMode- The mode to render the object in.aGXYContext- The context in which the object is rendered.- Returns:
- a cursor to indicate the type of operating mode and context. Returns
nullif no particular cursor is required.
-
setShapeGXYEditorProvider
Sets the editor provider used to provide an editor for each shape inside the shape list.- Parameters:
aShapeGXYEditorProvider- the editor provider for theILcdShapeobjects inside theILcdShapeListobject.- See Also:
-
getShapeGXYEditorProvider
Returns the editor provider used to provide an editor for each shape inside the shape list.- Returns:
- the editor provider used to provide an editor for each shape inside the shape list.
- See Also:
-
retrieveShapeEditor
Returns the editor for the shape at the given index in theILcdShapeListobject.- Parameters:
aShapeList- The shape list containing the shape.aShapeIndex- The index of the shape within the shape list.- Returns:
- the editor for the shape at the given index in the
ILcdShapeListobject.
-
edit
This implementation edits, depending on the
editTouchedOnlyproperty, allILcdShapeobjects of theILcdShapeListobject are edited or only the touched object. An exception to this is when a handle is edited: this only affects the objects whose handle is touched.
For each shape object that has to be edited, an editor is retrieved via the methodretrieveShapeEditor. The retrieved editor is then used to edit the correspondingILcdShapeobject.In the creation render modes, only the last
ILcdShapeobject is edited.- Specified by:
editin interfaceILcdGXYEditor- Parameters:
aGraphics- The graphics to edit the object on.aRenderMode- The mode to render the object in.aGXYContext- The context to render the object in.- Returns:
- true if the object has changed when this method returns, false otherwise.
- See Also:
-
editShape
protected boolean editShape(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext, ILcdGXYEditor aGXYEditor, ILcdShapeList aShapeList, int aIndex) Edits the shape at the specified index in aShapeList. This method is called by the edit method.- Parameters:
aGraphics- the graphics on which to edit.aRenderMode- the rendering mode.aGXYContext- the GXY context.aGXYEditor- the shape's editoraShapeList- the shape list to be edited.aIndex- the index of the shape to be edited.- Returns:
trueif the shape has been edited,falseotherwise.
-
getCreationClickCount
public int getCreationClickCount()Returns the number of user interactions required to complete the initialization of theILcdShapeListobject set to this editor. This method will return the number of user interactions required by the editor corresponding to the lastILcdShapeobject.- Specified by:
getCreationClickCountin interfaceILcdGXYEditor- Returns:
- the number of user interactions required by the editor corresponding to the last
ILcdShapeobject.
-
acceptSnapTarget
Determines whether a snap target should be accepted or not. A snap target is accepted if at least one of the shape editors returned by the shape editor provider accepts the snap target.
- Specified by:
acceptSnapTargetin interfaceILcdGXYEditor- Parameters:
aGraphics- the graphics on which the snap target should be checked.aGXYContext- the context in which the snap target should be checked.- Returns:
trueif at least one of the shape editors returned by the shape editor provider accepts the snap target,falseotherwise.- See Also:
-
getGXYEditor
Returns this instance as editor for editing the specifiedObject. If thisObjectis not the same as theObjectset to this painter, thesetObject(Object)method is called to update the object set to the painter.- Specified by:
getGXYEditorin interfaceILcdGXYEditorProvider- Parameters:
aObject- the object to be edited.- Returns:
- this instance as editor for editing the specified
Object.
-
clone
Description copied from interface:ILcdDeepCloneableReturns a deep clone of this Object. An object dictionary is used to keep track of all objects of the original Object graph, for which a clone has already been created. The dictionary should be ajava.util.Map, using reference-equality instead of object-equality when comparing keys (such as thejava.util.IdentityHashMap). It contains as keys the objects in the original object graph that have already been cloned, and as values their corresponding clone. The Object returned by this method should fulfill the following conditions, as specified in the generalObject.clone()contract:this.clone(aObjectDictionary) != thisthis.clone(aObjectDictionary).getClass() == this.getClass()this.clone(aObjectDictionary).equals(this)
- If a clone of this Object already exists in the object dictionary before this
clonemethod is called, this method shall return that clone:aObjectDictionary.get(this) == null || aObjectDictionary.get(this) == this.clone(aObjectDictionary) - The object dictionary shall contain the resulting clone, after this
clone method has completed:this.clone(aObjectDictionary) == aObjectDictionary.get(this)
- Specified by:
clonein interfaceILcdDeepCloneable- Parameters:
aObjectDictionary- the Object dictionary that keeps track of the objects for which a clone has already been made, and their corresponding clone Object.- Returns:
- a deep clone of this Object that fulfills the conditions described above.
-
clone
Description copied from interface:ILcdCloneableMakes
When for example extending fromObject.clone()public.java.lang.Object, it can be implemented like this:public Object clone() { try { return super.clone(); } catch ( CloneNotSupportedException e ) { // Cannot happen: extends from Object and implements Cloneable (see also Object.clone) throw new RuntimeException( e ); } }- Specified by:
clonein interfaceILcdCloneable- Specified by:
clonein interfaceILcdGXYEditorProvider- Specified by:
clonein interfaceILcdGXYPainterProvider- Overrides:
clonein classALcdGXYPainter- Returns:
- a clone of this painter provider.
- See Also:
-
appendAWTPath
Appends a discretized representation in view coordinates to the given path. This implementation returns true if at least one shape in the current shape list could be appended to the given path.- Specified by:
appendAWTPathin interfaceILcdGXYPathPainter- Parameters:
aGXYContext- the graphics contextaRenderMode- the rendering modeaAWTPathSFCT- the path to append to- Returns:
- true if a discretization of the shape could be successfully appended to the path
-
appendGeneralPath
public boolean appendGeneralPath(ILcdGXYContext aGXYContext, int aRenderMode, ILcdGeneralPath aGeneralPathSFCT) Appends a discretized representation in world coordinates to the given path. This implementation returns true if at least one shape in the current shape list could be appended to the given path.- Specified by:
appendGeneralPathin interfaceILcdGXYPathPainter- Parameters:
aGXYContext- the graphics contextaRenderMode- the rendering modeaGeneralPathSFCT- the path to append to- Returns:
- true if a discretization of the shape could be successfully appended to the path
-