Venice 0.751beta

nz.org.venice.chart
Class ChartModule

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended bynz.org.venice.chart.ChartModule
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, Module, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.io.Serializable

public class ChartModule
extends javax.swing.JPanel
implements Module, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.ActionListener

The charting module for venice. This class provides the user interface used to draw any of the required charts. Example:

	EODQuoteBundle quoteBundle = new EODQuoteBundle(new EODQuoteRange(symbol));
 `*	GraphSource dayClose = new OHLCVQuoteGraphSource(quoteBundle, Quote.DAY_CLOSE);
	Graph graph = new LineGraph(dayClose, Locale.getString("LINE_CHART"), true);

	ChartModule chart = new ChartModule(desktop);
	chart.add(graph, 0);
	chart.redraw();

	// Create a frame around the module and add to the desktop
	ModuleFrame frame = new ModuleFrame(chart, 0, 0, 400, 300);
	desktop.add(frame);
 

Structure

The chart module is made up of three core classes. These core classes are: ChartModule, Chart & BasicChartUI.

Glossary

The charting module uses a variety of phrases which have special meaning:

Annotations
These appear on the graph as little yellow notes indicating Graph specific information to the user. This information may include buy/sell recommendations or any other data.
Chart
A chart represents the entire graphable area. The chart can consist of several Graph Levels, each graph level may contain several Graphs.
Graph
A graph represents a specific type of graph to display, for example a Line Graph, a Bar Graph, a Moving Average Graph etc. These graphs can then be used to display different things to the user, for example the Bar Graph can be used to graph a stock's volume. A Line Graph can be used to graph a stock's day close.
Graph Level
For each chart there can be several levels of graph, these levels are displayed vertical one on top of the other. The top level may contain several stock's day close graphs. The bottom levels typically contain indicators such as volume or RSI.
Graph Source
Contains useful information that Graphs need to know so they can graph particular data (such as quote data). This information includes the values to be graphed, a title, the axis types to use and any Annotations to display for the graph.

See Also:
Graph, 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
 
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
ChartModule(javax.swing.JDesktopPane desktop)
          Create a new Chart.
ChartModule(javax.swing.JDesktopPane desktop, boolean indexChart)
          Create a new Chart.
ChartModule(javax.swing.JDesktopPane desktop, ChartModuleSettings settings)
          Create a new Chart.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Handle widget events.
 void activateButton(javax.swing.JButton b)
          Activate chart button b, and deactivate all the rest of the buttons.
 void add(Graph graph, Portfolio portfolio, EODQuoteBundle quoteBundle, int level)
          Add a new portfolio graph to the specified level.
 void add(Graph graph, Portfolio portfolio, EODQuoteBundle quoteBundle, int level, MenuSettings menuSettings)
          Add a new portfolio graph to the specified level.
 void add(Graph graph, Symbol symbol, EODQuoteBundle quoteBundle, int level)
          Add a new graph to the specified level.
 void add(Graph graph, Symbol symbol, EODQuoteBundle quoteBundle, int level, MenuSettings menuSettings)
          Add a new graph to the specified level.
 void add(java.util.SortedSet symbols)
           
 void addMarketIndicator(Graph graph)
           
 void addModuleChangeListener(java.beans.PropertyChangeListener listener)
          Add a property change listener for module change events.
 void addTracker(Symbol symbol)
          Add a cursor which tracks the trading date and price
 void append(Graph graph)
          Create a new level and add the graph.
 void append(Graph graph, int level)
          Add the graph to the specified level.
 int count()
          Return the number of graphs in the chart.
 void disableTracker()
          Deactivate the cursor
 void enableTracker()
          Activate the cursor
 boolean encloseInScrollPane()
          Return whether the module should be enclosed in a scroll pane.
 Chart getChart()
           
 javax.swing.JComponent getComponent()
          Return displayed component for this module.
 javax.swing.JDesktopPane getDesktop()
           
 javax.swing.ImageIcon getFrameIcon()
          Return frame icon for chart module.
 java.awt.image.BufferedImage getImage()
           
 javax.swing.JMenuBar getJMenuBar()
          Return menu bar for chart module.
 Settings getSettings()
          Return the Settings for the module.
 java.lang.String getTitle()
          Return the window title.
 ChartTracking getTracker()
           
 void handleAnnotation(Graph graph, boolean enabled)
          Record whether the given graph should have its annotations displayed or not.
 boolean isDataAvailable(Graph g)
           
 boolean isGraphing(java.lang.String name)
          Return if we graphing the given symbol/portfolio.
 void mouseClicked(java.awt.event.MouseEvent e)
           
 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)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void postLoad()
          Functions that will run after the chart has been fully loaded TODO: Check if we should implement listeners/observers
 void redraw()
          Redraw the current display.
 void remove(Graph graph)
          Remove the graph from the chart.
 void removeAll(java.lang.String name)
          Remove all graphs with the given symbol from the chart.
 void removeModuleChangeListener(java.beans.PropertyChangeListener listener)
          Remove a property change listener for module change events.
 void removeTracker()
          Remove all cursors.
 void replaceGraph(Graph oldGraph, Graph newGraph)
          Replace a graph on the chart with a new graph.
 void save()
          Tell module to save any current state data / preferences data because the window is being closed.
 void setHBarToMax()
          Move the horizontal scroll bar to the end of the pane.
 
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, getMinimumSize, 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, paintComponent, 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
 

Constructor Detail

ChartModule

public ChartModule(javax.swing.JDesktopPane desktop)
Create a new Chart.

Parameters:
desktop - the parent desktop.

ChartModule

public ChartModule(javax.swing.JDesktopPane desktop,
                   boolean indexChart)
Create a new Chart.

Parameters:
desktop - the parent desktop.

ChartModule

public ChartModule(javax.swing.JDesktopPane desktop,
                   ChartModuleSettings settings)
Create a new Chart.

Parameters:
desktop - the parent desktop.
settings - The settings data for the chart.
Method Detail

redraw

public void redraw()
Redraw the current display.


add

public void add(Graph graph,
                Symbol symbol,
                EODQuoteBundle quoteBundle,
                int level)
Add a new graph to the specified level. Add new menu for graph.

Parameters:
graph - the new graph to add
level - graph level to add the new graph

add

public void add(Graph graph,
                Symbol symbol,
                EODQuoteBundle quoteBundle,
                int level,
                MenuSettings menuSettings)
Add a new graph to the specified level. Add new menu for graph.

Parameters:
graph - the new graph to add
level - graph level to add the new graph
menuSettings - The menusettings for the graph

add

public void add(java.util.SortedSet symbols)

isGraphing

public boolean isGraphing(java.lang.String name)
Return if we graphing the given symbol/portfolio.

Parameters:
name - Name of symbol/portfolio
Returns:
whether we are graphing the symbol/portfolio or not

add

public void add(Graph graph,
                Portfolio portfolio,
                EODQuoteBundle quoteBundle,
                int level)
Add a new portfolio graph to the specified level. Add new menu for graph.

Parameters:
graph - the portfolio graph
portfolio - the portfolio
quoteBundle - the quote bundle
level - specified level

add

public void add(Graph graph,
                Portfolio portfolio,
                EODQuoteBundle quoteBundle,
                int level,
                MenuSettings menuSettings)
Add a new portfolio graph to the specified level. Add new menu for graph.

Parameters:
graph - the portfolio graph
portfolio - the portfolio
quoteBundle - the quote bundle
level - specified level

addMarketIndicator

public void addMarketIndicator(Graph graph)

append

public void append(Graph graph,
                   int level)
Add the graph to the specified level. This is identical to the add method except that it does not add a new menu for the graph.

Parameters:
graph - The new graph to add
level - graph level to add the new graph
See Also:
add(nz.org.venice.chart.graph.Graph, nz.org.venice.quote.Symbol, nz.org.venice.quote.EODQuoteBundle, int)

append

public void append(Graph graph)
Create a new level and add the graph. This is identical to the add method except that it does not add a new menu for the graph.

Parameters:
graph - the new graph to add.
See Also:
add(nz.org.venice.chart.graph.Graph, nz.org.venice.quote.Symbol, nz.org.venice.quote.EODQuoteBundle, int)

replaceGraph

public void replaceGraph(Graph oldGraph,
                         Graph newGraph)
Replace a graph on the chart with a new graph.

Parameters:
oldGraph - the graph to remove
newGraph - the new graph to replace the old one.

remove

public void remove(Graph graph)
Remove the graph from the chart. Currently does not remove the menu for the appropriate symbol. Probably should.

Parameters:
graph - the graph to remove.

count

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

Returns:
the number of graphs in the chart

removeAll

public void removeAll(java.lang.String name)
Remove all graphs with the given symbol from the chart.

Parameters:
name - The name of the graphs to remove

handleAnnotation

public void handleAnnotation(Graph graph,
                             boolean enabled)
Record whether the given graph should have its annotations displayed or not. Annotations are little popup text notes that contain information about the graph, such as buy/sell suggestions.

Parameters:
graph - the graph to change annotations for.
enabled - set to true if the graph should handle annotations false otherwise.

getTitle

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

Specified by:
getTitle in interface Module
Returns:
the window title

addModuleChangeListener

public void addModuleChangeListener(java.beans.PropertyChangeListener listener)
Add a property change listener for module change events.

Specified by:
addModuleChangeListener in interface Module
Parameters:
listener - listener

removeModuleChangeListener

public void removeModuleChangeListener(java.beans.PropertyChangeListener listener)
Remove a property change listener for module change events.

Specified by:
removeModuleChangeListener in interface Module
Parameters:
listener - listener

getComponent

public javax.swing.JComponent getComponent()
Return displayed component for this module.

Specified by:
getComponent in interface Module
Returns:
the component to display.

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

mouseDragged

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

mouseMoved

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

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Handle widget events.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
e - action event

activateButton

public void activateButton(javax.swing.JButton b)
Activate chart button b, and deactivate all the rest of the buttons.

Parameters:
b - Chart Drawing button to activate

getDesktop

public javax.swing.JDesktopPane getDesktop()

getJMenuBar

public javax.swing.JMenuBar getJMenuBar()
Return menu bar for chart module.

Specified by:
getJMenuBar in interface Module
Returns:
the menu bar.

getFrameIcon

public javax.swing.ImageIcon getFrameIcon()
Return frame icon for chart module.

Specified by:
getFrameIcon in interface Module
Returns:
the frame icon

encloseInScrollPane

public boolean encloseInScrollPane()
Return whether the module should be enclosed in a scroll pane.

Specified by:
encloseInScrollPane in interface Module
Returns:
enclose module in scroll bar

save

public void save()
Tell module to save any current state data / preferences data because the window is being closed.

Specified by:
save in interface Module

getImage

public java.awt.image.BufferedImage getImage()

isDataAvailable

public boolean isDataAvailable(Graph g)

getSettings

public Settings getSettings()
Description copied from interface: Module
Return the Settings for the module.

Specified by:
getSettings in interface Module

enableTracker

public void enableTracker()
Activate the cursor


disableTracker

public void disableTracker()
Deactivate the cursor


removeTracker

public void removeTracker()
Remove all cursors.


addTracker

public void addTracker(Symbol symbol)
Add a cursor which tracks the trading date and price

Parameters:
symbol - The symbol to track

getTracker

public ChartTracking getTracker()

setHBarToMax

public void setHBarToMax()
Move the horizontal scroll bar to the end of the pane.


postLoad

public void postLoad()
Functions that will run after the chart has been fully loaded TODO: Check if we should implement listeners/observers


getChart

public Chart getChart()
Returns:
current Chart being used by ChartModule

Venice 0.751beta