use of org.jfree.chart.annotations.XYTextAnnotation in project SIMVA-SoS by SESoS.
the class StandardChartTheme method applyToXYAnnotation.
/**
* 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);
}
}
use of org.jfree.chart.annotations.XYTextAnnotation in project SIMVA-SoS by SESoS.
the class XYPlotTest method testRemoveAnnotation.
/**
* Some checks for the removeAnnotation() method.
*/
@Test
public void testRemoveAnnotation() {
XYPlot plot = new XYPlot();
XYTextAnnotation a1 = new XYTextAnnotation("X", 1.0, 2.0);
XYTextAnnotation a2 = new XYTextAnnotation("X", 3.0, 4.0);
XYTextAnnotation a3 = new XYTextAnnotation("X", 1.0, 2.0);
plot.addAnnotation(a1);
plot.addAnnotation(a2);
plot.addAnnotation(a3);
plot.removeAnnotation(a2);
XYTextAnnotation x = (XYTextAnnotation) plot.getAnnotations().get(0);
assertEquals(x, a1);
// now remove a3, but since a3.equals(a1), this will in fact remove
// a1...
assertTrue(a1.equals(a3));
// actually removes a1
plot.removeAnnotation(a3);
x = (XYTextAnnotation) plot.getAnnotations().get(0);
assertEquals(x, a3);
}
use of org.jfree.chart.annotations.XYTextAnnotation in project SIMVA-SoS by SESoS.
the class YIntervalRendererTest method testEquals.
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
YIntervalRenderer r1 = new YIntervalRenderer();
YIntervalRenderer r2 = new YIntervalRenderer();
assertEquals(r1, r2);
// the following fields are inherited from the AbstractXYItemRenderer
r1.setItemLabelGenerator(new StandardXYItemLabelGenerator());
assertFalse(r1.equals(r2));
r2.setItemLabelGenerator(new StandardXYItemLabelGenerator());
assertTrue(r1.equals(r2));
r1.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator());
assertFalse(r1.equals(r2));
r2.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator());
assertTrue(r1.equals(r2));
r1.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
assertFalse(r1.equals(r2));
r2.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
assertTrue(r1.equals(r2));
r1.setToolTipGenerator(new StandardXYToolTipGenerator());
assertFalse(r1.equals(r2));
r2.setToolTipGenerator(new StandardXYToolTipGenerator());
assertTrue(r1.equals(r2));
r1.setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator());
assertFalse(r1.equals(r2));
r2.setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator());
assertTrue(r1.equals(r2));
r1.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
assertFalse(r1.equals(r2));
r2.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
assertTrue(r1.equals(r2));
r1.setURLGenerator(new StandardXYURLGenerator());
assertFalse(r1.equals(r2));
r2.setURLGenerator(new StandardXYURLGenerator());
assertTrue(r1.equals(r2));
r1.addAnnotation(new XYTextAnnotation("X", 1.0, 2.0), Layer.FOREGROUND);
assertFalse(r1.equals(r2));
r2.addAnnotation(new XYTextAnnotation("X", 1.0, 2.0), Layer.FOREGROUND);
assertTrue(r1.equals(r2));
r1.addAnnotation(new XYTextAnnotation("X", 1.0, 2.0), Layer.BACKGROUND);
assertFalse(r1.equals(r2));
r2.addAnnotation(new XYTextAnnotation("X", 1.0, 2.0), Layer.BACKGROUND);
assertTrue(r1.equals(r2));
r1.setDefaultEntityRadius(99);
assertFalse(r1.equals(r2));
r2.setDefaultEntityRadius(99);
assertTrue(r1.equals(r2));
r1.setLegendItemLabelGenerator(new StandardXYSeriesLabelGenerator("{0} {1}"));
assertFalse(r1.equals(r2));
r2.setLegendItemLabelGenerator(new StandardXYSeriesLabelGenerator("{0} {1}"));
assertTrue(r1.equals(r2));
r1.setLegendItemToolTipGenerator(new StandardXYSeriesLabelGenerator());
assertFalse(r1.equals(r2));
r2.setLegendItemToolTipGenerator(new StandardXYSeriesLabelGenerator());
assertTrue(r1.equals(r2));
r1.setLegendItemURLGenerator(new StandardXYSeriesLabelGenerator());
assertFalse(r1.equals(r2));
r2.setLegendItemURLGenerator(new StandardXYSeriesLabelGenerator());
assertTrue(r1.equals(r2));
r1.setAdditionalItemLabelGenerator(new IntervalXYItemLabelGenerator());
assertFalse(r1.equals(r2));
r2.setAdditionalItemLabelGenerator(new IntervalXYItemLabelGenerator());
assertTrue(r1.equals(r2));
}
use of org.jfree.chart.annotations.XYTextAnnotation in project SIMVA-SoS by SESoS.
the class CombinedRangeXYPlotTest method createPlot.
/**
* 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;
}
use of org.jfree.chart.annotations.XYTextAnnotation in project MtgDesktopCompanion by nicho92.
the class HistoryPricesPanel method refresh.
private void refresh() {
TimeSeriesCollection dataset = new TimeSeriesCollection();
TimeSeries series1 = new TimeSeries(title);
if (showAll) {
for (MTGDashBoard d : MTGControler.getInstance().getDashBoards()) {
TimeSeries series = new TimeSeries(d.getName());
Map<Date, Double> mapTime;
try {
mapTime = d.getPriceVariation(mc, me);
if (mapTime != null) {
for (Entry<Date, Double> da : mapTime.entrySet()) series.add(new Day(da.getKey()), da.getValue().doubleValue());
dataset.addSeries(series);
}
} catch (IOException e) {
MTGLogger.printStackTrace(e);
}
}
} else {
for (Entry<Date, Double> d : map.entrySet()) series1.add(new Day(d.getKey()), d.getValue().doubleValue());
dataset.addSeries(series1);
}
JFreeChart chart = ChartFactory.createTimeSeriesChart("Price Variation", "Date", "Price", dataset, true, true, false);
if (showEdition)
try {
for (MagicEdition edition : MTGControler.getInstance().getEnabledProviders().loadEditions()) {
Date d = new SimpleDateFormat("yyyy-MM-dd hh:mm").parse(edition.getReleaseDate() + " 00:00");
TimeSeriesDataItem item = series1.getDataItem(new Day(d));
if (item != null) {
double x = item.getPeriod().getFirstMillisecond();
double y = item.getValue().doubleValue();
XYTextAnnotation annot = new XYTextAnnotation(edition.getId(), x, y);
annot.setToolTipText(edition.getSet());
XYPlot plot = (XYPlot) chart.getPlot();
plot.addAnnotation(annot);
}
}
} catch (Exception e) {
MTGLogger.printStackTrace(e);
}
pane.setChart(chart);
pane.addMouseWheelListener(mwe -> {
if (mwe.getWheelRotation() > 0) {
pane.zoomOutDomain(0.5, 0.5);
} else if (mwe.getWheelRotation() < 0) {
pane.zoomInDomain(1.5, 1.5);
}
});
this.add(pane, BorderLayout.CENTER);
chart.fireChartChanged();
}
Aggregations