org.opensourcephysics.display
Class HighlightableDataset

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by org.opensourcephysics.display.Dataset
          extended by org.opensourcephysics.display.HighlightableDataset
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel, Data, Drawable, Interactive, LogMeasurable, Measurable

public class HighlightableDataset
extends Dataset
implements Interactive

A Dataset that can highlight selected points.

Version:
1.0
Author:
Doug Brown
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.opensourcephysics.display.Dataset
AREA, BAR, CIRCLE, columnID, CUSTOM, customMarker, datasetID, errorBars, generalPath, index, maxPoints, NO_MARKER, PIXEL, POST, sorted, SQUARE, visible, xmax, xmaxLogscale, xmin, xminLogscale, xpoints, ymax, ymaxLogscale, ymin, yminLogscale, ypoints
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
HighlightableDataset()
          Default constructor.
HighlightableDataset(java.awt.Color markerColor)
          Constructor specifying the marker color.
HighlightableDataset(java.awt.Color markerColor, java.awt.Color lineColor, boolean connected)
          Constructor specifying the marker color, line color, and whether points are connected.
 
Method Summary
 void append(double[] xarray, double[] yarray)
          Appends (x,y) arrays to the Dataset.
 void append(double x, double y)
          Appends an (x,y) datum to the Dataset.
 void clear()
          Clear all data from this Dataset.
 void clearHighlights()
          Clears highlights.
 void draw(DrawingPanel drawingPanel, java.awt.Graphics g)
          Draw this Dataset in the drawing panel.
 Interactive findInteractive(DrawingPanel panel, int xpix, int ypix)
          Returns the Interactive object at a specified pixel position.
 int getHitIndex()
           
static XML.ObjectLoader getLoader()
          Returns the XML.ObjectLoader for this class.
 double getX()
          Implements Interactive.
 double getY()
          Implements Interactive.
 boolean isEnabled()
          Implements Interactive.
 boolean isHighlighted(int i)
          Gets the highlighted flag for the specified point.
protected  void moveDatum(int loc)
          Move an out-of-place datum into its correct position.
 void restoreHighlights()
          Restores previous highlights.
 void setEnabled(boolean enabled)
          Implements Interactive.
 void setHighlightColor(java.awt.Color color)
          Sets the highlight color.
 void setHighlighted(int i, boolean highlight)
          Sets the highlighted flag for the specified point.
 void setX(double x)
          Implements Interactive.
 void setXY(double x, double y)
          Implements Interactive.
 void setY(double y)
          Implements Interactive.
 
Methods inherited from class org.opensourcephysics.display.Dataset
append, append, convertTableColumnIndex, countColumnsVisible, drawFilledPlot, drawLinePlot, drawScatterPlot, getColumnClass, getColumnCount, getColumnID, getColumnName, getColumnNames, getData2D, getData3D, getDataList, getDatasets, getEdgeColor, getFillColor, getFillColors, getID, getIndex, getLineColor, getLineColors, getMarkerShape, getMarkerSize, getName, getPoints, getRowCount, getValidXPoints, getValidYPoints, getValueAt, getVisible, getXColumnName, getXMax, getXMaxLogscale, getXMin, getXMinLogscale, getXPoints, getYColumnName, getYMax, getYMaxLogscale, getYMin, getYMinLogscale, getYPoints, insertionSort, isConnected, isMeasured, isSorted, isXColumnVisible, isYColumnVisible, read, recalculatePath, setColumnID, setConnected, setCustomMarker, setID, setLineColor, setMarkerColor, setMarkerColor, setMarkerColor, setMarkerShape, setMarkerSize, setMaximumPoints, setName, setSorted, setStride, setVisible, setXColumnVisible, setXYColumnNames, setXYColumnNames, setYColumnVisible, toString, write
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener, setValueAt
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.opensourcephysics.display.Measurable
getXMax, getXMin, getYMax, getYMin, isMeasured
 

Constructor Detail

HighlightableDataset

public HighlightableDataset()
Default constructor.


HighlightableDataset

public HighlightableDataset(java.awt.Color markerColor)
Constructor specifying the marker color.

Parameters:
markerColor - marker color

HighlightableDataset

public HighlightableDataset(java.awt.Color markerColor,
                            java.awt.Color lineColor,
                            boolean connected)
Constructor specifying the marker color, line color, and whether points are connected.

Parameters:
markerColor - marker color
lineColor - line color
connected - true to connect points with line
Method Detail

append

public void append(double x,
                   double y)
Appends an (x,y) datum to the Dataset.

Overrides:
append in class Dataset
Parameters:
x - the x value
y - the y value

append

public void append(double[] xarray,
                   double[] yarray)
Appends (x,y) arrays to the Dataset.

Overrides:
append in class Dataset
Parameters:
xarray - the x array
yarray - the y array

clear

public void clear()
Clear all data from this Dataset.

Overrides:
clear in class Dataset

restoreHighlights

public void restoreHighlights()
Restores previous highlights.


clearHighlights

public void clearHighlights()
Clears highlights.


setHighlighted

public void setHighlighted(int i,
                           boolean highlight)
Sets the highlighted flag for the specified point.

Parameters:
i - the array index
highlight - true to highlight the point

isHighlighted

public boolean isHighlighted(int i)
Gets the highlighted flag for the specified point.

Parameters:
i - the array index
Returns:
true if point is highlighted

setHighlightColor

public void setHighlightColor(java.awt.Color color)
Sets the highlight color.

Parameters:
color - the color

moveDatum

protected void moveDatum(int loc)
Move an out-of-place datum into its correct position.

Overrides:
moveDatum in class Dataset
Parameters:
loc - the datum

draw

public void draw(DrawingPanel drawingPanel,
                 java.awt.Graphics g)
Draw this Dataset in the drawing panel.

Specified by:
draw in interface Drawable
Overrides:
draw in class Dataset
Parameters:
drawingPanel - the drawing panel
g - the graphics

findInteractive

public Interactive findInteractive(DrawingPanel panel,
                                   int xpix,
                                   int ypix)
Returns the Interactive object at a specified pixel position. Implements Interactive.

Specified by:
findInteractive in interface Interactive
Parameters:
panel - the drawing panel
xpix - the x pixel position on the panel
ypix - the y pixel position on the panel
Returns:
the object

getHitIndex

public int getHitIndex()

setEnabled

public void setEnabled(boolean enabled)
Implements Interactive.

Specified by:
setEnabled in interface Interactive
Parameters:
enabled - ignored

isEnabled

public boolean isEnabled()
Implements Interactive.

Specified by:
isEnabled in interface Interactive
Returns:
true

setXY

public void setXY(double x,
                  double y)
Implements Interactive.

Specified by:
setXY in interface Interactive
Parameters:
x - ignored
y - ignored

setX

public void setX(double x)
Implements Interactive.

Specified by:
setX in interface Interactive
Parameters:
x - ignored

setY

public void setY(double y)
Implements Interactive.

Specified by:
setY in interface Interactive
Parameters:
y - ignored

getX

public double getX()
Implements Interactive.

Specified by:
getX in interface Interactive
Returns:
the x value at the current hit index, or Double.NaN if none

getY

public double getY()
Implements Interactive.

Specified by:
getY in interface Interactive
Returns:
the y value at the current hit index, or Double.NaN if none

getLoader

public static XML.ObjectLoader getLoader()
Returns the XML.ObjectLoader for this class.

Returns:
the object loader