List of usage examples for java.awt BasicStroke JOIN_ROUND
int JOIN_ROUND
To view the source code for java.awt BasicStroke JOIN_ROUND.
Click Source Link
From source file:edu.ku.brc.specify.plugins.ipadexporter.ChartHelper.java
/** * @param list/* w w w .ja v a 2 s . c om*/ * @param title * @param xAxisTitle * @param yAxisTitle * @param isVertical * @param width * @param height */ public JFreeChart createLineChart(final List<Object> list, final String title, final String xAxisTitle, final String yAxisTitle, final boolean isVertical, final int width, final int height) { DefaultCategoryDataset catDataSet = new DefaultCategoryDataset(); for (int i = 0; i < list.size(); i++) { Object xVal = list.get(i++); Object yVal = list.get(i); double xv = getDbl(xVal); numMin = Math.min(numMin, xv); numMax = Math.max(numMax, xv); catDataSet.addValue(getDbl(yVal), "X", xVal.toString()); } /*XYDataset dataset = createXYDataSet(list); JFreeChart chart = ChartFactory.createXYLineChart( title, // chart title xAxisTitle, // domain axis label yAxisTitle, // range axis label dataset, // data isVertical ? PlotOrientation.VERTICAL : PlotOrientation.HORIZONTAL, false, // include legend true, // tooltips? false // URLs? ); XYPlot xyplot = chart.getXYPlot(); NumberAxis numberAxis = (NumberAxis) xyplot.getDomainAxis(); numberAxis.setRange(numMin, numMax); //ValueAxis axis = xyplot.getDomainAxis(); //axis = xyplot.getRangeAxis(); //((NumberAxis) axis).setTickUnit(new NumberTickUnit(1)); //axis.setRange(1870,2010);*/ /* JFreeChart jfreechart = ChartFactory.createLineChart3D( title, xAxisTitle, yAxisTitle, catDataSet, PlotOrientation.VERTICAL, false, true, false); jfreechart.setBackgroundPaint(new Color(187, 187, 221)); CategoryPlot categoryplot = (CategoryPlot)jfreechart.getPlot(); NumberAxis numberaxis = (NumberAxis)categoryplot.getRangeAxis(); numberaxis.setAutoRangeIncludesZero(false); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); CategoryItemRenderer renderer = categoryplot.getRenderer(); renderer.setSeriesPaint(0, new Color(95, 158, 160)); renderer.setSeriesOutlinePaint(0, Color.DARK_GRAY); */ JFreeChart jfreechart = ChartFactory.createLineChart(title, xAxisTitle, yAxisTitle, catDataSet, PlotOrientation.VERTICAL, false, true, false); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setRangeGridlinePaint(Color.DARK_GRAY); categoryplot.setBackgroundPaint(null); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setAutoRangeIncludesZero(false); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); CategoryItemRenderer renderer = categoryplot.getRenderer(); renderer.setSeriesPaint(0, new Color(95, 158, 160)); renderer.setSeriesOutlinePaint(0, Color.DARK_GRAY); BasicStroke lineStroke = new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); renderer.setBaseStroke(lineStroke); renderer.setBaseOutlineStroke(lineStroke); renderer.setSeriesStroke(0, lineStroke); //renderer.setOutlineStroke(lineStroke); //renderer.setStroke(lineStroke); return jfreechart; }
From source file:net.imglib2.script.analysis.Histogram.java
static private final void setBackgroundDefault(final JFreeChart chart) { BasicStroke gridStroke = new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 2.0f, 1.0f }, 0.0f); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRangeGridlineStroke(gridStroke); plot.setDomainGridlineStroke(gridStroke); plot.setBackgroundPaint(new Color(235, 235, 235)); plot.setRangeGridlinePaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setOutlineVisible(false);//from ww w . j a v a 2 s .c o m plot.getDomainAxis().setAxisLineVisible(false); plot.getRangeAxis().setAxisLineVisible(false); plot.getDomainAxis().setLabelPaint(Color.gray); plot.getRangeAxis().setLabelPaint(Color.gray); plot.getDomainAxis().setTickLabelPaint(Color.gray); plot.getRangeAxis().setTickLabelPaint(Color.gray); chart.getTitle().setPaint(Color.gray); }
From source file:smarthouse_server.LineChart.java
/** * Creates a sample chart./*from w w w.j av a 2 s .c o m*/ * * @param dataset a dataset. * * @return The chart. */ private JFreeChart createChart(CategoryDataset dataset) { // create the chart... chart = ChartFactory.createLineChart("Room Monitor #", // chart title "Time", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); // legend.setShapeScaleX(1.5); // legend.setShapeScaleY(1.5); //legend.setDisplaySeriesLines(true); chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setRangeGridlinePaint(Color.white); plot.getDomainAxis().setVisible(false); // customise the range axis... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(true); // **************************************************************************** // * JFREECHART DEVELOPER GUIDE * // * The JFreeChart Developer Guide, written by David Gilbert, is available * // * to purchase from Object Refinery Limited: * // * * // * http://www.object-refinery.com/jfreechart/guide.html * // * * // * Sales are used to provide funding for the JFreeChart project - please * // * support us so that we can continue developing free software. * // **************************************************************************** // customise the renderer... LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); // renderer.setDrawShapes(true); renderer.setSeriesStroke(0, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 10.0f, 6.0f }, 0.0f)); renderer.setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 6.0f, 6.0f }, 0.0f)); /* renderer.setSeriesStroke( 2, new BasicStroke( 2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] {2.0f, 6.0f}, 0.0f ) );*/ // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:no.met.jtimeseries.marinogram.MarinogramTemperaturePlot.java
private XYPlot createPlot(TimeZone timezone, boolean plotAirTemp, boolean plotWaterTemp, boolean plotDewpointTemp) throws ParseException { Date startTime = null;/*from w ww. j ava 2s . c om*/ NumberPhenomenon aTemperature = null; NumberPhenomenon wTemperature = null; NumberPhenomenon dTemperature = null; // default setting ChartPlotter plotter = new ChartPlotter(); plotter.setHeight(this.getHeight()); plotter.setWidth(this.getWidth()); plotter.setPlotDefaultProperties("", ""); double minValue = 100; double maxValue = -100; int plotIndex = 0; if (plotAirTemp) { aTemperature = getLocationForecastDataModel().getPhenomenen(PhenomenonName.AirTemperature.toString(), NumberPhenomenon.class); minValue = aTemperature.getMinValue() < minValue ? aTemperature.getMinValue() : minValue; maxValue = aTemperature.getMaxValue() > maxValue ? aTemperature.getMaxValue() : maxValue; startTime = aTemperature.getTime().get(0); plotTemperature(plotter, aTemperature, new BasicStroke(2.0f), Color.RED, messages.getString("label.air"), true); plotter.getPlot().getRenderer(plotIndex).setSeriesVisibleInLegend(0, true); plotter.getPlot().getRenderer(plotIndex).setSeriesVisibleInLegend(1, true); plotIndex++; } if (plotWaterTemp) { wTemperature = getOceanForecastDataModel().getPhenomenen(PhenomenonName.seaTemperature.toString(), NumberPhenomenon.class); // only plot water temperature if it is availbe for this location if (wTemperature != null) { minValue = wTemperature.getMinValue() < minValue ? wTemperature.getMinValue() : minValue; maxValue = wTemperature.getMaxValue() > maxValue ? wTemperature.getMaxValue() : maxValue; startTime = wTemperature.getTime().get(0); BasicStroke dottedStroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 2.0f, 6.0f }, 0.0f); plotTemperature(plotter, wTemperature, dottedStroke, Color.RED, messages.getString("label.water"), true); plotter.getPlot().getRenderer(plotIndex++).setSeriesVisibleInLegend(0, true); } } if (plotDewpointTemp) { dTemperature = getLocationForecastDataModel() .getPhenomenen(PhenomenonName.dewPointTemperature.toString(), NumberPhenomenon.class); minValue = dTemperature.getMinValue() < minValue ? dTemperature.getMinValue() : minValue; maxValue = dTemperature.getMaxValue() > maxValue ? dTemperature.getMaxValue() : maxValue; startTime = dTemperature.getTime().get(0); plotTemperature(plotter, dTemperature, new BasicStroke(2.0f), Color.ORANGE, messages.getString("label.dewpoint"), false); plotter.getPlot().getRenderer(plotIndex).setSeriesVisibleInLegend(0, true); } double tick = (maxValue - minValue) / 3.5; tick = Math.ceil(tick); double lowBound = Math.floor(minValue / (tick)) * (tick); lowBound = lowBound - tick / 2; double upperBound = lowBound + tick * 7; // set range axis NumberAxis numberAxis = new NumberAxis(); numberAxis.setLabelPaint(Color.RED); numberAxis.setTickLabelPaint(Color.RED); numberAxis.setLabel(messages.getString("parameter.temperature") + " (\u00B0 C)"); numberAxis.setTickUnit(new NumberTickUnit(tick)); numberAxis.setLowerBound(lowBound); numberAxis.setUpperBound(upperBound); //Set left axis and right axis plotter.getPlot().setRangeAxis(0, numberAxis); plotter.getPlot().setRangeAxis(1, numberAxis); //Set the third axis and hide the third axis if (plotAirTemp && plotWaterTemp && plotDewpointTemp) { NumberAxis numberAxis2 = new NumberAxis(); numberAxis2.setTickUnit(new NumberTickUnit(tick)); numberAxis2.setLowerBound(lowBound); numberAxis2.setUpperBound(upperBound); plotter.getPlot().setRangeAxis(2, numberAxis2); plotter.getPlot().getRangeAxis(2).setVisible(false); } //Show legend at the top right position of the plot LegendTitle lt = new LegendTitle(plotter.getPlot()); lt.setItemFont(new Font("Dialog", Font.PLAIN, 9)); lt.setBackgroundPaint(new Color(255, 255, 255, 100)); lt.setFrame(new BlockBorder(Color.white)); lt.setPosition(RectangleEdge.TOP); XYTitleAnnotation ta = new XYTitleAnnotation(0.99, 0.95, lt, RectangleAnchor.TOP_RIGHT); plotter.getPlot().addAnnotation(ta); // set domain range after (must) plot all the data plotter.addHourBasedDomainGridLines(); // add markers plotter.addDomainMarkers(getShortTermTime(startTime), timezone, locale); Date minDate = getShortTermTime(startTime).get(0); Date maxDate = getShortTermTime(startTime).get(getShortTermTime(startTime).size() - 1); plotter.setDomainRange(minDate, maxDate); plotter.setDomainDateFormat(timezone, "HH"); plotter.getPlot().setOutlineVisible(true); // invisible the domain i.e, x axis plotter.getPlot().getDomainAxis().setTickLabelsVisible(false); return plotter.getPlot(); }
From source file:sim.util.media.chart.TimeSeriesAttributes.java
public void rebuildGraphicsDefinitions() { float[] newDashPattern = new float[dashPatterns[dashPattern].length]; for (int x = 0; x < newDashPattern.length; x++) if (stretch * thickness > 0) newDashPattern[x] = dashPatterns[dashPattern][x] * stretch * thickness; // include thickness so we dont' get overlaps -- will this confuse users? XYItemRenderer renderer = (XYItemRenderer) (((XYPlot) getPlot()).getRenderer()); // we do two different BasicStroke options here because recent versions of Java (for example, 1.6.0_35_b10-428-11M3811 on Retina Displays) // break when defining solid strokes as { X, 0.0 } even though that's perfecty cromulent. So instead we hack it so that the "solid" stroke // is done using a different constructor. renderer.setSeriesStroke(getSeriesIndex(), ((dashPattern == 0) ? // solid new BasicStroke(thickness, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 0) : new BasicStroke(thickness, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 0, newDashPattern, 0))); renderer.setSeriesPaint(getSeriesIndex(), strokeColor); repaint();//from w ww. j a v a 2s .com }
From source file:net.sf.maltcms.common.charts.api.overlay.SelectionOverlay.java
/** * * @param selectionFillColor//w ww . j av a 2 s. c o m * @param hoverFillColor * @param hoverScaleX * @param hoverScaleY * @param fillAlpha */ public SelectionOverlay(Color selectionFillColor, Color hoverFillColor, float hoverScaleX, float hoverScaleY, float fillAlpha) { super("Selection", "Selection", "Overlay for chart item entity selection", true); this.selectionFillColor = selectionFillColor; this.hoverFillColor = hoverFillColor; this.hoverScaleX = hoverScaleX; this.hoverScaleY = hoverScaleY; this.fillAlpha = fillAlpha; BasicStroke dashed = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 6.0f, 6.0f }, 0.0f); domainCrosshair = new Crosshair(1.5d, new Color(0, 0, 0, 128), dashed); domainCrosshair.setVisible(true); rangeCrosshair = new Crosshair(1.5d, new Color(0, 0, 0, 128), dashed); rangeCrosshair.setVisible(true); crosshairOverlay = new CrosshairOverlay(); crosshairOverlay.addDomainCrosshair(domainCrosshair); crosshairOverlay.addRangeCrosshair(rangeCrosshair); setLayerPosition(LAYER_HIGHEST); selectionLookupResult = actionsGlobalContext().lookupResult(ISelection.class); selectionLookupResult.addLookupListener(new LookupChangeListener()); }
From source file:org.matsim.contrib.dvrp.util.chart.RouteCharts.java
public static JFreeChart chartRoutesByStatus(List<? extends Vehicle> vehicles) { CoordDataset nData = new CoordDataset(); for (int i = 0; i < vehicles.size(); i++) { Schedule schedule = vehicles.get(i).getSchedule(); Map<TaskStatus, CoordSource> vsByStatus = createLinkSourceByStatus(schedule); nData.addSeries(i + "-PR", vsByStatus.get(TaskStatus.PERFORMED)); nData.addSeries(i + "-ST", vsByStatus.get(TaskStatus.STARTED)); nData.addSeries(i + "-PL", vsByStatus.get(TaskStatus.PLANNED)); }/*from w ww . j a va 2 s . com*/ JFreeChart chart = ChartFactory.createXYLineChart("Routes", "X", "Y", nData, PlotOrientation.VERTICAL, false, true, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRangeGridlinesVisible(false); plot.setDomainGridlinesVisible(false); plot.setBackgroundPaint(Color.white); NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setAutoRangeIncludesZero(false); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setSeriesShapesVisible(0, true); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesItemLabelsVisible(0, true); renderer.setBaseItemLabelGenerator(new LabelGenerator()); Paint[] paints = DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE; Shape[] shapes = DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE; for (int i = 0; i < vehicles.size(); i++) { int s = 3 * i; renderer.setSeriesItemLabelsVisible(s + 1, true); renderer.setSeriesItemLabelsVisible(s + 2, true); renderer.setSeriesItemLabelsVisible(s + 3, true); renderer.setSeriesShapesVisible(s + 1, true); renderer.setSeriesShapesVisible(s + 2, true); renderer.setSeriesShapesVisible(s + 3, true); renderer.setSeriesLinesVisible(s + 1, true); renderer.setSeriesLinesVisible(s + 2, true); renderer.setSeriesLinesVisible(s + 3, true); renderer.setSeriesPaint(s + 1, paints[(i + 1) % paints.length]); renderer.setSeriesPaint(s + 2, paints[(i + 1) % paints.length]); renderer.setSeriesPaint(s + 3, paints[(i + 1) % paints.length]); renderer.setSeriesShape(s + 1, shapes[(i + 1) % shapes.length]); renderer.setSeriesShape(s + 2, shapes[(i + 1) % shapes.length]); renderer.setSeriesShape(s + 3, shapes[(i + 1) % shapes.length]); renderer.setSeriesStroke(s + 2, new BasicStroke(3)); renderer.setSeriesStroke(s + 3, new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1, new float[] { 5f, 5f }, 0)); } return chart; }
From source file:edu.gmu.cs.sim.util.media.chart.TimeSeriesAttributes.java
public void rebuildGraphicsDefinitions() { float[] newDashPattern = new float[dashPatterns[dashPattern].length]; for (int x = 0; x < newDashPattern.length; x++) { if (stretch * thickness > 0) { newDashPattern[x] = dashPatterns[dashPattern][x] * stretch * thickness; // include thickness so we dont' get overlaps -- will this confuse users? }//w ww .jav a2 s . c o m } XYItemRenderer renderer = (XYItemRenderer) (((XYPlot) getPlot()).getRenderer()); // we do two different BasicStroke options here because recent versions of Java (for example, 1.6.0_35_b10-428-11M3811 on Retina Displays) // break when defining solid strokes as { X, 0.0 } even though that's perfecty cromulent. So instead we hack it so that the "solid" stroke // is done using a different constructor. renderer.setSeriesStroke(getSeriesIndex(), ((dashPattern == 0) ? // solid new BasicStroke(thickness, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 0) : new BasicStroke(thickness, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 0, newDashPattern, 0))); renderer.setSeriesPaint(getSeriesIndex(), strokeColor); repaint(); }
From source file:org.openmeetings.app.data.record.BatikMethods.java
public void paintRect2D(Graphics2D g2d, double x, double y, double width, double height, Color linecoler, int thickness, Color fillColor, float alpha) throws Exception { g2d.setStroke(new BasicStroke(thickness, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); int[] rules = new int[8]; //all possible Compositing Rules: rules[0] = AlphaComposite.SRC_OVER; rules[1] = AlphaComposite.DST_OVER; rules[2] = AlphaComposite.CLEAR; rules[3] = AlphaComposite.SRC; rules[4] = AlphaComposite.SRC_IN; rules[5] = AlphaComposite.DST_IN; rules[6] = AlphaComposite.SRC_OUT; rules[7] = AlphaComposite.DST_OUT; g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC, alpha)); //int x, int y, int width, int height if (linecoler != null) { g2d.setPaint(linecoler);/*w w w. j a v a 2 s .c o m*/ g2d.draw(new Rectangle2D.Double(x, y, width, height)); } if (fillColor != null) { g2d.setPaint(fillColor); g2d.fill(new Rectangle2D.Double(x, y, width, height)); } }
From source file:edu.cudenver.bios.chartsvc.resource.LegendResource.java
private XYPlot buildScatterPlot(Chart chart) throws ResourceException { // the first series is treated as the x values if (chart.getSeries() == null || chart.getSeries().size() <= 0) throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "No data series specified"); // create the jfree chart series XYSeriesCollection chartData = new XYSeriesCollection(); // use a spline renderer to make the connecting lines smooth XYSplineRenderer rend = new XYSplineRenderer(); int seriesIdx = 0; for (Series series : chart.getSeries()) { XYSeries xySeries = new XYSeries(series.getLabel()); List<Double> xList = series.getXCoordinates(); List<Double> yList = series.getYCoordinates(); if (xList != null && yList != null && xList.size() == yList.size()) { for (int i = 0; i < xList.size(); i++) { xySeries.add(xList.get(i), yList.get(i)); }/*from w w w .java 2s .c o m*/ } // set the line style rend.setSeriesPaint(seriesIdx, Color.BLACK); if (seriesIdx > 0) { rend.setSeriesStroke(seriesIdx, new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { (float) seriesIdx, (float) 2 * seriesIdx }, 0.0f)); } // add the series to the data set chartData.addSeries(xySeries); seriesIdx++; } // turn off shapes displayed at each data point to make a smooth curve rend.setBaseShapesVisible(false); // Create the line chart NumberAxis xAxis = new NumberAxis(); xAxis.setAutoRangeIncludesZero(false); if (chart.getXAxis() != null) { Axis xAxisSpec = chart.getXAxis(); xAxis.setLabel(xAxisSpec.getLabel()); if (!Double.isNaN(xAxisSpec.getRangeMin()) && !Double.isNaN(xAxisSpec.getRangeMax())) { xAxis.setRange(xAxisSpec.getRangeMin(), xAxisSpec.getRangeMax()); } } NumberAxis yAxis = new NumberAxis(); if (chart.getYAxis() != null) { Axis yAxisSpec = chart.getYAxis(); yAxis.setLabel(chart.getYAxis().getLabel()); if (!Double.isNaN(yAxisSpec.getRangeMin()) && !Double.isNaN(yAxisSpec.getRangeMax())) { xAxis.setRange(yAxisSpec.getRangeMin(), yAxisSpec.getRangeMax()); } } XYPlot plot = new XYPlot((XYDataset) chartData, xAxis, yAxis, rend); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); return plot; }