org.jfree.chart.annotations.XYLineAnnotation Java Examples

The following examples show how to use org.jfree.chart.annotations.XYLineAnnotation. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ScatterPlot.java    From Benchmark with GNU General Public License v2.0 6 votes vote down vote up
public static void makeGuessingLine(XYPlot xyplot) {
    // draw guessing line
    XYLineAnnotation guessing = new XYLineAnnotation(-5, -5, 100, 100, dashed, Color.red);
    xyplot.addAnnotation(guessing);

    XYPointerAnnotation worse = makePointer(80, 0, "Worse than guessing", TextAnchor.TOP_CENTER, 90);
    xyplot.addAnnotation(worse);

    XYPointerAnnotation better = makePointer(25, 100, "Better than guessing", TextAnchor.BOTTOM_CENTER, 270);
    xyplot.addAnnotation(better);

    XYTextAnnotation stroketext = new XYTextAnnotation("                     Random Guess", 88, 107);
    stroketext.setTextAnchor(TextAnchor.CENTER_RIGHT);
    stroketext.setBackgroundPaint(Color.white);
    stroketext.setPaint(Color.red);
    stroketext.setFont(theme.getRegularFont());
    xyplot.addAnnotation(stroketext);

    XYLineAnnotation strokekey = new XYLineAnnotation(58, 107, 68, 107, dashed, Color.red);
    xyplot.setBackgroundPaint(Color.white);
    xyplot.addAnnotation(strokekey);
}
 
Example #2
Source File: TimeSeriesGraphModel.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
void updateAnnotation(RasterDataNode raster) {
    removeAnnotation();

    final AbstractTimeSeries timeSeries = getTimeSeries();
    TimeCoding timeCoding = timeSeries.getRasterTimeMap().get(raster);
    if (timeCoding != null) {
        final ProductData.UTC startTime = timeCoding.getStartTime();
        final Millisecond timePeriod = new Millisecond(startTime.getAsDate(),
                ProductData.UTC.UTC_TIME_ZONE,
                Locale.getDefault());

        double millisecond = timePeriod.getFirstMillisecond();
        Range valueRange = null;
        for (int i = 0; i < timeSeriesPlot.getRangeAxisCount(); i++) {
            valueRange = Range.combine(valueRange, timeSeriesPlot.getRangeAxis(i).getRange());
        }
        if (valueRange != null) {
            XYAnnotation annotation = new XYLineAnnotation(millisecond, valueRange.getLowerBound(), millisecond,
                    valueRange.getUpperBound());
            timeSeriesPlot.addAnnotation(annotation, true);
        }
    }
}
 
Example #3
Source File: XYLineAnnotationTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Two objects that are equal are required to return the same hashCode.
 */
public void testHashCode() {
    Stroke stroke = new BasicStroke(2.0f);
    XYLineAnnotation a1 = new XYLineAnnotation(10.0, 20.0, 100.0, 200.0,
            stroke, Color.blue);
    XYLineAnnotation a2 = new XYLineAnnotation(10.0, 20.0, 100.0, 200.0,
            stroke, Color.blue);
    assertTrue(a1.equals(a2));
    int h1 = a1.hashCode();
    int h2 = a2.hashCode();
    assertEquals(h1, h2);
}
 
Example #4
Source File: XYLineAnnotationTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks that this class implements PublicCloneable.
 */
public void testPublicCloneable() {
    Stroke stroke = new BasicStroke(2.0f);
    XYLineAnnotation a1 = new XYLineAnnotation(10.0, 20.0, 100.0, 200.0,
            stroke, Color.blue);
    assertTrue(a1 instanceof PublicCloneable);
}
 
Example #5
Source File: XYLineAnnotationTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Two objects that are equal are required to return the same hashCode. 
 */
public void testHashCode() {
    Stroke stroke = new BasicStroke(2.0f);
    XYLineAnnotation a1 = new XYLineAnnotation(
        10.0, 20.0, 100.0, 200.0, stroke, Color.blue
    );
    XYLineAnnotation a2 = new XYLineAnnotation(
        10.0, 20.0, 100.0, 200.0, stroke, Color.blue
    );
    assertTrue(a1.equals(a2));
    int h1 = a1.hashCode();
    int h2 = a2.hashCode();
    assertEquals(h1, h2);
}