Example usage for org.jfree.chart.plot XYPlot clearAnnotations

List of usage examples for org.jfree.chart.plot XYPlot clearAnnotations

Introduction

In this page you can find the example usage for org.jfree.chart.plot XYPlot clearAnnotations.

Prototype

public void clearAnnotations() 

Source Link

Document

Clears all the annotations and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:com.bdb.weather.display.day.DayHumidityPane.java

@Override
protected void addAnnotations(XYPlot plot, SummaryRecord summaryRecord) {
    plot.clearAnnotations();

    if (summaryRecord == null)
        return;//from   ww  w .ja v  a  2s  .  c  o  m

    LocalDateTime highTime = summaryRecord.getMaxOutdoorHumidityTime();
    Humidity highHumidity = summaryRecord.getMaxOutdoorHumidity();
    LocalDateTime lowTime = summaryRecord.getMinOutdoorHumidityTime();
    Humidity lowHumidity = summaryRecord.getMinOutdoorHumidity();

    if (highTime == null || highHumidity == null || lowTime == null || lowHumidity == null)
        return;

    String highAnnotation = highHumidity.toString() + Humidity.Unit.RELATIVE_HUMIDITY + " "
            + DisplayConstants.formatTime(highTime.toLocalTime());
    String lowAnnotation = lowHumidity.toString() + Humidity.Unit.RELATIVE_HUMIDITY + " "
            + DisplayConstants.formatTime(lowTime.toLocalTime());

    XYTextAnnotation a = new XYTextAnnotation(highAnnotation, TimeUtils.localDateTimeToEpochMillis(highTime),
            highHumidity.get());
    a.setTextAnchor(TextAnchor.BASELINE_CENTER);
    plot.addAnnotation(a);

    a = new XYTextAnnotation(lowAnnotation, TimeUtils.localDateTimeToEpochMillis(lowTime), lowHumidity.get());
    a.setTextAnchor(TextAnchor.TOP_CENTER);
    plot.addAnnotation(a);
}

From source file:com.bdb.weather.display.day.DayWindPane.java

@Override
protected void addAnnotations(XYPlot plot, SummaryRecord summaryRecord) {
    plot.clearAnnotations();
    if (summaryRecord == null)
        return;//from w w w  .ja va 2  s.  c o m

    LocalDateTime maxSpeedTime = summaryRecord.getMaxWindSpeedTime();
    if (maxSpeedTime != null) {
        double maxSpeed = summaryRecord.getMaxWindSpeed().get();

        String maxSpeedAnnotation = Speed.getDefaultFormatter().format(maxSpeed) + Speed.getDefaultUnit() + " "
                + DisplayConstants.formatTime(maxSpeedTime.toLocalTime());

        XYTextAnnotation a = new XYTextAnnotation(maxSpeedAnnotation,
                (double) TimeUtils.localDateTimeToEpochMillis(maxSpeedTime), maxSpeed);
        a.setTextAnchor(TextAnchor.BASELINE_CENTER);
        plot.addAnnotation(a);
    }
}

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

public ChartPanel get_ChartPanel(int width, int height) {
    chr = new ChartPanel(chart);
    chr.setBackground(Color.blue);

    chr.setBounds(5, 5, width - 5, height - 10);
    chr.setVisible(true);/*from  w  w  w  . j  av  a2  s. c o m*/
    chr.setMouseWheelEnabled(true);
    chr.addChartMouseListener(new ChartMouseListener() {

        public void chartMouseMoved(ChartMouseEvent chartmouseevent) {

        }

        public void chartMouseClicked(ChartMouseEvent chartmouseevent) {

            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    XYPlot xyplot = (XYPlot) chr.getChart().getPlot();
                    xyplot.clearAnnotations();
                    double x, y;
                    x = new BigDecimal(xyplot.getDomainCrosshairValue()).setScale(3, RoundingMode.UP)
                            .doubleValue();

                    y = new BigDecimal(xyplot.getRangeCrosshairValue()).setScale(3, RoundingMode.UP)
                            .doubleValue();
                    XYTextAnnotation annotation = new XYTextAnnotation("(" + x + ", " + y + ")",
                            new BigDecimal(x).setScale(3, RoundingMode.UP).doubleValue(), y);
                    annotation.setFont(new Font("serif", Font.BOLD, 15));
                    annotation.setTextAnchor(TextAnchor.BOTTOM_CENTER);
                    xyplot.addAnnotation(annotation);
                }
            });
        }
    });

    return chr;
}

From source file:com.bdb.weather.display.day.DayTemperaturePane.java

@Override
public void addAnnotations(XYPlot plot, SummaryRecord summaryRecord) {
    plot.clearAnnotations();
    summary = summaryRecord;//from  w  ww  . j  ava 2  s .com
    if (summaryRecord == null)
        return;

    LocalDateTime highTime = summaryRecord.getMaxOutdoorTempTime();
    Temperature outdoorHighTemp = summaryRecord.getMaxOutdoorTemp();
    LocalDateTime lowTime = summaryRecord.getMinOutdoorTempTime();
    Temperature outdoorLowTemp = summaryRecord.getMinOutdoorTemp();

    if (highTime == null || outdoorHighTemp == null || lowTime == null || outdoorLowTemp == null)
        return;

    String highAnnotation = outdoorHighTemp.toString() + " " + Temperature.getDefaultUnit() + " "
            + DisplayConstants.formatTime(highTime.toLocalTime());
    String lowAnnotation = outdoorLowTemp.toString() + " " + Temperature.getDefaultUnit() + " "
            + DisplayConstants.formatTime(lowTime.toLocalTime());

    XYTextAnnotation a = new XYTextAnnotation(highAnnotation,
            (double) TimeUtils.localDateTimeToEpochMillis(highTime), outdoorHighTemp.get());
    a.setTextAnchor(TextAnchor.BASELINE_CENTER);
    plot.addAnnotation(a);

    a = new XYTextAnnotation(lowAnnotation, TimeUtils.localDateTimeToEpochMillis(lowTime),
            outdoorLowTemp.get());
    a.setTextAnchor(TextAnchor.TOP_CENTER);
    plot.addAnnotation(a);

    highTime = summaryRecord.getMaxIndoorTempTime();
    Temperature indoorHighTemp = summaryRecord.getMaxIndoorTemp();
    lowTime = summaryRecord.getMinIndoorTempTime();
    Temperature indoorLowTemp = summaryRecord.getMinIndoorTemp();

    highAnnotation = indoorHighTemp.toString() + " " + Temperature.getDefaultUnit() + " "
            + DisplayConstants.formatTime(highTime.toLocalTime());
    lowAnnotation = indoorLowTemp + " " + Temperature.getDefaultUnit() + " "
            + DisplayConstants.formatTime(lowTime.toLocalTime());

    a = new XYTextAnnotation(highAnnotation, TimeUtils.localDateTimeToEpochMillis(highTime),
            indoorHighTemp.get());
    a.setTextAnchor(TextAnchor.BASELINE_CENTER);
    plot.addAnnotation(a);

    a = new XYTextAnnotation(lowAnnotation, TimeUtils.localDateTimeToEpochMillis(lowTime), indoorLowTemp.get());
    a.setTextAnchor(TextAnchor.TOP_CENTER);
    plot.addAnnotation(a);
}

From source file:de.bfs.radon.omsimulation.gui.data.OMCharts.java

/**
 * Creates a chart displaying the radon concentration of a single room. Uses
 * red for normal rooms, blue for cellar rooms and green for misc rooms.
 * //from  w ww.jav a  2s .c o  m
 * @param title
 *          The headline of the chart. Will be hidden if set to null.
 * @param room
 *          The room object containing the radon data.
 * @param preview
 *          Will hide annotations, labels and headlines if true.
 * @return A chart displaying the radon concentration of a single room.
 */
public static JFreeChart createRoomChart(String title, OMRoom room, boolean preview) {
    Color lineColor = new Color(0, 0, 0, 128);
    Color rangeColor = new Color(222, 222, 222, 128);
    if (room.getType() == OMRoomType.Room) {
        lineColor = new Color(255, 0, 0, 128);
        rangeColor = new Color(255, 222, 222, 128);
    } else {
        if (room.getType() == OMRoomType.Cellar) {
            lineColor = new Color(0, 0, 255, 128);
            rangeColor = new Color(222, 222, 255, 128);
        } else {
            lineColor = new Color(0, 128, 0, 255);
            rangeColor = new Color(222, 255, 222, 128);
        }
    }
    double[] values = room.getValues();
    XYSeriesCollection dataSet = new XYSeriesCollection();
    XYSeries series = new XYSeries("Radon");
    int count = room.getCount();
    double maxPointerKey = 0;
    for (int i = 0; i < count; i++) {
        series.add(i, values[i]);
        if (values[i] == room.getMaximum()) {
            maxPointerKey = i;
        }
    }
    dataSet.addSeries(series);
    title = title + ": " + room.getType().toString() + " " + room.getId();
    JFreeChart chart = ChartFactory.createXYLineChart(title, "T [h]", "Rn [Bq/m\u00B3]", dataSet,
            PlotOrientation.VERTICAL, false, true, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    double positiveDeviation = room.getAverage() + room.getDeviation();
    double negativeDeviation = room.getAverage() - room.getDeviation();
    IntervalMarker deviation = new IntervalMarker(negativeDeviation, positiveDeviation);
    float[] dash = { 5, 3 };
    deviation.setPaint(rangeColor);
    deviation.setStroke(new BasicStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0));
    plot.addRangeMarker(deviation, Layer.BACKGROUND);
    ValueMarker arithMarker = new ValueMarker(room.getAverage(), lineColor,
            new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0));
    plot.addRangeMarker(arithMarker);
    ValueMarker maxiMarker = new ValueMarker(room.getMaximum(), lineColor,
            new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0));
    plot.addRangeMarker(maxiMarker);
    XYTextAnnotation amLabel = new XYTextAnnotation("AM=" + (int) room.getAverage(), count,
            room.getAverage() * 1.01);
    plot.addAnnotation(amLabel);
    XYTextAnnotation sdLabel = new XYTextAnnotation("SD=" + (int) room.getDeviation(), count,
            (room.getAverage() + room.getDeviation()) * 1.01);
    plot.addAnnotation(sdLabel);
    XYTextAnnotation maxLabel = new XYTextAnnotation("MAX=" + (int) room.getMaximum(), count,
            room.getMaximum() * 1.01);
    plot.addAnnotation(maxLabel);
    XYPointerAnnotation maxPointer = new XYPointerAnnotation("", maxPointerKey, room.getMaximum(),
            Math.PI * 1.1);
    plot.addAnnotation(maxPointer);
    XYItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesPaint(0, lineColor);
    if (preview) {
        chart.setTitle("");
        plot.clearAnnotations();
    }
    return chart;
}

From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java

protected void clearPreviousChartJunk(XYPlot xyp) {
    if (xyp != null) {
        xyp.clearAnnotations();
        xyp.clearDomainAxes();//from   w  w w  .jav a 2  s  .c  om
        xyp.clearRangeAxes();
        xyp.setDataset(null);
    }
}

From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java

/**
  * Draw a chart in a panel.  Good for precursors and daughters
  * @param parentPanel/*from ww  w  . ja  v  a  2 s.co  m*/
  * @param dataset
  * @param domainMin
  * @param domainMax
  * @param supplier
  * @param wg
  */

protected void createChartInPanel(JPanel parentPanel, XYSeriesCollection dataset, Double domainMin,
        Double domainMax, DrawingSupplier supplier, whichGraph wg) {
    if (precursorChromatogramEmpty(transitionOnPlot) && wg == whichGraph.Precursor) {
        precursorContainerContainerPanel.setVisible(false);
        if (this.getWidth() >= 100 && this.getHeight() >= 100)
            this.setPreferredSize(new Dimension(this.getWidth(), this.getHeight()));
        pack();
        return;
    }
    switch (wg) {
    case Precursor:
        clearPreviousChartJunk(oldPrecursorChart);
        oldPrecursorChart = null;
        break;
    case Daughter:
        clearPreviousChartJunk(oldProductChart);
        oldProductChart = null;
        break;
    }

    JFreeChart chart = ChartFactory.createXYLineChart(null, "seconds", null, dataset, PlotOrientation.VERTICAL,
            true, false, false);

    chart.setBackgroundPaint(new Color(220, 220, 220));
    XYPlot xyp = (XYPlot) (chart.getPlot());
    xyp.setBackgroundPaint(Color.WHITE);
    xyp.setDomainGridlinesVisible(true);
    xyp.setRangeGridlinesVisible(true);
    xyp.setDomainGridlinePaint(Color.LIGHT_GRAY);
    xyp.setRangeGridlinePaint(Color.LIGHT_GRAY);
    if (supplier != null) {
        xyp.setDrawingSupplier(supplier);
    } else {
        xyp.setDrawingSupplier(Utils.plainDrawingSupplier(Color.LIGHT_GRAY));
    }
    xyp.setSeriesRenderingOrder(SeriesRenderingOrder.REVERSE);

    CenterZoomNumberAxis axisDomain = new CenterZoomNumberAxis("seconds");
    axisDomain.setAutoRangeIncludesZero(false);
    axisDomain.setRange(Math.max(0.0, domainMin), domainMax);
    axisDomain.addChangeListener(new domainAxisZoomCoordinator(axisDomain));

    xyp.clearAnnotations();
    xyp.setDomainAxis(axisDomain);
    xyp.getDomainAxis().setAutoRange(false);
    xyp.getRangeAxis().setAutoRange(false);
    XYLineAndShapeRenderer xylsr = (XYLineAndShapeRenderer) xyp.getRenderer();
    xylsr.setLegendLine(Utils.legendThing(16, 6));

    xylsr.setShapesFilled(true);
    xylsr.setBaseShapesFilled(true);
    PanelWithChart panelWithChart = new PanelWithChart(chart);
    ChartPanel cp = panelWithChart.getChartPanel();
    cp.removeMouseListener(cp);
    cp.removeMouseMotionListener(cp);
    if (peaksTable != null) {
        MRMerMouseListener mml = new MRMerMouseListener(cp, (PeaksTableModel) peaksTable.getModel());
        cp.addMouseListener(mml);
        cp.addMouseMotionListener(mml);
    }
    cp.setPreferredSize(new Dimension(parentPanel.getWidth(), parentPanel.getHeight() - 10));
    cp.setDomainZoomable(true);
    cp.setRangeZoomable(false);
    cp.setPopupMenu(null);
    parentPanel.removeAll();
    parentPanel.add(panelWithChart);

    switch (wg) {
    case Precursor:
        createChartInPanelPrecursorTasksOnly(xyp);
        oldPrecursorChart = xyp;
        break;
    case Daughter:
        createChartInPanelDaughterTasksOnly(xyp);
        oldProductChart = xyp;
        break;
    }
    parentPanel.updateUI();
    listTransition.requestFocus();
}

From source file:edu.umn.ecology.populus.plot.BasicPlotInfo.java

public ChartTheme getJFreeChartTheme() {
    class PopChartTheme implements ChartTheme {
        private BasicPlotInfo bpiRef;

        public PopChartTheme(BasicPlotInfo bpi) {
            this.bpiRef = bpi;
        }//from www.ja v  a 2s  .co m

        public void apply(JFreeChart chart) {
            JFCXYAdapter jfca = new JFCXYAdapter();
            XYPlot plot = chart.getXYPlot();
            plot.setDataset(jfca);

            if (isLogPlot) {
                plot.setRangeAxis(new LogarithmicAxis(""));
            }
            if (isFrequencies) {
                ValueAxis va = plot.getRangeAxis();
                if (va instanceof NumberAxis) {
                    NumberAxis na = (NumberAxis) va;
                    na.setTickUnit(new NumberTickUnit(0.1));
                } else {
                    Logging.log("Range Axis is not NumberAxis, why?", Logging.kWarn);
                }
            }

            if (xMinSet)
                plot.getDomainAxis().setLowerBound(xAxisMin);
            if (xMaxSet)
                plot.getDomainAxis().setUpperBound(xAxisMax);
            if (yMinSet)
                plot.getRangeAxis().setLowerBound(yAxisMin);
            if (yMaxSet)
                plot.getRangeAxis().setUpperBound(yAxisMax);

            //TODO - just use this renderer
            plot.setRenderer(new ChartRendererWithOrientatedShapes(bpiRef));

            XYItemRenderer r = plot.getRenderer();
            //         AbstractXYItemRenderer r = plot.getRenderer();
            if (r instanceof XYLineAndShapeRenderer) {
                XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
                for (int i = 0; i < getNumSeries(); i++) {
                    //Set Line
                    renderer.setSeriesPaint(i, getLineColor(i));
                    renderer.setSeriesStroke(i, getLineStroke(i));

                    //Set Symbol
                    renderer.setSeriesFillPaint(i, getSymbolColor(i));
                    renderer.setSeriesOutlinePaint(i, getSymbolColor(i));

                    Shape shape = getSymbolShape(i);
                    if (shape != null) {
                        renderer.setSeriesShape(i, shape);
                        renderer.setSeriesShapesFilled(i, isSymbolOpaque(i));
                        renderer.setUseFillPaint(true);
                        renderer.setUseOutlinePaint(true);
                        renderer.setSeriesShapesVisible(i, true);
                    }
                }
            } else if (r instanceof XYBarRenderer) {
                XYBarRenderer barRenderer = (XYBarRenderer) r;
                barRenderer.setBarPainter(new StandardXYBarPainter());
            } else {
                Logging.log("Unknown renderer type: " + r.getClass(), Logging.kWarn);
            }

            //inner labels, used in AIDS: Therapy
            plot.clearAnnotations();
            Enumeration<InnerLabel> e = innerLabels.elements();
            while (e.hasMoreElements()) {
                InnerLabel lab = (InnerLabel) e.nextElement();
                Logging.log("Adding " + lab.caption + " at " + lab.x + ", " + lab.y);

                XYTextAnnotation annotation = new XYTextAnnotation(lab.caption, lab.x, lab.y);
                annotation.setTextAnchor(TextAnchor.BOTTOM_CENTER);
                annotation.setOutlineVisible(true);
                plot.addAnnotation(annotation);

                //I actually think the annotation above is ugly.  We can use one of these instead in the future, maybe...
                /*PointerAnnotation may look cool...
                 * That 2.0 is the angle, randomly picked
                 * XYPointerAnnotation annotation = new XYPointerAnnotation(lab.caption, lab.x, lab.y, 2.0); 
                 */

                /*
                ValueMarker marker = new ValueMarker(lab.x);
                marker.setLabel(lab.caption);
                marker.setLabelAnchor(RectangleAnchor.BOTTOM_LEFT);
                plot.addDomainMarker(marker);
                 */

            }

            //This is set for GD: AMCM
            if (startGridded) {
                plot.setDomainGridlinesVisible(true);
                plot.setDomainGridlinePaint(Color.BLACK);
                plot.setRangeGridlinesVisible(true);
                plot.setRangeGridlinePaint(Color.BLACK);
            }

        }
    }
    return new PopChartTheme(this);
}

From source file:de.bfs.radon.omsimulation.gui.data.OMCharts.java

/**
 * Creates a chart displaying the radon concentration of a virtual campaign.
 * Uses red for normal rooms and blue for cellar rooms.
 * //from ww  w.  j a va 2  s. c  o  m
 * @param campaign
 *          The campaign object containing all rooms and radon data.
 * @param preview
 *          Will hide annotations, labels and headlines if true.
 * @return A chart displaying the radon concentration of a virtual campaign.
 */
public static JFreeChart createCampaignChart(OMCampaign campaign, boolean preview) {
    OMRoom[] rooms = new OMRoom[7];
    OMRoom[] tmpRooms = campaign.getRooms();
    OMRoom tmpCellar = campaign.getCellar();
    String variation = campaign.getVariation();
    char[] variationChar = variation.toCharArray();
    int cellarPosition = 0;
    for (int i = 0; i < variationChar.length; i++) {
        if (variationChar[i] == 'C' || variationChar[i] == 'c') {
            cellarPosition = i / 2;
        }
    }
    int c = 0;
    for (int i = 0; i < rooms.length; i++) {
        if (i == cellarPosition) {
            rooms[i] = tmpCellar;
            c++;
        } else {
            rooms[i] = tmpRooms[i - c];
        }
    }
    int start = campaign.getStart();
    final int finalStart = start;
    String title = "Campaign: " + rooms[0].getId() + rooms[1].getId() + rooms[2].getId() + rooms[3].getId()
            + rooms[4].getId() + rooms[5].getId() + rooms[6].getId() + ", Start: " + finalStart;
    int count = 168;
    double[] values = campaign.getValueChain();
    XYSeriesCollection dataSet = new XYSeriesCollection();
    XYSeries roomSeries1 = new XYSeries(" Radon Rooms");
    XYSeries cellarSeries = new XYSeries("Radon Cellar");
    XYSeries roomSeries2 = new XYSeries("Radon Rooms");
    int cellarSeriesStart = cellarPosition * 24;
    int cellarSeriesEnd = cellarSeriesStart + 24;
    double cellarMaximum = campaign.getCellarMaximum();
    double cellarMaximumKey = 0;
    double roomMaximum = campaign.getRoomMaximum();
    double roomMaximumKey = 0;
    if (cellarSeriesStart > 0) {
        for (int i = 0; i < cellarSeriesStart; i++) {
            roomSeries1.add(finalStart + i, values[i]);
            if (values[i] == roomMaximum) {
                roomMaximumKey = i;
            }
        }
    }
    for (int i = cellarSeriesStart - 1; i < cellarSeriesEnd; i++) {
        if (i >= 0) {
            cellarSeries.add(finalStart + i, values[i]);
            if (values[i] == cellarMaximum) {
                cellarMaximumKey = i;
            }
        }
    }
    if (cellarSeriesEnd < count) {
        for (int i = cellarSeriesEnd - 1; i < count; i++) {
            roomSeries2.add(finalStart + i, values[i]);
            if (values[i] == roomMaximum) {
                roomMaximumKey = i;
            }
        }
    }
    dataSet.addSeries(roomSeries1);
    dataSet.addSeries(cellarSeries);
    dataSet.addSeries(roomSeries2);
    JFreeChart chart = ChartFactory.createXYLineChart(title, "T [h]", "Rn [Bq/m\u00B3]", dataSet,
            PlotOrientation.VERTICAL, false, true, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    ValueMarker sepMarker;
    Color sepColor = Color.BLACK;
    float[] sepDash = { 1, 2 };
    Stroke sepStroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, sepDash, 0);
    RectangleInsets sepLabelInsets = new RectangleInsets(20, -20, 0, 0);
    Font sepLabelFont = new Font(Font.SANS_SERIF, Font.BOLD, 16);
    sepMarker = new ValueMarker(finalStart + 0, sepColor, sepStroke);
    sepMarker.setLabel(rooms[0].getId());
    sepMarker.setLabelOffset(sepLabelInsets);
    sepMarker.setLabelFont(sepLabelFont);
    plot.addDomainMarker(sepMarker);
    if (rooms[0].getId() != rooms[1].getId()) {
        sepMarker = new ValueMarker(finalStart + 23, sepColor, sepStroke);
        sepMarker.setLabel(rooms[1].getId());
        sepMarker.setLabelOffset(sepLabelInsets);
        sepMarker.setLabelFont(sepLabelFont);
        plot.addDomainMarker(sepMarker);
    }
    if (rooms[1].getId() != rooms[2].getId()) {
        sepMarker = new ValueMarker(finalStart + 47, sepColor, sepStroke);
        sepMarker.setLabel(rooms[2].getId());
        sepMarker.setLabelOffset(sepLabelInsets);
        sepMarker.setLabelFont(sepLabelFont);
        plot.addDomainMarker(sepMarker);
    }
    if (rooms[2].getId() != rooms[3].getId()) {
        sepMarker = new ValueMarker(finalStart + 71, sepColor, sepStroke);
        sepMarker.setLabel(rooms[3].getId());
        sepMarker.setLabelOffset(sepLabelInsets);
        sepMarker.setLabelFont(sepLabelFont);
        plot.addDomainMarker(sepMarker);
    }
    if (rooms[3].getId() != rooms[4].getId()) {
        sepMarker = new ValueMarker(finalStart + 95, sepColor, sepStroke);
        sepMarker.setLabel(rooms[4].getId());
        sepMarker.setLabelOffset(sepLabelInsets);
        sepMarker.setLabelFont(sepLabelFont);
        plot.addDomainMarker(sepMarker);
    }
    if (rooms[4].getId() != rooms[5].getId()) {
        sepMarker = new ValueMarker(finalStart + 119, sepColor, sepStroke);
        sepMarker.setLabel(rooms[5].getId());
        sepMarker.setLabelOffset(sepLabelInsets);
        sepMarker.setLabelFont(sepLabelFont);
        plot.addDomainMarker(sepMarker);
    }
    if (rooms[5].getId() != rooms[6].getId()) {
        sepMarker = new ValueMarker(finalStart + 143, sepColor, sepStroke);
        sepMarker.setLabel(rooms[6].getId());
        sepMarker.setLabelOffset(sepLabelInsets);
        sepMarker.setLabelFont(sepLabelFont);
        plot.addDomainMarker(sepMarker);
    }
    double positiveCellarDeviation = campaign.getCellarAverage() + campaign.getCellarDeviation();
    double negativeCellarDeviation = campaign.getCellarAverage() - campaign.getCellarDeviation();
    IntervalMarker cellarDeviation = new IntervalMarker(negativeCellarDeviation, positiveCellarDeviation);
    float[] dash = { 5, 3 };
    cellarDeviation.setPaint(new Color(222, 222, 255, 128));
    cellarDeviation.setStroke(new BasicStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0));
    plot.addRangeMarker(cellarDeviation, Layer.BACKGROUND);
    ValueMarker arithCellarMarker = new ValueMarker(campaign.getCellarAverage(), new Color(0, 0, 255, 128),
            new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0));
    plot.addRangeMarker(arithCellarMarker);
    XYTextAnnotation amCellarLabel = new XYTextAnnotation("C_AM=" + (int) campaign.getCellarAverage(),
            finalStart + count, campaign.getCellarAverage() * 1.01);
    plot.addAnnotation(amCellarLabel);
    XYTextAnnotation sdCellarLabel = new XYTextAnnotation("C_SD=" + (int) campaign.getCellarDeviation(),
            finalStart + count, (campaign.getCellarAverage() + campaign.getCellarDeviation()) * 1.01);
    plot.addAnnotation(sdCellarLabel);
    ValueMarker maxiCellarMarker = new ValueMarker(cellarMaximum, new Color(0, 0, 255, 128),
            new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0));
    plot.addRangeMarker(maxiCellarMarker);
    XYTextAnnotation maxCellarLabel = new XYTextAnnotation("C_MAX=" + (int) cellarMaximum, finalStart + count,
            cellarMaximum * 1.01);
    plot.addAnnotation(maxCellarLabel);
    XYPointerAnnotation maxCellarPointer = new XYPointerAnnotation("", finalStart + cellarMaximumKey,
            cellarMaximum, Math.PI * 1.1);
    plot.addAnnotation(maxCellarPointer);
    double positiveRoomDeviation = campaign.getRoomAverage() + campaign.getRoomDeviation();
    double negativeRoomDeviation = campaign.getRoomAverage() - campaign.getRoomDeviation();
    IntervalMarker roomDeviation = new IntervalMarker(negativeRoomDeviation, positiveRoomDeviation);
    roomDeviation.setPaint(new Color(255, 222, 222, 128));
    roomDeviation.setStroke(new BasicStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0));
    plot.addRangeMarker(roomDeviation, Layer.BACKGROUND);
    ValueMarker arithRoomMarker = new ValueMarker(campaign.getRoomAverage(), new Color(255, 0, 0, 128),
            new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0));
    plot.addRangeMarker(arithRoomMarker);
    XYTextAnnotation amRoomLabel = new XYTextAnnotation("R_AM=" + (int) campaign.getRoomAverage(),
            finalStart + count, campaign.getRoomAverage() * 1.01);
    plot.addAnnotation(amRoomLabel);
    XYTextAnnotation sdRoomLabel = new XYTextAnnotation("R_SD=" + (int) campaign.getRoomDeviation(),
            finalStart + count, (campaign.getRoomAverage() + campaign.getRoomDeviation()) * 1.01);
    plot.addAnnotation(sdRoomLabel);
    ValueMarker maxiRoomMarker = new ValueMarker(roomMaximum, new Color(255, 0, 0, 128),
            new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0));
    plot.addRangeMarker(maxiRoomMarker);
    XYTextAnnotation maxRoomLabel = new XYTextAnnotation("R_MAX=" + (int) roomMaximum, finalStart + count,
            roomMaximum * 1.01);
    plot.addAnnotation(maxRoomLabel);
    XYPointerAnnotation maxRoomPointer = new XYPointerAnnotation("", finalStart + roomMaximumKey, roomMaximum,
            Math.PI * 1.1);
    plot.addAnnotation(maxRoomPointer);
    XYItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesPaint(0, new Color(255, 0, 0, 128));
    renderer.setSeriesPaint(1, new Color(0, 0, 255, 128));
    renderer.setSeriesPaint(2, new Color(255, 0, 0, 128));
    if (preview) {
        chart.setTitle("");
        plot.clearAnnotations();
    }
    return chart;
}