📄 xyplot.java
字号:
* Returns the stroke for the grid-lines (if any) plotted against the domain axis.
*
* @return the stroke.
*/
public Stroke getDomainGridlineStroke() {
return this.domainGridlineStroke;
}
/**
* Sets the stroke for the grid lines plotted against the domain axis.
* <p>
* If you set this to <code>null</code>, no grid lines will be drawn.
*
* @param stroke the stroke (<code>null</code> permitted).
*/
public void setDomainGridlineStroke(Stroke stroke) {
this.domainGridlineStroke = stroke;
notifyListeners(new PlotChangeEvent(this));
}
/**
* Returns the paint for the grid lines (if any) plotted against the domain axis.
*
* @return the paint.
*/
public Paint getDomainGridlinePaint() {
return this.domainGridlinePaint;
}
/**
* Sets the paint for the grid lines plotted against the domain axis.
* <p>
* If you set this to <code>null</code>, no grid lines will be drawn.
*
* @param paint the paint (<code>null</code> permitted).
*/
public void setDomainGridlinePaint(Paint paint) {
this.domainGridlinePaint = paint;
notifyListeners(new PlotChangeEvent(this));
}
/**
* Returns <code>true</code> if the range axis grid is visible, and <code>false<code>
* otherwise.
*
* @return <code>true</code> or <code>false</code>.
*/
public boolean isRangeGridlinesVisible() {
return this.rangeGridlinesVisible;
}
/**
* Sets the flag that controls whether or not the range axis grid lines are visible.
* <p>
* If the flag value is changed, a {@link PlotChangeEvent} is sent to all registered listeners.
*
* @param visible the new value of the flag.
*/
public void setRangeGridlinesVisible(boolean visible) {
if (this.rangeGridlinesVisible != visible) {
this.rangeGridlinesVisible = visible;
notifyListeners(new PlotChangeEvent(this));
}
}
/**
* Returns the stroke for the grid lines (if any) plotted against the range axis.
*
* @return the stroke.
*/
public Stroke getRangeGridlineStroke() {
return this.rangeGridlineStroke;
}
/**
* Sets the stroke for the grid lines plotted against the range axis.
* <p>
* If you set this to <code>null</code>, no grid lines will be drawn.
*
* @param stroke the stroke (<code>null</code> permitted).
*/
public void setRangeGridlineStroke(Stroke stroke) {
this.rangeGridlineStroke = stroke;
notifyListeners(new PlotChangeEvent(this));
}
/**
* Returns the paint for the grid lines (if any) plotted against the range axis.
*
* @return the paint.
*/
public Paint getRangeGridlinePaint() {
return this.rangeGridlinePaint;
}
/**
* Sets the paint for the grid lines plotted against the range axis.
* <p>
* If you set this to <code>null</code>, no grid lines will be drawn.
*
* @param paint the paint (<code>null</code> permitted).
*/
public void setRangeGridlinePaint(Paint paint) {
this.rangeGridlinePaint = paint;
notifyListeners(new PlotChangeEvent(this));
}
/**
* Returns the paint used for the domain tick bands. If this is <code>null</code>,
* no tick bands will be drawn.
*
* @return The paint (possibly <code>null</code>).
*/
public Paint getDomainTickBandPaint() {
return this.domainTickBandPaint;
}
/**
* Sets the paint for the domain tick bands.
*
* @param paint the paint (<code>null</code> permitted).
*/
public void setDomainTickBandPaint(Paint paint) {
this.domainTickBandPaint = paint;
notifyListeners(new PlotChangeEvent(this));
}
/**
* Returns the paint used for the range tick bands. If this is <code>null</code>,
* no tick bands will be drawn.
*
* @return The paint (possibly <code>null</code>).
*/
public Paint getRangeTickBandPaint() {
return this.rangeTickBandPaint;
}
/**
* Sets the paint for the range tick bands.
*
* @param paint the paint (<code>null</code> permitted).
*/
public void setRangeTickBandPaint(Paint paint) {
this.rangeTickBandPaint = paint;
notifyListeners(new PlotChangeEvent(this));
}
/**
* Adds a marker for the domain axis.
* <P>
* Typically a marker will be drawn by the renderer as a line perpendicular
* to the range axis, however this is entirely up to the renderer.
*
* @param marker the marker.
*/
public void addDomainMarker(Marker marker) {
if (this.domainMarkers == null) {
this.domainMarkers = new java.util.ArrayList();
}
this.domainMarkers.add(marker);
notifyListeners(new PlotChangeEvent(this));
}
/**
* Clears all the domain markers.
*/
public void clearDomainMarkers() {
if (this.domainMarkers != null) {
this.domainMarkers.clear();
notifyListeners(new PlotChangeEvent(this));
}
}
/**
* Adds a marker for the range axis.
* <P>
* Typically a marker will be drawn by the renderer as a line perpendicular
* to the range axis, however this is entirely up to the renderer.
*
* @param marker the marker.
*/
public void addRangeMarker(Marker marker) {
if (this.rangeMarkers == null) {
this.rangeMarkers = new java.util.ArrayList();
}
this.rangeMarkers.add(marker);
notifyListeners(new PlotChangeEvent(this));
}
/**
* Clears all the range markers.
*/
public void clearRangeMarkers() {
if (this.rangeMarkers != null) {
this.rangeMarkers.clear();
notifyListeners(new PlotChangeEvent(this));
}
}
/**
* Adds a secondary marker for the range axis.
* <P>
* Typically a marker will be drawn by the renderer as a line perpendicular
* to the range axis, however this is entirely up to the renderer.
*
* @param marker The marker.
*/
public void addSecondaryRangeMarker(Marker marker) {
if (this.secondaryRangeMarkers == null) {
this.secondaryRangeMarkers = new java.util.ArrayList();
}
this.secondaryRangeMarkers.add(marker);
notifyListeners(new PlotChangeEvent(this));
}
/**
* Clears all the secondary range markers.
*/
public void clearSecondaryRangeMarkers() {
if (this.secondaryRangeMarkers != null) {
this.secondaryRangeMarkers.clear();
notifyListeners(new PlotChangeEvent(this));
}
}
/**
* Adds an annotation to the plot.
*
* @param annotation the annotation.
*/
public void addAnnotation(XYAnnotation annotation) {
if (this.annotations == null) {
this.annotations = new java.util.ArrayList();
}
this.annotations.add(annotation);
notifyListeners(new PlotChangeEvent(this));
}
/**
* Clears all the annotations.
*/
public void clearAnnotations() {
if (this.annotations != null) {
this.annotations.clear();
notifyListeners(new PlotChangeEvent(this));
}
}
/**
* Calculates the space required for the domain axis/axes.
*
* @param g2 the graphics device.
* @param plotArea the plot area.
* @param space a carrier for the result (<code>null</code> permitted).
*
* @return The required space.
*/
protected AxisSpace calculateDomainAxisSpace(Graphics2D g2, Rectangle2D plotArea,
AxisSpace space) {
if (space == null) {
space = new AxisSpace();
}
// reserve some space for the domain axis...
if (this.fixedDomainAxisSpace != null) {
if (orientation == PlotOrientation.HORIZONTAL) {
space.ensureAtLeast(this.fixedDomainAxisSpace.getLeft(), RectangleEdge.LEFT);
space.ensureAtLeast(this.fixedDomainAxisSpace.getRight(), RectangleEdge.RIGHT);
}
else if (orientation == PlotOrientation.VERTICAL) {
space.ensureAtLeast(this.fixedDomainAxisSpace.getTop(), RectangleEdge.TOP);
space.ensureAtLeast(this.fixedDomainAxisSpace.getBottom(), RectangleEdge.BOTTOM);
}
}
else {
// reserve space for the primary domain axis...
if (this.domainAxis != null) {
space = this.domainAxis.reserveSpace(g2, this, plotArea, getDomainAxisEdge(),
space);
}
// reserve space for any secondary domain axes...
for (int i = 0; i < this.secondaryDomainAxes.size(); i++) {
Axis secondaryDomainAxis = getSecondaryDomainAxis(i);
if (secondaryDomainAxis != null) {
RectangleEdge edge = getSecondaryDomainAxisEdge(i);
space = secondaryDomainAxis.reserveSpace(g2, this, plotArea, edge, space);
}
}
}
return space;
}
/**
* Calculates the space required for the range axis/axes.
*
* @param g2 the graphics device.
* @param plotArea the plot area.
* @param space a carrier for the result (<code>null</code> permitted).
*
* @return The required space.
*/
protected AxisSpace calculateRangeAxisSpace(Graphics2D g2, Rectangle2D plotArea,
AxisSpace space) {
if (space == null) {
space = new AxisSpace();
}
// reserve some space for the range axis...
if (this.fixedRangeAxisSpace != null) {
if (orientation == PlotOrientation.HORIZONTAL) {
space.ensureAtLeast(this.fixedRangeAxisSpace.getTop(), RectangleEdge.TOP);
space.ensureAtLeast(this.fixedRangeAxisSpace.getBottom(), RectangleEdge.BOTTOM);
}
else if (orientation == PlotOrientation.VERTICAL) {
space.ensureAtLeast(this.fixedRangeAxisSpace.getLeft(), RectangleEdge.LEFT);
space.ensureAtLeast(this.fixedRangeAxisSpace.getRight(), RectangleEdge.RIGHT);
}
}
else {
Axis rangeAxis1 = this.rangeAxis;
if (rangeAxis1 != null) {
space = rangeAxis1.reserveSpace(g2, this, plotArea, getRangeAxisEdge(), space);
}
// reserve space for the secondary range axes (if any)...
for (int i = 0; i < this.secondaryRangeAxes.size(); i++) {
Axis secondaryRangeAxis = getSecondaryRangeAxis(i);
if (secondaryRangeAxis != null) {
RectangleEdge edge = getSecondaryRangeAxisEdge(i);
space = secondaryRangeAxis.reserveSpace(g2, this, plotArea, edge, space);
}
}
}
return space;
}
/**
* Calculates the space required for the axes.
*
* @param g2 the graphics device.
* @param plotArea the plot area.
*
* @return The required space.
*/
protected AxisSpace calculateAxisSpace(Graphics2D g2, Rectangle2D plotArea) {
AxisSpace space = new AxisSpace();
space = calculateDomainAxisSpace(g2, plotArea, space);
space = calculateRangeAxisSpace(g2, plotArea, space);
return space;
}
/**
* Draws the plot on a Java 2D graphics device (such as the screen or a printer).
* <P>
* This plot relies on an {@link XYItemRenderer} to draw each item in the plot. This
* allows the visual representation of the data to be changed easily.
* <P>
* The optional info argument collects information about the rendering of
* the plot (dimensions, tooltip information etc). Just pass in <code>null</code> if
* you do not need this information.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -