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

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.MusicPanel
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

public class MusicPanel
extends GraphPanel
implements java.awt.event.ActionListener

This generator creates blank music paper. There are multiple layout options, most of which involve spacing. The line space, between the lines of the staff, forms the basis for all the other measurements. The basic unit of measurement is the staff, which is six times the line space. They layout is controlled by the staff pattern which is a String of special characters. Unless specifically stopped the pattern will be repeated as many times as its visible parts will fit between the top and bottom margins.

The visible items that can be placed are musical staves, rules and lines. The musical staff consists of five evenly-spaced horizontal lines capped at the left side with a vertical line. Multiple staves can be joined with a vertical line and it is also possible to place independent horizontal lines (rules). Each of these items has its own pen: line pen, vertical pen, connector pen and rule pen. There are two types of rule(r)s. The full rule stretches from margin to margin and the half-rule stretches half that distance, centered. (N.B. The rules are not specifically a part of musical notation but the page may need one.)

Following the Pattern

The staff pattern is divided into visible components and spacing components. In order to calculate how many patterns will fit on the page the height of the pattern is calculated from the first visible component to the last, not including vertical lines. (If a vertical line is opened and not closed it will not appear at all!) When the pattern is actually put onto the paper any trailing spaces do appear. The pattern formatting characters are:

In addition to these characters the vertical pipe character ('|') serves to group staves and possibly spaces. These must appear in pairs: the first pipe indicates the starting point of a vertical line and the second its ending point. The line characters ('L', 'R' and 'I') do not count against spacing but in actuality each does incur a very small (1/1000th of a line space) vertical distance. This was done to prevent patterns like 'ISSI' from causing infinite loops.

Characters other than the ones listed above cause an immediate stop (per '!').

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
MusicPanel()
          The usual constructor.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent aev)
          All this does is handle the 'Help' button.
 void drawGraph(int pTop, int pBot, int pLeft, int pRight, SVGTag pPaper)
          Draw the paper.
 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 original values.
 void setLineSpace(int pSpace)
          Set the line spacing.
 void setPattern(java.lang.String pPattern)
          Set the staff pattern.
 void setPens(int pLine, int pRule, int pVertical, int pConnector)
          Set the pens to use.
 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

MusicPanel

public MusicPanel()
The usual constructor.

Method Detail

drawGraph

public void drawGraph(int pTop,
                      int pBot,
                      int pLeft,
                      int pRight,
                      SVGTag pPaper)
Draw the paper. If the staff pattern is null or blank NOTHING happens!

Overrides:
drawGraph in class GraphPanel
Parameters:
pTop - The top margin of the drawable area.
pBot - The bottom margin of the drawable area.
pLeft - The left margin.
pRight - The right margin.
pPaper - The SVGTag on which the drawing is to occur.

reset

public void reset()
Reset to original values.

Overrides:
reset in class GraphPanel

setPattern

public void setPattern(java.lang.String pPattern)
Set the staff pattern. Null or blank values are silently ignored but no other checking is done.

Parameters:
pPattern - The new staff pattern.

setLineSpace

public void setLineSpace(int pSpace)
Set the line spacing. Any value less than one is silently ignored.


setPens

public void setPens(int pLine,
                    int pRule,
                    int pVertical,
                    int pConnector)
Set the pens to use. Any negative values are ignored: that pen will not be set.

Parameters:
pLine - The horizontal line pen.
pRule - The Rule pen.
pVertical - The vertical non-connector pen.
pConnector - The staff connection pen.

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.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent aev)
All this does is handle the 'Help' button.

Specified by:
actionPerformed in interface java.awt.event.ActionListener