Venice 0.7beta

org.mov.chart
Class ChartModule

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 org.mov.chart.ChartModule
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, Module

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/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.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.
 
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, Symbol symbol, EODQuoteBundle quoteBundle, int level)
          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 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.
 boolean encloseInScrollPane()
          Return whether the module should be enclosed in a scroll pane.
 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.
 java.lang.String getTitle()
          Return the window title.
 void handleAnnotation(Graph graph, boolean enabled)
          Record whether the given graph should have its annotations displayed or not.
 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 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 save()
          Tell module to save any current state data / preferences data because the window is being closed.
 
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, 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, 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

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.
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(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

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(org.mov.chart.graph.Graph, org.mov.quote.Symbol, org.mov.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(org.mov.chart.graph.Graph, org.mov.quote.Symbol, org.mov.quote.EODQuoteBundle, int)

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()

Venice 0.7beta