List of usage examples for org.jfree.chart.annotations XYPointerAnnotation setBackgroundPaint
public void setBackgroundPaint(Paint paint)
From source file:org.jfree.chart.demo.NormalDistributionDemo2.java
public static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createXYLineChart("Normal Distribution Demo 2", "X", "Y", xydataset, PlotOrientation.VERTICAL, true, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setDomainZeroBaselineVisible(true); xyplot.setRangeZeroBaselineVisible(true); xyplot.setDomainPannable(true);//from ww w. j ava 2 s .c o m xyplot.setRangePannable(true); ValueAxis valueaxis = xyplot.getDomainAxis(); valueaxis.setLowerMargin(0.0D); valueaxis.setUpperMargin(0.0D); XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); xylineandshaperenderer.setDrawSeriesLineAsPath(true); xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(1.5F)); xylineandshaperenderer.setSeriesStroke(1, new BasicStroke(2.0F, 1, 1, 1.0F, new float[] { 6F, 4F }, 0.0F)); xylineandshaperenderer.setSeriesStroke(2, new BasicStroke(2.0F, 1, 1, 1.0F, new float[] { 6F, 4F, 3F, 3F }, 0.0F)); xylineandshaperenderer.setSeriesStroke(3, new BasicStroke(2.0F, 1, 1, 1.0F, new float[] { 4F, 4F }, 0.0F)); XYPointerAnnotation xypointerannotation = new XYPointerAnnotation(" = -2.0, \262 = 0.5", -2D, 0.56399999999999995D, 3.9269908169872414D); xypointerannotation.setLabelOffset(4D); xypointerannotation.setTextAnchor(TextAnchor.BOTTOM_RIGHT); xypointerannotation.setBackgroundPaint(Color.yellow); xyplot.addAnnotation(xypointerannotation); XYPointerAnnotation xypointerannotation1 = new XYPointerAnnotation(" = 0.0, \262 = 0.2", 0.22500000000000001D, 0.80000000000000004D, 0.0D); xypointerannotation1.setLabelOffset(4D); xypointerannotation1.setTextAnchor(TextAnchor.CENTER_LEFT); xypointerannotation1.setBackgroundPaint(new Color(0, 0, 255, 63)); xyplot.addAnnotation(xypointerannotation1); XYPointerAnnotation xypointerannotation2 = new XYPointerAnnotation(" = 0.0, \262 = 1.0", 0.75D, 0.29999999999999999D, 5.497787143782138D); xypointerannotation2.setLabelOffset(4D); xypointerannotation2.setTextAnchor(TextAnchor.HALF_ASCENT_LEFT); xypointerannotation2.setBackgroundPaint(new Color(255, 0, 0, 63)); xyplot.addAnnotation(xypointerannotation2); XYPointerAnnotation xypointerannotation3 = new XYPointerAnnotation(" = 0.0, \262 = 5.0", 3D, 0.074999999999999997D, 4.7123889803846897D); xypointerannotation3.setLabelOffset(4D); xypointerannotation3.setTextAnchor(TextAnchor.BOTTOM_CENTER); xypointerannotation3.setBackgroundPaint(new Color(0, 255, 0, 63)); xyplot.addAnnotation(xypointerannotation3); return jfreechart; }
From source file:org.owasp.benchmark.score.report.Scatter.java
private XYPointerAnnotation makePointer(int x, int y, String msg, TextAnchor anchor, int angle) { XYPointerAnnotation pointer = new XYPointerAnnotation(msg, x, y, Math.toRadians(angle)); pointer.setBackgroundPaint(Color.white); pointer.setTextAnchor(anchor);/*from ww w. j av a2s . c om*/ pointer.setArrowWidth(4); pointer.setArrowLength(8); pointer.setArrowPaint(Color.red); pointer.setLabelOffset(2); pointer.setPaint(Color.red); pointer.setFont(theme.getRegularFont()); return pointer; }
From source file:org.trade.ui.chart.CandlestickChart.java
/** * Method addBuySellTradeArrow.//from w ww . j a va 2 s .co m * * @param action * String * @param price * Money * @param time * Date * @param quantity * Integer * @throws ValueTypeException */ public void addBuySellTradeArrow(String action, Money price, Date time, Integer quantity) throws ValueTypeException { String label = Action.newInstance(action) + " " + quantity + "@" + price; XYPointerAnnotation arrow = new XYPointerAnnotation(label, time.getTime(), price.doubleValue(), 90d); arrow.setLabelOffset(5.0); arrow.setBackgroundPaint(Color.GREEN); if (action.equals(Action.SELL)) { arrow.setAngle(-90d); arrow.setBackgroundPaint(Color.RED); } CombinedDomainXYPlot combinedXYplot = (CombinedDomainXYPlot) this.chart.getPlot(); @SuppressWarnings("unchecked") List<XYPlot> subplots = combinedXYplot.getSubplots(); XYPlot xyplot = subplots.get(0); xyplot.addAnnotation(arrow); this.chart.fireChartChanged(); }