|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavax.swing.plaf.ComponentUI
org.jdesktop.jxlayer.plaf.LayerUI<V>
org.jdesktop.jxlayer.plaf.AbstractLayerUI<V>
public class AbstractLayerUI<V extends javax.swing.JComponent>
The AbstractLayerUI provided default implementation for most
of the abstract methods in the LayerUI class.
It takes care of the management of LayerItemListeners and
defines the hook method to configure the Graphics2D instance
specified in the paint(Graphics,JComponent) method.
It also provides convenient methods named
process<eventType>Event to process the given class of event.
AbstractLayerUI is changed, call setDirty(boolean)
with true as the parameter, it will repaint all JXLayers
connected with this AbstractLayerUI
JXLayer.setUI(LayerUI)| Constructor Summary | |
|---|---|
AbstractLayerUI()
|
|
| Method Summary | |
|---|---|
void |
addLayerItemListener(LayerItemListener l)
Adds a LayerItemListener to the layer item. |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list. |
void |
addPropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list for a specific property. |
protected void |
configureGraphics(java.awt.Graphics2D g2,
JXLayer<V> l)
This method is called by the paint(java.awt.Graphics, javax.swing.JComponent) method prior to
any drawing operations to configure the Graphics2D object. |
void |
eventDispatched(java.awt.AWTEvent e,
JXLayer<V> l)
Dispatches all input and focus events from the JXLayer
and all it subcomponents to this LayerUI,
when LayerItem.isEnabled() returns true.
This method calls the appropriate
process<eventType>Event
method for the given class of event. |
protected void |
fireLayerItemChanged()
Notifies all LayerItemListeners that
have been added to this object. |
protected void |
fireLayerItemChanged(LayerItemChangeEvent event)
Notifies all LayerItemListeners that
have been added to this object. |
protected void |
firePropertyChange(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue)
Support for reporting bound property changes for Object properties. |
protected java.awt.Shape |
getClip(JXLayer<V> l)
Returns the Shape to be used as the clip during painting of this JXLayer,
the default implementation returns null. |
protected java.awt.Composite |
getComposite(JXLayer<V> l)
Returns the Composite to be used during painting of this JXLayer,
the default implementation returns null. |
long |
getLayerEventMask()
Returns the bitmap of event mask to receive by this LayerUI
and all its JXLayers
It means that LayerUI.eventDispatched(AWTEvent, JXLayer) method
will only receive events that match the event mask.
By default only mouse, mouse motion, mouse wheel, keyboard and focus events are supported,
all other events included in the eventMask will be ignored. |
LayerItemListener[] |
getLayerItemListeners()
Returns an array of all the LayerItemListeners
registered on this LayerItem. |
java.beans.PropertyChangeListener[] |
getPropertyChangeListeners()
Returns an array of all the property change listeners registered on this component. |
java.beans.PropertyChangeListener[] |
getPropertyChangeListeners(java.lang.String propertyName)
Returns an array of all the listeners which have been associated with the named property. |
protected java.util.Map<java.awt.RenderingHints.Key,java.lang.Object> |
getRenderingHints(JXLayer<V> l)
Returns the map of rendering hints to be used during painting of this JXLayer,
the default implementation returns the empty unmodifiable map. |
protected java.awt.geom.AffineTransform |
getTransform(JXLayer<V> l)
Returns the AffineTransform to be used during painting of this JXLayer,
the default implementation returns null. |
void |
installUI(javax.swing.JComponent c)
Configures the specified JXLayer appropriate for this AbstractLayerUI. |
protected boolean |
isAWTEventListenerEnabled()
Returns true if this AbstractLayerUI catches AWT events
with help of AWTEventListener,
in this case registerAWTEventListener(JXLayer, long)
will be called from installUI(JComponent)
with getLayerEventMask() as the second parameter
and unregisterAWTEventListener(JXLayer)
will be called from uninstallUI(JComponent)
If this method is overridden to return true
don't forget to override getAWTEventListenerEventMask()
The default implementation returns false |
protected boolean |
isDirty()
Returns the "dirty bit". |
boolean |
isEnabled()
Indicates if this LayerItem is in active state.
AbstractLayerUI is enabled initially by default. |
void |
paint(java.awt.Graphics g,
javax.swing.JComponent c)
Paints the specified component. Note: It is rarely necessary to override this method, for custom painting override paintLayer(Graphics2D,JXLayer) instead
This method configures the passed Graphics with help of the
configureGraphics(Graphics2D,JXLayer) method,
then calls paintLayer(Graphics2D,JXLayer)
and resets the "dirty bit" at the end. |
protected void |
paintLayer(java.awt.Graphics2D g2,
JXLayer<V> l)
Subclasses should implement this method and perform custom painting operations here. |
protected void |
processFocusEvent(java.awt.event.FocusEvent e,
JXLayer<V> l)
Processes FocusEvent occurring on the JXLayer
or any of its subcomponents. |
protected void |
processKeyEvent(java.awt.event.KeyEvent e,
JXLayer<V> l)
Processes KeyEvent occurring on the JXLayer
or any of its subcomponents. |
protected void |
processMouseEvent(java.awt.event.MouseEvent e,
JXLayer<V> l)
Processes MouseEvent occurring on the JXLayer
or any of its subcomponents. |
protected void |
processMouseMotionEvent(java.awt.event.MouseEvent e,
JXLayer<V> l)
Processes mouse motion events occurring on the JXLayer
or any of its subcomponents. |
protected void |
processMouseWheelEvent(java.awt.event.MouseWheelEvent e,
JXLayer<V> l)
Processes MouseWheelEvent occurring on the JXLayer
or any of its subcomponents. |
protected void |
registerAWTEventListener(JXLayer<V> l,
long eventMask)
This is an alternative implementation of catching JXLayer's events. |
void |
removeLayerItemListener(LayerItemListener l)
Removes a LayerItemListener from this LayerItem. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a PropertyChangeListener from the listener list. |
void |
removePropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
Removes a PropertyChangeListener from the listener
list for a specific property. |
protected void |
setDirty(boolean isDirty)
Sets the "dirty bit". |
void |
setEnabled(boolean enabled)
Enables or disables this component, depending on the value of the parameter enabled. |
void |
setLayerEventMask(long layerEventMask)
Sets the eventMask for this AbstractLayerUI
and all its JXLayers
It means that eventDispatched(AWTEvent, JXLayer) method
will only receive events that match the event mask. |
void |
uninstallUI(javax.swing.JComponent c)
Reverses configuration which was done on the specified component during installUI(JComponent). |
protected void |
unregisterAWTEventListener(JXLayer<V> l)
Unregister an event listener which was previously set by registerAWTEventListener(JXLayer, long)
and also enables back the proxy InputContext of the passed JXLayer. |
| Methods inherited from class org.jdesktop.jxlayer.plaf.LayerUI |
|---|
getAccessibleChild, getAccessibleChildrenCount, getPreferredScrollableViewportSize, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, isEventEnabled, update, updateUI |
| Methods inherited from class javax.swing.plaf.ComponentUI |
|---|
contains, createUI, getMaximumSize, getMinimumSize, getPreferredSize |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AbstractLayerUI()
| Method Detail |
|---|
public void installUI(javax.swing.JComponent c)
JXLayer appropriate for this AbstractLayerUI.
This method is invoked when the LayerUI instance is being installed
as the UI delegate on the specified JXLayer.
Subclasses can install any listeners to the passed JXLayer,
configure its glassPane or do any other setting up.
The default implementation registers the passed JXLayer
as a LayerItemListener for this AbstractLayerUI.
Note: Subclasses can safely cast the passed component
to the JXLayer<V>
installUI in class javax.swing.plaf.ComponentUIc - the JXLayer where this UI delegate is being installeduninstallUI(JComponent)public void uninstallUI(javax.swing.JComponent c)
installUI(JComponent). This method is invoked when this
LayerUI instance is being removed as the UI delegate
for the specified JXLayer.
uninstallUI(JComponent) should undo the
configuration performed in installUI(JComponent), being careful to
leave the JXLayer instance in a clean state
(e.g. all previously set listeners must be removed in this method).
The default implementation removes the passed JXLayer
from the LayerItemListener's list of this AbstractLayerUI.
Note: Subclasses can safely cast the passed component
to the JXLayer<V>
uninstallUI in class javax.swing.plaf.ComponentUIc - the JXLayer where this UI delegate is being installedinstallUI(JComponent)
protected void registerAWTEventListener(JXLayer<V> l,
long eventMask)
checkPermission
method is called with an
AWTPermission("listenToAllAWTEvents") permission.
This may result in a SecurityException.
eventMask is a bitmask of event types to receive.
It is constructed by bitwise OR-ing together the event masks
defined in AWTEvent.
For example, the following mask includes all mouse events:
AWTEvent.MOUSE_EVENT_MASK |
AWTEvent.MOUSE_MOTION_EVENT_MASK |
AWTEvent.MOUSE_WHEEL_EVENT_MASK
It is guaranteed that this eventDispatched(AWTEvent, JXLayer)
will be notified of any event inside layer's hierarchy that matched with the eventMask
A specific AWTEventListener's implementation may also pass some events
that don't match with the eventMask, but you shouldn't rely on it.
Note: It is unlikely that you will ever need to manually call this method,
if you need to enable the AWTEventListener, just override isAWTEventListenerEnabled()
together with getLayerEventMask().
For more informaiton please see
JXLayer 3.0 - Event handling
l - the JXLayer to listen events foreventMask - the bitmask of event types to receiveisAWTEventListenerEnabled(),
getLayerEventMask(),
unregisterAWTEventListener(JXLayer)protected void unregisterAWTEventListener(JXLayer<V> l)
registerAWTEventListener(JXLayer, long)
and also enables back the proxy InputContext of the passed JXLayer.
Note: If you call (JXLayer, long)
from the installUI(), you must call this method in the
uninstallUI(JComponent) to release resources.
Note: It is unlikely that you will ever need to manually call this method,
if you need to enable the AWTEventListener, just override isAWTEventListenerEnabled()
together with getLayerEventMask().
l - the JXLayer to unregister the listener forregisterAWTEventListener(JXLayer, long)protected boolean isAWTEventListenerEnabled()
true if this AbstractLayerUI catches AWT events
with help of AWTEventListener,
in this case registerAWTEventListener(JXLayer, long)
will be called from installUI(JComponent)
with getLayerEventMask() as the second parameter
and unregisterAWTEventListener(JXLayer)
will be called from uninstallUI(JComponent)
If this method is overridden to return true
don't forget to override getAWTEventListenerEventMask()
The default implementation returns false
true if this AbstractLayerUI catches AWT events
with help of AWTEventListener(),
registerAWTEventListener(JXLayer, long)public long getLayerEventMask()
LayerUI
and all its JXLayers
It means that LayerUI.eventDispatched(AWTEvent, JXLayer) method
will only receive events that match the event mask. By default the mask
includes mouse, mouse motion, mouse wheel, keyboard and focus events.
By default only mouse, mouse motion, mouse wheel, keyboard and focus events are supported,
all other events included in the eventMask will be ignored.
To enable the rest of the events, like HierarchyEvents
you should override isAWTEventListenerEnabled() to return true.
getLayerEventMask in class LayerUI<V extends javax.swing.JComponent>LayerUIsetLayerEventMask(long),
isAWTEventListenerEnabled()public void setLayerEventMask(long layerEventMask)
AbstractLayerUI
and all its JXLayers
It means that eventDispatched(AWTEvent, JXLayer) method
will only receive events that match the event mask.
//Call from the ui's constructor to receive only keyboard and focus events:
setLayerEventMask(AWTEvent.KEY_EVENT_MASK | AWTEvent.FOCUS_EVENT_MASK);
By default only mouse, mouse motion, mouse wheel, keyboard and focus events are supported,
all other events included in the eventMask will be ignored.
To enable the rest of the events, like HierarchyEvents
you should override isAWTEventListenerEnabled() to return true.
layerEventMask - the bitmask of event types to receivegetLayerEventMask()public void addLayerItemListener(LayerItemListener l)
LayerItemListener to the layer item.
l - the listener to addpublic LayerItemListener[] getLayerItemListeners()
LayerItemListeners
registered on this LayerItem.
LayerItemListeners
or an empty array if no item listeners are currently registeredpublic void removeLayerItemListener(LayerItemListener l)
LayerItemListener from this LayerItem.
l - the listener to removeprotected void fireLayerItemChanged()
LayerItemListeners that
have been added to this object.
addLayerItemListener(LayerItemListener)protected void fireLayerItemChanged(LayerItemChangeEvent event)
LayerItemListeners that
have been added to this object.
event - the LayerItemChangeEventaddLayerItemListener(LayerItemListener)public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
listener is null,
no exception is thrown and no action is performed.
listener - the property change listener to be addedremovePropertyChangeListener(java.beans.PropertyChangeListener),
getPropertyChangeListeners(),
addPropertyChangeListener(String, PropertyChangeListener)public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
If listener is null, no exception is thrown and no action is performed.
listener - the PropertyChangeListener to be removedaddPropertyChangeListener(java.beans.PropertyChangeListener),
getPropertyChangeListeners(),
removePropertyChangeListener(String, PropertyChangeListener)public java.beans.PropertyChangeListener[] getPropertyChangeListeners()
PropertyChangeListeners
or an empty array if no property change
listeners are currently registeredaddPropertyChangeListener(java.beans.PropertyChangeListener),
removePropertyChangeListener(java.beans.PropertyChangeListener),
getPropertyChangeListeners(String)
public void addPropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
If propertyName or listener is null,
no exception is thrown and no action is taken.
propertyName - one of the property names listed abovelistener - the property change listener to be addedremovePropertyChangeListener(String, PropertyChangeListener),
getPropertyChangeListeners(String),
addPropertyChangeListener(String, PropertyChangeListener)
public void removePropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
PropertyChangeListener from the listener
list for a specific property. This method should be used to remove
PropertyChangeListeners
that were registered for a specific bound property.
If propertyName or listener is null,
no exception is thrown and no action is taken.
propertyName - a valid property namelistener - the PropertyChangeListener to be removedaddPropertyChangeListener(String, PropertyChangeListener),
getPropertyChangeListeners(String),
removePropertyChangeListener(PropertyChangeListener)public java.beans.PropertyChangeListener[] getPropertyChangeListeners(java.lang.String propertyName)
PropertyChangeListeners associated with
the named property; if no such listeners have been added or
if propertyName is null, an empty
array is returnedaddPropertyChangeListener(String, PropertyChangeListener),
removePropertyChangeListener(String, PropertyChangeListener),
getPropertyChangeListeners()
protected void firePropertyChange(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue)
propertyName - the property whose value has changedoldValue - the property's previous valuenewValue - the property's new valuepublic boolean isEnabled()
LayerItem is in active state.
AbstractLayerUI is enabled initially by default.
true if this LayerItem is in active statepublic void setEnabled(boolean enabled)
enabled. An enabled LayerUI paints
the JXLayers components they are set to and receives
their input and focuse events.
AbstractLayerUI is enabled initially by default.
enabled - If true, this AbstractLayerUI is
enabled; otherwise this AbstractLayerUI is disabledprotected boolean isDirty()
true, then the AbstractLayerUI is considered dirty
and in need of being repainted.
true if the AbstractLayerUI state has changed
and the JXLayers it is set to need to be repainted.protected void setDirty(boolean isDirty)
isDirty is true, then the AbstractLayerUI
is considered dirty and it triggers the repainting
of the JXLayers this AbstractLayerUI it is set to.
isDirty - whether this AbstractLayerUI is dirty or not.
public void paint(java.awt.Graphics g,
javax.swing.JComponent c)
Graphics object to
render the content of the component.
Note: Subclasses can safely cast the passed component
to the JXLayer<V> Graphics
to the Graphics2D instance.
Note: It is rarely necessary to override this method, for
custom painting override paintLayer(Graphics2D,JXLayer) instead
This method configures the passed Graphics with help of the
configureGraphics(Graphics2D,JXLayer) method,
then calls paintLayer(Graphics2D,JXLayer)
and resets the "dirty bit" at the end.
paint in class LayerUI<V extends javax.swing.JComponent>g - the Graphics context in which to paint;
this object can be safely cast to the Graphics2D instance.c - the component being painted;
it can be safely cast to the JXLayer<V>configureGraphics(Graphics2D,JXLayer),
paintLayer(Graphics2D,JXLayer),
setDirty(boolean)
protected void paintLayer(java.awt.Graphics2D g2,
JXLayer<V> l)
JXLayer as is.
g2 - the Graphics2D context in which to paintl - the JXLayer being painted
protected void configureGraphics(java.awt.Graphics2D g2,
JXLayer<V> l)
paint(java.awt.Graphics, javax.swing.JComponent) method prior to
any drawing operations to configure the Graphics2D object.
The default implementation sets the Composite, the clip,
AffineTransform and rendering hints
obtained from the corresponding hook methods.
g2 - the Graphics2D object to configurel - the JXLayer being paintedgetComposite(JXLayer),
getClip(JXLayer),
getTransform(JXLayer),
getRenderingHints(JXLayer)protected java.awt.Composite getComposite(JXLayer<V> l)
Composite to be used during painting of this JXLayer,
the default implementation returns null.
l - the JXLayer being painted
Composite to be used during painting for the JXLayerprotected java.awt.geom.AffineTransform getTransform(JXLayer<V> l)
AffineTransform to be used during painting of this JXLayer,
the default implementation returns null.
l - the JXLayer being painted
AffineTransform to be used during painting of the JXLayerprotected java.awt.Shape getClip(JXLayer<V> l)
Shape to be used as the clip during painting of this JXLayer,
the default implementation returns null.
l - the JXLayer being painted
Shape to be used as the clip during painting of the JXLayerprotected java.util.Map<java.awt.RenderingHints.Key,java.lang.Object> getRenderingHints(JXLayer<V> l)
JXLayer,
the default implementation returns the empty unmodifiable map.
l - the JXLayer being painted
JXLayer
public void eventDispatched(java.awt.AWTEvent e,
JXLayer<V> l)
JXLayer
and all it subcomponents to this LayerUI,
when LayerItem.isEnabled() returns true.
This method calls the appropriate
process<eventType>Event
method for the given class of event.
eventDispatched in class LayerUI<V extends javax.swing.JComponent>e - the event to be dispatchedl - the layer this LayerUI is set to
protected void processFocusEvent(java.awt.event.FocusEvent e,
JXLayer<V> l)
FocusEvent occurring on the JXLayer
or any of its subcomponents.
e - the FocusEvent to be processedl - the layer this LayerUI is set to
protected void processMouseEvent(java.awt.event.MouseEvent e,
JXLayer<V> l)
MouseEvent occurring on the JXLayer
or any of its subcomponents.
e - the MouseEvent to be processedl - the layer this LayerUI is set to
protected void processMouseMotionEvent(java.awt.event.MouseEvent e,
JXLayer<V> l)
JXLayer
or any of its subcomponents.
e - the MouseEvent to be processedl - the layer this LayerUI is set to
protected void processMouseWheelEvent(java.awt.event.MouseWheelEvent e,
JXLayer<V> l)
MouseWheelEvent occurring on the JXLayer
or any of its subcomponents.
e - the MouseWheelEvent to be processedl - the layer this LayerUI is set to
protected void processKeyEvent(java.awt.event.KeyEvent e,
JXLayer<V> l)
KeyEvent occurring on the JXLayer
or any of its subcomponents.
e - the KeyEvent to be processedl - the layer this LayerUI is set to
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||