org.icepdf.ri.util.jxlayer.plaf
Class LayerUI<V extends java.awt.Component>

java.lang.Object
  extended by javax.swing.plaf.ComponentUI
      extended by org.icepdf.ri.util.jxlayer.plaf.LayerUI<V>
Type Parameters:
V - one of the super types of JXLayer's view component
All Implemented Interfaces:
java.io.Serializable

public abstract class LayerUI<V extends java.awt.Component>
extends javax.swing.plaf.ComponentUI
implements java.io.Serializable

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 AWTEvents 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.

Author:
Alexander Potochkin
See Also:
JXLayer.setUI(LayerUI), JXLayer.setView(Component), JXLayer.getView(), Serialized Form

Constructor Summary
LayerUI()
           
 
Method Summary
 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.
 void eventDispatched(java.awt.AWTEvent e, JXLayer<? extends V> l)
          Dispatches AWTEvents for JXLayer and all it subcomponents to this LayerUI.
protected  void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
          Support for reporting bound property changes for Object properties.
 java.awt.Dimension getPreferredScrollableViewportSize(JXLayer<? extends V> l)
          Returns the preferred size of the viewport for a view component.
 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.
 int getScrollableBlockIncrement(JXLayer<? extends 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<? extends 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<? extends 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<? extends 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.
 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.
 void paint(java.awt.Graphics g, javax.swing.JComponent c)
          Paints the specified component.
 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.
 void uninstallUI(javax.swing.JComponent c)
          
 void updateUI(JXLayer<? extends 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, 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

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.

Overrides:
paint in class javax.swing.plaf.ComponentUI
Parameters:
g - the Graphics context in which to paint;
c - the component being painted; it can be safely cast to the JXLayer<V>

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 installUI(javax.swing.JComponent) and set the layer event mask to 0 in uninstallUI(javax.swing.JComponent) after that

Parameters:
e - the event to be dispatched
l - the layer this LayerUI is set to
See Also:
JXLayer.setLayerEventMask(long), JXLayer.getLayerEventMask()

updateUI

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

Parameters:
l - the JXLayer which UI is updated

installUI

public void installUI(javax.swing.JComponent c)
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 javax.swing.plaf.ComponentUI
Parameters:
c - the JXLayer where this UI delegate is being installed

uninstallUI

public void uninstallUI(javax.swing.JComponent c)

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

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list. The listener is registered for all bound properties of this class.

If listener is null, no exception is thrown and no action is performed.

Parameters:
listener - the property change listener to be added
See Also:
removePropertyChangeListener(java.beans.PropertyChangeListener), getPropertyChangeListeners(), addPropertyChangeListener(String, java.beans.PropertyChangeListener)

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a PropertyChangeListener from the listener list. This method should be used to remove PropertyChangeListeners that were registered for all bound properties of this class.

If listener is null, no exception is thrown and no action is performed.

Parameters:
listener - the PropertyChangeListener to be removed
See Also:
addPropertyChangeListener(java.beans.PropertyChangeListener), getPropertyChangeListeners(), removePropertyChangeListener(String, PropertyChangeListener)

getPropertyChangeListeners

public java.beans.PropertyChangeListener[] getPropertyChangeListeners()
Returns an array of all the property change listeners registered on this component.

Returns:
all of this ui's PropertyChangeListeners or an empty array if no property change listeners are currently registered
See Also:
addPropertyChangeListener(java.beans.PropertyChangeListener), removePropertyChangeListener(java.beans.PropertyChangeListener), getPropertyChangeListeners(String)

addPropertyChangeListener

public void addPropertyChangeListener(java.lang.String propertyName,
                                      java.beans.PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list for a specific property.

If propertyName or listener is null, no exception is thrown and no action is taken.

Parameters:
propertyName - one of the property names listed above
listener - the property change listener to be added
See Also:
removePropertyChangeListener(String, PropertyChangeListener), getPropertyChangeListeners(String), addPropertyChangeListener(String, PropertyChangeListener)

removePropertyChangeListener

public void removePropertyChangeListener(java.lang.String propertyName,
                                         java.beans.PropertyChangeListener listener)
Removes a 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.

Parameters:
propertyName - a valid property name
listener - the PropertyChangeListener to be removed
See Also:
addPropertyChangeListener(String, PropertyChangeListener), getPropertyChangeListeners(String), removePropertyChangeListener(PropertyChangeListener)

getPropertyChangeListeners

public java.beans.PropertyChangeListener[] getPropertyChangeListeners(java.lang.String propertyName)
Returns an array of all the listeners which have been associated with the named property.

Returns:
all of the PropertyChangeListeners associated with the named property; if no such listeners have been added or if propertyName is null, an empty array is returned
See Also:
addPropertyChangeListener(String, PropertyChangeListener), removePropertyChangeListener(String, PropertyChangeListener), getPropertyChangeListeners()

firePropertyChange

protected void firePropertyChange(java.lang.String propertyName,
                                  java.lang.Object oldValue,
                                  java.lang.Object newValue)
Support for reporting bound property changes for Object properties. This method can be called when a bound property has changed and it will send the appropriate PropertyChangeEvent to any registered PropertyChangeListeners.

Parameters:
propertyName - the property whose value has changed
oldValue - the property's previous value
newValue - the property's new value

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.

Parameters:
evt - the PropertyChangeEvent generated by this LayerUI
l - the JXLayer this LayerUI is set to

getPreferredScrollableViewportSize

public java.awt.Dimension getPreferredScrollableViewportSize(JXLayer<? extends 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:
()

getScrollableBlockIncrement

public int getScrollableBlockIncrement(JXLayer<? extends 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<? extends 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<? extends 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<? extends 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)