List of usage examples for org.jfree.chart.axis NumberAxis getUpperBound
public double getUpperBound()
From source file:org.jfree.experimental.chart.swt.editor.SWTNumberAxisEditor.java
/** * Creates a new editor.//from w ww . j av a 2 s . c o m * * @param parent the parent. * @param style the style. * @param axis the axis. */ public SWTNumberAxisEditor(Composite parent, int style, NumberAxis axis) { super(parent, style, axis); this.autoRange = axis.isAutoRange(); this.minimumValue = axis.getLowerBound(); this.maximumValue = axis.getUpperBound(); TabItem item2 = new TabItem(getOtherTabs(), SWT.NONE); item2.setText(" " + localizationResources.getString("Range") + " "); Composite range = new Composite(getOtherTabs(), SWT.NONE); range.setLayout(new GridLayout(2, true)); item2.setControl(range); this.autoRangeCheckBox = new Button(range, SWT.CHECK); this.autoRangeCheckBox.setText(localizationResources.getString("Auto-adjust_range")); this.autoRangeCheckBox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); this.autoRangeCheckBox.setSelection(this.autoRange); this.autoRangeCheckBox.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { toggleAutoRange(); } }); new Label(range, SWT.NONE).setText(localizationResources.getString("Minimum_range_value")); this.minimumRangeValue = new Text(range, SWT.BORDER); this.minimumRangeValue.setText(String.valueOf(this.minimumValue)); this.minimumRangeValue.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); this.minimumRangeValue.setEnabled(!this.autoRange); //this.minimumRangeValue.addModifyListener(this); //this.minimumRangeValue.addVerifyListener(this); this.minimumRangeValue.addFocusListener(this); new Label(range, SWT.NONE).setText(localizationResources.getString("Maximum_range_value")); this.maximumRangeValue = new Text(range, SWT.BORDER); this.maximumRangeValue.setText(String.valueOf(this.maximumValue)); this.maximumRangeValue.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); this.maximumRangeValue.setEnabled(!this.autoRange); //this.maximumRangeValue.addModifyListener(this); //this.maximumRangeValue.addVerifyListener(this); this.maximumRangeValue.addFocusListener(this); }
From source file:com.rcp.wbw.demo.editor.SWTNumberAxisEditor.java
/** * Creates a new editor./* ww w. java 2s .c om*/ * * @param parent * the parent. * @param style * the style. * @param axis * the axis. */ public SWTNumberAxisEditor(Composite parent, int style, NumberAxis axis) { super(parent, style, axis); this.autoRange = axis.isAutoRange(); this.minimumValue = axis.getLowerBound(); this.maximumValue = axis.getUpperBound(); TabItem item2 = new TabItem(getOtherTabs(), SWT.NONE); item2.setText(" " + localizationResources.getString("Range") + " "); Composite range = new Composite(getOtherTabs(), SWT.NONE); range.setLayout(new GridLayout(2, true)); item2.setControl(range); this.autoRangeCheckBox = new Button(range, SWT.CHECK); this.autoRangeCheckBox.setText(localizationResources.getString("Auto-adjust_range")); this.autoRangeCheckBox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); this.autoRangeCheckBox.setSelection(this.autoRange); this.autoRangeCheckBox.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { toggleAutoRange(); } }); new Label(range, SWT.NONE).setText(localizationResources.getString("Minimum_range_value")); this.minimumRangeValue = new Text(range, SWT.BORDER); this.minimumRangeValue.setText(String.valueOf(this.minimumValue)); this.minimumRangeValue.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); this.minimumRangeValue.setEnabled(!this.autoRange); // this.minimumRangeValue.addModifyListener(this); // this.minimumRangeValue.addVerifyListener(this); this.minimumRangeValue.addFocusListener(this); new Label(range, SWT.NONE).setText(localizationResources.getString("Maximum_range_value")); this.maximumRangeValue = new Text(range, SWT.BORDER); this.maximumRangeValue.setText(String.valueOf(this.maximumValue)); this.maximumRangeValue.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); this.maximumRangeValue.setEnabled(!this.autoRange); // this.maximumRangeValue.addModifyListener(this); // this.maximumRangeValue.addVerifyListener(this); this.maximumRangeValue.addFocusListener(this); }
From source file:org.cds06.speleograph.graph.ValueAxisEditor.java
public ValueAxisEditor(NumberAxis axis) { super();/* w ww.j a va 2 s . com*/ this.axis = axis; this.oldLowValue = axis.getLowerBound(); this.oldHighValue = axis.getUpperBound(); this.maxField = new JTextField(Double.toString(axis.getUpperBound())); this.lowField = new JTextField(Double.toString(axis.getLowerBound())); int max = (int) (axis.getUpperBound() / 5); translateSlider = new JSlider(Adjustable.VERTICAL, -max, max, 0); homotSlider = new JSlider(Adjustable.VERTICAL, -max, max, 0); construct(); setTitle(I18nSupport.translate("graph.valueAxisEditor")); }
From source file:opensonata.dataDisplays.BaselineImage.java
private JFreeChart createChart(String inFilename, String userTitle, NssBaseline nssBaseline) { XYSeries series = new XYSeries(""); float[] baselineValues = nssBaseline.getBaselineValues(); // plot subband values for (int i = 0; i < baselineValues.length; i++) { series.add(i, baselineValues[i]); }//from w w w .ja va 2 s . co m System.err.println("HERE!!!!"); // add a final point at the end with a zero Y value, series.add(baselineValues.length, 0.0); XYDataset data = new XYSeriesCollection(series); String inFilenameBase = new File(inFilename).getName(); DecimalFormat freqFormatter = new DecimalFormat("0000.000 MHz "); String freqString = freqFormatter.format(nssBaseline.getCenterFreqMhz()); DecimalFormat bandwidthFormatter = new DecimalFormat("0.00 MHz "); String bandwidthString = bandwidthFormatter.format(nssBaseline.getBandwidthMhz()); String mainTitle = ""; String xAxisLabel = "Subband"; String yAxisLabel = "Power"; JFreeChart chart = ChartFactory.createXYLineChart(mainTitle, xAxisLabel, yAxisLabel, data, PlotOrientation.VERTICAL, false, // legend true, // tooltips false // urls ); String subTitle1 = "Baseline: "; if (!userTitle.equals("")) { subTitle1 += userTitle; } else { subTitle1 += inFilenameBase; } chart.addSubtitle(new TextTitle(subTitle1)); String subTitle2 = "Center Freq: " + freqString + "Bandwidth: " + bandwidthString; chart.addSubtitle(new TextTitle(subTitle2)); // move the data off of the axes // by extending the minimum axis value XYPlot plot = (XYPlot) ((JFreeChart) chart).getPlot(); double axisMarginPercent = 0.02; NumberAxis valueAxis = (NumberAxis) plot.getRangeAxis(); valueAxis.setLowerBound(-1.0 * valueAxis.getUpperBound() * axisMarginPercent); valueAxis = (NumberAxis) plot.getDomainAxis(); valueAxis.setLowerBound(-1.0 * valueAxis.getUpperBound() * axisMarginPercent); return chart; }
From source file:org.pentaho.plugin.jfreereport.reportcharts.CategoricalChartExpressionTest.java
@Test public void configureRangeAxis_AnyValues() { final double lower = -20; final double upper = 20; NumberAxis axis = new NumberAxis(); axis.setRange(lower, upper);/*from w w w . j a v a 2 s. com*/ expression.configureRangeAxis(createCategoryPlotWith(axis), createFont()); Assert.assertTrue(axis.getLowerBound() < lower); Assert.assertTrue(axis.getUpperBound() > upper); }
From source file:org.pentaho.plugin.jfreereport.reportcharts.CategoricalChartExpressionTest.java
@Test public void configureRangeAxis_NegativeValues() { final double lower = -20; final double upper = -10; NumberAxis axis = new NumberAxis(); axis.setRange(lower, upper);//from ww w . j a va 2s .co m expression.configureRangeAxis(createCategoryPlotWith(axis), createFont()); Assert.assertTrue(axis.getLowerBound() < lower); Assert.assertTrue(axis.getUpperBound() > upper); Assert.assertTrue(axis.getUpperBound() < 0); }
From source file:ch.zhaw.simulation.diagram.charteditor.DefaultNumberAxisEditor.java
/** * Standard constructor: builds a property panel for the specified axis. * //from w w w .j a v a 2 s .co m * @param axis * the axis, which should be changed. */ public DefaultNumberAxisEditor(NumberAxis axis) { super(axis); this.autoRange = axis.isAutoRange(); this.minimumValue = axis.getLowerBound(); this.maximumValue = axis.getUpperBound(); this.gridPaintSample = new PaintSample(Color.blue); this.gridStrokeSample = new StrokeSample(new BasicStroke(1.0f)); this.availableStrokeSamples = new StrokeSample[3]; this.availableStrokeSamples[0] = new StrokeSample(new BasicStroke(1.0f)); this.availableStrokeSamples[1] = new StrokeSample(new BasicStroke(2.0f)); this.availableStrokeSamples[2] = new StrokeSample(new BasicStroke(3.0f)); JTabbedPane other = getOtherTabs(); JPanel range = new JPanel(new LCBLayout(3)); range.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); range.add(new JPanel()); this.autoRangeCheckBox = new JCheckBox(localizationResources.getString("Auto-adjust_range"), this.autoRange); this.autoRangeCheckBox.setActionCommand("AutoRangeOnOff"); this.autoRangeCheckBox.addActionListener(this); range.add(this.autoRangeCheckBox); range.add(new JPanel()); range.add(new JLabel(localizationResources.getString("Minimum_range_value"))); this.minimumRangeValue = new JTextField(Double.toString(this.minimumValue)); this.minimumRangeValue.setEnabled(!this.autoRange); this.minimumRangeValue.setActionCommand("MinimumRange"); this.minimumRangeValue.addActionListener(this); this.minimumRangeValue.addFocusListener(this); range.add(this.minimumRangeValue); range.add(new JPanel()); range.add(new JLabel(localizationResources.getString("Maximum_range_value"))); this.maximumRangeValue = new JTextField(Double.toString(this.maximumValue)); this.maximumRangeValue.setEnabled(!this.autoRange); this.maximumRangeValue.setActionCommand("MaximumRange"); this.maximumRangeValue.addActionListener(this); this.maximumRangeValue.addFocusListener(this); range.add(this.maximumRangeValue); range.add(new JPanel()); other.add(localizationResources.getString("Range"), range); }
From source file:desmoj.extensions.grafic.util.Plotter.java
/** * configure range axis ( lowerBound, upperBound, label, format ticks) * of time-series chart/* w ww .j a va2 s . c o m*/ * @param numberAxis * @param label */ private void configureRangeAxis(NumberAxis numberAxis, String label) { double min = numberAxis.getLowerBound(); double max = numberAxis.getUpperBound(); Double delta = 0.01 * (max - min); numberAxis.setLowerBound(min - delta); numberAxis.setUpperBound(max + delta); numberAxis.setLabel(label); // format Ticks double fontHeight = numberAxis.getTickLabelFont().getLineMetrics("X", this.frc).getHeight(); double maxTicks = this.paintPanel.getSize().height / fontHeight; int digits = Math.max(0, (int) -Math.floor(Math.log10((max - min) / maxTicks))); //System.out.println(fontHeight+" "+digits+" "+Math.log10((max - min)/ maxTicks)); NumberFormat formatter = NumberFormat.getNumberInstance(this.locale); formatter.setMinimumFractionDigits(digits); formatter.setMaximumFractionDigits(digits); formatter.setGroupingUsed(true); numberAxis.setNumberFormatOverride(formatter); }
From source file:org.pentaho.plugin.jfreereport.reportcharts.CategoricalChartExpressionTest.java
@Test public void configureRangeAxis_PositiveValues() { final double lower = 10; final double upper = 20; NumberAxis axis = new NumberAxis(); axis.setRange(lower, upper);/* w w w .ja va2 s.c om*/ expression.configureRangeAxis(createCategoryPlotWith(axis), createFont()); Assert.assertTrue(axis.getLowerBound() < lower); Assert.assertTrue(axis.getLowerBound() > 0); Assert.assertTrue(axis.getUpperBound() > upper); }
From source file:org.cds06.speleograph.data.fileio.SpeleoFileWriter.java
private Integer writeHeaders(List<Series> series, Integer[][] columns) { ArrayList<NumberAxis> axes = new ArrayList<>(); for (Series s : series) { NumberAxis axis = s.getAxis(); if (axes.contains(axis)) continue; axes.add(axis);//w ww .j a v a2 s . c o m int id = axes.indexOf(axis); boolean typeAxis = axis.equals(s.getType().getAxis()); try { write("axis", Integer.toString(id), '"' + axis.getLabel() + '"', DecimalFormat.getInstance().format(axis.getLowerBound()), DecimalFormat.getInstance().format(axis.getUpperBound()), "type:" + (typeAxis ? "1" : "0")); } catch (Exception e) { log.error("Can not write axis to file", e); } } write("date", "", Integer.toString(allocatedColumns), "d/M/y H:m:s"); allocatedColumns++; for (Series s : series) { String[] seriesDescriptor = { Integer.toString(allocatedColumns), s.getType().getName(), s.getType().getUnit() }; if (s.isMinMax()) { seriesDescriptor = ArrayUtils.add(seriesDescriptor, "min-max:1"); // NON-NLS seriesDescriptor = ArrayUtils.add(seriesDescriptor, "min:" + Integer.toString(allocatedColumns)); // NON-NLS seriesDescriptor = ArrayUtils.add(seriesDescriptor, "max:" + Integer.toString(allocatedColumns + 1)); // NON-NLS columns[series.indexOf(s)] = new Integer[] { allocatedColumns, allocatedColumns + 1 }; allocatedColumns++; allocatedColumns++; } else { columns[series.indexOf(s)] = new Integer[] { allocatedColumns }; allocatedColumns++; } if (s.isShow()) seriesDescriptor = ArrayUtils.add(seriesDescriptor, "show:1"); // NON-NLS if (s.getColor() != null) seriesDescriptor = ArrayUtils.add(seriesDescriptor, "color:" + s.getColor().getRGB()); // NON-NLS if (s.isMinMax()) seriesDescriptor = ArrayUtils.add(seriesDescriptor, "stepped:1"); // NON-NLS if (s.getStyle() != null) { seriesDescriptor = ArrayUtils.add(seriesDescriptor, "style:" + s.getStyle().toString()); // NON-NLS } if (s.isNameHumanSet()) { seriesDescriptor = ArrayUtils.add(seriesDescriptor, "name:" + s.getName()); // NON-NLS } seriesDescriptor = ArrayUtils.add(seriesDescriptor, "axis:" + axes.indexOf(s.getAxis())); write(seriesDescriptor); } return allocatedColumns; }