org.jvnet.substance.painter.text
Class AbstractTextPainter

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

public abstract class AbstractTextPainter
extends java.lang.Object
implements SubstanceTextPainter

Base implementation of SubstanceTextPainter that provides common functionality for core text painters.

Author:
Kirill Grouchnikov

Nested Class Summary
static class AbstractTextPainter.TextLineInfo
          Information on a single text line.
 
Nested classes/interfaces inherited from interface org.jvnet.substance.painter.text.SubstanceTextPainter
SubstanceTextPainter.BackgroundPaintingCallback, SubstanceTextPainter.ImageBackgroundPaintingCallback
 
Field Summary
protected  java.util.List<SubstanceTextPainter.BackgroundPaintingCallback> callbackList
          Attached background painting callbacks.
protected  java.awt.Component comp
           
protected  java.util.List<AbstractTextPainter.TextLineInfo> textLines
          Attached texts.
protected  boolean toEnforceRenderOnNoTexts
          If true, the painter implementation will fill the background and invoke all callbacks even when there are no attached texts or all texts are empty.
 
Constructor Summary
protected AbstractTextPainter()
          Creates a new abstract text painter.
 
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 init(javax.swing.JComponent comp, java.awt.Rectangle clip, boolean toEnforceRenderOnNoTexts)
          Re-initializes the contents of this painter.
protected  boolean toIgnoreBackgroundFill(java.awt.Component comp)
          Checks whether the background fill should be skipped for the specified component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jvnet.substance.painter.text.SubstanceTextPainter
attachVerticalText, dispose, getTextBounds, isNative, needsBackgroundImage, renderSurface, setBackgroundFill
 

Field Detail

callbackList

protected java.util.List<SubstanceTextPainter.BackgroundPaintingCallback> callbackList
Attached background painting callbacks.


textLines

protected java.util.List<AbstractTextPainter.TextLineInfo> textLines
Attached texts.


toEnforceRenderOnNoTexts

protected boolean toEnforceRenderOnNoTexts
If true, the painter implementation will fill the background and invoke all callbacks even when there are no attached texts or all texts are empty.


comp

protected java.awt.Component comp
Constructor Detail

AbstractTextPainter

protected AbstractTextPainter()
Creates a new abstract text painter. Is protected to enforce that it can't be directly created.

Method Detail

init

public void init(javax.swing.JComponent comp,
                 java.awt.Rectangle clip,
                 boolean toEnforceRenderOnNoTexts)
Description copied from interface: SubstanceTextPainter
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.

Specified by:
init in interface SubstanceTextPainter
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

attachCallback

public void attachCallback(SubstanceTextPainter.BackgroundPaintingCallback backgroundPaintingCallback)
Description copied from interface: SubstanceTextPainter
Attaches the specified background painting callback.

Specified by:
attachCallback in interface SubstanceTextPainter
Parameters:
backgroundPaintingCallback - Background painting callback to attach.

attachText

public 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)
Description copied from interface: SubstanceTextPainter
Attaches the specified text to paint.

Specified by:
attachText in interface SubstanceTextPainter
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.

toIgnoreBackgroundFill

protected boolean toIgnoreBackgroundFill(java.awt.Component comp)
Checks whether the background fill should be skipped for the specified component.

Parameters:
comp - Component.
Returns:
true if the background fill should be skipped for the specified component, false otherwise.