public class TLcyKML22GUIFactory extends ALcyGUIFactory<Component>
The main GUI Factory for the TLcyKML22AddOn
. This GUI Factory creates the panel
for the KML content tree. This factory was designed so that it is
easy to modify small parts of the creation process. This can be done by subclassing this class and
overriding certain methods. The TLcyKML22GUIFactory
creates the following for the KML model
content tree:
It uses the concept of an ALcyGUIFactory
, allowing the users
of this class to modify almost every part of the creation process.
The created tree makes use of TLcyKML22TreeModelObject as its domain object.
TLcyKML22TreeModelObject
Modifier and Type | Field and Description |
---|---|
static int |
CENTER_PANEL
The ID for the panel of the KML content tree, used by the createPanel(int, com.luciad.lucy.util.properties.ALcyProperties) method.
|
static String |
MAP_COMPONENT_KEY
A constant that is used to retrieve a map component from a
ALcyProperties instance. |
static int |
MODEL_CONTENT_TREE
The ID for KML content tree, used by the createTree(int,
com.luciad.lucy.util.properties.ALcyProperties) method.
|
static int |
MODEL_CONTENT_TREE_CELL_RENDERER
The ID for the cell renderer of the KML content tree, used by the createTreeCellRenderer(int, com.luciad.lucy.util.properties.ALcyProperties)
method.
|
static int |
MODEL_CONTENT_TREE_MODEL
The ID for the model of the KML content tree, used by the createTreeModel(int, ALcyProperties) method.
|
Constructor and Description |
---|
TLcyKML22GUIFactory(ILcyLucyEnv aLucyEnv)
Creates a new GUI factory with the given parameters.
|
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 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 JTree |
createTree(int aTreeID,
ALcyProperties aProperties)
Creates the tree corresponding to the ID
aTreeID . |
protected TreeCellRenderer |
createTreeCellRenderer(int aTreeCellRendererID,
ALcyProperties aProperties)
Creates the tree cell renderer corresponding to the ID
aTreeCellRendererID . |
protected TreeModel |
createTreeModel(int aTreeModelID,
ALcyProperties aProperties)
Creates the tree model corresponding to the ID
aTreeModelID . |
protected JTree |
getTree(int aTreeID)
Returns the
JTree for the given ID. |
protected TreeCellRenderer |
getTreeCellRenderer(int aTreeCellRendererID)
Returns the
TreeCellRenderer for the given ID. |
ILcdIntList |
getTreeCellRendererIDs()
Returns the tree cell renderer ID of the model content tree.
|
ILcdIntList |
getTreeIDs()
Returns the tree ID of the model content tree.
|
protected TreeModel |
getTreeModel(int aTreeModelID)
Returns the
TreeModel for the given ID. |
ILcdIntList |
getTreeModelIDs()
Returns the tree model ID of the model content tree.
|
protected void |
setup(ALcyProperties aProperties)
Sets up the KML content tree based on the given parameters.
|
createGUI, getAction, getActionContext, getActionIDs, getActiveSettable, getActiveSettableContext, getActiveSettableIDs, getComponent, getComponentIDs, getLucyEnv, getPanel, getPanelIDs, isActiveSettableDeactivatePossible
public static final String MAP_COMPONENT_KEY
A constant that is used to retrieve a map component from a ALcyProperties
instance. This
constant is used by the getMapComponent(ALcyProperties aProperties) method to retrieve
a map component from its given property object.
The ALcyProperties
instance passed to this factory will contain the map component for which
the model content tree must be created. This key can be used to retrieve that map component.
The corresponding value may be null
public static final int MODEL_CONTENT_TREE
public static final int MODEL_CONTENT_TREE_MODEL
The ID for the model of the KML content tree, used by the createTreeModel(int, ALcyProperties) method.
The model is completely self-sufficient in the sense that it keeps itself up to date based on ILcdLayered
events and ILcdModel
events. The TreeModel
makes exclusive use of TLcyKML22TreeModelObject
instances to model its children. A TLcyKML22TreeModelObject
contains the following:
TLcdKML22DynamicModel
in the case of containers)Only the root element contains null for all of the above
public static final int MODEL_CONTENT_TREE_CELL_RENDERER
The ID for the cell renderer of the KML content tree, used by the createTreeCellRenderer(int, com.luciad.lucy.util.properties.ALcyProperties) method.
The tree cell renderer expects its objects to be instances of TLcyKML22TreeModelObject
. It will
create check-boxes to manipulate the visibility of an element. It will also create an icon, a name and a description
for each element.
public static final int CENTER_PANEL
The ID for the panel of the KML content tree, used by the createPanel(int, com.luciad.lucy.util.properties.ALcyProperties) method.
The panel is a JPanel
with a JScrollPane
and the tree, obtained by calling
the createTree(int, com.luciad.lucy.util.properties.ALcyProperties) method with the MODEL_CONTENT_TREE
ID.
public TLcyKML22GUIFactory(ILcyLucyEnv aLucyEnv)
Creates a new GUI factory with the given parameters. This default constructor builds all actions, component and panels.
aLucyEnv
- an instance of ILcyLucyEnvprotected void setup(ALcyProperties aProperties)
Sets up the KML content tree based on the given parameters. The model content tree will be set up in the following order:
JTree
itself.setup
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 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 JTree createTree(int aTreeID, ALcyProperties aProperties)
aTreeID
. May return null
.aTreeID
- the ID of the tree. This is typically a constant ending in
TREE
.aProperties
- a properties object that can be used to tune the behavior of this factory.aTreeID
. May be null
.protected TreeModel createTreeModel(int aTreeModelID, ALcyProperties aProperties)
aTreeModelID
. May return
null
.aTreeModelID
- the ID of the tree model. This is typically a constant ending in
TREE_MODEL
.aProperties
- a properties object that can be used to tune the behavior of this factory.aTreeModelID
. May be
null
.protected TreeCellRenderer createTreeCellRenderer(int aTreeCellRendererID, ALcyProperties aProperties)
aTreeCellRendererID
. May
return null
.aTreeCellRendererID
- the ID of the tree cell renderer. This is typically a constant
ending in TREE_CELL_RENDERER
.aProperties
- a properties object that can be used to tune the behavior of this
factory.aTreeCellRendererID
. May be
null
.public ILcdIntList getTreeIDs()
public ILcdIntList getTreeModelIDs()
public ILcdIntList getTreeCellRendererIDs()
protected TreeModel getTreeModel(int aTreeModelID)
Returns the TreeModel
for the given ID.
Please refer to setup
to know
when this method can be used.
aTreeModelID
- the id describing which TreeModel
to return. This is usually a
constant that ends in TREE_MODEL
.TreeModel
for the given ID.protected TreeCellRenderer getTreeCellRenderer(int aTreeCellRendererID)
Returns the TreeCellRenderer
for the given ID.
Please refer to setup
to know
when this method can be used.
aTreeCellRendererID
- the id describing which TreeCellRenderer
to return.
This is normally a constant that ends in TREE_CELL_RENDERER
.TreeCellRenderer
for the given ID.protected JTree getTree(int aTreeID)
Returns the JTree
for the given ID.
Please refer to setup
to know
when this method can be used.
aTreeID
- the id describing which JTree
to return. This is normally a
constant that ends in TREE
.JTree
for the given ID.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 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 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 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.