org.jdesktop.jxlayer.plaf
Class AbstractLayerUI<V extends javax.swing.JComponent>

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>
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
AbstractBufferedLayerUI, ButtonPanelUI, MouseScrollableUI

public class AbstractLayerUI<V extends javax.swing.JComponent>
extends LayerUI<V>

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.

If state of the AbstractLayerUI is changed, call setDirty(boolean) with true as the parameter, it will repaint all JXLayers connected with this AbstractLayerUI

See Also:
JXLayer.setUI(LayerUI), Serialized Form

Constructor Summary
AbstractLayerUI()
           
 
Method Summary
protected  void configureGraphics(java.awt.Graphics2D g2, JXLayer<? extends 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<? extends V> l)
          Dispatches AWTEvents for JXLayer and all it subcomponents to this LayerUI.

This method calls the appropriate process<eventType>Event method for the given class of event.

protected  java.awt.Shape getClip(JXLayer<? extends 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<? extends V> l)
          Returns the Composite to be used during painting of this JXLayer, the default implementation returns null.
 long getLayerEventMask()
          By default only mouse, mouse motion, mouse wheel, keyboard and focus events are supported, if you need to catch any other type of events, override this method to return the different mask
protected  java.util.Map<java.awt.RenderingHints.Key,java.lang.Object> getRenderingHints(JXLayer<? extends 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<? extends V> l)
          Returns the AffineTransform to be used during painting of this JXLayer, the default implementation returns null.
 void handlePropertyChangeEvent(java.beans.PropertyChangeEvent evt, JXLayer<? extends V> l)
          Notifies the LayerUI when any of its property is changed and allows to update every JXLayer this LayerUI is set to.
 void installUI(javax.swing.JComponent c)
          Configures the JXLayer this LayerUI is set to.
protected  boolean isDirty()
          Returns the "dirty bit".
 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<? extends V> l)
          Subclasses should implement this method and perform custom painting operations here.
protected  void processFocusEvent(java.awt.event.FocusEvent e, JXLayer<? extends V> l)
          Processes FocusEvent occurring on the JXLayer or any of its subcomponents.
protected  void processKeyEvent(java.awt.event.KeyEvent e, JXLayer<? extends V> l)
          Processes KeyEvent occurring on the JXLayer or any of its subcomponents.
protected  void processMouseEvent(java.awt.event.MouseEvent e, JXLayer<? extends V> l)
          Processes MouseEvent occurring on the JXLayer or any of its subcomponents.
protected  void processMouseMotionEvent(java.awt.event.MouseEvent e, JXLayer<? extends V> l)
          Processes mouse motion events occurring on the JXLayer or any of its subcomponents.
protected  void processMouseWheelEvent(java.awt.event.MouseWheelEvent e, JXLayer<? extends V> l)
          Processes MouseWheelEvent occurring on the JXLayer or any of its subcomponents.
protected  void setDirty(boolean isDirty)
          Sets the "dirty bit".
 void uninstallUI(javax.swing.JComponent c)
          
 
Methods inherited from class org.jdesktop.jxlayer.plaf.LayerUI
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, getPreferredScrollableViewportSize, getPropertyChangeListeners, getPropertyChangeListeners, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, removePropertyChangeListener, removePropertyChangeListener, updateUI
 
Methods inherited from class javax.swing.plaf.ComponentUI
contains, createUI, getAccessibleChild, getAccessibleChildrenCount, getMaximumSize, getMinimumSize, getPreferredSize, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractLayerUI

public AbstractLayerUI()
Method Detail

installUI

public void installUI(javax.swing.JComponent c)
Description copied from class: LayerUI
Configures the JXLayer this LayerUI is set to. The default implementation registers the LayerUI as a property change listener for the passed JXLayer

Overrides:
installUI in class LayerUI<V extends javax.swing.JComponent>
Parameters:
c - the JXLayer where this UI delegate is being installed

uninstallUI

public void uninstallUI(javax.swing.JComponent c)
Description copied from class: LayerUI

Overrides:
uninstallUI in class LayerUI<V extends javax.swing.JComponent>

handlePropertyChangeEvent

public void handlePropertyChangeEvent(java.beans.PropertyChangeEvent evt,
                                      JXLayer<? extends V> l)
Notifies the LayerUI when any of its property is changed and allows to update every JXLayer this LayerUI is set to.

Overrides:
handlePropertyChangeEvent in class LayerUI<V extends javax.swing.JComponent>
Parameters:
evt - the PropertyChangeEvent generated by this LayerUI
l - the JXLayer this LayerUI is set to

isDirty

protected boolean isDirty()
Returns the "dirty bit". If true, then the AbstractLayerUI is considered dirty and in need of being repainted.

Returns:
true if the AbstractLayerUI state has changed and the JXLayers it is set to need to be repainted.

setDirty

protected void setDirty(boolean isDirty)
Sets the "dirty bit". If isDirty is true, then the AbstractLayerUI is considered dirty and it triggers the repainting of the JXLayers this AbstractLayerUI it is set to.

Parameters:
isDirty - whether this AbstractLayerUI is dirty or not.

paint

public void paint(java.awt.Graphics g,
                  javax.swing.JComponent c)
Paints the specified component. Subclasses should override this method and use the specified Graphics object to render the content of the 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.

Overrides:
paint in class LayerUI<V extends javax.swing.JComponent>
Parameters:
g - the Graphics context in which to paint;
c - the component being painted; it can be safely cast to the JXLayer<V>
See Also:
configureGraphics(Graphics2D,JXLayer), paintLayer(Graphics2D,JXLayer), setDirty(boolean)

paintLayer

protected void paintLayer(java.awt.Graphics2D g2,
                          JXLayer<? extends V> l)
Subclasses should implement this method and perform custom painting operations here.

The default implementation paints the passed JXLayer as is.

Parameters:
g2 - the Graphics2D context in which to paint
l - the JXLayer being painted

configureGraphics

protected void configureGraphics(java.awt.Graphics2D g2,
                                 JXLayer<? extends 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. The default implementation sets the Composite, the clip, AffineTransform and rendering hints obtained from the corresponding hook methods.

Parameters:
g2 - the Graphics2D object to configure
l - the JXLayer being painted
See Also:
getComposite(JXLayer), getClip(JXLayer), getTransform(JXLayer), getRenderingHints(JXLayer)

getComposite

protected java.awt.Composite getComposite(JXLayer<? extends V> l)
Returns the Composite to be used during painting of this JXLayer, the default implementation returns null.

Parameters:
l - the JXLayer being painted
Returns:
the Composite to be used during painting for the JXLayer

getTransform

protected java.awt.geom.AffineTransform getTransform(JXLayer<? extends V> l)
Returns the AffineTransform to be used during painting of this JXLayer, the default implementation returns null.

Parameters:
l - the JXLayer being painted
Returns:
the AffineTransform to be used during painting of the JXLayer

getClip

protected java.awt.Shape getClip(JXLayer<? extends V> l)
Returns the Shape to be used as the clip during painting of this JXLayer, the default implementation returns null.

Parameters:
l - the JXLayer being painted
Returns:
the Shape to be used as the clip during painting of the JXLayer

getRenderingHints

protected java.util.Map<java.awt.RenderingHints.Key,java.lang.Object> getRenderingHints(JXLayer<? extends V> l)
Returns the map of rendering hints to be used during painting of this JXLayer, the default implementation returns the empty unmodifiable map.

Parameters:
l - the JXLayer being painted
Returns:
the map of rendering hints to be used during painting of the JXLayer

getLayerEventMask

public long getLayerEventMask()
By default only mouse, mouse motion, mouse wheel, keyboard and focus events are supported, if you need to catch any other type of events, override this method to return the different mask

See Also:
JXLayer.setLayerEventMask(long)

eventDispatched

public void eventDispatched(java.awt.AWTEvent e,
                            JXLayer<? extends V> l)
Dispatches AWTEvents for JXLayer and all it subcomponents to this LayerUI.

To enable the AWTEvent of particular type, you should call JXLayer.setLayerEventMask(long) in LayerUI.installUI(javax.swing.JComponent) and set the layer event mask to 0 in LayerUI.uninstallUI(javax.swing.JComponent) after that

This method calls the appropriate process<eventType>Event method for the given class of event.

Overrides:
eventDispatched in class LayerUI<V extends javax.swing.JComponent>
Parameters:
e - the event to be dispatched
l - the layer this LayerUI is set to
See Also:
JXLayer.setLayerEventMask(long), JXLayer.getLayerEventMask()

processFocusEvent

protected void processFocusEvent(java.awt.event.FocusEvent e,
                                 JXLayer<? extends V> l)
Processes FocusEvent occurring on the JXLayer or any of its subcomponents.

Parameters:
e - the FocusEvent to be processed
l - the layer this LayerUI is set to

processMouseEvent

protected void processMouseEvent(java.awt.event.MouseEvent e,
                                 JXLayer<? extends V> l)
Processes MouseEvent occurring on the JXLayer or any of its subcomponents.

Parameters:
e - the MouseEvent to be processed
l - the layer this LayerUI is set to

processMouseMotionEvent

protected void processMouseMotionEvent(java.awt.event.MouseEvent e,
                                       JXLayer<? extends V> l)
Processes mouse motion events occurring on the JXLayer or any of its subcomponents.

Parameters:
e - the MouseEvent to be processed
l - the layer this LayerUI is set to

processMouseWheelEvent

protected void processMouseWheelEvent(java.awt.event.MouseWheelEvent e,
                                      JXLayer<? extends V> l)
Processes MouseWheelEvent occurring on the JXLayer or any of its subcomponents.

Parameters:
e - the MouseWheelEvent to be processed
l - the layer this LayerUI is set to

processKeyEvent

protected void processKeyEvent(java.awt.event.KeyEvent e,
                               JXLayer<? extends V> l)
Processes KeyEvent occurring on the JXLayer or any of its subcomponents.

Parameters:
e - the KeyEvent to be processed
l - the layer this LayerUI is set to