/** * Sets all matrix values to zero and sends a * {@link org.jfree.data.general.SeriesChangeEvent} to all registered * listeners. */ public void zeroAll() { int rows = getRowCount(); int columns = getColumnsCount(); for (int row = 0; row < rows; row++) { for (int column = 0; column < columns; column++) { this.data[row][column] = 0.0; } } fireSeriesChanged(); }
/** * Return the matrix item at the specified index. Note that this method * creates a new <code>Double</code> instance every time it is called. * * @param itemIndex item index. * * @return The matrix item at the specified index. * * @see #get(int, int) */ public Number getItem(int itemIndex) { int i = getItemRow(itemIndex); int j = getItemColumn(itemIndex); Number n = new Double(get(i, j)); return n; }
/** * Returns the number of items in the series. * * @return The item count. */ @Override public int getItemCount() { return getRowCount() * getColumnsCount(); }
/** * Tests this object instance for equality with an arbitrary object. * * @param obj the object (<code>null</code> permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof MatrixSeries)) { return false; } MatrixSeries that = (MatrixSeries) obj; if (!(getRowCount() == that.getRowCount())) { return false; } if (!(getColumnsCount() == that.getColumnsCount())) { return false; } for (int r = 0; r < getRowCount(); r++) { for (int c = 0; c < getColumnsCount(); c++) { if (get(r, c) != that.get(r, c)) { return false; } } } return super.equals(obj); }
/** * Constructs a dataset and populates it with a single matrix series. * * @param series the time series. */ public MatrixSeriesCollection(MatrixSeries series) { this.seriesList = new java.util.ArrayList(); if (series != null) { this.seriesList.add(series); series.addChangeListener(this); } }
/** * Returns the column of the specified item. * * @param itemIndex the index of the item. * * @return The column of the specified item. */ public int getItemColumn(int itemIndex) { //assert itemIndex >= 0 && itemIndex < getItemCount(); return itemIndex % getColumnsCount(); }
/** * Returns the number of items in the specified series. * * @param seriesIndex zero-based series index. * * @return The number of items in the specified series. */ @Override public int getItemCount(int seriesIndex) { return getSeries(seriesIndex).getItemCount(); }
/** * Returns the key for a series. * * @param seriesIndex zero-based series index. * * @return The key for a series. */ @Override public Comparable getSeriesKey(int seriesIndex) { return getSeries(seriesIndex).getKey(); }
/** * Updates the value of the specified item in this matrix series. * * @param i the row of the item. * @param j the column of the item. * @param mij the new value for the item. * * @see #get(int, int) */ public void update(int i, int j, double mij) { this.data[i][j] = mij; fireSeriesChanged(); }
/** * Returns the Mij item value of the specified Mij matrix item in the * specified matrix series. * * @param seriesIndex the series (zero-based index). * @param itemIndex zero-based item index. * * @return The Mij item value for the specified matrix item. * * @see org.jfree.data.xy.XYZDataset#getZValue(int, int) */ public Number getZ(int seriesIndex, int itemIndex) { MatrixSeries series = (MatrixSeries) this.seriesList.get(seriesIndex); Number z = series.getItem(itemIndex); return z; }
/** * Returns the i index value of the specified Mij matrix item in the * specified matrix series. * * @param seriesIndex zero-based series index. * @param itemIndex zero-based item index. * * @return The i index value for the specified matrix item. * * @see org.jfree.data.xy.XYDataset#getYValue(int, int) */ @Override public Number getY(int seriesIndex, int itemIndex) { MatrixSeries series = (MatrixSeries) this.seriesList.get(seriesIndex); int y = series.getItemRow(itemIndex); return new Integer(y); // I know it's bad to create object. better idea? }
/** * Returns the j index value of the specified Mij matrix item in the * specified matrix series. * * @param seriesIndex zero-based series index. * @param itemIndex zero-based item index. * * @return The j index value for the specified matrix item. * * @see org.jfree.data.xy.XYDataset#getXValue(int, int) */ public Number getX(int seriesIndex, int itemIndex) { MatrixSeries series = (MatrixSeries) this.seriesList.get(seriesIndex); int x = series.getItemColumn(itemIndex); return new Integer(x); // I know it's bad to create object. better idea? }
if (!(getRowCount() == that.getRowCount())) { return false; if (!(getColumnsCount() == that.getColumnsCount())) { return false; for (int r = 0; r < getRowCount(); r++) { for (int c = 0; c < getColumnsCount(); c++) { if (get(r, c) != that.get(r, c)) { return false;
/** * Returns the number of items in the series. * * @return The item count. */ public int getItemCount() { return getRowCount() * getColumnsCount(); }
/** * Constructs a dataset and populates it with a single matrix series. * * @param series the time series. */ public MatrixSeriesCollection(MatrixSeries series) { this.seriesList = new java.util.ArrayList(); if (series != null) { this.seriesList.add(series); series.addChangeListener(this); } }
/** * Returns the column of the specified item. * * @param itemIndex the index of the item. * * @return The column of the specified item. */ public int getItemColumn(int itemIndex) { //assert itemIndex >= 0 && itemIndex < getItemCount(); return itemIndex % getColumnsCount(); }
/** * Returns the number of items in the specified series. * * @param seriesIndex zero-based series index. * * @return The number of items in the specified series. */ public int getItemCount(int seriesIndex) { return getSeries(seriesIndex).getItemCount(); }
/** * Returns the key for a series. * * @param seriesIndex zero-based series index. * * @return The key for a series. */ public Comparable getSeriesKey(int seriesIndex) { return getSeries(seriesIndex).getKey(); }
/** * Updates the value of the specified item in this matrix series. * * @param i the row of the item. * @param j the column of the item. * @param mij the new value for the item. * * @see #get(int, int) */ public void update(int i, int j, double mij) { this.data[i][j] = mij; fireSeriesChanged(); }
/** * Returns the Mij item value of the specified Mij matrix item in the * specified matrix series. * * @param seriesIndex the series (zero-based index). * @param itemIndex zero-based item index. * * @return The Mij item value for the specified matrix item. * * @see org.jfree.data.xy.XYZDataset#getZValue(int, int) */ @Override public Number getZ(int seriesIndex, int itemIndex) { MatrixSeries series = (MatrixSeries) this.seriesList.get(seriesIndex); Number z = series.getItem(itemIndex); return z; }