org.jdesktop.jxlayer.plaf
Class BufferedLayerUI<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>
              extended by org.jdesktop.jxlayer.plaf.AbstractBufferedLayerUI<V>
                  extended by org.jdesktop.jxlayer.plaf.BufferedLayerUI<V>
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener

public class BufferedLayerUI<V extends javax.swing.JComponent>
extends AbstractBufferedLayerUI<V>

BufferedLayerUI is the mutable implementation of the AbstractBufferedLayerUI class.

It provides setters for all its graphics properties like clipping shape, array of the LayerEffects, etc. It also notifies its LayerItemListeners when any of its properties or properties of its Effects are changed, this leads to the automatic repainting of the JXLayer, this object is set to.

Note: The BufferedLayerUI is not shareable and can be set to single JXLayer instance. The current JXLayer can be obtained with AbstractBufferedLayerUI.getLayer() method

See Also:
setComposite(java.awt.Composite), setAlpha(float), setClip(java.awt.Shape), setLayerEffects(org.jdesktop.jxlayer.plaf.effect.LayerEffect[]), setRenderingHints(java.util.Map), setTransform(java.awt.geom.AffineTransform), Serialized Form

Constructor Summary
BufferedLayerUI()
           
 
Method Summary
 float getAlpha()
          If getComposite() returns an instanse of AlphaComposite then this method returns the value of AlphaComposite.getAlpha(), otherwise it returns 1.
 java.awt.Shape getClip()
          Returns the Shape to be applied to the Graphics2D during painting of this BufferedLayerUI.
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.

This implementation returns the Shape set using setClip(Shape)}

If a BufferedLayerUI provides more extensive API to support different clipping shapes depending on its state or on the state of the passed JXLayer, this method should be overridden.

 java.awt.Composite getComposite()
          Returns the Composite to be applied to the Graphics2D during painting of this BufferedLayerUI.
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.

This implementation returns the Composite set using setComposite(Composite)

If a BufferedLayerUI provides more extensive API to support different Composites depending on its state or on the state of the passed JXLayer, this method should be overridden.

 LayerEffect[] getLayerEffects()
          Returns the array of the LayerEffects to be applied to the buffer of this BufferedLayerUI
protected  LayerEffect[] getLayerEffects(JXLayer<? extends V> l)
          Returns the array of LayerEffect to be used during painting of this JXLayer, the default implementation returns constant empty array.

This implementation returns the array of Effects set using setLayerEffects(LayerEffect[])

If a BufferedLayerUI provides more extensive API to support different Effects depending on its state or on the state of the passed JXLayer, this method should be overridden.

 java.util.Map<java.awt.RenderingHints.Key,java.lang.Object> getRenderingHints()
          Returns the map of rendering hints to be applied to the Graphics2D during painting of this BufferedLayerUI.
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.

This implementation returns the map of rendreing hints set using setRenderingHints(java.util.Map)

If a BufferedLayerUI provides more extensive API to support different rendering hints depending on its state or on the state of the passed JXLayer, this method should be overridden.

 java.awt.geom.AffineTransform getTransform()
          Returns the AffineTransform to be applied to the Graphics2D during painting of this BufferedLayerUI.
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.

This implementation returns the AffineTransform set using setTransform(AffineTransform)

If a BufferedLayerUI provides more extensive API to support different AffineTransform depending on its state or on the state of the passed JXLayer, this method should be overridden.

 boolean isIncrementalUpdate()
          Returns true if incremental update is enabled for this BufferedLayerUI and its cache image is updated on every repainting, otherwise returns false.
protected  boolean isIncrementalUpdate(JXLayer<? extends V> l)
          If this method returns false and AbstractLayerUI.isDirty returns false and the cached image exists and matches the size of painted JXLayer then the existing image will be used during the painting.

This implementation returns the incremental update flag set using setIncrementalUpdate(boolean)

If a BufferedLayerUI provides more extensive API to support incremental updated depending on its state or on the state of the passed JXLayer, this method should be overridden.

 void setAlpha(float alpha)
          Sets the AlphaComposite with the specified alpha value as the Composite for this BufferedLayerUI.
 void setClip(java.awt.Shape clip)
          Sets the clipping Shape to be applied to the Graphics2D during painting of this BufferedLayerUI.
 void setComposite(java.awt.Composite composite)
          Sets the Composite to be applied to the Graphics2D during painting of this BufferedLayerUI.
 void setIncrementalUpdate(boolean incrementalUpdate)
          Sets the incremental update flag for this BufferedLayerUI.
 void setLayerEffects(LayerEffect... effects)
          Sets the array of the Effects to be applied to the Graphics2D during painting of this BufferedLayerUI

This BufferedLayerUI is set to every Effect in this array as a PropertyChangeListener to mark itself as dirty when any of those Effects changes its state.

 void setRenderingHints(java.util.Map<java.awt.RenderingHints.Key,java.lang.Object> renderingHints)
          Sets the map of rendering hints to be applied to the Graphics2D during painting of this BufferedLayerUI.
 void setTransform(java.awt.geom.AffineTransform transform)
          Sets the AffineTransform to be applied to the Graphics2D during painting of this BufferedLayerUI.
 
Methods inherited from class org.jdesktop.jxlayer.plaf.AbstractBufferedLayerUI
applyLayerEffects, createBuffer, getBuffer, getLayer, installUI, isBufferContentValid, isBufferFormatValid, paint, propertyChange, setBuffer, uninstallUI, updateUI
 
Methods inherited from class org.jdesktop.jxlayer.plaf.AbstractLayerUI
configureGraphics, eventDispatched, getLayerEventMask, handlePropertyChangeEvent, isDirty, paintLayer, processFocusEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, setDirty
 
Methods inherited from class org.jdesktop.jxlayer.plaf.LayerUI
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, getPreferredScrollableViewportSize, getPropertyChangeListeners, getPropertyChangeListeners, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, removePropertyChangeListener, removePropertyChangeListener
 
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

BufferedLayerUI

public BufferedLayerUI()
Method Detail

getLayerEffects

public LayerEffect[] getLayerEffects()
Returns the array of the LayerEffects to be applied to the buffer of this BufferedLayerUI

Returns:
the collection of the Effects to be applied to the buffer of this painter
See Also:
setLayerEffects(LayerEffect[]), getLayerEffects(JXLayer)

getLayerEffects

protected LayerEffect[] getLayerEffects(JXLayer<? extends V> l)
Returns the array of LayerEffect to be used during painting of this JXLayer, the default implementation returns constant empty array.

This implementation returns the array of Effects set using setLayerEffects(LayerEffect[])

If a BufferedLayerUI provides more extensive API to support different Effects depending on its state or on the state of the passed JXLayer, this method should be overridden.

Overrides:
getLayerEffects in class AbstractBufferedLayerUI<V extends javax.swing.JComponent>
Parameters:
l - the JXLayer being painted
Returns:
the array of LayerEffect to be used during painting of the JXLayer
See Also:
setLayerEffects(LayerEffect[]), getLayerEffects()

setLayerEffects

public void setLayerEffects(LayerEffect... effects)
Sets the array of the Effects to be applied to the Graphics2D during painting of this BufferedLayerUI

This BufferedLayerUI is set to every Effect in this array as a PropertyChangeListener to mark itself as dirty when any of those Effects changes its state.

This method marks BufferedLayerUI as dirty which causes repainting of its JXLayer.

Parameters:
effects - the array of the Effects to be applied to the buffer of this BufferedLayerUI
See Also:
getLayerEffects(), getLayerEffects(JXLayer), AbstractLayerUI.setDirty(boolean)

getClip

public java.awt.Shape getClip()
Returns the Shape to be applied to the Graphics2D during painting of this BufferedLayerUI.

Returns:
the Shape to be applied to the Graphics2D during painting of this BufferedLayerUI
See Also:
setClip(Shape), getClip(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.

This implementation returns the Shape set using setClip(Shape)}

If a BufferedLayerUI provides more extensive API to support different clipping shapes depending on its state or on the state of the passed JXLayer, this method should be overridden.

Overrides:
getClip in class AbstractLayerUI<V extends javax.swing.JComponent>
Parameters:
l - the JXLayer being painted
Returns:
the Shape to be used as the clip during painting of the JXLayer
See Also:
getClip(), setClip(Shape)

setClip

public void setClip(java.awt.Shape clip)
Sets the clipping Shape to be applied to the Graphics2D during painting of this BufferedLayerUI.

This method marks BufferedLayerUI as dirty which causes repainting of its JXLayer.

Parameters:
clip - the Shape to be used as the clip during painting of this BufferedLayerUI
See Also:
getClip(), getClip(JXLayer), AbstractLayerUI.setDirty(boolean)

getComposite

public java.awt.Composite getComposite()
Returns the Composite to be applied to the Graphics2D during painting of this BufferedLayerUI.

Returns:
the Composite to be applied to the Graphics2D during painting of this BufferedLayerUI
See Also:
setComposite(Composite), getComposite(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.

This implementation returns the Composite set using setComposite(Composite)

If a BufferedLayerUI provides more extensive API to support different Composites depending on its state or on the state of the passed JXLayer, this method should be overridden.

Overrides:
getComposite in class AbstractLayerUI<V extends javax.swing.JComponent>
Parameters:
l - the JXLayer being painted
Returns:
the Composite to be used during painting for the JXLayer
See Also:
setComposite(Composite), getComposite()

setComposite

public void setComposite(java.awt.Composite composite)
Sets the Composite to be applied to the Graphics2D during painting of this BufferedLayerUI.

This method marks BufferedLayerUI as dirty which causes repainting of its JXLayer.

Parameters:
composite - the Composite to be applied to the Graphics2D during painting of this BufferedLayerUI.
See Also:
getComposite(), getComposite(JXLayer), AbstractLayerUI.setDirty(boolean)

getAlpha

public float getAlpha()
If getComposite() returns an instanse of AlphaComposite then this method returns the value of AlphaComposite.getAlpha(), otherwise it returns 1.

Returns:
If getComposite() returns an instanse of AlphaComposite returns the value of AlphaComposite.getAlpha(), otherwise it returns 1
See Also:
setAlpha(float), setComposite(Composite), getComposite()

setAlpha

public void setAlpha(float alpha)
Sets the AlphaComposite with the specified alpha value as the Composite for this BufferedLayerUI.

Parameters:
alpha - the constant alpha to be multiplied with the alpha of the source. alpha must be a floating point number in the inclusive range [0.0, 1.0].
Throws:
java.lang.IllegalArgumentException - if alpha is less than 0.0 or greater than 1.0,
See Also:
getAlpha(), setComposite(Composite)

getRenderingHints

public java.util.Map<java.awt.RenderingHints.Key,java.lang.Object> getRenderingHints()
Returns the map of rendering hints to be applied to the Graphics2D during painting of this BufferedLayerUI.

Returns:
the map of rendering hints to be applied to the Graphics2D during painting of this BufferedLayerUI
See Also:
setRenderingHints(Map), getRenderingHints(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.

This implementation returns the map of rendreing hints set using setRenderingHints(java.util.Map)

If a BufferedLayerUI provides more extensive API to support different rendering hints depending on its state or on the state of the passed JXLayer, this method should be overridden.

Overrides:
getRenderingHints in class AbstractLayerUI<V extends javax.swing.JComponent>
Parameters:
l - the JXLayer being painted
Returns:
the map of rendering hints to be used during painting of the JXLayer
See Also:
setRenderingHints(java.util.Map), getRenderingHints()

setRenderingHints

public void setRenderingHints(java.util.Map<java.awt.RenderingHints.Key,java.lang.Object> renderingHints)
Sets the map of rendering hints to be applied to the Graphics2D during painting of this BufferedLayerUI.

This method marks BufferedLayerUI as dirty which causes repainting of its JXLayer.

Parameters:
renderingHints - the map of rendering hints to be applied to the Graphics2D during painting of this BufferedLayerUI
See Also:
getRenderingHints(), getRenderingHints(JXLayer), AbstractLayerUI.setDirty(boolean)

getTransform

public java.awt.geom.AffineTransform getTransform()
Returns the AffineTransform to be applied to the Graphics2D during painting of this BufferedLayerUI.

Returns:
the AffineTransform to be applied to the Graphics2D during painting of this BufferedLayerUI
See Also:
setTransform(AffineTransform), getTransform(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.

This implementation returns the AffineTransform set using setTransform(AffineTransform)

If a BufferedLayerUI provides more extensive API to support different AffineTransform depending on its state or on the state of the passed JXLayer, this method should be overridden.

Overrides:
getTransform in class AbstractLayerUI<V extends javax.swing.JComponent>
Parameters:
l - the JXLayer being painted
Returns:
the AffineTransform to be used during painting of the JXLayer
See Also:
setTransform(AffineTransform), getTransform()

setTransform

public void setTransform(java.awt.geom.AffineTransform transform)
Sets the AffineTransform to be applied to the Graphics2D during painting of this BufferedLayerUI.

This method marks BufferedLayerUI as dirty which causes repainting of its JXLayer.

Parameters:
transform - the AffineTransform to be applied to the Graphics2D during painting of this BufferedLayerUI
See Also:
getTransform(), getTransform(JXLayer), AbstractLayerUI.setDirty(boolean)

isIncrementalUpdate

public boolean isIncrementalUpdate()
Returns true if incremental update is enabled for this BufferedLayerUI and its cache image is updated on every repainting, otherwise returns false.

Returns:
true if incremental update is enabled for this BufferedLayerUI and its cache image is updated on every repainting, otherwise returns false
See Also:
setIncrementalUpdate(boolean), isIncrementalUpdate(JXLayer)

isIncrementalUpdate

protected boolean isIncrementalUpdate(JXLayer<? extends V> l)
If this method returns false and AbstractLayerUI.isDirty returns false and the cached image exists and matches the size of painted JXLayer then the existing image will be used during the painting.

It helps to skip unnecessary painting and save a lot of time, especially if BufferedImageOpEffects are used.
If this method returns true the cache image will be updated on every painting.

The default implementation returns true

This implementation returns the incremental update flag set using setIncrementalUpdate(boolean)

If a BufferedLayerUI provides more extensive API to support incremental updated depending on its state or on the state of the passed JXLayer, this method should be overridden.

Overrides:
isIncrementalUpdate in class AbstractBufferedLayerUI<V extends javax.swing.JComponent>
Parameters:
l - the JXLayer being painted
Returns:
true if the cache image should be updated on every painting, otherwise returns false
See Also:
setIncrementalUpdate(boolean), isIncrementalUpdate()

setIncrementalUpdate

public void setIncrementalUpdate(boolean incrementalUpdate)
Sets the incremental update flag for this BufferedLayerUI. If it is true the cache image will be updated on every repainting, otherwise the existing image will be painted.

This method marks BufferedLayerUI as dirty which causes repainting of its JXLayer.

Parameters:
incrementalUpdate - true if incremental update is enabled and cache image will be updated on every repainting, otherwise false
See Also:
isIncrementalUpdate(), isIncrementalUpdate(JXLayer), AbstractLayerUI.setDirty(boolean)