at.tuwien.ifs.somtoolbox.apps.server
Class LabelDescription

java.lang.Object
  extended by at.tuwien.ifs.somtoolbox.apps.server.LabelDescription

public class LabelDescription
extends Object

This class represents all the information needed to draw a specific label - its psition, font, rotation, etc.

Version:
$Id: LabelDescription.java 3587 2010-05-21 10:35:33Z mayer $
Author:
Rudolf Mayer

Field Summary
private  Color color
          The colour to draw the label with.
static Font DEFAULT_FONT
          The default font of all labels.
private  Font font
          The font to draw the label with.
private  float fontSize
          The font size to draw the label with.
private  double rotation
          The rotation of the label.
private  String text
          The label text.
private  boolean visible
           
private  int x
          The horizontal position of the label.
private  int y
          The vertical position of the label.
 
Constructor Summary
LabelDescription(String text, float fontSize, int x, int y, double rotation, boolean visible)
           
 
Method Summary
 boolean equals(Object obj)
          Compares two LabelDescription with each other.
 Color getColor()
          Gets the current colour of this label.
 Font getFont()
          Gets the current font of this label.
 Font getFont(double scale)
          Gets a scaled version of the current font.
 float getFontSize()
          Gets the current font size of this label.
 double getFontSize(double scale)
          Gets scaled value of the current font size of this label.
 double getRotation()
          Gets the current rotation of this label.
 String getText()
          Gets the current text of this label.
 int getX()
           
 int getX(double scale)
          Calculates a scaled x position of the label, by the given scale factor
 int getY()
           
 int getY(double scale)
          Calculates a scaled y position of the label, by the given scale factor
 int getYBaseline(FontMetrics fontMetrics)
          Calculates the offset y position, considering font ascents.
 int getYBaseline(FontMetrics fontMetrics, double scale, int lineNumber)
          Calculates a scaled offset y position, considering font ascents.
 boolean isVisible()
           
 void setColor(Color color)
          Sets a new colour for the label.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_FONT

public static Font DEFAULT_FONT
The default font of all labels. Instances will use this font, and only modify the size.


color

private Color color
The colour to draw the label with.


font

private Font font
The font to draw the label with. This will be initially a copy of DEFAULT_FONT, with only the size modified to fontSize


fontSize

private float fontSize
The font size to draw the label with. Used to instantiate font.


rotation

private double rotation
The rotation of the label.


text

private String text
The label text.


x

private int x
The horizontal position of the label.


y

private int y
The vertical position of the label.


visible

private boolean visible
Constructor Detail

LabelDescription

public LabelDescription(String text,
                        float fontSize,
                        int x,
                        int y,
                        double rotation,
                        boolean visible)
Method Detail

equals

public boolean equals(Object obj)
Compares two LabelDescription with each other. They are considered identical if the values of getText(), getX(), getY(), getFontSize(), getColor() and getRotation() are equal.

Overrides:
equals in class Object

getColor

public Color getColor()
Gets the current colour of this label.


getFont

public Font getFont()
Gets the current font of this label.


getFont

public Font getFont(double scale)
Gets a scaled version of the current font. The font-size of label is scaled by the given factor.


getFontSize

public float getFontSize()
Gets the current font size of this label.


getFontSize

public double getFontSize(double scale)
Gets scaled value of the current font size of this label.


getRotation

public double getRotation()
Gets the current rotation of this label.


getText

public String getText()
Gets the current text of this label.


getX

public int getX()
Returns:
the x position of the label

getX

public int getX(double scale)
Calculates a scaled x position of the label, by the given scale factor

Parameters:
scale - the scale factor
Returns:
the scaled x position of the label

getY

public int getY()
Returns:
the y position of the label

getY

public int getY(double scale)
Calculates a scaled y position of the label, by the given scale factor

Parameters:
scale - the scale factor
Returns:
the scaled y positon of the label

getYBaseline

public int getYBaseline(FontMetrics fontMetrics)
Calculates the offset y position, considering font ascents.

Parameters:
fontMetrics - metric to calculate the ascents.
Returns:
the y position increased by the ascent.

getYBaseline

public int getYBaseline(FontMetrics fontMetrics,
                        double scale,
                        int lineNumber)
Calculates a scaled offset y position, considering font ascents.

Parameters:
fontMetrics - metric to calculate the ascents.
scale - the scale factor
lineNumber - the line number of the string, used when wanting to print multi-line labels
Returns:
the scaled y position increased by the ascent.

setColor

public void setColor(Color color)
Sets a new colour for the label.


isVisible

public boolean isVisible()