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), ... @author Joshua Gould @author
| 37 | * @version 1.1 |
| 38 | */ |
| 39 | public class Histogram extends DataTable.DataModel implements Measurable, LogMeasurable, Data { |
| 40 | |
| 41 | final public TableModel model; |
| 42 | |
| 43 | public class Model extends DataTable.OSPTableModel { |
| 44 | |
| 45 | @Override |
| 46 | public int getRowCount() { |
| 47 | return Histogram.this.getRowCount(); |
| 48 | } |
| 49 | |
| 50 | @Override |
| 51 | public int getColumnCount() { |
| 52 | return Histogram.this.getColumnCount(); |
| 53 | } |
| 54 | |
| 55 | @Override |
| 56 | public Object getValueAt(int rowIndex, int columnIndex) { |
| 57 | return Double.valueOf(Histogram.this.getValueAt(rowIndex, columnIndex)); |
| 58 | } |
| 59 | |
| 60 | @Override |
| 61 | public Class<?> getColumnClass(int columnIndex) { |
| 62 | return ((columnIndex == 0) ? Integer.class : Double.class); |
| 63 | } |
| 64 | |
| 65 | } |
| 66 | |
| 67 | HistogramDataset histogramDataset; |
| 68 | |
| 69 | /** draw point at top of bin */ |
| 70 | public final static int DRAW_POINT = 0; |
| 71 | |
| 72 | /** draw bin from y min to top of bin */ |
| 73 | public final static int DRAW_BIN = 1; |
| 74 | |
| 75 | /** |
| 76 | * Should histogram be drawn on a log scale? Default is false. |
| 77 | */ |
| 78 | public boolean logScale = false; |
| 79 | |
| 80 | /** |
| 81 | * Should the height be adjusted by bin width? Default is false. |
| 82 | */ |
| 83 | public boolean adjustForWidth = false; |
| 84 | |
| 85 | /** |
| 86 | * The visibility of the histogram |
| 87 | */ |
| 88 | private boolean visible = true; // Paco |
| 89 | |
| 90 | /** |
| 91 | * Force the measured condition |
| 92 | */ |
| 93 | private boolean measured = true; // Paco |
| 94 | |
| 95 | /** color of bins */ |
| 96 | protected Color binFillColor = Color.red; |