Class Plotter

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by Plotter
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class Plotter
extends javax.swing.JPanel

Plot datasets

Version:
1.1 March 2010
Author:
Stephan Euler
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.Component
java.awt.Component.BaselineResizeBehavior
 
Field Summary
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, 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
Plotter()
          Constructs a new Plotter
Plotter(java.lang.String name)
          Constructs a new Plotter with the given name
 
Method Summary
 void add(double y)
          Add a point to the current data set, use index as x coordinate
 void add(double x, double y)
          Add a point to the current data set
 void add(java.lang.String key, double x, double y)
          Add a point to the specified data set
 void clearPlotVector()
          remove all data sets
 double getHalfBarWidth()
          Get the value of half the width of the boxes in plot mode HISTOGRAM
 LineStyle getPlotMode()
           
 java.lang.String getStatusLine()
          Returns a string with status information
 int getSymbolSize()
           
 void nextVector()
          Switch to next data set.
 void paint(java.awt.Graphics g)
           
 boolean removeText(java.lang.String string)
          Remove the first text object that matches the given string.
 void setAutoXgrid(double autoXgrid)
           
 void setAutoYgrid(double autoYgrid)
           
 void setDataColor(java.lang.String key, java.awt.Color c)
          Set the color for the specified data set.
 void setDataLineStyle(LineStyle lineStyle)
          Set the plot mode.
 void setDataLineStyle(java.lang.String key, LineStyle lineStyle)
           
 void setHalfBarWidth(double halfBarWidth)
          Set the half the width of the boxes in plot mode HISTOGRAM
 void setSymbolSize(int symbolSize)
          Set the size of the symbols used in some plotting styles
 TextObject setText(java.lang.String s, double x, double y)
          Write text at the specified position
 void setXGrid(double[] x, double xmax)
           
 void setXLabel(java.lang.String[] label)
           
 void setXLabelFormat(java.lang.String labelFormat)
          Define the formatting of the labels of the x-axis.
 void setXLine(double x)
          Draw a vertical line
 void setXrange(double min, double max)
          Set the x range for plotting
 void setYGrid(double[] y)
           
 void setYLabelFormat(java.lang.String labelFormat)
          Define the formatting of the labels of the y-axis.
 void setYLine(double y)
          Draw a horizontal line
 void setYrange(double min, double max)
          Set the y range for plotting
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, 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, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, 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, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, 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, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, 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, 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
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Plotter

public Plotter()
Constructs a new Plotter


Plotter

public Plotter(java.lang.String name)
Constructs a new Plotter with the given name

Parameters:
name - the name of the new Plotter object
Method Detail

clearPlotVector

public void clearPlotVector()
remove all data sets


add

public void add(double x,
                double y)
Add a point to the current data set

Parameters:
x - x coordinate
y - y coordinate

add

public void add(java.lang.String key,
                double x,
                double y)
Add a point to the specified data set

Parameters:
key - key for the data set
x - x coordinate
y - y coordinate

setDataColor

public void setDataColor(java.lang.String key,
                         java.awt.Color c)
Set the color for the specified data set.

Parameters:
key - key for the data set
c - color

add

public void add(double y)
Add a point to the current data set, use index as x coordinate

Parameters:
y - y coordinate

setText

public TextObject setText(java.lang.String s,
                          double x,
                          double y)
Write text at the specified position

Parameters:
s - text to write
x - x coordinate
y - y coordinate

setYLine

public void setYLine(double y)
Draw a horizontal line

Parameters:
y - where to draw the line

setXLine

public void setXLine(double x)
Draw a vertical line

Parameters:
x - where to draw the line

setXGrid

public void setXGrid(double[] x,
                     double xmax)

setXLabel

public void setXLabel(java.lang.String[] label)

setYGrid

public void setYGrid(double[] y)

setXrange

public void setXrange(double min,
                      double max)
Set the x range for plotting

Parameters:
min - Minimum value to plot
max - Maximuma value to plot

setYrange

public void setYrange(double min,
                      double max)
Set the y range for plotting

Parameters:
min - Minimum value to plot
max - Maximuma value to plot

paint

public void paint(java.awt.Graphics g)
Overrides:
paint in class javax.swing.JComponent

nextVector

public void nextVector()
Switch to next data set. This creates a new empty data set. The new set is default target for subsequent calls of the methode add.


setAutoXgrid

public void setAutoXgrid(double autoXgrid)
Parameters:
autoXgrid - the autoXgrid to set

setAutoYgrid

public void setAutoYgrid(double autoYgrid)
Parameters:
autoYgrid - the autoYgrid to set

getPlotMode

public LineStyle getPlotMode()
Returns:
the plotMode

setDataLineStyle

public void setDataLineStyle(LineStyle lineStyle)
Set the plot mode. Currently available:

Parameters:
lineStyle - the plotMode to set

setDataLineStyle

public void setDataLineStyle(java.lang.String key,
                             LineStyle lineStyle)
Parameters:
key -
lineStyle -
See Also:
setDataLineStyle

getSymbolSize

public int getSymbolSize()
Returns:
the symbolSize

setSymbolSize

public void setSymbolSize(int symbolSize)
Set the size of the symbols used in some plotting styles

Parameters:
symbolSize - the symbolSize to set

getStatusLine

public java.lang.String getStatusLine()
Returns a string with status information

Returns:
the string

removeText

public boolean removeText(java.lang.String string)
Remove the first text object that matches the given string. Returns true if this plotter contained the specified element.

Parameters:
string - element to be removed from this plotter, if present
Returns:
true if this plotter contained the specified element

getHalfBarWidth

public double getHalfBarWidth()
Get the value of half the width of the boxes in plot mode HISTOGRAM

Returns:
the halfBarWidth

setHalfBarWidth

public void setHalfBarWidth(double halfBarWidth)
Set the half the width of the boxes in plot mode HISTOGRAM

Parameters:
halfBarWidth - the halfBarWidth to set

setYLabelFormat

public void setYLabelFormat(java.lang.String labelFormat)
Define the formatting of the labels of the y-axis. The given string will be used in String.format(labelFormat, y) to format a value y. For example "%f.2%%" will print numbers with two decimal place and a %-symbol. Default is null, i. e. the label is converted directly into a String.

Parameters:
labelFormat - the yLabelFormat to set

setXLabelFormat

public void setXLabelFormat(java.lang.String labelFormat)
Define the formatting of the labels of the x-axis. The given string will be used in String.format(labelFormat, x) to format a value x. For example "%f.2%%" will print numbers with two decimal place and a %-symbol. Default is null, i. e. the label is converted directly into a String.

Parameters:
labelFormat - the xLabelFormat to set