cox.jmatt.java.MathTools.demo.gpgdemo
Class LedgerPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Panel
              extended by cox.jmatt.java.MathTools.demo.gpgdemo.GraphPanel
                  extended by cox.jmatt.java.MathTools.demo.gpgdemo.LedgerPanel
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class LedgerPanel
extends GraphPanel

LedgerPanel generates a rectangular grid consisting of evenly-spaced rows and columns of uneven width. The top row is assumed to be column headers; it can be underlined with a different pen ('Row 1 Pen') and can have a different height ('Row 1 Height'). The 'Horizontal Pen' field sets the pen number used for the other horizontal lines and the 'Vertical Pen' field is the pen number used for all vertical lines. Finally the 'Text Pen' field is the pen number used for any text present.

The columns and their headers are set in the small text area to the right of the other fields. Column entries are of the form 'NN Column Text' where NN is the width of the column, followed by a single space, followed by the text to appear at the top of the column. Each line is split on spaces with a limit of two, so the number MUST be first, followed by ONE SPACE. The remainder of the line becomes the column header. Each line describes one column and the lines are taken in the order they appear (contents initially split on newlines). If a column cannot be parsed or has width zero it is ignored.

The '[]Draw top line' Checkbox determines whether or not a horizontal line appears above the first row and whether the vertical lines will stretch to touch it. Enabling the '[]Stretch last column' Checkbox causes the last column to extend to the right margin. IMPORTANT NOTE: Regardless of the status of this box the last column MUST have a width greater than zero or it will be ignored!

The clearColumns() and addColumn() methods are defined for scripting purposes. The reset() method resets the default data in the column header area, the 'clear' method clears it. The 'add' method allows scripts to add column definitions one at a time.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
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
 
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
LedgerPanel()
          Basic constructor.
 
Method Summary
 void addColumn(int pWidth, java.lang.String pHeader)
          This scripting method adds a single entry to the column header area.
 void clearColumns()
          This scripting-only method clears the entire column header area.
 void drawGraph(int mTop, int mBottom, int mLeft, int mRight, SVGTag pPaper)
          Draw the graph.
 void eatPizza(java.util.Properties pPizza, java.lang.String pPrefix)
          This method accepts a Properties object and an optional String prefix and attempts to extract configuration data from it.
 void reset()
          Reset to defaults.
 void setColumns(java.lang.String pHeaderText)
          Set the columns for the chart.
 void setHeights(int pRowHeight, int pFirstHeight)
          Set the row height and the first row height.
 void setPens(int pHorizontal, int pVertical, int pFirst, int pText)
          Set the pens used to draw the chart.
 void setStretch(boolean pStretchLastColumn)
          Set whether or not the last column does (true) or does not (false) stretch to the right margin.
 void setTopLine(boolean pEnableTopLine)
          Enable (true) or disable (false) the top line and boxes around the header row.
 java.lang.String toPizza(java.lang.String pPrefix)
          This method extracts the configuration and state information from a generator and produces java.util.Properties-style output.
 
Methods inherited from class cox.jmatt.java.MathTools.demo.gpgdemo.GraphPanel
asDouble, asInt, eatGlobalPizza, getKey, getKey, getPen, getPen, GP_DEBUG, loadPizza, setGPDebug, setGPDebugMode, setKey, setKey
 
Methods inherited from class java.awt.Panel
addNotify, getAccessibleContext
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, 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, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, 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, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, 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

LedgerPanel

public LedgerPanel()
Basic constructor.

Method Detail

reset

public void reset()
Reset to defaults. Includes the sample column headers.

Overrides:
reset in class GraphPanel

drawGraph

public void drawGraph(int mTop,
                      int mBottom,
                      int mLeft,
                      int mRight,
                      SVGTag pPaper)
Draw the graph.

Overrides:
drawGraph in class GraphPanel
Parameters:
mTop - The top margin of the drawable area.
mBottom - The bottom margin of the drawable area.
mLeft - The left margin.
mRight - The right margin.
pPaper - The SVGTag on which the drawing is to occur.

setPens

public void setPens(int pHorizontal,
                    int pVertical,
                    int pFirst,
                    int pText)
Set the pens used to draw the chart.

Parameters:
pHorizontal - The pen used for (standard) horizontal lines.
pVertical - The pen used for all vertical lines.
pFirst - The pen used to underline the first row (header pen).
pText - The pen used for column header text.

setColumns

public void setColumns(java.lang.String pHeaderText)
Set the columns for the chart. This must be a String of newline-separated column descriptors, each of which is of the form 'NN Column Text' where NN is the column width in 1/100ths of an inch and 'Column Text' is the column header text. The text is optional and any descriptor that cannot be parsed is ignored.

Parameters:
pHeaderText - The String header formatted as described above. Ignored if null or blank.

clearColumns

public void clearColumns()
This scripting-only method clears the entire column header area.


addColumn

public void addColumn(int pWidth,
                      java.lang.String pHeader)
This scripting method adds a single entry to the column header area. If no text is given it is blank. If the number is zero or less nothing happens.

Parameters:
pWidth - The width of the column to add.
pHeader - The column label. If null or blank the column header is blank.

setTopLine

public void setTopLine(boolean pEnableTopLine)
Enable (true) or disable (false) the top line and boxes around the header row.


setStretch

public void setStretch(boolean pStretchLastColumn)
Set whether or not the last column does (true) or does not (false) stretch to the right margin.


setHeights

public void setHeights(int pRowHeight,
                       int pFirstHeight)
Set the row height and the first row height.

Parameters:
pRowHeight - The height of all rows after the first.
pFirstHeight - The height of the first (header) row.

toPizza

public java.lang.String toPizza(java.lang.String pPrefix)
Description copied from class: GraphPanel

This method extracts the configuration and state information from a generator and produces java.util.Properties-style output. A String prefix can be prepended to each key. If 'pPrefix' is not null or blank it will be attached to the front of the key String, separated by a single dot. If the prefix does not end with a dot one will be supplied automatically.

Use of the prefix allows multiple configurations to be stored in a single file. Also, since each generator has its own unique prefix (separate from the one supplied) multiple generator configs can be stored in a single file.

This is primarily a scripting method. It was developed in order to allow the perfect settings to be saved in a (scripting-) language-agnostic way that was also human-readable. The individual property names are typically Java-fied versions of their GUI labels. If MathTools is run from its JAR and the standard GUI is present the instances exposed to scripts are the ones in the GUI, so setting values in the GUI will affect script output and settings made by the script are reflected in the GUI.

Specified by:
toPizza in class GraphPanel
Parameters:
pPrefix - The prefix to prepend to each key. Ignored if null or blank.

eatPizza

public void eatPizza(java.util.Properties pPizza,
                     java.lang.String pPrefix)
Description copied from class: GraphPanel

This method accepts a Properties object and an optional String prefix and attempts to extract configuration data from it. It complements toPizza(). If 'pPizza' is null or empty nothing happens: the method returns silently. If 'pPrefix' is not null or blank it is used as a prefix to each key. If the String sent in does not end with a dot one will be supplied automatically. All of the keys requested have default valus that match the ones on the GUI.

Under normal cirucmstances the generator instances exposed to scripts are the ones in the GUI so changes using one are reflected in the other.

Specified by:
eatPizza in class GraphPanel
Parameters:
pPizza - A java.util.Properties object containing configuration data.
pPrefix - An optional prefix to include with each key. Ignored if null or blank.