use of org.jfree.data.category.CategoryDataset in project SIMVA-SoS by SESoS.
the class CombinedCategoryPlotDemo1 method createChart.
/**
* Creates a chart.
*
* @return A chart.
*/
private static JFreeChart createChart() {
CategoryDataset dataset1 = createDataset1();
NumberAxis rangeAxis1 = new NumberAxis("Value");
rangeAxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
LineAndShapeRenderer renderer1 = new LineAndShapeRenderer();
renderer1.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
CategoryPlot subplot1 = new CategoryPlot(dataset1, null, rangeAxis1, renderer1);
subplot1.setDomainGridlinesVisible(true);
CategoryDataset dataset2 = createDataset2();
NumberAxis rangeAxis2 = new NumberAxis("Value");
rangeAxis2.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
BarRenderer renderer2 = new BarRenderer();
renderer2.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
CategoryPlot subplot2 = new CategoryPlot(dataset2, null, rangeAxis2, renderer2);
subplot2.setDomainGridlinesVisible(true);
CategoryAxis domainAxis = new CategoryAxis("Category");
CombinedCategoryPlot plot = new CombinedCategoryPlot(domainAxis, new NumberAxis("Range"));
plot.add(subplot1, 2);
plot.add(subplot2, 1);
JFreeChart result = new JFreeChart("Combined Domain Category Plot Demo", new Font("SansSerif", Font.BOLD, 12), plot, true);
return result;
}
use of org.jfree.data.category.CategoryDataset in project SIMVA-SoS by SESoS.
the class CategoryPlot method clone.
/**
* Returns a clone of the plot.
*
* @return A clone.
*
* @throws CloneNotSupportedException if the cloning is not supported.
*/
@Override
public Object clone() throws CloneNotSupportedException {
CategoryPlot clone = (CategoryPlot) super.clone();
clone.domainAxes = CloneUtils.cloneMapValues(this.domainAxes);
for (CategoryAxis axis : clone.domainAxes.values()) {
if (axis != null) {
axis.setPlot(clone);
axis.addChangeListener(clone);
}
}
clone.rangeAxes = CloneUtils.cloneMapValues(this.rangeAxes);
for (ValueAxis axis : clone.rangeAxes.values()) {
if (axis != null) {
axis.setPlot(clone);
axis.addChangeListener(clone);
}
}
// AxisLocation is immutable, so we can just copy the maps
clone.domainAxisLocations = new HashMap<Integer, AxisLocation>(this.domainAxisLocations);
clone.rangeAxisLocations = new HashMap<Integer, AxisLocation>(this.rangeAxisLocations);
clone.datasets = new HashMap<Integer, CategoryDataset>(this.datasets);
for (CategoryDataset dataset : clone.datasets.values()) {
if (dataset != null) {
dataset.addChangeListener(clone);
}
}
clone.datasetToDomainAxesMap = new TreeMap();
clone.datasetToDomainAxesMap.putAll(this.datasetToDomainAxesMap);
clone.datasetToRangeAxesMap = new TreeMap();
clone.datasetToRangeAxesMap.putAll(this.datasetToRangeAxesMap);
clone.renderers = CloneUtils.cloneMapValues(this.renderers);
for (CategoryItemRenderer renderer : clone.renderers.values()) {
if (renderer != null) {
renderer.setPlot(clone);
renderer.addChangeListener(clone);
}
}
if (this.fixedDomainAxisSpace != null) {
clone.fixedDomainAxisSpace = (AxisSpace) ObjectUtilities.clone(this.fixedDomainAxisSpace);
}
if (this.fixedRangeAxisSpace != null) {
clone.fixedRangeAxisSpace = (AxisSpace) ObjectUtilities.clone(this.fixedRangeAxisSpace);
}
clone.annotations = (List) ObjectUtilities.deepClone(this.annotations);
clone.foregroundDomainMarkers = cloneMarkerMap(this.foregroundDomainMarkers);
clone.backgroundDomainMarkers = cloneMarkerMap(this.backgroundDomainMarkers);
clone.foregroundRangeMarkers = cloneMarkerMap(this.foregroundRangeMarkers);
clone.backgroundRangeMarkers = cloneMarkerMap(this.backgroundRangeMarkers);
if (this.fixedLegendItems != null) {
clone.fixedLegendItems = (LegendItemCollection) this.fixedLegendItems.clone();
}
return clone;
}
use of org.jfree.data.category.CategoryDataset in project SIMVA-SoS by SESoS.
the class CategoryPlot method datasetsMappedToRangeAxis.
/**
* A utility method that returns a list of datasets that are mapped to a
* given range axis.
*
* @param index the axis index.
*
* @return A list of datasets.
*/
private List datasetsMappedToRangeAxis(int index) {
Integer key = new Integer(index);
List result = new ArrayList();
for (CategoryDataset dataset : this.datasets.values()) {
int i = indexOf(dataset);
List mappedAxes = (List) this.datasetToRangeAxesMap.get(new Integer(i));
if (mappedAxes == null) {
if (key.equals(ZERO)) {
result.add(this.datasets.get(i));
}
} else {
if (mappedAxes.contains(key)) {
result.add(this.datasets.get(i));
}
}
}
return result;
}
use of org.jfree.data.category.CategoryDataset in project SIMVA-SoS by SESoS.
the class CategoryPlot method getDataRange.
/**
* Returns the range of data values that will be plotted against the range
* axis. If the dataset is <code>null</code>, this method returns
* <code>null</code>.
*
* @param axis the axis.
*
* @return The data range.
*/
@Override
public Range getDataRange(ValueAxis axis) {
Range result = null;
List<CategoryDataset> mappedDatasets = new ArrayList<CategoryDataset>();
int rangeIndex = findRangeAxisIndex(axis);
if (rangeIndex >= 0) {
mappedDatasets.addAll(datasetsMappedToRangeAxis(rangeIndex));
} else if (axis == getRangeAxis()) {
mappedDatasets.addAll(datasetsMappedToRangeAxis(0));
}
// of the ranges.
for (CategoryDataset d : mappedDatasets) {
CategoryItemRenderer r = getRendererForDataset(d);
if (r != null) {
result = Range.combine(result, r.findRangeBounds(d));
}
}
return result;
}
use of org.jfree.data.category.CategoryDataset in project SIMVA-SoS by SESoS.
the class CategoryPlot method datasetsMappedToDomainAxis.
/**
* Returns a list of the datasets that are mapped to the axis with the
* specified index.
*
* @param axisIndex the axis index.
*
* @return The list (possibly empty, but never <code>null</code>).
*
* @since 1.0.3
*/
private List<CategoryDataset> datasetsMappedToDomainAxis(int axisIndex) {
Integer key = new Integer(axisIndex);
List<CategoryDataset> result = new ArrayList<CategoryDataset>();
for (CategoryDataset dataset : this.datasets.values()) {
if (dataset == null) {
continue;
}
int i = indexOf(dataset);
List mappedAxes = (List) this.datasetToDomainAxesMap.get(new Integer(i));
if (mappedAxes == null) {
if (key.equals(ZERO)) {
result.add(dataset);
}
} else {
if (mappedAxes.contains(key)) {
result.add(dataset);
}
}
}
return result;
}
Aggregations