bibliothek.extension.gui.dock.theme.bubble
Class RoundButton

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by bibliothek.extension.gui.dock.theme.bubble.RoundButton
All Implemented Interfaces:
RoundButtonConnectable, ImageObserver, MenuContainer, Serializable

@ColorCodes(value={"action.button","action.button.focus","action.button.enabled","action.button.enabled.focus","action.button.selected","action.button.selected.focus","action.button.selected.enabled","action.button.selected.enabled.focus","action.button.mouse.enabled","action.button.mouse.enabled.focus","action.button.mouse.selected.enabled","action.button.mouse.selected.enabled.focus","action.button.pressed.enabled","action.button.pressed.enabled.focus","action.button.pressed.selected.enabled","action.button.pressed.selected.enabled.focus","action.button.text","action.button.text.enabled","action.button.text.selected","action.button.text.selected.enabled","action.button.text.mouse.enabled","action.button.text.mouse.selected.enabled","action.button.text.pressed.enabled","action.button.text.pressed.selected.enabled"})
public class RoundButton
extends JComponent
implements RoundButtonConnectable

A round button is a button that has a oval form. Clients should call setController(DockController) for optimal usage.

Author:
Benjamin Sigg
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
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
RoundButton(BasicTrigger trigger, BasicResourceInitializer initializer, Dockable dockable, DockAction action)
          Creates a new round button.
 
Method Summary
protected  void animate(String key, String color)
          Searches for the AbstractDockColor with id color and sets this color in the animation.
 boolean contains(int x, int y)
           
protected  MiniButtonContent createButtonContent()
          Creates the component that shows the contents of this button.
protected  AbstractDockColor createColor(String key, Dockable dockable, DockAction action, Color backup)
          Creates a new DockColor representing one color used by this button.
protected  AbstractDockColor[] createColors(Dockable dockable, DockAction action)
           
 void doLayout()
           
protected  void doPaintBackground(Graphics g)
          Paints the background of this button.
protected  void doPaintForeground(Graphics g)
          Paints the foreground of this button.
protected  BubbleColorAnimation getAnimation()
          Access to the BubbleColorAnimation which is responsible for repainting this button.
protected  MiniButtonContent getContent()
          Gets the content component of this button.
 BasicButtonModel getModel()
           
 Dimension getPreferredSize()
           
 boolean isPaintFocusBorder()
          Tells whether a special border is painted if this button is focused.
protected  void paintComponent(Graphics g)
           
 void setController(DockController controller)
          Connects this button with a controller, that is necessary to get the colors for this button.
 void setPaintFocusBorder(boolean paintFocusBorder)
          Sets whether a special border should be painted if this button is focused.
protected  void updateColors()
          Reads all DockColors of this RoundButton and updates the animation if necessary.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, 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, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, 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, inside, 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
 

Constructor Detail

RoundButton

public RoundButton(BasicTrigger trigger,
                   BasicResourceInitializer initializer,
                   Dockable dockable,
                   DockAction action)
Creates a new round button.

Parameters:
trigger - a trigger which gets informed when the user clicks the button.
initializer - a strategy to lazily initialize resources, can be null
dockable - the dockable for which this button is used
action - the action for which this button is used
Method Detail

createButtonContent

protected MiniButtonContent createButtonContent()
Creates the component that shows the contents of this button.

Returns:
the new component

createColors

protected AbstractDockColor[] createColors(Dockable dockable,
                                           DockAction action)

createColor

protected AbstractDockColor createColor(String key,
                                        Dockable dockable,
                                        DockAction action,
                                        Color backup)
Creates a new DockColor representing one color used by this button.

Parameters:
key - the unique identifier of the color
dockable - the dockable for which the color is used, may be null
action - the action represented by this button, may be null
backup - the backup color that is used if no other color was found
Returns:
the new DockColor

getAnimation

protected BubbleColorAnimation getAnimation()
Access to the BubbleColorAnimation which is responsible for repainting this button. Subclasses may use this method to insert or modify custom colors.

Returns:
the animtation

setPaintFocusBorder

public void setPaintFocusBorder(boolean paintFocusBorder)
Sets whether a special border should be painted if this button is focused.

Parameters:
paintFocusBorder - whether to paint the border

isPaintFocusBorder

public boolean isPaintFocusBorder()
Tells whether a special border is painted if this button is focused.

Returns:
whether to paint a special border

setController

public void setController(DockController controller)
Connects this button with a controller, that is necessary to get the colors for this button.

Specified by:
setController in interface RoundButtonConnectable
Parameters:
controller - the controller, can be null

getModel

public BasicButtonModel getModel()

contains

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

getContent

protected MiniButtonContent getContent()
Gets the content component of this button.

Returns:
the component that paints icon and text

getPreferredSize

public Dimension getPreferredSize()
Overrides:
getPreferredSize in class JComponent

doLayout

public void doLayout()
Overrides:
doLayout in class Container

paintComponent

protected void paintComponent(Graphics g)
Overrides:
paintComponent in class JComponent

doPaintBackground

protected void doPaintBackground(Graphics g)
Paints the background of this button.

Parameters:
g - the graphics context to use

doPaintForeground

protected void doPaintForeground(Graphics g)
Paints the foreground of this button.

Parameters:
g - the graphics context to use

updateColors

protected void updateColors()
Reads all DockColors of this RoundButton and updates the animation if necessary.


animate

protected void animate(String key,
                       String color)
Searches for the AbstractDockColor with id color and sets this color in the animation.

Parameters:
key - the key of the color in the animation
color - the key of the AbstractDockColor