|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.knime.base.node.viz.plotter.LabelPaintUtil
public final class LabelPaintUtil
Util class providing methods for drawing labels, which can be rotated if the
available space is to small. Since the rotation depends on the position,
where the labels is drawn, a value of the
LabelPaintUtil.Position
must be
passed to the drawLabel(String, Graphics2D, Rectangle,
org.knime.base.node.viz.plotter.LabelPaintUtil.Position, boolean)
method. If
the labels must be rotated due to the lack of space can also be determined
with the rotateLabels(CoordinateMapping[], int, FontMetrics)
method.
Nested Class Summary | |
---|---|
static class |
LabelPaintUtil.Position
Possible positions of the label. |
Method Summary | |
---|---|
static String |
cutLabel(String label,
int desiredLength,
FontMetrics fm)
Cuts the passed label until it fits into the desired length by cutting out the middle of the label. |
static void |
drawLabel(String label,
Graphics2D g,
Rectangle availableSpace,
LabelPaintUtil.Position position,
boolean rotate)
Draws the label, and if the available space is to small it rotates the label depending on the LabelPaintUtil.Position where to
draw it. |
static String |
getDoubleAsString(double value,
double roundingFactor)
Rounds the passed double value by the rounding factor and returns a string representation of it. |
static boolean |
rotateLabels(CoordinateMapping[] mappings,
int availableSize,
FontMetrics fm)
Returns true if any label is too long to be displayed in the available space. |
static boolean |
rotateLabels(List<String> labels,
int availableSize,
FontMetrics fm)
Returns true if any label is too long to be displayed in the available space. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static String getDoubleAsString(double value, double roundingFactor)
value
- the value to be roundedroundingFactor
- the rounding factor use 100 for two numbers after
the comma, 1000 for three numbers after the comma and so on.
public static void drawLabel(String label, Graphics2D g, Rectangle availableSpace, LabelPaintUtil.Position position, boolean rotate)
LabelPaintUtil.Position
where to
draw it. If it is still too large it cuts the label with the
cutLabel(String, int, FontMetrics)
method. The Rectangle
available space gives information about the available space, depending on
the position the labels is placed inside this rectangle.
label
- the label to displayg
- the graphics objectavailableSpace
- the available spaceposition
- the positionrotate
- whether labels are rotated or notpublic static String cutLabel(String label, int desiredLength, FontMetrics fm)
label
- the label to cutdesiredLength
- the desired lengthfm
- the font metrics
public static boolean rotateLabels(CoordinateMapping[] mappings, int availableSize, FontMetrics fm)
mappings
- the set of labels to be displayed.availableSize
- the available widthfm
- the font metrics
public static boolean rotateLabels(List<String> labels, int availableSize, FontMetrics fm)
labels
- the set of labels to be displayed.availableSize
- the available widthfm
- the font metrics
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |