Example usage for org.jfree.chart.plot ValueMarker ValueMarker

List of usage examples for org.jfree.chart.plot ValueMarker ValueMarker

Introduction

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

Prototype

public ValueMarker(double value, Paint paint, Stroke stroke) 

Source Link

Document

Creates a new marker.

Usage

From source file:view.FuzzySetView.java

/**
 *
 * @param value/*  w  ww.j av  a 2 s  . c  om*/
 */
public void showSingleton(double value) {
    plot.clearDomainMarkers();

    BasicStroke stroke = new BasicStroke(2f);
    ValueMarker marker = new ValueMarker(value, Color.BLACK, stroke);
    plot.addDomainMarker(marker);

    fillView();
}

From source file:storybook.ui.chart.jfreechart.ChartUtil.java

public static Marker getAverageMarker(double paramDouble) {
    ValueMarker localValueMarker = new ValueMarker(paramDouble, Color.red, new BasicStroke(0.3F));
    localValueMarker.setLabel(I18N.getMsg("msg.common.average"));
    localValueMarker.setLabelFont(new Font("SansSerif", 2, 11));
    localValueMarker.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
    localValueMarker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
    return localValueMarker;
}

From source file:it.eng.spagobi.engines.kpi.bo.charttypes.dialcharts.BulletGraph.java

public JFreeChart createChart() {

    logger.debug("IN");
    Number value = null;/*from w w w .  j  a v  a 2  s. com*/

    if (dataset == null) {
        logger.debug("The dataset to be represented is null");
        value = new Double(0);
    } else {
        value = dataset.getValue();
    }

    DefaultCategoryDataset datasetC = new DefaultCategoryDataset();
    datasetC.addValue(value, "", "");

    // customize a bar chart 
    JFreeChart chart = ChartFactory.createBarChart(null, null, null, datasetC, PlotOrientation.HORIZONTAL,
            false, false, false);
    chart.setBorderVisible(false);

    CategoryPlot plot = chart.getCategoryPlot();
    plot.setOutlineVisible(true);
    plot.setOutlinePaint(Color.BLACK);

    plot.setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
    plot.setBackgroundPaint(null);
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);
    plot.setRangeCrosshairVisible(false);
    plot.setAnchorValue(value.doubleValue());

    // add the target marker 
    if (target != null) {
        ValueMarker marker = new ValueMarker(target.doubleValue(), Color.BLACK, new BasicStroke(2.0f));
        plot.addRangeMarker(marker, Layer.FOREGROUND);
    }

    //sets different marks
    for (Iterator iterator = intervals.iterator(); iterator.hasNext();) {
        KpiInterval interval = (KpiInterval) iterator.next();
        // add the marks 
        IntervalMarker marker = new IntervalMarker(interval.getMin(), interval.getMax(), interval.getColor());
        plot.addRangeMarker(marker, Layer.BACKGROUND);
        logger.debug("Added new interval to the plot");
    }

    // customize axes 
    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setVisible(false);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setVisible(show_axis);
    rangeAxis.setLabelFont(new Font("Arial", Font.PLAIN, 4));
    // calculate the upper limit 
    //double upperBound = target * upperFactor; 
    rangeAxis.setRange(new Range(lower, upper));
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    // customize renderer 
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setMaximumBarWidth(0.18);
    renderer.setSeriesPaint(0, Color.BLACK);
    /*BasicStroke d = new BasicStroke(3f,BasicStroke.CAP_ROUND ,BasicStroke.JOIN_ROUND);
    renderer.setSeriesOutlineStroke(0, d);
    renderer.setSeriesStroke(0, d);
            
    renderer.setStroke(d);*/

    return chart;
}

From source file:org.codehaus.mojo.dashboard.report.plugin.chart.time.MarkerTimeChartDecorator.java

public void createChart() {

    XYPlot xyplot = (XYPlot) report.getPlot();
    // if (this.decoratedChart instanceof TimeChartRenderer ) {

    if (this.results != null && !this.results.isEmpty()) {
        Iterator iter1 = this.results.iterator();
        ValueMarker valuemarker = null;/*from ww w .j  av a  2  s . c  om*/
        BlockContainer blockcontainerLabel = new BlockContainer(new ColumnArrangement());
        // blockcontainerLabel.setFrame( new LineBorder() );
        int i = 0;
        while (iter1.hasNext()) {
            Object[] item = (Object[]) iter1.next();
            Date date = (Date) item[1];
            Calendar cal = Calendar.getInstance();
            cal.setTime(date);
            cal.set(Calendar.HOUR_OF_DAY, 0);
            cal.set(Calendar.MINUTE, 0);
            cal.set(Calendar.SECOND, 0);
            valuemarker = new ValueMarker(cal.getTimeInMillis(), ChartColor.createDefaultPaintArray()[i],
                    new BasicStroke(2.0F));

            xyplot.addDomainMarker(valuemarker);
            LegendItem legendLabel = new LegendItem((String) item[0], null, null, null,
                    new Line2D.Double(-7.0, 0.0, 7.0, 0.0), valuemarker.getPaint(), valuemarker.getStroke(),
                    valuemarker.getPaint());

            blockcontainerLabel.add(createLegendItemBlock(legendLabel, i));
            i++;
        }
        createLegendBlock(blockcontainerLabel);
    }
    // }
}

From source file:mls.FramePlot.java

public void addMarker(double val, Color colore) {
    ValueMarker mark = new ValueMarker(val, colore, new BasicStroke(1));
    plotMedia.addRangeMarker(mark);//  ww  w  .  jav  a2 s .  c o m
}

From source file:uk.ac.ed.epcc.webapp.charts.jfreechart.JFreeTimeChartData.java

public void addWarningLevel(double value) {
    ((XYPlot) chart.getPlot()).addRangeMarker(new ValueMarker(value, Color.RED, new BasicStroke(2f)));

}

From source file:eu.udig.tools.jgrass.profile.ProfileView.java

public void addStopLine(double x) {

    DecimalFormat formatter = new DecimalFormat("0.0");
    // add a category marker
    ValueMarker marker = new ValueMarker(x, Color.red, new BasicStroke(1.0f));
    marker.setAlpha(0.6f);/*w  w w .  ja  v a 2  s . co  m*/
    marker.setLabel(formatter.format(x));
    marker.setLabelFont(new Font("Dialog", Font.PLAIN, 8));
    marker.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
    marker.setLabelOffset(new RectangleInsets(2, 5, 2, 5));
    plot.addDomainMarker(marker, Layer.BACKGROUND);
    markers.add(marker);
}

From source file:org.uncommons.watchmaker.swing.evolutionmonitor.JVMView.java

private JFreeChart createHeapChart(double maxMemory) {
    TimeSeriesCollection dataSet = new TimeSeriesCollection();
    dataSet.addSeries(memoryUsageSeries);
    dataSet.addSeries(heapSizeSeries);/*from w  ww  .  ja  v a 2  s.c  o  m*/
    JFreeChart chart = ChartFactory.createXYAreaChart("JVM Heap", "Time", "Megabytes", dataSet,
            PlotOrientation.VERTICAL, true, // Legend.
            false, // Tooltips.
            false);
    DateAxis timeAxis = new DateAxis("Time");
    timeAxis.setLowerMargin(0);
    timeAxis.setUpperMargin(0);
    chart.getXYPlot().setDomainAxis(timeAxis);
    chart.getXYPlot().getRangeAxis().setLowerBound(0);
    chart.getXYPlot().getRangeAxis().setUpperBound(maxMemory * 1.1); // Add 10% to leave room for marker.

    // Add a horizontal marker to indicate the heap growth limit.
    ValueMarker marker = new ValueMarker(maxMemory, Color.BLACK, new BasicStroke(1));
    marker.setLabel("Maximum Permitted Heap Size (adjust with -Xmx)");
    marker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
    marker.setLabelAnchor(RectangleAnchor.RIGHT);
    chart.getXYPlot().addRangeMarker(marker);

    chart.getXYPlot().getRenderer().setSeriesPaint(0, Color.RED);
    chart.getXYPlot().getRenderer().setSeriesPaint(1, new Color(0, 128, 0, 128));

    return chart;
}

From source file:storybook.ui.chart.jfreechart.ChartUtil.java

public static Marker getDateMarker(Date paramDate, String paramString, boolean paramBoolean) {
    double d = paramDate.getTime();
    ValueMarker localValueMarker = new ValueMarker(d, Color.red, new BasicStroke(0.3F));
    localValueMarker.setLabel(paramString);
    localValueMarker.setLabelFont(new Font("SansSerif", 2, 11));
    localValueMarker.setLabelAnchor(RectangleAnchor.BOTTOM);
    if (paramBoolean) {
        localValueMarker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
    } else {//w  w w. j  a  va 2  s. c  o  m
        localValueMarker.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT);
    }
    return localValueMarker;
}

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  .j  a  va  2s . c  om*/
 * @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;
}