com.tensegrity.gui.swing.control
Class PaintFormatComboBox

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.AbstractButton
                  extended byjavax.swing.JButton
                      extended bycom.tensegrity.gui.swing.control.multiselect.MultiSelectComboBox
                          extended bycom.tensegrity.gui.swing.control.PaintFormatComboBox
All Implemented Interfaces:
javax.accessibility.Accessible, Evaluable, java.util.EventListener, java.awt.image.ImageObserver, java.awt.event.ItemListener, java.awt.ItemSelectable, java.awt.MenuContainer, java.io.Serializable, javax.swing.SwingConstants
Direct Known Subclasses:
GradientComboBox, PatternComboBox, TextureComboBox

public abstract class PaintFormatComboBox
extends MultiSelectComboBox

This class is the abstract class for all type of PaintFormat related ComboBox controls. It already implements the necessary mechanism for creating and updating the label as well as creating the right ItemEvent on selections. This class should be used to implement all possible variations of a PaintFormat, like Gradient, Pattern, Texture, etc.

Version:
$Id: PaintFormatComboBox.java,v 1.36 2005/09/13 13:49:01 BurkhardWick Exp $
Author:
Gilles Iachelini
See Also:
PaintFormat, GradientComboBox, PatternComboBox, TextureComboBox, Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JButton
javax.swing.JButton.AccessibleJButton
 
Nested classes inherited from class javax.swing.AbstractButton
javax.swing.AbstractButton.AccessibleAbstractButton, javax.swing.AbstractButton.ButtonChangeListener
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  com.tensegrity.gui.swing.control.PaintFormatComboBox.ColorMenu backgroundMenuItem
          Menu instance for the background of the paint instance.
protected  com.tensegrity.gui.swing.control.PaintFormatComboBox.CustomColorPanel backgroundPanel
          Panel holding control to launch the ColorChooser and the currently selected custom color.
protected  com.tensegrity.gui.swing.control.PaintFormatComboBox.ColorMenu foregroundMenuItem
          Menu instance for the foreground of the paint instance.
protected  com.tensegrity.gui.swing.control.PaintFormatComboBox.CustomColorPanel foregroundPanel
          Panel holding control to launch the ColorChooser and the currently selected custom color.
protected  int paintColorback
          The background color.
protected  int paintColorfore
          The foreground color.
 
Fields inherited from class com.tensegrity.gui.swing.control.multiselect.MultiSelectComboBox
listeners, multiSelect, uiItemEvList, uiManager
 
Fields inherited from class javax.swing.AbstractButton
actionListener, BORDER_PAINTED_CHANGED_PROPERTY, changeEvent, changeListener, CONTENT_AREA_FILLED_CHANGED_PROPERTY, DISABLED_ICON_CHANGED_PROPERTY, DISABLED_SELECTED_ICON_CHANGED_PROPERTY, FOCUS_PAINTED_CHANGED_PROPERTY, HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY, HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY, ICON_CHANGED_PROPERTY, itemListener, MARGIN_CHANGED_PROPERTY, MNEMONIC_CHANGED_PROPERTY, model, MODEL_CHANGED_PROPERTY, PRESSED_ICON_CHANGED_PROPERTY, ROLLOVER_ENABLED_CHANGED_PROPERTY, ROLLOVER_ICON_CHANGED_PROPERTY, ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY, SELECTED_ICON_CHANGED_PROPERTY, TEXT_CHANGED_PROPERTY, VERTICAL_ALIGNMENT_CHANGED_PROPERTY, VERTICAL_TEXT_POSITION_CHANGED_PROPERTY
 
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 javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
PaintFormatComboBox(UIManager uiManager)
          Creates the PaintFormatComboBox.
 
Method Summary
protected  void createCombo()
          Adds a custom panel to the multiselect.
protected  javax.swing.JLabel createLabel()
          Returns a new PaintFormatLabel.
protected  java.awt.event.ItemEvent getItemEvent(MultiSelectItem item)
          Returns a new ItemEvent with this combo as source and a PaintFormat instance as item.
 void init(int colorFore, int colorBack, int index)
          Method init initializes the PaintFormatComboBox with the given forground-, background color and the sets the item with the index in the multiselect as selected.
 void setBackgroundColor(int c)
          Method setBackgroundColor sets the background color of this ComboBox.
 void setForegroundColor(int c)
          Method setForegroundColor sets the foreground color of this ComboBox.
 void updateCombo(int colorback, int colorfore)
          Updates the label and each item of the internal multiSelect with the given paintformat instance without changing the style.
protected  void updateItemLabel(MultiSelectItem item)
          Updates the label with the PaintFormat from the given item.
protected abstract  boolean usesColorCombos()
          Subclasses must specify whether they wish to have two additional entries within their ComboBox, to let users specify a back- and foreground color.
 
Methods inherited from class com.tensegrity.gui.swing.control.multiselect.MultiSelectComboBox
addItemListener, applyEvList, createMultiSelect, fireEvent, fireEvent, getItemLabel, getMinimumSize, getMultiSelect, getPopup, getPreferredSize, getSelectedIndex, getSelectedObjects, getSelection, indexOf, installEvList, itemStateChanged, paintChildren, removeItemListener, setEnabled, setSelectedIndex, togglePopup
 
Methods inherited from class javax.swing.JButton
configurePropertiesFromAction, getAccessibleContext, getUIClassID, isDefaultButton, isDefaultCapable, paramString, removeNotify, setDefaultCapable, updateUI
 
Methods inherited from class javax.swing.AbstractButton
addActionListener, addChangeListener, checkHorizontalKey, checkVerticalKey, createActionListener, createActionPropertyChangeListener, createChangeListener, createItemListener, doClick, doClick, fireActionPerformed, fireItemStateChanged, fireStateChanged, getAction, getActionCommand, getActionListeners, getChangeListeners, getDisabledIcon, getDisabledSelectedIcon, getDisplayedMnemonicIndex, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getItemListeners, getLabel, getMargin, getMnemonic, getModel, getMultiClickThreshhold, getPressedIcon, getRolloverIcon, getRolloverSelectedIcon, getSelectedIcon, getText, getUI, getVerticalAlignment, getVerticalTextPosition, imageUpdate, init, isBorderPainted, isContentAreaFilled, isFocusPainted, isRolloverEnabled, isSelected, paintBorder, removeActionListener, removeChangeListener, setAction, setActionCommand, setBorderPainted, setContentAreaFilled, setDisabledIcon, setDisabledSelectedIcon, setDisplayedMnemonicIndex, setFocusPainted, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabel, setMargin, setMnemonic, setMnemonic, setModel, setMultiClickThreshhold, setPressedIcon, setRolloverEnabled, setRolloverIcon, setRolloverSelectedIcon, setSelected, setSelectedIcon, setText, setUI, setVerticalAlignment, setVerticalTextPosition
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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

paintColorback

protected int paintColorback
The background color.

See Also:
PaintFormat

paintColorfore

protected int paintColorfore
The foreground color.

See Also:
PaintFormat

foregroundMenuItem

protected com.tensegrity.gui.swing.control.PaintFormatComboBox.ColorMenu foregroundMenuItem
Menu instance for the foreground of the paint instance.


backgroundMenuItem

protected com.tensegrity.gui.swing.control.PaintFormatComboBox.ColorMenu backgroundMenuItem
Menu instance for the background of the paint instance.


foregroundPanel

protected com.tensegrity.gui.swing.control.PaintFormatComboBox.CustomColorPanel foregroundPanel
Panel holding control to launch the ColorChooser and the currently selected custom color.


backgroundPanel

protected com.tensegrity.gui.swing.control.PaintFormatComboBox.CustomColorPanel backgroundPanel
Panel holding control to launch the ColorChooser and the currently selected custom color.

Constructor Detail

PaintFormatComboBox

public PaintFormatComboBox(UIManager uiManager)
Creates the PaintFormatComboBox.

Parameters:
uiManager - the UIManager instance to obtain localized strings from.
Method Detail

usesColorCombos

protected abstract boolean usesColorCombos()
Subclasses must specify whether they wish to have two additional entries within their ComboBox, to let users specify a back- and foreground color. Return true indicates that the createCombo() method will add two menu entries to the combobox. If no such entries should be added, return false.

Returns:
a boolean that indicates whether the two color menu entries should be added or not.

createCombo

protected void createCombo()
Adds a custom panel to the multiselect.

Overrides:
createCombo in class MultiSelectComboBox
See Also:
MultiSelectComboBox.createCombo()

init

public void init(int colorFore,
                 int colorBack,
                 int index)
Method init initializes the PaintFormatComboBox with the given forground-, background color and the sets the item with the index in the multiselect as selected. Use this method to change any of the parameter values of the ComboBox, if you need to avoid to overwrite the passed variables, because of the triggered events. Note: Each call to setForeground or setBackgroud would fire an itemStateChanged, which may then result in overwriting the passed values (Dialog scenario, where a FormatComboBox operates on class member).

Parameters:
colorFore - Foreground color as integer.
colorBack - Background color as integer.
index - the index of the selected item of the multiselect.

setForegroundColor

public void setForegroundColor(int c)
Method setForegroundColor sets the foreground color of this ComboBox. An itemStateChanged will be fired, when the ColorComboBox receives its setSelectedColor/-Index call.

Parameters:
c - the color as integer.

setBackgroundColor

public void setBackgroundColor(int c)
Method setBackgroundColor sets the background color of this ComboBox. An itemStateChanged will be fired, when the ColorComboBox receives its setSelectedColor/-Index call.

Parameters:
c - the color as integer.

getItemEvent

protected java.awt.event.ItemEvent getItemEvent(MultiSelectItem item)
Returns a new ItemEvent with this combo as source and a PaintFormat instance as item.

Overrides:
getItemEvent in class MultiSelectComboBox
Parameters:
item - The item which has been selected by user.
Returns:
ItemEvent a newly created ItemEvent instance.
See Also:
MultiSelectComboBox.getItemEvent(MultiSelectItem)

updateItemLabel

protected void updateItemLabel(MultiSelectItem item)
Updates the label with the PaintFormat from the given item.

Specified by:
updateItemLabel in class MultiSelectComboBox
Parameters:
item - the selected item.
See Also:
MultiSelectComboBox.updateItemLabel(MultiSelectItem)

createLabel

protected javax.swing.JLabel createLabel()
Returns a new PaintFormatLabel.

Specified by:
createLabel in class MultiSelectComboBox
Returns:
the label to be used.
See Also:
MultiSelectComboBox.createLabel()

updateCombo

public void updateCombo(int colorback,
                        int colorfore)
Updates the label and each item of the internal multiSelect with the given paintformat instance without changing the style.

Parameters:
colorback - the background color as rgb int.
colorfore - the foreground color as rgb int.


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.