Example usage for org.jfree.chart ChartFactory createXYAreaChart

List of usage examples for org.jfree.chart ChartFactory createXYAreaChart

Introduction

In this page you can find the example usage for org.jfree.chart ChartFactory createXYAreaChart.

Prototype

public static JFreeChart createXYAreaChart(String title, String xAxisLabel, String yAxisLabel,
        XYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) 

Source Link

Document

Creates an area chart using an XYDataset .

Usage

From source file:com.devoteam.srit.xmlloader.core.report.derived.DerivedCounter.java

public JFreeChart getTimeChart() {
    double[] graphTable = this.counter.graphDataset.getGraphArray();

    double[] weightTable = null;
    if (this instanceof StatValue) {
        weightTable = ((StatValue) this).eventCounter.graphDataset.getGraphArray();
    }/*from   w w  w  . j  a  v a 2s.  co m*/

    TimeSeries timeSeries = new TimeSeries("", FixedMillisecond.class);

    double hits = 0;

    long offset;
    boolean absoluteDate = Config.getConfigByName("tester.properties").getBoolean("stats.CHARTS_ABSOLUTE_DATE",
            false);
    if (absoluteDate) {
        offset = reportZeroTimestamp;
    } else {
        offset = 0;
    }
    for (int i = 0; i < graphTable.length; i++) {
        long timestamp = offset + i * this.counter.graphDataset.graphParameters.graphPeriod;
        timeSeries.add(new FixedMillisecond(timestamp), graphTable[i], false);
    }

    JFreeChart chart = ChartFactory.createXYAreaChart(null, // chart title
            null, // domain axis label
            null, // range axis label
            new TimeSeriesCollection(timeSeries), // data
            PlotOrientation.VERTICAL, // orientation
            false, // include legend
            false, // tooltips
            false // urls
    );
    if (null != mean && null != std_dv) {
        chart.getXYPlot().addRangeMarker(new ValueMarker(mean));
        IntervalMarker intervalMarker = new IntervalMarker(mean - std_dv / 2, mean + std_dv / 2);
        intervalMarker.setAlpha(0.3f);
        chart.getXYPlot().addRangeMarker(intervalMarker);
    }

    chart.getXYPlot().setDomainAxis(new DateAxis());
    DateAxis axis = (DateAxis) chart.getXYPlot().getDomainAxis();
    DateFormat dateFormat;

    if (absoluteDate) {
        dateFormat = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss");
        axis.setVerticalTickLabels(true);
    } else {
        dateFormat = new SimpleDateFormat("HH:mm:ss");
        dateFormat.setTimeZone(new SimpleTimeZone(0, "GMT"));
    }
    axis.setDateFormatOverride(dateFormat);

    chart.setBackgroundPaint(Color.WHITE);
    return chart;
}

From source file:org.systemsbiology.mzxmlviewer.utilities.SpectrumComponent.java

public static Component getTICComponent(ScanHeader[] scanHeaders, ClickListener cl) {
    XYSeries dataSeries = new XYSeries("BPI");
    for (int i = 0; i < scanHeaders.length; i++)
        dataSeries.add(scanHeaders[i].getDoubleRetentionTime(), scanHeaders[i].getBasePeakIntensity());
    XYSeriesCollection dataSet = new XYSeriesCollection(dataSeries);
    JFreeChart BPIChart = ChartFactory.createXYAreaChart(null, "Retention time (s)", "Intensity", dataSet,
            PlotOrientation.VERTICAL, false, false, false);

    ChartPanel cPanel = new ChartPanel(BPIChart);
    cPanel.setPreferredSize(new Dimension(640, 300));
    cPanel.addChartMouseListener(new CMListAdapter(cl, scanHeaders));
    return cPanel;

}

From source file:org.hxzon.demo.jfreechart.XYDatasetDemo.java

private static JFreeChart createXYAreaChart(XYDataset dataset) {

    JFreeChart chart = ChartFactory.createXYAreaChart("Legal & General Unit Trust Prices", // title
            "Date", // x-axis label
            "Price Per Unit", // y-axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips?
            false // URLs?
    );//from w  w  w  . j a va2  s  . c o m

    chart.setBackgroundPaint(Color.white);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setNumberFormatOverride(MyNumberFormat.getMyNumberFormat());

    return chart;
}

From source file:ispd.gui.auxiliar.Graficos.java

public void criarProcessamentoTempoTarefa(List<Tarefa> tarefas) {

    XYSeriesCollection dadosGrafico = new XYSeriesCollection();
    if (!tarefas.isEmpty()) {
        for (Tarefa task : tarefas) {
            XYSeries tmp_series;//w w w . j  av  a  2 s .c om
            tmp_series = new XYSeries("task " + task.getIdentificador());
            CS_Processamento temp = (CS_Processamento) task.getLocalProcessamento();
            if (temp != null) {
                Double uso = (temp.getPoderComputacional() / this.poderComputacionalTotal) * 100;
                for (int j = 0; j < task.getTempoInicial().size(); j++) {
                    tmp_series.add(task.getTempoInicial().get(j), (Double) 0.0);
                    tmp_series.add(task.getTempoInicial().get(j), uso);
                    tmp_series.add(task.getTempoFinal().get(j), uso);
                    tmp_series.add(task.getTempoFinal().get(j), (Double) 0.0);
                }
                dadosGrafico.addSeries(tmp_series);
            }
        }

    }

    JFreeChart jfc = ChartFactory.createXYAreaChart("Use of total computing power through time " + "\nTasks", //Titulo
            "Time (seconds)", // Eixo X
            "Rate of total use of resources (%)", //Eixo Y
            dadosGrafico, // Dados para o grafico
            PlotOrientation.VERTICAL, //Orientacao do grafico
            true, true, false); // exibir: legendas, tooltips, url
    TaskThroughTimeChart = new ChartPanel(jfc);
}

From source file:org.pentaho.plugin.jfreereport.reportcharts.XYAreaLineChartExpression.java

protected JFreeChart computeXYChart(final XYDataset xyDataset) {
    final JFreeChart chart;
    if (xyDataset instanceof TimeSeriesCollection) {

        if (isStacked()) {
            final ExtTimeTableXYDataset tableXYDataset = convertToTable(xyDataset);
            chart = createTimeSeriesChart(computeTitle(), getDomainTitle(), getRangeTitle(), tableXYDataset,
                    isShowLegend(), false, false, isStacked());
        } else {/*from  ww  w .ja v  a2s  . c o  m*/
            chart = createTimeSeriesChart(computeTitle(), getDomainTitle(), getRangeTitle(), xyDataset,
                    isShowLegend(), false, false, isStacked());
        }
    } else {
        final PlotOrientation orientation = computePlotOrientation();
        if (isStacked()) {
            chart = createStackedXYAreaChart(computeTitle(), getDomainTitle(), getRangeTitle(), xyDataset,
                    orientation, isShowLegend(), false, false);
        } else {
            chart = ChartFactory.createXYAreaChart(computeTitle(), getDomainTitle(), getRangeTitle(), xyDataset,
                    orientation, isShowLegend(), false, false);
        }
    }

    configureLogarithmicAxis(chart.getXYPlot());
    configureLineChart(chart.getXYPlot());
    return chart;
}

From source file:cachedataanalysis.FlowCache.java

public XYSeries exportReportChart() throws IOException {

    File outputHitRate = new File("report/" + name + "_" + policy + "_hitrate.txt");

    FileWriter fw = new FileWriter(outputHitRate);

    XYSeries hitRateCount = new XYSeries(name + "(" + size + " entries)");

    for (int i = 0; i < hitRateRecord.size(); i++) {
        hitRateCount.add(i, hitRateRecord.get(i));
        fw.write(i + "," + hitRateRecord.get(i) + "\n");
        fw.flush();// ww  w .  j  a v a2 s.  c  om
    }
    fw.close();

    XYSeriesCollection HitRateData = new XYSeriesCollection();
    HitRateData.addSeries(hitRateCount);
    JFreeChart hitRateStat = ChartFactory.createXYLineChart(
            "Hit Rate variatoion throughout recording in " + name, "Seconds", "HitRate", HitRateData,
            PlotOrientation.VERTICAL, true, true, false);

    ChartUtilities.saveChartAsJPEG(new File("report/" + name + "_hitRate" + size + ".jpg"), hitRateStat, 1500,
            900);

    //-------------------------------

    if (!fullReport) {
        return hitRateCount;
    }

    DefaultPieDataset hitProtoData = new DefaultPieDataset();
    DefaultPieDataset missProtoData = new DefaultPieDataset();

    CategoryTableXYDataset hitProtoDataRec = new CategoryTableXYDataset();
    for (int i = 0; i < hitProtoRec.size(); i++) {
        if (i % 120 != 0) {
            continue;
        }
        HashMap<String, Integer> _map = hitProtoRec.get(i);
        for (String _str : _map.keySet()) {
            hitProtoDataRec.add(i, _map.get(_str), _str);
        }

    }

    CategoryTableXYDataset missProtoDataRec = new CategoryTableXYDataset();
    for (int i = 0; i < missProtoRec.size(); i++) {
        if (i % 120 != 0) {
            continue;
        }
        HashMap<String, Integer> _map = missProtoRec.get(i);
        for (String _str : _map.keySet()) {
            missProtoDataRec.add(i, _map.get(_str), _str);
        }

    }

    XYSeries hitCountData = new XYSeries("Hit");
    XYSeries allCountData = new XYSeries("All");

    for (int i = 0; i < hitCount.size(); i++) {
        hitCountData.add(i, hitCount.get(i));
        //hitRateCount.add(i,(float)hitCount.get(i)/(hitCount.get(i)+allCount.get(i)));
    }

    for (int i = 0; i < allCount.size(); i++) {
        allCountData.add(i, allCount.get(i));

    }

    XYSeriesCollection CountStatData = new XYSeriesCollection();

    CountStatData.addSeries(hitCountData);
    CountStatData.addSeries(allCountData);

    for (String protocol : hitProto.keySet()) {
        hitProtoData.setValue(protocol, hitProto.get(protocol));
    }

    for (String protocol : missProto.keySet()) {
        missProtoData.setValue(protocol, missProto.get(protocol));
    }

    JFreeChart hitStatRec = ChartFactory.createStackedXYAreaChart(
            "Hit Protocol Fraction throughout record in " + name, "Seconds", "Count", hitProtoDataRec);

    JFreeChart missStatRec = ChartFactory.createStackedXYAreaChart(
            "Miss Protocol Fraction throughout record in " + name, "Seconds", "Count", missProtoDataRec);

    JFreeChart hitStat = ChartFactory.createPieChart3D("Protocal Fraction of Hit Flows in " + name,
            hitProtoData, true, true, false);
    JFreeChart missStat = ChartFactory.createPieChart3D("Protocal Fraction of Miss Flows in " + name,
            missProtoData, true, true, false);
    JFreeChart countStat = ChartFactory.createXYAreaChart("Hit Count to All Packet lookup in " + name,
            "Seconds", "Count", CountStatData, PlotOrientation.VERTICAL, true, true, false);

    ChartUtilities.saveChartAsJPEG(new File("report/" + name + "_hitProto" + size + ".jpg"), hitStat, 1500,
            900);
    ChartUtilities.saveChartAsJPEG(new File("report/" + name + "_missProto" + size + ".jpg"), missStat, 1500,
            900);
    ChartUtilities.saveChartAsJPEG(new File("report/" + name + "_hitCount" + size + ".jpg"), countStat, 1500,
            900);

    ChartUtilities.saveChartAsJPEG(new File("report/" + name + "_hitProtoRecord" + size + ".jpg"), hitStatRec,
            1500, 900);
    ChartUtilities.saveChartAsJPEG(new File("report/" + name + "_missProtoRecord" + size + ".jpg"), missStatRec,
            1500, 900);

    return hitRateCount;
}

From source file:info.puzz.trackprofiler.gui.TrackProfilerFrame.java

protected void drawChart() throws TrackProfilerException {
    if (this.track == null) {
        throw new TrackProfilerException("track_not_loaded"); //$NON-NLS-1$
    }/*from w w  w.  j  a  va2s  . com*/

    this.computeTrackInfo();

    String name = trackFile != null ? trackFile.getName() : "TrackProfiler"; //$NON-NLS-1$

    JFreeChart chart;

    if (TrackProfilerAppContext.getInstance().isFilledGraph()) {
        chart = ChartFactory.createXYAreaChart(name, new Message(Messages.LENGTH).toString(),
                new Message(Messages.ELEVATION).toString(), this.toDataset(), PlotOrientation.VERTICAL, true,
                true, false);
    } else {
        chart = ChartFactory.createXYLineChart(name, new Message(Messages.LENGTH).toString(),
                new Message(Messages.ELEVATION).toString(), this.toDataset(), PlotOrientation.VERTICAL, true,
                true, false);
    }

    chart.setBackgroundPaint(Color.white);

    XYPlot xyplot = (XYPlot) chart.getPlot();
    XYAreaRenderer xyarearenderer = new XYAreaRenderer();
    xyarearenderer.setSeriesPaint(0, new Color(186, 197, 231, 200));

    xyplot.setRenderer(0, xyarearenderer);
    drawSelectedPoints(xyplot);

    if (this.track.getWaypoints().size() > 0) {

        Waypoints markerPoints = new Waypoints();
        markerPoints.addAll(this.track.getWaypoints());

        for (int i = 0; i < this.track.getWaypoints().size(); i++) {
            Waypoint waypoint = (Waypoint) this.track.getWaypoints().get(i);
            prepareWaypontOnChart(xyplot, waypoint);
        }

        xyplot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));
        xyplot.getRangeAxis().setUpperMargin(0.15);
    }

    if (showExtreemes) {
        Vector/* <TrackExtreeme> */ extreemes = this.track.findExtremes();
        for (int i = 0; i < extreemes.size(); i++) {
            Waypoint ex = (Waypoint) extreemes.get(i);
            prepareWaypontOnChart(xyplot, ex);
        }
    }

    getChartPanel().setChart(chart);
    getJPanel1().repaint();
}

From source file:api.window.Histogram.java

private JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createXYAreaChart(null, null, null, xydataset,
            PlotOrientation.VERTICAL, false, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setForegroundAlpha(0.65F);//  w  ww.j a  v  a2  s.co m
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    ValueAxis valueaxis = xyplot.getDomainAxis();
    valueaxis.setTickMarkPaint(Color.black);
    valueaxis.setLowerMargin(0.0D);
    valueaxis.setUpperMargin(0.0D);
    renderer = xyplot.getRenderer();
    if (xydataset.getSeriesCount() == 4) {
        renderer.setSeriesPaint(0, Color.red);
        renderer.setSeriesPaint(1, Color.green);
        renderer.setSeriesPaint(2, Color.blue);
        renderer.setSeriesVisible(0, true);
        renderer.setSeriesVisible(1, true);
        renderer.setSeriesVisible(2, true);
        renderer.setSeriesPaint(3, Color.BLACK);
        renderer.setSeriesVisible(3, true);
    } else {
        this.remove(this.jPanel1);
        renderer.setSeriesPaint(0, Color.BLACK);
        renderer.setSeriesVisible(0, true);
    }
    ValueAxis valueaxis1 = xyplot.getRangeAxis();
    valueaxis1.setTickMarkPaint(Color.black);
    return jfreechart;
}

From source file:CGgui.java

public CGgui() {
    //main window frame
    f.setResizable(false);/*w  w w  .  j  a v a  2 s.  co  m*/
    f.getContentPane().setLayout(new BorderLayout());
    f.getContentPane().add(fCenter, BorderLayout.CENTER);
    f.getContentPane().add(fEast, BorderLayout.EAST);

    //menu
    mnuFile.add(mnuLoad);
    mnuLoad.add(mnuItemOpenFasta);
    mnuLoad.add(mnuItemOpenBed);
    mnuFile.add(mnuSaveData);
    mnuSaveData.add(mnuItemSavePositions);
    mnuSaveData.add(mnuItemSaveClusters);

    //mnuFile.add(mnuItemOpenDataFile);
    mnuFile.add(mnuSaveCharts);
    mnuSaveCharts.add(mnuItemSaveChrt);
    mnuSaveCharts.add(mnuItemSaveMinChrt);
    mnuSaveCharts.add(mnuItemSaveClusterChrt);
    mnuSaveCharts.add(mnuItemSaveGrayChrt);
    mnuSaveCharts.add(mnuItemSaveGrayMinChrt);
    mnuSaveCharts.add(mnuItemSaveGrayClusterChrt);
    mnuFile.add(mnuItemClearData);
    mnuFile.add(mnuItemQuit);
    mnuEdit.add(mnuItemChartProps);
    mnuEdit.add(mnuItemMinimaProps);
    mnuEdit.add(mnuItemClusterProps);
    mnuEdit.add(mnuItemFindMin);
    mnuEdit.add(mnuItemSetAxes);
    mnuEdit.add(mnuItemShowGrid);
    //   mnuHelp.add(mnuItemMan);
    //   mnuHelp.add(mnuItemAbout);
    mb.add(mnuFile);
    mb.add(mnuEdit);
    //   mb.add(mnuHelp);
    f.setJMenuBar(mb);

    //progressbar
    jprogressbar.setVisible(false);
    jprogressbar.setBorderPainted(false);
    f.getContentPane().add(jprogressbar, BorderLayout.SOUTH);

    //chart area
    //histogram
    ChartArea.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    chart = ChartFactory.createXYAreaChart("Fragment Length Histogram", "Fragment Length (l)", "Frequency f(l)",
            histogramdataset, PlotOrientation.VERTICAL, true, true, false);
    chart.addSubtitle(0, new TextTitle("n = " + CurrCG));
    XYPlot xyplot = (XYPlot) chart.getPlot();
    xyplot.setForegroundAlpha(0.85F);
    xyplot.setDomainCrosshairVisible(false);
    chartpanel = new ChartPanel(chart);
    ChartArea.add("Fragment Length", chartpanel);

    //minima
    minchart = ChartFactory.createXYLineChart("Local Minima", "Fragment Length (l)",
            "Number of Matches per Fragment", minimadataset, PlotOrientation.VERTICAL, true, true, false);
    XYPlot minxyplot = (XYPlot) minchart.getPlot();
    minxyplot.setForegroundAlpha(0.85F);
    minchartpanel = new ChartPanel(minchart);
    ChartArea.add("Minima", minchartpanel);

    //optimization
    clusterchart = ChartFactory.createScatterPlot("Average Cluster Size vs. Maximum Fragment Length",
            "Number (n) of Matches per Fragment",
            "Number of Overlapping Fragments per Cluster/Max Fragment Length", clusterdataset,
            PlotOrientation.VERTICAL, true, true, false);

    XYPlot clusterplot = (XYPlot) clusterchart.getPlot();
    clusterplot.setForegroundAlpha(0.85F);
    clusterchartpanel = new ChartPanel(clusterchart);
    ChartArea.add("Optimization", clusterchartpanel);

    //text area
    SeqText.setLineWrap(true);
    SeqText.setWrapStyleWord(true);
    SeqText.setEditable(false);
    jScrollPane.setBorder(BorderFactory
            .createCompoundBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Debug"),
                    BorderFactory.createEmptyBorder(5, 5, 5, 5)), jScrollPane.getBorder()));
    textPanel.add(jScrollPane);
    //this next line is a hack to fix the ScrollPane size when the chart is scrolled
    jScrollPane.setPreferredSize(jScrollPane.getPreferredSize());
    //auto scroll to added text
    SeqText.setAutoscrolls(true);
    jScrollPane.setAutoscrolls(true);

    //center panel layout
    GroupLayout centerlayout = new GroupLayout(fCenter);
    fCenter.setLayout(centerlayout);
    ////Create a sequential and a parallel groups
    SequentialGroup h1 = centerlayout.createSequentialGroup();
    SequentialGroup v1 = centerlayout.createSequentialGroup();
    ////grouping
    h1.addGroup(centerlayout.createParallelGroup().addComponent(ChartArea).addComponent(textPanel));
    centerlayout.setHorizontalGroup(h1);
    ////more grouping
    v1.addGroup(centerlayout.createParallelGroup().addComponent(ChartArea));
    v1.addGroup(centerlayout.createParallelGroup().addComponent(textPanel));
    centerlayout.setVerticalGroup(v1);

    //CG Panel (search settings panel)
    CGPanel.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Search Settings"),
                    BorderFactory.createEmptyBorder(5, 5, 5, 5)),
            CGPanel.getBorder()));
    //set subpanel1 layout
    GroupLayout CGsublayout1 = new GroupLayout(CGsubPanel1);
    CGsubPanel1.setLayout(CGsublayout1);
    ////Create a sequential and a parallel groups
    SequentialGroup h4 = CGsublayout1.createSequentialGroup();
    SequentialGroup v4 = CGsublayout1.createSequentialGroup();
    ////grouping
    h4.addGroup(CGsublayout1.createParallelGroup().addComponent(searchPatternLabel).addComponent(minCGsLabel)
            .addComponent(maxCGsLabel).addComponent(CGstepLabel).addComponent(smoothCheckBox)
            .addComponent(CGApplyButton).addComponent(CGsetCurrLabel));
    h4.addGroup(CGsublayout1.createParallelGroup().addComponent(searchPatternText).addComponent(minCGsText)
            .addComponent(maxCGsText).addComponent(CGstepText).addComponent(smoothText)
            .addComponent(CGResetButton).addComponent(CGcurrText));
    CGsublayout1.setHorizontalGroup(h4);
    ////more grouping
    v4.addGroup(CGsublayout1.createParallelGroup(GroupLayout.Alignment.BASELINE)
            .addComponent(searchPatternLabel).addComponent(searchPatternText));
    v4.addContainerGap(5, 5);
    v4.addGroup(CGsublayout1.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(minCGsLabel)
            .addComponent(minCGsText));
    v4.addContainerGap(5, 5);
    v4.addGroup(CGsublayout1.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(maxCGsLabel)
            .addComponent(maxCGsText));
    v4.addContainerGap(5, 5);
    v4.addGroup(CGsublayout1.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(CGstepLabel)
            .addComponent(CGstepText));
    v4.addContainerGap(5, 5);
    v4.addGroup(CGsublayout1.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(smoothCheckBox)
            .addComponent(smoothText));
    v4.addContainerGap(5, 5);
    v4.addGroup(CGsublayout1.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(CGApplyButton)
            .addComponent(CGResetButton));
    v4.addContainerGap(15, 15);
    v4.addGroup(CGsublayout1.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(CGsetCurrLabel)
            .addComponent(CGcurrText));
    CGsublayout1.setVerticalGroup(v4);

    //set subpanel2 layout
    GroupLayout CGsublayout2 = new GroupLayout(CGsubPanel2);
    CGsubPanel2.setLayout(CGsublayout2);
    ////Create a sequential and a parallel groups
    SequentialGroup hSettingsSub2 = CGsublayout2.createSequentialGroup();
    SequentialGroup vSettingsSub2 = CGsublayout2.createSequentialGroup();

    ////horizontal grouping
    hSettingsSub2.addGroup(CGsublayout2.createParallelGroup().addComponent(CGsetCurrLabel));
    hSettingsSub2.addContainerGap(25, 25);
    hSettingsSub2.addGroup(CGsublayout2.createParallelGroup().addComponent(CGcurrText));
    hSettingsSub2.addContainerGap(25, 25);
    hSettingsSub2.addGroup(CGsublayout2.createParallelGroup().addComponent(CGsetCurrButton));
    CGsublayout2.setHorizontalGroup(hSettingsSub2);
    ////vertical grouping
    vSettingsSub2.addGroup(CGsublayout2.createParallelGroup(GroupLayout.Alignment.BASELINE)
            .addComponent(CGsetCurrLabel).addComponent(CGcurrText).addComponent(CGsetCurrButton));
    CGsublayout2.setVerticalGroup(vSettingsSub2);

    //set overall layout (subpanel3)
    GroupLayout CGsublayout3 = new GroupLayout(CGsubPanel3);
    CGsubPanel3.setLayout(CGsublayout3);
    ////Create a sequential and a parallel groups
    SequentialGroup h5 = CGsublayout3.createSequentialGroup();
    SequentialGroup v5 = CGsublayout3.createSequentialGroup();
    ////grouping
    h5.addGroup(CGsublayout3.createParallelGroup().addComponent(caseCheckBox).addComponent(CGsubPanel1)
            .addComponent(CGsubPanel2));
    CGsublayout3.setHorizontalGroup(h5);
    ////more grouping
    v5.addGroup(CGsublayout3.createParallelGroup().addComponent(caseCheckBox));
    v5.addContainerGap(5, 5);
    v5.addGroup(CGsublayout3.createParallelGroup().addComponent(CGsubPanel1));
    v5.addContainerGap(5, 5);
    v5.addGroup(CGsublayout3.createParallelGroup().addComponent(CGsubPanel2));
    CGsublayout3.setVerticalGroup(v5);
    //add to resizable container
    CGPanel.add(CGsubPanel3);
    //button and slider listeners
    CGApplyButton.addActionListener(new ListenCGApplyButton());
    CGResetButton.addActionListener(new ListenCGResetButton());
    CGsetCurrButton.addActionListener(new ListenCGsetCurrButton());
    CGcurrText.addActionListener(new ListenCGsetCurrButton());

    //minimum area
    findminPanel.setVisible(true);
    findminPanel.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Find Minimum"),
                    BorderFactory.createEmptyBorder(5, 5, 5, 5)),
            findminPanel.getBorder()));
    GroupLayout minlayout = new GroupLayout(findminPanel);
    findminPanel.setLayout(minlayout);

    ////Create a sequential and a parallel groups
    SequentialGroup h2 = minlayout.createSequentialGroup();
    SequentialGroup v2 = minlayout.createSequentialGroup();

    ////group find minimum and find all buttons
    SequentialGroup hFindMinButtons = minlayout.createSequentialGroup();
    SequentialGroup vFindMinButtons = minlayout.createSequentialGroup();
    hFindMinButtons.addGroup(minlayout.createParallelGroup().addComponent(CalcButton));
    hFindMinButtons.addGroup(minlayout.createParallelGroup().addComponent(CalcAllButton));
    vFindMinButtons.addGroup(minlayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
            .addComponent(CalcButton).addComponent(CalcAllButton));
    ////general grouping
    h2.addGroup(minlayout.createParallelGroup().addComponent(minLabel).addComponent(maxLabel)
            .addComponent(ClearButton));
    h2.addContainerGap(5, 5);
    h2.addGroup(minlayout.createParallelGroup().addComponent(minText).addComponent(maxText)
            .addGroup(hFindMinButtons));
    h2.addContainerGap(5, 5);
    h2.addGroup(minlayout.createParallelGroup().addComponent(minGrabButton).addComponent(maxGrabButton)
            .addComponent(CancelButton));
    minlayout.setHorizontalGroup(h2);
    ////more grouping
    v2.addGroup(minlayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(minLabel)
            .addComponent(minText).addComponent(minGrabButton));
    v2.addContainerGap(5, 5);
    v2.addGroup(minlayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(maxLabel)
            .addComponent(maxText).addComponent(maxGrabButton));
    v2.addContainerGap(5, 5);
    v2.addContainerGap(5, 5);
    v2.addGroup(minlayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(ClearButton)
            .addGroup(vFindMinButtons).addComponent(CancelButton));
    minlayout.setVerticalGroup(v2);
    //add button listeners
    ClearButton.addActionListener(new ListenClearButton());
    CalcButton.addActionListener(new ListenCalcButton());
    CalcAllButton.addActionListener(new ListenCalcAllButton());
    CancelButton.addActionListener(new ListenCancelButton());
    minGrabButton.addActionListener(new ListenminGrabButton());
    maxGrabButton.addActionListener(new ListenmaxGrabButton());

    //axes panel
    mnuItemSetAxes.setState(false);
    setaxesPanel.setVisible(false);
    setaxesPanel.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Set Domain"),
                    BorderFactory.createEmptyBorder(5, 5, 5, 5)),
            setaxesPanel.getBorder()));
    GroupLayout setaxeslayout = new GroupLayout(setaxesPanel);
    setaxesPanel.setLayout(setaxeslayout);
    ////Create a sequential and a parallel groups
    SequentialGroup h6 = setaxeslayout.createSequentialGroup();
    SequentialGroup v6 = setaxeslayout.createSequentialGroup();
    ////grouping
    h6.addGroup(setaxeslayout.createParallelGroup().addComponent(mindomainLabel).addComponent(maxdomainLabel)
            .addComponent(SetDomainButton));
    h6.addContainerGap(5, 5);
    h6.addGroup(setaxeslayout.createParallelGroup().addComponent(mindomainText).addComponent(maxdomainText)
            .addComponent(ResetDomainButton));
    setaxeslayout.setHorizontalGroup(h6);
    ////more grouping
    v6.addGroup(setaxeslayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(mindomainLabel)
            .addComponent(mindomainText));
    v6.addContainerGap(5, 5);
    v6.addGroup(setaxeslayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(maxdomainLabel)
            .addComponent(maxdomainText));
    v6.addContainerGap(5, 5);
    v6.addGroup(setaxeslayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(SetDomainButton)
            .addComponent(ResetDomainButton));
    setaxeslayout.setVerticalGroup(v6);
    //add button listeners
    SetDomainButton.addActionListener(new ListenSetDomainButton());
    ResetDomainButton.addActionListener(new ListenResetDomainButton());

    //east panel layout
    GroupLayout eastlayout = new GroupLayout(fEast);
    fEast.setLayout(eastlayout);
    ////Create a sequential and a parallel groups
    SequentialGroup h3 = eastlayout.createSequentialGroup();
    SequentialGroup v3 = eastlayout.createSequentialGroup();
    ////grouping
    h3.addGroup(eastlayout.createParallelGroup().addComponent(CGPanel).addComponent(findminPanel)
            .addComponent(setaxesPanel));
    eastlayout.setHorizontalGroup(h3);
    ////more grouping
    v3.addGroup(eastlayout.createParallelGroup().addComponent(CGPanel));
    v3.addGroup(eastlayout.createParallelGroup().addComponent(findminPanel));
    v3.addGroup(eastlayout.createParallelGroup().addComponent(setaxesPanel));
    eastlayout.setVerticalGroup(v3);

    //listen for exit signals
    f.addWindowListener(new ListenCloseWdw());
    mnuItemQuit.addActionListener(new ListenMenuQuit());

    //listen for exit signals
    f.addWindowListener(new ListenCloseWdw());
    mnuItemClearData.addActionListener(new ListenClearData());

    //listen for open signal
    mnuItemOpenFasta.addActionListener(new ListenMenuOpenFasta());

    //listen for open signal
    mnuItemOpenBed.addActionListener(new ListenMenuOpenBed());

    //listen for save position signal
    mnuItemSavePositions.addActionListener(new ListenMenuSavePositions());

    //listen for save cluster signal
    mnuItemSaveClusters.addActionListener(new ListenMenuSaveClusters());

    //listen for save histogram chart signal
    mnuItemSaveChrt.addActionListener(new ListenMenuSaveChrt());

    //listen for save chart signal
    mnuItemSaveMinChrt.addActionListener(new ListenMenuSaveMinChrt());

    //listen for save cluster chart signal
    mnuItemSaveClusterChrt.addActionListener(new ListenMenuSaveClusterChrt());

    //listen for save histogram chart in grayscale signal;
    mnuItemSaveGrayChrt.addActionListener(new ListenMenuSaveGrayChrt());

    //listen for save chart signal
    mnuItemSaveGrayMinChrt.addActionListener(new ListenMenuSaveGrayMinChrt());

    //listen for save cluster chart signal
    mnuItemSaveGrayClusterChrt.addActionListener(new ListenMenuSaveGrayClusterChrt());

    //listen for edit histogram properties signal
    mnuItemChartProps.addActionListener(new ListenMenuChartProps());

    //listen for edit minima chart properties signal
    mnuItemMinimaProps.addActionListener(new ListenMenuMinimaProps());

    //listen for edit optimization chart properties signal
    mnuItemClusterProps.addActionListener(new ListenMenuClusterProps());

    //listen for find minimum signal
    mnuItemFindMin.addActionListener(new ListenMenuFindMin());

    //listen for find minimum signal
    mnuItemSetAxes.addActionListener(new ListenMenuSetAxes());

    //listen for show gridlines
    mnuItemShowGrid.addActionListener(new ListenMenuShowGrid());

    //other menu items

    //garbage collect
    //System.gc();
}

From source file:net.sf.jsfcomp.chartcreator.utils.ChartUtils.java

public static JFreeChart createChartWithXYDataSet(ChartData chartData) {
    XYDataset dataset = (XYDataset) chartData.getDatasource();
    String type = chartData.getType();
    String xAxis = chartData.getXlabel();
    String yAxis = chartData.getYlabel();
    boolean legend = chartData.isLegend();

    JFreeChart chart = null;//from w  w w. j  a  v  a  2  s  .  co  m
    PlotOrientation plotOrientation = ChartUtils.getPlotOrientation(chartData.getOrientation());

    if (type.equalsIgnoreCase("timeseries")) {
        chart = ChartFactory.createTimeSeriesChart("", xAxis, yAxis, dataset, legend, true, false);
    } else if (type.equalsIgnoreCase("xyline")) {
        chart = ChartFactory.createXYLineChart("", xAxis, yAxis, dataset, plotOrientation, legend, true, false);
    } else if (type.equalsIgnoreCase("polar")) {
        chart = ChartFactory.createPolarChart("", dataset, legend, true, false);
    } else if (type.equalsIgnoreCase("scatter")) {
        chart = ChartFactory.createScatterPlot("", xAxis, yAxis, dataset, plotOrientation, legend, true, false);
    } else if (type.equalsIgnoreCase("xyarea")) {
        chart = ChartFactory.createXYAreaChart("", xAxis, yAxis, dataset, plotOrientation, legend, true, false);
    } else if (type.equalsIgnoreCase("xysteparea")) {
        chart = ChartFactory.createXYStepAreaChart("", xAxis, yAxis, dataset, plotOrientation, legend, true,
                false);
    } else if (type.equalsIgnoreCase("xystep")) {
        chart = ChartFactory.createXYStepChart("", xAxis, yAxis, dataset, plotOrientation, legend, true, false);
    } else if (type.equalsIgnoreCase("bubble")) {
        chart = ChartFactory.createBubbleChart("", xAxis, yAxis, (XYZDataset) dataset, plotOrientation, legend,
                true, false);
    } else if (type.equalsIgnoreCase("candlestick")) {
        chart = ChartFactory.createCandlestickChart("", xAxis, yAxis, (OHLCDataset) dataset, legend);
    } else if (type.equalsIgnoreCase("boxandwhisker")) {
        chart = ChartFactory.createBoxAndWhiskerChart("", xAxis, yAxis, (BoxAndWhiskerXYDataset) dataset,
                legend);
    } else if (type.equalsIgnoreCase("highlow")) {
        chart = ChartFactory.createHighLowChart("", xAxis, yAxis, (OHLCDataset) dataset, legend);
    } else if (type.equalsIgnoreCase("histogram")) {
        chart = ChartFactory.createHistogram("", xAxis, yAxis, (IntervalXYDataset) dataset, plotOrientation,
                legend, true, false);
    } else if (type.equalsIgnoreCase("wind")) {
        chart = ChartFactory.createWindPlot("", xAxis, yAxis, (WindDataset) dataset, legend, true, false);
    }

    if (chart.getPlot() instanceof XYPlot) {
        chart.getXYPlot().setDomainGridlinesVisible(chartData.isDomainGridLines());
        chart.getXYPlot().setRangeGridlinesVisible(chartData.isRangeGridLines());

        if (chartData.getGenerateMap() != null)
            chart.getXYPlot().getRenderer().setURLGenerator(new StandardXYURLGenerator(""));
    }

    setXYSeriesColors(chart, chartData);

    setXYExtensions(chart, chartData);

    return chart;
}