📄 categoryplot.java
字号:
* Sets a secondary range axis.
*
* @param index the axis index.
* @param axis the axis.
*/
public void setSecondaryRangeAxis(int index, ValueAxis axis) {
ValueAxis existing = getSecondaryRangeAxis(index);
if (existing != null) {
existing.removeChangeListener(this);
}
if (axis != null) {
try {
axis.setPlot(this);
}
catch (PlotNotCompatibleException e) {
}
}
this.secondaryRangeAxes.set(index, axis);
if (axis != null) {
axis.configure();
axis.addChangeListener(this);
}
notifyListeners(new PlotChangeEvent(this));
}
/**
* Clears the secondary range axes from the plot.
*/
public void clearSecondaryRangeAxes() {
for (int i = 0; i < this.secondaryRangeAxes.size(); i++) {
ValueAxis axis = (ValueAxis) this.secondaryRangeAxes.get(i);
if (axis != null) {
axis.removeChangeListener(this);
}
}
this.secondaryRangeAxes.clear();
notifyListeners(new PlotChangeEvent(this));
}
/**
* Configures the secondary range axes.
*/
public void configureSecondaryRangeAxes() {
for (int i = 0; i < this.secondaryRangeAxes.size(); i++) {
ValueAxis axis = (ValueAxis) this.secondaryRangeAxes.get(i);
if (axis != null) {
axis.configure();
}
}
}
/**
* Returns the location for a secondary range axis.
*
* @param index the axis index.
*
* @return The location.
*/
public AxisLocation getSecondaryRangeAxisLocation(int index) {
AxisLocation result = null;
if (index < this.secondaryRangeAxisLocations.size()) {
result = (AxisLocation) this.secondaryRangeAxisLocations.get(index);
}
if (result == null) {
Plot parent = getParent();
if (parent instanceof CategoryPlot) {
CategoryPlot cp = (CategoryPlot) parent;
result = cp.getSecondaryRangeAxisLocation(index);
}
}
return result;
}
/**
* Sets the location for a secondary range axis.
*
* @param index the axis index.
* @param location the location.
*/
public void setSecondaryRangeAxisLocation(int index, AxisLocation location) {
this.secondaryRangeAxisLocations.set(index, location);
notifyListeners(new PlotChangeEvent(this));
}
/**
* Returns the edge for a secondary range axis.
*
* @param index the axis index.
*
* @return The edge.
*/
public RectangleEdge getSecondaryRangeAxisEdge(int index) {
AxisLocation location = getSecondaryRangeAxisLocation(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 CategoryDataset getDataset() {
return this.dataset;
}
/**
* Sets the dataset for the plot, replacing the existing dataset if there is one.
*
* @param dataset the dataset (<code>null</code> permitted).
*/
public void setDataset(CategoryDataset dataset) {
// if there is an existing dataset, remove the plot from the list of change listeners...
CategoryDataset existing = this.dataset;
if (existing != null) {
existing.removeChangeListener(this);
}
// set the new dataset, and register the chart as a change listener...
this.dataset = dataset;
if (dataset != null) {
setDatasetGroup(dataset.getGroup());
dataset.addChangeListener(this);
}
// send a dataset change event to self...
DatasetChangeEvent event = new DatasetChangeEvent(this, dataset);
datasetChanged(event);
}
/**
* Returns one of the secondary datasets.
*
* @param index the dataset index.
*
* @return The dataset (possibly <code>null</code>).
*/
public CategoryDataset getSecondaryDataset(int index) {
CategoryDataset result = null;
if (this.secondaryDatasets.size() > index) {
result = (CategoryDataset) this.secondaryDatasets.get(index);
}
return result;
}
/**
* Adds or changes a secondary dataset for the plot.
*
* @param index the dataset index.
* @param dataset the dataset.
*/
public void setSecondaryDataset(int index, CategoryDataset dataset) {
this.secondaryDatasets.set(index, dataset);
// send a dataset change event to self...
DatasetChangeEvent event = new DatasetChangeEvent(this, dataset);
datasetChanged(event);
}
/**
* Maps a secondary dataset to a particular domain axis.
*
* @param index the dataset index (zero-based).
* @param key the key (<code>null</code> for primary axis, or the index of the secondary
* axis).
*/
public void mapSecondaryDatasetToDomainAxis(int index, Integer key) {
this.secondaryDatasetDomainAxisMap.set(index, key);
// fake a dataset change event to update axes...
datasetChanged(new DatasetChangeEvent(this, this.dataset));
}
/**
* Maps a secondary dataset to a particular range axis.
*
* @param index the dataset index (zero-based).
* @param key the key (<code>null</code> for primary axis, or the index of the secondary
* axis).
*/
public void mapSecondaryDatasetToRangeAxis(int index, Integer key) {
this.secondaryDatasetRangeAxisMap.set(index, key);
// fake a dataset change event to update axes...
datasetChanged(new DatasetChangeEvent(this, this.dataset));
}
/**
* Returns a reference to the renderer for the plot.
*
* @return The renderer.
*/
public CategoryItemRenderer getRenderer() {
return this.renderer;
}
/**
* Sets the renderer for the plot. A {@link PlotChangeEvent} is sent to all registered
* listeners.
*
* @param renderer the renderer.
*/
public void setRenderer(CategoryItemRenderer renderer) {
setRenderer(renderer, true);
}
/**
* Sets the renderer for the plot.
* <p>
* You can set the renderer to <code>null</code>, but this is not recommended because:
* <ul>
* <li>no data will be displayed;</li>
* <li>the plot background will not be painted;</li>
* </ul>
*
* @param renderer the renderer (<code>null</code> permitted).
* @param notify notify listeners?
*/
public void setRenderer(CategoryItemRenderer renderer, boolean notify) {
this.renderer = renderer;
if (renderer != null) {
renderer.setPlot(this);
}
if (notify) {
notifyListeners(new PlotChangeEvent(this));
}
}
/**
* Returns a secondary renderer.
*
* @param index the renderer index.
*
* @return The renderer (possibly <code>null</code>).
*/
public CategoryItemRenderer getSecondaryRenderer(int index) {
CategoryItemRenderer result = null;
if (this.secondaryRenderers.size() > index) {
result = (CategoryItemRenderer) this.secondaryRenderers.get(index);
}
return result;
}
/**
* Sets a secondary renderer. A {@link PlotChangeEvent} is sent to all registered listeners.
*
* @param index the index.
* @param renderer the renderer.
*/
public void setSecondaryRenderer(int index, CategoryItemRenderer renderer) {
CategoryItemRenderer existing = getSecondaryRenderer(index);
if (existing != null) {
// existing.removePropertyChangeListener(this);
}
this.secondaryRenderers.set(index, renderer);
if (renderer != null) {
renderer.setPlot(this);
}
notifyListeners(new PlotChangeEvent(this));
}
/**
* Returns the dataset rendering order.
*
* @return The dataset rendering order.
*/
public DatasetRenderingOrder getDatasetRenderingOrder() {
return this.renderingOrder;
}
/**
* Sets the rendering order. A {@link PlotChangeEvent} is sent to all registered listeners.
* <P>
* By default, the plot renders the secondary dataset first, then the primary dataset (so that
* the primary dataset overlays the secondary dataset). You can reverse this if you want to.
*
* @param order the rendering order.
*/
public void setDatasetRenderingOrder(DatasetRenderingOrder order) {
this.renderingOrder = order;
notifyListeners(new PlotChangeEvent(this));
}
/**
* Returns the flag that controls whether the domain grid-lines are visible.
*
* @return the <code>true</code> or <code>false</code>.
*/
public boolean isDomainGridlinesVisible() {
return this.domainGridlinesVisible;
}
/**
* Sets the flag that controls whether or not grid-lines are drawn against the domain axis.
* <p>
* If the flag value changes, a {@link PlotChangeEvent} is sent to all registered listeners.
*
* @param visible the new value of the flag.
*/
public void setDomainGridlinesVisible(boolean visible) {
if (this.domainGridlinesVisible != visible) {
this.domainGridlinesVisible = visible;
notifyListeners(new PlotChangeEvent(this));
}
}
/**
* Returns the position used for the domain gridlines.
*
* @return The gridline position.
*/
public CategoryAnchor getDomainGridlinePosition() {
return this.domainGridlinePosition;
}
/**
* Sets the position used for the domain gridlines.
*
* @param position the position.
*/
public void setDomainGridlinePosition(CategoryAnchor position) {
this.domainGridlinePosition = position;
notifyListeners(new PlotChangeEvent(this));
}
/**
* Returns the stroke used to draw grid-lines against the domain axis.
*
* @return the stroke.
*/
public Stroke getDomainGridlineStroke() {
return this.domainGridlineStroke;
}
/**
* Sets the stroke used to draw grid-lines against the domain axis. A {@link PlotChangeEvent}
* is sent to all registered listeners.
*
* @param stroke the stroke.
*/
public void setDomainGridlineStroke(Stroke stroke) {
this.domainGridlineStroke = stroke;
notifyListeners(new PlotChangeEvent(this));
}
/**
* Returns the paint used to draw grid-lines against the domain axis.
*
* @return the paint.
*/
public Paint getDomainGridlinePaint() {
return this.domainGridlinePaint;
}
/**
* Sets the paint used to draw the grid-lines (if any) against the domain axis.
* A {@link PlotChangeEvent} is sent to all registered listeners.
*
* @param paint the paint.
*/
public void setDomainGridlinePaint(Paint paint) {
this.domainGridlinePaint = paint;
notifyListeners(new PlotChangeEvent(this));
}
/**
* Returns the flag that controls whether the range grid-lines are visible.
*
* @return the flag.
*/
public boolean isRangeGridlinesVisible() {
return this.rangeGridlinesVisible;
}
/**
* Sets the flag that controls whether or not grid-lines are drawn against the range axis.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -