List of usage examples for org.jfree.chart.axis ValueAxis getUpperBound
public double getUpperBound()
From source file:org.openfaces.component.chart.impl.plots.XYPlotAdapter.java
private void renderItems(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info, CrosshairState crosshairState, XYDataset xyDataset, ValueAxis xValueAxis, ValueAxis yValueAxis, XYItemRenderer xyItemRenderer, XYItemRendererState state, int totalRendererPasses, int seriesIndex) { for (int currentPassIndex = 0; currentPassIndex < totalRendererPasses; currentPassIndex++) { if (xyDataset.getItemCount(seriesIndex) == 0) { return; }/*from ww w .jav a2s .c o m*/ int firstItemIndex = 0; int lastItemIndex = xyDataset.getItemCount(seriesIndex) - 1; if (state.getProcessVisibleItemsOnly()) { final double xLowerBound = xValueAxis.getLowerBound(); final double xUpperBound = xValueAxis.getUpperBound(); int[] itemBounds = RendererUtilities.findLiveItems(xyDataset, seriesIndex, xLowerBound, xUpperBound); firstItemIndex = itemBounds[0] - 1; if (firstItemIndex < 0) { firstItemIndex = 0; } final int lastBoundaryIndex = itemBounds[1] + 1; if (lastBoundaryIndex < lastItemIndex) { lastItemIndex = lastBoundaryIndex; } } state.startSeriesPass(xyDataset, seriesIndex, firstItemIndex, lastItemIndex, currentPassIndex, totalRendererPasses); for (int item = firstItemIndex; item <= lastItemIndex; item++) { xyItemRenderer.drawItem(g2, state, dataArea, info, this, xValueAxis, yValueAxis, xyDataset, seriesIndex, item, crosshairState, currentPassIndex); } state.endSeriesPass(xyDataset, seriesIndex, firstItemIndex, lastItemIndex, currentPassIndex, totalRendererPasses); } }
From source file:de.unibayreuth.bayeos.goat.panels.timeseries.JPanelChart.java
public void chartChanged(ChartChangeEvent event) { try {//from ww w .j av a 2 s .c o m if (event.getChart() == null) { return; } BoundedRangeModel scrollBarModel = this.chartScrollBar.getModel(); if (scrollBarModel == null) { return; } boolean chartIsZoomed = false; Plot plot = event.getChart().getPlot(); if (plot instanceof XYPlot) { XYPlot hvp = (XYPlot) plot; ValueAxis xAxis = hvp.getDomainAxis(); Range xAxisRange = xAxis.getRange(); // avoid recursion scrollBarModel.removeChangeListener(this); int low = (int) (xAxisRange.getLowerBound() * scrollFactor); scrollBarModel.setValue(low); int ext = (int) (xAxisRange.getUpperBound() * scrollFactor - low); scrollBarModel.setExtent(ext); // restore scrollBarModel.addChangeListener(this); // check if zoomed horizontally //Range hdr = hvp.getHorizontalDataRange(xAxis); Range hdr = hvp.getDataRange(xAxis); double len = hdr == null ? 0 : hdr.getLength(); chartIsZoomed |= xAxisRange.getLength() < len; } if (!chartIsZoomed && plot instanceof XYPlot) { // check if zoomed vertically XYPlot vvp = (XYPlot) plot; ValueAxis yAxis = vvp.getRangeAxis(); if (yAxis != null) { chartIsZoomed = yAxis.getLowerBound() > yMin || yAxis.getUpperBound() < yMax; } } // enable "zoom-out-buttons" if chart is zoomed // otherwise disable them chartPanButton.setEnabled(chartIsZoomed); chartZoomOutButton.setEnabled(chartIsZoomed); chartFitButton.setEnabled(chartIsZoomed); chartScrollBar.setEnabled(chartIsZoomed); if (!chartIsZoomed) { setPanMode(false); chartZoomButton.setSelected(true); } } catch (Exception e) { MsgBox.error(e.getMessage()); } }
From source file:com.tradedesksoftware.ets.client.charting.ChartShiftController.java
public void mouseDragged(MouseEvent mouseEvent) { if (!mouseEvent.isControlDown()) return;/* w ww . ja v a 2 s .co m*/ if (oldx > -1 && oldy > -1) { ValueAxis domAxis = getPlotAxis(chartPanel.getChart(), !axesSwaped); ValueAxis rngAxis = getPlotAxis(chartPanel.getChart(), axesSwaped); int xdif = mouseEvent.getX() - oldx; int ydif = mouseEvent.getY() - oldy; final Rectangle scaledDataArea = chartPanel.getScreenDataArea(); double xdelta = (double) xdif * domAxis.getRange().getLength() / (scaledDataArea.width); double ydelta = (double) ydif * rngAxis.getRange().getLength() / (scaledDataArea.height); domAxis.setRange(domAxis.getLowerBound() - xdelta, domAxis.getUpperBound() - xdelta); rngAxis.setRange(rngAxis.getLowerBound() + ydelta, rngAxis.getUpperBound() + ydelta); } oldx = mouseEvent.getX(); oldy = mouseEvent.getY(); }
From source file:com.tradedesksoftware.ets.client.charting.ChartShiftController.java
/** * Pan/Shifts a plot if the arrow keys are pressed. * @see java.awt.event.KeyListener#keyPressed(java.awt.event.KeyEvent) *///from ww w .ja v a 2 s .c om public void keyPressed(KeyEvent e) { if (!plotSupported) return; int keyCode = e.getKeyCode(); // we're only interested in arrows (code 37,38,39,40) if ((keyCode < 37) || (keyCode > 40)) return; // The axis we're gonna shift ValueAxis axis = null; // Delta is the amount we'll shift in axis units. double delta; boolean domainShift = false; // used for PAN_FIXED // Calculations for the domain axis if ((keyCode == KeyEvent.VK_LEFT) || (keyCode == KeyEvent.VK_RIGHT)) { axis = getPlotAxis(chartPanel.getChart(), !axesSwaped); domainShift = true; } // Calculations for the range axis else { axis = getPlotAxis(chartPanel.getChart(), axesSwaped); } // Let's calculate 'delta', the amount by which we'll shift the plot switch (shiftType) { case SHIFT_PERCENTUAL: delta = (axis.getUpperBound() - axis.getLowerBound()) / 100.0; break; case SHIFT_FIXED: delta = (domainShift ? fixedDomainShiftUnits : fixedRangeShiftUnits); break; case SHIFT_PIXEL: // also the default default: // Let's find out what's the range for 1 pixel. final Rectangle scaledDataArea = chartPanel.getScreenDataArea(); delta = axis.getRange().getLength() / (scaledDataArea.width); break; } // Shift modifier multiplies delta by 10 if (e.isShiftDown()) { delta *= 10; } switch (keyCode) { case KeyEvent.VK_LEFT: case KeyEvent.VK_DOWN: axis.setRange(axis.getLowerBound() - delta, axis.getUpperBound() - delta); break; case KeyEvent.VK_UP: case KeyEvent.VK_RIGHT: axis.setRange(axis.getLowerBound() + delta, axis.getUpperBound() + delta); break; } }
From source file:org.esa.snap.rcp.statistics.ScatterPlotPanel.java
private void computeRegressionAndAcceptableDeviationData() { acceptableDeviationDataset.removeAllSeries(); regressionDataset.removeAllSeries(); getPlot().removeAnnotation(r2Annotation); if (computedDatas != null) { final ValueAxis domainAxis = getPlot().getDomainAxis(); final double min = domainAxis.getLowerBound(); final double max = domainAxis.getUpperBound(); acceptableDeviationDataset.addSeries(computeAcceptableDeviationData(min, max)); if (scatterPlotModel.showRegressionLine) { final XYIntervalSeries series = computeRegressionData(min, max); if (series != null) { regressionDataset.addSeries(series); computeCoefficientOfDetermination(); }//from w w w .ja v a 2 s. c om } } }
From source file:apidemo.PanScrollZoomDemo.java
/** * Handles a {@link ChartChangeEvent}.//w ww . j av a 2 s .c o m * * @param event the event. */ public void chartChanged(final ChartChangeEvent event) { try { if (event.getChart() == null) { return; } final BoundedRangeModel scrollBarModel = this.scrollBar.getModel(); if (scrollBarModel == null) { return; } boolean chartIsZoomed = false; final Plot plot = event.getChart().getPlot(); if (plot instanceof XYPlot) { final XYPlot hvp = (XYPlot) plot; final ValueAxis xAxis = hvp.getDomainAxis(); final Range xAxisRange = xAxis.getRange(); // avoid recursion scrollBarModel.removeChangeListener(this); final int low = (int) (xAxisRange.getLowerBound() * this.scrollFactor); scrollBarModel.setValue(low); final int ext = (int) (xAxisRange.getUpperBound() * this.scrollFactor - low); scrollBarModel.setExtent(ext); // restore scrollBarModel.addChangeListener(this); // check if zoomed horizontally //Range hdr = hvp.getHorizontalDataRange(xAxis); final Range hdr = hvp.getDataRange(xAxis); final double len = hdr == null ? 0 : hdr.getLength(); chartIsZoomed |= xAxisRange.getLength() < len; } if (!chartIsZoomed && plot instanceof XYPlot) { // check if zoomed vertically final XYPlot vvp = (XYPlot) plot; ValueAxis yAxis = vvp.getRangeAxis(); if (yAxis != null) { chartIsZoomed = yAxis.getLowerBound() > this.primYMinMax[0] || yAxis.getUpperBound() < this.primYMinMax[1]; // right y-axis if (!chartIsZoomed && plot instanceof XYPlot) { final XYPlot xyPlot = (XYPlot) plot; yAxis = xyPlot.getRangeAxis(1); if (yAxis != null) { chartIsZoomed = yAxis.getLowerBound() > this.secondYMinMax[0] || yAxis.getUpperBound() < this.secondYMinMax[1]; } } } } // enable "zoom-out-buttons" if chart is zoomed // otherwise disable them this.panButton.setEnabled(chartIsZoomed); this.zoomOutButton.setEnabled(chartIsZoomed); this.fitButton.setEnabled(chartIsZoomed); this.scrollBar.setEnabled(chartIsZoomed); if (!chartIsZoomed) { setPanMode(false); this.zoomButton.setSelected(true); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.lfx.web.WebChartXYPlot.java
/** * Draws the gridlines for the plot, if they are visible. *//from w ww .j av a2s . c om * @param g2 the graphics device. * @param dataArea the data area. * @param ticks the ticks. * * @see #drawRangeGridlines(Graphics2D, Rectangle2D, List) */ protected void drawRangeGridlines(Graphics2D g2, Rectangle2D dataArea, List ticks) { Composite oldcomp = g2.getComposite(); Paint bandPaint = getBackgroundPaint(); if (bandPaint != null && bandPaint instanceof java.awt.Color) { // g2.setComposite(AlphaComposite.SrcO); java.awt.Color bandcolor = (java.awt.Color) (bandPaint); boolean fillBand = false; ValueAxis axis = getRangeAxis(); double previous = axis.getLowerBound(); Iterator iterator = ticks.iterator(); while (iterator.hasNext()) { ValueTick tick = (ValueTick) iterator.next(); if (!tick.getTickType().equals(TickType.MAJOR)) continue; double current = tick.getValue(); double y1 = axis.valueToJava2D(previous, dataArea, getRangeAxisEdge()); double y2 = axis.valueToJava2D(current, dataArea, getRangeAxisEdge()); Rectangle2D band = new Rectangle2D.Double(dataArea.getMinX(), y2, dataArea.getWidth(), y1 - y2); if (fillBand) g2.setPaint(bandcolor); else g2.setPaint(bandcolor.darker()); g2.fill(band); previous = current; fillBand = !fillBand; } double end = axis.getUpperBound(); double y1 = axis.valueToJava2D(previous, dataArea, getRangeAxisEdge()); double y2 = axis.valueToJava2D(end, dataArea, getRangeAxisEdge()); Rectangle2D band = new Rectangle2D.Double(dataArea.getMinX(), y2, dataArea.getWidth(), y1 - y2); if (fillBand) g2.setPaint(bandcolor); else g2.setPaint(bandcolor.darker()); g2.fill(band); } else { super.drawRangeGridlines(g2, dataArea, ticks); } g2.setComposite(oldcomp); }
From source file:com.lfx.web.WebChartXYPlot.java
/** * Draws the gridlines for the plot's primary range axis, if they are * visible./* w w w. ja v a2 s . c om*/ * * @param g2 the graphics device. * @param area the data area. * @param ticks the ticks. * * @see #drawDomainGridlines(Graphics2D, Rectangle2D, List) */ protected void drawDomainGridlines(Graphics2D g2, Rectangle2D dataArea, List ticks) { Composite oldcomp = g2.getComposite(); Paint bandPaint = getBackgroundPaint(); if (bandPaint != null && bandPaint instanceof java.awt.Color) { g2.setComposite(AlphaComposite.SrcIn); java.awt.Color bandcolor = (java.awt.Color) (bandPaint); boolean fillBand = true; ValueAxis axis = getDomainAxis(); double previous = axis.getLowerBound(); Iterator iterator = ticks.iterator(); while (iterator.hasNext()) { ValueTick tick = (ValueTick) iterator.next(); if (!tick.getTickType().equals(TickType.MAJOR)) continue; double current = tick.getValue(); double y1 = axis.valueToJava2D(previous, dataArea, getDomainAxisEdge()); double y2 = axis.valueToJava2D(current, dataArea, getDomainAxisEdge()); Rectangle2D band = new Rectangle2D.Double(y1, dataArea.getMinY(), y2 - y1, dataArea.getWidth()); if (fillBand) g2.setPaint(bandcolor); else g2.setPaint(bandcolor.darker()); g2.fill(band); previous = current; fillBand = !fillBand; } double end = axis.getUpperBound(); double y1 = axis.valueToJava2D(previous, dataArea, getDomainAxisEdge()); double y2 = axis.valueToJava2D(end, dataArea, getDomainAxisEdge()); Rectangle2D band = new Rectangle2D.Double(y1, dataArea.getMinY(), y2 - y1, dataArea.getWidth()); if (fillBand) g2.setPaint(bandcolor); else g2.setPaint(bandcolor.darker()); g2.fill(band); } else { super.drawDomainGridlines(g2, dataArea, ticks); } g2.setComposite(oldcomp); }
From source file:org.esa.beam.visat.toolviews.stat.ScatterPlotPanel.java
private void computeRegressionAndAcceptableDeviationData() { acceptableDeviationDataset.removeAllSeries(); regressionDataset.removeAllSeries(); getPlot().removeAnnotation(r2Annotation); if (computedDatas != null) { final ValueAxis domainAxis = getPlot().getDomainAxis(); final double min = domainAxis.getLowerBound(); final double max = domainAxis.getUpperBound(); acceptableDeviationDataset.addSeries(computeAcceptableDeviationData(min, max)); if (scatterPlotModel.showRegressionLine) { regressionDataset.addSeries(computeRegressionData(min, max)); computeCoefficientOfDetermination(); }//from w w w .j a v a 2s . c om } }
From source file:org.tsho.dmc2.core.chart.AbsorbingAreaRenderer.java
public void render(final Graphics2D g2, final Rectangle2D dataArea, final PlotRenderingInfo info) { state = STATE_RUNNING;// w w w.j a v a 2 s . c om gridWidth = (int) dataArea.getWidth(); gridHeight = (int) dataArea.getHeight(); //imageX,imageY correspond to point(0,0) int imageX = (int) dataArea.getX() + 1; int imageY = (int) dataArea.getY() + 1; DataBufferInt dataBuffer; image = new BufferedImage(gridWidth, gridHeight, BufferedImage.TYPE_INT_RGB); WritableRaster raster = image.getRaster(); grid = ((DataBufferInt) raster.getDataBuffer()).getData(); ValueAxis domainAxis = plot.getDomainAxis(); ValueAxis rangeAxis = plot.getRangeAxis(); xEpsilon = Math.abs((domainAxis.getUpperBound() - domainAxis.getLowerBound()) / (double) gridWidth); yEpsilon = Math.abs((rangeAxis.getUpperBound() - rangeAxis.getLowerBound()) / (double) gridHeight); int numPoints = gridHeight * gridWidth; int index = 0; int rate = numPoints / 100; if (justClearedSet) { if (criticalSetFound) { this.clearDisplay(); g2.drawImage(image, null, imageX, imageY); } justClearedSet = false; return; } if (!notYetRendered) { plotCopiedDisplay(); g2.drawImage(image, null, imageX, imageY); } notYetRendered = false; if (criticalSetFound && !findCriticalSetAgain) { if (this.chooseSegmentsSet) chooseSegments(g2, image, imageX, imageY); if (this.plotAttractorSet) plotAttractor(g2, image, imageX, imageY); if (this.iterateChosenSegmentsSet) iterateChosenSegments(g2, image, imageX, imageY); if (this.hideAttractorSet) hideAttractor(g2, image, imageX, imageY); } else { this.disableAllActionsExceptStop(); det = new AbsorbingAreaRenderer.ImplicitDeterminant(gridWidth, gridHeight, epsilon, g2, image, imageX, imageY); gridBackup = new int[grid.length]; copyDisplay(); criticalSetFound = true; findCriticalSetAgain = false; g2.drawImage(image, null, imageX, imageY); this.enableAllActionsExceptStop(); } }