Example usage for org.jfree.chart.annotations XYDrawableAnnotation XYDrawableAnnotation

List of usage examples for org.jfree.chart.annotations XYDrawableAnnotation XYDrawableAnnotation

Introduction

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

Prototype

public XYDrawableAnnotation(double x, double y, double width, double height, Drawable drawable) 

Source Link

Document

Creates a new annotation to be displayed within the given area.

Usage

From source file:org.jfree.chart.demo.MarkerDemo1.java

/**
 * Creates a sample chart.//from  w  w w.j  a  va2s.co  m
 *
 * @param data  the sample data.
 *
 * @return A configured chart.
 */
private JFreeChart createChart(final XYDataset data) {

    final JFreeChart chart = ChartFactory.createScatterPlot("Marker Demo 1", "X", "Y", data,
            PlotOrientation.VERTICAL, true, true, false);
    //    chart.getLegend().setAnchor(Legend.EAST);

    // customise...
    final XYPlot plot = chart.getXYPlot();
    plot.getRenderer().setToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance());

    // set axis margins to allow space for marker labels...
    final DateAxis domainAxis = new DateAxis("Time");
    domainAxis.setUpperMargin(0.50);
    plot.setDomainAxis(domainAxis);

    final ValueAxis rangeAxis = plot.getRangeAxis();
    rangeAxis.setUpperMargin(0.30);
    rangeAxis.setLowerMargin(0.50);

    // add a labelled marker for the bid start price...
    final Marker start = new ValueMarker(200.0);
    start.setPaint(Color.green);
    start.setLabel("Bid Start Price");
    start.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT);
    start.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
    plot.addRangeMarker(start);

    // add a labelled marker for the target price...
    final Marker target = new ValueMarker(175.0);
    target.setPaint(Color.red);
    target.setLabel("Target Price");
    target.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
    target.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
    plot.addRangeMarker(target);

    // add a labelled marker for the original closing time...
    final Hour hour = new Hour(2, new Day(22, 5, 2003));
    double millis = hour.getFirstMillisecond();
    final Marker originalEnd = new ValueMarker(millis);
    originalEnd.setPaint(Color.orange);
    originalEnd.setLabel("Original Close (02:00)");
    originalEnd.setLabelAnchor(RectangleAnchor.TOP_LEFT);
    originalEnd.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
    plot.addDomainMarker(originalEnd);

    // add a labelled marker for the current closing time...
    final Minute min = new Minute(15, hour);
    millis = min.getFirstMillisecond();
    final Marker currentEnd = new ValueMarker(millis);
    currentEnd.setPaint(Color.red);
    currentEnd.setLabel("Close Date (02:15)");
    currentEnd.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
    currentEnd.setLabelTextAnchor(TextAnchor.TOP_LEFT);
    plot.addDomainMarker(currentEnd);

    // ****************************************************************************
    // * 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.             *
    // ****************************************************************************

    // label the best bid with an arrow and label...
    final Hour h = new Hour(2, new Day(22, 5, 2003));
    final Minute m = new Minute(10, h);
    millis = m.getFirstMillisecond();
    final CircleDrawer cd = new CircleDrawer(Color.red, new BasicStroke(1.0f), null);
    final XYAnnotation bestBid = new XYDrawableAnnotation(millis, 163.0, 11, 11, cd);
    plot.addAnnotation(bestBid);
    final XYPointerAnnotation pointer = new XYPointerAnnotation("Best Bid", millis, 163.0, 3.0 * Math.PI / 4.0);
    pointer.setBaseRadius(35.0);
    pointer.setTipRadius(10.0);
    pointer.setFont(new Font("SansSerif", Font.PLAIN, 9));
    pointer.setPaint(Color.blue);
    pointer.setTextAnchor(TextAnchor.HALF_ASCENT_RIGHT);
    plot.addAnnotation(pointer);

    return chart;

}

From source file:com.romraider.logger.ecu.ui.tab.dyno.DynoChartPanel.java

public void interpolate(double[] results, String[] resultStrings) {
    hpAxis.setAutoRange(true);/*  w w w.  j  ava  2 s.  com*/
    tqAxis.setAutoRange(true);
    double rangeMin = Math.min(tqAxis.getLowerBound(), hpAxis.getLowerBound());
    double yMin = Math.round(rangeMin);
    double ySpace = (hpAxis.getUpperBound() - hpAxis.getLowerBound()) / 25;
    double xMin = ((plot.getDomainAxis().getUpperBound() - plot.getDomainAxis().getLowerBound()) / 7)
            + plot.getDomainAxis().getLowerBound();
    hpAxis.setRange(Math.round(rangeMin), Math.round(hpAxis.getUpperBound() + ySpace));
    tqAxis.setRange(Math.round(rangeMin), Math.round(tqAxis.getUpperBound() + ySpace));
    bestHp = new XYDrawableAnnotation(results[1], results[0], 10, 10, cd);
    hpPointer.setX(results[1]);
    hpPointer.setY(results[0]);
    hpPointer.setArrowPaint(BLUE);
    hpPointer.setTipRadius(7.0);
    hpPointer.setBaseRadius(30.0);
    hpPointer.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 10));
    hpPointer.setPaint(BLUE);
    bestTq = new XYDrawableAnnotation(results[3], results[2], 10, 10, cd);
    tqPointer.setX(results[3]);
    tqPointer.setY(results[2]);
    tqPointer.setArrowPaint(YELLOW);
    tqPointer.setTipRadius(7.0);
    tqPointer.setBaseRadius(30.0);
    tqPointer.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 10));
    tqPointer.setPaint(YELLOW);
    final XYTextAnnotation dynoResults = new XYTextAnnotation(resultStrings[1], xMin, yMin + (ySpace * 5));
    dynoResults.setPaint(RED);
    dynoResults.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    dynoResults.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 14));
    final XYTextAnnotation carText = new XYTextAnnotation(resultStrings[0], xMin, yMin + (ySpace * 4));
    carText.setPaint(RED);
    carText.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    carText.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 12));
    final XYTextAnnotation stat1 = new XYTextAnnotation(resultStrings[2], xMin, yMin + (ySpace * 3));
    stat1.setPaint(RED);
    stat1.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    stat1.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 12));
    final XYTextAnnotation stat2 = new XYTextAnnotation(resultStrings[3], xMin, yMin + ySpace * 2);
    stat2.setPaint(RED);
    stat2.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    stat2.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 12));
    final XYTextAnnotation stat3 = new XYTextAnnotation(resultStrings[4], xMin, yMin + ySpace);
    stat3.setPaint(RED);
    stat3.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    stat3.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 12));
    final XYTextAnnotation stat4 = new XYTextAnnotation(resultStrings[5], xMin, yMin);
    stat4.setPaint(RED);
    stat4.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    stat4.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 12));
    if (!refStat.equals(" ")) {
        refStat.setX(plot.getDomainAxis().getLowerBound() + 10);
        refStat.setY(hpAxis.getUpperBound());
        plot.addAnnotation(refStat);
    }
    rendererY1.addAnnotation(bestHp);
    rendererY2.addAnnotation(bestTq);
    rendererY1.addAnnotation(hpPointer);
    rendererY2.addAnnotation(tqPointer);
    plot.addAnnotation(dynoResults);
    plot.addAnnotation(carText);
    plot.addAnnotation(stat1);
    plot.addAnnotation(stat2);
    plot.addAnnotation(stat3);
    plot.addAnnotation(stat4);
}

From source file:com.romraider.logger.ecu.ui.tab.DynoChartPanel.java

public void interpolate(double[] results, String[] resultStrings) {
    hpAxis.setAutoRange(true);//  www.  j  av  a2s . c  o m
    tqAxis.setAutoRange(true);
    double rangeMin = Math.min(tqAxis.getLowerBound(), hpAxis.getLowerBound());
    double yMin = Math.round(rangeMin);
    double ySpace = (hpAxis.getUpperBound() - hpAxis.getLowerBound()) / 25;
    double xMin = ((plot.getDomainAxis().getUpperBound() - plot.getDomainAxis().getLowerBound()) / 7)
            + plot.getDomainAxis().getLowerBound();
    hpAxis.setRange(Math.round(rangeMin), Math.round(hpAxis.getUpperBound() + ySpace));
    tqAxis.setRange(Math.round(rangeMin), Math.round(tqAxis.getUpperBound() + ySpace));
    bestHp = new XYDrawableAnnotation(results[1], results[0], 10, 10, cd);
    hpPointer.setX(results[1]);
    hpPointer.setY(results[0]);
    hpPointer.setArrowPaint(BLUE);
    hpPointer.setTipRadius(7.0);
    hpPointer.setBaseRadius(30.0);
    hpPointer.setFont(new Font("SansSerif", Font.BOLD, 10));
    hpPointer.setPaint(BLUE);
    bestTq = new XYDrawableAnnotation(results[3], results[2], 10, 10, cd);
    tqPointer.setX(results[3]);
    tqPointer.setY(results[2]);
    tqPointer.setArrowPaint(YELLOW);
    tqPointer.setTipRadius(7.0);
    tqPointer.setBaseRadius(30.0);
    tqPointer.setFont(new Font("SansSerif", Font.BOLD, 10));
    tqPointer.setPaint(YELLOW);
    final XYTextAnnotation dynoResults = new XYTextAnnotation(resultStrings[1], xMin, yMin + (ySpace * 5));
    dynoResults.setPaint(RED);
    dynoResults.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    dynoResults.setFont(new Font("SansSerif", Font.BOLD, 14));
    final XYTextAnnotation carText = new XYTextAnnotation(resultStrings[0], xMin, yMin + (ySpace * 4));
    carText.setPaint(RED);
    carText.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    carText.setFont(new Font("SansSerif", Font.BOLD, 12));
    final XYTextAnnotation stat1 = new XYTextAnnotation(resultStrings[2], xMin, yMin + (ySpace * 3));
    stat1.setPaint(RED);
    stat1.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    stat1.setFont(new Font("SansSerif", Font.BOLD, 12));
    final XYTextAnnotation stat2 = new XYTextAnnotation(resultStrings[3], xMin, yMin + ySpace * 2);
    stat2.setPaint(RED);
    stat2.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    stat2.setFont(new Font("SansSerif", Font.BOLD, 12));
    final XYTextAnnotation stat3 = new XYTextAnnotation(resultStrings[4], xMin, yMin + ySpace);
    stat3.setPaint(RED);
    stat3.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    stat3.setFont(new Font("SansSerif", Font.BOLD, 12));
    final XYTextAnnotation stat4 = new XYTextAnnotation(resultStrings[5], xMin, yMin);
    stat4.setPaint(RED);
    stat4.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    stat4.setFont(new Font("SansSerif", Font.BOLD, 12));
    if (!refStat.equals(" ")) {
        refStat.setX(plot.getDomainAxis().getLowerBound() + 10);
        refStat.setY(hpAxis.getUpperBound());
        plot.addAnnotation(refStat);
    }
    rendererY1.addAnnotation(bestHp);
    rendererY2.addAnnotation(bestTq);
    rendererY1.addAnnotation(hpPointer);
    rendererY2.addAnnotation(tqPointer);
    plot.addAnnotation(dynoResults);
    plot.addAnnotation(carText);
    plot.addAnnotation(stat1);
    plot.addAnnotation(stat2);
    plot.addAnnotation(stat3);
    plot.addAnnotation(stat4);
}

From source file:com.romraider.logger.ecu.ui.tab.dyno.DynoChartPanel.java

public void updateEtResults(String carInfo, double[] etResults, String units) {
    String s60Text = "60 ft";
    String s330Text = "330 ft";
    String s660Text = "1/2 track";
    String s1000Text = "1,000 ft";
    String s1320Text = "1/4 mile";
    String zTo60Text = "60 mph";
    if (units.equalsIgnoreCase("km/h")) {
        s60Text = "18.3m";
        s330Text = "100m";
        s1000Text = "305m";
        s1320Text = "402m";
        zTo60Text = "97 km/h";
    }/* w w w . j a  v a  2  s  .c o  m*/
    hpAxis.setLabel("Vehicle Speed (" + units + ")");
    String[] car = carInfo.split(";");
    car[0] = "LANE 1: " + car[0].substring(0, car[0].length() - 3) + " - ET: "
            + String.format("%1.3f", etResults[8]) + "\" / " + String.format("%1.2f", etResults[9]) + " "
            + units;
    double ySpace = hpAxis.getUpperBound() / 25;
    double xMin = ((plot.getDomainAxis().getUpperBound() - plot.getDomainAxis().getLowerBound()) / 7)
            + plot.getDomainAxis().getLowerBound();
    tqAxis.setRange(hpAxis.getLowerBound(), hpAxis.getUpperBound());
    final XYAnnotation s60Marker = new XYDrawableAnnotation(etResults[0], etResults[1], 10, 10, cd);
    final XYTextAnnotation s60Label = new XYTextAnnotation(s60Text, etResults[0], (etResults[1] + ySpace));
    s60Label.setPaint(RED);
    s60Label.setTextAnchor(TextAnchor.TOP_RIGHT);
    s60Label.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 10));
    final XYTextAnnotation s60Time = new XYTextAnnotation(
            String.format("%1.3f", etResults[0]) + "\" / " + String.format("%1.2f", etResults[1]), etResults[0],
            (etResults[1] - ySpace));
    s60Time.setPaint(RED);
    s60Time.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    s60Time.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 10));
    final XYAnnotation s330Marker = new XYDrawableAnnotation(etResults[2], etResults[3], 10, 10, cd);
    final XYTextAnnotation s330Label = new XYTextAnnotation(s330Text, etResults[2], (etResults[3] + ySpace));
    s330Label.setPaint(RED);
    s330Label.setTextAnchor(TextAnchor.TOP_RIGHT);
    s330Label.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 10));
    final XYTextAnnotation s330Time = new XYTextAnnotation(
            String.format("%1.3f", etResults[2]) + "\" / " + String.format("%1.2f", etResults[3]), etResults[2],
            (etResults[3] - ySpace));
    s330Time.setPaint(RED);
    s330Time.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    s330Time.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 10));
    final XYAnnotation s660Marker = new XYDrawableAnnotation(etResults[4], etResults[5], 10, 10, cd);
    final XYTextAnnotation s660Label = new XYTextAnnotation(s660Text, etResults[4], (etResults[5] + ySpace));
    s660Label.setPaint(RED);
    s660Label.setTextAnchor(TextAnchor.TOP_RIGHT);
    s660Label.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 10));
    final XYTextAnnotation s660Time = new XYTextAnnotation(
            String.format("%1.3f", etResults[4]) + "\" / " + String.format("%1.2f", etResults[5]), etResults[4],
            (etResults[5] - ySpace));
    s660Time.setPaint(RED);
    s660Time.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    s660Time.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 10));
    final XYAnnotation s1000Marker = new XYDrawableAnnotation(etResults[6], etResults[7], 10, 10, cd);
    final XYTextAnnotation s1000Label = new XYTextAnnotation(s1000Text, etResults[6], (etResults[7] + ySpace));
    s1000Label.setPaint(RED);
    s1000Label.setTextAnchor(TextAnchor.TOP_RIGHT);
    s1000Label.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 10));
    final XYTextAnnotation s1000Time = new XYTextAnnotation(
            String.format("%1.3f", etResults[6]) + "\" / " + String.format("%1.2f", etResults[7]), etResults[6],
            (etResults[7] - ySpace));
    s1000Time.setPaint(RED);
    s1000Time.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    s1000Time.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 10));
    final XYAnnotation s1320Marker = new XYDrawableAnnotation(etResults[8], etResults[9], 10, 10, cd);
    final XYTextAnnotation s1320Label = new XYTextAnnotation(s1320Text, etResults[8], (etResults[9] - ySpace));
    s1320Label.setPaint(RED);
    s1320Label.setTextAnchor(TextAnchor.BOTTOM_CENTER);
    s1320Label.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 10));
    final XYTextAnnotation s1320Time = new XYTextAnnotation(
            String.format("%1.3f", etResults[8]) + "\" / " + String.format("%1.2f", etResults[9]),
            (etResults[8] - 0.2), etResults[9]);
    s1320Time.setPaint(RED);
    s1320Time.setTextAnchor(TextAnchor.CENTER_RIGHT);
    s1320Time.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 10));
    final XYTextAnnotation carText = new XYTextAnnotation(car[0], (plot.getDomainAxis().getUpperBound() - 0.2),
            (hpAxis.getLowerBound() + ySpace));
    carText.setPaint(RED);
    carText.setTextAnchor(TextAnchor.BOTTOM_RIGHT);
    carText.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 12));
    final XYAnnotation zTo60Marker = new XYDrawableAnnotation(etResults[10], etResults[11], 10, 10, cdGreen);
    final XYTextAnnotation zTo60Label = new XYTextAnnotation(zTo60Text, etResults[10],
            (etResults[11] + ySpace));
    zTo60Label.setPaint(GREEN);
    zTo60Label.setTextAnchor(TextAnchor.TOP_RIGHT);
    zTo60Label.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 10));
    final XYTextAnnotation zTo60Time = new XYTextAnnotation((String.format("%1.3f", etResults[10]) + "\""),
            etResults[10], (etResults[11] - ySpace));
    zTo60Time.setPaint(GREEN);
    zTo60Time.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    zTo60Time.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 10));
    plot.addAnnotation(s60Marker);
    plot.addAnnotation(s60Label);
    plot.addAnnotation(s60Time);
    plot.addAnnotation(s330Marker);
    plot.addAnnotation(s330Label);
    plot.addAnnotation(s330Time);
    plot.addAnnotation(s660Marker);
    plot.addAnnotation(s660Label);
    plot.addAnnotation(s660Time);
    plot.addAnnotation(s1000Marker);
    plot.addAnnotation(s1000Label);
    plot.addAnnotation(s1000Time);
    plot.addAnnotation(s1320Marker);
    plot.addAnnotation(s1320Label);
    plot.addAnnotation(s1320Time);
    plot.addAnnotation(carText);
    plot.addAnnotation(zTo60Marker);
    plot.addAnnotation(zTo60Label);
    plot.addAnnotation(zTo60Time);
}

From source file:com.romraider.logger.ecu.ui.tab.DynoChartPanel.java

public void updateEtResults(String carInfo, double[] etResults, String units) {
    String s60Text = "60 ft";
    String s330Text = "330 ft";
    String s660Text = "1/2 track";
    String s1000Text = "1,000 ft";
    String s1320Text = "1/4 mile";
    String zTo60Text = "60 mph";
    if (units.equalsIgnoreCase("kph")) {
        s60Text = "18.3m";
        s330Text = "100m";
        s1000Text = "305m";
        s1320Text = "402m";
        zTo60Text = "97 kph";
    }/* ww  w .  java 2s  . c  o  m*/
    hpAxis.setLabel("Vehicle Speed (" + units + ")");
    String[] car = carInfo.split(";");
    car[0] = "LANE 1: " + car[0].substring(0, car[0].length() - 3) + " - ET: "
            + String.format("%1.3f", etResults[8]) + "\" / " + String.format("%1.2f", etResults[9]) + " "
            + units;
    double ySpace = hpAxis.getUpperBound() / 25;
    double xMin = ((plot.getDomainAxis().getUpperBound() - plot.getDomainAxis().getLowerBound()) / 7)
            + plot.getDomainAxis().getLowerBound();
    tqAxis.setRange(hpAxis.getLowerBound(), hpAxis.getUpperBound());
    final XYAnnotation s60Marker = new XYDrawableAnnotation(etResults[0], etResults[1], 10, 10, cd);
    final XYTextAnnotation s60Label = new XYTextAnnotation(s60Text, etResults[0], (etResults[1] + ySpace));
    s60Label.setPaint(RED);
    s60Label.setTextAnchor(TextAnchor.TOP_RIGHT);
    s60Label.setFont(new Font("SansSerif", Font.BOLD, 10));
    final XYTextAnnotation s60Time = new XYTextAnnotation(
            String.format("%1.3f", etResults[0]) + "\" / " + String.format("%1.2f", etResults[1]), etResults[0],
            (etResults[1] - ySpace));
    s60Time.setPaint(RED);
    s60Time.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    s60Time.setFont(new Font("SansSerif", Font.BOLD, 10));
    final XYAnnotation s330Marker = new XYDrawableAnnotation(etResults[2], etResults[3], 10, 10, cd);
    final XYTextAnnotation s330Label = new XYTextAnnotation(s330Text, etResults[2], (etResults[3] + ySpace));
    s330Label.setPaint(RED);
    s330Label.setTextAnchor(TextAnchor.TOP_RIGHT);
    s330Label.setFont(new Font("SansSerif", Font.BOLD, 10));
    final XYTextAnnotation s330Time = new XYTextAnnotation(
            String.format("%1.3f", etResults[2]) + "\" / " + String.format("%1.2f", etResults[3]), etResults[2],
            (etResults[3] - ySpace));
    s330Time.setPaint(RED);
    s330Time.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    s330Time.setFont(new Font("SansSerif", Font.BOLD, 10));
    final XYAnnotation s660Marker = new XYDrawableAnnotation(etResults[4], etResults[5], 10, 10, cd);
    final XYTextAnnotation s660Label = new XYTextAnnotation(s660Text, etResults[4], (etResults[5] + ySpace));
    s660Label.setPaint(RED);
    s660Label.setTextAnchor(TextAnchor.TOP_RIGHT);
    s660Label.setFont(new Font("SansSerif", Font.BOLD, 10));
    final XYTextAnnotation s660Time = new XYTextAnnotation(
            String.format("%1.3f", etResults[4]) + "\" / " + String.format("%1.2f", etResults[5]), etResults[4],
            (etResults[5] - ySpace));
    s660Time.setPaint(RED);
    s660Time.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    s660Time.setFont(new Font("SansSerif", Font.BOLD, 10));
    final XYAnnotation s1000Marker = new XYDrawableAnnotation(etResults[6], etResults[7], 10, 10, cd);
    final XYTextAnnotation s1000Label = new XYTextAnnotation(s1000Text, etResults[6], (etResults[7] + ySpace));
    s1000Label.setPaint(RED);
    s1000Label.setTextAnchor(TextAnchor.TOP_RIGHT);
    s1000Label.setFont(new Font("SansSerif", Font.BOLD, 10));
    final XYTextAnnotation s1000Time = new XYTextAnnotation(
            String.format("%1.3f", etResults[6]) + "\" / " + String.format("%1.2f", etResults[7]), etResults[6],
            (etResults[7] - ySpace));
    s1000Time.setPaint(RED);
    s1000Time.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    s1000Time.setFont(new Font("SansSerif", Font.BOLD, 10));
    final XYAnnotation s1320Marker = new XYDrawableAnnotation(etResults[8], etResults[9], 10, 10, cd);
    final XYTextAnnotation s1320Label = new XYTextAnnotation(s1320Text, etResults[8], (etResults[9] - ySpace));
    s1320Label.setPaint(RED);
    s1320Label.setTextAnchor(TextAnchor.BOTTOM_CENTER);
    s1320Label.setFont(new Font("SansSerif", Font.BOLD, 10));
    final XYTextAnnotation s1320Time = new XYTextAnnotation(
            String.format("%1.3f", etResults[8]) + "\" / " + String.format("%1.2f", etResults[9]),
            (etResults[8] - 0.2), etResults[9]);
    s1320Time.setPaint(RED);
    s1320Time.setTextAnchor(TextAnchor.CENTER_RIGHT);
    s1320Time.setFont(new Font("SansSerif", Font.BOLD, 10));
    final XYTextAnnotation carText = new XYTextAnnotation(car[0], (plot.getDomainAxis().getUpperBound() - 0.2),
            (hpAxis.getLowerBound() + ySpace));
    carText.setPaint(RED);
    carText.setTextAnchor(TextAnchor.BOTTOM_RIGHT);
    carText.setFont(new Font("SansSerif", Font.BOLD, 12));
    final XYAnnotation zTo60Marker = new XYDrawableAnnotation(etResults[10], etResults[11], 10, 10, cdGreen);
    final XYTextAnnotation zTo60Label = new XYTextAnnotation(zTo60Text, etResults[10],
            (etResults[11] + ySpace));
    zTo60Label.setPaint(GREEN);
    zTo60Label.setTextAnchor(TextAnchor.TOP_RIGHT);
    zTo60Label.setFont(new Font("SansSerif", Font.BOLD, 10));
    final XYTextAnnotation zTo60Time = new XYTextAnnotation((String.format("%1.3f", etResults[10]) + "\""),
            etResults[10], (etResults[11] - ySpace));
    zTo60Time.setPaint(GREEN);
    zTo60Time.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    zTo60Time.setFont(new Font("SansSerif", Font.BOLD, 10));
    plot.addAnnotation(s60Marker);
    plot.addAnnotation(s60Label);
    plot.addAnnotation(s60Time);
    plot.addAnnotation(s330Marker);
    plot.addAnnotation(s330Label);
    plot.addAnnotation(s330Time);
    plot.addAnnotation(s660Marker);
    plot.addAnnotation(s660Label);
    plot.addAnnotation(s660Time);
    plot.addAnnotation(s1000Marker);
    plot.addAnnotation(s1000Label);
    plot.addAnnotation(s1000Time);
    plot.addAnnotation(s1320Marker);
    plot.addAnnotation(s1320Label);
    plot.addAnnotation(s1320Time);
    plot.addAnnotation(carText);
    plot.addAnnotation(zTo60Marker);
    plot.addAnnotation(zTo60Label);
    plot.addAnnotation(zTo60Time);
}

From source file:com.sdk.connector.chart.TimeDomainRenderer.java

public void createAnnotation(String lap, double x, double y) {

    final CircleDrawer cd = new CircleDrawer(Color.GREEN, new BasicStroke(1.0f), null);
    final XYAnnotation lapLabel = new XYDrawableAnnotation(x, y, 15, 15, cd);
    lapAnnotations.add(lapLabel);//  ww  w  .  j  ava2  s.c om
    plot.addAnnotation(lapAnnotations.lastElement(), false);
    final XYPointerAnnotation pointer = new XYPointerAnnotation(
            java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle").getString("label.lap") + lap,
            x, y, 345);
    pointer.setBaseRadius(35.0);
    pointer.setTipRadius(10.0);
    pointer.setFont(new Font("DejaVu Sans", Font.BOLD, 11));
    pointer.setPaint(Color.black);
    pointer.setTextAnchor(TextAnchor.HALF_ASCENT_RIGHT);
    lapAnnotations.add(pointer);
    plot.addAnnotation(lapAnnotations.lastElement(), false);
}

From source file:lu.lippmann.cdb.ext.hydviga.ui.GapFillingFrame.java

private void showEnvelope(final int[] arr, final List<XYAnnotation> aaa) throws Exception {
    final Color cc = ColorHelper.getColorForAString(attr.name());
    final Color newcc = new Color(cc.getRed(), cc.getGreen(), cc.getBlue(), cc.getAlpha() / 4).brighter();

    final Map<Double, Double> minMap = new HashMap<Double, Double>();
    final Map<Double, Double> maxMap = new HashMap<Double, Double>();

    for (final Algo aall : Algo.values()) {
        Instances filteredDs2 = WekaDataProcessingUtil.buildFilteredByAttributesDataSet(dataSet, arr);

        filteredDs2 = WekaDataProcessingUtil.buildFilteredDataSet(filteredDs2, 0,
                filteredDs2.numAttributes() - 1, Math.max(0, this.position - this.valuesBeforeAndAfter),
                Math.min(this.position + this.gapsize + this.valuesBeforeAndAfter,
                        filteredDs2.numInstances() - 1));

        final GapFiller gp = GapFillerFactory.getGapFiller(aall);

        final Instances completedds2 = gp.fillGaps(filteredDs2);
        final Instances diff2 = WekaTimeSeriesUtil.buildDiff(filteredDs2, completedds2);

        //final double mae2=this.gapFiller.evaluateMeanAbsoluteError(filteredDs2,valuesBeforeAndAfterForMAE);

        final Instances decomposition2 = WekaTimeSeriesUtil.buildMergedDataSet(filteredDs2, diff2);
        final Attribute diffAttribute2 = decomposition2.attribute(attr.name() + "_diff");

        final Attribute timestampDiffAttribute2 = decomposition2
                .attribute(WekaDataStatsUtil.getFirstDateAttributeIdx(decomposition2));

        for (int i = 1; i < decomposition2.numInstances() - 1; i++) {
            if (!decomposition2.instance(i).isMissing(diffAttribute2)/*&&i%10==0*/) {
                final double d = decomposition2.instance(i).value(diffAttribute2);
                final double timestamp = decomposition2.instance(i).value(timestampDiffAttribute2);

                aaa.add(new XYDrawableAnnotation(timestamp, d, 1, 1, new AnnotationDrawer(newcc)));

                if (!minMap.containsKey(timestamp) || minMap.get(timestamp) > d)
                    minMap.put(timestamp, d);
                if (!maxMap.containsKey(timestamp) || maxMap.get(timestamp) < d)
                    maxMap.put(timestamp, d);
            }/* www .j ava  2  s. c  o  m*/
        }
    }

    for (final Map.Entry<Double, Double> entry : minMap.entrySet()) {
        final Double timestamp = entry.getKey();
        final Double min = minMap.get(timestamp);
        final Double max = maxMap.get(timestamp);
        if (min > max)
            throw new IllegalStateException("min>max -> " + min + ">" + max);
        else if (max > min) {
            final double step = (max - min) / 20d;
            for (double dd = min; dd <= max; dd += step) {
                aaa.add(new XYDrawableAnnotation(timestamp, dd, 1, 1, new AnnotationDrawer(newcc)));
            }
        }
    }

    System.out.println("done");
}

From source file:lu.lippmann.cdb.ext.hydviga.ui.GapFillingFrame.java

private void showError(final double mae, final Instances decomposition, final Attribute diffAttribute,
        final List<XYAnnotation> aaa) {
    //System.out.println("*************** SHOW ERROR **************************");
    final Attribute timestampDiffAttribute = decomposition
            .attribute(WekaDataStatsUtil.getFirstDateAttributeIdx(decomposition));
    final Color cc = ColorHelper.getColorForAString(diffAttribute.name());
    final Color newcc = new Color(cc.getRed(), cc.getGreen(), cc.getBlue(), cc.getAlpha() / 4).brighter();
    for (int i = 1; i < decomposition.numInstances() - 1; i++) {
        //if (i%10!=1) continue;
        if (!decomposition.instance(i).isMissing(diffAttribute)/*&&i%10==0*/) {
            final double d = decomposition.instance(i).value(diffAttribute);
            final double timestamp = decomposition.instance(i).value(timestampDiffAttribute);

            aaa.add(new XYDrawableAnnotation(timestamp, d + mae, 0.5, 0.5, new AnnotationDrawer(newcc)));
            aaa.add(new XYDrawableAnnotation(timestamp, d - mae, 0.5, 0.5, new AnnotationDrawer(newcc)));
            for (double dd = d - mae; dd <= d + mae; dd += mae / 20) {
                aaa.add(new XYDrawableAnnotation(timestamp, dd, 1, 1, new AnnotationDrawer(newcc)));
            }/* ww w  .  j  a  v a  2  s .c o  m*/
            //aaa.add(new XYDrawableAnnotation(timestamp,d,1,1,new AnnotationDrawer(cc)));
        }
    }
    //System.out.println("*****************************************************");
}