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

项目:eurocarbdb    文件:PeakListChartPanel.java   
private void showSelection() {    
thePlot.clearAnnotations();
if( selected_peaks.size()>0 ) {        
    double width = screenToDataX(6.);
    double height = screenToDataY(6.);
    double margin = screenToDataY(8.);
    for( Peak p : selected_peaks ) {
    // add annotation
    Shape shape = new Rectangle2D.Double(p.getMZ()-width/2.,p.getIntensity()-height/2.,width,height);
    if( p.equals(current_peak) ) {
        thePlot.addAnnotation( new XYShapeAnnotation(shape,new BasicStroke(2.f),Color.black) );    
        thePlot.addAnnotation( new XYTextAnnotation(new java.text.DecimalFormat("0.0000").format(p.getMZ()), p.getMZ(), p.getIntensity() + margin ) );    
    }
    else
        thePlot.addAnnotation( new XYShapeAnnotation(shape,new BasicStroke(1.f),Color.black) );    
    }
}
}
项目:eurocarbdb    文件:SpectraPanel.java   
private void showSelection() {    
thePlot.clearAnnotations();
if( selected_peaks.size()>0 ) {        
    double width = screenToDataX(6.);
    double height = screenToDataY(6.);
    double margin = screenToDataY(8.);
    for( Peak p : selected_peaks ) {
    // add annotation
    Shape shape = new Rectangle2D.Double(p.getMZ()-width/2.,p.getIntensity()-height/2.,width,height);
    if( p.equals(current_peak) ) {
        thePlot.addAnnotation( new XYShapeAnnotation(shape,new BasicStroke(2.f),Color.blue) );    
        thePlot.addAnnotation( new XYTextAnnotation(new java.text.DecimalFormat("0.0000").format(p.getMZ()), p.getMZ(), p.getIntensity() + margin ) );    
    }
    else
        thePlot.addAnnotation( new XYShapeAnnotation(shape,new BasicStroke(1.f),Color.black) );    
    }
}
}
项目:Benchmark    文件:ScatterVulns.java   
private void makeDataLabels(String category, Set<Report> toolResults, XYPlot xyplot) {
    HashMap<Point2D, String> map = makePointList(category, toolResults);
    for (Entry<Point2D, String> e : map.entrySet()) {
        if (e.getValue() != null) {
            Point2D p = e.getKey();
            String label = sort(e.getValue());
            XYTextAnnotation annotation = new XYTextAnnotation(label, p.getX(), p.getY());
            annotation.setTextAnchor(p.getX() < 3 ? TextAnchor.TOP_LEFT : TextAnchor.TOP_CENTER);
            annotation.setBackgroundPaint(Color.white);
            if (label.toCharArray()[0] == averageLabel) {
                annotation.setPaint(Color.magenta);
            } else {
                annotation.setPaint(Color.blue);
            }
            annotation.setFont(theme.getRegularFont());
            xyplot.addAnnotation(annotation);
        }
    }
}
项目:Benchmark    文件:ScatterTools.java   
private void makeDataLabels(OverallResults or, XYPlot xyplot) {
    HashMap<Point2D, String> map = makePointList(or);
    for (Entry<Point2D, String> e : map.entrySet()) {
        if (e.getValue() != null) {
            Point2D p = e.getKey();
            String label = sort(e.getValue());
            XYTextAnnotation annotation = new XYTextAnnotation(label, p.getX(), p.getY());
            annotation.setTextAnchor(p.getX() < 3 ? TextAnchor.TOP_LEFT : TextAnchor.TOP_CENTER);
            annotation.setBackgroundPaint(Color.white);
            // set color of average to black and everything else to blue
            if(averageLabel==label.toCharArray()[0]){
                annotation.setPaint(Color.magenta);
            } else {
                annotation.setPaint(Color.blue);
            }
            annotation.setFont(theme.getRegularFont());
            xyplot.addAnnotation(annotation);
        }
    }
}
项目: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    文件:ScatterHome.java   
private void makeDataLabels( Set<Report> toolResults, XYPlot xyplot ) {        
    HashMap<Point2D,String> map = makePointList( toolResults );
    for (Entry<Point2D,String> e : map.entrySet() ) {
        if ( e.getValue() != null ) {
            Point2D p = e.getKey();
            String label = sort( e.getValue() );
            XYTextAnnotation annotation = new XYTextAnnotation( label, p.getX(), p.getY());
            annotation.setTextAnchor( p.getX() < 3 ? TextAnchor.TOP_LEFT : TextAnchor.TOP_CENTER);
            annotation.setBackgroundPaint(Color.white);
            if (label.toCharArray()[0] == averageLabel)
            {
                annotation.setPaint(Color.magenta);
            } else {
                annotation.setPaint(Color.blue);
            }
            annotation.setFont(theme.getRegularFont());
            xyplot.addAnnotation(annotation);
        }
    }
}
项目:mitraq    文件:MiTRAQ.java   
/**
 * Remove the data point annotation in the fold change plot.
 */
private void removeDataPointAnnotations() {
    if (foldChangeplot != null && foldChangeplot.getAnnotations() != null) {

        Iterator iterator = foldChangeplot.getAnnotations().iterator();

        // store the keys in a list first to escape a ConcurrentModificationException
        ArrayList<XYTextAnnotation> tempAnnotations = new ArrayList<XYTextAnnotation>();

        while (iterator.hasNext()) {
            tempAnnotations.add((XYTextAnnotation) iterator.next());
        }

        for (int i = 0; i < tempAnnotations.size(); i++) {
            if (tempAnnotations.get(i).getText().startsWith("Current: ")) {
                foldChangeplot.removeAnnotation(tempAnnotations.get(i));
            }
        }
    }
}
项目:opensim-gui    文件:FunctionPanel.java   
/** Creates a new instance of FunctionPanel */
public FunctionPanel(JFreeChart chart) {
   super(chart);
   //this.setFocusable(true);
   this.functionPanelListeners = new EventListenerList();
   this.renderer = (XYLineAndShapeRendererWithHighlight) chart.getXYPlot().getRenderer();
   this.enableEvents(AWTEvent.INPUT_METHOD_EVENT_MASK);
   this.enableEvents(AWTEvent.KEY_EVENT_MASK);
   this.addKeyListener(this);
   this.nodePopUpMenu = createNodePopupMenu();
   this.addNodePopUpMenu = createAddNodePopupMenu();
   this.crosshairAnnotation = new XYTextAnnotation("", 0, 0);
   this.crosshairAnnotation.setTextAnchor(TextAnchor.BOTTOM_LEFT);
   // Make sure the X and Y ranges are not zero, which messes up the display
   chart.getXYPlot().getDomainAxis().setAutoRangeMinimumSize(0.000001);
   chart.getXYPlot().getRangeAxis().setAutoRangeMinimumSize(0.000001);
   //chart.getXYPlot().getRangeAxis().setAutoRange(false);
   //chart.getXYPlot().getRangeAxis().setRangeWithMargins(0.0, 1.0);
   //chart.getXYPlot().getRangeAxis().addChangeListener(new EnforceExcitationRange());
}
项目:pm    文件:ChartMain.java   
public ChartMain(Date startDate, JFreeChartTimePeriod jFreeTimePeriod) {
    super();

    this.jFreeTimePeriod = jFreeTimePeriod;
    UIManager.put("ToolTip.background", new java.awt.Color(239, 203, 152, 255));
    UIManager.put("ToolTip.foreground", java.awt.Color.BLACK);

    //ToolTipManager.sharedInstance().setInitialDelay(100);
    ToolTipManager.sharedInstance().setInitialDelay(20);
    //ToolTipManager.sharedInstance().setReshowDelay(0);
    ToolTipManager.sharedInstance().setDismissDelay(120000);

    XYBarRenderer.setDefaultShadowsVisible(false);
    XYBarRenderer.setDefaultBarPainter(new StandardXYBarPainter());

    barChartDisplayStrategy = new ChartBarSquare(this);

    lineAnnotations = new HashMap<Long, XYTextAnnotation>();

}
项目:parabuild-ci    文件:CombinedDomainXYPlotTests.java   
/**
 * Creates a sample plot.
 * 
 * @return A sample plot.
 */
private CombinedDomainXYPlot createPlot() {
    // create subplot 1...
    XYDataset data1 = createDataset1();
    XYItemRenderer renderer1 = new StandardXYItemRenderer();
    NumberAxis rangeAxis1 = new NumberAxis("Range 1");
    XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1);
    subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    XYTextAnnotation annotation = new XYTextAnnotation("Hello!", 50.0, 10000.0);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 9));
    annotation.setRotationAngle(Math.PI / 4.0);
    subplot1.addAnnotation(annotation);

    // create subplot 2...
    XYDataset data2 = createDataset2();
    XYItemRenderer renderer2 = new StandardXYItemRenderer();
    NumberAxis rangeAxis2 = new NumberAxis("Range 2");
    rangeAxis2.setAutoRangeIncludesZero(false);
    XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2);
    subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);

    // parent plot...
    CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Domain"));
    plot.setGap(10.0);

    // add the subplots...
    plot.add(subplot1, 1);
    plot.add(subplot2, 1);
    plot.setOrientation(PlotOrientation.VERTICAL);
    return plot;
}
项目:parabuild-ci    文件:CombinedRangeXYPlotTests.java   
/**
 * Creates a sample plot.
 * 
 * @return A sample plot.
 */
private CombinedRangeXYPlot createPlot() {
    // create subplot 1...
    XYDataset data1 = createDataset1();
    XYItemRenderer renderer1 = new StandardXYItemRenderer();
    NumberAxis rangeAxis1 = new NumberAxis("Range 1");
    XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1);
    subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    XYTextAnnotation annotation = new XYTextAnnotation("Hello!", 50.0, 10000.0);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 9));
    annotation.setRotationAngle(Math.PI / 4.0);
    subplot1.addAnnotation(annotation);

    // create subplot 2...
    XYDataset data2 = createDataset2();
    XYItemRenderer renderer2 = new StandardXYItemRenderer();
    NumberAxis rangeAxis2 = new NumberAxis("Range 2");
    rangeAxis2.setAutoRangeIncludesZero(false);
    XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2);
    subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); 

    // parent plot...
    CombinedRangeXYPlot plot = new CombinedRangeXYPlot(new NumberAxis("Range"));
    plot.setGap(10.0);

    // add the subplots...
    plot.add(subplot1, 1);
    plot.add(subplot2, 1);
    plot.setOrientation(PlotOrientation.VERTICAL);
    return plot;
}
项目:parabuild-ci    文件:XYTextAnnotationTests.java   
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {

    XYTextAnnotation a1 = new XYTextAnnotation("Text", 10.0, 20.0);
    XYTextAnnotation a2 = new XYTextAnnotation("Text", 10.0, 20.0);
    assertTrue(a1.equals(a2));

}
项目:parabuild-ci    文件:CombinedDomainXYPlotTests.java   
/**
 * Creates a sample plot.
 * 
 * @return A sample plot.
 */
private CombinedDomainXYPlot createPlot() {
    // create subplot 1...
    XYDataset data1 = createDataset1();
    XYItemRenderer renderer1 = new StandardXYItemRenderer();
    NumberAxis rangeAxis1 = new NumberAxis("Range 1");
    XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1);
    subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    XYTextAnnotation annotation 
        = new XYTextAnnotation("Hello!", 50.0, 10000.0);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 9));
    annotation.setRotationAngle(Math.PI / 4.0);
    subplot1.addAnnotation(annotation);

    // create subplot 2...
    XYDataset data2 = createDataset2();
    XYItemRenderer renderer2 = new StandardXYItemRenderer();
    NumberAxis rangeAxis2 = new NumberAxis("Range 2");
    rangeAxis2.setAutoRangeIncludesZero(false);
    XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2);
    subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);

    // parent plot...
    CombinedDomainXYPlot plot 
        = new CombinedDomainXYPlot(new NumberAxis("Domain"));
    plot.setGap(10.0);

    // add the subplots...
    plot.add(subplot1, 1);
    plot.add(subplot2, 1);
    plot.setOrientation(PlotOrientation.VERTICAL);
    return plot;
}
项目:parabuild-ci    文件:CombinedRangeXYPlotTests.java   
/**
 * Creates a sample plot.
 * 
 * @return A sample plot.
 */
private CombinedRangeXYPlot createPlot() {
    // create subplot 1...
    XYDataset data1 = createDataset1();
    XYItemRenderer renderer1 = new StandardXYItemRenderer();
    NumberAxis rangeAxis1 = new NumberAxis("Range 1");
    XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1);
    subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    XYTextAnnotation annotation 
        = new XYTextAnnotation("Hello!", 50.0, 10000.0);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 9));
    annotation.setRotationAngle(Math.PI / 4.0);
    subplot1.addAnnotation(annotation);

    // create subplot 2...
    XYDataset data2 = createDataset2();
    XYItemRenderer renderer2 = new StandardXYItemRenderer();
    NumberAxis rangeAxis2 = new NumberAxis("Range 2");
    rangeAxis2.setAutoRangeIncludesZero(false);
    XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2);
    subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); 

    // parent plot...
    CombinedRangeXYPlot plot 
        = new CombinedRangeXYPlot(new NumberAxis("Range"));
    plot.setGap(10.0);

    // add the subplots...
    plot.add(subplot1, 1);
    plot.add(subplot2, 1);
    plot.setOrientation(PlotOrientation.VERTICAL);
    return plot;
}
项目:parabuild-ci    文件:XYTextAnnotationTests.java   
/**
 * Two objects that are equal are required to return the same hashCode. 
 */
public void testHashCode() {
    XYTextAnnotation a1 = new XYTextAnnotation("Text", 10.0, 20.0);
    XYTextAnnotation a2 = new XYTextAnnotation("Text", 10.0, 20.0);
    assertTrue(a1.equals(a2));
    int h1 = a1.hashCode();
    int h2 = a2.hashCode();
    assertEquals(h1, h2);
}
项目:ccu-historian    文件:YIntervalRendererTest.java   
/**
 * Confirm that cloning works.
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    YIntervalRenderer r1 = new YIntervalRenderer();
    YIntervalRenderer r2 = (YIntervalRenderer) r1.clone();
    assertTrue(r1 != r2);
    assertTrue(r1.getClass() == r2.getClass());
    assertTrue(r1.equals(r2));

    // check independence
    r1.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator());
    assertFalse(r1.equals(r2));
    r2.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator());
    assertTrue(r1.equals(r2));

    r1.setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator());
    assertFalse(r1.equals(r2));
    r2.setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator());
    assertTrue(r1.equals(r2));

    r1.addAnnotation(new XYTextAnnotation("ABC", 1.0, 2.0),
            Layer.FOREGROUND);
    assertFalse(r1.equals(r2));
    r2.addAnnotation(new XYTextAnnotation("ABC", 1.0, 2.0),
            Layer.FOREGROUND);
    assertTrue(r1.equals(r2));

    r1.addAnnotation(new XYTextAnnotation("ABC", 1.0, 2.0),
            Layer.BACKGROUND);
    assertFalse(r1.equals(r2));
    r2.addAnnotation(new XYTextAnnotation("ABC", 1.0, 2.0),
            Layer.BACKGROUND);
    assertTrue(r1.equals(r2));

}
项目:ccu-historian    文件:CombinedDomainXYPlotTest.java   
/**
 * Creates a sample plot.
 *
 * @return A sample plot.
 */
private CombinedDomainXYPlot createPlot() {
    // create subplot 1...
    XYDataset data1 = createDataset1();
    XYItemRenderer renderer1 = new StandardXYItemRenderer();
    NumberAxis rangeAxis1 = new NumberAxis("Range 1");
    XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1);
    subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    XYTextAnnotation annotation = new XYTextAnnotation("Hello!", 50.0,
            10000.0);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 9));
    annotation.setRotationAngle(Math.PI / 4.0);
    subplot1.addAnnotation(annotation);

    // create subplot 2...
    XYDataset data2 = createDataset2();
    XYItemRenderer renderer2 = new StandardXYItemRenderer();
    NumberAxis rangeAxis2 = new NumberAxis("Range 2");
    rangeAxis2.setAutoRangeIncludesZero(false);
    XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2);
    subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);

    // parent plot...
    CombinedDomainXYPlot plot = new CombinedDomainXYPlot(
            new NumberAxis("Domain"));
    plot.setGap(10.0);

    // add the subplots...
    plot.add(subplot1, 1);
    plot.add(subplot2, 1);
    plot.setOrientation(PlotOrientation.VERTICAL);
    return plot;
}
项目:ccu-historian    文件:CombinedRangeXYPlotTest.java   
/**
 * Creates a sample plot.
 *
 * @return A sample plot.
 */
private CombinedRangeXYPlot createPlot() {
    // create subplot 1...
    XYDataset data1 = createDataset1();
    XYItemRenderer renderer1 = new StandardXYItemRenderer();
    NumberAxis xAxis1 = new NumberAxis("X1");
    XYPlot subplot1 = new XYPlot(data1, xAxis1, null, renderer1);
    subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    XYTextAnnotation annotation
            = new XYTextAnnotation("Hello!", 50.0, 10000.0);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 9));
    annotation.setRotationAngle(Math.PI / 4.0);
    subplot1.addAnnotation(annotation);

    // create subplot 2...
    XYDataset data2 = createDataset2();
    XYItemRenderer renderer2 = new StandardXYItemRenderer();
    NumberAxis xAxis2 = new NumberAxis("X2");
    xAxis2.setAutoRangeIncludesZero(false);
    XYPlot subplot2 = new XYPlot(data2, xAxis2, null, renderer2);
    subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);

    // parent plot...
    CombinedRangeXYPlot plot = new CombinedRangeXYPlot(new NumberAxis(
            "Range"));
    plot.setGap(10.0);

    // add the subplots...
    plot.add(subplot1, 1);
    plot.add(subplot2, 1);
    plot.setOrientation(PlotOrientation.VERTICAL);
    return plot;
}
项目:ccu-historian    文件:StandardChartTheme.java   
/**
 * Applies the settings of this theme to the specified annotation.
 *
 * @param annotation  the annotation.
 */
protected void applyToXYAnnotation(XYAnnotation annotation) {
    ParamChecks.nullNotPermitted(annotation, "annotation");
    if (annotation instanceof XYTextAnnotation) {
        XYTextAnnotation xyta = (XYTextAnnotation) annotation;
        xyta.setFont(this.smallFont);
        xyta.setPaint(this.itemLabelPaint);
    }
}
项目:jfreechart    文件:StandardChartTheme.java   
/**
 * Applies the settings of this theme to the specified annotation.
 *
 * @param annotation  the annotation.
 */
protected void applyToXYAnnotation(XYAnnotation annotation) {
    Args.nullNotPermitted(annotation, "annotation");
    if (annotation instanceof XYTextAnnotation) {
        XYTextAnnotation xyta = (XYTextAnnotation) annotation;
        xyta.setFont(this.smallFont);
        xyta.setPaint(this.itemLabelPaint);
    }
}
项目:jfreechart    文件:YIntervalRendererTest.java   
/**
 * Confirm that cloning works.
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    YIntervalRenderer r1 = new YIntervalRenderer();
    YIntervalRenderer r2 = (YIntervalRenderer) r1.clone();
    assertTrue(r1 != r2);
    assertTrue(r1.getClass() == r2.getClass());
    assertTrue(r1.equals(r2));

    // check independence
    r1.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator());
    assertFalse(r1.equals(r2));
    r2.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator());
    assertTrue(r1.equals(r2));

    r1.setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator());
    assertFalse(r1.equals(r2));
    r2.setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator());
    assertTrue(r1.equals(r2));

    r1.addAnnotation(new XYTextAnnotation("ABC", 1.0, 2.0),
            Layer.FOREGROUND);
    assertFalse(r1.equals(r2));
    r2.addAnnotation(new XYTextAnnotation("ABC", 1.0, 2.0),
            Layer.FOREGROUND);
    assertTrue(r1.equals(r2));

    r1.addAnnotation(new XYTextAnnotation("ABC", 1.0, 2.0),
            Layer.BACKGROUND);
    assertFalse(r1.equals(r2));
    r2.addAnnotation(new XYTextAnnotation("ABC", 1.0, 2.0),
            Layer.BACKGROUND);
    assertTrue(r1.equals(r2));

}
项目:jfreechart    文件:CombinedDomainXYPlotTest.java   
/**
 * Creates a sample plot.
 *
 * @return A sample plot.
 */
private CombinedDomainXYPlot createPlot() {
    // create subplot 1...
    XYDataset data1 = createDataset1();
    XYItemRenderer renderer1 = new StandardXYItemRenderer();
    NumberAxis rangeAxis1 = new NumberAxis("Range 1");
    XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1);
    subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    XYTextAnnotation annotation = new XYTextAnnotation("Hello!", 50.0,
            10000.0);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 9));
    annotation.setRotationAngle(Math.PI / 4.0);
    subplot1.addAnnotation(annotation);

    // create subplot 2...
    XYDataset data2 = createDataset2();
    XYItemRenderer renderer2 = new StandardXYItemRenderer();
    NumberAxis rangeAxis2 = new NumberAxis("Range 2");
    rangeAxis2.setAutoRangeIncludesZero(false);
    XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2);
    subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);

    // parent plot...
    CombinedDomainXYPlot plot = new CombinedDomainXYPlot(
            new NumberAxis("Domain"));
    plot.setGap(10.0);

    // add the subplots...
    plot.add(subplot1, 1);
    plot.add(subplot2, 1);
    plot.setOrientation(PlotOrientation.VERTICAL);
    return plot;
}
项目:jfreechart    文件:CombinedRangeXYPlotTest.java   
/**
 * Creates a sample plot.
 *
 * @return A sample plot.
 */
private CombinedRangeXYPlot createPlot() {
    // create subplot 1...
    XYDataset data1 = createDataset1();
    XYItemRenderer renderer1 = new StandardXYItemRenderer();
    NumberAxis xAxis1 = new NumberAxis("X1");
    XYPlot subplot1 = new XYPlot(data1, xAxis1, null, renderer1);
    subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    XYTextAnnotation annotation
            = new XYTextAnnotation("Hello!", 50.0, 10000.0);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 9));
    annotation.setRotationAngle(Math.PI / 4.0);
    subplot1.addAnnotation(annotation);

    // create subplot 2...
    XYDataset data2 = createDataset2();
    XYItemRenderer renderer2 = new StandardXYItemRenderer();
    NumberAxis xAxis2 = new NumberAxis("X2");
    xAxis2.setAutoRangeIncludesZero(false);
    XYPlot subplot2 = new XYPlot(data2, xAxis2, null, renderer2);
    subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);

    // parent plot...
    CombinedRangeXYPlot plot = new CombinedRangeXYPlot(new NumberAxis(
            "Range"));
    plot.setGap(10.0);

    // add the subplots...
    plot.add(subplot1, 1);
    plot.add(subplot2, 1);
    plot.setOrientation(PlotOrientation.VERTICAL);
    return plot;
}
项目:seqcode-core    文件:ScatterData.java   
/**
 * Get annotated datapoints for a dataset
 * @param ID
 * @return
 */
public List<XYTextAnnotation> getAnnotations(int ID, double xshift,double yshift, TextAnchor anchor, int textSize, int style, Color c){
    List<XYTextAnnotation> annot = new ArrayList<XYTextAnnotation>();
    for(int i=0; i<data.get(ID).annotations.length; i++){
        XYTextAnnotation a = new XYTextAnnotation(data.get(ID).annotations[i], data.get(ID).annotationCoords.get(i,0)+xshift, data.get(ID).annotationCoords.get(i,0)+yshift);
        a.setFont(new Font("Tahoma", style, textSize));
        a.setTextAnchor(anchor);
        a.setPaint(c);
        annot.add(a);
    }
    return annot;
}
项目:seqcode-core    文件:ScatterPlot.java   
/**
 * Add a dataset to the plot
 * @param name  String
 * @param datasetMatrix  2D matrix
 * @param c   Color
 * @param dotSize  int 
 * @param drawAnnotations  boolean
 */
public void addDataset(String name, Matrix datasetMatrix, Color c, int dotSize, boolean drawAnnotations, boolean drawConnectingLines, boolean drawDots){
    data.loadDataset(name, datasetMatrix);
    this.plot.setDataset(data.getDatasetIndex(), data.getDataset(data.getDatasetIndex()));
    data.editRenderer(data.getDatasetIndex(), dotSize, c, drawConnectingLines, drawDots);
    this.plot.setRenderer(data.getDatasetIndex(), data.getRenderer(data.getDatasetIndex()));
    if(drawAnnotations){
        List<XYTextAnnotation> annots = data.getAnnotations(data.getDatasetIndex(), 0.0, 0.0, TextAnchor.BOTTOM_RIGHT, dataLabelFontSize, Font.PLAIN, c);
        for(XYTextAnnotation a : annots)
            plot.addAnnotation(a);
    }
}
项目:seqcode-core    文件:ScatterPlot.java   
/**
 * Add a dataset from a file
 * @param f File
 * @param c Color
 * @param dotSize   integer
 */
public void addFileDataset(File f, Color c, int dotSize, boolean drawAnnotations){
    data.loadFileDataset(f, "S"+(data.getDatasetIndex()+1), 1);
    this.plot.setDataset(
            data.getDatasetIndex(), data.getDataset(data.getDatasetIndex())
    );
    data.editRenderer(data.getDatasetIndex(), dotSize, c);
    this.plot.setRenderer(data.getDatasetIndex(), data.getRenderer(data.getDatasetIndex()));
    if(drawAnnotations){
        List<XYTextAnnotation> annots = data.getAnnotations(data.getDatasetIndex(), 0.0, 0.0, TextAnchor.BOTTOM_RIGHT, dataLabelFontSize, Font.PLAIN, c);
        for(XYTextAnnotation a : annots)
            plot.addAnnotation(a);
    }
    configAxes();
}
项目:PhET    文件:CombinedXYPlotDemo1.java   
/**
 * Creates a combined chart.
 *
 * @return the combined chart.
 */
private static JFreeChart createCombinedChart() {

    // create subplot 1...
    final XYDataset data1 = createDataset1();
    final XYItemRenderer renderer1 = new StandardXYItemRenderer();
    final NumberAxis rangeAxis1 = new NumberAxis( "Range 1" );
    final XYPlot subplot1 = new XYPlot( data1, null, rangeAxis1, renderer1 );
    subplot1.setRangeAxisLocation( AxisLocation.BOTTOM_OR_LEFT );

    final XYTextAnnotation annotation = new XYTextAnnotation( "Hello!", 50.0, 10000.0 );
    annotation.setFont( new Font( "SansSerif", Font.PLAIN, 9 ) );
    annotation.setRotationAngle( Math.PI / 4.0 );
    subplot1.addAnnotation( annotation );

    // create subplot 2...
    final XYDataset data2 = createDataset2();
    final XYItemRenderer renderer2 = new StandardXYItemRenderer();
    final NumberAxis rangeAxis2 = new NumberAxis( "Range 2" );
    rangeAxis2.setAutoRangeIncludesZero( false );
    final XYPlot subplot2 = new XYPlot( data2, null, rangeAxis2, renderer2 );
    subplot2.setRangeAxisLocation( AxisLocation.TOP_OR_LEFT );

    // parent plot...
    final CombinedDomainXYPlot plot = new CombinedDomainXYPlot( new NumberAxis( "Domain" ) );
    plot.setGap( 10.0 );

    // add the subplots...
    plot.add( subplot1, 1 );
    plot.add( subplot2, 1 );
    plot.setOrientation( PlotOrientation.VERTICAL );

    // return a new chart containing the overlaid plot...
    return new JFreeChart( "CombinedDomainXYPlot Demo",
                           JFreeChart.DEFAULT_TITLE_FONT, plot, true );

}
项目:PhET    文件:TestCombinedChartNode.java   
private static JFreeChart createCombinedChart() {

        // create subplot 1...
        final XYItemRenderer renderer1 = new StandardXYItemRenderer();
        final NumberAxis rangeAxis1 = new NumberAxis( "Range 1" );
        final XYPlot subplot1 = new XYPlot( createDataset1(), null, rangeAxis1, renderer1 );
        subplot1.setRangeAxisLocation( AxisLocation.BOTTOM_OR_LEFT );

        final XYTextAnnotation annotation = new XYTextAnnotation( "Hello!", 50.0, 10000.0 );
        annotation.setFont( new Font( "SansSerif", Font.PLAIN, 9 ) );
        annotation.setRotationAngle( Math.PI / 4.0 );
        subplot1.addAnnotation( annotation );

        // create subplot 2...
        final XYItemRenderer renderer2 = new StandardXYItemRenderer();
        final NumberAxis rangeAxis2 = new NumberAxis( "Range 2" );
        rangeAxis2.setAutoRangeIncludesZero( false );
        final XYPlot subplot2 = new XYPlot( createDataset2(), null, rangeAxis2, renderer2 );
        subplot2.setRangeAxisLocation( AxisLocation.TOP_OR_LEFT );

        // parent plot...
        final CombinedDomainXYPlot plot = new CombinedDomainXYPlot( new NumberAxis( "Domain" ) );
        plot.setGap( 10.0 );

        // add the subplots...
        plot.add( subplot1, 1 );
        plot.add( subplot2, 1 );
        plot.setOrientation( PlotOrientation.VERTICAL );

        // return a new chart containing the overlaid plot...
        return new JFreeChart( "CombinedDomainXYPlot Demo",
                               JFreeChart.DEFAULT_TITLE_FONT, plot, true );

    }
项目:aya-lang    文件:YIntervalRendererTest.java   
/**
 * Confirm that cloning works.
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    YIntervalRenderer r1 = new YIntervalRenderer();
    YIntervalRenderer r2 = (YIntervalRenderer) r1.clone();
    assertTrue(r1 != r2);
    assertTrue(r1.getClass() == r2.getClass());
    assertTrue(r1.equals(r2));

    // check independence
    r1.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator());
    assertFalse(r1.equals(r2));
    r2.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator());
    assertTrue(r1.equals(r2));

    r1.setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator());
    assertFalse(r1.equals(r2));
    r2.setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator());
    assertTrue(r1.equals(r2));

    r1.addAnnotation(new XYTextAnnotation("ABC", 1.0, 2.0),
            Layer.FOREGROUND);
    assertFalse(r1.equals(r2));
    r2.addAnnotation(new XYTextAnnotation("ABC", 1.0, 2.0),
            Layer.FOREGROUND);
    assertTrue(r1.equals(r2));

    r1.addAnnotation(new XYTextAnnotation("ABC", 1.0, 2.0),
            Layer.BACKGROUND);
    assertFalse(r1.equals(r2));
    r2.addAnnotation(new XYTextAnnotation("ABC", 1.0, 2.0),
            Layer.BACKGROUND);
    assertTrue(r1.equals(r2));

}
项目:aya-lang    文件:CombinedDomainXYPlotTest.java   
/**
 * Creates a sample plot.
 *
 * @return A sample plot.
 */
private CombinedDomainXYPlot createPlot() {
    // create subplot 1...
    XYDataset data1 = createDataset1();
    XYItemRenderer renderer1 = new StandardXYItemRenderer();
    NumberAxis rangeAxis1 = new NumberAxis("Range 1");
    XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1);
    subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    XYTextAnnotation annotation = new XYTextAnnotation("Hello!", 50.0,
            10000.0);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 9));
    annotation.setRotationAngle(Math.PI / 4.0);
    subplot1.addAnnotation(annotation);

    // create subplot 2...
    XYDataset data2 = createDataset2();
    XYItemRenderer renderer2 = new StandardXYItemRenderer();
    NumberAxis rangeAxis2 = new NumberAxis("Range 2");
    rangeAxis2.setAutoRangeIncludesZero(false);
    XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2);
    subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);

    // parent plot...
    CombinedDomainXYPlot plot = new CombinedDomainXYPlot(
            new NumberAxis("Domain"));
    plot.setGap(10.0);

    // add the subplots...
    plot.add(subplot1, 1);
    plot.add(subplot2, 1);
    plot.setOrientation(PlotOrientation.VERTICAL);
    return plot;
}
项目:aya-lang    文件:CombinedRangeXYPlotTest.java   
/**
 * Creates a sample plot.
 *
 * @return A sample plot.
 */
private CombinedRangeXYPlot createPlot() {
    // create subplot 1...
    XYDataset data1 = createDataset1();
    XYItemRenderer renderer1 = new StandardXYItemRenderer();
    NumberAxis xAxis1 = new NumberAxis("X1");
    XYPlot subplot1 = new XYPlot(data1, xAxis1, null, renderer1);
    subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    XYTextAnnotation annotation
            = new XYTextAnnotation("Hello!", 50.0, 10000.0);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 9));
    annotation.setRotationAngle(Math.PI / 4.0);
    subplot1.addAnnotation(annotation);

    // create subplot 2...
    XYDataset data2 = createDataset2();
    XYItemRenderer renderer2 = new StandardXYItemRenderer();
    NumberAxis xAxis2 = new NumberAxis("X2");
    xAxis2.setAutoRangeIncludesZero(false);
    XYPlot subplot2 = new XYPlot(data2, xAxis2, null, renderer2);
    subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);

    // parent plot...
    CombinedRangeXYPlot plot = new CombinedRangeXYPlot(new NumberAxis(
            "Range"));
    plot.setGap(10.0);

    // add the subplots...
    plot.add(subplot1, 1);
    plot.add(subplot2, 1);
    plot.setOrientation(PlotOrientation.VERTICAL);
    return plot;
}
项目:aya-lang    文件:StandardChartTheme.java   
/**
 * Applies the settings of this theme to the specified annotation.
 *
 * @param annotation  the annotation.
 */
protected void applyToXYAnnotation(XYAnnotation annotation) {
    ParamChecks.nullNotPermitted(annotation, "annotation");
    if (annotation instanceof XYTextAnnotation) {
        XYTextAnnotation xyta = (XYTextAnnotation) annotation;
        xyta.setFont(this.smallFont);
        xyta.setPaint(this.itemLabelPaint);
    }
}
项目:EccPlayground    文件:CurveGraphPanel.java   
public void showAnnotations() {
    XYItemRenderer renderer = getChart().getXYPlot().getRenderer();
    renderer.removeAnnotations();

    for (int i = 0; i < eccSeries.getItemCount(); i++) {
        XYDataItem item = (XYDataItem) eccSeries.getDataItem(i);
        XYTextAnnotation annon = new XYTextAnnotation(new Integer(i).toString(), item.getX().longValue(), item
                .getY().longValue());
        renderer.addAnnotation(annon);
    }
}
项目:HTML5_WebSite    文件:StandardChartTheme.java   
/**
 * Applies the settings of this theme to the specified annotation.
 *
 * @param annotation  the annotation.
 */
protected void applyToXYAnnotation(XYAnnotation annotation) {
    if (annotation == null) {
        throw new IllegalArgumentException("Null 'annotation' argument.");
    }
    if (annotation instanceof XYTextAnnotation) {
        XYTextAnnotation xyta = (XYTextAnnotation) annotation;
        xyta.setFont(this.smallFont);
        xyta.setPaint(this.itemLabelPaint);
    }
}
项目:populus    文件:StandardChartTheme.java   
/**
 * Applies the settings of this theme to the specified annotation.
 *
 * @param annotation  the annotation.
 */
protected void applyToXYAnnotation(XYAnnotation annotation) {
    ParamChecks.nullNotPermitted(annotation, "annotation");
    if (annotation instanceof XYTextAnnotation) {
        XYTextAnnotation xyta = (XYTextAnnotation) annotation;
        xyta.setFont(this.smallFont);
        xyta.setPaint(this.itemLabelPaint);
    }
}
项目:MakamBox    文件:MakamChart.java   
public void addAnnotation(float[] peaks){
    annotation = new XYTextAnnotation[peaks.length];
    for (int i = 1; i < peaks.length; i++) {
        if(isComma){
            annotation[i] = new XYTextAnnotation(String.valueOf((int) Math.round(peaks[i]))+" comma", peaks[i], 0.01);
        } else {                
            annotation[i] = new XYTextAnnotation(String.valueOf((int) Math.round(peaks[i]))+" cent", peaks[i], 0.01);
        }
        annotation[i].setFont(new Font("Lucida Grande", Font.PLAIN, 11));
        annotation[i].setRotationAngle(200);
    }
}
项目:MakamBox    文件:MakamChart.java   
public void addSysAnnotation(float[] peaks,float offset){
    sysAnnotation = new XYTextAnnotation[peaks.length];
    for (int i = 1; i < peaks.length; i++) {
        if(isComma){
            sysAnnotation[i] = new XYTextAnnotation(String.valueOf(Math.round((peaks[i]/(1200f/53f))*100.0)/100.0)+" comma", (peaks[i]/(1200f/53f)), offset);
        } else {                
            sysAnnotation[i] = new XYTextAnnotation(String.valueOf(Math.round(peaks[i]*100.0)/100.0)+" cent", peaks[i], offset);
        }
        sysAnnotation[i].setFont(new Font("Lucida Grande", Font.PLAIN, 11));
        sysAnnotation[i].setRotationAngle(200);
    }
}
项目:MakamBox    文件:Plot.java   
public static void addBar(int[] barPos){
    annotation = new XYTextAnnotation[barPos.length];
    for (int i = 1; i < barPos.length; i++) {
            annotation[i] = new XYTextAnnotation(String.valueOf(Math.round(barPos[i]))+" SEP", barPos[i], 550);
            annotation[i].setFont(new Font("Lucida Grande", Font.PLAIN, 11));
            annotation[i].setRotationAngle(200); 
    }
}
项目:PI    文件:StandardChartTheme.java   
/**
 * Applies the settings of this theme to the specified annotation.
 *
 * @param annotation  the annotation.
 */
protected void applyToXYAnnotation(XYAnnotation annotation) {
    if (annotation == null) {
        throw new IllegalArgumentException("Null 'annotation' argument.");
    }
    if (annotation instanceof XYTextAnnotation) {
        XYTextAnnotation xyta = (XYTextAnnotation) annotation;
        xyta.setFont(this.smallFont);
        xyta.setPaint(this.itemLabelPaint);
    }
}
项目:nabs    文件:CombinedDomainXYPlotTests.java   
/**
 * Creates a sample plot.
 * 
 * @return A sample plot.
 */
private CombinedDomainXYPlot createPlot() {
    // create subplot 1...
    XYDataset data1 = createDataset1();
    XYItemRenderer renderer1 = new StandardXYItemRenderer();
    NumberAxis rangeAxis1 = new NumberAxis("Range 1");
    XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1);
    subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    XYTextAnnotation annotation 
        = new XYTextAnnotation("Hello!", 50.0, 10000.0);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 9));
    annotation.setRotationAngle(Math.PI / 4.0);
    subplot1.addAnnotation(annotation);

    // create subplot 2...
    XYDataset data2 = createDataset2();
    XYItemRenderer renderer2 = new StandardXYItemRenderer();
    NumberAxis rangeAxis2 = new NumberAxis("Range 2");
    rangeAxis2.setAutoRangeIncludesZero(false);
    XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2);
    subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);

    // parent plot...
    CombinedDomainXYPlot plot 
        = new CombinedDomainXYPlot(new NumberAxis("Domain"));
    plot.setGap(10.0);

    // add the subplots...
    plot.add(subplot1, 1);
    plot.add(subplot2, 1);
    plot.setOrientation(PlotOrientation.VERTICAL);
    return plot;
}