org.jfree.chart.RenderingSource Java Examples
The following examples show how to use
org.jfree.chart.RenderingSource.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractXYItemRenderer.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Initialises the renderer and returns a state object that should be * passed to all subsequent calls to the drawItem() method. * <P> * This method will be called before the first item is rendered, giving the * renderer an opportunity to initialise any state information it wants to * maintain. The renderer can do nothing if it chooses. * * @param g2 the graphics device. * @param dataArea the area inside the axes. * @param plot the plot. * @param dataset the dataset. * @param info an optional info collection object to return data back to * the caller. * * @return The renderer state (never <code>null</code>). */ public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, XYPlot plot, XYDataset dataset, PlotRenderingInfo info) { XYItemRendererState state = createState(info); // determine if there is any selection state for the dataset XYDatasetSelectionState selectionState = null; if (dataset instanceof SelectableXYDataset) { SelectableXYDataset sxyd = (SelectableXYDataset) dataset; selectionState = sxyd.getSelectionState(); } // if the selection state is still null, go to the selection source // and ask if it has state... if (selectionState == null && info != null) { ChartRenderingInfo cri = info.getOwner(); if (cri != null) { RenderingSource rs = cri.getRenderingSource(); selectionState = (XYDatasetSelectionState) rs.getSelectionState(dataset); } } state.setSelectionState(selectionState); return state; }
Example #2
Source File: Cardumen_009_s.java From coming with MIT License | 5 votes |
/** * Selects the data items within the specified region. * * @param region the region (in Java2D coordinates). * @param dataArea the data area. * @param source the rendering source. * * @since 1.2.0 */ public void select(GeneralPath region, Rectangle2D dataArea, RenderingSource source) { // cycle through the datasets and change the selection state for the // items that fall within the specified region int datasetCount = this.datasets.size(); for (int d = 0; d < datasetCount; d++) { XYDataset dataset = (XYDataset) this.datasets.get(d); if (dataset == null) { continue; } XYDatasetSelectionState state = findSelectionStateForDataset( dataset, source); if (state == null) { continue; } GeneralPath path = convertToDataSpace(region, dataArea, dataset); // now we have to iterate over all the dataset values and // convert each point to Java2D space and then check if it should // be selected. int seriesCount = dataset.getSeriesCount(); for (int s = 0; s < seriesCount; s++) { int itemCount = dataset.getItemCount(s); for (int i = 0; i < itemCount; i++) { double x = dataset.getXValue(s, i); double y = dataset.getYValue(s, i); if (path.contains(x, y)) { state.setSelected(s, i, true); // FIXME: we should fire just one dataset change event // for the whole selection } } } } }
Example #3
Source File: Cardumen_009_t.java From coming with MIT License | 5 votes |
/** * Selects the data items within the specified region. * * @param region the region (in Java2D coordinates). * @param dataArea the data area. * @param source the rendering source. * * @since 1.2.0 */ public void select(GeneralPath region, Rectangle2D dataArea, RenderingSource source) { // cycle through the datasets and change the selection state for the // items that fall within the specified region int datasetCount = this.datasets.size(); for (int d = 0; d < datasetCount; d++) { XYDataset dataset = (XYDataset) this.datasets.get(d); if (dataset == null) { continue; } XYDatasetSelectionState state = findSelectionStateForDataset( dataset, source); if (state == null) { continue; } GeneralPath path = convertToDataSpace(region, dataArea, dataset); // now we have to iterate over all the dataset values and // convert each point to Java2D space and then check if it should // be selected. int seriesCount = dataset.getSeriesCount(); for (int s = 0; s < seriesCount; s++) { int itemCount = dataset.getItemCount(s); for (int i = 0; i < itemCount; i++) { double x = dataset.getXValue(s, i); double y = dataset.getYValue(s, i); if (path.contains(x, y)) { state.setSelected(s, i, true); // FIXME: we should fire just one dataset change event // for the whole selection } } } } }
Example #4
Source File: Cardumen_0082_t.java From coming with MIT License | 5 votes |
/** * Selects the data items within the specified region. * * @param region the region (in Java2D coordinates). * @param dataArea the data area. * @param source the rendering source. * * @since 1.2.0 */ public void select(GeneralPath region, Rectangle2D dataArea, RenderingSource source) { // cycle through the datasets and change the selection state for the // items that fall within the specified region int datasetCount = this.datasets.size(); for (int d = 0; d < datasetCount; d++) { XYDataset dataset = (XYDataset) this.datasets.get(d); if (dataset == null) { continue; } XYDatasetSelectionState state = findSelectionStateForDataset( dataset, source); if (state == null) { continue; } GeneralPath path = convertToDataSpace(region, dataArea, dataset); // now we have to iterate over all the dataset values and // convert each point to Java2D space and then check if it should // be selected. int seriesCount = dataset.getSeriesCount(); for (int s = 0; s < seriesCount; s++) { int itemCount = dataset.getItemCount(s); for (int i = 0; i < itemCount; i++) { double x = dataset.getXValue(s, i); double y = dataset.getYValue(s, i); if (path.contains(x, y)) { state.setSelected(s, i, true); // FIXME: we should fire just one dataset change event // for the whole selection } } } } }
Example #5
Source File: Cardumen_0082_s.java From coming with MIT License | 5 votes |
/** * Selects the data items within the specified region. * * @param region the region (in Java2D coordinates). * @param dataArea the data area. * @param source the rendering source. * * @since 1.2.0 */ public void select(GeneralPath region, Rectangle2D dataArea, RenderingSource source) { // cycle through the datasets and change the selection state for the // items that fall within the specified region int datasetCount = this.datasets.size(); for (int d = 0; d < datasetCount; d++) { XYDataset dataset = (XYDataset) this.datasets.get(d); if (dataset == null) { continue; } XYDatasetSelectionState state = findSelectionStateForDataset( dataset, source); if (state == null) { continue; } GeneralPath path = convertToDataSpace(region, dataArea, dataset); // now we have to iterate over all the dataset values and // convert each point to Java2D space and then check if it should // be selected. int seriesCount = dataset.getSeriesCount(); for (int s = 0; s < seriesCount; s++) { int itemCount = dataset.getItemCount(s); for (int i = 0; i < itemCount; i++) { double x = dataset.getXValue(s, i); double y = dataset.getYValue(s, i); if (path.contains(x, y)) { state.setSelected(s, i, true); // FIXME: we should fire just one dataset change event // for the whole selection } } } } }
Example #6
Source File: XYLineAndShapeRenderer.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Initialises the renderer. * <P> * This method will be called before the first item is rendered, giving the * renderer an opportunity to initialise any state information it wants to * maintain. The renderer can do nothing if it chooses. * * @param g2 the graphics device. * @param dataArea the area inside the axes. * @param plot the plot. * @param dataset the dataset. * @param info an optional info collection object to return data back to * the caller. * * @return The renderer state. */ public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, XYPlot plot, XYDataset dataset, PlotRenderingInfo info) { State state = new State(info); state.seriesPath = new GeneralPath(); // determine if there is any selection state for the dataset XYDatasetSelectionState selectionState = null; if (dataset instanceof SelectableXYDataset) { SelectableXYDataset sxyd = (SelectableXYDataset) dataset; selectionState = sxyd.getSelectionState(); } // if the selection state is still null, go to the selection source // and ask if it has state... if (selectionState == null && info != null) { ChartRenderingInfo cri = info.getOwner(); if (cri != null) { RenderingSource rs = cri.getRenderingSource(); if (rs != null) { selectionState = (XYDatasetSelectionState) rs.getSelectionState(dataset); } } } state.setSelectionState(selectionState); return state; }
Example #7
Source File: CategoryPlot.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Perform a select for the item(s) at the specified (x, y) coordinates * in Java2D space. * * @param x the x-coordinate. * @param y the y-coordinate. * @param dataArea the data area. * @param source the rendering source. * * @since 1.2.0 */ public void select(double x, double y, Rectangle2D dataArea, RenderingSource source) { int datasetCount = this.datasets.size(); for (int d = 0; d < datasetCount; d++) { CategoryDataset dataset = (CategoryDataset) this.datasets.get(d); if (dataset == null) { continue; } CategoryDatasetSelectionState state = findSelectionStateForDataset( dataset, source); if (state == null) { continue; } Graphics2D g2 = source.createGraphics2D(); CategoryItemRenderer renderer = getRendererForDataset(dataset); CategoryItemRendererState rs = renderer.initialise(g2, dataArea, this, dataset, null); int rowCount = dataset.getRowCount(); int columnCount = dataset.getColumnCount(); for (int r = 0; r < rowCount; r++) { for (int c = 0; c < columnCount; c++) { if (renderer.hitTest(x, y, null, dataArea, this, getDomainAxisForDataset(d), getRangeAxisForDataset(d), dataset, r, c, false, rs)) { state.setSelected(r, c, !state.isSelected(r, c)); } } } } }
Example #8
Source File: PiePlot.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Selects a data item. * * @param x * @param y * @param dataArea * @param source */ public void select(double x, double y, Rectangle2D dataArea, RenderingSource source) { System.out.println("select " + x + ", " + y); PieDatasetSelectionState state = findSelectionStateForDataset( dataset, source); if (state == null) { return; } Rectangle2D[] areas = calculateLinkAndExplodeAreas(null, dataArea); Rectangle2D linkArea = areas[0]; Rectangle2D explodeArea = areas[1]; // the pie area defines the circle/ellipse for regular pie sections. // it is defined by shrinking the explodeArea by the explodeMargin // factor. double maximumExplodePercent = getMaximumExplodePercent(); double percent = maximumExplodePercent / (1.0 + maximumExplodePercent); double h1 = explodeArea.getWidth() * percent; double v1 = explodeArea.getHeight() * percent; Rectangle2D pieArea = new Rectangle2D.Double(explodeArea.getX() + h1 / 2.0, explodeArea.getY() + v1 / 2.0, explodeArea.getWidth() - h1, explodeArea.getHeight() - v1); // plot the data (unless the dataset is null)... if ((this.dataset != null) && (this.dataset.getKeys().size() > 0)) { List keys = this.dataset.getKeys(); double total = DatasetUtilities.calculatePieDatasetTotal( this.dataset); double runningTotal = 0.0; for (int section = 0; section < keys.size(); section++) { Number n = this.dataset.getValue(section); if (n == null) { continue; } double value = n.doubleValue(); if (value > 0.0) { double angle0 = calculateAngleForValue(runningTotal, total); double angle1 = calculateAngleForValue(runningTotal + value, total); runningTotal += value; System.out.println(this.dataset.getValue(section)); System.out.println(angle0); System.out.println(angle1); double angle = (angle1 - angle0); if (Math.abs(angle) > getMinimumArcAngleToDraw()) { double ep = 0.0; double mep = getMaximumExplodePercent(); if (mep > 0.0) { ep = getExplodePercent(getSectionKey(section)) / mep; } Rectangle2D arcBounds = getArcBounds(pieArea, explodeArea, angle0, angle, ep); Arc2D.Double arc = new Arc2D.Double(arcBounds, angle0, angle, Arc2D.PIE); if (arc.contains(x, y)) { Comparable key = this.dataset.getKey(section); state.setSelected(key, !state.isSelected(key)); System.out.println(key + " is " + state.isSelected(key)); } } } } } }
Example #9
Source File: Cardumen_009_s.java From coming with MIT License | 2 votes |
/** * Selects a single point - NOT YET IMPLEMENTED. * * @since 1.2.0 */ public void select(double x, double y, Rectangle2D dataArea, RenderingSource source) { // TODO: implement }
Example #10
Source File: Cardumen_009_t.java From coming with MIT License | 2 votes |
/** * Selects a single point - NOT YET IMPLEMENTED. * * @since 1.2.0 */ public void select(double x, double y, Rectangle2D dataArea, RenderingSource source) { // TODO: implement }
Example #11
Source File: Cardumen_0082_t.java From coming with MIT License | 2 votes |
/** * Selects a single point - NOT YET IMPLEMENTED. * * @since 1.2.0 */ public void select(double x, double y, Rectangle2D dataArea, RenderingSource source) { // TODO: implement }
Example #12
Source File: Cardumen_0082_s.java From coming with MIT License | 2 votes |
/** * Selects a single point - NOT YET IMPLEMENTED. * * @since 1.2.0 */ public void select(double x, double y, Rectangle2D dataArea, RenderingSource source) { // TODO: implement }
Example #13
Source File: Selectable.java From astor with GNU General Public License v2.0 | 2 votes |
/** * Set the selection state for the data item(s) at the specified (x, y) * coordinates in Java2D space. * * @param x the x-coordinate. * @param y the y-coordinate. * @param dataArea the data area. * @param source the selection source (usually a chart panel, possibly * <code>null</code>). */ public void select(double x, double y, Rectangle2D dataArea, RenderingSource source);
Example #14
Source File: Selectable.java From astor with GNU General Public License v2.0 | 2 votes |
/** * Set the selection state for the data item(s) within the specified region * in Java2D space. * * @param region the region. * @param dataArea the data area. * @param source the selection source (usually a chart panel, possibly * <code>null</code>). */ public void select(GeneralPath region, Rectangle2D dataArea, RenderingSource source);
Example #15
Source File: PiePlot.java From astor with GNU General Public License v2.0 | 2 votes |
/** * This method does nothing, because this plot does not support * selection by region. * * @param region ignored. * @param dataArea ignored. * @param source ignored. * * @see #canSelectByRegion() * * @since 1.2.0 */ public void select(GeneralPath region, Rectangle2D dataArea, RenderingSource source) { // operation not supported }
Example #16
Source File: CategoryPlot.java From astor with GNU General Public License v2.0 | 2 votes |
/** * Perform a select for the item(s) within the specified region * in Java2D space. * * @param region the region. * @param dataArea the data area. * @param source the rendering source. * * @since 1.2.0 */ public void select(GeneralPath region, Rectangle2D dataArea, RenderingSource source) { System.out.println(region); System.out.println("Select a region..."); }