Example usage for org.jfree.chart.annotations XYPointerAnnotation setAngle

List of usage examples for org.jfree.chart.annotations XYPointerAnnotation setAngle

Introduction

In this page you can find the example usage for org.jfree.chart.annotations XYPointerAnnotation setAngle.

Prototype

public void setAngle(double angle) 

Source Link

Document

Sets the angle of the arrow and sends an AnnotationChangeEvent to all registered listeners.

Usage

From source file:org.trade.ui.chart.CandlestickChart.java

/**
 * Method addBuySellTradeArrow./* www.  j  ava 2  s .c o 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();
}