📄 pieplot.java
字号:
/**
* Sets the base section paint.
*
* @param paint the paint (<code>null</code> not permitted).
*
* @see #getBaseSectionOutlinePaint()
*/
public void setBaseSectionOutlinePaint(Paint paint) {
if (paint == null) {
throw new IllegalArgumentException("Null 'paint' argument.");
}
this.baseSectionOutlinePaint = paint;
notifyListeners(new PlotChangeEvent(this));
}
//// SECTION OUTLINE STROKE ///////////////////////////////////////////////
/**
* Returns the outline stroke for the specified section. This is equivalent
* to <code>lookupSectionOutlineStroke(section, false)</code>.
*
* @param key the section key.
*
* @return The stroke for the specified section.
*
* @since 1.0.3
*
* @see #lookupSectionOutlineStroke(Comparable, boolean)
*/
protected Stroke lookupSectionOutlineStroke(Comparable key) {
return lookupSectionOutlineStroke(key, false);
}
/**
* Returns the outline stroke for the specified section. The lookup
* involves these steps:
* <ul>
* <li>if {@link #getSectionOutlineStroke()} is non-<code>null</code>,
* return it;</li>
* <li>otherwise, if {@link #getSectionOutlineStroke(int)} is
* non-<code>null</code> return it;</li>
* <li>if {@link #getSectionOutlineStroke(int)} is <code>null</code> but
* <code>autoPopulate</code> is <code>true</code>, attempt to fetch
* a new outline stroke from the drawing supplier
* ({@link #getDrawingSupplier()});
* <li>if all else fails, return {@link #getBaseSectionOutlineStroke()}.
* </ul>
*
* @param key the section key.
* @param autoPopulate a flag that controls whether the drawing supplier
* is used to auto-populate the section outline stroke settings.
*
* @return The stroke.
*
* @since 1.0.3
*/
protected Stroke lookupSectionOutlineStroke(Comparable key,
boolean autoPopulate) {
// is there an override?
Stroke result = getSectionOutlineStroke();
if (result != null) {
return result;
}
// if not, check if there is a stroke defined for the specified key
result = this.sectionOutlineStrokeMap.getStroke(key);
if (result != null) {
return result;
}
// nothing defined - do we autoPopulate?
if (autoPopulate) {
DrawingSupplier ds = getDrawingSupplier();
if (ds != null) {
result = ds.getNextOutlineStroke();
this.sectionOutlineStrokeMap.put(key, result);
}
else {
result = this.baseSectionOutlineStroke;
}
}
else {
result = this.baseSectionOutlineStroke;
}
return result;
}
/**
* Returns the outline stroke for ALL sections in the plot.
*
* @return The stroke (possibly <code>null</code>).
*
* @see #setSectionOutlineStroke(Stroke)
*
* @deprecated Use {@link #getSectionOutlineStroke(Comparable)} and
* {@link #getBaseSectionOutlineStroke()}. Deprecated as of version
* 1.0.6.
*/
public Stroke getSectionOutlineStroke() {
return this.sectionOutlineStroke;
}
/**
* Sets the outline stroke for ALL sections in the plot. If this is set to
* </code>null</code>, then a list of paints is used instead (to allow
* different colors to be used for each section).
*
* @param stroke the stroke (<code>null</code> permitted).
*
* @see #getSectionOutlineStroke()
*
* @deprecated Use {@link #setSectionOutlineStroke(Comparable, Stroke)} and
* {@link #setBaseSectionOutlineStroke(Stroke)}. Deprecated as of
* version 1.0.6.
*/
public void setSectionOutlineStroke(Stroke stroke) {
this.sectionOutlineStroke = stroke;
notifyListeners(new PlotChangeEvent(this));
}
/**
* Returns the outline stroke associated with the specified key, or
* <code>null</code> if there is no stroke associated with the key.
*
* @param key the key (<code>null</code> not permitted).
*
* @return The stroke associated with the specified key, or
* <code>null</code>.
*
* @throws IllegalArgumentException if <code>key</code> is
* <code>null</code>.
*
* @see #setSectionOutlineStroke(Comparable, Stroke)
*
* @since 1.0.3
*/
public Stroke getSectionOutlineStroke(Comparable key) {
// null argument check delegated...
return this.sectionOutlineStrokeMap.getStroke(key);
}
/**
* Sets the outline stroke associated with the specified key, and sends a
* {@link PlotChangeEvent} to all registered listeners.
*
* @param key the key (<code>null</code> not permitted).
* @param stroke the stroke.
*
* @throws IllegalArgumentException if <code>key</code> is
* <code>null</code>.
*
* @see #getSectionOutlineStroke(Comparable)
*
* @since 1.0.3
*/
public void setSectionOutlineStroke(Comparable key, Stroke stroke) {
// null argument check delegated...
this.sectionOutlineStrokeMap.put(key, stroke);
notifyListeners(new PlotChangeEvent(this));
}
/**
* Returns the base section stroke. This is used when no other stroke is
* available.
*
* @return The stroke (never <code>null</code>).
*
* @see #setBaseSectionOutlineStroke(Stroke)
*/
public Stroke getBaseSectionOutlineStroke() {
return this.baseSectionOutlineStroke;
}
/**
* Sets the base section stroke.
*
* @param stroke the stroke (<code>null</code> not permitted).
*
* @see #getBaseSectionOutlineStroke()
*/
public void setBaseSectionOutlineStroke(Stroke stroke) {
if (stroke == null) {
throw new IllegalArgumentException("Null 'stroke' argument.");
}
this.baseSectionOutlineStroke = stroke;
notifyListeners(new PlotChangeEvent(this));
}
/**
* Returns the shadow paint.
*
* @return The paint (possibly <code>null</code>).
*
* @see #setShadowPaint(Paint)
*/
public Paint getShadowPaint() {
return this.shadowPaint;
}
/**
* Sets the shadow paint and sends a {@link PlotChangeEvent} to all
* registered listeners.
*
* @param paint the paint (<code>null</code> permitted).
*
* @see #getShadowPaint()
*/
public void setShadowPaint(Paint paint) {
this.shadowPaint = paint;
notifyListeners(new PlotChangeEvent(this));
}
/**
* Returns the x-offset for the shadow effect.
*
* @return The offset (in Java2D units).
*
* @see #setShadowXOffset(double)
*/
public double getShadowXOffset() {
return this.shadowXOffset;
}
/**
* Sets the x-offset for the shadow effect and sends a
* {@link PlotChangeEvent} to all registered listeners.
*
* @param offset the offset (in Java2D units).
*
* @see #getShadowXOffset()
*/
public void setShadowXOffset(double offset) {
this.shadowXOffset = offset;
notifyListeners(new PlotChangeEvent(this));
}
/**
* Returns the y-offset for the shadow effect.
*
* @return The offset (in Java2D units).
*
* @see #setShadowYOffset(double)
*/
public double getShadowYOffset() {
return this.shadowYOffset;
}
/**
* Sets the y-offset for the shadow effect and sends a
* {@link PlotChangeEvent} to all registered listeners.
*
* @param offset the offset (in Java2D units).
*
* @see #getShadowYOffset()
*/
public void setShadowYOffset(double offset) {
this.shadowYOffset = offset;
notifyListeners(new PlotChangeEvent(this));
}
/**
* Returns the amount that the section with the specified key should be
* exploded.
*
* @param key the key (<code>null</code> not permitted).
*
* @return The amount that the section with the specified key should be
* exploded.
*
* @throws IllegalArgumentException if <code>key</code> is
* <code>null</code>.
*
* @since 1.0.3
*
* @see #setExplodePercent(Comparable, double)
*/
public double getExplodePercent(Comparable key) {
double result = 0.0;
if (this.explodePercentages != null) {
Number percent = (Number) this.explodePercentages.get(key);
if (percent != null) {
result = percent.doubleValue();
}
}
return result;
}
/**
* Sets the amount that a pie section should be exploded and sends a
* {@link PlotChangeEvent} to all registered listeners.
*
* @param key the section key (<code>null</code> not permitted).
* @param percent the explode percentage (0.30 = 30 percent).
*
* @since 1.0.3
*
* @see #getExplodePercent(Comparable)
*/
public void setExplodePercent(Comparable key, double percent) {
if (key == null) {
throw new IllegalArgumentException("Null 'key' argument.");
}
if (this.explodePercentages == null) {
this.explodePercentages = new TreeMap();
}
this.explodePercentages.put(key, new Double(percent));
notifyListeners(new PlotChangeEvent(this));
}
/**
* Returns the maximum explode percent.
*
* @return The percent.
*/
public double getMaximumExplodePercent() {
double result = 0.0;
Iterator iterator = this.dataset.getKeys().iterator();
while (iterator.hasNext()) {
Comparable key = (Comparable) iterator.next();
Number explode = (Number) this.explodePercentages.get(key);
if (explode != null) {
result = Math.max(result, explode.doubleValue());
}
}
return result;
}
/**
* Returns the section label generator.
*
* @return The generator (possibly <code>null</code>).
*
* @see #setLabelGenerator(PieSectionLabelGenerator)
*/
public PieSectionLabelGenerator getLabelGenerator() {
return this.labelGenerator;
}
/**
* Sets the section label generator and sends a {@link PlotChangeEvent} to
* all registered listeners.
*
* @param generator the generator (<code>null</code> permitted).
*
* @see #getLabelGenerator()
*/
public void setLabelGenerator(PieSectionLabelGenerator generator) {
this.labelGenerator = generator;
notifyListeners(new PlotChangeEvent(this));
}
/**
* Returns the gap between the edge of the pie and the labels, expressed as
* a percentage of the plot width.
*
* @return The gap (a percentage, where 0.05 = five percent).
*
* @see #setLabelGap(double)
*/
public double getLabelGap() {
return this.labelGap;
}
/**
* Sets the gap between the edge of the pie and the labels (expressed as a
* percentage of the plot width) and sends a {@link PlotChangeEvent} to all
* registered listeners.
*
* @param gap the gap (a percentage, where 0.05 = five percent).
*
* @see #getLabelGap()
*/
public void setLabelGap(double gap) {
this.labelGap = gap;
notifyListeners(new PlotChangeEvent(this));
}
/**
* Returns the maximum label width as a percentage of the plot width.
*
* @return The width (a percentage, where 0.20 = 20 percent).
*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -