List of usage examples for org.jfree.chart.plot PlotRenderingInfo setPlotArea
public void setPlotArea(Rectangle2D area)
From source file:peakml.util.jfreechart.FastSpectrumPlot.java
@Override public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) { // add the plot area to the info (used amongst other by the axis for zooming) if (info != null) info.setPlotArea(area); // add the insets (if any) RectangleInsets insets = getInsets(); insets.trim(area);// w w w.j a v a2 s. com // draw the axis and add the dataArea to the info (used amongst other by the axis for zooming) AxisSpace space = new AxisSpace(); space = xaxis.reserveSpace(g2, this, area, RectangleEdge.BOTTOM, space); space = yaxis.reserveSpace(g2, this, area, RectangleEdge.LEFT, space); Rectangle2D dataArea = space.shrink(area, null); if (info != null) info.setDataArea(dataArea); // flood fill the whole area with the background color drawBackground(g2, dataArea); // draw the axis xaxis.draw(g2, dataArea.getMaxY(), area, dataArea, RectangleEdge.BOTTOM, info); yaxis.draw(g2, dataArea.getMinX(), area, dataArea, RectangleEdge.LEFT, info); // sanity check if (dataseries.size() == 0) return; // clip the draw area Shape originalclip = g2.getClip(); g2.clip(dataArea); // draw all the values for (Data data : dataseries) { int xpos = (int) xaxis.valueToJava2D(data.mass, dataArea, RectangleEdge.BOTTOM); int ypos = (int) yaxis.valueToJava2D(data.intensity, dataArea, RectangleEdge.LEFT); g2.drawLine(xpos, (int) yaxis.valueToJava2D(0, dataArea, RectangleEdge.LEFT), xpos, ypos); // draw the label if (data.description != null && data.description.length() != 0) { g2.setColor(Color.RED); g2.drawLine(xpos + 2, ypos - 2, xpos + 15, ypos - 15); g2.setColor(Color.BLACK); g2.drawString(data.description, xpos + 17, ypos - 17); } } // reset g2.setClip(originalclip); }
From source file:peakml.util.jfreechart.FastTimePlot.java
@Override public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) { // add the plot area to the info (used amongst other by the axis for zooming) if (info != null) info.setPlotArea(area); // add the insets (if any) RectangleInsets insets = getInsets(); insets.trim(area);// w w w. ja v a 2s . com // draw the axis and add the dataArea to the info (used amongst other by the axis for zooming) AxisSpace space = new AxisSpace(); space = xaxis.reserveSpace(g2, this, area, RectangleEdge.BOTTOM, space); space = yaxis.reserveSpace(g2, this, area, RectangleEdge.LEFT, space); Rectangle2D dataArea = space.shrink(area, null); if (info != null) info.setDataArea(dataArea); // flood fill the whole area with the background color drawBackground(g2, dataArea); // draw the axis xaxis.draw(g2, dataArea.getMaxY(), area, dataArea, RectangleEdge.BOTTOM, info); yaxis.draw(g2, dataArea.getMinX(), area, dataArea, RectangleEdge.LEFT, info); // sanity check if (dataseries.size() == 0) return; // clip the draw area Shape originalclip = g2.getClip(); g2.clip(dataArea); // draw all the values int index = 0; for (Data data : dataseries.values()) { g2.setColor(new Color(data.color == -1 ? colormap.getColor(index++) : data.color)); for (int i = 0; i < data.size - 1; ++i) { g2.drawLine((int) xaxis.valueToJava2D(data.time[i], dataArea, RectangleEdge.BOTTOM), (int) yaxis.valueToJava2D(data.values[i], dataArea, RectangleEdge.LEFT), (int) xaxis.valueToJava2D(data.time[i + 1], dataArea, RectangleEdge.BOTTOM), (int) yaxis.valueToJava2D(data.values[i + 1], dataArea, RectangleEdge.LEFT)); } } // reset g2.setClip(originalclip); }
From source file:peakml.util.jfreechart.FastErrorBarPlot.java
@Override public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) { // add the plot area to the info (used amongst other by the axis for zooming) if (info != null) info.setPlotArea(area); // add the insets (if any) RectangleInsets insets = getInsets(); insets.trim(area);/*ww w . j a va 2s .c om*/ // draw the axis and add the dataArea to the info (used amongst other by the axis for zooming) AxisSpace space = new AxisSpace(); space = xaxis.reserveSpace(g2, this, area, RectangleEdge.BOTTOM, space); space = yaxis.reserveSpace(g2, this, area, RectangleEdge.LEFT, space); Rectangle2D dataArea = space.shrink(area, null); if (info != null) info.setDataArea(dataArea); // flood fill the whole area with the background color drawBackground(g2, dataArea); // draw the axis xaxis.draw(g2, dataArea.getMaxY(), area, dataArea, RectangleEdge.BOTTOM, info); yaxis.draw(g2, dataArea.getMinX(), area, dataArea, RectangleEdge.LEFT, info); // sanity check if (dataseries.size() == 0) return; // clip the draw area Shape originalclip = g2.getClip(); g2.clip(dataArea); // create the strokes BasicStroke stroke_solid = new BasicStroke(1.f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND, 1.f); BasicStroke stroke_dashed = new BasicStroke(1.f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND, 1.f, new float[] { 2, 4 }, 0); g2.setStroke(stroke_solid); // count the number of labels int categoryCount = 0; if (showall) { for (Data data : dataseries) categoryCount += data.yvalues.length; } else categoryCount = dataseries.size(); // draw all the values int pos = 0; boolean dashed = false; double prevx = -1, prevy = -1; for (Data data : dataseries) { if (data.yvalues.length == 0) { dashed = true; pos++; continue; } double mean[] = showall ? data.yvalues : new double[] { data.getMeanY() }; double min[] = showall ? data.yvalues : new double[] { data.getMinY() }; double max[] = showall ? data.yvalues : new double[] { data.getMaxY() }; for (int i = 0; i < mean.length; ++i) { double ypos, xpos = xaxis.getCategoryJava2DCoordinate(CategoryAnchor.MIDDLE, pos++, categoryCount, dataArea, RectangleEdge.BOTTOM); // draw the mean value g2.setColor(Color.RED); ypos = yaxis.valueToJava2D(mean[i], dataArea, RectangleEdge.LEFT); g2.drawLine((int) xpos - 2, (int) ypos, (int) xpos + 2, (int) ypos); // conect the dots if (prevx != -1 && prevy != -1) { g2.setColor(Color.BLACK); if (dashed) g2.setStroke(stroke_dashed); g2.drawLine((int) prevx, (int) prevy, (int) xpos, (int) ypos); if (dashed) { dashed = false; g2.setStroke(stroke_solid); } } prevy = ypos; prevx = xpos; // draw the outer values g2.setColor(Color.LIGHT_GRAY); double ypos_min = yaxis.valueToJava2D(min[i], dataArea, RectangleEdge.LEFT); g2.drawLine((int) xpos - 2, (int) ypos_min, (int) xpos + 2, (int) ypos_min); double ypos_max = yaxis.valueToJava2D(max[i], dataArea, RectangleEdge.LEFT); g2.drawLine((int) xpos - 2, (int) ypos_max, (int) xpos + 2, (int) ypos_max); g2.drawLine((int) xpos, (int) ypos_min, (int) xpos, (int) ypos_max); } } // reset g2.setClip(originalclip); }
From source file:net.sourceforge.processdash.ui.lib.chart.DiscPlot.java
@Override public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) { // adjust for insets... RectangleInsets insets = getInsets(); insets.trim(area);//from w w w . j av a 2 s.c o m if (info != null) { info.setPlotArea(area); info.setDataArea(area); } drawBackground(g2, area); drawOutline(g2, area); Shape savedClip = g2.getClip(); g2.clip(area); Composite originalComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getForegroundAlpha())); if (!getDiscDistributor().isDatasetEmpty()) { Rectangle2D dataArea = getDataArea(area); drawDiscs(g2, dataArea, info); drawLegendAxis(g2, dataArea, info); } else { drawNoDataMessage(g2, area); } g2.setClip(savedClip); g2.setComposite(originalComposite); drawOutline(g2, area); }
From source file:org.tsho.dmc2.core.chart.AbstractDmcPlot.java
/** * Draws the fast scatter plot on a Java 2D graphics device (such as the screen or * a printer).// ww w.j a v a 2s.c o m * * @param g2 the graphics device. * @param plotArea the area within which the plot (including axis labels) should be drawn. * @param info collects chart drawing information (<code>null</code> permitted). */ public void draw(Graphics2D g2, Rectangle2D plotArea, PlotState parentState, PlotRenderingInfo info) { // if (data == null) // return; // set up info collection... if (info != null) { info.setPlotArea(plotArea); } // adjust the drawing area for plot insets (if any)... Insets insets = getInsets(); if (insets != null) { plotArea.setRect(plotArea.getX() + insets.left, plotArea.getY() + insets.top, plotArea.getWidth() - insets.left - insets.right, plotArea.getHeight() - insets.top - insets.bottom); } AxisSpace space = new AxisSpace(); space = this.domainAxis.reserveSpace(g2, this, plotArea, RectangleEdge.BOTTOM, space); space = this.rangeAxis.reserveSpace(g2, this, plotArea, RectangleEdge.LEFT, space); Rectangle2D dataArea = space.shrink(plotArea, null); if (info != null) { info.setDataArea(dataArea); } // draw the plot background and axes... drawBackground(g2, dataArea); /* if automatic bounds... */ if (!isNoData()) { if (this instanceof DmcRenderablePlot) { DmcPlotRenderer renderer; renderer = ((DmcRenderablePlot) this).getPlotRenderer(); if (renderer != null) { renderer.initialize(); if (renderer.getState() == DmcPlotRenderer.STATE_STOPPED) { return; } } } } AxisState domainAxisState = null, rangeAxisState = null; if (this.domainAxis != null) { double cursor; cursor = dataArea.getMaxY(); domainAxisState = this.domainAxis.draw(g2, cursor, plotArea, dataArea, RectangleEdge.BOTTOM, info); // cursor = info.getCursor(); } if (this.rangeAxis != null) { double cursor; cursor = dataArea.getMinX(); rangeAxisState = this.rangeAxis.draw(g2, cursor, plotArea, dataArea, RectangleEdge.LEFT, info); } if (drawGridlines == true && domainAxisState != null && rangeAxisState != null) { drawGridlines(g2, dataArea, domainAxisState.getTicks(), rangeAxisState.getTicks()); } Shape originalClip = g2.getClip(); g2.clip(dataArea); // Composite originalComposite = g2.getComposite(); // g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, // getForegroundAlpha())); // g2.setStroke(new BasicStroke(12.0F)); if (isNoData()) { drawNoDataMessage(g2, plotArea); } else { drawPlot(g2, dataArea, info); } g2.setClip(originalClip); drawOutline(g2, dataArea); }
From source file:org.proteosuite.FastScatterPlot.java
/** * Draws the fast scatter plot on a Java 2D graphics device (such as the * screen or a printer).//from w ww .jav a2s . c om * * @param g2 the graphics device. * @param area the area within which the plot (including axis labels) * should be drawn. * @param anchor the anchor point (<code>null</code> permitted). * @param parentState the state from the parent plot, if there is one. * @param info collects chart drawing information (<code>null</code> * permitted). */ public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) { // set up info collection... if (info != null) { info.setPlotArea(area); } // adjust the drawing area for plot insets (if any)... RectangleInsets insets = getInsets(); insets.trim(area); AxisSpace space = new AxisSpace(); space = this.domainAxis.reserveSpace(g2, this, area, RectangleEdge.BOTTOM, space); space = this.rangeAxis.reserveSpace(g2, this, area, RectangleEdge.LEFT, space); Rectangle2D dataArea = space.shrink(area, null); if (info != null) { info.setDataArea(dataArea); } // draw the plot background and axes... drawBackground(g2, dataArea); AxisState domainAxisState = null; AxisState rangeAxisState = null; if (this.domainAxis != null) { domainAxisState = this.domainAxis.draw(g2, dataArea.getMaxY(), area, dataArea, RectangleEdge.BOTTOM, info); } if (this.rangeAxis != null) { rangeAxisState = this.rangeAxis.draw(g2, dataArea.getMinX(), area, dataArea, RectangleEdge.LEFT, info); } drawDomainGridlines(g2, dataArea, domainAxisState.getTicks()); drawRangeGridlines(g2, dataArea, rangeAxisState.getTicks()); Shape originalClip = g2.getClip(); Composite originalComposite = g2.getComposite(); g2.clip(dataArea); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getForegroundAlpha())); render(g2, dataArea, info, null); g2.setClip(originalClip); g2.setComposite(originalComposite); drawOutline(g2, dataArea); }
From source file:net.sourceforge.processdash.ui.web.reports.RadarPlot.java
/** * Draws the plot on a Java 2D graphics device (such as the screen * or a printer)./*from www .j av a2s .c om*/ * @param g2 The graphics device. * @param plotArea The area within which the plot should be drawn. */ @Override public void draw(Graphics2D g2, Rectangle2D plotArea, Point2D anchor, PlotState state, PlotRenderingInfo info) { // adjust for insets... RectangleInsets insets = getInsets(); if (insets != null) { plotArea.setRect(plotArea.getX() + insets.getLeft(), plotArea.getY() + insets.getTop(), plotArea.getWidth() - insets.getLeft() - insets.getRight(), plotArea.getHeight() - insets.getTop() - insets.getBottom()); } if (info != null) { info.setPlotArea(plotArea); info.setDataArea(plotArea); } drawBackground(g2, plotArea); drawOutline(g2, plotArea); Shape savedClip = g2.getClip(); g2.clip(plotArea); Composite originalComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getForegroundAlpha())); if (this.dataset != null) { drawRadar(g2, plotArea, info, 0, this.dataset); } else { drawNoDataMessage(g2, plotArea); } g2.clip(savedClip); g2.setComposite(originalComposite); drawOutline(g2, plotArea); }
From source file:net.sf.maltcms.chromaui.charts.FastHeatMapPlot.java
/** * Draws the fast scatter plot on a Java 2D graphics device (such as the * screen or a printer)./*from w w w . j a va 2s. com*/ * * @param g2 the graphics device. * @param area the area within which the plot (including axis labels) should * be drawn. * @param anchor the anchor point (<code>null</code> permitted). * @param parentState the state from the parent plot (ignored). * @param info collects chart drawing information (<code>null</code> * permitted). */ @Override public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) { // set up info collection... if (info != null) { info.setPlotArea(area); } // adjust the drawing area for plot insets (if any)... RectangleInsets insets = getInsets(); insets.trim(area); AxisSpace space = new AxisSpace(); space = this.domainAxis.reserveSpace(g2, this, area, RectangleEdge.BOTTOM, space); space = this.rangeAxis.reserveSpace(g2, this, area, RectangleEdge.LEFT, space); Rectangle2D dataArea = space.shrink(area, null); if (info != null) { info.setDataArea(dataArea); } // draw the plot background and axes... drawBackground(g2, dataArea); AxisState domainAxisState = this.domainAxis.draw(g2, dataArea.getMaxY(), area, dataArea, RectangleEdge.BOTTOM, info); AxisState rangeAxisState = this.rangeAxis.draw(g2, dataArea.getMinX(), area, dataArea, RectangleEdge.LEFT, info); drawDomainGridlines(g2, dataArea, domainAxisState.getTicks()); drawRangeGridlines(g2, dataArea, rangeAxisState.getTicks()); Shape originalClip = g2.getClip(); Composite originalComposite = g2.getComposite(); g2.clip(dataArea); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getForegroundAlpha())); render(g2, dataArea, info, null); g2.setClip(originalClip); g2.setComposite(originalComposite); drawOutline(g2, dataArea); }
From source file:genlab.gui.jfreechart.EnhancedSpiderWebPlot.java
/** * Draws the plot on a Java 2D graphics device (such as the screen or a * printer).//from ww w .j a v a2 s . c o m * * @param g2 the graphics device. * @param area the area within which the plot should be drawn. * @param anchor the anchor point (<code>null</code> permitted). * @param parentState the state from the parent plot, if there is one. * @param info collects info about the drawing. */ public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) { // adjust for insets... RectangleInsets insets = getInsets(); insets.trim(area); if (info != null) { info.setPlotArea(area); info.setDataArea(area); } drawBackground(g2, area); //drawOutline(g2, area); Shape savedClip = g2.getClip(); g2.clip(area); Composite originalComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getForegroundAlpha())); if (!DatasetUtilities.isEmptyOrNull(this.dataset)) { int seriesCount = 0, catCount = 0; if (this.dataExtractOrder == TableOrder.BY_ROW) { seriesCount = this.dataset.getRowCount(); catCount = this.dataset.getColumnCount(); } else { seriesCount = this.dataset.getColumnCount(); catCount = this.dataset.getRowCount(); } // ensure we have a maximum value to use on the axes if (this.maxValue == DEFAULT_MAX_VALUE) calculateMaxValue(seriesCount, catCount); // Next, setup the plot area // adjust the plot area by the interior spacing value double gapHorizontal = area.getWidth() * getInteriorGap(); double gapVertical = area.getHeight() * getInteriorGap(); double X = area.getX() + gapHorizontal / 2; double Y = area.getY() + gapVertical / 2; double W = area.getWidth() - gapHorizontal; double H = area.getHeight() - gapVertical; double headW = area.getWidth() * this.headPercent; double headH = area.getHeight() * this.headPercent; // make the chart area a square double min = Math.min(W, H) / 2; X = (X + X + W) / 2 - min; Y = (Y + Y + H) / 2 - min; W = 2 * min; H = 2 * min; Point2D centre = new Point2D.Double(X + W / 2, Y + H / 2); Rectangle2D radarArea = new Rectangle2D.Double(X, Y, W, H); // draw the axis and category label for (int cat = 0; cat < catCount; cat++) { double angle = getStartAngle() + (getDirection().getFactor() * cat * 360 / (catCount > 2 ? catCount : 3)); Point2D endPoint = getWebPoint(radarArea, angle, 1); // 1 = end of axis Line2D line = new Line2D.Double(centre, endPoint); g2.setPaint(this.axisLinePaint); g2.setStroke(this.axisLineStroke); g2.draw(line); drawLabel(g2, radarArea, 0.0, cat, angle, 360.0 / (catCount > 2 ? catCount : 3)); } // Now actually plot each of the series polygons.. for (int series = 0; series < seriesCount; series++) { drawRadarPoly(g2, radarArea, centre, info, series, catCount, headH, headW); } } else { drawNoDataMessage(g2, area); } g2.setClip(savedClip); g2.setComposite(originalComposite); //drawOutline(g2, area); }
From source file:spinworld.gui.RadarPlot.java
/** * Draws the plot on a Java 2D graphics device (such as the screen or a * printer)./*from w w w . j a va 2s.c o m*/ * * @param g2 the graphics device. * @param area the area within which the plot should be drawn. * @param anchor the anchor point (<code>null</code> permitted). * @param parentState the state from the parent plot, if there is one. * @param info collects info about the drawing. */ public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) { // adjust for insets... RectangleInsets insets = getInsets(); insets.trim(area); if (info != null) { info.setPlotArea(area); info.setDataArea(area); } drawBackground(g2, area); drawOutline(g2, area); Shape savedClip = g2.getClip(); g2.clip(area); Composite originalComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getForegroundAlpha())); if (!DatasetUtilities.isEmptyOrNull(this.dataset)) { int seriesCount = 0, catCount = 0; if (this.dataExtractOrder == TableOrder.BY_ROW) { seriesCount = this.dataset.getRowCount(); catCount = this.dataset.getColumnCount(); } else { seriesCount = this.dataset.getColumnCount(); catCount = this.dataset.getRowCount(); } // ensure we have origin and maximum value for each axis ensureBoundaryValues(seriesCount, catCount); // Next, setup the plot area // adjust the plot area by the interior spacing value double gapHorizontal = area.getWidth() * getInteriorGap(); double gapVertical = area.getHeight() * getInteriorGap(); double X = area.getX() + gapHorizontal / 2; double Y = area.getY() + gapVertical / 2; double W = area.getWidth() - gapHorizontal; double H = area.getHeight() - gapVertical; double headW = area.getWidth() * this.headPercent; double headH = area.getHeight() * this.headPercent; // make the chart area a square double min = Math.min(W, H) / 2; X = (X + X + W) / 2 - min; Y = (Y + Y + H) / 2 - min; W = 2 * min; H = 2 * min; Point2D centre = new Point2D.Double(X + W / 2, Y + H / 2); Rectangle2D radarArea = new Rectangle2D.Double(X, Y, W, H); // draw the axis and category label for (int cat = 0; cat < catCount; cat++) { double angle = getStartAngle() + (getDirection().getFactor() * cat * 360 / catCount); Point2D endPoint = getWebPoint(radarArea, angle, 1); // 1 = end of axis Line2D line = new Line2D.Double(centre, endPoint); g2.setPaint(this.axisLinePaint); g2.setStroke(this.axisLineStroke); g2.draw(line); if (isAxisTickVisible()) { drawTicks(g2, radarArea, angle, cat); } drawLabel(g2, area, radarArea, 0.0, cat, angle, 360.0 / catCount); } // Now actually plot each of the series polygons.. for (int series = 0; series < seriesCount; series++) { drawRadarPoly(g2, radarArea, centre, info, series, catCount, headH, headW); } } else { drawNoDataMessage(g2, area); } g2.setClip(savedClip); g2.setComposite(originalComposite); drawOutline(g2, area); }