Package org.jfree.data.general
Class DefaultHeatMapDataset
- java.lang.Object
-
- org.jfree.data.general.AbstractDataset
-
- org.jfree.data.general.DefaultHeatMapDataset
-
- All Implemented Interfaces:
java.io.ObjectInputValidation
,java.io.Serializable
,java.lang.Cloneable
,PublicCloneable
,Dataset
,HeatMapDataset
public class DefaultHeatMapDataset extends AbstractDataset implements HeatMapDataset, java.lang.Cloneable, PublicCloneable, java.io.Serializable
A default implementation of theHeatMapDataset
interface.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private double
maxX
The maximum x-value in the dataset.private double
maxY
The maximum y-value in the dataset.private double
minX
The minimum x-value in the dataset.private double
minY
The minimum y-value in the dataset.private int
xSamples
The number of samples in this dataset for the x-dimension.private int
ySamples
The number of samples in this dataset for the y-dimension.private double[][]
zValues
Storage for the z-values.
-
Constructor Summary
Constructors Constructor Description DefaultHeatMapDataset(int xSamples, int ySamples, double minX, double maxX, double minY, double maxY)
Creates a new dataset where all the z-values are initially 0.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
clone()
Returns an independent copy of this dataset.boolean
equals(java.lang.Object obj)
Tests this dataset for equality with an arbitrary object.double
getMaximumXValue()
Returns the highest x-value represented in this dataset.double
getMaximumYValue()
Returns the highest y-value represented in this dataset.double
getMinimumXValue()
Returns the lowest x-value represented in this dataset.double
getMinimumYValue()
Returns the lowest y-value represented in this dataset.int
getXSampleCount()
Returns the number of x values across the width of the dataset.double
getXValue(int xIndex)
A convenience method that returns the x-value for the given index.int
getYSampleCount()
Returns the number of y values (or samples) for the dataset.double
getYValue(int yIndex)
A convenience method that returns the y-value for the given index.java.lang.Number
getZ(int xIndex, int yIndex)
Returns the z-value at the specified sample position in the dataset.double
getZValue(int xIndex, int yIndex)
Returns the z-value at the specified sample position in the dataset.void
setZValue(int xIndex, int yIndex, double z)
Updates a z-value in the dataset and sends aDatasetChangeEvent
to all registered listeners.void
setZValue(int xIndex, int yIndex, double z, boolean notify)
Updates a z-value in the dataset and, if requested, sends aDatasetChangeEvent
to all registered listeners.-
Methods inherited from class org.jfree.data.general.AbstractDataset
addChangeListener, canEqual, fireDatasetChanged, getGroup, getNotify, hashCode, hasListener, notifyListeners, removeChangeListener, setGroup, setNotify, validateObject
-
-
-
-
Field Detail
-
xSamples
private int xSamples
The number of samples in this dataset for the x-dimension.
-
ySamples
private int ySamples
The number of samples in this dataset for the y-dimension.
-
minX
private double minX
The minimum x-value in the dataset.
-
maxX
private double maxX
The maximum x-value in the dataset.
-
minY
private double minY
The minimum y-value in the dataset.
-
maxY
private double maxY
The maximum y-value in the dataset.
-
zValues
private double[][] zValues
Storage for the z-values.
-
-
Constructor Detail
-
DefaultHeatMapDataset
public DefaultHeatMapDataset(int xSamples, int ySamples, double minX, double maxX, double minY, double maxY)
Creates a new dataset where all the z-values are initially 0. This is a fixed size array of z-values.- Parameters:
xSamples
- the number of x-values.ySamples
- the number of y-valuesminX
- the minimum x-value in the dataset.maxX
- the maximum x-value in the dataset.minY
- the minimum y-value in the dataset.maxY
- the maximum y-value in the dataset.
-
-
Method Detail
-
getXSampleCount
public int getXSampleCount()
Returns the number of x values across the width of the dataset. The values are evenly spaced betweengetMinimumXValue()
andgetMaximumXValue()
.- Specified by:
getXSampleCount
in interfaceHeatMapDataset
- Returns:
- The number of x-values (always > 0).
-
getYSampleCount
public int getYSampleCount()
Returns the number of y values (or samples) for the dataset. The values are evenly spaced betweengetMinimumYValue()
andgetMaximumYValue()
.- Specified by:
getYSampleCount
in interfaceHeatMapDataset
- Returns:
- The number of y-values (always > 0).
-
getMinimumXValue
public double getMinimumXValue()
Returns the lowest x-value represented in this dataset. A requirement of this interface is that this method must never return infinite or Double.NAN values.- Specified by:
getMinimumXValue
in interfaceHeatMapDataset
- Returns:
- The lowest x-value represented in this dataset.
-
getMaximumXValue
public double getMaximumXValue()
Returns the highest x-value represented in this dataset. A requirement of this interface is that this method must never return infinite or Double.NAN values.- Specified by:
getMaximumXValue
in interfaceHeatMapDataset
- Returns:
- The highest x-value represented in this dataset.
-
getMinimumYValue
public double getMinimumYValue()
Returns the lowest y-value represented in this dataset. A requirement of this interface is that this method must never return infinite or Double.NAN values.- Specified by:
getMinimumYValue
in interfaceHeatMapDataset
- Returns:
- The lowest y-value represented in this dataset.
-
getMaximumYValue
public double getMaximumYValue()
Returns the highest y-value represented in this dataset. A requirement of this interface is that this method must never return infinite or Double.NAN values.- Specified by:
getMaximumYValue
in interfaceHeatMapDataset
- Returns:
- The highest y-value represented in this dataset.
-
getXValue
public double getXValue(int xIndex)
A convenience method that returns the x-value for the given index.- Specified by:
getXValue
in interfaceHeatMapDataset
- Parameters:
xIndex
- the xIndex.- Returns:
- The x-value.
-
getYValue
public double getYValue(int yIndex)
A convenience method that returns the y-value for the given index.- Specified by:
getYValue
in interfaceHeatMapDataset
- Parameters:
yIndex
- the yIndex.- Returns:
- The y-value.
-
getZValue
public double getZValue(int xIndex, int yIndex)
Returns the z-value at the specified sample position in the dataset. For a missing or unknown value, this method should return Double.NAN.- Specified by:
getZValue
in interfaceHeatMapDataset
- Parameters:
xIndex
- the position of the x sample in the dataset.yIndex
- the position of the y sample in the dataset.- Returns:
- The z-value.
-
getZ
public java.lang.Number getZ(int xIndex, int yIndex)
Returns the z-value at the specified sample position in the dataset. In this implementation, where the underlying values are stored in an array of double primitives, you should avoid using this method and usegetZValue(int, int)
instead.- Specified by:
getZ
in interfaceHeatMapDataset
- Parameters:
xIndex
- the position of the x sample in the dataset.yIndex
- the position of the y sample in the dataset.- Returns:
- The z-value.
-
setZValue
public void setZValue(int xIndex, int yIndex, double z)
Updates a z-value in the dataset and sends aDatasetChangeEvent
to all registered listeners.- Parameters:
xIndex
- the x-index.yIndex
- the y-index.z
- the new z-value.
-
setZValue
public void setZValue(int xIndex, int yIndex, double z, boolean notify)
Updates a z-value in the dataset and, if requested, sends aDatasetChangeEvent
to all registered listeners.- Parameters:
xIndex
- the x-index.yIndex
- the y-index.z
- the new z-value.notify
- notify listeners?
-
equals
public boolean equals(java.lang.Object obj)
Tests this dataset for equality with an arbitrary object.- Overrides:
equals
in classAbstractDataset
- Parameters:
obj
- the object (null
permitted).- Returns:
- A boolean.
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
Returns an independent copy of this dataset.- Specified by:
clone
in interfacePublicCloneable
- Overrides:
clone
in classAbstractDataset
- Returns:
- A clone.
- Throws:
java.lang.CloneNotSupportedException
- if there is a problem cloning.
-
-