Venice 0.7beta

org.mov.chart
Class Chart

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by org.mov.chart.Chart
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener

public class Chart
extends javax.swing.JComponent
implements java.awt.event.MouseListener

New swing component that allows creation of charts. This charting component supports graphing levels and also highlighting of a graph region.

See Also:
ChartModule, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
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.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
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
Chart()
          Create a new Chart component.
 
Method Summary
 void add(Graph graph, int index)
          Chart a new graph at the given level.
 void clearHighlightedRegion()
          Clear the highlighted region.
 boolean contains(int x, int y)
          Return whether the x,y coordinate is within this component.
 int count()
          Return the number of graphs in the chart.
 ChartDrawingModel getChartDrawingModel()
           
 double getDifference(java.lang.Integer x, java.lang.Integer y, int index)
          Generate the equation of the line passing through points specified by index, and return the difference between those points and x,y
 java.lang.Comparable getEndX()
          Get the last X value that appears in the chart.
 java.awt.Color getGraphColour(Graph graph)
          Return the colour that the given graph will be drawn.
 java.lang.Comparable getHighlightedEnd()
          Get the end X of the highlighted region.
 java.lang.Comparable getHighlightedStart()
          Get the start X of the highlighted region.
 java.awt.image.BufferedImage getImage()
           
 java.util.Vector getLevels()
          Return all the graphs for each level.
 java.lang.Comparable getStartX()
          Get the first X value that appears in the chart.
 java.util.Vector getSymbols()
          Return the window symbols.
 java.lang.String getTitle()
          Return the window title.
 java.lang.String getUIClassID()
          Returns a string that specifies the name of the l&f class that renders this component.
 java.lang.Comparable getXAtPoint(int x)
          Return the X value at the given x coordinate.
 java.util.Vector getXRange()
          Get the range of X values which appear in the chart.
 java.lang.Double getYAtPoint(int y)
          Return the Y value at the given y coordinate.
 void handleAnnotation(Graph graph, boolean enabled)
          Set whether the given graph should display its annotations.
 boolean isAnnotated(Graph graph)
          Query whether the given graph is displaying its annotations.
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 Coordinate move(java.lang.Integer x, java.lang.Integer y)
          Find the line intersecting at x,y.
 void remove(Graph graph)
          Remove the graph from the chart.
 void resetBuffer()
          Reset the double buffer, forcing the graph to redraw.
 void setDrawnLineEnd(java.lang.Comparable dataX, java.lang.Double dataY, java.lang.Integer absY)
          Sets the end point of a drawn line.
 void setDrawnLineStart(java.lang.Comparable dataX, java.lang.Double dataY, java.lang.Integer absY)
          Sets the end point of a drawn line.
 void setErase(java.lang.Comparable dataX, java.lang.Double dataY, java.lang.Integer absY)
          Find the graph element intersecting at x,y and delete it
 void setHighlightedEnd(java.lang.Comparable x)
          Sets the end X point of the highlighted region.
 void setHighlightedStart(java.lang.Comparable x)
          Sets the start X point of the highlighted region.
 void setPoint(java.lang.Comparable dataX, java.lang.Double dataY, java.lang.Integer absY)
          Puts a point on a chart.
 void setPoint(Coordinate coord)
          Puts a point on a chart.
 void setText(java.lang.String text, java.lang.Comparable dataX, java.lang.Double dataY, java.lang.Integer absY)
          Put text at x,y.
 void setUI(BasicChartUI ui)
          Sets the L&F object that renders this component.
 void updateUI()
          Resets the UI property to a value from the current look and feel.
 void zoomToDefaultRegion()
          Draw the graph back at its default zoom.
 void zoomToHighlightedRegion()
          Draw the graph zoomed into the given highlighted region.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, 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, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, 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
 

Constructor Detail

Chart

public Chart()
Create a new Chart component.

Method Detail

getXRange

public java.util.Vector getXRange()
Get the range of X values which appear in the chart.

Returns:
Vector of Comparables

getStartX

public java.lang.Comparable getStartX()
Get the first X value that appears in the chart.


getEndX

public java.lang.Comparable getEndX()
Get the last X value that appears in the chart.


handleAnnotation

public void handleAnnotation(Graph graph,
                             boolean enabled)
Set whether the given graph should display its annotations.

Parameters:
graph - the graph to modify
enabled - true to turn on graph annotations; false to turn them off

isAnnotated

public boolean isAnnotated(Graph graph)
Query whether the given graph is displaying its annotations.

Parameters:
graph - the graph to query
Returns:
true if the graph is displaying its annotations; false otherwise

add

public void add(Graph graph,
                int index)
Chart a new graph at the given level. If the chart does not contain the level, create a new one.

Parameters:
graph - the new graph to chart
index - the level index

count

public int count()
Return the number of graphs in the chart.

Returns:
the number of graphs in the chart

remove

public void remove(Graph graph)
Remove the graph from the chart. If the graph was an only member of its level, then the level will also be removed.

Parameters:
graph - the graph to remove

getLevels

public java.util.Vector getLevels()
Return all the graphs for each level.

Returns:
A Vector where each element represents a a graph level. Each element in the Vector is another Vector containing the graphs at that level.

getGraphColour

public java.awt.Color getGraphColour(Graph graph)
Return the colour that the given graph will be drawn. Note that the graph may choose to override this colour.

Parameters:
graph - the graph to query
Returns:
the colour the graph may be drawn as

setUI

public void setUI(BasicChartUI ui)
Sets the L&F object that renders this component.

Parameters:
ui - the ButtonUI L&F object

updateUI

public void updateUI()
Resets the UI property to a value from the current look and feel.

Overrides:
updateUI in class javax.swing.JComponent

getXAtPoint

public java.lang.Comparable getXAtPoint(int x)
Return the X value at the given x coordinate.

Parameters:
x - an x coordinate on the screen
Returns:
the X value at the x coordinate

getYAtPoint

public java.lang.Double getYAtPoint(int y)
Return the Y value at the given y coordinate.

Parameters:
y - an x coordinate on the screen
Returns:
the Y value at the y coordinate

contains

public boolean contains(int x,
                        int y)
Return whether the x,y coordinate is within this component.

Overrides:
contains in class javax.swing.JComponent
Parameters:
x - the x coordinate
y - the y coordinate
Returns:
true if the point is within this component; false otherwise.

getUIClassID

public java.lang.String getUIClassID()
Returns a string that specifies the name of the l&f class that renders this component.

Overrides:
getUIClassID in class javax.swing.JComponent
Returns:
String "ChartUI"

setHighlightedStart

public void setHighlightedStart(java.lang.Comparable x)
Sets the start X point of the highlighted region. Also resets the end point of the highlighted region to the start point. This creates a highlighted region 1 pixel thick.

Parameters:
x - the starting x value

setHighlightedEnd

public void setHighlightedEnd(java.lang.Comparable x)
Sets the end X point of the highlighted region.

Parameters:
x - the starting x value

setDrawnLineStart

public void setDrawnLineStart(java.lang.Comparable dataX,
                              java.lang.Double dataY,
                              java.lang.Integer absY)
Sets the end point of a drawn line. The line will now stretch from the start to the end point.

Parameters:
dataX - the x data point corresponding to the start of the line
dataY - the y data point corresponding to the start of the line.
absY - the absolute y coordinate of the start of the line

setDrawnLineEnd

public void setDrawnLineEnd(java.lang.Comparable dataX,
                            java.lang.Double dataY,
                            java.lang.Integer absY)
Sets the end point of a drawn line. The line will now stretch from the start to the end point.

Parameters:
dataX - the x data point corresponding to the end of the line
dataY - the y data point corresponding to the end of the line.
absY - the absolute y coordinate of the end of the line
newline - a flag indicating if the line drawn is new, or being continued.

setPoint

public void setPoint(Coordinate coord)
Puts a point on a chart.

Parameters:
coord - the coordinate

setPoint

public void setPoint(java.lang.Comparable dataX,
                     java.lang.Double dataY,
                     java.lang.Integer absY)
Puts a point on a chart.

Parameters:
coord - the coordinate

getDifference

public double getDifference(java.lang.Integer x,
                            java.lang.Integer y,
                            int index)
Generate the equation of the line passing through points specified by index, and return the difference between those points and x,y

Parameters:
x - the x coordinate
dataY - the y coordinate
index - the index a drawn line

setErase

public void setErase(java.lang.Comparable dataX,
                     java.lang.Double dataY,
                     java.lang.Integer absY)
Find the graph element intersecting at x,y and delete it

Parameters:
dataX - the x data corresponding to the selected point
dataY - the y data corresponding to the selected point
absY - the y coordinate of the selected point

move

public Coordinate move(java.lang.Integer x,
                       java.lang.Integer y)
Find the line intersecting at x,y. Return the coordinate of the end point which the user has chosen.

Parameters:
x - The X Coordinate of the selected point.
y - The Y Coordinate of the selected point.

setText

public void setText(java.lang.String text,
                    java.lang.Comparable dataX,
                    java.lang.Double dataY,
                    java.lang.Integer absY)
Put text at x,y.

Parameters:
x - the x coordinate of the selected point
y - the y coordinate of the selected point

getHighlightedStart

public java.lang.Comparable getHighlightedStart()
Get the start X of the highlighted region.

Returns:
the start X

getHighlightedEnd

public java.lang.Comparable getHighlightedEnd()
Get the end X of the highlighted region.

Returns:
the end X

getChartDrawingModel

public ChartDrawingModel getChartDrawingModel()

clearHighlightedRegion

public void clearHighlightedRegion()
Clear the highlighted region.


zoomToHighlightedRegion

public void zoomToHighlightedRegion()
Draw the graph zoomed into the given highlighted region.


zoomToDefaultRegion

public void zoomToDefaultRegion()
Draw the graph back at its default zoom.


resetBuffer

public void resetBuffer()
Reset the double buffer, forcing the graph to redraw.


getTitle

public java.lang.String getTitle()
Return the window title.

Returns:
the window title

getSymbols

public java.util.Vector getSymbols()
Return the window symbols.

Returns:
the window symbols

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

getImage

public java.awt.image.BufferedImage getImage()

Venice 0.7beta