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

java.lang.Object
  extended by javax.swing.plaf.ComponentUI
      extended by org.jdesktop.jxlayer.plaf.LayerUI<V>
All Implemented Interfaces:
LayerItem
Direct Known Subclasses:
AbstractLayerUI

public abstract class LayerUI<V extends javax.swing.JComponent>
extends javax.swing.plaf.ComponentUI
implements LayerItem

The base class for all JXLayer's UI delegates.

paint(java.awt.Graphics, javax.swing.JComponent) method performes the painting of the JXLayer and eventDispatched(AWTEvent, JXLayer) method is notified about any input or focus events which have been generated by a JXLayer or any of its subcomponents.

The LayerUI is different from UI delegates of the other components, because it is LookAndFeel independent and is not updated by default when the system LookAndFeel is changed.

The subclasses of LayerUI can either be stateless and shareable by multiple JXLayers or not shareable.

See Also:
JXLayer.setUI(LayerUI), AbstractLayerUI

Constructor Summary
LayerUI()
           
 
Method Summary
 void eventDispatched(java.awt.AWTEvent event, JXLayer<V> l)
          Dispatches all input and focus events from the JXLayer and all it subcomponents to this LayerUI, when LayerItem.isEnabled() returns true.
 javax.accessibility.Accessible getAccessibleChild(javax.swing.JComponent c, int i)
          
 int getAccessibleChildrenCount(javax.swing.JComponent c)
          
 long getLayerEventMask()
          Returns the bitmap of event mask to receive by this LayerUI and all its JXLayers

It means that eventDispatched(AWTEvent, JXLayer) method will only receive events that match the event mask.

 java.awt.Dimension getPreferredScrollableViewportSize(JXLayer<V> l)
          Returns the preferred size of the viewport for a view component.
 int getScrollableBlockIncrement(JXLayer<V> l, java.awt.Rectangle visibleRect, int orientation, int direction)
          Components that display logical rows or columns should compute the scroll increment that will completely expose one block of rows or columns, depending on the value of orientation.
 boolean getScrollableTracksViewportHeight(JXLayer<V> l)
          Returns false to indicate that the height of the viewport does not determine the height of the layer, unless the preferred height of the layer is smaller than the viewports height.
 boolean getScrollableTracksViewportWidth(JXLayer<V> l)
          Returns false to indicate that the width of the viewport does not determine the width of the layer, unless the preferred width of the layer is smaller than the viewports width.
 int getScrollableUnitIncrement(JXLayer<V> l, java.awt.Rectangle visibleRect, int orientation, int direction)
          Components that display logical rows or columns should compute the scroll increment that will completely expose one new row or column, depending on the value of orientation.
 boolean isEventEnabled(int id)
          Returns true if the events with the passed id are enabled for this LayerUI
 void paint(java.awt.Graphics g, javax.swing.JComponent c)
          Paints the specified component.
 void update(java.awt.Graphics g, javax.swing.JComponent c)
           JXLayer manages its painting in a different way so this method doesn't call the paint(Graphics, JComponent) method after background is filled for the opaque JXLayers.
 void updateUI(JXLayer<V> l)
          Invoked when JXLayer.updateUI() is called from the JXLayer this LayerUI is set to.
 
Methods inherited from class javax.swing.plaf.ComponentUI
contains, createUI, getMaximumSize, getMinimumSize, getPreferredSize, installUI, uninstallUI
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jdesktop.jxlayer.plaf.item.LayerItem
addLayerItemListener, getLayerItemListeners, isEnabled, removeLayerItemListener
 

Constructor Detail

LayerUI

public LayerUI()
Method Detail

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: Subclasses can safely cast the passed component to the JXLayer<V>
and the passed Graphics to the Graphics2D instance.

Overrides:
paint in class javax.swing.plaf.ComponentUI
Parameters:
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>

eventDispatched

public void eventDispatched(java.awt.AWTEvent event,
                            JXLayer<V> l)
Dispatches all input and focus events from the JXLayer and all it subcomponents to this LayerUI, when LayerItem.isEnabled() returns true.

Parameters:
event - the event to be dispatched
l - the layer this LayerUI is set to

getLayerEventMask

public long getLayerEventMask()
Returns the bitmap of event mask to receive by this LayerUI and all its JXLayers

It means that 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.

Returns:
the bitmask of event types to receive for this LayerUI

isEventEnabled

public boolean isEventEnabled(int id)
Returns true if the events with the passed id are enabled for this LayerUI

Parameters:
id - id of the event to be checked
Returns:
true if the events with the the passed id are enabled for this JXLayer, otherwise returns false

updateUI

public void updateUI(JXLayer<V> l)
Invoked when JXLayer.updateUI() is called from the JXLayer this LayerUI is set to.

Parameters:
l - the JXLayer which UI is updated

update

public final void update(java.awt.Graphics g,
                         javax.swing.JComponent c)
JXLayer manages its painting in a different way so this method doesn't call the paint(Graphics, JComponent) method after background is filled for the opaque JXLayers.

Overrides:
update in class javax.swing.plaf.ComponentUI

getAccessibleChild

public final javax.accessibility.Accessible getAccessibleChild(javax.swing.JComponent c,
                                                               int i)

Overrides:
getAccessibleChild in class javax.swing.plaf.ComponentUI

getAccessibleChildrenCount

public final int getAccessibleChildrenCount(javax.swing.JComponent c)

Overrides:
getAccessibleChildrenCount in class javax.swing.plaf.ComponentUI

getPreferredScrollableViewportSize

public java.awt.Dimension getPreferredScrollableViewportSize(JXLayer<V> l)
Returns the preferred size of the viewport for a view component.

Returns:
the preferred size of the viewport for a view component
See Also:
Scrollable.getPreferredScrollableViewportSize()

getScrollableBlockIncrement

public int getScrollableBlockIncrement(JXLayer<V> l,
                                       java.awt.Rectangle visibleRect,
                                       int orientation,
                                       int direction)
Components that display logical rows or columns should compute the scroll increment that will completely expose one block of rows or columns, depending on the value of orientation.

Returns:
the "block" increment for scrolling in the specified direction
See Also:
Scrollable.getScrollableBlockIncrement(Rectangle, int, int)

getScrollableTracksViewportHeight

public boolean getScrollableTracksViewportHeight(JXLayer<V> l)
Returns false to indicate that the height of the viewport does not determine the height of the layer, unless the preferred height of the layer is smaller than the viewports height.

Returns:
whether the layer should track the height of the viewport
See Also:
Scrollable.getScrollableTracksViewportHeight()

getScrollableTracksViewportWidth

public boolean getScrollableTracksViewportWidth(JXLayer<V> l)
Returns false to indicate that the width of the viewport does not determine the width of the layer, unless the preferred width of the layer is smaller than the viewports width.

Returns:
whether the layer should track the width of the viewport
See Also:
Scrollable, getScrollableTracksViewportWidth(JXLayer)

getScrollableUnitIncrement

public int getScrollableUnitIncrement(JXLayer<V> l,
                                      java.awt.Rectangle visibleRect,
                                      int orientation,
                                      int direction)
Components that display logical rows or columns should compute the scroll increment that will completely expose one new row or column, depending on the value of orientation. Ideally, components should handle a partially exposed row or column by returning the distance required to completely expose the item.

Scrolling containers, like JScrollPane, will use this method each time the user requests a unit scroll.

Returns:
The "unit" increment for scrolling in the specified direction. This value should always be positive.
See Also:
Scrollable.getScrollableUnitIncrement(Rectangle, int, int)