public class TLcdLonLatGridPainter extends ALcdGXYPainter implements ILcdGXYPainter
ILcdGXYPainter
paints TLcdLonLatGrid
instances.
By default, the meridians and parallels are painted as gray lines, except for
the equator and the Greenwich meridian, which are painted in red.
By default, labels are painted in gray, slanted along the grid lines, at a
small offset from the edge of the view and from the grid lines.
These style properties can all be modified.
This painter can optionally add a halo effect to the labels it draws.
For a more detailed explanation of halos, please refer to TLcdGXYHaloLabelPainter
.
The methods that control the appearance of the halos are equivalent to those
in TLcdGXYHaloLabelPainter
.
Modifier and Type | Class and Description |
---|---|
static class |
TLcdLonLatGridPainter.LabelPosition
Determines where grid labels are positioned.
|
Modifier and Type | Field and Description |
---|---|
static int |
ABOVE
Label alignment mode, indicating that the label is positioned above the chosen line segment.
|
static int |
BELOW
Label alignment mode, indicating that the label is positioned below the chosen line segment.
|
static int |
CENTER
Label alignment mode, indicating that the label center is positioned on the chosen line segment.
|
defaultCreationFillStyle, defaultCreationLineStyle, defaultFillStyle, defaultLineStyle, fWorkBounds
BODY, CREATING, DEFAULT, HANDLES, RESHAPING, SELECTED, SNAPS, TRANSLATING
Constructor and Description |
---|
TLcdLonLatGridPainter()
Constructs a new
TLcdLonLatGridPainter object. |
Modifier and Type | Method and Description |
---|---|
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. |
Color |
getColor()
Returns the color that is used to paint the grid lines.
|
int |
getLabelAlignment()
Returns how a grid label is aligned with respect to the grid line.
|
Color |
getLabelBackgroundColor()
Returns the color of the label frames filling.
|
Color |
getLabelColor()
Returns the color that is to paint the grid labels.
|
int |
getLabelEdgeOffset()
Returns the minimum offset between the grid labels and the edge of the view.
|
Font |
getLabelFont()
Returns the
Font for the grid labels. |
int |
getLabelGridOffset()
Returns the offset between the grid labels and their grid lines.
|
Color |
getLabelHaloColor()
Returns the color of the halo effect.
|
int |
getLabelHaloThickness()
Returns the thickness of the halo effect for the grid labels.
|
int |
getLabelMargin()
Returns the amount of padding used around the text.
|
TLcdLonLatGridPainter.LabelPosition |
getLabelPosition()
Returns where grid labels are positioned.
|
ILcdLonLatFormatter |
getLonLatFormatter()
Returns the formatter that is used for the grid labels.
|
Object |
getObject()
Returns the Object for which the representation is currently being handled by this painter.
|
Color |
getZeroColor()
Returns the color that is used to paint the Greenwich meridian and the
equator.
|
boolean |
isLabeled()
Returns whether the grid labels are painted.
|
boolean |
isLabelFilled()
Returns whether to surround labels with a filled background.
|
boolean |
isLabelFrame()
Returns whether to surround labels with a frame.
|
boolean |
isLabelHaloEnabled()
Returns whether the painter will add a halo effect around the grid labels.
|
boolean |
isSlantedLabels()
Returns whether the grid labels are painted at an angle.
|
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 |
setColor(Color aColor)
Sets the color to be used to paint the grid lines.
|
void |
setLabelAlignment(int aAlignment)
Sets how a grid label is aligned with respect to the grid line.
|
void |
setLabelBackgroundColor(Color aBackgroundColor)
Sets the color of the grid label frames filling to
aBackgroundColor . |
void |
setLabelColor(Color aLabelColor)
Sets the color to be used to paint the grid labels.
|
void |
setLabeled(boolean aLabeled)
Specifies whether the grid labels should be painted.
|
void |
setLabelEdgeOffset(int aLabelEdgeOffset)
Sets the minimum offset between the grid labels and the edge of the view.
|
void |
setLabelFilled(boolean aFilled)
Sets whether to surround labels with a filled background.
|
void |
setLabelFont(Font aLabelFont)
Sets the
Font for the grid labels. |
void |
setLabelFrame(boolean aFramed)
Sets whether or not to surround the labels with a frame.
|
void |
setLabelGridOffset(int aLabelGridOffset)
Sets the offset between the grid labels and their grid lines.
|
void |
setLabelHaloColor(Color aHaloColor)
Sets the color of the halo effect for the grid labels.
|
void |
setLabelHaloEnabled(boolean aHaloEnabled)
Determines whether the painter will add a halo effect around the grid labels.
|
void |
setLabelHaloThickness(int aHaloThickness)
Sets the thickness defined in pixels of the halo effect for the grid labels.
|
void |
setLabelMargin(int aMargin)
Sets the amount of the padding margin around the label text, in pixels.
|
void |
setLabelPosition(TLcdLonLatGridPainter.LabelPosition aLabelPosition)
Determines where grid labels are positioned.
|
void |
setLonLatFormatter(ILcdLonLatFormatter aLonLatFormatter)
Sets the formatter to be used for the grid labels.
|
void |
setObject(Object aObject)
Sets the Object for which the representation shall be handled by this painter.
|
void |
setSlantedLabels(boolean aSlantedLabels)
Specifies whether the grid labels should be painted at an angle.
|
void |
setZeroColor(Color aZeroColor)
Sets the color to be used to paint the Greenwich meridian and the equator.
|
addPropertyChangeListener, anchorPointSFCT, firePropertyChangeEvent, firePropertyChangeEvent, getCursor, getDisplayName, getGXYPainter, isTraceOn, removePropertyChangeListener, setClassTraceOn, setDisplayName, setTraceOn, snapTarget, supportSnap
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
anchorPointSFCT, getCursor, getDisplayName, snapTarget, supportSnap
addPropertyChangeListener, removePropertyChangeListener
public static final int ABOVE
public static final int CENTER
public static final int BELOW
public TLcdLonLatGridPainter()
TLcdLonLatGridPainter
object.public Color getColor()
public void setColor(Color aColor)
public Color getZeroColor()
public void setZeroColor(Color aZeroColor)
public boolean isLabeled()
public void setLabeled(boolean aLabeled)
public TLcdLonLatGridPainter.LabelPosition getLabelPosition()
setLabelPosition(com.luciad.view.map.painter.TLcdLonLatGridPainter.LabelPosition)
public void setLabelPosition(TLcdLonLatGridPainter.LabelPosition aLabelPosition)
aLabelPosition
- the desired position of the labelsgetLabelPosition()
public boolean isLabelHaloEnabled()
setLabelHaloEnabled(boolean)
public void setLabelHaloEnabled(boolean aHaloEnabled)
false
.aHaloEnabled
- a flag indicating whether to add a halo effect around the grid labels.isLabelHaloEnabled()
public int getLabelHaloThickness()
setLabelHaloThickness(int)
public void setLabelHaloThickness(int aHaloThickness)
1
.aHaloThickness
- the thickness defined in pixels of the halo effect for the grid labels.getLabelHaloThickness()
,
TLcdGXYHaloLabelPainter.setHaloThickness(int)
public Color getLabelHaloColor()
setLabelHaloColor(java.awt.Color)
public void setLabelHaloColor(Color aHaloColor)
Color.white
.aHaloColor
- the color of the halo effect for the grid labels.getLabelHaloColor()
,
TLcdGXYHaloLabelPainter.setHaloColor(java.awt.Color)
public ILcdLonLatFormatter getLonLatFormatter()
public void setLonLatFormatter(ILcdLonLatFormatter aLonLatFormatter)
aLonLatFormatter
- the new formatter to use. The formatter must implement ILcdCloneable
if it should be cloned when this painter is cloned.public boolean isSlantedLabels()
public void setSlantedLabels(boolean aSlantedLabels)
public Color getLabelColor()
public void setLabelColor(Color aLabelColor)
public Font getLabelFont()
Font
for the grid labels.public void setLabelFont(Font aLabelFont)
Font
for the grid labels.public int getLabelGridOffset()
public void setLabelGridOffset(int aLabelGridOffset)
aLabelGridOffset
- the label grid offset, expressed in pixels.public int getLabelEdgeOffset()
public void setLabelEdgeOffset(int aLabelEdgeOffset)
aLabelEdgeOffset
- the label edge offset, expressed in pixels.public void setLabelAlignment(int aAlignment)
aAlignment
- one of ABOVE
, CENTER
, or BELOW
getLabelAlignment()
public int getLabelAlignment()
ABOVE
, CENTER
, or BELOW
setLabelAlignment(int)
public void setLabelBackgroundColor(Color aBackgroundColor)
aBackgroundColor
.aBackgroundColor
- the color to be used for the grid label frames filling.getLabelBackgroundColor()
,
setLabelFilled(boolean)
public Color getLabelBackgroundColor()
setLabelBackgroundColor(java.awt.Color)
public void setLabelFrame(boolean aFramed)
aFramed
- true to paint the labels in a frame.isLabelFrame()
public boolean isLabelFrame()
setLabelFrame(boolean)
public void setLabelFilled(boolean aFilled)
aFilled
- true to paint labels with a filled background.isLabelFilled()
public boolean isLabelFilled()
true
if labels are surround with a filled background, false
otherwisesetLabelFilled(boolean)
public void setLabelMargin(int aMargin)
aMargin
- the new margin size, in pixelsgetLabelMargin()
public int getLabelMargin()
setLabelMargin(int)
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 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.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 boundsSFCT(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext, ILcd2DEditableBounds aBoundsSFCT)
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.isTouched
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()