List of usage examples for org.jfree.chart.plot CategoryPlot draw
@Override public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo state)
From source file:org.n52.oxf.render.sos.AnimatedMapChartRenderer4OnePhenomenon.java
/** * // ww w .j a va 2s .c o m * @param observationCollection * the observations belonging to the timeStamp (frame) which shall be rendered * @param screenW * @param screenH * @param bbox * @return */ protected Image renderFrame(ITimePosition timePos, int screenW, int screenH, IBoundingBox bbox, Set<OXFFeature> featuresWithCharts, ObservationSeriesCollection tupleFinder) { ContextBoundingBox contextBBox = new ContextBoundingBox(bbox); BufferedImage image = new BufferedImage(screenW, screenH, BufferedImage.TYPE_INT_RGB); Graphics2D g = image.createGraphics(); // draw white background: g.setColor(Color.WHITE); g.fillRect(0, 0, screenW, screenH); for (OXFFeature chartFeature : featuresWithCharts) { // // create Plot for each "chart feature" and add it to the plotArray: // CategoryPlot plot = renderFoiBarChart(chartFeature.getID(), timePos.toString(), tupleFinder.getTuple(chartFeature, timePos)); // // draw the plots into the image at the georeferenced position of the corresponding chartFeature: // Point pRealWorld = (Point) chartFeature.getGeometry(); java.awt.Point pScreen = ContextBoundingBox.realworld2Screen(contextBBox.getActualBBox(), screenW, screenH, new Point2D.Double(pRealWorld.getCoordinate().x, pRealWorld.getCoordinate().y)); plot.getRangeAxis(0).setRange((Double) tupleFinder.getMinimum(0), (Double) tupleFinder.getMaximum(0)); plot.draw(g, new Rectangle2D.Float(pScreen.x + X_SHIFT + 10, pScreen.y + Y_SHIFT, CHART_WIDTH, CHART_HEIGHT), null, null, null); } return image; }
From source file:org.n52.oxf.render.sos.AnimatedMapBarChartRenderer.java
protected Image renderFrame(ITimePosition[] sortedTimeArray, int currentTimeIndex, int screenW, int screenH, IBoundingBox bbox, Set<OXFFeature> featuresWithCharts, ObservationSeriesCollection tupleFinder) { ContextBoundingBox contextBBox = new ContextBoundingBox(bbox); BufferedImage image = new BufferedImage(screenW, screenH, BufferedImage.TYPE_INT_RGB); Graphics2D g = image.createGraphics(); // draw white background: g.setColor(Color.WHITE);// w w w.j a va 2 s. c om g.fillRect(0, 0, screenW, screenH); g.setColor(Color.BLACK); ITimePosition currentTimePos = sortedTimeArray[currentTimeIndex]; for (OXFFeature chartFeature : featuresWithCharts) { // // create Plot for each "chart feature" and add it to the cache: // if (!chartCache.contains(currentTimePos, chartFeature)) { // if there is a data tuple for the current time position -> create a new plot if (tupleFinder.getTuple(chartFeature, currentTimePos) != null) { CategoryPlot plot = drawChart4FOI(chartFeature.getID(), currentTimePos.toString(), tupleFinder.getTuple(chartFeature, currentTimePos)); chartCache.add(currentTimePos, chartFeature, plot); } } CategoryPlot plot = (CategoryPlot) chartCache.get(currentTimePos, chartFeature); // if there wasn't a plot for the current time position go backwards through the sortedTimeArray and take the most recent one: int j = currentTimeIndex - 1; while (plot == null && j >= 0) { plot = (CategoryPlot) chartCache.get(sortedTimeArray[j], chartFeature); j--; } // // draw the plots into the image at the georeferenced position of the corresponding chartFeature: // Point pRealWorld = (Point) chartFeature.getGeometry(); java.awt.Point pScreen = ContextBoundingBox.realworld2Screen(contextBBox.getActualBBox(), screenW, screenH, new Point2D.Double(pRealWorld.getCoordinate().x, pRealWorld.getCoordinate().y)); // if an appropriate plot was found -> draw it if (plot != null) { for (int i = 0; i < observedProperties.length; i++) { plot.getRangeAxis(i).setRange((Double) tupleFinder.getMinimum(i) - 5, (Double) tupleFinder.getMaximum(i)); if (i > 0) { plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); } } plot.draw(g, new Rectangle2D.Float(pScreen.x + X_SHIFT + 10, pScreen.y + Y_SHIFT, CHART_WIDTH + observedProperties.length * CHART_WIDTH_MULTIPLICATOR, CHART_HEIGHT), null, null, null); } // otherwise draw "no data available" else { g.drawString("No data available", pScreen.x + X_SHIFT, pScreen.y + Y_SHIFT); } // draw point of feature: g.fillOval(pScreen.x - (FeatureGeometryRenderer.DOT_SIZE_POINT / 2), pScreen.y - (FeatureGeometryRenderer.DOT_SIZE_POINT / 2), FeatureGeometryRenderer.DOT_SIZE_POINT, FeatureGeometryRenderer.DOT_SIZE_POINT); } return image; }