List of usage examples for org.jfree.chart.plot XYPlot setRangeZeroBaselineVisible
public void setRangeZeroBaselineVisible(boolean visible)
From source file:org.lmn.fc.frameworks.starbase.plugins.observatory.ui.tabs.charts.GpsScatterPlotUIComponent.java
/*********************************************************************************************** * Customise the XYPlot of a new chart, e.g. for fixed range axes. * Remember that a GPS Scatter Plot has no ChannelSelector. * * @param datasettype/*from w ww .jav a 2 s.c o m*/ * @param primarydataset * @param secondarydatasets * @param updatetype * @param displaylimit * @param channelselector * @param debug * * @return JFreeChart */ public JFreeChart createCustomisedChart(final DatasetType datasettype, final XYDataset primarydataset, final List<XYDataset> secondarydatasets, final DataUpdateType updatetype, final int displaylimit, final ChannelSelectorUIComponentInterface channelselector, final boolean debug) { final String SOURCE = "GpsScatterPlotUIComponent.createCustomisedChart() "; final JFreeChart jFreeChart; final XYPlot plot; final Stroke strokeCrosshair; final XYDotRenderer renderer; final ValueAxis axisRange; final NumberAxis axisDomain; // See ChartHelper for other calls to ChartFactory // Note that no ChannelSector means no way to control the legend, so turn it off jFreeChart = ChartFactory.createScatterPlot(MSG_WAITING_FOR_DATA, MSG_WAITING_FOR_DATA, MSG_WAITING_FOR_DATA, primarydataset, PlotOrientation.VERTICAL, false, //channelselector.hasLegend(), true, false); jFreeChart.setBackgroundPaint(UIComponentPlugin.DEFAULT_COLOUR_CANVAS.getColor()); // Experimental chart configuration jFreeChart.getTitle().setFont(UIComponentPlugin.DEFAULT_FONT.getFont().deriveFont(20.0f)); plot = (XYPlot) jFreeChart.getPlot(); plot.setBackgroundPaint(ChartHelper.COLOR_PLOT); plot.setDomainGridlinePaint(ChartHelper.COLOR_GRIDLINES); plot.setRangeGridlinePaint(ChartHelper.COLOR_GRIDLINES); plot.setAxisOffset(ChartHelper.PLOT_RECTANGLE_INSETS); plot.setDomainZeroBaselineVisible(true); plot.setRangeZeroBaselineVisible(true); plot.setDomainCrosshairVisible(true); plot.setDomainCrosshairLockedOnData(false); plot.setRangeCrosshairVisible(true); plot.setRangeCrosshairLockedOnData(true); // Make the Crosshair more visible by changing the width from the default strokeCrosshair = new BasicStroke(2.0f, // The width of this BasicStroke BasicStroke.CAP_BUTT, // The decoration of the ends of a BasicStroke BasicStroke.JOIN_BEVEL, // The decoration applied where path segments meet 0.0f, // The limit to trim the miter join new float[] { 2.0f, 2.0f }, // The array representing the dashing pattern 0.0f); // The offset to start the dashing pattern plot.setDomainCrosshairStroke(strokeCrosshair); plot.setRangeCrosshairStroke(strokeCrosshair); renderer = new XYDotRenderer(); renderer.setDotWidth(2); renderer.setDotHeight(2); plot.setRenderer(renderer); axisDomain = (NumberAxis) plot.getDomainAxis(); axisRange = plot.getRangeAxis(); // Remember that a GPS Scatter Plot has no ChannelSelector if (canAutorange()) { // The fix could be anywhere... axisDomain.setAutoRangeIncludesZero(false); axisDomain.setAutoRange(true); axisRange.setAutoRange(true); } else { // Allow range to full global extents! axisDomain.setRange(getLinearFixedMinY(), getLinearFixedMaxY()); axisRange.setRange(-90.0, 90.0); } return (jFreeChart); }
From source file:net.sf.fspdfs.chartthemes.spring.EyeCandySixtiesChartTheme.java
/** * *///from w w w . j a v a 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_134); categoryPlot.setRangeGridlineStroke(new BasicStroke(1f)); categoryPlot.setDomainGridlinesVisible(false); } else if (plot instanceof XYPlot) { XYPlot xyPlot = (XYPlot) plot; XYDataset xyDataset = xyPlot.getDataset(); if (xyDataset != null) { XYItemRenderer xyItemRenderer = xyPlot.getRenderer(); for (int i = 0; i < xyDataset.getSeriesCount(); i++) { xyItemRenderer.setSeriesOutlinePaint(i, ChartThemesConstants.TRANSPARENT_PAINT); } } xyPlot.setRangeGridlinePaint(ChartThemesConstants.GRAY_PAINT_134); xyPlot.setRangeGridlineStroke(new BasicStroke(1f)); xyPlot.setDomainGridlinesVisible(false); xyPlot.setRangeZeroBaselineVisible(true); } }
From source file:net.sf.jasperreports.chartthemes.spring.EyeCandySixtiesChartTheme.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); }/*w w w .j ava2 s. com*/ } categoryPlot.setRangeGridlinePaint(ChartThemesConstants.GRAY_PAINT_134); categoryPlot.setRangeGridlineStroke(new BasicStroke(1f)); categoryPlot.setDomainGridlinesVisible(false); } else if (plot instanceof XYPlot) { XYPlot xyPlot = (XYPlot) plot; XYDataset xyDataset = xyPlot.getDataset(); if (xyDataset != null) { XYItemRenderer xyItemRenderer = xyPlot.getRenderer(); for (int i = 0; i < xyDataset.getSeriesCount(); i++) { xyItemRenderer.setSeriesOutlinePaint(i, ChartThemesConstants.TRANSPARENT_PAINT); } } xyPlot.setRangeGridlinePaint(ChartThemesConstants.GRAY_PAINT_134); xyPlot.setRangeGridlineStroke(new BasicStroke(1f)); xyPlot.setDomainGridlinesVisible(false); xyPlot.setRangeZeroBaselineVisible(true); } }
From source file:org.pf.midea.MainUI.java
private void showConstellationWindow(ConstellationPoint[] _map, String _name) { JFrame constellation = new JFrame(" ?? " + _name); constellation.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); XYSeriesCollection dots = new XYSeriesCollection(); XYSeries series = new XYSeries(_name); JFreeChart chart = ChartFactory.createScatterPlot("", "I", "Q", dots, PlotOrientation.VERTICAL, false, false, false);//from ww w. j a v a2 s . co m XYPlot xyPlot = chart.getXYPlot(); CustomXYToolTipGenerator tooltipsGenerator = new CustomXYToolTipGenerator(); ArrayList<String> tooltips = new ArrayList<>(); for (ConstellationPoint ccp : _map) { double I = ccp.getI(); double Q = ccp.getQ(); series.add(I, Q); tooltips.add(ccp.getCode().getStringSequence()); } tooltipsGenerator.addToolTipSeries(tooltips); xyPlot.getRenderer().setBaseToolTipGenerator(tooltipsGenerator); double maxX = StatisticsTools.round(Math.abs(series.getMaxX()), 3); double maxY = StatisticsTools.round(Math.abs(series.getMaxY()), 3); double minX = StatisticsTools.round(Math.abs(series.getMinX()), 3); double minY = StatisticsTools.round(Math.abs(series.getMinY()), 3); if (maxX != 0 || minX != 0) { double X = Math.max(minX, maxX); xyPlot.getDomainAxis().setRange(-1.1 * X, 1.1 * X); } else xyPlot.getDomainAxis().setRange(-1, 1); if (maxY != 0 || minY != 0) { double Y = Math.max(minY, maxY); xyPlot.getRangeAxis().setRange(-1.1 * Y, 1.1 * Y); } else xyPlot.getRangeAxis().setRange(-1, 1); dots.addSeries(series); xyPlot.setBackgroundPaint(Color.WHITE); xyPlot.setDomainGridlinePaint(Color.GRAY); xyPlot.setRangeGridlinePaint(Color.GRAY); xyPlot.getRenderer().setSeriesPaint(0, Color.BLACK); xyPlot.setDomainZeroBaselineVisible(true); xyPlot.setRangeZeroBaselineVisible(true); ChartPanel chartPanel = new ChartPanel(chart); JPanel nestedPanel = new JPanel(); nestedPanel.add(chartPanel, new CellConstraints()); constellation.add(nestedPanel); constellation.pack(); constellation.setLocationRelativeTo(null); constellation.setResizable(false); constellation.setVisible(true); }
From source file:org.operamasks.faces.render.graph.ChartRenderer.java
protected void setChartAxes(JFreeChart chart, UIChart comp) { UIAxis xAxis = comp.getxAxis();// w w w .j av a 2 s .co m UIAxis yAxis = comp.getyAxis(); String xAxisLabel = comp.getxAxisLabel(); String yAxisLabel = comp.getyAxisLabel(); Plot plot = chart.getPlot(); Axis domainAxis = null; Axis rangeAxis = null; if (plot instanceof CategoryPlot) { CategoryPlot categoryPlot = (CategoryPlot) plot; if (yAxis != null && yAxis.isLogarithmic()) categoryPlot.setRangeAxis(new LogarithmicAxis(null)); domainAxis = categoryPlot.getDomainAxis(); rangeAxis = categoryPlot.getRangeAxis(); if (xAxis != null) { Boolean drawGridLine = xAxis.getDrawGridLine(); if (drawGridLine != null) { categoryPlot.setDomainGridlinesVisible(drawGridLine); } Paint gridLineColor = xAxis.getGridLineColor(); if (gridLineColor != null) { categoryPlot.setDomainGridlinePaint(gridLineColor); } } if (yAxis != null) { Boolean drawGridLine = yAxis.getDrawGridLine(); if (drawGridLine != null) { categoryPlot.setRangeGridlinesVisible(drawGridLine); } Paint gridLineColor = yAxis.getGridLineColor(); if (gridLineColor != null) { categoryPlot.setRangeGridlinePaint(gridLineColor); } } } else if (plot instanceof XYPlot) { XYPlot xyPlot = (XYPlot) plot; if (xAxis != null && xAxis.isLogarithmic()) xyPlot.setDomainAxis(new LogarithmicAxis(null)); if (yAxis != null && yAxis.isLogarithmic()) xyPlot.setRangeAxis(new LogarithmicAxis(null)); domainAxis = xyPlot.getDomainAxis(); rangeAxis = xyPlot.getRangeAxis(); if (xAxis != null) { Boolean drawGridLine = xAxis.getDrawGridLine(); if (drawGridLine != null) { xyPlot.setDomainGridlinesVisible(drawGridLine); } Paint gridLineColor = xAxis.getGridLineColor(); if (gridLineColor != null) { xyPlot.setDomainGridlinePaint(gridLineColor); } Boolean drawBaseLine = xAxis.getDrawBaseLine(); if (drawBaseLine != null) { xyPlot.setDomainZeroBaselineVisible(drawBaseLine); } Paint baseLineColor = xAxis.getBaseLineColor(); if (baseLineColor != null) { xyPlot.setDomainZeroBaselinePaint(baseLineColor); } } if (yAxis != null) { Boolean drawGridLine = yAxis.getDrawGridLine(); if (drawGridLine != null) { xyPlot.setRangeGridlinesVisible(drawGridLine); } Paint gridLineColor = yAxis.getGridLineColor(); if (gridLineColor != null) { xyPlot.setRangeGridlinePaint(gridLineColor); } Boolean drawBaseLine = yAxis.getDrawBaseLine(); if (drawBaseLine != null) { xyPlot.setRangeZeroBaselineVisible(drawBaseLine); } Paint baseLineColor = yAxis.getBaseLineColor(); if (baseLineColor != null) { xyPlot.setRangeZeroBaselinePaint(baseLineColor); } } } if (domainAxis != null) { if (xAxisLabel != null) domainAxis.setLabel(xAxisLabel); if (xAxis != null) setAxisStyles(domainAxis, xAxis); } if (rangeAxis != null) { if (yAxisLabel != null) rangeAxis.setLabel(yAxisLabel); if (yAxis != null) setAxisStyles(rangeAxis, yAxis); } }
From source file:org.jfree.chart.ChartFactory.java
/** * Creates a histogram chart. This chart is constructed with an * {@link XYPlot} using an {@link XYBarRenderer}. The domain and range * axes are {@link NumberAxis} instances. * * @param title the chart title (<code>null</code> permitted). * @param xAxisLabel the x axis label (<code>null</code> permitted). * @param yAxisLabel the y axis label (<code>null</code> permitted). * @param dataset the dataset (<code>null</code> permitted). * * @return The chart.//from ww w . ja v a2s. c o m */ public static JFreeChart createHistogram(String title, String xAxisLabel, String yAxisLabel, IntervalXYDataset dataset) { NumberAxis xAxis = new NumberAxis(xAxisLabel); xAxis.setAutoRangeIncludesZero(false); ValueAxis yAxis = new NumberAxis(yAxisLabel); XYItemRenderer renderer = new XYBarRenderer(); renderer.setDefaultToolTipGenerator(new StandardXYToolTipGenerator()); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setDomainZeroBaselineVisible(true); plot.setRangeZeroBaselineVisible(true); JFreeChart chart = new JFreeChart(title, plot); currentTheme.apply(chart); return chart; }
From source file:org.jfree.chart.plot.StackedXYPlot.java
/** * Adds a subplot with the specified weight * @param subplot the subplot (<code>null</code> not permitted). * @param weight the weight (must be >= 1). *///from w w w.j a va 2 s . c o m @Override public void add(XYPlot subplot, int weight) { Objects.requireNonNull(subplot, "subplot must not be null"); if (weight <= 0) { throw new IllegalArgumentException("weight must be >= 1."); } subplot.setParent(this); subplot.setWeight(weight); subplot.addChangeListener(this); subplot.setRangeZeroBaselineVisible(false); subplot.setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0), false); List subplots = Collections.EMPTY_LIST; try { subplots = (List) FieldUtils.readField(this, "subplots", true); } catch (IllegalAccessException ex) { Logger.getLogger(StackedXYPlot.class.getName()).log(Level.SEVERE, ex.getMessage(), ex); } subplots.add(subplot); ValueAxis axis = getDomainAxis(); if (axis != null) { axis.configure(); } fireChangeEvent(); }