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

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

Introduction

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

Prototype

public void setForegroundAlpha(float alpha) 

Source Link

Document

Sets the alpha-transparency for the plot and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:edu.ucla.stat.SOCR.chart.SuperBubbleChart.java

/**
 * Creates a chart./*from  w w w. j av a2s. com*/
 * 
 * @param dataset  the dataset.
 * 
 * @return a chart.
 */
protected JFreeChart createChart(XYZDataset dataset) {
    // create the chart...
    JFreeChart chart = ChartFactory.createBubbleChart(chartTitle, // chart titl                          
            rangeLabel, // y axis label
            domainLabel, // x axis label
            dataset, // data
            PlotOrientation.VERTICAL, !legendPanelOn, // include legend
            true, // tooltips
            false // urls
    );

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setForegroundAlpha(0.65f);

    XYItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesPaint(0, Color.blue);
    renderer.setLegendItemLabelGenerator(new SOCRXYZSeriesLabelGenerator());

    // increase the margins to account for the fact that the auto-range 
    // doesn't take into account the bubble size...
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setLowerMargin(0.15);
    domainAxis.setUpperMargin(0.15);
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setLowerMargin(0.15);
    rangeAxis.setUpperMargin(0.15);

    return chart;
}

From source file:slash.navigation.converter.gui.profileview.ProfileView.java

private XYPlot createPlot(JFreeChart chart) {
    XYPlot plot = chart.getXYPlot();
    plot.setForegroundAlpha(0.65F);
    plot.setDomainGridlinesVisible(preferences.getBoolean(X_GRID_PREFERENCE, true));
    plot.setRangeGridlinesVisible(preferences.getBoolean(Y_GRID_PREFERENCE, true));

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(createIntegerTickUnits());
    Font font = new JLabel().getFont();
    rangeAxis.setLabelFont(font);//from  w w  w .  j  a  v a 2 s.  c  o m

    NumberAxis valueAxis = (NumberAxis) plot.getDomainAxis();
    valueAxis.setStandardTickUnits(createIntegerTickUnits());
    valueAxis.setLowerMargin(0.0);
    valueAxis.setUpperMargin(0.0);
    valueAxis.setLabelFont(font);

    plot.getRenderer().setBaseToolTipGenerator(null);
    return plot;
}

From source file:org.operamasks.faces.render.graph.CurveAreaChartRenderer.java

private JFreeChart createXYCurveAreaChart(XYDataset dataset, PlotOrientation orientation) {
    ValueAxis xAxis;/*  www . j ava2 s  .  c o  m*/
    if (dataset instanceof TimeSeriesCollection) {
        xAxis = new DateAxis();
    } else {
        xAxis = new NumberAxis();
        ((NumberAxis) xAxis).setAutoRangeIncludesZero(false);
    }
    xAxis.setLowerMargin(0.0);
    xAxis.setUpperMargin(0.0);

    NumberAxis yAxis = new NumberAxis();
    yAxis.setAutoRangeIncludesZero(false);

    XYCurveAndShapeRenderer renderer = new XYCurveAndShapeRenderer(true, false);
    renderer.setDrawArea(true);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setOrientation(orientation);
    if (dataset.getSeriesCount() > 1) {
        plot.setForegroundAlpha(0.75f);
    }

    return new JFreeChart(null, null, plot, false);
}

From source file:com.itemanalysis.jmetrik.graph.itemmap.ItemMapPanel.java

public void updateItemDataSet(HistogramChartDataset data) {
    //set histogram data
    CombinedDomainXYPlot cplot = (CombinedDomainXYPlot) chart.getPlot();
    List plots = cplot.getSubplots();
    XYPlot p = (XYPlot) plots.get(1);
    if (data.getSeriesCount() > 1)
        p.setForegroundAlpha(0.70f);
    p.setDataset(1, data);//from ww  w  .  ja  v a2s  . com
}

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

/**
 * Creates a chart./* w w w. j av  a2  s .  c  o  m*/
 * 
 * @param dataset  the dataset.
 * 
 * @return A chart.
 */
private JFreeChart createChart(final XYDataset dataset) {

    final JFreeChart chart = ChartFactory.createXYAreaChart("XY Area Chart Demo", "Domain (X)", "Range (Y)",
            dataset, PlotOrientation.VERTICAL, true, // legend
            true, // tool tips
            false // URLs
    );

    chart.setBackgroundPaint(Color.white);

    final XYPlot plot = chart.getXYPlot();
    //plot.setOutlinePaint(Color.black);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setForegroundAlpha(0.65f);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    final ValueAxis domainAxis = plot.getDomainAxis();
    domainAxis.setTickMarkPaint(Color.black);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);

    final ValueAxis rangeAxis = plot.getRangeAxis();
    rangeAxis.setTickMarkPaint(Color.black);

    return chart;

}

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

/**
 * Creates a chart./*from  www .j  a v  a 2  s. co  m*/
 * 
 * @param dataset  the dataset.
 * 
 * @return A chart.
 */
private JFreeChart createChart(final XYDataset dataset) {

    final JFreeChart chart = ChartFactory.createXYAreaChart("XY Area Chart Test", "Domain (X)", "Range (Y)",
            dataset, PlotOrientation.VERTICAL, true, // legend
            true, // tool tips
            false // URLs
    );

    chart.setBackgroundPaint(Color.white);

    final XYPlot plot = chart.getXYPlot();
    //plot.setOutlinePaint(Color.black);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setForegroundAlpha(0.65f);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    plot.setRenderer(new XYAreaRenderer2());
    final ValueAxis domainAxis = plot.getDomainAxis();
    domainAxis.setTickMarkPaint(Color.black);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);

    final ValueAxis rangeAxis = plot.getRangeAxis();
    rangeAxis.setTickMarkPaint(Color.black);

    return chart;

}

From source file:com.itemanalysis.jmetrik.graph.histogram.HistogramPanel.java

public void setGraph() {
    HistogramChartDataset dataset = null;
    dataset = new HistogramChartDataset();

    chart = HistogramChart.createHistogram(chartTitle, xlabel, //x-axis label
            ylabel, //y-axis label
            dataset, chartOrientation, hasGroupingVariable, //legend
            true, //tooltips
            false //urls
    );/*from w  ww.j av a2  s .c o  m*/

    if (chartSubtitle != null && !"".equals(chartSubtitle)) {
        TextTitle subtitle1 = new TextTitle();
        chart.addSubtitle(subtitle1);
    }

    XYPlot plot = (XYPlot) chart.getPlot();
    if (hasGroupingVariable)
        plot.setForegroundAlpha(0.80f);
    plot.setBackgroundPaint(Color.WHITE);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(true);
    renderer.setShadowVisible(false);

    //next two lines are temp setting for book
    //these two lines will create a histogram with white bars so it appears as just the bar outline
    //        renderer.setBarPainter(new StandardXYBarPainter());
    //        renderer.setSeriesPaint(0, Color.white);

    ChartPanel panel = new ChartPanel(chart);
    panel.getPopupMenu().addSeparator();
    this.addJpgMenuItem(this, panel.getPopupMenu());
    panel.setPreferredSize(new Dimension(width, height));

    //        //temp setting for book
    //        this.addLocalEPSMenuItem(this, panel.getPopupMenu(), chart);//remove this line for public release versions

    chart.setPadding(new RectangleInsets(20.0, 5.0, 20.0, 5.0));
    this.setBackground(Color.WHITE);
    this.add(panel);

}

From source file:edu.ucla.stat.SOCR.chart.demo.XYAreaChartDemo1.java

/**
 * Creates a chart.//from  ww w  .  j  a  v a2s.co  m
 * 
 * @param dataset  the dataset.
 * 
 * @return A chart.
 */
protected JFreeChart createChart(XYDataset dataset) {

    JFreeChart chart = ChartFactory.createXYAreaChart(chartTitle, "Domain (X)", "Range (Y)", dataset,
            PlotOrientation.VERTICAL, !legendPanelOn, // legend
            true, // tool tips
            false // URLs
    );

    chart.setBackgroundPaint(Color.white);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setForegroundAlpha(0.65f);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    ValueAxis domainAxis = plot.getDomainAxis();
    domainAxis.setTickMarkPaint(Color.black);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);

    ValueAxis rangeAxis = plot.getRangeAxis();
    rangeAxis.setTickMarkPaint(Color.black);

    /*  XYPointerAnnotation pointer = new XYPointerAnnotation(
    "Test", 5.0, -500.0, 3.0 * Math.PI / 4.0
      );
      pointer.setTipRadius(0.0); 
      pointer.setBaseRadius(35.0); 
      pointer.setFont(new Font("SansSerif", Font.PLAIN, 9)); 
      pointer.setPaint(Color.blue); 
      pointer.setTextAnchor(TextAnchor.HALF_ASCENT_RIGHT); 
      plot.addAnnotation(pointer);*/

    XYItemRenderer renderer = plot.getRenderer();
    renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator());
    setXSummary(dataset);
    return chart;

}

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

/**
 * Creates a chart./*from ww  w .  j  av  a 2s  .co m*/
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
private JFreeChart createChart(final XYDataset dataset) {
    final JFreeChart chart = ChartFactory.createXYAreaChart("XY Area Chart Demo 2", "Time", "Value", dataset,
            PlotOrientation.VERTICAL, true, // legend
            true, // tool tips
            false // URLs
    );
    final XYPlot plot = chart.getXYPlot();

    final ValueAxis domainAxis = new DateAxis("Time");
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    plot.setDomainAxis(domainAxis);
    plot.setForegroundAlpha(0.5f);

    final XYItemRenderer renderer = plot.getRenderer();
    renderer.setToolTipGenerator(
            new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
                    new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("#,##0.00")));
    return chart;
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.clusterchart.SimpleCluster.java

public JFreeChart createChart(DatasetMap datasets) {

    DefaultXYZDataset dataset = (DefaultXYZDataset) datasets.getDatasets().get("1");

    JFreeChart chart = ChartFactory.createBubbleChart(name, yLabel, xLabel, dataset, PlotOrientation.HORIZONTAL,
            legend, true, false);//  ww w. j  av  a 2  s .  c  o  m

    /*Font font = new Font("Tahoma", Font.BOLD, titleDimension);
    TextTitle title = new TextTitle(name, font);
    chart.setTitle(title);*/

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

    Color colorSubInvisibleTitle = Color.decode("#FFFFFF");
    StyleLabel styleSubSubTitle = new StyleLabel("Arial", 12, colorSubInvisibleTitle);
    TextTitle subsubTitle = setStyleTitle("", styleSubSubTitle);
    chart.addSubtitle(subsubTitle);

    chart.setBackgroundPaint(color);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD);
    //plot.setForegroundAlpha(0.50f);
    plot.setForegroundAlpha(0.65f);

    XYItemRenderer renderer = plot.getRenderer();

    //define colors
    int seriesN = dataset.getSeriesCount();
    if (colorMap != null) {
        boolean isSerieSel = true;
        for (int i = 0; i < seriesN; i++) {
            String serieName = (String) dataset.getSeriesKey(i);
            String tmpName = serieName.replaceAll(" ", "");
            tmpName = tmpName.replace('.', ' ').trim();
            if (serie_selected != null && serie_selected.size() > 0) {
                String serieSel = serie_selected.get(tmpName).toString();
                isSerieSel = (serieSel.equalsIgnoreCase("TRUE") || serieSel.equalsIgnoreCase("YES")
                        || serieSel.equalsIgnoreCase("1")) ? true : false;
                serieName = tmpName;
            }

            if (color != null && isSerieSel) {
                Color color = (Color) colorMap.get(serieName);
                renderer.setSeriesPaint(i, color);
            } else {
                Color color = new Color(Integer.decode(defaultColor).intValue());
                renderer.setSeriesPaint(i, color);
            }
        }
    }

    // increase the margins to account for the fact that the auto-range 
    // doesn't take into account the bubble size...
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    //domainAxis.setAutoRange(true);
    domainAxis.setRange(yMin, yMax);
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();

    rangeAxis.setLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize()));
    rangeAxis.setLabelPaint(styleXaxesLabels.getColor());
    rangeAxis
            .setTickLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize()));
    rangeAxis.setTickLabelPaint(styleXaxesLabels.getColor());

    //rangeAxis.setAutoRange(true);
    rangeAxis.setRange(xMin, xMax);

    TickUnits units = null;
    if (decimalXValues == false)
        units = (TickUnits) NumberAxis.createIntegerTickUnits();
    else
        units = (TickUnits) NumberAxis.createStandardTickUnits();
    rangeAxis.setStandardTickUnits(units);

    TickUnits domainUnits = null;
    if (decimalYValues == false)
        domainUnits = (TickUnits) NumberAxis.createIntegerTickUnits();
    else
        domainUnits = (TickUnits) NumberAxis.createStandardTickUnits();
    domainAxis.setStandardTickUnits(domainUnits);

    rangeAxis.setLowerMargin(1.0);
    rangeAxis.setUpperMargin(1.0);

    domainAxis.setLabelFont(new Font(styleYaxesLabels.getFontName(), Font.PLAIN, styleYaxesLabels.getSize()));
    domainAxis.setLabelPaint(styleYaxesLabels.getColor());
    domainAxis
            .setTickLabelFont(new Font(styleYaxesLabels.getFontName(), Font.PLAIN, styleYaxesLabels.getSize()));
    domainAxis.setTickLabelPaint(styleYaxesLabels.getColor());

    domainAxis.setLowerMargin(1.0);
    domainAxis.setUpperMargin(1.0);
    //DecimalFormat format=(new DecimalFormat("0"));
    //rangeAxis.setNumberFormatOverride(format);

    if (legend == true)
        drawLegend(chart);

    return chart;
}