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

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

Introduction

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

Prototype

public void setDomainGridlinesVisible(boolean visible) 

Source Link

Document

Sets the flag that controls whether or not the domain grid-lines are visible.

Usage

From source file:org.jstockchart.plot.TimeseriesPlot.java

private XYPlot createPricePlot() {
    Font axisFont = new Font("Arial", 0, 12);
    Stroke stroke = new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.CAP_SQUARE, 0.0f,
            new float[] { 1.0f, 1.0f }, 1.0f);
    PriceArea priceArea = timeseriesArea.getPriceArea();
    Color averageColor = new Color(243, 182, 117);
    priceArea.setAverageColor(averageColor);
    priceArea.setPriceColor(Color.BLUE);
    TimeSeriesCollection priceDataset = new TimeSeriesCollection();
    priceDataset.addSeries(dataset.getPriceTimeSeries().getTimeSeries());
    if (priceArea.isAverageVisible()) {
        priceDataset.addSeries(dataset.getAverageTimeSeries().getTimeSeries());
    }//ww w  .  j  a v  a 2s.  co m

    CentralValueAxis logicPriceAxis = priceArea.getLogicPriceAxis();

    logicPriceAxis.setTickCount(7);

    CFXNumberAxis priceAxis = new CFXNumberAxis(logicPriceAxis.getLogicTicks());
    priceAxis.setShowUD(true);
    priceAxis.setOpenPrice(logicPriceAxis.getCentralValue().doubleValue());
    priceAxis.setTickMarksVisible(false);
    XYLineAndShapeRenderer priceRenderer = new XYLineAndShapeRenderer(true, false);
    priceAxis.setUpperBound(logicPriceAxis.getUpperBound());
    priceAxis.setLowerBound(logicPriceAxis.getLowerBound());
    priceAxis.setAxisLineVisible(false);
    priceAxis.setTickLabelFont(axisFont);
    priceRenderer.setSeriesPaint(0, priceArea.getPriceColor());
    priceRenderer.setSeriesPaint(1, priceArea.getAverageColor());

    CFXNumberAxis rateAxis = new CFXNumberAxis(logicPriceAxis.getRatelogicTicks());
    rateAxis.setShowUD(true);
    rateAxis.setOpenPrice(logicPriceAxis.getCentralValue().doubleValue());
    rateAxis.setTickMarksVisible(false);
    ;
    rateAxis.setTickLabelFont(axisFont);
    rateAxis.setAxisLineVisible(false);
    rateAxis.setUpperBound(logicPriceAxis.getUpperBound());
    rateAxis.setLowerBound(logicPriceAxis.getLowerBound());
    XYPlot plot = new XYPlot(priceDataset, null, priceAxis, priceRenderer);
    plot.setBackgroundPaint(priceArea.getBackgroudColor());
    plot.setOrientation(priceArea.getOrientation());
    plot.setRangeAxisLocation(priceArea.getPriceAxisLocation());
    plot.setRangeMinorGridlinesVisible(false);

    Stroke outLineStroke = new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.CAP_SQUARE, 0.0f,
            new float[] { 1.0f, 1.0f }, 1.0f);
    Stroke gridLineStroke = new BasicStroke(0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0.0f,
            new float[] { 2.0f, 2.0f }, 1.0f);

    plot.setRangeGridlineStroke(gridLineStroke);
    plot.setDomainGridlineStroke(gridLineStroke);
    plot.setRangeGridlinesVisible(true);
    plot.setDomainGridlinesVisible(true);
    plot.setOutlineVisible(true);
    plot.setOutlineStroke(outLineStroke);
    plot.setOutlinePaint(Color.BLACK);

    if (priceArea.isRateVisible()) {
        plot.setRangeAxis(1, rateAxis);
        plot.setRangeAxisLocation(1, priceArea.getRateAxisLocation());
        plot.setDataset(1, null);
        plot.mapDatasetToRangeAxis(1, 1);
    }

    if (priceArea.isMarkCentralValue()) {
        Number centralPrice = logicPriceAxis.getCentralValue();
        if (centralPrice != null) {
            plot.addRangeMarker(new ValueMarker(centralPrice.doubleValue(), priceArea.getCentralPriceColor(),
                    new BasicStroke()));
        }
    }
    return plot;
}

From source file:org.ujmp.jfreechart.MatrixChartPanel.java

public synchronized void redraw() {
    Dataset dataset = null;// w  ww.ja  v  a  2s .  c  o m
    dataset = new XYSeriesCollectionWrapper(getMatrix());
    // dataset = new CategoryDatasetWrapper(getMatrix());

    String title = getMatrix().getLabel();
    String xLabel = StringUtil.format(getMatrix().getMatrix().getDimensionLabel(Matrix.ROW));
    String yLabel = null;

    // setChart(ChartFactory.createLineChart(title, xLabel, yLabel,
    // (CategoryDataset) dataset, PlotOrientation.VERTICAL, true,
    // true, false));
    setChart(ChartFactory.createXYLineChart(title, xLabel, yLabel, (XYDataset) dataset,
            PlotOrientation.VERTICAL, true, true, false));

    XYPlot plot = getChart().getXYPlot();

    if (getConfig().isLogScaleDomain()) {
        try {
            NumberAxis axis = new LogarithmicAxis(null);
            plot.setDomainAxis(axis);
        } catch (Exception e) {
            NumberAxis axis = new NumberAxis();
            plot.setDomainAxis(axis);
        }
    } else {
        NumberAxis axis = new NumberAxis();
        plot.setDomainAxis(axis);
    }

    if (getConfig().isLogScaleRange()) {
        try {
            NumberAxis axis = new LogarithmicAxis(null);
            plot.setRangeAxis(axis);
        } catch (Exception e) {
            NumberAxis axis = new NumberAxis();
            plot.setRangeAxis(axis);
        }
    } else {
        NumberAxis axis = new NumberAxis();
        plot.setRangeAxis(axis);
    }

    getChart().setTitle((String) null);

    getChart().setBackgroundPaint(Color.WHITE);

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

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();

    renderer.setBaseShapesVisible(false);
    renderer.setDrawSeriesLineAsPath(true);
    for (int i = 0; i < getMatrix().getColumnCount(); i++) {
        renderer.setSeriesStroke(i, new BasicStroke(3));
        plot.setRenderer(i, renderer);
    }

    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);

    plot.getRangeAxis().setAutoRange(true);
    plot.getDomainAxis().setAutoRange(true);
    plot.getDomainAxis().setUpperMargin(0);

    setMouseZoomable(false);
}

From source file:org.jfree.eastwood.ChartEngine.java

/**
 * Creates a scatter chart.//  ww  w.  ja  va 2  s  .  co  m
 *
 * @return A scatter chart.
 */
private static JFreeChart createScatterChart() {
    JFreeChart chart = ChartFactory.createScatterPlot(null, null, null, null, PlotOrientation.VERTICAL, false,
            false, false);
    chart.setBackgroundPaint(Color.white);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(null);
    plot.setOutlinePaint(null);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBasePaint(new Color(0x76A4FB));
    renderer.setAutoPopulateSeriesPaint(false);

    GValueAxis xAxis = new GValueAxis();
    xAxis.setTickLabelsVisible(false);
    xAxis.setTickMarksVisible(false);
    plot.setDomainAxis(xAxis);
    GValueAxis yAxis = new GValueAxis();
    yAxis.setTickLabelsVisible(false);
    yAxis.setTickMarksVisible(false);
    plot.setRangeAxis(yAxis);
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);
    return chart;
}

From source file:financepro.XYLineChartExample.java

License:asdf

private JPanel createChartPanel() {
    // creates a line chart object
    // returns the chart panel
    String chartTitle = "Various Financial Ratios";
    String xAxisLabel = "Years";
    String yAxisLabel = "Ratio Values";

    XYDataset dataset = createDataset();

    JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, xAxisLabel, yAxisLabel, dataset);

    XYPlot plot = chart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    plot.setRenderer(renderer);//from ww  w . ja  va2  s  .c  om

    renderer.setSeriesPaint(0, Color.RED);
    renderer.setSeriesPaint(1, Color.GREEN);
    renderer.setSeriesPaint(2, Color.YELLOW);
    renderer.setSeriesPaint(3, Color.CYAN);
    renderer.setSeriesPaint(4, Color.BLACK);

    renderer.setSeriesStroke(0, new BasicStroke(4.0f));
    renderer.setSeriesStroke(1, new BasicStroke(4.0f));
    renderer.setSeriesStroke(2, new BasicStroke(4.0f));
    renderer.setSeriesStroke(3, new BasicStroke(4.0f));
    renderer.setSeriesStroke(4, new BasicStroke(4.0f));

    plot.setRenderer(renderer);
    plot.setOutlinePaint(Color.BLUE);
    plot.setOutlineStroke(new BasicStroke(4.0f));
    plot.setBackgroundPaint(Color.DARK_GRAY);

    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.BLACK);

    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.BLACK);

    return new ChartPanel(chart);
}

From source file:org.jstockchart.plot.TimeseriesPlot.java

private XYPlot createVolumePlot() {
    Font axisFont = new Font("Arial", 0, 12);
    Stroke stroke = new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.CAP_SQUARE, 0.0f,
            new float[] { 1.0f, 1.0f }, 1.0f);
    VolumeArea volumeArea = timeseriesArea.getVolumeArea();
    LogicNumberAxis logicVolumeAxis = volumeArea.getLogicVolumeAxis();
    Color volumeColor = new Color(86, 126, 160);
    volumeArea.setVolumeColor(volumeColor);
    CFXNumberAxis volumeAxis = new CFXNumberAxis(logicVolumeAxis.getLogicTicks());
    volumeAxis.setAxisLineVisible(false);
    volumeAxis.setCustomTickCount(2);//ww  w . j  a v  a2  s . c o  m
    volumeAxis.setTickLabelPaint(volumeColor);
    volumeAxis.setUpperBound(logicVolumeAxis.getUpperBound());
    volumeAxis.setTickLabelFont(axisFont);
    volumeAxis.setTickMarkStroke(stroke);
    volumeAxis.setLowerBound(logicVolumeAxis.getLowerBound());
    volumeAxis.setAutoRangeIncludesZero(true);
    XYAreaRenderer2 volumeRenderer = new XYAreaRenderer2();
    volumeRenderer.setSeriesPaint(0, volumeArea.getVolumeColor());
    //volumeRenderer.setShadowVisible(false);
    volumeRenderer.setSeriesStroke(0, stroke);
    volumeRenderer.setBaseStroke(stroke);
    XYPlot plot = new XYPlot(new TimeSeriesCollection(dataset.getVolumeTimeSeries()), null, volumeAxis,
            volumeRenderer);
    plot.setBackgroundPaint(volumeArea.getBackgroudColor());
    plot.setOrientation(volumeArea.getOrientation());
    plot.setRangeAxisLocation(volumeArea.getVolumeAxisLocation());
    plot.setRangeMinorGridlinesVisible(false);

    Stroke outLineStroke = new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.CAP_SQUARE, 0.0f,
            new float[] { 1.0f, 1.0f }, 1.0f);
    Stroke gridLineStroke = new BasicStroke(0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0.0f,
            new float[] { 2.0f, 2.0f }, 1.0f);
    // plot.setBackgroundPaint(Color.RED);
    plot.setRangeGridlineStroke(gridLineStroke);
    plot.setDomainGridlineStroke(gridLineStroke);
    plot.setRangeGridlinesVisible(true);
    plot.setDomainGridlinesVisible(true);
    plot.setOutlineVisible(true);
    plot.setOutlineStroke(outLineStroke);
    plot.setOutlinePaint(Color.black);
    plot.setRangeZeroBaselineVisible(true);
    return plot;
}

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

public VOILUTPanel(LUTControl aP) {

    iCurveName = java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle").getString("VOILUTPANEL.VOI_LUT");

    iLUT = LUTControl.create(aP);/*from   www .  ja va2  s .c  o  m*/

    aP.addWindowChangeListener(this);

    initComponents();

    XYPlot plot = new XYPlot();

    plot.setDataset(0, makeLUTCurve());
    plot.setRenderer(0, new XYSplineRenderer());

    ((XYSplineRenderer) plot.getRenderer()).setShapesVisible(false);
    plot.setRangeAxis(0, new NumberAxis(java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle")
            .getString("VOILUTPANEL.AXIS_LABEL_VOI_CURVE")));

    XYSeriesCollection col2 = new XYSeriesCollection();
    col2.addSeries(makeHistogram());

    plot.setDataset(1, col2);
    plot.setRenderer(1, new XYBarRenderer());
    plot.setRangeAxis(1, new NumberAxis(java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle")
            .getString("VOILUTPANEL.AXIS_LABEL_IMAGE_SPACE")));
    plot.mapDatasetToRangeAxis(1, 1);

    plot.setDomainAxis(new NumberAxis(java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle")
            .getString("VOILUTPANEL.AXIS_LABEL_IMAGE_HISTOGRAM")));
    plot.setRangeGridlinesVisible(true);
    plot.setDomainGridlinesVisible(true);
    // change the rendering order so the primary dataset appears "behind" the 
    // other datasets...
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE);

    JFreeChart jfc = new JFreeChart(plot);

    jfc.setBorderVisible(true);
    jfc.removeLegend();
    iPanel = new ChartPanel(jfc);
    iPanel.setSize(jPanel1.getPreferredSize());
    jPanel1.add(iPanel);//, java.awt.BorderLayout.CENTER);              
    iLUT.setSize(jPanel2.getPreferredSize());
    jPanel2.add(iLUT);
    iLabelMin.setText(String.format("%.0f", iLUT.getView().getMin()));
    iLabelMax.setText(String.format("%.0f", iLUT.getView().getMax()));

    validate();
}

From source file:IHM.compargraph.java

/**
 *
 * @param title//from  w  w w.j a  v a 2s . c  o m
 * @param c1
 * @param c2
 * @param comp
 * 
 */
public compargraph(String title, ArrayList<ReleveMeteo> c1, ArrayList<ReleveMeteo> c2, String comp) {
    super(title);
    t1 = c1;
    t2 = c2;
    c = comp;

    // 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:net.sf.fspdfs.chartthemes.spring.AegeanChartTheme.java

/**
 *
 *//*from www. ja va  2  s.c  o m*/
protected void configurePlot(Plot plot, JRChartPlot jrPlot) {

    super.configurePlot(plot, jrPlot);

    if (plot instanceof CategoryPlot) {
        CategoryPlot categoryPlot = (CategoryPlot) plot;
        CategoryItemRenderer categoryRenderer = categoryPlot.getRenderer();
        CategoryDataset categoryDataset = categoryPlot.getDataset();
        if (categoryDataset != null) {
            for (int i = 0; i < categoryDataset.getRowCount(); i++) {
                categoryRenderer.setSeriesOutlinePaint(i, ChartThemesConstants.TRANSPARENT_PAINT);
            }
        }
        categoryPlot.setRangeGridlinePaint(ChartThemesConstants.GRAY_PAINT_217);
        categoryPlot.setRangeGridlineStroke(new BasicStroke(0.5f));
        categoryPlot.setDomainGridlinesVisible(false);
        categoryPlot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    } else if (plot instanceof XYPlot) {
        XYPlot xyPlot = (XYPlot) plot;
        XYItemRenderer xyItemRenderer = xyPlot.getRenderer();
        XYDataset xyDataset = xyPlot.getDataset();
        if (xyDataset != null) {
            for (int i = 0; i < xyDataset.getSeriesCount(); i++) {
                xyItemRenderer.setSeriesOutlinePaint(i, ChartThemesConstants.TRANSPARENT_PAINT);
            }
        }
        xyPlot.setRangeGridlinePaint(ChartThemesConstants.GRAY_PAINT_217);
        xyPlot.setRangeGridlineStroke(new BasicStroke(0.5f));
        xyPlot.setDomainGridlinesVisible(false);
        xyPlot.setRangeZeroBaselineVisible(true);
    }
}

From source file:net.sf.jasperreports.chartthemes.spring.AegeanChartTheme.java

@Override
protected void configurePlot(Plot plot, JRChartPlot jrPlot) {

    super.configurePlot(plot, jrPlot);

    if (plot instanceof CategoryPlot) {
        CategoryPlot categoryPlot = (CategoryPlot) plot;
        CategoryItemRenderer categoryRenderer = categoryPlot.getRenderer();
        CategoryDataset categoryDataset = categoryPlot.getDataset();
        if (categoryDataset != null) {
            for (int i = 0; i < categoryDataset.getRowCount(); i++) {
                categoryRenderer.setSeriesOutlinePaint(i, ChartThemesConstants.TRANSPARENT_PAINT);
            }/*from  w  w  w .  ja  v  a  2s  . co  m*/
        }
        categoryPlot.setRangeGridlinePaint(ChartThemesConstants.GRAY_PAINT_217);
        categoryPlot.setRangeGridlineStroke(new BasicStroke(0.5f));
        categoryPlot.setDomainGridlinesVisible(false);
        categoryPlot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    } else if (plot instanceof XYPlot) {
        XYPlot xyPlot = (XYPlot) plot;
        XYItemRenderer xyItemRenderer = xyPlot.getRenderer();
        XYDataset xyDataset = xyPlot.getDataset();
        if (xyDataset != null) {
            for (int i = 0; i < xyDataset.getSeriesCount(); i++) {
                xyItemRenderer.setSeriesOutlinePaint(i, ChartThemesConstants.TRANSPARENT_PAINT);
            }
        }
        xyPlot.setRangeGridlinePaint(ChartThemesConstants.GRAY_PAINT_217);
        xyPlot.setRangeGridlineStroke(new BasicStroke(0.5f));
        xyPlot.setDomainGridlinesVisible(false);
        xyPlot.setRangeZeroBaselineVisible(true);
    }
}

From source file:net.sf.fspdfs.chartthemes.spring.EyeCandySixtiesChartTheme.java

protected JFreeChart createScatterChart() throws JRException {
    JFreeChart jfreeChart = super.createScatterChart();
    XYPlot xyPlot = (XYPlot) jfreeChart.getPlot();

    xyPlot.setRangeGridlinePaint(SCATTER_GRIDLINE_COLOR);
    xyPlot.setRangeGridlineStroke(new BasicStroke(0.75f));
    xyPlot.setDomainGridlinesVisible(true);
    xyPlot.setDomainGridlinePaint(SCATTER_GRIDLINE_COLOR);
    xyPlot.setDomainGridlineStroke(new BasicStroke(0.75f));
    xyPlot.setRangeZeroBaselinePaint(ChartThemesConstants.GRAY_PAINT_134);

    XYLineAndShapeRenderer lineRenderer = (XYLineAndShapeRenderer) xyPlot.getRenderer();
    lineRenderer.setUseFillPaint(true);//from  w w  w .  j  a v  a 2  s.c  o  m
    JRScatterPlot scatterPlot = (JRScatterPlot) getPlot();
    boolean isShowLines = scatterPlot.getShowLines() == null ? false
            : scatterPlot.getShowLines().booleanValue();
    lineRenderer.setBaseLinesVisible(isShowLines);
    XYDataset xyDataset = xyPlot.getDataset();
    if (xyDataset != null) {
        for (int i = 0; i < xyDataset.getSeriesCount(); i++) {
            lineRenderer.setSeriesOutlinePaint(i, ChartThemesConstants.TRANSPARENT_PAINT);
            lineRenderer.setSeriesFillPaint(i,
                    (Paint) ChartThemesConstants.EYE_CANDY_SIXTIES_GRADIENT_PAINTS.get(i));
            lineRenderer.setSeriesPaint(i, (Paint) ChartThemesConstants.EYE_CANDY_SIXTIES_COLORS.get(i));
            //lineRenderer.setSeriesShape(i, new Ellipse2D.Double(-3, -3, 6, 6));
        }
    }
    return jfreeChart;
}