Example usage for org.jfree.chart.labels CustomXYToolTipGenerator CustomXYToolTipGenerator

List of usage examples for org.jfree.chart.labels CustomXYToolTipGenerator CustomXYToolTipGenerator

Introduction

In this page you can find the example usage for org.jfree.chart.labels CustomXYToolTipGenerator CustomXYToolTipGenerator.

Prototype

public CustomXYToolTipGenerator() 

Source Link

Document

Default constructor.

Usage

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

/**
 * Starting point for the demo./*from w ww.j  a  v a  2s  .c  o  m*/
 *
 * @param args  ignored.
 *
 * @throws ParseException if there is a problem parsing dates.
 */
public static void main(final String[] args) throws ParseException {

    //  Create a sample dataset
    final SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy");
    final XYSeries dataSeries = new XYSeries("Curve data");
    final ArrayList toolTips = new ArrayList();
    dataSeries.add(sdf.parse("01-Jul-2002").getTime(), 5.22);
    toolTips.add("1D - 5.22");
    dataSeries.add(sdf.parse("02-Jul-2002").getTime(), 5.18);
    toolTips.add("2D - 5.18");
    dataSeries.add(sdf.parse("03-Jul-2002").getTime(), 5.23);
    toolTips.add("3D - 5.23");
    dataSeries.add(sdf.parse("04-Jul-2002").getTime(), 5.15);
    toolTips.add("4D - 5.15");
    dataSeries.add(sdf.parse("05-Jul-2002").getTime(), 5.22);
    toolTips.add("5D - 5.22");
    dataSeries.add(sdf.parse("06-Jul-2002").getTime(), 5.25);
    toolTips.add("6D - 5.25");
    dataSeries.add(sdf.parse("07-Jul-2002").getTime(), 5.31);
    toolTips.add("7D - 5.31");
    dataSeries.add(sdf.parse("08-Jul-2002").getTime(), 5.36);
    toolTips.add("8D - 5.36");
    final XYSeriesCollection xyDataset = new XYSeriesCollection(dataSeries);
    final CustomXYToolTipGenerator ttg = new CustomXYToolTipGenerator();
    ttg.addToolTipSeries(toolTips);

    //  Create the chart
    final StandardXYURLGenerator urlg = new StandardXYURLGenerator("xy_details.jsp");
    final ValueAxis timeAxis = new DateAxis("");
    final NumberAxis valueAxis = new NumberAxis("");
    valueAxis.setAutoRangeIncludesZero(false); // override default
    final XYPlot plot = new XYPlot(xyDataset, timeAxis, valueAxis, null);
    final StandardXYItemRenderer sxyir = new StandardXYItemRenderer(
            StandardXYItemRenderer.LINES + StandardXYItemRenderer.SHAPES, ttg, urlg);
    sxyir.setShapesFilled(true);
    plot.setRenderer(sxyir);
    final JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, false);
    chart.setBackgroundPaint(java.awt.Color.white);

    // ****************************************************************************
    // * JFREECHART DEVELOPER GUIDE                                               *
    // * The JFreeChart Developer Guide, written by David Gilbert, is available   *
    // * to purchase from Object Refinery Limited:                                *
    // *                                                                          *
    // * http://www.object-refinery.com/jfreechart/guide.html                     *
    // *                                                                          *
    // * Sales are used to provide funding for the JFreeChart project - please    * 
    // * support us so that we can continue developing free software.             *
    // ****************************************************************************

    // save it to an image
    try {
        final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
        final File file1 = new File("xychart100.png");
        ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info);

        // write an HTML page incorporating the image with an image map
        final File file2 = new File("xychart100.html");
        final OutputStream out = new BufferedOutputStream(new FileOutputStream(file2));
        final PrintWriter writer = new PrintWriter(out);
        writer.println("<HTML>");
        writer.println("<HEAD><TITLE>JFreeChart Image Map Demo</TITLE></HEAD>");
        writer.println("<BODY>");
        //            ChartUtilities.writeImageMap(writer, "chart", info);
        writer.println("<IMG SRC=\"xychart100.png\" "
                + "WIDTH=\"600\" HEIGHT=\"400\" BORDER=\"0\" USEMAP=\"#chart\">");
        writer.println("</BODY>");
        writer.println("</HTML>");
        writer.close();

    } catch (IOException e) {
        System.out.println(e.toString());
    }
    return;
}

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

private void showConstellationWindow(ConstellationPoint[] _map, String _name) {
    JFrame constellation = new JFrame(" ?? " + _name);
    constellation.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    XYSeriesCollection dots = new XYSeriesCollection();
    XYSeries series = new XYSeries(_name);
    JFreeChart chart = ChartFactory.createScatterPlot("", "I", "Q", dots, PlotOrientation.VERTICAL, false,
            false, false);//from  w w  w. ja va 2s .  co  m
    XYPlot xyPlot = chart.getXYPlot();
    CustomXYToolTipGenerator tooltipsGenerator = new CustomXYToolTipGenerator();
    ArrayList<String> tooltips = new ArrayList<>();
    for (ConstellationPoint ccp : _map) {
        double I = ccp.getI();
        double Q = ccp.getQ();
        series.add(I, Q);
        tooltips.add(ccp.getCode().getStringSequence());
    }
    tooltipsGenerator.addToolTipSeries(tooltips);
    xyPlot.getRenderer().setBaseToolTipGenerator(tooltipsGenerator);
    double maxX = StatisticsTools.round(Math.abs(series.getMaxX()), 3);
    double maxY = StatisticsTools.round(Math.abs(series.getMaxY()), 3);
    double minX = StatisticsTools.round(Math.abs(series.getMinX()), 3);
    double minY = StatisticsTools.round(Math.abs(series.getMinY()), 3);
    if (maxX != 0 || minX != 0) {
        double X = Math.max(minX, maxX);
        xyPlot.getDomainAxis().setRange(-1.1 * X, 1.1 * X);
    } else
        xyPlot.getDomainAxis().setRange(-1, 1);
    if (maxY != 0 || minY != 0) {
        double Y = Math.max(minY, maxY);
        xyPlot.getRangeAxis().setRange(-1.1 * Y, 1.1 * Y);
    } else
        xyPlot.getRangeAxis().setRange(-1, 1);
    dots.addSeries(series);

    xyPlot.setBackgroundPaint(Color.WHITE);
    xyPlot.setDomainGridlinePaint(Color.GRAY);
    xyPlot.setRangeGridlinePaint(Color.GRAY);
    xyPlot.getRenderer().setSeriesPaint(0, Color.BLACK);
    xyPlot.setDomainZeroBaselineVisible(true);
    xyPlot.setRangeZeroBaselineVisible(true);

    ChartPanel chartPanel = new ChartPanel(chart);
    JPanel nestedPanel = new JPanel();
    nestedPanel.add(chartPanel, new CellConstraints());
    constellation.add(nestedPanel);
    constellation.pack();
    constellation.setLocationRelativeTo(null);
    constellation.setResizable(false);
    constellation.setVisible(true);
}

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;/*  w ww  .  ja  v a2  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.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  ww.  j av  a 2 s  .co  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_;
}

From source file:org.matsim.pt.counts.PtCountsSimRealPerHourGraph.java

/**
 * @param hour/*  w  ww .  ja va 2  s  .  co  m*/
 *            A value in 1..24, 1 for 0 a.m. to 1 a.m., 2 for 1 a.m. to 2
 *            a.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 = "[" + this.countsType + "]\tVolumes " + (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_;
}

From source file:org.matsim.pt.counts.obsolete.PtCountsSimRealPerHourGraph.java

/**
 * @param hour//  ww  w  . ja v  a 2 s.c  o  m
 *            A value in 1..24, 1 for 0 a.m. to 1 a.m., 2 for 1 a.m. to 2
 *            a.m. ...
 */
@Override
@Deprecated // use standard counts package
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 = "[" + this.countsType + "]\tVolumes " + (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_;
}

From source file:com.android.ddmuilib.log.event.DisplaySync.java

/**
 * Resets the display.// w ww.j ava 2  s  . c  o  m
 */
@Override
void resetUI() {
    super.resetUI();
    XYPlot xyPlot = mChart.getXYPlot();

    XYBarRenderer br = new XYBarRenderer();
    mDatasetsSync = new TimePeriodValues[NUM_AUTHS];

    @SuppressWarnings("unchecked")
    List<String> mTooltipsSyncTmp[] = new List[NUM_AUTHS];
    mTooltipsSync = mTooltipsSyncTmp;

    mTooltipGenerators = new CustomXYToolTipGenerator[NUM_AUTHS];

    TimePeriodValuesCollection tpvc = new TimePeriodValuesCollection();
    xyPlot.setDataset(tpvc);
    xyPlot.setRenderer(0, br);

    XYLineAndShapeRenderer ls = new XYLineAndShapeRenderer();
    ls.setBaseLinesVisible(false);
    mDatasetsSyncTickle = new TimeSeries[NUM_AUTHS];
    TimeSeriesCollection tsc = new TimeSeriesCollection();
    xyPlot.setDataset(1, tsc);
    xyPlot.setRenderer(1, ls);

    mDatasetError = new TimeSeries("Errors", FixedMillisecond.class);
    xyPlot.setDataset(2, new TimeSeriesCollection(mDatasetError));
    XYLineAndShapeRenderer errls = new XYLineAndShapeRenderer();
    errls.setBaseLinesVisible(false);
    errls.setSeriesPaint(0, Color.RED);
    xyPlot.setRenderer(2, errls);

    for (int i = 0; i < NUM_AUTHS; i++) {
        br.setSeriesPaint(i, AUTH_COLORS[i]);
        ls.setSeriesPaint(i, AUTH_COLORS[i]);
        mDatasetsSync[i] = new TimePeriodValues(AUTH_NAMES[i]);
        tpvc.addSeries(mDatasetsSync[i]);
        mTooltipsSync[i] = new ArrayList<String>();
        mTooltipGenerators[i] = new CustomXYToolTipGenerator();
        br.setSeriesToolTipGenerator(i, mTooltipGenerators[i]);
        mTooltipGenerators[i].addToolTipSeries(mTooltipsSync[i]);

        mDatasetsSyncTickle[i] = new TimeSeries(AUTH_NAMES[i] + " tickle", FixedMillisecond.class);
        tsc.addSeries(mDatasetsSyncTickle[i]);
        ls.setSeriesShape(i, ShapeUtilities.createUpTriangle(2.5f));
    }
}

From source file:com.android.ddmuilib.log.event.DisplaySyncPerf.java

/**
 * Resets the display.//ww w .j  a  v  a2 s.  c  o  m
 */
@Override
void resetUI() {
    super.resetUI();
    XYPlot xyPlot = mChart.getXYPlot();
    xyPlot.getRangeAxis().setVisible(false);
    mTooltipGenerator = new CustomXYToolTipGenerator();

    @SuppressWarnings("unchecked")
    List<String>[] mTooltipsTmp = new List[NUM_SERIES];
    mTooltips = mTooltipsTmp;

    XYBarRenderer br = new XYBarRenderer();
    br.setUseYInterval(true);
    mDatasets = new TimePeriodValues[NUM_SERIES];

    TimePeriodValuesCollection tpvc = new YIntervalTimePeriodValuesCollection(1);
    xyPlot.setDataset(tpvc);
    xyPlot.setRenderer(br);

    for (int i = 0; i < NUM_SERIES; i++) {
        br.setSeriesPaint(i, SERIES_COLORS[i]);
        mDatasets[i] = new TimePeriodValues(SERIES_NAMES[i]);
        tpvc.addSeries(mDatasets[i]);
        mTooltips[i] = new ArrayList<String>();
        mTooltipGenerator.addToolTipSeries(mTooltips[i]);
        br.setSeriesToolTipGenerator(i, mTooltipGenerator);
    }
}

From source file:com.projity.pm.graphic.chart.TimeChartPanel.java

public void updateChart() {
    JFreeChart chart = chartInfo.getChart();
    final Object[] traces = chartInfo.getTraces();
    setChart(chart);/*from ww  w.ja  v a  2s . c  o  m*/

    Color color;
    Paint paint;
    int series = 0;
    for (int i = 0; i < traces.length; i++) {
        color = ChartHelper.getColorForField(traces[i]);

        if (traces[i] == HasTimeDistributedData.AVAILABILITY) {
            chart.getXYPlot().getRenderer(1).setSeriesPaint(0, color);
            chart.getXYPlot().getRenderer(1).setSeriesStroke(0, PredefinedStroke.LARGE_FRAMED);
            continue; // do not increment series
        }

        chart.getXYPlot().getRenderer().setSeriesPaint(series, color);

        chart.getXYPlot().getRenderer().setToolTipGenerator(new CustomXYToolTipGenerator() {
            public String generateToolTip(XYDataset data, int series, int item) {
                return traces[0] + " ";
            }

        });
        series++; // excludes availability from count
    }
    // chart.getXYPlot().addRangeMarker(new ValueMarker(1.0));

    chart.getXYPlot().getDomainAxis().setLowerBound(chartInfo.getCoord().getOrigin());
    chart.getXYPlot().getDomainAxis().setUpperBound(
            Math.max(chartInfo.getCoord().getEnd(), chartInfo.getCoord().toTime(viewport.getWidth())));
}

From source file:Output.SplitChart.java

public void drawAggreagtedSupplyAndDemandWithTrueCostData(String outputTimeTypeSelect, int iStartTime,
        int iEndTime, int iDayHour, int[] selectIndex) {
    ArrayList genAgentSupplyOfferByDay = this.amesFrame.getAMESMarket().getGenAgentSupplyOfferByDay();

    Object[][] genData = this.amesFrame.getGeneratorData();
    int iGenNumber = genData.length;

    double[][] genOfferData = new double[iGenNumber][8]; // a, b, minCap, maxCap, 1/b, a/b, currentPower, currentPrice
    double[][] offerPrices = new double[iGenNumber * 2][2]; // price, index

    for (int i = 0; i < iGenNumber; i++) {
        genOfferData[i][0] = Support.parseDouble(genData[i][4].toString());
        genOfferData[i][1] = Support.parseDouble(genData[i][5].toString());
        genOfferData[i][2] = Support.parseDouble(genData[i][6].toString());
        genOfferData[i][3] = Support.parseDouble(genData[i][7].toString());
        genOfferData[i][4] = 1.0 / genOfferData[i][1];
        genOfferData[i][5] = genOfferData[i][0] / genOfferData[i][1];

        offerPrices[2 * i][0] = genOfferData[i][0] + (2 * genOfferData[i][1] * genOfferData[i][2]);
        offerPrices[2 * i][1] = 2 * i;//from  w  w w. ja va2  s  .c o  m
        offerPrices[(2 * i) + 1][0] = genOfferData[i][0] + (2 * genOfferData[i][1] * genOfferData[i][3]);
        offerPrices[(2 * i) + 1][1] = (2 * i) + 1;

        genOfferData[i][6] = genOfferData[i][2];
        genOfferData[i][7] = offerPrices[2 * i][0];
    }

    // sort the price of each generator
    double dTemp = 0;
    double iTemp = 0;
    for (int i = 0; i < (2 * iGenNumber); i++) {
        for (int j = i + 1; j < (2 * iGenNumber); j++) {
            if (offerPrices[i][0] > offerPrices[j][0]) {
                dTemp = offerPrices[i][0];
                iTemp = offerPrices[i][1];
                offerPrices[i][0] = offerPrices[j][0];
                offerPrices[i][1] = offerPrices[j][1];
                offerPrices[j][0] = dTemp;
                offerPrices[j][1] = iTemp;
            }
        }
    }

    double[][] genAggregateOfferDataPoints = new double[(iGenNumber * 2) - 1][4]; // leftPoint(power, price), rightPoint(power, price)
    int[][] genAggregateOfferCommit = new int[(iGenNumber * 2) - 1][iGenNumber * 2];
    // in the first iGenNumber of each row is the index of gen whose output is fixed
    // in the second iGenNumber of each row is the index of gen whose output is variable
    // otherwise -1

    for (int i = 0; i < ((2 * iGenNumber) - 1); i++) {
        for (int j = 0; j < (2 * iGenNumber); j++) {
            genAggregateOfferCommit[i][j] = -1;
        }
    }

    double leftPrice = offerPrices[0][0];
    for (int i = 0; i < iGenNumber; i++) {
        if (leftPrice >= genOfferData[i][7]) {
            genAggregateOfferDataPoints[0][0] += genOfferData[i][6];
        }
    }

    for (int i = 0; i < ((2 * iGenNumber) - 1); i++) {
        genAggregateOfferDataPoints[i][1] = offerPrices[i][0];
        genAggregateOfferDataPoints[i][3] = offerPrices[i + 1][0];

        if (i > 0) {
            genAggregateOfferDataPoints[i][0] = genAggregateOfferDataPoints[i - 1][2];
        }

        genAggregateOfferDataPoints[i][2] = genAggregateOfferDataPoints[i][0];

        int iIndexFixed = 0;
        int iIndexVariable = 0;

        double rightPrice = offerPrices[i + 1][0];
        for (int j = 0; j < iGenNumber; j++) {
            if (rightPrice > genOfferData[j][7]) {
                if (Math.abs(genOfferData[j][6] - genOfferData[j][3]) < 0.000001) { // already at maxCap
                    genAggregateOfferCommit[i][iIndexFixed++] = j;
                } else {
                    double power = (rightPrice - genOfferData[j][0]) / (2 * genOfferData[j][1]);
                    genAggregateOfferDataPoints[i][2] += power - genOfferData[j][6];
                    genAggregateOfferCommit[i][iGenNumber + iIndexVariable] = j;
                    iIndexVariable++;

                    genOfferData[j][7] = rightPrice;
                    genOfferData[j][6] = power;

                }

            }
        }
    }

    double HighestGenOfferPrice = genAggregateOfferDataPoints[(iGenNumber * 2) - 2][3];
    double HighestGenOfferPower = genAggregateOfferDataPoints[(iGenNumber * 2) - 2][2];

    // Demand
    Object[][][] lsePriceSensitiveData = this.amesFrame.getLSEPriceSensitiveDemandData();
    Object[][] lseHybridData = this.amesFrame.getLSEHybridDemandData();
    Object[][] lseData = this.amesFrame.getLSEData();
    int iLSENumber = lsePriceSensitiveData.length;
    double[][] lseDemandData = new double[iLSENumber][6]; // c, d, slMax, fixed demand, currentPower, currentPrice
    double[][] lsePrices = new double[iLSENumber * 2][2]; // price, index
    int hourlyLoadHybridFlagByLSE = 0;
    double priceCap = 1000.0;

    for (int i = 0; i < iLSENumber; i++) {
        hourlyLoadHybridFlagByLSE = Integer.parseInt(lseHybridData[i][iDayHour + 3].toString());

        if ((hourlyLoadHybridFlagByLSE & 2) == 2) {
            double c = Support.parseDouble(lsePriceSensitiveData[i][iDayHour][4].toString());
            double d = Support.parseDouble(lsePriceSensitiveData[i][iDayHour][5].toString());
            double slMax = Support.parseDouble(lsePriceSensitiveData[i][iDayHour][6].toString());

            lseDemandData[i][0] = c;
            lseDemandData[i][1] = d;
            lseDemandData[i][2] = slMax;
            lseDemandData[i][4] = 0.0;
            lseDemandData[i][5] = c;

            lsePrices[2 * i][0] = c;
            lsePrices[2 * i][1] = 2 * i;
            lsePrices[(2 * i) + 1][0] = c - (2 * d * slMax);
            lsePrices[(2 * i) + 1][1] = (2 * i) + 1;
        } else {
            lseDemandData[i][0] = 0.0;
            lseDemandData[i][1] = 0.0;
            lseDemandData[i][2] = 0.0;
            lseDemandData[i][4] = 0.0;
            lseDemandData[i][5] = priceCap;

            lsePrices[2 * i][0] = priceCap;
            lsePrices[2 * i][1] = 2 * i;
            lsePrices[(2 * i) + 1][0] = priceCap;
            lsePrices[(2 * i) + 1][1] = (2 * i) + 1;
        }

        if ((hourlyLoadHybridFlagByLSE & 1) == 1) { // fixed demand
            lseDemandData[i][3] = Support.parseDouble(lseData[i][iDayHour + 3].toString());
        }
    }

    // sort the price of each lse
    for (int i = 0; i < (2 * iLSENumber); i++) {
        for (int j = i + 1; j < (2 * iLSENumber); j++) {
            if (lsePrices[i][0] < lsePrices[j][0]) {
                dTemp = lsePrices[i][0];
                iTemp = lsePrices[i][1];
                lsePrices[i][0] = lsePrices[j][0];
                lsePrices[i][1] = lsePrices[j][1];
                lsePrices[j][0] = dTemp;
                lsePrices[j][1] = iTemp;
            }
        }
    }

    double[][] lseAggregateDemandDataPoints = new double[(iLSENumber * 2) - 1][4]; // leftPoint(power, price), rightPoint(power, price)
    int[][] lseAggregateDemandCommit = new int[(iLSENumber * 2) - 1][iLSENumber * 2];
    // in the first iLSENumber of each row is the index of LSE whose commit is fixed
    // in the second iLSENumber of each row is the index of LSE whose commit is variable
    // otherwise -1

    for (int i = 0; i < ((2 * iLSENumber) - 1); i++) {
        for (int j = 0; j < (2 * iLSENumber); j++) {
            lseAggregateDemandCommit[i][j] = -1;
        }
    }

    leftPrice = lsePrices[0][0];
    for (int i = 0; i < iLSENumber; i++) {
        lseAggregateDemandDataPoints[0][0] += lseDemandData[i][3];

        if (leftPrice <= lseDemandData[i][5]) {
            lseAggregateDemandDataPoints[0][0] += lseDemandData[i][4];
        }
    }

    for (int i = 0; i < ((2 * iLSENumber) - 1); i++) {
        lseAggregateDemandDataPoints[i][1] = lsePrices[i][0];
        lseAggregateDemandDataPoints[i][3] = lsePrices[i + 1][0];

        if (i > 0) {
            lseAggregateDemandDataPoints[i][0] = lseAggregateDemandDataPoints[i - 1][2];
        }

        lseAggregateDemandDataPoints[i][2] = lseAggregateDemandDataPoints[i][0];

        int iIndexFixed = 0;
        int iIndexVariable = 0;

        double rightPrice = lsePrices[i + 1][0];
        for (int j = 0; j < iLSENumber; j++) {
            if (rightPrice < lseDemandData[j][5]) {
                if (Math.abs(lseDemandData[j][4] - lseDemandData[j][2]) < 0.000001) { // already at slMax
                    lseAggregateDemandCommit[i][iIndexFixed++] = j;
                } else {
                    double power = (lseDemandData[j][0] - rightPrice) / (2 * lseDemandData[j][1]);
                    lseAggregateDemandDataPoints[i][2] += power - lseDemandData[j][4];
                    lseAggregateDemandCommit[i][iLSENumber + iIndexVariable] = j;
                    iIndexVariable++;

                    lseDemandData[j][5] = rightPrice;
                    lseDemandData[j][4] = power;

                }

            }
        }
    }

    double HighestLSEDemandPrice = lseAggregateDemandDataPoints[0][1];
    double HighestLSEDemandPower = lseAggregateDemandDataPoints[0][0];

    double highestPrice = (HighestGenOfferPrice > HighestLSEDemandPrice) ? HighestGenOfferPrice
            : HighestLSEDemandPrice;
    highestPrice += 50;

    this.chartTitle = "True Total Supply and Demand Curves at Hour " + iDayHour;
    String xLabel = "Power (MWs)";

    this.dataset = new XYSeriesCollection();

    XYSeries series = new XYSeries("Supply");

    ArrayList genTipList = new ArrayList();
    String tipString = "";

    leftPrice = genAggregateOfferDataPoints[0][1];
    double leftPower = genAggregateOfferDataPoints[0][0];
    series.add(leftPower, leftPrice);
    tipString = String.format("Power=%1$.2f Price=%2$.2f", leftPower, leftPrice);
    genTipList.add(new String(tipString));
    double rightPrice = 0;
    double rightPower = 0;

    for (int i = 0; i < ((2 * iGenNumber) - 1); i++) {
        rightPrice = genAggregateOfferDataPoints[i][3];
        rightPower = genAggregateOfferDataPoints[i][2];

        series.add(rightPower, rightPrice);

        // For tip display
        tipString = String.format("Power=%1$.2f Price=%2$.2f", rightPower, rightPrice);

        String tempFixed = " FixedGen: ";
        String tempVariable = " Marginal GenCos: ";
        String temp;
        boolean bFixed = false;
        boolean bVariable = false;

        for (int j = 0; j < (2 * iGenNumber); j++) {
            if ((j < iGenNumber) && (genAggregateOfferCommit[i][j] != -1)) {
                bFixed = true;
                tempFixed += genData[genAggregateOfferCommit[i][j]][0] + " ";
            }

            if ((j >= iGenNumber) && (genAggregateOfferCommit[i][j] != -1)) {
                bVariable = true;
                tempVariable += genData[genAggregateOfferCommit[i][j]][0] + " ";
            }
        }

        if (bFixed) {
            tipString += tempFixed;
        }

        if (bVariable) {
            tipString += tempVariable;
        }

        genTipList.add(new String(tipString));

    }
    // last infinity part
    series.add(rightPower, highestPrice);
    tipString = String.format("Power=%1$.2f Price=%2$.2f", rightPower, highestPrice);
    genTipList.add(new String(tipString));

    this.dataset.addSeries(series);

    series = new XYSeries("Demand");

    ArrayList LSETipList = new ArrayList();

    //first infinity part
    series.add(HighestLSEDemandPower, highestPrice);
    tipString = String.format("Power=%1$.2f Price=%2$.2f", HighestLSEDemandPower, highestPrice);
    LSETipList.add(new String(tipString));

    //second point
    leftPrice = lseAggregateDemandDataPoints[0][1];
    leftPower = lseAggregateDemandDataPoints[0][0];
    series.add(leftPower, leftPrice);
    tipString = String.format("Power=%1$.2f Price=%2$.2f", leftPower, leftPrice);
    LSETipList.add(new String(tipString));

    for (int i = 0; i < ((2 * iLSENumber) - 1); i++) {
        rightPrice = lseAggregateDemandDataPoints[i][3];
        rightPower = lseAggregateDemandDataPoints[i][2];

        series.add(rightPower, rightPrice);

        // For tip display
        tipString = String.format("Power=%1$.2f Price=%2$.2f", rightPower, rightPrice);

        String tempFixed = " MaxPS LSE: ";
        String tempVariable = " VariablePS LSE: ";
        String temp;
        boolean bFixed = false;
        boolean bVariable = false;

        for (int j = 0; j < (2 * iLSENumber); j++) {
            if ((j < iLSENumber) && (lseAggregateDemandCommit[i][j] != -1)) {
                bFixed = true;
                tempFixed += lseData[lseAggregateDemandCommit[i][j]][0] + " ";
            }

            if ((j >= iLSENumber) && (lseAggregateDemandCommit[i][j] != -1)) {
                bVariable = true;
                tempVariable += lseData[lseAggregateDemandCommit[i][j]][0] + " ";
            }
        }

        if (bFixed) {
            tipString += tempFixed;
        }

        if (bVariable) {
            tipString += tempVariable;
        }

        LSETipList.add(new String(tipString));

    }

    // last infinity part
    series.add(rightPower, 0.0);
    tipString = String.format("Power=%1$.2f Price=%2$.2f", rightPower, 0.0);
    LSETipList.add(new String(tipString));

    this.dataset.addSeries(series);

    // create the chart...
    this.chart = ChartFactory.createXYLineChart(this.chartTitle, // chart title
            xLabel, // x axis label
            "Price ($/MWh)", // y axis label
            this.dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );

    this.chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    final XYPlot plot = this.chart.getXYPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.blue);
    plot.setRangeGridlinePaint(Color.blue);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    XYToolTipGenerator generator = new StandardXYToolTipGenerator("{2}", new DecimalFormat("0.00"),
            new DecimalFormat("0.00"));
    CustomXYToolTipGenerator customTip = new CustomXYToolTipGenerator();
    customTip.addToolTipSeries(genTipList);
    customTip.addToolTipSeries(LSETipList);

    renderer.setToolTipGenerator(customTip);
    plot.setRenderer(renderer);

    NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
    xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    this.chart.getTitle().setFont(this.font);
    this.chartPanel.setChart(this.chart);
}