edu.brook.ascape.view
Class ChartView

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--jclass.base.BaseComponent
                          |
                          +--jclass.base.TransientComponent
                                |
                                +--jclass.chart.JCChart
                                      |
                                      +--jclass.chart.BaseChart
                                            |
                                            +--edu.brook.ascape.view.ChartView

public class ChartView
extends jclass.chart.BaseChart
implements ComponentView

A chart view of a scape. Delegates many functions, including scape listener, to subclasses of ChartViewModel. This view uses KL Group's JChart; if you want to use other charting packages, let us know, we'd like to generalize further so that multiple charting packages can be used. Requires KLGroup JCChart.

Since:
1.0
Version:
1.2.6
See Also:
Serialized Form

Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Field Summary
protected  boolean awaitingUpdate
          Are we waiting for the paint method to be called before an update?
protected  int chartType
          The chart type this view is using.
protected  ChartCustomizer customizer
          The panel responsible for customizing this chart.
protected  ViewFrameBridge frame
          The frame, if any, that this iew is displayed within
static int HISTOGRAM
          Histogram (bar graph) chart type.
protected  java.lang.String name
          The name of the view.
static int PIE
          Pie chart type.
protected  GraphicsRecorder recorder
          A recorder for the graphic of this view.
protected  boolean recordNext
          Are we waiting for a record to occur?
protected  Scape scape
          The scape that we are principally charting.
static int TIME_SERIES
          Time series (line graph) chart type.
protected  ChartViewModel viewModel
          The view model that we are delegating to.
 
Fields inherited from class jclass.chart.BaseChart
AUTOMATIC, axesOrientationStrings, axesOrientationValues, dataSource, DAYS, EAST, HORIZONTAL, HOURS, MAX, MIN, MINUTES, MONTHS, NORTH, NORTHEAST, NORTHWEST, ORIENT_INVERTED_X_NORMAL_Y_NORMAL, ORIENT_INVERTED_X_NORMAL_Y_REVERSED, ORIENT_INVERTED_X_REVERSED_Y_NORMAL, ORIENT_INVERTED_X_REVERSED_Y_REVERSED, ORIENT_X_NORMAL_Y_NORMAL, ORIENT_X_NORMAL_Y_REVERSED, ORIENT_X_REVERSED_Y_NORMAL, ORIENT_X_REVERSED_Y_REVERSED, ORIGIN, POINT_LABELS, ROTATE_270, ROTATE_90, ROTATE_NONE, SECONDS, SOUTH, SOUTHEAST, SOUTHWEST, tableModel, TIME_LABELS, VALUE, VALUE_ANCHORED, VALUE_LABELS, VERTICAL, WEEKS, WEST, YEARS
 
Fields inherited from class jclass.chart.JCChart
AREA, BAR, cancelKey, CANDLE, chartArea, currentDwellLabel, customizerName, data, dataviewHashtable, dwellLabels, ENCODE_GIF, ENCODE_PNG, eventAction_strings, eventAction_values, eventMod_strings, eventMod_values, fillColorIndex, FILLED_RADAR, footer, header, HILO, HILO_OPEN_CLOSE, indexHashtable, labels, legend, lineColorIndex, listeners, margins, NONE, pickListeners, PIE, PLOT, POLAR, RADAR, resetKey, SCATTER_PLOT, STACKING_AREA, STACKING_BAR, symbolColorIndex, symbolShapeIndex, triggers
 
Fields inherited from class jclass.base.TransientComponent
draw_gc, highlight, highlight_color, mouse_down_event_timestamp, popdown_event_timestamp, pref_height, pref_width, traversable
 
Fields inherited from class jclass.base.BaseComponent
applet, applet_context, BELL, border, border_style, BS, clipToScreen, dblbuffer_image, dblbuffer_image_gc, DELETE, do_repaint, double_buffer, ENTER, ESC, has_focus, images, in_repaint, insets, LOCK, needs_layout, NOVALUE, paint_rect, realized, rect, TAB, use_system_colors, userdata
 
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
 
Constructor Summary
ChartView()
          Construct a chart view of default time series type.
ChartView(int chartType)
          Construct a chart view with a specicifed chart type.
ChartView(int chartType, java.lang.String name)
          Construct a chart view of default time series type.
ChartView(java.lang.String name)
          Construct a chart view of default time series type.
 
Method Summary
 void addScape(Scape scape)
          Sets the scape that this chart and, by delegation, its view model, is viewing.
 void addSeries(java.lang.String valueName)
          Adds a series to the chart being viewed.
 void addSeries(java.lang.String valueName, java.awt.Color color)
          Adds a series to the chart being viewed.
 void addSeries(java.lang.String valueName, java.awt.Color color, boolean continuous)
          Adds a series to the chart being viewed.
 void build()
          Prepare the component view, once the view's scape has been created.
 void clearSeries()
          Clears all series selections from the chart being viewed.
 void displayViewCustomizer()
          Displays a window for altering the setting for this chart.
 GraphicsRecorder getGraphicsRecorder()
          Returns a recorder that can be used to record the graphics of this view.
 java.lang.String getName()
          Returns a name for the view as defined by set name.
 Scape getScape()
          Returns the scape this chart views.
 ViewFrameBridge getViewFrame()
          Returns the frame this view occupies, null if none.
 ChartViewModel getViewModel()
          Returns the view model that this chart view is displaying.
 boolean isShowLegend()
          Is the legend showing?
 void paint(java.awt.Graphics g)
          Paints the chart.
 void removeScape(Scape scape)
          Removes the scape from the view model.
 void removeSeries(java.lang.String valueName)
          Removes a series from the chart being viewed.
protected  void requestPaintUpdate()
          Instructs the chart view that it is waiting for a a paint and should request an update the next time one occurs.
 void requestRecord()
          Instructs the chart view to call a graphics recorder at the next paint if one exists.
 void scapeUpdated(ScapeEvent scapeEvent)
          Delegates the scap eupdate event to the view model, informing it that the scape has been updated.
 void setChartType(int chartType)
          Sets the chart type, creating the appropriate delegate view model and adding the scape to it.
 void setGraphicsRecorder(GraphicsRecorder recorder)
          Sets the recorder that can be used to record the graphics of this view.
 void setName(java.lang.String name)
          Sets the name of this view.
 void setShowLegend(boolean showing)
          Show the legend? True by default.
 void setViewFrame(ViewFrameBridge frame)
          Sets the frame this view appears in.
 java.lang.String toString()
          Returns a short description of this view.
 
Methods inherited from class jclass.chart.BaseChart
getAxisOrientation, getChartType, getFooterText, getHeaderText, getLegendAnchor, getLegendIsShowing, getLegendOrientation, getMargins, getSwingDataModel, getView3D, getXAxisAnnotationMethod, getXAxisGridIsShowing, getXAxisIsLogarithmic, getXAxisIsShowing, getXAxisMax, getXAxisMin, getXAxisMinMax, getXAxisNumSpacing, getXAxisTitleText, getYAxisAnnotationMethod, getYAxisGridIsShowing, getYAxisIsLogarithmic, getYAxisIsShowing, getYAxisMax, getYAxisMin, getYAxisMinMax, getYAxisNumSpacing, getYAxisTitleText, setAxisOrientation, setFooterText, setHeaderText, setLegendAnchor, setLegendIsShowing, setLegendOrientation, setMargins, setSwingDataModel, setView3D, setXAxisAnnotationMethod, setXAxisGridIsShowing, setXAxisIsLogarithmic, setXAxisIsShowing, setXAxisMax, setXAxisMin, setXAxisMinMax, setXAxisNumSpacing, setXAxisTitleText, setYAxisAnnotationMethod, setYAxisGridIsShowing, setYAxisIsLogarithmic, setYAxisIsShowing, setYAxisMax, setYAxisMin, setYAxisMinMax, setYAxisNumSpacing, setYAxisTitleText
 
Methods inherited from class jclass.chart.JCChart
addChartLabel, addChartListener, addDataView, addNotify, addPickListener, addToDwellLabels, addTrigger, appendChartLabel, cancel, chartDataChange, deleteChartLabel, findDataView, getAbout, getAllowUserChanges, getApplet, getBorderType, getBorderWidth, getBottomMargin, getCancelKey, getChanged, getChanged, getChartArea, getChartLabels, getChartLabels, getConverter, getCustomizerName, getDataView, getDataView, getFillColorIndex, getFooter, getHeader, getIsBatched, getLeftMargin, getLegend, getLineColorIndex, getNumChartLabels, getNumData, getNumTriggers, getResetKey, getRightMargin, getSaveParamStream, getSymbolColorIndex, getSymbolShapeIndex, getTopMargin, getTrigger, getVersion, getWarningDialog, insets, isChanged, isChanged, isNetscape, keyDown, keyPressed, keyReleased, keyTyped, launchPropertyPage, layout, loadParams, loadParams, locateChartRegion, main, makeChart, markAllChartLabelsForRecalc, minimumSize, mouseClicked, mouseDown, mouseDrag, mouseDragged, mouseEntered, mouseExit, mouseExited, mouseMove, mouseMoved, mousePressed, mouseReleased, mouseUp, paintComponent, pick, preferredSize, printAll, processMouseEvent, recalc, recalcChangedChartLabels, removeAllChartLabels, removeChartLabel, removeChartListener, removeDataView, removeFromDwellLabels, removePickListener, removeTrigger, requestFocus, reset, resetDefaults, rotate, rotateEnd, rotateStart, saveChartAs, saveChartAsGif, saveChartAsPng, saveParams, scale, setAbout, setAllowUserChanges, setBackground, setBorderType, setBorderWidth, setBottomMargin, setCancelKey, setChanged, setChanged, setChartArea, setChartLabels, setChartLabels, setCustomizerName, setDataView, setDataView, setFillColorIndex, setFont, setFooter, setForeground, setHeader, setIsBatched, setLeftMargin, setLegend, setLineColorIndex, setResetKey, setRightMargin, setSaveParamStream, setSymbolColorIndex, setSymbolShapeIndex, setTopMargin, setTrigger, setVersion, setWarningDialog, snapshot, timerExpired, translate, translateStart, unpick, unpick, update, zoom
 
Methods inherited from class jclass.base.TransientComponent
clipGCToAncestors, convertEvent, disable, drawBorder, drawHighlight, drawHighlight, drawHighlightAndBorder, enable, getDrawingArea, getDrawingArea, getDrawingAreaHeight, getDrawingAreaWidth, getHighlightColor, getHighlightThickness, getPaintRect, getPreferredHeightInternal, getPreferredWidthInternal, gotFocus102, isBustedVM, isFocusTraversable, isTraversable, lostFocus102, preferredHeight, preferredWidth, processFocusEvent, processKeyEvent, processMouseMotionEvent, setBounds, setBounds, setCursor, setHighlightColor, setHighlightThickness, setPreferredSize, setPreferredSize, setTraversable
 
Methods inherited from class jclass.base.BaseComponent
copyArea, createImage, createImage, createImage, dispose, fillBackground, getApplet, getAppletContext, getAppletContext, getAWTLock, getBorderStyle, getBorderThickness, getClipToScreen, getDoubleBuffer, getDoubleBufferGraphics, getDoubleBufferImage, getFrame, getFrame, getInsets, getShadowThickness, getUserData, getUserDataInt, getVisibleScreenLoc, getWindow, hasFocus, intersects, isRealized, isShowing, paintImmediately, removeNotify, repaint, repaint, repaint, repaint, setBorderStyle, setBorderThickness, setClipToScreen, setDoubleBuffer, setInsets, setShadowThickness, setUserData, translateFromParent, translateToParent, update, updateParent, useSystemColors, validate
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getUIClassID, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isFocusCycleRoot, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintImmediately, paramString, processComponentKeyEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, requestDefaultFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setRequestFocusEnabled, setToolTipText, setUI, setVisible, unregisterKeyboardAction, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, invalidate, isAncestorOf, list, list, locate, paintComponents, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hide, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isValid, isVisible, keyUp, list, list, list, location, lostFocus, mouseEnter, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processInputMethodEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, repaint, resize, resize, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setSize, setSize, show, show, size, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TIME_SERIES

public static final int TIME_SERIES
Time series (line graph) chart type. Same as JCChart.PLOT. Note: Chart types have the same ints as cooresponding JCChart chart types. Only the names have been changed to match general usage. Note that this is just for convenience and clarity; these symbols may also be translated for other charting packages. So this usage should not be relied on; whenever possible use these ChartView constants, and not their JCChart counterparts.

HISTOGRAM

public static final int HISTOGRAM
Histogram (bar graph) chart type. Same as JCChart.BAR.

PIE

public static final int PIE
Pie chart type. Same as JCChart.PIE.

chartType

protected int chartType
The chart type this view is using. (Time series is default.)

viewModel

protected ChartViewModel viewModel
The view model that we are delegating to.

customizer

protected ChartCustomizer customizer
The panel responsible for customizing this chart.

scape

protected Scape scape
The scape that we are principally charting. Note that data from all scapes is available to the chart.

frame

protected ViewFrameBridge frame
The frame, if any, that this iew is displayed within

name

protected java.lang.String name
The name of the view.

recorder

protected GraphicsRecorder recorder
A recorder for the graphic of this view. Usually null, unless this view is being recorded.

recordNext

protected boolean recordNext
Are we waiting for a record to occur?

awaitingUpdate

protected boolean awaitingUpdate
Are we waiting for the paint method to be called before an update?
Constructor Detail

ChartView

public ChartView()
Construct a chart view of default time series type.

ChartView

public ChartView(int chartType)
Construct a chart view with a specicifed chart type.
Parameters:
chartType - the charttype symbol

ChartView

public ChartView(java.lang.String name)
Construct a chart view of default time series type.
Parameters:
name - a name for the chart series

ChartView

public ChartView(int chartType,
                 java.lang.String name)
Construct a chart view of default time series type.
Parameters:
chartType - the charttype symbol
name - a name for the chart series
Method Detail

build

public void build()
Prepare the component view, once the view's scape has been created.
Specified by:
build in interface ComponentView

getName

public java.lang.String getName()
Returns a name for the view as defined by set name.
Overrides:
getName in class java.awt.Component

setName

public final void setName(java.lang.String name)
Sets the name of this view.
Parameters:
name - a user relevant name for this view
Overrides:
setName in class java.awt.Component

toString

public java.lang.String toString()
Returns a short description of this view. Sames as name unless overridden.
Overrides:
toString in class java.awt.Component

displayViewCustomizer

public void displayViewCustomizer()
Displays a window for altering the setting for this chart.

setChartType

public void setChartType(int chartType)
Sets the chart type, creating the appropriate delegate view model and adding the scape to it. If a chart type has allready been specified, copies the exisiting selection model and other relevant settings to it. Please see the documentation for JCChart.TIME_SERIES for important information regarding chart type symbols.
Parameters:
chartType - the symbol for the chart type to set
Overrides:
setChartType in class jclass.chart.BaseChart

isShowLegend

public boolean isShowLegend()
Is the legend showing?

setShowLegend

public void setShowLegend(boolean showing)
Show the legend? True by default.
Parameters:
showing - true to show legend, false to hide it.

getViewModel

public ChartViewModel getViewModel()
Returns the view model that this chart view is displaying.

addSeries

public void addSeries(java.lang.String valueName)
Adds a series to the chart being viewed. Convenience method (could also get view model and set select group.)
Parameters:
valueName - the name of the series to add

addSeries

public void addSeries(java.lang.String valueName,
                      java.awt.Color color)
Adds a series to the chart being viewed. Convenience method.
Parameters:
valueName - the name of the series to add
Color - the color to use for the series in the chart

addSeries

public void addSeries(java.lang.String valueName,
                      java.awt.Color color,
                      boolean continuous)
Adds a series to the chart being viewed. Convenience method.
Parameters:
valueName - the name of the series to add
Color - the color to use for the series in the chart
boolean - should the series be drawn as a line or series of symbols?

removeSeries

public void removeSeries(java.lang.String valueName)
Removes a series from the chart being viewed. Convenience method.
Parameters:
valueName - the name of the series to remove

clearSeries

public void clearSeries()
Clears all series selections from the chart being viewed. Convenience method.
Parameters:
valueName - the name of the series to remove

getScape

public Scape getScape()
Returns the scape this chart views.
Specified by:
getScape in interface ComponentView

addScape

public void addScape(Scape scape)
              throws java.util.TooManyListenersException
Sets the scape that this chart and, by delegation, its view model, is viewing. Note that it doesn't really matter what scape you add, as the chart view will have access to every statistic available for the entire model, but all views still need to be controlled by one particular scape. One and only one scape may be added (we use addScape form to match beans registration signature.)
Parameters:
the - scape this cahrt is viewing

removeScape

public void removeScape(Scape scape)
Removes the scape from the view model. Null expected; scape used to match beans registration signature.
Parameters:
scape - the scape to remove, or null

getViewFrame

public ViewFrameBridge getViewFrame()
Returns the frame this view occupies, null if none.
Specified by:
getViewFrame in interface ComponentView

setViewFrame

public void setViewFrame(ViewFrameBridge frame)
Sets the frame this view appears in.
Specified by:
setViewFrame in interface ComponentView

getGraphicsRecorder

public GraphicsRecorder getGraphicsRecorder()
Returns a recorder that can be used to record the graphics of this view. If null (default, and typical), there is no recorder for this view.
Specified by:
getGraphicsRecorder in interface ComponentView

setGraphicsRecorder

public void setGraphicsRecorder(GraphicsRecorder recorder)
Sets the recorder that can be used to record the graphics of this view. If null, do not record.
Specified by:
setGraphicsRecorder in interface ComponentView

requestRecord

public void requestRecord()
Instructs the chart view to call a graphics recorder at the next paint if one exists. Has no effect if a graphics recorder is not set for this chart (as is typically the case.)

requestPaintUpdate

protected void requestPaintUpdate()
Instructs the chart view that it is waiting for a a paint and should request an update the next time one occurs. Used in collaboration with ChartViewModel.

scapeUpdated

public void scapeUpdated(ScapeEvent scapeEvent)
Delegates the scap eupdate event to the view model, informing it that the scape has been updated. The viewmodel is responsible for notifying the scape that it has been updated.
Parameters:
event - the scape setup event

paint

public void paint(java.awt.Graphics g)
Paints the chart. If view is awaiting update, paint calls updated so that the scape will be notified when we are done painting. This method should rarely need to be overridden; use scapeUpdated to update component state.
Specified by:
paint in interface ComponentView
Parameters:
g - the graphics context.
Overrides:
paint in class jclass.chart.JCChart

(c) 1998-2000 The Brookings Insitution
Webpage