legenditem.java
来自「JFreeChart它主要是用来制作各种各样的图表」· Java 代码 · 共 813 行 · 第 1/2 页
JAVA
813 行
* @param line the line.
* @param lineStroke the stroke (<code>null</code> not permitted).
* @param linePaint the line paint (<code>null</code> not permitted).
*/
public LegendItem(AttributedString label, String description,
String toolTipText, String urlText,
boolean shapeVisible, Shape shape,
boolean shapeFilled, Paint fillPaint,
boolean shapeOutlineVisible, Paint outlinePaint,
Stroke outlineStroke,
boolean lineVisible, Shape line, Stroke lineStroke,
Paint linePaint) {
if (label == null) {
throw new IllegalArgumentException("Null 'label' argument.");
}
if (fillPaint == null) {
throw new IllegalArgumentException("Null 'fillPaint' argument.");
}
if (lineStroke == null) {
throw new IllegalArgumentException("Null 'lineStroke' argument.");
}
if (outlinePaint == null) {
throw new IllegalArgumentException("Null 'outlinePaint' argument.");
}
if (outlineStroke == null) {
throw new IllegalArgumentException(
"Null 'outlineStroke' argument.");
}
this.label = characterIteratorToString(label.getIterator());
this.attributedLabel = label;
this.description = description;
this.shapeVisible = shapeVisible;
this.shape = shape;
this.shapeFilled = shapeFilled;
this.fillPaint = fillPaint;
this.shapeOutlineVisible = shapeOutlineVisible;
this.outlinePaint = outlinePaint;
this.outlineStroke = outlineStroke;
this.lineVisible = lineVisible;
this.line = line;
this.lineStroke = lineStroke;
this.linePaint = linePaint;
this.toolTipText = toolTipText;
this.urlText = urlText;
}
/**
* Returns a string containing the characters from the given iterator.
*
* @param iterator the iterator (<code>null</code> not permitted).
*
* @return A string.
*/
private String characterIteratorToString(CharacterIterator iterator) {
int endIndex = iterator.getEndIndex();
int beginIndex = iterator.getBeginIndex();
int count = endIndex - beginIndex;
if (count <= 0) {
return "";
}
char[] chars = new char[count];
int i = 0;
char c = iterator.first();
while (c != CharacterIterator.DONE) {
chars[i] = c;
i++;
c = iterator.next();
}
return new String(chars);
}
/**
* Returns the dataset index for this legend item.
*
* @return The dataset index.
*
* @since 1.0.2
*/
public int getDatasetIndex() {
return this.datasetIndex;
}
/**
* Sets the dataset index for this legend item.
*
* @param index the index.
*
* @since 1.0.2
*/
public void setDatasetIndex(int index) {
this.datasetIndex = index;
}
/**
* Returns the series index for this legend item.
*
* @return The series index.
*
* @since 1.0.2
*/
public int getSeriesIndex() {
return this.series;
}
/**
* Sets the series index for this legend item.
*
* @param index the index.
*
* @since 1.0.2
*/
public void setSeriesIndex(int index) {
this.series = index;
}
/**
* Returns the label.
*
* @return The label (never <code>null</code>).
*/
public String getLabel() {
return this.label;
}
/**
* Returns the attributed label.
*
* @return The attributed label (possibly <code>null</code>).
*/
public AttributedString getAttributedLabel() {
return this.attributedLabel;
}
/**
* Returns the description for the legend item.
*
* @return The description.
*/
public String getDescription() {
return this.description;
}
/**
* Returns the tool tip text.
*
* @return The tool tip text (possibly <code>null</code>).
*/
public String getToolTipText() {
return this.toolTipText;
}
/**
* Returns the URL text.
*
* @return The URL text (possibly <code>null</code>).
*/
public String getURLText() {
return this.urlText;
}
/**
* Returns a flag that indicates whether or not the shape is visible.
*
* @return A boolean.
*/
public boolean isShapeVisible() {
return this.shapeVisible;
}
/**
* Returns the shape used to label the series represented by this legend
* item.
*
* @return The shape (never <code>null</code>).
*/
public Shape getShape() {
return this.shape;
}
/**
* Returns a flag that controls whether or not the shape is filled.
*
* @return A boolean.
*/
public boolean isShapeFilled() {
return this.shapeFilled;
}
/**
* Returns the fill paint.
*
* @return The fill paint (never <code>null</code>).
*/
public Paint getFillPaint() {
return this.fillPaint;
}
/**
* Returns the flag that controls whether or not the shape outline
* is visible.
*
* @return A boolean.
*/
public boolean isShapeOutlineVisible() {
return this.shapeOutlineVisible;
}
/**
* Returns the line stroke for the series.
*
* @return The stroke (never <code>null</code>).
*/
public Stroke getLineStroke() {
return this.lineStroke;
}
/**
* Returns the paint used for lines.
*
* @return The paint.
*/
public Paint getLinePaint() {
return this.linePaint;
}
/**
* Returns the outline paint.
*
* @return The outline paint (never <code>null</code>).
*/
public Paint getOutlinePaint() {
return this.outlinePaint;
}
/**
* Returns the outline stroke.
*
* @return The outline stroke (never <code>null</code>).
*/
public Stroke getOutlineStroke() {
return this.outlineStroke;
}
/**
* Returns a flag that indicates whether or not the line is visible.
*
* @return A boolean.
*/
public boolean isLineVisible() {
return this.lineVisible;
}
/**
* Returns the line.
*
* @return The line.
*/
public Shape getLine() {
return this.line;
}
/**
* Returns the transformer used when the fill paint is an instance of
* <code>GradientPaint</code>.
*
* @return The transformer (never <code>null</code>).
*
* @since 1.0.4
*
* @see #setFillPaintTransformer(GradientPaintTransformer)
*/
public GradientPaintTransformer getFillPaintTransformer() {
return this.fillPaintTransformer;
}
/**
* Sets the transformer used when the fill paint is an instance of
* <code>GradientPaint</code>.
*
* @param transformer the transformer (<code>null</code> not permitted).
*
* @since 1.0.4
*
* @see #getFillPaintTransformer()
*/
public void setFillPaintTransformer(GradientPaintTransformer transformer) {
if (transformer == null) {
throw new IllegalArgumentException("Null 'transformer' attribute.");
}
this.fillPaintTransformer = transformer;
}
/**
* Tests this item for equality with an arbitrary object.
*
* @param obj the object (<code>null</code> permitted).
*
* @return A boolean.
*/
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof LegendItem)) {
return false;
}
LegendItem that = (LegendItem) obj;
if (this.datasetIndex != that.datasetIndex) {
return false;
}
if (this.series != that.series) {
return false;
}
if (!this.label.equals(that.label)) {
return false;
}
if (!AttributedStringUtilities.equal(this.attributedLabel,
that.attributedLabel)) {
return false;
}
if (!ObjectUtilities.equal(this.description, that.description)) {
return false;
}
if (this.shapeVisible != that.shapeVisible) {
return false;
}
if (!ShapeUtilities.equal(this.shape, that.shape)) {
return false;
}
if (this.shapeFilled != that.shapeFilled) {
return false;
}
if (!this.fillPaint.equals(that.fillPaint)) {
return false;
}
if (!ObjectUtilities.equal(this.fillPaintTransformer,
that.fillPaintTransformer)) {
return false;
}
if (this.shapeOutlineVisible != that.shapeOutlineVisible) {
return false;
}
if (!this.outlineStroke.equals(that.outlineStroke)) {
return false;
}
if (!this.outlinePaint.equals(that.outlinePaint)) {
return false;
}
if (!this.lineVisible == that.lineVisible) {
return false;
}
if (!ShapeUtilities.equal(this.line, that.line)) {
return false;
}
if (!this.lineStroke.equals(that.lineStroke)) {
return false;
}
if (!this.linePaint.equals(that.linePaint)) {
return false;
}
return true;
}
/**
* Provides serialization support.
*
* @param stream the output stream (<code>null</code> not permitted).
*
* @throws IOException if there is an I/O error.
*/
private void writeObject(ObjectOutputStream stream) throws IOException {
stream.defaultWriteObject();
SerialUtilities.writeAttributedString(this.attributedLabel, stream);
SerialUtilities.writeShape(this.shape, stream);
SerialUtilities.writePaint(this.fillPaint, stream);
SerialUtilities.writeStroke(this.outlineStroke, stream);
SerialUtilities.writePaint(this.outlinePaint, stream);
SerialUtilities.writeShape(this.line, stream);
SerialUtilities.writeStroke(this.lineStroke, stream);
SerialUtilities.writePaint(this.linePaint, stream);
}
/**
* Provides serialization support.
*
* @param stream the input stream (<code>null</code> not permitted).
*
* @throws IOException if there is an I/O error.
* @throws ClassNotFoundException if there is a classpath problem.
*/
private void readObject(ObjectInputStream stream)
throws IOException, ClassNotFoundException {
stream.defaultReadObject();
this.attributedLabel = SerialUtilities.readAttributedString(stream);
this.shape = SerialUtilities.readShape(stream);
this.fillPaint = SerialUtilities.readPaint(stream);
this.outlineStroke = SerialUtilities.readStroke(stream);
this.outlinePaint = SerialUtilities.readPaint(stream);
this.line = SerialUtilities.readShape(stream);
this.lineStroke = SerialUtilities.readStroke(stream);
this.linePaint = SerialUtilities.readPaint(stream);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?