Documentation of 'org.jhotdraw.draw.action.ButtonFactory' Java class
ButtonFactory
org.jhotdraw.draw.action

Class ButtonFactory



  • public class ButtonFactory
    extends java.lang.Object
    ButtonFactory.

    Design pattern:
    Name: Abstract Factory.
    Role: Abstract Factory.
    Partners: DrawApplicationModel as Client, DrawView as Client, DrawingPanel as Client. FIXME - All buttons created using the ButtonFactory must automatically become disabled/enabled, when the DrawingEditor is disabled/enabled.

    • Field Detail

      • DEFAULT_COLORS

        public static final java.util.List<ColorIcon> DEFAULT_COLORS
        Mac OS X 'Apple Color Palette'. This palette has 8 columns.
      • DEFAULT_COLORS_COLUMN_COUNT

        public static final int DEFAULT_COLORS_COLUMN_COUNT
        See Also:
        Constant Field Values
      • WEBSAVE_COLORS

        public static final java.util.List<ColorIcon> WEBSAVE_COLORS
        Websave color palette as used by Macromedia Fireworks. This palette has 19 columns. The leftmost column contains a redundant set of color icons to make selection of gray scales and of the primary colors easier.
      • WEBSAVE_COLORS_COLUMN_COUNT

        public static final int WEBSAVE_COLORS_COLUMN_COUNT
        See Also:
        Constant Field Values
      • HSB_COLORS

        public static final java.util.List<ColorIcon> HSB_COLORS
        HSB color palette with a set of colors chosen based on a physical criteria.

        This is a 'human friendly' color palette which arranges the color in a way that makes it easy for humans to select the desired color. The colors are ordered in a way which minimizes the color contrast effect in the human visual system.

        This palette has 12 columns and 10 rows.

        The topmost row contains a null-color and a gray scale from white to black in 10 percent steps.

        The remaining rows contain colors taken from the outer hull of the HSB color model:

        The columns are ordered by hue starting with red - the lowest wavelength - and ending with purple - the highest wavelength. There are 12 different hues, so that all primary colors with their additive complements can be selected.

        The rows are orderd by brightness with the brightest color at the top (sky) and the darkest color at the bottom (earth). The first 5 rows contain colors with maximal brightness and a saturation ranging form 20% up to 100%. The remaining 4 rows contain colors with maximal saturation and a brightness ranging from 90% to 20% (this also makes for a range from 100% to 20% if the 5th row is taken into account).

      • HSB_COLORS_COLUMN_COUNT

        public static final int HSB_COLORS_COLUMN_COUNT
        See Also:
        Constant Field Values
      • HSB_COLORS_AS_RGB

        public static final java.util.List<ColorIcon> HSB_COLORS_AS_RGB
        This is the same palette as HSB_COLORS, but all color values are specified in the sRGB color space.
      • HSB_COLORS_AS_RGB_COLUMN_COUNT

        public static final int HSB_COLORS_AS_RGB_COLUMN_COUNT
        See Also:
        Constant Field Values
    • Method Detail

      • createDrawingActions

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

        public static java.util.Collection<javax.swing.Action> createDrawingActions(DrawingEditor editor,
                                                                                    java.util.List<Disposable> dsp)
      • 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)
      • addSelectionToolTo

        public static javax.swing.JToggleButton addSelectionToolTo(javax.swing.JToolBar tb,
                                                                   DrawingEditor editor,
                                                                   Tool selectionTool)
      • 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)
      • addColorButtonsTo

        public static void addColorButtonsTo(javax.swing.JToolBar bar,
                                             DrawingEditor editor,
                                             java.util.List<ColorIcon> colors,
                                             int columnCount)
      • createEditorColorButton

        public static JPopupButton createEditorColorButton(DrawingEditor editor,
                                                           AttributeKey<java.awt.Color> attributeKey,
                                                           java.util.List<ColorIcon> swatches,
                                                           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:
        • When the user clicks on the action region, the default color of the DrawingEditor is applied to the selected figures.
        • When the user opens the popup menu, a color palette is displayed. Choosing a color from the palette changes the default color of the editor and also changes the color of the selected figures.
        • A rectangle on the color button displays the current default color of the DrawingEditor. The rectangle has the dimensions 1, 17, 20, 4 (x, y, width, height).
        Parameters:
        editor - The DrawingEditor.
        attributeKey - The AttributeKey of the color.
        swatches - A list 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<java.awt.Color> attributeKey,
                                                           java.util.List<ColorIcon> swatches,
                                                           int columnCount,
                                                           java.lang.String labelKey,
                                                           ResourceBundleUtil labels,
                                                           @Nullable
                                                           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:
        • When the user clicks on the action region, the default color of the DrawingEditor is applied to the selected figures.
        • When the user opens the popup menu, a color palette is displayed. Choosing a color from the palette changes the default color of the editor and also changes the color of the selected figures.
        • A rectangle on the color button displays the current default color of the DrawingEditor. The rectangle has the dimensions 1, 17, 20, 4 (x, y, width, height).
        Parameters:
        editor - The DrawingEditor.
        attributeKey - The AttributeKey of the color.
        swatches - A list 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<java.awt.Color> attributeKey,
                                                           java.util.List<ColorIcon> swatches,
                                                           int columnCount,
                                                           java.lang.String labelKey,
                                                           ResourceBundleUtil labels,
                                                           @Nullable
                                                           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:
        • When the user clicks on the action region, the default color of the DrawingEditor is applied to the selected figures.
        • When the user opens the popup menu, a color palette is displayed. Choosing a color from the palette changes the default color of the editor and also changes the color of the selected figures.
        • A shape on the color button displays the current default color of the DrawingEditor.
        Parameters:
        editor - The DrawingEditor.
        attributeKey - The AttributeKey of the color.
        swatches - A list 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<java.awt.Color> attributeKey,
                                                              java.util.List<ColorIcon> swatches,
                                                              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 Adobe Fireworks:
        • When the user clicks at the button a popup menu with a color palette is displayed. Choosing a color from the palette changes the default color of the editor and also changes the color of the selected figures.
        • A shape on the color button displays the color of the selected figures. If no figures are selected, the default color of the DrawingEditor is displayed.
        • A rectangle on the color button displays the current default color of the DrawingEditor. The rectangle has the dimensions 1, 17, 20, 4 (x, y, width, height).
        Parameters:
        editor - The DrawingEditor.
        attributeKey - The AttributeKey of the color.
        swatches - A list 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.
      • createSelectionColorButton

        public static JPopupButton createSelectionColorButton(DrawingEditor editor,
                                                              AttributeKey<java.awt.Color> attributeKey,
                                                              java.util.List<ColorIcon> swatches,
                                                              int columnCount,
                                                              java.lang.String labelKey,
                                                              ResourceBundleUtil labels,
                                                              @Nullable
                                                              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 Adobe Fireworks:
        • When the user clicks at the button a popup menu with a color palette is displayed. Choosing a color from the palette changes the default color of the editor and also changes the color of the selected figures.
        • A rectangle on the color button displays the current default color of the DrawingEditor. The rectangle has the dimensions 1, 17, 20, 4 (x, y, width, height).
        Parameters:
        editor - The DrawingEditor.
        attributeKey - The AttributeKey of the color.
        swatches - A list 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.
      • createSelectionColorButton

        public static JPopupButton createSelectionColorButton(DrawingEditor editor,
                                                              AttributeKey<java.awt.Color> attributeKey,
                                                              java.util.List<ColorIcon> swatches,
                                                              int columnCount,
                                                              java.lang.String labelKey,
                                                              ResourceBundleUtil labels,
                                                              @Nullable
                                                              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:
        • When the user clicks at the button a popup menu with a color palette is displayed. Choosing a color from the palette changes the default color of the editor and also changes the color of the selected figures.
        • A shape on the color button displays the color of the selected figures. If no figures are selected, the default color of the DrawingEditor is displayed.
        Parameters:
        editor - The DrawingEditor.
        attributeKey - The AttributeKey of the color.
        swatches - A list 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<java.awt.Color> attributeKey,
                                                              java.util.List<ColorIcon> swatches,
                                                              int columnCount,
                                                              java.lang.String labelKey,
                                                              ResourceBundleUtil labels,
                                                              @Nullable
                                                              java.util.Map<AttributeKey,java.lang.Object> defaultAttributes,
                                                              java.awt.Shape colorShape,
                                                              java.util.List<Disposable> dsp)
        Creates a color button, with an action region and a popup menu. The button works like the color button in Adobe Fireworks:
        • When the user clicks at the button a popup menu with a color palette is displayed. Choosing a color from the palette changes the default color of the editor and also changes the color of the selected figures.
        • A shape on the color button displays the color of the selected figures. If no figures are selected, the default color of the DrawingEditor is displayed.
        Parameters:
        editor - The DrawingEditor.
        attributeKey - The AttributeKey of the color.
        swatches - A list 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.
      • createDrawingColorButton

        public static JPopupButton createDrawingColorButton(DrawingEditor editor,
                                                            AttributeKey<java.awt.Color> attributeKey,
                                                            java.util.List<ColorIcon> swatches,
                                                            int columnCount,
                                                            java.lang.String labelKey,
                                                            ResourceBundleUtil labels)
        Creates a color button, with an action region and a popup menu. The button acts on attributes of the Drawing object in the current DrawingView of the DrawingEditor.
        Parameters:
        editor - The DrawingEditor.
        attributeKey - The AttributeKey of the color.
        swatches - A list 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.
      • createDrawingColorButton

        public static JPopupButton createDrawingColorButton(DrawingEditor editor,
                                                            AttributeKey<java.awt.Color> attributeKey,
                                                            java.util.List<ColorIcon> swatches,
                                                            int columnCount,
                                                            java.lang.String labelKey,
                                                            ResourceBundleUtil labels,
                                                            @Nullable
                                                            java.util.Map<AttributeKey,java.lang.Object> defaultAttributes)
        Creates a color button, with an action region and a popup menu. The button acts on attributes of the Drawing object in the current DrawingView of the DrawingEditor.
        Parameters:
        editor - The DrawingEditor.
        attributeKey - The AttributeKey of the color.
        swatches - A list 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.
      • createDrawingColorButton

        public static JPopupButton createDrawingColorButton(DrawingEditor editor,
                                                            AttributeKey<java.awt.Color> attributeKey,
                                                            java.util.List<ColorIcon> swatches,
                                                            int columnCount,
                                                            java.lang.String labelKey,
                                                            ResourceBundleUtil labels,
                                                            @Nullable
                                                            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 acts on attributes of the Drawing object in the current DrawingView of the DrawingEditor.
        Parameters:
        editor - The DrawingEditor.
        attributeKey - The AttributeKey of the color.
        swatches - A list 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.
      • createDrawingColorButton

        public static JPopupButton createDrawingColorButton(DrawingEditor editor,
                                                            AttributeKey<java.awt.Color> attributeKey,
                                                            java.util.List<ColorIcon> swatches,
                                                            int columnCount,
                                                            java.lang.String labelKey,
                                                            ResourceBundleUtil labels,
                                                            @Nullable
                                                            java.util.Map<AttributeKey,java.lang.Object> defaultAttributes,
                                                            java.awt.Shape colorShape,
                                                            java.util.List<Disposable> dsp)
        Creates a color button, with an action region and a popup menu. The button acts on attributes of the Drawing object in the current DrawingView of the DrawingEditor.
        Parameters:
        editor - The DrawingEditor.
        attributeKey - The AttributeKey of the color.
        swatches - A list 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)
      • addFontButtonsTo

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

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

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

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

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

        public static void addAlignmentButtonsTo(javax.swing.JToolBar bar,
                                                 DrawingEditor editor,
                                                 java.util.List<Disposable> dsp)
        Creates toolbar buttons and adds them to the specified JToolBar.
      • createToggleGridButton

        public static javax.swing.AbstractButton createToggleGridButton(DrawingView view)
        Creates a button which toggles between two GridConstrainer for a DrawingView.
      • createPickAttributesButton

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

        public static javax.swing.JButton createPickAttributesButton(DrawingEditor editor,
                                                                     java.util.List<Disposable> dsp)
      • createApplyAttributesButton

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

        public static javax.swing.JButton createApplyAttributesButton(DrawingEditor editor,
                                                                      java.util.List<Disposable> dsp)

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.