Ejemplo n.º 1
0
 private List<Line> createStructure(GUIText text) {
   char[] chars = text.getTextString().toCharArray();
   List<Line> lines = new ArrayList<Line>();
   Line currentLine =
       new Line(metaData.getSpaceWidth(), text.getFontSize(), text.getMaxLineSize());
   Word currentWord = new Word(text.getFontSize());
   for (char c : chars) {
     int ascii = (int) c;
     if (ascii == SPACE_ASCII) {
       boolean added = currentLine.attemptToAddWord(currentWord);
       if (!added) {
         lines.add(currentLine);
         currentLine =
             new Line(metaData.getSpaceWidth(), text.getFontSize(), text.getMaxLineSize());
         currentLine.attemptToAddWord(currentWord);
       }
       currentWord = new Word(text.getFontSize());
       continue;
     }
     Character character = metaData.getCharacter(ascii);
     currentWord.addCharacter(character);
   }
   completeStructure(lines, currentLine, currentWord, text);
   return lines;
 }
Ejemplo n.º 2
0
 private void completeStructure(
     List<Line> lines, Line currentLine, Word currentWord, GUIText text) {
   boolean added = currentLine.attemptToAddWord(currentWord);
   if (!added) {
     lines.add(currentLine);
     currentLine = new Line(metaData.getSpaceWidth(), text.getFontSize(), text.getMaxLineSize());
     currentLine.attemptToAddWord(currentWord);
   }
   lines.add(currentLine);
 }