List of usage examples for java.awt BasicStroke CAP_ROUND
int CAP_ROUND
To view the source code for java.awt BasicStroke CAP_ROUND.
Click Source Link
From source file:org.n52.server.io.render.DiagramRenderer.java
/** * <pre>/* www .j ava 2 s.c om*/ * dataset := associated to one range-axis; * corresponds to one observedProperty; * may contain multiple series; * series := corresponds to a time series for one foi * </pre> * * . * * @param entireCollMap * the entire coll map * @param options * the options * @param begin * the begin * @param end * the end * @param compress * @return the j free chart */ public JFreeChart renderChart(Map<String, OXFFeatureCollection> entireCollMap, DesignOptions options, Calendar begin, Calendar end, boolean compress) { DesignDescriptionList designDescriptions = buildUpDesignDescriptionList(options); /*** FIRST RUN ***/ JFreeChart chart = initializeTimeSeriesChart(); chart.setBackgroundPaint(Color.white); if (!this.isOverview) { chart.addSubtitle(new TextTitle(ConfigurationContext.COPYRIGHT, new Font(LABEL_FONT, Font.PLAIN, 9), Color.black, RectangleEdge.BOTTOM, HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, new RectangleInsets(0, 0, 20, 20))); } XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(2.0, 2.0, 2.0, 2.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setDomainGridlinesVisible(options.getGrid()); plot.setRangeGridlinesVisible(options.getGrid()); // add additional datasets: DateAxis dateAxis = (DateAxis) plot.getDomainAxis(); dateAxis.setRange(begin.getTime(), end.getTime()); dateAxis.setDateFormatOverride(new SimpleDateFormat()); dateAxis.setTimeZone(end.getTimeZone()); // add all axes String[] phenomenaIds = options.getAllPhenomenIds(); // all the axis indices to map them later HashMap<String, Integer> axes = new HashMap<String, Integer>(); for (int i = 0; i < phenomenaIds.length; i++) { axes.put(phenomenaIds[i], i); plot.setRangeAxis(i, new NumberAxis(phenomenaIds[i])); } // list range markers ArrayList<ValueMarker> referenceMarkers = new ArrayList<ValueMarker>(); HashMap<String, double[]> referenceBounds = new HashMap<String, double[]>(); // create all TS collections for (int i = 0; i < options.getProperties().size(); i++) { TimeseriesProperties prop = options.getProperties().get(i); String phenomenonId = prop.getPhenomenon(); TimeSeriesCollection dataset = createDataset(entireCollMap, prop, phenomenonId, compress); dataset.setGroup(new DatasetGroup(prop.getTimeseriesId())); XYDataset additionalDataset = dataset; NumberAxis axe = (NumberAxis) plot.getRangeAxis(axes.get(phenomenonId)); if (this.isOverview) { axe.setAutoRange(true); axe.setAutoRangeIncludesZero(false); } else if (prop.getAxisUpperBound() == prop.getAxisLowerBound() || prop.isAutoScale()) { if (prop.isZeroScaled()) { axe.setAutoRangeIncludesZero(true); } else { axe.setAutoRangeIncludesZero(false); } } else { if (prop.isZeroScaled()) { if (axe.getUpperBound() < prop.getAxisUpperBound()) { axe.setUpperBound(prop.getAxisUpperBound()); } if (axe.getLowerBound() > prop.getAxisLowerBound()) { axe.setLowerBound(prop.getAxisLowerBound()); } } else { axe.setRange(prop.getAxisLowerBound(), prop.getAxisUpperBound()); axe.setAutoRangeIncludesZero(false); } } plot.setDataset(i, additionalDataset); plot.mapDatasetToRangeAxis(i, axes.get(phenomenonId)); // set bounds new for reference values if (!referenceBounds.containsKey(phenomenonId)) { double[] bounds = new double[] { axe.getLowerBound(), axe.getUpperBound() }; referenceBounds.put(phenomenonId, bounds); } else { double[] bounds = referenceBounds.get(phenomenonId); if (bounds[0] >= axe.getLowerBound()) { bounds[0] = axe.getLowerBound(); } if (bounds[1] <= axe.getUpperBound()) { bounds[1] = axe.getUpperBound(); } } double[] bounds = referenceBounds.get(phenomenonId); for (String string : prop.getReferenceValues()) { if (prop.getRefValue(string).show()) { Double value = prop.getRefValue(string).getValue(); if (value <= bounds[0]) { bounds[0] = value; } else if (value >= bounds[1]) { bounds[1] = value; } } } Axis axis = prop.getAxis(); if (axis == null) { axis = new Axis(axe.getUpperBound(), axe.getLowerBound()); } else if (prop.isAutoScale()) { axis.setLowerBound(axe.getLowerBound()); axis.setUpperBound(axe.getUpperBound()); axis.setMaxY(axis.getMaxY()); axis.setMinY(axis.getMinY()); } prop.setAxisData(axis); this.axisMapping.put(prop.getTimeseriesId(), axis); for (String string : prop.getReferenceValues()) { if (prop.getRefValue(string).show()) { referenceMarkers.add(new ValueMarker(prop.getRefValue(string).getValue(), Color.decode(prop.getRefValue(string).getColor()), new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f))); } } plot.mapDatasetToRangeAxis(i, axes.get(phenomenonId)); } for (ValueMarker valueMarker : referenceMarkers) { plot.addRangeMarker(valueMarker); } // show actual time ValueMarker nowMarker = new ValueMarker(System.currentTimeMillis(), Color.orange, new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f)); plot.addDomainMarker(nowMarker); if (!this.isOverview) { Iterator<Entry<String, double[]>> iterator = referenceBounds.entrySet().iterator(); while (iterator.hasNext()) { Entry<String, double[]> boundsEntry = iterator.next(); String phenId = boundsEntry.getKey(); NumberAxis axe = (NumberAxis) plot.getRangeAxis(axes.get(phenId)); axe.setAutoRange(true); // add a margin double marginOffset = (boundsEntry.getValue()[1] - boundsEntry.getValue()[0]) / 25; boundsEntry.getValue()[0] -= marginOffset; boundsEntry.getValue()[1] += marginOffset; axe.setRange(boundsEntry.getValue()[0], boundsEntry.getValue()[1]); } } /**** SECOND RUN ***/ // set domain axis labels: plot.getDomainAxis().setLabelFont(label); plot.getDomainAxis().setLabelPaint(LABEL_COLOR); plot.getDomainAxis().setTickLabelFont(tickLabelDomain); plot.getDomainAxis().setTickLabelPaint(LABEL_COLOR); plot.getDomainAxis().setLabel(designDescriptions.getDomainAxisLabel()); // define the design for each series: for (int datasetIndex = 0; datasetIndex < plot.getDatasetCount(); datasetIndex++) { TimeSeriesCollection dataset = (TimeSeriesCollection) plot.getDataset(datasetIndex); for (int seriesIndex = 0; seriesIndex < dataset.getSeriesCount(); seriesIndex++) { String timeseriesId = (String) dataset.getSeries(seriesIndex).getKey(); RenderingDesign dd = designDescriptions.get(timeseriesId); if (dd != null) { // LINESTYLE: String lineStyle = dd.getLineStyle(); int width = dd.getLineWidth(); if (this.isOverview) { width = width / 2; width = (width == 0) ? 1 : width; } // "1" is lineStyle "line" if (lineStyle.equalsIgnoreCase(LINE)) { XYLineAndShapeRenderer ren = new XYLineAndShapeRenderer(true, false); ren.setStroke(new BasicStroke(width)); plot.setRenderer(datasetIndex, ren); } // "2" is lineStyle "area" else if (lineStyle.equalsIgnoreCase(AREA)) { plot.setRenderer(datasetIndex, new XYAreaRenderer()); } // "3" is lineStyle "dotted" else if (lineStyle.equalsIgnoreCase(DOTTED)) { XYLineAndShapeRenderer ren = new XYLineAndShapeRenderer(false, true); ren.setShape(new Ellipse2D.Double(-width, -width, 2 * width, 2 * width)); plot.setRenderer(datasetIndex, ren); } // "4" is dashed else if (lineStyle.equalsIgnoreCase("4")) { // dashed XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false); renderer.setSeriesStroke(0, new BasicStroke(width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 4.0f * width, 4.0f * width }, 0.0f)); plot.setRenderer(datasetIndex, renderer); } else if (lineStyle.equalsIgnoreCase("5")) { // lines and dots XYLineAndShapeRenderer ren = new XYLineAndShapeRenderer(true, true); int thickness = 2 * width; ren.setShape(new Ellipse2D.Double(-width, -width, thickness, thickness)); ren.setStroke(new BasicStroke(width)); plot.setRenderer(datasetIndex, ren); } else { // default is lineStyle "line" plot.setRenderer(datasetIndex, new XYLineAndShapeRenderer(true, false)); } plot.getRenderer(datasetIndex).setSeriesPaint(seriesIndex, dd.getColor()); // plot.getRenderer(datasetIndex).setShapesVisible(true); XYToolTipGenerator toolTipGenerator = StandardXYToolTipGenerator.getTimeSeriesInstance(); XYURLGenerator urlGenerator = new MetadataInURLGenerator(designDescriptions); plot.getRenderer(datasetIndex).setBaseToolTipGenerator(toolTipGenerator); plot.getRenderer(datasetIndex).setURLGenerator(urlGenerator); // GRID: // PROBLEM: JFreeChart only allows to switch the grid on/off // for the whole XYPlot. And the // grid will always be displayed for the first series in the // plot. I'll always show the // grid. // --> plot.setDomainGridlinesVisible(visible) // RANGE AXIS LABELS: if (isOverview) { plot.getRangeAxisForDataset(datasetIndex).setTickLabelsVisible(false); plot.getRangeAxisForDataset(datasetIndex).setTickMarksVisible(false); plot.getRangeAxisForDataset(datasetIndex).setVisible(false); } else { plot.getRangeAxisForDataset(datasetIndex).setLabelFont(label); plot.getRangeAxisForDataset(datasetIndex).setLabelPaint(LABEL_COLOR); plot.getRangeAxisForDataset(datasetIndex).setTickLabelFont(tickLabelDomain); plot.getRangeAxisForDataset(datasetIndex).setTickLabelPaint(LABEL_COLOR); StringBuilder unitOfMeasure = new StringBuilder(); unitOfMeasure.append(dd.getPhenomenon().getLabel()); String uomLabel = dd.getUomLabel(); if (uomLabel != null && !uomLabel.isEmpty()) { unitOfMeasure.append(" (").append(uomLabel).append(")"); } plot.getRangeAxisForDataset(datasetIndex).setLabel(unitOfMeasure.toString()); } } } } return chart; }
From source file:Applet.EmbeddedChart.java
/** * Creates a chart.//from w w w.j ava2 s. com * * @param dataset * the data for the chart. * * @return a chart. */ private JFreeChart createChart(final XYDataset dataset, String title, boolean gofr) { // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart(null, // chart // title "Radial Distance, r/\u03c3", // x axis label title, // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); chart.getLegend().setPosition(RectangleEdge.RIGHT); // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); // get a reference to the plot for further customisation... final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); XYTitleAnnotation xyta = new XYTitleAnnotation(0.98, 0.98, chart.getLegend(), RectangleAnchor.TOP_RIGHT); chart.removeLegend(); plot.addAnnotation(xyta); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false); for (int i = 0; i < 2; i++) { renderer.setSeriesPaint(i * 6 + 0, new Color(255, 0, 0)); renderer.setSeriesPaint(i * 6 + 1, new Color(0, 0, 255)); renderer.setSeriesPaint(i * 6 + 2, new Color(0, 139, 0)); renderer.setSeriesPaint(i * 6 + 3, new Color(255, 165, 0)); renderer.setSeriesPaint(i * 6 + 4, new Color(255, 0, 255)); renderer.setSeriesPaint(i * 6 + 5, new Color(0, 0, 0)); renderer.setSeriesStroke(i * 6 + 0, new BasicStroke(1.3f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f, new float[] { 10.0f }, 0.0f)); renderer.setSeriesStroke(i * 6 + 1, new BasicStroke(1.3f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f, new float[] { 50.0f, 2.0f }, 0.0f)); renderer.setSeriesStroke(i * 6 + 2, new BasicStroke(1.3f, BasicStroke.JOIN_ROUND, BasicStroke.JOIN_MITER, 10.0f, new float[] { 30.0f, 1.0f, 1.0f }, 0.0f)); renderer.setSeriesStroke(i * 6 + 3, new BasicStroke(1.3f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 10.0f, new float[] { 1.0f, 3.0f }, 0.0f)); renderer.setSeriesStroke(i * 6 + 4, new BasicStroke(1.3f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f, new float[] { 1.0f, 2.0f, 3.0f, 4.0f }, 0.0f)); renderer.setSeriesStroke(i * 6 + 5, new BasicStroke(1.3f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f, new float[] { 5.0f, 1.0f, 20.0f, 1.0f }, 0.0f)); } plot.setRenderer(renderer); return chart; }
From source file:org.n52.server.sos.render.DiagramRenderer.java
/** * <pre>//from www .j a v a 2 s. co m * dataset := associated to one range-axis; * corresponds to one observedProperty; * may contain multiple series; * series := corresponds to a time series for one foi * </pre> * * . * * @param entireCollMap * the entire coll map * @param options * the options * @param begin * the begin * @param end * the end * @param compress * @return the j free chart */ public JFreeChart renderChart(Map<String, OXFFeatureCollection> entireCollMap, DesignOptions options, Calendar begin, Calendar end, boolean compress) { DesignDescriptionList designDescriptions = buildUpDesignDescriptionList(options); /*** FIRST RUN ***/ JFreeChart chart = initializeTimeSeriesChart(); chart.setBackgroundPaint(Color.white); if (!this.isOverview) { chart.addSubtitle(new TextTitle(ConfigurationContext.COPYRIGHT, new Font(LABEL_FONT, Font.PLAIN, 9), Color.black, RectangleEdge.BOTTOM, HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, new RectangleInsets(0, 0, 20, 20))); } XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(2.0, 2.0, 2.0, 2.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setDomainGridlinesVisible(options.getGrid()); plot.setRangeGridlinesVisible(options.getGrid()); // add additional datasets: DateAxis dateAxis = (DateAxis) plot.getDomainAxis(); dateAxis.setRange(begin.getTime(), end.getTime()); dateAxis.setDateFormatOverride(new SimpleDateFormat()); // add all axes String[] phenomenaIds = options.getAllPhenomenIds(); // all the axis indices to map them later HashMap<String, Integer> axes = new HashMap<String, Integer>(); for (int i = 0; i < phenomenaIds.length; i++) { axes.put(phenomenaIds[i], i); plot.setRangeAxis(i, new NumberAxis(phenomenaIds[i])); } // list range markers ArrayList<ValueMarker> referenceMarkers = new ArrayList<ValueMarker>(); HashMap<String, double[]> referenceBounds = new HashMap<String, double[]>(); // create all TS collections for (int i = 0; i < options.getProperties().size(); i++) { TimeseriesProperties prop = options.getProperties().get(i); String phenomenonId = prop.getPhenomenon(); TimeSeriesCollection dataset = createDataset(entireCollMap, prop, phenomenonId, compress); dataset.setGroup(new DatasetGroup(prop.getTimeseriesId())); XYDataset additionalDataset = dataset; NumberAxis axe = (NumberAxis) plot.getRangeAxis(axes.get(phenomenonId)); if (this.isOverview) { axe.setAutoRange(true); axe.setAutoRangeIncludesZero(false); } else if (prop.getAxisUpperBound() == prop.getAxisLowerBound() || prop.isAutoScale()) { if (prop.isZeroScaled()) { axe.setAutoRangeIncludesZero(true); } else { axe.setAutoRangeIncludesZero(false); } } else { if (prop.isZeroScaled()) { if (axe.getUpperBound() < prop.getAxisUpperBound()) { axe.setUpperBound(prop.getAxisUpperBound()); } if (axe.getLowerBound() > prop.getAxisLowerBound()) { axe.setLowerBound(prop.getAxisLowerBound()); } } else { axe.setRange(prop.getAxisLowerBound(), prop.getAxisUpperBound()); axe.setAutoRangeIncludesZero(false); } } plot.setDataset(i, additionalDataset); plot.mapDatasetToRangeAxis(i, axes.get(phenomenonId)); // set bounds new for reference values if (!referenceBounds.containsKey(phenomenonId)) { double[] bounds = new double[] { axe.getLowerBound(), axe.getUpperBound() }; referenceBounds.put(phenomenonId, bounds); } else { double[] bounds = referenceBounds.get(phenomenonId); if (bounds[0] >= axe.getLowerBound()) { bounds[0] = axe.getLowerBound(); } if (bounds[1] <= axe.getUpperBound()) { bounds[1] = axe.getUpperBound(); } } double[] bounds = referenceBounds.get(phenomenonId); for (String string : prop.getReferenceValues()) { if (prop.getRefValue(string).show()) { Double value = prop.getRefValue(string).getValue(); if (value <= bounds[0]) { bounds[0] = value; } else if (value >= bounds[1]) { bounds[1] = value; } } } Axis axis = prop.getAxis(); if (axis == null) { axis = new Axis(axe.getUpperBound(), axe.getLowerBound()); } else if (prop.isAutoScale()) { axis.setLowerBound(axe.getLowerBound()); axis.setUpperBound(axe.getUpperBound()); axis.setMaxY(axis.getMaxY()); axis.setMinY(axis.getMinY()); } prop.setAxisData(axis); this.axisMapping.put(prop.getTimeseriesId(), axis); for (String string : prop.getReferenceValues()) { if (prop.getRefValue(string).show()) { referenceMarkers.add(new ValueMarker(prop.getRefValue(string).getValue(), Color.decode(prop.getRefValue(string).getColor()), new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f))); } } plot.mapDatasetToRangeAxis(i, axes.get(phenomenonId)); } for (ValueMarker valueMarker : referenceMarkers) { plot.addRangeMarker(valueMarker); } // show actual time ValueMarker nowMarker = new ValueMarker(System.currentTimeMillis(), Color.orange, new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f)); plot.addDomainMarker(nowMarker); if (!this.isOverview) { Iterator<Entry<String, double[]>> iterator = referenceBounds.entrySet().iterator(); while (iterator.hasNext()) { Entry<String, double[]> boundsEntry = iterator.next(); String phenId = boundsEntry.getKey(); NumberAxis axe = (NumberAxis) plot.getRangeAxis(axes.get(phenId)); axe.setAutoRange(true); // add a margin double marginOffset = (boundsEntry.getValue()[1] - boundsEntry.getValue()[0]) / 25; boundsEntry.getValue()[0] -= marginOffset; boundsEntry.getValue()[1] += marginOffset; axe.setRange(boundsEntry.getValue()[0], boundsEntry.getValue()[1]); } } /**** SECOND RUN ***/ // set domain axis labels: plot.getDomainAxis().setLabelFont(label); plot.getDomainAxis().setLabelPaint(LABEL_COLOR); plot.getDomainAxis().setTickLabelFont(tickLabelDomain); plot.getDomainAxis().setTickLabelPaint(LABEL_COLOR); plot.getDomainAxis().setLabel(designDescriptions.getDomainAxisLabel()); // define the design for each series: for (int datasetIndex = 0; datasetIndex < plot.getDatasetCount(); datasetIndex++) { TimeSeriesCollection dataset = (TimeSeriesCollection) plot.getDataset(datasetIndex); for (int seriesIndex = 0; seriesIndex < dataset.getSeriesCount(); seriesIndex++) { String timeseriesId = (String) dataset.getSeries(seriesIndex).getKey(); RenderingDesign dd = designDescriptions.get(timeseriesId); if (dd != null) { // LINESTYLE: String lineStyle = dd.getLineStyle(); int width = dd.getLineWidth(); if (this.isOverview) { width = width / 2; width = (width == 0) ? 1 : width; } // "1" is lineStyle "line" if (lineStyle.equalsIgnoreCase(LINE)) { XYLineAndShapeRenderer ren = new XYLineAndShapeRenderer(true, false); ren.setStroke(new BasicStroke(width)); plot.setRenderer(datasetIndex, ren); } // "2" is lineStyle "area" else if (lineStyle.equalsIgnoreCase(AREA)) { plot.setRenderer(datasetIndex, new XYAreaRenderer()); } // "3" is lineStyle "dotted" else if (lineStyle.equalsIgnoreCase(DOTTED)) { XYLineAndShapeRenderer ren = new XYLineAndShapeRenderer(false, true); ren.setShape(new Ellipse2D.Double(-width, -width, 2 * width, 2 * width)); plot.setRenderer(datasetIndex, ren); } // "4" is dashed else if (lineStyle.equalsIgnoreCase("4")) { XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false); renderer.setSeriesStroke(0, new BasicStroke(width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 4.0f * width, 4.0f * width }, 0.0f)); plot.setRenderer(datasetIndex, renderer); } else if (lineStyle.equalsIgnoreCase("5")) { // lines and dots XYLineAndShapeRenderer ren = new XYLineAndShapeRenderer(true, true); int thickness = 2 * width; ren.setShape(new Ellipse2D.Double(-width, -width, thickness, thickness)); ren.setStroke(new BasicStroke(width)); plot.setRenderer(datasetIndex, ren); } else { // default is lineStyle "line" plot.setRenderer(datasetIndex, new XYLineAndShapeRenderer(true, false)); } plot.getRenderer(datasetIndex).setSeriesPaint(seriesIndex, dd.getColor()); // plot.getRenderer(datasetIndex).setShapesVisible(true); XYToolTipGenerator toolTipGenerator = StandardXYToolTipGenerator.getTimeSeriesInstance(); XYURLGenerator urlGenerator = new MetadataInURLGenerator(designDescriptions); plot.getRenderer(datasetIndex).setBaseToolTipGenerator(toolTipGenerator); plot.getRenderer(datasetIndex).setURLGenerator(urlGenerator); // GRID: // PROBLEM: JFreeChart only allows to switch the grid on/off // for the whole XYPlot. And the // grid will always be displayed for the first series in the // plot. I'll always show the // grid. // --> plot.setDomainGridlinesVisible(visible) // RANGE AXIS LABELS: if (isOverview) { plot.getRangeAxisForDataset(datasetIndex).setTickLabelsVisible(false); plot.getRangeAxisForDataset(datasetIndex).setTickMarksVisible(false); plot.getRangeAxisForDataset(datasetIndex).setVisible(false); } else { plot.getRangeAxisForDataset(datasetIndex).setLabelFont(label); plot.getRangeAxisForDataset(datasetIndex).setLabelPaint(LABEL_COLOR); plot.getRangeAxisForDataset(datasetIndex).setTickLabelFont(tickLabelDomain); plot.getRangeAxisForDataset(datasetIndex).setTickLabelPaint(LABEL_COLOR); StringBuilder unitOfMeasure = new StringBuilder(); unitOfMeasure.append(dd.getPhenomenon().getLabel()); String uomLabel = dd.getUomLabel(); if (uomLabel != null && !uomLabel.isEmpty()) { unitOfMeasure.append(" (").append(uomLabel).append(")"); } plot.getRangeAxisForDataset(datasetIndex).setLabel(unitOfMeasure.toString()); } } } } return chart; }
From source file:com.graphhopper.jsprit.analysis.toolbox.Plotter.java
private XYItemRenderer getShipmentRenderer(XYSeriesCollection shipments) { XYItemRenderer shipmentsRenderer = new XYLineAndShapeRenderer(true, false); // Shapes only for (int i = 0; i < shipments.getSeriesCount(); i++) { shipmentsRenderer.setSeriesPaint(i, Color.DARK_GRAY); shipmentsRenderer.setSeriesStroke(i, new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.f, new float[] { 4.0f, 4.0f }, 0.0f)); }//from ww w . j a va 2s . c o m return shipmentsRenderer; }
From source file:org.drools.planner.benchmark.core.statistic.PlannerStatistic.java
private void writeScalabilitySummaryChart() { NumberAxis xAxis = new NumberAxis("Problem scale"); NumberAxis yAxis = new NumberAxis("Time spend"); yAxis.setNumberFormatOverride(new MillisecondsSpendNumberFormat()); XYPlot plot = new XYPlot(null, xAxis, yAxis, null); int seriesIndex = 0; for (SolverBenchmark solverBenchmark : plannerBenchmark.getSolverBenchmarkList()) { String solverLabel = solverBenchmark.getName(); if (solverBenchmark.isRankingBest()) { solverLabel += " (winner)"; }//from w w w .j a va 2 s. c om XYSeries series = new XYSeries(solverLabel); for (SingleBenchmark singleBenchmark : solverBenchmark.getSingleBenchmarkList()) { if (singleBenchmark.isSuccess()) { long problemScale = singleBenchmark.getProblemScale(); long timeMillisSpend = singleBenchmark.getTimeMillisSpend(); series.add((Long) problemScale, (Long) timeMillisSpend); } } XYSeriesCollection seriesCollection = new XYSeriesCollection(); seriesCollection.addSeries(series); plot.setDataset(seriesIndex, seriesCollection); XYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES_AND_LINES); // Use dashed line renderer.setSeriesStroke(0, new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 2.0f, 6.0f }, 0.0f)); plot.setRenderer(seriesIndex, renderer); seriesIndex++; } plot.setOrientation(PlotOrientation.VERTICAL); JFreeChart chart = new JFreeChart("Scalability summary (lower is better)", JFreeChart.DEFAULT_TITLE_FONT, plot, true); BufferedImage chartImage = chart.createBufferedImage(1024, 768); scalabilitySummaryFile = new File(plannerBenchmark.getBenchmarkReportDirectory(), "scalabilitySummary.png"); OutputStream out = null; try { out = new FileOutputStream(scalabilitySummaryFile); ImageIO.write(chartImage, "png", out); } catch (IOException e) { throw new IllegalArgumentException("Problem writing scalabilitySummaryFile: " + scalabilitySummaryFile, e); } finally { IOUtils.closeQuietly(out); } }
From source file:SWTGraphics2D.java
/** * Sets the stroke for this graphics context. For now, this implementation * only recognises the {@link BasicStroke} class. * * @param stroke the stroke (<code>null</code> not permitted). * * @see #getStroke()/*from ww w. j a v a2s . c om*/ */ public void setStroke(Stroke stroke) { if (stroke instanceof BasicStroke) { BasicStroke bs = (BasicStroke) stroke; // linewidth this.gc.setLineWidth((int) bs.getLineWidth()); // line join switch (bs.getLineJoin()) { case BasicStroke.JOIN_BEVEL: this.gc.setLineJoin(SWT.JOIN_BEVEL); break; case BasicStroke.JOIN_MITER: this.gc.setLineJoin(SWT.JOIN_MITER); break; case BasicStroke.JOIN_ROUND: this.gc.setLineJoin(SWT.JOIN_ROUND); break; } // line cap switch (bs.getEndCap()) { case BasicStroke.CAP_BUTT: this.gc.setLineCap(SWT.CAP_FLAT); break; case BasicStroke.CAP_ROUND: this.gc.setLineCap(SWT.CAP_ROUND); break; case BasicStroke.CAP_SQUARE: this.gc.setLineCap(SWT.CAP_SQUARE); break; } // set the line style to solid by default this.gc.setLineStyle(SWT.LINE_SOLID); // apply dash style if any float[] dashes = bs.getDashArray(); if (dashes != null) { int[] swtDashes = new int[dashes.length]; for (int i = 0; i < swtDashes.length; i++) { swtDashes[i] = (int) dashes[i]; } this.gc.setLineDash(swtDashes); } } else { throw new RuntimeException("Can only handle 'Basic Stroke' at present."); } }
From source file:business.ImageManager.java
private void doDrawPathOrdemArmy(Graphics2D big, Point ori, Point dest, Color color) { //setup para os rastros big.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); big.setComposite(alcom);/*from w ww. j a v a2s . c o m*/ big.setStroke(new BasicStroke(3f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1f, new float[] { 3f, 5f, 7f, 5f, 11f, 5f, 15f, 5f, 21f, 5f, 27f, 5f, 33f, 5f }, 0f)); big.setColor(color); //draw path Path2D.Double path = new Path2D.Double(); path.moveTo(ori.getX(), ori.getY()); path.curveTo(dest.getX() + 10, dest.getY() - 10, dest.getX() - 10, dest.getY() + 10, dest.getX(), dest.getY()); //draw on graph big.draw(path); }
From source file:com.vgi.mafscaling.Rescale.java
private void createGraghPanel(JPanel dataPanel) { JFreeChart chart = ChartFactory.createScatterPlot(null, null, null, null, PlotOrientation.VERTICAL, false, true, false);/*w ww . j ava 2s . c o m*/ chart.setBorderVisible(true); mafChartPanel = new MafChartPanel(chart, this); GridBagConstraints gbl_chartPanel = new GridBagConstraints(); gbl_chartPanel.anchor = GridBagConstraints.PAGE_START; gbl_chartPanel.insets = insets0; gbl_chartPanel.fill = GridBagConstraints.BOTH; gbl_chartPanel.weightx = 1.0; gbl_chartPanel.weighty = 1.0; gbl_chartPanel.gridx = 0; gbl_chartPanel.gridy = 2; dataPanel.add(mafChartPanel.getChartPanel(), gbl_chartPanel); XYSplineRenderer lineRenderer = new XYSplineRenderer(3); lineRenderer.setUseFillPaint(true); lineRenderer.setBaseToolTipGenerator( new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new DecimalFormat("0.00"), new DecimalFormat("0.00"))); Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, null, 0.0f); lineRenderer.setSeriesStroke(0, stroke); lineRenderer.setSeriesStroke(1, stroke); lineRenderer.setSeriesPaint(0, new Color(201, 0, 0)); lineRenderer.setSeriesPaint(1, new Color(0, 0, 255)); lineRenderer.setSeriesShape(0, ShapeUtilities.createDiamond((float) 2.5)); lineRenderer.setSeriesShape(1, ShapeUtilities.createUpTriangle((float) 2.5)); ValueAxis mafvDomain = new NumberAxis(XAxisName); ValueAxis mafgsRange = new NumberAxis(YAxisName); XYSeriesCollection lineDataset = new XYSeriesCollection(); lineDataset.addSeries(currMafData); lineDataset.addSeries(corrMafData); XYPlot plot = chart.getXYPlot(); plot.setRangePannable(true); plot.setDomainPannable(true); plot.setDomainGridlinePaint(Color.DARK_GRAY); plot.setRangeGridlinePaint(Color.DARK_GRAY); plot.setBackgroundPaint(new Color(224, 224, 224)); plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD); plot.setDataset(0, lineDataset); plot.setRenderer(0, lineRenderer); plot.setDomainAxis(0, mafvDomain); plot.setRangeAxis(0, mafgsRange); plot.mapDatasetToDomainAxis(0, 0); plot.mapDatasetToRangeAxis(0, 0); LegendTitle legend = new LegendTitle(plot.getRenderer()); legend.setItemFont(new Font("Arial", 0, 10)); legend.setPosition(RectangleEdge.TOP); chart.addLegend(legend); }
From source file:org.drools.planner.benchmark.core.statistic.BenchmarkReport.java
private void writeScalabilitySummaryChart() { NumberAxis xAxis = new NumberAxis("Problem scale"); xAxis.setNumberFormatOverride(NumberFormat.getInstance(locale)); NumberAxis yAxis = new NumberAxis("Time spend"); yAxis.setNumberFormatOverride(new MillisecondsSpendNumberFormat(locale)); XYPlot plot = new XYPlot(null, xAxis, yAxis, null); int seriesIndex = 0; for (SolverBenchmark solverBenchmark : plannerBenchmark.getSolverBenchmarkList()) { String solverLabel = solverBenchmark.getNameWithFavoriteSuffix(); XYSeries series = new XYSeries(solverLabel); for (SingleBenchmark singleBenchmark : solverBenchmark.getSingleBenchmarkList()) { if (singleBenchmark.isSuccess()) { long problemScale = singleBenchmark.getProblemBenchmark().getProblemScale(); long timeMillisSpend = singleBenchmark.getTimeMillisSpend(); series.add((Long) problemScale, (Long) timeMillisSpend); }/*from w w w .j av a2 s. c o m*/ } XYSeriesCollection seriesCollection = new XYSeriesCollection(); seriesCollection.addSeries(series); plot.setDataset(seriesIndex, seriesCollection); XYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES_AND_LINES); // Use dashed line renderer.setSeriesStroke(0, new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 2.0f, 6.0f }, 0.0f)); plot.setRenderer(seriesIndex, renderer); seriesIndex++; } plot.setOrientation(PlotOrientation.VERTICAL); JFreeChart chart = new JFreeChart("Scalability summary (lower is better)", JFreeChart.DEFAULT_TITLE_FONT, plot, true); scalabilitySummaryChartFile = writeChartToImageFile(chart, "scalabilitySummary"); }
From source file:business.ImageManager.java
private void doDrawPathOrdem(Graphics2D big, Point ori, Point dest, Color color) { //setup para os rastros big.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); big.setStroke(new BasicStroke(1.75f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1f, new float[] { 3f, 5f, 7f, 5f, 11f, 5f, 15f, 5f, 21f, 5f, 27f, 5f, 33f, 5f }, 0f)); big.setColor(color);/* w w w . j ava2 s .c o m*/ //draw path Path2D.Double path = new Path2D.Double(); path.moveTo(ori.getX(), ori.getY()); path.curveTo(dest.getX() - 20, dest.getY() + 20, dest.getX() + 20, dest.getY() - 20, dest.getX() + 12, dest.getY()); //path.lineTo(dest.getX(), dest.getY()); //draw on graph big.draw(path); }