📄 categoryplot.java
字号:
public String getPlotType() {
return "Category Plot";
}
/**
* Returns the orientation of the plot.
*
* @return The orientation of the plot.
*/
public PlotOrientation getOrientation() {
return this.orientation;
}
/**
* Sets the orientation for the plot.
*
* @param orientation the orientation.
*/
public void setOrientation(PlotOrientation orientation) {
if (orientation != this.orientation) {
this.orientation = orientation;
notifyListeners(new PlotChangeEvent(this));
}
}
/**
* Returns the axis offset.
*
* @return The axis offset.
*/
public Spacer getAxisOffset() {
return this.axisOffset;
}
/**
* Sets the axis offsets (gap between the data area and the axes).
*
* @param offset the offset.
*/
public void setAxisOffset(Spacer offset) {
this.axisOffset = offset;
notifyListeners(new PlotChangeEvent(this));
}
/**
* Returns the domain axis for the plot. If the domain axis for this plot
* is <code>null</code>, then the method will return the parent plot's domain axis (if
* there is a parent plot).
*
* @return the domain axis.
*/
public CategoryAxis getDomainAxis() {
CategoryAxis result = this.domainAxis;
if (result == null) {
Plot parent = getParent();
if (parent instanceof CategoryPlot) {
CategoryPlot p = (CategoryPlot) parent;
result = p.getDomainAxis();
}
}
return result;
}
/**
* Sets the domain axis for the plot (this must be compatible with the
* plot type or an exception is thrown).
*
* @param axis the new axis.
*/
public void setDomainAxis(CategoryAxis axis) {
if (axis != null) {
try {
axis.setPlot(this);
}
catch (PlotNotCompatibleException e) {
// ignored...
}
axis.addChangeListener(this);
}
// plot is likely registered as a listener with the existing axis...
if (this.domainAxis != null) {
this.domainAxis.removeChangeListener(this);
}
this.domainAxis = axis;
notifyListeners(new PlotChangeEvent(this));
}
/**
* Returns the domain axis location.
*
* @return the domain axis location.
*/
public AxisLocation getDomainAxisLocation() {
return this.domainAxisLocation;
}
/**
* Sets the location of the domain axis. A {@link PlotChangeEvent} is sent to all registered
* listeners.
*
* @param location the axis location.
*/
public void setDomainAxisLocation(AxisLocation location) {
setDomainAxisLocation(location, true);
}
/**
* Sets the location of the domain axis.
*
* @param location the axis location.
* @param notify a flag that controls whether listeners are notified.
*/
public void setDomainAxisLocation(AxisLocation location, boolean notify) {
if (location != this.domainAxisLocation) {
this.domainAxisLocation = location;
if (notify) {
notifyListeners(new PlotChangeEvent(this));
}
}
}
/**
* Returns the domain axis edge.
*
* @return The edge.
*/
public RectangleEdge getDomainAxisEdge() {
return Plot.resolveDomainAxisLocation(this.domainAxisLocation, this.orientation);
}
/**
* Returns a secondary domain axis.
*
* @param index the axis index.
*
* @return The axis (<code>null</code> possible).
*/
public CategoryAxis getSecondaryDomainAxis(int index) {
CategoryAxis result = null;
if (index < this.secondaryDomainAxes.size()) {
result = (CategoryAxis) this.secondaryDomainAxes.get(index);
}
if (result == null) {
Plot parent = getParent();
if (parent instanceof CategoryPlot) {
CategoryPlot cp = (CategoryPlot) parent;
result = cp.getSecondaryDomainAxis(index);
}
}
return result;
}
/**
* Sets a secondary domain axis.
*
* @param index the axis index.
* @param axis the axis.
*/
public void setSecondaryDomainAxis(int index, CategoryAxis axis) {
CategoryAxis existing = getSecondaryDomainAxis(index);
if (existing != null) {
existing.removeChangeListener(this);
}
if (axis != null) {
try {
axis.setPlot(this);
}
catch (PlotNotCompatibleException e) {
}
}
this.secondaryDomainAxes.set(index, axis);
if (axis != null) {
axis.configure();
axis.addChangeListener(this);
}
notifyListeners(new PlotChangeEvent(this));
}
/**
* Clears the secondary domain axes from the plot.
*/
public void clearSecondaryDomainAxes() {
for (int i = 0; i < this.secondaryDomainAxes.size(); i++) {
CategoryAxis axis = (CategoryAxis) this.secondaryDomainAxes.get(i);
if (axis != null) {
axis.removeChangeListener(this);
}
}
this.secondaryDomainAxes.clear();
notifyListeners(new PlotChangeEvent(this));
}
/**
* Configures the secondary domain axes.
*/
public void configureSecondaryDomainAxes() {
for (int i = 0; i < this.secondaryDomainAxes.size(); i++) {
CategoryAxis axis = (CategoryAxis) this.secondaryDomainAxes.get(i);
if (axis != null) {
axis.configure();
}
}
}
/**
* Returns the location for a secondary domain axis.
*
* @param index the axis index.
*
* @return The location.
*/
public AxisLocation getSecondaryDomainAxisLocation(int index) {
AxisLocation result = null;
if (index < this.secondaryDomainAxisLocations.size()) {
result = (AxisLocation) this.secondaryDomainAxisLocations.get(index);
}
if (result == null) {
Plot parent = getParent();
if (parent instanceof CategoryPlot) {
CategoryPlot cp = (CategoryPlot) parent;
result = cp.getSecondaryDomainAxisLocation(index);
}
}
return result;
}
/**
* Sets the location for a secondary domain axis.
*
* @param index the axis index.
* @param location the location.
*/
public void setSecondaryDomainAxisLocation(int index, AxisLocation location) {
this.secondaryDomainAxisLocations.set(index, location);
notifyListeners(new PlotChangeEvent(this));
}
/**
* Returns the edge for a secondary domain axis.
*
* @param index the axis index.
*
* @return The edge.
*/
public RectangleEdge getSecondaryDomainAxisEdge(int index) {
AxisLocation location = getSecondaryDomainAxisLocation(index);
RectangleEdge result = Plot.resolveDomainAxisLocation(location, this.orientation);
if (result == null) {
result = RectangleEdge.opposite(getDomainAxisEdge());
}
return result;
}
/**
* 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.
*/
public ValueAxis getRangeAxis() {
ValueAxis result = this.rangeAxis;
if (result == null) {
Plot parent = getParent();
if (parent instanceof CategoryPlot) {
CategoryPlot cp = (CategoryPlot) parent;
result = cp.getRangeAxis();
}
}
return result;
}
/**
* Sets the range axis for the plot.
* <P>
* An exception is thrown if the new axis and the plot are not mutually compatible.
*
* @param axis the new axis.
*/
public void setRangeAxis(ValueAxis axis) {
if (axis != null) {
try {
axis.setPlot(this);
}
catch (PlotNotCompatibleException e) {
}
axis.addChangeListener(this);
}
// plot is likely registered as a listener with the existing axis...
if (this.rangeAxis != null) {
this.rangeAxis.removeChangeListener(this);
}
this.rangeAxis = axis;
notifyListeners(new PlotChangeEvent(this));
}
/**
* Returns the range axis location.
*
* @return the range axis location.
*/
public AxisLocation getRangeAxisLocation() {
return this.rangeAxisLocation;
}
/**
* Sets the location of the range axis.
*
* @param location the location.
*/
public void setRangeAxisLocation(AxisLocation location) {
setRangeAxisLocation(location, true);
}
/**
* Sets the location of the range axis.
*
* @param location the location.
* @param notify a flag that controls whether listeners are notified.
*/
public void setRangeAxisLocation(AxisLocation location, boolean notify) {
if (location != this.rangeAxisLocation) {
this.rangeAxisLocation = location;
if (notify) {
notifyListeners(new PlotChangeEvent(this));
}
}
}
/**
* Returns the range axis edge.
*
* @return The edge.
*/
public RectangleEdge getRangeAxisEdge() {
return Plot.resolveRangeAxisLocation(this.rangeAxisLocation, this.orientation);
}
/**
* Returns a secondary range axis.
*
* @param index the axis index.
*
* @return The axis (<code>null</code> possible).
*/
public ValueAxis getSecondaryRangeAxis(int index) {
ValueAxis result = null;
if (index < this.secondaryRangeAxes.size()) {
result = (ValueAxis) this.secondaryRangeAxes.get(index);
}
if (result == null) {
Plot parent = getParent();
if (parent instanceof CategoryPlot) {
CategoryPlot cp = (CategoryPlot) parent;
result = cp.getSecondaryRangeAxis(index);
}
}
return result;
}
/**
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -