List of usage examples for java.awt BasicStroke BasicStroke
@ConstructorProperties({ "lineWidth", "endCap", "lineJoin", "miterLimit", "dashArray", "dashPhase" }) public BasicStroke(float width, int cap, int join, float miterlimit, float[] dash, float dash_phase)
From source file:org.azrul.langmera.LineChart.java
/** * Creates a chart./* ww w . j ava2 s .c o m*/ * * @param dataset the data for the chart. * * @return a chart. */ private JFreeChart createChart(final XYDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart(this.getTitle(), // chart title "Number of messages", // x axis label "Value of actions", // 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); // 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); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); for (int i = 0; i < dataset.getSeriesCount(); i++) { renderer.setSeriesStroke(i, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 10.0f, 6.0f }, 0.0f)); } return chart; }
From source file:org.n52.io.type.quantity.handler.img.LineRenderer.java
private BasicStroke getDashedLineDefinition(LineStyle lineStyle) { int width = lineStyle.getDashGapWidth(); float[] dashSequence = new float[] { 4.0f * width, 4.0f * width }; return new BasicStroke(width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, dashSequence, 0.0f); }
From source file:org.n52.io.img.LineRenderer.java
private BasicStroke getDashedLineDefinition(LineStyle style) { int width = style.getDashGapWidth(); float[] dashSequence = new float[] { 4.0f * width, 4.0f * width }; return new BasicStroke(width, CAP_ROUND, JOIN_ROUND, 1.0f, dashSequence, 0.0f); }
From source file:GeMSE.Visualization.ElbowPlot.java
public void Plot(ArrayList<Double[]> pvData, ArrayList<Double[]> dData, int cut) { double maxY = 0; float[] secYColor = new float[3]; Color.RGBtoHSB(153, 245, 255, secYColor); float[] priYColor = new float[3]; Color.RGBtoHSB(255, 255, 255, priYColor); float[] cutColor = new float[3]; Color.RGBtoHSB(255, 255, 0, cutColor); //create the series - add some dummy data XYSeries pvSeries = new XYSeries("Percentage of variance "); for (int i = 1; i < pvData.size(); i++) { pvSeries.add(pvData.get(i)[0], pvData.get(i)[1]); maxY = Math.max(maxY, pvData.get(i)[1]); }/*w w w . j a v a 2 s . c o m*/ XYSeries dSeries = new XYSeries("Percentage of differences between slopes "); for (int i = 0; i < dData.size(); i++) dSeries.add(dData.get(i)[0], dData.get(i)[1]); XYSeries cutSeries = new XYSeries("Cut "); cutSeries.add(cut, 0.0); cutSeries.add(cut, maxY); //create the datasets XYSeriesCollection pvDataSeries = new XYSeriesCollection(); pvDataSeries.addSeries(pvSeries); XYSeriesCollection cutDataSeries = new XYSeriesCollection(); cutDataSeries.addSeries(cutSeries); XYSeriesCollection dDataSeries = new XYSeriesCollection(); dDataSeries.addSeries(dSeries); //construct the plot XYPlot plot = new XYPlot(); plot.setDataset(0, pvDataSeries); plot.setDataset(1, cutDataSeries); plot.setDataset(2, dDataSeries); // use XYSplineRenderer if you want to smooth the lines. XYLineAndShapeRenderer pvRenderer = new XYLineAndShapeRenderer(); pvRenderer.setSeriesPaint(0, Color.getHSBColor(priYColor[0], priYColor[1], priYColor[2])); BasicStroke dstroke = new BasicStroke(2.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 1.0f, 10.0f }, 0.0f); XYLineAndShapeRenderer dRenderer = new XYLineAndShapeRenderer(); dRenderer.setSeriesPaint(0, Color.getHSBColor(secYColor[0], secYColor[1], secYColor[2])); dRenderer.setSeriesStroke(0, dstroke); BasicStroke cutStoke = new BasicStroke(4); // use XYSplineRenderer if you want to smooth the lines. //XYSplineRenderer cutRenderer = new XYSplineRenderer(); XYLineAndShapeRenderer cutRenderer = new XYLineAndShapeRenderer(); cutRenderer.setSeriesPaint(0, Color.getHSBColor(cutColor[0], cutColor[1], cutColor[2])); cutRenderer.setSeriesStroke(0, cutStoke); plot.setRenderer(0, pvRenderer); plot.setRenderer(1, cutRenderer); plot.setRenderer(2, dRenderer); plot.setRangeAxis(0, new NumberAxis("\n\nPercentage of Variance")); plot.setRangeAxis(1, new NumberAxis("Percentage of Difference Between Slopes")); plot.setDomainAxis(new NumberAxis("Number of Clusters\n\n")); //Map the data to the appropriate axis plot.mapDatasetToRangeAxis(0, 0); plot.mapDatasetToRangeAxis(1, 0); plot.mapDatasetToRangeAxis(2, 1); float[] hsbValues = new float[3]; Color.RGBtoHSB(16, 23, 67, hsbValues); plot.setBackgroundPaint(Color.getHSBColor(hsbValues[0], hsbValues[1], hsbValues[2])); Font axisLabelFont = new Font("Dialog", Font.PLAIN, 14); Font axisTickLabelFont = new Font("Dialog", Font.PLAIN, 12); Font legendFont = new Font("Dialog", Font.PLAIN, 14); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); plot.getDomainAxis().setTickLabelPaint(Color.white); plot.getDomainAxis().setLabelPaint(Color.white); plot.getDomainAxis().setLabelFont(axisLabelFont); plot.getDomainAxis().setTickLabelFont(axisTickLabelFont); plot.getRangeAxis().setTickLabelPaint(Color.getHSBColor(priYColor[0], priYColor[1], priYColor[2])); plot.getRangeAxis().setLabelPaint(Color.getHSBColor(priYColor[0], priYColor[1], priYColor[2])); plot.getRangeAxis().setLabelFont(axisLabelFont); plot.getRangeAxis().setTickLabelFont(axisTickLabelFont); plot.getRangeAxis(1).setTickLabelPaint(Color.getHSBColor(secYColor[0], secYColor[1], secYColor[2])); plot.getRangeAxis(1).setLabelPaint(Color.getHSBColor(secYColor[0], secYColor[1], secYColor[2])); plot.getRangeAxis(1).setLabelFont(axisLabelFont); plot.getRangeAxis(1).setTickLabelFont(axisTickLabelFont); //generate the chart JFreeChart chart = new JFreeChart("\nSuggested number of clusters determined using Elbow method", getFont(), plot, true); chart.getTitle().setPaint(Color.white); chart.getLegend().setBackgroundPaint(Color.black); chart.getLegend().setItemPaint(Color.white); chart.getLegend().setPosition(RectangleEdge.BOTTOM); chart.getLegend().setItemFont(legendFont); float[] hsbValues2 = new float[3]; Color.RGBtoHSB(36, 43, 87, hsbValues2); chart.setBackgroundPaint(Color.getHSBColor(hsbValues2[0], hsbValues2[1], hsbValues2[2])); JPanel chartPanel = new ChartPanel(chart); GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); chartPanel.setPreferredSize( new java.awt.Dimension((int) Math.round((gd.getDisplayMode().getWidth() * 1.5) / 3.0), (int) Math.round((gd.getDisplayMode().getHeight() * 1.5) / 3.0))); setContentPane(chartPanel); }
From source file:edu.jhuapl.graphs.jfreechart.TimeSeriesEffectsTest.java
public static JFreeChartGraphSource getSource() throws GraphException { Calendar base = Calendar.getInstance(); base.set(Calendar.WEEK_OF_YEAR, 6); Random r = new Random(); List<TimePoint> ps1 = new LinkedList<TimePoint>(); List<TimePoint> ps2 = new LinkedList<TimePoint>(); List<TimePoint> ps3 = new LinkedList<TimePoint>(); for (int count = 0; count < 4; count += 1) { base.set(Calendar.DAY_OF_WEEK, 2); addPoint(base.getTime(), ps2, r); // now generate five points for ps1 and p23, the daily sets addPoint(base.getTime(), ps1, r); addPoint(base.getTime(), ps3, r, "showPoint?week=" + count + "&day=0", null); for (int i = 1; i < 5; i += 1) { base.add(Calendar.DAY_OF_WEEK, 1); addPoint(base.getTime(), ps1, r); addPoint(base.getTime(), ps3, r, "showPoint?week=" + count + "&day=" + i, null); }/*from w w w . ja v a2 s. co m*/ base.set(Calendar.DAY_OF_WEEK, 1); base.add(Calendar.WEEK_OF_YEAR, 1); } List<DefaultTimeSeries> series = new LinkedList<DefaultTimeSeries>(); Map<String, Object> s1Md = new HashMap<String, Object>(); s1Md.put(GraphSource.SERIES_TIME_RESOLUTION, TimeResolution.DAILY); s1Md.put(GraphSource.SERIES_SHAPE, new Ellipse2D.Float(-5, -5, 10, 10)); s1Md.put(GraphSource.SERIES_TITLE, "Frederick County Counts"); series.add(new DefaultTimeSeries(ps1, s1Md)); Map<String, Object> s2Md = new HashMap<String, Object>(); s2Md.put(GraphSource.SERIES_TIME_RESOLUTION, TimeResolution.WEEKLY); s2Md.put(GraphSource.SERIES_SHAPE, new Ellipse2D.Float(-7, -7, 14, 14)); s2Md.put(GraphSource.SERIES_TITLE, "NCR Counts"); series.add(new DefaultTimeSeries(ps2, s2Md)); Map<String, Object> s3Md = new HashMap<String, Object>(); s3Md.put(GraphSource.SERIES_TIME_RESOLUTION, TimeResolution.DAILY); s3Md.put(GraphSource.SERIES_SHAPE, new Rectangle2D.Float(-3, -3, 6, 6)); s3Md.put(GraphSource.SERIES_TITLE, "Carroll County Counts"); BasicStroke bs = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10, new float[] { 3F, 2F, 8F }, 1F); s3Md.put(GraphSource.SERIES_STROKE, bs); series.add(new DefaultTimeSeries(ps3, s3Md)); Map<String, Object> params = new HashMap<String, Object>(); params.put(GraphSource.BACKGROUND_COLOR, Color.BLUE); params.put(JFreeChartTimeSeriesGraphSource.PLOT_COLOR, Color.WHITE); params.put(GraphSource.GRAPH_TITLE, "Counts"); params.put(GraphSource.GRAPH_X_LABEL, "Time"); params.put(GraphSource.GRAPH_Y_LABEL, "Total Counts"); DateAxis customAxis = new RotatedTickDateAxis(60.); params.put(JFreeChartTimeSeriesGraphSource.DATE_AXIS, customAxis); JFreeChartGraphSource source = new JFreeChartGraphSource(); source.setData(series); source.setParams(params); source.initialize(); return source; }
From source file:ancat.visualizers.UndirectedModelVisualizer.java
private void produce(String fileName) { _currentLayout.setSize(new Dimension(600, 600)); VisualizationImageServer<V, E> vv = new VisualizationImageServer<V, E>(_currentLayout, new Dimension(600, 600)); vv.setPreferredSize(new Dimension(600, 600)); // Setup up a new vertex to paint transformer... Transformer<V, Paint> vertexPaint = new Transformer<V, Paint>() { public Paint transform(V v) { //return Color.GREEN; ancat.common.Vertex vertex = (Vertex) v; if (vertex instanceof ancat.common.ExecutableFile) return Color.BLUE; if (vertex instanceof ancat.common.DynamicLibrary) return Color.YELLOW; if (vertex instanceof ancat.common.ConfigurationFile) return Color.ORANGE; if (vertex instanceof ancat.common.Unspecified) return Color.RED; return Color.darkGray; }/*from w w w. ja va2s . c o m*/ }; // Set up a new stroke Transformer for the edges float dash[] = { 10.0f }; final Stroke edgeStroke = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash, 0.0f); Transformer<E, Stroke> edgeStrokeTransformer = new Transformer<E, Stroke>() { public Stroke transform(E s) { return edgeStroke; } }; Transformer<E, Font> edgeFontTransformer = new Transformer<E, Font>() { public Font transform(E e) { return new Font("Dialog", Font.PLAIN, 10); } }; Transformer<E, String> lblTransformer = new Transformer<E, String>() { public String transform(E e) { Edge edge = (Edge) e; //return edge.getXMLId(); return edge.getXMLId() != null ? edge.getXMLId() : ""; } }; Transformer<V, Font> vertexFontTransformer = new Transformer<V, Font>() { public Font transform(V v) { return new Font("Dialog", Font.PLAIN, 10); } }; Transformer<V, String> vLblTransformer = new Transformer<V, String>() { public String transform(V v) { Vertex vertex = (Vertex) v; return vertex.getElementID(); } }; vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint); vv.getRenderContext().setEdgeStrokeTransformer(edgeStrokeTransformer); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<V>()); vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller<E>()); // ----> vv.getRenderContext().setEdgeFontTransformer(edgeFontTransformer); vv.getRenderContext().setLabelOffset(20); vv.getRenderContext().setEdgeLabelTransformer(lblTransformer); vv.getRenderContext().setVertexFontTransformer(vertexFontTransformer); vv.getRenderContext().setVertexLabelTransformer(vLblTransformer); vv.getRenderer().getVertexLabelRenderer().setPosition(Position.N); BufferedImage img = new BufferedImage((int) _currentLayout.getSize().getWidth(), (int) _currentLayout.getSize().getHeight(), BufferedImage.TYPE_INT_ARGB); vv.getImage(new Point(0, 0), new Dimension(700, 700)); Graphics2D g2d = (Graphics2D) img.getGraphics(); vv.paint(g2d); setDisclaimer(g2d); g2d.dispose(); try { File file = new File(fileName); ImageIO.write(img, "png", file); } catch (IOException e) { e.printStackTrace(); } }
From source file:net.imglib2.script.analysis.BarChart.java
static private 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); CategoryPlot plot = (CategoryPlot) 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 w w w . j av 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:de.bfs.radon.omsimulation.gui.data.OMCharts.java
/** * Creates a chart displaying the radon concentration of a single room. Uses * red for normal rooms, blue for cellar rooms and green for misc rooms. * // w ww. j a va 2 s . c om * @param title * The headline of the chart. Will be hidden if set to null. * @param room * The room object containing the radon data. * @param preview * Will hide annotations, labels and headlines if true. * @return A chart displaying the radon concentration of a single room. */ public static JFreeChart createRoomChart(String title, OMRoom room, boolean preview) { Color lineColor = new Color(0, 0, 0, 128); Color rangeColor = new Color(222, 222, 222, 128); if (room.getType() == OMRoomType.Room) { lineColor = new Color(255, 0, 0, 128); rangeColor = new Color(255, 222, 222, 128); } else { if (room.getType() == OMRoomType.Cellar) { lineColor = new Color(0, 0, 255, 128); rangeColor = new Color(222, 222, 255, 128); } else { lineColor = new Color(0, 128, 0, 255); rangeColor = new Color(222, 255, 222, 128); } } double[] values = room.getValues(); XYSeriesCollection dataSet = new XYSeriesCollection(); XYSeries series = new XYSeries("Radon"); int count = room.getCount(); double maxPointerKey = 0; for (int i = 0; i < count; i++) { series.add(i, values[i]); if (values[i] == room.getMaximum()) { maxPointerKey = i; } } dataSet.addSeries(series); title = title + ": " + room.getType().toString() + " " + room.getId(); JFreeChart chart = ChartFactory.createXYLineChart(title, "T [h]", "Rn [Bq/m\u00B3]", dataSet, PlotOrientation.VERTICAL, false, true, false); XYPlot plot = (XYPlot) chart.getPlot(); double positiveDeviation = room.getAverage() + room.getDeviation(); double negativeDeviation = room.getAverage() - room.getDeviation(); IntervalMarker deviation = new IntervalMarker(negativeDeviation, positiveDeviation); float[] dash = { 5, 3 }; deviation.setPaint(rangeColor); deviation.setStroke(new BasicStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0)); plot.addRangeMarker(deviation, Layer.BACKGROUND); ValueMarker arithMarker = new ValueMarker(room.getAverage(), lineColor, new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0)); plot.addRangeMarker(arithMarker); ValueMarker maxiMarker = new ValueMarker(room.getMaximum(), lineColor, new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0)); plot.addRangeMarker(maxiMarker); XYTextAnnotation amLabel = new XYTextAnnotation("AM=" + (int) room.getAverage(), count, room.getAverage() * 1.01); plot.addAnnotation(amLabel); XYTextAnnotation sdLabel = new XYTextAnnotation("SD=" + (int) room.getDeviation(), count, (room.getAverage() + room.getDeviation()) * 1.01); plot.addAnnotation(sdLabel); XYTextAnnotation maxLabel = new XYTextAnnotation("MAX=" + (int) room.getMaximum(), count, room.getMaximum() * 1.01); plot.addAnnotation(maxLabel); XYPointerAnnotation maxPointer = new XYPointerAnnotation("", maxPointerKey, room.getMaximum(), Math.PI * 1.1); plot.addAnnotation(maxPointer); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, lineColor); if (preview) { chart.setTitle(""); plot.clearAnnotations(); } return chart; }
From source file:view.FuzzySetView.java
/** * *//* w ww . ja v a 2s . c o m*/ public void showFuzzyValues() { clearMarkers(); BasicStroke dashedStroke = new BasicStroke(1.7f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 6f, new float[] { 6f }, 0); double crispValue = 0; FuzzySet fuzzySet = getFuzzySet(); for (int i = 0; i < fuzzySet.getMembershipValuesLength(); i++) { MembershipValue value = fuzzySet.getMembershipValueAt(i); if (value != null) { ValueMarker marker = new ValueMarker(value.getValue(), colors[i], dashedStroke); plot.addRangeMarker(marker); crispValue = value.getCrispValue(); } } plot.addDomainMarker(new ValueMarker(crispValue, Color.BLACK, dashedStroke)); }
From source file:org.jstockchart.plot.TimeseriesPlot.java
private CombinedDomainXYPlot createCombinedXYPlot() { Font axisFont = new Font("Arial", 0, 12); Stroke stroke = new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.CAP_SQUARE, 0.0f, new float[] { 1.0f, 1.0f }, 1.0f); LogicDateAxis logicDateAxis = timeseriesArea.getlogicDateAxis(); TimeseriesDateAxis dateAxis = new TimeseriesDateAxis(logicDateAxis.getLogicTicks()); if (timeline != null) { dateAxis.setTimeline(timeline);/* www .j av a 2 s . c o m*/ } dateAxis.setTickLabelFont(axisFont); dateAxis.setTickMarkStroke(stroke); List<String> hideTick = new ArrayList<String>(); hideTick.add("10:00"); hideTick.add("11:00"); hideTick.add("13:30"); //hideTick.add("14:30"); hideTick.add("14:30"); dateAxis.setHideTickLabel(hideTick); dateAxis.setTickMarkPosition(DateTickMarkPosition.START); dateAxis.setTickMarksVisible(false); Date startTime = DateUtils.createDate(2008, 1, 1, 9, 30, 0); Date endTime = DateUtils.createDate(2008, 1, 1, 15, 0, 0); dateAxis.setRange(timeseriesArea.getStartDate(), timeseriesArea.getEndDate()); dateAxis.setAxisLineVisible(false); CFXCombinedPlot combinedDomainXYPlot = new CFXCombinedPlot(dateAxis); combinedDomainXYPlot.setInsets(new RectangleInsets(5, 2, 4, 2)); AxisSpace axisSpace = new AxisSpace(); axisSpace.setBottom(22); axisSpace.setLeft(0); axisSpace.setRight(0); axisSpace.setTop(0); combinedDomainXYPlot.setFixedDomainAxisSpace(axisSpace); combinedDomainXYPlot.setGap(0); combinedDomainXYPlot.setOrientation(timeseriesArea.getOrientation()); combinedDomainXYPlot.setDomainAxis(dateAxis); combinedDomainXYPlot.setDomainAxisLocation(timeseriesArea.getDateAxisLocation()); if (timeseriesArea.getPriceWeight() <= 0 && timeseriesArea.getVolumeWeight() <= 0) { throw new IllegalArgumentException("Illegal weight value: priceWeight=" + timeseriesArea.getPriceWeight() + ", volumeWeight=" + timeseriesArea.getVolumeWeight()); } if (timeseriesArea.getPriceWeight() > 0) { XYPlot pricePlot = createPricePlot(); combinedDomainXYPlot.add(pricePlot, timeseriesArea.getPriceWeight()); } if (timeseriesArea.getVolumeWeight() > 0) { XYPlot volumePlot = createVolumePlot(); combinedDomainXYPlot.add(volumePlot, timeseriesArea.getVolumeWeight()); } return combinedDomainXYPlot; }