org.jvnet.substance.painter.text
Interface SubstanceTextPainter

All Known Implementing Classes:
AbstractTextPainter, DefaultTextPainter

public interface SubstanceTextPainter

Base interface for Substance text painters.

Since:
version 4.2
Author:
Kirill Grouchnikov

Nested Class Summary
static interface SubstanceTextPainter.BackgroundPaintingCallback
          Callback for custom background painting.
static class SubstanceTextPainter.ImageBackgroundPaintingCallback
          Background painting callback that draws an image at the specified location.
 
Method Summary
 void attachCallback(SubstanceTextPainter.BackgroundPaintingCallback backgroundPaintingCallback)
          Attaches the specified background painting callback.
 void attachText(javax.swing.JComponent comp, java.awt.Rectangle textRect, java.lang.String text, int mnemonicIndex, java.awt.Font font, java.awt.Color color, java.awt.Rectangle clip)
          Attaches the specified text to paint.
 void attachVerticalText(javax.swing.JComponent comp, java.awt.Rectangle textRect, java.lang.String text, int mnemonicIndex, java.awt.Font font, java.awt.Color color, java.awt.Rectangle clip, boolean isFromBottomToTop)
          Attaches the specified vertical text to paint.
 void dispose()
          Disposes the resources allocated by this text painter.
 java.awt.Dimension getTextBounds(java.awt.Component comp, java.awt.Font font, java.lang.String text)
           
 void init(javax.swing.JComponent comp, java.awt.Rectangle clip, boolean toEnforceRenderOnNoTexts)
          Re-initializes the contents of this painter.
 boolean isNative()
          Returns true if this text painter uses native font rendering.
 boolean needsBackgroundImage()
          Returns indication whether this painter requires background to be fully set before painting the text (with renderSurface(Graphics)).
 void renderSurface(java.awt.Graphics g)
          Paints the surface.
 void setBackgroundFill(javax.swing.JComponent comp, java.awt.Color backgroundFillColor, boolean toOverlayWatermark, int watermarkOffsetX, int watermarkOffsetY)
          Sets the fill color of the background.
 

Method Detail

init

void init(javax.swing.JComponent comp,
          java.awt.Rectangle clip,
          boolean toEnforceRenderOnNoTexts)
Re-initializes the contents of this painter. Is usually called at the beginning of the component painting cycle. The painter implementation is expected to remove all registered callbacks.

Parameters:
comp - Component.
clip - Clip to apply. The painter implementation should respect this clip, especially on components such as lists or tables that use cell renderers. In these components, the specific cell is usually much smaller than the whole component, and the painting is done on each visible cell in a loop.
toEnforceRenderOnNoTexts - If true, the painter implementation must fill the background and invoke all callbacks even when there are no attached texts or all texts are empty.
See Also:
AbstractTextPainter

needsBackgroundImage

boolean needsBackgroundImage()
Returns indication whether this painter requires background to be fully set before painting the text (with renderSurface(Graphics)).

Returns:
true if this painter requires background to be fully set before painting the text, false otherwise.

setBackgroundFill

void setBackgroundFill(javax.swing.JComponent comp,
                       java.awt.Color backgroundFillColor,
                       boolean toOverlayWatermark,
                       int watermarkOffsetX,
                       int watermarkOffsetY)
Sets the fill color of the background.

Parameters:
comp - Component.
backgroundFillColor - Fill color for the background.
toOverlayWatermark - If true, the background fill should be overlayed with the current watermark.
watermarkOffsetX - The X offset for the watermark relative to the screen position of the component. This is relevant for cell-based components such as lists, tables and trees.
watermarkOffsetY - The Y offset for the watermark relative to the screen position of the component. This is relevant for cell-based components such as lists, tables and trees.

attachCallback

void attachCallback(SubstanceTextPainter.BackgroundPaintingCallback backgroundPaintingCallback)
Attaches the specified background painting callback.

Parameters:
backgroundPaintingCallback - Background painting callback to attach.

attachText

void attachText(javax.swing.JComponent comp,
                java.awt.Rectangle textRect,
                java.lang.String text,
                int mnemonicIndex,
                java.awt.Font font,
                java.awt.Color color,
                java.awt.Rectangle clip)
Attaches the specified text to paint.

Parameters:
comp - Component.
textRect - Text rectangle.
text - The text itself.
mnemonicIndex - Optional mnemonic index. Can be -1 if no mnemonic.
font - Font for this text.
color - Color for this text.
clip - Clip rectangle for this text.

attachVerticalText

void attachVerticalText(javax.swing.JComponent comp,
                        java.awt.Rectangle textRect,
                        java.lang.String text,
                        int mnemonicIndex,
                        java.awt.Font font,
                        java.awt.Color color,
                        java.awt.Rectangle clip,
                        boolean isFromBottomToTop)
Attaches the specified vertical text to paint.

Parameters:
comp - Component.
textRect - Text rectangle.
text - The text itself.
mnemonicIndex - Optional mnemonic index. Can be -1 if no mnemonic.
font - Font for this text.
color - Color for this text.
clip - Clip rectangle for this text.
isFromBottomToTop - If true, the text will be painted from bottom to top (so that the top of the letters is on the left). If false, the text will be painted from top to bottom (so that the top of the letters is on the right).

renderSurface

void renderSurface(java.awt.Graphics g)
Paints the surface. The painter implementation should respect the clip set in #init(JComponent, Rectangle), background fill set in setBackgroundFill(JComponent, Color, boolean, int, int), invoke the background callbacks added with attachCallback(BackgroundPaintingCallback) and paint all the texts added with #attachText(JComponent, Rectangle, String, int, Font, Color).

Parameters:
g - Graphic context.

isNative

boolean isNative()
Returns true if this text painter uses native font rendering.

Returns:
true if this text painter uses native font rendering.

dispose

void dispose()
Disposes the resources allocated by this text painter.


getTextBounds

java.awt.Dimension getTextBounds(java.awt.Component comp,
                                 java.awt.Font font,
                                 java.lang.String text)