org.pbjar.jxlayer.plaf.misc
Class GeneralLayerUI<V extends JComponent,S>

java.lang.Object
  extended by javax.swing.plaf.ComponentUI
      extended by org.jdesktop.jxlayer.plaf.LayerUI<V>
          extended by org.jdesktop.jxlayer.plaf.AbstractLayerUI<V>
              extended by org.pbjar.jxlayer.plaf.misc.GeneralLayerUI<V,S>
Type Parameters:
V - JXLayer's view
S - A state object
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
AbstractTransparentMouseUI, HideCursorUI, MagnifierUI, MouseDrawingUI

public class GeneralLayerUI<V extends JComponent,S>
extends org.jdesktop.jxlayer.plaf.AbstractLayerUI<V>

A generalized implementation of LayerUI.

Some additional functionality:

  1. It facilitates the use of a state object for LayerUIs that are intended for shared use.
  2. It supplies Actions that can be used for the controls of a GUI.
  3. It re-dispatches MouseWheelEvents to the first component up in the hierarchy from the originating component that has a MouseWheelListener registered.
  4. Via the constructor one can enable AWTEventListener.

Author:
Piet Blok
See Also:
Serialized Form

Constructor Summary
GeneralLayerUI()
           
 
Method Summary
protected  void cleanupStateObject(S stateObject)
          Cleanup the state object.
protected  S createStateObject(org.jdesktop.jxlayer.JXLayer<? extends V> layer)
          Create a StateObject specific for this LayerUI and the JXLayer argument.
 List<Action> getActions()
          Get actions that are applicable to this LayerUI.
 List<Action> getActions(org.jdesktop.jxlayer.JXLayer<? extends V> layer)
          Get actions that are applicable to this LayerUI and a specific JXLayer.
 String getName()
          Returns the simple class name.
protected  S getStateObject(org.jdesktop.jxlayer.JXLayer<? extends V> layer)
          Get the created StateObject specific to the JXLayer argument.
 void installUI(JComponent c)
          Invokes super.installUI.
protected  void processMouseWheelEvent(MouseWheelEvent event, org.jdesktop.jxlayer.JXLayer<? extends V> jxlayer)
          Re-dispatches the event to the first component in the hierarchy that has a MouseWheelEventListener registered.
 void uninstallUI(JComponent c)
          Invokes super.uninstallUI.
 
Methods inherited from class org.jdesktop.jxlayer.plaf.AbstractLayerUI
configureGraphics, eventDispatched, getClip, getComposite, getLayerEventMask, getRenderingHints, getTransform, handlePropertyChangeEvent, isDirty, paint, paintLayer, processFocusEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, setDirty
 
Methods inherited from class org.jdesktop.jxlayer.plaf.LayerUI
addPropertyChangeListener, addPropertyChangeListener, contains, firePropertyChange, getPreferredScrollableViewportSize, getPropertyChangeListeners, getPropertyChangeListeners, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, removePropertyChangeListener, removePropertyChangeListener, updateUI
 
Methods inherited from class javax.swing.plaf.ComponentUI
createUI, getAccessibleChild, getAccessibleChildrenCount, getBaseline, getBaselineResizeBehavior, getMaximumSize, getMinimumSize, getPreferredSize, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GeneralLayerUI

public GeneralLayerUI()
Method Detail

getActions

public List<Action> getActions()
Get actions that are applicable to this LayerUI. This implementation returns an enable/disable action for this LayerUI

Returns:
a list of applicable actions

getActions

public List<Action> getActions(org.jdesktop.jxlayer.JXLayer<? extends V> layer)
Get actions that are applicable to this LayerUI and a specific JXLayer. This implementation returns an empty list

Parameters:
layer - the JXLayer
Returns:
a list of applicable actions

getName

public String getName()
Returns the simple class name.

Returns:
a name

installUI

public void installUI(JComponent c)
Invokes super.installUI. Then invokes createStateObject. User installation actions may be coded in createStateObject.

Overrides:
installUI in class org.jdesktop.jxlayer.plaf.AbstractLayerUI<V extends JComponent>

uninstallUI

public void uninstallUI(JComponent c)
Invokes super.uninstallUI. If a state object is available, the method GeneralLayerUI#cleanupStateObject(Object) is invoked to cleanup the state object.

Overrides:
uninstallUI in class org.jdesktop.jxlayer.plaf.AbstractLayerUI<V extends JComponent>

cleanupStateObject

protected void cleanupStateObject(S stateObject)
Cleanup the state object. The default implementation does nothing.

Parameters:
stateObject - a state object

createStateObject

protected S createStateObject(org.jdesktop.jxlayer.JXLayer<? extends V> layer)
Create a StateObject specific for this LayerUI and the JXLayer argument. The default implementation returns null.

Parameters:
layer - the JXLayer
Returns:
a StateObject or null, if no state is maintained.

getStateObject

protected final S getStateObject(org.jdesktop.jxlayer.JXLayer<? extends V> layer)
Get the created StateObject specific to the JXLayer argument.

Parameters:
layer - the JXLayer
Returns:
the StateObject or null, if createStateObject(JXLayer) returned null

processMouseWheelEvent

protected void processMouseWheelEvent(MouseWheelEvent event,
                                      org.jdesktop.jxlayer.JXLayer<? extends V> jxlayer)
Re-dispatches the event to the first component in the hierarchy that has a MouseWheelEventListener registered.

Overrides:
processMouseWheelEvent in class org.jdesktop.jxlayer.plaf.AbstractLayerUI<V extends JComponent>