Class LabelRenderer<N>
java.lang.Object
de.engehausen.treemap.swing.impl.LabelRenderer<N>
- Type Parameters:
N- the type of node the rectangles work on.
- All Implemented Interfaces:
IRectangleRenderer<N,Graphics2D, Color>
Renders labels for rectangles.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionLabelRenderer(Font aFont) Create the renderer using the given font.LabelRenderer(Font aFont, boolean showsRoot) Create the renderer using the given font. -
Method Summary
Modifier and TypeMethodDescriptionprotected doubleaspectRatio(int w, int h) Compute the aspect ratio.voidhighlight(Graphics2D graphics, ITreeModel<IRectangle<N>> model, IRectangle<N> rectangle, IColorProvider<N, Color> colorProvider, ILabelProvider<N> labelProvider) voidrender(Graphics2D graphics, ITreeModel<IRectangle<N>> model, IRectangle<N> rectangle, IColorProvider<N, Color> colorProvider, ILabelProvider<N> labelProvider) protected voidrender(Graphics2D graphics, String text, Color color, IRectangle<N> bounds) Renders a label for the given rectangle if possible.
-
Field Details
-
font
-
showRoot
protected final boolean showRoot
-
-
Constructor Details
-
LabelRenderer
Create the renderer using the given font.- Parameters:
aFont- the font, must not benull.
-
LabelRenderer
Create the renderer using the given font.- Parameters:
aFont- the font, must not benull.showsRoot- set totrueif the root node label should be rendered,falseotherwise.
-
-
Method Details
-
render
public void render(Graphics2D graphics, ITreeModel<IRectangle<N>> model, IRectangle<N> rectangle, IColorProvider<N, Color> colorProvider, ILabelProvider<N> labelProvider) - Specified by:
renderin interfaceIRectangleRenderer<N,Graphics2D, Color>
-
highlight
public void highlight(Graphics2D graphics, ITreeModel<IRectangle<N>> model, IRectangle<N> rectangle, IColorProvider<N, Color> colorProvider, ILabelProvider<N> labelProvider) - Specified by:
highlightin interfaceIRectangleRenderer<N,Graphics2D, Color>
-
render
Renders a label for the given rectangle if possible. The label is rotated 90 degrees if it fits "better" into the rectangle that way.- Parameters:
graphics- the graphics object to work ontext- the text to rendercolor- the color to usebounds- the rectangle bounds
-
aspectRatio
protected double aspectRatio(int w, int h) Compute the aspect ratio.- Parameters:
w- the widthh- the height- Returns:
- the aspect ratio
-