standup.clouds
Class CloudLabel

java.lang.Object
  extended by standup.clouds.CloudLabel

public class CloudLabel
extends Object

An instance of this class specifies the caption, layout, symbols, and speech of a label that can be associated with a Captionable element. A CloudLabel has a List<CloudLabelSegment> of CloudLabelSegments. A CloudLabel has an array of STANDUPSpeakables for speech synthesis purposes.

Author:
Ruli Manurung

Field Summary
protected  STANDUPSpeakable[] customSpeechSegments
           
private static double DEFAULT_IMAGE_HEIGHT_AS_RATIO_OF_A
           
private static int DEFAULT_IMAGE_HEIGHT_GAP
           
private static int DEFAULT_IMAGE_WIDTH_GAP
           
private  List<CloudLabelSegment> segments
           
 
Constructor Summary
CloudLabel()
          A default empty BubbleLabel.
CloudLabel(CloudLabelSegment seg)
           
CloudLabel(JokeStructure joke, CloudLabelJokeDisplay jd, SymbolType[] _st)
          BubbleLabel for a JokeStructure.
CloudLabel(JokeStructure joke, SymbolType[] _st)
          Default BubbleLabel for a JokeStructure, which just shows the question.
CloudLabel(String text)
          A default BubbleLabel with just a plain text String.
CloudLabel(String prefix, Lexeme lex, SymbolType[] _st, Color c)
           
CloudLabel(String prefix, Topic topic, SymbolType[] _st, Color c)
           
 
Method Summary
 void addLabel(CloudLabel label)
           
 void addSegment(CloudLabelSegment segment)
           
private  void addSymbols(BufferedImage[] images, Dimension[] dimensions, double widthForImages, double segmentWidth, List<StuffToRender> lineOfStuff, double startX, double startY)
           
private  Dimension calculateScaledDimension(BufferedImage img, double intendedHeight)
           
private  void capitalize(List<CloudLabelSegment> seg)
           
private  List<STANDUPSpeakable> compressSpeakables(List<STANDUPSpeakable> oldSegments)
           
 boolean equals(Object arg0)
           
private  List<CloudLabelSegment> getBubbleLabelSegment(WordStruct _ws, SymbolType[] _st)
          Returns a BubbleLabelSegment for a WordStruct
private  TextLayout[] getLayoutsForSegment(BubbleLabelSegmentString seg, Font font, Font fontEmph, FontRenderContext fontRenderContext)
           
 String getPlainText()
           
 Object[] getRectPCSTextOnALine(FontRenderContext frc, CloudLabelSegment[] segs, int wrappingWidth, int maxHeight, SymbolSupport symSupp, float fontSizeFirstGuess)
           
 Object[] getRectPCSTextPerLine(FontRenderContext frc, CloudLabelSegment[] segs, int wrappingWidth, int maxHeight, SymbolSupport symSupp, float fontSizefirstGuess)
          Performs layout of given BubbleLabelSegments to fit in the space defined by wrappingWidth x maxHeight
 CloudLabelSegment[] getSegments()
           
private  List<STANDUPSpeakable> getSpeakables(WordStruct _ws)
           
(package private)  STANDUPSpeakable[] getSpeechSegments()
           
private  boolean isStartOfPseudoLexeme(List<? extends StructElement> ws, int ii)
           
private  Object[] layoutBubbleLabelSegments(FontRenderContext frc, CloudLabelSegment[] segs, int boundingWidth, int boundingHeight, Font font, Font fontEmph, SymbolSupport symSupp, int imageWidthGap, int imageHeightGap)
          this is an improved algorithm: -it handles segments with multiple images -it no longer breaks a segment between lines! this really assumes that the segment lengths will be short enough w.r.t.
private  Object[] layoutBubbleLabelSegmentsOnALine(FontRenderContext frc, CloudLabelSegment[] segs, int boundingWidth, int boundingHeight, Font font, Font fontEmph, SymbolSupport symSupp, int imageWidthGap, int imageHeightGap)
           
private  void lineBreak(List<StuffToRender> line, List<StuffToRender> all, boolean shiftDown, int distance)
           
private  boolean satisfies(SymbolSupport minSymSupp, SymbolSupport currentlySetSymSupp)
           
(package private)  void setSpeechSegments()
          Override this method to get a custom speech segments.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

customSpeechSegments

protected STANDUPSpeakable[] customSpeechSegments

segments

private final List<CloudLabelSegment> segments

DEFAULT_IMAGE_HEIGHT_AS_RATIO_OF_A

private static final double DEFAULT_IMAGE_HEIGHT_AS_RATIO_OF_A
See Also:
Constant Field Values

DEFAULT_IMAGE_WIDTH_GAP

private static final int DEFAULT_IMAGE_WIDTH_GAP
See Also:
Constant Field Values

DEFAULT_IMAGE_HEIGHT_GAP

private static final int DEFAULT_IMAGE_HEIGHT_GAP
See Also:
Constant Field Values
Constructor Detail

CloudLabel

public CloudLabel(JokeStructure joke,
                  SymbolType[] _st)
Default BubbleLabel for a JokeStructure, which just shows the question.


CloudLabel

public CloudLabel(JokeStructure joke,
                  CloudLabelJokeDisplay jd,
                  SymbolType[] _st)
BubbleLabel for a JokeStructure. The JokeDisplay argument specifies whether the BubbleLabel shows just the question, the answer, or both.


CloudLabel

public CloudLabel(String prefix,
                  Topic topic,
                  SymbolType[] _st,
                  Color c)

CloudLabel

public CloudLabel(String prefix,
                  Lexeme lex,
                  SymbolType[] _st,
                  Color c)

CloudLabel

public CloudLabel(CloudLabelSegment seg)

CloudLabel

public CloudLabel(String text)
A default BubbleLabel with just a plain text String.

Parameters:
text -

CloudLabel

public CloudLabel()
A default empty BubbleLabel.

Method Detail

getSpeechSegments

STANDUPSpeakable[] getSpeechSegments()

setSpeechSegments

void setSpeechSegments()
Override this method to get a custom speech segments. Alternatively, set customSpeechSegments during Constructor call!


compressSpeakables

private List<STANDUPSpeakable> compressSpeakables(List<STANDUPSpeakable> oldSegments)

isStartOfPseudoLexeme

private boolean isStartOfPseudoLexeme(List<? extends StructElement> ws,
                                      int ii)

getSpeakables

private List<STANDUPSpeakable> getSpeakables(WordStruct _ws)

getBubbleLabelSegment

private List<CloudLabelSegment> getBubbleLabelSegment(WordStruct _ws,
                                                      SymbolType[] _st)
Returns a BubbleLabelSegment for a WordStruct


capitalize

private void capitalize(List<CloudLabelSegment> seg)

getPlainText

public String getPlainText()

getSegments

public CloudLabelSegment[] getSegments()

addSegment

public void addSegment(CloudLabelSegment segment)

addLabel

public void addLabel(CloudLabel label)

equals

public boolean equals(Object arg0)
Overrides:
equals in class Object

getRectPCSTextPerLine

public Object[] getRectPCSTextPerLine(FontRenderContext frc,
                                      CloudLabelSegment[] segs,
                                      int wrappingWidth,
                                      int maxHeight,
                                      SymbolSupport symSupp,
                                      float fontSizefirstGuess)
Performs layout of given BubbleLabelSegments to fit in the space defined by wrappingWidth x maxHeight

Parameters:
g2 -
segs -
wrappingWidth -
maxHeight -
symSupp -
Returns:

getRectPCSTextOnALine

public Object[] getRectPCSTextOnALine(FontRenderContext frc,
                                      CloudLabelSegment[] segs,
                                      int wrappingWidth,
                                      int maxHeight,
                                      SymbolSupport symSupp,
                                      float fontSizeFirstGuess)

calculateScaledDimension

private Dimension calculateScaledDimension(BufferedImage img,
                                           double intendedHeight)

getLayoutsForSegment

private TextLayout[] getLayoutsForSegment(BubbleLabelSegmentString seg,
                                          Font font,
                                          Font fontEmph,
                                          FontRenderContext fontRenderContext)

satisfies

private boolean satisfies(SymbolSupport minSymSupp,
                          SymbolSupport currentlySetSymSupp)

layoutBubbleLabelSegments

private Object[] layoutBubbleLabelSegments(FontRenderContext frc,
                                           CloudLabelSegment[] segs,
                                           int boundingWidth,
                                           int boundingHeight,
                                           Font font,
                                           Font fontEmph,
                                           SymbolSupport symSupp,
                                           int imageWidthGap,
                                           int imageHeightGap)
this is an improved algorithm: -it handles segments with multiple images -it no longer breaks a segment between lines! this really assumes that the segment lengths will be short enough w.r.t. the bounding width not to cause terrible linebreaking...

Parameters:
segments -
width -
height -
Returns:

layoutBubbleLabelSegmentsOnALine

private Object[] layoutBubbleLabelSegmentsOnALine(FontRenderContext frc,
                                                  CloudLabelSegment[] segs,
                                                  int boundingWidth,
                                                  int boundingHeight,
                                                  Font font,
                                                  Font fontEmph,
                                                  SymbolSupport symSupp,
                                                  int imageWidthGap,
                                                  int imageHeightGap)

addSymbols

private void addSymbols(BufferedImage[] images,
                        Dimension[] dimensions,
                        double widthForImages,
                        double segmentWidth,
                        List<StuffToRender> lineOfStuff,
                        double startX,
                        double startY)

lineBreak

private void lineBreak(List<StuffToRender> line,
                       List<StuffToRender> all,
                       boolean shiftDown,
                       int distance)