List of usage examples for org.jfree.chart.axis NumberAxis setAutoRangeIncludesZero
public void setAutoRangeIncludesZero(boolean flag)
From source file:org.locationtech.udig.processingtoolbox.tools.BoxPlotDialog.java
private void updateChart(SimpleFeatureCollection features, String[] fields) { // Setup Box plot int fontStyle = java.awt.Font.BOLD; FontData fontData = getShell().getDisplay().getSystemFont().getFontData()[0]; CategoryAxis xPlotAxis = new CategoryAxis(EMPTY); // Type xPlotAxis.setLabelFont(new Font(fontData.getName(), fontStyle, 12)); xPlotAxis.setTickLabelFont(new Font(fontData.getName(), fontStyle, 12)); NumberAxis yPlotAxis = new NumberAxis("Value"); // Value //$NON-NLS-1$ yPlotAxis.setLabelFont(new Font(fontData.getName(), fontStyle, 12)); yPlotAxis.setTickLabelFont(new Font(fontData.getName(), fontStyle, 10)); yPlotAxis.setAutoRangeIncludesZero(false); BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setMedianVisible(true);// www . ja v a2 s .co m renderer.setMeanVisible(false); renderer.setFillBox(true); renderer.setSeriesFillPaint(0, java.awt.Color.CYAN); renderer.setBaseFillPaint(java.awt.Color.CYAN); renderer.setBaseToolTipGenerator(new BoxAndWhiskerToolTipGenerator()); // Set the scatter data, renderer, and axis into plot CategoryDataset dataset = getDataset(features, fields); CategoryPlot plot = new CategoryPlot(dataset, xPlotAxis, yPlotAxis, renderer); plot.setOrientation(PlotOrientation.VERTICAL); plot.setBackgroundPaint(java.awt.Color.WHITE); plot.setRangePannable(false); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setForegroundAlpha(0.85f); // Map the scatter to the first Domain and first Range plot.mapDatasetToDomainAxis(0, 0); plot.mapDatasetToRangeAxis(0, 0); // 3. Setup Selection /***************************************************************************************** * CategoryAxis xSelectionAxis = new CategoryAxis(EMPTY); * xSelectionAxis.setTickMarksVisible(false); xSelectionAxis.setTickLabelsVisible(false); * * NumberAxis ySelectionAxis = new NumberAxis(EMPTY); * ySelectionAxis.setTickMarksVisible(false); ySelectionAxis.setTickLabelsVisible(false); * * BoxAndWhiskerRenderer selectionRenderer = new BoxAndWhiskerRenderer(); * selectionRenderer.setSeriesShape(0, new Ellipse2D.Double(0, 0, 6, 6)); * selectionRenderer.setSeriesPaint(0, java.awt.Color.RED); // dot * * plot.setDataset(2, new DefaultBoxAndWhiskerCategoryDataset()); plot.setRenderer(2, * selectionRenderer); plot.setDomainAxis(2, xSelectionAxis); plot.setRangeAxis(2, * ySelectionAxis); * * // Map the scatter to the second Domain and second Range plot.mapDatasetToDomainAxis(2, * 0); plot.mapDatasetToRangeAxis(2, 0); *****************************************************************************************/ // 5. Finally, Create the chart with the plot and a legend java.awt.Font titleFont = new Font(fontData.getName(), fontStyle, 20); JFreeChart chart = new JFreeChart(EMPTY, titleFont, plot, false); chart.setBackgroundPaint(java.awt.Color.WHITE); chart.setBorderVisible(false); chartComposite.setChart(chart); chartComposite.forceRedraw(); }
From source file:charts.Chart.java
public static void GraficoSeries() { //System.out.println("After initComponents"); JFrame janela = new JFrame("Example of the series graphic"); janela.getContentPane().setLayout(null); javax.swing.JLabel jLabel1 = new javax.swing.JLabel(); jLabel1.setText(""); janela.getContentPane().add(jLabel1); y_of_x = new double[n_points]; x = new double[n_points]; XYSeries series1 = new XYSeries("Cos(x) versus x"); XYSeries series2 = new XYSeries("Cos^2(x) versus x"); for (int i = 0; i < n_points; i++) {//calculate the data to be plotted y_of_x[i] = Math.cos(i * Math.PI / 180); series1.add((double) i, y_of_x[i]);//add values to the series series2.add((double) i, Math.pow(y_of_x[i], 2)); }/*w w w. j a v a2 s .co m*/ XYDataset dataset1 = new XYSeriesCollection(series1); XYDataset dataset2 = new XYSeriesCollection(series2); CombinedDomainXYPlot parent = new CombinedDomainXYPlot(new NumberAxis("x-angle argument")); XYItemRenderer renderer1 = new StandardXYItemRenderer(); XYPlot subplot1 = new XYPlot(dataset1, null, new NumberAxis("Cos(x)"), renderer1); NumberAxis axis1 = (NumberAxis) subplot1.getRangeAxis(); axis1.setTickLabelFont(new Font("Monospaced", Font.PLAIN, 10)); axis1.setLabelFont(new Font("SansSerif", Font.PLAIN, 10)); axis1.setAutoRangeIncludesZero(false); parent.add(subplot1, 1); XYItemRenderer renderer2 = new StandardXYItemRenderer(); XYPlot subplot2 = new XYPlot(dataset2, null, new NumberAxis("Cos^2(x)"), renderer2); NumberAxis axis2 = (NumberAxis) subplot2.getRangeAxis(); axis2.setTickLabelFont(new Font("Monospaced", Font.PLAIN, 10)); axis2.setLabelFont(new Font("SansSerif", Font.PLAIN, 10)); axis2.setAutoRangeIncludesZero(false); parent.add(subplot2, 1); JFreeChart chart = new JFreeChart("Cos(x) versus x", parent); ChartPanel myChart = new ChartPanel(chart); janela.setSize(500, 600); janela.setContentPane(myChart); janela.setVisible(true); }
From source file:adapters.AxisAdapter.java
/** * Create a new <TT>AxisAdapter</TT> instance from an existing <TT>NumberAxis</TT> * instance with vertical (<SPAN CLASS="MATH"><I>y</I></SPAN>-axis) or horizontal (<SPAN CLASS="MATH"><I>x</I></SPAN>-axis) orientation. * * @param inAxis NumberAxis instance associated to the new variable. * * @param orientation axis direction, horizontal or vertical * *//*from w w w . java 2 s . com*/ public AxisAdapter(NumberAxis inAxis, boolean orientation) { this.axis = inAxis; this.orientation = orientation; this.labelsFlag = false; this.labelsValue = null; this.labelsName = null; inAxis.setAutoRangeIncludesZero(false); inAxis.setLowerMargin(0); inAxis.setUpperMargin(0); axis.setTickUnit(new NumberTickUnit(computeAutoTickValue())); }
From source file:org.ramadda.data.services.PointFormHandler.java
/** * create jfree chart//from www . j a v a 2 s .c om * * @param request the request * @param entry The entry * @param dataset the dataset * @param backgroundImage background image * * @return the chart */ public static JFreeChart createTimeseriesChart(Request request, Entry entry, XYDataset dataset, Image backgroundImage) { JFreeChart chart = ChartFactory.createXYLineChart("", // chart title "", // x axis label "Height", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); DateAxis timeAxis = new DateAxis("Time", request.getRepository().TIMEZONE_UTC); NumberAxis valueAxis = new NumberAxis("Data"); valueAxis.setAutoRangeIncludesZero(true); XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null); chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true); chart.setBackgroundPaint(Color.white); if (backgroundImage != null) { plot.setBackgroundImage(backgroundImage); plot.setBackgroundImageAlignment(org.jfree.ui.Align.TOP_LEFT); } plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setInsets(new RectangleInsets(0, 0, 0, 0)); plot.setAxisOffset(new RectangleInsets(5, 0, 5, 0)); return chart; }
From source file:edu.ucla.stat.SOCR.chart.demo.PowerTransformXYScatterChart.java
/** * Creates a chart.//from w w w.ja v a 2 s . c o m * * @param dataset the data for the chart. * * @return a chart. */ protected JFreeChart createChart(XYDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, //"Power Transformed XYScatter Chart", // chart title domainLabel, // x axis label rangeLabel, // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); // renderer.setLinesVisible(false); renderer.setSeriesLinesVisible(1, true); renderer.setSeriesShapesVisible(1, true); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(0, true); renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); // change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(false); rangeAxis.setUpperMargin(0); rangeAxis.setLowerMargin(0); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); domainAxis.setAutoRangeIncludesZero(false); domainAxis.setUpperMargin(0); domainAxis.setLowerMargin(0); // OPTIONAL CUSTOMISATION COMPLETED. setXSummary(dataset); return chart; }
From source file:edu.ucla.stat.SOCR.chart.SuperCategoryChart_Stat_Raw.java
/** * Creates a chart.//from w w w .ja v a 2s .c om * * @param dataset the dataset. * * @return a chart. */ protected JFreeChart createChart(CategoryDataset dataset) { // create the chart... // create the chart... JFreeChart chart = ChartFactory.createLineChart(chartTitle, // chart title domainLabel, // domain axis label rangeLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation !legendPanelOn, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setRangeGridlinePaint(Color.white); // customise the range axis... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(true); // customise the renderer... StatisticalBarRenderer renderer = new StatisticalBarRenderer(); renderer.setErrorIndicatorPaint(Color.black); plot.setRenderer(renderer); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:org.jls.toolbox.math.chart.XYBlockChart.java
/** * Permet de paramtrer le graphique une fois cr. *///from ww w . ja va 2 s .c o m private void setChartStyle() { this.plot.setBackgroundAlpha((float) 0.0); this.plot.setDomainCrosshairLockedOnData(false); this.plot.setRangeCrosshairLockedOnData(false); this.plot.setDomainCrosshairVisible(true); this.plot.setRangeCrosshairVisible(true); this.plot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); this.plot.setDomainGridlinesVisible(true); this.plot.setRangeGridlinesVisible(true); this.plot.setRangeGridlinePaint(Color.white); this.plot.setDomainCrosshairStroke(new BasicStroke(1f)); this.plot.setRangeCrosshairStroke(new BasicStroke(1f)); this.chart.setBackgroundPaint(this.CHART_BACKGROUND_COLOR); NumberAxis xAxis = (NumberAxis) this.plot.getDomainAxis(); NumberAxis yAxis = (NumberAxis) this.plot.getRangeAxis(); xAxis.setAxisLinePaint(this.CHART_FOREGROUND_COLOR); xAxis.setLabelPaint(this.CHART_FOREGROUND_COLOR); xAxis.setTickLabelPaint(this.CHART_FOREGROUND_COLOR); xAxis.setTickMarkPaint(this.CHART_FOREGROUND_COLOR); xAxis.setAutoRange(true); xAxis.setAutoRangeIncludesZero(false); yAxis.setAxisLinePaint(this.CHART_FOREGROUND_COLOR); yAxis.setLabelPaint(this.CHART_FOREGROUND_COLOR); yAxis.setTickLabelPaint(this.CHART_FOREGROUND_COLOR); yAxis.setTickMarkPaint(this.CHART_FOREGROUND_COLOR); yAxis.setAutoRange(true); yAxis.setAutoRangeIncludesZero(false); this.plot.setBackgroundPaint(this.CHART_FOREGROUND_COLOR); this.plot.setDomainGridlinePaint(this.CHART_FOREGROUND_COLOR); this.plot.setRangeGridlinePaint(this.CHART_FOREGROUND_COLOR); this.plot.setDomainCrosshairPaint(this.CROSSHAIR_COLOR); this.plot.setRangeCrosshairPaint(this.CROSSHAIR_COLOR); }
From source file:com.bwc.ora.views.LrpDisplayFrame.java
private void setChart(LrpSeries series) { lrpSeries = series.getLrpSeries();//from www. j av a2 s. c om maximaSeries = series.getMaximaSeries(); hiddenMaximaSeries = series.getHiddenMaximaSeries(); graphData = new XYSeriesCollection(); //add series data to graph graphData.addSeries(lrpSeries); graphData.addSeries(maximaSeries); graphData.addSeries(hiddenMaximaSeries); series.getFwhmSeries().forEach(graphData::addSeries); //create the chart for displaying the data JFreeChart chart = ChartFactory.createXYLineChart("LRP", "Pixel Height", "Reflectivity", graphData, PlotOrientation.HORIZONTAL, true, true, false); chartPanel.setChart(chart); //create a custom renderer to control the display of each series //set draw properties for the LRP data HighlightXYRenderer renderer = new HighlightXYRenderer(); renderer.setSeriesLinesVisible(0, true); renderer.setSeriesShapesVisible(0, false); renderer.setSeriesPaint(0, Color.RED); //set draw properties for the maxima data renderer.setDrawOutlines(true); renderer.setUseOutlinePaint(true); renderer.setUseFillPaint(true); renderer.setSeriesLinesVisible(1, false); renderer.setSeriesShapesVisible(1, true); renderer.setSeriesShapesFilled(1, true); renderer.setSeriesFillPaint(1, Color.BLUE); renderer.setSeriesShape(1, new Ellipse2D.Double(-3.0, -3.0, 6.0, 6.0)); //set draw properties for the hidden maxima data renderer.setSeriesLinesVisible(2, false); renderer.setSeriesShapesVisible(2, true); renderer.setSeriesShapesFilled(2, true); renderer.setSeriesFillPaint(2, Color.MAGENTA); renderer.setSeriesShape(2, new Rectangle2D.Double(-3.0, -3.0, 6.0, 6.0)); //set draw properties for each of the full-width half-max lines for (int i = 3; i < series.getFwhmSeries().size() + 3; i++) { renderer.setSeriesLinesVisible(i, true); renderer.setSeriesShapesVisible(i, false); renderer.setSeriesPaint(i, Color.BLACK); renderer.setSeriesVisibleInLegend(i, false, false); } chart.getXYPlot().setRenderer(renderer); //add listener for highlighting points when hovered over if (mouseMovementListener != null) { chartPanel.removeChartMouseListener(mouseMovementListener); } mouseMovementListener = getMovementChartMouseListener(renderer); chartPanel.addChartMouseListener(mouseMovementListener); //mark the Domain (which appears as the range in a horizontal graph) // axis as inverted so LRP matches with OCT ValueAxis domainAxis = chart.getXYPlot().getDomainAxis(); if (domainAxis instanceof NumberAxis) { NumberAxis axis = (NumberAxis) domainAxis; axis.setInverted(true); } //disable the need for the range of the chart to include zero ValueAxis rangeAxis = chart.getXYPlot().getRangeAxis(); if (rangeAxis instanceof NumberAxis) { NumberAxis axis = (NumberAxis) rangeAxis; axis.setAutoRangeIncludesZero(false); } //if there were any previous annotations to the LRP add them to the chart lrps.getSelectedValue().getAnnotations().forEach(chart.getXYPlot()::addAnnotation); }
From source file:org.amanzi.awe.charts.builder.TimeChartBuilder.java
@Override protected NumberAxis configRangeAxis(IRangeAxis axis) { NumberAxis rangeAxis; if (axis.equals(getModel().getMainRangeAxis())) { rangeAxis = (NumberAxis) getPlot().getRangeAxis(); rangeAxis.setNumberFormatOverride(NumberFormat.getInstance()); rangeAxis.getNumberFormatOverride().setMaximumFractionDigits(MAXIMUM_FRACTION_DIGITS); } else {//from w w w. j av a2s. c o m rangeAxis = new NumberAxis(getModel().getSecondRangeAxis().getName()); rangeAxis.setNumberFormatOverride(NumberFormat.getInstance()); rangeAxis.getNumberFormatOverride().setMaximumFractionDigits(MAXIMUM_FRACTION_DIGITS); rangeAxis.setAutoRangeIncludesZero(false); } return rangeAxis; }
From source file:net.sf.mzmine.modules.visualization.neutralloss.NeutralLossPlot.java
NeutralLossPlot(NeutralLossVisualizerWindow visualizer, NeutralLossDataSet dataset, Object xAxisType) { super(null, true); this.visualizer = visualizer; setBackground(Color.white);// w w w.j a v a 2 s . com setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); NumberFormat rtFormat = MZmineCore.getConfiguration().getRTFormat(); NumberFormat mzFormat = MZmineCore.getConfiguration().getMZFormat(); // set the X axis (retention time) properties NumberAxis xAxis; if (xAxisType.equals(NeutralLossParameters.xAxisPrecursor)) { xAxis = new NumberAxis("Precursor m/z"); xAxis.setNumberFormatOverride(mzFormat); } else { xAxis = new NumberAxis("Retention time"); xAxis.setNumberFormatOverride(rtFormat); } xAxis.setUpperMargin(0); xAxis.setLowerMargin(0); xAxis.setAutoRangeIncludesZero(false); // set the Y axis (intensity) properties NumberAxis yAxis = new NumberAxis("Neutral loss (Da)"); yAxis.setAutoRangeIncludesZero(false); yAxis.setNumberFormatOverride(mzFormat); yAxis.setUpperMargin(0); yAxis.setLowerMargin(0); // set the renderer properties defaultRenderer = new NeutralLossDataPointRenderer(false, true); defaultRenderer.setTransparency(0.4f); setSeriesColorRenderer(0, pointColor, dataPointsShape); setSeriesColorRenderer(1, searchPrecursorColor, dataPointsShape2); setSeriesColorRenderer(2, searchNeutralLossColor, dataPointsShape2); // tooltips defaultRenderer.setBaseToolTipGenerator(dataset); // set the plot properties plot = new XYPlot(dataset, xAxis, yAxis, defaultRenderer); plot.setBackgroundPaint(Color.white); plot.setRenderer(defaultRenderer); plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD); // chart properties chart = new JFreeChart("", titleFont, plot, false); chart.setBackgroundPaint(Color.white); setChart(chart); // title chartTitle = chart.getTitle(); chartTitle.setMargin(5, 0, 0, 0); chartTitle.setFont(titleFont); // disable maximum size (we don't want scaling) setMaximumDrawWidth(Integer.MAX_VALUE); setMaximumDrawHeight(Integer.MAX_VALUE); // set crosshair (selection) properties plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setDomainCrosshairPaint(crossHairColor); plot.setRangeCrosshairPaint(crossHairColor); plot.setDomainCrosshairStroke(crossHairStroke); plot.setRangeCrosshairStroke(crossHairStroke); plot.addRangeMarker(new ValueMarker(0)); // set focusable state to receive key events setFocusable(true); // register key handlers GUIUtils.registerKeyHandler(this, KeyStroke.getKeyStroke("SPACE"), visualizer, "SHOW_SPECTRUM"); // add items to popup menu JPopupMenu popupMenu = getPopupMenu(); popupMenu.addSeparator(); JMenuItem highLightPrecursorRange = new JMenuItem("Highlight precursor m/z range..."); highLightPrecursorRange.addActionListener(visualizer); highLightPrecursorRange.setActionCommand("HIGHLIGHT_PRECURSOR"); popupMenu.add(highLightPrecursorRange); JMenuItem highLightNeutralLossRange = new JMenuItem("Highlight neutral loss m/z range..."); highLightNeutralLossRange.addActionListener(visualizer); highLightNeutralLossRange.setActionCommand("HIGHLIGHT_NEUTRALLOSS"); popupMenu.add(highLightNeutralLossRange); }