jaxx.runtime.swing
Class BlockingLayerUI

java.lang.Object
  extended by javax.swing.plaf.ComponentUI
      extended by org.jdesktop.jxlayer.plaf.LayerUI<V>
          extended by org.jdesktop.jxlayer.plaf.AbstractLayerUI<JComponent>
              extended by jaxx.runtime.swing.BlockingLayerUI
All Implemented Interfaces:
org.jdesktop.jxlayer.plaf.item.LayerItem

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 :

Since:
1.2
Author:
tchemit

Field Summary
static String ACCEPT_ICON_PROPERTY
           
protected  Action acceptAction
          Action to be treated when click on icon
protected  List<String> acceptedComponentNames
          Extra components names to accept even in block mode
protected  BufferedImage acceptIcon
          Icon when you can click
protected  boolean block
          Internal state when should block event and paint layer
static String BLOCK_ICON_PROPERTY
           
static String BLOCK_PROPERTY
           
protected  BufferedImage blockIcon
          Icon when you can not click
protected  Color blockingColor
          Optinal color to put fill background when blocking
static String CAN_CLICK_PROPERTY
           
protected  boolean canClick
          Internal state to known when we can accept click
protected  boolean useIcon
          A flag to enable or disable the use of the icon.
 
Constructor Summary
BlockingLayerUI()
           
 
Method Summary
protected  void acceptEvent(MouseEvent e, org.jdesktop.jxlayer.JXLayer<JComponent> l)
           
 BlockingLayerUI clone()
           
protected  BufferedImage getAcceptIcon()
           
 BufferedImage getBlockIcon()
           
protected  BufferedImage getCurrentIcon()
           
 boolean isCanClick()
           
protected  void paintLayer(Graphics2D g2, org.jdesktop.jxlayer.JXLayer<JComponent> l)
           
protected  BufferedImage prepareIcon(ImageIcon image)
           
protected  void processKeyEvent(KeyEvent e, org.jdesktop.jxlayer.JXLayer<JComponent> l)
           
protected  void processMouseEvent(MouseEvent e, org.jdesktop.jxlayer.JXLayer<JComponent> l)
           
protected  void processMouseMotionEvent(MouseEvent e, org.jdesktop.jxlayer.JXLayer<JComponent> l)
           
 void setAcceptAction(Action acceptAction)
           
 void setAcceptedComponentNames(String... acceptedComponentNames)
           
 void setAcceptIcon(ImageIcon acceptIcon)
           
 void setBlock(boolean block)
           
 void setBlockIcon(BufferedImage blockIcon)
           
 void setBlockIcon(ImageIcon blockIcon)
           
 void setBlockingColor(Color blockingColor)
           
 void setCanClick(boolean canClick)
           
 void setDirty(boolean isDirty)
           
 void setUseIcon(boolean useIcon)
           
protected  void updateCanClickState(org.jdesktop.jxlayer.JXLayer<JComponent> l, MouseEvent e)
           
 
Methods inherited from class org.jdesktop.jxlayer.plaf.AbstractLayerUI
addLayerItemListener, addPropertyChangeListener, addPropertyChangeListener, configureGraphics, eventDispatched, fireLayerItemChanged, fireLayerItemChanged, firePropertyChange, getClip, getComposite, getLayerEventMask, getLayerItemListeners, getPropertyChangeListeners, getPropertyChangeListeners, getRenderingHints, getTransform, installUI, isAWTEventListenerEnabled, isDirty, isEnabled, paint, processFocusEvent, processMouseWheelEvent, registerAWTEventListener, removeLayerItemListener, removePropertyChangeListener, removePropertyChangeListener, setEnabled, setLayerEventMask, uninstallUI, unregisterAWTEventListener
 
Methods inherited from class org.jdesktop.jxlayer.plaf.LayerUI
getAccessibleChild, getAccessibleChildrenCount, getPreferredScrollableViewportSize, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, isEventEnabled, update, updateUI
 
Methods inherited from class javax.swing.plaf.ComponentUI
contains, createUI, getBaseline, getBaselineResizeBehavior, getMaximumSize, getMinimumSize, getPreferredSize
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 List<String> acceptedComponentNames
Extra components names to accept even in block mode

Constructor Detail

BlockingLayerUI

public BlockingLayerUI()
Method Detail

setAcceptedComponentNames

public void setAcceptedComponentNames(String... acceptedComponentNames)

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:
setDirty in class org.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()
Overrides:
clone in class Object

processKeyEvent

protected void processKeyEvent(KeyEvent e,
                               org.jdesktop.jxlayer.JXLayer<JComponent> l)
Overrides:
processKeyEvent in class org.jdesktop.jxlayer.plaf.AbstractLayerUI<JComponent>

processMouseMotionEvent

protected void processMouseMotionEvent(MouseEvent e,
                                       org.jdesktop.jxlayer.JXLayer<JComponent> l)
Overrides:
processMouseMotionEvent in class org.jdesktop.jxlayer.plaf.AbstractLayerUI<JComponent>

processMouseEvent

protected void processMouseEvent(MouseEvent e,
                                 org.jdesktop.jxlayer.JXLayer<JComponent> l)
Overrides:
processMouseEvent in class org.jdesktop.jxlayer.plaf.AbstractLayerUI<JComponent>

paintLayer

protected void paintLayer(Graphics2D g2,
                          org.jdesktop.jxlayer.JXLayer<JComponent> l)
Overrides:
paintLayer in class org.jdesktop.jxlayer.plaf.AbstractLayerUI<JComponent>

acceptEvent

protected void acceptEvent(MouseEvent e,
                           org.jdesktop.jxlayer.JXLayer<JComponent> l)

getCurrentIcon

protected BufferedImage getCurrentIcon()

prepareIcon

protected BufferedImage prepareIcon(ImageIcon image)

updateCanClickState

protected void updateCanClickState(org.jdesktop.jxlayer.JXLayer<JComponent> l,
                                   MouseEvent e)


Copyright © 2008-2011 CodeLutin. All Rights Reserved.