UI.Run.JSci
Class GEVAGraph

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by JSci.swing.JDoubleBufferedComponent
                  extended by JSci.swing.JGraph2D
                      extended by UI.Run.JSci.GEVAGraph
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, JSci.awt.GraphDataListener

public class GEVAGraph
extends JSci.swing.JGraph2D

Override the JSci JGraph2D to do some custom rendering

Author:
eliott bartley
See Also:
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.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class JSci.swing.JGraph2D
axisPad, dataMarker, gridLines, leftAxisPad, LINEAR_SCALE, LOG_SCALE, model, origin, scalePad, seriesColor, xAxisLine, xNumberFormat, xNumbering, yAxisLine, yNumberFormat, yNumbering
 
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
GEVAGraph(JSci.awt.Graph2DModel model)
           
 
Method Summary
 float calcSeriesValueAt(int seriesIndex, int screenX)
          Calculate the value of the data for a series at a particular mouse location on the graph.
 void dataChanged(JSci.awt.GraphDataEvent event)
           
protected  void drawData(java.awt.Graphics graphics)
           
protected  void drawXLabel(java.awt.Graphics graphics, double value, java.awt.Point point)
          X labels are being packed together too tightly, overlapping each other.
 float getDataIndexAt(int screenX)
          Get the data index at a screen coordinate relative to the graph.
 float getDataIndexBetween(int screenX, int screenU)
          Get the range of data indexes between screen coordinates relative to the graph.
 float getDataValueAt(int screenY)
          Get the data value at a screen coordinate relative to the graph.
 float getDataValueBetween(int screenY, int screenV)
          Get the range of data values between screen coordinates relative to the graph.
protected  int getX(float x)
          Convert from data x to screen x
protected  int getY(float y)
          Convert from data y to screen y
protected  void offscreenPaint(java.awt.Graphics graphics)
           
 void setXExtremaSafe(float minimum, float maximum)
          Helper for setXExtrema to prevent illegal values being passed
 void setYExtremaSafe(float minimum, float maximum)
          Helper for setYExtrema to prevent illegal values being passed
 
Methods inherited from class JSci.swing.JGraph2D
addNotify, dataToScreen, drawAxes, drawYLabel, getColor, getExtrema, getMinimumSize, getModel, getPreferredSize, getXIncrement, getXMaximum, getXMinimum, getYIncrement, getYMaximum, getYMinimum, rescale, scaledDataToScreen, screenToData, setAxisLines, setBounds, setColor, setGridLines, setMarker, setModel, setNumberFormat, setNumbering, setNumbering, setXExtrema, setXExtrema, setXIncrement, setXNumberFormat, setXScale, setYExtrema, setYExtrema, setYIncrement, setYNumberFormat, setYScale
 
Methods inherited from class JSci.swing.JDoubleBufferedComponent
getOffscreenGraphics, isDoubleBuffered, paintComponent, printComponent, redraw, setDoubleBuffered, update
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, 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, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateUI
 
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, 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

GEVAGraph

public GEVAGraph(JSci.awt.Graph2DModel model)
Method Detail

dataChanged

public void dataChanged(JSci.awt.GraphDataEvent event)
Specified by:
dataChanged in interface JSci.awt.GraphDataListener
Overrides:
dataChanged in class JSci.swing.JGraph2D

offscreenPaint

protected void offscreenPaint(java.awt.Graphics graphics)
Overrides:
offscreenPaint in class JSci.swing.JGraph2D

drawData

protected void drawData(java.awt.Graphics graphics)
Overrides:
drawData in class JSci.swing.JGraph2D

getX

protected int getX(float x)
Convert from data x to screen x

Parameters:
x - data x
Returns:
screen x

getY

protected int getY(float y)
Convert from data y to screen y

Parameters:
y - data y
Returns:
screen y

setXExtremaSafe

public void setXExtremaSafe(float minimum,
                            float maximum)
Helper for setXExtrema to prevent illegal values being passed

Parameters:
minimum -
maximum -

setYExtremaSafe

public void setYExtremaSafe(float minimum,
                            float maximum)
Helper for setYExtrema to prevent illegal values being passed

Parameters:
minimum -
maximum -

drawXLabel

protected void drawXLabel(java.awt.Graphics graphics,
                          double value,
                          java.awt.Point point)
X labels are being packed together too tightly, overlapping each other. This only renders every second label to space them out

Overrides:
drawXLabel in class JSci.swing.JGraph2D
Parameters:
graphics -
value -
point -

calcSeriesValueAt

public float calcSeriesValueAt(int seriesIndex,
                               int screenX)
Calculate the value of the data for a series at a particular mouse location on the graph. This is 'calculate', rather than 'get', as a single pixel can cover several data points; this returns the average of all points under the specified point

Parameters:
seriesIndex - Index of the series whose value is to be calculated
screenX - The x point in pixels of the data value to calculate
Returns:
The average of all the data points under the screen X

getDataIndexAt

public float getDataIndexAt(int screenX)
Get the data index at a screen coordinate relative to the graph. This is the value of the x axis on the graph


getDataValueAt

public float getDataValueAt(int screenY)
Get the data value at a screen coordinate relative to the graph. This is the value of the y axis on the graph


getDataIndexBetween

public float getDataIndexBetween(int screenX,
                                 int screenU)
Get the range of data indexes between screen coordinates relative to the graph. This is the value along the x axis on the graph


getDataValueBetween

public float getDataValueBetween(int screenY,
                                 int screenV)
Get the range of data values between screen coordinates relative to the graph. This is the value along the y axis on the graph