net.infonode.gui.shaped.panel
Class ShapedPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by net.infonode.gui.panel.BaseContainer
                      extended by net.infonode.gui.shaped.panel.ShapedPanel
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, BackgroundPainter
Direct Known Subclasses:
HoverableShapedPanel

public class ShapedPanel
extends BaseContainer
implements BackgroundPainter

A panel that has support for a ComponentPainter and a ShapedBorder. The background of the panel is painted as normal and then the ComponentPainter paints the area inside the ShapedBorder or the complete component area if the its border isn't a ShapedBorder.

If a ShapedBorder is applied to this panel, mouse events etc. are only triggered for this panel if the point is inside the Shape of the ShapedBorder. Child components of this panel can optionally be clipped using the Shape.

A ShapedBorder wrapped inside CompoundBorder's will be used by the ShapedPanel, but a ShapedBorder wrapped inside other border types can't be found and is hence not used by the panel.

Author:
johan
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private  boolean clipChildren
           
private  Direction direction
           
private  boolean horizontalFlip
           
private  ComponentPainter painter
           
private  ShapedBorder shapedBorder
           
private  java.awt.Insets shapedInsets
           
private  boolean verticalFlip
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ShapedPanel()
           
ShapedPanel(java.awt.Component component)
           
ShapedPanel(ComponentPainter painter)
           
ShapedPanel(ComponentPainter painter, javax.swing.border.Border border)
           
ShapedPanel(java.awt.LayoutManager l)
           
 
Method Summary
 boolean contains(int x, int y)
           
private  boolean findShapedBorder(javax.swing.border.Border border, java.awt.Insets i)
           
 ComponentPainter getComponentPainter()
          Returns the ComponentPainter that is used to paint the background of this object.
 Direction getDirection()
           
 java.awt.Shape getShape()
           
 ShapedBorder getShapedBorder()
           
 boolean inside(int x, int y)
           
 boolean isClipChildren()
           
 boolean isHorizontalFlip()
           
 boolean isVerticalFlip()
           
protected  void paintChildren(java.awt.Graphics g)
           
protected  void paintComponent(java.awt.Graphics g)
           
 void setBorder(javax.swing.border.Border border)
           
 void setClipChildren(boolean clipChildren)
           
 void setComponentPainter(ComponentPainter painter)
           
 void setDirection(Direction direction)
           
 void setHorizontalFlip(boolean horizontalFlip)
           
 void setVerticalFlip(boolean verticalFlip)
           
 
Methods inherited from class net.infonode.gui.panel.BaseContainer
setBackground, setFont, setForeground, setOpaque, setUI
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

direction

private Direction direction

horizontalFlip

private boolean horizontalFlip

verticalFlip

private boolean verticalFlip

clipChildren

private boolean clipChildren

painter

private ComponentPainter painter

shapedBorder

private ShapedBorder shapedBorder

shapedInsets

private java.awt.Insets shapedInsets
Constructor Detail

ShapedPanel

public ShapedPanel()

ShapedPanel

public ShapedPanel(java.awt.LayoutManager l)

ShapedPanel

public ShapedPanel(ComponentPainter painter)

ShapedPanel

public ShapedPanel(ComponentPainter painter,
                   javax.swing.border.Border border)

ShapedPanel

public ShapedPanel(java.awt.Component component)
Method Detail

getShape

public java.awt.Shape getShape()

getComponentPainter

public ComponentPainter getComponentPainter()
Description copied from interface: BackgroundPainter
Returns the ComponentPainter that is used to paint the background of this object.

Specified by:
getComponentPainter in interface BackgroundPainter
Returns:
the ComponentPainter that is used to paint the background of this object, null if there is none

setComponentPainter

public void setComponentPainter(ComponentPainter painter)

getDirection

public Direction getDirection()

isHorizontalFlip

public boolean isHorizontalFlip()

setHorizontalFlip

public void setHorizontalFlip(boolean horizontalFlip)

isVerticalFlip

public boolean isVerticalFlip()

setVerticalFlip

public void setVerticalFlip(boolean verticalFlip)

setDirection

public void setDirection(Direction direction)

isClipChildren

public boolean isClipChildren()

setClipChildren

public void setClipChildren(boolean clipChildren)

getShapedBorder

public ShapedBorder getShapedBorder()

setBorder

public void setBorder(javax.swing.border.Border border)
Overrides:
setBorder in class javax.swing.JComponent

paintChildren

protected void paintChildren(java.awt.Graphics g)
Overrides:
paintChildren in class javax.swing.JComponent

paintComponent

protected void paintComponent(java.awt.Graphics g)
Overrides:
paintComponent in class BaseContainer

contains

public boolean contains(int x,
                        int y)
Overrides:
contains in class javax.swing.JComponent

inside

public boolean inside(int x,
                      int y)
Overrides:
inside in class java.awt.Component

findShapedBorder

private boolean findShapedBorder(javax.swing.border.Border border,
                                 java.awt.Insets i)