org.das2.graph
Class DasPlot

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by org.das2.graph.DasCanvasComponent
                  extended by org.das2.graph.DasPlot
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, Editable, DataSetConsumer
Direct Known Subclasses:
AngleSpectrogramSlicer, DasEventsIndicator, HistogramSlicer, HorizontalSpectrogramSlicer, VerticalSpectrogramAverager, VerticalSpectrogramSlicer

public class DasPlot
extends DasCanvasComponent
implements DataSetConsumer

See Also:
Serialized Form

Nested Class Summary
protected  class DasPlot.RebinListener
           
 
Nested classes/interfaces inherited from class org.das2.graph.DasCanvasComponent
DasCanvasComponent.CanvasComponentAction
 
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
protected  DataSet Data
           
protected  DataSetDescriptor dataSetDescriptor
           
 javax.swing.Action DUMP_TO_FILE_ACTION
           
static int ERROR
           
protected  Renderer focusRenderer
          returns the Renderer with the current focus.
protected  boolean gridOver
           
static int INFO
           
protected  java.lang.String offsetTime
           
protected  boolean overSize
           
protected  java.lang.String plotTitle
           
static java.lang.String PROP_DRAWGRID
           
static java.lang.String PROP_DRAWMINORGRID
           
static java.lang.String PROP_FOCUSRENDERER
           
static java.lang.String PROP_GRIDOVER
           
static java.lang.String PROP_OVERSIZE
           
static java.lang.String PROP_TITLE
           
protected  double[] psym_x
           
protected  double[] psym_y
           
protected  DasPlot.RebinListener rebinListener
           
protected  java.beans.PropertyChangeListener ticksListener
           
static int WARNING
           
 
Fields inherited from class org.das2.graph.DasCanvasComponent
mouseAdapter, PROPERTIES_ACTION
 
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, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
DasPlot(DasAxis xAxis, DasAxis yAxis)
           
 
Method Summary
 void addRenderer(Renderer rend)
           
 void addToLegend(Renderer renderer, javax.swing.ImageIcon icon, int pos, java.lang.String message)
           
protected  java.awt.AWTEvent coalesceEvents(java.awt.AWTEvent existingEvent, java.awt.AWTEvent newEvent)
          Potentially coalesce an event being posted with an existing event.
static DasPlot createDummyPlot()
           
static DasPlot createNamedPlot(java.lang.String name)
           
static DasPlot createPlot(DatumRange xrange, DatumRange yrange)
           
protected  void drawContent(java.awt.Graphics2D g)
           
 int findRendererAt(int x, int y)
          return the index of the renderer at canvas location (x,y), or -1 if no renderer is found at the position.
 java.awt.Shape getActiveRegion()
          returns the active region of the canvas component, which is not necessarily the bounds.
protected  java.awt.geom.AffineTransform getAffineTransform(DasAxis xAxis, DasAxis yAxis)
           
protected  java.awt.Rectangle getCacheImageBounds()
          returns the position of the cacheImage in the canvas frame of reference.
 DataSet getConsumedDataSet()
           
 DataSet getData()
           
 DataSet getDataSet()
           
 DataSetDescriptor getDataSetDescriptor()
          Getter for property dataSetDescriptor.
 org.w3c.dom.Element getDOMElement(org.w3c.dom.Document document)
           
 Renderer getFocusRenderer()
           
 Renderer getRenderer(int index)
           
 Renderer[] getRenderers()
           
 java.lang.String getTitle()
          Returns the title of this plot.
 DasAxis getXAxis()
           
 DasAxis getYAxis()
           
protected  void installComponent()
           
protected  void invalidateCacheImage()
           
 boolean isDrawGrid()
          Getter for property drawGrid.
 boolean isDrawMinorGrid()
          Get the value of drawMinorGrid
 boolean isGridOver()
           
 boolean isOverSize()
           
 boolean isPreviewEnabled()
           
protected  void paintComponent(java.awt.Graphics graphics1)
           
 void postException(Renderer renderer, java.lang.Exception exception)
          notify user of an exception, in the context of the plot.
 void postMessage(Renderer renderer, java.lang.String message, int messageType, Datum x, Datum y)
          Notify user of an exception, in the context of the plot.
protected  void processEvent(java.awt.AWTEvent e)
          Processes events occurring on this component.
static DasPlot processPlotElement(org.w3c.dom.Element element, FormBase form)
           
 void removeRenderer(Renderer rend)
           
 void repaint()
           
 void resize()
          Called by the DasCanvas layout manager to request this component to set its bounds.
 void setData(DataSet ds)
           
 void setDataSetDescriptor(DataSetDescriptor dataSetDescriptor)
          Setter for property dataSetDescriptor.
 void setDrawGrid(boolean drawGrid)
          Setter for property drawGrid.
 void setDrawMinorGrid(boolean newdrawMinorGrid)
          Set the value of drawMinorGrid
 void setFocusRenderer(Renderer focusRenderer)
           
 void setGridOver(boolean gridOver)
           
 void setOverSize(boolean overSize)
           
 void setPreviewEnabled(boolean preview)
           
 void setTitle(java.lang.String t)
          Sets the title which will be displayed above this plot.
 void setVisible(boolean visible)
           
 void setXAxis(DasAxis xAxis)
           
 void setYAxis(DasAxis yAxis)
          Attaches a new axis to the plot.
protected  void uninstallComponent()
           
protected  void updateImmediately()
          This method is called when a DasUpdateEvent is processed.
 
Methods inherited from class org.das2.graph.DasCanvasComponent
acceptContext, addMouseModule, getActions, getCanvas, getColumn, getDasMouseInputAdapter, getDasName, getEmSize, getFont, getMouseAdapter, getRow, processDasUpdateEvent, removeMouseModule, setBounds, setBounds, setColumn, setDasMouseInputAdapter, setDasName, setRow, showProperties, toString, update
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, 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, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, 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, unregisterKeyboardAction, update, updateUI
 
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, 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, 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, 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, resize, resize, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROP_TITLE

public static java.lang.String PROP_TITLE

dataSetDescriptor

protected DataSetDescriptor dataSetDescriptor

Data

protected DataSet Data

offsetTime

protected java.lang.String offsetTime

plotTitle

protected java.lang.String plotTitle

psym_x

protected double[] psym_x

psym_y

protected double[] psym_y

rebinListener

protected DasPlot.RebinListener rebinListener

ticksListener

protected java.beans.PropertyChangeListener ticksListener

focusRenderer

protected Renderer focusRenderer
returns the Renderer with the current focus. Clicking on a trace sets the focus.


PROP_FOCUSRENDERER

public static final java.lang.String PROP_FOCUSRENDERER
See Also:
Constant Field Values

DUMP_TO_FILE_ACTION

public javax.swing.Action DUMP_TO_FILE_ACTION

INFO

public static final int INFO
See Also:
Constant Field Values

WARNING

public static final int WARNING
See Also:
Constant Field Values

ERROR

public static final int ERROR
See Also:
Constant Field Values

PROP_DRAWGRID

public static final java.lang.String PROP_DRAWGRID
See Also:
Constant Field Values

PROP_DRAWMINORGRID

public static final java.lang.String PROP_DRAWMINORGRID
See Also:
Constant Field Values

gridOver

protected boolean gridOver

PROP_GRIDOVER

public static final java.lang.String PROP_GRIDOVER
See Also:
Constant Field Values

overSize

protected boolean overSize

PROP_OVERSIZE

public static final java.lang.String PROP_OVERSIZE
See Also:
Constant Field Values
Constructor Detail

DasPlot

public DasPlot(DasAxis xAxis,
               DasAxis yAxis)
Method Detail

getFocusRenderer

public Renderer getFocusRenderer()

setFocusRenderer

public void setFocusRenderer(Renderer focusRenderer)

findRendererAt

public int findRendererAt(int x,
                          int y)
return the index of the renderer at canvas location (x,y), or -1 if no renderer is found at the position.


getDataSet

public DataSet getDataSet()

getConsumedDataSet

public DataSet getConsumedDataSet()
Specified by:
getConsumedDataSet in interface DataSetConsumer

getData

public DataSet getData()

setXAxis

public void setXAxis(DasAxis xAxis)

setYAxis

public void setYAxis(DasAxis yAxis)
Attaches a new axis to the plot. The old axis is disconnected, and the plot will listen to the new axis. Also, the row and column for the axis is set, but this might change in the future. null appears to be a valid input as well. TODO: plot does not seem to be responding to changes in the axis. (goes grey because updatePlotImage is never done.


updateImmediately

protected void updateImmediately()
Description copied from class: DasCanvasComponent
This method is called when a DasUpdateEvent is processed. The default implementation does nothing. If a subclass needs to do any expensive operations involved in updating, they should be done by overriding this method so that the AWT Event Queue can coalesce update events.

Overrides:
updateImmediately in class DasCanvasComponent

getAffineTransform

protected java.awt.geom.AffineTransform getAffineTransform(DasAxis xAxis,
                                                           DasAxis yAxis)

paintComponent

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

postMessage

public void postMessage(Renderer renderer,
                        java.lang.String message,
                        int messageType,
                        Datum x,
                        Datum y)
Notify user of an exception, in the context of the plot. A position in the data space may be specified to locate the text within the data context. Note either or both x or y may be null. Messages must only be posted while the Renderer's render method is called. All messages are cleared before the render step.

Parameters:
renderer - identifies the renderer posting the exception
text - the text to be displayed, may contain granny text.
messageType - DasPlot.INFORMATION_MESSAGE, DasPlot.WARNING_MESSAGE, or DasPlot.ERROR_MESSAGE.
x - if non-null, the location on the x axis giving context for the text.
y - if non-null, the location on the y axis giving context for the text.

postException

public void postException(Renderer renderer,
                          java.lang.Exception exception)
notify user of an exception, in the context of the plot.


addToLegend

public void addToLegend(Renderer renderer,
                        javax.swing.ImageIcon icon,
                        int pos,
                        java.lang.String message)
Parameters:
renderer - identifies the renderer adding to the legend
icon - if non-null, an icon to use. If null, the renderer's icon is used.
pos - integer order parameter, and also identifies item.
message - String message to display.

drawContent

protected void drawContent(java.awt.Graphics2D g)

resize

public void resize()
Description copied from class: DasCanvasComponent
Called by the DasCanvas layout manager to request this component to set its bounds.

Overrides:
resize in class DasCanvasComponent

setTitle

public void setTitle(java.lang.String t)
Sets the title which will be displayed above this plot.

Parameters:
t - The new title for this plot.

getTitle

public java.lang.String getTitle()
Returns the title of this plot.

Returns:
The plot title
See Also:
setTitle(String)

getXAxis

public DasAxis getXAxis()

getYAxis

public DasAxis getYAxis()

getDataSetDescriptor

public DataSetDescriptor getDataSetDescriptor()
Getter for property dataSetDescriptor.

Returns:
Value of property dataSetDescriptor.

setDataSetDescriptor

public void setDataSetDescriptor(DataSetDescriptor dataSetDescriptor)
Setter for property dataSetDescriptor.

Parameters:
dataSetDescriptor - New value of property dataSetDescriptor.

setData

public void setData(DataSet ds)

installComponent

protected void installComponent()
Overrides:
installComponent in class DasCanvasComponent

uninstallComponent

protected void uninstallComponent()
Overrides:
uninstallComponent in class DasCanvasComponent

addRenderer

public void addRenderer(Renderer rend)

removeRenderer

public void removeRenderer(Renderer rend)

createDummyPlot

public static DasPlot createDummyPlot()

createPlot

public static DasPlot createPlot(DatumRange xrange,
                                 DatumRange yrange)

getRenderer

public Renderer getRenderer(int index)

getRenderers

public Renderer[] getRenderers()

processPlotElement

public static DasPlot processPlotElement(org.w3c.dom.Element element,
                                         FormBase form)
                                  throws DasPropertyException,
                                         DasNameException,
                                         DasException,
                                         java.text.ParseException
Throws:
DasPropertyException
DasNameException
DasException
java.text.ParseException

getDOMElement

public org.w3c.dom.Element getDOMElement(org.w3c.dom.Document document)

createNamedPlot

public static DasPlot createNamedPlot(java.lang.String name)

getActiveRegion

public java.awt.Shape getActiveRegion()
Description copied from class: DasCanvasComponent
returns the active region of the canvas component, which is not necessarily the bounds.

Overrides:
getActiveRegion in class DasCanvasComponent

coalesceEvents

protected java.awt.AWTEvent coalesceEvents(java.awt.AWTEvent existingEvent,
                                           java.awt.AWTEvent newEvent)
Potentially coalesce an event being posted with an existing event. This method is called by EventQueue.postEvent if an event with the same ID as the event to be posted is found in the queue (both events must have this component as their source). This method either returns a coalesced event which replaces the existing event (and the new event is then discarded), or null to indicate that no combining should be done (add the second event to the end of the queue). Either event parameter may be modified and returned, as the other one is discarded unless null is returned.

This implementation of coalesceEvents coalesces DasUpdateEvents, returning the existingEvent parameter

Overrides:
coalesceEvents in class DasCanvasComponent
Parameters:
existingEvent - the event already on the EventQueue
newEvent - the event being posted to the EventQueue
Returns:
a coalesced event, or null indicating that no coalescing was done

processEvent

protected void processEvent(java.awt.AWTEvent e)
Processes events occurring on this component. By default this method calls the appropriate process<event type>Event method for the given class of event.

Note that if the event parameter is null the behavior is unspecified and may result in an exception.

Overrides:
processEvent in class DasCanvasComponent
Parameters:
e - the event
See Also:
Component.processComponentEvent(java.awt.event.ComponentEvent), Component.processFocusEvent(java.awt.event.FocusEvent), Component.processKeyEvent(java.awt.event.KeyEvent), Component.processMouseEvent(java.awt.event.MouseEvent), Component.processMouseMotionEvent(java.awt.event.MouseEvent), Component.processInputMethodEvent(java.awt.event.InputMethodEvent), Component.processHierarchyEvent(java.awt.event.HierarchyEvent), Component.processMouseWheelEvent(java.awt.event.MouseWheelEvent), DasCanvasComponent.processDasUpdateEvent(org.das2.event.DasUpdateEvent)

repaint

public void repaint()
Overrides:
repaint in class java.awt.Component

invalidateCacheImage

protected void invalidateCacheImage()

isDrawGrid

public boolean isDrawGrid()
Getter for property drawGrid. If true, faint grey lines continue the axis major ticks across the plot.

Returns:
Value of property drawGrid.

setDrawGrid

public void setDrawGrid(boolean drawGrid)
Setter for property drawGrid. If true, faint grey lines continue the axis major ticks across the plot.

Parameters:
drawGrid - New value of property drawGrid.

isDrawMinorGrid

public boolean isDrawMinorGrid()
Get the value of drawMinorGrid

Returns:
the value of drawMinorGrid

setDrawMinorGrid

public void setDrawMinorGrid(boolean newdrawMinorGrid)
Set the value of drawMinorGrid

Parameters:
newdrawMinorGrid - new value of drawMinorGrid

isGridOver

public boolean isGridOver()

setGridOver

public void setGridOver(boolean gridOver)

setPreviewEnabled

public void setPreviewEnabled(boolean preview)

isPreviewEnabled

public boolean isPreviewEnabled()

setVisible

public void setVisible(boolean visible)
Overrides:
setVisible in class javax.swing.JComponent

isOverSize

public boolean isOverSize()

setOverSize

public void setOverSize(boolean overSize)

getCacheImageBounds

protected java.awt.Rectangle getCacheImageBounds()
returns the position of the cacheImage in the canvas frame of reference.

Returns:
Rectangle