Java Code Examples for org.jfree.chart.plot.XYPlot#getRangeAxisCount()
The following examples show how to use
org.jfree.chart.plot.XYPlot#getRangeAxisCount() .
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: AddParallelLineDialog.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
/** * Updates the preselected y-value. */ private void updateYFieldValue() { // update preselected y value because range axis has been changed if (mousePosition != null) { Rectangle2D plotArea = engine.getChartPanel().getScreenDataArea(); if (engine.getChartPanel().getChart().getPlot() instanceof XYPlot) { XYPlot plot = (XYPlot) engine.getChartPanel().getChart().getPlot(); // calculate y value for (int i = 0; i < plot.getRangeAxisCount(); i++) { ValueAxis config = plot.getRangeAxis(i); if (config != null && config.getLabel() != null) { if (config.getLabel().equals(String.valueOf(rangeAxisSelectionCombobox.getSelectedItem()))) { double chartY = config.java2DToValue(mousePosition.getY(), plotArea, plot.getRangeAxisEdge()); yField.setText(String.valueOf(chartY)); } } } } } }
Example 2
Source File: TimeSeriesGraphTopComponent.java From snap-desktop with GNU General Public License v3.0 | 6 votes |
@Override public void pixelPosChanged(ImageLayer imageLayer, int pixelX, int pixelY, int currentLevel, boolean pixelPosValid, MouseEvent e) { if (!graphModel.isShowCursorTimeSeries()) { return; } if (pixelPosValid && isVisible() && currentView != null) { final TimeSeriesGraphUpdater.Position position = new TimeSeriesGraphUpdater.Position(pixelX, pixelY, currentLevel); graphModel.updateTimeSeries(position, TimeSeriesType.CURSOR); } final boolean autorange = e.isShiftDown(); final XYPlot xyPlot = chart.getXYPlot(); for (int i = 0; i < xyPlot.getRangeAxisCount(); i++) { xyPlot.getRangeAxis(i).setAutoRange(autorange); } if (currentView != null) { graphModel.updateAnnotation(currentView.getRaster()); } }
Example 3
Source File: ChartGesture.java From mzmine3 with GNU General Public License v2.0 | 5 votes |
/** * The gesture entity type * * @param entity * @return */ public static Entity getGestureEntity(ChartEntity entity) { if (entity == null) return NONE; if (entity instanceof PlotEntity) return PLOT; if (entity instanceof AxisEntity) { AxisEntity e = (AxisEntity) entity; if (e.getAxis().getPlot() instanceof XYPlot) { XYPlot plot = ((XYPlot) e.getAxis().getPlot()); for (int i = 0; i < plot.getDomainAxisCount(); i++) if (plot.getDomainAxis(i).equals(e.getAxis())) return DOMAIN_AXIS; for (int i = 0; i < plot.getRangeAxisCount(); i++) if (plot.getRangeAxis(i).equals(e.getAxis())) return RANGE_AXIS; } // else return basic axis return AXIS; } if (entity instanceof LegendItemEntity) return LEGEND_ITEM; if (entity instanceof XYItemEntity) return XY_ITEM; if (entity instanceof XYAnnotationEntity) return XY_ANNOTATION; if (entity instanceof TitleEntity) { if (((TitleEntity) entity).getTitle() instanceof TextTitle) return TEXT_TITLE; else return NON_TEXT_TITLE; } if (entity instanceof JFreeChartEntity) return JFREECHART; if (entity instanceof CategoryItemEntity) return CATEGORY_ITEM; return GENERAL; }
Example 4
Source File: AbstractChartPanel.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
@Override public Collection<String> resolveYAxis(int axisIndex) { Plot p = chart.getPlot(); Collection<String> names = new LinkedList<>(); if (p instanceof XYPlot) { XYPlot plot = (XYPlot) p; for (int i = 0; i < plot.getRangeAxisCount(); i++) { ValueAxis domain = plot.getRangeAxis(i); names.add(domain.getLabel()); } } return names; }
Example 5
Source File: AbstractChartPanel.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
/** * Decreases the length of the range axis, centered about the given coordinate on the screen. * The length of the range axis is reduced by the value of {@link #getZoomInFactor()}. * * @param x * the x-coordinate (in screen coordinates). * @param y * the y coordinate (in screen coordinates). */ public void shrinkSelectionOnRange(double x, double y, MouseEvent selectionEvent) { Plot p = this.chart.getPlot(); if (p instanceof XYPlot) { XYPlot plot = (XYPlot) p; Selection selectionObject = new Selection(); for (int i = 0; i < plot.getRangeAxisCount(); i++) { ValueAxis domain = plot.getRangeAxis(i); double zoomFactor = getZoomInFactor(); shrinkSelectionYAxis(x, y, selectionObject, domain, i, zoomFactor); } informSelectionListener(selectionObject, selectionEvent); } }
Example 6
Source File: AbstractChartPanel.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
/** * Increases the length the range axis, centered about the given coordinate on the screen. The * length of the range axis is increased by the value of {@link #getZoomOutFactor()}. * * @param x * the x coordinate (in screen coordinates). * @param y * the y-coordinate (in screen coordinates). */ public void enlargeSelectionOnRange(double x, double y, MouseEvent selectionEvent) { Plot p = this.chart.getPlot(); if (p instanceof XYPlot) { XYPlot plot = (XYPlot) p; Selection selectionObject = new Selection(); for (int i = 0; i < plot.getRangeAxisCount(); i++) { ValueAxis domain = plot.getRangeAxis(i); double zoomFactor = getZoomOutFactor(); shrinkSelectionYAxis(x, y, selectionObject, domain, i, zoomFactor); } informSelectionListener(selectionObject, selectionEvent); } }
Example 7
Source File: AbstractChartPanel.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
/** * Restores the auto-range calculation on the range axis. */ public void selectCompleteRangeBounds() { Plot plot = this.chart.getPlot(); if (plot instanceof Zoomable) { Zoomable z = (Zoomable) plot; // here we tweak the notify flag on the plot so that only // one notification happens even though we update multiple // axes... boolean savedNotify = plot.isNotify(); plot.setNotify(false); // we need to guard against this.zoomPoint being null Point2D zp = this.zoomPoint != null ? this.zoomPoint : new Point(); z.zoomRangeAxes(0.0, this.info.getPlotInfo(), zp); plot.setNotify(savedNotify); if (plot instanceof XYPlot) { XYPlot xyPlot = (XYPlot) plot; Selection selectionObject = new Selection(); for (int i = 0; i < xyPlot.getRangeAxisCount(); i++) { ValueAxis range = xyPlot.getRangeAxis(i); Range axisRange = new Range(range.getLowerBound(), range.getUpperBound()); for (String axisName : axisNameResolver.resolveYAxis(i)) { selectionObject.addDelimiter(axisName, axisRange); } } informSelectionListener(selectionObject, null); } } }
Example 8
Source File: ChartGesture.java From old-mzmine3 with GNU General Public License v2.0 | 5 votes |
/** * The gesture entity type * * @param entity * @return */ public static Entity getGestureEntity(ChartEntity entity) { if (entity == null) return NONE; if (entity instanceof PlotEntity) return PLOT; if (entity instanceof AxisEntity) { AxisEntity e = (AxisEntity) entity; if (e.getAxis().getPlot() instanceof XYPlot) { XYPlot plot = ((XYPlot) e.getAxis().getPlot()); for (int i = 0; i < plot.getDomainAxisCount(); i++) if (plot.getDomainAxis(i).equals(e.getAxis())) return DOMAIN_AXIS; for (int i = 0; i < plot.getRangeAxisCount(); i++) if (plot.getRangeAxis(i).equals(e.getAxis())) return RANGE_AXIS; } // else return basic axis return AXIS; } if (entity instanceof LegendItemEntity) return LEGEND_ITEM; if (entity instanceof XYItemEntity) return XY_ITEM; if (entity instanceof XYAnnotationEntity) return XY_ANNOTATION; if (entity instanceof TitleEntity) { if (((TitleEntity) entity).getTitle() instanceof TextTitle) return TEXT_TITLE; else return NON_TEXT_TITLE; } if (entity instanceof JFreeChartEntity) return JFREECHART; if (entity instanceof CategoryItemEntity) return CATEGORY_ITEM; return GENERAL; }
Example 9
Source File: ChartGesture.java From mzmine2 with GNU General Public License v2.0 | 5 votes |
/** * The gesture entity type * * @param entity * @return */ public static Entity getGestureEntity(ChartEntity entity) { if (entity == null) return NONE; if (entity instanceof PlotEntity) return PLOT; if (entity instanceof AxisEntity) { AxisEntity e = (AxisEntity) entity; if (e.getAxis().getPlot() instanceof XYPlot) { XYPlot plot = ((XYPlot) e.getAxis().getPlot()); for (int i = 0; i < plot.getDomainAxisCount(); i++) if (plot.getDomainAxis(i).equals(e.getAxis())) return DOMAIN_AXIS; for (int i = 0; i < plot.getRangeAxisCount(); i++) if (plot.getRangeAxis(i).equals(e.getAxis())) return RANGE_AXIS; } // else return basic axis return AXIS; } if (entity instanceof LegendItemEntity) return LEGEND_ITEM; if (entity instanceof XYItemEntity) return XY_ITEM; if (entity instanceof XYAnnotationEntity) return XY_ANNOTATION; if (entity instanceof TitleEntity) { if (((TitleEntity) entity).getTitle() instanceof TextTitle) return TEXT_TITLE; else return NON_TEXT_TITLE; } if (entity instanceof JFreeChartEntity) return JFREECHART; if (entity instanceof CategoryItemEntity) return CATEGORY_ITEM; return GENERAL; }
Example 10
Source File: ChartFormatter.java From nmonvisualizer with Apache License 2.0 | 4 votes |
void formatChart(JFreeChart chart) { chart.getTitle().setFont(TITLE_FONT); ((TextTitle) chart.getSubtitle(0)).setFont(SUBTITLE_FONT); ((TextTitle) chart.getSubtitle(0)).setPadding(new RectangleInsets(0, 0, 0, 0)); chart.getTitle().setPaint(textColor); ((TextTitle) chart.getSubtitle(0)).setPaint(textColor); Plot plot = chart.getPlot(); // chart has no outline but a little padding plot.setOutlineStroke(null); chart.setPadding(new RectangleInsets(5, 5, 5, 5)); chart.getPlot().setDrawingSupplier(new DefaultDrawingSupplier(seriesColors, DefaultDrawingSupplier.DEFAULT_FILL_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE)); chart.setBackgroundPaint(background); chart.getPlot().setBackgroundPaint(plotBackground); if (plot instanceof XYPlot) { XYPlot xyPlot = (XYPlot) plot; for (int i = 0; i < xyPlot.getRangeAxisCount(); i++) { formatAxis(xyPlot.getRangeAxis(i)); } formatAxis(xyPlot.getDomainAxis()); xyPlot.setRangeGridlinePaint(gridLineColor); xyPlot.setDomainGridlinePaint(gridLineColor); xyPlot.setRangeGridlineStroke(GRID_LINES); } else if (plot instanceof CategoryPlot) { CategoryPlot categoryPlot = (CategoryPlot) plot; for (int i = 0; i < categoryPlot.getRangeAxisCount(); i++) { formatAxis(categoryPlot.getRangeAxis(i)); } formatAxis(categoryPlot.getDomainAxis()); categoryPlot.setRangeGridlinePaint(gridLineColor); categoryPlot.setDomainGridlinePaint(gridLineColor); categoryPlot.setRangeGridlineStroke(GRID_LINES); } }