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:net.sf.maltcms.chromaui.chromatogram2Dviewer.ui.Chromatogram2DViewTopComponent.java

private Chromatogram2DViewerPanel createPanel(IChromatogramDescriptor chromatogram,
        ADataset2D<IChromatogram2D, IScan2D> ds, List<ChartOverlay> overlays) {
    IPaintScaleProvider ips = Lookup.getDefault().lookup(IPaintScaleProvider.class);
    ips.setMin(ds.getMinZ());//from   w ww .  ja  va 2 s .  co  m
    ips.setMax(ds.getMaxZ());
    PaintScale ps = ips.getPaintScales().get(0);
    XYPlot p = createPlot(chromatogram, ds, ps);
    p.setDomainGridlinesVisible(false);
    p.setRangeGridlinesVisible(false);
    JFreeChart jfc = new JFreeChart(p);
    final ContextAwareChartPanel cp = new ContextAwareChartPanel(jfc, true);
    cp.setZoomFillPaint(new Color(192, 192, 192, 96));
    cp.setZoomOutlinePaint(new Color(220, 220, 220, 192));
    cp.setFillZoomRectangle(false);
    cp.getChart().getLegend().setVisible(true);
    Chromatogram2DViewerPanel panel = new Chromatogram2DViewerPanel(content, getLookup(), ds, ps);
    if (panel.getBackgroundColor() == null) {
        panel.setBackgroundColor((Color) ps.getPaint(ps.getLowerBound()));
    }
    cp.addKeyListener(panel);
    cp.setFocusable(true);
    cp.setDisplayToolTips(true);
    cp.setDismissDelay(3000);
    cp.setInitialDelay(0);
    cp.setReshowDelay(0);
    cp.setVisible(true);
    cp.setRefreshBuffer(true);
    cp.setMouseWheelEnabled(true);
    if (project != null) {
        for (Peak1DContainer peaks : project.getPeaks(chromatogram)) {
            Peak2DOverlay overlay = new Peak2DOverlay(chromatogram, peaks.getName(), peaks.getDisplayName(),
                    peaks.getShortDescription(), true, peaks);
            cp.addOverlay(overlay);
            content.add(overlay);
            overlays.add(overlay);
        }
    }

    panel.setChartPanel(cp);
    panel.setPlot(p);
    return panel;
}

From source file:com.rapidminer.gui.viewer.metadata.model.DateTimeAttributeStatisticsModel.java

/**
 * Creates the histogram chart./*w w w . j  av  a  2s . co m*/
 *
 * @param exampleSet
 * @return
 */
private JFreeChart createHistogramChart(final ExampleSet exampleSet) {
    JFreeChart chart = ChartFactory.createHistogram(null, null, null, createHistogramDataset(exampleSet),
            PlotOrientation.VERTICAL, false, false, false);
    AbstractAttributeStatisticsModel.setDefaultChartFonts(chart);
    chart.setBackgroundPaint(null);
    chart.setBackgroundImageAlpha(0.0f);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRangeGridlinesVisible(false);
    plot.setDomainGridlinesVisible(false);
    plot.setOutlineVisible(false);
    plot.setRangeZeroBaselineVisible(false);
    plot.setDomainZeroBaselineVisible(false);
    plot.getDomainAxis().setTickLabelsVisible(false);
    plot.setBackgroundPaint(COLOR_INVISIBLE);
    plot.setBackgroundImageAlpha(0.0f);

    XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
    renderer.setSeriesPaint(0, AttributeGuiTools.getColorForValueType(Ontology.DATE_TIME));
    renderer.setBarPainter(new StandardXYBarPainter());
    renderer.setDrawBarOutline(true);
    renderer.setShadowVisible(false);

    return chart;
}

From source file:org.jcryptool.visual.verifiablesecretsharing.views.ReconstructionChartComposite.java

/**
 * Creates a chart.//from  w w w.j a v  a  2s .  c  om
 *
 * @param dataset
 *            the data for the chart.
 *
 * @return a chart.
 */
private JFreeChart createChart(final XYDataset dataset) {

    // create the chart...

    final JFreeChart chart = ChartFactory.createXYLineChart("", // chart
            // title
            "", // x axis label
            "", // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            false, // tooltips
            false // urls
    );
    // XYSplineRenderer -- show data points
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    // show no line
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesLinesVisible(3, false);
    // show no points
    renderer.setSeriesShapesVisible(1, false);

    // set range of axis
    NumberAxis domain = (NumberAxis) plot.getDomainAxis();
    domain.setRange(-0.1, playerID[playerID.length - 1] + 0.1);
    domain.setTickUnit(new NumberTickUnit(1));
    domain.setVerticalTickLabels(false);

    // display value
    NumberFormat format = NumberFormat.getNumberInstance();
    format.setMaximumFractionDigits(0);
    XYItemLabelGenerator generator = new StandardXYItemLabelGenerator(
            StandardXYItemLabelGenerator.DEFAULT_ITEM_LABEL_FORMAT, format, format);
    renderer.setBaseItemLabelGenerator(generator);
    renderer.setBaseItemLabelsVisible(true);

    plot.setRenderer(renderer);

    return chart;

}

From source file:be.ac.ua.comp.scarletnebula.gui.DecoratedGraph.java

/**
 * @see Graph//from  w  ww  .  j a  va  2 s  .com
 */
@Override
public ChartPanel getChartPanel() {
    final XYPlot plot = new XYPlot(dataset, domain, range, renderer);
    plot.setBackgroundPaint(Color.darkGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    // plot.setInsets(new RectangleInsets(0, 0, 0, 0));
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinesVisible(true);

    if (stream.getMax() != null) {
        log.info("Getting chart panel for stream with maximum.");
        range.setAutoRange(false);

        range.setTickUnit(new NumberTickUnit(stream.getMax() / 10, new DecimalFormat(), 1));
        range.setRange(0, stream.getMax());
    } else if (stream.getType() == Type.RELATIVE) {
        range.setAutoRange(false);

        range.setTickUnit(new NumberTickUnit(0.1, new DecimalFormat(), 1));
        range.setRange(0, 1);
    } else {
        double sum = 0;
        final List<TimedDatapoint> datapoints = stream.getRecentlyProcessedDatapoints();

        range.setTickUnit(
                new NumberTickUnit((int) (Utils.max(datapoints).getValue() / 5) + 1, new DecimalFormat(), 1));
    }

    final JFreeChart chart = new JFreeChart(stream.getStreamname(), new Font("SansSerif", Font.PLAIN, 20), plot,
            true);
    chart.setBackgroundPaint(Color.white);
    chart.removeLegend();
    final ChartPanel chartPanel = new ChartPanel(chart);
    // chartPanel.setBorder(BorderFactory
    // .createBevelBorder(BevelBorder.LOWERED));

    return chartPanel;
}

From source file:org.tolven.analysis.bean.PercentTimeSeriesBean.java

private JFreeChart getChart(String dataSeriesTitle, String targetSeriesTitle, List<MenuData> snapshots,
        Date fromDate, Date toDate, Class<?> intervalUnitClass) {
    TimeSeries dataTimeSeries = new TimeSeries(dataSeriesTitle);
    TimeSeries targetTimeSeries = null;/*  w  w w.  j  a v  a  2 s . c om*/
    if (targetSeriesTitle != null) {
        targetTimeSeries = new TimeSeries(targetSeriesTitle);
    }
    for (MenuData snapshot : snapshots) {
        Date snapshotDate = snapshot.getDate01();
        long nSnapshotresultsNumerator = snapshot.getLongField("normCount");
        long nSnapshotresultsDenominator = snapshot.getLongField("allCount");
        Double value = null;
        if (nSnapshotresultsDenominator == 0) {
            value = 0d;
        } else {
            value = 1d * nSnapshotresultsNumerator / nSnapshotresultsDenominator;
        }
        RegularTimePeriod regTimePeriod = RegularTimePeriod.createInstance(intervalUnitClass, snapshotDate,
                TimeZone.getDefault());
        dataTimeSeries.addOrUpdate(regTimePeriod, value);
        if (targetTimeSeries != null) {
            Double targetPercent = snapshot.getDoubleField("targetPercent") / 100;
            targetTimeSeries.addOrUpdate(regTimePeriod, targetPercent);
        }
    }
    TimeSeriesCollection timeSeriesCollection = new TimeSeriesCollection();
    timeSeriesCollection.addSeries(dataTimeSeries);
    if (targetTimeSeries != null) {
        timeSeriesCollection.addSeries(targetTimeSeries);
    }
    XYDataset xyDataset = (XYDataset) timeSeriesCollection;
    JFreeChart chart = ChartFactory.createTimeSeriesChart(null, // title
            null, // x-axis label
            null, // y-axis label
            xyDataset, // data
            true, // create legend?
            false, // generate tooltips?
            false // generate URLs?
    );
    chart.setBackgroundPaint(Color.white);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.BLACK);
    plot.setDomainGridlinesVisible(false);
    XYItemRenderer r = plot.getRenderer();
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);
    renderer.setSeriesShape(0, new Ellipse2D.Double(-3, -3, 6, 6));
    renderer.setSeriesPaint(0, Color.BLUE);
    renderer.setSeriesShape(1, new Rectangle2D.Double(-3, -3, 6, 6));
    renderer.setSeriesPaint(1, Color.RED);
    NumberAxis vaxis = (NumberAxis) plot.getRangeAxis();
    vaxis.setAutoRange(true);
    vaxis.setAxisLineVisible(true);
    vaxis.setNumberFormatOverride(NumberFormat.getPercentInstance());
    vaxis.setTickMarksVisible(true);
    DateAxis daxis = (DateAxis) plot.getDomainAxis();
    daxis.setRange(fromDate, toDate);
    if (intervalUnitClass == Month.class) {
        DateFormatSymbols dateFormatSymbols = new DateFormatSymbols();
        dateFormatSymbols
                .setShortMonths(new String[] { "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D" });
        daxis.setDateFormatOverride(new SimpleDateFormat("MMM", dateFormatSymbols));
    }
    return chart;
}

From source file:net.sf.mzmine.modules.peaklistmethods.peakpicking.adap3decompositionV2.EICPlot.java

public EICPlot(List<List<NavigableMap<Double, Double>>> clusters, List<Double> colors, List<List<String>> info,
        List<NavigableMap<Double, Double>> modelPeaks) {
    super(null, true);

    setBackground(Color.white);//  w  w w . j  a v  a  2 s  .  c  o  m
    setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));

    NumberAxis xAxis = new NumberAxis("Retention Time");
    xAxis.setAutoRangeIncludesZero(false);
    xAxis.setUpperMargin(0);
    xAxis.setLowerMargin(0);

    NumberAxis yAxis = new NumberAxis("Intensity");
    yAxis.setAutoRangeIncludesZero(false);
    yAxis.setUpperMargin(0);
    yAxis.setLowerMargin(0);

    xyDataset = new XYSeriesCollection();
    colorDataset = new ArrayList<>();
    toolTips = new ArrayList<>();
    widths = new ArrayList<>();

    int seriesID = 0;

    for (int i = 0; i < clusters.size(); ++i) {
        List<NavigableMap<Double, Double>> cluster = clusters.get(i);
        double color = colors.get(i);

        for (int j = 0; j < cluster.size(); ++j) {
            XYSeries series = new XYSeries(seriesID++);

            for (Entry<Double, Double> e : cluster.get(j).entrySet())
                series.add(e.getKey(), e.getValue());

            xyDataset.addSeries(series);
            colorDataset.add(color);
            toolTips.add(info.get(i).get(j));
        }
    }

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer() {
        @Override
        public Paint getItemPaint(int row, int col) {
            String type = xyDataset.getSeries(row).getDescription();

            Paint color;

            if (type.equals(PeakType.MODEL.name()))
                color = COLORS[row % COLORS.length];
            else
                color = new Color(0, 0, 0, 50);

            return color;
        }

        @Override
        public Stroke getSeriesStroke(int series) {
            XYSeries s = xyDataset.getSeries(series);
            String type = s.getDescription();

            float width;
            if (type.equals((PeakType.MODEL.name())))
                width = 2.0f;
            else
                width = 1.0f;

            return new BasicStroke(width);
        }
    };

    renderer.setDefaultShapesVisible(false);
    renderer.setDefaultToolTipGenerator(new XYToolTipGenerator() {
        @Override
        public String generateToolTip(XYDataset dataset, int series, int item) {
            try {
                return toolTips.get(series);
            } catch (NullPointerException | IndexOutOfBoundsException e) {
                return "";
            }
        }
    });

    XYPlot plot = new XYPlot(xyDataset, xAxis, yAxis, renderer);
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinesVisible(true);

    JFreeChart chart = new JFreeChart("", new Font("SansSerif", Font.BOLD, 12), plot, false);
    chart.setBackgroundPaint(Color.white);

    super.setChart(chart);
}

From source file:org.gumtree.vis.awt.PlotFactory.java

public static JFreeChart createXYErrorChart(IXYErrorDataset dataset) {

    JFreeChart chart;/*from   w  w  w.  ja va2s .  c o m*/
    String title = null;
    String xTitle = null;
    String yTitle = null;
    if (dataset != null) {
        title = "";
        if (dataset.getTitle() != null) {
            title = dataset.getTitle();
        }
        xTitle = "";
        if (dataset.getXTitle() != null) {
            xTitle += dataset.getXTitle();
        }
        if (dataset.getXUnits() != null) {
            xTitle += " (" + dataset.getXUnits() + ")";
        }
        yTitle = "";
        if (dataset.getYTitle() != null) {
            yTitle += dataset.getYTitle();
        }
        if (dataset.getYUnits() != null) {
            yTitle += " (" + 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.setRangeZeroBaselineVisible(false);
    //      plot.setDomainZeroBaselineVisible(false);
    ValueAxis rangeAxis = plot.getRangeAxis();
    if (rangeAxis instanceof NumberAxis) {
        ((NumberAxis) rangeAxis).setAutoRangeStickyZero(false);
        ((NumberAxis) rangeAxis).setAutoRangeIncludesZero(false);
    }
    ValueAxis domainAxis = plot.getDomainAxis();
    if (domainAxis instanceof NumberAxis) {
        ((NumberAxis) domainAxis).setAutoRangeStickyZero(false);
        ((NumberAxis) domainAxis).setAutoRangeIncludesZero(false);
    }
    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 XYErrorRenderer) {
        //         ((XYLineAndShapeRenderer) renderer).setBaseShapesVisible(true);
        ((XYErrorRenderer) renderer).setBaseShapesFilled(true);
        ((XYErrorRenderer) renderer).setDrawXError(false);
        ((XYErrorRenderer) renderer).setDrawYError(true);
    }

    chart.fireChartChanged();
    return chart;
}

From source file:Demo.ScatterGraph.java

private JFreeChart CreateChart(int x, int y) {
    dataSet = new DefaultXYDataset();
    AddDataSet(x, y);//from w  w  w  .j  ava  2s . co m

    JFreeChart jfreechart = ChartFactory.createScatterPlot("Scatter", paraType_list.get(x),
            paraType_list.get(y), dataSet, PlotOrientation.VERTICAL, true, false, false);

    XYPlot plot = (XYPlot) jfreechart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);

    plot.setDomainGridlinesVisible(true);
    plot.setNoDataMessage("no data");

    XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) plot.getRenderer();
    xylineandshaperenderer.setSeriesOutlinePaint(0, Color.WHITE);
    xylineandshaperenderer.setUseOutlinePaint(true);
    xylineandshaperenderer.setSeriesPaint(0, Color.BLUE);

    return jfreechart;
}

From source file:org.jtotus.gui.graph.GraphPrinter.java

private XYPlot createSubPlot(String plotName, GraphSeriesType type) {

    final TimeSeriesCollection collection = new TimeSeriesCollection();
    final NumberAxis range = new NumberAxis("Value");
    final XYPlot newSubPlot = new XYPlot(collection, null, range, this.getRenderer(type));

    newSubPlot.setDomainCrosshairVisible(true);
    newSubPlot.setRangeCrosshairVisible(true);
    newSubPlot.setDomainGridlinesVisible(true);

    if (!plotMap.containsKey(plotName)) {
        plotMap.put(plotName, newSubPlot);
        mainPlot.add(newSubPlot);/*from w w  w  . ja  v  a 2  s  .  c o m*/
        return newSubPlot;
    }

    return null;
}

From source file:wattsup.jsdk.ui.ChartPanelSupport.java

/**
 * Clean the values of the chart.//w  w w  .  j av a2 s. c  o  m
 * 
 * @see #createChart()
 */
public void cleanChart() {
    this.chart_.removeLegend();
    this.chartPanel_.setBorder(null);

    cleanLabels();

    DateAxis localDateAxis = (DateAxis) ((XYPlot) this.chart_.getPlot()).getDomainAxis();
    localDateAxis.setTickLabelsVisible(false);
    localDateAxis.setTickMarksVisible(false);
    localDateAxis.setAxisLineVisible(false);

    ValueAxis localValueAxis = ((XYPlot) this.chart_.getPlot()).getRangeAxis();
    localValueAxis.setTickLabelsVisible(false);
    localValueAxis.setTickMarksVisible(false);
    localValueAxis.setAxisLineVisible(false);

    XYPlot localXYPlot = (XYPlot) this.chart_.getPlot();
    localXYPlot.setDomainGridlineStroke(this.defaultLineStroke_);
    localXYPlot.setDomainGridlinesVisible(true);
    localXYPlot.setRangeGridlineStroke(this.defaultLineStroke_);
    localXYPlot.setRangeGridlinesVisible(true);

    localXYPlot.setAxisOffset(new RectangleInsets(0.0D, 0.0D, 0.0D, 0.0D));
    localXYPlot.setInsets(new RectangleInsets(0.0D, 0.0D, 0.0D, 0.0D), true);
}