Java Code Examples for org.jfree.chart.axis.NumberAxis#setRange()
The following examples show how to use
org.jfree.chart.axis.NumberAxis#setRange() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StandardXYItemRendererTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * A check to ensure that an item that falls outside the plot's data area * does NOT generate an item entity. */ public void testNoDisplayedItem() { XYSeriesCollection dataset = new XYSeriesCollection(); XYSeries s1 = new XYSeries("S1"); s1.add(10.0, 10.0); dataset.addSeries(s1); JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y", dataset, PlotOrientation.VERTICAL, false, true, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRenderer(new StandardXYItemRenderer()); NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setRange(0.0, 5.0); NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setRange(0.0, 5.0); BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); ChartRenderingInfo info = new ChartRenderingInfo(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, info); g2.dispose(); EntityCollection ec = info.getEntityCollection(); assertFalse(TestUtilities.containsInstanceOf(ec.getEntities(), XYItemEntity.class)); }
Example 2
Source File: StandardXYItemRendererTest.java From ccu-historian with GNU General Public License v3.0 | 6 votes |
/** * A check to ensure that an item that falls outside the plot's data area * does NOT generate an item entity. */ @Test public void testNoDisplayedItem() { XYSeriesCollection dataset = new XYSeriesCollection(); XYSeries s1 = new XYSeries("S1"); s1.add(10.0, 10.0); dataset.addSeries(s1); JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y", dataset, PlotOrientation.VERTICAL, false, true, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRenderer(new StandardXYItemRenderer()); NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setRange(0.0, 5.0); NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setRange(0.0, 5.0); BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); ChartRenderingInfo info = new ChartRenderingInfo(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, info); g2.dispose(); EntityCollection ec = info.getEntityCollection(); assertFalse(TestUtilities.containsInstanceOf(ec.getEntities(), XYItemEntity.class)); }
Example 3
Source File: SimpleBox.java From Knowage-Server with GNU Affero General Public License v3.0 | 5 votes |
public JFreeChart createChart(DatasetMap datasetMap) { BoxAndWhiskerCategoryDataset dataset=(BoxAndWhiskerCategoryDataset)datasetMap.getDatasets().get("1"); JFreeChart chart = ChartFactory.createBoxAndWhiskerChart( name, categoryLabel, valueLabel, dataset, false); TextTitle title =setStyleTitle(name, styleTitle); chart.setTitle(title); if(subName!= null && !subName.equals("")){ TextTitle subTitle =setStyleTitle(subName, styleSubTitle); chart.addSubtitle(subTitle); } CategoryPlot plot = (CategoryPlot) chart.getPlot(); BoxAndWhiskerRenderer renderer=(BoxAndWhiskerRenderer)plot.getRenderer(); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(new Color(Integer.decode("#c0c0c0").intValue())); plot.setDomainGridlinePaint(Color.WHITE); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); renderer.setFillBox(true); renderer.setArtifactPaint(Color.BLACK); renderer.setSeriesPaint(0,new Color(Integer.decode("#0000FF").intValue())); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setRange(min, max); return chart; }
Example 4
Source File: NumberAxisTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Some checks for the setLowerBound() method. */ public void testSetLowerBound() { NumberAxis axis = new NumberAxis("X"); axis.setRange(0.0, 10.0); axis.setLowerBound(5.0); assertEquals(5.0, axis.getLowerBound(), EPSILON); axis.setLowerBound(10.0); assertEquals(10.0, axis.getLowerBound(), EPSILON); assertEquals(11.0, axis.getUpperBound(), EPSILON); //axis.setRangeType(RangeType.POSITIVE); //axis.setLowerBound(-5.0); //assertEquals(0.0, axis.getLowerBound(), EPSILON); }
Example 5
Source File: CategoricalChartExpressionTest.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void configureRangeAxis_NegativeValues() { final double lower = -20; final double upper = -10; NumberAxis axis = new NumberAxis(); axis.setRange( lower, upper ); expression.configureRangeAxis( createCategoryPlotWith( axis ), createFont() ); Assert.assertTrue( axis.getLowerBound() < lower ); Assert.assertTrue( axis.getUpperBound() > upper ); Assert.assertTrue( axis.getUpperBound() < 0 ); }
Example 6
Source File: DefaultNumberAxisEditor.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Sets the properties of the specified axis to match the properties * defined on this panel. * * @param axis the axis. */ public void setAxisProperties(Axis axis) { super.setAxisProperties(axis); NumberAxis numberAxis = (NumberAxis) axis; numberAxis.setAutoRange(this.autoRange); if (!this.autoRange) { numberAxis.setRange(this.minimumValue, this.maximumValue); } }
Example 7
Source File: SWTNumberAxisEditor.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * Sets the properties of the specified axis to match * the properties defined on this panel. * * @param axis the axis. */ public void setAxisProperties(Axis axis) { super.setAxisProperties(axis); NumberAxis numberAxis = (NumberAxis) axis; numberAxis.setAutoRange(this.autoRange); if (!this.autoRange) { numberAxis.setRange(this.minimumValue, this.maximumValue); } }
Example 8
Source File: NumberAxisTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Some checks for the setLowerBound() method. */ public void testSetLowerBound() { NumberAxis axis = new NumberAxis("X"); axis.setRange(0.0, 10.0); axis.setLowerBound(5.0); assertEquals(5.0, axis.getLowerBound(), EPSILON); axis.setLowerBound(10.0); assertEquals(10.0, axis.getLowerBound(), EPSILON); assertEquals(11.0, axis.getUpperBound(), EPSILON); //axis.setRangeType(RangeType.POSITIVE); //axis.setLowerBound(-5.0); //assertEquals(0.0, axis.getLowerBound(), EPSILON); }
Example 9
Source File: SWTNumberAxisEditor.java From openstock with GNU General Public License v3.0 | 5 votes |
/** * Sets the properties of the specified axis to match * the properties defined on this panel. * * @param axis the axis. */ public void setAxisProperties(Axis axis) { super.setAxisProperties(axis); NumberAxis numberAxis = (NumberAxis) axis; numberAxis.setAutoRange(this.autoRange); if (!this.autoRange) { numberAxis.setRange(this.minimumValue, this.maximumValue); } }
Example 10
Source File: DefaultNumberAxisEditor.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Sets the properties of the specified axis to match the properties * defined on this panel. * * @param axis the axis. */ public void setAxisProperties(Axis axis) { super.setAxisProperties(axis); NumberAxis numberAxis = (NumberAxis) axis; numberAxis.setAutoRange(this.autoRange); if (!this.autoRange) { numberAxis.setRange(this.minimumValue, this.maximumValue); } }
Example 11
Source File: ChartLogics.java From mzmine2 with GNU General Public License v2.0 | 5 votes |
/** * Auto range the range axis * * @param myChart * @param zoom * @param autoRangeY if true the range (Y) axis auto bounds will be restored */ public static void autoDomainAxis(ChartPanel myChart) { XYPlot plot = (XYPlot) myChart.getChart().getPlot(); NumberAxis axis = (NumberAxis) plot.getDomainAxis(); // trick. Otherwise auto range will fail sometimes axis.setRange(axis.getRange()); axis.setAutoRangeIncludesZero(false); myChart.restoreAutoDomainBounds(); }
Example 12
Source File: ChartLogics.java From mzmine3 with GNU General Public License v2.0 | 5 votes |
/** * Auto range the range axis * * @param myChart * @param zoom * @param autoRangeY if true the range (Y) axis auto bounds will be restored */ public static void autoDomainAxis(ChartPanel myChart) { XYPlot plot = (XYPlot) myChart.getChart().getPlot(); NumberAxis axis = (NumberAxis) plot.getDomainAxis(); // trick. Otherwise auto range will fail sometimes axis.setRange(axis.getRange()); axis.setAutoRangeIncludesZero(false); myChart.restoreAutoDomainBounds(); }
Example 13
Source File: ChartLogics.java From mzmine3 with GNU General Public License v2.0 | 5 votes |
/** * Auto range the range axis * * @param myChart * @param zoom * @param autoRangeY if true the range (Y) axis auto bounds will be restored */ public static void autoRangeAxis(ChartPanel myChart) { XYPlot plot = (XYPlot) myChart.getChart().getPlot(); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); // trick. Otherwise auto range will fail sometimes rangeAxis.setRange(rangeAxis.getRange()); rangeAxis.setAutoRangeIncludesZero(true); myChart.restoreAutoRangeBounds(); }
Example 14
Source File: SpectraVisualizerWindow.java From mzmine2 with GNU General Public License v2.0 | 5 votes |
public void setAxesRange(double xMin, double xMax, double xTickSize, double yMin, double yMax, double yTickSize) { NumberAxis xAxis = (NumberAxis) spectrumPlot.getXYPlot().getDomainAxis(); NumberAxis yAxis = (NumberAxis) spectrumPlot.getXYPlot().getRangeAxis(); xAxis.setRange(xMin, xMax); xAxis.setTickUnit(new NumberTickUnit(xTickSize)); yAxis.setRange(yMin, yMax); yAxis.setTickUnit(new NumberTickUnit(yTickSize)); }
Example 15
Source File: ScatterPlot.java From Benchmark with GNU General Public License v2.0 | 4 votes |
public void initializePlot( XYPlot xyplot ) { NumberAxis rangeAxis = (NumberAxis) xyplot.getRangeAxis(); NumberAxis domainAxis = (NumberAxis) xyplot.getDomainAxis(); rangeAxis.setRange(-9.99, 109.99); rangeAxis.setNumberFormatOverride(pctFormat); rangeAxis.setTickLabelPaint(Color.decode("#666666")); rangeAxis.setMinorTickCount(5); rangeAxis.setTickUnit(new NumberTickUnit(10)); rangeAxis.setAxisLineVisible(true); rangeAxis.setMinorTickMarksVisible(true); rangeAxis.setTickMarksVisible(true); rangeAxis.setLowerMargin(10); rangeAxis.setUpperMargin(10); domainAxis.setRange(-5, 175); domainAxis.setNumberFormatOverride(pctFormat); domainAxis.setTickLabelPaint(Color.decode("#666666")); domainAxis.setMinorTickCount(5); domainAxis.setTickUnit(new NumberTickUnit(10)); domainAxis.setAxisLineVisible(true); domainAxis.setTickMarksVisible(true); domainAxis.setMinorTickMarksVisible(true); domainAxis.setLowerMargin(10); domainAxis.setUpperMargin(10); xyplot.setRangeGridlineStroke(new BasicStroke()); xyplot.setRangeGridlinePaint(Color.lightGray); xyplot.setRangeMinorGridlinePaint(Color.decode("#DDDDDD")); xyplot.setRangeMinorGridlinesVisible(true); xyplot.setOutlineVisible(true); xyplot.setDomainGridlineStroke(new BasicStroke()); xyplot.setDomainGridlinePaint(Color.lightGray); xyplot.setDomainMinorGridlinePaint(Color.decode("#DDDDDD")); xyplot.setDomainMinorGridlinesVisible(true); xyplot.getRenderer().setSeriesPaint(0, Color.decode("#4572a7")); chart.setTextAntiAlias(true); chart.setAntiAlias(true); chart.removeLegend(); chart.setPadding(new RectangleInsets(20, 20, 20, 20)); Point2D legendLocation = new Point2D.Double( 101, -10 ); makeRect(xyplot, legendLocation, 120, 74, Color.WHITE ); Point2D triangleLocation = new Point2D.Double( 101, -10 ); Color grey = new Color(0.1f,0.1f,0.1f,0.1f); makeTriangle(xyplot, triangleLocation, grey ); makeGuessingLine( xyplot ); }
Example 16
Source File: LineChartBuilder.java From nmonvisualizer with Apache License 2.0 | 4 votes |
/** * This only sets the first Y axis as a percent. There is no support for having other axes with percent scales. */ public static void setPercentYAxis(JFreeChart chart) { NumberAxis yAxis = (NumberAxis) chart.getXYPlot().getRangeAxis(); yAxis.setRange(0, 100); }
Example 17
Source File: AdminJFreeChartController.java From Spring-MVC-Blueprints with MIT License | 4 votes |
private void adjustAxis(NumberAxis axis, boolean vertical) { axis.setRange(-3.0, 3.0); axis.setTickUnit(new NumberTickUnit(0.5)); axis.setVerticalTickLabels(vertical); }
Example 18
Source File: RTMZPlot.java From mzmine3 with GNU General Public License v2.0 | 4 votes |
public RTMZPlot(RTMZAnalyzerWindow masterFrame, AbstractXYZDataset dataset, InterpolatingLookupPaintScale paintScale) { super(null); this.paintScale = paintScale; chart = ChartFactory.createXYAreaChart("", "Retention time", "m/z", dataset, PlotOrientation.VERTICAL, false, false, false); chart.setBackgroundPaint(Color.white); setChart(chart); // title TextTitle chartTitle = chart.getTitle(); chartTitle.setMargin(5, 0, 0, 0); chartTitle.setFont(titleFont); chart.removeSubtitle(chartTitle); // disable maximum size (we don't want scaling) // setMaximumDrawWidth(Integer.MAX_VALUE); // setMaximumDrawHeight(Integer.MAX_VALUE); // set the plot properties plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); // set grid properties plot.setDomainGridlinePaint(gridColor); plot.setRangeGridlinePaint(gridColor); // set crosshair (selection) properties plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setDomainCrosshairPaint(crossHairColor); plot.setRangeCrosshairPaint(crossHairColor); plot.setDomainCrosshairStroke(crossHairStroke); plot.setRangeCrosshairStroke(crossHairStroke); NumberFormat rtFormat = MZmineCore.getConfiguration().getRTFormat(); NumberFormat mzFormat = MZmineCore.getConfiguration().getMZFormat(); // set the X axis (retention time) properties NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setNumberFormatOverride(rtFormat); xAxis.setUpperMargin(0.001); xAxis.setLowerMargin(0.001); // set the Y axis (intensity) properties NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setAutoRangeIncludesZero(false); yAxis.setNumberFormatOverride(mzFormat); plot.setDataset(dataset); spotRenderer = new RTMZRenderer(dataset, paintScale); plot.setRenderer(spotRenderer); spotRenderer.setDefaultToolTipGenerator(new RTMZToolTipGenerator()); // Add a paintScaleLegend to chart paintScaleAxis = new NumberAxis("Logratio"); paintScaleAxis.setRange(paintScale.getLowerBound(), paintScale.getUpperBound()); paintScaleLegend = new PaintScaleLegend(paintScale, paintScaleAxis); paintScaleLegend.setPosition(plot.getDomainAxisEdge()); paintScaleLegend.setMargin(5, 25, 5, 25); chart.addSubtitle(paintScaleLegend); // reset zoom history ZoomHistory history = getZoomHistory(); if (history != null) history.clear(); }
Example 19
Source File: KendrickMassPlotTask.java From mzmine3 with GNU General Public License v2.0 | 4 votes |
/** * create 2D Kendrick mass plot */ private JFreeChart create2DKendrickMassPlot() { if (zAxisLabel.equals("none")) { logger.info("Creating new 2D chart instance"); appliedSteps++; // load dataset dataset2D = new KendrickMassPlotXYDataset(parameters); // create chart chart = ChartFactory.createScatterPlot(title, xAxisLabel, yAxisLabel, dataset2D, PlotOrientation.VERTICAL, true, true, true); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainCrosshairPaint(Color.GRAY); plot.setRangeCrosshairPaint(Color.GRAY); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); appliedSteps++; // set axis NumberAxis domain = (NumberAxis) plot.getDomainAxis(); NumberAxis range = (NumberAxis) plot.getRangeAxis(); range.setRange(0, 1); if (xAxisLabel.contains("KMD")) { domain.setRange(0, 1); } // set renderer XYBlockPixelSizeRenderer renderer = new XYBlockPixelSizeRenderer(); // set tooltip generator ScatterPlotToolTipGenerator tooltipGenerator = new ScatterPlotToolTipGenerator(xAxisLabel, yAxisLabel, zAxisLabel, rows); renderer.setSeriesToolTipGenerator(0, tooltipGenerator); plot.setRenderer(renderer); // set item label generator NameItemLabelGenerator generator = new NameItemLabelGenerator(rows); renderer.setDefaultItemLabelGenerator(generator); renderer.setDefaultItemLabelsVisible(false); renderer.setDefaultItemLabelFont(legendFont); renderer.setDefaultPositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.TOP_RIGHT, TextAnchor.TOP_RIGHT, -45), true); } return chart; }
Example 20
Source File: ChartJFreeChartOutputHistogram.java From gama with GNU General Public License v3.0 | 4 votes |
@Override public void resetAxes(final IScope scope) { final CategoryPlot pp = (CategoryPlot) this.chart.getPlot(); NumberAxis rangeAxis = (NumberAxis) ((CategoryPlot) this.chart.getPlot()).getRangeAxis(); if (getY_LogScale(scope)) { final LogarithmicAxis logAxis = new LogarithmicAxis(rangeAxis.getLabel()); logAxis.setAllowNegativesFlag(true); ((CategoryPlot) this.chart.getPlot()).setRangeAxis(logAxis); rangeAxis = logAxis; } if (!useyrangeinterval && !useyrangeminmax) { rangeAxis.setAutoRange(true); } if (this.useyrangeinterval) { rangeAxis.setFixedAutoRange(yrangeinterval); rangeAxis.setAutoRangeMinimumSize(yrangeinterval); rangeAxis.setAutoRange(true); } if (this.useyrangeminmax) { rangeAxis.setRange(yrangemin, yrangemax); } resetDomainAxis(scope); final CategoryAxis domainAxis = ((CategoryPlot) this.chart.getPlot()).getDomainAxis(); pp.setDomainGridlinePaint(axesColor); pp.setRangeGridlinePaint(axesColor); pp.setRangeCrosshairVisible(true); pp.getRangeAxis().setAxisLinePaint(axesColor); pp.getRangeAxis().setLabelFont(getLabelFont()); pp.getRangeAxis().setTickLabelFont(getTickFont()); if (textColor != null) { pp.getRangeAxis().setLabelPaint(textColor); pp.getRangeAxis().setTickLabelPaint(textColor); } if (getYTickUnit(scope) > 0) { ((NumberAxis) pp.getRangeAxis()).setTickUnit(new NumberTickUnit(getYTickUnit(scope))); } if (getYLabel(scope) != null && !getYLabel(scope).isEmpty()) { pp.getRangeAxis().setLabel(getYLabel(scope)); } if (this.series_label_position.equals("yaxis")) { pp.getRangeAxis().setLabel(this.getChartdataset().getDataSeriesIds(scope).iterator().next()); chart.getLegend().setVisible(false); } if (getXLabel(scope) != null && !getXLabel(scope).isEmpty()) { pp.getDomainAxis().setLabel(getXLabel(scope)); } if (this.useSubAxis) { for (final String serieid : chartdataset.getDataSeriesIds(scope)) { ((SubCategoryAxis) domainAxis).addSubCategory(serieid); } } if (!this.getYTickLineVisible(scope)) { pp.setDomainGridlinesVisible(false); } if (!this.getYTickLineVisible(scope)) { pp.setRangeCrosshairVisible(false); } if (!this.getYTickValueVisible(scope)) { pp.getRangeAxis().setTickMarksVisible(false); pp.getRangeAxis().setTickLabelsVisible(false); } }