public class TLcdGXYSurfacePainter extends ALcdGXYAreaPainter implements ILcdGXYPathPainter, ILcdGXYEditor, ILcdGXYEditorProvider, ILcdDeepCloneable
ILcdSurface
objects and enables visual editing of
ILcdSurface
objects in an ILcdGXYView
.
This painter provides support for painting an ILcdSurface
object. For each ring of the
surface, a painter is retrieved using the painter provider set in setRingGXYPainterProvider(com.luciad.view.gxy.ILcdGXYPainterProvider)
.
The retrieved painter is then used to paint the corresponding ILcdCurve
object.
Note that this implementation assumes that a painter can be provided for each ring of the surface.
This painter does not define handles for ILcdSurface
objects.
This painter will process all ILcdRing
objects in the ILcdSurface
object
and tries to retrieve a snap target for each ring using the corresponding painter. The first snap target
that is found, is used as snap target for this TLcdGXYSurfacePainter
.
The visualization of the ILcdRing
object is governed by the line style and fill style
set to this painter. Depending on the paint mode chosen one or both of these will be taken into account.
The anchor point is defined by the anchor point of the exterior ring.
The ILcdSurface
object is touched when the exterior ring is touched and none of the interior rings
is touched.
This implementation translates all objects for ILcdGXYEditor.TRANSLATED
.
Non-composite curves or rings are expected to implement ILcd2DEditableShape
.
This painter supports creating ILcdSurface
objects without inner rings.
The ring painter provider
needs to support creating the exterior ring.
This painter accepts a snap target if at least one of the curve editors returned by the curve editor provider accepts the snap target.
ILcdGXYPainter
,
ILcdGXYEditor
,
ALcdGXYPainter
,
Serialized FormModifier and Type | Field and Description |
---|---|
static int |
INSIDE_SURFACE
Constant value indicating that the anchor point should be chosen somewhere inside the
surface.
|
static int |
MIDDLE_OF_BOUNDS
Constant value indicating that the anchor point should be chosen in the middle of the
bounds, calculated by
boundsSFCT . |
FILLED, OUTLINED, OUTLINED_FILLED
defaultCreationFillStyle, defaultCreationLineStyle, defaultFillStyle, defaultLineStyle, fWorkBounds
BODY, CREATING, DEFAULT, HANDLES, RESHAPING, SELECTED, SNAPS, TRANSLATING
CREATING, END_CREATION, RESHAPED, START_CREATION, TRANSLATED
Constructor and Description |
---|
TLcdGXYSurfacePainter()
Constructs a default
TLcdGXYSurfacePainter and sets the display name to "Surface". |
TLcdGXYSurfacePainter(ILcdGXYPainterProvider<ILcdGXYPathPainter> aRingGXYPainterProvider)
Constructs a default
TLcdGXYSurfacePainter with the specified painter,
and sets the display name to "Surface". |
TLcdGXYSurfacePainter(ILcdGXYPainterProvider<ILcdGXYPathPainter> aRingGXYPainterProvider,
ILcdCurveConnectorProvider aCurveConnectorProvider)
Constructs a default
TLcdGXYSurfacePainter with the specified painter and
connector provider, and sets the display name to "Surface". |
Modifier and Type | Method and Description |
---|---|
boolean |
acceptSnapTarget(Graphics aGraphics,
ILcdGXYContext aGXYContext)
Returns whether the object set to the editor can be edited so that (part of) the object snaps to the object passed
as snap target in the context.
|
void |
anchorPointSFCT(Graphics aGraphics,
int aMode,
ILcdGXYContext aGXYContext,
Point aPointSFCT)
Implements
ILcdGXYPainter.anchorPointSFCT . |
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 translates all rings for
ILcdGXYEditor.TRANSLATED . |
int |
getAnchorPointLocation()
Returns the location of the anchor point (by default: MIDDLE_OF_BOUNDS).
|
int |
getCreationClickCount()
Returns the number user interactions required to complete the initialization of an 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. |
ILcdCurveConnectorProvider |
getCurveConnectorProvider()
Returns the curve provider used to provider a curve connector for each shape inside any composite curve.
|
ILcdGXYEditor |
getGXYEditor(Object aObject)
Finds an
ILcdGXYEditor that can be used to edit the object passed. |
int |
getMinimumEditDelta()
Returns the minimum pixel distance the input device (a mouse, for example) must move before editing the shape.
|
Object |
getObject()
Returns the Object for which the representation is currently being handled by this painter.
|
boolean |
getPaintCache()
Returns whether caching is used when painting this painter's object.
|
ILcdGXYPainterProvider<ILcdGXYPathPainter> |
getRingGXYPainterProvider()
Returns the painter provider used to provide a painter for the exterior and interior rings.
|
boolean |
isTouched(Graphics aGraphics,
int aMode,
ILcdGXYContext aGXYContext)
Checks if the representation of the object in the given mode is touched at the location as defined in the
supplied context.
|
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.
|
void |
setAnchorPointLocation(int aAnchorPointLocation)
Sets the preferred anchor point location.
|
void |
setCurveConnectorProvider(ILcdCurveConnectorProvider aCurveConnectorProvider)
Sets a connector provider to ensure connectivity during editing operations.
|
void |
setMinimumEditDelta(int aDelta)
Sets the minimum pixel distance the input device (a mouse, for example) must move before editing the shape.
|
void |
setObject(Object aObject)
Sets the Object for which the representation shall be handled by this painter.
|
void |
setPaintCache(boolean aPaintCache)
Turns caching of the representation of the object on or off.
|
void |
setRingGXYPainterProvider(ILcdGXYPainterProvider<ILcdGXYPathPainter> aCurveGXYPainterProvider)
Sets the painter provider used to provide a painter for the exterior and interior rings.
|
Object |
snapTarget(Graphics aGraphics,
ILcdGXYContext aGXYContext)
Returns the first snap target that was found by the painters of the surface rings.
|
boolean |
supportSnap(Graphics aGraphics,
ILcdGXYContext aGXYContext)
Supports snapping when at least one of the painters of the rings in this surface
supports snapping.
|
getEditMode, getFillStyle, getLineStyle, getMode, getSelectionMode, setEditMode, setFillStyle, setLineStyle, setMode, setSelectionMode
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 INSIDE_SURFACE
public TLcdGXYSurfacePainter()
TLcdGXYSurfacePainter
and sets the display name to "Surface".
The painter provider is not initialized and is required to be set using the
method setRingGXYPainterProvider(com.luciad.view.gxy.ILcdGXYPainterProvider)
.
To ensure connectivity of the composite curve during translation operations,
an instance of TLcdDefaultCurveConnectorProvider
is used as ILcdCurveConnectorProvider
.
Custom implementations can be set through
setCurveConnectorProvider(com.luciad.shape.constraints.ILcdCurveConnectorProvider)
.
public TLcdGXYSurfacePainter(ILcdGXYPainterProvider<ILcdGXYPathPainter> aRingGXYPainterProvider)
TLcdGXYSurfacePainter
with the specified painter,
and sets the display name to "Surface".
To ensure connectivity of the composite curve during translation operations,
an instance of TLcdDefaultCurveConnectorProvider
is used as ILcdCurveConnectorProvider
.
Custom implementations can be set through
setCurveConnectorProvider(com.luciad.shape.constraints.ILcdCurveConnectorProvider)
.
aRingGXYPainterProvider
- the painter provider for the ILcdRing
objects
inside the composite ring object.public TLcdGXYSurfacePainter(ILcdGXYPainterProvider<ILcdGXYPathPainter> aRingGXYPainterProvider, ILcdCurveConnectorProvider aCurveConnectorProvider)
TLcdGXYSurfacePainter
with the specified painter and
connector provider, and sets the display name to "Surface".aRingGXYPainterProvider
- the painter provider for the ILcdRing
objects
inside the composite ring object.aCurveConnectorProvider
- the connector provider to ensure connectivity of any composite curves
during editing operations.public void setMinimumEditDelta(int aDelta)
aDelta
- the minimum pixel distance the input device should move in either the X or Y directionpublic int getMinimumEditDelta()
public void setRingGXYPainterProvider(ILcdGXYPainterProvider<ILcdGXYPathPainter> aCurveGXYPainterProvider)
aCurveGXYPainterProvider
- the painter provider for the ILcdRing
objects
defining the surface object.getRingGXYPainterProvider()
public ILcdGXYPainterProvider<ILcdGXYPathPainter> getRingGXYPainterProvider()
ILcdRing
objects defining the surface object.getRingGXYPainterProvider()
public void setCurveConnectorProvider(ILcdCurveConnectorProvider aCurveConnectorProvider)
aCurveConnectorProvider
- a connector provider that returns a connector for the curve types encountered
in every composite curve.getCurveConnectorProvider()
public ILcdCurveConnectorProvider getCurveConnectorProvider()
setCurveConnectorProvider(com.luciad.shape.constraints.ILcdCurveConnectorProvider)
public int getAnchorPointLocation()
MIDDLE_OF_BOUNDS
, INSIDE_SURFACE
.public void setAnchorPointLocation(int aAnchorPointLocation)
aAnchorPointLocation
- one of MIDDLE_OF_BOUNDS
, INSIDE_SURFACE
.public void setObject(Object aObject)
ILcdGXYPainter
Setting the object on the painter may have an effect on the internal state of the painter, for example, the color to use.
When the object is set to a painter, the context parameter in subsequent calls to methods in this class must contain a layer that contains this object and for which the painter for this object is this painter.
setObject
in interface ILcdGXYEditor
setObject
in interface ILcdGXYPainter
aObject
- the object for which the representation shall be handled by this painter.ILcdGXYPainter.getObject()
public Object getObject()
ILcdGXYPainter
getObject
in interface ILcdGXYEditor
getObject
in interface ILcdGXYPainter
ILcdGXYPainter.setObject(Object)
public void paint(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext)
This implementation will retrieve a painter for all ILcdRing
objects defining the
surface object and use these to construct a surface.
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 aMode, ILcdGXYContext aGXYContext)
ILcdGXYPainter
The location that must be taken into account to check whether the representation is touched can be retrieved from
the context passed with the methods
ILcdGXYContext.getX()
and ILcdGXYContext.getY()
.
If the check is part of an ongoing operation of
user interaction, for example, when the mouse is being dragged, the location of the start of the operation can also
be taken into account using the methods
ILcdGXYContext.getDeltaX()
and ILcdGXYContext.getDeltaY()
.
The context contains the transformations required to convert this location into the equivalent location in
model space. Implementations of this interface usually follow either of the following patterns:
As the mode influences the way an object is represented, it must also be taken into account when checking whether that representation is being touched. When the mode contains CREATING, RESHAPING or TRANSLATING which indicate that the object must be represented in a state for an ongoing operation, the location of the start of the operation may be taken into account as mentioned above. The painting result can take into account multiple locations, to respond to, for example, multi-touch input. When the mode contains SELECTED, the painter should also check if the non-selected representation is touched, since these are always painted on top of each other.
The boundsSFCT
is often used to speed up the performance of this method as a location outside these bounds can never
touch the representation of the object.
Note that this method does not give an indication of what part of the object is touched. It is up to the painter implementations to provide methods to make this distinction. The method does also not indicate what sensitivity must be applied when checking if an object is touched. It is up to the implementation to decide what should be the maximum distance between the location given in the context and the closest relevant point or area of the representation of the object.
isTouched
in interface ILcdGXYPainter
aGraphics
- the Graphics on which the representation of the object is paintedaMode
- the mode the object is represented inaGXYContext
- contains the location of the interaction and the transformations to convert this location into
model coordinatesboundsSFCT
public void anchorPointSFCT(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext, Point aPointSFCT) throws TLcdNoBoundsException
ALcdGXYPainter
ILcdGXYPainter.anchorPointSFCT
.
aPointSFCT
will be set to the center of the
bounds calculated by boundsSFCT.anchorPointSFCT
in interface ILcdGXYPainter
anchorPointSFCT
in class ALcdGXYPainter
aGraphics
- the Graphics on which the representation of the object is paintedaMode
- the mode the object is painted in (see class documentation)aGXYContext
- the context for which the representation of the object is painted. It contains amongst others
the transformations from model to world and world to view.aPointSFCT
- the point that has to be moved to the location of the anchor point of the representation of
the object. This point must not be taken into account when the method has thrown a TLcdNoBoundsException.TLcdNoBoundsException
- if no anchor point can be determined for the representation of the object.
This can be 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 projection as set in the views world reference.paint
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 boolean supportSnap(Graphics aGraphics, ILcdGXYContext aGXYContext)
Supports snapping when at least one of the painters of the rings in this surface 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 exterior or interior rings supports snapping,
false
otherwise.public Object snapTarget(Graphics aGraphics, ILcdGXYContext aGXYContext)
Returns the first snap target that was found by the painters of the surface rings.
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.null
otherwise.supportSnap
public void boundsSFCT(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext, ILcd2DEditableBounds aBoundsSFCT) throws TLcdNoBoundsException
ILcdGXYPainter
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 on which the representation of the object is paintedaRenderMode
- the mode the object is represented in (see class documentation). For example, an object may be
represented differently in SELECTED mode compared to DEFAULT mode. The returned bounds of the representation
must take this different representation into account.aGXYContext
- the context for which the representation of the object is painted. It contains amongst others
the transformations from model to world and world to view.aBoundsSFCT
- the bounds that must be adapted to encompass the representation of the object in the given
mode and context. These bounds must not be taken into account when the method has thrown an exception.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 ILcdGXYEditor getGXYEditor(Object aObject)
ILcdGXYEditorProvider
ILcdGXYEditor
that can be used to edit the object passed.
The editor provider is responsible for setting the object to the editor before returning the editor. An implementation should therefore have the following structure:
public ILcdGXYEditor getGXYEditor(Object aObject) {
ILcdGXYEditor editor = ... // find the editor for the object
editor.setObject( aObject );
return editor;
}
getGXYEditor
in interface ILcdGXYEditorProvider
aObject
- the object to find an editor forpublic boolean edit(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext)
ILcdGXYEditor.TRANSLATED
.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
public int getCreationClickCount()
This implementation returns 0, since object creation is not supported.
getCreationClickCount
in interface ILcdGXYEditor
public boolean acceptSnapTarget(Graphics aGraphics, ILcdGXYContext aGXYContext)
edit
method with this
context passed should edit the object so that (part of) the object snaps to the object passed
as snap target in the context.
The context contains information on the user interaction at hand: the current location of the
user interaction, given by its
X
and
Y
coordinates, and
the
distance in X direction
and
distance in Y direction
over which the user interaction is taking place.
For example, getX
and
getY
may contain the current mouse location while getDeltaX
and getDeltaY
contain the distance over which the mouse has been dragged.
The context also contains the candidate
snap target
and the
layer the snap target is contained in
.
This implementation does not support snapping.
acceptSnapTarget
in interface ILcdGXYEditor
aGraphics
- the Graphics on which the representation of the object is paintedaGXYContext
- the context containing the information on the user interaction and the snap target.ILcdGXYContext.getSnapTarget()
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 ALcdGXYAreaPainter
Object.clone()
public void setPaintCache(boolean aPaintCache)
ILcdCache
. By default, caching
is turned on.aPaintCache
- A flag indicating whether to use caching when painting an object.getPaintCache()
public boolean getPaintCache()
true
if caching is used to paint this painter's object, false
otherwise.setPaintCache(boolean)
public boolean appendAWTPath(ILcdGXYContext aGXYContext, int aRenderMode, ILcdAWTPath aAWTPathSFCT)
ILcdGXYPathPainter
appendAWTPath
in interface ILcdGXYPathPainter
aGXYContext
- the graphics contextaRenderMode
- the rendering modeaAWTPathSFCT
- the path to append topublic boolean appendGeneralPath(ILcdGXYContext aGXYContext, int aRenderMode, ILcdGeneralPath aGeneralPathSFCT)
ILcdGXYPathPainter
appendGeneralPath
in interface ILcdGXYPathPainter
aGXYContext
- the graphics contextaRenderMode
- the rendering modeaGeneralPathSFCT
- the path to append to