public class TLcdGXYShapeListPainter extends ALcdGXYPainter implements ILcdGXYPathPainter, ILcdGXYEditor, ILcdGXYEditorProvider, ILcdDeepCloneable
ILcdShapeList
objects and enables visual editing of
ILcdShapeList
objects in an ILcdGXYView
.
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.
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.
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
.
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.
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.
The ILcdShapeList
object is touched when one of the ILcdShape
objects in the
shape list is touched.
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.
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.
This painter accepts a snap target if at least one of the shape editors returned by the shape editor provider accepts the snap target.
ILcdGXYPainter
,
ILcdGXYEditor
,
ALcdGXYPainter
,
Serialized FormModifier and Type | Field and Description |
---|---|
static int |
FIRST_POSSIBLE_SHAPE_ANCHOR_POINT
Constant value indicating that the anchor point should be the anchor point of the first
possible shape in the shape list.
|
static int |
FOCUS_POINT
Constant value indicating that the anchor point should be chosen as the focus point of the
shape list.
|
protected ILcdGXYEditorProvider |
fShapeGXYEditorProvider
The editor provider to retrieve editors for the objects inside the
ILcdShapeList object. |
protected ILcdGXYPainterProvider |
fShapeGXYPainterProvider
The painter provider to retrieve painters for the objects inside the
ILcdShapeList object. |
static int |
MIDDLE_OF_BOUNDS
Constant value indicating that the anchor point should be chosen in the middle of the
bounds, calculated by
boundsSFCT . |
static int |
ONE_SHAPE_ANCHOR_POINT
Constant value indicating that the anchor point should be chosen as the anchor point of the
only shape in the shape list.
|
defaultCreationFillStyle, defaultCreationLineStyle, defaultFillStyle, defaultLineStyle, fWorkBounds
BODY, CREATING, DEFAULT, HANDLES, RESHAPING, SELECTED, SNAPS, TRANSLATING
CREATING, END_CREATION, RESHAPED, START_CREATION, TRANSLATED
Constructor and Description |
---|
TLcdGXYShapeListPainter()
Constructs a default
TLcdGXYShapeListPainter and sets the display name to "ShapeList". |
TLcdGXYShapeListPainter(ILcdGXYPainterProvider aShapeGXYPainterProvider)
Constructs a default
TLcdGXYShapeListPainter with the specified painter provider and sets
the display name to "ShapeList". |
Modifier and Type | Method and Description |
---|---|
boolean |
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 specified
aPointSFCT to the anchor point of the ILcdShapeList
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.
|
Object |
clone()
Makes
Object.clone() public. |
Object |
clone(Map aObjectDictionary)
Returns a deep clone of this Object.
|
boolean |
edit(Graphics aGraphics,
int aRenderMode,
ILcdGXYContext aGXYContext)
This implementation edits, depending on the
editTouchedOnly property,
all ILcdShape objects of the ILcdShapeList 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 |
getAnchorPointLocation()
Returns the location of the anchor point (by default: ONE_SHAPE_ANCHOR_POINT).
|
int |
getCreationClickCount()
Returns the number of user interactions required to complete the initialization of the
ILcdShapeList object set to this editor. |
Cursor |
getCursor(Graphics aGraphics,
int aRenderMode,
ILcdGXYContext aGXYContext)
Returns a
Cursor that clarifies the render mode and context this painter is operating
in. |
ILcdGXYEditor |
getGXYEditor(Object aObject)
Returns this instance as editor for editing the specified
Object . |
Object |
getObject()
Returns the object that can currently be painted or edited by this painter/editor.
|
ILcdGXYEditorProvider |
getShapeGXYEditorProvider()
Returns the editor provider used to provide an editor for each shape inside the shape list.
|
ILcdGXYPainterProvider |
getShapeGXYPainterProvider()
Returns the painter provider used to provide a painter for each shape inside the shape list.
|
boolean |
isEditTouchedOnly()
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 the
ILcdShape objects inside the ILcdShapeList 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 the
ILcdShapeList object. |
protected ILcdGXYPainter |
retrieveShapePainter(ILcdShapeList aShapeList,
int aShapeIndex)
Returns the painter for the shape at the given index in the
ILcdShapeList object. |
void |
setAnchorPointLocation(int aAnchorPointLocation)
Sets the preferred anchor point location.
|
void |
setEditTouchedOnly(boolean aEditTouchedOnly)
Determines whether only the touched
ILcdShape objects in the ILcdShapeList
object are edited or whether all shape objects should be edited. |
void |
setObject(Object aObject)
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.
|
Object |
snapTarget(Graphics aGraphics,
ILcdGXYContext aGXYContext)
Returns the first snap target that was found by the painters of the shapes inside the
ILcdShapeList object. |
boolean |
supportSnap(Graphics aGraphics,
ILcdGXYContext aGXYContext)
Supports snapping when at least one of the painters of the shapes inside the
ILcdShapeList
object supports snapping. |
addPropertyChangeListener, firePropertyChangeEvent, firePropertyChangeEvent, getDisplayName, getGXYPainter, isTraceOn, removePropertyChangeListener, setClassTraceOn, setDisplayName, setTraceOn
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getDisplayName
addPropertyChangeListener, removePropertyChangeListener
getDisplayName
public static final int MIDDLE_OF_BOUNDS
boundsSFCT
.public static final int FOCUS_POINT
public static final int ONE_SHAPE_ANCHOR_POINT
public static final int FIRST_POSSIBLE_SHAPE_ANCHOR_POINT
protected ILcdGXYPainterProvider fShapeGXYPainterProvider
ILcdShapeList
object.protected ILcdGXYEditorProvider fShapeGXYEditorProvider
ILcdShapeList
object.public TLcdGXYShapeListPainter()
TLcdGXYShapeListPainter
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
methods setShapeGXYPainterProvider(com.luciad.view.gxy.ILcdGXYPainterProvider)
and setShapeGXYEditorProvider(com.luciad.view.gxy.ILcdGXYEditorProvider)
respectively.public TLcdGXYShapeListPainter(ILcdGXYPainterProvider aShapeGXYPainterProvider)
TLcdGXYShapeListPainter
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 method setShapeGXYEditorProvider(com.luciad.view.gxy.ILcdGXYEditorProvider)
.aShapeGXYPainterProvider
- the painter provider for the ILcdShape
objects
inside the ILcdShapeList
object.setShapeGXYEditorProvider(com.luciad.view.gxy.ILcdGXYEditorProvider)
public void setShapeGXYPainterProvider(ILcdGXYPainterProvider aShapeGXYPainterProvider)
aShapeGXYPainterProvider
- the painter provider for the ILcdShape
objects
inside the ILcdShapeList
object.getShapeGXYPainterProvider()
public ILcdGXYPainterProvider getShapeGXYPainterProvider()
setShapeGXYPainterProvider(com.luciad.view.gxy.ILcdGXYPainterProvider)
protected ILcdGXYPainter retrieveShapePainter(ILcdShapeList aShapeList, int aShapeIndex)
ILcdShapeList
object.aShapeList
- The shape list containing the shape.aShapeIndex
- The index of the shape within the shape list.ILcdShapeList
object.public void setObject(Object aObject)
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 the ILcdShapeList
interface,
an IllegalArgumentException
will be thrown.
setObject
in interface ILcdGXYEditor
setObject
in interface ILcdGXYPainter
aObject
- The object to paint and edit.IllegalArgumentException
- when the object does not implement ILcdShapeList
.getObject()
public final Object getObject()
getObject
in interface ILcdGXYEditor
getObject
in interface ILcdGXYPainter
setObject(Object)
public final void setEditTouchedOnly(boolean aEditTouchedOnly)
ILcdShape
objects in the ILcdShapeList
object are edited or whether all shape objects should be edited. By default, this property is set
to false
.aEditTouchedOnly
- a flag indicating whether only the touched shapes are edited or all shapes.isEditTouchedOnly()
public final boolean isEditTouchedOnly()
setEditTouchedOnly(boolean)
public int getAnchorPointLocation()
MIDDLE_OF_BOUNDS
, FOCUS_POINT
, ONE_SHAPE_ANCHOR_POINT
,
FIRST_POSSIBLE_SHAPE_ANCHOR_POINT
public void setAnchorPointLocation(int aAnchorPointLocation)
aAnchorPointLocation
- one of MIDDLE_OF_BOUNDS
, ONE_SHAPE_ANCHOR_POINT
,
FOCUS_POINT
, FIRST_POSSIBLE_SHAPE_ANCHOR_POINT
public void paint(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext)
This implementation will retrieve a painter for all ILcdShape
objects inside the
ILcdShapeList
object using the retrieveShapePainter
method and will use that painter to paint the corresponding shape.
paint
in interface ILcdGXYPainter
aGraphics
- The graphics to paint the object on.aRenderMode
- The mode to render the object in.aGXYContext
- The context to render the object in.public boolean isTouched(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext)
ILcdShape
objects inside the ILcdShapeList
object
is touched.isTouched
in interface ILcdGXYPainter
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.ILcdShape
objects inside the ILcdShapeList
object
is touched.boundsSFCT
public void anchorPointSFCT(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext, Point aPointSFCT) throws TLcdNoBoundsException
Moves the specified aPointSFCT
to the anchor point of the ILcdShapeList
object. See getAnchorPointLocation()
on how the anchor point is calculated.
anchorPointSFCT
in interface ILcdGXYPainter
anchorPointSFCT
in class ALcdGXYPainter
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.TLcdNoBoundsException
- if the ILcdShapeList
object doesn't have
a valid anchor point, e.g. if it is always invisible in the current projection.paint
public boolean supportSnap(Graphics aGraphics, ILcdGXYContext aGXYContext)
Supports snapping when at least one of the painters of the shapes inside the ILcdShapeList
object supports snapping.
supportSnap
in interface ILcdGXYPainter
supportSnap
in class ALcdGXYPainter
aGraphics
- the graphics on which is worked.aGXYContext
- the context of the snapping.true
if one of the painters for the shapes inside the ILcdShapeList
object supports snapping, false
otherwise.public Object snapTarget(Graphics aGraphics, ILcdGXYContext aGXYContext)
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.
snapTarget
in interface ILcdGXYPainter
snapTarget
in class ALcdGXYPainter
aGraphics
- the graphics on which is worked.aGXYContext
- the context of the snapping.ILcdShapeList
object, null
otherwise.supportSnap
public void boundsSFCT(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext, ILcd2DEditableBounds aBoundsSFCT) throws TLcdNoBoundsException
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.
boundsSFCT
in interface ILcdGXYPainter
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.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.isTouched
public Cursor getCursor(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext)
Cursor
that clarifies the render mode and context this painter is operating
in. When no specific Cursor
is required, null
is returned.getCursor
in interface ILcdGXYPainter
getCursor
in class ALcdGXYPainter
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.null
if
no particular cursor is required.public void setShapeGXYEditorProvider(ILcdGXYEditorProvider aShapeGXYEditorProvider)
aShapeGXYEditorProvider
- the editor provider for the ILcdShape
objects
inside the ILcdShapeList
object.getShapeGXYEditorProvider()
public ILcdGXYEditorProvider getShapeGXYEditorProvider()
setShapeGXYEditorProvider(com.luciad.view.gxy.ILcdGXYEditorProvider)
protected ILcdGXYEditor retrieveShapeEditor(ILcdShapeList aShapeList, int aShapeIndex)
ILcdShapeList
object.aShapeList
- The shape list containing the shape.aShapeIndex
- The index of the shape within the shape list.ILcdShapeList
object.public boolean edit(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext)
This implementation edits, depending on the editTouchedOnly
property,
all ILcdShape
objects of the ILcdShapeList
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 method
retrieveShapeEditor
. The retrieved editor is then used to edit the
corresponding ILcdShape
object.
In the creation render modes, only the last ILcdShape
object is edited.
edit
in interface ILcdGXYEditor
aGraphics
- The graphics to edit the object on.aRenderMode
- The mode to render the object in.aGXYContext
- The context to render the object in.ILcdGXYContext
,
acceptSnapTarget
protected boolean editShape(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext, ILcdGXYEditor aGXYEditor, ILcdShapeList aShapeList, int aIndex)
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.true
if the shape has been edited, false
otherwise.public int getCreationClickCount()
ILcdShapeList
object set to this editor. This method will return the number of user interactions
required by the editor corresponding to the last ILcdShape
object.getCreationClickCount
in interface ILcdGXYEditor
ILcdShape
object.public boolean acceptSnapTarget(Graphics aGraphics, ILcdGXYContext aGXYContext)
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.
acceptSnapTarget
in interface ILcdGXYEditor
aGraphics
- the graphics on which the snap target should be checked.aGXYContext
- the context in which the snap target should be checked.true
if at least one of the shape editors returned by the shape editor provider
accepts the snap target, false
otherwise.ILcdGXYContext.getSnapTarget()
public ILcdGXYEditor getGXYEditor(Object aObject)
Object
. If this
Object
is not the same as the Object
set to this painter, the
setObject(Object)
method is called to update the object set to the painter.getGXYEditor
in interface ILcdGXYEditorProvider
aObject
- the object to be edited.Object
.public Object clone(Map aObjectDictionary)
ILcdDeepCloneable
java.util.Map
, using reference-equality instead of object-equality when
comparing keys (such as the java.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 general Object.clone()
contract:
this.clone(aObjectDictionary) != this
this.clone(aObjectDictionary).getClass() == this.getClass()
this.clone(aObjectDictionary).equals(this)
clone
method is called,
this method shall return that clone:
aObjectDictionary.get(this) == null || aObjectDictionary.get(this) == this.clone(aObjectDictionary)
clone method has completed:
this.clone(aObjectDictionary) == aObjectDictionary.get(this)
clone
in interface ILcdDeepCloneable
aObjectDictionary
- the Object dictionary that keeps track of the objects for which a clone has already been made,
and their corresponding clone Object.public Object clone()
ILcdCloneable
Makes Object.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 );
}
}
clone
in interface ILcdCloneable
clone
in interface ILcdGXYEditorProvider
clone
in interface ILcdGXYPainterProvider
clone
in class ALcdGXYPainter
Object.clone()
public boolean appendAWTPath(ILcdGXYContext aGXYContext, int aRenderMode, ILcdAWTPath aAWTPathSFCT)
appendAWTPath
in interface ILcdGXYPathPainter
aGXYContext
- the graphics contextaRenderMode
- the rendering modeaAWTPathSFCT
- the path to append topublic boolean appendGeneralPath(ILcdGXYContext aGXYContext, int aRenderMode, ILcdGeneralPath aGeneralPathSFCT)
appendGeneralPath
in interface ILcdGXYPathPainter
aGXYContext
- the graphics contextaRenderMode
- the rendering modeaGeneralPathSFCT
- the path to append to