public class TLcdDGNComplexShapeGXYPainter extends ALcdGXYPainter implements ILcdGXYPainter, ILcdDeepCloneable
ILcdGXYPainter
that accepts a
TLcdDGNComplexShape
for painting on an ILcdGXYView
.ILcdGXYPainter
,
Serialized FormModifier and Type | Field and Description |
---|---|
static int |
FILLED
Draw the
TLcdDGNComplexShape as a filled shape. |
static int |
OUTLINED
Draw the
TLcdDGNComplexShape as an outlined shape. |
static int |
OUTLINED_FILLED
Draw the
TLcdDGNComplexShape as an outlined and filled shape. |
defaultCreationFillStyle, defaultCreationLineStyle, defaultFillStyle, defaultLineStyle, fWorkBounds
BODY, CREATING, DEFAULT, HANDLES, RESHAPING, SELECTED, SNAPS, TRANSLATING
Constructor and Description |
---|
TLcdDGNComplexShapeGXYPainter()
Constructs a default
TLcdDGNComplexShapeGXYPainter with display name
"ComplexShape". |
TLcdDGNComplexShapeGXYPainter(ILcdGXYPainterProvider aShapeGXYPainterProvider)
Constructs a
TLcdDGNComplexShapeGXYPainter with a given
ILcdGXYPainterProvider for the elements of the complex shapes. |
TLcdDGNComplexShapeGXYPainter(ILcdGXYPainterProvider aShapeGXYPainterProvider,
ILcdGXYPainterStyle aLineStyle,
ILcdGXYPainterStyle aFillStyle)
Constructs a
TLcdDGNComplexShapeGXYPainter with a given
ILcdGXYPainterProvider for the elements of the complex shapes. |
Modifier and Type | Method and Description |
---|---|
void |
anchorPointSFCT(Graphics aGraphics,
int aMode,
ILcdGXYContext aGXYContext,
Point aPointSFCT)
Implements
ILcdGXYPainter.anchorPointSFCT . |
void |
boundsSFCT(Graphics aGraphics,
int aMode,
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.
|
Cursor |
getCursor(Graphics aGraphics,
int aMode,
ILcdGXYContext aGXYContext)
Override this method to return a cursor.
|
ILcdGXYPainterStyle |
getFillStyle() |
ILcdGXYPainterStyle |
getLineStyle() |
int |
getMode() |
Object |
getObject()
Returns the Object for which the representation is currently being handled by this painter.
|
boolean |
getPaintCache() |
ILcdGXYPainterProvider |
getShapeGXYPainterProvider() |
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 aMode,
ILcdGXYContext aGXYContext)
Displays the representation of the object in the given mode on the Graphics passed, taking into account the
supplied context.
|
void |
setFillStyle(ILcdGXYPainterStyle aFillStyle) |
void |
setLineStyle(ILcdGXYPainterStyle aLineStyle) |
void |
setMode(int aFillMode)
This property determines how the painter will paint the objects:
OUTLINED , FILLED , or OUTLINED_FILLED . |
void |
setObject(Object aObject)
Sets the Object for which the representation shall be handled by this painter.
|
void |
setPaintCache(boolean aCache)
The property paintCache determines whether the painter will cache the
points it has drawn.
|
void |
setShapeGXYPainterProvider(ILcdGXYPainterProvider aShapeGXYPainterProvider) |
protected void |
setupGraphicsForFill(Graphics aGraphics,
int aMode,
ILcdGXYContext aGXYContext)
This method is called by this
ILcdGXYPainter just before
filling polygons on aGraphics . |
protected void |
setupGraphicsForLine(Graphics aGraphics,
int aMode,
ILcdGXYContext aGXYContext)
This method is called by this
ILcdGXYPainter just before
drawing lines on aGraphics . |
Object |
snapTarget(Graphics aGraphics,
ILcdGXYContext aGXYContext)
Override this method to support snapping.
|
boolean |
supportSnap(Graphics aGraphics,
ILcdGXYContext aGXYContext)
Override this method to support snapping.
|
addPropertyChangeListener, firePropertyChangeEvent, firePropertyChangeEvent, getDisplayName, getGXYPainter, isTraceOn, removePropertyChangeListener, setClassTraceOn, setDisplayName, setTraceOn
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getDisplayName
addPropertyChangeListener, removePropertyChangeListener
public static final int OUTLINED
TLcdDGNComplexShape
as an outlined shape.public static final int FILLED
TLcdDGNComplexShape
as a filled shape.public static final int OUTLINED_FILLED
TLcdDGNComplexShape
as an outlined and filled shape.public TLcdDGNComplexShapeGXYPainter()
TLcdDGNComplexShapeGXYPainter
with display name
"ComplexShape".public TLcdDGNComplexShapeGXYPainter(ILcdGXYPainterProvider aShapeGXYPainterProvider)
TLcdDGNComplexShapeGXYPainter
with a given
ILcdGXYPainterProvider
for the elements of the complex shapes.public TLcdDGNComplexShapeGXYPainter(ILcdGXYPainterProvider aShapeGXYPainterProvider, ILcdGXYPainterStyle aLineStyle, ILcdGXYPainterStyle aFillStyle)
TLcdDGNComplexShapeGXYPainter
with a given
ILcdGXYPainterProvider
for the elements of the complex shapes.public void setShapeGXYPainterProvider(ILcdGXYPainterProvider aShapeGXYPainterProvider)
public ILcdGXYPainterProvider getShapeGXYPainterProvider()
public void setMode(int aFillMode)
OUTLINED
, FILLED
, or OUTLINED_FILLED
.public int getMode()
public void setLineStyle(ILcdGXYPainterStyle aLineStyle)
aLineStyle
- the new line style to set.public ILcdGXYPainterStyle getLineStyle()
public void setFillStyle(ILcdGXYPainterStyle aFillStyle)
aFillStyle
- the new fill style to set.public ILcdGXYPainterStyle getFillStyle()
public void setPaintCache(boolean aCache)
public boolean getPaintCache()
setPaintCache(boolean)
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 ILcdGXYPainter
aObject
- the object for which the representation shall be handled by this painter.ILcdGXYPainter.getObject()
public final Object getObject()
ILcdGXYPainter
getObject
in interface ILcdGXYPainter
ILcdGXYPainter.setObject(Object)
public void paint(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
ILcdGXYPainter
The visual representation of an object depends on the context. Depending on the context (e.g. is the location covered by the view), an object may or may not have a representation. The context contains:
The mode passed in this method indicates what part of the object must be painted, whether it should be painted as selected or not, and whether user interaction (via mouse movements) must be taken into account.
When the mode passed contains either TRANSLATING, RESHAPING or CREATING, this method is also responsible for
interpreting interaction on the representation of an object and modifying the representation of the object
accordingly. The painter is not responsible for modifying the object itself, this is done by
a corresponding ILcdGXYEditor
.
Implementations of ILcdGXYPainter
and ILcdGXYEditor
interfaces must be consistent for
an object: the painter must display the result of the user interaction on the object, while the editor is
responsible for modifying the object as a result of the user interaction.
A good practice to ensure a consistent implementation is to implement both the ILcdGXYPainter
and ILcdGXYEditor
interfaces in a single class.
When the mode passed includes SNAPS, the part of the representation which corresponds to the object returned as
snap target by the method snapTarget
must be painted in order to provide the user with a visual indication of the snap target.
The Graphics passed in this method can be different from the Graphics returned by a view due to techniques such as double buffering (as applied in Swing). Basic drawing operations must always be performed on the Graphics passed as an argument in this method.
paint
in interface ILcdGXYPainter
aGraphics
- the Graphics on which the representation of the object is paintedaMode
- the mode the object is represented in (see class documentation).aGXYContext
- the ILcdGXYContext
the drawing depends on.protected void setupGraphicsForLine(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
ILcdGXYPainter
just before
drawing lines on aGraphics
. It can be
redefined in order to set specific Graphics
properties like Color, etc ...
It calls getLineStyle().setupGraphics()
if such method returns a non null
value.protected void setupGraphicsForFill(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
ILcdGXYPainter
just before
filling polygons on aGraphics
. It can be
redefined in order to set specific Graphics
properties like Color, etc ...
It calls getFillStyle().setupGraphics()
if such method returns a non null
value.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 boolean supportSnap(Graphics aGraphics, ILcdGXYContext aGXYContext)
ALcdGXYPainter
supportSnap
in interface ILcdGXYPainter
supportSnap
in class ALcdGXYPainter
aGraphics
- the Graphics on which the representation of the object is paintedaGXYContext
- the context in which this object is represented and in which the editing of an object occurs.false
.public Object snapTarget(Graphics aGraphics, ILcdGXYContext aGXYContext)
ALcdGXYPainter
snapTarget
in interface ILcdGXYPainter
snapTarget
in class ALcdGXYPainter
aGraphics
- the Graphics on which the representation of the object is paintedaGXYContext
- the context in which this object is represented and in which the editing of an object occurs.null
.supportSnap
public void boundsSFCT(Graphics aGraphics, int aMode, 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 paintedaMode
- 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 Cursor getCursor(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
ALcdGXYPainter
getCursor
in interface ILcdGXYPainter
getCursor
in class ALcdGXYPainter
aGraphics
- the Graphics on which the representation of the object is paintedaMode
- the rendering mode to return the cursor for.aGXYContext
- the context in which the rendering occurs.null
.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 ILcdGXYPainterProvider
clone
in class ALcdGXYPainter
Object.clone()
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.