Spreadsheet Toolkit

corpus.doodle
Class AbstractVisualisationPane

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--corpus.doodle.AbstractVisualisationPane
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public abstract class AbstractVisualisationPane
extends javax.swing.JPanel

Used as a super class for a basic range of visualisations.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  int cellHeight
          The pixel height of a single cell in the visualisation
protected  int cellWidth
          The pixel width of a single cell in the visualisation
protected  java.awt.Color[] colorLookup
          A fairly evenly distributed range of colors.
protected  int colorMax
          The maximum number of colors
protected  java.awt.Graphics2D g
          The graphics object for drawing to the pane.
protected static Grid grid
          A grid of MathVectors that contains the data to be displayed
protected  int headsize
          The size of the mark at the head of the vector
protected  double maxX
          The largest X value found
protected  double maxY
          The largest Y value found
protected  double maxZ
          The largest Z value found
protected  double minX
          The smallest X value found
protected  double minY
          The smallest Y value found
protected  double minZ
          The smallest Z value found
protected  boolean ROYGBIV
          Color order for lookup table
protected  double scaleX
          The scale factor for X values
protected  double scaleY
          The scale factor for Y values
protected  double scaleZ
          The scale factor for Z values
protected  boolean square
          Use squares(true) or circles(false) when drawing integers
protected  corpus.doodle.ClassifyStatusBar status
          Info on whats happening
protected  int tailsize
          The size of the mark at the tail of the vector
protected  java.util.Vector toDraw
          A Vector of MathVectors that will be drawn.
protected  int xcorrect
           
protected  int xoff
          X offset from left edge
protected  int xoff_
          X offset from right edge
protected  int ycorrect
           
protected  int yoff
          Y offset from top edge
protected  int yoff_
          Y offset from bottom edge
protected  int zcorrect
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
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
AbstractVisualisationPane(Grid grid, corpus.doodle.ClassifyStatusBar status)
           
 
Method Summary
protected  double calculateCol(int x)
          Convert from a x pixel back to the x coordinate.
protected  double calculateRow(int y)
          Convert from a y pixel back to the y coordinate.
protected  double calculateX(double x)
          Convert a x coordinate into a pixel coordinate.
protected  double calculateY(double y)
          Convert a y coordinate into a pixel coordinate.
protected  double calculateZ(int z)
          Convert a z coordinate into a pixel coordinate.
protected  void checkPoints(double newX1, double newY1, double newZ1)
          Records the largest and smallest x,y,z values seen
protected  void checkPoints(double newX1, double newX2, double newY1, double newY2, double newZ1, double newZ2)
          Records the largest and smallest x,y,z values seen
protected  void colorBar(java.awt.Color[] c)
          Dumps the ColorCodeTable at the bottom of the screen.
protected  void colorBar(int N)
          Creates and then dumps the ColorCodeTable for N to the screen.
protected  java.awt.geom.GeneralPath computeArrowHead(java.awt.geom.Point2D p1, java.awt.geom.Point2D p2)
          Calculate the points used to represent the arrowhead.
static java.lang.String contents(int col, int row)
          Returns a String about the element at the given coordinates.
protected  java.awt.Color[] createColorCodeTable(int numColors, boolean ROYGBIV)
          Generates a series of colors such that the distribution of the colors is (fairly) evenly spaced throughout the color spectrum.
protected abstract  void draw(java.lang.Object o)
          draw the passed object on the grid.
protected  void drawArrow(int cx, int cy, int cx2, int cy2)
          Draw an arrow from (cx,cy) to (cx2,cy2) with the head at the latter end.
 double getMaxX()
           
 double getMaxY()
           
 java.awt.Dimension getMinimumSize()
          The Smallest size to render this pane at.
 double getMinX()
           
 double getMinY()
           
 void paintComponent(java.awt.Graphics comp)
          Draw Grid and Vectors
protected abstract  void process(Grid grid, java.util.Vector toDraw)
          Process incomming data grid and add the required elements to the toDraw vector.
protected  double round(double d, int n)
          Round the parameter double to n decimal places.
 void set(double minX, double maxX, double minY, double maxY)
          Changes the maximum and minimum values and redraws the screen.
protected  void update(java.lang.String text)
          Dump text in the status element.
protected  java.awt.Color valueToColor(int v)
          http://www.dgp.toronto.edu/~mjmcguff/learn/java/03-color/
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, 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, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, 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

xoff

protected int xoff
X offset from left edge


yoff

protected int yoff
Y offset from top edge


xoff_

protected int xoff_
X offset from right edge


yoff_

protected int yoff_
Y offset from bottom edge


minX

protected double minX
The smallest X value found


maxX

protected double maxX
The largest X value found


scaleX

protected double scaleX
The scale factor for X values


xcorrect

protected int xcorrect

minY

protected double minY
The smallest Y value found


maxY

protected double maxY
The largest Y value found


scaleY

protected double scaleY
The scale factor for Y values


ycorrect

protected int ycorrect

minZ

protected double minZ
The smallest Z value found


maxZ

protected double maxZ
The largest Z value found


scaleZ

protected double scaleZ
The scale factor for Z values


zcorrect

protected int zcorrect

cellWidth

protected int cellWidth
The pixel width of a single cell in the visualisation


cellHeight

protected int cellHeight
The pixel height of a single cell in the visualisation


colorMax

protected int colorMax
The maximum number of colors


colorLookup

protected java.awt.Color[] colorLookup
A fairly evenly distributed range of colors.


ROYGBIV

protected boolean ROYGBIV
Color order for lookup table


grid

protected static Grid grid
A grid of MathVectors that contains the data to be displayed


g

protected java.awt.Graphics2D g
The graphics object for drawing to the pane.


headsize

protected int headsize
The size of the mark at the head of the vector


tailsize

protected int tailsize
The size of the mark at the tail of the vector


toDraw

protected java.util.Vector toDraw
A Vector of MathVectors that will be drawn.


status

protected corpus.doodle.ClassifyStatusBar status
Info on whats happening


square

protected boolean square
Use squares(true) or circles(false) when drawing integers

Constructor Detail

AbstractVisualisationPane

public AbstractVisualisationPane(Grid grid,
                                 corpus.doodle.ClassifyStatusBar status)
Method Detail

process

protected abstract void process(Grid grid,
                                java.util.Vector toDraw)
Process incomming data grid and add the required elements to the toDraw vector.

Parameters:
grid - The incomming Grid data
toDraw - A vector that will be used to draw the required elements on the screen.

contents

public static java.lang.String contents(int col,
                                        int row)
Returns a String about the element at the given coordinates.

Parameters:
col - The Column
row - The Row
Returns:
A description of the object.

update

protected void update(java.lang.String text)
Dump text in the status element.


round

protected double round(double d,
                       int n)
Round the parameter double to n decimal places.


getMinimumSize

public java.awt.Dimension getMinimumSize()
The Smallest size to render this pane at.

Overrides:
getMinimumSize in class javax.swing.JComponent

paintComponent

public void paintComponent(java.awt.Graphics comp)
Draw Grid and Vectors

Overrides:
paintComponent in class javax.swing.JComponent

drawArrow

protected void drawArrow(int cx,
                         int cy,
                         int cx2,
                         int cy2)
Draw an arrow from (cx,cy) to (cx2,cy2) with the head at the latter end. The coordinates should already be in pixel format.

Parameters:
cx - start X pixel coordinate
cy - start Y pixel coordinate
cx2 - end X pixel coordinate
cy2 - end Y pixel coordinate
See Also:
computeArrowHead(Point2D, Point2D)

computeArrowHead

protected java.awt.geom.GeneralPath computeArrowHead(java.awt.geom.Point2D p1,
                                                     java.awt.geom.Point2D p2)
Calculate the points used to represent the arrowhead. We use a simple algorithm that just starts at p2, backs up to p1 a bit (as represented with p3), and goes to either side by rotating (p3-p2) +/- 90 degrees. BBB 12/98: There is a bug with Sun's JDK1.2 where if we create a Shape of zero area (due to the two points being equal, and then add them to another shape (as we do when we compute the local bounds), then the JDK will hang at run time. And so, we check to make sure the points aren't equal.


draw

protected abstract void draw(java.lang.Object o)
draw the passed object on the grid.


calculateX

protected double calculateX(double x)
Convert a x coordinate into a pixel coordinate.


calculateY

protected double calculateY(double y)
Convert a y coordinate into a pixel coordinate.


calculateZ

protected double calculateZ(int z)
Convert a z coordinate into a pixel coordinate.


calculateRow

protected double calculateRow(int y)
Convert from a y pixel back to the y coordinate.

See Also:
calculateY(double)

calculateCol

protected double calculateCol(int x)
Convert from a x pixel back to the x coordinate.

See Also:
calculateX(double)

checkPoints

protected void checkPoints(double newX1,
                           double newX2,
                           double newY1,
                           double newY2,
                           double newZ1,
                           double newZ2)
Records the largest and smallest x,y,z values seen


checkPoints

protected void checkPoints(double newX1,
                           double newY1,
                           double newZ1)
Records the largest and smallest x,y,z values seen


valueToColor

protected java.awt.Color valueToColor(int v)
http://www.dgp.toronto.edu/~mjmcguff/learn/java/03-color/


colorBar

protected void colorBar(int N)
Creates and then dumps the ColorCodeTable for N to the screen.


colorBar

protected void colorBar(java.awt.Color[] c)
Dumps the ColorCodeTable at the bottom of the screen.


createColorCodeTable

protected java.awt.Color[] createColorCodeTable(int numColors,
                                                boolean ROYGBIV)
Generates a series of colors such that the distribution of the colors is (fairly) evenly spaced throughout the color spectrum. This is especially useful for generating unique color codes to be used in a legend or on a graph. http://www.devx.com/free/tips/tipview.asp?content_id=1419

Parameters:
numColors - the number of colors to generate
ROYGBIV - if true the table will go from red to violet, else reversed. Added by Daniel.
Returns:
an array of Color objects representing the colors in the table

getMinX

public double getMinX()

getMaxX

public double getMaxX()

getMinY

public double getMinY()

getMaxY

public double getMaxY()

set

public void set(double minX,
                double maxX,
                double minY,
                double maxY)
Changes the maximum and minimum values and redraws the screen.


Spreadsheet Toolkit

Project Home Page