Class ScalingLabelRenderer<N>
java.lang.Object
de.engehausen.treemap.swing.impl.ScalingLabelRenderer<N>
- Type Parameters:
N- the type of node the rectangles work on.
- All Implemented Interfaces:
IRectangleRenderer<N,Graphics2D, Color>
public class ScalingLabelRenderer<N>
extends Object
implements IRectangleRenderer<N,Graphics2D,Color>
Renders labels for rectangles scaled to fit the rectangles,
keeping proportion of the font used.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionScalingLabelRenderer(Font aFont, Color aNormalColor, Color aHighlightColor) Create the renderer using the given font and label colors.ScalingLabelRenderer(Font aFont, Color aNormalColor, Color aHighlightColor, boolean showsRoot) Create the renderer using the given font and label colors. -
Method Summary
Modifier and TypeMethodDescriptionvoidhighlight(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.protected voidsetupGraphics(Graphics2D graphics) Sets up the graphics object for rendering the text.
-
Field Details
-
normal
-
highlight
-
font
-
showRoot
protected final boolean showRoot
-
-
Constructor Details
-
ScalingLabelRenderer
Create the renderer using the given font and label colors. The root node is not labeled.- Parameters:
aFont- the font, must not benull.aNormalColor- the color for painting the label when not selected, must not benull.aHighlightColor- the color for painting the label when selected, must not benull.
-
ScalingLabelRenderer
public ScalingLabelRenderer(Font aFont, Color aNormalColor, Color aHighlightColor, boolean showsRoot) Create the renderer using the given font and label colors.- Parameters:
aFont- the font, must not benull.aNormalColor- the color for painting the label when not selected, must not benull.aHighlightColor- the color for painting the label when selected, must not benull.showsRoot-trueif the root node label should be shown,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. The label is fitted into the rectangle if possible.- Parameters:
graphics- the graphics object to work ontext- the text to rendercolor- the color to usebounds- the rectangle bounds
-
setupGraphics
Sets up the graphics object for rendering the text. By default turns on the anti aliasing; if not wanted override this method.- Parameters:
graphics- the graphics to set up.
-