Example usage for org.jfree.chart.title TextTitle setText

List of usage examples for org.jfree.chart.title TextTitle setText

Introduction

In this page you can find the example usage for org.jfree.chart.title TextTitle setText.

Prototype

public void setText(String text) 

Source Link

Document

Sets the title to the specified text and sends a TitleChangeEvent to all registered listeners.

Usage

From source file:net.sf.jasperreports.components.spiderchart.FillSpiderChart.java

protected JFreeChart evaluateChart(byte evaluation) throws JRException {
    maxValue = (Double) fillContext.evaluate(getPlot().getMaxValueExpression(), evaluation);
    titleText = (String) fillContext.evaluate(getChartSettings().getTitleExpression(), evaluation);
    subtitleText = (String) fillContext.evaluate(getChartSettings().getSubtitleExpression(), evaluation);
    anchorName = (String) fillContext.evaluate(getChartSettings().getAnchorNameExpression(), evaluation);
    hyperlinkReference = (String) fillContext.evaluate(getChartSettings().getHyperlinkReferenceExpression(),
            evaluation);//  w ww. jav a  2s .c om
    hyperlinkAnchor = (String) fillContext.evaluate(getChartSettings().getHyperlinkAnchorExpression(),
            evaluation);
    hyperlinkPage = (Integer) fillContext.evaluate(getChartSettings().getHyperlinkPageExpression(), evaluation);
    hyperlinkTooltip = (String) fillContext.evaluate(getChartSettings().getHyperlinkTooltipExpression(),
            evaluation);
    hyperlinkParameters = JRFillHyperlinkHelper.evaluateHyperlinkParameters(getChartSettings(),
            expressionEvaluator, evaluation);

    dataset.evaluateDatasetRun(evaluation);
    dataset.finishDataset();

    chartHyperlinkProvider = new CategoryChartHyperlinkProvider(dataset.getItemHyperlinks());

    bookmarkLevel = getChartSettings().getBookmarkLevel();

    SpiderWebPlot spiderWebPlot = new SpiderWebPlot((DefaultCategoryDataset) dataset.getCustomDataset());

    if (getPlot().getAxisLineColor() != null) {
        spiderWebPlot.setAxisLinePaint(getPlot().getAxisLineColor());
    }
    if (getPlot().getAxisLineWidth() != null) {
        spiderWebPlot.setAxisLineStroke(new BasicStroke(getPlot().getAxisLineWidth()));
    }
    if (getPlot().getBackcolor() != null) {
        spiderWebPlot.setBackgroundPaint(getPlot().getBackcolor());
    }
    if (getPlot().getBackgroundAlpha() != null) {
        spiderWebPlot.setBackgroundAlpha(getPlot().getBackgroundAlpha());
    }
    if (getPlot().getForegroundAlpha() != null) {
        spiderWebPlot.setForegroundAlpha(getPlot().getForegroundAlpha());
    }
    if (getPlot().getHeadPercent() != null) {
        spiderWebPlot.setHeadPercent(getPlot().getHeadPercent());
    }
    if (getPlot().getInteriorGap() != null) {
        spiderWebPlot.setInteriorGap(getPlot().getInteriorGap());
    }
    if (getPlot().getLabelColor() != null) {
        spiderWebPlot.setLabelPaint(getPlot().getLabelColor());
    }
    if (getPlot().getLabelFont() != null) {
        spiderWebPlot.setLabelFont(JRFontUtil.getAwtFont(getPlot().getLabelFont(), Locale.getDefault()));
    }
    if (getPlot().getLabelGap() != null) {
        spiderWebPlot.setAxisLabelGap(getPlot().getLabelGap());
    }
    if (maxValue != null) {
        spiderWebPlot.setMaxValue(maxValue);
    }
    if (getPlot().getRotation() != null) {
        spiderWebPlot.setDirection(getPlot().getRotation().getRotation());
    }
    if (getPlot().getStartAngle() != null) {
        spiderWebPlot.setStartAngle(getPlot().getStartAngle());
    }
    if (getPlot().getTableOrder() != null) {
        spiderWebPlot.setDataExtractOrder(getPlot().getTableOrder().getOrder());
    }
    if (getPlot().getWebFilled() != null) {
        spiderWebPlot.setWebFilled(getPlot().getWebFilled());
    }

    spiderWebPlot.setToolTipGenerator(new StandardCategoryToolTipGenerator());
    spiderWebPlot.setLabelGenerator(new StandardCategoryItemLabelGenerator());

    Font titleFont = getChartSettings().getTitleFont() != null
            ? JRFontUtil.getAwtFont(getChartSettings().getTitleFont(), Locale.getDefault())
            : TextTitle.DEFAULT_FONT;

    JFreeChart jfreechart = new JFreeChart(titleText, titleFont, spiderWebPlot, true);

    if (chartSettings.getBackcolor() != null) {
        jfreechart.setBackgroundPaint(chartSettings.getBackcolor());
    }

    RectangleEdge titleEdge = getEdge(getChartSettings().getTitlePosition(), RectangleEdge.TOP);

    if (titleText != null) {
        TextTitle title = jfreechart.getTitle();
        title.setText(titleText);
        if (getChartSettings().getTitleColor() != null) {
            title.setPaint(getChartSettings().getTitleColor());
        }

        title.setFont(titleFont);
        title.setPosition(titleEdge);
        jfreechart.setTitle(title);
    }

    if (subtitleText != null) {
        TextTitle subtitle = new TextTitle(subtitleText);
        subtitle.setText(subtitleText);
        if (getChartSettings().getSubtitleColor() != null) {
            subtitle.setPaint(getChartSettings().getSubtitleColor());
        }

        if (getChartSettings().getSubtitleColor() != null) {
            Font subtitleFont = getChartSettings().getSubtitleFont() != null
                    ? JRFontUtil.getAwtFont(getChartSettings().getSubtitleFont(), Locale.getDefault())
                    : TextTitle.DEFAULT_FONT;
            subtitle.setFont(subtitleFont);
        }

        subtitle.setPosition(titleEdge);

        jfreechart.addSubtitle(subtitle);
    }

    // Apply all of the legend formatting options
    LegendTitle legend = jfreechart.getLegend();

    if (legend != null) {
        legend.setVisible((chartSettings.getShowLegend() == null || chartSettings.getShowLegend()));
        if (legend.isVisible()) {
            if (getChartSettings().getLegendColor() != null) {
                legend.setItemPaint(getChartSettings().getLegendColor());
            }
            if (getChartSettings().getLegendBackgroundColor() != null) {
                legend.setBackgroundPaint(getChartSettings().getLegendBackgroundColor());
            }

            if (getChartSettings().getLegendFont() != null) {
                legend.setItemFont(
                        JRFontUtil.getAwtFont(getChartSettings().getLegendFont(), Locale.getDefault()));
            }
            legend.setPosition(getEdge(getChartSettings().getLegendPosition(), RectangleEdge.BOTTOM));
        }
    }
    return jfreechart;

}

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   ww w  .  j  av a2 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.algotrader.client.chart.ChartTab.java

@SuppressWarnings("unchecked")
public void updateData(ChartDataVO chartData) {

    resetAxis();//from   ww  w.ja va2s  .c  o  m

    // add/update indicators
    for (IndicatorVO indicator : chartData.getIndicators()) {

        RegularTimePeriod timePeriod = getRegularTimePeriod(indicator.getDateTime());
        TimeSeries series = this.indicators.get(indicator.getName());

        if (series != null) {
            series.addOrUpdate(timePeriod, indicator.getValue());
        }
    }

    // add/update bars
    for (BarVO bar : chartData.getBars()) {

        OHLCSeries series = this.bars.get(bar.getSecurityId());

        if (series != null) {

            // remove a value if it already exists
            RegularTimePeriod timePeriod = getRegularTimePeriod(bar.getDateTime());
            if (series.indexOf(timePeriod) >= 0) {
                series.remove(timePeriod);
            }
            series.add(timePeriod, bar.getOpen().doubleValue(), bar.getHigh().doubleValue(),
                    bar.getLow().doubleValue(), bar.getClose().doubleValue());
        }
    }

    // make all invisible since they might not currently have a value
    for (Marker marker : this.markers.values()) {
        marker.setAlpha(0);
    }

    // update markers
    for (MarkerVO markerVO : chartData.getMarkers()) {

        Marker marker = this.markers.get(markerVO.getName());
        Boolean selected = this.markersSelectionStatus.get(markerVO.getName());
        String name = marker.getLabel().split(":")[0];
        if (marker instanceof ValueMarker && markerVO instanceof ValueMarkerVO) {

            ValueMarker valueMarker = (ValueMarker) marker;
            ValueMarkerVO valueMarkerVO = (ValueMarkerVO) markerVO;
            valueMarker.setValue(valueMarkerVO.getValue());
            marker.setLabel(name + ": " + valueMarkerVO.getValue());
            marker.setAlpha(selected ? 1.0f : 0.0f);

        } else if (marker instanceof IntervalMarker && markerVO instanceof IntervalMarkerVO) {

            IntervalMarker intervalMarker = (IntervalMarker) marker;
            IntervalMarkerVO intervalMarkerVO = (IntervalMarkerVO) markerVO;
            intervalMarker.setStartValue(intervalMarkerVO.getStartValue());
            intervalMarker.setEndValue(intervalMarkerVO.getEndValue());
            marker.setLabel(
                    name + ": " + intervalMarkerVO.getStartValue() + " - " + intervalMarkerVO.getEndValue());
            marker.setAlpha(selected ? 0.5f : 0.0f);

        } else {
            throw new RuntimeException(marker.getClass() + " does not match " + markerVO.getClass());
        }
    }

    // update annotations
    for (AnnotationVO annotationVO : chartData.getAnnotations()) {

        AbstractXYAnnotation annotation;
        if (annotationVO instanceof PointerAnnotationVO) {

            PointerAnnotationVO pointerAnnotationVO = (PointerAnnotationVO) annotationVO;
            XYPointerAnnotation pointerAnnotation = new XYPointerAnnotation(pointerAnnotationVO.getText(),
                    pointerAnnotationVO.getDateTime().getTime(), pointerAnnotationVO.getValue(),
                    3.926990816987241D);
            pointerAnnotation.setTipRadius(0);
            pointerAnnotation.setBaseRadius(20);
            pointerAnnotation.setTextAnchor(TextAnchor.BOTTOM_RIGHT);
            pointerAnnotation.setFont(new Font("SansSerif", 0, 9));
            pointerAnnotation.setToolTipText("<html>" + formatter.format(pointerAnnotationVO.getDateTime())
                    + "<br>" + pointerAnnotationVO.getValue() + "</html>");

            annotation = pointerAnnotation;

        } else if (annotationVO instanceof BoxAnnotationVO) {

            BoxAnnotationVO boxAnnotationVO = (BoxAnnotationVO) annotationVO;
            XYBoxAnnotation boxAnnotation = new XYBoxAnnotation(boxAnnotationVO.getStartDateTime().getTime(),
                    boxAnnotationVO.getStartValue(), boxAnnotationVO.getEndDateTime().getTime(),
                    boxAnnotationVO.getEndValue(), null, null, new java.awt.Color(0, 0, 0, 60));
            boxAnnotation.setToolTipText("<html>" + formatter.format(boxAnnotationVO.getStartDateTime()) + " - "
                    + formatter.format(boxAnnotationVO.getEndDateTime()) + "<br>"
                    + boxAnnotationVO.getStartValue() + " - " + boxAnnotationVO.getEndValue() + "</html>");

            annotation = boxAnnotation;
        } else {
            throw new RuntimeException("unkown annotation type" + annotationVO.getClass());
        }

        if (!getPlot().getAnnotations().contains(annotation)) {
            getPlot().addAnnotation(annotation);
        }
    }

    // update description
    for (Title title : (List<Title>) this.getChart().getSubtitles()) {
        if (title instanceof TextTitle) {
            TextTitle textTitle = ((TextTitle) title);
            if (chartData.getDescription() != null && !("".equals(chartData.getDescription()))) {
                textTitle.setText(chartData.getDescription());
                textTitle.setVisible(true);
            } else {
                textTitle.setVisible(false);
            }
        }
    }

    initAxis();
}

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;//from ww  w  . ja  va  2  s .  c o m
    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);
}