List of usage examples for java.awt BasicStroke BasicStroke
public BasicStroke(float width, int cap, int join)
From source file:org.openmeetings.app.data.record.BatikMethods.java
public void paintEllipse2D(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);/*from ww w . ja va 2 s. c o m*/ g2d.draw(new Ellipse2D.Double(x, y, width, height)); } if (fillColor != null) { g2d.setPaint(fillColor); g2d.fill(new Ellipse2D.Double(x, y, width, height)); } }
From source file:TapTapTap.java
@Override public void paint(Graphics g, JComponent c) { int w = c.getWidth(); int h = c.getHeight(); // Paint the view. super.paint(g, c); if (!mIsRunning) { return;/*from ww w. j a v a 2s . c o m*/ } Graphics2D g2 = (Graphics2D) g.create(); float fade = (float) mFadeCount / (float) mFadeLimit; // Gray it out. Composite urComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .5f * fade)); g2.fillRect(0, 0, w, h); g2.setComposite(urComposite); // Paint the wait indicator. int s = Math.min(w, h) / 5; int cx = w / 2; int cy = h / 2; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setStroke(new BasicStroke(s / 4, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); g2.setPaint(Color.white); g2.rotate(Math.PI * mAngle / 180, cx, cy); for (int i = 0; i < 12; i++) { float scale = (11.0f - (float) i) / 11.0f; g2.drawLine(cx + s, cy, cx + s * 2, cy); g2.rotate(-Math.PI / 6, cx, cy); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, scale * fade)); } g2.dispose(); }
From source file:hudson.plugins.emma.portlet.chart.EmmaBuilderTrendChart.java
/** * Creates a graph for Emma Coverage results. * * @param summaries//ww w .j a v a 2 s . co m * HashMap(key = run date and value = Instrumentation tests * results) * @param widthParam * the chart width * @param heightParam * the chart height * @return Graph (JFreeChart) */ private static Graph createTrendChart(final Map<LocalDate, EmmaCoverageResultSummary> summaries, int widthParam, int heightParam) { return new Graph(-1, widthParam, heightParam) { @Override protected JFreeChart createGraph() { // Show empty chart if (summaries == null) { JFreeChart chart = ChartFactory.createStackedAreaChart(null, Constants.AXIS_LABEL, Constants.AXIS_LABEL_VALUE, null, PlotOrientation.VERTICAL, true, false, false); return chart; } int lineNumber = 0; JFreeChart chart = ChartFactory.createLineChart("", Constants.AXIS_LABEL, Constants.AXIS_LABEL_VALUE, buildDataSet(summaries), PlotOrientation.VERTICAL, true, false, false); chart.setBackgroundPaint(Color.white); CategoryPlot plot = chart.getCategoryPlot(); // Line thickness CategoryItemRenderer renderer = plot.getRenderer(); BasicStroke stroke = new BasicStroke(Constants.LINE_THICKNESS, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); renderer.setSeriesStroke(lineNumber++, stroke); renderer.setSeriesStroke(lineNumber++, stroke); renderer.setSeriesStroke(lineNumber++, stroke); renderer.setSeriesStroke(lineNumber, stroke); plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null); plot.setForegroundAlpha(Constants.FOREGROUND_ALPHA); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.black); CategoryAxis domainAxis = new ShiftedCategoryAxis(null); plot.setDomainAxis(domainAxis); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); domainAxis.setLowerMargin(Constants.DEFAULT_MARGIN); domainAxis.setUpperMargin(Constants.DEFAULT_MARGIN); domainAxis.setCategoryMargin(Constants.DEFAULT_MARGIN); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setUpperBound(Constants.UPPER_BOUND); rangeAxis.setLowerBound(Constants.LOWER_BOUND); return chart; } }; }
From source file:hudson.plugins.karma.portlet.chart.KarmaBuilderTrendChart.java
/** * Creates a graph for Karma Coverage results. * * @param summaries//from ww w .ja v a 2 s . c o m * HashMap(key = run date and value = Instrumentation tests * results) * @param widthParam * the chart width * @param heightParam * the chart height * @return Graph (JFreeChart) */ private static Graph createTrendChart(final Map<LocalDate, KarmaCoverageResultSummary> summaries, int widthParam, int heightParam) { return new Graph(-1, widthParam, heightParam) { @Override protected JFreeChart createGraph() { // Show empty chart if (summaries == null) { JFreeChart chart = ChartFactory.createStackedAreaChart(null, Constants.AXIS_LABEL, Constants.AXIS_LABEL_VALUE, null, PlotOrientation.VERTICAL, true, false, false); return chart; } int lineNumber = 0; JFreeChart chart = ChartFactory.createLineChart("", Constants.AXIS_LABEL, Constants.AXIS_LABEL_VALUE, buildDataSet(summaries), PlotOrientation.VERTICAL, true, false, false); chart.setBackgroundPaint(Color.white); CategoryPlot plot = chart.getCategoryPlot(); // Line thickness CategoryItemRenderer renderer = plot.getRenderer(); BasicStroke stroke = new BasicStroke(Constants.LINE_THICKNESS, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); renderer.setSeriesStroke(lineNumber++, stroke); renderer.setSeriesStroke(lineNumber++, stroke); renderer.setSeriesStroke(lineNumber++, stroke); renderer.setSeriesStroke(lineNumber, stroke); plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null); plot.setForegroundAlpha(Constants.FOREGROUND_ALPHA); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.black); CategoryAxis domainAxis = new ShiftedCategoryAxis(null); plot.setDomainAxis(domainAxis); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); domainAxis.setLowerMargin(Constants.DEFAULT_MARGIN); domainAxis.setUpperMargin(Constants.DEFAULT_MARGIN); domainAxis.setCategoryMargin(Constants.DEFAULT_MARGIN); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setUpperBound(Constants.UPPER_BOUND); rangeAxis.setLowerBound(Constants.LOWER_BOUND); return chart; } }; }
From source file:hudson.plugins.jacoco.portlet.chart.JacocoBuilderTrendChart.java
/** * Creates a graph for JaCoCo Coverage results. * * @param summaries//from ww w .ja va 2 s . c om * HashMap(key = run date and value = Instrumentation tests * results) * @param widthParam * the chart width * @param heightParam * the chart height * @return Graph (JFreeChart) */ private static Graph createTrendChart(final Map<LocalDate, JacocoCoverageResultSummary> summaries, int widthParam, int heightParam) { return new Graph(-1, widthParam, heightParam) { @Override protected JFreeChart createGraph() { // Show empty chart if (summaries == null) { JFreeChart chart = ChartFactory.createStackedAreaChart(null, Constants.AXIS_LABEL, Constants.AXIS_LABEL_VALUE, null, PlotOrientation.VERTICAL, true, false, false); return chart; } int lineNumber = 0; JFreeChart chart = ChartFactory.createLineChart("", Constants.AXIS_LABEL, Constants.AXIS_LABEL_VALUE, buildDataSet(summaries), PlotOrientation.VERTICAL, true, false, false); chart.setBackgroundPaint(Color.white); CategoryPlot plot = chart.getCategoryPlot(); // Line thickness CategoryItemRenderer renderer = plot.getRenderer(); BasicStroke stroke = new BasicStroke(Constants.LINE_THICKNESS, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); renderer.setSeriesStroke(lineNumber++, stroke); renderer.setSeriesStroke(lineNumber++, stroke); renderer.setSeriesStroke(lineNumber++, stroke); renderer.setSeriesStroke(lineNumber, stroke); plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null); plot.setForegroundAlpha(Constants.FOREGROUND_ALPHA); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.black); CategoryAxis domainAxis = new ShiftedCategoryAxis(null); plot.setDomainAxis(domainAxis); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); domainAxis.setLowerMargin(Constants.DEFAULT_MARGIN); domainAxis.setUpperMargin(Constants.DEFAULT_MARGIN); domainAxis.setCategoryMargin(Constants.DEFAULT_MARGIN); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); //rangeAxis.setUpperBound(Constants.UPPER_BOUND); rangeAxis.setLowerBound(Constants.LOWER_BOUND); return chart; } }; }
From source file:com.joey.software.memoryToolkit.MemoryUsagePanel.java
/** * Creates a new application./* ww w .ja v a2s. c om*/ * * @param historyCount * the history count (in milliseconds). */ public MemoryUsagePanel(int historyCount, int interval) { super(new BorderLayout()); // create two series that automatically discard data more than 30 // seconds old... this.total = new TimeSeries("Total Memory", Millisecond.class); this.total.setMaximumItemCount(historyCount); this.free = new TimeSeries("Free Memory", Millisecond.class); this.free.setMaximumItemCount(historyCount); this.used = new TimeSeries("Used Memory", Millisecond.class); this.used.setMaximumItemCount(historyCount); this.max = new TimeSeries("Used Memory", Millisecond.class); this.max.setMaximumItemCount(historyCount); TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(this.total); dataset.addSeries(this.free); dataset.addSeries(this.used); dataset.addSeries(this.max); DateAxis domain = new DateAxis("Time"); NumberAxis range = new NumberAxis("Memory"); domain.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12)); range.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12)); domain.setLabelFont(new Font("SansSerif", Font.PLAIN, 14)); range.setLabelFont(new Font("SansSerif", Font.PLAIN, 14)); XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false); renderer.setSeriesPaint(0, Color.red); renderer.setSeriesPaint(1, Color.green); renderer.setSeriesPaint(2, Color.black); renderer.setStroke(new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); XYPlot plot = new XYPlot(dataset, domain, range, renderer); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); domain.setAutoRange(true); domain.setLowerMargin(0.0); domain.setUpperMargin(0.0); domain.setTickLabelsVisible(true); range.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); JFreeChart chart = new JFreeChart("JVM Memory Usage", new Font("SansSerif", Font.BOLD, 24), plot, true); chart.setBackgroundPaint(Color.white); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4), BorderFactory.createLineBorder(Color.black))); add(chartPanel); gen = new DataGenerator(interval); }
From source file:hudson.plugins.codecover.portlet.chart.CodeCoverBuilderTrendChart.java
/** * Creates a graph for CodeCover Coverage results. * * @param summaries// ww w .ja va 2 s . c o m * HashMap(key = run date and value = Instrumentation tests * results) * @param widthParam * the chart width * @param heightParam * the chart height * @return Graph (JFreeChart) */ private static Graph createTrendChart(final Map<LocalDate, CodeCoverCoverageResultSummary> summaries, int widthParam, int heightParam) { return new Graph(-1, widthParam, heightParam) { @Override protected JFreeChart createGraph() { // Show empty chart if (summaries == null) { JFreeChart chart = ChartFactory.createStackedAreaChart(null, Constants.AXIS_LABEL, Constants.AXIS_LABEL_VALUE, null, PlotOrientation.VERTICAL, true, false, false); return chart; } int lineNumber = 0; JFreeChart chart = ChartFactory.createLineChart("", Constants.AXIS_LABEL, Constants.AXIS_LABEL_VALUE, buildDataSet(summaries), PlotOrientation.VERTICAL, true, false, false); chart.setBackgroundPaint(Color.white); CategoryPlot plot = chart.getCategoryPlot(); // Line thickness CategoryItemRenderer renderer = plot.getRenderer(); BasicStroke stroke = new BasicStroke(Constants.LINE_THICKNESS, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); renderer.setSeriesStroke(lineNumber++, stroke); renderer.setSeriesStroke(lineNumber++, stroke); renderer.setSeriesStroke(lineNumber++, stroke); renderer.setSeriesStroke(lineNumber, stroke); plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null); plot.setForegroundAlpha(Constants.FOREGROUND_ALPHA); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.black); CategoryAxis domainAxis = new ShiftedCategoryAxis(null); plot.setDomainAxis(domainAxis); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); domainAxis.setLowerMargin(Constants.DEFAULT_MARGIN); domainAxis.setUpperMargin(Constants.DEFAULT_MARGIN); domainAxis.setCategoryMargin(Constants.DEFAULT_MARGIN); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setUpperBound(Constants.UPPER_BOUND); rangeAxis.setLowerBound(Constants.LOWER_BOUND); return chart; } }; }
From source file:org.jfree.fx.demo.FXGraphics2DDemo1.java
/** * Creates a chart./*from w w w .j a va 2 s . com*/ * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart("International Coffee Organisation : Coffee Prices", // title null, // x-axis label "US cents/lb", // y-axis label dataset); String fontName = "Palatino"; chart.getTitle().setFont(new Font(fontName, Font.BOLD, 18)); chart.addSubtitle(new TextTitle("Source: http://www.ico.org/historical/2010-19/PDF/HIST-PRICES.pdf", new Font(fontName, Font.PLAIN, 14))); XYPlot plot = (XYPlot) chart.getPlot(); plot.setDomainPannable(true); plot.setRangePannable(false); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.getDomainAxis().setLowerMargin(0.0); plot.getDomainAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getDomainAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); plot.getRangeAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); chart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14)); chart.getLegend().setFrame(BlockBorder.NONE); chart.getLegend().setHorizontalAlignment(HorizontalAlignment.CENTER); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(false); renderer.setDrawSeriesLineAsPath(true); // set the default stroke for all series renderer.setAutoPopulateSeriesStroke(false); renderer.setDefaultStroke(new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL), false); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, new Color(24, 123, 58)); renderer.setSeriesPaint(2, new Color(149, 201, 136)); renderer.setSeriesPaint(3, new Color(1, 62, 29)); renderer.setSeriesPaint(4, new Color(81, 176, 86)); renderer.setSeriesPaint(5, new Color(0, 55, 122)); renderer.setSeriesPaint(6, new Color(0, 92, 165)); } return chart; }
From source file:ega.projekt.graphDraw.DrawGraph.java
public static BasicVisualizationServer<Node, Edge> generatePanel(ega.projekt.graph.Graph dataGraph, int panelWidth, int panelHeight) { if (dataGraph.getEdges().isEmpty()) System.out.println("Error initializing graph"); DrawGraph graphView = new DrawGraph(dataGraph); Layout<Node, Edge> layout = new StaticLayout(graphView.drawGraph); for (Node n : graphView.drawGraph.getVertices()) { layout.setLocation(n, new java.awt.geom.Point2D.Double(n.getX(), n.getY())); }/*www . j a v a 2 s . c om*/ layout.setSize(new Dimension(panelWidth, panelHeight)); BasicVisualizationServer<Node, Edge> vv = new BasicVisualizationServer<>(layout); vv.setPreferredSize(new Dimension(panelWidth, panelHeight)); Transformer<Node, Paint> vertexPaint = new Transformer<Node, Paint>() { public Paint transform(Node i) { return Color.GREEN; } }; final Stroke edgeStroke = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER); Transformer<Edge, Stroke> edgeStrokeTransformer = new Transformer<Edge, Stroke>() { public Stroke transform(Edge e) { return edgeStroke; } }; vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint); vv.getRenderContext().setEdgeStrokeTransformer(edgeStrokeTransformer); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.QuadCurve<Node, Edge>()); vv.getRenderContext().setEdgeLabelTransformer(new Transformer<Edge, String>() { public String transform(Edge e) { return (e.getFlowString() + "/" + Integer.toString(e.getCapacity())); } }); vv.getRenderContext().setVertexLabelTransformer(new Transformer<Node, String>() { public String transform(Node n) { return (Integer.toString(n.getID())); } }); vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR); return vv; }
From source file:edu.ku.brc.specify.plugins.ipadexporter.ChartHelper.java
/** * @param list/*from w w w . ja va 2 s .c o m*/ * @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; }