📄 abstractrenderer.java
字号:
}
this.baseItemLabelPaint = paint;
if (notify) {
notifyListeners(new RendererChangeEvent(this));
}
}
// POSITIVE ITEM LABEL POSITION...
/**
* Returns the item label position for positive values.
*
* @param row the row index (zero-based).
* @param column the column index (zero-based).
*
* @return The item label position (never <code>null</code>).
*/
public ItemLabelPosition getPositiveItemLabelPosition(int row, int column) {
return getSeriesPositiveItemLabelPosition(row);
}
/**
* Returns the item label position for positive values in ALL series.
*
* @return The item label position (possibly <code>null</code>).
*/
public ItemLabelPosition getPositiveItemLabelPosition() {
return this.positiveItemLabelPosition;
}
/**
* Sets the item label position for positive values in ALL series, and sends a
* {@link RendererChangeEvent} to all registered listeners. You need to set this to
* <code>null</code> to expose the settings for individual series.
*
* @param position the position (<code>null</code> permitted).
*/
public void setPositiveItemLabelPosition(ItemLabelPosition position) {
setPositiveItemLabelPosition(position, true);
}
/**
* Sets the positive item label position for ALL series and (if requested) sends a
* {@link RendererChangeEvent} to all registered listeners.
*
* @param position the position (<code>null</code> permitted).
* @param notify notify registered listeners?
*/
public void setPositiveItemLabelPosition(ItemLabelPosition position, boolean notify) {
this.positiveItemLabelPosition = position;
if (notify) {
notifyListeners(new RendererChangeEvent(this));
}
}
/**
* Returns the item label position for all positive values in a series.
*
* @param series the series index (zero-based).
*
* @return The item label position (never <code>null</code>).
*/
public ItemLabelPosition getSeriesPositiveItemLabelPosition(int series) {
// return the override, if there is one...
if (this.positiveItemLabelPosition != null) {
return this.positiveItemLabelPosition;
}
// otherwise look up the position table
ItemLabelPosition position
= (ItemLabelPosition) this.positiveItemLabelPositionList.get(series);
if (position == null) {
position = this.basePositiveItemLabelPosition;
}
return position;
}
/**
* Sets the item label position for all positive values in a series and sends a
* {@link RendererChangeEvent} to all registered listeners.
*
* @param series the series index (zero-based).
* @param position the position (<code>null</code> permitted).
*/
public void setSeriesPositiveItemLabelPosition(int series, ItemLabelPosition position) {
setSeriesPositiveItemLabelPosition(series, position, true);
}
/**
* Sets the item label position for all positive values in a series and (if requested) sends a
* {@link RendererChangeEvent} to all registered listeners.
*
* @param series the series index (zero-based).
* @param position the position (<code>null</code> permitted).
* @param notify notify registered listeners?
*/
public void setSeriesPositiveItemLabelPosition(int series, ItemLabelPosition position,
boolean notify) {
this.positiveItemLabelPositionList.set(series, position);
if (notify) {
notifyListeners(new RendererChangeEvent(this));
}
}
/**
* Returns the base positive item label position.
*
* @return The position (never <code>null</code>).
*/
public ItemLabelPosition getBasePositiveItemLabelPosition() {
return this.basePositiveItemLabelPosition;
}
/**
* Sets the base positive item label position.
*
* @param position the position (<code>null</code> not permitted).
*/
public void setBasePositiveItemLabelPosition(ItemLabelPosition position) {
// defer argument checking...
setBasePositiveItemLabelPosition(position, true);
}
/**
* Sets the base positive item label position and, if requested, sends a
* {@link RendererChangeEvent} to all registered listeners.
*
* @param position the position (<code>null</code> not permitted).
* @param notify notify registered listeners?
*/
public void setBasePositiveItemLabelPosition(ItemLabelPosition position, boolean notify) {
if (position == null) {
throw new IllegalArgumentException("Null 'position' argument.");
}
this.basePositiveItemLabelPosition = position;
if (notify) {
notifyListeners(new RendererChangeEvent(this));
}
}
// NEGATIVE ITEM LABEL POSITION...
/**
* Returns the item label position for negative values. This method can be overridden to
* provide customisation of the item label position for individual data items.
*
* @param row the row index (zero-based).
* @param column the column (zero-based).
*
* @return The item label position (never <code>null</code>).
*/
public ItemLabelPosition getNegativeItemLabelPosition(int row, int column) {
return getSeriesNegativeItemLabelPosition(row);
}
/**
* Returns the item label position for negative values in ALL series.
*
* @return the item label position (possibly <code>null</code>).
*/
public ItemLabelPosition getNegativeItemLabelPosition() {
return this.negativeItemLabelPosition;
}
/**
* Sets the item label position for negative values in ALL series, and sends a
* {@link RendererChangeEvent} to all registered listeners. You need to set this to
* <code>null</code> to expose the settings for individual series.
*
* @param position the position (<code>null</code> permitted).
*/
public void setNegativeItemLabelPosition(ItemLabelPosition position) {
setNegativeItemLabelPosition(position, true);
}
/**
* Sets the item label position for negative values in ALL series and (if requested) sends
* a {@link RendererChangeEvent} to all registered listeners.
*
* @param position the position (<code>null</code> permitted).
* @param notify notify registered listeners?
*/
public void setNegativeItemLabelPosition(ItemLabelPosition position, boolean notify) {
this.negativeItemLabelPosition = position;
if (notify) {
notifyListeners(new RendererChangeEvent(this));
}
}
/**
* Returns the item label position for all negative values in a series.
*
* @param series the series index (zero-based).
*
* @return The item label position (never <code>null</code>).
*/
public ItemLabelPosition getSeriesNegativeItemLabelPosition(int series) {
// return the override, if there is one...
if (this.negativeItemLabelPosition != null) {
return this.negativeItemLabelPosition;
}
// otherwise look up the position list
ItemLabelPosition position
= (ItemLabelPosition) this.negativeItemLabelPositionList.get(series);
if (position == null) {
position = this.baseNegativeItemLabelPosition;
}
return position;
}
/**
* Sets the item label position for negative values in a series and sends a
* {@link RendererChangeEvent} to all registered listeners.
*
* @param series the series index (zero-based).
* @param position the position (<code>null</code> permitted).
*/
public void setSeriesNegativeItemLabelPosition(int series, ItemLabelPosition position) {
setSeriesNegativeItemLabelPosition(series, position, true);
}
/**
* Sets the item label position for negative values in a series and (if requested) sends a.
* {@link RendererChangeEvent} to all registered listeners.
*
* @param series the series index (zero-based).
* @param position the position (<code>null</code> permitted).
* @param notify notify registered listeners?
*/
public void setSeriesNegativeItemLabelPosition(int series, ItemLabelPosition position,
boolean notify) {
this.negativeItemLabelPositionList.set(series, position);
if (notify) {
notifyListeners(new RendererChangeEvent(this));
}
}
/**
* Returns the base item label position for negative values.
*
* @return The position (never <code>null</code>).
*/
public ItemLabelPosition getBaseNegativeItemLabelPosition() {
return this.baseNegativeItemLabelPosition;
}
/**
* Sets the base item label position for negative values and sends a
* {@link RendererChangeEvent} to all registered listeners.
*
* @param position the position (<code>null</code> not permitted).
*/
public void setBaseNegativeItemLabelPosition(ItemLabelPosition position) {
setBaseNegativeItemLabelPosition(position, true);
}
/**
* Sets the base negative item label position and, if requested, sends a
* {@link RendererChangeEvent} to all registered listeners.
*
* @param position the position (<code>null</code> not permitted).
* @param notify notify registered listeners?
*/
public void setBaseNegativeItemLabelPosition(ItemLabelPosition position, boolean notify) {
if (position == null) {
throw new IllegalArgumentException("Null 'position' argument.");
}
this.baseNegativeItemLabelPosition = position;
if (notify) {
notifyListeners(new RendererChangeEvent(this));
}
}
/**
* Returns the item label anchor offset.
*
* @return the offset.
*/
public double getItemLabelAnchorOffset() {
return this.itemLabelAnchorOffset;
}
/**
* Sets the item label anchor offset.
*
* @param offset the offset.
*/
public void setItemLabelAnchorOffset(double offset) {
this.itemLabelAnchorOffset = offset;
notifyListeners(new RendererChangeEvent(this));
}
/** The adjacent offset. */
private static final double ADJ = Math.cos(Math.PI / 6.0);
/** The opposite offset. */
private static final double OPP = Math.sin(Math.PI / 6.0);
/**
* Calculates the item label anchor point.
*
* @param anchor the anchor.
* @param x the x coordinate.
* @param y the y coordinate.
* @param orientation the plot orientation.
*
* @return the anchor point (never <code>null</code>).
*/
protected Point2D calculateLabelAnchorPoint(ItemLabelAnchor anchor,
double x,
double y,
PlotOrientation orientation) {
Point2D result = null;
if (anchor == ItemLabelAnchor.CENTER) {
result = new Point2D.Double(x, y);
}
else if (anchor == ItemLabelAnchor.INSIDE1) {
result = new Point2D.Double(
x + OPP * this.itemLabelAnchorOffset, y - ADJ * this.itemLabelAnchorOffset
);
}
else if (anchor == ItemLabelAnchor.INSIDE2) {
result = new Point2D.Double(
x + ADJ * this.itemLabelAnchorOffset, y - OPP * this.itemLabelAnchorOffset
);
}
else if (anchor == ItemLabelAnchor.INSIDE3) {
result = new Point2D.Double(x + this.itemLabelAnchorOffset, y);
}
else if (anchor == ItemLabelAnchor.INSIDE4) {
result = new Point2D.Double(
x + ADJ * this.itemLabelAnchorOffset, y + OPP * this.itemLabelAnchorOffset
);
}
else if (anchor == ItemLabelAnchor.INSIDE5) {
result = new Point2D.Double(
x + OPP * this.itemLabelAnchorOffset, y + ADJ * this.itemLabelAnchorOffset
);
}
else if (anchor == ItemLabelAnchor.INSIDE6) {
result = new Point2D.Double(x, y + this.itemLabelAnchorOffset);
}
else if (anchor == ItemLabelAnchor.INSIDE7) {
result = new Point2D.Double(
x - OPP * this.itemLabelAnchorOffset, y + ADJ * this.itemLabelAnchorOffset
);
}
else if (anchor == ItemLabelAnchor.INSIDE8) {
result = new Point2D.Double(
x - ADJ * this.itemLabelAnchorOffset, y + OPP * this.itemLabelAnchorOffset
);
}
else if (anchor == ItemLabelAnchor.INSIDE9) {
result = new Point2D.Double(x - this.itemLabelAnchorOffset, y);
}
else if (anchor == ItemLabelAnchor.INSIDE10) {
result = new Point2D.Double(
x - ADJ * this.itemLabelAnchorOffset, y - OPP * this.itemLabelAnchorOffset
);
}
else if (anchor == ItemLabelAnchor.INSIDE11) {
result = new Point2D.Double(
x - OPP * this.itemLabelAnchorOffset, y - ADJ * this.itemLabelAnchorOffset
);
}
else if (anchor == ItemLabelAnchor.INSIDE12) {
result = new Point2D.Double(x, y - this.it
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -