List of usage examples for org.jfree.data.general Dataset getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:de.laures.cewolf.taglib.PlotDefinition.java
public Plot getPlot(int chartType) throws DatasetProduceException, ChartValidationException { log.debug("Plot.getPlot: chartType: " + chartType); if (plot == null) { int rendererIndex = PlotTypes.getRendererIndex(type); Dataset data = (Dataset) getDataset(); log.debug("Plot.getPlot: data name: " + data.getClass().getName()); AbstractRenderer rend = PlotTypes.getRenderer(rendererIndex); log.debug("Plot.getPlot: rendererIndex: " + rendererIndex); if (chartType == ChartConstants.OVERLAY_XY || chartType == ChartConstants.COMBINED_XY) { switch (rendererIndex) { case XY_AREA: case XY_LINE: case XY_SHAPES_AND_LINES: case SCATTER: case STEP: check(data, XYDataset.class, rendererIndex); plot = new XYPlot((XYDataset) data, null, null, (XYItemRenderer) rend); break; case XY_VERTICAL_BAR: check(data, IntervalXYDataset.class, rendererIndex); plot = new XYPlot((IntervalXYDataset) data, null, null, (XYItemRenderer) rend); break; case CANDLESTICK: case HIGH_LOW: check(data, OHLCDataset.class, rendererIndex); plot = new XYPlot((OHLCDataset) data, null, null, (XYItemRenderer) rend); break; //case SIGNAL : // check(data, SignalsDataset.class, rendererIndex); // plot = new XYPlot((SignalsDataset) data, null, null, (XYItemRenderer) rend); default: throw new AttributeValidationException(chartType + ".type", type); }/*from www .j a va 2 s .c om*/ } else if (chartType == ChartConstants.OVERLAY_CATEGORY) { switch (rendererIndex) { case AREA: case VERTICAL_BAR: case LINE: case SHAPES_AND_LINES: check(data, CategoryDataset.class, rendererIndex); plot = new CategoryPlot((CategoryDataset) data, null, null, (CategoryItemRenderer) rend); break; default: throw new AttributeValidationException(chartType + ".type", type); } } } plot.setDrawingSupplier(drawingSupplier); return plot; }
From source file:net.sf.maltcms.common.charts.api.overlay.AbstractChartOverlay.java
/** * * @param entity/* w w w .j ava2 s . com*/ * @param chartPanel * @param dataset * @param seriesIndex * @param itemIndex * @return */ public static Shape toView(Shape entity, ChartPanel chartPanel, Dataset dataset, int seriesIndex, int itemIndex) { if (dataset instanceof XYDataset) { XYDataset xyds = (XYDataset) dataset; double x1 = xyds.getXValue(seriesIndex, itemIndex); double y1 = xyds.getYValue(seriesIndex, itemIndex); AffineTransform toPosition = getModelToViewTransformXY(chartPanel, x1, y1); toPosition.concatenate( getTranslateInstance(-entity.getBounds2D().getCenterX(), -entity.getBounds2D().getCenterY())); return toPosition.createTransformedShape(entity); } else if (dataset instanceof CategoryDataset) { CategoryDataset cds = (CategoryDataset) dataset; double y1 = cds.getValue(seriesIndex, itemIndex).doubleValue(); AffineTransform toPosition = getModelToViewTransformCategory(chartPanel, itemIndex, y1); toPosition.concatenate( getTranslateInstance(-entity.getBounds2D().getCenterX(), -entity.getBounds2D().getCenterY())); return toPosition.createTransformedShape(entity); } throw new IllegalArgumentException("Unsupported dataset type: " + dataset.getClass()); }
From source file:net.sf.maltcms.chromaui.charts.format.ScaledNumberFormatter.java
/** * * @param cce/*from w w w .j av a 2s. com*/ */ @Override public void chartChanged(ChartChangeEvent cce) { ChartChangeEventType ccet = cce.getType(); if (ccet == ChartChangeEventType.DATASET_UPDATED || ccet == ChartChangeEventType.NEW_DATASET) { if (cce.getSource() != (this)) { Plot p = cce.getChart().getPlot(); if (p instanceof XYPlot) { XYPlot xyp = (XYPlot) p; Range axisRange = xyp.getRangeAxis().getRange(); ; if (relativeMode) { int cnt = xyp.getDatasetCount(); Range r = new Range(0, 1); for (int i = 0; i < cnt; i++) { Dataset d = xyp.getDataset(i); if (d != null && d instanceof XYDataset) { XYDataset xyd = (XYDataset) d; Range dr = DatasetUtilities.findRangeBounds(xyd); if (dr != null) { r = new Range(Math.min(r.getLowerBound(), dr.getLowerBound()), Math.max(r.getUpperBound(), dr.getUpperBound())); } } else { throw new NotImplementedException( "No support yet for dataset of type: " + d.getClass()); } } this.dataMin = Math.min(0, r.getLowerBound()); this.dataMax = r.getUpperBound(); cce.getChart().fireChartChanged(); } else { this.min = axisRange.getLowerBound(); this.max = axisRange.getUpperBound(); cce.getChart().fireChartChanged(); } } } } }
From source file:net.sf.maltcms.common.charts.api.overlay.SelectionOverlay.java
private Shape generate(Dataset ds, int seriesIndex, int itemIndex) { if (ds instanceof XYDataset) { XYDataset xyds = (XYDataset) ds; double width = 10.0d; double height = 10.0d; double x = xyds.getXValue(seriesIndex, itemIndex) - (width / 2.0d); double y = xyds.getYValue(seriesIndex, itemIndex); Ellipse2D.Double e = new Ellipse2D.Double(x, y, width, height); return e; } else if (ds instanceof CategoryDataset) { CategoryDataset cds = (CategoryDataset) ds; double width = 10.0d; double height = 10.0d; double y = cds.getValue(seriesIndex, itemIndex).doubleValue(); Ellipse2D.Double e = new Ellipse2D.Double(itemIndex, y, width, height); return e; }/* w w w . j av a 2 s. c om*/ throw new IllegalArgumentException("Unsupported dataset type: " + ds.getClass()); }