Example usage for org.jfree.chart.renderer.xy XYLineAndShapeRenderer setBaseShapesVisible

List of usage examples for org.jfree.chart.renderer.xy XYLineAndShapeRenderer setBaseShapesVisible

Introduction

In this page you can find the example usage for org.jfree.chart.renderer.xy XYLineAndShapeRenderer setBaseShapesVisible.

Prototype

public void setBaseShapesVisible(boolean flag) 

Source Link

Document

Sets the base 'shapes visible' flag and sends a RendererChangeEvent to all registered listeners.

Usage

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

private JFreeChart createLineChart(String title, String xLabel, String yLabel, XYDataset dataset,
        String other) {//  w  w w . j  a v  a2 s .c o m

    // create the chart...
    JFreeChart chart = ChartFactory.createXYLineChart(title, // chart title
            xLabel, // domain axis label
            yLabel, // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            false, // include legend
            true, // tooltips
            false // urls
    );

    chart.setBackgroundPaint(Color.white);

    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.white);
    plot.setDomainGridlinePaint(Color.white);
    //plot.setNoDataMessage("No data available");

    // customise the range axis...

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    //rangeAxis.setAutoRange(false);   
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    // domainAxis.setAutoRange(false);   
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // customise the renderer...
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setBaseLinesVisible(false);
    renderer.setDrawOutlines(true);
    renderer.setBaseShapesFilled(true);
    renderer.setUseFillPaint(true);
    //renderer.setFillPaint(Color.white);

    if (other.toLowerCase().indexOf("noshape") != -1) {
        renderer.setBaseShapesVisible(false);
        renderer.setBaseLinesVisible(true);
    }

    if (other.toLowerCase().indexOf("excludeszero") != -1) {
        rangeAxis.setAutoRangeIncludesZero(false);
        domainAxis.setAutoRangeIncludesZero(false);
    }

    return chart;
}

From source file:sentimentanalyzer.ChartController.java

public void postTheTimeSeriesChartOnTheGUI_sentiment(JPanel timeSeriesChart, XYSeriesCollection dataset,
        String title, String y, String x, int row) {
    this.wordSentimentScore = ChartFactory.createXYLineChart(title, y, x, dataset, PlotOrientation.VERTICAL,
            true, true, false);//from   w  w w. j a  v  a 2 s  .co  m

    this.wordIndexesOnGraph.add(row);
    this.plot_sentiment = this.wordSentimentScore.getXYPlot();

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();

    //CHECK THIS
    renderer.setBaseShapesVisible(true);

    this.plot_sentiment.setRenderer(renderer);
    this.plot_sentiment.setOutlinePaint(Color.orange);

    NumberAxis rangeAxis = (NumberAxis) this.plot_sentiment.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    NumberAxis domainAxis = (NumberAxis) this.plot_sentiment.getDomainAxis();
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    this.wordSentimentScore.setBackgroundPaint(Color.white);
    this.wordSentimentScore.setBorderPaint(Color.ORANGE);
    ChartPanel CP = new ChartPanel(this.wordSentimentScore);
    timeSeriesChart.setLayout(new java.awt.BorderLayout());
    timeSeriesChart.add(CP, BorderLayout.CENTER);
    timeSeriesChart.revalidate();
}

From source file:web.diva.server.unused.ProfilePlotGenerator.java

private XYLineAndShapeRenderer chartColorUpdate(XYLineAndShapeRenderer renderer, String[] colors,
        HashMap<String, Color> colorMap) {
    if (renderer == null) {
        renderer = new XYLineAndShapeRenderer();
    }//from   w  w  w.  j av a 2  s .c  o m
    renderer.setBaseShapesVisible(false);//setShapesVisible(false);
    if (colorMap.size() > 2) {
        for (int x = 0; x < colors.length; x++) {
            if (colors[x].equalsIgnoreCase("#000000")) {
                renderer.setSeriesPaint(x, Color.BLACK);
                continue;
            }
            renderer.setSeriesPaint(x, colorMap.get(colors[x]));
        }
    } else {
        renderer.setPaint(Color.BLACK);

    }
    return renderer;

}

From source file:sentimentanalyzer.ChartController.java

public void postTheTimeSeriesChartOnTheGUI_words(JPanel timeSeriesChart, XYSeriesCollection dataset,
        String title, String y, String x, int row) {
    this.wordCountsChart = ChartFactory.createXYLineChart(title, x, y, dataset, PlotOrientation.VERTICAL, true,
            true, false);//from  w ww .j a va 2 s  .c o  m

    this.wordIndexesOnGraph.add(row);
    this.plot_counter = this.wordCountsChart.getXYPlot();

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();

    //CHECK THIS
    renderer.setBaseShapesVisible(true);

    this.plot_counter.setRenderer(renderer);
    this.plot_counter.setOutlinePaint(Color.orange);

    NumberAxis rangeAxis = (NumberAxis) this.plot_counter.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    NumberAxis domainAxis = (NumberAxis) this.plot_counter.getDomainAxis();
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    this.wordCountsChart.setBackgroundPaint(Color.white);
    this.wordCountsChart.setBorderPaint(Color.orange);
    ChartPanel CP = new ChartPanel(this.wordCountsChart);

    timeSeriesChart.setLayout(new java.awt.BorderLayout());
    timeSeriesChart.add(CP, BorderLayout.CENTER);
    timeSeriesChart.revalidate();
}

From source file:com.epiq.bitshark.ui.TimeDomainPanel.java

/**
 * Initializes the graph//from w w  w  .ja  v  a2  s.  c o m
 */
private void initGraph() {
    dataset = new XYSeriesCollection();

    realSeries = new BasicSeries("Real");
    imaginarySeries = new BasicSeries("Imaginary");

    dataset.addSeries(realSeries);
    dataset.addSeries(imaginarySeries);

    graph = ChartFactory.createXYLineChart(null, // no title
            "", // no x-axis label
            "", // no y-axis label
            dataset, // data
            PlotOrientation.VERTICAL, false, // no legend
            false, // no tooltips
            false // no URLs
    );

    graph.setBorderVisible(false);
    graph.setPadding(new RectangleInsets(-5, -5, 0, -7));
    graph.setBackgroundPaint(null);
    graph.setAntiAlias(true);

    plot = (XYPlot) graph.getPlot();
    plot.setBackgroundAlpha(0.0f);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);
    plot.setAxisOffset(new RectangleInsets(0, 0, 0, 0));
    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);

    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(false);
        renderer.setBaseShapesFilled(true);
        renderer.setSeriesPaint(0, I_COLOR);
        renderer.setSeriesPaint(1, Q_COLOR);
    }

    // X-axis setup
    plot.getDomainAxis().setAutoRange(false);
    plot.getDomainAxis().setVisible(true);
    plot.getDomainAxis().setRange(0, FMCUartClient.BLOCK_SIZE - 1);

    // Y-axis setup
    plot.getRangeAxis().setAutoRange(false);
    plot.getRangeAxis().setVisible(true);
    plot.getRangeAxis().setUpperBound(Math.pow(2, 13));
    plot.getRangeAxis().setLowerBound(-Math.pow(2, 13));

    // setup chart panel
    chartPanel = new ChartPanel(graph, false);
    chartPanel.setMouseZoomable(false);
    chartPanel.setOpaque(false);
    chartPanel.setMaximumDrawWidth(Integer.MAX_VALUE);
    chartPanel.setMaximumDrawHeight(Integer.MAX_VALUE);
    chartPanel.setMinimumDrawWidth(0);
    chartPanel.setMinimumDrawHeight(0);
    chartPanel.setDomainZoomable(true);
    // mouse wheel zooming
    chartPanel.addMouseWheelListener(new MouseWheelListener() {
        @Override
        public void mouseWheelMoved(MouseWheelEvent e) {
            int clicks = e.getWheelRotation();
            plot.getRangeAxis().setUpperBound(plot.getRangeAxis().getUpperBound() - (clicks * 100));
            plot.getRangeAxis().setLowerBound(plot.getRangeAxis().getLowerBound() + (clicks * 100));
        }
    });
}

From source file:graficoComparacion.graficaCompa.java

public graficaCompa() {

    //sxy.add(x[0], y[0]);

    ///////////////
    /*   s1.add(new Month(4, 2001), 153.8);
       s1.add(new Month(5, 2001), 167.6);
       s1.add(new Month(6, 2001), 158.8);
       s1.add(new Month(7, 2001), 148.3);
       s1.add(new Month(8, 2001), 153.9);
       s1.add(new Month(9, 2001), 142.7);
       s1.add(new Month(10, 2001), 123.2); 
       //////////////////////////////////////
       datos.addSeries(s1);/*from   w w w  .java2  s.c om*/
    */
    grafica = ChartFactory.createTimeSeriesChart("Progreso de cargas", "Fechas", "Peso", datos, true, true,
            false);
    /// 
    grafica.setBackgroundPaint(Color.white);

    XYPlot plot = (XYPlot) grafica.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);
        renderer.setBaseShapesFilled(true);
        renderer.setDrawSeriesLineAsPath(true);
    }

    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));

}

From source file:imc.graficaIMC.java

public void iejmplo() {
    TimeSeries s1 = new TimeSeries("Entrenamiento Actual");
    s1.add(new Month(2, 2001), 181.8);
    //s1.add(new Week(1, 1), null);
    s1.add(new Month(3, 2001), 167.3);
    s1.add(new Month(4, 2001), 153.8);
    s1.add(new Month(5, 2001), 167.6);
    s1.add(new Month(6, 2001), 158.8);
    s1.add(new Month(7, 2001), 148.3);
    s1.add(new Month(8, 2001), 153.9);
    s1.add(new Month(9, 2001), 142.7);
    s1.add(new Month(10, 2001), 123.2);
    s1.add(new Month(11, 2001), 131.8);
    s1.add(new Month(12, 2001), 139.6);
    s1.add(new Month(1, 2002), 142.9);
    s1.add(new Month(2, 2002), 138.7);
    s1.add(new Month(3, 2002), 137.3);
    s1.add(new Month(4, 2002), 143.9);
    s1.add(new Month(5, 2002), 139.8);
    s1.add(new Month(6, 2002), 137.0);
    s1.add(new Month(7, 2002), 132.8);

    TimeSeries s2 = new TimeSeries("L&G UK Index Trust");
    s2.add(new Month(2, 2001), 129.6);
    s2.add(new Month(3, 2001), 123.2);
    s2.add(new Month(4, 2001), 117.2);
    s2.add(new Month(5, 2001), 124.1);
    s2.add(new Month(6, 2001), 122.6);
    s2.add(new Month(7, 2001), 119.2);
    s2.add(new Month(8, 2001), 116.5);
    s2.add(new Month(9, 2001), 112.7);
    s2.add(new Month(10, 2001), 101.5);
    s2.add(new Month(11, 2001), 106.1);
    s2.add(new Month(12, 2001), 110.3);
    s2.add(new Month(1, 2002), 111.7);
    s2.add(new Month(2, 2002), 111.0);
    s2.add(new Month(3, 2002), 109.6);
    s2.add(new Month(4, 2002), 113.2);
    s2.add(new Month(5, 2002), 111.6);
    s2.add(new Month(6, 2002), 108.8);
    s2.add(new Month(7, 2002), 101.6);

    TimeSeries s3 = new TimeSeries("andres2255");
    s3.add(new Month(2, 2001), 129.6);

    s3.add(new Month(10, 2001), 106.1);
    s3.add(new Month(1, 2002), 111.7);
    s3.add(new Month(2, 2002), 111.0);
    datos.addSeries(s1);/*from w  w  w  .j  ava2 s. c om*/
    datos.addSeries(s2);
    datos.addSeries(s3);

    grafica = ChartFactory.createTimeSeriesChart("titulo", "etiquetas X", "etiquetaY", datos, true, true,
            false);
    /// 
    grafica.setBackgroundPaint(Color.white);

    XYPlot plot = (XYPlot) grafica.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);
        renderer.setBaseShapesFilled(true);
        renderer.setDrawSeriesLineAsPath(true);
    }

    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));
}

From source file:de.tsystems.mms.apm.performancesignature.PerfSigBuildActionResultsDisplay.java

private JFreeChart createTimeSeriesChart(final StaplerRequest req, final XYDataset dataset)
        throws UnsupportedEncodingException {
    String chartDashlet = req.getParameter(Messages.PerfSigBuildActionResultsDisplay_ReqParamChartDashlet());
    String measure = req.getParameter(Messages.PerfSigBuildActionResultsDisplay_ReqParamMeasure());
    String unit = req.getParameter(Messages.PerfSigBuildActionResultsDisplay_ReqParamUnit());
    String color = req.getParameter(Messages.PerfSigBuildActionResultsDisplay_ReqParamColor());
    if (StringUtils.isBlank(color))
        color = Messages.PerfSigBuildActionResultsDisplay_DefaultColor();
    else//from  w  w  w  .  j  av  a 2  s  .com
        URLDecoder.decode(req.getParameter(Messages.PerfSigBuildActionResultsDisplay_ReqParamColor()), "UTF-8");

    String[] timeUnits = { "ns", "ms", "s", "min", "h" };
    JFreeChart chart;

    if (ArrayUtils.contains(timeUnits, unit)) {
        chart = ChartFactory.createTimeSeriesChart(PerfSigUtils.generateTitle(measure, chartDashlet), // title
                "time", // domain axis label
                unit, dataset, // data
                false, // include legend
                false, // tooltips
                false // urls
        );
    } else {
        chart = ChartFactory.createXYBarChart(PerfSigUtils.generateTitle(measure, chartDashlet), // title
                "time", // domain axis label
                true, unit, (IntervalXYDataset) dataset, // data
                PlotOrientation.VERTICAL, // orientation
                false, // include legend
                false, // tooltips
                false // urls
        );
    }

    XYPlot xyPlot = chart.getXYPlot();
    xyPlot.setForegroundAlpha(0.8f);
    xyPlot.setRangeGridlinesVisible(true);
    xyPlot.setRangeGridlinePaint(Color.black);
    xyPlot.setOutlinePaint(null);

    XYItemRenderer xyitemrenderer = xyPlot.getRenderer();
    if (xyitemrenderer instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer;
        xylineandshaperenderer.setBaseShapesVisible(true);
        xylineandshaperenderer.setBaseShapesFilled(true);
    }
    DateAxis dateAxis = (DateAxis) xyPlot.getDomainAxis();
    dateAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
    dateAxis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss"));
    xyitemrenderer.setSeriesPaint(0, Color.decode(color));
    xyitemrenderer.setSeriesStroke(0, new BasicStroke(2));

    chart.setBackgroundPaint(Color.white);
    return chart;
}

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

/**
 * Creates a chart./*from   www. j a v a2s . c o m*/
 * 
 * @param dataset  the dataset.
 * 
 * @return a chart.
 */
protected JFreeChart createChart1(XYDataset dataset) {
    // create the chart...
    JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title
            domainLabel, // x axis label
            rangeLabel, // y axis label
            dataset, // data
            PlotOrientation.HORIZONTAL, !legendPanelOn, // include legend
            true, // tooltips
            false // urls
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);

    // change the auto tick unit selection to integer units only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

From source file:visualizer.datamining.dataanalysis.NeighborhoodPreservation.java

private JFreeChart createChart(XYDataset xydataset) {
    JFreeChart chart = ChartFactory.createXYLineChart("Neighborhood Preservation", "Number Neighbors",
            "Precision", xydataset, PlotOrientation.VERTICAL, true, true, false);

    chart.setBackgroundPaint(Color.WHITE);

    XYPlot xyplot = (XYPlot) chart.getPlot();
    NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis();
    numberaxis.setAutoRangeIncludesZero(false);

    xyplot.setDomainGridlinePaint(Color.BLACK);
    xyplot.setRangeGridlinePaint(Color.BLACK);

    xyplot.setOutlinePaint(Color.BLACK);
    xyplot.setOutlineStroke(new BasicStroke(1.0f));
    xyplot.setBackgroundPaint(Color.white);
    xyplot.setDomainCrosshairVisible(true);
    xyplot.setRangeCrosshairVisible(true);

    xyplot.setDrawingSupplier(new DefaultDrawingSupplier(
            new Paint[] { Color.RED, Color.BLUE, Color.GREEN, Color.MAGENTA, Color.CYAN, Color.ORANGE,
                    Color.BLACK, Color.DARK_GRAY, Color.GRAY, Color.LIGHT_GRAY, Color.YELLOW },
            DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE));

    XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer();
    xylineandshaperenderer.setBaseShapesVisible(true);
    xylineandshaperenderer.setBaseShapesFilled(true);
    xylineandshaperenderer.setDrawOutlines(true);

    return chart;
}