org.jvnet.substance.painter.text
Class DefaultTextPainter

java.lang.Object
  extended by org.jvnet.substance.painter.text.AbstractTextPainter
      extended by org.jvnet.substance.painter.text.DefaultTextPainter
All Implemented Interfaces:
SubstanceTextPainter

public class DefaultTextPainter
extends AbstractTextPainter

The default core implementation of SubstanceTextPainter.

Author:
Kirill Grouchnikov

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jvnet.substance.painter.text.AbstractTextPainter
AbstractTextPainter.TextLineInfo
 
Nested classes/interfaces inherited from interface org.jvnet.substance.painter.text.SubstanceTextPainter
SubstanceTextPainter.BackgroundPaintingCallback, SubstanceTextPainter.ImageBackgroundPaintingCallback
 
Field Summary
 
Fields inherited from class org.jvnet.substance.painter.text.AbstractTextPainter
callbackList, comp, textLines, toEnforceRenderOnNoTexts
 
Constructor Summary
DefaultTextPainter()
           
 
Method Summary
 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)
           
 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 SubstanceTextPainter.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.
 
Methods inherited from class org.jvnet.substance.painter.text.AbstractTextPainter
attachCallback, attachText, init, toIgnoreBackgroundFill
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultTextPainter

public DefaultTextPainter()
Method Detail

needsBackgroundImage

public boolean needsBackgroundImage()
Description copied from interface: SubstanceTextPainter
Returns indication whether this painter requires background to be fully set before painting the text (with SubstanceTextPainter.renderSurface(Graphics)).

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

setBackgroundFill

public void setBackgroundFill(javax.swing.JComponent comp,
                              java.awt.Color backgroundFillColor,
                              boolean toOverlayWatermark,
                              int watermarkOffsetX,
                              int watermarkOffsetY)
Description copied from interface: SubstanceTextPainter
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.

renderSurface

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

Parameters:
g - Graphic context.

attachVerticalText

public 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)
Description copied from interface: SubstanceTextPainter
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).

isNative

public boolean isNative()
Description copied from interface: SubstanceTextPainter
Returns true if this text painter uses native font rendering.

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

dispose

public void dispose()
Description copied from interface: SubstanceTextPainter
Disposes the resources allocated by this text painter.


getTextBounds

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