public class TLcdMGRSGridLayer extends Object implements ILcdGXYLayer, ILcdNotLabelDeconflictableLayer
ILcdGXYLayer
implementation that is capable of visualizing MGRS grid data (UTM + UPS). The
styling of the MGRS grid and its labels can be done using TLcdMGRSGridStyle
. An overlay label can added using TLcdMGRSGridOverlayLabelBuilder
.Constructor and Description |
---|
TLcdMGRSGridLayer()
Constructs a layer depicting a WGS-84 MGRS (UTM + UPS) grid, with
"MGRS Grid"
as label. |
TLcdMGRSGridLayer(String aLabel)
Constructs a layer depicting a WGS-84 MGRS (UTM + UPS) grid, with the given label.
|
TLcdMGRSGridLayer(String aLabel,
ILcdGeodeticDatum aGeodeticDatum)
Constructs a layer depicting a MGRS (UTM + UPS) grid based on the given geodetic datum, with the given label.
|
Modifier and Type | Method and Description |
---|---|
void |
addOverlayLabel(TLcdMGRSGridOverlayLabelBuilder aOverlayLabelBuilder,
TLcdOverlayLayout.Location aLocation)
Adds an overlay label that is painted on the view.
|
void |
addPropertyChangeListener(PropertyChangeListener aPropertyChangeListener)
Registers the given
PropertyChangeListener to be notified when this object's
properties change. |
void |
addSelectionListener(ILcdSelectionListener aSelectionListener)
This layer does not support selection.
|
int |
applyOnInteract(ILcdFunction aFunction,
Rectangle aBounds,
boolean aStrictInteract,
ILcdGXYView aGXYView)
No interaction is possible with this type of layer.
|
void |
clearSelection(int aDispatchEventMode)
This layer does not support selection.
|
void |
fireCollectedSelectionChanges()
This layer does not support selection.
|
ILcdBounds |
getBounds(int aMode,
ILcdGXYView aGXYView)
This method returns the view bounds of this layer, taking into account the XYWorldReference of the given
ILcdGXYView aGXYView. |
ILcdGXYEditor |
getGXYEditor(Object aObject)
This layer does not support editing.
|
ILcdGXYLabelPainter |
getGXYLabelPainter(Object aObject)
Label painting of this layer is handled by an internal painter.
|
ILcdGXYPainter |
getGXYPainter(Object aObject)
Painting of this layer is handled by an internal painter.
|
ILcdGXYPen |
getGXYPen()
Grid lines are painted internally.
|
ILcdIcon |
getIcon()
Returns the icon to represent this layer.
|
String |
getLabel()
Returns the textual representation of this layer.
|
ILcdInterval |
getLabelScaleRange()
Returns the toolkit scale range for which to display labels for elements of the model.
|
TLcdMGRSGridStyle |
getMGRSGridStyle()
Returns the mgrs grid style to use when painting this layer.
|
ILcdModel |
getModel()
Returns a model with an element defining an MGRS grid.
|
Class |
getModelXYWorldTransfoClass()
Returns the transformation class that to use to transform points and bounds from model space to world space and
back.
|
ILcdInterval |
getScaleRange()
Returns the toolkit scale range for which to display elements of the model.
|
int |
getSelectionCount()
This layer does not support selection.
|
boolean |
isEditable()
This layer does not support editing.
|
boolean |
isEditableSupported()
This layer does not support editing.
|
boolean |
isLabeled()
Returns whether the grids labels will be painted when the grid is painted.
|
boolean |
isLabeledSupported()
This layer supports labels.
|
boolean |
isSelectable()
This layer does not support selection.
|
boolean |
isSelectableSupported()
This layer does not support selection.
|
boolean |
isSelected(Object aObject)
This layer does not support selection.
|
boolean |
isVisible()
Whether or not this layer should be rendered.
|
void |
paint(Graphics aGraphics,
int aMode,
ILcdGXYView aGXYView)
Paints the combined representation of the layer's objects for a view, taking into account the mode.
|
void |
removeOverlayLabel(TLcdMGRSGridOverlayLabelBuilder aOverlayLabelBuilder)
Removes the overlay label created using the given overlay label builder.
|
void |
removePropertyChangeListener(PropertyChangeListener aPropertyChangeListener)
De-registers the given
PropertyChangeListener from receiving property change events
for this object. |
void |
removeSelectionListener(ILcdSelectionListener aSelectionListener)
This layer does not support selection.
|
Enumeration |
selectedObjects()
This layer does not support selection.
|
void |
selectObject(Object aObject,
boolean aSelection,
int aDispatchEventMode)
This layer does not support selection.
|
void |
setEditable(boolean aEditable)
This layer does not support editing.
|
void |
setIcon(ILcdIcon aIcon)
Sets the icon to represent this layer.
|
void |
setLabel(String aLabel)
Sets the textual representation of this layer.
|
void |
setLabeled(boolean aLabeled)
Sets whether labels should be painted for the grid or not.
|
void |
setMGRSGridStyle(TLcdMGRSGridStyle aStyle)
Sets the mgrs grid style to use when painting this layer.
|
void |
setSelectable(boolean aSelectable)
This layer does not support selection.
|
void |
setVisible(boolean aVisible)
Sets whether or not the layer's content is painted.
|
void |
stopPainting()
Inform the layer that it should terminate the current paint operation.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getLabelMapScaleRange, getMapScaleRange
getSelectedObjects
public TLcdMGRSGridLayer()
"MGRS Grid"
as label.public TLcdMGRSGridLayer(String aLabel)
aLabel
- the textual representation of this layer.public TLcdMGRSGridLayer(String aLabel, ILcdGeodeticDatum aGeodeticDatum)
aLabel
- the textual representation of this layer.aGeodeticDatum
- the datum on which the MGRS grid is located.public ILcdGXYPainter getGXYPainter(Object aObject)
null
.getGXYPainter
in interface ILcdGXYLayer
aObject
- the object to find a painter for.null
.public ILcdGXYLabelPainter getGXYLabelPainter(Object aObject)
null
.getGXYLabelPainter
in interface ILcdGXYLayer
aObject
- the object to find a label painter for.null
.public ILcdGXYEditor getGXYEditor(Object aObject)
getGXYEditor
in interface ILcdGXYLayer
aObject
- the object to find an editor for.null
.public int applyOnInteract(ILcdFunction aFunction, Rectangle aBounds, boolean aStrictInteract, ILcdGXYView aGXYView)
applyOnInteract
in interface ILcdGXYLayer
aFunction
- the function to apply. When the function returns false, no more objects should be passed to
the function.aBounds
- all objects who lie partially or completely in this area in the view are candidates to be passed to
the function.aStrictInteract
- if true
, the ILcdFunction
shall be applied only to the objects
interacting with the given bounds. When false is passed, other objects may be taken into account too.
When applying the function to an object consumes less time than checking whether an objects representation
interacts with the bounds, non-strict interaction is generally faster.aGXYView
- the view in whose bounds the objects representations should be in order to be passed to the
function.0
.public ILcdIcon getIcon()
null
.getIcon
in interface ILcdLayer
setIcon(com.luciad.gui.ILcdIcon)
public void setIcon(ILcdIcon aIcon)
null
.public ILcdGXYPen getGXYPen()
null
.getGXYPen
in interface ILcdGXYLayer
null
public void setMGRSGridStyle(TLcdMGRSGridStyle aStyle)
Sets the mgrs grid style to use when painting this layer. This style makes it for example possible to define the line color, scale levels, label formatting, ...
By default, this method returns a default mgrs style.
aStyle
- the mgrs grid style to use when painting this layer.getMGRSGridStyle()
public TLcdMGRSGridStyle getMGRSGridStyle()
setMGRSGridStyle(com.luciad.view.map.mgrs.TLcdMGRSGridStyle)
public void addOverlayLabel(TLcdMGRSGridOverlayLabelBuilder aOverlayLabelBuilder, TLcdOverlayLayout.Location aLocation)
Adds an overlay label that is painted on the view.
The location parameter should not be equal to FULL_EXTENT
or
NO_LAYOUT
. In that case an IllegalArgumentException
is thrown.
It is not possible to pass the same overlay label builder instance twice to this method. In that case,
an IllegalArgumentException
is thrown.
In order to remove the overlay label again, the removeOverlayLabel
should be
called with the same instance as the one given in this method.
aOverlayLabelBuilder
- a builder for overlay labels. Should not be null
.aLocation
- the location at which this label is paintedpublic void removeOverlayLabel(TLcdMGRSGridOverlayLabelBuilder aOverlayLabelBuilder)
Removes the overlay label created using the given overlay label builder. This method only has effect when the
same overlay label builder instance was previously passed to the addOverlayLabel
method.
aOverlayLabelBuilder
- the overlay label builder to remove.public ILcdInterval getScaleRange()
view.getScale()
< getScaleRange().getMin()
or
view.getScale()
>= getScaleRange().getMax()
.
This does not imply that all objects in the model should be painted when the scale is inside this range as
other restrictions may apply. For example, a layer may have a filter which defines which objects should be painted.
For most use cases, we recommended using the unitless map scale range
instead.
This property is mutually exclusive with the map scale range:
only one of them has a non-null
value.
The scale range can be configured using setMGRSGridStyle(TLcdMGRSGridStyle)
getScaleRange
in interface ILcdGXYLayer
ILcdInterval
containing the minimum and maximum value of view scales for which objects
should be rendered, excluding the maximum. null
if the scale constraints are determined by ILcdGXYLayer.getMapScaleRange()
.
The scales are expressed in toolkit pixels/world unit.ILcdGXYLayer.getMapScaleRange()
public ILcdInterval getLabelScaleRange()
view.getScale()
< getLabelScaleRange().getMin()
or
view.getScale()
>= getLabelScaleRange().getMax()
.
This does not imply that labels for all objects in the model should be painted when the scale is inside this range
as other restrictions may apply. For example, a layer may decide not to paint any labels for objects whose body is
not painted.
For most use cases, we recommended using the unitless map scale range
instead.
This property is mutually exclusive with the label map scale range:
only one of them has a non-null
value.
The scale range can be configured using setMGRSGridStyle(TLcdMGRSGridStyle)
getLabelScaleRange
in interface ILcdGXYLayer
ILcdInterval
containing the minimum and maximum value of view scales for which
labels should be rendered, excluding the maximum.
null
if the scale constraints are determined by ILcdGXYLayer.getLabelMapScaleRange()
The scales are expressed in toolkit pixels/world unit.ILcdGXYLayer.getLabelMapScaleRange()
public ILcdBounds getBounds(int aMode, ILcdGXYView aGXYView)
ILcdGXYView
aGXYView.getBounds
in interface ILcdGXYLayer
aMode
- a bitwise combination of ALL or SELECTION and one or more of BODIES and HANDLES.
The ILcdGXYLayer.LABELS
mode is not supported.aGXYView
- the view in which the layer could be placed. This enables taking into account the views settings,
for example the scale.public void paint(Graphics aGraphics, int aMode, ILcdGXYView aGXYView)
ILcdGXYLayer
The mode indicates what objects of the model should be taken into account and what representation should be provided. The objects to be taken into account shall be one of:
Note that the combined representation may contain less than the representation of all objects that were taken into account, as some objects may be disregarded for various reasons (filters, scale, ... ). When the views scale is outside the scale range (BODIES or HANDLES mode) or the label scale range (LABELS mode) nothing shall be painted.
The representations provided shall be one or more of:
The mode supplied shall be a bitwise or combination of a constant of the first group and one or more of the
second group. When painting in BODIES or HANDLES mode, painting of an object shall be delegated to the
painter
for that object, when the LABELS mode is passed, painting shall be delegated
to the labelpainter
for that object.
The view is passed to provide contextual information: some of the objects may have a different representation depending on the view, or depending on a property of the view, for example, the scale of the view.
The combined representation of the objects has to be painted on the Graphics supplied, as these may be different from the Graphics provided by the view (due to double buffering, for example).
When stopPainting
is called, the current painting operation should be aborted.
paint
in interface ILcdGXYLayer
aGraphics
- the Graphics to paint on.aMode
- indicates what should be painted and how it should be painted.aGXYView
- the view to paint for.ILcdGXYLayer.getGXYPainter(Object)
,
ILcdGXYLayer.getGXYLabelPainter(Object)
,
ILcdGXYLayer.getScaleRange()
,
ILcdGXYLayer.getLabelScaleRange()
,
ILcdGXYLayer.stopPainting()
public void stopPainting()
ILcdGXYLayer
Thread
and needs to be
stopped in a safe state from another Thread.stopPainting
in interface ILcdGXYLayer
paint
public void addPropertyChangeListener(PropertyChangeListener aPropertyChangeListener)
ILcdPropertyChangeSource
Registers the given PropertyChangeListener
to be notified when this object's
properties change.
In case you need to register a listener which keeps a reference to an object with a shorter life-time than this change source,
you can use a ALcdWeakPropertyChangeListener
instance as property change listener.
addPropertyChangeListener
in interface ILcdPropertyChangeSource
aPropertyChangeListener
- The listener to be notifiedALcdWeakPropertyChangeListener
,
ILcdPropertyChangeSource.removePropertyChangeListener(java.beans.PropertyChangeListener)
public void removePropertyChangeListener(PropertyChangeListener aPropertyChangeListener)
ILcdPropertyChangeSource
De-registers the given PropertyChangeListener
from receiving property change events
for this object.
If the listener was added more than once, it will be notified one less time after being
removed.
If the listener is null
, or was never added, no exception is thrown and no action is taken.
removePropertyChangeListener
in interface ILcdPropertyChangeSource
aPropertyChangeListener
- the listener that should no longer be notified of changes of
this object's propertiesILcdPropertyChangeSource.addPropertyChangeListener(java.beans.PropertyChangeListener)
public ILcdModel getModel()
public void setVisible(boolean aVisible)
ILcdLayer
setVisible
in interface ILcdLayer
aVisible
- true
if the layer should be visible, false
otherwise.ILcdLayer.isVisible()
public boolean isVisible()
isVisible
in interface ILcdLayer
ILcdLayer.setVisible(boolean)
public boolean isEditableSupported()
isEditableSupported
in interface ILcdLayer
ILcdLayer.setEditable(boolean)
public boolean isEditable()
isEditable
in interface ILcdLayer
ILcdLayer.setEditable(boolean)
public void setEditable(boolean aEditable)
setEditable
in interface ILcdLayer
aEditable
- true if the layer content can be editedILcdLayer.isEditableSupported()
,
ILcdLayer.isEditable()
public boolean isSelectableSupported()
isSelectableSupported
in interface ILcdLayer
ILcdLayer.setSelectable(boolean)
,
ILcdLayer.selectObject(java.lang.Object, boolean, int)
public boolean isSelectable()
isSelectable
in interface ILcdLayer
ILcdSelection
,
ILcdLayer.setSelectable(boolean)
public void setSelectable(boolean aSelectable)
setSelectable
in interface ILcdLayer
aSelectable
- true
if the layer allows selection, false
otherwise.ILcdLayer.isSelectable()
,
ILcdLayer.isSelectableSupported()
public boolean isLabeledSupported()
isLabeledSupported
in interface ILcdGXYLayer
public boolean isLabeled()
isLabeled
in interface ILcdGXYLayer
ILcdGXYLayer.isLabeledSupported()
public void setLabeled(boolean aLabeled)
setLabeled
in interface ILcdGXYLayer
aLabeled
- true
to make sure labels should be painted, and false
otherwise.isLabeled()
public String getLabel()
getLabel
in interface ILcdLayer
setLabel(String)
public void setLabel(String aLabel)
setLabel
in interface ILcdLayer
aLabel
- the the textual representation to use for this ILcdLayer
.getLabel()
public int getSelectionCount()
getSelectionCount
in interface ILcdSelection<Object>
public Enumeration selectedObjects()
selectedObjects
in interface ILcdSelection<Object>
TLcdEmptyEnumeration.getInstance
().public boolean isSelected(Object aObject)
isSelected
in interface ILcdSelection<Object>
aObject
- the Object
to be checked.false
.public void selectObject(Object aObject, boolean aSelection, int aDispatchEventMode)
selectObject
in interface ILcdLayer
aObject
- the Object
to select or deselect. The object should be in the model
of this layer. The implementation of this method is not responsible for checking this.aSelection
- the selection state, true
to select, false
to deselect.aDispatchEventMode
- shall be one among ILcdFireEventMode.FIRE_NOW
,
ILcdFireEventMode.FIRE_LATER
, ILcdFireEventMode.NO_EVENT
ILcdFireEventMode
public void fireCollectedSelectionChanges()
fireCollectedSelectionChanges
in interface ILcdLayer
public void clearSelection(int aDispatchEventMode)
clearSelection
in interface ILcdLayer
aDispatchEventMode
- shall be one among ILcdFireEventMode.FIRE_NOW
,
ILcdFireEventMode.FIRE_LATER
, ILcdFireEventMode.NO_EVENT
ILcdFireEventMode
public void addSelectionListener(ILcdSelectionListener aSelectionListener)
addSelectionListener
in interface ILcdSelection<Object>
aSelectionListener
- the ILcdSelectionListener
to be added.public void removeSelectionListener(ILcdSelectionListener aSelectionListener)
removeSelectionListener
in interface ILcdSelection<Object>
aSelectionListener
- the ILcdSelectionListener
to be removed.public Class getModelXYWorldTransfoClass()
ILcdGXYLayer
getModelXYWorldTransfoClass
in interface ILcdGXYLayer