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

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

Introduction

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

Prototype

public void setDomainGridlinePaint(Paint paint) 

Source Link

Document

Sets the paint for the grid lines plotted against the domain axis, and sends a PlotChangeEvent to all registered listeners.

Usage

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

private static JFreeChart createChart(IntervalXYDataset intervalxydataset) {
    JFreeChart jfreechart = ChartFactory.createXYBarChart("Maximum Temperature", "Day", true, "Temperature",
            intervalxydataset, PlotOrientation.VERTICAL, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    xyplot.setDomainCrosshairVisible(true);
    xyplot.setRangeCrosshairVisible(true);
    PeriodAxis periodaxis = new PeriodAxis("Day");
    periodaxis.setAutoRangeTimePeriodClass(org.jfree.data.time.Day.class);
    PeriodAxisLabelInfo aperiodaxislabelinfo[] = new PeriodAxisLabelInfo[3];
    aperiodaxislabelinfo[0] = new PeriodAxisLabelInfo(org.jfree.data.time.Day.class, new SimpleDateFormat("d"));
    aperiodaxislabelinfo[1] = new PeriodAxisLabelInfo(org.jfree.data.time.Day.class, new SimpleDateFormat("E"),
            new RectangleInsets(2D, 2D, 2D, 2D), new Font("SansSerif", 1, 10), Color.blue, false,
            new BasicStroke(0.0F), Color.lightGray);
    aperiodaxislabelinfo[2] = new PeriodAxisLabelInfo(org.jfree.data.time.Month.class,
            new SimpleDateFormat("MMM"));
    periodaxis.setLabelInfo(aperiodaxislabelinfo);
    xyplot.setDomainAxis(periodaxis);// ww w .  j  a  v a 2  s . com
    return jfreechart;
}

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

private static JFreeChart createChart(IntervalXYDataset intervalxydataset) {
    NumberAxis numberaxis = new NumberAxis("X");
    NumberAxis numberaxis1 = new NumberAxis("Y");
    XYErrorRenderer xyerrorrenderer = new XYErrorRenderer();
    XYPlot xyplot = new XYPlot(intervalxydataset, numberaxis, numberaxis1, xyerrorrenderer);
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    JFreeChart jfreechart = new JFreeChart("XYErrorRenderer Demo 1", xyplot);
    jfreechart.setBackgroundPaint(Color.white);
    return jfreechart;
}

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

private static JFreeChart createChart(IntervalXYDataset intervalxydataset) {
    NumberAxis numberaxis = new NumberAxis("X");
    NumberAxis numberaxis1 = new NumberAxis("Y");
    XYErrorRenderer xyerrorrenderer = new XYErrorRenderer();
    xyerrorrenderer.setBaseLinesVisible(true);
    xyerrorrenderer.setBaseShapesVisible(false);
    XYPlot xyplot = new XYPlot(intervalxydataset, numberaxis, numberaxis1, xyerrorrenderer);
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    JFreeChart jfreechart = new JFreeChart("XYErrorRenderer Demo 2", xyplot);
    jfreechart.setBackgroundPaint(Color.white);
    return jfreechart;
}

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

private static JFreeChart createChart(String s, IntervalXYDataset intervalxydataset) {
    JFreeChart jfreechart = ChartFactory.createXYBarChart(s, null, true, "Y", intervalxydataset,
            PlotOrientation.VERTICAL, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    ClusteredXYBarRenderer clusteredxybarrenderer = new ClusteredXYBarRenderer(0.20000000000000001D, false);
    xyplot.setRenderer(clusteredxybarrenderer);
    return jfreechart;
}

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

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Legal & General Unit Trust Prices", "Date",
            "Price Per Unit", xydataset, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    xyplot.setDomainCrosshairVisible(true);
    xyplot.setRangeCrosshairVisible(true);
    org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = xyplot.getRenderer();
    if (xyitemrenderer instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer;
        xylineandshaperenderer.setBaseShapesVisible(true);
        xylineandshaperenderer.setBaseShapesFilled(true);
    }/*w  w w  .java 2 s  . c o m*/
    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
    dateaxis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));
    return jfreechart;
}

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

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createXYLineChart("Marker Demo 2", "X", "Temperature", xydataset,
            PlotOrientation.VERTICAL, false, true, false);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setDomainGridlinePaint(Color.lightGray);
    xyplot.setDomainGridlineStroke(new BasicStroke(1.0F));
    xyplot.setRangeGridlinePaint(Color.lightGray);
    xyplot.setRangeGridlineStroke(new BasicStroke(1.0F));
    xyplot.setRangeTickBandPaint(new Color(240, 240, 240));
    PeriodAxis periodaxis = new PeriodAxis(null, new Hour(0, 30, 6, 2005), new Hour(23, 30, 6, 2005));
    PeriodAxisLabelInfo aperiodaxislabelinfo[] = new PeriodAxisLabelInfo[2];
    aperiodaxislabelinfo[0] = new PeriodAxisLabelInfo(org.jfree.data.time.Hour.class,
            new SimpleDateFormat("HH"));
    aperiodaxislabelinfo[1] = new PeriodAxisLabelInfo(org.jfree.data.time.Day.class,
            new SimpleDateFormat("dd-MMM"));
    periodaxis.setLabelInfo(aperiodaxislabelinfo);
    xyplot.setDomainAxis(periodaxis);/*from  ww  w.  j av  a  2  s. c om*/
    ValueAxis valueaxis = xyplot.getRangeAxis();
    valueaxis.setRange(0.0D, 100D);
    XYItemRenderer xyitemrenderer = xyplot.getRenderer();
    xyitemrenderer.setSeriesPaint(0, Color.green);
    xyitemrenderer.setSeriesStroke(0, new BasicStroke(2.0F));
    ValueMarker valuemarker = new ValueMarker(80D);
    valuemarker.setLabelOffsetType(LengthAdjustmentType.EXPAND);
    valuemarker.setPaint(Color.red);
    valuemarker.setStroke(new BasicStroke(2.0F));
    valuemarker.setLabel("Temperature Threshold");
    valuemarker.setLabelFont(new Font("SansSerif", 0, 11));
    valuemarker.setLabelPaint(Color.red);
    valuemarker.setLabelAnchor(RectangleAnchor.TOP_LEFT);
    valuemarker.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT);
    xyplot.addRangeMarker(valuemarker);
    Hour hour = new Hour(18, 30, 6, 2005);
    Hour hour1 = new Hour(20, 30, 6, 2005);
    double d = hour.getFirstMillisecond();
    double d1 = hour1.getFirstMillisecond();
    IntervalMarker intervalmarker = new IntervalMarker(d, d1);
    intervalmarker.setLabelOffsetType(LengthAdjustmentType.EXPAND);
    intervalmarker.setPaint(new Color(150, 150, 255));
    intervalmarker.setLabel("Automatic Cooling");
    intervalmarker.setLabelFont(new Font("SansSerif", 0, 11));
    intervalmarker.setLabelPaint(Color.blue);
    intervalmarker.setLabelAnchor(RectangleAnchor.TOP_LEFT);
    intervalmarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
    xyplot.addDomainMarker(intervalmarker, Layer.BACKGROUND);
    ValueMarker valuemarker1 = new ValueMarker(d, Color.blue, new BasicStroke(2.0F));
    ValueMarker valuemarker2 = new ValueMarker(d1, Color.blue, new BasicStroke(2.0F));
    xyplot.addDomainMarker(valuemarker1, Layer.BACKGROUND);
    xyplot.addDomainMarker(valuemarker2, Layer.BACKGROUND);
    return jfreechart;
}

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

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Legal & General Unit Trust Prices", "Date",
            "Price Per Unit", xydataset, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    xyplot.setDomainCrosshairVisible(true);
    xyplot.setRangeCrosshairVisible(true);
    org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = xyplot.getRenderer();
    if (xyitemrenderer instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer;
        xylineandshaperenderer.setBaseShapesVisible(true);
        xylineandshaperenderer.setBaseShapesFilled(true);
        xylineandshaperenderer.setBaseItemLabelsVisible(true);
    }//from  w  w w . ja v a  2  s . c om
    PeriodAxis periodaxis = new PeriodAxis("Date");
    periodaxis.setTimeZone(TimeZone.getTimeZone("Pacific/Auckland"));
    periodaxis.setAutoRangeTimePeriodClass(org.jfree.data.time.Day.class);
    PeriodAxisLabelInfo aperiodaxislabelinfo[] = new PeriodAxisLabelInfo[3];
    aperiodaxislabelinfo[0] = new PeriodAxisLabelInfo(org.jfree.data.time.Day.class, new SimpleDateFormat("d"));
    aperiodaxislabelinfo[1] = new PeriodAxisLabelInfo(org.jfree.data.time.Month.class,
            new SimpleDateFormat("MMM"), new RectangleInsets(2D, 2D, 2D, 2D), new Font("SansSerif", 1, 10),
            Color.blue, false, new BasicStroke(0.0F), Color.lightGray);
    aperiodaxislabelinfo[2] = new PeriodAxisLabelInfo(org.jfree.data.time.Year.class,
            new SimpleDateFormat("yyyy"));
    periodaxis.setLabelInfo(aperiodaxislabelinfo);
    xyplot.setDomainAxis(periodaxis);
    return jfreechart;
}

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

public static JPanel createDemoPanel() {
    NumberAxis numberaxis = new NumberAxis("X");
    numberaxis.setAutoRangeIncludesZero(false);
    NumberAxis numberaxis1 = new NumberAxis("Y");
    numberaxis1.setAutoRangeIncludesZero(false);
    XYSplineRenderer xysplinerenderer = new XYSplineRenderer();
    XYPlot xyplot = new XYPlot(createSampleData(), numberaxis, numberaxis1, xysplinerenderer);
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    xyplot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D));
    JFreeChart jfreechart = new JFreeChart("XYSplineRenderer", JFreeChart.DEFAULT_TITLE_FONT, xyplot, true);
    ChartUtilities.applyCurrentTheme(jfreechart);
    ChartPanel chartpanel = new ChartPanel(jfreechart);
    return chartpanel;
}

From source file:br.unicamp.cst.util.ChartViewerUtil.java

public static synchronized ChartPanel createLineXYChart(XYSeriesCollection dataset, String title,
        String categoryAxisLabel, String valueAxisLabel, long timeRefresh) {

    final JFreeChart chart = ChartFactory.createXYLineChart(title, categoryAxisLabel, valueAxisLabel, dataset,
            PlotOrientation.VERTICAL, true, true, false);

    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.getDomainAxis().setFixedAutoRange(timeRefresh * 100);
    chart.setBackgroundPaint(Color.lightGray);

    ChartPanel localChartPanel = new ChartPanel(chart);
    localChartPanel.setVisible(true);/*from   w w  w.  j av a 2s  .c om*/
    localChartPanel.setDomainZoomable(true);

    return localChartPanel;
}

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

private static JFreeChart createChart(TableXYDataset tablexydataset) {
    DateAxis dateaxis = new DateAxis("Year");
    dateaxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
    dateaxis.setLowerMargin(0.01D);//from  w w  w.  ja va2  s. c o m
    dateaxis.setUpperMargin(0.01D);
    NumberAxis numberaxis = new NumberAxis("Tonnes");
    numberaxis.setNumberFormatOverride(new DecimalFormat("0.0%"));
    StackedXYBarRenderer stackedxybarrenderer = new StackedXYBarRenderer(0.29999999999999999D);
    stackedxybarrenderer.setRenderAsPercentages(true);
    GradientPaint gradientpaint = new GradientPaint(0.0F, 0.0F, new Color(64, 0, 0), 0.0F, 0.0F, Color.red);
    GradientPaint gradientpaint1 = new GradientPaint(0.0F, 0.0F, new Color(0, 64, 0), 0.0F, 0.0F, Color.green);
    stackedxybarrenderer.setSeriesPaint(0, gradientpaint);
    stackedxybarrenderer.setSeriesPaint(1, gradientpaint1);
    stackedxybarrenderer.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL));
    stackedxybarrenderer.setDrawBarOutline(false);
    stackedxybarrenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0} : {1} = {2} tonnes",
            new SimpleDateFormat("yyyy"), new DecimalFormat("#,##0")));
    XYPlot xyplot = new XYPlot(tablexydataset, dateaxis, numberaxis, stackedxybarrenderer);
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    JFreeChart jfreechart = new JFreeChart("Waste Management", xyplot);
    jfreechart.setBackgroundPaint(Color.white);
    jfreechart.addSubtitle(new TextTitle("St Albans City and District Council"));
    return jfreechart;
}