public abstract class ALcyFormatBar extends Object implements ILcdPropertyChangeSource
(Swing) component that can be displayed to manipulate a layer of a given format. Manipulation can be anything. A typical use could be to have buttons to start drawing new domain objects into (the model of) the layer.
For an example use of these bars, please refer to the TLcyFormatBarAddOn
.
Modifier and Type | Field and Description |
---|---|
static String |
LONG_DESCRIPTION
The key representing the long description of a format bar.
|
static String |
NAME
Constant key for Name property.
|
static String |
SHORT_DESCRIPTION
The key representing the short description of a format bar.
|
static String |
SMALL_ICON
The key representing the icon value of an application pane.
|
Modifier | Constructor and Description |
---|---|
protected |
ALcyFormatBar()
Creates a new format bar named "Toolbar"
|
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(PropertyChangeListener aListener)
Registers the given
PropertyChangeListener to be notified when this object's
properties change. |
void |
addPropertyChangeListener(String aProperty,
PropertyChangeListener aListener)
Adds the given listener to the list of listeners, so that it will receive notifications about
changes in
aProperty . |
abstract boolean |
canSetLayer(ILcdLayer aLayer)
Returns
true if the layer can be accepted, false otherwise. |
protected void |
firePropertyChange(String aProperty,
Object aOldValue,
Object aNewValue)
Fires the given event to the associated listeners.
|
abstract Component |
getComponent()
Returns the (Swing) component that can be displayed to the end-user.
|
ILcdLayer |
getLayer()
Returns the associated layer.
|
Object |
getValue(String aKey)
Gets one of this object's properties using the associated key.
|
void |
putValue(String aKey,
Object aValue)
Sets one of this object's properties using the associated key.
|
void |
removePropertyChangeListener(PropertyChangeListener aListener)
De-registers the given
PropertyChangeListener from receiving property change events
for this object. |
void |
removePropertyChangeListener(String aProperty,
PropertyChangeListener aListener)
Removes the given listener for the given property, so that it no longer receives those change
events.
|
void |
setLayer(ILcdLayer aLayer)
Sets the layer to the given layer.
|
protected abstract void |
updateForLayer(ILcdLayer aPreviousLayer,
ILcdLayer aLayer)
Called by
setLayer(com.luciad.view.ILcdLayer) when a new layer is set. |
public static final String NAME
String
.public static final String SMALL_ICON
ILcdIcon
.public static final String SHORT_DESCRIPTION
String
.public static final String LONG_DESCRIPTION
String
.public void addPropertyChangeListener(PropertyChangeListener aListener)
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
aListener
- The listener to be notifiedALcdWeakPropertyChangeListener
,
ILcdPropertyChangeSource.removePropertyChangeListener(java.beans.PropertyChangeListener)
public void addPropertyChangeListener(String aProperty, PropertyChangeListener aListener)
aProperty
.aProperty
- The property to watch for changes.aListener
- The listener to add.public void removePropertyChangeListener(PropertyChangeListener aListener)
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
aListener
- the listener that should no longer be notified of changes of
this object's propertiesILcdPropertyChangeSource.addPropertyChangeListener(java.beans.PropertyChangeListener)
public void removePropertyChangeListener(String aProperty, PropertyChangeListener aListener)
aProperty
- The property to stop listening to.aListener
- The listener to remove.public void putValue(String aKey, Object aValue)
Sets one of this object's properties using the associated key. The keys are defined by
the constants in the class, for example SMALL_ICON
.
Implementations of this interface can use these properties to show them in their user
interface. For instance the icon set with the SMALL_ICON key could be shown in the tab of a
tabbed pane.
The type of the value is specified by the key. For instance, the key SMALL_ICON
demands that the value is an ILcdIcon
.
If the value has changed, a PropertyChangeEvent
is sent to listeners with
aKey
as the property name.
aKey
- a String
representing the key. This must not be null
,
but can otherwise be any String
, ie. it is not restricted to being
one of SMALL_ICON
, SHORT_DESCRIPTION
or
LONG_DESCRIPTION
.aValue
- an Object
value. This may be null
.getValue(String)
public Object getValue(String aKey)
aKey
- the String
of the key for which you want to retrieve the value. This
can be any String
, ie. it is not restricted to being one of
SMALL_ICON, SHORT_DESCRIPTION or LONG_DESCRIPTION.Object
value corresponding to aKey
, or null
if no value corresponding to aKey
could be found. The type of this value
is determined by the key. For instance, the SMALL_ICON
key specifies that
the returned value is an ILcdIcon
.putValue(String, Object)
protected void firePropertyChange(String aProperty, Object aOldValue, Object aNewValue)
aProperty
- The property that was changed.aOldValue
- The old value.aNewValue
- The new value.public ILcdLayer getLayer()
public void setLayer(ILcdLayer aLayer)
updateForLayer(com.luciad.view.ILcdLayer, com.luciad.view.ILcdLayer)
so that
sub-classes can update their representation for the new layer.aLayer
- The layer to manipulate. Can be null
, which indicates a (temporary)
de-initialization.IllegalArgumentException
- If canSetLayer(com.luciad.view.ILcdLayer)
returns
false
for the same layer.protected abstract void updateForLayer(ILcdLayer aPreviousLayer, ILcdLayer aLayer)
setLayer(com.luciad.view.ILcdLayer)
when a new layer is set.aPreviousLayer
- The previously set layer. Can be null
. This parameter can
for example be useful to remove listeners from it.aLayer
- The new layer, to update this bar for. Can be null
.public abstract boolean canSetLayer(ILcdLayer aLayer)
Returns true
if the layer can be accepted, false
otherwise.
A typical implementation would verify that only the layers of its own format are accepted.
Another implementation could be to only accept one specific layer instance, so that the
ALcyFormatBar
cannot be reused for other layer instances of the same type, which
might simplify the implementation of this ALcyFormatBar
.
aLayer
- The layer to test.true
if the layer can be accepted, false
otherwise.
null
must be accepted as this indicates a (temporary) de-initialization.public abstract Component getComponent()