jimm.datavision.gui
Class FormatWin

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Dialog
                  extended by javax.swing.JDialog
                      extended by jimm.datavision.gui.EditWin
                          extended by jimm.datavision.gui.FormatWin
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants, FieldWalker

public class FormatWin
extends EditWin
implements FieldWalker

A field format editing dialog box. There are tabs for text format and borders. The initial format and border values are retrieved from one of two places: either a field passed in to the constructor or the first selected field in the desing window. The format and border are applied to either a single field or all selected fields.

Warning: this code depends upon the fact that the strings in edgeCountChoices equals the integer value of the string (zero, one, two, etc.) and that the strings in edgeStyleChoices correspond to the numeric values of the BorderEdge.STYLE_* constants.

Author:
Jim Menard, jimm@io.com
See Also:
Serialized Form

Nested Class Summary
(package private) static class FormatWin.EdgeWidgets
          Holds a border edge and the widgets used for editing it.
 
Nested classes/interfaces inherited from class javax.swing.JDialog
javax.swing.JDialog.AccessibleJDialog
 
Nested classes/interfaces inherited from class java.awt.Dialog
java.awt.Dialog.AccessibleAWTDialog, java.awt.Dialog.ModalExclusionType, java.awt.Dialog.ModalityType
 
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
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
protected  javax.swing.JComboBox align
           
protected  javax.swing.JCheckBox bold
           
protected  Border border
           
protected  javax.swing.JLabel borderColorLabel
           
protected static int BOTTOM
           
protected  FormatWin.EdgeWidgets[] edgeWidgets
           
protected  Field field
           
protected  javax.swing.JLabel fieldColorLabel
           
protected  javax.swing.JComboBox fontFamily
           
protected static java.lang.String[] fontFamilyNames
           
protected  Format format
           
protected static int FORMAT_TEXT_FIELD_COLS
           
protected  javax.swing.JTextField formatText
           
protected  javax.swing.JCheckBox italic
           
protected static int LEFT
           
protected  Border origBorder
           
protected  Format origFormat
           
protected static int RIGHT
           
protected  boolean saveRevertInfo
           
protected  javax.swing.JComboBox size
           
protected static java.lang.Integer[] SIZE_CHOICES
          List of pre-approved font size choices.
protected static int THICKNESS_COLS
           
protected static int TOP
           
protected  javax.swing.JCheckBox underline
           
protected  javax.swing.JCheckBox wrap
           
 
Fields inherited from class jimm.datavision.gui.EditWin
commands, designer, revertButton
 
Fields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Dialog
DEFAULT_MODALITY_TYPE
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
FormatWin(Designer designer, Field f, int whichTab)
          Constructor.
 
Method Summary
protected  java.lang.String[] alignChoices()
           
protected  javax.swing.Box buildBorderColorWidgets()
           
protected  javax.swing.Box buildBorderEdge(int edgeIndex, java.lang.String edgeName, BorderEdge edge)
          Builds one of the edges of the border.
protected  javax.swing.Box buildBorderTab()
          Builds the border tab contents.
protected  javax.swing.Box buildFieldColorWidgets()
           
protected  java.awt.Container buildFormatTab()
          Builds the format tab contents.
protected  void buildWindow(int whichTab)
          Builds the window contents.
protected  void copyFormatAndBorder(Format origFormat, Border origBorder)
          Saves copies of format and border into the objects that we really edit.
protected  javax.swing.JButton createBorderColorChooserButton()
           
protected  javax.swing.JButton createFieldColorChooserButton()
           
protected  void doRevert()
          Gives subclasses a chance to clean up their GUI.
protected  void doSave()
          Saves all data by creating a new command, performing it, and adding it to commands.
protected  java.lang.String[] edgeCountChoices()
           
protected  java.lang.String[] edgeStyleChoices()
           
protected  void fillBorderTab()
          Fills the border tab edit fields with values of border.
protected  void fillFormatTab()
          Fills the format tab edit fields with values of format.
protected  java.lang.String[] fontChoices()
          Returns the list of font choices.
protected  int fontIndexOf(java.lang.String fontFamilyName)
          Returns the index of the specified font family name.
static void loadFontChoices()
          This method loads all the font family names in a separate thread.
protected  void setBorderExampleColor()
           
protected  void setFieldExampleColor()
           
protected  java.lang.Integer[] sizeChoices()
          Returns the list of font size choices, lazily instantiating it if necessary.
protected  int sizeIndexOf(int size)
          Returns the index of the specified size value in the SIZE_CHOICES list.
 void step(Field f)
          Creates and performs a command that gives the format and borders to the specified field.
 
Methods inherited from class jimm.datavision.gui.EditWin
actionPerformed, closeButtonPanel, revert, save
 
Methods inherited from class javax.swing.JDialog
addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
 
Methods inherited from class java.awt.Dialog
addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setModalityType, setResizable, setTitle, setUndecorated, setVisible, show, toBack
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SIZE_CHOICES

protected static java.lang.Integer[] SIZE_CHOICES
List of pre-approved font size choices. Don't use this directly; instead call sizeChoices().


FORMAT_TEXT_FIELD_COLS

protected static final int FORMAT_TEXT_FIELD_COLS
See Also:
Constant Field Values

THICKNESS_COLS

protected static final int THICKNESS_COLS
See Also:
Constant Field Values

TOP

protected static final int TOP
See Also:
Constant Field Values

LEFT

protected static final int LEFT
See Also:
Constant Field Values

RIGHT

protected static final int RIGHT
See Also:
Constant Field Values

BOTTOM

protected static final int BOTTOM
See Also:
Constant Field Values

fontFamilyNames

protected static java.lang.String[] fontFamilyNames

field

protected Field field

format

protected Format format

border

protected Border border

origFormat

protected Format origFormat

origBorder

protected Border origBorder

saveRevertInfo

protected boolean saveRevertInfo

fontFamily

protected javax.swing.JComboBox fontFamily

size

protected javax.swing.JComboBox size

bold

protected javax.swing.JCheckBox bold

italic

protected javax.swing.JCheckBox italic

underline

protected javax.swing.JCheckBox underline

wrap

protected javax.swing.JCheckBox wrap

align

protected javax.swing.JComboBox align

formatText

protected javax.swing.JTextField formatText

fieldColorLabel

protected javax.swing.JLabel fieldColorLabel

borderColorLabel

protected javax.swing.JLabel borderColorLabel

edgeWidgets

protected FormatWin.EdgeWidgets[] edgeWidgets
Constructor Detail

FormatWin

public FormatWin(Designer designer,
                 Field f,
                 int whichTab)
Constructor.

Parameters:
designer - the window to which this dialog belongs
f - a field from which we will take the format and border
whichTab - the index of the tab to display when opened
Method Detail

loadFontChoices

public static void loadFontChoices()
This method loads all the font family names in a separate thread. It is called each time a design window is created, though it only does its thang the first time it is called.


copyFormatAndBorder

protected void copyFormatAndBorder(Format origFormat,
                                   Border origBorder)
Saves copies of format and border into the objects that we really edit. Either may be null. Called from constructor and doRevert().

Parameters:
origFormat - the format we are copying; not necessarily that of the field
origBorder - the border we are copying; not necessarily that of the field

buildWindow

protected void buildWindow(int whichTab)
Builds the window contents.

Parameters:
whichTab - the index of the tab to display when opened

buildFormatTab

protected java.awt.Container buildFormatTab()
Builds the format tab contents.


buildFieldColorWidgets

protected javax.swing.Box buildFieldColorWidgets()

buildBorderColorWidgets

protected javax.swing.Box buildBorderColorWidgets()

setFieldExampleColor

protected void setFieldExampleColor()

setBorderExampleColor

protected void setBorderExampleColor()

createFieldColorChooserButton

protected javax.swing.JButton createFieldColorChooserButton()

createBorderColorChooserButton

protected javax.swing.JButton createBorderColorChooserButton()

sizeChoices

protected java.lang.Integer[] sizeChoices()
Returns the list of font size choices, lazily instantiating it if necessary.

Returns:
an array of Integer size choices

sizeIndexOf

protected int sizeIndexOf(int size)
Returns the index of the specified size value in the SIZE_CHOICES list. Returns -1 if not found.

Returns:
an index, or -1 if not found

fontChoices

protected java.lang.String[] fontChoices()
Returns the list of font choices.

Returns:
an array of font family names

fontIndexOf

protected int fontIndexOf(java.lang.String fontFamilyName)
Returns the index of the specified font family name. Returns -1 if not found.

Returns:
an index, or -1 if not found

alignChoices

protected java.lang.String[] alignChoices()

edgeCountChoices

protected java.lang.String[] edgeCountChoices()

edgeStyleChoices

protected java.lang.String[] edgeStyleChoices()

buildBorderTab

protected javax.swing.Box buildBorderTab()
Builds the border tab contents.


buildBorderEdge

protected javax.swing.Box buildBorderEdge(int edgeIndex,
                                          java.lang.String edgeName,
                                          BorderEdge edge)
Builds one of the edges of the border.

Warning: this code depends upon the fact that the strings in edgeCountChoices equals the integer value of the string (zero, one, two, etc.) and that the strings in edgeStyleChoices correspond to the numeric values of the BorderEdge.STYLE_* constants.

Parameters:
edgeIndex - one of TOP, LEFT, etc.
edgeName - the text name of the widget
edge - the edge we are representing visually
Returns:
one box to rule them all, one box to bind them

fillFormatTab

protected void fillFormatTab()
Fills the format tab edit fields with values of format.


fillBorderTab

protected void fillBorderTab()
Fills the border tab edit fields with values of border.


doSave

protected void doSave()
Description copied from class: EditWin
Saves all data by creating a new command, performing it, and adding it to commands.

Specified by:
doSave in class EditWin

step

public void step(Field f)
Creates and performs a command that gives the format and borders to the specified field.

Specified by:
step in interface FieldWalker
Parameters:
f - the field

doRevert

protected void doRevert()
Description copied from class: EditWin
Gives subclasses a chance to clean up their GUI.

Specified by:
doRevert in class EditWin