use of org.jfree.chart.ChartRenderingInfo in project SIMVA-SoS by SESoS.
the class ScrollHandlerFX method handleZoomable.
/**
* Handle the case where a plot implements the {@link Zoomable} interface.
*
* @param zoomable the zoomable plot.
* @param e the mouse wheel event.
*/
private void handleZoomable(ChartCanvas canvas, Zoomable zoomable, ScrollEvent e) {
// don't zoom unless the mouse pointer is in the plot's data area
ChartRenderingInfo info = canvas.getRenderingInfo();
PlotRenderingInfo pinfo = info.getPlotInfo();
Point2D p = new Point2D.Double(e.getX(), e.getY());
if (pinfo.getDataArea().contains(p)) {
Plot plot = (Plot) zoomable;
// do not notify while zooming each axis
boolean notifyState = plot.isNotify();
plot.setNotify(false);
int clicks = (int) e.getDeltaY();
double zf = 1.0 + this.zoomFactor;
if (clicks < 0) {
zf = 1.0 / zf;
}
if (true) {
// this.chartPanel.isDomainZoomable()) {
zoomable.zoomDomainAxes(zf, pinfo, p, true);
}
if (true) {
// this.chartPanel.isRangeZoomable()) {
zoomable.zoomRangeAxes(zf, pinfo, p, true);
}
// this generates the change event too
plot.setNotify(notifyState);
}
}
use of org.jfree.chart.ChartRenderingInfo in project SIMVA-SoS by SESoS.
the class TooltipHandlerFX method getTooltipText.
/**
* Returns the tooltip text.
*
* @param canvas the canvas that is displaying the chart.
* @param x the x-coordinate of the mouse pointer.
* @param y the y-coordinate of the mouse pointer.
*
* @return String The tooltip text (possibly <code>null</code>).
*/
private String getTooltipText(ChartCanvas canvas, double x, double y) {
ChartRenderingInfo info = canvas.getRenderingInfo();
if (info == null) {
return null;
}
EntityCollection entities = info.getEntityCollection();
if (entities == null) {
return null;
}
ChartEntity entity = entities.getEntity(x, y);
if (entity == null) {
return null;
}
return entity.getToolTipText();
}
use of org.jfree.chart.ChartRenderingInfo in project SIMVA-SoS by SESoS.
the class StandardXYItemRendererTest method testNoDisplayedItem.
/**
* A check to ensure that an item that falls outside the plot's data area
* does NOT generate an item entity.
*/
@Test
public void testNoDisplayedItem() {
XYSeriesCollection dataset = new XYSeriesCollection();
XYSeries s1 = new XYSeries("S1");
s1.add(10.0, 10.0);
dataset.addSeries(s1);
JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y", dataset, PlotOrientation.VERTICAL, false, true, false);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setRenderer(new StandardXYItemRenderer());
NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
xAxis.setRange(0.0, 5.0);
NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
yAxis.setRange(0.0, 5.0);
BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = image.createGraphics();
ChartRenderingInfo info = new ChartRenderingInfo();
chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, info);
g2.dispose();
EntityCollection ec = info.getEntityCollection();
assertFalse(TestUtilities.containsInstanceOf(ec.getEntities(), XYItemEntity.class));
}
use of org.jfree.chart.ChartRenderingInfo in project SIMVA-SoS by SESoS.
the class BoxAndWhiskerRendererTest method testBug1572478Vertical.
/**
* A check for bug 1572478 (for the vertical orientation).
*/
@Test
public void testBug1572478Vertical() {
DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset() {
@Override
public Number getQ1Value(int row, int column) {
return null;
}
@Override
public Number getQ1Value(Comparable rowKey, Comparable columnKey) {
return null;
}
};
List values = new ArrayList();
values.add(new Double(1.0));
values.add(new Double(10.0));
values.add(new Double(100.0));
dataset.add(values, "row", "column");
CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("x"), new NumberAxis("y"), new BoxAndWhiskerRenderer());
JFreeChart chart = new JFreeChart(plot);
boolean success;
try {
BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = image.createGraphics();
chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, new ChartRenderingInfo());
g2.dispose();
success = true;
} catch (Exception e) {
success = false;
}
assertTrue(success);
}
use of org.jfree.chart.ChartRenderingInfo in project SIMVA-SoS by SESoS.
the class BoxAndWhiskerRendererTest method testDrawWithNullMinOutlier.
/**
* Draws a chart where the dataset contains a null min outlier value.
*/
@Test
public void testDrawWithNullMinOutlier() {
boolean success;
try {
DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(3.0), new Double(4.0), new Double(0.5), new Double(4.5), null, new Double(5.5), null), "S1", "C1");
CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new BoxAndWhiskerRenderer());
ChartRenderingInfo info = new ChartRenderingInfo();
JFreeChart chart = new JFreeChart(plot);
/* BufferedImage image = */
chart.createBufferedImage(300, 200, info);
success = true;
} catch (Exception e) {
success = false;
}
assertTrue(success);
}
Aggregations