📄 xyplot.java
字号:
setDomainAxis(i, axes[i], false);
}
notifyListeners(new PlotChangeEvent(this));
}
/**
* Returns the location of the primary domain axis.
*
* @return The location (never <code>null</code>).
*
* @see #setDomainAxisLocation(AxisLocation)
*/
public AxisLocation getDomainAxisLocation() {
return (AxisLocation) this.domainAxisLocations.get(0);
}
/**
* Sets the location of the primary domain axis and sends a
* {@link PlotChangeEvent} to all registered listeners.
*
* @param location the location (<code>null</code> not permitted).
*
* @see #getDomainAxisLocation()
*/
public void setDomainAxisLocation(AxisLocation location) {
// delegate...
setDomainAxisLocation(0, location, true);
}
/**
* Sets the location of the domain 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?
*
* @see #getDomainAxisLocation()
*/
public void setDomainAxisLocation(AxisLocation location, boolean notify) {
// delegate...
setDomainAxisLocation(0, location, notify);
}
/**
* Returns the edge for the primary domain axis (taking into account the
* plot's orientation).
*
* @return The edge.
*
* @see #getDomainAxisLocation()
* @see #getOrientation()
*/
public RectangleEdge getDomainAxisEdge() {
return Plot.resolveDomainAxisLocation(getDomainAxisLocation(),
this.orientation);
}
/**
* Returns the number of domain axes.
*
* @return The axis count.
*
* @see #getRangeAxisCount()
*/
public int getDomainAxisCount() {
return this.domainAxes.size();
}
/**
* Clears the domain axes from the plot and sends a {@link PlotChangeEvent}
* to all registered listeners.
*
* @see #clearRangeAxes()
*/
public void clearDomainAxes() {
for (int i = 0; i < this.domainAxes.size(); i++) {
ValueAxis axis = (ValueAxis) this.domainAxes.get(i);
if (axis != null) {
axis.removeChangeListener(this);
}
}
this.domainAxes.clear();
notifyListeners(new PlotChangeEvent(this));
}
/**
* Configures the domain axes.
*/
public void configureDomainAxes() {
for (int i = 0; i < this.domainAxes.size(); i++) {
ValueAxis axis = (ValueAxis) this.domainAxes.get(i);
if (axis != null) {
axis.configure();
}
}
}
/**
* Returns the location for a domain axis. If this hasn't been set
* explicitly, the method returns the location that is opposite to the
* primary domain axis location.
*
* @param index the axis index.
*
* @return The location (never <code>null</code>).
*
* @see #setDomainAxisLocation(int, AxisLocation)
*/
public AxisLocation getDomainAxisLocation(int index) {
AxisLocation result = null;
if (index < this.domainAxisLocations.size()) {
result = (AxisLocation) this.domainAxisLocations.get(index);
}
if (result == null) {
result = AxisLocation.getOpposite(getDomainAxisLocation());
}
return result;
}
/**
* Sets the location for a domain axis and sends a {@link PlotChangeEvent}
* to all registered listeners.
*
* @param index the axis index.
* @param location the location (<code>null</code> not permitted for index
* 0).
*
* @see #getDomainAxisLocation(int)
*/
public void setDomainAxisLocation(int index, AxisLocation location) {
// delegate...
setDomainAxisLocation(index, location, true);
}
/**
* Sets the axis location for a domain axis and, if requested, sends a
* {@link PlotChangeEvent} to all registered listeners.
*
* @param index the axis index.
* @param location the location (<code>null</code> not permitted for
* index 0).
* @param notify notify listeners?
*
* @since 1.0.5
*
* @see #getDomainAxisLocation(int)
* @see #setRangeAxisLocation(int, AxisLocation, boolean)
*/
public void setDomainAxisLocation(int index, AxisLocation location,
boolean notify) {
if (index == 0 && location == null) {
throw new IllegalArgumentException(
"Null 'location' for index 0 not permitted.");
}
this.domainAxisLocations.set(index, location);
if (notify) {
notifyListeners(new PlotChangeEvent(this));
}
}
/**
* Returns the edge for a domain axis.
*
* @param index the axis index.
*
* @return The edge.
*
* @see #getRangeAxisEdge(int)
*/
public RectangleEdge getDomainAxisEdge(int index) {
AxisLocation location = getDomainAxisLocation(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
* <code>null</code>, then the method will return the parent plot's range
* axis (if there is a parent plot).
*
* @return The range axis.
*
* @see #getRangeAxis(int)
* @see #setRangeAxis(ValueAxis)
*/
public ValueAxis getRangeAxis() {
return getRangeAxis(0);
}
/**
* Sets the range axis for the plot and sends a {@link PlotChangeEvent} to
* all registered listeners.
*
* @param axis the axis (<code>null</code> permitted).
*
* @see #getRangeAxis()
* @see #setRangeAxis(int, ValueAxis)
*/
public void setRangeAxis(ValueAxis axis) {
if (axis != null) {
axis.setPlot(this);
}
// plot is likely registered as a listener with the existing axis...
ValueAxis existing = getRangeAxis();
if (existing != null) {
existing.removeChangeListener(this);
}
this.rangeAxes.set(0, axis);
if (axis != null) {
axis.configure();
axis.addChangeListener(this);
}
notifyListeners(new PlotChangeEvent(this));
}
/**
* Returns the location of the primary range axis.
*
* @return The location (never <code>null</code>).
*
* @see #setRangeAxisLocation(AxisLocation)
*/
public AxisLocation getRangeAxisLocation() {
return (AxisLocation) this.rangeAxisLocations.get(0);
}
/**
* Sets the location of the primary range axis and sends a
* {@link PlotChangeEvent} to all registered listeners.
*
* @param location the location (<code>null</code> not permitted).
*
* @see #getRangeAxisLocation()
*/
public void setRangeAxisLocation(AxisLocation location) {
// delegate...
setRangeAxisLocation(0, 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?
*
* @see #getRangeAxisLocation()
*/
public void setRangeAxisLocation(AxisLocation location, boolean notify) {
// delegate...
setRangeAxisLocation(0, location, notify);
}
/**
* Returns the edge for the primary range axis.
*
* @return The range axis edge.
*
* @see #getRangeAxisLocation()
* @see #getOrientation()
*/
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).
*
* @see #setRangeAxis(int, ValueAxis)
*/
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).
*
* @see #getRangeAxis(int)
*/
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 (<code>null</code> permitted).
* @param notify notify listeners?
*
* @see #getRangeAxis(int)
*/
public void setRangeAxis(int index, ValueAxis axis, boolean notify) {
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);
}
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 (<code>null</code> not permitted).
*
* @see #setDomainAxes(ValueAxis[])
*/
public void setRangeAxes(ValueAxis[] axes) {
for (int i = 0; i < axes.length; i++) {
setRangeAxis(i, axes[i], false);
}
notifyListeners(new PlotChangeEvent(this));
}
/**
* Returns the number of range axes.
*
* @return The axis count.
*
* @see #getDomainAxisCount()
*/
public int getRangeAxisCount() {
return this.rangeAxes.size();
}
/**
* Clears the range axes from the plot and sends a {@link PlotChangeEvent}
* to all registered listeners.
*
* @see #clearDomainAxes()
*/
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();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -