Java 类org.jfree.chart.annotations.XYPointerAnnotation 实例源码

项目:Benchmark    文件:ScatterPlot.java   
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(75, 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);
}
项目:Benchmark    文件:ScatterPlot.java   
public static void makePointer(XYPlot plot, double x, double y, String msg, TextAnchor anchor, int angle ) {
//        TextTitle textTitle = new TextTitle(msg, theme.getSmallFont(), Color.red, RectangleEdge.TOP, HorizontalAlignment.LEFT, VerticalAlignment.TOP, new RectangleInsets(2, 2, 2, 2));
//        XYTitleAnnotation title = new XYTitleAnnotation(x/100, y/100, textTitle, RectangleAnchor.TOP_LEFT);
//        plot.addAnnotation( title );

        XYPointerAnnotation pointer = new XYPointerAnnotation(msg, x, y, Math.toRadians(angle));
        pointer.setBackgroundPaint(Color.white);
        pointer.setTextAnchor(anchor);
        pointer.setArrowWidth(4);
        pointer.setArrowLength(8);
        pointer.setArrowPaint(Color.red);
        pointer.setLabelOffset(2);
        pointer.setPaint(Color.red);
        pointer.setFont(theme.getRegularFont());
        plot.addAnnotation(pointer);;
    }
项目:parabuild-ci    文件:XYPointerAnnotationTests.java   
/**
 * Two objects that are equal are required to return the same hashCode. 
 */
public void testHashCode() {
    XYPointerAnnotation a1 = new XYPointerAnnotation("Label", 10.0, 20.0, 
            Math.PI);
    XYPointerAnnotation a2 = new XYPointerAnnotation("Label", 10.0, 20.0, 
            Math.PI);
    assertTrue(a1.equals(a2));
    int h1 = a1.hashCode();
    int h2 = a2.hashCode();
    assertEquals(h1, h2);
}
项目:scalalab    文件:jPlot.java   
/**
 * Draws annotation on the chart.
 *
 * @param x          pointer X position
 * @param y          pointer Y position
 * @param annotation annotation text
 * @param angle      annotation line angle in degrees
 */
public void addAnnotation(double x, double y, String annotation, float angle) {
    m_xyAnnotation = new XYPointerAnnotation(annotation,
            x,
            y,
            -angle * Math.PI / 180);
    m_xyAnnotation.setLabelOffset(m_xyAnnotation.getLabelOffset() * 2 + 10);

    if (m_chart != null) {
        XYPlot plot = m_chart.getXYPlot();
        plot.addAnnotation(m_xyAnnotation);
    }
}
项目:Benchmark    文件:ScatterPlot.java   
public static 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);
    pointer.setArrowWidth(4);
    pointer.setArrowLength(8);
    pointer.setArrowPaint(Color.red);
    pointer.setLabelOffset(2);
    pointer.setPaint(Color.red);
    pointer.setFont(theme.getRegularFont());
    return pointer;
}
项目:nabs    文件:XYPointerAnnotationTests.java   
/**
 * Two objects that are equal are required to return the same hashCode. 
 */
public void testHashCode() {
    XYPointerAnnotation a1 = new XYPointerAnnotation("Label", 10.0, 20.0, 
            Math.PI);
    XYPointerAnnotation a2 = new XYPointerAnnotation("Label", 10.0, 20.0, 
            Math.PI);
    assertTrue(a1.equals(a2));
    int h1 = a1.hashCode();
    int h2 = a2.hashCode();
    assertEquals(h1, h2);
}
项目:astor    文件:XYPointerAnnotationTests.java   
/**
 * Two objects that are equal are required to return the same hashCode.
 */
public void testHashCode() {
    XYPointerAnnotation a1 = new XYPointerAnnotation("Label", 10.0, 20.0,
            Math.PI);
    XYPointerAnnotation a2 = new XYPointerAnnotation("Label", 10.0, 20.0,
            Math.PI);
    assertTrue(a1.equals(a2));
    int h1 = a1.hashCode();
    int h2 = a2.hashCode();
    assertEquals(h1, h2);
}
项目:EFTEMj    文件:AngularAperture.java   
private void stylePointer(final XYPointerAnnotation pointer) {
    pointer.setLabelOffset(15);
    pointer.setBaseRadius(50.0);
    pointer.setTipRadius(5);
    pointer.setFont(new Font("SansSerif", Font.PLAIN, 12));
    pointer.setPaint(Color.blue);
    pointer.setTextAnchor(TextAnchor.HALF_ASCENT_CENTER);
}
项目:parabuild-ci    文件:XYPointerAnnotationTests.java   
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {

    XYPointerAnnotation a1 = new XYPointerAnnotation("Label", 10.0, 20.0, Math.PI);
    XYPointerAnnotation a2 = new XYPointerAnnotation("Label", 10.0, 20.0, Math.PI);
    assertTrue(a1.equals(a2));

    //private double angle;
    a1.setAngle(Math.PI / 4.0);
    assertFalse(a1.equals(a2));
    a2.setAngle(Math.PI / 4.0);
    assertTrue(a1.equals(a2));

    //private double tipRadius;
    a1.setTipRadius(20.0);
    assertFalse(a1.equals(a2));
    a2.setTipRadius(20.0);
    assertTrue(a1.equals(a2));

    //private double baseRadius;
    a1.setBaseRadius(5.0);
    assertFalse(a1.equals(a2));
    a2.setBaseRadius(5.0);
    assertTrue(a1.equals(a2));

    //private double arrowLength;
    a1.setArrowLength(33.0);
    assertFalse(a1.equals(a2));
    a2.setArrowLength(33.0);
    assertTrue(a1.equals(a2));

    //private double arrowWidth;
    a1.setArrowWidth(9.0);
    assertFalse(a1.equals(a2));
    a2.setArrowWidth(9.0);
    assertTrue(a1.equals(a2));

    //private Stroke arrowStroke;
    Stroke stroke = new BasicStroke(1.5f);
    a1.setArrowStroke(stroke);
    assertFalse(a1.equals(a2));
    a2.setArrowStroke(stroke);
    assertTrue(a1.equals(a2));

    //private Paint arrowPaint;
    a1.setArrowPaint(Color.blue);
    assertFalse(a1.equals(a2));
    a2.setArrowPaint(Color.blue);
    assertTrue(a1.equals(a2));

    //private double labelOffset;
    a1.setLabelOffset(10.0);
    assertFalse(a1.equals(a2));
    a2.setLabelOffset(10.0);
    assertTrue(a1.equals(a2));

}
项目:astor    文件:XYPointerAnnotationTests.java   
/**
 * Checks that this class implements PublicCloneable.
 */
public void testPublicCloneable() {
    XYPointerAnnotation a1 = new XYPointerAnnotation("Label", 10.0, 20.0,
            Math.PI);
    assertTrue(a1 instanceof PublicCloneable);
}
项目:EFTEMj    文件:AngularAperture.java   
@Override
public void run(final String arg0) {
    // http://www.tutorialspoint.com/jfreechart/index.htm
    final ApplicationFrame chart = new ApplicationFrame("Angular aperture");
    final JFreeChart xyChart = ChartFactory.createXYLineChart(
        "Angular aperture", "aperture diameter in µm", "delta in nm",
        createDataset(), PlotOrientation.VERTICAL, true, true, false);
    final ChartPanel chartPanel = new ChartPanel(xyChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(800, 600));
    final XYPlot plot = xyChart.getXYPlot();
    final ValueAxis axis = plot.getRangeAxis();
    axis.setAutoRange(false);
    axis.setUpperBound(2.0);
    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesPaint(0, Color.RED);
    renderer.setSeriesPaint(1, Color.GREEN);
    renderer.setSeriesPaint(2, Color.BLUE);
    renderer.setSeriesStroke(0, new BasicStroke(2f));
    renderer.setSeriesShapesVisible(0, false);
    renderer.setSeriesShapesVisible(1, false);
    renderer.setSeriesShapesVisible(2, false);
    plot.setRenderer(renderer);

    final double x_opt = mrad2µm(alpha_opt);
    final double y_opt = 0.9 * Math.pow(C_s * Math.pow(lambda, 3), 0.25) * 1e9;
    final XYLineAnnotation line = new XYLineAnnotation(0, y_opt, mrad2µm(Math
        .ceil(2 * alpha_opt)), y_opt);
    plot.addAnnotation(line);
    final XYPointerAnnotation pointer = new XYPointerAnnotation(String.format(
        "Smallest error disc: %.2g nm @ %.1f µm", y_opt, x_opt), x_opt, y_opt,
        5.0 * Math.PI / 4.0);
    stylePointer(pointer);
    plot.addAnnotation(pointer);
    final double aperture_alpha = 0.5 * 20 * 1e-6 / fl;
    final XYPointerAnnotation resolution = new XYPointerAnnotation(String
        .format("Resolution with %.0f µm aperture: %.2f nm", mrad2µm(
            aperture_alpha * 1e3), delta(aperture_alpha) * 1e9), mrad2µm(
                aperture_alpha * 1e3), delta(aperture_alpha) * 1e9, 1.0 * Math.PI /
                    4.0);
    stylePointer(resolution);

    plot.addAnnotation(resolution);

    chart.setContentPane(chartPanel);
    chart.pack();
    RefineryUtilities.centerFrameOnScreen(chart);
    chart.setVisible(true);
}