Package org.nuiton.jaxx.runtime.swing
Class BlockingLayerUI
- java.lang.Object
-
- javax.swing.plaf.ComponentUI
-
- org.jdesktop.jxlayer.plaf.LayerUI<V>
-
- org.jdesktop.jxlayer.plaf.AbstractLayerUI<JComponent>
-
- org.nuiton.jaxx.runtime.swing.BlockingLayerUI
-
- All Implemented Interfaces:
Serializable
public class BlockingLayerUI extends org.jdesktop.jxlayer.plaf.AbstractLayerUI<JComponent>
A JXLayer ui implementation that permits to block a component but still allow an action when clicking on the right-top icon painted on the layer. You can change the blocking and accepting icon. To hook an click on the layer's icon, you can :- pass an Action via method
setAcceptAction(Action) - override the method
acceptEvent(MouseEvent, JXLayer)
- Since:
- 1.2
- Author:
- Tony Chemit - dev@tchemit.fr
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringACCEPT_ICON_PROPERTYprotected ActionacceptActionAction to be treated when click on iconprotected Set<String>acceptedComponentNamesExtra components names to accept even in block modeprotected Set<Class<?>>acceptedComponentTypesExtra components types to accept even in block modeprotected BufferedImageacceptIconIcon when you can clickprotected booleanblockInternal state when should block event and paint layerstatic StringBLOCK_ICON_PROPERTYstatic StringBLOCK_PROPERTYprotected BufferedImageblockIconIcon when you can not clickprotected ColorblockingColorOptinal color to put fill background when blockingstatic StringCAN_CLICK_PROPERTYprotected booleancanClickInternal state to known when we can accept clickprotected booleanuseIconA flag to enable or disable the use of the icon.
-
Constructor Summary
Constructors Constructor Description BlockingLayerUI()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidacceptEvent(MouseEvent e, org.jdesktop.jxlayer.JXLayer<? extends JComponent> l)booleanacceptEventOrConsumeIt(ActionEvent e)protected booleanacceptEventOrConsumeIt(InputEvent e)BlockingLayerUIclone()protected BufferedImagegetAcceptIcon()BufferedImagegetBlockIcon()protected BufferedImagegetCurrentIcon()booleanisBlock()booleanisCanClick()protected voidpaintLayer(Graphics2D g2, org.jdesktop.jxlayer.JXLayer<? extends JComponent> l)protected BufferedImageprepareIcon(ImageIcon image)protected voidprocessKeyEvent(KeyEvent e, org.jdesktop.jxlayer.JXLayer<? extends JComponent> l)protected voidprocessMouseEvent(MouseEvent e, org.jdesktop.jxlayer.JXLayer<? extends JComponent> l)protected voidprocessMouseMotionEvent(MouseEvent e, org.jdesktop.jxlayer.JXLayer<? extends JComponent> l)protected voidprocessMouseWheelEvent(MouseWheelEvent e, org.jdesktop.jxlayer.JXLayer<? extends JComponent> l)voidsetAcceptAction(Action acceptAction)voidsetAcceptedComponentNames(String... acceptedComponentNames)voidsetAcceptedComponentTypes(Class<?>... acceptedComponentTypes)voidsetAcceptIcon(ImageIcon acceptIcon)voidsetBlock(boolean block)voidsetBlockIcon(BufferedImage blockIcon)voidsetBlockIcon(ImageIcon blockIcon)voidsetBlockingColor(Color blockingColor)voidsetCanClick(boolean canClick)voidsetDirty(boolean isDirty)voidsetUseIcon(boolean useIcon)protected voidupdateCanClickState(org.jdesktop.jxlayer.JXLayer<? extends JComponent> l, MouseEvent e)-
Methods inherited from class org.jdesktop.jxlayer.plaf.AbstractLayerUI
configureGraphics, eventDispatched, getClip, getComposite, getLayerEventMask, getRenderingHints, getTransform, handlePropertyChangeEvent, installUI, isDirty, paint, processFocusEvent, uninstallUI
-
Methods inherited from class javax.swing.plaf.ComponentUI
contains, createUI, getAccessibleChild, getAccessibleChildrenCount, getBaseline, getBaselineResizeBehavior, getMaximumSize, getMinimumSize, getPreferredSize, update
-
Methods inherited from class org.jdesktop.jxlayer.plaf.LayerUI
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, getPreferredScrollableViewportSize, getPropertyChangeListeners, getPropertyChangeListeners, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, removePropertyChangeListener, removePropertyChangeListener, updateUI
-
-
-
-
Field Detail
-
CAN_CLICK_PROPERTY
public static final String CAN_CLICK_PROPERTY
- See Also:
- Constant Field Values
-
ACCEPT_ICON_PROPERTY
public static final String ACCEPT_ICON_PROPERTY
- See Also:
- Constant Field Values
-
BLOCK_ICON_PROPERTY
public static final String BLOCK_ICON_PROPERTY
- See Also:
- Constant Field Values
-
BLOCK_PROPERTY
public static final String BLOCK_PROPERTY
- See Also:
- Constant Field Values
-
acceptAction
protected Action acceptAction
Action to be treated when click on icon
-
blockIcon
protected BufferedImage blockIcon
Icon when you can not click
-
acceptIcon
protected BufferedImage acceptIcon
Icon when you can click
-
blockingColor
protected Color blockingColor
Optinal color to put fill background when blocking
-
canClick
protected boolean canClick
Internal state to known when we can accept click
-
useIcon
protected boolean useIcon
A flag to enable or disable the use of the icon. If set to false, no icon will be displayed and no action will be possible. By default, this is active.
-
block
protected boolean block
Internal state when should block event and paint layer
-
acceptedComponentNames
protected final Set<String> acceptedComponentNames
Extra components names to accept even in block mode
-
-
Method Detail
-
isBlock
public boolean isBlock()
-
setAcceptedComponentNames
public void setAcceptedComponentNames(String... acceptedComponentNames)
-
setAcceptedComponentTypes
public void setAcceptedComponentTypes(Class<?>... acceptedComponentTypes)
-
setAcceptAction
public void setAcceptAction(Action acceptAction)
-
setAcceptIcon
public void setAcceptIcon(ImageIcon acceptIcon)
-
setBlockIcon
public void setBlockIcon(ImageIcon blockIcon)
-
setCanClick
public void setCanClick(boolean canClick)
-
setBlock
public void setBlock(boolean block)
-
setDirty
public void setDirty(boolean isDirty)
- Overrides:
setDirtyin classorg.jdesktop.jxlayer.plaf.AbstractLayerUI<JComponent>
-
setBlockIcon
public void setBlockIcon(BufferedImage blockIcon)
-
setBlockingColor
public void setBlockingColor(Color blockingColor)
-
getBlockIcon
public BufferedImage getBlockIcon()
-
getAcceptIcon
protected BufferedImage getAcceptIcon()
-
isCanClick
public boolean isCanClick()
-
setUseIcon
public void setUseIcon(boolean useIcon)
-
clone
public BlockingLayerUI clone() throws CloneNotSupportedException
- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-
processKeyEvent
protected void processKeyEvent(KeyEvent e, org.jdesktop.jxlayer.JXLayer<? extends JComponent> l)
- Overrides:
processKeyEventin classorg.jdesktop.jxlayer.plaf.AbstractLayerUI<JComponent>
-
processMouseMotionEvent
protected void processMouseMotionEvent(MouseEvent e, org.jdesktop.jxlayer.JXLayer<? extends JComponent> l)
- Overrides:
processMouseMotionEventin classorg.jdesktop.jxlayer.plaf.AbstractLayerUI<JComponent>
-
processMouseEvent
protected void processMouseEvent(MouseEvent e, org.jdesktop.jxlayer.JXLayer<? extends JComponent> l)
- Overrides:
processMouseEventin classorg.jdesktop.jxlayer.plaf.AbstractLayerUI<JComponent>
-
processMouseWheelEvent
protected void processMouseWheelEvent(MouseWheelEvent e, org.jdesktop.jxlayer.JXLayer<? extends JComponent> l)
- Overrides:
processMouseWheelEventin classorg.jdesktop.jxlayer.plaf.AbstractLayerUI<JComponent>
-
acceptEventOrConsumeIt
protected boolean acceptEventOrConsumeIt(InputEvent e)
-
acceptEventOrConsumeIt
public boolean acceptEventOrConsumeIt(ActionEvent e)
-
paintLayer
protected void paintLayer(Graphics2D g2, org.jdesktop.jxlayer.JXLayer<? extends JComponent> l)
- Overrides:
paintLayerin classorg.jdesktop.jxlayer.plaf.AbstractLayerUI<JComponent>
-
acceptEvent
protected void acceptEvent(MouseEvent e, org.jdesktop.jxlayer.JXLayer<? extends JComponent> l)
-
getCurrentIcon
protected BufferedImage getCurrentIcon()
-
prepareIcon
protected BufferedImage prepareIcon(ImageIcon image)
-
updateCanClickState
protected void updateCanClickState(org.jdesktop.jxlayer.JXLayer<? extends JComponent> l, MouseEvent e)
-
-