Example #1
0
 private void handleLine(
     Settings elementSettings, String line, PropertiesConfig propCfg, BaseDrawHandler drawer) {
   boolean drawText = true;
   for (Facet facet : elementSettings.getFacets()) {
     if (facet.checkStart(line)) {
       facet.handleLine(line, drawer, propCfg);
       if (facet.replacesText(line)) {
         drawText = false;
       }
     }
   }
   if (drawText) {
     XPoints xLimitsForText = propCfg.getXLimitsForArea(propCfg.getyPos(), drawer.textHeight());
     Float spaceNotUsedForText = propCfg.getGridElementSize().width - xLimitsForText.getSpace();
     if (!spaceNotUsedForText.equals(
         Float.NaN)) { // NaN is possible if xlimits calculation contains e.g. a division by zero
       propCfg.calcMaxTextWidth(spaceNotUsedForText + drawer.textWidth(line));
     }
     drawer.print(
         line,
         calcHorizontalTextBoundaries(xLimitsForText, propCfg),
         propCfg.getyPos(),
         propCfg.gethAlign());
     propCfg.addToYPos(drawer.textHeightWithSpace());
   }
 }
Example #2
0
 private float calcHorizontalTextBoundaries(XPoints xLimitsForText, PropertiesConfig propCfg) {
   float x;
   if (propCfg.gethAlign() == AlignHorizontal.LEFT) {
     x = xLimitsForText.getLeft() + drawer.getDistanceBetweenTexts();
   } else if (propCfg.gethAlign() == AlignHorizontal.CENTER) {
     x = propCfg.getGridElementSize().width / 2;
   } else /*if (propCfg.gethAlign() == AlignHorizontal.RIGHT)*/ {
     x = xLimitsForText.getRight() - drawer.getDistanceBetweenTexts();
   }
   return x;
 }