Example usage for org.jfree.ui Layer FOREGROUND

List of usage examples for org.jfree.ui Layer FOREGROUND

Introduction

In this page you can find the example usage for org.jfree.ui Layer FOREGROUND.

Prototype

Layer FOREGROUND

To view the source code for org.jfree.ui Layer FOREGROUND.

Click Source Link

Document

Foreground.

Usage

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 a2 s .  c  o  m*/

    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:ec.ui.view.ARPView.java

@Override
protected void onColorSchemeChange() {
    XYPlot plot = getPlot();//from  w  ww . j  a va2  s .c  o  m
    plot.setBackgroundPaint(themeSupport.getPlotColor());
    plot.setDomainGridlinePaint(themeSupport.getGridColor());
    plot.setRangeGridlinePaint(themeSupport.getGridColor());
    chartPanel.getChart().setBackgroundPaint(themeSupport.getBackColor());

    plot.getRenderer().setBasePaint(themeSupport.getLineColor(KnownColor.BROWN));

    List<Marker> markers = new ArrayList<>();
    Collection rm = plot.getRangeMarkers(Layer.FOREGROUND);
    if (rm != null) {
        markers.addAll(rm);
    }
    Collection dm = plot.getDomainMarkers(Layer.FOREGROUND);
    if (dm != null) {
        markers.addAll(dm);
    }
    for (Marker o : markers) {
        if (o instanceof ExtValueMarker) {
            ((ExtValueMarker) o).applyColorScheme(themeSupport);
        }
    }
}

From source file:scheduler.benchmarker.manager.CreateStackedBarChart3D.java

public ChartPanel createChartPanel() {
    JFreeChart jfreechart = ChartFactory.createStackedBarChart3D(title, "Category", "Value", createDataset(),
            PlotOrientation.HORIZONTAL, true, true, false);
    jfreechart.setBackgroundPaint(new Color(214, 217, 223));

    CustomBarRenderer cRenderer = new CustomBarRenderer(pluginColors);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();

    ValueMarker marker = new ValueMarker(dataSource.getSumTotalTime());

    marker.setLabel("CLASSIFICATION FINISH");
    marker.setPaint(Color.RED);/*  w w  w .jav a2 s .co m*/
    marker.setLabelPaint(Color.RED);
    marker.setLabelAnchor(RectangleAnchor.TOP_LEFT);
    marker.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
    marker.setLabelOffsetType(LengthAdjustmentType.EXPAND);
    marker.setLabelFont(new Font(Font.SERIF, Font.BOLD, 12));

    categoryplot.addRangeMarker(marker, Layer.FOREGROUND);
    categoryplot.setFixedLegendItems(createCustomLegend());
    categoryplot.setRenderer(cRenderer);
    cPanel = new ChartPanel(jfreechart, true);
    return cPanel;
}

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

public JFreeChart createChart(DatasetMap datasets) {

    logger.debug("IN");
    Dataset dataset = (Dataset) datasets.getDatasets().get("1");
    ValueDataset valDataSet = (ValueDataset) dataset;

    Number value = valDataSet.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);/*from w  ww. ja  v  a 2s .  co m*/
    chart.setBorderVisible(false);

    chart.setBackgroundPaint(color);

    TextTitle title = setStyleTitle(name, styleTitle);
    chart.setTitle(title);
    if (subName != null && !subName.equals("")) {
        TextTitle subTitle = setStyleTitle(subName, styleSubTitle);
        chart.addSubtitle(subTitle);
    }

    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(true);
    // 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);

    return chart;
}

From source file:slash.navigation.converter.gui.elevationview.ElevationView.java

public void setSelectedPositions(int[] selectPositions) {
    plot.clearDomainMarkers();/*from w w w. j  av a 2 s  . com*/

    double[] distances = positionsModel.getRoute().getDistancesFromStart(selectPositions);
    for (double distance : distances) {
        plot.addDomainMarker(0, new ValueMarker(distance / 1000.0), Layer.FOREGROUND, false);
    }
    // make sure the protected fireChangeEvent() is called without any side effects
    plot.setWeight(plot.getWeight());
}

From source file:ec.ui.view.AutoCorrelationsView.java

@Override
protected void onColorSchemeChange() {
    XYPlot plot = chartPanel.getChart().getXYPlot();
    plot.setBackgroundPaint(themeSupport.getPlotColor());
    plot.setDomainGridlinePaint(themeSupport.getGridColor());
    plot.setRangeGridlinePaint(themeSupport.getGridColor());
    chartPanel.getChart().setBackgroundPaint(themeSupport.getBackColor());

    XYItemRenderer renderer = plot.getRenderer();
    KnownColor color = ACKind.Normal == kind ? NORMAL_COLOR : PARTIAL_COLOR;
    renderer.setBasePaint(themeSupport.getAreaColor(color));
    renderer.setBaseOutlinePaint(themeSupport.getLineColor(color));

    Collection<Marker> markers = (Collection<Marker>) plot.getDomainMarkers(Layer.FOREGROUND);
    if (!Jdk6.Collections.isNullOrEmpty(markers)) {
        Color markerColor = themeSupport.getLineColor(MARKER_COLOR);
        for (Marker o : markers) {
            o.setPaint(markerColor);//from ww  w .j av a  2 s  .  c om
        }
    }
}

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

/**
 * Returns the chart./*w w w .  j av  a  2  s .  co  m*/
 *
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
private JFreeChart createChart(final CategoryDataset dataset) {

    final CategoryAxis xAxis = new CategoryAxis("Category");
    final NumberAxis yAxis = new NumberAxis("$ in Thousands");
    yAxis.setLowerMargin(0.10);
    yAxis.setUpperMargin(0.10);

    // create a custom tick unit collection...
    final DecimalFormat formatter = new DecimalFormat("##,###");
    formatter.setNegativePrefix("(");
    formatter.setNegativeSuffix(")");
    final TickUnits standardUnits = new TickUnits();
    standardUnits.add(new NumberTickUnit(200, formatter));
    standardUnits.add(new NumberTickUnit(500, formatter));
    standardUnits.add(new NumberTickUnit(1000, formatter));
    standardUnits.add(new NumberTickUnit(2000, formatter));
    standardUnits.add(new NumberTickUnit(5000, formatter));

    yAxis.setStandardTickUnits(standardUnits);

    // ****************************************************************************
    // * JFREECHART DEVELOPER GUIDE                                               *
    // * The JFreeChart Developer Guide, written by David Gilbert, is available   *
    // * to purchase from Object Refinery Limited:                                *
    // *                                                                          *
    // * http://www.object-refinery.com/jfreechart/guide.html                     *
    // *                                                                          *
    // * Sales are used to provide funding for the JFreeChart project - please    * 
    // * support us so that we can continue developing free software.             *
    // ****************************************************************************

    final DecimalFormat labelFormatter = new DecimalFormat("##,###");
    labelFormatter.setNegativePrefix("(");
    labelFormatter.setNegativeSuffix(")");

    final WaterfallBarRenderer renderer = new WaterfallBarRenderer();
    //        renderer.setLabelGenerator(
    //          new StandardCategoryLabelGenerator("{2}", labelFormatter)
    //    );
    renderer.setItemLabelsVisible(Boolean.TRUE);

    final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.white);
    plot.setRangeGridlinesVisible(true);
    final ValueMarker baseline = new ValueMarker(0.0);
    baseline.setPaint(Color.blue);
    baseline.setStroke(new BasicStroke(1.1f));
    plot.addRangeMarker(baseline, Layer.FOREGROUND);

    final JFreeChart chart = new JFreeChart("OM WaterFall Chart", JFreeChart.DEFAULT_TITLE_FONT, plot, false);
    chart.setBackgroundPaint(Color.white);
    return chart;
}

From source file:org.openfaces.component.chart.impl.configuration.charts.GridChartConfigurator.java

private Layer getMarkerLayer(Marker marker) {
    if (marker.getLayer() != null && marker.getLayer().equals(MarkerLayer.FOREGROUND)) {
        return Layer.FOREGROUND;
    } else {//from  ww w  . ja va 2  s  .  c om
        return Layer.BACKGROUND;
    }
}

From source file:com.ivli.roim.controls.ChartControl.java

void addMarker(DomainMarker aM) {
    getChart().getXYPlot().addDomainMarker(aM, Layer.FOREGROUND);
    ValueMarker vm = new ValueMarker(.0);
    getChart().getXYPlot().addRangeMarker(vm, Layer.FOREGROUND);
    aM.setLinkedMarker(vm);/*  w w  w.  j  a v a  2  s  .  c o m*/
}

From source file:ec.ui.view.MarginView.java

@Override
protected void onColorSchemeChange() {
    XYPlot plot = chartPanel.getChart().getXYPlot();
    plot.setBackgroundPaint(themeSupport.getPlotColor());
    plot.setDomainGridlinePaint(themeSupport.getGridColor());
    plot.setRangeGridlinePaint(themeSupport.getGridColor());
    chartPanel.getChart().setBackgroundPaint(themeSupport.getBackColor());

    XYLineAndShapeRenderer main = (XYLineAndShapeRenderer) plot.getRenderer(MAIN_INDEX);
    main.setBasePaint(themeSupport.getLineColor(MAIN_COLOR));

    XYDifferenceRenderer difference = ((XYDifferenceRenderer) plot.getRenderer(DIFFERENCE_INDEX));
    Color diffArea = SwingColorSchemeSupport.withAlpha(themeSupport.getAreaColor(DIFFERENCE_COLOR), 150);
    difference.setPositivePaint(diffArea);
    difference.setNegativePaint(diffArea);
    difference.setBasePaint(themeSupport.getLineColor(DIFFERENCE_COLOR));

    Collection<Marker> markers = (Collection<Marker>) plot.getDomainMarkers(Layer.FOREGROUND);
    if (!Jdk6.Collections.isNullOrEmpty(markers)) {
        Color markerColor = themeSupport.getLineColor(DATE_MARKER_COLOR);
        for (Marker o : markers) {
            o.setPaint(markerColor);//from  www.j  a v  a2s . co  m
        }
    }

    Collection<Marker> intervalMarkers = (Collection<Marker>) plot.getDomainMarkers(Layer.BACKGROUND);
    if (!Jdk6.Collections.isNullOrEmpty(intervalMarkers)) {
        Color markerColor = themeSupport.getLineColor(KnownColor.ORANGE);
        for (Marker o : intervalMarkers) {
            o.setPaint(markerColor);
        }
    }
}