org.jfree.chart.renderer.xy.XYDotRenderer Java Examples
The following examples show how to use
org.jfree.chart.renderer.xy.XYDotRenderer.
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: XYDotRendererTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Check that the equals() method distinguishes all fields. */ public void testEquals() { XYDotRenderer r1 = new XYDotRenderer(); XYDotRenderer r2 = new XYDotRenderer(); assertEquals(r1, r2); r1.setDotWidth(11); assertFalse(r1.equals(r2)); r2.setDotWidth(11); assertTrue(r1.equals(r2)); r1.setDotHeight(12); assertFalse(r1.equals(r2)); r2.setDotHeight(12); assertTrue(r1.equals(r2)); r1.setLegendShape(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); assertFalse(r1.equals(r2)); r2.setLegendShape(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); assertTrue(r1.equals(r2)); }
Example #2
Source File: XYDotRendererTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { XYDotRenderer r1 = new XYDotRenderer(); XYDotRenderer r2 = new XYDotRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); r1.setDotHeight(12); r2.setDotHeight(12); assertTrue(r1.equals(r2)); h1 = r1.hashCode(); h2 = r2.hashCode(); assertEquals(h1, h2); }
Example #3
Source File: XYDotRendererTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Check that the equals() method distinguishes all fields. */ public void testEquals() { XYDotRenderer r1 = new XYDotRenderer(); XYDotRenderer r2 = new XYDotRenderer(); assertEquals(r1, r2); r1.setDotWidth(11); assertFalse(r1.equals(r2)); r2.setDotWidth(11); assertTrue(r1.equals(r2)); r1.setDotHeight(12); assertFalse(r1.equals(r2)); r2.setDotHeight(12); assertTrue(r1.equals(r2)); r1.setLegendShape(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); assertFalse(r1.equals(r2)); r2.setLegendShape(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); assertTrue(r1.equals(r2)); }
Example #4
Source File: XYDotRendererTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { XYDotRenderer r1 = new XYDotRenderer(); XYDotRenderer r2 = new XYDotRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); r1.setDotHeight(12); r2.setDotHeight(12); assertTrue(r1.equals(r2)); h1 = r1.hashCode(); h2 = r2.hashCode(); assertEquals(h1, h2); }
Example #5
Source File: XYDotRendererTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * A check for the datasetIndex and seriesIndex fields in the LegendItem * returned by the getLegendItem() method. */ public void testGetLegendItemSeriesIndex() { XYSeriesCollection d1 = new XYSeriesCollection(); XYSeries s1 = new XYSeries("S1"); s1.add(1.0, 1.1); XYSeries s2 = new XYSeries("S2"); s2.add(1.0, 1.1); d1.addSeries(s1); d1.addSeries(s2); XYSeriesCollection d2 = new XYSeriesCollection(); XYSeries s3 = new XYSeries("S3"); s3.add(1.0, 1.1); XYSeries s4 = new XYSeries("S4"); s4.add(1.0, 1.1); XYSeries s5 = new XYSeries("S5"); s5.add(1.0, 1.1); d2.addSeries(s3); d2.addSeries(s4); d2.addSeries(s5); XYDotRenderer r = new XYDotRenderer(); XYPlot plot = new XYPlot(d1, new NumberAxis("x"), new NumberAxis("y"), r); plot.setDataset(1, d2); /*JFreeChart chart =*/ new JFreeChart(plot); LegendItem li = r.getLegendItem(1, 2); assertEquals("S5", li.getLabel()); assertEquals(1, li.getDatasetIndex()); assertEquals(2, li.getSeriesIndex()); }
Example #6
Source File: XYDotRendererTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * A check for the datasetIndex and seriesIndex fields in the LegendItem * returned by the getLegendItem() method. */ public void testGetLegendItemSeriesIndex() { XYSeriesCollection d1 = new XYSeriesCollection(); XYSeries s1 = new XYSeries("S1"); s1.add(1.0, 1.1); XYSeries s2 = new XYSeries("S2"); s2.add(1.0, 1.1); d1.addSeries(s1); d1.addSeries(s2); XYSeriesCollection d2 = new XYSeriesCollection(); XYSeries s3 = new XYSeries("S3"); s3.add(1.0, 1.1); XYSeries s4 = new XYSeries("S4"); s4.add(1.0, 1.1); XYSeries s5 = new XYSeries("S5"); s5.add(1.0, 1.1); d2.addSeries(s3); d2.addSeries(s4); d2.addSeries(s5); XYDotRenderer r = new XYDotRenderer(); XYPlot plot = new XYPlot(d1, new NumberAxis("x"), new NumberAxis("y"), r); plot.setDataset(1, d2); /*JFreeChart chart =*/ new JFreeChart(plot); LegendItem li = r.getLegendItem(1, 2); assertEquals("S5", li.getLabel()); assertEquals(1, li.getDatasetIndex()); assertEquals(2, li.getSeriesIndex()); }
Example #7
Source File: SimpleScatterPlot.java From mzmine3 with GNU General Public License v2.0 | 4 votes |
public SimpleScatterPlot(double[] xValues, double[] yValues, double[] colors, String xLabel, String yLabel) { super(null); // setBackground(Color.white); setCursor(Cursor.CROSSHAIR); xAxis = new NumberAxis(xLabel); xAxis.setAutoRangeIncludesZero(false); xAxis.setUpperMargin(0); xAxis.setLowerMargin(0); yAxis = new NumberAxis(yLabel); yAxis.setAutoRangeIncludesZero(false); yAxis.setUpperMargin(0); yAxis.setLowerMargin(0); xyDataset = new DefaultXYZDataset(); int length = Math.min(xValues.length, yValues.length); double[][] data = new double[3][length]; System.arraycopy(xValues, 0, data[0], 0, length); System.arraycopy(yValues, 0, data[1], 0, length); System.arraycopy(colors, 0, data[2], 0, length); xyDataset.addSeries(SERIES_ID, data); XYDotRenderer renderer = new XYDotRenderer() { @Override public Paint getItemPaint(int row, int col) { double c = xyDataset.getZ(row, col).doubleValue(); return Color.getHSBColor((float) c, 1.0f, 1.0f); } }; renderer.setDotHeight(3); renderer.setDotWidth(3); plot = new XYPlot(xyDataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinesVisible(true); chart = new JFreeChart("", new Font("SansSerif", Font.BOLD, 12), plot, false); chart.setBackgroundPaint(Color.white); super.setChart(chart); // reset zoom history ZoomHistory history = getZoomHistory(); if (history != null) history.clear(); }
Example #8
Source File: JPanelAnalysisSpeedSlope.java From Course_Generator with GNU General Public License v3.0 | 4 votes |
private JFreeChart CreateChart(XYDataset dataset1, XYDataset dataset2) { JFreeChart chart = ChartFactory.createScatterPlot("", // x axis label bundle.getString("JPanelAnalysisSpeedSlope.labelX"), // "Slope", // y axis label bundle.getString("JPanelAnalysisSpeedSlope.labelY"), // "Speed", // data dataset1, PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); // Panel background color chart.setAntiAlias(true); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); plot.setRangeCrosshairLockedOnData(false); XYDotRenderer renderer = new XYDotRenderer(); renderer.setSeriesPaint(0, new Color(0x6B, 0xB2, 0x00)); renderer.setDotWidth(2); renderer.setDotHeight(2); plot.setRenderer(renderer); NumberAxis rangeAxis2 = new NumberAxis(); plot.setRangeAxis(1, rangeAxis2); plot.setDataset(1, dataset2); plot.setRangeAxis(1, rangeAxis2); plot.mapDatasetToRangeAxis(1, 1); XYAreaRenderer renderer2 = new XYAreaRenderer(); renderer2.setSeriesPaint(0, new Color(0x99, 0xff, 0x00, 0x80)); renderer2.setOutline(true); renderer2.setSeriesOutlinePaint(0, new Color(0x80, 0x80, 0x80, 0x80)); renderer2.setSeriesOutlineStroke(0, new BasicStroke(2.0f)); plot.setRenderer(1, renderer2); /* * StandardXYItemRenderer renderer2 = new StandardXYItemRenderer(); * renderer2.setSeriesPaint(0, Color.red); plot.setRenderer(1, renderer2); */ // -- Select the display order plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE); return chart; }
Example #9
Source File: SimpleScatterPlot.java From mzmine2 with GNU General Public License v2.0 | 4 votes |
public SimpleScatterPlot(double[] xValues, double[] yValues, double[] colors, String xLabel, String yLabel) { super(null, true); setBackground(Color.white); setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); xAxis = new NumberAxis(xLabel); xAxis.setAutoRangeIncludesZero(false); xAxis.setUpperMargin(0); xAxis.setLowerMargin(0); yAxis = new NumberAxis(yLabel); yAxis.setAutoRangeIncludesZero(false); yAxis.setUpperMargin(0); yAxis.setLowerMargin(0); xyDataset = new DefaultXYZDataset(); int length = Math.min(xValues.length, yValues.length); double[][] data = new double[3][length]; System.arraycopy(xValues, 0, data[0], 0, length); System.arraycopy(yValues, 0, data[1], 0, length); System.arraycopy(colors, 0, data[2], 0, length); xyDataset.addSeries(SERIES_ID, data); XYDotRenderer renderer = new XYDotRenderer() { @Override public Paint getItemPaint(int row, int col) { double c = xyDataset.getZ(row, col).doubleValue(); return Color.getHSBColor((float) c, 1.0f, 1.0f); } }; renderer.setDotHeight(3); renderer.setDotWidth(3); plot = new XYPlot(xyDataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinesVisible(true); chart = new JFreeChart("", new Font("SansSerif", Font.BOLD, 12), plot, false); chart.setBackgroundPaint(Color.white); super.setChart(chart); // reset zoom history ZoomHistory history = getZoomHistory(); if (history != null) history.clear(); }
Example #10
Source File: XYDotRendererTests.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { XYDotRenderer r1 = new XYDotRenderer(); assertTrue(r1 instanceof PublicCloneable); }