Class TLcdXYGridLayer
- All Implemented Interfaces:
ILcdPropertyChangeSource,ILcdSelection<Object>,ILcdGXYLayer,ILcdNotLabelDeconflictableLayer,ILcdLayer,Serializable
ILcdGXYLayer implementation that is capable of visualizing cartesian (XY) grid data. The
styling of the XY grid and its labels can be done using TLcdXYGridStyle.
An example of how to use this builder:
TLcdXYGridLayer layer = new TLcdXYGridLayer("XY grid");
TLcdXYGridStyle gridStyle = ...; // See TLcdXYGridStyle documentation
layer.setXYGridStyle(gridStyle);
It is possible to specify a model reference for the xy grid, or to make the grid always use the world reference.
- Since:
- 2016.0
- See Also:
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a grid layer that visualizes a grid that uses the same reference as the view it is visualized in.TLcdXYGridLayer(String aLabel) Creates a grid layer that visualizes a grid that uses the same reference as the view it is visualized in.TLcdXYGridLayer(String aLabel, ILcdModelReference aModelReference) Creates a grid layer that visualizes a grid in the given model reference. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddOverlayLabel(TLcdXYGridOverlayLabelBuilder aOverlayLabelBuilder, TLcdOverlayLayout.Location aLocation) Adds an overlay label to be used.voidaddPropertyChangeListener(PropertyChangeListener aPropertyChangeListener) Registers the givenPropertyChangeListenerto be notified when this object's properties change.voidaddSelectionListener(ILcdSelectionListener aSelectionListener) This layer does not support selection.intapplyOnInteract(ILcdFunction aFunction, Rectangle aBounds, boolean aStrictInteract, ILcdGXYView aGXYView) No interaction is possible with this type of layer.voidclearSelection(int aDispatchEventMode) This layer does not support selection.voidThis layer does not support selection.getBounds(int aMode, ILcdGXYView aGXYView) Returns the view bounds of thisILcdGXYLayercontent, the bounds of all the drawings (for the supplied mode) that represent the Objects contained in theILcdModelof thisILcdGXYLayer.getGXYEditor(Object aObject) This layer does not support editing.getGXYLabelPainter(Object aObject) Label painting of this layer is handled by an internal painter.getGXYPainter(Object aObject) Painting of this layer is handled by an internal painter.Grid lines are painted internally.getIcon()Returns the icon to represent this layer.getLabel()Returns the display name of this layer.Returns the toolkit scale range for which to display labels for elements of the model.getModel()Returns a model with an element defining an XY grid.Returns the transformation class that to use to transform points and bounds from model space to world space and back.Returns the toolkit scale range for which to display elements of the model.intThis layer does not support selection.Returns the xy grid style to use when painting this layer.booleanThis layer does not support editing.booleanThis layer does not support editing.booleanReturns whether the grids labels will be painted when the grid is painted.booleanThis layer supports labels.booleanThis layer does not support selection.booleanThis layer does not support selection.booleanisSelected(Object aObject) This layer does not support selection.booleanWhether or not this layer should be rendered.voidpaint(Graphics aGraphics, int aMode, ILcdGXYView aGXYView) Paints the combined representation of the layer's objects for a view, taking into account the mode.voidremoveOverlayLabel(TLcdXYGridOverlayLabelBuilder aOverlayLabelBuilder) Removes the overlay label created using the given overlay label builder.voidremovePropertyChangeListener(PropertyChangeListener aPropertyChangeListener) De-registers the givenPropertyChangeListenerfrom receiving property change events for this object.voidremoveSelectionListener(ILcdSelectionListener aSelectionListener) This layer does not support selection.This layer does not support selection.voidselectObject(Object aObject, boolean aSelection, int aDispatchEventMode) This layer does not support selection.voidsetEditable(boolean aEditable) This layer does not support editing.voidSets the icon to represent this layer.voidSets the display name of this layer.voidsetLabeled(boolean aLabeled) Sets whether labels should be painted for the grid or not.voidsetSelectable(boolean aSelectable) This layer does not support selection.voidsetVisible(boolean aVisible) Sets whether or not the layer's content is painted.voidsetXYGridStyle(TLcdXYGridStyle aStyle) Sets the xy grid style to use when painting this layer.voidInform the layer that it should terminate the current paint operation.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.luciad.view.gxy.ILcdGXYLayer
getLabelMapScaleRange, getMapScaleRangeMethods inherited from interface com.luciad.util.ILcdSelection
getSelectedObjects
-
Constructor Details
-
TLcdXYGridLayer
public TLcdXYGridLayer()Creates a grid layer that visualizes a grid that uses the same reference as the view it is visualized in. This means that the grid uses a different reference during painting when the world reference of the view changes. A default name is used as the display name for the layer, "XY Grid".
Use this method when you don't want your grid to be warped by the world reference.
When the world reference of the view to which this grid layer is added is not an
ILcdXYWorldReference, nothing will be painted.Note that the model used will always have a default geodetic model reference. This means that the model reference of the created model will not be changed to the reference of the view. The XY grid layer will make sure that the grid is generated/painted for the world reference. This is not explicitly modelled though.
-
TLcdXYGridLayer
Creates a grid layer that visualizes a grid that uses the same reference as the view it is visualized in. This means that the grid uses a different reference during painting when the world reference of the view changes. The given name is used as a display name for the layer.
Use this method when you don't want your grid to be warped by the world reference.
When the world reference of the view to which this grid layer is added is not an
ILcdXYWorldReference, nothing will be painted.Note that the model used will always have a default geodetic model reference. This means that the model reference of the created model will not be changed to the reference of the view. The XY grid layer will make sure that the grid is generated/painted for the world reference. This is not explicitly modelled though.
- Parameters:
aLabel- the display name of this layer.
-
TLcdXYGridLayer
Creates a grid layer that visualizes a grid in the given model reference. The label String is used as the display name for the layer. This method throws an exception when the given model reference is not an
ILcdXYWorldReference.Use this method when you always want to display an axis-aligned grid.
- Parameters:
aLabel- the display name of this layer.aModelReference- the model reference in which the grid is defined
-
-
Method Details
-
getGXYPainter
Painting of this layer is handled by an internal painter. This method will always returnnull.- Specified by:
getGXYPainterin interfaceILcdGXYLayer- Parameters:
aObject- the object to find a painter for.- Returns:
null.
-
getGXYLabelPainter
Label painting of this layer is handled by an internal painter. This method will always returnnull.- Specified by:
getGXYLabelPainterin interfaceILcdGXYLayer- Parameters:
aObject- the object to find a label painter for.- Returns:
null.
-
getGXYEditor
This layer does not support editing. No editors will be returned.- Specified by:
getGXYEditorin interfaceILcdGXYLayer- Parameters:
aObject- the object to find an editor for.- Returns:
- Always returns
null.
-
applyOnInteract
public int applyOnInteract(ILcdFunction aFunction, Rectangle aBounds, boolean aStrictInteract, ILcdGXYView aGXYView) No interaction is possible with this type of layer.- Specified by:
applyOnInteractin interfaceILcdGXYLayer- Parameters:
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- iftrue, theILcdFunctionshall 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.- Returns:
- Always returns
0.
-
getIcon
Returns the icon to represent this layer. By default the icon isnull. -
setIcon
Sets the icon to represent this layer. By default the icon isnull. -
getGXYPen
Grid lines are painted internally. This method always returnsnull.- Specified by:
getGXYPenin interfaceILcdGXYLayer- Returns:
null
-
setXYGridStyle
Sets the xy 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 the layer uses a default xy grid style.
- Parameters:
aStyle- the xy grid style to use when painting this layer.- See Also:
-
getXYGridStyle
Returns the xy grid style to use when painting this layer.- Returns:
- the xy grid style to use when painting this layer.
- See Also:
-
addOverlayLabel
public void addOverlayLabel(TLcdXYGridOverlayLabelBuilder aOverlayLabelBuilder, TLcdOverlayLayout.Location aLocation) Adds an overlay label to be used. When the layer is added to the view, this overlay label builder is used to add an overlay component to a view. The overlay component is also removed when the layer is removed from a view.
The location parameter should not be equal to
FULL_EXTENTorNO_LAYOUT. In that case anIllegalArgumentExceptionis thrown.It is not possible to pass the same overlay label builder instance twice to this method. In that case, an
IllegalArgumentExceptionis thrown.In order to remove the overlay label again, the
removeOverlayLabelshould be called with the same instance as the one given in this method.- Parameters:
aOverlayLabelBuilder- the overlay label builder used to create an overlay component. Should not benull. It is not needed to call theTLspXYGridOverlayLabelBuilder.modelReference()methods before calling this method. This will be done automatically.aLocation- the location at which this label is painted.
-
removeOverlayLabel
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
addOverlayLabelmethod.- Parameters:
aOverlayLabelBuilder- the overlay label builder to remove.
-
getScaleRange
Returns the toolkit scale range for which to display elements of the model. In other words, the paint method will not render any objects in a view when:
view.getScale()<getScaleRange().getMin()orview.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 theunitless map scale rangeinstead. This property is mutually exclusive with the map scale range: only one of them has a non-nullvalue.The scale range can be configured using
setXYGridStyle(TLcdXYGridStyle)- Specified by:
getScaleRangein interfaceILcdGXYLayer- Returns:
- an
ILcdIntervalcontaining the minimum and maximum value of view scales for which objects should be rendered, excluding the maximum.nullif the scale constraints are determined byILcdGXYLayer.getMapScaleRange(). The scales are expressed in toolkit pixels/world unit. - See Also:
-
getLabelScaleRange
Returns the toolkit scale range for which to display labels for elements of the model. In other words, the paint method will not render any labels for objects in a view when:
view.getScale()<getLabelScaleRange().getMin()orview.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 theunitless map scale rangeinstead. This property is mutually exclusive with the label map scale range: only one of them has a non-nullvalue.The scale range can be configured using
setXYGridStyle(TLcdXYGridStyle)- Specified by:
getLabelScaleRangein interfaceILcdGXYLayer- Returns:
- an
ILcdIntervalcontaining the minimum and maximum value of view scales for which labels should be rendered, excluding the maximum.nullif the scale constraints are determined byILcdGXYLayer.getLabelMapScaleRange()The scales are expressed in toolkit pixels/world unit. - See Also:
-
getBounds
Description copied from interface:ILcdGXYLayerReturns the view bounds of thisILcdGXYLayercontent, the bounds of all the drawings (for the supplied mode) that represent the Objects contained in theILcdModelof thisILcdGXYLayer. For this operation, thisILcdGXYLayeris to be considered as part ofaGXYView.Outside of the layers bounds no interaction with any object of the layer via its representation is possible. Note that these bounds do not necessarily encompass the representation of all objects in the model, only the objects for which there is a representation in the view.
- Specified by:
getBoundsin interfaceILcdGXYLayer- Parameters:
aMode- a bitwise combination of ALL or SELECTION and one or more of BODIES and HANDLES. TheILcdGXYLayer.LABELSmode 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.- Returns:
- a bounds (in view coordinates, pixels) that encompasses the representation of all objects that are rendered in a view.
-
paint
Description copied from interface:ILcdGXYLayerPaints the combined representation of the layer's objects for a view, taking into account the mode.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:
- ALL: all the objects in the layer's model, or
- SELECTION: all the objects in the layer's selection.
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:
- BODIES: the combination of geometric representations of the objects,
- HANDLES: the handles for the objects. These are the parts of the objects representation on which user interaction can be applied. For example, for a circle this can be the center point, allowing to move the circle.
- LABELS: the combination of the textual representations of the objects.
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
painterfor that object, when the LABELS mode is passed, painting shall be delegated to thelabelpainterfor 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
stopPaintingis called, the current painting operation should be aborted.- Specified by:
paintin interfaceILcdGXYLayer- Parameters:
aGraphics- the Graphics to paint on.aMode- indicates what should be painted and how it should be painted.aGXYView- the view to paint for.- See Also:
-
stopPainting
public void stopPainting()Description copied from interface:ILcdGXYLayerInform the layer that it should terminate the current paint operation. This method can be useful when the paint method is executed in a specificThreadand needs to be stopped in a safe state from another Thread.- Specified by:
stopPaintingin interfaceILcdGXYLayer- See Also:
-
addPropertyChangeListener
Description copied from interface:ILcdPropertyChangeSourceRegisters the given
PropertyChangeListenerto 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
ALcdWeakPropertyChangeListenerinstance as property change listener.- Specified by:
addPropertyChangeListenerin interfaceILcdPropertyChangeSource- Parameters:
aPropertyChangeListener- The listener to be notified- See Also:
-
removePropertyChangeListener
Description copied from interface:ILcdPropertyChangeSourceDe-registers the given
PropertyChangeListenerfrom 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.- Specified by:
removePropertyChangeListenerin interfaceILcdPropertyChangeSource- Parameters:
aPropertyChangeListener- the listener that should no longer be notified of changes of this object's properties- See Also:
-
getModel
Returns a model with an element defining an XY grid. The model reference of the returned model depends on theTLcdXYGridLayerconstructor used. When using the constructor with theILcdModelReference, that model reference is used. Otherwise, a geodetic reference is used. -
setVisible
public void setVisible(boolean aVisible) Description copied from interface:ILcdLayerSets whether or not the layer's content is painted.- Specified by:
setVisiblein interfaceILcdLayer- Parameters:
aVisible-trueif the layer should be visible,falseotherwise.- See Also:
-
isVisible
public boolean isVisible()Whether or not this layer should be rendered. Default value is true. -
isEditableSupported
public boolean isEditableSupported()This layer does not support editing. This method always returns false.- Specified by:
isEditableSupportedin interfaceILcdLayer- Returns:
- Always false.
- See Also:
-
isEditable
public boolean isEditable()This layer does not support editing. This method always returns false.- Specified by:
isEditablein interfaceILcdLayer- Returns:
- Always false.
- See Also:
-
setEditable
public void setEditable(boolean aEditable) This layer does not support editing. This method has an empty implementation.- Specified by:
setEditablein interfaceILcdLayer- Parameters:
aEditable- true if the layer content can be edited- See Also:
-
isSelectableSupported
public boolean isSelectableSupported()This layer does not support selection. This method always returns false.- Specified by:
isSelectableSupportedin interfaceILcdLayer- Returns:
- Always false.
- See Also:
-
isSelectable
public boolean isSelectable()This layer does not support selection. This method always returns false.- Specified by:
isSelectablein interfaceILcdLayer- Returns:
- Always false.
- See Also:
-
setSelectable
public void setSelectable(boolean aSelectable) This layer does not support selection. This method has an empty implementation.- Specified by:
setSelectablein interfaceILcdLayer- Parameters:
aSelectable-trueif the layer allows selection,falseotherwise.- See Also:
-
isLabeledSupported
public boolean isLabeledSupported()This layer supports labels.- Specified by:
isLabeledSupportedin interfaceILcdGXYLayer- Returns:
- Always true.
-
isLabeled
public boolean isLabeled()Returns whether the grids labels will be painted when the grid is painted.- Specified by:
isLabeledin interfaceILcdGXYLayer- Returns:
- whether the grids labels will be painted when the grid is painted.
- See Also:
-
setLabeled
public void setLabeled(boolean aLabeled) Sets whether labels should be painted for the grid or not.- Specified by:
setLabeledin interfaceILcdGXYLayer- Parameters:
aLabeled-trueto make sure labels should be painted, andfalseotherwise.- See Also:
-
getLabel
Returns the display name of this layer. -
setLabel
Sets the display name of this layer. -
getSelectionCount
public int getSelectionCount()This layer does not support selection. This method always returns 0.- Specified by:
getSelectionCountin interfaceILcdSelection<Object>- Returns:
- Always 0.
-
selectedObjects
This layer does not support selection. This method always returns an empty enumeration.- Specified by:
selectedObjectsin interfaceILcdSelection<Object>- Returns:
TLcdEmptyEnumeration.getInstance().
-
isSelected
This layer does not support selection. This method always returns false.- Specified by:
isSelectedin interfaceILcdSelection<Object>- Parameters:
aObject- theObjectto be checked.- Returns:
false.
-
selectObject
This layer does not support selection. This method has an empty implementation.- Specified by:
selectObjectin interfaceILcdLayer- Parameters:
aObject- theObjectto 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,trueto select,falseto deselect.aDispatchEventMode- shall be one amongILcdFireEventMode.FIRE_NOW,ILcdFireEventMode.FIRE_LATER,ILcdFireEventMode.NO_EVENT- See Also:
-
fireCollectedSelectionChanges
public void fireCollectedSelectionChanges()This layer does not support selection. This method has an empty implementation.- Specified by:
fireCollectedSelectionChangesin interfaceILcdLayer
-
clearSelection
public void clearSelection(int aDispatchEventMode) This layer does not support selection. This method has an empty implementation.- Specified by:
clearSelectionin interfaceILcdLayer- Parameters:
aDispatchEventMode- shall be one amongILcdFireEventMode.FIRE_NOW,ILcdFireEventMode.FIRE_LATER,ILcdFireEventMode.NO_EVENT- See Also:
-
addSelectionListener
This layer does not support selection. This method has an empty implementation.- Specified by:
addSelectionListenerin interfaceILcdSelection<Object>- Parameters:
aSelectionListener- theILcdSelectionListenerto be added.
-
removeSelectionListener
This layer does not support selection. This method has an empty implementation.- Specified by:
removeSelectionListenerin interfaceILcdSelection<Object>- Parameters:
aSelectionListener- theILcdSelectionListenerto be removed.
-
getModelXYWorldTransfoClass
Description copied from interface:ILcdGXYLayerReturns the transformation class that to use to transform points and bounds from model space to world space and back. This class has to be conform with the reference of the model of this layer and the reference of the view this layer is part of.- Specified by:
getModelXYWorldTransfoClassin interfaceILcdGXYLayer- Returns:
- the transformation class that to use to transform points and bounds from model space to world space and back.
-