Example usage for org.jfree.chart JFreeChart getLegend

List of usage examples for org.jfree.chart JFreeChart getLegend

Introduction

In this page you can find the example usage for org.jfree.chart JFreeChart getLegend.

Prototype

public LegendTitle getLegend() 

Source Link

Document

Returns the legend for the chart, if there is one.

Usage

From source file:hudson.plugins.codeviation.MetricsAction.java

private JFreeChart createChart(CategoryDataset dataset, int maxVal) {

    final JFreeChart chart = ChartFactory.createLineChart(null, // chart title
            null, // unused
            "count", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );//from   w w  w.  j  a  v a2 s . c o m

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...

    final LegendTitle legend = chart.getLegend();
    legend.setPosition(RectangleEdge.RIGHT);

    chart.setBackgroundPaint(Color.white);

    final CategoryPlot plot = chart.getCategoryPlot();

    // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setBackgroundPaint(Color.WHITE);
    plot.setOutlinePaint(null);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.black);

    CategoryAxis domainAxis = new ShiftedCategoryAxis(null);
    plot.setDomainAxis(domainAxis);
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    domainAxis.setCategoryMargin(0.0);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setUpperBound(maxVal);
    rangeAxis.setLowerBound(0);

    final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    renderer.setStroke(new BasicStroke(4.0f));

    // crop extra space around the graph
    plot.setInsets(new RectangleInsets(5.0, 0, 0, 5.0));

    return chart;
}

From source file:org.pf.midea.SimulationController.java

@Override
public void run() {
    textAreaNumeric.setText("");
    XYSeriesCollection xySeriesCollection = new XYSeriesCollection();
    double progress = 0;
    double progressStep = 100.0 / (planCells.length * (hSquareHigh - hSquareLow + hSquareStep) / hSquareStep);
    progressBar.setValue(0);//from w w w.ja  v  a 2  s.  co m
    for (int i = 0; i < planCells.length; i++) {
        XYSeries xySeries;
        if (showLineNumbers)
            xySeries = new XYSeries(String.valueOf(i + 1) + ") " + planCells[i].getShortDescription());
        else
            xySeries = new XYSeries(planCells[i].getShortDescription());
        textAreaNumeric.append(planCells[i].getDescription() + "\n");
        textAreaNumeric.setCaretPosition(textAreaNumeric.getDocument().getLength());

        PlanStates.SourceType currentSourceType = planCells[i].getSourceCell().getSourceType();
        PlanStates.CodeType currentCodeType = planCells[i].getCodeCell().getCodeType();
        PlanStates.ModulationType currentModulationType = planCells[i].getModulationCell().getModulationType();
        PlanStates.ChannelType currentChannelType = planCells[i].getChannelCell().getChannelType();
        PlanStates.ErrorsType currentErrorsType = planCells[i].getErrorsCell().getErrorsType();

        BinaryNumber[] sourcePoints = null;
        switch (currentSourceType) {
        case ST_TEST:
            sourcePoints = ConstellationPointsGenerator.getTestPoints(currentModulationType, iterationsCount);
            break;
        case ST_RANDOM:
            sourcePoints = ConstellationPointsGenerator.getRandomPoints(currentModulationType, iterationsCount);
            break;
        }

        Coder coder = null;
        Decoder decoder = null;
        switch (currentCodeType) {
        case CT_NONE:
            coder = new CoderNone();
            decoder = new DecoderNone();
            break;
        case CT_HAMMING74:
            coder = new CoderHamming74();
            decoder = new DecoderHamming74();
            break;
        case CT_CYCLIC:
            coder = new CoderCyclic85();
            decoder = new DecoderCyclic85();
            break;
        case CT_BCH155:
            coder = new CoderBCH155();
            decoder = new DecoderBCH155();
            break;
        }

        Modulator modulator = null;
        Demodulator demodulator = null;
        switch (currentModulationType) {
        case MT_ASK:
            modulator = new ModulatorASK();
            demodulator = new DemodulatorASK();
            break;
        case MT_FSK:
            modulator = new ModulatorFSK();
            demodulator = new DemodulatorFSK();
            break;
        case MT_BPSK:
            modulator = new ModulatorBPSK();
            demodulator = new DemodulatorBPSK();
            break;
        case MT_QPSK:
            modulator = new ModulatorQPSK();
            demodulator = new DemodulatorQPSK();
            break;
        case MT_8PSK:
            modulator = new Modulator8PSK();
            demodulator = new Demodulator8PSK();
            break;
        case MT_16PSK:
            modulator = new Modulator16PSK();
            demodulator = new Demodulator16PSK();
            break;
        case MT_32PSK:
            modulator = new Modulator32PSK();
            demodulator = new Demodulator32PSK();
            break;
        case MT_16QAM:
            modulator = new Modulator16QAM();
            demodulator = new Demodulator16QAM();
            break;
        case MT_32QAM:
            modulator = new Modulator32QAM();
            demodulator = new Demodulator32QAM();
            break;
        case MT_64QAM:
            modulator = new Modulator64QAM();
            demodulator = new Demodulator64QAM();
            break;
        case MT_256QAM:
            modulator = new Modulator256QAM();
            demodulator = new Demodulator256QAM();
            break;
        }

        Channel channel = null;
        switch (currentChannelType) {
        case CHT_AWGN:
            channel = new ChannelAWGN();
            break;
        case CHT_RAYLEIGH:
            channel = new ChannelRayleigh();
            break;
        }

        BinaryNumber[] encoded = coder.encode(sourcePoints);
        Signal[] modulated = modulator.modulate(encoded);

        double error = 0;

        for (double h = hSquareLow; h <= hSquareHigh; h += hSquareStep) {
            double realH;
            if (dBs)
                realH = StatisticsTools.decibelsToTimes(h);
            else
                realH = h;

            Signal[] noised = channel.noise(realH, modulated);
            BinaryNumber[] demodulated = demodulator.demodulate(noised);
            noised = null;
            System.gc();
            BinaryNumber[] decoded = decoder.decode(demodulated);
            demodulated = null;
            System.gc();
            switch (currentErrorsType) {
            case ET_SER:
                error = StatisticsTools.getSER(sourcePoints, decoded);
                break;
            case ET_BER:
                error = StatisticsTools.getBER(sourcePoints, decoded);
                break;
            }
            decoded = null;
            System.gc();

            if (error > 0) {
                xySeries.add(h, error);
                textAreaNumeric.append(String.valueOf(h) + "\t" + String.valueOf(error) + "\n");
                textAreaNumeric.setCaretPosition(textAreaNumeric.getDocument().getLength());
            }

            progress += progressStep;
            progressBar.setValue((int) Math.round(progress));
        }
        xySeriesCollection.addSeries(xySeries);
        textAreaNumeric.append("\n");
        textAreaNumeric.setCaretPosition(textAreaNumeric.getDocument().getLength());
    }

    JFreeChart chart = ChartFactory.createXYLineChart("", dBs ? "" : "", "?",
            xySeriesCollection, PlotOrientation.VERTICAL, true, true, false);
    chart.getLegend().setPosition(RectangleEdge.RIGHT);
    XYPlot xyPlot = chart.getXYPlot();

    for (int i = 0; i < planCells.length; i++) {
        xyPlot.getRenderer().setSeriesStroke(i, new BasicStroke(planCells[i].getLineWidth()));
        if (planCells[i].getLineColor() != null)
            xyPlot.getRenderer().setSeriesPaint(i, planCells[i].getLineColor());

        if (showLineNumbers) {
            XYSeries currentSeries = xySeriesCollection.getSeries(i);
            double annotationY = currentSeries.getY(0).doubleValue();
            double annotationX = currentSeries.getX(0).doubleValue();
            for (int j = 1; j < currentSeries.getItemCount(); j++)
                if (currentSeries.getY(j).doubleValue() == 0) {
                    annotationY = currentSeries.getY(j - 1).doubleValue();
                    annotationX = currentSeries.getX(j - 1).doubleValue();
                    break;
                } else {
                    annotationY = currentSeries.getY(j).doubleValue();
                    annotationX = currentSeries.getX(j).doubleValue();
                }
            XYTextAnnotation annotation = new XYTextAnnotation(String.valueOf(i + 1), annotationX, annotationY);
            annotation.setBackgroundPaint(Color.WHITE);
            annotation.setFont(new Font("Dialog", 0, 14));
            xyPlot.addAnnotation(annotation);
        }
    }

    xyPlot.setBackgroundPaint(Color.WHITE);
    xyPlot.setDomainGridlinePaint(Color.GRAY);
    xyPlot.setRangeGridlinePaint(Color.GRAY);
    NumberAxis domainAxis = new NumberAxis("h, " + (dBs ? "" : ""));
    LogAxis rangeAxis = new LogAxis("?");
    rangeAxis.setNumberFormatOverride(new HumanNumberFormat(1));
    domainAxis.setTickLabelFont(new Font("Dialog", 0, 14));
    rangeAxis.setTickLabelFont(new Font("Dialog", 0, 14));
    xyPlot.setDomainAxis(domainAxis);
    xyPlot.setRangeAxis(rangeAxis);

    ChartPanel nestedPanel = new ChartPanel(chart);
    chartPanel.removeAll();
    chartPanel.add(nestedPanel, new CellConstraints());
    chartPanel.updateUI();
}

From source file:net.footballpredictions.footballstats.swing.LeaguePositionGraph.java

/**
 * Plot league positions by date./*from  w w w  . ja va 2  s . c om*/
 */
public void updateGraph(Object[] teams, LeagueSeason data) {
    assert teams.length > 0 : "Must be at least one team selected.";
    TimeSeriesCollection dataSet = new TimeSeriesCollection();
    for (Object team : teams) {
        String teamName = (String) team;
        TimeSeries positionSeries = new TimeSeries(teamName);

        SortedMap<Date, Integer> positions = data.getTeam(teamName).getLeaguePositions();
        for (Map.Entry<Date, Integer> entry : positions.entrySet()) {
            positionSeries.add(new Day(entry.getKey()), entry.getValue());
        }
        dataSet.addSeries(positionSeries);
    }

    JFreeChart chart = ChartFactory.createTimeSeriesChart(null, // Title
            messageResources.getString("graphs.date"),
            messageResources.getString("combo.GraphType.LEAGUE_POSITION"), dataSet, true, // Legend.
            false, // Tooltips.
            false); // URLs.
    chart.getXYPlot().getRangeAxis().setInverted(true);
    chart.getXYPlot().getRangeAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    chart.getXYPlot().getRangeAxis().setRangeWithMargins(1, data.getTeamNames().size());
    chart.getLegend().setPosition(legendPosition);
    setChart(chart);
}

From source file:com.itemanalysis.jmetrik.graph.nicc.NonparametricCurvePanel.java

private void createChart(String name, String title, String xLabel, String yLabel, double minScore,
        double maxScore) {
    XYSeriesCollection dataset = new XYSeriesCollection();
    final JFreeChart chart = ChartFactory.createXYLineChart(title, // chart title
            xLabel, // x axis label
            yLabel, // y axis label
            dataset, // data
            chartOrientation, // chart orientation
            showLegend, // include legend
            true, // tooltips
            false // urls
    );/*from ww  w.  ja v a  2 s  . c o m*/

    if (showLegend) {
        LegendTitle chartTitle = chart.getLegend();
        chartTitle.setPosition(legendPosition);
    }

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);

    //        //can use this code to fix the number of tick marks on the y-axis
    //        NumberFormat myFormatter = new DecimalFormat("#.0");
    //        NumberAxis yaxis = (NumberAxis)plot.getRangeAxis();
    //        yaxis.setTickUnit(new NumberTickUnit(.1, myFormatter));

    ChartPanel panel = new ChartPanel(chart);
    panel.getPopupMenu().addSeparator();
    panel.setPreferredSize(new Dimension(width, height));

    //        this.addLocalEPSMenuItem(this, panel.getPopupMenu(), chart);//remove this line for public release versions

    chart.setPadding(new RectangleInsets(20.0, 5.0, 20.0, 5.0));
    charts.put(name, chart);

    JPanel subPanel = new JPanel();//additional panel needed to prevent gridlayout from stretching graph
    subPanel.add(panel);
    subPanel.setBackground(Color.WHITE);
    this.add(subPanel);

}

From source file:net.praqma.jenkins.memorymap.MemoryMapBuildAction.java

public void doDrawMemoryMapUsageGraph(StaplerRequest req, StaplerResponse rsp) throws IOException {
    DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel> dataset = new DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel>();

    String members = req.getParameter("categories");
    String graphTitle = req.getParameter("title");

    int w = Integer.parseInt(req.getParameter("width"));
    int h = Integer.parseInt(req.getParameter("height"));

    List<String> memberList = Arrays.asList(members.split(","));
    List<List<String>> memberLists = new ArrayList<List<String>>();

    for (String s : memberList) {
        memberLists.add(Arrays.asList(s.split(" ")));
    }//from ww  w  . ja  v a2s  .c o  m

    List<ValueMarker> markers = new ArrayList<ValueMarker>();

    double max = Double.MIN_VALUE;
    Set<String> drawnMarker = new HashSet<String>();

    String scale = getRecorder().scale;

    for (MemoryMapBuildAction membuild = this; membuild != null; membuild = membuild.getPreviousAction()) {
        ChartUtil.NumberOnlyBuildLabel label = new ChartUtil.NumberOnlyBuildLabel(membuild.build);
        MemoryMapConfigMemory result = membuild.getMemoryMapConfig();
        MemoryMapConfigMemory resultBlacklist = new MemoryMapConfigMemory();
        for (List<String> list : memberLists) {
            double value = 0.0d;
            double maxx = 0.0d;
            String labelName = "";
            for (MemoryMapConfigMemoryItem res : result) {
                if (list.contains(res.getName()) && !resultBlacklist.contains(res)) {
                    resultBlacklist.add(res);
                    if (labelName.equals("")) {
                        labelName = res.getName();
                    } else {
                        labelName = String.format("%s+%s", labelName, res.getName());
                    }

                    if (getRecorder().getShowBytesOnGraph()) {
                        maxx = maxx + HexUtils.byteCount(res.getLength(), getRecorder().getWordSize(), scale);
                        value = value + HexUtils.byteCount(res.getUsed(), getRecorder().getWordSize(), scale);
                    } else {
                        maxx = maxx + HexUtils.wordCount(res.getLength(), getRecorder().getWordSize(), scale);
                        value = value + HexUtils.wordCount(res.getUsed(), getRecorder().getWordSize(), scale);
                    }
                } else {
                }

                if (maxx > max) {
                    max = maxx;
                }
                if (value > max) {
                    max = value;
                }
            }
            if (!labelName.equals("")) {
                dataset.add(value, labelName, label);
            }

            boolean makeMarker = true;
            for (ValueMarker vm : markers) {
                if (maxx == vm.getValue() && !vm.getLabel().contains(labelName) && !labelName.equals("")) {
                    drawnMarker.add(vm.getLabel().replace("(MAX) - ", "") + " - " + labelName);
                    String s = vm.getLabel().replace("(MAX) - ", "");

                    vm.setLabel(String.format("%s - %s", vm.getLabel(), labelName));
                    //this is the size of chars used for setting the offset right
                    double i = vm.getLabel().length() * labelOffset + 40;
                    vm.setLabelOffset(new RectangleInsets(5, i, -20, 5));

                    makeMarker = false;
                }
            }

            if ((!labelName.equals("")) && (drawnMarker.add(labelName))) {
                if (makeMarker) {
                    ValueMarker vm = new ValueMarker((double) maxx, Color.BLACK,
                            new BasicStroke(1.2f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 1.0f,
                                    new float[] { 6.0f, 6.0f }, 0.0f));

                    vm.setLabel(String.format("(MAX) - %s", labelName));

                    double i = vm.getLabel().length() * labelOffset + 40;
                    vm.setLabelOffset(new RectangleInsets(5, i, -20, 5));
                    vm.setLabelAnchor(RectangleAnchor.TOP_LEFT);
                    vm.setPaint(Color.BLACK);
                    vm.setOutlinePaint(Color.BLACK);
                    vm.setAlpha(1.0f);
                    markers.add(vm);
                }
            }
        }
    }

    String s = "";
    if (scale.equalsIgnoreCase("kilo")) {
        s = "k";
    } else if (scale.equalsIgnoreCase("mega")) {
        s = "M";
    } else if (scale.equalsIgnoreCase("giga")) {
        s = "G";
    }

    String byteLegend = s + "Bytes";
    String wordLegend = s + "Words";

    String legend = getRecorder().getShowBytesOnGraph() ? byteLegend : wordLegend;

    JFreeChart chart = createPairedBarCharts(graphTitle, legend, max * 1.1d, 0d, dataset.build(), markers);

    chart.setBackgroundPaint(Color.WHITE);
    chart.getLegend().setPosition(RectangleEdge.BOTTOM);
    ChartUtil.generateGraph(req, rsp, chart, w, h);
}

From source file:hudson.plugins.codeviation.RepositoryView.java

private JFreeChart createChart(CategoryDataset dataset, int max) {

    final JFreeChart chart = ChartFactory.createLineChart(null, // chart title
            null, // unused
            "counts", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );/*from  ww  w . j a  v  a  2s  . c  o m*/

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...

    final LegendTitle legend = chart.getLegend();
    legend.setPosition(RectangleEdge.RIGHT);

    chart.setBackgroundPaint(Color.white);

    final CategoryPlot plot = chart.getCategoryPlot();

    // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setBackgroundPaint(Color.WHITE);
    plot.setOutlinePaint(null);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.black);

    CategoryAxis domainAxis = new ShiftedCategoryAxis(null);
    plot.setDomainAxis(domainAxis);
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    domainAxis.setCategoryMargin(0.0);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setUpperBound(max * 1.2);
    rangeAxis.setLowerBound(0);

    final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    renderer.setStroke(new BasicStroke(4.0f));

    // crop extra space around the graph
    plot.setInsets(new RectangleInsets(5.0, 0, 0, 5.0));

    return chart;
}

From source file:edu.msu.cme.rdp.classifier.train.validation.distance.TaxaSimilarityMain.java

public void createPlot(String plotTitle, File outdir) throws IOException {
    XYSeriesCollection dataset = new XYSeriesCollection();
    DefaultBoxAndWhiskerCategoryDataset scatterDataset = new DefaultBoxAndWhiskerCategoryDataset();

    PrintStream boxchart_dataStream = new PrintStream(new File(outdir, plotTitle + ".boxchart.txt"));

    boxchart_dataStream.println(//  w  w  w  .j a  va  2  s  .  c o m
            "#\tkmer" + "\trank" + "\t" + "max" + "\t" + "avg" + "\t" + "min" + "\t" + "Q1" + "\t" + "median"
                    + "\t" + "Q3" + "\t" + "98Pct" + "\t" + "2Pct" + "\t" + "comparisons" + "\t" + "sum");
    for (int i = 0; i < ranks.size(); i++) {
        long[] countArray = sabCoutMap.get(ranks.get(i));
        if (countArray == null)
            continue;

        double sum = 0.0;
        int max = 0;
        int min = 100;
        double mean = 0;
        int Q1 = -1;
        int median = -1;
        int Q3 = -1;
        int pct_98 = -1;
        int pct_2 = -1;
        long comparisons = 0;
        int minOutlier = 0; // we don't care about the outliers
        int maxOutlier = 0; //

        XYSeries series = new XYSeries(ranks.get(i));

        for (int c = 0; c < countArray.length; c++) {
            if (countArray[c] == 0)
                continue;
            comparisons += countArray[c];
            sum += countArray[c] * c;
            if (c < min) {
                min = c;
            }
            if (c > max) {
                max = c;
            }
        }

        // create series
        double cum = 0;
        for (int c = 0; c < countArray.length; c++) {
            if (countArray[c] == 0)
                continue;
            cum += countArray[c];
            int pct = (int) Math.floor(100 * cum / comparisons);
            series.add(c, pct);

            if (pct_2 == -1 && pct >= 5) {
                pct_2 = c;
            }
            if (Q3 == -1 && pct >= 25) {
                Q3 = c;
            }
            if (median == -1 && pct >= 50) {
                median = c;
            }
            if (Q1 == -1 && pct >= 75) {
                Q1 = c;
            }
            if (pct_98 == -1 && pct >= 98) {
                pct_98 = c;
            }
        }
        if (!series.isEmpty()) {
            dataset.addSeries(series);

            BoxAndWhiskerItem item = new BoxAndWhiskerItem(sum / comparisons, median, Q1, Q3, pct_2, pct_98,
                    minOutlier, maxOutlier, new ArrayList());
            scatterDataset.add(item, ranks.get(i), "");

            boxchart_dataStream.println("#\t" + GoodWordIterator.getWordsize() + "\t" + ranks.get(i) + "\t"
                    + max + "\t" + format.format(sum / comparisons) + "\t" + min + "\t" + Q1 + "\t" + median
                    + "\t" + Q3 + "\t" + pct_98 + "\t" + pct_2 + "\t" + comparisons + "\t" + sum);
        }
    }
    boxchart_dataStream.close();
    Font lableFont = new Font("Helvetica", Font.BOLD, 28);

    JFreeChart chart = ChartFactory.createXYLineChart(plotTitle, "Similarity%", "Percent Comparisions", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    ((XYPlot) chart.getPlot()).getRenderer().setStroke(new BasicStroke(2.0f));
    chart.getLegend().setItemFont(new Font("Helvetica", Font.BOLD, 24));
    chart.getTitle().setFont(lableFont);
    ((XYPlot) chart.getPlot()).getDomainAxis().setLabelFont(lableFont);
    ((XYPlot) chart.getPlot()).getDomainAxis().setTickLabelFont(lableFont);
    ValueAxis rangeAxis = ((XYPlot) chart.getPlot()).getRangeAxis();
    rangeAxis.setRange(0, 100);
    rangeAxis.setTickLabelFont(lableFont);
    rangeAxis.setLabelFont(lableFont);
    ((NumberAxis) rangeAxis).setTickUnit(new NumberTickUnit(5));
    ChartUtilities.writeScaledChartAsPNG(new PrintStream(new File(outdir, plotTitle + ".linechart.png")), chart,
            800, 1000, 3, 3);

    BoxPlotUtils.createBoxplot(scatterDataset, new PrintStream(new File(outdir, plotTitle + ".boxchart.png")),
            plotTitle, "Rank", "Similarity%", lableFont);

}

From source file:ecg.ecgshow.ECGShowUI.java

private void createECGData(long timeZone) {
    ECGData = new JPanel(new GridLayout(LEAD_COUNT, 1));
    dateAxises = new DateAxis[LEAD_COUNT];
    ECGSeries = new TimeSeries[LEAD_COUNT * 2];
    for (int i = 0; i < LEAD_COUNT; i++) {
        TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(); //XYDataset  TimeSeriesCollection
        ECGSeries[i] = new TimeSeries("?" + (i + 1));
        ECGSeries[i].setMaximumItemCount(500);
        ECGSeries[i + LEAD_COUNT] = new TimeSeries("");
        ECGSeries[i + LEAD_COUNT].setMaximumItemAge(timeZone);
        ECGSeries[i + LEAD_COUNT].setMaximumItemCount(2);

        timeseriescollection.addSeries(ECGSeries[i]);
        timeseriescollection.addSeries(ECGSeries[i + LEAD_COUNT]);

        //DateAxis dateaxis = new DateAxis("Time");
        dateAxises[i] = new DateAxis("");
        dateAxises[i].setTickLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.016)));
        dateAxises[i].setLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.018)));
        dateAxises[i].setTickLabelsVisible(true);
        dateAxises[i].setVisible(false);

        //NumberAxis numberaxis = new NumberAxis("ecg");
        NumberAxis numberaxis = new NumberAxis("ecg");
        numberaxis.setTickLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.016)));
        numberaxis.setLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.018)));
        numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
        numberaxis.setVisible(false);//ww  w.ja  va2  s  .  c  om
        numberaxis.setLowerBound(1500D);
        numberaxis.setUpperBound(3000D);

        XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(true, false);
        xylineandshaperenderer.setSeriesPaint(0, Color.GREEN); //
        xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(2));
        xylineandshaperenderer.setSeriesPaint(1, Color.LIGHT_GRAY); //
        xylineandshaperenderer.setSeriesStroke(1, new BasicStroke(5));

        XYPlot xyplot = new XYPlot(timeseriescollection, dateAxises[i], numberaxis, xylineandshaperenderer);
        xyplot.setBackgroundPaint(Color.LIGHT_GRAY);
        xyplot.setDomainGridlinePaint(Color.LIGHT_GRAY);
        xyplot.setRangeGridlinePaint(Color.LIGHT_GRAY);
        xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
        xyplot.setBackgroundPaint(Color.BLACK);

        JFreeChart jfreechart = new JFreeChart(xyplot);
        jfreechart.setBackgroundPaint(new Color(237, 237, 237));//?
        jfreechart.getLegend().setVisible(false);

        ChartPanel chartpanel = new ChartPanel(jfreechart, (int) (WIDTH * 46 / 100), (int) (HEIGHT * 17 / 100),
                0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE, true, true, false, true, false, false);

        chartpanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0) //??0
                , BorderFactory.createEmptyBorder() //????
        ));
        chartpanel.setMouseZoomable(false); //?
        ECGData.add(chartpanel);
    }
}

From source file:ecg.ecgshow.ECGShowUI.java

private void createPressureData(long timeZone) {
    PressureData = new JPanel();
    PressuredateAxises = new DateAxis[1];
    SystolicPressureSeries = new TimeSeries[2];
    DiastolicPressureSeries = new TimeSeries[2];

    TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
    SystolicPressureSeries[0] = new TimeSeries("");
    SystolicPressureSeries[0].setMaximumItemAge(timeZone);
    SystolicPressureSeries[0].setMaximumItemCount(500);
    SystolicPressureSeries[1] = new TimeSeries("");
    SystolicPressureSeries[1].setMaximumItemAge(timeZone);
    SystolicPressureSeries[1].setMaximumItemCount(2);
    timeseriescollection.addSeries(SystolicPressureSeries[0]);
    timeseriescollection.addSeries(SystolicPressureSeries[1]);

    PressuredateAxises[0] = new DateAxis("");
    PressuredateAxises[0].setTickLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.016)));
    PressuredateAxises[0].setLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.018)));
    PressuredateAxises[0].setTickLabelsVisible(true);
    PressuredateAxises[0].setVisible(false);

    DiastolicPressureSeries[0] = new TimeSeries("");
    DiastolicPressureSeries[0].setMaximumItemAge(timeZone);
    DiastolicPressureSeries[0].setMaximumItemCount(500);
    DiastolicPressureSeries[1] = new TimeSeries("");
    DiastolicPressureSeries[1].setMaximumItemAge(timeZone);
    DiastolicPressureSeries[1].setMaximumItemCount(2);
    timeseriescollection.addSeries(DiastolicPressureSeries[0]);
    timeseriescollection.addSeries(DiastolicPressureSeries[1]);

    NumberAxis numberaxis = new NumberAxis("Pressure");
    numberaxis.setTickLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.016)));
    numberaxis.setLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.018)));
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    numberaxis.setVisible(false);/*from  w w w.  jav a 2s.c  o m*/
    numberaxis.setLowerBound(0D);
    numberaxis.setUpperBound(200D);

    XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(true, false);
    xylineandshaperenderer.setSeriesPaint(0, Color.GREEN); //
    xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(2)); //
    xylineandshaperenderer.setSeriesPaint(1, Color.LIGHT_GRAY); //
    xylineandshaperenderer.setSeriesStroke(1, new BasicStroke(5));

    xylineandshaperenderer.setSeriesPaint(2, Color.ORANGE); //
    xylineandshaperenderer.setSeriesStroke(2, new BasicStroke(2)); //
    xylineandshaperenderer.setSeriesPaint(3, Color.LIGHT_GRAY); //
    xylineandshaperenderer.setSeriesStroke(3, new BasicStroke(5));

    //XYPlot xyplot = new XYPlot(timeseriescollection, PressuredateAxises[0], numberaxis, xylineandshaperenderer);
    XYPlot xyplot = new XYPlot(timeseriescollection, dateAxises[0], numberaxis, xylineandshaperenderer);

    xyplot.setBackgroundPaint(Color.LIGHT_GRAY);
    xyplot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    xyplot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    xyplot.setBackgroundPaint(Color.BLACK);

    JFreeChart jfreechart = new JFreeChart(xyplot);
    jfreechart.setBackgroundPaint(new Color(237, 237, 237));//?
    jfreechart.getLegend().setVisible(false);

    ChartPanel chartpanel = new ChartPanel(jfreechart, (int) (WIDTH * 0.155), (int) (HEIGHT * 0.18), 0, 0,
            Integer.MAX_VALUE, Integer.MAX_VALUE, true, true, false, true, false, false);

    chartpanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0) //??0
            , BorderFactory.createEmptyBorder() //????
    ));
    chartpanel.setMouseZoomable(false);
    PressureData.add(chartpanel);

}

From source file:com.okmich.hackerday.client.tool.dashboard.ReportItemPanel.java

/**
 *
 * @return A panel.//  w w w. jav  a2 s.c  om
 */
public JPanel createChartPanel() {
    JFreeChart chart = ChartFactory.createPieChart(title, // chart title
            getChartDataset(), // data
            true, // include legend
            true, false);

    TextTitle textTitle = new TextTitle(title, new Font("SansSerif", Font.BOLD, 16));
    chart.setTitle(textTitle);
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    plot.setNoDataMessage("No data available");
    plot.setCircular(false);
    plot.setLabelGap(0.02);

    LegendTitle legend = chart.getLegend();
    legend.setPosition(RectangleEdge.BOTTOM);
    this.chartPanel = new ChartPanel(chart);
    this.chartPanel.addMouseListener(new MouseListenerImpl(this));

    return this.chartPanel;
}