📄 standardxyitemrenderer.java
字号:
* for ALL series and sends a {@link RendererChangeEvent} to all registered
* listeners.
*
* @param filled the flag (<code>null</code> permitted).
*
* @see #setShapesFilled(boolean)
*/
public void setShapesFilled(Boolean filled) {
this.shapesFilled = filled;
fireChangeEvent();
}
/**
* Returns the flag used to control whether or not the shapes for a series
* are filled.
*
* @param series the series index (zero-based).
*
* @return A boolean.
*/
public Boolean getSeriesShapesFilled(int series) {
return this.seriesShapesFilled.getBoolean(series);
}
/**
* Sets the 'shapes filled' flag for a series.
*
* @param series the series index (zero-based).
* @param flag the flag.
*
* @see #getSeriesShapesFilled(int)
*/
public void setSeriesShapesFilled(int series, Boolean flag) {
this.seriesShapesFilled.setBoolean(series, flag);
fireChangeEvent();
}
/**
* Returns the base 'shape filled' attribute.
*
* @return The base flag.
*
* @see #setBaseShapesFilled(boolean)
*/
public boolean getBaseShapesFilled() {
return this.baseShapesFilled;
}
/**
* Sets the base 'shapes filled' flag.
*
* @param flag the flag.
*
* @see #getBaseShapesFilled()
*/
public void setBaseShapesFilled(boolean flag) {
this.baseShapesFilled = flag;
}
/**
* Returns true if lines are being plotted by the renderer.
*
* @return <code>true</code> if lines are being plotted by the renderer.
*
* @see #setPlotLines(boolean)
*/
public boolean getPlotLines() {
return this.plotLines;
}
/**
* Sets the flag that controls whether or not a line is plotted between
* each data point.
*
* @param flag the flag.
*
* @see #getPlotLines()
*/
public void setPlotLines(boolean flag) {
if (this.plotLines != flag) {
this.plotLines = flag;
notifyListeners(new RendererChangeEvent(this));
}
}
/**
* Returns the gap threshold type (relative or absolute).
*
* @return The type.
*
* @see #setGapThresholdType(UnitType)
*/
public UnitType getGapThresholdType() {
return this.gapThresholdType;
}
/**
* Sets the gap threshold type.
*
* @param thresholdType the type (<code>null</code> not permitted).
*
* @see #getGapThresholdType()
*/
public void setGapThresholdType(UnitType thresholdType) {
if (thresholdType == null) {
throw new IllegalArgumentException(
"Null 'thresholdType' argument.");
}
this.gapThresholdType = thresholdType;
notifyListeners(new RendererChangeEvent(this));
}
/**
* Returns the gap threshold for discontinuous lines.
*
* @return The gap threshold.
*
* @see #setGapThreshold(double)
*/
public double getGapThreshold() {
return this.gapThreshold;
}
/**
* Sets the gap threshold for discontinuous lines.
*
* @param t the threshold.
*
* @see #getGapThreshold()
*/
public void setGapThreshold(double t) {
this.gapThreshold = t;
notifyListeners(new RendererChangeEvent(this));
}
/**
* Returns true if images are being plotted by the renderer.
*
* @return <code>true</code> if images are being plotted by the renderer.
*
* @see #setPlotImages(boolean)
*/
public boolean getPlotImages() {
return this.plotImages;
}
/**
* Sets the flag that controls whether or not an image is drawn at each
* data point.
*
* @param flag the flag.
*
* @see #getPlotImages()
*/
public void setPlotImages(boolean flag) {
if (this.plotImages != flag) {
this.plotImages = flag;
notifyListeners(new RendererChangeEvent(this));
}
}
/**
* Returns a flag that controls whether or not the renderer shows
* discontinuous lines.
*
* @return <code>true</code> if lines should be discontinuous.
*/
public boolean getPlotDiscontinuous() {
return this.plotDiscontinuous;
}
/**
* Sets the flag that controls whether or not the renderer shows
* discontinuous lines, and sends a {@link RendererChangeEvent} to all
* registered listeners.
*
* @param flag the new flag value.
*
* @since 1.0.5
*/
public void setPlotDiscontinuous(boolean flag) {
if (this.plotDiscontinuous != flag) {
this.plotDiscontinuous = flag;
fireChangeEvent();
}
}
/**
* Returns a flag that controls whether or not each series is drawn as a
* single path.
*
* @return A boolean.
*
* @see #setDrawSeriesLineAsPath(boolean)
*/
public boolean getDrawSeriesLineAsPath() {
return this.drawSeriesLineAsPath;
}
/**
* Sets the flag that controls whether or not each series is drawn as a
* single path.
*
* @param flag the flag.
*
* @see #getDrawSeriesLineAsPath()
*/
public void setDrawSeriesLineAsPath(boolean flag) {
this.drawSeriesLineAsPath = flag;
}
/**
* Returns the shape used to represent a line in the legend.
*
* @return The legend line (never <code>null</code>).
*
* @see #setLegendLine(Shape)
*/
public Shape getLegendLine() {
return this.legendLine;
}
/**
* Sets the shape used as a line in each legend item and sends a
* {@link RendererChangeEvent} to all registered listeners.
*
* @param line the line (<code>null</code> not permitted).
*
* @see #getLegendLine()
*/
public void setLegendLine(Shape line) {
if (line == null) {
throw new IllegalArgumentException("Null 'line' argument.");
}
this.legendLine = line;
notifyListeners(new RendererChangeEvent(this));
}
/**
* Returns a legend item for a series.
*
* @param datasetIndex the dataset index (zero-based).
* @param series the series index (zero-based).
*
* @return A legend item for the series.
*/
public LegendItem getLegendItem(int datasetIndex, int series) {
XYPlot plot = getPlot();
if (plot == null) {
return null;
}
LegendItem result = null;
XYDataset dataset = plot.getDataset(datasetIndex);
if (dataset != null) {
if (getItemVisible(series, 0)) {
String label = getLegendItemLabelGenerator().generateLabel(
dataset, series);
String description = label;
String toolTipText = null;
if (getLegendItemToolTipGenerator() != null) {
toolTipText = getLegendItemToolTipGenerator().generateLabel(
dataset, series);
}
String urlText = null;
if (getLegendItemURLGenerator() != null) {
urlText = getLegendItemURLGenerator().generateLabel(
dataset, series);
}
Shape shape = lookupSeriesShape(series);
boolean shapeFilled = getItemShapeFilled(series, 0);
Paint paint = lookupSeriesPaint(series);
Paint linePaint = paint;
Stroke lineStroke = lookupSeriesStroke(series);
result = new LegendItem(label, description, toolTipText,
urlText, this.baseShapesVisible, shape, shapeFilled,
paint, !shapeFilled, paint, lineStroke,
this.plotLines, this.legendLine, lineStroke, linePaint);
result.setDataset(dataset);
result.setDatasetIndex(datasetIndex);
result.setSeriesKey(dataset.getSeriesKey(series));
result.setSeriesIndex(series);
}
}
return result;
}
/**
* Records the state for the renderer. This is used to preserve state
* information between calls to the drawItem() method for a single chart
* drawing.
*/
public static class State extends XYItemRendererState {
/** The path for the current series. */
public GeneralPath seriesPath;
/** The series index. */
private int seriesIndex;
/**
* A flag that indicates if the last (x, y) point was 'good'
* (non-null).
*/
private boolean lastPointGood;
/**
* Creates a new state instance.
*
* @param info the plot rendering info.
*/
public State(PlotRenderingInfo info) {
super(info);
}
/**
* Returns a flag that indicates if the last point drawn (in the
* current series) was 'good' (non-null).
*
* @return A boolean.
*/
public boolean isLastPointGood() {
return this.lastPointGood;
}
/**
* Sets a flag that indicates if the last point drawn (in the current
* series) was 'good' (non-null).
*
* @param good the flag.
*/
public void setLastPointGood(boolean good) {
this.lastPointGood = good;
}
/**
* Returns the series index for the current path.
*
* @return The series index for the current path.
*/
public int getSeriesIndex() {
return this.seriesIndex;
}
/**
* Sets the series index for the current path.
*
* @param index the index.
*/
public void setSeriesIndex(int index) {
this.seriesIndex = index;
}
}
/**
* Initialises the renderer.
* <P>
* This method will be called before the first item is rendered, giving the
* renderer an opportunity to initialise any state information it wants to
* maintain. The renderer can do nothing if it chooses.
*
* @param g2 the graphics device.
* @param dataArea the area inside the axes.
* @param plot the plot.
* @param data the data.
* @param info an optional info collection object to return data back to
* the caller.
*
* @return The renderer state.
*/
public XYItemRendererState initialise(Graphics2D g2,
Rectangle2D dataArea,
XYPlot plot,
XYDataset data,
PlotRenderingInfo info) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -