コード例 #1
0
ファイル: Properties.java プロジェクト: WonderPanda/Besieged
 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());
   }
 }
コード例 #2
0
ファイル: Properties.java プロジェクト: WonderPanda/Besieged
  public void initSettingsFromText(NewGridElement element) {
    propertiesTextToDraw = new ArrayList<String>();
    this.elementSettings = element.getSettings();
    this.propCfg = new PropertiesConfig(element.getSettings());

    for (String line : getPanelAttributesAsList()) {
      boolean drawText = true;
      for (Facet gf : elementSettings.getGlobalFacets()) {
        if (gf.checkStart(line)) {
          gf.handleLine(line, drawer, propCfg);
          if (gf.replacesText(line)) drawText = false;
        }
      }
      if (drawText && !line.startsWith("//")) propertiesTextToDraw.add(line);
    }

    handleAutoresize(element);
    this.propCfg.setGridElementSize(element.getRealSize());
  }