Java Code Examples for org.jfree.chart.renderer.xy.XYDotRenderer#setDotHeight()

The following examples show how to use org.jfree.chart.renderer.xy.XYDotRenderer#setDotHeight() . 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 vote down vote up
/**
 * 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 vote down vote up
/**
 * 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 vote down vote up
/**
 * 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 vote down vote up
/**
 * 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: SimpleScatterPlot.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
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 6
Source File: JPanelAnalysisSpeedSlope.java    From Course_Generator with GNU General Public License v3.0 4 votes vote down vote up
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 7
Source File: SimpleScatterPlot.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
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();
}