?? categoryplot.java
字號:
/**
* 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.
* If the flag changes value, 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 used to draw the grid-lines against the range axis.
*
* @return the stroke.
*/
public Stroke getRangeGridlineStroke() {
return this.rangeGridlineStroke;
}
/**
* Sets the stroke used to draw the grid-lines against the range axis.
* A {@link PlotChangeEvent} is sent to all registered listeners.
*
* @param stroke the stroke.
*/
public void setRangeGridlineStroke(Stroke stroke) {
this.rangeGridlineStroke = stroke;
notifyListeners(new PlotChangeEvent(this));
}
/**
* Returns the paint used to draw the grid-lines against the range axis.
*
* @return the paint.
*/
public Paint getRangeGridlinePaint() {
return this.rangeGridlinePaint;
}
/**
* Sets the paint used to draw the grid lines against the range axis.
* A {@link PlotChangeEvent} is sent to all registered listeners.
*
* @param paint the paint.
*/
public void setRangeGridlinePaint(Paint paint) {
this.rangeGridlinePaint = paint;
notifyListeners(new PlotChangeEvent(this));
}
/**
* Returns the legend items for the plot. By default, this method creates a legend item for
* each series in the primary and secondary datasets. You can change this behaviour by
* overriding this method.
*
* @return the legend items.
*/
public LegendItemCollection getLegendItems() {
LegendItemCollection result = new LegendItemCollection();
CategoryDataset data = getDataset();
if (data != null) {
int seriesCount = data.getRowCount();
for (int i = 0; i < seriesCount; i++) {
CategoryItemRenderer r = getRenderer();
if (r != null) {
LegendItem item = r.getLegendItem(0, i);
result.add(item);
}
}
}
// get the legend items for the secondary datasets...
int count = this.secondaryDatasets.size();
for (int datasetIndex = 0; datasetIndex < count; datasetIndex++) {
CategoryDataset dataset2 = getSecondaryDataset(datasetIndex);
if (dataset2 != null) {
CategoryItemRenderer renderer2 = getSecondaryRenderer(datasetIndex);
if (renderer2 != null) {
int seriesCount = dataset2.getRowCount();
for (int i = 0; i < seriesCount; i++) {
LegendItem item = renderer2.getLegendItem(datasetIndex + 1, i);
result.add(item);
}
}
}
}
return result;
}
/**
* Handles a 'click' on the plot by updating the anchor value.
*
* @param x x-coordinate of the click.
* @param y y-coordinate of the click.
* @param info an optional info collection object to return data back to the caller.
*
*/
public void handleClick(int x, int y, ChartRenderingInfo info) {
// set the anchor value for the range axis...
float java2D = 0.0f;
if (this.orientation == PlotOrientation.HORIZONTAL) {
java2D = (float) x;
}
else if (this.orientation == PlotOrientation.VERTICAL) {
java2D = (float) y;
}
RectangleEdge edge = Plot.resolveRangeAxisLocation(getRangeAxisLocation(),
this.orientation);
double value = this.rangeAxis.translateJava2DtoValue(java2D, info.getDataArea(), edge);
setAnchorValue(value);
setRangeCrosshairValue(value);
}
/**
* Zooms (in or out) on the plot's value axis.
* <p>
* If the value 0.0 is passed in as the zoom percent, the auto-range
* calculation for the axis is restored (which sets the range to include
* the minimum and maximum data values, thus displaying all the data).
*
* @param percent the zoom amount.
*/
public void zoom(double percent) {
if (percent > 0.0) {
double range = this.rangeAxis.getRange().getLength();
double scaledRange = range * percent;
rangeAxis.setRange(this.anchorValue - scaledRange / 2.0,
this.anchorValue + scaledRange / 2.0);
}
else {
rangeAxis.setAutoRange(true);
}
}
/**
* Receives notification of a change to the plot's dataset.
* <P>
* The range axis bounds will be recalculated if necessary.
*
* @param event information about the event (not used here).
*/
public void datasetChanged(DatasetChangeEvent event) {
if (this.rangeAxis != null) {
this.rangeAxis.configure();
}
int count = this.secondaryRangeAxes.size();
for (int axisIndex = 0; axisIndex < count; axisIndex++) {
ValueAxis secondaryRangeAxis = getSecondaryRangeAxis(axisIndex);
if (secondaryRangeAxis != null) {
secondaryRangeAxis.configure();
}
}
if (getParent() != null) {
getParent().datasetChanged(event);
}
else {
PlotChangeEvent e = new PlotChangeEvent(this);
notifyListeners(e);
}
}
/**
* Adds a marker for display against 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 for the plot.
*/
public void clearRangeMarkers() {
if (this.rangeMarkers != null) {
this.rangeMarkers.clear();
notifyListeners(new PlotChangeEvent(this));
}
}
/**
* Returns the list of range markers (read only).
*
* @return The list of range markers.
*/
public List getRangeMarkers() {
return Collections.unmodifiableList(this.rangeMarkers);
}
/**
* Adds a marker for display against the secondary 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 for the plot.
*/
public void clearSecondaryRangeMarkers() {
if (this.secondaryRangeMarkers != null) {
this.secondaryRangeMarkers.clear();
notifyListeners(new PlotChangeEvent(this));
}
}
/**
* Returns the list of secondary range markers (read only).
*
* @return The list of secondary range markers.
*/
public List getSecondaryRangeMarkers() {
if (this.secondaryRangeMarkers != null) {
return Collections.unmodifiableList(this.secondaryRangeMarkers);
}
else {
return null;
}
}
/**
* Returns a flag indicating whether or not the range crosshair is visible.
*
* @return the flag.
*/
public boolean isRangeCrosshairVisible() {
return this.rangeCrosshairVisible;
}
/**
* Sets the flag indicating whether or not the range crosshair is visible.
*
* @param flag the new value of the flag.
*/
public void setRangeCrosshairVisible(boolean flag) {
if (this.rangeCrosshairVisible != flag) {
this.rangeCrosshairVisible = flag;
notifyListeners(new PlotChangeEvent(this));
}
}
/**
* Returns a flag indicating whether or not the crosshair should "lock-on"
* to actual data values.
*
* @return the flag.
*/
public boolean isRangeCrosshairLockedOnData() {
return this.rangeCrosshairLockedOnData;
}
/**
* Sets the flag indicating whether or not the range crosshair should "lock-on"
* to actual data values.
*
* @param flag the flag.
*/
public void setRangeCrosshairLockedOnData(boolean flag) {
if (this.rangeCrosshairLockedOnData != flag) {
this.rangeCrosshairLockedOnData = flag;
notifyListeners(new PlotChangeEvent(this));
}
}
/**
* Returns the range crosshair value.
*
* @return The value.
*/
public double getRangeCrosshairValue() {
return this.rangeCrosshairValue;
}
/**
* Sets the domain crosshair value.
* <P>
* Registered listeners are notified that the plot has been modified, but
* only if the crosshair is visible.
*
* @param value the new value.
*/
public void setRangeCrosshairValue(double value) {
setRangeCrosshairValue(value, true);
}
/**
* Sets the range crosshair value.
* <P>
* Registered listeners are notified that the axis has been modified, but
* only if the crosshair is visible.
*
* @param value the new value.
* @param notify a flag that controls whether or not listeners are notified.
*/
public void setRangeCrosshairValue(double value, boolean notify) {
this.rangeCrosshairValue = value;
if (isRangeCrosshairVisible() && notify) {
notifyListeners(new PlotChangeEvent(this));
}
}
/**
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -