Example usage for org.jfree.data.xy XYSeriesCollection setAutoWidth

List of usage examples for org.jfree.data.xy XYSeriesCollection setAutoWidth

Introduction

In this page you can find the example usage for org.jfree.data.xy XYSeriesCollection setAutoWidth.

Prototype

public void setAutoWidth(boolean b) 

Source Link

Document

Sets the flag that indicates whether the interval width is automatically calculated or not.

Usage

From source file:mt.DisplayHistogram.java

public static IntervalXYDataset createDataset(final List<Double> values, final int numBins,
        final String title) {
    final XYSeries series = new XYSeries(title);

    final ValuePair<Double, Double> minmax = getMinMax(values);
    min = minmax.getA();//from   w ww.j a  v  a 2s . c o m
    max = minmax.getB();

    final List<ValuePair<Double, Integer>> hist = binData(values, min, max, numBins);

    for (final ValuePair<Double, Integer> pair : hist)
        series.add(pair.getA(), pair.getB());

    final XYSeriesCollection dataset = new XYSeriesCollection(series);
    dataset.setAutoWidth(true);

    return dataset;
}

From source file:fungus.UtilizationChartFrame.java

public UtilizationChartFrame(String prefix) {
    simulationCycles = Configuration.getDouble(PAR_SIMULATION_CYCLES);
    this.setTitle("MycoNet Statistics Chart");
    graph = JungGraphObserver.getGraph();

    //data.add(-1,0);
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.setAutoWidth(false);
    dataset.setIntervalWidth(simulationCycles);

    averageUtilizationData = new XYSeries("Average Utilization");
    dataset.addSeries(averageUtilizationData);
    averageStableUtilizationData = new XYSeries("Avg Stable Util");
    dataset.addSeries(averageStableUtilizationData);
    hyphaRatioData = new XYSeries("Hypha Ratio");
    dataset.addSeries(hyphaRatioData);/* w w w  . j  ava 2s  .  c om*/
    stableHyphaRatioData = new XYSeries("Stable Hypha Ratio");
    dataset.addSeries(stableHyphaRatioData);

    //XYSeriesCollection dataset;

    JFreeChart utilizationChart = ChartFactory.createXYLineChart("Utilization Metrics", "Cycle",
            "Average Utilization", dataset, PlotOrientation.VERTICAL, true, false, false);
    ChartPanel utilizationChartPanel = new ChartPanel(utilizationChart);

    //chart.setBackgroundPaint(Color.white);
    //XYPlot plot = chart.getXYPlot();

    //        BufferedImage chartImage = chart.createBufferedImage(500,300);
    //        chartLabel = new JLabel();
    //chartLabel.setIcon(new ImageIcon(chartImage));

    Container contentPane = getContentPane();
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS));
    JPanel labelPane = new JPanel();
    labelPane.setLayout(new GridLayout(1, 1));
    //chartPane.setPreferredSize(new java.awt.Dimension(500, 300));
    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));

    ////contentPane.add(labelPane,BorderLayout.PAGE_START);
    //contentPane.add(Box.createRigidArea(new Dimension(0,5)));
    contentPane.add(utilizationChartPanel, BorderLayout.CENTER);
    //contentPane.add(Box.createRigidArea(new Dimension(0,5)));
    ////contentPane.add(buttonPane, BorderLayout.PAGE_END);

    //data = node.getHyphaData();
    //link = node.getHyphaLink();
    //mycocast = node.getMycoCast();

    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    //chartPanel.add(chartLabel);

    /*JButton updateButton = new JButton("Refresh");
      ActionListener updater = new ActionListener() {
      public void actionPerformed(ActionEvent e) {
      refreshData();
      }
      };
      updateButton.addActionListener(updater);
            
      JButton closeButton = new JButton("Close");
      ActionListener closer = new ActionListener() {
      public void actionPerformed(ActionEvent e) {
      closeFrame();
      }
      };
      closeButton.addActionListener(closer);
            
      buttonPane.add(Box.createHorizontalGlue());
      buttonPane.add(updateButton);
      buttonPane.add(Box.createRigidArea(new Dimension(5,0)));
      buttonPane.add(closeButton);
      refreshData();
    */

    //JungGraphObserver.addChangeListener(this);

    this.pack();
    this.setVisible(true);
}

From source file:fungus.PeerRatioChartFrame.java

public PeerRatioChartFrame(String prefix) {
    simulationCycles = Configuration.getDouble(PAR_SIMULATION_CYCLES);
    this.setTitle("MycoNet Statistics Chart");
    graph = JungGraphObserver.getGraph();

    //data.add(-1,0);
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.setAutoWidth(false);
    dataset.setIntervalWidth(simulationCycles);

    //averageUtilizationData = new XYSeries("Average Utilization");
    //dataset.addSeries(averageUtilizationData);
    //averageStableUtilizationData = new XYSeries("Avg Stable Util");
    //dataset.addSeries(averageStableUtilizationData);
    bulwarkRatioData = new XYSeries("Bulwark Ratio");
    dataset.addSeries(bulwarkRatioData);
    biomassRatioData = new XYSeries("Biomass Ratio");
    dataset.addSeries(biomassRatioData);
    hyphaRatioData = new XYSeries("Hypha Ratio");
    dataset.addSeries(hyphaRatioData);// www  .  j  a  v  a  2s.  c o m
    // stableHyphaRatioData = new XYSeries("Stable Hypha Ratio");
    // dataset.addSeries(stableHyphaRatioData);

    //XYSeriesCollection dataset;

    JFreeChart peerRatioChart = ChartFactory.createXYLineChart("Bulwark Metrics", "Cycle", "Peer State Ratio",
            dataset, PlotOrientation.VERTICAL, true, false, false);
    ChartPanel peerRatioChartPanel = new ChartPanel(peerRatioChart);

    XYPlot xyplot = peerRatioChart.getXYPlot();

    NumberAxis domainAxis = (NumberAxis) xyplot.getDomainAxis();
    NumberAxis rangeAxis = (NumberAxis) xyplot.getRangeAxis();
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setRange(0, 1);

    //chart.setBackgroundPaint(Color.white);
    //XYPlot plot = chart.getXYPlot();

    //        BufferedImage chartImage = chart.createBufferedImage(500,300);
    //        chartLabel = new JLabel();
    //chartLabel.setIcon(new ImageIcon(chartImage));

    Container contentPane = getContentPane();
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS));
    JPanel labelPane = new JPanel();
    labelPane.setLayout(new GridLayout(1, 1));
    //chartPane.setPreferredSize(new java.awt.Dimension(500, 300));
    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));

    ////contentPane.add(labelPane,BorderLayout.PAGE_START);
    //contentPane.add(Box.createRigidArea(new Dimension(0,5)));
    contentPane.add(peerRatioChartPanel, BorderLayout.CENTER);
    //contentPane.add(Box.createRigidArea(new Dimension(0,5)));
    ////contentPane.add(buttonPane, BorderLayout.PAGE_END);

    //data = node.getHyphaData();
    //link = node.getHyphaLink();
    //mycocast = node.getMycoCast();

    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    //chartPanel.add(chartLabel);

    /*JButton updateButton = new JButton("Refresh");
      ActionListener updater = new ActionListener() {
      public void actionPerformed(ActionEvent e) {
      refreshData();
      }
      };
      updateButton.addActionListener(updater);
            
      JButton closeButton = new JButton("Close");
      ActionListener closer = new ActionListener() {
      public void actionPerformed(ActionEvent e) {
      closeFrame();
      }
      };
      closeButton.addActionListener(closer);
            
      buttonPane.add(Box.createHorizontalGlue());
      buttonPane.add(updateButton);
      buttonPane.add(Box.createRigidArea(new Dimension(5,0)));
      buttonPane.add(closeButton);
      refreshData();
    */

    //JungGraphObserver.addChangeListener(this);

    this.pack();
    this.setVisible(true);
}

From source file:beadAnalyzer.DrawPoints.java

public IntervalXYDataset createDataset(final List<Double> values, final int numBins, final String title) {
    final XYSeries series = new XYSeries(title);

    final ValuePair<Double, Double> minmax = getMinMax(values);
    this.min = minmax.getA();
    this.max = minmax.getB();

    final List<ValuePair<Double, Integer>> hist = binData(values, min, max, numBins);

    for (final ValuePair<Double, Integer> pair : hist)
        series.add(pair.getA(), pair.getB());

    final XYSeriesCollection dataset = new XYSeriesCollection(series);
    dataset.setAutoWidth(true);

    return dataset;
}

From source file:com.signalcollect.sna.gephiconnectors.SignalCollectGephiConnector.java

/**
 * Creates the Chart of the Degree Distribution according to the calculated
 * distribution//from   w ww. ja  v  a  2 s.c  o m
 * 
 * @param degreeDistribution
 * @return a {@link JFreeChart} containing the distribution of degrees in
 *         the graph
 * @throws IOException
 */
public JFreeChart createDegreeDistributionChart(Map<Integer, Integer> degreeDistribution) throws IOException {
    XYSeries dSeries = new XYSeries("number of occurences");
    for (Iterator it = degreeDistribution.entrySet().iterator(); it.hasNext();) {
        Map.Entry d = (Map.Entry) it.next();
        Number x = (Number) d.getKey();
        Number y = (Number) d.getValue();
        dSeries.add(x, y);
    }
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(dSeries);
    dataset.setAutoWidth(true);

    JFreeChart chart = ChartFactory.createHistogram("Degree Distribution", "Degree centrality value",
            "number of occurences", dataset, PlotOrientation.VERTICAL, true, true, true);

    XYPlot plot = chart.getXYPlot();
    XYBarRenderer renderer0 = new XYBarRenderer();
    Font font = new Font("Font", 0, 14);
    renderer0.setMargin(0.2);
    renderer0.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
    renderer0.setBaseItemLabelsVisible(true);
    renderer0.setBaseItemLabelFont(font);
    plot.setDataset(0, dataset);
    plot.setRenderer(0, renderer0);
    plot.getRendererForDataset(plot.getDataset(0)).setSeriesPaint(0, Color.BLUE);
    return chart;
}

From source file:com.signalcollect.sna.gephiconnectors.SignalCollectGephiConnector.java

/**
 * Creates the Chart of the Clustering Distribution according to the
 * calculated distribution/*from w w w .ja  v a  2  s  .  c om*/
 * 
 * @param clusterDistribution
 * @return a {@link JFreeChart} containing the distribution of local cluster
 *         coefficients in the graph
 * @throws IOException
 */
public JFreeChart createClusterDistributionChart(Map<Double, Integer> clusterDistribution) throws IOException {
    XYSeries dSeries = new XYSeries("number of occurences");
    for (Iterator it = clusterDistribution.entrySet().iterator(); it.hasNext();) {
        Map.Entry d = (Map.Entry) it.next();
        Number x = (Number) d.getKey();
        Number y = (Number) d.getValue();
        dSeries.add(x, y);
    }
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(dSeries);
    dataset.setAutoWidth(true);

    JFreeChart chart = ChartFactory.createHistogram("Local Cluster Coefficient Distribution",
            "Local Cluster Coefficient value", "number of occurences", dataset, PlotOrientation.VERTICAL, true,
            true, true);

    XYPlot plot = chart.getXYPlot();
    XYBarRenderer renderer0 = new XYBarRenderer();
    Font font = new Font("Font", 0, 14);
    renderer0.setMargin(0.2);
    renderer0.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
    renderer0.setBaseItemLabelsVisible(true);
    renderer0.setBaseItemLabelFont(font);
    plot.setDataset(0, dataset);
    plot.setRenderer(0, renderer0);

    plot.getRendererForDataset(plot.getDataset(0)).setSeriesPaint(0, Color.BLUE);

    return chart;
}

From source file:org.jfree.data.xy.junit.XYSeriesCollectionTest.java

/**
 * Confirm that the equals method can distinguish all the required fields.
 *///from w w w  .j a  v a2 s  . c  o m
public void testEquals() {
    XYSeries s1 = new XYSeries("Series");
    s1.add(1.0, 1.1);
    XYSeriesCollection c1 = new XYSeriesCollection();
    c1.addSeries(s1);
    XYSeries s2 = new XYSeries("Series");
    s2.add(1.0, 1.1);
    XYSeriesCollection c2 = new XYSeriesCollection();
    c2.addSeries(s2);
    assertTrue(c1.equals(c2));
    assertTrue(c2.equals(c1));

    c1.addSeries(new XYSeries("Empty Series"));
    assertFalse(c1.equals(c2));
    c2.addSeries(new XYSeries("Empty Series"));
    assertTrue(c1.equals(c2));

    c1.setIntervalWidth(5.0);
    assertFalse(c1.equals(c2));
    c2.setIntervalWidth(5.0);
    assertTrue(c1.equals(c2));

    c1.setIntervalPositionFactor(0.75);
    assertFalse(c1.equals(c2));
    c2.setIntervalPositionFactor(0.75);
    assertTrue(c1.equals(c2));

    c1.setAutoWidth(true);
    assertFalse(c1.equals(c2));
    c2.setAutoWidth(true);
    assertTrue(c1.equals(c2));

}

From source file:org.jfree.data.xy.XYSeriesCollectionTest.java

/**
 * Confirm that the equals method can distinguish all the required fields.
 *///from ww  w.  ja  v a 2  s. c om
@Test
public void testEquals() {
    XYSeries s1 = new XYSeries("Series");
    s1.add(1.0, 1.1);
    XYSeriesCollection c1 = new XYSeriesCollection();
    c1.addSeries(s1);
    XYSeries s2 = new XYSeries("Series");
    s2.add(1.0, 1.1);
    XYSeriesCollection c2 = new XYSeriesCollection();
    c2.addSeries(s2);
    assertEquals(c1, c2);
    assertEquals(c2, c1);

    c1.addSeries(new XYSeries("Empty Series"));
    assertFalse(c1.equals(c2));
    c2.addSeries(new XYSeries("Empty Series"));
    assertEquals(c1, c2);

    c1.setIntervalWidth(5.0);
    assertFalse(c1.equals(c2));
    c2.setIntervalWidth(5.0);
    assertEquals(c1, c2);

    c1.setIntervalPositionFactor(0.75);
    assertFalse(c1.equals(c2));
    c2.setIntervalPositionFactor(0.75);
    assertEquals(c1, c2);

    c1.setAutoWidth(true);
    assertFalse(c1.equals(c2));
    c2.setAutoWidth(true);
    assertEquals(c1, c2);

}