| Constructor: |
public LabelBlock(String label) {
this(label, new Font("SansSerif", Font.PLAIN, 10), DEFAULT_PAINT);
}
Creates a new label block. Parameters:
label - the label (null not permitted).
|
public LabelBlock(String text,
Font font) {
this(text, font, DEFAULT_PAINT);
}
Creates a new label block. Parameters:
text - the text for the label (null not permitted).
font - the font (null not permitted).
|
public LabelBlock(String text,
Font font,
Paint paint) {
this.text = text;
this.paint = paint;
this.label = TextUtilities.createTextBlock(text, font, this.paint);
this.font = font;
this.toolTipText = null;
this.urlText = null;
}
Creates a new label block. Parameters:
text - the text for the label (null not permitted).
font - the font (null not permitted).
paint - the paint (null not permitted).
|
| Method from org.jfree.chart.block.LabelBlock Detail: |
public Size2D arrange(Graphics2D g2,
RectangleConstraint constraint) {
g2.setFont(this.font);
Size2D s = this.label.calculateDimensions(g2);
return new Size2D(calculateTotalWidth(s.getWidth()),
calculateTotalHeight(s.getHeight()));
}
Arranges the contents of the block, within the given constraints, and
returns the block size. |
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
Returns a clone of this LabelBlock instance. |
public void draw(Graphics2D g2,
Rectangle2D area) {
draw(g2, area, null);
}
|
public Object draw(Graphics2D g2,
Rectangle2D area,
Object params) {
area = trimMargin(area);
drawBorder(g2, area);
area = trimBorder(area);
area = trimPadding(area);
// check if we need to collect chart entities from the container
EntityBlockParams ebp = null;
StandardEntityCollection sec = null;
Shape entityArea = null;
if (params instanceof EntityBlockParams) {
ebp = (EntityBlockParams) params;
if (ebp.getGenerateEntities()) {
sec = new StandardEntityCollection();
entityArea = (Shape) area.clone();
}
}
g2.setPaint(this.paint);
g2.setFont(this.font);
this.label.draw(g2, (float) area.getX(), (float) area.getY(),
TextBlockAnchor.TOP_LEFT);
BlockResult result = null;
if (ebp != null && sec != null) {
if (this.toolTipText != null || this.urlText != null) {
ChartEntity entity = new ChartEntity(entityArea,
this.toolTipText, this.urlText);
sec.add(entity);
result = new BlockResult();
result.setEntityCollection(sec);
}
}
return result;
}
Draws the block within the specified area. |
public boolean equals(Object obj) {
if (!(obj instanceof LabelBlock)) {
return false;
}
LabelBlock that = (LabelBlock) obj;
if (!this.text.equals(that.text)) {
return false;
}
if (!this.font.equals(that.font)) {
return false;
}
if (!PaintUtilities.equal(this.paint, that.paint)) {
return false;
}
if (!ObjectUtilities.equal(this.toolTipText, that.toolTipText)) {
return false;
}
if (!ObjectUtilities.equal(this.urlText, that.urlText)) {
return false;
}
return super.equals(obj);
}
Tests this LabelBlock for equality with an arbitrary
object. |
public Font getFont() {
return this.font;
}
|
public Paint getPaint() {
return this.paint;
}
|
public String getToolTipText() {
return this.toolTipText;
}
Returns the tool tip text. |
public String getURLText() {
return this.urlText;
}
|
public void setFont(Font font) {
if (font == null) {
throw new IllegalArgumentException("Null 'font' argument.");
}
this.font = font;
this.label = TextUtilities.createTextBlock(this.text, font, this.paint);
}
Sets the font and regenerates the label. |
public void setPaint(Paint paint) {
if (paint == null) {
throw new IllegalArgumentException("Null 'paint' argument.");
}
this.paint = paint;
this.label = TextUtilities.createTextBlock(this.text, this.font,
this.paint);
}
Sets the paint and regenerates the label. |
public void setToolTipText(String text) {
this.toolTipText = text;
}
|
public void setURLText(String text) {
this.urlText = text;
}
|