|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavax.swing.plaf.ComponentUI
org.jdesktop.jxlayer.plaf.LayerUI<V>
org.jdesktop.jxlayer.plaf.AbstractLayerUI<V>
org.jdesktop.jxlayer.plaf.AbstractBufferedLayerUI<V>
public class AbstractBufferedLayerUI<V extends javax.swing.JComponent>
The AbstractBufferedLayerUI paitns the JXLayer
to the BufferedImage and then paints this image to the Graphics
passed to its paint method.
AbstractBufferedLayerUI
is the ability to apply various LayerEffects to its content,BufferedImageOpEffect
which uses BufferedImageOp to filter the buffer
This class introduces the isIncrementalUpdate(JXLayer) method.
If it 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 isIncrementalUpdate(JXLayer) returns true
the cache image will be updated on every painting.
For custom painting, override AbstractLayerUI.paintLayer(Graphics2D,JXLayer) as usual.
If you want to apply Effects, override getLayerEffects(JXLayer) methods
or use more flexible BufferedLayerUI.
Note: The AbstractBufferedLayerUI is not shareable and
can be set to single JXLayer instance.
The current JXLayer can be obtained with getLayer() method
LayerEffect,
BufferedImageOpEffect,
BufferedLayerUI,
isIncrementalUpdate(JXLayer),
Serialized Form| Constructor Summary | |
|---|---|
AbstractBufferedLayerUI()
|
|
| Method Summary | |
|---|---|
protected void |
applyLayerEffects(JXLayer<? extends V> l,
java.awt.Shape clip)
Iterates through the current array of LayerEffects
and applies each enabled one to the buffer. |
protected java.awt.image.BufferedImage |
createBuffer(int width,
int height)
Creates the BufferedImage to be used as the cached image. |
protected java.awt.image.BufferedImage |
getBuffer()
Returns the current cached image. |
JXLayer<? extends V> |
getLayer()
The JXLayer this AbstractBufferedLayerUI is set to. |
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. |
void |
installUI(javax.swing.JComponent c)
Configures the JXLayer this LayerUI is set to.
This implementation saves the passed JXLayer instance
and checks that it set to one layer only |
protected boolean |
isBufferContentValid(JXLayer<? extends V> l,
java.awt.Shape clip)
Defines if the cached image has the valid content for the current painting painting operation and there is no need to repaint it. |
protected boolean |
isBufferFormatValid(JXLayer<? extends V> l)
Defines if the cached image has the valid format for the current painting painting operation and there is no need to recreate it. |
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. |
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 AbstractLayerUI.paintLayer(Graphics2D,JXLayer) instead
This method configures the passed Graphics with help of the
AbstractLayerUI.configureGraphics(Graphics2D,JXLayer) method,
then calls paintLayer(Graphics2D,JXLayer)
and resets the "dirty bit" at the end.
This method paints the paitns the JXLayer to the BufferedImage
and then paints this image to the passed Graphics. |
void |
propertyChange(java.beans.PropertyChangeEvent evt)
This method is public as an implementation side effect. |
protected void |
setBuffer(java.awt.image.BufferedImage buffer)
Sets the current cached image. |
void |
uninstallUI(javax.swing.JComponent c)
|
void |
updateUI(JXLayer<? extends V> l)
Mark AbstractBufferedLayerUI as dirty if the LookAndFeel was changed |
| Methods inherited from class org.jdesktop.jxlayer.plaf.AbstractLayerUI |
|---|
configureGraphics, eventDispatched, getClip, getComposite, getLayerEventMask, getRenderingHints, getTransform, handlePropertyChangeEvent, isDirty, paintLayer, processFocusEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, setDirty |
| 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 |
|---|
public AbstractBufferedLayerUI()
| Method Detail |
|---|
public void installUI(javax.swing.JComponent c)
JXLayer this LayerUI is set to.
The default implementation registers the LayerUI
as a property change listener for the passed JXLayer
This implementation saves the passed JXLayer instance
and checks that it set to one layer only
installUI in class AbstractLayerUI<V extends javax.swing.JComponent>c - the JXLayer where this UI delegate is being installed
java.lang.IllegalStateException - if this BufferedLayerUI
is set to multiple JXLayersuninstallUI(JComponent),
getLayer()public void uninstallUI(javax.swing.JComponent c)
uninstallUI in class AbstractLayerUI<V extends javax.swing.JComponent>public void propertyChange(java.beans.PropertyChangeEvent evt)
AbstractBufferedLayerUI listens property changes of its JXLayer
and marks itself as dirty if the JXLayer's view component has been changed.
propertyChange in interface java.beans.PropertyChangeListenerevt - the PropertyChangeEventJXLayer.setView(Component),
AbstractLayerUI.setDirty(boolean)public void updateUI(JXLayer<? extends V> l)
AbstractBufferedLayerUI as dirty if the LookAndFeel was changed
updateUI in class LayerUI<V extends javax.swing.JComponent>l - the JXLayer this AbstractBufferedLayerUI is set topublic JXLayer<? extends V> getLayer()
JXLayer this AbstractBufferedLayerUI is set to.
JXLayer this AbstractBufferedLayerUI is set toprotected java.awt.image.BufferedImage getBuffer()
null at any time.
However it is guaranteed that is safe to call this method inside
AbstractLayerUI.paintLayer(Graphics2D,JXLayer) method, because a strong reference
to the buffer is kept during painting process and you'll get the actual
BufferedImage which you are free to use withing paintLayer.
setBuffer(BufferedImage)protected void setBuffer(java.awt.image.BufferedImage buffer)
buffer - the BufferedImage to be used as the cachegetBuffer()protected LayerEffect[] getLayerEffects(JXLayer<? extends V> l)
LayerEffect to be used during painting of this JXLayer,
the default implementation returns constant empty array.
l - the JXLayer being painted
LayerEffect to be used during painting of the JXLayerprotected boolean isIncrementalUpdate(JXLayer<? extends V> l)
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.
true the cache image will be updated on every painting.
The default implementation returns true
l - the JXLayer being painted
true if the cache image should be updated on every painting,
otherwise returns falsegetBuffer()
public void paint(java.awt.Graphics g,
javax.swing.JComponent c)
Graphics object to
render the content of the component.
Note: It is rarely necessary to override this method, for
custom painting override AbstractLayerUI.paintLayer(Graphics2D,JXLayer) instead
This method configures the passed Graphics with help of the
AbstractLayerUI.configureGraphics(Graphics2D,JXLayer) method,
then calls paintLayer(Graphics2D,JXLayer)
and resets the "dirty bit" at the end.
This method paints the paitns the JXLayer to the BufferedImage
and then paints this image to the passed Graphics.
It also manages the state of the existing cached image
and applies the existing LayerEffects to the image.
paint in class AbstractLayerUI<V extends javax.swing.JComponent>g - the Graphics context in which to paint;c - the component being painted;
it can be safely cast to the JXLayer<V>AbstractLayerUI.paintLayer(Graphics2D,JXLayer),
isBufferFormatValid(JXLayer),
isBufferContentValid(JXLayer,Shape),
getLayerEffects(JXLayer)protected boolean isBufferFormatValid(JXLayer<? extends V> l)
true
if the cached image is not null and its size matches
the size of the JXLayer being painted,
otherwise it returns true.
l - the JXLayer being painted
true if the format of existing cache image
is valid, otherwise returns falsegetBuffer()
protected boolean isBufferContentValid(JXLayer<? extends V> l,
java.awt.Shape clip)
true
if this AbstractBufferedLayerUI hasn't been marked as dirty
and incremental update is disabled.
l - the JXLayer being paintedclip - the current clipping shape
true if the content of existing cache image
is valid, otherwise returns falseAbstractLayerUI.isDirty(),
isIncrementalUpdate(JXLayer)
protected java.awt.image.BufferedImage createBuffer(int width,
int height)
BufferedImage to be used as the cached image.
This method must never return null.
width - the width of the imageheight - the height of the image
BufferedImage,
which can be used for double buffering.
protected void applyLayerEffects(JXLayer<? extends V> l,
java.awt.Shape clip)
LayerEffects
and applies each enabled one to the buffer.
l - the JXLayer being paintedclip - the current clipping shapegetLayerEffects(JXLayer),
LayerEffect.isEnabled()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||