📄 pieplot.java
字号:
if (autoPopulate) {
DrawingSupplier ds = getDrawingSupplier();
if (ds != null) {
result = ds.getNextOutlinePaint();
this.sectionOutlinePaintMap.put(key, result);
}
else {
result = this.baseSectionOutlinePaint;
}
}
else {
result = this.baseSectionOutlinePaint;
}
return result;
}
/**
* Returns the outline paint associated with the specified key, or
* <code>null</code> if there is no paint associated with the key.
*
* @param key the key (<code>null</code> not permitted).
*
* @return The paint associated with the specified key, or
* <code>null</code>.
*
* @throws IllegalArgumentException if <code>key</code> is
* <code>null</code>.
*
* @see #setSectionOutlinePaint(Comparable, Paint)
*
* @since 1.0.3
*/
public Paint getSectionOutlinePaint(Comparable key) {
// null argument check delegated...
return this.sectionOutlinePaintMap.getPaint(key);
}
/**
* Sets the outline paint associated with the specified key, and sends a
* {@link PlotChangeEvent} to all registered listeners.
*
* @param key the key (<code>null</code> not permitted).
* @param paint the paint.
*
* @throws IllegalArgumentException if <code>key</code> is
* <code>null</code>.
*
* @see #getSectionOutlinePaint(Comparable)
*
* @since 1.0.3
*/
public void setSectionOutlinePaint(Comparable key, Paint paint) {
// null argument check delegated...
this.sectionOutlinePaintMap.put(key, paint);
fireChangeEvent();
}
/**
* Clears the section outline paint settings for this plot and, if
* requested, sends a {@link PlotChangeEvent} to all registered listeners.
* Be aware that if the <code>autoPopulateSectionPaint</code> flag is set,
* the section paints may be repopulated using the same colours as before.
*
* @param notify notify listeners?
*
* @since 1.0.11
*
* @see #autoPopulateSectionOutlinePaint
*/
public void clearSectionOutlinePaints(boolean notify) {
this.sectionOutlinePaintMap.clear();
if (notify) {
fireChangeEvent();
}
}
/**
* Returns the base section paint. This is used when no other paint is
* available.
*
* @return The paint (never <code>null</code>).
*
* @see #setBaseSectionOutlinePaint(Paint)
*/
public Paint getBaseSectionOutlinePaint() {
return this.baseSectionOutlinePaint;
}
/**
* 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;
fireChangeEvent();
}
/**
* Returns the flag that controls whether or not the section outline paint
* is auto-populated by the {@link #lookupSectionOutlinePaint(Comparable)}
* method.
*
* @return A boolean.
*
* @since 1.0.11
*/
public boolean getAutoPopulateSectionOutlinePaint() {
return this.autoPopulateSectionOutlinePaint;
}
/**
* Sets the flag that controls whether or not the section outline paint is
* auto-populated by the {@link #lookupSectionOutlinePaint(Comparable)}
* method, and sends a {@link PlotChangeEvent} to all registered listeners.
*
* @param auto auto-populate?
*
* @since 1.0.11
*/
public void setAutoPopulateSectionOutlinePaint(boolean auto) {
this.autoPopulateSectionOutlinePaint = auto;
fireChangeEvent();
}
//// SECTION OUTLINE STROKE ///////////////////////////////////////////////
/**
* Returns the outline stroke for the specified section. This is
* equivalent to <code>lookupSectionOutlineStroke(section,
* getAutoPopulateSectionOutlineStroke())</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,
getAutoPopulateSectionOutlineStroke());
}
/**
* 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 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);
fireChangeEvent();
}
/**
* Clears the section outline stroke settings for this plot and, if
* requested, sends a {@link PlotChangeEvent} to all registered listeners.
* Be aware that if the <code>autoPopulateSectionPaint</code> flag is set,
* the section paints may be repopulated using the same colours as before.
*
* @param notify notify listeners?
*
* @since 1.0.11
*
* @see #autoPopulateSectionOutlineStroke
*/
public void clearSectionOutlineStrokes(boolean notify) {
this.sectionOutlineStrokeMap.clear();
if (notify) {
fireChangeEvent();
}
}
/**
* 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;
fireChangeEvent();
}
/**
* Returns the flag that controls whether or not the section outline stroke
* is auto-populated by the {@link #lookupSectionOutlinePaint(Comparable)}
* method.
*
* @return A boolean.
*
* @since 1.0.11
*/
public boolean getAutoPopulateSectionOutlineStroke() {
return this.autoPopulateSectionOutlineStroke;
}
/**
* Sets the flag that controls whether or not the section outline stroke is
* auto-populated by the {@link #lookupSectionOutlineStroke(Comparable)}
* method, and sends a {@link PlotChangeEvent} to all registered listeners.
*
* @param auto auto-populate?
*
* @since 1.0.11
*/
public void setAutoPopulateSectionOutlineStroke(boolean auto) {
this.autoPopulateSectionOutlineStroke = auto;
fireChangeEvent();
}
/**
* 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;
fireChangeEvent();
}
/**
* 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;
fireChangeEvent();
}
/**
* 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;
fireChangeEvent();
}
/**
* Returns the amount that the section with the specified key should be
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -