List of usage examples for org.jfree.chart.renderer.xy XYLineAndShapeRenderer setToolTipGenerator
@Override public void setToolTipGenerator(XYToolTipGenerator generator)
From source file:gov.nih.nci.caintegrator.plots.kaplanmeier.JFreeChartIKMPlottermpl.java
public JFreeChart createKMPlot(Collection<GroupCoordinates> groupsToBePlotted, String title, String xAxisLabel, String yAxisLabel) {//from w w w .j a v a 2 s. c om List<KMPlotPointSeriesSet> kmPlotSets = new ArrayList<KMPlotPointSeriesSet>( convertToKaplanMeierPlotPointSeriesSet(groupsToBePlotted)); XYSeriesCollection finalDataCollection = new XYSeriesCollection(); /* Repackage all the datasets to go into the XYSeriesCollection */ for (KMPlotPointSeriesSet dataSet : kmPlotSets) { finalDataCollection.addSeries(dataSet.getCensorPlotPoints()); finalDataCollection.addSeries(dataSet.getProbabilityPlotPoints()); } JFreeChart chart = ChartFactory.createXYLineChart("", xAxisLabel, yAxisLabel, finalDataCollection, PlotOrientation.VERTICAL, true, //legend true, //tooltips false//urls ); XYPlot plot = (XYPlot) chart.getPlot(); /* * Ideally the actual Renderer settings should have been created * at the survivalLength of iterating KaplanMeierPlotPointSeriesSets, adding them to the actual * Data Set that is going to be going into the Chart plotter. But you have no idea how * they are going to be sitting in the Plot dataset so there is no guarantee that setting the * renderer based on a supposed index will actually work. In fact */ XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); for (int i = 0; i < finalDataCollection.getSeriesCount(); i++) { KMPlotPointSeries kmSeries = (KMPlotPointSeries) finalDataCollection.getSeries(i); if (kmSeries.getType() == KMPlotPointSeries.SeriesType.CENSOR) { renderer.setSeriesLinesVisible(i, false); renderer.setSeriesShapesVisible(i, true); renderer.setSeriesShape(i, getCensorShape()); } else if (kmSeries.getType() == KMPlotPointSeries.SeriesType.PROBABILITY) { renderer.setSeriesLinesVisible(i, true); renderer.setSeriesShapesVisible(i, false); } else { //don't show this set as it is not a known type renderer.setSeriesLinesVisible(i, false); renderer.setSeriesShapesVisible(i, false); } renderer.setSeriesPaint(i, getKMSetColor(kmPlotSets, kmSeries.getKey(), kmSeries.getType()), true); } renderer.setToolTipGenerator(new StandardXYToolTipGenerator()); renderer.setDefaultEntityRadius(6); plot.setRenderer(renderer); /* change the auto tick unit selection to integer units only... */ NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits()); /* OPTIONAL CUSTOMISATION COMPLETED. */ rangeAxis.setAutoRange(true); rangeAxis.setRange(0.0, 1.0); /* set Title and Legend */ chart.setTitle(title); createLegend(chart, kmPlotSets); return chart; }
From source file:Output.SplitChart.java
public void drawGeneratorCommitmentWithTrueCostData(String outputTimeTypeSelect, int iStartTime, int iEndTime, int iDayHour, int[] selectIndex) { String[] names = { "GenCo Name", "Hour", "Power (MW)" }; this.chartTitle = "GenCo Commitments (Benchmark)"; ArrayList genAgentCommitmentWithTrueCost = this.amesFrame.getAMESMarket() .getGenAgentCommitmentWithTrueCost(); boolean draw3DChart = false; this.dataset = new XYSeriesCollection(); DefaultCategoryDataset dataset3D = new DefaultCategoryDataset(); Object[][] genData = this.amesFrame.getGeneratorData(); int iGenNumber = genData.length; if ((selectIndex.length < 1) || (selectIndex[0] == 0)) { double[][] genCommitmentWithTrueCost = (double[][]) genAgentCommitmentWithTrueCost.get(0); for (int j = 0; j < iGenNumber; j++) { XYSeries series = new XYSeries((String) genData[j][0]); for (int i = 0; i < 24; i++) { series.add(i, (Math.round(genCommitmentWithTrueCost[i][j] * 1000)) / 1000.0); }// w w w . j a v a 2 s. c o m this.dataset.addSeries(series); } } else { int iDataNumber = selectIndex.length; int iField = names.length; double[][] genCommitmentWithTrueCost = (double[][]) genAgentCommitmentWithTrueCost.get(0); for (int j = 0; j < iDataNumber; j++) { XYSeries series = new XYSeries((String) genData[selectIndex[j] - 1][0]); for (int i = 0; i < 24; i++) { series.add(i, (Math.round(genCommitmentWithTrueCost[i][selectIndex[j] - 1] * 1000)) / 1000.0); } this.dataset.addSeries(series); } } // create the chart... this.chart = ChartFactory.createXYLineChart(this.chartTitle, // chart title "Hour", // x axis label "Power (MWs)", // y axis label this.dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... 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")); renderer.setToolTipGenerator(generator); plot.setRenderer(renderer); NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); xAxis.setRange(0, 23.5); this.chart.getTitle().setFont(this.font); this.chartPanel.setChart(this.chart); }
From source file:Output.SplitChart.java
public void drawNodeLMPWithTrueCostData(String outputTimeTypeSelect, int iStartTime, int iEndTime, int iDayHour, int[] selectIndex) { String[] names = { "Bus Name", " Hour", " LMP" }; this.chartTitle = "Locational Marginal Prices (Benchmark)"; ArrayList LMPWithTrueCost = this.amesFrame.getAMESMarket().getLMPWithTrueCost(); String[] nodeName = this.amesFrame.getNodeNameData(); int iNodeNumber = nodeName.length; boolean draw3DChart = false; this.dataset = new XYSeriesCollection(); DefaultCategoryDataset dataset3D = new DefaultCategoryDataset(); if ((selectIndex.length < 1) || (selectIndex[0] == 0)) { double[][] lmp = (double[][]) LMPWithTrueCost.get(0); for (int j = 0; j < iNodeNumber; j++) { XYSeries series = new XYSeries(nodeName[j]); for (int i = 0; i < 24; i++) { series.add(i, (Math.round(lmp[i][j] * 1000)) / 1000.0); }//from ww w .java 2 s .com this.dataset.addSeries(series); } } else { int iDataNumber = selectIndex.length; int iField = names.length; double[][] lmp = (double[][]) LMPWithTrueCost.get(0); for (int j = 0; j < iDataNumber; j++) { XYSeries series = new XYSeries(nodeName[selectIndex[j] - 1]); for (int i = 0; i < 24; i++) { series.add(i, (Math.round(lmp[i][selectIndex[j] - 1] * 1000)) / 1000.0); } this.dataset.addSeries(series); } } // create the chart... this.chart = ChartFactory.createXYLineChart(this.chartTitle, // chart title "Hour", // x axis label "Price ($/MWh)", // y axis label this.dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMIZATION OF THE CHART... 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")); renderer.setToolTipGenerator(generator); plot.setRenderer(renderer); NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); xAxis.setRange(0, 23.5); this.chart.getTitle().setFont(this.font); this.chartPanel.setChart(this.chart); }
From source file:Output.SplitChart.java
public void drawGeneratorSupplyOfferData(String outputTimeTypeSelect, int iStartTime, int iEndTime, int[] selectIndex) { String[] names = { "GenCo Name", "Day Index", "aR ($/MWh)", "bR ($/MW2h)", "CapRL (MW)", "CapRU (MW)", }; ArrayList genAgentSupplyOfferByDay = this.amesFrame.getAMESMarket().getGenAgentSupplyOfferByDay(); Object[][] genData = this.amesFrame.getGeneratorData(); int iGenNumber = genData.length; String xLabel = "Power (MWs)"; this.dataset = new XYSeriesCollection(); if (selectIndex.length < 1) { JOptionPane.showMessageDialog(this, "No GenCo is selected!", "Error Message", JOptionPane.ERROR_MESSAGE); return;/*from ww w. j av a2 s .c om*/ } double[][] genOffer = (double[][]) genAgentSupplyOfferByDay.get(iStartTime - 1); int genIndex = selectIndex[0]; this.chartTitle = genData[genIndex][0] + " Supply Offer for Day " + iStartTime; XYSeries series = new XYSeries("Reported"); double dStart = genOffer[genIndex][0] + (2.0 * genOffer[genIndex][1] * genOffer[genIndex][2]); double dEnd = genOffer[genIndex][0] + (2.0 * genOffer[genIndex][1] * genOffer[genIndex][3]); series.add(genOffer[genIndex][2], dStart); series.add(genOffer[genIndex][3], dEnd); this.dataset.addSeries(series); series = new XYSeries("True"); double da = Support.parseDouble(genData[genIndex][4].toString()); double db = Support.parseDouble(genData[genIndex][5].toString()); double dMinCap = Support.parseDouble(genData[genIndex][6].toString()); double dMaxCap = Support.parseDouble(genData[genIndex][7].toString()); dStart = da + (2.0 * db * dMinCap); dEnd = da + (2.0 * db * dMaxCap); series.add(dMinCap, dStart); series.add(dMaxCap, dEnd); 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")); renderer.setToolTipGenerator(generator); plot.setRenderer(renderer); NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); this.chart.getTitle().setFont(this.font); this.chartPanel.setChart(this.chart); }
From source file:Output.SplitChart.java
public void drawLSESurplusWithTrueCostData(String outputTimeTypeSelect, int iStartTime, int iEndTime, int iDayHour, int[] selectIndex) { this.chartTitle = "LSE Net Earnings (Benchmark)"; ArrayList LSEAgentSurplusWithTrueCost = this.amesFrame.getAMESMarket().getLSEAgentSurplusWithTrueCost(); Object[][] lseHybridData = this.amesFrame.getLSEHybridDemandData(); int iLSENumber = lseHybridData.length; boolean draw3DChart = false; this.dataset = new XYSeriesCollection(); DefaultCategoryDataset dataset3D = new DefaultCategoryDataset(); if ((selectIndex.length < 1) || (selectIndex[0] == 0)) { double[][] surplus = (double[][]) LSEAgentSurplusWithTrueCost.get(0); for (int j = 0; j < iLSENumber; j++) { XYSeries series = new XYSeries((String) lseHybridData[j][0]); for (int i = 0; i < 24; i++) { series.add(i, (Math.round(surplus[j][i + 1] * 1000)) / 1000.0); }/*from w w w .j av a 2 s. c o m*/ this.dataset.addSeries(series); /* series = new XYSeries((String)lseHybridData[j][0]+" Total"); double sum=0.0; for(int i=0; i<24; i++) { sum+=surplus[j][i+1]; series.add(i, (double)(Math.round(sum*1000))/1000.0); } dataset.addSeries(series); */ } } else { int iDataNumber = selectIndex.length; double[][] surplus = (double[][]) LSEAgentSurplusWithTrueCost.get(0); for (int j = 0; j < iDataNumber; j++) { XYSeries series = new XYSeries((String) lseHybridData[selectIndex[j] - 1][0]); for (int i = 0; i < 24; i++) { series.add(i, (Math.round(surplus[selectIndex[j] - 1][i + 1] * 1000)) / 1000.0); } this.dataset.addSeries(series); /* series = new XYSeries((String)lseHybridData[selectIndex[j]-1][0]+" Total"); double sum=0.0; for(int i=0; i<24; i++) { sum+=surplus[selectIndex[j]-1][i+1]; series.add(i, (double)(Math.round(sum*1000))/1000.0); } dataset.addSeries(series); */ } } // create the chart... this.chart = ChartFactory.createXYLineChart(this.chartTitle, // chart title "Hour", // x axis label "Net Earnings ($)", // y axis label this.dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... 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")); renderer.setToolTipGenerator(generator); plot.setRenderer(renderer); NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); xAxis.setRange(0, 23.5); this.chart.getTitle().setFont(this.font); this.chartPanel.setChart(this.chart); }
From source file:Output.SplitChart.java
public void drawPSDemandDispatchWithTrueCostData(String outputTimeTypeSelect, int iStartTime, int iEndTime, int iDayHour, int[] selectIndex) { String[] names = { "LSE Name", "Hour", "c ($/MWh)", "d ($/MW2h)", "SLMax (MW)", "Price-Sensitive Demand (MW)" }; Object[][][] lsePriceSensitiveData = this.amesFrame.getLSEPriceSensitiveDemandData(); Object[][] lseHybridData = this.amesFrame.getLSEHybridDemandData(); int iLSENumber = lsePriceSensitiveData.length; ArrayList LMPWithTrueCost = this.amesFrame.getAMESMarket().getLMPWithTrueCost(); double[][] lmp = (double[][]) LMPWithTrueCost.get(0); ArrayList priceSensitiveWithTrueCost = this.amesFrame.getAMESMarket() .getLSEAgentPriceSensitiveDemandWithTrueCost(); this.chartTitle = "LSE Price-Sensitive Demand Function \nand Cleared Point (Benchmark)"; String xLabel = "Power (MWs)"; this.dataset = new XYSeriesCollection(); if (selectIndex.length < 1) { JOptionPane.showMessageDialog(this, "No LSE is selected!", "Error Message", JOptionPane.ERROR_MESSAGE); return;//from w w w.j a v a2 s. c o m } double[][] lsePS = (double[][]) priceSensitiveWithTrueCost.get(0); int lseIndex = selectIndex[0]; int lseAtBus = Integer.parseInt(lseHybridData[lseIndex][2].toString()); double busLMP = lmp[iDayHour][lseAtBus - 1]; this.chartTitle = this.chartTitle + "\n " + lsePriceSensitiveData[lseIndex][0][0] + " Hour " + iDayHour; XYSeries series = new XYSeries("Cleared Point"); int psLoadIndex = 0; // Get the psLoadIndex for (int k = 0; k < selectIndex[0]; k++) { int hourlyFlag = Integer.parseInt(lseHybridData[k][iDayHour + 3].toString()); if ((hourlyFlag & 2) == 2) { psLoadIndex++; } } double dStart = 0; double dEnd = 0; int hourlyLoadHybridFlagByLSE = Integer.parseInt(lseHybridData[selectIndex[0]][iDayHour + 3].toString()); if ((hourlyLoadHybridFlagByLSE & 2) == 2) { dStart = lsePS[iDayHour][psLoadIndex]; } double c = Support.parseDouble(lsePriceSensitiveData[lseIndex][iDayHour][4].toString()); double d = Support.parseDouble(lsePriceSensitiveData[lseIndex][iDayHour][5].toString()); double slMax = Support.parseDouble(lsePriceSensitiveData[lseIndex][iDayHour][6].toString()); dEnd = c - (2.0 * d * dStart); series.add(dStart, busLMP); this.dataset.addSeries(series); series = new XYSeries("Price-Sensitive Demand Function"); dEnd = c - (2.0 * d * slMax); series.add(0, c); series.add(slMax, dEnd); 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")); renderer.setToolTipGenerator(generator); plot.setRenderer(renderer); NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); this.chart.getTitle().setFont(this.font); this.chartPanel.setChart(this.chart); }
From source file:Output.SplitChart.java
public void drawLSEPriceSensitiveDemandData(String outputTimeTypeSelect, int iStartTime, int iEndTime, int iDayHour, int[] selectIndex) { String[] names = { "LSE Name", "Day Index", "Hour", "c ($/MWh)", "d ($/MW2h)", "SLMax (MW)", "Price-Sensitive Demand (MW)" }; Object[][][] lsePriceSensitiveData = this.amesFrame.getLSEPriceSensitiveDemandData(); Object[][] lseHybridData = this.amesFrame.getLSEHybridDemandData(); int iLSENumber = lsePriceSensitiveData.length; ArrayList LMPByDay = this.amesFrame.getAMESMarket().getLMPByDay(); ArrayList priceSensitiveByDay = this.amesFrame.getAMESMarket().getLSEAgenPriceSensitiveDemandByDay(); this.chartTitle = "LSE Price-Sensitive Demand Function and Cleared Point"; String xLabel = "Power (MWs)"; this.dataset = new XYSeriesCollection(); if (selectIndex.length < 1) { JOptionPane.showMessageDialog(this, "No LSE is selected!", "Error Message", JOptionPane.ERROR_MESSAGE); return;//from w w w . j av a 2s . co m } double[][] lsePS = (double[][]) priceSensitiveByDay.get(iStartTime - 2); double[][] lmp = (double[][]) LMPByDay.get(iStartTime - 2); int lseIndex = selectIndex[0]; int lseAtBus = Integer.parseInt(lseHybridData[lseIndex][2].toString()); double busLMP = lmp[iDayHour][lseAtBus - 1]; this.chartTitle = this.chartTitle + "\n " + lsePriceSensitiveData[lseIndex][0][0] + " for Day " + iStartTime + " ( At Hour " + iDayHour + ":00)"; XYSeries series = new XYSeries("Cleared Point"); int psLoadIndex = 0; // Get the psLoadIndex for (int k = 0; k < selectIndex[0]; k++) { int hourlyFlag = Integer.parseInt(lseHybridData[k][iDayHour + 3].toString()); if ((hourlyFlag & 2) == 2) { psLoadIndex++; } } double dStart = 0; double dEnd = 0; int hourlyLoadHybridFlagByLSE = Integer.parseInt(lseHybridData[selectIndex[0]][iDayHour + 3].toString()); if ((hourlyLoadHybridFlagByLSE & 2) == 2) { dStart = lsePS[iDayHour][psLoadIndex]; } double c = Support.parseDouble(lsePriceSensitiveData[lseIndex][iDayHour][4].toString()); double d = Support.parseDouble(lsePriceSensitiveData[lseIndex][iDayHour][5].toString()); double slMax = Support.parseDouble(lsePriceSensitiveData[lseIndex][iDayHour][6].toString()); //dEnd=c-2.0*d*dStart; series.add(dStart, busLMP); this.dataset.addSeries(series); series = new XYSeries("Price-Sensitive Demand Function"); dEnd = c - (2.0 * d * slMax); series.add(0, c); series.add(slMax, dEnd); 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")); renderer.setToolTipGenerator(generator); plot.setRenderer(renderer); NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); this.chart.getTitle().setFont(this.font); this.chartPanel.setChart(this.chart); }
From source file:Output.SplitChart.java
public void drawGeneratorProfitWithTrueCostData(String outputTimeTypeSelect, int iStartTime, int iEndTime, int iDayHour, int[] selectIndex, boolean bProfit) { if (bProfit) { this.chartTitle = "GenCo Profits (Benchmark)"; } else {// w w w.j av a 2 s . com this.chartTitle = "GenCo Net Earnings (Benchmark)"; } ArrayList genAgentProfitWithTrueCost = this.amesFrame.getAMESMarket() .getGenAgentProfitAndNetGainWithTrueCost(); boolean draw3DChart = false; this.dataset = new XYSeriesCollection(); DefaultCategoryDataset dataset3D = new DefaultCategoryDataset(); Object[][] genData = this.amesFrame.getGeneratorData(); int iGenNumber = genData.length; if ((selectIndex.length < 1) || (selectIndex[0] == 0)) { double[][] genProfitWithTrueCost = (double[][]) genAgentProfitWithTrueCost.get(0); for (int j = 0; j < iGenNumber; j++) { XYSeries series; /* = new XYSeries((String)genData[j][0]+" Hourly Profits"); for(int i=0; i<24; i++) { series.add(i, (double)(Math.round(genProfitWithTrueCost[j][i+3]*1000))/1000.0); } dataset.addSeries(series); series = new XYSeries((String)genData[j][0]+" Daily Profits"); double sum=0.0; for(int i=0; i<24; i++) { sum+=genProfitWithTrueCost[j][i+3]; series.add(i, (double)(Math.round(sum*1000))/1000.0); } dataset.addSeries(series); */ series = new XYSeries((String) genData[j][0]); for (int i = 0; i < 24; i++) { if (bProfit) { series.add(i, (Math.round(genProfitWithTrueCost[j][i + 3] * 1000)) / 1000.0); } else { series.add(i, (Math.round(genProfitWithTrueCost[j][i + 27] * 1000)) / 1000.0); } } this.dataset.addSeries(series); /* series = new XYSeries((String)genData[j][0]+" Daily Net Earnings"); double sum=0.0; for(int i=0; i<24; i++) { sum+=genProfitWithTrueCost[j][i+27]; series.add(i, (double)(Math.round(sum*1000))/1000.0); } dataset.addSeries(series); series = new XYSeries((String)genData[j][0]+" Hourly Revenue"); for(int i=0; i<24; i++) { series.add(i, (double)(Math.round(genProfitWithTrueCost[j][i+51]*1000))/1000.0); } dataset.addSeries(series); series = new XYSeries((String)genData[j][0]+" Daily Revenue"); sum=0.0; for(int i=0; i<24; i++) { sum+=genProfitWithTrueCost[j][i+51]; series.add(i, (double)(Math.round(sum*1000))/1000.0); } dataset.addSeries(series); */ } } else { int iDataNumber = selectIndex.length; double[][] genProfitWithTrueCost = (double[][]) genAgentProfitWithTrueCost.get(0); for (int j = 0; j < iDataNumber; j++) { XYSeries series; /* = new XYSeries((String)genData[selectIndex[j]-1][0]+" Houely Profits"); for(int i=0; i<24; i++) { series.add(i, (double)(Math.round(genProfitWithTrueCost[selectIndex[j]-1][i+3]*1000))/1000.0); } dataset.addSeries(series); series = new XYSeries((String)genData[selectIndex[j]-1][0]+" Daily Profits"); double sum=0.0; for(int i=0; i<24; i++) { sum+=genProfitWithTrueCost[selectIndex[j]-1][i+3]; series.add(i, (double)(Math.round(sum*1000))/1000.0); } dataset.addSeries(series); */ series = new XYSeries((String) genData[selectIndex[j] - 1][0]); for (int i = 0; i < 24; i++) { if (bProfit) { series.add(i, (Math.round(genProfitWithTrueCost[selectIndex[j] - 1][i + 3] * 1000)) / 1000.0); } else { series.add(i, (Math.round(genProfitWithTrueCost[selectIndex[j] - 1][i + 27] * 1000)) / 1000.0); } } this.dataset.addSeries(series); /* series = new XYSeries((String)genData[selectIndex[j]-1][0]+" Daily Net Earnings"); sum=0.0; for(int i=0; i<24; i++) { sum+=genProfitWithTrueCost[selectIndex[j]-1][i+27]; series.add(i, (double)(Math.round(sum*1000))/1000.0); } dataset.addSeries(series); series = new XYSeries((String)genData[selectIndex[j]-1][0]+" Hourly Revenue"); for(int i=0; i<24; i++) { series.add(i, (double)(Math.round(genProfitWithTrueCost[selectIndex[j]-1][i+51]*1000))/1000.0); } dataset.addSeries(series); series = new XYSeries((String)genData[selectIndex[j]-1][0]+" Daily Revenue"); sum=0.0; for(int i=0; i<24; i++) { sum+=genProfitWithTrueCost[selectIndex[j]-1][i+51]; series.add(i, (double)(Math.round(sum*1000))/1000.0); } dataset.addSeries(series); */ } } // create the chart... this.chart = ChartFactory.createXYLineChart(this.chartTitle, // chart title "Hour", // x axis label "Money ($/H)", // y axis label this.dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... 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")); renderer.setToolTipGenerator(generator); plot.setRenderer(renderer); NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); xAxis.setRange(0, 23.5); this.chart.getTitle().setFont(this.font); this.chartPanel.setChart(this.chart); }
From source file:Output.SplitChart.java
public void drawGeneratorCommitmentData(String outputTimeTypeSelect, int iStartTime, int iEndTime, int iDayHour, int[] selectIndex) { String[] names = { " GenCo Name", "Day Index", " Hour", " Power (MW)", "CapRL (MW)", "CapRU (MW)" }; this.chartTitle = "GenCo Commitments"; String xLabel = ""; iStartTime = iStartTime - 1;//from w w w .j a v a2s. com iEndTime = iEndTime - 1; ArrayList genAgentCommitmentByDay = this.amesFrame.getAMESMarket().getGenAgentCommitmentByDay(); ArrayList hasSolutionByDay = this.amesFrame.getAMESMarket().getHasSolutionByDay(); int[] hasSolutions; this.dataset = new XYSeriesCollection(); Object[][] genData = this.amesFrame.getGeneratorData(); int iGenNumber = genData.length; if ((selectIndex.length < 1) || (selectIndex[0] == 0)) { if (outputTimeTypeSelect.equalsIgnoreCase("Entire Run (Selected Hour)")) { int iDayNumber = genAgentCommitmentByDay.size(); double[][] genCommitment; this.chartTitle = this.chartTitle + "\n " + "for Entire Run (At Hour " + iDayHour + ":00)"; xLabel = "Day"; XYSeries noSolutionSeries = new XYSeries("No solution"); this.dataset.addSeries(noSolutionSeries); boolean bNoSolution = false; for (int j = 0; j < iGenNumber; j++) { XYSeries series = new XYSeries((String) genData[j][0]); for (int iDay = 0; iDay < iDayNumber; iDay++) { hasSolutions = (int[]) hasSolutionByDay.get(iDay); genCommitment = (double[][]) genAgentCommitmentByDay.get(iDay); series.add(iDay + 2, (Math.round(genCommitment[iDayHour][j] * 1000)) / 1000.0); if (hasSolutions[iDayHour] == 0) { noSolutionSeries.add(iDay + 2, 0.0); bNoSolution = true; } } this.dataset.addSeries(series); } if (!bNoSolution) { this.dataset.removeSeries(noSolutionSeries); } } else if (outputTimeTypeSelect.equalsIgnoreCase("Start to End Day (Selected Hour)")) { int iDayNumber = (iEndTime - iStartTime) + 1; double[][] genCommitment; this.chartTitle = this.chartTitle + "\n " + "From Day " + (iStartTime + 1) + " to Day " + (iEndTime + 1) + " (At Hour " + iDayHour + ":00)"; xLabel = "Day"; XYSeries noSolutionSeries = new XYSeries("No solution"); this.dataset.addSeries(noSolutionSeries); boolean bNoSolution = false; for (int j = 0; j < iGenNumber; j++) { XYSeries series = new XYSeries((String) genData[j][0]); for (int iDay = iStartTime - 1; iDay < iEndTime; iDay++) { hasSolutions = (int[]) hasSolutionByDay.get(iDay); genCommitment = (double[][]) genAgentCommitmentByDay.get(iDay); series.add(iDay + 2, (Math.round(genCommitment[iDayHour][j] * 1000)) / 1000.0); if (hasSolutions[iDayHour] == 0) { noSolutionSeries.add(iDay + 2, 0.0); bNoSolution = true; } } this.dataset.addSeries(series); } if (!bNoSolution) { this.dataset.removeSeries(noSolutionSeries); } } else if (outputTimeTypeSelect.equalsIgnoreCase("Entire Run (All Hours)")) { int iDayNumber = genAgentCommitmentByDay.size(); double[][] genCommitment; this.chartTitle = this.chartTitle + "\n " + "for Entire Run"; xLabel = "Day"; XYSeries noSolutionSeries = new XYSeries("No solution"); this.dataset.addSeries(noSolutionSeries); boolean bNoSolution = false; for (int j = 0; j < iGenNumber; j++) { XYSeries series = new XYSeries((String) genData[j][0]); for (int iDay = 0; iDay < iDayNumber; iDay++) { hasSolutions = (int[]) hasSolutionByDay.get(iDay); genCommitment = (double[][]) genAgentCommitmentByDay.get(iDay); for (int i = 0; i < 24; i++) { series.add(iDay + 1 + (i / 24.0), (Math.round(genCommitment[i][j] * 1000)) / 1000.0); if (hasSolutions[i] == 0) { noSolutionSeries.add(iDay + 1 + (i / 24.0), 0.0); bNoSolution = true; } } } this.dataset.addSeries(series); } if (!bNoSolution) { this.dataset.removeSeries(noSolutionSeries); } } else if (outputTimeTypeSelect.equalsIgnoreCase("Start to End Day (All Hours)")) { int iDayNumber = (iEndTime - iStartTime) + 1; double[][] genCommitment; this.chartTitle = this.chartTitle + "\n " + "From Day " + (iStartTime + 1) + " to Day " + (iEndTime + 1) + " (All Hours)"; xLabel = "Day"; XYSeries noSolutionSeries = new XYSeries("No solution"); this.dataset.addSeries(noSolutionSeries); boolean bNoSolution = false; for (int j = 0; j < iGenNumber; j++) { XYSeries series = new XYSeries((String) genData[j][0]); for (int iDay = iStartTime - 1; iDay < iEndTime; iDay++) { genCommitment = (double[][]) genAgentCommitmentByDay.get(iDay); hasSolutions = (int[]) hasSolutionByDay.get(iDay); for (int i = 0; i < 24; i++) { series.add(iDay + 1 + (i / 24.0), (Math.round(genCommitment[i][j] * 1000)) / 1000.0); if (hasSolutions[i] == 0) { noSolutionSeries.add(iDay + 1 + (i / 24.0), 0.0); bNoSolution = true; } } } this.dataset.addSeries(series); if (!bNoSolution) { this.dataset.removeSeries(noSolutionSeries); } } } } else { int iDataNumber = selectIndex.length; int iField = names.length; if (outputTimeTypeSelect.equalsIgnoreCase("Entire Run (Selected Hour)")) { int iDayNumber = genAgentCommitmentByDay.size(); double[][] genCommitment; this.chartTitle = this.chartTitle + "\n " + "for Entire Run (At Hour " + iDayHour + ":00)"; xLabel = "Day"; XYSeries noSolutionSeries = new XYSeries("No solution"); this.dataset.addSeries(noSolutionSeries); boolean bNoSolution = false; for (int j = 0; j < iDataNumber; j++) { XYSeries series = new XYSeries((String) genData[selectIndex[j] - 1][0]); for (int iDay = 0; iDay < iDayNumber; iDay++) { hasSolutions = (int[]) hasSolutionByDay.get(iDay); genCommitment = (double[][]) genAgentCommitmentByDay.get(iDay); series.add(iDay + 1, (Math.round(genCommitment[iDayHour][selectIndex[j] - 1] * 1000)) / 1000.0); if (hasSolutions[iDayHour] == 0) { noSolutionSeries.add(iDay + 1, 0.0); bNoSolution = true; } } this.dataset.addSeries(series); } if (!bNoSolution) { this.dataset.removeSeries(noSolutionSeries); } } else if (outputTimeTypeSelect.equalsIgnoreCase("Start to End Day (Selected Hour)")) { int iDayNumber = (iEndTime - iStartTime) + 1; double[][] genCommitment; this.chartTitle = this.chartTitle + "\n " + "From Day " + (iStartTime + 1) + " to Day " + (iEndTime + 1) + " (At Hour " + iDayHour + ":00)"; xLabel = "Day"; XYSeries noSolutionSeries = new XYSeries("No solution"); this.dataset.addSeries(noSolutionSeries); boolean bNoSolution = false; for (int j = 0; j < iDataNumber; j++) { XYSeries series = new XYSeries((String) genData[selectIndex[j] - 1][0]); for (int iDay = iStartTime - 1; iDay < iEndTime; iDay++) { hasSolutions = (int[]) hasSolutionByDay.get(iDay); genCommitment = (double[][]) genAgentCommitmentByDay.get(iDay); series.add(iDay + 2, (Math.round(genCommitment[iDayHour][selectIndex[j] - 1] * 1000)) / 1000.0); if (hasSolutions[iDayHour] == 0) { noSolutionSeries.add(iDay + 2, 0.0); bNoSolution = true; } } this.dataset.addSeries(series); } if (!bNoSolution) { this.dataset.removeSeries(noSolutionSeries); } } else if (outputTimeTypeSelect.equalsIgnoreCase("Entire Run (All Hours)")) { int iDayNumber = genAgentCommitmentByDay.size(); double[][] genCommitment; this.chartTitle = this.chartTitle + "\n " + "for Entire Run"; xLabel = "Day"; XYSeries noSolutionSeries = new XYSeries("No solution"); this.dataset.addSeries(noSolutionSeries); boolean bNoSolution = false; for (int j = 0; j < iDataNumber; j++) { XYSeries series = new XYSeries((String) genData[selectIndex[j] - 1][0]); for (int iDay = 0; iDay < iDayNumber; iDay++) { hasSolutions = (int[]) hasSolutionByDay.get(iDay); genCommitment = (double[][]) genAgentCommitmentByDay.get(iDay); for (int i = 0; i < 24; i++) { series.add(iDay + 1 + (i / 24.0), (Math.round(genCommitment[i][selectIndex[j] - 1] * 1000)) / 1000.0); if (hasSolutions[i] == 0) { noSolutionSeries.add(iDay + 1 + (i / 24.0), 0.0); bNoSolution = true; } } } this.dataset.addSeries(series); } if (!bNoSolution) { this.dataset.removeSeries(noSolutionSeries); } } else if (outputTimeTypeSelect.equalsIgnoreCase("Start to End Day (All Hours)")) { int iDayNumber = (iEndTime - iStartTime) + 1; double[][] genCommitment; this.chartTitle = this.chartTitle + "\n " + "From Day " + (iStartTime + 1) + " to Day " + (iEndTime + 1) + " (All Hours)"; xLabel = "Day"; XYSeries noSolutionSeries = new XYSeries("No solution"); this.dataset.addSeries(noSolutionSeries); boolean bNoSolution = false; for (int j = 0; j < iDataNumber; j++) { XYSeries series = new XYSeries((String) genData[selectIndex[j] - 1][0]); for (int iDay = iStartTime - 1; iDay < iEndTime; iDay++) { hasSolutions = (int[]) hasSolutionByDay.get(iDay); genCommitment = (double[][]) genAgentCommitmentByDay.get(iDay); for (int i = 0; i < 24; i++) { series.add(iDay + 1 + (i / 24.0), (Math.round(genCommitment[i][selectIndex[j] - 1] * 1000)) / 1000.0); if (hasSolutions[i] == 0) { noSolutionSeries.add(iDay + 1 + (i / 24.0), 0.0); bNoSolution = true; } } } this.dataset.addSeries(series); } if (!bNoSolution) { this.dataset.removeSeries(noSolutionSeries); } } } // create the chart... this.chart = ChartFactory.createXYLineChart(this.chartTitle, // chart title xLabel, // x axis label "Power (MWs)", // 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")); renderer.setToolTipGenerator(generator); plot.setRenderer(renderer); NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); this.chart.getTitle().setFont(this.font); this.chartPanel.setChart(this.chart); }
From source file:Output.SplitChart.java
public void drawNodeLMPData(String outputTimeTypeSelect, int iStartTime, int iEndTime, int iDayHour, int[] selectIndex) { String[] names = { "Bus Name", "Day Index", " Hour", "LMP ($/MWh)" }; this.chartTitle = "Locational Marginal Price"; String xLabel = ""; iStartTime = iStartTime - 1;// w w w . j a v a 2 s.c om iEndTime = iEndTime - 1; ArrayList LMPByDay = this.amesFrame.getAMESMarket().getLMPByDay(); ArrayList hasSolutionByDay = this.amesFrame.getAMESMarket().getHasSolutionByDay(); int[] hasSolutions; String[] nodeName = this.amesFrame.getNodeNameData(); int iNodeNumber = nodeName.length; boolean draw3DChart = false; this.dataset = new XYSeriesCollection(); DefaultCategoryDataset dataset3D = new DefaultCategoryDataset(); if ((selectIndex.length < 1) || (selectIndex[0] == 0)) { if (outputTimeTypeSelect.equalsIgnoreCase("Entire Run (Selected Hour)")) { int iDayNumber = LMPByDay.size(); xLabel = "Day"; XYSeries noSolutionSeries = new XYSeries("No solution"); this.dataset.addSeries(noSolutionSeries); boolean bNoSolution = false; double[][] lmp; for (int j = 0; j < iNodeNumber; j++) { XYSeries series = new XYSeries(nodeName[j]); for (int iDay = 0; iDay < iDayNumber; iDay++) { hasSolutions = (int[]) hasSolutionByDay.get(iDay); lmp = (double[][]) LMPByDay.get(iDay); series.add(iDay + 2, (Math.round(lmp[iDayHour][j] * 1000)) / 1000.0); if (hasSolutions[iDayHour] == 0) { noSolutionSeries.add(iDay + 2, 0.0); bNoSolution = true; } } this.dataset.addSeries(series); } if (!bNoSolution) { this.dataset.removeSeries(noSolutionSeries); } this.chartTitle = this.chartTitle + "\n " + "for Entire Run (At Hour " + iDayHour + ":00)"; } else if (outputTimeTypeSelect.equalsIgnoreCase("Start to End Day (Selected Hour)")) { xLabel = "Day"; XYSeries noSolutionSeries = new XYSeries("No solution"); this.dataset.addSeries(noSolutionSeries); boolean bNoSolution = false; double[][] lmp; for (int j = 0; j < iNodeNumber; j++) { XYSeries series = new XYSeries(nodeName[j]); for (int iDay = iStartTime - 1; iDay < iEndTime; iDay++) { hasSolutions = (int[]) hasSolutionByDay.get(iDay); lmp = (double[][]) LMPByDay.get(iDay); series.add(iDay + 2, (Math.round(lmp[iDayHour][j] * 1000)) / 1000.0); if (hasSolutions[iDayHour] == 0) { noSolutionSeries.add(iDay + 2, 0.0); bNoSolution = true; } } this.dataset.addSeries(series); } if (!bNoSolution) { this.dataset.removeSeries(noSolutionSeries); } this.chartTitle = this.chartTitle + "\n " + "From Day " + (iStartTime + 1) + " to Day " + (iEndTime + 1) + " (At Hour " + iDayHour + ":00)"; } else if (outputTimeTypeSelect.equalsIgnoreCase("Entire Run (All Hours)")) { int iDayNumber = LMPByDay.size(); xLabel = "Day"; XYSeries noSolutionSeries = new XYSeries("No solution"); this.dataset.addSeries(noSolutionSeries); boolean bNoSolution = false; double[][] lmp; for (int j = 0; j < iNodeNumber; j++) { XYSeries series = new XYSeries(nodeName[j]); for (int iDay = 0; iDay < iDayNumber; iDay++) { hasSolutions = (int[]) hasSolutionByDay.get(iDay); lmp = (double[][]) LMPByDay.get(iDay); for (int i = 0; i < 24; i++) { series.add(iDay + 1 + (i / 24.0), (Math.round(lmp[i][j] * 1000)) / 1000.0); if (hasSolutions[i] == 0) { noSolutionSeries.add(iDay + 1 + (i / 24.0), 0.0); bNoSolution = true; } } } this.dataset.addSeries(series); } if (!bNoSolution) { this.dataset.removeSeries(noSolutionSeries); } this.chartTitle = this.chartTitle + "\n " + "for Entire Run (All Hours)"; } else if (outputTimeTypeSelect.equalsIgnoreCase("Start to End Day (All Hours)")) { xLabel = "Day"; XYSeries noSolutionSeries = new XYSeries("No solution"); this.dataset.addSeries(noSolutionSeries); boolean bNoSolution = false; double[][] lmp; for (int j = 0; j < iNodeNumber; j++) { XYSeries series = new XYSeries(nodeName[j]); for (int iDay = iStartTime - 1; iDay < iEndTime; iDay++) { hasSolutions = (int[]) hasSolutionByDay.get(iDay); lmp = (double[][]) LMPByDay.get(iDay); for (int i = 0; i < 24; i++) { series.add(iDay + 1 + (i / 24.0), (Math.round(lmp[i][j] * 1000)) / 1000.0); if (hasSolutions[i] == 0) { noSolutionSeries.add(iDay + 1 + (i / 24.0), 0.0); bNoSolution = true; } } } this.dataset.addSeries(series); } if (!bNoSolution) { this.dataset.removeSeries(noSolutionSeries); } this.chartTitle = this.chartTitle + "\n " + "From Day " + (iStartTime + 1) + " to Day " + (iEndTime + 1) + " (All Hours)"; } } else { int iDataNumber = selectIndex.length; if (outputTimeTypeSelect.equalsIgnoreCase("Entire Run (Selected Hour)")) { int iDayNumber = LMPByDay.size(); xLabel = "Day"; XYSeries noSolutionSeries = new XYSeries("No solution"); this.dataset.addSeries(noSolutionSeries); boolean bNoSolution = false; double[][] lmp; for (int j = 0; j < iDataNumber; j++) { XYSeries series = new XYSeries(nodeName[selectIndex[j] - 1]); for (int iDay = 0; iDay < iDayNumber; iDay++) { hasSolutions = (int[]) hasSolutionByDay.get(iDay); lmp = (double[][]) LMPByDay.get(iDay); series.add(iDay + 2, (Math.round(lmp[iDayHour][selectIndex[j] - 1] * 1000)) / 1000.0); if (hasSolutions[iDayHour] == 0) { noSolutionSeries.add(iDay + 2, 0.0); bNoSolution = true; } } this.dataset.addSeries(series); } if (!bNoSolution) { this.dataset.removeSeries(noSolutionSeries); } this.chartTitle = this.chartTitle + "\n " + "for Entire Run (At Hour " + iDayHour + ":00)"; } else if (outputTimeTypeSelect.equalsIgnoreCase("Start to End Day (Selected Hour)")) { xLabel = "Day"; XYSeries noSolutionSeries = new XYSeries("No solution"); this.dataset.addSeries(noSolutionSeries); boolean bNoSolution = false; double[][] lmp; for (int j = 0; j < iDataNumber; j++) { XYSeries series = new XYSeries(nodeName[selectIndex[j] - 1]); for (int iDay = iStartTime - 1; iDay < iEndTime; iDay++) { hasSolutions = (int[]) hasSolutionByDay.get(iDay); lmp = (double[][]) LMPByDay.get(iDay); series.add(iDay + 2, (Math.round(lmp[iDayHour][selectIndex[j] - 1] * 1000)) / 1000.0); if (hasSolutions[iDayHour] == 0) { noSolutionSeries.add(iDay + 2, 0.0); bNoSolution = true; } } this.dataset.addSeries(series); } if (!bNoSolution) { this.dataset.removeSeries(noSolutionSeries); } this.chartTitle = this.chartTitle + "\n " + "From Day " + (iStartTime + 1) + " to Day " + (iEndTime + 1) + " (At Hour " + iDayHour + ":00)"; } else if (outputTimeTypeSelect.equalsIgnoreCase("Entire Run (All Hours)")) { int iDayNumber = LMPByDay.size(); xLabel = "Day"; XYSeries noSolutionSeries = new XYSeries("No solution"); this.dataset.addSeries(noSolutionSeries); boolean bNoSolution = false; double[][] lmp; for (int j = 0; j < iDataNumber; j++) { XYSeries series = new XYSeries(nodeName[selectIndex[j] - 1]); for (int iDay = 0; iDay < iDayNumber; iDay++) { hasSolutions = (int[]) hasSolutionByDay.get(iDay); lmp = (double[][]) LMPByDay.get(iDay); for (int i = 0; i < 24; i++) { series.add(iDay + 1 + (i / 24.0), (Math.round(lmp[i][selectIndex[j] - 1] * 1000)) / 1000.0); if (hasSolutions[i] == 0) { noSolutionSeries.add(iDay + 1 + (i / 24.0), 0.0); bNoSolution = true; } } } this.dataset.addSeries(series); } if (!bNoSolution) { this.dataset.removeSeries(noSolutionSeries); } this.chartTitle = this.chartTitle + "\n " + "for Entire Run (All Hours)"; } else if (outputTimeTypeSelect.equalsIgnoreCase("Start to End Day (All Hours)")) { xLabel = "Day"; XYSeries noSolutionSeries = new XYSeries("No solution"); this.dataset.addSeries(noSolutionSeries); boolean bNoSolution = false; double[][] lmp; for (int j = 0; j < iDataNumber; j++) { XYSeries series = new XYSeries(nodeName[selectIndex[j] - 1]); for (int iDay = iStartTime - 1; iDay < iEndTime; iDay++) { hasSolutions = (int[]) hasSolutionByDay.get(iDay); lmp = (double[][]) LMPByDay.get(iDay); for (int i = 0; i < 24; i++) { series.add(iDay + 1 + (i / 24.0), (Math.round(lmp[i][selectIndex[j] - 1] * 1000)) / 1000.0); if (hasSolutions[i] == 0) { noSolutionSeries.add(iDay + 1 + (i / 24.0), 0.0); bNoSolution = true; } } } this.dataset.addSeries(series); } if (!bNoSolution) { this.dataset.removeSeries(noSolutionSeries); } this.chartTitle = this.chartTitle + "\n " + "From Day " + (iStartTime + 1) + " to Day " + (iEndTime + 1) + " (All Hours)"; } } // 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")); renderer.setToolTipGenerator(generator); plot.setRenderer(renderer); NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); this.chart.getTitle().setFont(this.font); this.chartPanel.setChart(this.chart); }