Example usage for org.jfree.data.xy XYSeries XYSeries

List of usage examples for org.jfree.data.xy XYSeries XYSeries

Introduction

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

Prototype

public XYSeries(Comparable key) 

Source Link

Document

Creates a new empty series.

Usage

From source file:PointingMap.java

public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, java.io.IOException {

    Connection conn = null;//  www . ja v a 2 s.c  om
    Statement stmt = null;
    ResultSet rs = null;
    ResultSetMetaData rsm = null;

    OutputStream out = response.getOutputStream();
    try {

        String dbHost = request.getParameter("dbHost");
        String dbName = request.getParameter("dbName");

        conn = connect(dbHost, dbName);

        // get & plot target catalog
        String targetCatQuery = "select " + "ra2000Hours, dec2000Deg " + "from TargetCat limit 200";

        stmt = conn.createStatement();
        rs = stmt.executeQuery(targetCatQuery);
        rsm = rs.getMetaData();
        //int colCount = rsm.getColumnCount();

        XYSeries series = new XYSeries("Target Catalog");
        int raColIndex = 1;
        int decColIndex = 2;
        while (rs.next()) {
            series.add(rs.getDouble(raColIndex), rs.getDouble(decColIndex));
        }

        XYDataset data = new XYSeriesCollection(series);
        stmt.close();

        // Get latest primary beam pointing position
        String latestPointingQuery = "select " + "actId, ts, " + "raHours, decDeg " + "from TscopePointReq "
                + "where atabeam = 'primary' " + "order by actId desc limit 1";

        stmt = conn.createStatement();
        rs = stmt.executeQuery(latestPointingQuery);
        rsm = rs.getMetaData();
        //int colCount = rsm.getColumnCount();

        int actId = -1;
        String timeString = "";
        double pointingRaHours = -1;
        double pointingDecDeg = -1;

        int actIdIndex = 1;
        int timeIndex = 2;
        raColIndex = 3;
        decColIndex = 4;

        while (rs.next()) {
            actId = rs.getInt(actIdIndex);
            timeString = rs.getString(timeIndex);
            pointingRaHours = rs.getDouble(raColIndex);
            pointingDecDeg = rs.getDouble(decColIndex);
        }

        String plotTitle = "ATA Primary Pointing" + " (Act Id: " + actId + ")" + " " + timeString;

        JFreeChart chart = ChartFactory.createScatterPlot(plotTitle, "RA (Hours)", // x-axis label
                "Dec (Deg)", // y axis label
                data, PlotOrientation.VERTICAL, false, // legend 
                true, // tooltips
                false // urls
        );

        // plot RA hours with higher values to the left
        //chart.getXYPlot().getDomainAxis().setInverted(true);
        chart.getXYPlot().getDomainAxis().setLowerBound(-1);
        chart.getXYPlot().getDomainAxis().setUpperBound(25);

        // increase axis label fonts for better readability
        Font axisFont = new Font("Serif", Font.BOLD, 14);
        chart.getXYPlot().getDomainAxis().setLabelFont(axisFont);
        chart.getXYPlot().getDomainAxis().setTickLabelFont(axisFont);
        chart.getXYPlot().getRangeAxis().setLabelFont(axisFont);
        chart.getXYPlot().getRangeAxis().setTickLabelFont(axisFont);

        // show current pointing as crosshairs
        chart.getXYPlot().setDomainCrosshairValue(pointingRaHours);
        chart.getXYPlot().setRangeCrosshairValue(pointingDecDeg);
        chart.getXYPlot().setDomainCrosshairVisible(true);
        chart.getXYPlot().setRangeCrosshairVisible(true);
        chart.getXYPlot().setDomainCrosshairPaint(Color.BLACK);
        chart.getXYPlot().setRangeCrosshairPaint(Color.BLACK);

        Stroke stroke = new BasicStroke(2);
        chart.getXYPlot().setDomainCrosshairStroke(stroke);
        chart.getXYPlot().setRangeCrosshairStroke(stroke);

        // set hat creek dec range
        chart.getXYPlot().getRangeAxis().setLowerBound(-40);
        chart.getXYPlot().getRangeAxis().setUpperBound(90);

        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) chart.getXYPlot().getRenderer();
        int seriesIndex = 0;
        renderer.setSeriesPaint(seriesIndex, Color.BLUE);

        Shape circularShape = new Ellipse2D.Double(-1.0, -1.0, 1.2, 1.2);
        renderer.setSeriesShape(seriesIndex, circularShape);

        // Default shape [0-9]: 0=square 1=circle 2=uptriangle 3=diamond...
        //renderer.setShape(DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[1]);
        response.setContentType("image/png");
        int width = 800;
        int height = 600;
        ChartUtilities.writeChartAsPNG(out, chart, width, height);

    } catch (Exception e) {
        throw new ServletException(e);
    } finally {

        try {
            if (stmt != null) {
                stmt.close();
            }

            if (conn != null) {
                conn.close();
            }

        } catch (SQLException sql) {
        }

    }

}

From source file:org.optaplanner.benchmark.impl.statistic.calculatecount.CalculateCountProblemStatistic.java

@Override
public void writeGraphFiles(BenchmarkReport benchmarkReport) {
    Locale locale = benchmarkReport.getLocale();
    NumberAxis xAxis = new NumberAxis("Time spent");
    xAxis.setNumberFormatOverride(new MillisecondsSpentNumberFormat(locale));
    NumberAxis yAxis = new NumberAxis("Calculate count per second");
    yAxis.setNumberFormatOverride(NumberFormat.getInstance(locale));
    yAxis.setAutoRangeIncludesZero(false);
    XYPlot plot = new XYPlot(null, xAxis, yAxis, null);
    plot.setOrientation(PlotOrientation.VERTICAL);
    int seriesIndex = 0;
    for (SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult.getSingleBenchmarkResultList()) {
        XYSeries series = new XYSeries(
                singleBenchmarkResult.getSolverBenchmarkResult().getNameWithFavoriteSuffix());
        XYItemRenderer renderer = new XYLineAndShapeRenderer();
        if (singleBenchmarkResult.isSuccess()) {
            CalculateCountSingleStatistic singleStatistic = (CalculateCountSingleStatistic) singleBenchmarkResult
                    .getSingleStatistic(problemStatisticType);
            for (CalculateCountStatisticPoint point : singleStatistic.getPointList()) {
                long timeMillisSpent = point.getTimeMillisSpent();
                long calculateCountPerSecond = point.getCalculateCountPerSecond();
                series.add(timeMillisSpent, calculateCountPerSecond);
            }// ww w  .  j av  a  2  s  .c  o  m
        }
        plot.setDataset(seriesIndex, new XYSeriesCollection(series));

        if (singleBenchmarkResult.getSolverBenchmarkResult().isFavorite()) {
            // Make the favorite more obvious
            renderer.setSeriesStroke(0, new BasicStroke(2.0f));
        }
        plot.setRenderer(seriesIndex, renderer);
        seriesIndex++;
    }
    JFreeChart chart = new JFreeChart(problemBenchmarkResult.getName() + " calculate count statistic",
            JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    graphFile = writeChartToImageFile(chart, problemBenchmarkResult.getName() + "CalculateCountStatistic");
}

From source file:org.jfree.chart.demo.XYLineAndShapeRendererDemo.java

/**
 * Creates a sample dataset./*  w w  w .  ja v  a 2 s  .  co m*/
 * 
 * @return A dataset.
 */
private XYDataset createSampleDataset() {
    XYSeries series1 = new XYSeries("Series 1");
    series1.add(1.0, 3.3);
    series1.add(2.0, 4.4);
    series1.add(3.0, 1.7);
    XYSeries series2 = new XYSeries("Series 2");
    series2.add(1.0, 7.3);
    series2.add(2.0, 6.8);
    series2.add(3.0, 9.6);
    series2.add(4.0, 5.6);
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(series1);
    dataset.addSeries(series2);
    return dataset;
}

From source file:wm.edu.cs420.Data.ChartBuilder.java

/**
 * Creates a sample dataset./*from   ww w .j a  v a  2s .c o m*/
 * 
 * @return a sample dataset.
 */
public XYDataset createTestDataset() {

    final XYSeries series1 = new XYSeries("");
    series1.add(1.0, 1.0);
    series1.add(2.0, 4.0);
    series1.add(3.0, 3.0);
    series1.add(4.0, 5.0);
    series1.add(5.0, 5.0);
    series1.add(6.0, 7.0);
    series1.add(7.0, 7.0);
    series1.add(8.0, 8.0);

    final XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(series1);

    return dataset;

}

From source file:org.owasp.benchmark.score.report.ScatterHome.java

private JFreeChart display(String title, int height, Set<Report> toolResults) {
    JFrame f = new JFrame(title);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //averages// www .  jav a 2s .  c om
    ArrayList<Double> averageCommercialFalseRates = new ArrayList<Double>();
    ArrayList<Double> averageCommercialTrueRates = new ArrayList<Double>();

    XYSeriesCollection dataset = new XYSeriesCollection();
    XYSeries series = new XYSeries("Scores");
    for (Report toolReport : toolResults) {
        if (!toolReport.isCommercial()) {
            OverallResults overallResults = toolReport.getOverallResults();
            series.add(overallResults.getFalsePositiveRate() * 100, overallResults.getTruePositiveRate() * 100);
            if (toolReport.isCommercial()) {
                averageCommercialFalseRates.add(overallResults.getFalsePositiveRate());
                averageCommercialTrueRates.add(overallResults.getTruePositiveRate());
            }
        }
    }

    int commercialToolCount = 0;
    for (Report toolReport : toolResults) {
        if (toolReport.isCommercial()) {
            commercialToolCount++;
            OverallResults overallResults = toolReport.getOverallResults();
            if (!BenchmarkScore.showAveOnlyMode) {
                series.add(overallResults.getFalsePositiveRate() * 100,
                        overallResults.getTruePositiveRate() * 100);
            }
            if (toolReport.isCommercial()) {
                averageCommercialFalseRates.add(overallResults.getFalsePositiveRate());
                averageCommercialTrueRates.add(overallResults.getTruePositiveRate());
            }
        }
    }

    for (double d : averageCommercialFalseRates) {
        afr += d;
    }
    afr = afr / averageCommercialFalseRates.size();

    for (double d : averageCommercialTrueRates) {
        atr += d;
    }
    atr = atr / averageCommercialTrueRates.size();

    if (commercialToolCount > 1 || (BenchmarkScore.showAveOnlyMode && commercialToolCount == 1)) {
        series.add(afr * 100, atr * 100);
    }

    dataset.addSeries(series);

    chart = ChartFactory.createScatterPlot(title, "False Positive Rate", "True Positive Rate", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    theme.apply(chart);

    XYPlot xyplot = chart.getXYPlot();
    initializePlot(xyplot);

    makeDataLabels(toolResults, xyplot);
    makeLegend(toolResults, 103, 100.5, dataset, xyplot);

    for (XYDataItem item : (List<XYDataItem>) series.getItems()) {
        double x = item.getX().doubleValue();
        double y = item.getY().doubleValue();
        double z = (x + y) / 2;
        XYLineAnnotation score = new XYLineAnnotation(x, y, z, z, dashed, Color.blue);
        xyplot.addAnnotation(score);
    }

    ChartPanel cp = new ChartPanel(chart, height, height, 400, 400, 1200, 1200, false, false, false, false,
            false, false);
    f.add(cp);
    f.pack();
    f.setLocationRelativeTo(null);
    //      f.setVisible(true);
    return chart;
}

From source file:org.usfirst.frc.team2084.neuralnetwork.HeadingNeuralNetworkTrainer.java

public HeadingNeuralNetworkTrainer() {
    outputGraphNetworkSeries = new XYSeries("Network Prediction");
    outputGraphDataSeries = new XYSeries("Error");
    final XYSeriesCollection data = new XYSeriesCollection();
    data.addSeries(outputGraphDataSeries);
    data.addSeries(outputGraphNetworkSeries);
    outputGraph = ChartFactory.createXYLineChart("Error vs. Output", "Time", "Error", data,
            PlotOrientation.VERTICAL, true, true, false);

    NumberAxis xAxis = new NumberAxis();
    xAxis.setRange(new Range(-Math.PI, Math.PI));
    xAxis.setAutoRange(false);/*from w  w  w .j a  va  2s .  c  o m*/
    NumberAxis yAxis = new NumberAxis();
    yAxis.setRange(new Range(-1, 1));

    XYPlot plot = (XYPlot) outputGraph.getPlot();
    plot.setDomainAxis(xAxis);
    plot.setRangeAxis(yAxis);

    network = new Network(new int[] { 1, 5, 1 }, eta, momentum, new TransferFunction.HyperbolicTangent());

    try {
        SwingUtilities.invokeAndWait(() -> {
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            final Container content = frame.getContentPane();
            content.setLayout(new BorderLayout());

            outputGraphPanel = new ChartPanel(outputGraph);
            outputGraphPanel.setDomainZoomable(false);
            outputGraphPanel.setRangeZoomable(false);
            graphPanel.add(outputGraphPanel);

            graphPanel.setLayout(new GridLayout(1, 1));
            content.add(graphPanel, BorderLayout.CENTER);
            {

                JLabel etaLabel = new JLabel("Eta:");
                etaLabel.setLabelFor(etaField);
                etaField.setText(Double.toString(network.getEta()));
                etaField.setColumns(5);
                etaField.addPropertyChangeListener("value",
                        (evt) -> eta = ((Number) evt.getNewValue()).doubleValue());
                controlPanel.add(etaLabel);
                controlPanel.add(etaField);

                JLabel momentumLabel = new JLabel("Momentum:");
                momentumLabel.setLabelFor(etaField);
                momentumField.setText(Double.toString(network.getMomentum()));
                momentumField.setColumns(5);
                momentumField.addPropertyChangeListener("value",
                        (evt) -> momentum = ((Number) evt.getNewValue()).doubleValue());
                controlPanel.add(momentumLabel);
                controlPanel.add(momentumField);

                JLabel iterationsLabel = new JLabel("Iterations:");
                iterationsLabel.setLabelFor(iterationsField);
                iterationsField.setText(Integer.toString(iterations));
                iterationsField.setColumns(10);
                iterationsField.addPropertyChangeListener("value",
                        (evt) -> iterations = ((Number) evt.getNewValue()).intValue());
                controlPanel.add(iterationsLabel);
                controlPanel.add(iterationsField);
            }

            chooseDataButton.addActionListener((e) -> {
                if (dataDirectoryChooser.showOpenDialog(frame) == JFileChooser.APPROVE_OPTION) {
                    dataDirectory = dataDirectoryChooser.getSelectedFile();
                    displayData();
                }
            });
            controlPanel.add(chooseDataButton);

            trainButton.addActionListener((e) -> trainNetwork());
            controlPanel.add(trainButton);

            saveButton.addActionListener((e) -> {
                saveNetwork();
            });
            controlPanel.add(saveButton);

            content.add(controlPanel, BorderLayout.SOUTH);

            dataDirectoryChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.pack();
            frame.setVisible(true);
        });
    } catch (InvocationTargetException | InterruptedException e) {
        e.printStackTrace();
    }
}

From source file:org.matsim.counts.algorithms.graphs.CountsSimReal24Graph.java

@Override
public JFreeChart createChart(final int nbr) {

    XYSeriesCollection dataset0 = new XYSeriesCollection();
    XYSeries series = new XYSeries("MATSim volumes");
    // easier to use another dataset
    XYSeriesCollection dataset_outliers = new XYSeriesCollection();
    XYSeries series_outliers = new XYSeries("MATSim outliers");

    CustomXYURLGenerator url_gen = new CustomXYURLGenerator();
    CustomXYToolTipGenerator tt_gen = new CustomXYToolTipGenerator();

    final ArrayList<String> urls = new ArrayList<>();
    final ArrayList<String> tooltips = new ArrayList<>();
    List<Comp> comps = new Vector<>();

    //--------------------
    CountSimComparisonLinkFilter linkFilter = new CountSimComparisonLinkFilter(this.ccl_);

    final Vector<Id<Link>> linkIds = new CountSimComparisonLinkFilter(this.ccl_).getLinkIds();
    Iterator<Id<Link>> id_it = linkIds.iterator();

    double maxCountValue = 0.1;
    double maxSimValue = 0.1;
    // yyyy PtCountsKMLWriterTest.testPtAlightKMLCreation never touches these and then leads to an exception later
    // when they are zero.  Don't know why. kai, sep'16

    while (id_it.hasNext()) {
        Id<Link> id = id_it.next();

        double countVal = linkFilter.getAggregatedCountValue(id);
        double simVal = linkFilter.getAggregatedSimValue(id);

        if (countVal > 100.0 && simVal > 100.0) {

            if (countVal > maxCountValue)
                maxCountValue = countVal;
            if (simVal > maxSimValue)
                maxSimValue = simVal;/*from   w  w w  .j  a  v  a 2 s  . c o m*/

            series.add(countVal, simVal);
            comps.add(new Comp(countVal, "link" + id + ".html",
                    "Link " + id + "; " + "Count: " + countVal + ", Sim: " + simVal));
        } else {
            /* values with simVal<100.0 or countVal<100.0 are drawn on the x==100 or/and y==100-line
             */
            countVal = Math.max(100.0, countVal);
            simVal = Math.max(100.0, simVal);
            series_outliers.add(countVal, simVal);

            if (countVal > maxCountValue)
                maxCountValue = countVal;
            if (simVal > maxSimValue)
                maxSimValue = simVal;
        }
    } //while
    dataset0.addSeries(series);
    dataset_outliers.addSeries(series_outliers);

    Collections.sort(comps, new MyComparator());

    for (Iterator<Comp> iter = comps.iterator(); iter.hasNext();) {
        Comp cp = iter.next();
        urls.add(cp.getURL());
        tooltips.add(cp.getTooltip());
    }

    url_gen.addURLSeries(urls);
    tt_gen.addToolTipSeries(tooltips);

    String title = "Avg. Weekday Traffic Volumes, Iteration: " + this.iteration_;
    this.setChartTitle(title);
    this.chart_ = ChartFactory.createXYLineChart(title, "Count Volumes", // x axis label
            "Sim Volumes", // y axis label
            dataset0, // data
            PlotOrientation.VERTICAL, false, // include legend
            true, // tooltips
            true // urls
    );
    XYPlot plot = this.chart_.getXYPlot();
    final LogarithmicAxis axis_x = new LogarithmicAxis("Count Volumes [veh/24h]");
    final LogarithmicAxis axis_y = new LogarithmicAxis("Sim Volumes [veh/24h]");
    axis_x.setAllowNegativesFlag(false);
    axis_y.setAllowNegativesFlag(false);

    //regular values
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setLinesVisible(false);
    renderer.setURLGenerator(url_gen);
    renderer.setSeriesPaint(0, Color.black);
    renderer.setSeriesToolTipGenerator(0, tt_gen);
    renderer.setSeriesShape(0, new Rectangle2D.Double(-1.5, -1.5, 3.0, 3.0));

    //outliers
    XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
    renderer2.setLinesVisible(false);
    renderer2.setSeriesPaint(0, Color.red);
    renderer2.setSeriesShape(0, new Ellipse2D.Double(-3.0, -3.0, 6.0, 6.0));

    // error band
    DefaultXYDataset dataset1 = new DefaultXYDataset();
    Gbl.assertIf(maxCountValue > 0.);
    dataset1.addSeries("f1x", new double[][] { { 100.0, maxCountValue }, { 100.0, maxCountValue } });
    dataset1.addSeries("f2x", new double[][] { { 100.0, maxCountValue }, { 200.0, 2 * maxCountValue } });
    dataset1.addSeries("f05x", new double[][] { { 200.0, maxCountValue }, { 100.0, 0.5 * maxCountValue } });

    XYLineAndShapeRenderer renderer3 = new XYLineAndShapeRenderer();
    renderer3.setShapesVisible(false);
    renderer3.setSeriesPaint(0, Color.blue);
    renderer3.setSeriesPaint(1, Color.blue);
    renderer3.setSeriesPaint(2, Color.blue);
    renderer3.setBaseSeriesVisibleInLegend(false);
    renderer3.setSeriesItemLabelsVisible(0, true);
    renderer3.setSeriesItemLabelsVisible(1, false);
    renderer3.setSeriesItemLabelsVisible(2, false);

    XYTextAnnotation annotation0 = new XYTextAnnotation("2.0 count", maxCountValue, 2 * maxCountValue);
    annotation0.setFont(new Font("SansSerif", Font.BOLD, 11));
    plot.addAnnotation(annotation0);
    XYTextAnnotation annotation1 = new XYTextAnnotation("count", maxCountValue, maxCountValue);
    annotation1.setFont(new Font("SansSerif", Font.BOLD, 11));
    plot.addAnnotation(annotation1);
    XYTextAnnotation annotation2 = new XYTextAnnotation("0.5 count", maxCountValue, 0.5 * maxCountValue);
    annotation2.setFont(new Font("SansSerif", Font.BOLD, 11));
    plot.addAnnotation(annotation2);

    plot.setDomainAxis(axis_x);
    plot.setRangeAxis(axis_y);
    plot.setRenderer(0, renderer);

    plot.setRenderer(1, renderer2);
    plot.setDataset(1, dataset_outliers);

    plot.setRenderer(2, renderer3);
    plot.setDataset(2, dataset1);

    //plot.getRangeAxis().setRange(1.0, 19000.0);
    //plot.getDomainAxis().setRange(1.0, 19000.0);

    return this.chart_;
}

From source file:org.optaplanner.benchmark.impl.statistic.bestsolutionmutation.BestSolutionMutationProblemStatistic.java

@Override
public void writeGraphFiles(BenchmarkReport benchmarkReport) {
    Locale locale = benchmarkReport.getLocale();
    NumberAxis xAxis = new NumberAxis("Time spent");
    xAxis.setNumberFormatOverride(new MillisecondsSpentNumberFormat(locale));
    NumberAxis yAxis = new NumberAxis("Best solution mutation count");
    yAxis.setNumberFormatOverride(NumberFormat.getInstance(locale));
    yAxis.setAutoRangeIncludesZero(true);
    XYPlot plot = new XYPlot(null, xAxis, yAxis, null);
    plot.setOrientation(PlotOrientation.VERTICAL);
    int seriesIndex = 0;
    for (SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult.getSingleBenchmarkResultList()) {
        XYSeries series = new XYSeries(
                singleBenchmarkResult.getSolverBenchmarkResult().getNameWithFavoriteSuffix());
        XYItemRenderer renderer = new XYLineAndShapeRenderer();
        if (singleBenchmarkResult.isSuccess()) {
            BestSolutionMutationSingleStatistic singleStatistic = (BestSolutionMutationSingleStatistic) singleBenchmarkResult
                    .getSingleStatistic(problemStatisticType);
            for (BestSolutionMutationStatisticPoint point : singleStatistic.getPointList()) {
                long timeMillisSpent = point.getTimeMillisSpent();
                long mutationCount = point.getMutationCount();
                series.add(timeMillisSpent, mutationCount);
            }/* ww  w .  ja va 2  s  .co  m*/
        }
        plot.setDataset(seriesIndex, new XYSeriesCollection(series));

        if (singleBenchmarkResult.getSolverBenchmarkResult().isFavorite()) {
            // Make the favorite more obvious
            renderer.setSeriesStroke(0, new BasicStroke(2.0f));
        }
        plot.setRenderer(seriesIndex, renderer);
        seriesIndex++;
    }
    JFreeChart chart = new JFreeChart(problemBenchmarkResult.getName() + " best solution mutation statistic",
            JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    graphFile = writeChartToImageFile(chart,
            problemBenchmarkResult.getName() + "BestSolutionMutationStatistic");
}

From source file:com.choicemaker.cm.modelmaker.gui.panels.HoldVsAccuracyPlotPanel.java

private void buildPanel() {
    XYSeriesCollection dataset = new XYSeriesCollection();
    String title = ChoiceMakerCoreMessages.m.formatMessage("train.gui.modelmaker.panel.holdvsacc.title");
    data = new XYSeries(title);
    dataset.addSeries(data);//from  w w  w  .  j av  a 2 s .co m
    final PlotOrientation orientation = PlotOrientation.VERTICAL;
    chart = ChartFactory.createXYLineChart(title,
            ChoiceMakerCoreMessages.m.formatMessage("train.gui.modelmaker.panel.holdvsacc.cm.accuracy"),
            ChoiceMakerCoreMessages.m.formatMessage("train.gui.modelmaker.panel.holdvsacc.holdpercentage"),
            dataset, orientation, true, true, true);
    MouseListener tableMouseListener = new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            Point origin = e.getPoint();
            JTable src = (JTable) e.getSource();
            int row = src.rowAtPoint(origin);
            int col = src.columnAtPoint(origin);
            ModelMaker mm = parent.getModelMaker();
            if (src == accuracyTable) {
                if (col < 2) {
                    if (!Float.isNaN(accuracyData[row][2]) && !Float.isNaN(accuracyData[row][3]))
                        mm.setThresholds(new Thresholds(accuracyData[row][2], accuracyData[row][3]));
                } else if (col == 2) {
                    if (!Float.isNaN(accuracyData[row][2]))
                        mm.setDifferThreshold(accuracyData[row][2]);
                } else {
                    if (!Float.isNaN(accuracyData[row][3]))
                        mm.setMatchThreshold(accuracyData[row][3]);
                }
            } else {
                if (col < 2) {
                    if (!Float.isNaN(hrData[row][2]) && !Float.isNaN(hrData[row][3]))
                        mm.setThresholds(new Thresholds(hrData[row][2], hrData[row][3]));
                } else if (col == 2) {
                    if (!Float.isNaN(hrData[row][2]))
                        mm.setDifferThreshold(hrData[row][2]);
                } else {
                    if (!Float.isNaN(hrData[row][3]))
                        mm.setMatchThreshold(hrData[row][3]);
                }
            }
        }
    };
    chart.setBackgroundPaint(getBackground());
    accuracyTable = new AccuracyTable(true, accuracies);
    accuracyTable.addMouseListener(tableMouseListener);
    accuracyPanel = getPanel(accuracyTable,
            ChoiceMakerCoreMessages.m.formatMessage("train.gui.modelmaker.panel.holdvsacc.table.hrvsacc"));

    hrTable = new AccuracyTable(false, hrs);
    hrTable.addMouseListener(tableMouseListener);
    hrPanel = getPanel(hrTable,
            ChoiceMakerCoreMessages.m.formatMessage("train.gui.modelmaker.panel.holdvsacc.table.accvshr"));

    accuracyTable.setEnabled(false);
    hrTable.setEnabled(false);
}

From source file:org.matsim.counts.algorithms.graphs.CountsSimRealPerHourGraph.java

/**
 * @param hour A value in 1..24, 1 for 0 a.m. to 1 a.m., 2 for 1 a.m. to 2 a.m. ...
 *///from w w w .  jav a2  s. c  o  m
@Override
public JFreeChart createChart(final int hour) {
    this.hour = hour;

    XYSeriesCollection dataset0 = new XYSeriesCollection();
    XYSeries series = new XYSeries("MATSim volumes");
    // easier to use another dataset
    XYSeriesCollection dataset_outliers = new XYSeriesCollection();
    XYSeries series_outliers = new XYSeries("MATSim outliers");

    CustomXYURLGenerator url_gen = new CustomXYURLGenerator();
    CustomXYToolTipGenerator tt_gen = new CustomXYToolTipGenerator();

    final ArrayList<String> urls = new ArrayList<String>();
    final ArrayList<String> tooltips = new ArrayList<String>();
    List<Comp> comps = new Vector<Comp>();

    Iterator<CountSimComparison> l_it = this.ccl_.iterator();
    //int elementCounter=0;
    while (l_it.hasNext()) {
        CountSimComparison cc = l_it.next();

        /* values with simVal==0.0 or countVal==0.0 are drawn on the x==1 or/and y==1-line
         * Such values are the result of a poor simulation run, but they can also represent 
         * a valid result (closing summer road during winter time)
         * 
         */
        if (cc.getHour() == hour) {
            //elementCounter++;
            double realVal = 1.0;
            double simVal = 1.0;
            if (cc.getCountValue() > 0.0 && cc.getSimulationValue() > 0.0) {
                realVal = cc.getCountValue();
                simVal = cc.getSimulationValue();
                series.add(realVal, simVal);
                comps.add(new Comp(realVal, "link" + cc.getId() + ".html",
                        "Link " + cc.getId() + "; " + "Count: " + realVal + ", Sim: " + simVal));
            } else {
                realVal = Math.max(1.0, cc.getCountValue());
                simVal = Math.max(1.0, cc.getSimulationValue());
                series_outliers.add(realVal, simVal);
            }

        } //if
    } //while
    dataset0.addSeries(series);
    dataset_outliers.addSeries(series_outliers);

    /* first we have to sort the vector according to the rendering ordering
    * (which is the x value).
    * REALLY??? After hours of searching no better solution found!
    * please help!
    */

    Collections.sort(comps, new MyComparator());

    for (Iterator<Comp> iter = comps.iterator(); iter.hasNext();) {
        Comp cp = iter.next();
        urls.add(cp.getURL());
        tooltips.add(cp.getTooltip());
    }

    url_gen.addURLSeries(urls);
    tt_gen.addToolTipSeries(tooltips);

    String title = "Volumes " + (hour - 1) + ":00 - " + (hour) + ":00, Iteration: " + this.iteration_;
    this.setChartTitle(title);
    this.chart_ = ChartFactory.createXYLineChart(title, "Count Volumes [veh/h]", // x axis label
            "Sim Volumes [veh/h]", // y axis label
            dataset0, // data
            PlotOrientation.VERTICAL, false, // include legend
            true, // tooltips
            true // urls
    );
    XYPlot plot = this.chart_.getXYPlot();
    final LogarithmicAxis axis_x = new LogarithmicAxis("Count Volumes [veh/h]");
    final LogarithmicAxis axis_y = new LogarithmicAxis("Sim Volumes [veh/h]");
    axis_x.setAllowNegativesFlag(false);
    axis_y.setAllowNegativesFlag(false);

    //regular values
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setLinesVisible(false);
    renderer.setURLGenerator(url_gen);
    renderer.setSeriesPaint(0, Color.black);
    renderer.setSeriesToolTipGenerator(0, tt_gen);
    renderer.setSeriesShape(0, new Rectangle2D.Double(-1.5, -1.5, 3.0, 3.0));

    //outliers
    XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
    renderer2.setLinesVisible(false);
    renderer2.setSeriesPaint(0, Color.red);
    renderer2.setSeriesShape(0, new Ellipse2D.Double(-3.0, -3.0, 6.0, 6.0));

    // error band
    DefaultXYDataset dataset1 = new DefaultXYDataset();
    dataset1.addSeries("f1x", new double[][] { { 1.0, 10000.0 }, { 1.0, 10000.0 } });
    dataset1.addSeries("f2x", new double[][] { { 1.0, 10000.0 }, { 2.0, 20000.0 } });
    dataset1.addSeries("f05x", new double[][] { { 2.0, 10000.0 }, { 1.0, 5000.0 } });

    XYLineAndShapeRenderer renderer3 = new XYLineAndShapeRenderer();
    renderer3.setShapesVisible(false);
    renderer3.setSeriesPaint(0, Color.blue);
    renderer3.setSeriesPaint(1, Color.blue);
    renderer3.setSeriesPaint(2, Color.blue);
    renderer3.setBaseSeriesVisibleInLegend(false);
    renderer3.setSeriesItemLabelsVisible(0, true);
    renderer3.setSeriesItemLabelsVisible(1, false);
    renderer3.setSeriesItemLabelsVisible(2, false);

    XYTextAnnotation annotation0 = new XYTextAnnotation("2.0 count", 12000.0, 15500.0);
    annotation0.setFont(new Font("SansSerif", Font.BOLD, 11));
    plot.addAnnotation(annotation0);
    XYTextAnnotation annotation1 = new XYTextAnnotation("count", 13000.0, 10000.0);
    annotation1.setFont(new Font("SansSerif", Font.BOLD, 11));
    plot.addAnnotation(annotation1);
    XYTextAnnotation annotation2 = new XYTextAnnotation("0.5 count", 11000.0, 3500.0);
    annotation2.setFont(new Font("SansSerif", Font.BOLD, 11));
    plot.addAnnotation(annotation2);

    plot.setDomainAxis(axis_x);
    plot.setRangeAxis(axis_y);
    plot.setRenderer(0, renderer);

    plot.setRenderer(1, renderer2);
    plot.setDataset(1, dataset_outliers);

    plot.setRenderer(2, renderer3);
    plot.setDataset(2, dataset1);

    plot.getRangeAxis().setRange(1.0, 19000.0);
    plot.getDomainAxis().setRange(1.0, 19000.0);

    return this.chart_;
}