|
|||||||||
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.GPGenerator
public class GPGenerator
This class is a graph paper generator demo/utility. It uses SVG and the svg.*
package to create various types of graph paper. The SVG documents
can then be transformed into PDF or other formats by an external utility like Apache Batik. Each panel creates a different
type of graph paper and the output can be sent to the clipboard.
All graph paper generated is by default for letter-sized paper (8.5" x 11") with a viewport set to '850 1100'. This yields a scale of 100 units per inch in both dimensions and that is how all spacing is measured. NOTE: Whenever a length or other absolute linear measure is used each unit is automatically 1/100 of the base unit! So, margin settings are 100 per inch. Default margins are Top 50, Bottom 1150, Left 50 and Right 800; this yields a half-inch margin all the way around the paper.
For advanced users all of these quantities can be changed. The units are all recognized by the SVG standard: inches, centimeters, millimeters, 'em', 'ex', points, picas and pixels. The SVG 'viewBox=' attribute is calculated for 100 user units per inch: it is set to 100 * the (double) value in the height and width TextFields. There is no safety checking so USE WITH CARE!!
GPGenerator
defines 31 built-in pens for creating graphs. Specific details are given in the addPens()
method, which adds the
standard (global) pens to Any SVGTag
. Pen 30 is the suppression pen; it has no stroke or fill set, so it is invisible. It can also be
hand-edited easily; it appears at the end of the CSS list.
Speaking of CSS, GPGenerator
creates a massive embedded stylesheet with each document. More pens than any one utility could ever use.
If this becomes a problem the unused pens (CSS rules) are easily deleted. The internal stylesheet is just that, internal!
Each type of graph paper is generated by its own dedicated GraphPanel
. Configuration methods are
there. All this class really does is manage them and prepare the SVGTag
used for drawing.
Besides being good for generating graph paper the individual generators are also scriptable. The demo.gpgdemo.GraphPanelFactory
class
('Notebook' to scripts). facilitates this. When run from the JAR each generator in the GUI is the instance exposed to scripts. This means scripts can set
the GUI and GUI settings can affect script output. GraphPanel
defines two complementary methods toPizza()
and eatPizza()
.
The former turns the current GUI settings for a generator into java.util.Properties
-formatted lines of text. The former takes a Properties
object and extracts configuration information from it. Panel 'B' in this demo provides an area to put such information.
Each generator has a '[To Pizza]' button, an '[Eat Pizza]' button and a text field for key prefixes. When the text output from a generator is placed into
the pizza area and its '[Eat Pizza]' button clicked it will configure from the data there. The prefix, if provided, is prepended to the property key. This
allows multiple configurations to be stored in a single file or placed into the pizza area. Even though it is not a GraphPanel
the margin and
paper size Panel can also create and consume a pizza.
Each graph paper generator is independent of all the others. The only thing they really share is the pens and those are output with each document. The default values listed on each panel give 'pretty' graph paper but by all means experiment!
This class actually has very little to configure. The margins can be set but should be set carefully. Some sanity-checking is done but carelessness with the margins may result in unparseable or invalid documents. As with other quantities the units are 1/100 of an inch.
This panel is for pizza configuration information for the other generators and the Config Panel. Pizzas placed here can be used to configure the other panels.
Clicking the 'B' panel '[Eat Pizza]' button does parse the Properties object BUT it uses it to set default config properties for the getMDraw()
method. This means any tag- or pen-class pizza-settable properties can be specified here. All graph paper generators here use this method to get their
MathDrawSVG
instances so any properties 'eaten' from this panel go there.
This panel generates plain vanilla square-grid paper. Details are here
.
This panel generates polar-grid paper. Details are here
.
This panel generates logarithmic and semilog paper. Details are here
.
The default settings have a logarithmic vertical scale (horizontal lines) and a quarter-inch linear horizontal scale (vertical lines). For a decent horizontal log scale use 4 cycles at length 10 with an interval of 55.
This generator produces multi-column paper with optional headers and row lines. See here
.
BP/S stands for 'Blood Pressure / Sugar' and creates a chart
for tracking blood pressure or blood
sugar (or both!).
This
is a quick and dirty generator for hex-grid paper. The size and number of hexes can be
adjusted and the rows and columns numbered.
This generator generates bar charts. Check here
for details.
MusicPanel
provides a simple, flexible generator for music paper
.
This panel generates configurable-line paper usable to design lettering guides
children use
when learning to write.
This
generator produces square- or rectangular-grid paper with alternate rows offset,
resuilting in a brick-like grid.
This
is a modified type of logarithmic paper. The intervals begin at the axis and shrink
as they move away from it.
Isometric
paper consists of a grid of equilateral triangles, which is what this generator
creates.
The perspective
generator produces a one-point perspective grid. Both horizontal and
vertical perspective can be configured independently.
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 | |
---|---|
static boolean |
GP_DEBUG
This constant is defined to assist in developing the various graph paper generators. |
static java.lang.String |
GPG_CLIP
This constant holds the name of the <clipPath> defined around the margins of the paper. |
static int |
MAX_PEN
Static constant for the number of the last defined pen. |
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 | |
---|---|
GPGenerator()
Standard constructor. |
Method Summary | |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent aev)
Handle all button clicks. |
static void |
addPens(SVGTag gPaper)
Add the standard pens to the SVGTag supplied. |
void |
eatPizza(java.util.Properties pPizza,
java.lang.String pPrefix)
Load size and margin settings from a Properties object. |
void |
eatPizza(java.lang.String pPrefix)
Load configuraton data from the Pizzaria panel. |
static StylePen |
getClipPen()
This method is used in conjunction with the margin clipPath tag that is automatically defined. |
static MathDrawSVG |
getMDraw()
This class maintains ONE MathDrawSVG instance. |
java.awt.Menu |
getMenu()
This is the menu that appears in the Demo Frame whenever 'View/Graph Paper' is selected. |
void |
setPizza(java.lang.String pPizza)
Put a non-null, non-blank String into the Pizzaria area. |
java.awt.Panel |
standardGUI()
Build the standard GUI. |
java.lang.String |
toPizza(java.lang.String pPrefix)
Even though this is not technically a GraphPanel this method was defined to allow persistence of margin and size settings. |
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 |
Field Detail |
---|
public static final int MAX_PEN
public static boolean GP_DEBUG
This constant is defined to assist in developing the various graph paper generators. It is settable via the '[]GP Debug' Checkbox on the margin panel here,
GraphPanel
and GraphPanelFactory
Its only effect here is to draw a border along the margins of the SVGTag
delivered
to the panels when in GUI mode. The value is set any time the '[Go!]' button is clicked.
public static final java.lang.String GPG_CLIP
Constructor Detail |
---|
public GPGenerator()
Method Detail |
---|
public static StylePen getClipPen()
This method is used in conjunction with the margin clipPath tag that is automatically defined. It is ONLY defined within this class, so this is of
most use when subclassing. The StylePen
returned has NO attributes set other than the clip URL, which refers to the clipPath tag.
public static MathDrawSVG getMDraw()
MathDrawSVG
instance. This is done to allow pre-configuration if needed. This method maintains it. Clicking the '[Reset]'
button on the Pizzaria panel clears the current instance and forces a new one the next time this method is called.
public java.awt.Menu getMenu()
public void actionPerformed(java.awt.event.ActionEvent aev)
actionPerformed
in interface java.awt.event.ActionListener
public static final void addPens(SVGTag gPaper)
Add the standard pens to the SVGTag supplied. The detailed descriptions are here.
The font sizes range from (about) 8-point to (roughly) 24-point. The 'stroke: none' makes the letters look nice.
gPaper
- The SVGTag to receive the standard StylePen
s.public final java.awt.Panel standardGUI()
public java.lang.String toPizza(java.lang.String pPrefix)
GraphPanel
this method was defined to allow persistence of margin and size settings. The two Checkboxes,
'processMathObject' and 'Debug mode' are not saved.
public void eatPizza(java.util.Properties pPizza, java.lang.String pPrefix)
Properties
object. If present the prefix is prepended to the property keys.
public void eatPizza(java.lang.String pPrefix)
public void setPizza(java.lang.String pPizza)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |