Java 类org.jfree.chart.renderer.xy.XYStepRenderer 实例源码

项目:HTML5_WebSite    文件:XYStepRendererDemo1.java   
/**
   * Creates a sample chart.
   * 
   * @param dataset  a dataset for the chart.
   * 
   * @return A sample chart.
   */
  protected JFreeChart createChart(XYDataset dataset) {
      JFreeChart chart = ChartFactory.createXYLineChart(
          chartTitle,
          domainLabel,
          rangeLabel,
          dataset,
          PlotOrientation.VERTICAL,
          !legendPanelOn,
          true,
          false
      );
      XYPlot plot = (XYPlot) chart.getPlot();
      XYStepRenderer renderer = new XYStepRenderer();
      renderer.setBaseStroke(new BasicStroke(2.0f));
      renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
      renderer.setDefaultEntityRadius(6);
renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator());

      plot.setRenderer(renderer);
setXSummary(dataset);
      return chart;
  }
项目:HTML5_WebSite    文件:ChartGenerator_JTable.java   
private JFreeChart createXYStepChart(String title, String xLabel, String yLabel, XYDataset dataset) {
 JFreeChart chart = ChartFactory.createXYLineChart(
           title,
           xLabel,
           yLabel,
           dataset,
          orientation,
           true,
           true,
           false
       );
       XYPlot plot = (XYPlot) chart.getPlot();
       XYStepRenderer renderer = new XYStepRenderer();
     //  renderer.setStroke(new BasicStroke(2.0f));
    //   renderer.setToolTipGenerator(new StandardXYToolTipGenerator());
       renderer.setDefaultEntityRadius(6);
    //renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator());

       plot.setRenderer(renderer);

       return chart;
}
项目:astor    文件:XYStepRendererTests.java   
/**
 * Check that the equals() method distinguishes all fields.
 */
public void testEquals() {
    XYStepRenderer r1 = new XYStepRenderer();
    XYStepRenderer r2 = new XYStepRenderer();
    assertEquals(r1, r2);

    r1.setStepPoint(0.44);
    assertFalse(r1.equals(r2));
    r2.setStepPoint(0.44);
    assertTrue(r1.equals(r2));

    // try something from the base class
    r1.setBaseCreateEntities(false);
    assertFalse(r1.equals(r2));
    r2.setBaseCreateEntities(false);
    assertTrue(r1.equals(r2));
}
项目:astor    文件:ChartFactory.java   
/**
 * Creates a stepped XY plot with default settings.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
 * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 *
 * @return A chart.
 */
public static JFreeChart createXYStepChart(String title, String xAxisLabel,
        String yAxisLabel, XYDataset dataset, boolean legend) {

    DateAxis xAxis = new DateAxis(xAxisLabel);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    XYItemRenderer renderer = new XYStepRenderer();
    renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
    plot.setRenderer(renderer);
    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
项目:dynamicreports-jasper    文件:XyStepRendererCustomizer.java   
@Override
public void customize(JFreeChart chart, ReportParameters reportParameters) {
    XYLineAndShapeRenderer lineRenderer = (XYLineAndShapeRenderer) chart.getXYPlot().getRenderer();
    XYStepRenderer renderer = new XYStepRenderer();

   renderer.setBaseItemLabelsVisible(lineRenderer.getBaseItemLabelsVisible());
   renderer.setBaseItemLabelFont(lineRenderer.getBaseItemLabelFont());
   renderer.setBaseItemLabelPaint(lineRenderer.getBaseItemLabelPaint());
   renderer.setBaseItemLabelGenerator(lineRenderer.getBaseItemLabelGenerator());
   renderer.setBaseShapesVisible(lineRenderer.getBaseShapesVisible());
   renderer.setBaseLinesVisible(lineRenderer.getBaseLinesVisible());

   if (stepPoint != null) {
    renderer.setStepPoint(stepPoint);
   }
   chart.getXYPlot().setRenderer(renderer);
}
项目:parabuild-ci    文件:XYStepRendererTests.java   
/**
 * Two objects that are equal are required to return the same hashCode. 
 */
public void testHashcode() {
    XYStepRenderer r1 = new XYStepRenderer();
    XYStepRenderer r2 = new XYStepRenderer();
    assertTrue(r1.equals(r2));
    int h1 = r1.hashCode();
    int h2 = r2.hashCode();
    assertEquals(h1, h2);
}
项目:parabuild-ci    文件:XYStepRendererTests.java   
/**
 * Two objects that are equal are required to return the same hashCode. 
 */
public void testHashcode() {
    XYStepRenderer r1 = new XYStepRenderer();
    XYStepRenderer r2 = new XYStepRenderer();
    assertTrue(r1.equals(r2));
    int h1 = r1.hashCode();
    int h2 = r2.hashCode();
    assertEquals(h1, h2);
}
项目:parabuild-ci    文件:XYStepRendererTests.java   
/**
 * Draws the chart with a <code>null</code> info object to make sure that 
 * no exceptions are thrown (particularly by code in the renderer).
 */
public void testDrawWithNullInfo() {
    boolean success = false;
    try {
        DefaultTableXYDataset dataset = new DefaultTableXYDataset();

        XYSeries s1 = new XYSeries("Series 1", true, false);
        s1.add(5.0, 5.0);
        s1.add(10.0, 15.5);
        s1.add(15.0, 9.5);
        s1.add(20.0, 7.5);
        dataset.addSeries(s1);

        XYSeries s2 = new XYSeries("Series 2", true, false);
        s2.add(5.0, 5.0);
        s2.add(10.0, 15.5);
        s2.add(15.0, 9.5);
        s2.add(20.0, 3.5);
        dataset.addSeries(s2);
        XYPlot plot = new XYPlot(dataset, 
                new NumberAxis("X"), new NumberAxis("Y"), 
                new XYStepRenderer());
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200, 
                null);
        success = true;
    }
    catch (NullPointerException e) {
        e.printStackTrace();
        success = false;
    }
    assertTrue(success);
}
项目:jasperreports    文件:StepCustomizer.java   
@Override
public void customize(JFreeChart jfc, JRChart jrc) 
{
    Plot plot = jfc.getPlot();
    if (plot instanceof XYPlot)
    {
        ((XYPlot)plot).setRenderer(new XYStepRenderer());
    }
}
项目:HTML5_WebSite    文件:XYStepRendererDemo1.java   
protected JFreeChart createLegend(XYDataset dataset) {

      JFreeChart chart = ChartFactory.createXYLineChart(
          chartTitle,             // chart title
          domainLabel,               // domain axis label
          rangeLabel,                  // range axis label
          dataset,                  // data
          PlotOrientation.VERTICAL, // orientation
          true,                     // include legend
          true,                     // tooltips
          false                     // url
      );

      // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
      chart.setBackgroundPaint(Color.white);
      XYPlot plot = (XYPlot) chart.getPlot();

      XYStepRenderer renderer = new XYStepRenderer();
      renderer.setBaseStroke(new BasicStroke(2.0f));
      renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
      renderer.setDefaultEntityRadius(6);
renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator());

      plot.setRenderer(renderer);
      return chart;

  }
项目:nabs    文件:XYStepRendererTests.java   
/**
 * Two objects that are equal are required to return the same hashCode. 
 */
public void testHashcode() {
    XYStepRenderer r1 = new XYStepRenderer();
    XYStepRenderer r2 = new XYStepRenderer();
    assertTrue(r1.equals(r2));
    int h1 = r1.hashCode();
    int h2 = r2.hashCode();
    assertEquals(h1, h2);
}
项目:nabs    文件:XYStepRendererTests.java   
/**
 * Draws the chart with a <code>null</code> info object to make sure that 
 * no exceptions are thrown (particularly by code in the renderer).
 */
public void testDrawWithNullInfo() {
    boolean success = false;
    try {
        DefaultTableXYDataset dataset = new DefaultTableXYDataset();

        XYSeries s1 = new XYSeries("Series 1", true, false);
        s1.add(5.0, 5.0);
        s1.add(10.0, 15.5);
        s1.add(15.0, 9.5);
        s1.add(20.0, 7.5);
        dataset.addSeries(s1);

        XYSeries s2 = new XYSeries("Series 2", true, false);
        s2.add(5.0, 5.0);
        s2.add(10.0, 15.5);
        s2.add(15.0, 9.5);
        s2.add(20.0, 3.5);
        dataset.addSeries(s2);
        XYPlot plot = new XYPlot(dataset, 
                new NumberAxis("X"), new NumberAxis("Y"), 
                new XYStepRenderer());
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200, 
                null);
        success = true;
    }
    catch (NullPointerException e) {
        e.printStackTrace();
        success = false;
    }
    assertTrue(success);
}
项目:astor    文件:XYStepRendererTests.java   
/**
 * Two objects that are equal are required to return the same hashCode.
 */
public void testHashcode() {
    XYStepRenderer r1 = new XYStepRenderer();
    r1.setStepPoint(0.123);
    XYStepRenderer r2 = new XYStepRenderer();
    r2.setStepPoint(0.123);
    assertTrue(r1.equals(r2));
    int h1 = r1.hashCode();
    int h2 = r2.hashCode();
    assertEquals(h1, h2);
}
项目:astor    文件:XYStepRendererTests.java   
/**
 * Draws the chart with a <code>null</code> info object to make sure that
 * no exceptions are thrown (particularly by code in the renderer).
 */
public void testDrawWithNullInfo() {
    boolean success = false;
    try {
        DefaultTableXYDataset dataset = new DefaultTableXYDataset();

        XYSeries s1 = new XYSeries("Series 1", true, false);
        s1.add(5.0, 5.0);
        s1.add(10.0, 15.5);
        s1.add(15.0, 9.5);
        s1.add(20.0, 7.5);
        dataset.addSeries(s1);

        XYSeries s2 = new XYSeries("Series 2", true, false);
        s2.add(5.0, 5.0);
        s2.add(10.0, 15.5);
        s2.add(15.0, 9.5);
        s2.add(20.0, 3.5);
        dataset.addSeries(s2);
        XYPlot plot = new XYPlot(dataset,
                new NumberAxis("X"), new NumberAxis("Y"),
                new XYStepRenderer());
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200,
                null);
        success = true;
    }
    catch (NullPointerException e) {
        e.printStackTrace();
        success = false;
    }
    assertTrue(success);
}
项目:astor    文件:XYStepRendererTests.java   
/**
 * Draws the chart with a <code>null</code> value in the dataset to make
 * sure that no exceptions are thrown.
 */
public void testDrawWithNullValue() {
    boolean success = false;
    try {
        DefaultTableXYDataset dataset = new DefaultTableXYDataset();

        XYSeries s1 = new XYSeries("Series 1", true, false);
        s1.add(5.0, 5.0);
        s1.add(10.0, null);
        s1.add(15.0, 9.5);
        s1.add(20.0, 7.5);
        dataset.addSeries(s1);

        XYSeries s2 = new XYSeries("Series 2", true, false);
        s2.add(5.0, 5.0);
        s2.add(10.0, 15.5);
        s2.add(15.0, null);
        s2.add(20.0, null);
        dataset.addSeries(s2);
        XYPlot plot = new XYPlot(dataset,
                new NumberAxis("X"), new NumberAxis("Y"),
                new XYStepRenderer());
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200,
                null);
        success = true;
    }
    catch (NullPointerException e) {
        e.printStackTrace();
        success = false;
    }
    assertTrue(success);
}
项目:dynamicreports-jasper    文件:XyStepChartTest.java   
@Override
public void test() {
    super.test();

    numberOfPagesTest(1);

    JFreeChart chart = getChart("summary.chart1", 0);
    XYItemRenderer renderer = chart.getXYPlot().getRenderer();
    Assert.assertEquals("renderer", XYStepRenderer.class, renderer.getClass());
    Assert.assertEquals("step point", 0.5d, ((XYStepRenderer) renderer).getStepPoint());

    chart = getChart("summary.chart2", 0);
    Axis axis = chart.getXYPlot().getDomainAxis();
    Assert.assertEquals("category label", "category", axis.getLabel());
    Assert.assertEquals("category label color", Color.BLUE, axis.getLabelPaint());
    Assert.assertEquals("category label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont());
    Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint());
    Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont());
    Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());

    chart = getChart("summary.chart3", 0);
    axis = chart.getXYPlot().getRangeAxis();
    Assert.assertEquals("value label", "value", axis.getLabel());
    Assert.assertEquals("value label color", Color.BLUE, axis.getLabelPaint());
    Assert.assertEquals("value label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont());
    Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint());
    Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont());
    Assert.assertEquals("tick label mask", "10.00", ((NumberAxis) axis).getNumberFormatOverride().format(10));
    Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());
    Assert.assertEquals("range min value", 1d, ((ValueAxis) axis).getLowerBound());
    Assert.assertEquals("range max value", 15d, ((ValueAxis) axis).getUpperBound());
}
项目:parabuild-ci    文件:XYStepRendererTests.java   
/**
 * Problem that the equals(...) method distinguishes all fields.
 */
public void testEquals() {
    XYStepRenderer r1 = new XYStepRenderer();
    XYStepRenderer r2 = new XYStepRenderer();
    assertEquals(r1, r2);
}
项目:parabuild-ci    文件:XYStepRendererTests.java   
/**
 * Check that the equals() method distinguishes all fields.
 */
public void testEquals() {
    XYStepRenderer r1 = new XYStepRenderer();
    XYStepRenderer r2 = new XYStepRenderer();
    assertEquals(r1, r2);
}
项目:nabs    文件:XYStepRendererTests.java   
/**
 * Check that the equals() method distinguishes all fields.
 */
public void testEquals() {
    XYStepRenderer r1 = new XYStepRenderer();
    XYStepRenderer r2 = new XYStepRenderer();
    assertEquals(r1, r2);
}
项目:astor    文件:XYStepRendererTests.java   
/**
 * Verify that this class implements {@link PublicCloneable}.
 */
public void testPublicCloneable() {
    XYStepRenderer r1 = new XYStepRenderer();
    assertTrue(r1 instanceof PublicCloneable);
}
项目:freedomotic    文件:GraphPanel.java   
private void createChart(UsageDataFrame points, String title) {
    series = new TimeSeries(title);

    for (UsageData d : points.getData()) {
        Date resultdate = d.getDateTime();
        Millisecond msRead = new Millisecond(resultdate);
        int poweredValue = -1;
        if (d.getObjBehavior().equalsIgnoreCase("powered")) {
            poweredValue = d.getObjValue().equalsIgnoreCase("true") ? 1 : 0;
        } else if (d.getObjBehavior().equalsIgnoreCase("brigthness")) {
            try {
                poweredValue = Integer.parseInt(d.getObjValue());
            } catch (NumberFormatException ex) {
                poweredValue = -1;
            }
        }
        series.addOrUpdate(msRead, poweredValue);
    }

    XYDataset xyDataset = new TimeSeriesCollection(series);

    chart = ChartFactory.createTimeSeriesChart("Chart",
            "TIME", "VALUE",
            xyDataset,
            true, // legend
            true, // tooltips
            false // urls
    );
    chart.setAntiAlias(true);
    // Set plot styles
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(2.0, 2.0, 2.0, 2.0));
    // Set series line styles
    plot.setRenderer(new XYStepRenderer());

    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setShapesVisible(true);
        renderer.setShapesFilled(true);
    }

    // Set date axis style
    DateAxis axis = (DateAxis) plot.getDomainAxis();

    String formatString = "MM-dd HH";
    DateTickUnitType dtut = DateTickUnitType.HOUR;

    if (jComboGranularity.getSelectedItem().equals("Year")) {
        formatString = "yyyy";
        dtut = DateTickUnitType.YEAR;
    } else if (jComboGranularity.getSelectedItem().equals("Month")) {
        axis.setDateFormatOverride(new SimpleDateFormat("yyyy-MM"));
        dtut = DateTickUnitType.MONTH;
    } else if (jComboGranularity.getSelectedItem().equals("Day")) {
        axis.setDateFormatOverride(new SimpleDateFormat("MM-dd"));
        dtut = DateTickUnitType.DAY;
    } else if (jComboGranularity.getSelectedItem().equals("Minute")) {
        formatString = "MM-dd HH:mm";
        dtut = DateTickUnitType.MINUTE;
    } else if (jComboGranularity.getSelectedItem().equals("Second")) {
        formatString = "HH:mm:SS";
        dtut = DateTickUnitType.SECOND;
    }

    DateFormat formatter = new SimpleDateFormat(formatString);
    DateTickUnit unit = new DateTickUnit(dtut, 1, formatter);
    axis.setTickUnit(unit);

    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(800, 500));
    graphPanel.removeAll();
    graphPanel.add(chartPanel);

}