📄 xyplot.java
字号:
* * @param location the location (<code>null</code> not permitted). */ public void setRangeAxisLocation(AxisLocation location) { // defer argument checking... setRangeAxisLocation(location, true); } /** * Sets the location of the primary range axis and, if requested, sends a * {@link PlotChangeEvent} to all registered listeners. * * @param location the location (<code>null</code> not permitted). * @param notify notify listeners? */ public void setRangeAxisLocation(AxisLocation location, boolean notify) { if (location == null) { throw new IllegalArgumentException("Null 'location' argument."); } this.rangeAxisLocations.set(0, location); if (notify) { notifyListeners(new PlotChangeEvent(this)); } } /** * Returns the edge for the primary range axis. * * @return The range axis edge. */ public RectangleEdge getRangeAxisEdge() { return Plot.resolveRangeAxisLocation(getRangeAxisLocation(), this.orientation); } /** * Returns a range axis. * * @param index the axis index. * * @return The axis (<code>null</code> possible). */ public ValueAxis getRangeAxis(int index) { ValueAxis result = null; if (index < this.rangeAxes.size()) { result = (ValueAxis) this.rangeAxes.get(index); } if (result == null) { Plot parent = getParent(); if (parent instanceof XYPlot) { XYPlot xy = (XYPlot) parent; result = xy.getRangeAxis(index); } } return result; } /** * Sets a range axis and sends a {@link PlotChangeEvent} to all registered listeners. * * @param index the axis index. * @param axis the axis (<code>null</code> permitted). */ public void setRangeAxis(int index, ValueAxis axis) { ValueAxis existing = getRangeAxis(index); if (existing != null) { existing.removeChangeListener(this); } if (axis != null) { axis.setPlot(this); } this.rangeAxes.set(index, axis); if (axis != null) { axis.configure(); axis.addChangeListener(this); } notifyListeners(new PlotChangeEvent(this)); } /** * Returns the number of range axes. * * @return The axis count. */ public int getRangeAxisCount() { return this.rangeAxes.size(); } /** * Clears the range axes from the plot and sends a {@link PlotChangeEvent} to all * registered listeners. */ public void clearRangeAxes() { for (int i = 0; i < this.rangeAxes.size(); i++) { ValueAxis axis = (ValueAxis) this.rangeAxes.get(i); if (axis != null) { axis.removeChangeListener(this); } } this.rangeAxes.clear(); notifyListeners(new PlotChangeEvent(this)); } /** * Configures the range axes. */ public void configureRangeAxes() { for (int i = 0; i < this.rangeAxes.size(); i++) { ValueAxis axis = (ValueAxis) this.rangeAxes.get(i); if (axis != null) { axis.configure(); } } } /** * Returns the location for a range axis. If this hasn't been set explicitly, * the method returns the location that is opposite to the primary range axis location. * * @param index the axis index. * * @return The location (never <code>null</code>). */ public AxisLocation getRangeAxisLocation(int index) { AxisLocation result = null; if (index < this.rangeAxisLocations.size()) { result = (AxisLocation) this.rangeAxisLocations.get(index); } if (result == null) { result = AxisLocation.getOpposite(getRangeAxisLocation()); } return result; } /** * Sets the location for a range axis and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param index the axis index. * @param location the location (<code>null</code> permitted). */ public void setRangeAxisLocation(int index, AxisLocation location) { this.rangeAxisLocations.set(index, location); notifyListeners(new PlotChangeEvent(this)); } /** * Returns the edge for a range axis. * * @param index the axis index. * * @return The edge. */ public RectangleEdge getRangeAxisEdge(int index) { AxisLocation location = getRangeAxisLocation(index); RectangleEdge result = Plot.resolveRangeAxisLocation(location, this.orientation); if (result == null) { result = RectangleEdge.opposite(getRangeAxisEdge()); } return result; } /** * Returns the primary dataset for the plot. * * @return The primary dataset (possibly <code>null</code>). */ public XYDataset getDataset() { return getDataset(0); } /** * Returns a dataset. * * @param index the dataset index. * * @return The dataset (possibly <code>null</code>). */ public XYDataset getDataset(int index) { XYDataset result = null; if (this.datasets.size() > index) { result = (XYDataset) this.datasets.get(index); } return result; } /** * Sets the primary dataset for the plot, replacing the existing dataset if there is one. * * @param dataset the dataset (<code>null</code> permitted). */ public void setDataset(XYDataset dataset) { setDataset(0, dataset); } /** * Sets a dataset for the plot. * * @param index the dataset index. * @param dataset the dataset (<code>null</code> permitted). */ public void setDataset(int index, XYDataset dataset) { XYDataset existing = getDataset(index); if (existing != null) { existing.removeChangeListener(this); } this.datasets.set(index, dataset); if (dataset != null) { dataset.addChangeListener(this); } // map dataset to main axis by default if (index >= this.domainAxisMap.size()) { this.domainAxisMap.set(index, new Integer(0)); } if (index >= this.rangeAxisMap.size()) { this.rangeAxisMap.set(index, new Integer(0)); } // send a dataset change event to self... DatasetChangeEvent event = new DatasetChangeEvent(this, dataset); datasetChanged(event); } /** * Returns the number of datasets. * * @return The number of datasets. */ public int getDatasetCount() { return this.datasets.size(); } /** * Returns the index of the specified dataset, or <code>-1</code> if the dataset * does not belong to the plot. * * @param dataset the dataset (<code>null</code> not permitted). * * @return The index. */ public int indexOf(XYDataset dataset) { int result = -1; for (int i = 0; i < this.datasets.size(); i++) { if (dataset == this.datasets.get(i)) { result = i; break; } } return result; } /** * Maps a dataset to a particular domain axis. * * @param index the dataset index (zero-based). * @param axisIndex the axis index. */ public void mapDatasetToDomainAxis(int index, int axisIndex) { this.domainAxisMap.set(index, new Integer(axisIndex)); // fake a dataset change event to update axes... datasetChanged(new DatasetChangeEvent(this, getDataset(index))); } /** * Maps a dataset to a particular range axis. * * @param index the dataset index (zero-based). * @param axisIndex the axis index. */ public void mapDatasetToRangeAxis(int index, int axisIndex) { this.rangeAxisMap.set(index, new Integer(axisIndex)); // fake a dataset change event to update axes... datasetChanged(new DatasetChangeEvent(this, getDataset(index))); } /** * Returns the renderer for the primary dataset. * * @return The item renderer (possibly <code>null</code>). */ public XYItemRenderer getRenderer() { return getRenderer(0); } /** * Returns the renderer for a dataset, or <code>null</code>. * * @param index the renderer index. * * @return The renderer (possibly <code>null</code>). */ public XYItemRenderer getRenderer(int index) { XYItemRenderer result = null; if (this.renderers.size() > index) { result = (XYItemRenderer) this.renderers.get(index); } return result; } /** * Sets the renderer for the primary dataset and sends a {@link PlotChangeEvent} to all * registered listeners. If the renderer is set to <code>null</code>, no data will be * displayed. * * @param renderer the renderer (<code>null</code> permitted). */ public void setRenderer(XYItemRenderer renderer) { setRenderer(0, renderer); } /** * Sets a renderer and sends a {@link PlotChangeEvent} is sent to all registered listeners. * * @param index the index. * @param renderer the renderer. */ public void setRenderer(int index, XYItemRenderer renderer) { XYItemRenderer existing = getRenderer(index); if (existing != null) { existing.removeChangeListener(this); } this.renderers.set(index, renderer); if (renderer != null) { renderer.setPlot(this); } notifyListeners(new PlotChangeEvent(this)); } /** * Returns the dataset rendering order. * * @return the order (never <code>null</code>). */ public DatasetRenderingOrder getDatasetRenderingOrder() { return this.renderingOrder; } /** * Sets the rendering order and sends a {@link PlotChangeEvent} to all registered listeners. * By default, the plot renders the primary dataset last (so that * the primary dataset overlays the secondary datasets). You can reverse this if you want to. * * @param order the rendering order (<code>null</code> not permitted). */ public void setDatasetRenderingOrder(DatasetRenderingOrder order) { if (order == null) { throw new IllegalArgumentException("Null 'order' argument."); } this.renderingOrder = order; notifyListeners(new PlotChangeEvent(this)); } /** * Returns the renderer for the specified dataset. * * @param dataset the dataset (<code>null</code> permitted). * * @return The renderer (possibly <code>null</code>). */ public XYItemRenderer getRendererForDataset(XYDataset dataset) { XYItemRenderer result = null; for (int i = 0; i < this.datasets.size(); i++) { if (this.datasets.get(i) == dataset) { result = (XYItemRenderer) this.renderers.get(i); break; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -