|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.swing.table.AbstractTableModel org.opensourcephysics.display.Histogram
public class Histogram
Histogram maps bin number to occurrences. Histogram is Drawable and can be rendered on a DrawingPanel. Histogram also implements TableModel and can be displayed in a JTable. By default, bins consist of (notation: [ inclusive, ) exclusive): ..., [-1,0), [0,1), [1,2), ...
Nested Class Summary | |
---|---|
protected static class |
Histogram.HistogramLoader
A class to save and load Dataset data in an XMLControl. |
Field Summary | |
---|---|
boolean |
adjustForWidth
Should the height be adjusted by bin width? Default is false. |
protected java.awt.Color |
binEdgeColor
color of bins |
protected java.awt.Color |
binFillColor
color of bins |
protected int |
binStyle
style for drawing bins |
protected int |
datasetID
an integer ID that identifies this object |
static int |
DRAW_BIN
draw bin from y min to top of bin |
static int |
DRAW_POINT
draw point at top of bin |
boolean |
logScale
Should histogram be drawn on a log scale? Default is false. |
Fields inherited from class javax.swing.table.AbstractTableModel |
---|
listenerList |
Constructor Summary | |
---|---|
Histogram()
Histogram constructor. |
Method Summary | |
---|---|
void |
append(double value)
Appends a value with 1 occurence. |
void |
append(double[] values)
Appends an array of values with 1 occurence. |
void |
append(double value,
double numberOfoccurrences)
Append a value with number of occurrences to the Histogram. |
void |
append(java.lang.String inputPathName)
Appends values from an input file. |
void |
clear()
Clears all data from this histogram and resets min and max values. |
void |
draw(DrawingPanel drawingPanel,
java.awt.Graphics g)
Draws this histogram in the drawing panel. |
protected void |
drawBin(DrawingPanel drawingPanel,
java.awt.Graphics g,
int binNumber,
double occurrences)
Draws a filled bin. |
protected void |
drawPoint(DrawingPanel drawingPanel,
java.awt.Graphics g,
int binNumber,
double occurrences)
Draws a point at the top of a bin. |
java.util.Map.Entry<?,?>[] |
entries()
Gets an array of bin number-occurrences pairs |
double |
getBinOffset()
Gets the offset of the bins. |
double |
getBinWidth()
Gets the width of a bin. |
java.lang.Class<?> |
getColumnClass(int columnIndex)
Gets the type of object for JTable entry. |
int |
getColumnCount()
Gets the name of the colummn for rendering in a JTable |
java.lang.String |
getColumnName(int column)
Gets the name of the column for rendering in a JTable |
java.lang.String[] |
getColumnNames()
The column names to be used in the data display tool |
double[][] |
getData2D()
Gets a 2D array of data. |
double[][][] |
getData3D()
Gets a 3D array of data. |
java.util.List<Data> |
getDataList()
Some elements (a Group, for instance) do not contain data, but a list of subelements which do. |
java.util.ArrayList<Dataset> |
getDatasets()
Gets a list of OSP Datasets. |
java.awt.Color |
getFillColor()
Fill color to use for this data |
java.awt.Color[] |
getFillColors()
Fill colors for Data interface. |
int |
getID()
Returns a unique identifier for this Data. |
double |
getLeftMostBinPosition(int binNumber)
Method getLeftMostBinPosition |
java.awt.Color |
getLineColor()
Line color to use for this data |
java.awt.Color[] |
getLineColors()
Line colors for Data interface. |
static XML.ObjectLoader |
getLoader()
Returns the XML.ObjectLoader for this class. |
double[][] |
getLogPoints()
Gets a data array containing both the bin centers and the values within the bins. |
java.lang.String |
getName()
Gets the dataset name. |
double[][] |
getPoints()
Gets a data array containing both the bin centers and the values within the bins. |
double |
getRightMostBinPosition(int binNumber)
Method getRightMostBinPosition |
int |
getRowCount()
Gets the number of rows for rendering in a JTable. |
java.lang.Object |
getValueAt(int row,
int column)
Gets a bin number or occurrences for bin number for rendering in a JTable. |
double |
getXMax()
Gets the x world coordinate for the right hand side of this histogram. |
double |
getXMaxLogscale()
Gets the maximum x needed to draw this object on a log scale. |
double |
getXMin()
Gets the x world coordinate for the left hand side of this histogram. |
double |
getXMinLogscale()
Gets the minimum x needed to draw this object on a log scale. |
double[] |
getXPoints()
Gets an array containing the bin centers. |
double |
getYMax()
Gets the y world coordinate for the top of this histogram. |
double |
getYMaxLogscale()
Gets the maximum y needed to draw this object on a log scale on a log scale. |
double |
getYMin()
Gets the y world coordinate for the bottom of this histogram. |
double |
getYMinLogscale()
Gets the minimum y needed to draw this object on a log scale. |
double[] |
getYPoints()
Gets an array containing the values within the bins. |
int |
hashCode(double value)
Computes the hash code (bin number) for the specified value |
boolean |
isMeasured()
Gets the valid measure flag. |
void |
read(java.lang.String inputPathName)
Reads a file and appends the data contained in the file to this Histogram. |
void |
setBarOffset(double _barOffset)
Set the offset of the bars as a fraction of a bin width. |
void |
setBinColor(java.awt.Color binColor)
Sets the bin color. |
void |
setBinColor(java.awt.Color fillColor,
java.awt.Color edgeColor)
Sets the bin's fill and edge colors. |
void |
setBinOffset(double _binOffset)
Sets the offset of the bins. |
void |
setBinStyle(int style)
Sets the style for drawing this histogram. |
void |
setBinWidth(double _binWidth)
Sets the width of a bin. |
void |
setDiscrete(boolean _discrete)
Sets the discrete flag. |
void |
setID(int id)
Sets the ID number of this Data. |
void |
setName(java.lang.String name)
Sets a name that can be used to identify the dataset. |
void |
setNormalizedToOne(boolean b)
Normalizes the occurrences in this histogram to one. |
void |
setXYColumnNames(java.lang.String _xColumnName,
java.lang.String _yColumnName)
Sets the column names when rendering this histogram in a JTable. |
void |
setXYColumnNames(java.lang.String _xColumnName,
java.lang.String _yColumnName,
java.lang.String _name)
Sets the column names when rendering this histogram in a JTable. |
java.lang.String |
toSortedString()
Creates a string representation of this Histogram. |
java.lang.String |
toString()
Creates a string representation of this Histogram. |
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 |
Field Detail |
---|
public static final int DRAW_POINT
public static final int DRAW_BIN
public boolean logScale
public boolean adjustForWidth
protected java.awt.Color binFillColor
protected java.awt.Color binEdgeColor
protected int binStyle
protected int datasetID
Constructor Detail |
---|
public Histogram()
Method Detail |
---|
public void read(java.lang.String inputPathName) throws java.io.IOException
inputPathName
- A pathname string.
java.io.IOException
- Description of the Exceptionpublic java.lang.String toSortedString()
toString()
public java.lang.String toString()
toString
in class java.lang.Object
public int hashCode(double value)
value
-
public void append(double value, double numberOfoccurrences)
value
- numberOfoccurrences
- public void append(double value)
value
- public void append(java.lang.String inputPathName) throws java.io.IOException
inputPathName
- A pathname string.
java.io.IOException
- Description of the Exceptionpublic void append(double[] values)
values
- public void draw(DrawingPanel drawingPanel, java.awt.Graphics g)
draw
in interface Drawable
drawingPanel
- g
- public void clear()
public java.util.Map.Entry<?,?>[] entries()
public void setBinStyle(int style)
style
- public void setDiscrete(boolean _discrete)
_discrete
- true<\code> if bins are discrete, false<\code> if bins are continuous.
public void setBinOffset(double _binOffset)
_binOffset
- public void setBarOffset(double _barOffset)
_barOffset
- The new barOffset valuepublic java.awt.Color getLineColor()
public java.awt.Color[] getLineColors()
getLineColors
in interface Data
public java.awt.Color getFillColor()
public java.awt.Color[] getFillColors()
getFillColors
in interface Data
public void setBinColor(java.awt.Color binColor)
binColor
- public void setBinColor(java.awt.Color fillColor, java.awt.Color edgeColor)
fillColor
- edgeColor
- public void setBinWidth(double _binWidth)
_binWidth
- public void setName(java.lang.String name)
name
- Stringpublic java.lang.String getName()
getName
in interface Data
public java.lang.String[] getColumnNames()
getColumnNames
in interface Data
public java.util.List<Data> getDataList()
getDataList
in interface Data
public void setXYColumnNames(java.lang.String _xColumnName, java.lang.String _yColumnName)
_binColumnName
- _yColumnName
- public void setXYColumnNames(java.lang.String _xColumnName, java.lang.String _yColumnName, java.lang.String _name)
_binColumnName
- _yColumnName
- _name
- String the name of the histogrampublic void setNormalizedToOne(boolean b)
b
- public double getBinWidth()
public double getBinOffset()
public double getXMin()
getXMin
in interface Measurable
public double getXMax()
getXMax
in interface Measurable
public double getYMin()
getYMin
in interface Measurable
public double getYMax()
getYMax
in interface Measurable
public double getXMinLogscale()
getXMinLogscale
in interface LogMeasurable
public double getXMaxLogscale()
getXMaxLogscale
in interface LogMeasurable
public double getYMinLogscale()
getYMinLogscale
in interface LogMeasurable
public double getYMaxLogscale()
getYMaxLogscale
in interface LogMeasurable
public boolean isMeasured()
isMeasured
in interface Measurable
true<\code> if measure is valid.
public java.lang.String getColumnName(int column)
getColumnName
in interface javax.swing.table.TableModel
getColumnName
in class javax.swing.table.AbstractTableModel
column
- the column whose value is to be queried
public int getRowCount()
getRowCount
in interface javax.swing.table.TableModel
public int getColumnCount()
getColumnCount
in interface javax.swing.table.TableModel
public java.lang.Object getValueAt(int row, int column)
getValueAt
in interface javax.swing.table.TableModel
row
- the row whose value is to be queriedcolumn
- the column whose value is to be queried
public java.lang.Class<?> getColumnClass(int columnIndex)
getColumnClass
in interface javax.swing.table.TableModel
getColumnClass
in class javax.swing.table.AbstractTableModel
columnIndex
- the column whose value is to be queried
public void setID(int id)
setID
in interface Data
id
- the ID numberpublic int getID()
getID
in interface Data
protected void drawPoint(DrawingPanel drawingPanel, java.awt.Graphics g, int binNumber, double occurrences)
drawingPanel
- g
- binNumber
- occurrences
- protected void drawBin(DrawingPanel drawingPanel, java.awt.Graphics g, int binNumber, double occurrences)
drawingPanel
- g
- binNumber
- occurrences
- public double[] getXPoints()
public double[] getYPoints()
public double[][] getPoints()
public double[][] getLogPoints()
public double getLeftMostBinPosition(int binNumber)
binNumber
-
public double getRightMostBinPosition(int binNumber)
binNumber
-
public double[][] getData2D()
Data
getData2D
in interface Data
public double[][][] getData3D()
Data
getData3D
in interface Data
public java.util.ArrayList<Dataset> getDatasets()
Data
getDatasets
in interface Data
public static XML.ObjectLoader getLoader()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |