org.jfree.chart.annotations.XYTextAnnotation Java Examples

The following examples show how to use org.jfree.chart.annotations.XYTextAnnotation. 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: ScatterHome.java    From Benchmark with GNU General Public License v2.0 6 votes vote down vote up
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);
        }
    }
}
 
Example #2
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 #3
Source File: ChartFormatter.java    From nmonvisualizer with Apache License 2.0 6 votes vote down vote up
public void reformatAnnotations() {
    for (Annotation a : AnnotationCache.getAnnotations()) {
        if (a instanceof TextAnnotation) {
            formatAnnotation((TextAnnotation) a);
        }
        else if (a instanceof XYTextAnnotation) {
            formatAnnotation((XYTextAnnotation) a);
        }
    }

    for (Marker m : AnnotationCache.getMarkers()) {
        boolean horizontal = m.getLabelTextAnchor() == TextAnchor.TOP_CENTER;

        // match offsets adjustments in formatMarker()
        if (horizontal) {
            formatMarker(m, true, (int) m.getLabelOffset().getLeft() - 50);
        }
        else {
            formatMarker(m, false, (int) m.getLabelOffset().getTop() - 5);
        }
    }
}
 
Example #4
Source File: FunctionPanel.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
/** 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());
}
 
Example #5
Source File: ScatterTools.java    From Benchmark with GNU General Public License v2.0 6 votes vote down vote up
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);
		}
	}
}
 
Example #6
Source File: ScatterVulns.java    From Benchmark with GNU General Public License v2.0 6 votes vote down vote up
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);
        }
    }
}
 
Example #7
Source File: CombinedDomainXYPlotTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #8
Source File: CombinedDomainXYPlotTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #9
Source File: StandardChartTheme.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example #10
Source File: YIntervalRendererTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Confirm that cloning works.
 */
public void testCloning() {
    YIntervalRenderer r1 = new YIntervalRenderer();
    YIntervalRenderer r2 = null;
    try {
        r2 = (YIntervalRenderer) r1.clone();
    }
    catch (CloneNotSupportedException e) {
        e.printStackTrace();
    }
    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));

}
 
Example #11
Source File: CombinedDomainXYPlotTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #12
Source File: CombinedRangeXYPlotTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #13
Source File: XYTextAnnotationTests.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() {
    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);
}
 
Example #14
Source File: StandardChartTheme.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example #15
Source File: YIntervalRendererTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Confirm that cloning works.
 */
public void testCloning() {
    YIntervalRenderer r1 = new YIntervalRenderer();
    YIntervalRenderer r2 = null;
    try {
        r2 = (YIntervalRenderer) r1.clone();
    }
    catch (CloneNotSupportedException e) {
        e.printStackTrace();
    }
    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));

}
 
Example #16
Source File: CombinedRangeXYPlotTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #17
Source File: CombinedRangeXYPlotTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #18
Source File: XYTextAnnotationTests.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() {
    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);
}
 
Example #19
Source File: JOpenSimChartMouseListener.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
public void mouseClicked(MouseEvent e) {
   int x=e.getX();
   int y=e.getY();
   // handleClick only serves to locate the Corosshair Values to convert from 
   // Java2D space to data space.
   int mask=e.getModifiers();
   if ((mask & e.CTRL_MASK) !=0){    // Show query only if CTRL button is held down
       chartPanel.getChart().handleClick(x, y, chartPanel.getChartRenderingInfo());
       double dataX = chartPanel.getChart().getXYPlot().getDomainCrosshairValue();
       double dataY = chartPanel.getChart().getXYPlot().getRangeCrosshairValue();
       //%[argument_index$][flags][width][.precision]conversion
       String annotationText = String.format("(%1$f, %2$f)", dataX, dataY);
       chartPanel.getChart().getXYPlot().addAnnotation(new XYTextAnnotation(annotationText, dataX, dataY));
   }
}
 
Example #20
Source File: Scatter.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
public void addAnnotation( String text, double x ) {
    XYPlot plot = (XYPlot) getChart().getPlot();
    Color color = new Color(0, 0, 0, 100);
    Marker updateMarker = new ValueMarker(x, color, new BasicStroke(2f));
    plot.addDomainMarker(updateMarker);
    if (text != null) {
        XYTextAnnotation updateLabel = new XYTextAnnotation(text, x, 0);
        updateLabel.setRotationAnchor(TextAnchor.BASELINE_CENTER);
        updateLabel.setTextAnchor(TextAnchor.BASELINE_CENTER);
        updateLabel.setRotationAngle(-3.14 / 2);
        updateLabel.setPaint(Color.black);
        plot.addAnnotation(updateLabel);
    }
    setShapeLinesVisibility(plot);
}
 
Example #21
Source File: YIntervalRendererTest.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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));

}
 
Example #22
Source File: CombinedDomainXYPlotTest.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #23
Source File: CombinedRangeXYPlotTest.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #24
Source File: StandardChartTheme.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example #25
Source File: StandardChartTheme.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example #26
Source File: CombinedDomainXYPlotTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #27
Source File: YIntervalRendererTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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));

}
 
Example #28
Source File: CombinedDomainXYPlotTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #29
Source File: CombinedRangeXYPlotTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #30
Source File: StandardChartTheme.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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);
    }
}