|
|||||||||
| 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<javax.swing.JComponent>
org.jdesktop.jxlayer.plaf.ext.LockableUI
public class LockableUI
An implementation of the BufferedLayerUI which provides
a lightweight disabling for the content of its JXLayer.
This allows temporarily blocking a part of the interface
with all it subcomponents, it is also useful when some kind of action
is in progress, e.g. reading data from a database.
true is passed to the setLocked(boolean),
the JXLayer of this LockableLayerUI becomes "locked".
It sets the "wait" mouse cursor and stops reacting
on mouse, keyboard and focus events.
If setLocked(boolean) is called with false parameter
after that, the JXLayer, together with all its subcomponents,
gets back to live.
Subclasses usually override paintLayer(Graphics2D,JXLayer) or
getLayerEffects(JXLayer) to implement some visual effects
when JXLayer is in locked state.
Here is an example of using LockableLayerUI:
JComponent myComponent = getMyComponent(); // just any component LockableLayerUI lockableUI = new LockableLayerUI(); JXLayer<JComponent> layer = new JXLayer<JComponent>(myComponent, lockableUI); // locking the layer, use lockableUI.setLocked(false) to unlock lockableUI.setLocked(true); // add the layer to a frame or a panel, like any other component frame.add(layer);The LockableDemo is available
| Constructor Summary | |
|---|---|
LockableUI()
Creates a new instance of LockableUI |
|
LockableUI(LayerEffect... lockedEffects)
Creates a new instance of LockableUI, passed lockedEffects will be used for when this UI in the locked state |
|
| Method Summary | |
|---|---|
protected LayerEffect[] |
getLayerEffects(JXLayer<javax.swing.JComponent> l)
Returns the array of LayerEffect to be used during painting of this JXLayer,
the default implementation returns constant empty array. |
java.awt.Cursor |
getLockedCursor()
Returns the mouse cursor to be used by this LockableLayerUI when it locked state. |
LayerEffect[] |
getLockedEffects()
Returns the effects to be used when this UI is locked. |
protected LayerEffect[] |
getLockedEffects(JXLayer<javax.swing.JComponent> l)
|
void |
installUI(javax.swing.JComponent c)
Configures the specified JXLayer appropriate for this AbstractLayerUI.
This method is invoked when the LayerUI instance is being installed
as the UI delegate on the specified JXLayer.
Subclasses can install any listeners to the passed JXLayer,
configure its glassPane or do any other setting up.
The default implementation registers the passed JXLayer
as a LayerItemListener for this AbstractLayerUI.
Note: Subclasses can safely cast the passed component
to the JXLayer<V>
This implementation saves the passed JXLayer instance
and checks that it set to one layer only |
protected boolean |
isIncrementalUpdate(JXLayer<javax.swing.JComponent> 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. |
boolean |
isLocked()
Returns true if this LockableLayerUI
is in locked state and all JXLayer's mouse, keyboard and focuse events
are temporarily blocked, otherwise returns false. |
void |
layerItemChanged(LayerItemChangeEvent e)
This method is public as an implementation side effect. |
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.
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. |
protected void |
paintLayer(java.awt.Graphics2D g2,
JXLayer<javax.swing.JComponent> l)
Subclasses should implement this method and perform custom painting operations here. |
void |
setEnabled(boolean enabled)
Enables or disables this component, depending on the value of the parameter enabled. |
void |
setLocked(boolean isLocked)
If isLocked is true then all mouse, keyboard and focuse events
from the JXLayer of this LockableLayerUI
will be temporarily blocked. |
void |
setLockedCursor(java.awt.Cursor lockedCursor)
Sets the mouse cursor to be used by this LockableLayerUI when it locked state. |
void |
setLockedEffects(LayerEffect... lockedEffects)
Sets the effects to be used when this UI is locked. |
void |
uninstallUI(javax.swing.JComponent c)
Reverses configuration which was done on the specified component during installUI(JComponent). This method is invoked when this
LayerUI instance is being removed as the UI delegate
for the specified JXLayer.
uninstallUI(JComponent) should undo the
configuration performed in installUI(JComponent), being careful to
leave the JXLayer instance in a clean state
(e.g. all previously set listeners must be removed in this method).
The default implementation removes the passed JXLayer
from the LayerItemListener's list of this AbstractLayerUI.
Note: Subclasses can safely cast the passed component
to the JXLayer<V> |
| Methods inherited from class org.jdesktop.jxlayer.plaf.AbstractBufferedLayerUI |
|---|
applyLayerEffects, createBuffer, getBuffer, getLayer, isBufferContentValid, isBufferFormatValid, propertyChange, setBuffer, updateUI |
| Methods inherited from class org.jdesktop.jxlayer.plaf.LayerUI |
|---|
getAccessibleChild, getAccessibleChildrenCount, getPreferredScrollableViewportSize, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, isEventEnabled, update |
| Methods inherited from class javax.swing.plaf.ComponentUI |
|---|
contains, createUI, getMaximumSize, getMinimumSize, getPreferredSize |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public LockableUI()
public LockableUI(LayerEffect... lockedEffects)
lockedEffects - effects to be used when this UI is lockedsetLocked(boolean),
setLockedEffects(LayerEffect...)| Method Detail |
|---|
public void installUI(javax.swing.JComponent c)
JXLayer appropriate for this AbstractLayerUI.
This method is invoked when the LayerUI instance is being installed
as the UI delegate on the specified JXLayer.
Subclasses can install any listeners to the passed JXLayer,
configure its glassPane or do any other setting up.
The default implementation registers the passed JXLayer
as a LayerItemListener for this AbstractLayerUI.
Note: Subclasses can safely cast the passed component
to the JXLayer<V>
This implementation saves the passed JXLayer instance
and checks that it set to one layer only
installUI in class AbstractBufferedLayerUI<javax.swing.JComponent>c - the JXLayer where this UI delegate is being installedAbstractBufferedLayerUI.uninstallUI(JComponent),
AbstractBufferedLayerUI.getLayer()public void uninstallUI(javax.swing.JComponent c)
installUI(JComponent). This method is invoked when this
LayerUI instance is being removed as the UI delegate
for the specified JXLayer.
uninstallUI(JComponent) should undo the
configuration performed in installUI(JComponent), being careful to
leave the JXLayer instance in a clean state
(e.g. all previously set listeners must be removed in this method).
The default implementation removes the passed JXLayer
from the LayerItemListener's list of this AbstractLayerUI.
Note: Subclasses can safely cast the passed component
to the JXLayer<V>
uninstallUI in class AbstractBufferedLayerUI<javax.swing.JComponent>c - the JXLayer where this UI delegate is being installedAbstractLayerUI.installUI(JComponent)public void layerItemChanged(LayerItemChangeEvent e)
LockableUI listens its LayerEffects
and marks itself as dirty if any of them changed its state.
layerItemChanged in interface LayerItemListenere - the LayerItemChangeEventsetLockedEffects(LayerEffect...),
AbstractLayerUI.setDirty(boolean)public boolean isLocked()
true if this LockableLayerUI
is in locked state and all JXLayer's mouse, keyboard and focuse events
are temporarily blocked, otherwise returns false.
true if this LockableLayerUI
is in locked state and all JXLayer's mouse, keyboard and focuse events
are temporarily blocked, otherwise returns falsepublic void setLocked(boolean isLocked)
isLocked is true then all mouse, keyboard and focuse events
from the JXLayer of this LockableLayerUI
will be temporarily blocked.
isLocked - if true then all mouse, keyboard and focuse events
from the JXLayer of this LockableLayerUI will be temporarily blockedprotected boolean isIncrementalUpdate(JXLayer<javax.swing.JComponent> l)
AbstractBufferedLayerUIfalse 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
isIncrementalUpdate in class AbstractBufferedLayerUI<javax.swing.JComponent>l - the JXLayer being painted
true if the cache image should be updated on every painting,
otherwise returns falseAbstractBufferedLayerUI.getBuffer()
protected void paintLayer(java.awt.Graphics2D g2,
JXLayer<javax.swing.JComponent> l)
AbstractLayerUIJXLayer as is.
paintLayer in class AbstractLayerUI<javax.swing.JComponent>g2 - the Graphics2D context in which to paintl - the JXLayer being painted
public void paint(java.awt.Graphics g,
javax.swing.JComponent c)
AbstractBufferedLayerUIGraphics object to
render the content of the component.
Note: Subclasses can safely cast the passed component
to the JXLayer<V> Graphics
to the Graphics2D instance.
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 AbstractBufferedLayerUI<javax.swing.JComponent>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>AbstractLayerUI.paintLayer(Graphics2D,JXLayer),
AbstractBufferedLayerUI.isBufferFormatValid(JXLayer),
AbstractBufferedLayerUI.isBufferContentValid(JXLayer,Shape),
AbstractBufferedLayerUI.getLayerEffects(JXLayer)public java.awt.Cursor getLockedCursor()
LockableLayerUI when it locked state.
LockableLayerUI when it locked stategetLockedCursor(),
setLocked(boolean)public void setLockedCursor(java.awt.Cursor lockedCursor)
LockableLayerUI when it locked state.
lockedCursor - the mouse cursor to be used
by this LockableLayerUI when it locked statepublic LayerEffect[] getLockedEffects()
setLocked(boolean)protected LayerEffect[] getLockedEffects(JXLayer<javax.swing.JComponent> l)
public void setLockedEffects(LayerEffect... lockedEffects)
lockedEffects - the effects to be used when this UI is lockedsetLocked(boolean)protected LayerEffect[] getLayerEffects(JXLayer<javax.swing.JComponent> l)
LayerEffect to be used during painting of this JXLayer,
the default implementation returns constant empty array.
getLayerEffects in class AbstractBufferedLayerUI<javax.swing.JComponent>l - the JXLayer being painted
LayerEffect to be used during painting of the JXLayerpublic void setEnabled(boolean enabled)
enabled. An enabled LayerUI paints
the JXLayers components they are set to and receives
their input and focuse events.
AbstractLayerUI is enabled initially by default.
setEnabled in class AbstractLayerUI<javax.swing.JComponent>enabled - If true, this AbstractLayerUI is
enabled; otherwise this AbstractLayerUI is disabled
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||