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

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

Introduction

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

Prototype

public void setRangeGridlinesVisible(boolean visible) 

Source Link

Document

Sets the flag that controls whether or not the range axis grid lines are visible.

Usage

From source file:net.nosleep.superanalyzer.analysis.views.PlayCountView.java

private void createChart() {
    _chart = ChartFactory.createXYBarChart(Misc.getString("PLAY_COUNT"), Misc.getString("PLAY_COUNT"), false,
            Misc.getString("NUMBER_OF_SONGS"), _dataset, PlotOrientation.VERTICAL, false, true, false);

    _chart.addSubtitle(HomePanel.createSubtitle(Misc.getString("PLAY_COUNT_SUBTITLE")));

    // then customise it a little...
    XYPlot plot = (XYPlot) _chart.getPlot();
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
    plot.setForegroundAlpha(0.75f);//  w ww.j a  v  a2  s . c om

    ChartUtilities.applyCurrentTheme(_chart);

    renderer.setBarPainter(new StandardXYBarPainter());
    renderer.setShadowVisible(false);

    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);

    domainAxis.setLowerMargin(0);
    domainAxis.setUpperMargin(0);
    // domainAxis.setLowerBound(0);
    // domainAxis.setAutoRangeIncludesZero(true);
    // domainAxis.setAutoRangeStickyZero(true);

    Misc.formatChart(plot);
    renderer.setSeriesPaint(0, Theme.getColorSet()[1]);

}

From source file:clientv2.GUI.java

/**
 * Creates a chart//w  w  w  .j a v  a2  s  .c o m
 *
 * @param TS
 * @param GraphName
 * @return
 */
public JFreeChart createChart(TimeSeriesCollection TS, String GraphName, double minRange, double maxRange) {
    JFreeChart chart = ChartFactory.createTimeSeriesChart(GraphName, "Time", "Value", TS, true, true, false);
    final XYPlot plot = chart.getXYPlot();
    ValueAxis axis = plot.getDomainAxis();
    plot.getRangeAxis().setRange(minRange, maxRange);
    plot.setBackgroundPaint(WHITE);
    plot.setDomainMinorGridlinePaint(BLACK);
    plot.setDomainGridlinePaint(BLACK);
    plot.setRangeMinorGridlinePaint(BLACK);
    plot.setRangeGridlinesVisible(true);

    axis.setFixedAutoRange(20000.0);

    return chart;
}

From source file:adams.flow.sink.JFreeChartPlot.java

/**
 * Creates a new display panel for the token.
 *
 * @param token   the token to display in a new panel, can be null
 * @return      the generated panel/*from  ww w.  ja  v a  2s  .c om*/
 */
@Override
public DisplayPanel createDisplayPanel(Token token) {
    AbstractDisplayPanel result;

    result = new AbstractComponentDisplayPanel(getClass().getSimpleName()) {
        private static final long serialVersionUID = -3785685146120118884L;
        protected JFreeChart m_JFreeChart;
        protected ChartPanel m_PlotPanel;

        @Override
        protected void initGUI() {
            super.initGUI();
            setLayout(new BorderLayout());
        }

        @Override
        public void display(Token token) {
            SpreadSheet sheet = (SpreadSheet) token.getPayload();
            Dataset dataset = m_Dataset.generate(sheet);
            m_JFreeChart = m_Chart.generate(dataset);
            if (m_JFreeChart.getPlot() instanceof XYPlot) {
                XYPlot plot = (XYPlot) m_JFreeChart.getPlot();
                plot.setDomainGridlinesVisible(true);
                plot.setDomainGridlinePaint(Color.GRAY);
                plot.setRangeGridlinesVisible(true);
                plot.setRangeGridlinePaint(Color.GRAY);
                plot.getRenderer().setSeriesPaint(0, m_PlotColor);
                if (plot.getSeriesCount() > 1)
                    plot.getRenderer().setSeriesPaint(1, m_DiagonalColor);
                Shape shape = m_Shape.generate();
                if (shape != null)
                    plot.getRenderer().setSeriesShape(0, shape);
            }
            m_PlotPanel = new ChartPanel(m_JFreeChart);
            removeAll();
            add(m_PlotPanel, BorderLayout.CENTER);
        }

        @Override
        public void clearPanel() {
            removeAll();
            m_JFreeChart = null;
        }

        @Override
        public void cleanUp() {
            removeAll();
            m_JFreeChart = null;
        }

        @Override
        public JComponent supplyComponent() {
            return m_PlotPanel;
        }
    };

    if (token != null)
        result.display(token);

    return result;
}

From source file:ch.algotrader.client.chart.ChartTab.java

public void init(ChartDefinitionVO chartDefinition) {

    // remove all components first
    this.removeAll();

    resetPopupMenu();/*from  w  w  w  .j  av a2 s  . co m*/

    this.chartDefinition = chartDefinition;

    // create the plot
    XYPlot plot = new XYPlot();

    // add gridlines
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinesVisible(true);

    // create the JFreeChart
    JFreeChart chart = new JFreeChart(plot);
    this.setChart(chart);

    // init the maps
    this.bars = new HashMap<>();
    this.indicators = new HashMap<>();
    this.markers = new HashMap<>();
    this.markersSelectionStatus = new HashMap<>();

    // init domain axis
    initDomainAxis(chartDefinition);

    // init range axis
    initRangeAxis(chartDefinition);

    // create a subtitle
    TextTitle title = new TextTitle();
    title.setFont(new Font("SansSerif", 0, 9));
    chart.addSubtitle(title);

    // crosshair
    plot.setDomainCrosshairVisible(true);
    plot.setDomainCrosshairLockedOnData(true);
    plot.setRangeCrosshairVisible(true);
    plot.setDomainCrosshairLockedOnData(true);
}

From source file:IHM.NewClass.java

/**
 *
 * @param title//from  w  w w  . j  a v  a2 s . c om
 */
public NewClass(String title /*,*JInternalFrame jp*/) {
    super(title);
    // jp = new JInternalFrame("courbes");

    JFreeChart chart = createChart(createDataset());
    ChartPanel panel = new ChartPanel(chart);
    panel.setPreferredSize(new Dimension(500, 300));
    setContentPane(panel);
    //  jp.add(panel, BorderLayout.EAST);
    //  jp.setVisible(true);
    panel.setVisible(true);
    XYPlot plot = chart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    plot.setRenderer(renderer);
    renderer.setSeriesPaint(0, Color.RED);
    renderer.setSeriesPaint(1, Color.GREEN);
    renderer.setSeriesPaint(2, Color.YELLOW);
    // sets thickness for series (using strokes)
    renderer.setSeriesStroke(0, new BasicStroke(4.0f));
    renderer.setSeriesStroke(1, new BasicStroke(3.0f));
    renderer.setSeriesStroke(2, new BasicStroke(2.0f));
    plot.setRenderer(renderer);
    plot.setOutlinePaint(Color.BLUE);
    plot.setOutlineStroke(new BasicStroke(2.0f));
    plot.setBackgroundPaint(Color.DARK_GRAY);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.BLACK);
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.BLACK);

}

From source file:org.knime.knip.core.ui.imgviewer.panels.HistogramBC.java

private final void setBackgroundDefault(final JFreeChart chart) {
    final BasicStroke gridStroke = new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
            new float[] { 2.0f, 1.0f }, 0.0f);
    final XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRangeGridlineStroke(gridStroke);
    plot.setDomainGridlineStroke(gridStroke);
    // Background of Histogram inside border
    //plot.setBackgroundPaint(new Color(235,235,235));
    plot.setBackgroundPaint(Color.white);
    // change from white to gray
    plot.setRangeGridlinePaint(Color.gray);
    plot.setDomainGridlinePaint(Color.gray);
    // set lines invisible
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);
    plot.setOutlineVisible(true);//from w  w  w  . j  a  v a 2s.  c o  m
    plot.getDomainAxis().setAxisLineVisible(false);
    plot.getRangeAxis().setAxisLineVisible(false);
    plot.getDomainAxis().setLabelPaint(Color.gray);
    plot.getRangeAxis().setLabelPaint(Color.gray);
    plot.getDomainAxis().setTickLabelPaint(Color.gray);
    plot.getRangeAxis().setTickLabelPaint(Color.gray);
    final TextTitle title = chart.getTitle();
    if (title != null) {
        title.setPaint(Color.black);
    }
}

From source file:asl.util.PlotMaker.java

public void plotCoherence(double per[], double[] gamma, String plotString) {

    final String plotTitle = String.format("%04d%03d.%s.%s-%s", date.get(Calendar.YEAR),
            date.get(Calendar.DAY_OF_YEAR), station, channelX, channelY);
    final String pngName = String.format("%s/%04d%03d.%s.%s-%s.%s.png", outputDir, date.get(Calendar.YEAR),
            date.get(Calendar.DAY_OF_YEAR), station, channelX, channelY, plotString);

    File outputFile = new File(pngName);

    // Check that we will be able to output the file without problems and if not --> return
    if (!checkFileOut(outputFile)) {
        System.out.format("== plotCoherence: request to output plot=[%s] but we are unable to create it "
                + " --> skip plot\n", pngName);
        return;/*from www .ja  va 2s .  co m*/
    }

    final String legend = String.format("%s--%s", channelX, channelY);
    final XYSeries series1 = new XYSeries(legend);

    for (int k = 0; k < gamma.length; k++) {
        series1.add(per[k], gamma[k]);
    }

    //final XYItemRenderer renderer1 = new StandardXYItemRenderer();
    final XYLineAndShapeRenderer renderer1 = new XYLineAndShapeRenderer();
    Rectangle rectangle = new Rectangle(3, 3);
    renderer1.setSeriesShape(0, rectangle);
    renderer1.setSeriesShapesVisible(0, true);
    renderer1.setSeriesLinesVisible(0, false);

    Paint[] paints = new Paint[] { Color.red, Color.black };
    renderer1.setSeriesPaint(0, paints[0]);

    final NumberAxis rangeAxis1 = new NumberAxis("Coherence, Gamma");
    rangeAxis1.setRange(new Range(0, 1.2));
    rangeAxis1.setTickUnit(new NumberTickUnit(0.1));

    final LogarithmicAxis horizontalAxis = new LogarithmicAxis("Period (sec)");
    horizontalAxis.setRange(new Range(0.05, 10000));

    final XYSeriesCollection seriesCollection = new XYSeriesCollection();
    seriesCollection.addSeries(series1);

    final XYPlot xyplot = new XYPlot((XYDataset) seriesCollection, horizontalAxis, rangeAxis1, renderer1);

    xyplot.setDomainGridlinesVisible(true);
    xyplot.setRangeGridlinesVisible(true);
    xyplot.setRangeGridlinePaint(Color.black);
    xyplot.setDomainGridlinePaint(Color.black);

    final JFreeChart chart = new JFreeChart(xyplot);
    chart.setTitle(new TextTitle(plotTitle));

    try {
        ChartUtilities.saveChartAsPNG(outputFile, chart, 500, 300);
    } catch (IOException e) {
        System.err.println("Problem occurred creating chart.");

    }
}

From source file:researchbehaviour.ChangePanel.java

private JFreeChart createChart(final XYDataset dataset) throws IOException {

    JFreeChart chart = ChartFactory.createXYLineChart("Default values and current values", "Personality factor",
            "Personality factor values", dataset, PlotOrientation.VERTICAL, true, true, false);

    XYPlot plot = chart.getXYPlot();

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();

    renderer.setSeriesPaint(0, Color.RED);
    renderer.setSeriesStroke(0, new BasicStroke(2.0f));

    renderer.setSeriesPaint(1, Color.BLUE);
    renderer.setSeriesStroke(1, new BasicStroke(2.0f));

    plot.setRenderer(renderer);// www. j ava2  s.c o  m
    plot.setBackgroundPaint(Color.white);

    plot.setRangeGridlinesVisible(false);
    plot.setDomainGridlinesVisible(false);

    chart.getLegend().setFrame(BlockBorder.NONE);

    chart.setTitle(new TextTitle("Default values and current values", new Font("Serif", Font.BOLD, 18)));

    return chart;
}

From source file:org.gumtree.vis.plot1d.Plot1D.java

private void createChart() {

    String title = null;//from   w  w w. java2s .com
    String xTitle = null;
    String yTitle = null;
    if (dataset != null) {
        title = dataset.getTitle();
        xTitle = dataset.getXTitle() + (dataset.getXUnits() == null ? "" : " (" + dataset.getXUnits() + ")");
        yTitle = dataset.getYTitle() + (dataset.getYUnits() == null ? "" : " (" + dataset.getYUnits() + ")");
    } else {
        dataset = new XYErrorDataset();
    }
    chart = createXYLineChart(title, xTitle, yTitle, dataset, PlotOrientation.VERTICAL, true, false, true);
    chart.setBackgroundPaint(Color.WHITE);
    final LegendTitle legend = (LegendTitle) chart.getLegend();
    RectangleEdge legendPosition = RectangleEdge.BOTTOM;
    try {
        String legendProperty = "RectangleEdge." + System.getProperty("kuranda1D.legendPosition");
        if (RectangleEdge.BOTTOM.toString().equals(legendProperty))
            legendPosition = RectangleEdge.BOTTOM;
        else if (RectangleEdge.RIGHT.toString().equals(legendProperty))
            legendPosition = RectangleEdge.RIGHT;
        else if (RectangleEdge.LEFT.toString().equals(legendProperty))
            legendPosition = RectangleEdge.LEFT;
        else if (RectangleEdge.TOP.toString().equals(legendProperty))
            legendPosition = RectangleEdge.TOP;
    } catch (Exception e) {
        // TODO: handle exception
    }
    legend.setPosition(legendPosition);
    chart.setBorderVisible(true);
    //      ChartUtilities.applyCurrentTheme(chart);
    //      chartTheme.apply(chart);

    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setDomainPannable(true);
    plot.setRangePannable(true);

    plot.setDomainGridlinesVisible(true);
    //        plot.setDomainCrosshairLockedOnData(true);
    //        plot.setDomainCrosshairVisible(true);
    plot.setRangeGridlinesVisible(true);
    //        plot.setRangeCrosshairLockedOnData(true);
    //        plot.setRangeCrosshairVisible(true);

    xAxis = plot.getDomainAxis();
    yAxis = plot.getRangeAxis();

    plot.setDataset(dataset);
    XYItemRenderer renderer = chart.getXYPlot().getRenderer();
    if (renderer instanceof XYLineAndShapeRenderer) {
        //         ((XYLineAndShapeRenderer) renderer).setBaseShapesVisible(true);
        ((XYLineAndShapeRenderer) renderer).setBaseShapesFilled(true);
    }
    //      XYErrorRenderer errorRenderer = (XYErrorRenderer) chart.getXYPlot().getRenderer();
    //      errorRenderer.setDrawXError(true);
    //        StandardXYItemRenderer renderer = (StandardXYItemRenderer) plot.getRenderer();
    //        renderer.setPlotLines(true);
    //        renderer.setBaseShapesVisible(true);

    chart.fireChartChanged();
}

From source file:GUI.ServerUI_Client.java

private JFreeChart createChart(final XYDataset dataset) {
    final JFreeChart result = ChartFactory.createTimeSeriesChart("Bandwidth Estimator", "Time/s", "Bandwidth",
            dataset, true, true, false);

    final XYPlot plot = result.getXYPlot();
    Color plotColor = new Color(245, 245, 245);
    plot.setBackgroundPaint(plotColor);/*from w w  w .j a v  a  2 s  . c o m*/
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.lightGray);
    ValueAxis xaxis = plot.getDomainAxis();
    //xaxis.setAutoRange(true);
    xaxis.setFixedAutoRange(5000.0);
    //xaxis.setVerticalTickLabels(true);
    ValueAxis yaxis = plot.getRangeAxis();
    yaxis.setAutoRange(true);
    //yaxis.setRange(0.0, 300.0);
    return result;
}