|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
java.awt.Panel
cox.jmatt.java.MathTools.demo.gpgdemo.GraphPanel
public abstract class GraphPanel
This is the base Panel for the graph paper generator panels. It defines the basic structure and function, others customize it.
The toPizza()
method can be used to generate a java.util.Properties
-style snapshot of the current state of the panel. All graph
settings are stored and the key values are quite obvious. If desired a prefix can be prepended to the key values to allow storing more than one graph in a
single text file. This allows a particular graph to be saved for later use. Of course prudent use of the other script tools can even have one graph (prefix)
picked from a file full of them at random. Once graph data has been saved it can be loaded. There are five options for this: a Properties
object,
the Global Pizza, as raw data in a String, from a file and from a resource stream.
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 | |
---|---|
GraphPanel()
Standard constructor. |
Method Summary | |
---|---|
double |
asDouble(java.lang.String pData,
double pDefault,
java.lang.Double pMin,
java.lang.Double pMax)
Convert a String to double with default and clamping. |
int |
asInt(java.lang.String pData,
int pDefault,
java.lang.Integer pMin,
java.lang.Integer pMax)
Convert a String to int with default values and clamping. |
void |
drawGraph(int mTop,
int mBottom,
int mLeft,
int mRight,
SVGTag pPaper)
This is the primary method for this class. |
void |
eatGlobalPizza(java.lang.String pPrefix)
Attempt to extract a graph (with optional prefix) from the Global Pizza. |
abstract 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. |
protected java.lang.String |
getKey(java.awt.Checkbox pCBX,
java.lang.String pPrefix,
java.lang.String pKey)
Extract the value of a Checkbox and return it as a Properties -formatted line. |
protected java.lang.String |
getKey(java.awt.TextField pTXF,
java.lang.String pPrefix,
java.lang.String pKey)
Extract the value of a TextField and return it as a Properties -formatted line. |
int |
getPen(java.awt.TextField txfPen)
Shortcut method: defaults to pen zero. |
int |
getPen(java.awt.TextField txfPen,
int pDefault)
Extract the contents of a TextField and interpret the result as a pen. |
protected boolean |
GP_DEBUG()
Finalized static method to fetch the value of GPGenerator.GP_DEBUG . |
void |
loadPizza(java.lang.String pData,
java.lang.String pPrefix,
boolean pIsFile,
boolean pGRAS)
Load a graph configuration from a file or raw String. |
void |
reset()
This method provides a way for the individual generators to reset to default values. |
void |
setGPDebug(boolean pEnable)
Instance debug mode method. |
static void |
setGPDebugMode(boolean pEnable)
Set or clear the GPGenerator.GP_DEBUG field. |
protected void |
setKey(java.util.Properties pPizza,
java.awt.Checkbox pCBX,
java.lang.String pPrefix,
java.lang.String pKey)
Extract the value from the supplied Properties object and use it to set the value of the Checkbox sent in. |
protected void |
setKey(java.util.Properties pPizza,
java.awt.TextField pTXF,
java.lang.String pPrefix,
java.lang.String pKey,
java.lang.String pDefault)
Extract the value from the supplied Properties object and use it to set the value of the TextField sent in. |
abstract 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 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 |
---|
public GraphPanel()
Method Detail |
---|
public void drawGraph(int mTop, int mBottom, int mLeft, int mRight, SVGTag pPaper)
This is the primary method for this class. Subclasses override it to draw the graph paper on the SVGTag
sent in. The desired margins are
also sent in and are assumed to be in user units. Subclasses may construct a MathDrawSVG
instance but the 'pPaper' is what will ultimately be
rendered and printed. The default implementation prints a Debug-level message.
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.public void reset()
This method provides a way for the individual generators to reset to default values. This implementation prints a debug message containing the name
of the class invoking it. This allows subclasses to print a simple message by calling super.reset()
.
public abstract 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. 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.
pPrefix
- The prefix to prepend to each key. Ignored if null or blank.public abstract 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. 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.
pPizza
- A java.util.Properties
object containing configuration data.pPrefix
- An optional prefix to include with each key. Ignored if null or blank.public void eatGlobalPizza(java.lang.String pPrefix)
public void loadPizza(java.lang.String pData, java.lang.String pPrefix, boolean pIsFile, boolean pGRAS)
Load a graph configuration from a file or raw String. Either way the data is parsed into a Properties
object then pulls the data from it.
A prefix can be supplied or not. Any errors are reported at Error level. If the filename/raw data is null or blank the method returns silently.
If 'pData' is a file and not raw data it can be loaded from the file system or via getResourceAsStream()
. The 'pGRAS' argument controls
this; it is provided for Applet use.
pData
- The raw data or filename.pIsFile
- 'true' to load from a file, 'false' for raw data.pGRAS
- Controls whether to use a resource stream ('true') or a normal fileInputStream
('false').pPrefix
- The graph data prefix.public int asInt(java.lang.String pData, int pDefault, java.lang.Integer pMin, java.lang.Integer pMax)
pData
- The String to be converted.pDefault
- The default value.pMin
- The minimum value, or null to ignore it.pMax
- The maximum value, ignored if null.public int getPen(java.awt.TextField txfPen, int pDefault)
TextField
and interpret the result as a pen. If the default is less than zero it is set to zero.
txfPen
- The TextField holding a pen value.pDefault
- The default value for the pen. Clamped to zero on the low end.public int getPen(java.awt.TextField txfPen)
public double asDouble(java.lang.String pData, double pDefault, java.lang.Double pMin, java.lang.Double pMax)
protected java.lang.String getKey(java.awt.TextField pTXF, java.lang.String pPrefix, java.lang.String pKey)
TextField
and return it as a Properties
-formatted line. If the key value is null or blank or 'pTXF' is null
nothing happens and an empty String is returned.
pTXF
- The TextField
to supply the value.pPrefix
- The prefix to prepend to the key.pKey
- The key used to store the value.
protected java.lang.String getKey(java.awt.Checkbox pCBX, java.lang.String pPrefix, java.lang.String pKey)
Checkbox
and return it as a Properties
-formatted line. If the key value is null or blank or 'pCBX' is null
nothing happens and an empty String is returned.
pCBX
- The Checkbox
to supply the value.pPrefix
- The prefix to prepend to the key.pKey
- The key used to store the value.
protected void setKey(java.util.Properties pPizza, java.awt.TextField pTXF, java.lang.String pPrefix, java.lang.String pKey, java.lang.String pDefault)
Properties
object and use it to set the value of the TextField
sent in. If 'pPizza' is null,
pTXF is null or 'pKey' is null or blank nothing happens. A default value can be supplied; if null it is replaced by a blank.
pPizza
- The Properties object used to extract the value.pTXF
- The text field to be set.pPrefix
- The key prefix; replaced with a blank if null.pKey
- The key used to extract the value.pDefault
- The default value if the key is not found.protected void setKey(java.util.Properties pPizza, java.awt.Checkbox pCBX, java.lang.String pPrefix, java.lang.String pKey)
Properties
object and use it to set the value of the Checkbox
sent in. If 'pPizza' is null,
'pCBX' is null or 'pKey' is null or blank nothing happens.
pPizza
- The Properties object used to extract the value.pCBX
- The text field to be set.pPrefix
- The key prefix; replaced with a blank if null.pKey
- The key used to extract the value.public static final void setGPDebugMode(boolean pEnable)
GPGenerator.GP_DEBUG
field.
public final void setGPDebug(boolean pEnable)
protected final boolean GP_DEBUG()
GPGenerator.GP_DEBUG
. Intended for development of new generators.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |