Skip to content

Commit

Permalink
Rename histogram datasets.
Browse files Browse the repository at this point in the history
  • Loading branch information
jfree committed Mar 22, 2014
1 parent 4bc242b commit 6e9c0bd
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 47 deletions.
12 changes: 6 additions & 6 deletions src/main/java/org/jfree/chart/demo/selection/SelectionDemo4.java
Expand Up @@ -43,8 +43,8 @@
import org.jfree.data.general.SelectionChangeEvent;
import org.jfree.data.general.SelectionChangeListener;
import org.jfree.data.statistics.HistogramDataset;
import org.jfree.data.statistics.SimpleHistogramBin;
import org.jfree.data.statistics.SimpleHistogramDataset;
import org.jfree.data.statistics.HistogramBin;
import org.jfree.data.statistics.HistogramDataset;
import org.jfree.data.xy.IntervalXYDataset;

/**
Expand All @@ -53,7 +53,7 @@
public class SelectionDemo4 extends ApplicationFrame implements
SelectionChangeListener<XYCursor> {

private SimpleHistogramDataset dataset;
private HistogramDataset dataset;
private DefaultTableModel model;
private JTable table;

Expand All @@ -69,7 +69,7 @@ public SelectionDemo4(String title) {

JFreeChart chart = chartPanel.getChart();
XYPlot plot = (XYPlot) chart.getPlot();
this.dataset = (SimpleHistogramDataset) plot.getDataset();
this.dataset = (HistogramDataset) plot.getDataset();
JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
split.add(chartPanel);

Expand Down Expand Up @@ -114,11 +114,11 @@ public void selectionChanged(SelectionChangeEvent<XYCursor> event) {
* @return the dataset.
*/
private static IntervalXYDataset createDataset() {
SimpleHistogramDataset dataset = new SimpleHistogramDataset("H1");
HistogramDataset dataset = new HistogramDataset("H1");
double lower = 0.0;
for (int i = 0; i < 100; i++) {
double upper = (i + 1) / 10.0;
SimpleHistogramBin bin = new SimpleHistogramBin(lower, upper, true,
HistogramBin bin = new HistogramBin(lower, upper, true,
false);
dataset.addBin(bin);
lower = upper;
Expand Down
Expand Up @@ -2,7 +2,7 @@
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
* (C) Copyright 2000-2014, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
Expand All @@ -24,10 +24,10 @@
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* -----------------------
* SimpleHistogramBin.java
* -----------------------
* (C) Copyright 2005-2012, by Object Refinery Limited and Contributors.
* -----------------
* HistogramBin.java
* -----------------
* (C) Copyright 2005-2014, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
Expand All @@ -36,6 +36,7 @@
* -------
* 10-Jan-2005 : Version 1 (DG);
* 17-Jun-2012 : Removed JCommon dependencies (DG);
* 22-Mar-2014 : Renamed SimpleHistogramBin --> HistogramBin (DG);
*
*/

Expand All @@ -46,9 +47,9 @@
import org.jfree.chart.util.PublicCloneable;

/**
* A bin for the {@link SimpleHistogramDataset}.
* A bin for the {@link HistogramDataset}.
*/
public class SimpleHistogramBin implements Comparable,
public class HistogramBin implements Comparable,
Cloneable, PublicCloneable, Serializable {

/** For serialization. */
Expand Down Expand Up @@ -81,7 +82,7 @@ public class SimpleHistogramBin implements Comparable,
* @param lowerBound the lower bound (inclusive).
* @param upperBound the upper bound (inclusive);
*/
public SimpleHistogramBin(double lowerBound, double upperBound) {
public HistogramBin(double lowerBound, double upperBound) {
this(lowerBound, upperBound, true, true);
}

Expand All @@ -93,7 +94,7 @@ public SimpleHistogramBin(double lowerBound, double upperBound) {
* @param includeLowerBound include the lower bound?
* @param includeUpperBound include the upper bound?
*/
public SimpleHistogramBin(double lowerBound, double upperBound,
public HistogramBin(double lowerBound, double upperBound,
boolean includeLowerBound,
boolean includeUpperBound) {
if (lowerBound >= upperBound) {
Expand Down Expand Up @@ -177,7 +178,7 @@ public boolean accepts(double value) {
*
* @return A boolean.
*/
public boolean overlapsWith(SimpleHistogramBin bin) {
public boolean overlapsWith(HistogramBin bin) {
if (this.upperBound < bin.lowerBound) {
return false;
}
Expand All @@ -204,10 +205,10 @@ public boolean overlapsWith(SimpleHistogramBin bin) {
*/
@Override
public int compareTo(Object obj) {
if (!(obj instanceof SimpleHistogramBin)) {
if (!(obj instanceof HistogramBin)) {
return 0;
}
SimpleHistogramBin bin = (SimpleHistogramBin) obj;
HistogramBin bin = (HistogramBin) obj;
if (this.lowerBound < bin.lowerBound) {
return -1;
}
Expand All @@ -233,10 +234,10 @@ public int compareTo(Object obj) {
*/
@Override
public boolean equals(Object obj) {
if (!(obj instanceof SimpleHistogramBin)) {
if (!(obj instanceof HistogramBin)) {
return false;
}
SimpleHistogramBin that = (SimpleHistogramBin) obj;
HistogramBin that = (HistogramBin) obj;
if (this.lowerBound != that.lowerBound) {
return false;
}
Expand Down
Expand Up @@ -2,7 +2,7 @@
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
* (C) Copyright 2000-2014, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
Expand All @@ -24,10 +24,10 @@
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ---------------------------
* SimpleHistogramDataset.java
* ---------------------------
* (C) Copyright 2005-2012, by Object Refinery Limited and Contributors.
* ---------------------
* HistogramDataset.java
* ---------------------
* (C) Copyright 2005-2014, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): Sergei Ivanov;
Expand All @@ -49,6 +49,7 @@
import java.util.List;

import org.jfree.chart.util.ObjectUtilities;
import org.jfree.chart.util.ParamChecks;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.DomainOrder;
import org.jfree.data.general.DatasetChangeEvent;
Expand All @@ -57,12 +58,10 @@

/**
* A dataset used for creating simple histograms with custom defined bins.
*
* @see HistogramDataset
*/
public class SimpleHistogramDataset extends AbstractIntervalXYDataset
public class HistogramDataset extends AbstractIntervalXYDataset
implements IntervalXYDataset, Cloneable, PublicCloneable,
Serializable {
Serializable {

/** For serialization. */
private static final long serialVersionUID = 7997996479768018443L;
Expand All @@ -71,7 +70,7 @@ public class SimpleHistogramDataset extends AbstractIntervalXYDataset
private Comparable key;

/** The bins. */
private List<SimpleHistogramBin> bins;
private List<HistogramBin> bins;

/**
* A flag that controls whether or not the bin count is divided by the
Expand All @@ -85,12 +84,10 @@ public class SimpleHistogramDataset extends AbstractIntervalXYDataset
*
* @param key the series key (<code>null</code> not permitted).
*/
public SimpleHistogramDataset(Comparable key) {
if (key == null) {
throw new IllegalArgumentException("Null 'key' argument.");
}
public HistogramDataset(Comparable key) {
ParamChecks.nullNotPermitted(key, "key");
this.key = key;
this.bins = new ArrayList<SimpleHistogramBin>();
this.bins = new ArrayList<HistogramBin>();
this.adjustForBinSize = true;
}

Expand Down Expand Up @@ -174,9 +171,9 @@ public int getItemCount(int series) {
*
* @see #removeAllBins()
*/
public void addBin(SimpleHistogramBin bin) {
public void addBin(HistogramBin bin) {
// check that the new bin doesn't overlap with any existing bin
for (SimpleHistogramBin existingBin : this.bins) {
for (HistogramBin existingBin : this.bins) {
if (bin.overlapsWith(existingBin)) {
throw new RuntimeException("Overlapping bin");
}
Expand Down Expand Up @@ -206,7 +203,7 @@ public void addObservation(double value) {
*/
public void addObservation(double value, boolean notify) {
boolean placed = false;
for (SimpleHistogramBin bin : this.bins) {
for (HistogramBin bin : this.bins) {
if (bin.accepts(value)) {
bin.setItemCount(bin.getItemCount() + 1);
placed = true;
Expand Down Expand Up @@ -246,7 +243,7 @@ public void addObservations(double[] values) {
* @see #removeAllBins()
*/
public void clearObservations() {
for (SimpleHistogramBin bin : this.bins) {
for (HistogramBin bin : this.bins) {
bin.setItemCount(0);
}
notifyListeners(new DatasetChangeEvent(this, this));
Expand All @@ -261,7 +258,7 @@ public void clearObservations() {
* @see #addBin(SimpleHistogramBin)
*/
public void removeAllBins() {
this.bins = new ArrayList<SimpleHistogramBin>();
this.bins = new ArrayList<HistogramBin>();
notifyListeners(new DatasetChangeEvent(this, this));
}

Expand Down Expand Up @@ -290,7 +287,7 @@ public Number getX(int series, int item) {
*/
@Override
public double getXValue(int series, int item) {
SimpleHistogramBin bin = this.bins.get(item);
HistogramBin bin = this.bins.get(item);
return (bin.getLowerBound() + bin.getUpperBound()) / 2.0;
}

Expand Down Expand Up @@ -319,7 +316,7 @@ public Number getY(int series, int item) {
*/
@Override
public double getYValue(int series, int item) {
SimpleHistogramBin bin = this.bins.get(item);
HistogramBin bin = this.bins.get(item);
if (this.adjustForBinSize) {
return bin.getItemCount()
/ (bin.getUpperBound() - bin.getLowerBound());
Expand Down Expand Up @@ -353,7 +350,7 @@ public Number getStartX(int series, int item) {
*/
@Override
public double getStartXValue(int series, int item) {
SimpleHistogramBin bin = this.bins.get(item);
HistogramBin bin = this.bins.get(item);
return bin.getLowerBound();
}

Expand Down Expand Up @@ -381,7 +378,7 @@ public Number getEndX(int series, int item) {
*/
@Override
public double getEndXValue(int series, int item) {
SimpleHistogramBin bin = this.bins.get(item);
HistogramBin bin = this.bins.get(item);
return bin.getUpperBound();
}

Expand Down Expand Up @@ -451,10 +448,10 @@ public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof SimpleHistogramDataset)) {
if (!(obj instanceof HistogramDataset)) {
return false;
}
SimpleHistogramDataset that = (SimpleHistogramDataset) obj;
HistogramDataset that = (HistogramDataset) obj;
if (!this.key.equals(that.key)) {
return false;
}
Expand All @@ -477,7 +474,7 @@ public boolean equals(Object obj) {
*/
@Override
public Object clone() throws CloneNotSupportedException {
SimpleHistogramDataset clone = (SimpleHistogramDataset) super.clone();
HistogramDataset clone = (HistogramDataset) super.clone();
clone.bins = ObjectUtilities.deepClone(this.bins);
return clone;
}
Expand Down

0 comments on commit 6e9c0bd

Please sign in to comment.