List of usage examples for org.jfree.chart.axis NumberAxis getLowerBound
public double getLowerBound()
From source file:org.jfree.experimental.chart.swt.editor.SWTNumberAxisEditor.java
/** * Creates a new editor./*w ww. j a va 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:com.rcp.wbw.demo.editor.SWTNumberAxisEditor.java
/** * Creates a new editor./*from w w w . j a va 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:org.cds06.speleograph.graph.ValueAxisEditor.java
public ValueAxisEditor(NumberAxis axis) { super();/*w w w.ja v a2 s . c o m*/ 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: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);//w w w. j a v a 2 s . c o m 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_PositiveValues() { final double lower = 10; final double upper = 20; NumberAxis axis = new NumberAxis(); axis.setRange(lower, upper);// w ww .j a v a 2s . com expression.configureRangeAxis(createCategoryPlotWith(axis), createFont()); Assert.assertTrue(axis.getLowerBound() < lower); Assert.assertTrue(axis.getLowerBound() > 0); 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);/*ww w. j a v a 2 s . 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. * //www . ja v a 2 s . c o 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//from w w w . java 2 s .c om * @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.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 w w . j a va 2 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; }
From source file:no.met.jtimeseries.marinogram.MarinogramPressurePlot.java
private XYPlot createPlot(TimeZone timezone, boolean plotPressure) { ChartPlotter plotter = null;//w w w . ja va 2 s. c o m if (plotPressure) { plotter = new ChartPlotter(); // default setting plotter.setHeight(this.getHeight()); plotter.setWidth(this.getWidth()); plotter.setPlotDefaultProperties("", ""); NumberPhenomenon pressure = getLocationForecastDataModel() .getPhenomenen(PhenomenonName.Pressure.toString(), NumberPhenomenon.class); List<Date> shortTermTime = pressure.getTime(); Color pressureColor = new Color(11, 164, 42); PlotStyle.Builder pressureStyleBuilder = new PlotStyle.Builder( messages.getString("parameter.pressure") + " (hPa)"); PlotStyle plotStyle = pressureStyleBuilder.spline(SplineStyle.HYBRID).ticks(4).difference(50.0d) .seriesColor(pressureColor).labelColor(pressureColor).build(); plotter.addLineChart(TimeBase.SECOND, pressure, plotStyle); //plotter.formalizeRangeAxisWithMargins(plotter.getRangeAxisIndex() - 1, 950, 1050); double tick = (pressure.getMaxValue() - pressure.getMinValue()) / 2; tick = Math.ceil(tick / 10) * 10; double lowBound = Math.floor(pressure.getMinValue() / (tick)) * (tick); lowBound = lowBound - tick / 2; double upperBound = lowBound + tick * 4; //replicate the range axis NumberAxis referenceAxis = (NumberAxis) plotter.getPlot().getRangeAxis(); referenceAxis.setTickUnit(new NumberTickUnit(tick)); referenceAxis.setLowerBound(lowBound); referenceAxis.setUpperBound(upperBound); NumberAxis numberAxis = new NumberAxis(); numberAxis.setLabelPaint(pressureColor); numberAxis.setTickLabelPaint(referenceAxis.getTickLabelPaint()); //numberAxis.setLowerMargin(ChartPlotter.LOWER_PLOT_MARGIN); numberAxis.setRange(referenceAxis.getLowerBound(), referenceAxis.getUpperBound()); numberAxis.setTickUnit(referenceAxis.getTickUnit()); //numberAxis.setRangeWithMargins(950, 1050); plotter.getPlot().setRangeAxis(1, numberAxis); //first set domain date format and then add hour based domain grid lines //TODO: wrap this inside the addHourBasedDomainGridLines for simplicity Date minDate = shortTermTime.get(0); Date maxDate = shortTermTime.get(shortTermTime.size() >= 48 ? 48 : shortTermTime.size() - 1); plotter.setDomainRange(minDate, maxDate); plotter.setDomainDateFormat(timezone, "HH"); plotter.getPlot().setOutlineVisible(true); //set domain range after (must) plot all the data plotter.addHourBasedDomainGridLines(); //invisible domain axis plotter.getPlot().getDomainAxis().setTickLabelsVisible(false); // add markers plotter.addDomainMarkers(shortTermTime, timezone, locale); } return plotter.getPlot(); }