S
- The type of the view used in the map component for which this factory creates a
drawing toolbar (ILcdGXYView
for GXY and ILspView
for Lightspeed)T
- The type of the layers contained in the view of the map component (ILcdGXYLayer
for GXY and ILspLayer
for Lightspeed)public abstract class ALcyDrawingToolBarFactory<S extends ILcdView & ILcdTreeLayered,T extends ILcdLayer> extends ALcyGUIFactory<Component>
Abstract base class to create the default tool bar for editing a drawing model. It has concrete subclasses for a GXY and a Lightspeed view. It is recommended to extend one of those subclasses directly and not extend from this class.
The tool bar is constructed in the same manner a GUI panel is constructed in an ALcyGUIFactory
. The main create function createGUI
first creates all actions and active settables, then all the components and finally
all the panels. Then it calls createGUIContent
, which will create the content of the tool bar using the created panels by
calling ALcyGUIFactory.getPanel(int)
.
Each GUI element can be replaced by overriding the respective create* method to return a
custom element for the respective GUI ID. For example, to change the functionality of the load
action, override the createAction
method to return a custom action for the LOAD_ACTION
ID. All the default
IDs are available as public static fields in this class.
Similarly, one can override the createGUIContent
method to produce a customized layout for the GUI elements.
The default actions and active settables can be removed from the tool bar by removing them for the drawing config file.
Adding items to the tool bar can be achieved by overriding the createGUIContent
method,
retrieving the tool bar and inserting actions or components into it.
If items needs to be added from for example another add-on, it might be convenient to use TLcyActionBarUtil
with action bar id DRAWING_TOOL_BAR_ID
.
Modifier and Type | Field and Description |
---|---|
static int |
ARROW_COMPONENT
Deprecated.
The component is replaced by an action, which can be configured into any
ILcyActionBar .
See CHANGE_ARROW_STYLE_ACTION and createAction(int, ALcyProperties) |
static int |
BUFFER_3D_ACTION
Converts a polyline into a lonlatheightbuffer with a certain width and height.
|
static int |
BUFFER_ACTION
Converts a polyline into a buffer with a certain width.
|
static int |
CHANGE_ARROW_STYLE_ACTION
Adds or removes arrows at the beginning and/or end of lines.
|
static int |
CHANGE_FILL_COLOR_ACTION
Changes the fill color of a shape.
|
static int |
CHANGE_LINE_SIZE_ACTION
Changes the line size of a shape.
|
static int |
CHANGE_LINE_STYLE_ACTION
Changes the line style of a shape.
|
static int |
CHANGE_POINT_STYLE_ACTION
Changes the icon used to display points on the map
|
static int |
COPY_STYLE_ACTION
Copies the style of an object to other objects
|
static int |
DELETE_ACTION
Deletes all the selected shapes.
|
static int |
DOME_ACTION
Converts an existing circle into a dome.
|
static String |
DRAWING_TOOL_BAR_ID
The ID of the
ILcyActionBar that is created by this factory. |
static int |
DUPLICATE_ACTION
Makes a copy of the selected objects, and pastes every copy in the layer of the original
object.
|
static int |
EXTRUDE_ACTION
Converts an existing 2D shape into an extruded 3D version with a minimal and maximal altitude.
|
static int |
FILL_COLOR_COMPONENT
Deprecated.
The component is replaced by an action, which can be configured into any
ILcyActionBar .
See CHANGE_FILL_COLOR_ACTION and createAction(int, ALcyProperties) |
static int |
FONT_ACTION
Changes the font of text shapes.
|
static int |
GROUP_ACTION
Groups the selected shapes, after which they are threaded as one.
|
static int |
INTERSECTION_ACTION
Calculates the intersection point(s) between two or more shapes.
|
static int |
LINE_COLOR_ACTION
Changes the line color of shapes.
|
static int |
LINE_SIZE_COMPONENT
Deprecated.
The component is replaced by an action, which can be configured into any
ILcyActionBar .
See CHANGE_LINE_SIZE_ACTION and createAction(int, ALcyProperties) |
static int |
LINE_STYLE_COMPONENT
Deprecated.
The component is replaced by an action, which can be configured into any
ILcyActionBar .
See CHANGE_LINE_STYLE_ACTION and createAction(int, ALcyProperties) |
static int |
LOAD_ACTION
Loads an external file into Lucy as an editable layer.
|
static int |
MAIN_PANEL
The only panel of the drawing toolbar containing all the default components, actions and active
settables which are included in the drawing config file.
|
static int |
NEW_LAYER_ACTION
Adds an extra drawing layer to the map.
|
static int |
PARALLEL_ACTION
Creates a polyline parallel at an existing polyline.
|
static int |
PERPENDICULAR_ACTION
Makes two polylines, containing only two points, perpendicular to each other.
|
static int |
POINT_ACTION
Adds a point at a certain distance from the beginning or the end of an existing polyline.
|
static int |
POINT_COMPONENT
Deprecated.
The component is replaced by an action, which can be configured into any
ILcyActionBar .
See CHANGE_POINT_STYLE_ACTION and createAction(int, ALcyProperties) |
static int |
POLYGON_CONVEX_HULL_ACTION
Calculates the convex hull of one or more shapes.
|
static int |
POLYGON_DIFFERENCE_ACTION
Calculates the difference between two or more shapes.
|
static int |
POLYGON_INTERSECTION_ACTION
Calculates the intersection between two or more shapes.
|
static int |
POLYGON_INVERTED_DIFFERENCE_ACTION
Calculates the inverted difference between two or more shapes.
|
static int |
POLYGON_SYMMETRIC_DIFFERENCE_ACTION
Calculates the symmetric difference between two or more shapes.
|
static int |
POLYGON_UNION_ACTION
Calculates the union between two or more shapes.
|
static int |
SAVE_ACTION
Saves a drawing layer to disk.
|
static int |
SPHERE_ACTION
Converts an existing circle into a sphere.
|
static int |
TRANSLATE_ACTION
Translates the selected shapes over a certain distance and azimuth.
|
static int |
UNEXTRUDE_ACTION
Converts an extruded 3D shape into its base shape.
|
static int |
UNGROUP_ACTION
Restores a group of shapes as individual objects.
|
static int |
VARIABLE_BUFFER_3D_ACTION
Converts a polyline into a lonlatheightvariablegeobuffer with a certain width and height.
|
Modifier | Constructor and Description |
---|---|
protected |
ALcyDrawingToolBarFactory(String aPropertyPrefix,
ILcyLucyEnv aLucyEnv)
Constructs a new drawing tool bar factory which will create all actions, active settables,
components and panels which are specified in the class as static fields.
|
Modifier and Type | Method and Description |
---|---|
protected void |
cleanup(ALcyProperties aProperties)
Performs cleanup operations, such as nullifying fields that are no longer needed.
|
protected ILcdAction |
createAction(int aActionID,
ALcyProperties aProperties)
Creates an
ILcdAction for the given ID. |
protected ILcyActiveSettable |
createActiveSettable(int aActiveSettableID,
ALcyProperties aProperties)
Creates an
ILcyActiveSettable for the given ID. |
protected Component |
createComponent(int aComponentID,
ALcyProperties aProperties)
Creates a widget for the given ID.
|
protected TLcyToolBar |
createEmptyToolBar()
Deprecated.
Override
createEmptyToolBar(ALcyProperties) instead |
protected TLcyToolBar |
createEmptyToolBar(ALcyProperties aProperties)
Returns an empty toolbar
|
Component |
createGUI(ALcyProperties aProperties)
This function calls
setup , which creates all sub-parts such as actions, components and panels. |
protected Component |
createGUIContent(ALcyProperties aProperties)
Retrieves all panels and lays them out in a
java.awt.Component . |
protected Component |
createPanel(int aPanelID,
ALcyProperties aProperties)
Creates a panel for the given ID.
|
protected String |
createToolBarID()
Creates the action bar ID of the drawing tool bar.
|
protected Object |
getActionContext(int aActionID,
ALcyProperties aProperties)
Returns the context of the action bars in which the action with the specified ID should be
inserted.
|
protected Object |
getActiveSettableContext(int aActiveSettableID,
ALcyProperties aProperties)
Returns the context of the action bars in which the active settable with the specified ID
should be inserted.
|
protected ALcyFormatBar |
getFormatBar(ALcyProperties aProperties)
Convenience method to return the format bar contained in the properties with key
getFormatBarPropertiesKey() . |
protected abstract String |
getFormatBarPropertiesKey()
Returns the complete key (including the prefix) which was used to store the format bar in the
ALcyProperties passed to the createGUI(com.luciad.lucy.util.properties.ALcyProperties)
method. |
protected ILcyGenericMapComponent<S,T> |
getMapComponent(ALcyProperties aProperties)
Convenience method to return the map component contained in the properties with key
getMapComponentPropertiesKey() . |
protected abstract String |
getMapComponentPropertiesKey()
Returns the complete key (including the prefix) which was used to store the map component in
the
ALcyProperties passed to the createGUI(com.luciad.lucy.util.properties.ALcyProperties)
method. |
protected String |
getPropertyPrefix()
Returns the prefix used in the properties as passed in the constructor
|
protected TLcyToolBar |
getToolBar()
Returns the tool bar that is under construction
|
protected String |
getToolBarID()
Returns the action bar ID of the drawing tool bar, as created by
createToolBarID() . |
protected void |
setup(ALcyProperties aProperties)
This functions creates all the components for the user interface, in a certain order.
|
getAction, getActionIDs, getActiveSettable, getActiveSettableIDs, getComponent, getComponentIDs, getLucyEnv, getPanel, getPanelIDs, isActiveSettableDeactivatePossible
public static final String DRAWING_TOOL_BAR_ID
ILcyActionBar
that is created by this factory. The context for this
action bar is the map component to which this action bar belongs.public static final int MAIN_PANEL
public static final int LOAD_ACTION
public static final int SAVE_ACTION
public static final int LINE_COLOR_ACTION
public static final int FONT_ACTION
public static final int INTERSECTION_ACTION
public static final int POLYGON_INTERSECTION_ACTION
ILcdPoint
ILcdPolypoint
ILcdPolyline
ILcdPolygon
ILcdComplexPolygon
ILcdShapeList
containing any of the
supported shapespublic static final int POLYGON_UNION_ACTION
ILcdPoint
ILcdPolypoint
ILcdPolyline
ILcdPolygon
ILcdComplexPolygon
ILcdShapeList
containing any of the
supported shapespublic static final int PERPENDICULAR_ACTION
public static final int BUFFER_ACTION
public static final int BUFFER_3D_ACTION
public static final int POLYGON_DIFFERENCE_ACTION
ILcdPoint
ILcdPolypoint
ILcdPolyline
ILcdPolygon
ILcdComplexPolygon
ILcdShapeList
containing any of the
supported shapespublic static final int POLYGON_INVERTED_DIFFERENCE_ACTION
ILcdPoint
ILcdPolypoint
ILcdPolyline
ILcdPolygon
ILcdComplexPolygon
ILcdShapeList
containing any of the
supported shapespublic static final int POLYGON_SYMMETRIC_DIFFERENCE_ACTION
ILcdPoint
ILcdPolypoint
ILcdPolyline
ILcdPolygon
ILcdComplexPolygon
ILcdShapeList
containing any of the
supported shapespublic static final int POLYGON_CONVEX_HULL_ACTION
ILcdPoint
ILcdPolypoint
ILcdPolyline
ILcdPolygon
ILcdComplexPolygon
ILcdShapeList
containing any of the
supported shapespublic static final int VARIABLE_BUFFER_3D_ACTION
public static final int PARALLEL_ACTION
public static final int POINT_ACTION
public static final int EXTRUDE_ACTION
public static final int DOME_ACTION
public static final int SPHERE_ACTION
public static final int DELETE_ACTION
public static final int GROUP_ACTION
public static final int UNGROUP_ACTION
public static final int DUPLICATE_ACTION
public static final int NEW_LAYER_ACTION
public static final int TRANSLATE_ACTION
public static final int COPY_STYLE_ACTION
public static final int UNEXTRUDE_ACTION
public static final int CHANGE_LINE_SIZE_ACTION
public static final int CHANGE_LINE_STYLE_ACTION
public static final int CHANGE_ARROW_STYLE_ACTION
public static final int CHANGE_POINT_STYLE_ACTION
public static final int CHANGE_FILL_COLOR_ACTION
@Deprecated public static final int LINE_SIZE_COMPONENT
ILcyActionBar
.
See CHANGE_LINE_SIZE_ACTION
and createAction(int, ALcyProperties)
@Deprecated public static final int LINE_STYLE_COMPONENT
ILcyActionBar
.
See CHANGE_LINE_STYLE_ACTION
and createAction(int, ALcyProperties)
@Deprecated public static final int ARROW_COMPONENT
ILcyActionBar
.
See CHANGE_ARROW_STYLE_ACTION
and createAction(int, ALcyProperties)
@Deprecated public static final int POINT_COMPONENT
ILcyActionBar
.
See CHANGE_POINT_STYLE_ACTION
and createAction(int, ALcyProperties)
@Deprecated public static final int FILL_COLOR_COMPONENT
ILcyActionBar
.
See CHANGE_FILL_COLOR_ACTION
and createAction(int, ALcyProperties)
protected ALcyDrawingToolBarFactory(String aPropertyPrefix, ILcyLucyEnv aLucyEnv)
Constructs a new drawing tool bar factory which will create all actions, active settables, components and panels which are specified in the class as static fields.
Use the get*IDs
methods if you want to modify the available IDs.
aPropertyPrefix
- The prefix which will be used in the ALcyProperties
instance
passed to the createGUI
methodaLucyEnv
- The Lucy back-endprotected ILcyGenericMapComponent<S,T> getMapComponent(ALcyProperties aProperties)
getMapComponentPropertiesKey()
.aProperties
- The properties in which to look for a map componentprotected abstract String getMapComponentPropertiesKey()
ALcyProperties
passed to the createGUI(com.luciad.lucy.util.properties.ALcyProperties)
method.protected ALcyFormatBar getFormatBar(ALcyProperties aProperties)
getFormatBarPropertiesKey()
.aProperties
- The properties in which to look for a format barprotected abstract String getFormatBarPropertiesKey()
ALcyProperties
passed to the createGUI(com.luciad.lucy.util.properties.ALcyProperties)
method.protected String getToolBarID()
createToolBarID()
.protected String createToolBarID()
Creates the action bar ID of the drawing tool bar. The action bar ID is used to parse the
actions from the configuration file, and is defined as in TLcyActionBarUtil
.
The default implementation returns DRAWING_TOOL_BAR_ID
.
Overriding this method is useful when multiple drawing bars need to be created for a single
ILcyMapComponent
(that for example work on different layers). Multiple bars (for
a single map) need different ID's to avoid that their actions get mixed up.
public Component createGUI(ALcyProperties aProperties)
setup
, which creates all sub-parts such as actions, components and panels. createGUIContent
, which
creates the content of the panel by laying out all panels created in the previous step.
cleanup
to perform
some cleanup tasks. The Component
created in the second step is returned. It is up to the user of
this factory to make the returned Component
visible in for example an
ILcyApplicationPane
or a dialog.
Warning: There is normally no need to override this method, instead overwrite one of the three methods that it calls. Also note that it is possible that this method is called an a worker thread. If you override it, be sure to call the super function and to invoke any Swing or other EDT dependent code on the EDT thread.
The ALcyProperties
passed to this method must contain a valid value for the map component properties key
and the format bar properties key
.
createGUI
in class ALcyGUIFactory<Component>
aProperties
- a properties object that can be used to tune the behavior of this factory.ALcyGUIFactory.createGUIContent(com.luciad.lucy.util.properties.ALcyProperties)
.protected void setup(ALcyProperties aProperties)
ALcyGUIFactory
This functions creates all the components for the user interface, in a certain order. It
createAction
with all given action ID's (see
ALcyGUIFactory.getActionIDs()
) and insert them in all configured action bars using TLcyActionBarUtil.insertInConfiguredActionBars(com.luciad.gui.ILcdAction,
Object, TLcyActionBarManager, com.luciad.lucy.util.properties.ALcyProperties)
with the
specified properties. The context is determined by calling ALcyGUIFactory.getActionContext(int, com.luciad.lucy.util.properties.ALcyProperties)
. TLcyActionBarUtil.ID_KEY
).createActiveSettable
with all
given active settable ID's (see ALcyGUIFactory.getActiveSettableIDs()
and insert them in all
configured action bars using TLcyActionBarUtil.insertInConfiguredActionBars(ILcyActiveSettable,
Object, TLcyActionBarManager, com.luciad.lucy.util.properties.ALcyProperties)
with the
specified properties. The context is determined by calling ALcyGUIFactory.getActiveSettableContext(int, com.luciad.lucy.util.properties.ALcyProperties)
.TLcyActionBarUtil.ID_KEY
).ALcyGUIFactory.createComponent(int, com.luciad.lucy.util.properties.ALcyProperties)
with all given component ID's (see
ALcyGUIFactory.getComponentIDs()
).ALcyGUIFactory.createPanel(int, com.luciad.lucy.util.properties.ALcyProperties)
with all given panel ID's (see ALcyGUIFactory.getPanelIDs()
). Note that because of this order, panels can be composed of components, and components can
use the active settables and actions. So the ALcyGUIFactory.createPanel(int, com.luciad.lucy.util.properties.ALcyProperties)
method can use ALcyGUIFactory.getComponent(int)
to retrieve its sub components, and the ALcyGUIFactory.createComponent(int, com.luciad.lucy.util.properties.ALcyProperties)
method can use
ALcyGUIFactory.getAction(int)
and ALcyGUIFactory.getActiveSettable(int)
to retrieve needed actions and active
settables.
Warning: It is possible that this method is called on a worker thread. When
overriding this method, care should be taken to ensure that all code that should be run on the
EDT thread (Swing code etc...) is invoked using for example TLcdAWTUtil.invokeAndWait(java.lang.Runnable)
.
Also, don't override this method without calling the super function.
setup
in class ALcyGUIFactory<Component>
aProperties
- a properties object that can be used to tune the behavior of this factory.protected void cleanup(ALcyProperties aProperties)
ALcyGUIFactory
Performs cleanup operations, such as nullifying fields that are no longer needed.
Warning: Should not be overridden without calling the super function.
cleanup
in class ALcyGUIFactory<Component>
aProperties
- a properties object that can be used to tune the behavior of this factory.protected Component createGUIContent(ALcyProperties aProperties)
ALcyGUIFactory
Retrieves all panels and lays them out in a java.awt.Component
. Therefore, this
method uses ALcyGUIFactory.getPanel(int)
with all ID's that end in PANEL
, and lays out
those components in for example a javax.swing.JPanel
.
This function should be overridden when the global layout of the panel needs to be changed, for example when the main panels need to be rearranged, or when a new panel needs to be added.
An example implementation could be:
public Component createGUIContent( ALcyProperties aProperties ) {
JPanel content = new JPanel( new BorderLayout() );
Component somePanel = getPanel( SOME_PANEL );
if ( somePanel != null ) content.add( somePanel, BorderLayout.NORTH );
Component otherPanel = getPanel( OTHER_PANEL );
if ( otherPanel != null ) content.add( otherPanel, BorderLayout.CENTER );
return content;
}
createGUIContent
in class ALcyGUIFactory<Component>
aProperties
- a properties object that can be used to tune the behavior of this factory.protected ILcdAction createAction(int aActionID, ALcyProperties aProperties)
ALcyGUIFactory
Creates an ILcdAction
for the given ID.
Note: if the action should be inserted in the configured action bars, the ID_KEY of the
returned action must be set (see TLcyActionBarUtil.ID_KEY
).
createAction
in class ALcyGUIFactory<Component>
aActionID
- the ID describing which action to create. This is normally a constant that
ends with ACTION
.aProperties
- a properties object that can be used to tune the behavior of this factory.ILcdAction
, or null
.ALcyGUIFactory.setup(com.luciad.lucy.util.properties.ALcyProperties)
protected Object getActionContext(int aActionID, ALcyProperties aProperties)
ALcyGUIFactory
Returns the context of the action bars in which the action with the specified ID should be inserted.
All actions are inserted in the action bars by TLcyActionBarUtil.insertInConfiguredActionBars(com.luciad.gui.ILcdAction,
Object, com.luciad.lucy.gui.TLcyActionBarManager, com.luciad.lucy.util.properties.ALcyProperties)
.
This method specifies the context for which the action with ID aActionID
is
inserted.
By default this method returns null
.
getActionContext
in class ALcyGUIFactory<Component>
aActionID
- the ID of the action.aProperties
- The properties. Can be used to tune the behavior of this factory.protected ILcyActiveSettable createActiveSettable(int aActiveSettableID, ALcyProperties aProperties)
ALcyGUIFactory
Creates an ILcyActiveSettable
for the given ID.
Note: if the active settable should be inserted in the configured action bars, the ID_KEY of
the returned active settable must be set (see TLcyActionBarUtil.ID_KEY
).
createActiveSettable
in class ALcyGUIFactory<Component>
aActiveSettableID
- the ID describing which active settable to create. This is normally a
constant that ends with ACTIVE_SETTABLE
.aProperties
- a properties object that can be used to tune the behavior of this
factory.ILcyActiveSettable
, or null
.protected Object getActiveSettableContext(int aActiveSettableID, ALcyProperties aProperties)
ALcyGUIFactory
Returns the context of the action bars in which the active settable with the specified ID should be inserted.
All active settables are inserted in the action bars by TLcyActionBarUtil#insertInConfiguredActionBars
. This method
specifies the context for which the active settable with ID aActiveSettableID
is
inserted.
By default this method returns null
.
getActiveSettableContext
in class ALcyGUIFactory<Component>
aActiveSettableID
- the ID of the active settableaProperties
- The properties. Can be used to tune the behavior of this factory.protected Component createComponent(int aComponentID, ALcyProperties aProperties)
ALcyGUIFactory
Creates a widget for the given ID. It is safe to use the ALcyGUIFactory.getAction(int)
and ALcyGUIFactory.getActiveSettable(int)
methods in this method, to build widgets that use an action or active
settable.
These widgets might interact with the given properties object, to retrieve or store some state. Such a widget could for example be a check box whose 'selected' state is synchronized with some property.
createComponent
in class ALcyGUIFactory<Component>
aComponentID
- the ID describing which component to create. This is normally a constant
that ends with COMPONENT
.aProperties
- a properties object that can be used to tune the behavior of this factory.
state.java.awt.Component
, or null.protected Component createPanel(int aPanelID, ALcyProperties aProperties)
ALcyGUIFactory
Creates a panel for the given ID. It is safe to use ALcyGUIFactory.getComponent(int)
in this method, to
build panels that are composed of components.
An example implementation could be:
protected Component createPanel( int aPanelID, ALcyProperties aProperties ) {
if ( aPanelID == SOME_PANEL ) {
JPanel content = new JPanel( new BorderLayout() );
Component someComponent = getComponent( SOME_COMPONENT );
if ( someComponent != null ) content.add( someComponent, BorderLayout.NORTH );
Component otherComponent = getComponent( OTHER_COMPONENT );
if ( otherComponent != null ) content.add( otherComponent, BorderLayout.CENTER );
return content;
}
else if ( aPanelID == ... ) {
...
}
}
createPanel
in class ALcyGUIFactory<Component>
aPanelID
- the ID describing which panel to create. This is normally a constant that
ends with PANEL
.aProperties
- a properties object that can be used to tune the behavior of this factory.java.awt.Component
, or null.protected TLcyToolBar createEmptyToolBar()
createEmptyToolBar(ALcyProperties)
insteadprotected TLcyToolBar createEmptyToolBar(ALcyProperties aProperties)
aProperties
- a properties object that can be used to tune the behavior of this factory.protected TLcyToolBar getToolBar()
createEmptyToolBar(ALcyProperties)
protected final String getPropertyPrefix()