List of usage examples for org.jfree.chart.axis NumberAxis setFixedAutoRange
public void setFixedAutoRange(double length)
From source file:net.sf.maltcms.chromaui.chromatogram1Dviewer.ui.Chromatogram1DHeatmapViewTopComponent.java
private XYPlot createPlot(ADataset2D<IChromatogram1D, IScan> ds) { XYBlockRenderer xybr = new XYBlockRenderer(); IPaintScaleProvider ips = Lookup.getDefault().lookup(IPaintScaleProvider.class); ips.setMin(ds.getMinZ());//w ww. j a va 2s . co m ips.setMax(ds.getMaxZ()); PaintScale ps = ips.getPaintScales().get(0); xybr.setPaintScale(ps); xybr.setDefaultEntityRadius(5); xybr.setBlockWidth(0.1); xybr.setBlockAnchor(RectangleAnchor.CENTER); xybr.setBlockHeight(1.0); RTUnit rtUnit = RTUnit.SECONDS; xybr.setToolTipGenerator( new StandardXYZToolTipGenerator("{0}: @({1}, {2}) = {3}", DecimalFormat.getNumberInstance(), DecimalFormat.getNumberInstance(), DecimalFormat.getNumberInstance())); NumberAxis rt1 = new NumberAxis("Retention Time [" + rtUnit.name().toLowerCase() + "]"); NumberAxis rt2 = new NumberAxis("M/Z"); rt1.setAutoRange(false); rt1.setLowerBound(ds.getMinX()); rt1.setUpperBound(ds.getMaxX()); rt1.setRangeWithMargins(ds.getMinX(), ds.getMaxX()); rt2.setFixedAutoRange(ds.getMaxX() - ds.getMinX()); rt2.setAutoRange(false); rt2.setLowerBound(ds.getMinY()); rt2.setUpperBound(ds.getMaxY()); rt2.setFixedAutoRange(ds.getMaxY() - ds.getMinY()); rt2.setRangeWithMargins(ds.getMinY(), ds.getMaxY()); XYPlot heatmapPlot = new XYPlot(ds, rt1, rt2, xybr); heatmapPlot.setDomainPannable(true); heatmapPlot.setRangePannable(true); return heatmapPlot; }
From source file:net.sf.maltcms.chromaui.chromatogram2Dviewer.ui.Chromatogram2DViewTopComponent.java
private XYPlot createPlot(IChromatogramDescriptor chromatogram, ADataset2D<IChromatogram2D, IScan2D> ds, PaintScale ps) {/*from w w w . j a v a 2s . c o m*/ XYNoBlockRenderer xybr = new XYNoBlockRenderer(); xybr.setPaintScale(ps); try { double modulationTime = chromatogram.getChromatogram().getParent().getChild("modulation_time") .getArray().getDouble(0); double scanRate = chromatogram.getChromatogram().getParent().getChild("scan_rate").getArray() .getDouble(0); xybr.setDefaultEntityRadius(10);//Math.max(1, (int)(modulationTime / scanRate))); xybr.setEntityThreshold(ds.getMinZ()); xybr.setBlockWidth(modulationTime); xybr.setBlockAnchor(RectangleAnchor.CENTER); double spm = modulationTime * scanRate; double scanDuration = modulationTime / spm; xybr.setBlockHeight(scanDuration); } catch (ResourceNotAvailableException rnae) { } RTUnit rtUnit = RTUnit.SECONDS; xybr.setToolTipGenerator( new StandardXYZToolTipGenerator("{0}: @({1}, {2}) = {3}", DecimalFormat.getNumberInstance(), DecimalFormat.getNumberInstance(), DecimalFormat.getNumberInstance())); NumberAxis rt1 = new NumberAxis("RT1 [" + rtUnit.name().toLowerCase() + "]"); NumberAxis rt2 = new NumberAxis("RT2 [" + rtUnit.name().toLowerCase() + "]"); rt1.setAutoRange(false); rt1.setLowerBound(ds.getMinX()); rt1.setUpperBound(ds.getMaxX()); rt1.setRangeWithMargins(ds.getMinX(), ds.getMaxX()); rt2.setFixedAutoRange(ds.getMaxX() - ds.getMinX()); rt2.setAutoRange(false); rt2.setLowerBound(ds.getMinY()); rt2.setUpperBound(ds.getMaxY()); rt2.setFixedAutoRange(ds.getMaxY() - ds.getMinY()); rt2.setRangeWithMargins(ds.getMinY(), ds.getMaxY()); XYPlot heatmapPlot = new XYPlot(ds, rt1, rt2, xybr); heatmapPlot.setDomainPannable(true); heatmapPlot.setRangePannable(true); return heatmapPlot; }
From source file:msi.gama.outputs.layers.charts.ChartJFreeChartOutputHistogram.java
@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;/*from w w w . ja v a2s . c o m*/ } 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); } }
From source file:msi.gama.outputs.layers.charts.ChartJFreeChartOutputHeatmap.java
@Override public void resetAxes(final IScope scope) { NumberAxis domainAxis = (NumberAxis) ((XYPlot) this.chart.getPlot()).getDomainAxis(); NumberAxis rangeAxis = (NumberAxis) ((XYPlot) this.chart.getPlot()).getRangeAxis(); if (getX_LogScale(scope)) { LogarithmicAxis logAxis = new LogarithmicAxis(domainAxis.getLabel()); logAxis.setAllowNegativesFlag(true); ((XYPlot) this.chart.getPlot()).setDomainAxis(logAxis); domainAxis = logAxis;//from w ww . java2 s . c om } if (getY_LogScale(scope)) { LogarithmicAxis logAxis = new LogarithmicAxis(rangeAxis.getLabel()); logAxis.setAllowNegativesFlag(true); ((XYPlot) this.chart.getPlot()).setRangeAxis(logAxis); rangeAxis = logAxis; } if (!usexrangeinterval && !usexrangeminmax) { // domainAxis.setAutoRangeMinimumSize(0.5); // domainAxis.setAutoRange(true); } if (this.usexrangeinterval) { domainAxis.setFixedAutoRange(xrangeinterval); domainAxis.setAutoRangeMinimumSize(xrangeinterval); domainAxis.setAutoRange(true); } if (this.usexrangeminmax) { domainAxis.setRange(xrangemin, xrangemax); } if (!useyrangeinterval && !useyrangeminmax) { // rangeAxis.setAutoRangeMinimumSize(0.5); // rangeAxis.setAutoRange(true); } if (this.useyrangeinterval) { rangeAxis.setFixedAutoRange(yrangeinterval); rangeAxis.setAutoRangeMinimumSize(yrangeinterval); rangeAxis.setAutoRange(true); } if (this.useyrangeminmax) { rangeAxis.setRange(yrangemin, yrangemax); } if (this.series_label_position.equals("none")) { if ((this.chart).getLegend() != null) (this.chart).getLegend().setVisible(false); } if (!this.getXTickLineVisible(scope)) { ((XYPlot) this.chart.getPlot()).setDomainGridlinesVisible(false); } if (!this.getYTickLineVisible(scope)) { ((XYPlot) this.chart.getPlot()).setRangeGridlinesVisible(false); } }
From source file:msi.gama.outputs.layers.ChartLayerStatement.java
private void createBars(final IScope scope) { final CategoryPlot plot = (CategoryPlot) chart.getPlot(); BarRenderer renderer = new CustomRenderer(); plot.setRenderer(renderer);/*from www . j av a 2 s . com*/ dataset = new DefaultCategoryDataset(); int i = 0; for (final ChartData e : datas) { // String legend = e.getName(); // ((DefaultCategoryDataset) dataset).setValue(0d, new Integer(0), legend/* , legend */); final String legend = e.getName(); if (!CategoryItemRenderer.class.isInstance(e.getRenderer())) { e.renderer = new CustomRenderer(); } plot.setRenderer(i, (CategoryItemRenderer) e.getRenderer(), false); final Color c = e.getColor(); plot.getRenderer(i).setSeriesPaint(0, c); // plot.setDataset(i, (DefaultCategoryDataset) dataset); i++; history.append(legend); history.append(','); } if (history.length() > 0) { history.deleteCharAt(history.length() - 1); } history.append(Strings.LN); plot.setDataset((DefaultCategoryDataset) dataset); chart.removeLegend(); final NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setTickLabelFont(getTickFont()); yAxis.setLabelFont(getLabelFont()); IExpression expr = getFacet(YRANGE); IExpression expr2 = getFacet(YTICKUNIT); if (expr != null) { Object range = expr.value(scope); // Double range = Cast.asFloat(scope, expr.value(scope)); if (range instanceof Number) { double r = ((Number) range).doubleValue(); if (r > 0) { yAxis.setFixedAutoRange(r); yAxis.setAutoRangeMinimumSize(r); } // yAxis.setAutoRangeIncludesZero(false); } else if (range instanceof GamaPoint) { yAxis.setRange(((GamaPoint) range).getX(), ((GamaPoint) range).getY()); } } if (expr2 != null) { Object range = expr2.value(scope); // Double range = Cast.asFloat(scope, expr.value(scope)); if (range instanceof Number) { double r = ((Number) range).doubleValue(); if (r > 0) { yAxis.setTickUnit(new NumberTickUnit(r)); } } } final CategoryAxis axis = plot.getDomainAxis(); Double gap = Cast.asFloat(scope, getFacetValue(scope, IKeyword.GAP, 0.01)); // ((BarRenderer) plot.getRenderer()).setItemMargin(gap); renderer.setMaximumBarWidth(1 - gap); axis.setCategoryMargin(gap); axis.setUpperMargin(gap); axis.setLowerMargin(gap); }
From source file:msi.gama.outputs.layers.ChartLayerStatement.java
void createSeries(final IScope scope, final boolean isTimeSeries) throws GamaRuntimeException { final XYPlot plot = (XYPlot) chart.getPlot(); final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setTickLabelFont(getTickFont()); domainAxis.setLabelFont(getLabelFont()); if (isTimeSeries) { domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); if (timeSeriesXData == null) { timeSeriesXData = (ChartDataStatement) DescriptionFactory.create(IKeyword.DATA, description, IKeyword.LEGEND, xAxisName, IKeyword.VALUE, SimulationAgent.CYCLE).compile(); if (getFacet(IKeyword.TIMEXSERIES) != null) { timeSeriesXData.getDescription().getFacets().get(IKeyword.VALUE) .setExpression(getFacet(IKeyword.TIMEXSERIES)); }//from ww w.ja va2 s . c o m } // FIXME: datas can NOT contain timeSeriesXData (a ChartDataStatement and not a ChartData) if (!datas.contains(timeSeriesXData)) { datas.add(0, timeSeriesXData.createData(scope)); } } IExpression expr = getFacet(XRANGE); IExpression expr2 = getFacet(XTICKUNIT); if (expr != null) { Object range = expr.value(scope); // Double range = Cast.asFloat(scope, expr.value(scope)); if (range instanceof Number) { double r = ((Number) range).doubleValue(); if (r > 0) { domainAxis.setFixedAutoRange(r); domainAxis.setAutoRangeMinimumSize(r); } domainAxis.setAutoRangeIncludesZero(false); } else if (range instanceof GamaPoint) { domainAxis.setRange(((GamaPoint) range).getX(), ((GamaPoint) range).getY()); } } if (expr2 != null) { Object range = expr2.value(scope); // Double range = Cast.asFloat(scope, expr.value(scope)); if (range instanceof Number) { double r = ((Number) range).doubleValue(); if (r > 0) { domainAxis.setTickUnit(new NumberTickUnit(r)); } } } if (datas.size() > 0) { domainAxis.setLabel(datas.get(0).getName()); } final NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setTickLabelFont(getTickFont()); yAxis.setLabelFont(getLabelFont()); expr = getFacet(YRANGE); expr2 = getFacet(YTICKUNIT); if (expr != null) { Object range = expr.value(scope); // Double range = Cast.asFloat(scope, expr.value(scope)); if (range instanceof Number) { double r = ((Number) range).doubleValue(); if (r > 0) { yAxis.setFixedAutoRange(r); yAxis.setAutoRangeMinimumSize(r); } yAxis.setAutoRangeIncludesZero(false); } else if (range instanceof GamaPoint) { yAxis.setRange(((GamaPoint) range).getX(), ((GamaPoint) range).getY()); } } if (expr2 != null) { Object range = expr2.value(scope); // Double range = Cast.asFloat(scope, expr.value(scope)); if (range instanceof Number) { double r = ((Number) range).doubleValue(); if (r > 0) { yAxis.setTickUnit(new NumberTickUnit(r)); } } } if (datas.size() == 2) { yAxis.setLabel(datas.get(1).getName()); chart.removeLegend(); } final LegendTitle ll = chart.getLegend(); if (ll != null) { ll.setItemFont(getLegendFont()); } for (int i = 0; i < datas.size(); i++) { ChartData e = datas.get(i); final String legend = e.getName(); if (i != 0 | !isTimeSeries) { // the first data is the domain XYDataset data = plot.getDataset(i); XYSeries serie = new XYSeries(0, false, false); if (type == SERIES_CHART || type == XY_CHART) { dataset = new DefaultTableXYDataset(); // final XYSeries nserie = new XYSeries(serie.getKey(), false, false); final XYSeries nserie = new XYSeries(e.getName(), false, false); ((DefaultTableXYDataset) dataset).addSeries(nserie); } if (type == SCATTER_CHART) { dataset = new XYSeriesCollection(); final XYSeries nserie = new XYSeries(e.getName(), false, true); // final XYSeries nserie = new XYSeries(serie.getKey(), false, true); ((XYSeriesCollection) dataset).addSeries(nserie); } // dataset = new DefaultTableXYDataset(); // final XYSeries serie = new XYSeries(legend, false, false); // final XYSeries serie = new XYSeries(legend, false, true); // ((DefaultTableXYDataset) dataset).addSeries(serie); expressions_index.put(legend, i); plot.setRenderer(i, (XYItemRenderer) e.getRenderer(), false); // final Color c = e.getColor(); // ((XYLineAndShapeRenderer) plot.getRenderer(i)).setSeriesPaint(0, c); // TODO Control this with a facet // ((XYLineAndShapeRenderer) plot.getRenderer(i)).setBaseShapesFilled(false); // TODO Control this with a facet // ((XYLineAndShapeRenderer) plot.getRenderer(i)).setSeriesShapesVisible(0, false); // if (type==SERIES_CHART) // plot.setDataset(i-1, (DefaultTableXYDataset) dataset); // else plot.setDataset(i, (XYDataset) dataset); } history.append(legend); history.append(','); } if (history.length() > 0) { history.deleteCharAt(history.length() - 1); } history.append(Strings.LN); }
From source file:msi.gama.outputs.layers.charts.ChartJFreeChartOutputScatter.java
@Override public void resetAxes(final IScope scope) { NumberAxis domainAxis = (NumberAxis) ((XYPlot) this.chart.getPlot()).getDomainAxis(); NumberAxis rangeAxis = (NumberAxis) ((XYPlot) this.chart.getPlot()).getRangeAxis(); NumberAxis range2Axis = rangeAxis;/*from w ww. j a v a 2 s. c om*/ boolean secondaxis = false; if (getUseSecondYAxis(scope)) { secondaxis = true; range2Axis = (NumberAxis) ((XYPlot) this.chart.getPlot()).getRangeAxis(1); if (range2Axis == null) { NumberAxis secondAxis = new NumberAxis(""); ((XYPlot) this.chart.getPlot()).setRangeAxis(1, secondAxis); range2Axis = secondAxis; range2Axis = (NumberAxis) ((XYPlot) this.chart.getPlot()).getRangeAxis(1); range2Axis = formatYAxis(scope, range2Axis); ((XYPlot) this.chart.getPlot()).setRangeAxis(1, range2Axis); } } if (getX_LogScale(scope)) { LogarithmicAxis logAxis = new LogarithmicAxis(domainAxis.getLabel()); logAxis.setAllowNegativesFlag(true); ((XYPlot) this.chart.getPlot()).setDomainAxis(logAxis); domainAxis = logAxis; } if (getY_LogScale(scope)) { LogarithmicAxis logAxis = new LogarithmicAxis(rangeAxis.getLabel()); logAxis.setAllowNegativesFlag(true); logAxis = (LogarithmicAxis) formatYAxis(scope, logAxis); ((XYPlot) this.chart.getPlot()).setRangeAxis(logAxis); rangeAxis = logAxis; } if (secondaxis) { if (getY2_LogScale(scope)) { LogarithmicAxis logAxis = new LogarithmicAxis(range2Axis.getLabel()); logAxis.setAllowNegativesFlag(true); logAxis = (LogarithmicAxis) formatYAxis(scope, logAxis); ((XYPlot) this.chart.getPlot()).setRangeAxis(1, logAxis); range2Axis = logAxis; } } if (!getUseXRangeInterval(scope) && !getUseXRangeMinMax(scope)) { domainAxis.setAutoRange(true); } if (this.getUseXRangeInterval(scope)) { domainAxis.setFixedAutoRange(getXRangeInterval(scope)); domainAxis.setAutoRangeMinimumSize(getXRangeInterval(scope)); domainAxis.setAutoRange(true); } if (this.getUseXRangeMinMax(scope)) { domainAxis.setRange(getXRangeMin(scope), getXRangeMax(scope)); } if (this.getXTickLineVisible(scope)) { ((XYPlot) this.chart.getPlot()).setDomainGridlinePaint(this.tickColor); if (getXTickUnit(scope) > 0) { domainAxis.setTickUnit(new NumberTickUnit(getXTickUnit(scope))); ((XYPlot) this.chart.getPlot()).setDomainGridlinesVisible(true); } else ((XYPlot) this.chart.getPlot()) .setDomainGridlinesVisible(GamaPreferences.Displays.CHART_GRIDLINES.getValue()); } else { ((XYPlot) this.chart.getPlot()).setDomainGridlinesVisible(false); } if (!getUseYRangeInterval(scope) && !getUseYRangeMinMax(scope)) { rangeAxis.setAutoRange(true); } if (this.getUseYRangeInterval(scope)) { rangeAxis.setFixedAutoRange(getYRangeInterval(scope)); rangeAxis.setAutoRangeMinimumSize(getYRangeInterval(scope)); rangeAxis.setAutoRange(true); } if (this.getUseYRangeMinMax(scope)) { rangeAxis.setRange(getYRangeMin(scope), getYRangeMax(scope)); } if (this.getYTickLineVisible(scope)) { ((XYPlot) this.chart.getPlot()).setRangeGridlinePaint(this.tickColor); if (getYTickUnit(scope) > 0) { rangeAxis.setTickUnit(new NumberTickUnit(getYTickUnit(scope))); ((XYPlot) this.chart.getPlot()).setRangeGridlinesVisible(true); } else ((XYPlot) this.chart.getPlot()) .setRangeGridlinesVisible(GamaPreferences.Displays.CHART_GRIDLINES.getValue()); } else { ((XYPlot) this.chart.getPlot()).setRangeGridlinesVisible(false); } if (secondaxis) { if (!getUseY2RangeInterval(scope) && !getUseY2RangeMinMax(scope)) { range2Axis.setAutoRange(true); } if (this.getUseY2RangeInterval(scope)) { range2Axis.setFixedAutoRange(getY2RangeInterval(scope)); range2Axis.setAutoRangeMinimumSize(getY2RangeInterval(scope)); range2Axis.setAutoRange(true); } if (this.getUseY2RangeMinMax(scope)) { range2Axis.setRange(getY2RangeMin(scope), getY2RangeMax(scope)); } if (this.getYTickLineVisible(scope)) { ((XYPlot) this.chart.getPlot()).setRangeGridlinePaint(this.tickColor); if (getY2TickUnit(scope) > 0) { range2Axis.setTickUnit(new NumberTickUnit(getY2TickUnit(scope))); ((XYPlot) this.chart.getPlot()).setRangeGridlinesVisible(true); } else ((XYPlot) this.chart.getPlot()) .setRangeGridlinesVisible(GamaPreferences.Displays.CHART_GRIDLINES.getValue()); } else { ((XYPlot) this.chart.getPlot()).setRangeGridlinesVisible(false); } } if (getXLabel(scope) != null && !getXLabel(scope).isEmpty()) { domainAxis.setLabel(getXLabel(scope)); } if (getYLabel(scope) != null && !getYLabel(scope).isEmpty()) { rangeAxis.setLabel(getYLabel(scope)); } if (secondaxis) { if (getY2Label(scope) != null && !getY2Label(scope).isEmpty()) { range2Axis.setLabel(getY2Label(scope)); } } if (this.series_label_position.equals("none")) { (this.chart).getLegend().setVisible(false); } if (!this.getXTickValueVisible(scope)) { domainAxis.setTickMarksVisible(false); domainAxis.setTickLabelsVisible(false); } }