ucar.unidata.idv.control.chart
Class ChartWrapper

java.lang.Object
  extended by ucar.unidata.collab.SharableImpl
      extended by ucar.unidata.collab.PropertiedThing
          extended by ucar.unidata.idv.control.multi.DisplayComponent
              extended by ucar.unidata.idv.control.chart.ChartWrapper
All Implemented Interfaces:
KeyListener, PropertyChangeListener, EventListener, Sharable
Direct Known Subclasses:
PlotWrapper, ReadoutTable, StatisticsChartWrapper, TableChartWrapper

public abstract class ChartWrapper
extends DisplayComponent
implements KeyListener

Abstract class for chart implementations

Version:
$Revision: 1.46 $
Author:
IDV Development Team

Nested Class Summary
protected static class ChartWrapper.FieldProperties
          Class FieldProperties holds state for the data choice wrappers in the properties dialog
 
Field Summary
protected  AnimationWidget animationWidget
          The widget
protected  List dataChoiceWrappers
          List of data choices
static String PROP_SELECTEDTIME
          Property change id
static String PROP_TIMERANGE
          Property change id
protected  TimeSeriesChartWrapper timeFilterSource
          This is the time series that we get the time segments from for subsetting
protected  ChartWrapper timeSelectSource
          This is the source for time selects
 
Fields inherited from class ucar.unidata.idv.control.multi.DisplayComponent
CMD_SAVEIMAGE, CMD_SAVEMOVIE, displayControl, displayLabel, hasBeenInitialized, isRemoved, PROP_REMOVED
 
Fields inherited from class ucar.unidata.collab.PropertiedThing
propertiesDialog
 
Constructor Summary
ChartWrapper()
          Default ctor
ChartWrapper(String name, List dataChoices)
          Ctor
 
Method Summary
 void addDataChoice(DataChoice dataChoice)
          Add the dta choice
 void addDataChoices(List newDataChoices)
          Add the data choices
 void addField()
          Add a field to thei chart
 void animationTimeChanged(Real time)
          Use the animation time to set the domain crosshairs
 void applyJython()
          Get the jython text from the text field and apply it
protected  void applyJython(String jython)
          Evaluate the jython.
protected  boolean applyProperties()
          Apply properties
protected  boolean canBeASourceForTimeSelectionEvents()
          Can this component be a source for time selection events
 boolean canDoDataChoiceList()
          ok to show the data choice list
protected  boolean canDoDriveTime()
          Can this chart drive the times in the main display.
protected  boolean canDoJython()
          Should the jython field be shown in the properties
protected  boolean canDoMinMaxDate()
          Can this chart subset the entire data set on time
 boolean canDoParameters()
          Can we add fields
 boolean canDoRemoveParameters()
          Can we remove fields
protected  boolean canDoResolution()
          Should show resolution widget
protected  boolean canDoTimeFilters()
          Can this chart use time subset filters.
protected  boolean canDoTimeSelect()
          Can this chart use time selects This is used to determine whether the checkbox should be shown in the menus
 boolean canDoWrapperColor()
          Can the color swatch be shown in the properties for the data choice wrappers.
 boolean canDoWrapperSide()
          Can the Side menu be shown in the properties for the data choice wrappers.
protected  DataChoiceWrapper createDataChoiceWrapper(DataChoice dataChoice)
          A utility to create a data choice wrapper
protected  boolean doApplyProperties()
          Apply the properties
protected  JComponent doMakeWrapperDisplayComponent(int idx, ChartWrapper.FieldProperties fieldProperty)
          Make the widget for the field
 boolean doMultipleAddFields()
          When selecting data does the data tree support multiple selections
 void doRemove()
          Cleanup the chart
protected  double[][] filterData(double[] samples, double[] timeValues)
          Utility to pull subset the given samples based on the time filter ranges
 String formatValue(double v)
          utility to format the value
 String getAnimationShareGroup()
          Get the AnimationShareGroup property.
 List getCategories()
          Get the data categories for selecting data choices
 List getDataChoices()
          Create and return a list of the data choices held by the data choice wrappers.
 List getDataChoiceWrappers()
          Get the DataChoiceWrappers property.
 boolean getDriveTime()
          Get the DriveTime property.
 List getFieldSelectionLabels()
          Returns the list of labels used for selecting data choices.
protected  FlatField getFlatField(FieldImpl data)
          Utility to extract a FlatField from the data
protected  org.python.util.PythonInterpreter getInterpreter()
          Create, if needed, and return the interpreter
 String getJython()
          Get the Jython property.
 double getMaxDate()
          Get the MaxDate property.
 double getMinDate()
          Get the MinDate property.
protected  List getPopupMenuItems(List items)
          Add the default menu items
protected  void getPropertiesComponents(List comps, int tabIdx)
          Create the properties contents
 double getResolution()
          Get the Resolution property.
 boolean getShowTime()
          Get the ShowTime property.
protected  List getTimeFilterRanges()
          Get get list of Ranges for time subsetting.
 TimeSeriesChartWrapper getTimeFilterSource()
          Get the FilterSource property.
 List getTimeRanges()
          Get the time ranges to use
 ChartWrapper getTimeSelectSource()
          Get the SelectSource property.
 double[] getTimeValues(double[][] samples, FlatField data)
          Convert the time from the data (in samples[1]) into an array of milliseconds
abstract  String getTypeName()
          Overwritten by derived classes to return the name of the type of this chart.
 void init(MultiDisplayHolder displayControl, List dataChoices)
          Initialize
 void initDone()
          Called after this chart has been created.
protected  void initializeJython(org.python.util.PythonInterpreter interpreter)
          Add the state of this chart to the interpreter
 void keyPressed(KeyEvent e)
          Noop
 void keyReleased(KeyEvent e)
          Noop
 void keyTyped(KeyEvent e)
          Noop
 void loadData()
          create shapes for an individual time step.
 void propertyChange(PropertyChangeEvent event)
          Handle the event
 void removeTimeFilterSource()
          Remove the current time filter source
 void removeTimeSelectSource()
          Remove the current time select source
 void setAnimationShareGroup(String value)
          Set the AnimationShareGroup property.
 void setDataChoiceWrappers(List value)
          Set the DataChoiceWrappers property.
 void setDriveTime(boolean value)
          Set the DriveTime property.
 void setJython(String value)
          Set the Jython property.
 void setMaxDate(double value)
          Set the MaxDate property.
 void setMinDate(double value)
          Set the MinDate property.
 void setResolution(double value)
          Set the Resolution property.
 void setShowTime(boolean value)
          Set the ShowTime property.
 void setTimeFilterSource(TimeSeriesChartWrapper value)
          Set the FilterSource property.
 void setTimeFromAnimation(Real time)
          Animation in main display changed.
 void setTimeSelectSource(ChartWrapper value)
          Set the SelectSource property.
protected  List wrapDataChoices(List choices)
          A utility that takes a list of DataChoice-s and wraps each one in the DataChoiceWrapper.
 
Methods inherited from class ucar.unidata.idv.control.multi.DisplayComponent
addGroupMenuItems, doMakeContents, doMakeDisplayLabel, doSaveImage, doSaveMovie, getBackgroundColor, getContents, getDisplayables, getDisplayControl, getDisplayGroup, getDisplayLabel, getIsRemoved, getLabelShown, getName, initAfterUnPersistence, removeDisplayComponent, setBackgroundColor, setDisplayControl, setDisplayGroup, setIsRemoved, setLabelShown, setName, showPopup, showProperties, toString
 
Methods inherited from class ucar.unidata.collab.PropertiedThing
addPropertyChangeListener, firePropertyChange, firePropertyChange, getPropertyListeners, getPropertyTabs, isShowing, removePropertyChangeListener, showProperties
 
Methods inherited from class ucar.unidata.collab.SharableImpl
applySharableProperties, doShare, doShare, doShareExternal, doShareInternal, getSharablePropertiesComponent, getShareGroup, getSharing, getUniqueId, initSharable, receiveShareData, removeSharable, setShareGroup, setSharing, setUniqueId, showSharableDialog
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROP_TIMERANGE

public static final String PROP_TIMERANGE
Property change id

See Also:
Constant Field Values

PROP_SELECTEDTIME

public static final String PROP_SELECTEDTIME
Property change id

See Also:
Constant Field Values

animationWidget

protected AnimationWidget animationWidget
The widget


dataChoiceWrappers

protected List dataChoiceWrappers
List of data choices


timeFilterSource

protected TimeSeriesChartWrapper timeFilterSource
This is the time series that we get the time segments from for subsetting


timeSelectSource

protected ChartWrapper timeSelectSource
This is the source for time selects

Constructor Detail

ChartWrapper

public ChartWrapper()
Default ctor


ChartWrapper

public ChartWrapper(String name,
                    List dataChoices)
Ctor

Parameters:
name - The name
dataChoices - List of data choices
Method Detail

getCategories

public List getCategories()
Get the data categories for selecting data choices

Returns:
List of data categories

init

public void init(MultiDisplayHolder displayControl,
                 List dataChoices)
Initialize

Parameters:
displayControl - The display control we're in.
dataChoices - List of data choices

initDone

public void initDone()
Called after this chart has been created.

Overrides:
initDone in class DisplayComponent

getFlatField

protected FlatField getFlatField(FieldImpl data)
                          throws VisADException,
                                 RemoteException
Utility to extract a FlatField from the data

Parameters:
data - The data
Returns:
The flat field
Throws:
RemoteException - On badness
VisADException - On badness

getTypeName

public abstract String getTypeName()
Overwritten by derived classes to return the name of the type of this chart. ex: Histogram, Time Series, etc.

Overrides:
getTypeName in class DisplayComponent
Returns:
The type name

keyPressed

public void keyPressed(KeyEvent e)
Noop

Specified by:
keyPressed in interface KeyListener
Parameters:
e - The event

keyReleased

public void keyReleased(KeyEvent e)
Noop

Specified by:
keyReleased in interface KeyListener
Parameters:
e - The event

keyTyped

public void keyTyped(KeyEvent e)
Noop

Specified by:
keyTyped in interface KeyListener
Parameters:
e - The event

wrapDataChoices

protected List wrapDataChoices(List choices)
A utility that takes a list of DataChoice-s and wraps each one in the DataChoiceWrapper. We use the DataChoiceWrapper so that sub classes can have their own extra info for each data choice. ex: colors, etc.

Parameters:
choices - List of data choices
Returns:
List of data choice wrappers

createDataChoiceWrapper

protected DataChoiceWrapper createDataChoiceWrapper(DataChoice dataChoice)
A utility to create a data choice wrapper

Parameters:
dataChoice - The data choice
Returns:
The data choice wrapper

getTimeFilterRanges

protected List getTimeFilterRanges()
Get get list of Ranges for time subsetting. If there are none then return null.

Returns:
List of time ranges or null

getTimeRanges

public List getTimeRanges()
Get the time ranges to use

Returns:
null

getPopupMenuItems

protected List getPopupMenuItems(List items)
Add the default menu items

Overrides:
getPopupMenuItems in class DisplayComponent
Parameters:
items - List of menu items
Returns:
The items list

getInterpreter

protected org.python.util.PythonInterpreter getInterpreter()
Create, if needed, and return the interpreter

Returns:
The interpreter

applyJython

public void applyJython()
Get the jython text from the text field and apply it


applyJython

protected void applyJython(String jython)
Evaluate the jython. This is used so end users can write some jython to extract and muck with the data in a chart.

Parameters:
jython - The jython

initializeJython

protected void initializeJython(org.python.util.PythonInterpreter interpreter)
Add the state of this chart to the interpreter

Parameters:
interpreter - The interpreter to initialize

canDoJython

protected boolean canDoJython()
Should the jython field be shown in the properties

Returns:
Can this chart have jython applied to it

canBeASourceForTimeSelectionEvents

protected boolean canBeASourceForTimeSelectionEvents()
Can this component be a source for time selection events

Returns:
false

canDoTimeFilters

protected boolean canDoTimeFilters()
Can this chart use time subset filters. This is used to determine whether the checkbox should be shown in the menus

Returns:
Can this chart use time subset filters.

canDoTimeSelect

protected boolean canDoTimeSelect()
Can this chart use time selects This is used to determine whether the checkbox should be shown in the menus

Returns:
Can this chart use time select

canDoDriveTime

protected boolean canDoDriveTime()
Can this chart drive the times in the main display. This is used to determine whether the checkbox should be shown in the menus

Returns:
Can this chart drive the times in the main display

canDoMinMaxDate

protected boolean canDoMinMaxDate()
Can this chart subset the entire data set on time

Returns:
Can do min max data subsetting

canDoResolution

protected boolean canDoResolution()
Should show resolution widget

Returns:
Should show resolution widget

canDoParameters

public boolean canDoParameters()
Can we add fields

Returns:
ok to add fields

canDoRemoveParameters

public boolean canDoRemoveParameters()
Can we remove fields

Returns:
ok to add fields

canDoDataChoiceList

public boolean canDoDataChoiceList()
ok to show the data choice list

Returns:
ok to show the data choice list

canDoWrapperColor

public boolean canDoWrapperColor()
Can the color swatch be shown in the properties for the data choice wrappers.

Returns:
Can do wrapper colors

canDoWrapperSide

public boolean canDoWrapperSide()
Can the Side menu be shown in the properties for the data choice wrappers.

Returns:
Can do sides in properties

propertyChange

public void propertyChange(PropertyChangeEvent event)
Handle the event

Specified by:
propertyChange in interface PropertyChangeListener
Overrides:
propertyChange in class PropertiedThing
Parameters:
event - The event

doRemove

public void doRemove()
Cleanup the chart

Overrides:
doRemove in class DisplayComponent

getPropertiesComponents

protected void getPropertiesComponents(List comps,
                                       int tabIdx)
Create the properties contents

Overrides:
getPropertiesComponents in class DisplayComponent
Parameters:
comps - List of components
tabIdx - Which tab

doMakeWrapperDisplayComponent

protected JComponent doMakeWrapperDisplayComponent(int idx,
                                                   ChartWrapper.FieldProperties fieldProperty)
Make the widget for the field

Parameters:
idx - which one
fieldProperty - The wrapper wrapper
Returns:
The gui

applyProperties

protected boolean applyProperties()
Apply properties

Overrides:
applyProperties in class DisplayComponent
Returns:
Was successful

doApplyProperties

protected boolean doApplyProperties()
Apply the properties

Overrides:
doApplyProperties in class DisplayComponent
Returns:
success

addField

public void addField()
Add a field to thei chart


getFieldSelectionLabels

public List getFieldSelectionLabels()
Returns the list of labels used for selecting data choices. If a derived class needs more than one data choice they can override this.

Returns:
List of field labels

doMultipleAddFields

public boolean doMultipleAddFields()
When selecting data does the data tree support multiple selections

Returns:
Do multiples

formatValue

public String formatValue(double v)
utility to format the value

Parameters:
v - the value
Returns:
the value formatted

addDataChoice

public void addDataChoice(DataChoice dataChoice)
                   throws VisADException,
                          RemoteException
Add the dta choice

Parameters:
dataChoice - the choice
Throws:
RemoteException - On badness
VisADException - On badness

addDataChoices

public void addDataChoices(List newDataChoices)
                    throws VisADException,
                           RemoteException
Add the data choices

Parameters:
newDataChoices - the choices
Throws:
RemoteException - On badness
VisADException - On badness

loadData

public void loadData()
              throws VisADException,
                     RemoteException
create shapes for an individual time step.

Overrides:
loadData in class DisplayComponent
Throws:
RemoteException - On badness
VisADException - On badness

setTimeFromAnimation

public void setTimeFromAnimation(Real time)
Animation in main display changed. Some charts show this

Parameters:
time - the animation time

animationTimeChanged

public void animationTimeChanged(Real time)
Use the animation time to set the domain crosshairs

Overrides:
animationTimeChanged in class DisplayComponent
Parameters:
time - The time

setDataChoiceWrappers

public void setDataChoiceWrappers(List value)
Set the DataChoiceWrappers property.

Parameters:
value - The new value for DataChoiceWrappers

getDataChoiceWrappers

public List getDataChoiceWrappers()
Get the DataChoiceWrappers property.

Returns:
The DataChoiceWrappers

setResolution

public void setResolution(double value)
Set the Resolution property.

Parameters:
value - The new value for Resolution

getResolution

public double getResolution()
Get the Resolution property.

Returns:
The Resolution

getDataChoices

public List getDataChoices()
Create and return a list of the data choices held by the data choice wrappers.

Returns:
List of data choices

removeTimeFilterSource

public void removeTimeFilterSource()
Remove the current time filter source


setTimeFilterSource

public void setTimeFilterSource(TimeSeriesChartWrapper value)
Set the FilterSource property.

Parameters:
value - The new value for FilterSource

getTimeFilterSource

public TimeSeriesChartWrapper getTimeFilterSource()
Get the FilterSource property.

Returns:
The FilterSource

removeTimeSelectSource

public void removeTimeSelectSource()
Remove the current time select source


setTimeSelectSource

public void setTimeSelectSource(ChartWrapper value)
Set the SelectSource property.

Parameters:
value - The new value for SelectSource

getTimeSelectSource

public ChartWrapper getTimeSelectSource()
Get the SelectSource property.

Returns:
The SelectSource

filterData

protected double[][] filterData(double[] samples,
                                double[] timeValues)
                         throws VisADException,
                                RemoteException
Utility to pull subset the given samples based on the time filter ranges

Parameters:
samples - The data
timeValues - The times
Returns:
The sampled data/time
Throws:
RemoteException - On badness_
VisADException - On badness_

getTimeValues

public double[] getTimeValues(double[][] samples,
                              FlatField data)
                       throws VisADException,
                              RemoteException
Convert the time from the data (in samples[1]) into an array of milliseconds

Parameters:
samples - The data
data - Where the data came from
Returns:
The times
Throws:
RemoteException - On badness
VisADException - On badness

setShowTime

public void setShowTime(boolean value)
Set the ShowTime property.

Parameters:
value - The new value for ShowTime

getShowTime

public boolean getShowTime()
Get the ShowTime property.

Returns:
The ShowTime

setDriveTime

public void setDriveTime(boolean value)
Set the DriveTime property.

Parameters:
value - The new value for DriveTime

getDriveTime

public boolean getDriveTime()
Get the DriveTime property.

Returns:
The DriveTime

setMinDate

public void setMinDate(double value)
Set the MinDate property.

Parameters:
value - The new value for MinDate

getMinDate

public double getMinDate()
Get the MinDate property.

Returns:
The MinDate

setMaxDate

public void setMaxDate(double value)
Set the MaxDate property.

Parameters:
value - The new value for MaxDate

getMaxDate

public double getMaxDate()
Get the MaxDate property.

Returns:
The MaxDate

setJython

public void setJython(String value)
Set the Jython property.

Parameters:
value - The new value for Jython

getJython

public String getJython()
Get the Jython property.

Returns:
The Jython

setAnimationShareGroup

public void setAnimationShareGroup(String value)
Set the AnimationShareGroup property.

Parameters:
value - The new value for AnimationShareGroup

getAnimationShareGroup

public String getAnimationShareGroup()
Get the AnimationShareGroup property.

Returns:
The AnimationShareGroup