danger.text.span
Class DropCapSpan

java.lang.Object
  extended by danger.text.span.DropCapSpan
All Implemented Interfaces:
LeftMarginSpan, LineHeightSpan, MetricAffectingSpan, ParagraphSpan


public class DropCapSpan
extends Object
implements LeftMarginSpan, LineHeightSpan

DropCapSpan is a LeftMarginSpan that draws a specified bitmap in front of as much of the paragraph as the bitmap is tall, and then lets the margin width go back to 0. If the bitmap is taller than the paragraph, the last line of the paragraph will be stretched to be as tall as is necessary to complete the bitmap.


Nested Class Summary
 
Nested classes/interfaces inherited from interface danger.text.span.LeftMarginSpan
LeftMarginSpan.Standard
 
Nested classes/interfaces inherited from interface danger.text.span.ParagraphSpan
ParagraphSpan.Set
 
Nested classes/interfaces inherited from interface danger.text.span.ParagraphSpan
ParagraphSpan.Set
 
Field Summary
 
Fields inherited from interface danger.text.span.ParagraphSpan
PARAGRAPH_SPAN_TYPE
 
Fields inherited from interface danger.text.span.ParagraphSpan
PARAGRAPH_SPAN_TYPE
 
Constructor Summary
DropCapSpan(Bitmap b)
          Create a new drop cap with the specified bitmap.
 
Method Summary
 int drawLeftMargin(Pen p, int x, int top, int baseline, int bottom, Object[] spans, CharSequence text, int parStart, int lineStart, int paragraphDistance, Object[] cspans)
          If this line of the paragraph is close enough to the top that it is next to the bitmap, the appropriate section of the bitmap is drawn in the left margin.
 int getVerticalDimensions(Font f, CharSequence text, int parStart, int lineStart, int lineEnd, Object[] rulers, int ascent, int descent, int pd)
          If this is the last line of the paragraph and the height of the line is still not enough that the bitmap will be done by the bottom of it, the line is stretched tall enough to complete the bitmap.
 int modifyLeftMargin(int margin, Object[] spans, Font f, CharSequence text, int parStart, int lineStart, int paragraphDistance)
          If this line of the paragraph is close enough to the top that it is next to the bitmap, the left margin is as wide as the bitmap.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DropCapSpan

public DropCapSpan(Bitmap b)
Create a new drop cap with the specified bitmap.

Method Detail

modifyLeftMargin

public int modifyLeftMargin(int margin,
                            Object[] spans,
                            Font f,
                            CharSequence text,
                            int parStart,
                            int lineStart,
                            int paragraphDistance)
If this line of the paragraph is close enough to the top that it is next to the bitmap, the left margin is as wide as the bitmap.

Specified by:
modifyLeftMargin in interface LeftMarginSpan

drawLeftMargin

public int drawLeftMargin(Pen p,
                          int x,
                          int top,
                          int baseline,
                          int bottom,
                          Object[] spans,
                          CharSequence text,
                          int parStart,
                          int lineStart,
                          int paragraphDistance,
                          Object[] cspans)
If this line of the paragraph is close enough to the top that it is next to the bitmap, the appropriate section of the bitmap is drawn in the left margin.

Specified by:
drawLeftMargin in interface LeftMarginSpan

getVerticalDimensions

public int getVerticalDimensions(Font f,
                                 CharSequence text,
                                 int parStart,
                                 int lineStart,
                                 int lineEnd,
                                 Object[] rulers,
                                 int ascent,
                                 int descent,
                                 int pd)
If this is the last line of the paragraph and the height of the line is still not enough that the bitmap will be done by the bottom of it, the line is stretched tall enough to complete the bitmap.

Specified by:
getVerticalDimensions in interface LineHeightSpan