📄 categoryplot.java
字号:
axis.configure();
}
}
}
/**
* Returns the range axis for the plot. If the range axis for this plot is
* null, then the method will return the parent plot's range axis (if there
* is a parent plot).
*
* @return The range axis (possibly <code>null</code>).
*/
public ValueAxis getRangeAxis() {
return getRangeAxis(0);
}
/**
* 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 CategoryPlot) {
CategoryPlot cp = (CategoryPlot) parent;
result = cp.getRangeAxis(index);
}
}
return result;
}
/**
* Sets the range axis for the plot and sends a {@link PlotChangeEvent} to
* all registered listeners.
*
* @param axis the axis (<code>null</code> permitted).
*/
public void setRangeAxis(ValueAxis axis) {
setRangeAxis(0, axis);
}
/**
* Sets a range axis and sends a {@link PlotChangeEvent} to all registered
* listeners.
*
* @param index the axis index.
* @param axis the axis.
*/
public void setRangeAxis(int index, ValueAxis axis) {
setRangeAxis(index, axis, true);
}
/**
* Sets a range axis and, if requested, sends a {@link PlotChangeEvent} to
* all registered listeners.
*
* @param index the axis index.
* @param axis the axis.
* @param notify notify listeners?
*/
public void setRangeAxis(int index, ValueAxis axis, boolean notify) {
ValueAxis existing = (ValueAxis) this.rangeAxes.get(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);
}
if (notify) {
notifyListeners(new PlotChangeEvent(this));
}
}
/**
* Sets the range axes for this plot and sends a {@link PlotChangeEvent}
* to all registered listeners.
*
* @param axes the axes.
*/
public void setRangeAxes(ValueAxis[] axes) {
for (int i = 0; i < axes.length; i++) {
setRangeAxis(i, axes[i], false);
}
notifyListeners(new PlotChangeEvent(this));
}
/**
* Returns the range axis location.
*
* @return The location (never <code>null</code>).
*/
public AxisLocation getRangeAxisLocation() {
return getRangeAxisLocation(0);
}
/**
* Returns the location for a range axis.
*
* @param index the axis index.
*
* @return The location.
*/
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(0));
}
return result;
}
/**
* Sets the location of the range axis and sends a {@link PlotChangeEvent}
* to all registered listeners.
*
* @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 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) {
setRangeAxisLocation(0, location, notify);
}
/**
* 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.
*/
public void setRangeAxisLocation(int index, AxisLocation location) {
setRangeAxisLocation(index, location, true);
}
/**
* 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.
* @param notify notify listeners?
*/
public void setRangeAxisLocation(int index, AxisLocation location,
boolean notify) {
// TODO: don't allow null for index = 0
this.rangeAxisLocations.set(index, location);
if (notify) {
notifyListeners(new PlotChangeEvent(this));
}
}
/**
* Returns the edge where the primary range axis is located.
*
* @return The edge (never <code>null</code>).
*/
public RectangleEdge getRangeAxisEdge() {
return getRangeAxisEdge(0);
}
/**
* 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(0));
}
return result;
}
/**
* 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 primary dataset for the plot.
*
* @return The primary dataset (possibly <code>null</code>).
*/
public CategoryDataset getDataset() {
return getDataset(0);
}
/**
* Returns the dataset at the given index.
*
* @param index the dataset index.
*
* @return The dataset (possibly <code>null</code>).
*/
public CategoryDataset getDataset(int index) {
CategoryDataset result = null;
if (this.datasets.size() > index) {
result = (CategoryDataset) this.datasets.get(index);
}
return result;
}
/**
* Sets the dataset for the plot, replacing the existing dataset, if there
* is one. This method also calls the
* {@link #datasetChanged(DatasetChangeEvent)} method, which adjusts the
* axis ranges if necessary and sends a {@link PlotChangeEvent} to all
* registered listeners.
*
* @param dataset the dataset (<code>null</code> permitted).
*/
public void setDataset(CategoryDataset 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, CategoryDataset dataset) {
CategoryDataset existing = (CategoryDataset) this.datasets.get(index);
if (existing != null) {
existing.removeChangeListener(this);
}
this.datasets.set(index, dataset);
if (dataset != null) {
dataset.addChangeListener(this);
}
// send a dataset change event to self...
DatasetChangeEvent event = new DatasetChangeEvent(this, dataset);
datasetChanged(event);
}
/**
* Maps a dataset to a particular domain axis.
*
* @param index the dataset index (zero-based).
* @param axisIndex the axis index (zero-based).
*/
public void mapDatasetToDomainAxis(int index, int axisIndex) {
this.datasetToDomainAxisMap.set(index, new Integer(axisIndex));
// fake a dataset change event to update axes...
datasetChanged(new DatasetChangeEvent(this, getDataset(index)));
}
/**
* Returns the domain axis for a dataset. You can change the axis for a
* dataset using the {@link #mapDatasetToDomainAxis(int, int)} method.
*
* @param index the dataset index.
*
* @return The domain axis.
*/
public CategoryAxis getDomainAxisForDataset(int index) {
CategoryAxis result = getDomainAxis();
Integer axisIndex = (Integer) this.datasetToDomainAxisMap.get(index);
if (axisIndex != null) {
result = getDomainAxis(axisIndex.intValue());
}
return result;
}
/**
* Maps a dataset to a particular range axis.
*
* @param index the dataset index (zero-based).
* @param axisIndex the axis index (zero-based).
*/
public void mapDatasetToRangeAxis(int index, int axisIndex) {
this.datasetToRangeAxisMap.set(index, new Integer(axisIndex));
// fake a dataset change event to update axes...
datasetChanged(new DatasetChangeEvent(this, getDataset(index)));
}
/**
* Returns the range axis for a dataset. You can change the axis for a
* dataset using the {@link #mapDatasetToRangeAxis(int, int)} method.
*
* @param index the dataset index.
*
* @return The range axis.
*/
public ValueAxis getRangeAxisForDataset(int index) {
ValueAxis result = getRangeAxis();
Integer axisIndex = (Integer) this.datasetToRangeAxisMap.get(index);
if (axisIndex != null) {
result = getRangeAxis(axisIndex.intValue());
}
return result;
}
/**
* Returns a reference to the renderer for the plot.
*
* @return The renderer.
*/
public CategoryItemRenderer getRenderer() {
return getRenderer(0);
}
/**
* Returns the renderer at the given index.
*
* @param index the renderer index.
*
* @return The renderer (possibly <code>null</code>).
*/
public CategoryItemRenderer getRenderer(int index) {
CategoryItemRenderer result = null;
if (this.renderers.size() > index) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -