List of usage examples for org.jfree.chart.title TextTitle TextTitle
public TextTitle()
From source file:org.n52.io.measurement.img.ChartIoHandler.java
private void addNotice(JFreeChart chart) { TextTitle notice = new TextTitle(); String msg = i18n.get("msg.io.chart.notice"); if (msg != null && !msg.isEmpty()) { notice.setText(msg);/*from w w w . j av a2s . c om*/ notice.setPaint(BLACK); notice.setFont(FONT_LABEL_SMALL); notice.setPosition(RectangleEdge.BOTTOM); notice.setHorizontalAlignment(HorizontalAlignment.RIGHT); notice.setVerticalAlignment(VerticalAlignment.BOTTOM); notice.setPadding(new RectangleInsets(0, 0, 20, 20)); chart.addSubtitle(notice); } }
From source file:org.n52.io.type.quantity.handler.img.ChartIoHandler.java
private void addNotice(JFreeChart chart) { TextTitle notice = new TextTitle(); String msg = i18n.get("msg.io.chart.notice"); if (msg != null && !msg.isEmpty()) { notice.setText(msg);//from ww w . j a va2 s . co m notice.setPaint(Color.BLACK); notice.setFont(LabelConstants.FONT_LABEL_SMALL); notice.setPosition(RectangleEdge.BOTTOM); notice.setHorizontalAlignment(HorizontalAlignment.RIGHT); notice.setVerticalAlignment(VerticalAlignment.BOTTOM); notice.setPadding(new RectangleInsets(0, 0, 20, 20)); chart.addSubtitle(notice); } }
From source file:edu.jhuapl.graphs.jfreechart.JFreeChartCategoryGraphSource.java
@Override public void initialize() throws GraphException { String title = getParam(GraphSource.GRAPH_TITLE, String.class, DEFAULT_TITLE); String xLabel = getParam(GraphSource.GRAPH_X_LABEL, String.class, DEFAULT_DOMAIN_LABEL); String yLabel = getParam(GraphSource.GRAPH_Y_LABEL, String.class, DEFAULT_RANGE_LABEL); CategoryDataset dataset = makeDataSet(); chart = createChart(title, xLabel, yLabel, dataset, false, false); // start customizing the graph Paint backgroundColor = getParam(GraphSource.BACKGROUND_COLOR, Paint.class, DEFAULT_BACKGROUND_COLOR); Paint plotColor = getParam(JFreeChartTimeSeriesGraphSource.PLOT_COLOR, Paint.class, backgroundColor); Double offset = getParam(GraphSource.AXIS_OFFSET, Double.class, DEFAULT_AXIS_OFFSET); Paint graphDomainGridlinePaint = getParam(GraphSource.GRAPH_DOMAIN_GRIDLINE_PAINT, Paint.class, backgroundColor);//from w w w . ja v a2 s. c om Paint graphRangeGridlinePaint = getParam(GraphSource.GRAPH_RANGE_GRIDLINE_PAINT, Paint.class, backgroundColor); boolean graphBorder = getParam(GraphSource.GRAPH_BORDER, Boolean.class, DEFAULT_GRAPH_BORDER); chart.setBackgroundPaint(backgroundColor); CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(plotColor); plot.setAxisOffset(new RectangleInsets(offset, offset, offset, offset)); plot.setDomainGridlinePaint(graphDomainGridlinePaint); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(graphRangeGridlinePaint); plot.setOutlineVisible(graphBorder); // set the axis location AxisLocation axisLocation = getParam(GraphSource.GRAPH_RANGE_AXIS_LOCATION, AxisLocation.class, AxisLocation.TOP_OR_LEFT); plot.setRangeAxisLocation(axisLocation); // customize the y-axis if (params.get(RANGE_AXIS) instanceof ValueAxis) { ValueAxis valueAxis = (ValueAxis) params.get(RANGE_AXIS); plot.setRangeAxis(valueAxis); } ValueAxis valueAxis = plot.getRangeAxis(); Object yAxisFont = params.get(GraphSource.GRAPH_Y_AXIS_FONT); Object yAxisLabelFont = params.get(GraphSource.GRAPH_Y_AXIS_LABEL_FONT); Double rangeLowerBound = getParam(GraphSource.GRAPH_RANGE_LOWER_BOUND, Double.class, null); Double rangeUpperBound = getParam(GraphSource.GRAPH_RANGE_UPPER_BOUND, Double.class, null); boolean graphRangeIntegerTick = getParam(GraphSource.GRAPH_RANGE_INTEGER_TICK, Boolean.class, false); boolean graphRangeMinorTickVisible = getParam(GraphSource.GRAPH_RANGE_MINOR_TICK_VISIBLE, Boolean.class, true); if (yAxisFont instanceof Font) { valueAxis.setTickLabelFont((Font) yAxisFont); } if (yAxisLabelFont instanceof Font) { valueAxis.setLabelFont((Font) yAxisLabelFont); } if (rangeLowerBound != null) { valueAxis.setLowerBound(rangeLowerBound); } if (rangeUpperBound != null) { valueAxis.setUpperBound(rangeUpperBound); } if (graphRangeIntegerTick) { valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); } valueAxis.setMinorTickMarksVisible(graphRangeMinorTickVisible); // customize the x-axis if (params.get(DOMAIN_AXIS) instanceof CategoryAxis) { CategoryAxis domainAxis = (CategoryAxis) params.get(DOMAIN_AXIS); plot.setDomainAxis(domainAxis); } CategoryAxis domainAxis = plot.getDomainAxis(); Object xAxisFont = params.get(GraphSource.GRAPH_X_AXIS_FONT); Object xAxisLabelFont = params.get(GraphSource.GRAPH_X_AXIS_LABEL_FONT); if (xAxisFont instanceof Font) { domainAxis.setTickLabelFont((Font) xAxisFont); } if (xAxisLabelFont instanceof Font) { domainAxis.setLabelFont((Font) xAxisLabelFont); } domainAxis.setLabel(xLabel); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); plot.setDomainAxis(domainAxis); // change the font of the graph title Font titleFont = getParam(GraphSource.GRAPH_FONT, Font.class, DEFAULT_GRAPH_TITLE_FONT); TextTitle textTitle = new TextTitle(); textTitle.setText(title); textTitle.setFont(titleFont); chart.setTitle(textTitle); // makes a wrapper for the legend to remove the border around it boolean legend = getParam(GraphSource.GRAPH_LEGEND, Boolean.class, DEFAULT_GRAPH_LEGEND); boolean legendBorder = getParam(GraphSource.LEGEND_BORDER, Boolean.class, DEFAULT_LEGEND_BORDER); Object legendFont = params.get(GraphSource.LEGEND_FONT); if (legend) { LegendTitle legendTitle = new LegendTitle(chart.getPlot()); BlockContainer wrapper = new BlockContainer(new BorderArrangement()); if (legendBorder) { wrapper.setFrame(new BlockBorder(1, 1, 1, 1)); } else { wrapper.setFrame(new BlockBorder(0, 0, 0, 0)); } BlockContainer items = legendTitle.getItemContainer(); items.setPadding(2, 10, 5, 2); wrapper.add(items); legendTitle.setWrapper(wrapper); legendTitle.setPosition(RectangleEdge.BOTTOM); legendTitle.setHorizontalAlignment(HorizontalAlignment.CENTER); if (legendFont instanceof Font) { legendTitle.setItemFont((Font) legendFont); } chart.addSubtitle(legendTitle); } this.initialized = true; }
From source file:ch.algotrader.client.chart.ChartTab.java
public void init(ChartDefinitionVO chartDefinition) { // remove all components first this.removeAll(); resetPopupMenu();//from w ww .j a v a2s. c om this.chartDefinition = chartDefinition; // create the plot XYPlot plot = new XYPlot(); // add gridlines plot.setDomainGridlinesVisible(true); plot.setRangeGridlinesVisible(true); // create the JFreeChart JFreeChart chart = new JFreeChart(plot); this.setChart(chart); // init the maps this.bars = new HashMap<>(); this.indicators = new HashMap<>(); this.markers = new HashMap<>(); this.markersSelectionStatus = new HashMap<>(); // init domain axis initDomainAxis(chartDefinition); // init range axis initRangeAxis(chartDefinition); // create a subtitle TextTitle title = new TextTitle(); title.setFont(new Font("SansSerif", 0, 9)); chart.addSubtitle(title); // crosshair plot.setDomainCrosshairVisible(true); plot.setDomainCrosshairLockedOnData(true); plot.setRangeCrosshairVisible(true); plot.setDomainCrosshairLockedOnData(true); }
From source file:edu.jhuapl.graphs.jfreechart.JFreeChartTimeSeriesGraphSource.java
/** * Initializes the graph. This method generates the backing {@link JFreeChart} from the time series and graph * parameter data.//from w ww . jav a 2 s .co m * * @throws GraphException if the initialization fails */ public void initialize() throws GraphException { String title = getParam(GraphSource.GRAPH_TITLE, String.class, DEFAULT_TITLE); String xLabel = getParam(GraphSource.GRAPH_X_LABEL, String.class, DEFAULT_DOMAIN_LABEL); String yLabel = getParam(GraphSource.GRAPH_Y_LABEL, String.class, DEFAULT_RANGE_LABEL); Shape graphShape = getParam(GraphSource.GRAPH_SHAPE, Shape.class, DEFAULT_GRAPH_SHAPE); Paint graphColor = getParam(GraphSource.GRAPH_COLOR, Paint.class, DEFAULT_GRAPH_COLOR); boolean legend = getParam(GraphSource.GRAPH_LEGEND, Boolean.class, DEFAULT_GRAPH_LEGEND); boolean graphToolTip = getParam(GraphSource.GRAPH_TOOL_TIP, Boolean.class, DEFAULT_GRAPH_TOOL_TIP); Stroke graphStroke = getParam(GraphSource.GRAPH_STROKE, Stroke.class, DEFAULT_GRAPH_STROKE); Font titleFont = getParam(GraphSource.GRAPH_FONT, Font.class, DEFAULT_GRAPH_TITLE_FONT); boolean graphBorder = getParam(GraphSource.GRAPH_BORDER, Boolean.class, DEFAULT_GRAPH_BORDER); boolean legendBorder = getParam(GraphSource.LEGEND_BORDER, Boolean.class, DEFAULT_LEGEND_BORDER); Double offset = getParam(GraphSource.AXIS_OFFSET, Double.class, DEFAULT_AXIS_OFFSET); checkSeriesType(data); @SuppressWarnings("unchecked") List<? extends TimeSeriesInterface> timeData = (List<? extends TimeSeriesInterface>) data; TimeSeriesCollection dataset = new TimeSeriesCollection(); int seriesCount = 1; for (TimeSeriesInterface series : timeData) { dataset.addSeries(buildTimeSeries(series, seriesCount)); seriesCount += 1; } // actually create the chart this.chart = ChartFactory.createTimeSeriesChart(title, xLabel, yLabel, dataset, false, graphToolTip, false); // start customizing it Paint backgroundColor = getParam(GraphSource.BACKGROUND_COLOR, Paint.class, DEFAULT_BACKGROUND_COLOR); Paint plotColor = getParam(JFreeChartTimeSeriesGraphSource.PLOT_COLOR, Paint.class, backgroundColor); Paint graphDomainGridlinePaint = getParam(GraphSource.GRAPH_DOMAIN_GRIDLINE_PAINT, Paint.class, backgroundColor); Paint graphRangeGridlinePaint = getParam(GraphSource.GRAPH_RANGE_GRIDLINE_PAINT, Paint.class, backgroundColor); this.chart.setBackgroundPaint(backgroundColor); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(plotColor); plot.setAxisOffset(new RectangleInsets(offset, offset, offset, offset)); plot.setDomainGridlinePaint(graphDomainGridlinePaint); plot.setRangeGridlinePaint(graphRangeGridlinePaint); if (graphBorder) { } else { plot.setOutlinePaint(null); } //Use a TextTitle to change the font of the graph title TextTitle title1 = new TextTitle(); title1.setText(title); title1.setFont(titleFont); chart.setTitle(title1); //Makes a wrapper for the legend to remove the border around it if (legend) { LegendTitle legend1 = new LegendTitle(chart.getPlot()); BlockContainer wrapper = new BlockContainer(new BorderArrangement()); if (legendBorder) { wrapper.setFrame(new BlockBorder(1, 1, 1, 1)); } else { wrapper.setFrame(new BlockBorder(0, 0, 0, 0)); } BlockContainer items = legend1.getItemContainer(); items.setPadding(2, 10, 5, 2); wrapper.add(items); legend1.setWrapper(wrapper); legend1.setPosition(RectangleEdge.BOTTOM); legend1.setHorizontalAlignment(HorizontalAlignment.CENTER); if (params.get(GraphSource.LEGEND_FONT) instanceof Font) { legend1.setItemFont(((Font) params.get(GraphSource.LEGEND_FONT))); } chart.addSubtitle(legend1); } boolean include0 = getParam(GraphSource.GRAPH_RANGE_INCLUDE_0, Boolean.class, true); NumberAxis numAxis = (NumberAxis) plot.getRangeAxis(); double rangeLower = getParam(GraphSource.GRAPH_RANGE_LOWER_BOUND, Double.class, numAxis.getLowerBound()); double rangeUpper = getParam(GraphSource.GRAPH_RANGE_UPPER_BOUND, Double.class, numAxis.getUpperBound()); boolean graphRangeIntegerTick = getParam(GraphSource.GRAPH_RANGE_INTEGER_TICK, Boolean.class, false); boolean graphRangeMinorTickVisible = getParam(GraphSource.GRAPH_RANGE_MINOR_TICK_VISIBLE, Boolean.class, true); if (include0) { rangeLower = 0; } numAxis.setRange(rangeLower, rangeUpper); if (graphRangeIntegerTick) { numAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); } numAxis.setMinorTickMarksVisible(graphRangeMinorTickVisible); setupFont(numAxis, GraphSource.GRAPH_Y_AXIS_FONT); if (params.get(GraphSource.GRAPH_Y_AXIS_LABEL_FONT) instanceof Font) { numAxis.setLabelFont(((Font) params.get(GraphSource.GRAPH_Y_AXIS_LABEL_FONT))); } TimeResolution minimumResolution = getMinimumResolution(timeData); DateFormat dateFormat = getParam(GraphSource.GRAPH_DATE_FORMATTER, DateFormat.class, new DefaultDateFormatFactory().getFormat(minimumResolution)); if (params.get(DATE_AXIS) instanceof DateAxis) { DateAxis dateAxis = (DateAxis) params.get(DATE_AXIS); dateAxis.setLabel(xLabel); plot.setDomainAxis(dateAxis); } DateAxis dateAxis = ((DateAxis) plot.getDomainAxis()); dateAxis.setDateFormatOverride(dateFormat); if (params.get(GraphSource.GRAPH_X_AXIS_LABEL_FONT) instanceof Font) { dateAxis.setLabelFont(((Font) params.get(GraphSource.GRAPH_X_AXIS_LABEL_FONT))); } int minTick = getParam(GraphSource.GRAPH_MIN_DOMAIN_TICK, Integer.class, 1); if (minTick <= 0) { minTick = 1; } dateAxis.setTickUnit(getDateTickUnit(minimumResolution, minTick), false, false); //dateAxis.setMinorTickMarksVisible(true); //dateAxis.setMinorTickCount(7); dateAxis.setMinorTickMarkOutsideLength(2); Integer minorTick = getParam(GraphSource.GRAPH_MINOR_TICKS, Integer.class, null); if (minorTick != null) { int minorVal = minorTick; if (minorVal > 0) { dateAxis.setMinorTickCount(minorVal); } } setupFont(dateAxis, GraphSource.GRAPH_X_AXIS_FONT); //double lowerMargin = getParam(DOMAIN_AXIS_LOWER_MARGIN, Double.class, DEFAULT_DOMAIN_AXIS_LOWER_MARGIN); double lowerMargin = getParam(DOMAIN_AXIS_LOWER_MARGIN, Double.class, DEFAULT_DOMAIN_AXIS_LOWER_MARGIN); dateAxis.setLowerMargin(lowerMargin); //double upperMargin = getParam(DOMAIN_AXIS_UPPER_MARGIN, Double.class, DEFAULT_DOMAIN_AXIS_UPPER_MARGIN); double upperMargin = getParam(DOMAIN_AXIS_UPPER_MARGIN, Double.class, DEFAULT_DOMAIN_AXIS_UPPER_MARGIN); dateAxis.setUpperMargin(upperMargin); Date domainLower = getParam(GraphSource.GRAPH_DOMAIN_LOWER_BOUND, Date.class, dateAxis.getMinimumDate()); Date domainUpper = getParam(GraphSource.GRAPH_DOMAIN_UPPER_BOUND, Date.class, dateAxis.getMaximumDate()); dateAxis.setRange(domainLower, domainUpper); // depending on the domain axis range, display either 1 tick per day, week, month or year TickUnits standardUnits = new TickUnits(); standardUnits.add(new DateTickUnit(DateTickUnitType.DAY, 1)); standardUnits.add(new DateTickUnit(DateTickUnitType.DAY, 7)); standardUnits.add(new DateTickUnit(DateTickUnitType.MONTH, 1)); standardUnits.add(new DateTickUnit(DateTickUnitType.YEAR, 1)); dateAxis.setStandardTickUnits(standardUnits); TimeSeriesRenderer renderer = new TimeSeriesRenderer(dataset); setupRenderer(renderer, graphColor, graphShape, graphStroke); renderer.setBaseFillPaint(Color.BLACK); renderer.setSeriesOutlinePaint(0, Color.WHITE); //renderer.setUseOutlinePaint(true); plot.setRenderer(renderer); this.initialized = true; }
From source file:ch.zhaw.simulation.diagram.charteditor.DefaultTitleEditor.java
/** * Sets the properties of the specified title to match the properties * defined on this panel./*from w w w . j a va2 s . c om*/ * * @param chart * the chart whose title is to be modified. */ public void setTitleProperties(JFreeChart chart) { TextTitle title = chart.getTitle(); if (title == null) { title = new TextTitle(); chart.setTitle(title); } title.setText(getTitleText()); title.setFont(getTitleFont()); title.setPaint(getTitlePaint()); title.setVisible(this.showTitle); }
From source file:com.rcp.wbw.demo.editor.SWTTitleEditor.java
/** * Sets the properties of the specified title to match the properties * defined on this panel./*from w ww . ja v a2 s. c om*/ * * @param chart * the chart whose title is to be modified. */ public void setTitleProperties(JFreeChart chart) { if (this.showTitle) { TextTitle title = chart.getTitle(); if (title == null) { title = new TextTitle(); chart.setTitle(title); } title.setText(getTitleText()); title.setFont(SWTUtils.toAwtFont(getDisplay(), getTitleFont(), true)); title.setPaint(SWTUtils.toAwtColor(getTitleColor())); } else { chart.setTitle((TextTitle) null); } }
From source file:com.bdaum.zoom.report.internal.wizards.ReportComponent.java
private static void applyProperties(JFreeChart chart, Map<String, Object> properties) { if (properties != null) { String text = (String) properties.get(TITLE); if (text != null) { TextTitle title = chart.getTitle(); if (title == null) { title = new TextTitle(); chart.setTitle(title);/* ww w . j a va2s .c o m*/ } title.setText(text); Font titleFont = (Font) properties.get(TITLEFONT); if (titleFont != null) title.setFont(titleFont); Paint paint = (Paint) properties.get(TITLECOLOR); if (paint != null) title.setPaint(paint); } else chart.setTitle((TextTitle) null); Plot plot = chart.getPlot(); Paint paint = (Paint) properties.get(BGCOLOR); if (paint != null) plot.setBackgroundPaint(paint); paint = (Color) properties.get(OUTLINEPAINT); if (paint != null) plot.setOutlinePaint(paint); Stroke stroke = (Stroke) properties.get(OUTLINESTROKE); if (stroke != null) plot.setOutlineStroke(stroke); PlotOrientation orientation = (PlotOrientation) properties.get(ORIENTATION); Axis domainAxis = null; Axis rangeAxis = null; if (plot instanceof CategoryPlot) { CategoryPlot p = (CategoryPlot) plot; domainAxis = p.getDomainAxis(); rangeAxis = p.getRangeAxis(); if (orientation != null) p.setOrientation(orientation); } else if (plot instanceof XYPlot) { XYPlot p = (XYPlot) plot; domainAxis = p.getDomainAxis(); rangeAxis = p.getRangeAxis(); if (orientation != null) p.setOrientation(orientation); } if (domainAxis != null) applyAxisProperties(domainAxis, "x", properties); //$NON-NLS-1$ if (rangeAxis != null) applyAxisProperties(rangeAxis, "y", properties); //$NON-NLS-1$ Boolean anti = (Boolean) properties.get(ANTIALIAS); if (anti != null) chart.setAntiAlias(anti); paint = (Paint) properties.get(CANVASPAINT); if (paint != null) chart.setBackgroundPaint(paint); } }
From source file:Output.SplitChart.java
public void drawBranchPowerFlowData(String outputTimeTypeSelect, int iStartTime, int iEndTime, int iDayHour, int[] selectIndex) { String[] names = { "Branch Name", "Day Index", "Hour", "Power (MW)", "MaxCap (MW)" }; this.chartTitle = "Branch Power Flows"; boolean bSubtitle = false; String subtitles = ""; String xLabel = ""; iStartTime = iStartTime - 1;// ww w .ja v a 2 s . com iEndTime = iEndTime - 1; ArrayList branchFlowByDay = this.amesFrame.getAMESMarket().getBranchFlowByDay(); ArrayList hasSolutionByDay = this.amesFrame.getAMESMarket().getHasSolutionByDay(); int[] hasSolutions; Object[][] branchData = this.amesFrame.getBranchData(); int iBranchNumber = branchData.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)")) { this.chartTitle = this.chartTitle + "\n " + "For Entire Run (At Hour " + iDayHour + ":00)\n"; xLabel = "Day"; XYSeries noSolutionSeries = new XYSeries("No solution"); this.dataset.addSeries(noSolutionSeries); boolean bNoSolution = false; int iDayNumber = branchFlowByDay.size(); double[][] branchFlow; for (int j = 0; j < iBranchNumber; j++) { XYSeries series = new XYSeries((String) branchData[j][0]); for (int iDay = 0; iDay < iDayNumber; iDay++) { branchFlow = (double[][]) branchFlowByDay.get(iDay); hasSolutions = (int[]) hasSolutionByDay.get(iDay); series.add(iDay + 2, (Math.round(branchFlow[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; XYSeries noSolutionSeries = new XYSeries("No solution"); this.dataset.addSeries(noSolutionSeries); boolean bNoSolution = false; double[][] branchFlow; for (int j = 0; j < iBranchNumber; j++) { XYSeries series = new XYSeries((String) branchData[j][0]); for (int iDay = iStartTime - 1; iDay < iEndTime; iDay++) { branchFlow = (double[][]) branchFlowByDay.get(iDay); hasSolutions = (int[]) hasSolutionByDay.get(iDay); series.add(iDay + 2, (Math.round(branchFlow[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)"; xLabel = "Day"; } else if (outputTimeTypeSelect.equalsIgnoreCase("Entire Run (All Hours)")) { int iDayNumber = branchFlowByDay.size(); XYSeries noSolutionSeries = new XYSeries("No solution"); this.dataset.addSeries(noSolutionSeries); boolean bNoSolution = false; double[][] branchFlow; for (int j = 0; j < iBranchNumber; j++) { XYSeries series = new XYSeries((String) branchData[j][0]); for (int iDay = 0; iDay < iDayNumber; iDay++) { hasSolutions = (int[]) hasSolutionByDay.get(iDay); branchFlow = (double[][]) branchFlowByDay.get(iDay); for (int i = 0; i < 24; i++) { series.add(iDay + 1 + (i / 24.0), (Math.round(branchFlow[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)"; xLabel = "Day"; } else if (outputTimeTypeSelect.equalsIgnoreCase("Start to End Day (All Hours)")) { int iDayNumber = (iEndTime - iStartTime) + 1; XYSeries noSolutionSeries = new XYSeries("No solution"); this.dataset.addSeries(noSolutionSeries); boolean bNoSolution = false; double[][] branchFlow; for (int j = 0; j < iBranchNumber; j++) { XYSeries series = new XYSeries((String) branchData[j][0]); for (int iDay = iStartTime - 1; iDay < iEndTime; iDay++) { hasSolutions = (int[]) hasSolutionByDay.get(iDay); branchFlow = (double[][]) branchFlowByDay.get(iDay); for (int i = 0; i < 24; i++) { series.add(iDay + 1 + (i / 24.0), (Math.round(branchFlow[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)"; xLabel = "Day"; } } else { int iDataNumber = selectIndex.length; if (iDataNumber == 1) { bSubtitle = true; } int iField = names.length; if (outputTimeTypeSelect.equalsIgnoreCase("Entire Run (Selected Hour)")) { XYSeries noSolutionSeries = new XYSeries("No solution"); this.dataset.addSeries(noSolutionSeries); boolean bNoSolution = false; int iDayNumber = branchFlowByDay.size(); double[][] branchFlow; for (int j = 0; j < iDataNumber; j++) { XYSeries series = new XYSeries((String) branchData[selectIndex[j] - 1][0]); subtitles += branchData[selectIndex[j] - 1][0] + " Thermal Limit: " + branchData[selectIndex[j] - 1][3].toString() + "\n"; for (int iDay = 0; iDay < iDayNumber; iDay++) { hasSolutions = (int[]) hasSolutionByDay.get(iDay); branchFlow = (double[][]) branchFlowByDay.get(iDay); series.add(iDay + 2, (Math.round(branchFlow[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)"; xLabel = "Day"; } else if (outputTimeTypeSelect.equalsIgnoreCase("Start to End Day (Selected Hour)")) { XYSeries noSolutionSeries = new XYSeries("No solution"); this.dataset.addSeries(noSolutionSeries); boolean bNoSolution = false; int iDayNumber = (iEndTime - iStartTime) + 1; double[][] branchFlow; for (int j = 0; j < iDataNumber; j++) { XYSeries series = new XYSeries((String) branchData[selectIndex[j] - 1][0]); subtitles += branchData[selectIndex[j] - 1][0] + " Thermal Limit: " + branchData[selectIndex[j] - 1][3].toString() + "\n"; for (int iDay = iStartTime - 1; iDay < iEndTime; iDay++) { hasSolutions = (int[]) hasSolutionByDay.get(iDay); branchFlow = (double[][]) branchFlowByDay.get(iDay); series.add(iDay + 2, (Math.round(branchFlow[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)"; xLabel = "Day"; } else if (outputTimeTypeSelect.equalsIgnoreCase("Entire Run (All Hours)")) { XYSeries noSolutionSeries = new XYSeries("No solution"); this.dataset.addSeries(noSolutionSeries); boolean bNoSolution = false; int iDayNumber = branchFlowByDay.size(); double[][] branchFlow; for (int j = 0; j < iDataNumber; j++) { XYSeries series = new XYSeries((String) branchData[selectIndex[j] - 1][0]); subtitles += branchData[selectIndex[j] - 1][0] + " Thermal Limit: " + branchData[selectIndex[j] - 1][3].toString() + "\n"; for (int iDay = 0; iDay < iDayNumber; iDay++) { hasSolutions = (int[]) hasSolutionByDay.get(iDay); branchFlow = (double[][]) branchFlowByDay.get(iDay); for (int i = 0; i < 24; i++) { series.add(iDay + 1 + (i / 24.0), (Math.round(branchFlow[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)"; xLabel = "Day"; } else if (outputTimeTypeSelect.equalsIgnoreCase("Start to End Day (All Hours)")) { XYSeries noSolutionSeries = new XYSeries("No solution"); this.dataset.addSeries(noSolutionSeries); boolean bNoSolution = false; int iDayNumber = (iEndTime - iStartTime) + 1; double[][] branchFlow; for (int j = 0; j < iDataNumber; j++) { XYSeries series = new XYSeries((String) branchData[selectIndex[j] - 1][0]); subtitles += branchData[selectIndex[j] - 1][0] + " Thermal Limit: " + branchData[selectIndex[j] - 1][3].toString() + "\n"; for (int iDay = iStartTime - 1; iDay < iEndTime; iDay++) { hasSolutions = (int[]) hasSolutionByDay.get(iDay); branchFlow = (double[][]) branchFlowByDay.get(iDay); for (int i = 0; i < 24; i++) { series.add(iDay + 1 + (i / 24.0), (Math.round(branchFlow[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)"; xLabel = "Day"; } } // 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 ); if (bSubtitle) { TextTitle subTitle = new TextTitle(); subTitle.setText(subtitles); this.chart.addSubtitle(subTitle); } // 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()); this.chart.getTitle().setFont(this.font); this.chartPanel.setChart(this.chart); }