Plotting
Class TwoDPlotter<E>

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 Plotting.TwoDPlotter<E>
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.MouseInputListener, Histogram, PlotBase, TwoDPlot

public class TwoDPlotter<E>
extends javax.swing.JPanel
implements TwoDPlot, Histogram, java.io.Serializable, javax.swing.event.MouseInputListener

Two dimensional plot class.

This class implements the public two D plotting related APIs in TwoDPlot interface. It contains a buffered image for faster repaints.


This class serves as a container for two dimensional plotting.The container can show a line plot along with a histogram (on the same X axis). The left Y Axis corresponds to line plot data and right Y axis shows the corresponding values for histogram.


This class has a template parameter representing the type of data, e.g. Double, Integer etc.

Since:
1.0
See Also:
TwoDPlot, Histogram, Serialized Form

Nested Class Summary
static class TwoDPlotter.PlotType
           
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
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
private  boolean bAutoFitOn
           
private  boolean bFinancialPresent
          flag indicating if financial plot is present
private  boolean bFourierPresent
          flag indicating if fourier plot is present
private  boolean bGridOn
           
private  boolean bHighlightDataPoints
           
private  boolean bHighlightDataPresent
          Is highlighting data present (prevents race condition between drawing and computing)
private  boolean bHistogramPresent
          flag indicating if atleast one histogram data is present
private  boolean bLegendOn
           
private  boolean bShowHighlightedCoord
          Flag for showing/hiding highlighted coordinates in a box
private  boolean bSuperimposePhase
          flag indicating if phase should be superimposed on amplitude chart for fourier plots
private  boolean bXLabelOn
           
private  boolean bXMajorTicksOn
           
private  boolean bXMinorTicksOn
           
private  boolean bYLabelOn
           
private  boolean bYMajorTicksOn
           
private  boolean bYMinorTicksOn
           
private static int HIGHLIGHT_CIRCLE_RADIUS
           
private static float HISTOGRAM_FRACTION
          Percentage of y axis given to histogram , expressed in decimal
private static int INSET
          Insets between the drawing area and plot axis.
private static int LEGEND_ITEM_SQUARE_LEN
           
private  boolean m_bDrawingRuler
           
private  boolean m_bDrawMode
           
private  boolean m_bJapaneseCandlesticks
           
private  java.awt.Color m_RulerColor
           
private static int MAX_HISTOGRAM_TICKS
           
private static int MAX_LEGEND_BOX_WIDTH
           
private static int MAX_MAJOR_TICKS
           
private static int MAX_MINOR_TICKS
           
private  java.awt.Color mAxisColor
           
private  java.awt.Color mAxisLabelColor
           
private  java.awt.Color mBGColor
           
private  java.awt.image.BufferedImage mBufImg
          Buffered image
private  ConnectionType mConnType
           
private  java.awt.Color mCoordBoxColor
           
private  Pair<java.lang.Double> mCurrMousePoint
           
private  java.util.List<PlotData<E>> mDataSetList
          A list of line plots, each element is a different line plot.
private  java.awt.Color mGridLineColor
           
private  Pair<java.lang.Integer> mHighlightPoint
          X and Y coordinates of point for highlighting (in screen coordinates)
private  float mHistYMax
           
private  float mHistYMin
          min max for histogram data.
private  int mLeftPtIndex
           
private  LineType mLineType
           
private  int mLineWidth
           
protected  int mMouseX
          X coordinate (in screen coordinates of mouse pressed event.
private  int mMouseY
          Y coordinate (in screen coordinates of mouse pressed event.
private  java.awt.Color mNegHistogramColor
          color of negative bar in histogram
private  int mNewMouseX
           
private  int mNewMouseY
           
private  int mPlotDataIndex
           
private  java.util.ArrayList<TwoDPlotter.PlotType> mPlotTypeList
          A list containing flags telling if the corresponding line plot is a histogram, financial plot, fourier plot or a line plot.
private  java.awt.Color mPosHistogramColor
          Color of positive bar in histogram
private  int mPosXAxis
           
private  int mPosYAxis
           
private  double mProjX
          Nearest point X coord (in world coordinates)
private  double mProjY
          Nearest point Y coord (in world coordinates)
private  java.awt.Color mTickColor
           
private  int mXLegendBox
           
private  float mXMajorTickSpacing
           
private  float mXMax
           
private  float mXMin
          min, max for plot data (excluding histogram data) which may have a different axis scale.
private  float mXMinorTickSpacing
           
private  java.lang.String mXTitle
           
private  int mYLegendBox
           
private  float mYMajorTickSpacing
           
private  float mYMax
           
private  float mYMin
           
private  float mYMinorTickSpacing
           
private  java.lang.String mYTitle
           
private static int SPACING
          Spacing inside legend box, between legend items, box boundaries
 
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
TwoDPlotter()
           
TwoDPlotter(int width, int height)
           
 
Method Summary
 void AddDataSet(PlotData<E> data)
          Add a data set representing line plot.
 void AddFinancialSet(PlotData<E> data)
          Add a data set representing financial data (typically includes day high, low, close, volume.
 void AddFourierSet(PlotData<E> data)
          Add a data set representing Fourier Transform plot.
 void AddHistogramSet(PlotData<E> data)
          Add a data set representing histogram plot.
private  void ComputeMinMax()
           
private  void ConvertScreenToWorldCoord(int pt_x, int pt_y, Pair<java.lang.Double> worldCoord)
           
private  void ConvertWorldToScreenCoord(double pt_x, double pt_y, Pair<java.lang.Integer> screenCoord)
           
 void DeleteAllData()
           
private  void Draw(java.awt.Graphics g)
          Draw the graph on provided graphics instance.
private  void DrawCoordBox(java.awt.Graphics g)
           
private  void DrawDataPoints(java.awt.Graphics g)
           
private  void DrawGraph(java.awt.Graphics g)
          The actual method responsible for drawing the appropriate graph.
private  void DrawGrid(java.awt.Graphics g)
           
private  void DrawLegend(java.awt.Graphics g)
          Draw the legend box at specified location.
private  void DrawLineGraph(java.awt.Graphics g)
           
private  void DrawNewtonGraph(java.awt.Graphics g)
           
protected  void DrawRulerOutline(java.awt.Graphics g)
           
private  void DrawXAxisTitle(java.awt.Graphics g)
           
private  void DrawXMajorTicks(java.awt.Graphics g)
           
private  void DrawXMinorTicks(java.awt.Graphics g)
           
private  void DrawXYAxis(java.awt.Graphics g)
           
private  void DrawYAxisTitle(java.awt.Graphics g)
           
private  void DrawYMajorTicks(java.awt.Graphics g)
           
private  void DrawYMinorTicks(java.awt.Graphics g)
           
 boolean FourierTransform(int plotIndex)
           
 java.awt.Color GetAxisColor()
           
 java.awt.Color GetAxisLabelColor()
           
 java.awt.Color GetBGColor()
           
 boolean GetCandlestickFlag()
           
 java.awt.Color GetCoordBoxColor()
           
 java.awt.Color GetGridLineColor()
           
 boolean GetHighlightedCoordDisplayFlag()
           
 java.awt.Graphics GetImageGraphics()
          Get the Graphics2d instance associated with buffered image.
 int GetLegendBoxXCorner()
           
 int GetLegendBoxYCorner()
           
 float GetMajorXTickSpacing()
           
 float GetMajorYTickSpacing()
           
 float GetMaxXRange()
           
 float GetMaxYRange()
           
 float GetMinorXTickSpacing()
           
 float GetMinorYTickSpacing()
           
 float GetMinXRange()
           
 float GetMinYRange()
           
 java.awt.Color GetNegativeRectColor()
           
 java.util.List<PlotData<E>> GetPlotData()
           
 TwoDPlotter.PlotType GetPlotType(int i)
           
 java.awt.Color GetPositiveRectColor()
           
 java.awt.Dimension getPreferredSize()
           
 java.awt.Dimension GetSize()
           
 boolean GetSuperimposePhase()
           
 java.awt.Color GetTickColor()
           
 int GetXAxisPos()
           
 java.lang.String GetXTitle()
           
 int GetYAxisPos()
           
 java.lang.String GetYTitle()
           
 void HighlightCandlestick(int pattern)
          highlight special candlestick pattern.
 void HighlightDataPoints(boolean toHighlight)
           
 boolean IsGridOn()
           
 boolean IsLegendOn()
           
 boolean IsXMajorTickOn()
           
 boolean IsXMinorTickOn()
           
 boolean IsYMajorTickOn()
           
 boolean IsYMinorTickOn()
           
 void mouseClicked(java.awt.event.MouseEvent e)
          Handler for mouseClicked event..
 void mouseDragged(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
          Handler for mouseMoved event.
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
protected  void paintComponent(java.awt.Graphics g)
           
 void Redraw()
           
 void RegenerateImage()
          Paint the buffered image again, after possibly resizing it.
 PlotData<E> RemoveDataSet(int setNum)
           
private  void ResizeBufferedImage()
          Resize the buffered image to drawing canvas size.
 void SaveScreenShot(java.io.File file, java.lang.String extension)
          Save the screen shot of graphics window in JPG, BMP, TIG or PNG format.
 void SetAutoFitOn(boolean on)
           
 void SetAxisColor(java.awt.Color col)
           
 void SetAxisLabelColor(java.awt.Color col)
           
 void SetBGColor(java.awt.Color col)
           
 void SetCandlestickFlag(boolean flag)
           
 void SetConnectionType(ConnectionType connType)
           
 void SetCoordBoxColor(java.awt.Color col)
           
 void SetDrawMode(boolean on)
           
 void SetGridLineColor(java.awt.Color col)
           
 void SetHighlightedCoordDisplayFlag(boolean flag)
           
 void SetLegendBoxXCorner(int xcorner)
           
 void SetLegendBoxYCorner(int ycorner)
           
 void SetLineType(LineType lineType)
           
 void SetLineWidth(int width)
           
 void SetMajorXTickSpacing(float delta)
           
 void SetMajorYTickSpacing(float delta)
           
 void SetMinorXTickSpacing(float delta)
           
 void SetMinorYTickSpacing(float delta)
           
 void SetNegativeRectColor(java.awt.Color col)
          Set the color of negative valued bar.
 void SetPlotSize(int xPixelNum, int yPixelNum)
           
 void SetPositiveRectColor(java.awt.Color col)
          Set the color of positive valued bar.
 void SetRulerColor(java.awt.Color col)
           
 void SetSuperimposePhase(boolean flag)
           
 void SetTickColor(java.awt.Color col)
           
 void SetXAxisPos(int pos)
           
 void SetXLabelOn(boolean on)
           
 void SetXRange(float min, float max)
           
 void SetXTitle(java.lang.String title)
           
 void SetYAxisPos(int pos)
           
 void SetYLabelOn(boolean on)
           
 void SetYRange(float min, float max)
           
 void SetYTitle(java.lang.String title)
           
 void ShowGrid(boolean on)
           
 void ShowLegend(boolean legendOn)
           
 void ShowXMajorTicks(boolean showXTicks)
           
 void ShowXMinorTicks(boolean showXTicks)
           
 void ShowYMajorTicks(boolean showYTicks)
           
 void ShowYMinorTicks(boolean showYTicks)
           
 void ZoomIn(int screen_x, int screen_y, int width, int height)
           
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, 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, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, 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
 

Field Detail

mDataSetList

private java.util.List<PlotData<E>> mDataSetList
A list of line plots, each element is a different line plot.

See Also:
PlotData

mPlotTypeList

private java.util.ArrayList<TwoDPlotter.PlotType> mPlotTypeList
A list containing flags telling if the corresponding line plot is a histogram, financial plot, fourier plot or a line plot.
The size of this list is equal to that of mDataSetList ( @see #mDataSetList ).

See Also:
TwoDPlotter.PlotType

INSET

private static final int INSET
Insets between the drawing area and plot axis.

See Also:
Constant Field Values

SPACING

private static final int SPACING
Spacing inside legend box, between legend items, box boundaries

See Also:
Constant Field Values

LEGEND_ITEM_SQUARE_LEN

private static final int LEGEND_ITEM_SQUARE_LEN
See Also:
Constant Field Values

MAX_LEGEND_BOX_WIDTH

private static final int MAX_LEGEND_BOX_WIDTH
See Also:
Constant Field Values

HIGHLIGHT_CIRCLE_RADIUS

private static final int HIGHLIGHT_CIRCLE_RADIUS
See Also:
Constant Field Values

MAX_MAJOR_TICKS

private static final int MAX_MAJOR_TICKS
See Also:
Constant Field Values

MAX_MINOR_TICKS

private static final int MAX_MINOR_TICKS
See Also:
Constant Field Values

MAX_HISTOGRAM_TICKS

private static final int MAX_HISTOGRAM_TICKS
See Also:
Constant Field Values

HISTOGRAM_FRACTION

private static final float HISTOGRAM_FRACTION
Percentage of y axis given to histogram , expressed in decimal

See Also:
Constant Field Values

mXMin

private float mXMin
min, max for plot data (excluding histogram data) which may have a different axis scale.


mXMax

private float mXMax

mYMin

private float mYMin

mYMax

private float mYMax

mHistYMin

private float mHistYMin
min max for histogram data. Histogram has Y axis toward right. X axis is shared with plot data, so we do not have min and max for histogram X axis data. If autofit is on, X axis will be large enough to fit all histogram and plot data on X axis


mHistYMax

private float mHistYMax

bHistogramPresent

private boolean bHistogramPresent
flag indicating if atleast one histogram data is present


bFourierPresent

private boolean bFourierPresent
flag indicating if fourier plot is present


bFinancialPresent

private boolean bFinancialPresent
flag indicating if financial plot is present


bSuperimposePhase

private boolean bSuperimposePhase
flag indicating if phase should be superimposed on amplitude chart for fourier plots


bXMajorTicksOn

private boolean bXMajorTicksOn

bXMinorTicksOn

private boolean bXMinorTicksOn

bYMajorTicksOn

private boolean bYMajorTicksOn

bYMinorTicksOn

private boolean bYMinorTicksOn

bGridOn

private boolean bGridOn

mXMinorTickSpacing

private float mXMinorTickSpacing

mXMajorTickSpacing

private float mXMajorTickSpacing

mYMinorTickSpacing

private float mYMinorTickSpacing

mYMajorTickSpacing

private float mYMajorTickSpacing

bXLabelOn

private boolean bXLabelOn

bYLabelOn

private boolean bYLabelOn

mXTitle

private java.lang.String mXTitle

mYTitle

private java.lang.String mYTitle

bLegendOn

private boolean bLegendOn

mBGColor

private java.awt.Color mBGColor

mAxisColor

private java.awt.Color mAxisColor

mAxisLabelColor

private java.awt.Color mAxisLabelColor

mTickColor

private java.awt.Color mTickColor

mGridLineColor

private java.awt.Color mGridLineColor

mPosHistogramColor

private java.awt.Color mPosHistogramColor
Color of positive bar in histogram


mNegHistogramColor

private java.awt.Color mNegHistogramColor
color of negative bar in histogram


bHighlightDataPoints

private boolean bHighlightDataPoints

mLineType

private LineType mLineType

mConnType

private ConnectionType mConnType

mLineWidth

private int mLineWidth

bAutoFitOn

private boolean bAutoFitOn

mPosXAxis

private int mPosXAxis

mPosYAxis

private int mPosYAxis

mXLegendBox

private int mXLegendBox

mYLegendBox

private int mYLegendBox

mMouseX

protected int mMouseX
X coordinate (in screen coordinates of mouse pressed event.


mMouseY

private int mMouseY
Y coordinate (in screen coordinates of mouse pressed event.


mNewMouseX

private int mNewMouseX

mNewMouseY

private int mNewMouseY

bShowHighlightedCoord

private boolean bShowHighlightedCoord
Flag for showing/hiding highlighted coordinates in a box


mCoordBoxColor

private java.awt.Color mCoordBoxColor

mHighlightPoint

private Pair<java.lang.Integer> mHighlightPoint
X and Y coordinates of point for highlighting (in screen coordinates)


mProjX

private double mProjX
Nearest point X coord (in world coordinates)


mProjY

private double mProjY
Nearest point Y coord (in world coordinates)


bHighlightDataPresent

private boolean bHighlightDataPresent
Is highlighting data present (prevents race condition between drawing and computing)


mCurrMousePoint

private Pair<java.lang.Double> mCurrMousePoint

mPlotDataIndex

private int mPlotDataIndex

mLeftPtIndex

private int mLeftPtIndex

mBufImg

private java.awt.image.BufferedImage mBufImg
Buffered image


m_bDrawMode

private boolean m_bDrawMode

m_bDrawingRuler

private boolean m_bDrawingRuler

m_RulerColor

private java.awt.Color m_RulerColor

m_bJapaneseCandlesticks

private boolean m_bJapaneseCandlesticks
Constructor Detail

TwoDPlotter

public TwoDPlotter()

TwoDPlotter

public TwoDPlotter(int width,
                   int height)
Method Detail

GetPlotType

public TwoDPlotter.PlotType GetPlotType(int i)

GetCandlestickFlag

public boolean GetCandlestickFlag()

SetCandlestickFlag

public void SetCandlestickFlag(boolean flag)

GetHighlightedCoordDisplayFlag

public boolean GetHighlightedCoordDisplayFlag()

SetHighlightedCoordDisplayFlag

public void SetHighlightedCoordDisplayFlag(boolean flag)

GetCoordBoxColor

public java.awt.Color GetCoordBoxColor()

SetRulerColor

public void SetRulerColor(java.awt.Color col)

SetDrawMode

public void SetDrawMode(boolean on)

SetCoordBoxColor

public void SetCoordBoxColor(java.awt.Color col)

SetXRange

public void SetXRange(float min,
                      float max)
Specified by:
SetXRange in interface Histogram
Specified by:
SetXRange in interface TwoDPlot

SetPositiveRectColor

public void SetPositiveRectColor(java.awt.Color col)
Description copied from interface: Histogram
Set the color of positive valued bar.

Specified by:
SetPositiveRectColor in interface Histogram

SetNegativeRectColor

public void SetNegativeRectColor(java.awt.Color col)
Description copied from interface: Histogram
Set the color of negative valued bar.

Specified by:
SetNegativeRectColor in interface Histogram

GetPositiveRectColor

public java.awt.Color GetPositiveRectColor()

GetNegativeRectColor

public java.awt.Color GetNegativeRectColor()

GetMinXRange

public float GetMinXRange()

GetMaxXRange

public float GetMaxXRange()

SetYRange

public void SetYRange(float min,
                      float max)
Specified by:
SetYRange in interface Histogram
Specified by:
SetYRange in interface TwoDPlot

GetMinYRange

public float GetMinYRange()

GetMaxYRange

public float GetMaxYRange()

SetXAxisPos

public void SetXAxisPos(int pos)

GetXAxisPos

public int GetXAxisPos()

SetYAxisPos

public void SetYAxisPos(int pos)

GetYAxisPos

public int GetYAxisPos()

ShowXMajorTicks

public void ShowXMajorTicks(boolean showXTicks)
Specified by:
ShowXMajorTicks in interface Histogram
Specified by:
ShowXMajorTicks in interface TwoDPlot

IsXMajorTickOn

public boolean IsXMajorTickOn()

ShowYMajorTicks

public void ShowYMajorTicks(boolean showYTicks)
Specified by:
ShowYMajorTicks in interface Histogram
Specified by:
ShowYMajorTicks in interface TwoDPlot

IsYMajorTickOn

public boolean IsYMajorTickOn()

ShowXMinorTicks

public void ShowXMinorTicks(boolean showXTicks)
Specified by:
ShowXMinorTicks in interface Histogram
Specified by:
ShowXMinorTicks in interface TwoDPlot

IsXMinorTickOn

public boolean IsXMinorTickOn()

ShowYMinorTicks

public void ShowYMinorTicks(boolean showYTicks)
Specified by:
ShowYMinorTicks in interface Histogram
Specified by:
ShowYMinorTicks in interface TwoDPlot

IsYMinorTickOn

public boolean IsYMinorTickOn()

SetMinorXTickSpacing

public void SetMinorXTickSpacing(float delta)
Specified by:
SetMinorXTickSpacing in interface Histogram
Specified by:
SetMinorXTickSpacing in interface TwoDPlot

GetMinorXTickSpacing

public float GetMinorXTickSpacing()

SetMajorXTickSpacing

public void SetMajorXTickSpacing(float delta)
Specified by:
SetMajorXTickSpacing in interface Histogram
Specified by:
SetMajorXTickSpacing in interface TwoDPlot

GetMajorXTickSpacing

public float GetMajorXTickSpacing()

SetMinorYTickSpacing

public void SetMinorYTickSpacing(float delta)
Specified by:
SetMinorYTickSpacing in interface Histogram
Specified by:
SetMinorYTickSpacing in interface TwoDPlot

GetMinorYTickSpacing

public float GetMinorYTickSpacing()

SetMajorYTickSpacing

public void SetMajorYTickSpacing(float delta)
Specified by:
SetMajorYTickSpacing in interface Histogram
Specified by:
SetMajorYTickSpacing in interface TwoDPlot

GetMajorYTickSpacing

public float GetMajorYTickSpacing()

ShowGrid

public void ShowGrid(boolean on)
Specified by:
ShowGrid in interface PlotBase

SetXLabelOn

public void SetXLabelOn(boolean on)

SetYLabelOn

public void SetYLabelOn(boolean on)

SetXTitle

public void SetXTitle(java.lang.String title)

GetXTitle

public java.lang.String GetXTitle()

SetYTitle

public void SetYTitle(java.lang.String title)

GetYTitle

public java.lang.String GetYTitle()

ShowLegend

public void ShowLegend(boolean legendOn)
Specified by:
ShowLegend in interface PlotBase

IsLegendOn

public boolean IsLegendOn()

SetBGColor

public void SetBGColor(java.awt.Color col)
Specified by:
SetBGColor in interface PlotBase

GetBGColor

public java.awt.Color GetBGColor()

SetAxisColor

public void SetAxisColor(java.awt.Color col)

GetAxisColor

public java.awt.Color GetAxisColor()

SetAxisLabelColor

public void SetAxisLabelColor(java.awt.Color col)

GetAxisLabelColor

public java.awt.Color GetAxisLabelColor()

SetTickColor

public void SetTickColor(java.awt.Color col)

GetTickColor

public java.awt.Color GetTickColor()

SetGridLineColor

public void SetGridLineColor(java.awt.Color col)

GetGridLineColor

public java.awt.Color GetGridLineColor()

HighlightDataPoints

public void HighlightDataPoints(boolean toHighlight)
Specified by:
HighlightDataPoints in interface PlotBase

SetLegendBoxXCorner

public void SetLegendBoxXCorner(int xcorner)
Specified by:
SetLegendBoxXCorner in interface PlotBase

GetLegendBoxXCorner

public int GetLegendBoxXCorner()

SetLegendBoxYCorner

public void SetLegendBoxYCorner(int ycorner)
Specified by:
SetLegendBoxYCorner in interface PlotBase

GetLegendBoxYCorner

public int GetLegendBoxYCorner()

IsGridOn

public boolean IsGridOn()

FourierTransform

public boolean FourierTransform(int plotIndex)

GetSuperimposePhase

public boolean GetSuperimposePhase()

SetSuperimposePhase

public void SetSuperimposePhase(boolean flag)

SetAutoFitOn

public void SetAutoFitOn(boolean on)
Specified by:
SetAutoFitOn in interface PlotBase

SetPlotSize

public void SetPlotSize(int xPixelNum,
                        int yPixelNum)
Specified by:
SetPlotSize in interface PlotBase

GetSize

public java.awt.Dimension GetSize()
Specified by:
GetSize in interface PlotBase

AddDataSet

public void AddDataSet(PlotData<E> data)
Add a data set representing line plot.


AddHistogramSet

public void AddHistogramSet(PlotData<E> data)
Add a data set representing histogram plot.


AddFinancialSet

public void AddFinancialSet(PlotData<E> data)
Add a data set representing financial data (typically includes day high, low, close, volume.


AddFourierSet

public void AddFourierSet(PlotData<E> data)
Add a data set representing Fourier Transform plot.


GetPlotData

public java.util.List<PlotData<E>> GetPlotData()

RemoveDataSet

public PlotData<E> RemoveDataSet(int setNum)

DeleteAllData

public void DeleteAllData()
Specified by:
DeleteAllData in interface PlotBase

SetLineType

public void SetLineType(LineType lineType)
Specified by:
SetLineType in interface TwoDPlot

SetConnectionType

public void SetConnectionType(ConnectionType connType)
Specified by:
SetConnectionType in interface TwoDPlot

SetLineWidth

public void SetLineWidth(int width)
Specified by:
SetLineWidth in interface TwoDPlot

Redraw

public void Redraw()

paintComponent

protected void paintComponent(java.awt.Graphics g)
Overrides:
paintComponent in class javax.swing.JComponent

DrawRulerOutline

protected void DrawRulerOutline(java.awt.Graphics g)

getPreferredSize

public java.awt.Dimension getPreferredSize()
Overrides:
getPreferredSize in class javax.swing.JComponent

ResizeBufferedImage

private void ResizeBufferedImage()
Resize the buffered image to drawing canvas size.


GetImageGraphics

public java.awt.Graphics GetImageGraphics()
Get the Graphics2d instance associated with buffered image.

Returns:
Graphics instance

RegenerateImage

public void RegenerateImage()
Paint the buffered image again, after possibly resizing it.


Draw

private void Draw(java.awt.Graphics g)
Draw the graph on provided graphics instance.

Parameters:
g - Graphics instance where painting needs to be done.

DrawGraph

private void DrawGraph(java.awt.Graphics g)
The actual method responsible for drawing the appropriate graph.

Parameters:
g - Graphics instance on which graph needs to be rendered.

ZoomIn

public void ZoomIn(int screen_x,
                   int screen_y,
                   int width,
                   int height)

HighlightCandlestick

public void HighlightCandlestick(int pattern)
highlight special candlestick pattern. 1: Doji line 2: engulfing pattern 4: hanging man 8: hammer More than one pattern can be chosen by 'bitwise or' in the flag


ComputeMinMax

private void ComputeMinMax()

DrawCoordBox

private void DrawCoordBox(java.awt.Graphics g)

DrawXYAxis

private void DrawXYAxis(java.awt.Graphics g)

DrawXMajorTicks

private void DrawXMajorTicks(java.awt.Graphics g)

DrawXMinorTicks

private void DrawXMinorTicks(java.awt.Graphics g)

DrawYMajorTicks

private void DrawYMajorTicks(java.awt.Graphics g)

DrawYMinorTicks

private void DrawYMinorTicks(java.awt.Graphics g)

DrawXAxisTitle

private void DrawXAxisTitle(java.awt.Graphics g)

DrawYAxisTitle

private void DrawYAxisTitle(java.awt.Graphics g)

DrawGrid

private void DrawGrid(java.awt.Graphics g)

DrawNewtonGraph

private void DrawNewtonGraph(java.awt.Graphics g)

ConvertWorldToScreenCoord

private void ConvertWorldToScreenCoord(double pt_x,
                                       double pt_y,
                                       Pair<java.lang.Integer> screenCoord)

ConvertScreenToWorldCoord

private void ConvertScreenToWorldCoord(int pt_x,
                                       int pt_y,
                                       Pair<java.lang.Double> worldCoord)

DrawLineGraph

private void DrawLineGraph(java.awt.Graphics g)

DrawDataPoints

private void DrawDataPoints(java.awt.Graphics g)

DrawLegend

private void DrawLegend(java.awt.Graphics g)
Draw the legend box at specified location. The size of the box is adjusted to fit contents.
The lower bottom corner of the box is (mXLegendBox,mYLegendBox)

See Also:
mXLegendBox, mYLegendBox

SaveScreenShot

public void SaveScreenShot(java.io.File file,
                           java.lang.String extension)
Save the screen shot of graphics window in JPG, BMP, TIG or PNG format.


mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Handler for mouseClicked event..

Specified by:
mouseClicked in interface java.awt.event.MouseListener
Parameters:
e - MouseEvent corresponding to mouse movement

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Handler for mouseMoved event.

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
Parameters:
e - MouseEvent corresponding to mouse movement

mouseExited

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

mouseReleased

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

mouseEntered

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

mousePressed

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

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener