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

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

Introduction

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

Prototype

public void addDomainMarker(Marker marker) 

Source Link

Document

Adds a marker for the domain axis and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:com.yahoo.egads.utilities.GUIUtils.java

/**
 * Add anomalies to the plot./*from   w  ww .j a v  a  2s . c  o  m*/
 */
public void addAnomalies(XYPlot plot, ArrayList<Anomaly> anomalyList) {
    for (Anomaly a : anomalyList) {
        IntervalSequence is = a.intervals;
        for (Interval i : is) {
            ValueMarker marker = new ValueMarker(i.index);
            marker.setPaint(Color.black);
            plot.addDomainMarker(marker);
        }
    }
}

From source file:org.geopublishing.atlasStyler.classification.RasterClassification.java

@Override
public BufferedImage createHistogramImage(boolean showMean, boolean showSd, int histogramBins,
        String label_xachsis) throws InterruptedException, IOException {
    HistogramDataset hds = new HistogramDataset();

    DoubleArrayList valuesAL;// w w w .  j  av  a 2s .  co m
    valuesAL = getStatistics().elements();
    double[] elements = Arrays.copyOf(valuesAL.elements(), getStatistics().size());
    hds.addSeries(1, elements, histogramBins);

    /** Statically label the Y Axis **/
    String label_yachsis = ASUtil.R("QuantitiesClassificationGUI.Histogram.YAxisLabel");

    JFreeChart chart = org.jfree.chart.ChartFactory.createHistogram(null, label_xachsis, label_yachsis, hds,
            PlotOrientation.VERTICAL, false, true, true);

    /***********************************************************************
     * Paint the classes into the JFreeChart
     */
    int countLimits = 0;
    for (Double cLimit : getClassLimits()) {
        ValueMarker marker = new ValueMarker(cLimit);
        XYPlot plot = chart.getXYPlot();
        marker.setPaint(Color.orange);
        marker.setLabel(String.valueOf(countLimits));
        marker.setLabelAnchor(RectangleAnchor.TOP_LEFT);
        marker.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
        plot.addDomainMarker(marker);

        countLimits++;
    }

    /***********************************************************************
     * Optionally painting SD and MEAN into the histogram
     */
    try {
        if (showSd) {
            ValueMarker marker;
            marker = new ValueMarker(getSD(), Color.green.brighter(), new BasicStroke(1.5f));
            XYPlot plot = chart.getXYPlot();
            marker.setLabel(ASUtil.R("QuantitiesClassificationGUI.Histogram.SD.ShortLabel"));
            marker.setLabelAnchor(RectangleAnchor.BOTTOM_LEFT);
            marker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
            plot.addDomainMarker(marker);
        }

        if (showMean) {
            ValueMarker marker;
            marker = new ValueMarker(getMean(), Color.green.darker(), new BasicStroke(1.5f));
            XYPlot plot = chart.getXYPlot();
            marker.setLabel(ASUtil.R("QuantitiesClassificationGUI.Histogram.Mean.ShortLabel"));
            marker.setLabelAnchor(RectangleAnchor.BOTTOM_LEFT);
            marker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
            plot.addDomainMarker(marker);
        }

    } catch (Exception e) {
        LOGGER.error("Painting SD and MEAN into the histogram", e);
    }

    /***********************************************************************
     * Render the Chart
     */
    BufferedImage image = chart.createBufferedImage(400, 200);

    return image;
}

From source file:com.googlecode.logVisualizer.chart.StatDevelopmentLineChart.java

@Override
protected ChartPanel createChartPanel() {
    final ChartPanel panel = super.createChartPanel();
    final XYPlot plot = (XYPlot) panel.getChart().getPlot();

    for (final DayChange dc : getLogData().getDayChanges()) {
        final ValueMarker day = new ValueMarker(dc.getTurnNumber());
        day.setLabel("Day " + dc.getDayNumber());
        day.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
        day.setLabelTextAnchor(TextAnchor.TOP_LEFT);
        day.setStroke(new BasicStroke(2));
        day.setPaint(new Color(175, 175, 255));
        plot.addDomainMarker(day);
    }//from   w w  w  . ja v a2 s  . c  om

    return panel;
}

From source file:edu.cmu.sv.modelinference.eventtool.EventVisualizer.java

private void setViolationMarkers(Collection<Range<Integer>> violations, XYPlot plot) {
    for (Range<Integer> violation : violations) {

        ValueMarker startViolationMarker = new ValueMarker(violation.lowerEndpoint()); // position is the value on the axis
        startViolationMarker.setPaint(Color.BLACK);
        startViolationMarker.setStroke(new BasicStroke(1.0f));
        plot.addDomainMarker(startViolationMarker);

        ValueMarker endViolationMarker = new ValueMarker(violation.upperEndpoint()); // position is the value on the axis
        endViolationMarker.setPaint(Color.GREEN);
        endViolationMarker.setStroke(new BasicStroke(0.5f));
        plot.addDomainMarker(endViolationMarker);
    }/* ww  w  .  j ava 2s  . c om*/
}

From source file:grafix.graficos.eixos.Eixo.java

protected void incluirMarcas(final XYPlot plot, final JanelaGraficos janela) {
    try {/*  www .  ja  va  2s  .  com*/
        Vector<MarcaGrafica> marcas = janela.getAcao().getAnalise().getMarcas();
        for (MarcaGrafica m : marcas) {
            if (m.isRangeMarker()) {
                if (getNomeEixo().equals(m.getNomeEixo())) {
                    plot.addRangeMarker(gerarRangeMarker(m));
                }
            } else {
                plot.addDomainMarker(gerarIntervalMarker(m, janela));
            }
        }
        incluirMarcaIntraday(plot, janela);
    } catch (Exception e) {
        AjudaGrafix.exibirMensagem(AjudaGrafix.ERRO_MARCAS);
        janela.getAcao().getAnalise().apagarMarcasAnalise();
    }
}

From source file:org.geopublishing.atlasStyler.classification.FeatureClassification.java

@Override
public BufferedImage createHistogramImage(boolean showMean, boolean showSd, int histogramBins,
        String label_xachsis) throws InterruptedException, IOException {
    HistogramDataset hds = new HistogramDataset();
    DoubleArrayList valuesAL;/*from   ww w . ja va  2  s  .com*/
    valuesAL = getStatistics().elements();
    // new double[] {0.4,3,4,2,5.,22.,4.,2.,33.,12.}
    double[] elements = Arrays.copyOf(valuesAL.elements(), getStatistics().size());
    hds.addSeries(1, elements, histogramBins);

    /** Statically label the Y Axis **/
    String label_yachsis = ASUtil.R("QuantitiesClassificationGUI.Histogram.YAxisLabel");

    JFreeChart chart = org.jfree.chart.ChartFactory.createHistogram(null, label_xachsis, label_yachsis, hds,
            PlotOrientation.VERTICAL, false, true, true);

    /***********************************************************************
     * Paint the classes into the JFreeChart
     */
    int countLimits = 0;
    for (Double cLimit : getClassLimits()) {
        ValueMarker marker = new ValueMarker(cLimit);
        XYPlot plot = chart.getXYPlot();
        marker.setPaint(Color.orange);
        marker.setLabel(String.valueOf(countLimits));
        marker.setLabelAnchor(RectangleAnchor.TOP_LEFT);
        marker.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
        plot.addDomainMarker(marker);

        countLimits++;
    }

    /***********************************************************************
     * Optionally painting SD and MEAN into the histogram
     */
    try {
        if (showSd) {
            ValueMarker marker;
            marker = new ValueMarker(getStatistics().standardDeviation(), Color.green.brighter(),
                    new BasicStroke(1.5f));
            XYPlot plot = chart.getXYPlot();
            marker.setLabel(ASUtil.R("QuantitiesClassificationGUI.Histogram.SD.ShortLabel"));
            marker.setLabelAnchor(RectangleAnchor.BOTTOM_LEFT);
            marker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
            plot.addDomainMarker(marker);
        }

        if (showMean) {
            ValueMarker marker;
            marker = new ValueMarker(getStatistics().mean(), Color.green.darker(), new BasicStroke(1.5f));
            XYPlot plot = chart.getXYPlot();
            marker.setLabel(ASUtil.R("QuantitiesClassificationGUI.Histogram.Mean.ShortLabel"));
            marker.setLabelAnchor(RectangleAnchor.BOTTOM_LEFT);
            marker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
            plot.addDomainMarker(marker);
        }

    } catch (Exception e) {
        LOGGER.error("Painting SD and MEAN into the histogram", e);
    }

    /***********************************************************************
     * Render the Chart
     */
    BufferedImage image = chart.createBufferedImage(400, 200);

    return image;
}

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

/**
 * Creates a chart displaying the distribution of certain selected statistical
 * values. Uses red for normal rooms and blue for cellar rooms.
 * /*from  ww  w .j a  v a 2s  .c o m*/
 * @param title
 *          The headline of the chart. Will be hidden if set to null.
 * @param statistics
 *          The selected statistics of a campaign containing all needed
 *          values.
 * @param roomType
 *          The room type to determine the colour of the chart.
 * @param preview
 *          Will hide annotations, labels and headlines if true.
 * @return A chart displaying the distribution of certain selected statistical
 *         values.
 */
public static JFreeChart createDistributionChart(String title, DescriptiveStatistics statistics,
        OMRoomType roomType, boolean preview) {
    Color lineColor = new Color(0, 0, 0, 128);
    Color rangeColor = new Color(222, 222, 222, 128);
    if (roomType == OMRoomType.Room) {
        lineColor = new Color(255, 0, 0, 128);
        rangeColor = new Color(255, 222, 222, 128);
    } else {
        if (roomType == 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[] distValues = statistics.getSortedValues();
    XYSeriesCollection dataSet = new XYSeriesCollection();
    XYSeries distSeries = new XYSeries("Distribution");
    for (int i = 0; i < distValues.length; i++) {
        distSeries.add(distValues[i], (0.5 + (double) i) / (double) distValues.length);
    }
    dataSet.addSeries(distSeries);
    JFreeChart chart = ChartFactory.createXYLineChart(title, "Rn [Bq/m\u00B3]", "F(emp)", dataSet,
            PlotOrientation.VERTICAL, false, true, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    float[] dash = { 5, 3 };
    int pos = 0;
    double y = (Double) distSeries.getY(pos);
    XYPointerAnnotation minPointer = new XYPointerAnnotation("MIN=" + (int) distValues[pos], distValues[pos], y,
            Math.PI * 1.5);
    plot.addAnnotation(minPointer);
    pos = (int) (((double) distValues.length / 100. * 5.0) - 1.0);
    while (pos < 0) {
        pos++;
    }
    if (pos > 0) {
        y = (Double) distSeries.getY(pos);
    } else {
        y = (Double) distSeries.getY(pos + 1);
    }
    final double posQ5 = distValues[pos];
    XYPointerAnnotation q05Pointer = new XYPointerAnnotation("Q5=" + (int) distValues[pos], distValues[pos], y,
            Math.PI * 1.5);
    plot.addAnnotation(q05Pointer);
    pos = (int) (((double) distValues.length / 2.0) - 1.0);
    y = (Double) distSeries.getY(pos);
    XYPointerAnnotation q50Pointer = new XYPointerAnnotation("Q50=" + (int) distValues[pos], distValues[pos], y,
            Math.PI * 1.5);
    plot.addAnnotation(q50Pointer);
    ValueMarker medMarker = new ValueMarker(distValues[pos], lineColor,
            new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0));
    plot.addDomainMarker(medMarker);
    pos = (int) (((double) distValues.length / 100.0 * 95.0) - 1.0);
    if (pos < distValues.length - 1) {
        y = (Double) distSeries.getY(pos);
    } else {
        y = (Double) distSeries.getY(pos - 1);
    }
    final double posQ95 = distValues[pos];
    XYPointerAnnotation q95Pointer = new XYPointerAnnotation("Q95=" + (int) distValues[pos], distValues[pos], y,
            Math.PI * 0.5);
    plot.addAnnotation(q95Pointer);
    pos = distValues.length - 1;
    y = (Double) distSeries.getY(pos);
    XYPointerAnnotation maxPointer = new XYPointerAnnotation("MAX=" + (int) distValues[pos], distValues[pos], y,
            Math.PI * 0.5);
    plot.addAnnotation(maxPointer);
    IntervalMarker percentiles = new IntervalMarker(posQ5, posQ95);
    percentiles.setPaint(rangeColor);
    percentiles.setStroke(new BasicStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0));
    plot.addDomainMarker(percentiles, Layer.BACKGROUND);
    XYItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesPaint(0, lineColor);
    return chart;
}

From source file:grafix.graficos.eixos.Eixo.java

protected void incluirMarcaIntraday(final XYPlot plot, final JanelaGraficos janela) {
    if (Controle.getConfiguracoesVolateis().isIntraday()) {
        MarcaGrafica m = new MarcaGrafica("", "INTRADAY",
                janela.getAcao().getRegistro(janela.getAcao().getNumeroRegistros() - 1).getData(), Color.BLUE);
        if (m.isRangeMarker()) {
            if (getNomeEixo().equals(m.getNomeEixo())) {
                plot.addRangeMarker(gerarRangeMarker(m));
            }/*from www  .  j av a2  s. com*/
        } else {
            plot.addDomainMarker(gerarIntervalMarker(m, janela));
        }
    }
}

From source file:com.griddynamics.jagger.monitoring.reporting.SystemUnderTestPlotsGeneralProvider.java

public Map<String, List<MonitoringReporterData>> createTaskPlots() {
    log.info("BEGIN: Create general task plots");

    Map<String, List<MonitoringReporterData>> taskPlots = new LinkedHashMap<String, List<MonitoringReporterData>>();
    GeneralStatistics generalStatistics = getStatistics();

    Set<String> taskIds = generalStatistics.findTaskIds();
    Set<String> boxIdentifiers = generalStatistics.findBoxIdentifiers();
    Set<String> sutUrls = generalStatistics.findSutUrls();
    for (GroupKey groupName : plotGroups.getPlotGroups().keySet()) {
        log.info("    Create general task plots for group '{}'", groupName);

        if (showPlotsByGlobal) {
            log.info("        Create general global task plots");

            List<MonitoringReporterData> plots = new LinkedList<MonitoringReporterData>();
            XYSeriesCollection chartsCollection = new XYSeriesCollection();
            LinkedHashMap<String, IntervalMarker> markers = new LinkedHashMap<String, IntervalMarker>();
            for (MonitoringParameter parameterId : plotGroups.getPlotGroups().get(groupName)) {
                log.info("            Create general global task plots for parameter '{}'", parameterId);

                MonitoringParameterBean param = MonitoringParameterBean.copyOf(parameterId);
                if (generalStatistics.hasGlobalStatistics(param)) {
                    XYSeries values = new XYSeries(param.getDescription());
                    long timeShift = 0;
                    int taskNum = 0;
                    for (String taskId : taskIds) {
                        log.info("                Create general global task plots for task '{}'", taskId);

                        long maxTime = 0;
                        for (MonitoringStatistics monitoringStatistics : generalStatistics
                                .findGlobalStatistics(taskId, param)) {
                            long time = monitoringStatistics.getTime();
                            double t = timeShift + time;
                            values.add(t, monitoringStatistics.getAverageValue());

                            if (time > maxTime) {
                                maxTime = time;
                            }//from  www .j  av  a 2 s .c  o  m

                            if (showNumbers) {
                                IntervalMarker marker = markers.get(taskId);
                                if (marker == null) {
                                    marker = new IntervalMarker(t, t);
                                    marker.setLabel(monitoringStatistics.getTaskData().getNumber().toString());
                                    marker.setAlpha((taskNum % 2 == 0) ? 0.2f : 0.4f);

                                    int mod = taskNum % 3;
                                    if (mod == 0) {
                                        marker.setLabelAnchor(RectangleAnchor.CENTER);
                                    } else if (mod == 1) {
                                        marker.setLabelAnchor(RectangleAnchor.TOP);
                                    } else if (mod == 2) {
                                        marker.setLabelAnchor(RectangleAnchor.BOTTOM);
                                    }

                                    marker.setLabelFont(
                                            marker.getLabelFont().deriveFont(10.0f).deriveFont(Font.BOLD));
                                    markers.put(taskId, marker);
                                } else {
                                    if (t < marker.getStartValue()) {
                                        marker.setStartValue(t);
                                    }
                                    if (t > marker.getEndValue()) {
                                        marker.setEndValue(t);
                                    }
                                }
                            }
                        }
                        timeShift += maxTime;
                        taskNum++;
                    }
                    if (values.isEmpty()) {
                        values.add(0, 0);
                    }
                    chartsCollection.addSeries(values);
                }
            }

            log.debug("group name \n{} \nparams {}]\n", groupName,
                    Lists.newArrayList(plotGroups.getPlotGroups().get(groupName)));

            Pair<String, XYSeriesCollection> pair = ChartHelper.adjustTime(chartsCollection, markers.values());

            chartsCollection = pair.getSecond();

            String name = groupName.getUpperName();

            if (chartsCollection.getSeriesCount() > 0) {
                JFreeChart chart = ChartHelper.createXYChart(null, chartsCollection,
                        "Time (" + pair.getFirst() + ")", groupName.getLeftName(), 0, 1,
                        ChartHelper.ColorTheme.LIGHT);

                XYPlot plot = (XYPlot) chart.getPlot();
                for (IntervalMarker marker : markers.values()) {
                    plot.addDomainMarker(marker);
                }

                MonitoringReporterData monitoringReporterData = new MonitoringReporterData();
                monitoringReporterData.setParameterName(name);
                monitoringReporterData.setTitle(name);
                monitoringReporterData.setPlot(new JCommonDrawableRenderer(chart));
                plots.add(monitoringReporterData);
            }

            if (!plots.isEmpty()) {
                taskPlots.put(name, plots);
            }
        }

        if (showPlotsByBox) {
            log.info("        Create general box task plots");

            for (String boxIdentifier : boxIdentifiers) {
                log.info("            Create general box task plots for box '{}'", boxIdentifier);

                List<MonitoringReporterData> plots = new LinkedList<MonitoringReporterData>();
                XYSeriesCollection chartsCollection = new XYSeriesCollection();
                LinkedHashMap<String, IntervalMarker> markers = new LinkedHashMap<String, IntervalMarker>();
                for (MonitoringParameter parameterId : plotGroups.getPlotGroups().get(groupName)) {
                    log.info("                Create general box task plots for parameter '{}'", parameterId);

                    MonitoringParameterBean param = MonitoringParameterBean.copyOf(parameterId);
                    if (generalStatistics.hasBoxStatistics(param, boxIdentifier)) {
                        XYSeries values = new XYSeries(param.getDescription());
                        long timeShift = 0;
                        int taskNum = 0;
                        for (String taskId : taskIds) {
                            log.info("                    Create general box task plots for task '{}'", taskId);

                            long maxTime = 0;
                            for (MonitoringStatistics monitoringStatistics : generalStatistics
                                    .findBoxStatistics(taskId, param, boxIdentifier)) {
                                long time = monitoringStatistics.getTime();
                                double t = timeShift + time;
                                values.add(t, monitoringStatistics.getAverageValue());

                                if (time > maxTime) {
                                    maxTime = time;
                                }

                                if (showNumbers) {
                                    IntervalMarker marker = markers.get(taskId);
                                    if (marker == null) {
                                        marker = new IntervalMarker(t, t);
                                        marker.setLabel(
                                                monitoringStatistics.getTaskData().getNumber().toString());
                                        marker.setAlpha((taskNum % 2 == 0) ? 0.2f : 0.4f);

                                        int mod = taskNum % 3;
                                        if (mod == 0) {
                                            marker.setLabelAnchor(RectangleAnchor.CENTER);
                                        } else if (mod == 1) {
                                            marker.setLabelAnchor(RectangleAnchor.TOP);
                                        } else if (mod == 2) {
                                            marker.setLabelAnchor(RectangleAnchor.BOTTOM);
                                        }

                                        marker.setLabelFont(
                                                marker.getLabelFont().deriveFont(10.0f).deriveFont(Font.BOLD));
                                        markers.put(taskId, marker);
                                    } else {
                                        if (t < marker.getStartValue()) {
                                            marker.setStartValue(t);
                                        }
                                        if (t > marker.getEndValue()) {
                                            marker.setEndValue(t);
                                        }
                                    }
                                }
                            }
                            timeShift += maxTime;
                            taskNum++;
                        }
                        if (values.isEmpty()) {
                            values.add(0, 0);
                        }
                        chartsCollection.addSeries(values);
                    }
                }

                log.debug("group name \n{} \nparams {}]\n", groupName,
                        Lists.newArrayList(plotGroups.getPlotGroups().get(groupName)));

                Pair<String, XYSeriesCollection> pair = ChartHelper.adjustTime(chartsCollection,
                        markers.values());

                chartsCollection = pair.getSecond();

                String name = groupName.getUpperName() + " on " + boxIdentifier;

                if (chartsCollection.getSeriesCount() > 0) {
                    JFreeChart chart = ChartHelper.createXYChart(null, chartsCollection,
                            "Time (" + pair.getFirst() + ")", groupName.getLeftName(), 0, 1,
                            ChartHelper.ColorTheme.LIGHT);

                    XYPlot plot = (XYPlot) chart.getPlot();
                    for (IntervalMarker marker : markers.values()) {
                        plot.addDomainMarker(marker);
                    }

                    MonitoringReporterData monitoringReporterData = new MonitoringReporterData();
                    monitoringReporterData.setParameterName(name);
                    monitoringReporterData.setTitle(name);
                    monitoringReporterData.setPlot(new JCommonDrawableRenderer(chart));
                    plots.add(monitoringReporterData);
                }

                if (!plots.isEmpty()) {
                    taskPlots.put(name, plots);
                }
            }
        }

        if (showPlotsBySuT) {
            log.info("        Create general sut task plots");

            for (String sutUrl : sutUrls) {
                log.info("            Create general sut task plots for sut '{}'", sutUrl);

                List<MonitoringReporterData> plots = new LinkedList<MonitoringReporterData>();
                XYSeriesCollection chartsCollection = new XYSeriesCollection();
                LinkedHashMap<String, IntervalMarker> markers = new LinkedHashMap<String, IntervalMarker>();
                for (MonitoringParameter parameterId : plotGroups.getPlotGroups().get(groupName)) {
                    log.info("                Create general sut task plots for parameter '{}'", parameterId);

                    MonitoringParameterBean param = MonitoringParameterBean.copyOf(parameterId);
                    if (generalStatistics.hasSutStatistics(param, sutUrl)) {
                        XYSeries values = new XYSeries(param.getDescription());
                        long timeShift = 0;
                        int taskNum = 0;
                        for (String taskId : taskIds) {
                            log.info("                    Create general sut task plots for task '{}'", taskId);

                            long maxTime = 0;
                            for (MonitoringStatistics monitoringStatistics : generalStatistics
                                    .findSutStatistics(taskId, param, sutUrl)) {
                                long time = monitoringStatistics.getTime();
                                double t = timeShift + time;
                                values.add(t, monitoringStatistics.getAverageValue());

                                if (time > maxTime) {
                                    maxTime = time;
                                }

                                if (showNumbers) {
                                    IntervalMarker marker = markers.get(taskId);
                                    if (marker == null) {
                                        marker = new IntervalMarker(t, t);
                                        marker.setLabel(
                                                monitoringStatistics.getTaskData().getNumber().toString());
                                        marker.setAlpha((taskNum % 2 == 0) ? 0.2f : 0.4f);

                                        int mod = taskNum % 3;
                                        if (mod == 0) {
                                            marker.setLabelAnchor(RectangleAnchor.CENTER);
                                        } else if (mod == 1) {
                                            marker.setLabelAnchor(RectangleAnchor.TOP);
                                        } else if (mod == 2) {
                                            marker.setLabelAnchor(RectangleAnchor.BOTTOM);
                                        }

                                        marker.setLabelFont(
                                                marker.getLabelFont().deriveFont(10.0f).deriveFont(Font.BOLD));
                                        markers.put(taskId, marker);
                                    } else {
                                        if (t < marker.getStartValue()) {
                                            marker.setStartValue(t);
                                        }
                                        if (t > marker.getEndValue()) {
                                            marker.setEndValue(t);
                                        }
                                    }
                                }
                            }
                            timeShift += maxTime;
                            taskNum++;
                        }
                        if (values.isEmpty()) {
                            values.add(0, 0);
                        }
                        chartsCollection.addSeries(values);
                    }
                }

                log.debug("group name \n{} \nparams {}]\n", groupName,
                        Lists.newArrayList(plotGroups.getPlotGroups().get(groupName)));

                Pair<String, XYSeriesCollection> pair = ChartHelper.adjustTime(chartsCollection,
                        markers.values());

                chartsCollection = pair.getSecond();

                String name = groupName.getUpperName() + " on " + sutUrl;

                if (chartsCollection.getSeriesCount() > 0) {
                    JFreeChart chart = ChartHelper.createXYChart(null, chartsCollection,
                            "Time (" + pair.getFirst() + ")", groupName.getLeftName(), 0, 1,
                            ChartHelper.ColorTheme.LIGHT);

                    XYPlot plot = (XYPlot) chart.getPlot();
                    for (IntervalMarker marker : markers.values()) {
                        plot.addDomainMarker(marker);
                    }

                    MonitoringReporterData monitoringReporterData = new MonitoringReporterData();
                    monitoringReporterData.setParameterName(name);
                    monitoringReporterData.setTitle(name);
                    monitoringReporterData.setPlot(new JCommonDrawableRenderer(chart));
                    plots.add(monitoringReporterData);
                }

                if (!plots.isEmpty()) {
                    taskPlots.put(name, plots);
                }
            }
        }
    }

    clearStatistics();

    log.info("END: Create general task plots");

    return taskPlots;
}

From source file:org.jrecruiter.web.actions.admin.ShowStatisticsAction.java

public final String chartJobCount() throws Exception {

    final Calendar calendarToday = CalendarUtils.getCalendarWithoutTime();

    final Calendar calendar30 = CalendarUtils.getCalendarWithoutTime();
    calendar30.add(Calendar.MONTH, -36);

    final List<JobCountPerDay> jobCountPerDayList = jobService.getJobCountPerDayAndPeriod(calendar30.getTime(),
            calendarToday.getTime());/* w  w w. j av a 2 s.  c o m*/

    final TimeSeries hitsPerDayData = new TimeSeries("Hits", Day.class);
    final XYDataset hitsPerDayDataset = new TimeSeriesCollection(hitsPerDayData);
    this.chart = ChartFactory.createTimeSeriesChart("",
            super.getText("class.ShowStatisticsAcion.chart.job.count.caption"), "", hitsPerDayDataset, false,
            true, false);

    final XYPlot xyplot = (XYPlot) this.chart.getPlot();

    for (JobCountPerDay jobCountPerDay : jobCountPerDayList) {

        final Day day = new Day(jobCountPerDay.getJobDate());

        if (jobCountPerDay.getAutomaticallyCleaned()) {

            final Marker originalEnd = new ValueMarker(day.getFirstMillisecond());
            originalEnd.setPaint(new Color(0, 80, 138, 150));
            float[] dashPattern = { 6, 2 };

            originalEnd.setStroke(
                    new BasicStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10, dashPattern, 0));
            originalEnd.setLabelAnchor(RectangleAnchor.TOP_LEFT);
            originalEnd.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
            originalEnd.setLabel("C");
            originalEnd.setAlpha(0.1F);
            xyplot.addDomainMarker(originalEnd);
        }

        hitsPerDayData.add(day, jobCountPerDay.getTotalNumberOfJobs());
    }

    chart.setBackgroundPaint(new Color(255, 255, 255, 0));

    xyplot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    xyplot.setBackgroundPaint(new Color(255, 255, 255, 0));

    xyplot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    xyplot.setDomainCrosshairVisible(true);
    xyplot.setRangeCrosshairVisible(true);

    org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = xyplot.getRenderer();
    if (xyitemrenderer instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer;
        xylineandshaperenderer.setBaseShapesVisible(false);
        xyitemrenderer.setSeriesPaint(0, new Color(244, 66, 0));
    }

    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();

    dateaxis.setAutoRange(true);
    dateaxis.setAutoTickUnitSelection(true);

    NumberAxis valueAxis = (NumberAxis) xyplot.getRangeAxis();
    valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    return SUCCESS;
}