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
Modifier and TypeFieldDescriptionstatic final int
Constant value indicating that the anchor point should be the anchor point of the first possible shape in the shape list.static final int
Constant value indicating that the anchor point should be chosen as the focus point of the shape list.protected ILcdGXYEditorProvider
The editor provider to retrieve editors for the objects inside theILcdShapeList
object.protected ILcdGXYPainterProvider
The painter provider to retrieve painters for the objects inside theILcdShapeList
object.static final int
Constant value indicating that the anchor point should be chosen in the middle of the bounds, calculated byboundsSFCT
.static final int
Constant 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, fWorkBounds
Fields inherited from interface com.luciad.view.gxy.ILcdGXYEditor
CREATING, END_CREATION, RESHAPED, START_CREATION, TRANSLATED
Fields inherited from interface com.luciad.view.gxy.ILcdGXYPainter
BODY, CREATING, DEFAULT, HANDLES, RESHAPING, SELECTED, SNAPS, TRANSLATING
-
Constructor Summary
ConstructorDescriptionConstructs a defaultTLcdGXYShapeListPainter
and sets the display name to "ShapeList".TLcdGXYShapeListPainter
(ILcdGXYPainterProvider aShapeGXYPainterProvider) Constructs a defaultTLcdGXYShapeListPainter
with the specified painter provider and sets the display name to "ShapeList". -
Method Summary
Modifier and TypeMethodDescriptionboolean
acceptSnapTarget
(Graphics aGraphics, ILcdGXYContext aGXYContext) Determines whether a snap target should be accepted or not.void
anchorPointSFCT
(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext, Point aPointSFCT) Moves the specifiedaPointSFCT
to the anchor point of theILcdShapeList
object.boolean
appendAWTPath
(ILcdGXYContext aGXYContext, int aRenderMode, ILcdAWTPath aAWTPathSFCT) Appends a discretized representation in view coordinates to the given path.boolean
appendGeneralPath
(ILcdGXYContext aGXYContext, int aRenderMode, ILcdGeneralPath aGeneralPathSFCT) Appends a discretized representation in world coordinates to the given path.void
boundsSFCT
(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.boolean
edit
(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext) This implementation edits, depending on theeditTouchedOnly
property, allILcdShape
objects of theILcdShapeList
object are edited or only the touched object.protected boolean
editShape
(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext, ILcdGXYEditor aGXYEditor, ILcdShapeList aShapeList, int aIndex) Edits the shape at the specified index in aShapeList.int
Returns the location of the anchor point (by default: ONE_SHAPE_ANCHOR_POINT).int
Returns the number of user interactions required to complete the initialization of theILcdShapeList
object set to this editor.getCursor
(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext) Returns aCursor
that clarifies the render mode and context this painter is operating in.getGXYEditor
(Object aObject) Returns this instance as editor for editing the specifiedObject
.final Object
Returns 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 boolean
Returns whether only the touched shape objects should be edited or all of them.boolean
isTouched
(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext) Returns whether one of theILcdShape
objects inside theILcdShapeList
object is touched.void
paint
(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 ILcdGXYEditor
retrieveShapeEditor
(ILcdShapeList aShapeList, int aShapeIndex) Returns the editor for the shape at the given index in theILcdShapeList
object.protected ILcdGXYPainter
retrieveShapePainter
(ILcdShapeList aShapeList, int aShapeIndex) Returns the painter for the shape at the given index in theILcdShapeList
object.void
setAnchorPointLocation
(int aAnchorPointLocation) Sets the preferred anchor point location.final void
setEditTouchedOnly
(boolean aEditTouchedOnly) Determines whether only the touchedILcdShape
objects in theILcdShapeList
object are edited or whether all shape objects should be edited.void
Sets the object to paint and edit.void
setShapeGXYEditorProvider
(ILcdGXYEditorProvider aShapeGXYEditorProvider) Sets the editor provider used to provide an editor for each shape inside the shape list.void
setShapeGXYPainterProvider
(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 theILcdShapeList
object.boolean
supportSnap
(Graphics aGraphics, ILcdGXYContext aGXYContext) Supports snapping when at least one of the painters of the shapes inside theILcdShapeList
object supports snapping.Methods inherited from class com.luciad.view.gxy.ALcdGXYPainter
addPropertyChangeListener, firePropertyChangeEvent, firePropertyChangeEvent, getDisplayName, getGXYPainter, isTraceOn, removePropertyChangeListener, setClassTraceOn, setDisplayName, setTraceOn
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.luciad.view.gxy.ILcdGXYEditor
getDisplayName
Methods inherited from interface com.luciad.view.gxy.ILcdGXYPainter
getDisplayName
Methods 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 theILcdShapeList
object. -
fShapeGXYEditorProvider
The editor provider to retrieve editors for the objects inside theILcdShapeList
object.
-
-
Constructor Details
-
TLcdGXYShapeListPainter
public TLcdGXYShapeListPainter()Constructs a defaultTLcdGXYShapeListPainter
and 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 defaultTLcdGXYShapeListPainter
with 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 theILcdShape
objects inside theILcdShapeList
object.- 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 theILcdShape
objects inside theILcdShapeList
object.- 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 theILcdShapeList
object.- 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
ILcdShapeList
object.
-
setObject
Sets the object to paint and edit. The object should be an instance of
ILcdShapeList
for painting and editing. When the object does not implement theILcdShapeList
interface, anIllegalArgumentException
will be thrown.- Specified by:
setObject
in interfaceILcdGXYEditor
- Specified by:
setObject
in 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:
getObject
in interfaceILcdGXYEditor
- Specified by:
getObject
in 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 touchedILcdShape
objects in theILcdShapeList
object 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
ILcdShape
objects inside theILcdShapeList
object using theretrieveShapePainter
method and will use that painter to paint the corresponding shape.- Specified by:
paint
in 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 theILcdShape
objects inside theILcdShapeList
object is touched.- Specified by:
isTouched
in 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
ILcdShape
objects inside theILcdShapeList
object is touched. - See Also:
-
anchorPointSFCT
public void anchorPointSFCT(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext, Point aPointSFCT) throws TLcdNoBoundsException Moves the specified
aPointSFCT
to the anchor point of theILcdShapeList
object. SeegetAnchorPointLocation()
on how the anchor point is calculated.- Specified by:
anchorPointSFCT
in interfaceILcdGXYPainter
- Overrides:
anchorPointSFCT
in 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 theILcdShapeList
object 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
ILcdShapeList
object supports snapping.- Specified by:
supportSnap
in interfaceILcdGXYPainter
- Overrides:
supportSnap
in classALcdGXYPainter
- Parameters:
aGraphics
- the graphics on which is worked.aGXYContext
- the context of the snapping.- Returns:
true
if one of the painters for the shapes inside theILcdShapeList
object supports snapping,false
otherwise.
-
snapTarget
Returns the first snap target that was found by the painters of the shapes inside the
ILcdShapeList
object. If no point was touched,null
will be returned.- Specified by:
snapTarget
in interfaceILcdGXYPainter
- Overrides:
snapTarget
in 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
ILcdShapeList
object,null
otherwise. - 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
ILcdBounded
objects.- Specified by:
boundsSFCT
in 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 aCursor
that clarifies the render mode and context this painter is operating in. When no specificCursor
is required,null
is returned.- Specified by:
getCursor
in interfaceILcdGXYPainter
- Overrides:
getCursor
in 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
null
if 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 theILcdShape
objects inside theILcdShapeList
object.- 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 theILcdShapeList
object.- 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
ILcdShapeList
object.
-
edit
This implementation edits, depending on the
editTouchedOnly
property, allILcdShape
objects of theILcdShapeList
object 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 correspondingILcdShape
object.In the creation render modes, only the last
ILcdShape
object is edited.- Specified by:
edit
in 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:
true
if the shape has been edited,false
otherwise.
-
getCreationClickCount
public int getCreationClickCount()Returns the number of user interactions required to complete the initialization of theILcdShapeList
object set to this editor. This method will return the number of user interactions required by the editor corresponding to the lastILcdShape
object.- Specified by:
getCreationClickCount
in interfaceILcdGXYEditor
- Returns:
- the number of user interactions required by the editor corresponding to the last
ILcdShape
object.
-
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:
acceptSnapTarget
in 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:
true
if at least one of the shape editors returned by the shape editor provider accepts the snap target,false
otherwise.- See Also:
-
getGXYEditor
Returns this instance as editor for editing the specifiedObject
. If thisObject
is not the same as theObject
set to this painter, thesetObject(Object)
method is called to update the object set to the painter.- Specified by:
getGXYEditor
in interfaceILcdGXYEditorProvider
- Parameters:
aObject
- the object to be edited.- Returns:
- this instance as editor for editing the specified
Object
.
-
clone
Description copied from interface:ILcdDeepCloneable
Returns 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) != this
this.clone(aObjectDictionary).getClass() == this.getClass()
this.clone(aObjectDictionary).equals(this)
- If a clone of this Object already exists in the object dictionary before this
clone
method 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:
clone
in 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:ILcdCloneable
Makes
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:
clone
in interfaceILcdCloneable
- Specified by:
clone
in interfaceILcdGXYEditorProvider
- Specified by:
clone
in interfaceILcdGXYPainterProvider
- Overrides:
clone
in 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:
appendAWTPath
in 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:
appendGeneralPath
in 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
-