JHotDraw 7.0.9

org.jhotdraw.draw.action
Class ButtonFactory

java.lang.Object
  extended by org.jhotdraw.draw.action.ButtonFactory

public class ButtonFactory
extends java.lang.Object

ButtonFactory.

Version:
2.0 2007-03-31 Renamed from ToolBarButtonFactory to ButtonFactory. Replaced most add...ButtonTo methods by create...Button methods.
1.3 2006-12-29 Split methods even more up. Added additional buttons.
1.2 2006-07-16 Split some methods up for better reuse.
1.1 2006-03-27 Font exclusion list updated.
1.0 13. Februar 2006 Created.
Author:
Werner Randelshofer

Field Summary
static java.util.Map<java.lang.String,java.awt.Color> DEFAULT_COLORS
           
 
Method Summary
static void addAlignmentButtonsTo(javax.swing.JToolBar bar, DrawingEditor editor)
          Creates toolbar buttons and adds them to the specified JToolBar
static void addAttributesButtonsTo(javax.swing.JToolBar bar, DrawingEditor editor)
          Creates toolbar buttons and adds them to the specified JToolBar
static void addColorButtonsTo(javax.swing.JToolBar bar, DrawingEditor editor)
           
static void addFontButtonsTo(javax.swing.JToolBar bar, DrawingEditor editor)
           
static javax.swing.JToggleButton addSelectionToolTo(javax.swing.JToolBar tb, DrawingEditor editor)
           
static javax.swing.JToggleButton addSelectionToolTo(javax.swing.JToolBar tb, DrawingEditor editor, java.util.Collection<javax.swing.Action> drawingActions, java.util.Collection<javax.swing.Action> selectionActions)
           
static void addStrokeButtonsTo(javax.swing.JToolBar bar, DrawingEditor editor)
           
static javax.swing.JToggleButton addToolTo(javax.swing.JToolBar tb, DrawingEditor editor, Tool tool, java.lang.String labelKey, ResourceBundleUtil labels)
          Method addSelectionToolTo must have been invoked prior to this on the JToolBar.
static void addZoomButtonsTo(javax.swing.JToolBar bar, DrawingEditor editor)
           
static javax.swing.JButton createApplyAttributesButton(DrawingEditor editor)
          Creates a button that applies the default attributes of the editor to the current selection.
static java.util.Collection<javax.swing.Action> createDrawingActions(DrawingEditor editor)
           
static JPopupButton createEditorColorButton(DrawingEditor editor, AttributeKey attributeKey, java.util.Map<java.lang.String,java.awt.Color> colorMap, int columnCount, java.lang.String labelKey, ResourceBundleUtil labels)
          Creates a color button, with an action region and a popup menu.
static JPopupButton createEditorColorButton(DrawingEditor editor, AttributeKey attributeKey, java.util.Map<java.lang.String,java.awt.Color> colorMap, int columnCount, java.lang.String labelKey, ResourceBundleUtil labels, java.util.Map<AttributeKey,java.lang.Object> defaultAttributes)
          Creates a color button, with an action region and a popup menu.
static JPopupButton createEditorColorButton(DrawingEditor editor, AttributeKey attributeKey, java.util.Map<java.lang.String,java.awt.Color> colorMap, int columnCount, java.lang.String labelKey, ResourceBundleUtil labels, java.util.Map<AttributeKey,java.lang.Object> defaultAttributes, java.awt.Shape colorShape)
          Creates a color button, with an action region and a popup menu.
static JPopupButton createFontButton(DrawingEditor editor)
           
static JPopupButton createFontButton(DrawingEditor editor, ResourceBundleUtil labels)
           
static javax.swing.JButton createFontStyleBoldButton(DrawingEditor editor)
           
static javax.swing.JButton createFontStyleBoldButton(DrawingEditor editor, ResourceBundleUtil labels)
           
static javax.swing.JButton createFontStyleItalicButton(DrawingEditor editor)
           
static javax.swing.JButton createFontStyleItalicButton(DrawingEditor editor, ResourceBundleUtil labels)
           
static javax.swing.JButton createFontStyleUnderlineButton(DrawingEditor editor)
           
static javax.swing.JButton createFontStyleUnderlineButton(DrawingEditor editor, ResourceBundleUtil labels)
           
static javax.swing.JButton createPickAttributesButton(DrawingEditor editor)
           
static java.util.Collection<javax.swing.Action> createSelectionActions(DrawingEditor editor)
           
static JPopupButton createSelectionColorButton(DrawingEditor editor, AttributeKey attributeKey, java.util.Map<java.lang.String,java.awt.Color> colorMap, int columnCount, java.lang.String labelKey, ResourceBundleUtil labels)
           
static JPopupButton createSelectionColorButton(DrawingEditor editor, AttributeKey attributeKey, java.util.Map<java.lang.String,java.awt.Color> colorMap, int columnCount, java.lang.String labelKey, ResourceBundleUtil labels, java.util.Map<AttributeKey,java.lang.Object> defaultAttributes)
           
static JPopupButton createSelectionColorButton(DrawingEditor editor, AttributeKey attributeKey, java.util.Map<java.lang.String,java.awt.Color> colorMap, int columnCount, java.lang.String labelKey, ResourceBundleUtil labels, java.util.Map<AttributeKey,java.lang.Object> defaultAttributes, java.awt.Shape colorShape)
          Creates a color button, with an action region and a popup menu.
static JPopupButton createStrokeCapButton(DrawingEditor editor)
           
static JPopupButton createStrokeCapButton(DrawingEditor editor, ResourceBundleUtil labels)
           
static JPopupButton createStrokeDashesButton(DrawingEditor editor)
           
static JPopupButton createStrokeDashesButton(DrawingEditor editor, double[][] dashes)
           
static JPopupButton createStrokeDashesButton(DrawingEditor editor, double[][] dashes, ResourceBundleUtil labels)
           
static JPopupButton createStrokeDashesButton(DrawingEditor editor, ResourceBundleUtil labels)
           
static JPopupButton createStrokeDecorationButton(DrawingEditor editor)
           
static JPopupButton createStrokeJoinButton(DrawingEditor editor)
           
static JPopupButton createStrokeJoinButton(DrawingEditor editor, ResourceBundleUtil labels)
           
static JPopupButton createStrokePlacementButton(DrawingEditor editor)
           
static JPopupButton createStrokeTypeButton(DrawingEditor editor)
           
static JPopupButton createStrokeWidthButton(DrawingEditor editor)
           
static JPopupButton createStrokeWidthButton(DrawingEditor editor, double[] widths)
           
static JPopupButton createStrokeWidthButton(DrawingEditor editor, double[] widths, ResourceBundleUtil labels)
           
static JPopupButton createStrokeWidthButton(DrawingEditor editor, ResourceBundleUtil labels)
           
static javax.swing.AbstractButton createToggleGridButton(DrawingEditor editor)
          Creates toolbar buttons and adds them to the specified JToolBar
static javax.swing.AbstractButton createToggleGridButton(DrawingView view)
          Creates toolbar buttons and adds them to the specified JToolBar
static javax.swing.AbstractButton createZoomButton(DrawingEditor editor)
           
static javax.swing.AbstractButton createZoomButton(DrawingView view)
           
static javax.swing.AbstractButton createZoomButton(DrawingView view, double[] factors)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_COLORS

public static final java.util.Map<java.lang.String,java.awt.Color> DEFAULT_COLORS
Method Detail

createDrawingActions

public static java.util.Collection<javax.swing.Action> createDrawingActions(DrawingEditor editor)

createSelectionActions

public static java.util.Collection<javax.swing.Action> createSelectionActions(DrawingEditor editor)

addSelectionToolTo

public static javax.swing.JToggleButton addSelectionToolTo(javax.swing.JToolBar tb,
                                                           DrawingEditor editor)

addSelectionToolTo

public static javax.swing.JToggleButton addSelectionToolTo(javax.swing.JToolBar tb,
                                                           DrawingEditor editor,
                                                           java.util.Collection<javax.swing.Action> drawingActions,
                                                           java.util.Collection<javax.swing.Action> selectionActions)

addToolTo

public static javax.swing.JToggleButton addToolTo(javax.swing.JToolBar tb,
                                                  DrawingEditor editor,
                                                  Tool tool,
                                                  java.lang.String labelKey,
                                                  ResourceBundleUtil labels)
Method addSelectionToolTo must have been invoked prior to this on the JToolBar.


addZoomButtonsTo

public static void addZoomButtonsTo(javax.swing.JToolBar bar,
                                    DrawingEditor editor)

createZoomButton

public static javax.swing.AbstractButton createZoomButton(DrawingEditor editor)

createZoomButton

public static javax.swing.AbstractButton createZoomButton(DrawingView view)

createZoomButton

public static javax.swing.AbstractButton createZoomButton(DrawingView view,
                                                          double[] factors)

addAttributesButtonsTo

public static void addAttributesButtonsTo(javax.swing.JToolBar bar,
                                          DrawingEditor editor)
Creates toolbar buttons and adds them to the specified JToolBar


addColorButtonsTo

public static void addColorButtonsTo(javax.swing.JToolBar bar,
                                     DrawingEditor editor)

createEditorColorButton

public static JPopupButton createEditorColorButton(DrawingEditor editor,
                                                   AttributeKey attributeKey,
                                                   java.util.Map<java.lang.String,java.awt.Color> colorMap,
                                                   int columnCount,
                                                   java.lang.String labelKey,
                                                   ResourceBundleUtil labels)
Creates a color button, with an action region and a popup menu. The button works like the color button in Microsoft Office:

Parameters:
editor - The DrawingEditor.
attributeKey - The AttributeKey of the default color.
colorMap - A map with labeled colors containing the color palette of the popup menu. The actual labels are retrieved from the supplied resource bundle. This is usually a LinkedMap, so that the colors have a predictable order.
columnCount - The number of columns of the color palette.
labelKey - The resource bundle key used for retrieving the icon and the tooltip of the button.
labels - The resource bundle.

createEditorColorButton

public static JPopupButton createEditorColorButton(DrawingEditor editor,
                                                   AttributeKey attributeKey,
                                                   java.util.Map<java.lang.String,java.awt.Color> colorMap,
                                                   int columnCount,
                                                   java.lang.String labelKey,
                                                   ResourceBundleUtil labels,
                                                   java.util.Map<AttributeKey,java.lang.Object> defaultAttributes)
Creates a color button, with an action region and a popup menu. The button works like the color button in Microsoft Office:

Parameters:
editor - The DrawingEditor.
attributeKey - The AttributeKey of the default color.
colorMap - A map with labeled colors containing the color palette of the popup menu. The actual labels are retrieved from the supplied resource bundle. This is usually a LinkedMap, so that the colors have a predictable order.
columnCount - The number of columns of the color palette.
labelKey - The resource bundle key used for retrieving the icon and the tooltip of the button.
labels - The resource bundle.
defaultAttributes - A set of attributes which are also applied to the selected figures, when a color is selected. This can be used, to set attributes that otherwise prevent the color from being shown. For example, when the color attribute is set, we wan't the gradient attribute of the Figure to be cleared.

createEditorColorButton

public static JPopupButton createEditorColorButton(DrawingEditor editor,
                                                   AttributeKey attributeKey,
                                                   java.util.Map<java.lang.String,java.awt.Color> colorMap,
                                                   int columnCount,
                                                   java.lang.String labelKey,
                                                   ResourceBundleUtil labels,
                                                   java.util.Map<AttributeKey,java.lang.Object> defaultAttributes,
                                                   java.awt.Shape colorShape)
Creates a color button, with an action region and a popup menu. The button works like the color button in Microsoft Office:

Parameters:
editor - The DrawingEditor.
attributeKey - The AttributeKey of the default color.
colorMap - A map with labeled colors containing the color palette of the popup menu. The actual labels are retrieved from the supplied resource bundle. This is usually a LinkedHashMap, so that the colors have a predictable order.
columnCount - The number of columns of the color palette.
labelKey - The resource bundle key used for retrieving the icon and the tooltip of the button.
labels - The resource bundle.
defaultAttributes - A set of attributes which are also applied to the selected figures, when a color is selected. This can be used, to set attributes that otherwise prevent the color from being shown. For example, when the color attribute is set, we wan't the gradient attribute of the Figure to be cleared.
colorShape - This shape is superimposed on the icon of the button. The shape is drawn with the default color of the DrawingEditor.

createSelectionColorButton

public static JPopupButton createSelectionColorButton(DrawingEditor editor,
                                                      AttributeKey attributeKey,
                                                      java.util.Map<java.lang.String,java.awt.Color> colorMap,
                                                      int columnCount,
                                                      java.lang.String labelKey,
                                                      ResourceBundleUtil labels)

createSelectionColorButton

public static JPopupButton createSelectionColorButton(DrawingEditor editor,
                                                      AttributeKey attributeKey,
                                                      java.util.Map<java.lang.String,java.awt.Color> colorMap,
                                                      int columnCount,
                                                      java.lang.String labelKey,
                                                      ResourceBundleUtil labels,
                                                      java.util.Map<AttributeKey,java.lang.Object> defaultAttributes)

createSelectionColorButton

public static JPopupButton createSelectionColorButton(DrawingEditor editor,
                                                      AttributeKey attributeKey,
                                                      java.util.Map<java.lang.String,java.awt.Color> colorMap,
                                                      int columnCount,
                                                      java.lang.String labelKey,
                                                      ResourceBundleUtil labels,
                                                      java.util.Map<AttributeKey,java.lang.Object> defaultAttributes,
                                                      java.awt.Shape colorShape)
Creates a color button, with an action region and a popup menu. The button works like the color button in Adobe Fireworks:

Parameters:
editor - The DrawingEditor.
attributeKey - The AttributeKey of the default color.
colorMap - A map with labeled colors containing the color palette of the popup menu. The actual labels are retrieved from the supplied resource bundle. This is usually a LinkedHashMap, so that the colors have a predictable order.
columnCount - The number of columns of the color palette.
labelKey - The resource bundle key used for retrieving the icon and the tooltip of the button.
labels - The resource bundle.
defaultAttributes - A set of attributes which are also applied to the selected figures, when a color is selected. This can be used, to set attributes that otherwise prevent the color from being shown. For example, when the color attribute is set, we wan't the gradient attribute of the Figure to be cleared.
colorShape - This shape is superimposed on the icon of the button. The shape is drawn with the default color of the DrawingEditor.

addStrokeButtonsTo

public static void addStrokeButtonsTo(javax.swing.JToolBar bar,
                                      DrawingEditor editor)

createStrokeWidthButton

public static JPopupButton createStrokeWidthButton(DrawingEditor editor)

createStrokeWidthButton

public static JPopupButton createStrokeWidthButton(DrawingEditor editor,
                                                   ResourceBundleUtil labels)

createStrokeWidthButton

public static JPopupButton createStrokeWidthButton(DrawingEditor editor,
                                                   double[] widths)

createStrokeWidthButton

public static JPopupButton createStrokeWidthButton(DrawingEditor editor,
                                                   double[] widths,
                                                   ResourceBundleUtil labels)

createStrokeDecorationButton

public static JPopupButton createStrokeDecorationButton(DrawingEditor editor)

createStrokeDashesButton

public static JPopupButton createStrokeDashesButton(DrawingEditor editor)

createStrokeDashesButton

public static JPopupButton createStrokeDashesButton(DrawingEditor editor,
                                                    ResourceBundleUtil labels)

createStrokeDashesButton

public static JPopupButton createStrokeDashesButton(DrawingEditor editor,
                                                    double[][] dashes)

createStrokeDashesButton

public static JPopupButton createStrokeDashesButton(DrawingEditor editor,
                                                    double[][] dashes,
                                                    ResourceBundleUtil labels)

createStrokeTypeButton

public static JPopupButton createStrokeTypeButton(DrawingEditor editor)

createStrokePlacementButton

public static JPopupButton createStrokePlacementButton(DrawingEditor editor)

addFontButtonsTo

public static void addFontButtonsTo(javax.swing.JToolBar bar,
                                    DrawingEditor editor)

createFontButton

public static JPopupButton createFontButton(DrawingEditor editor)

createFontButton

public static JPopupButton createFontButton(DrawingEditor editor,
                                            ResourceBundleUtil labels)

createFontStyleBoldButton

public static javax.swing.JButton createFontStyleBoldButton(DrawingEditor editor)

createFontStyleBoldButton

public static javax.swing.JButton createFontStyleBoldButton(DrawingEditor editor,
                                                            ResourceBundleUtil labels)

createFontStyleItalicButton

public static javax.swing.JButton createFontStyleItalicButton(DrawingEditor editor)

createFontStyleItalicButton

public static javax.swing.JButton createFontStyleItalicButton(DrawingEditor editor,
                                                              ResourceBundleUtil labels)

createFontStyleUnderlineButton

public static javax.swing.JButton createFontStyleUnderlineButton(DrawingEditor editor)

createFontStyleUnderlineButton

public static javax.swing.JButton createFontStyleUnderlineButton(DrawingEditor editor,
                                                                 ResourceBundleUtil labels)

addAlignmentButtonsTo

public static void addAlignmentButtonsTo(javax.swing.JToolBar bar,
                                         DrawingEditor editor)
Creates toolbar buttons and adds them to the specified JToolBar


createToggleGridButton

public static javax.swing.AbstractButton createToggleGridButton(DrawingEditor editor)
Creates toolbar buttons and adds them to the specified JToolBar


createToggleGridButton

public static javax.swing.AbstractButton createToggleGridButton(DrawingView view)
Creates toolbar buttons and adds them to the specified JToolBar


createStrokeCapButton

public static JPopupButton createStrokeCapButton(DrawingEditor editor)

createStrokeCapButton

public static JPopupButton createStrokeCapButton(DrawingEditor editor,
                                                 ResourceBundleUtil labels)

createStrokeJoinButton

public static JPopupButton createStrokeJoinButton(DrawingEditor editor)

createStrokeJoinButton

public static JPopupButton createStrokeJoinButton(DrawingEditor editor,
                                                  ResourceBundleUtil labels)

createPickAttributesButton

public static javax.swing.JButton createPickAttributesButton(DrawingEditor editor)

createApplyAttributesButton

public static javax.swing.JButton createApplyAttributesButton(DrawingEditor editor)
Creates a button that applies the default attributes of the editor to the current selection.


Copyright 1996-2007 (c) JHotDraw.org.
Some rights reserved.