Example #1
0
  private String getNextText(TextView v) {
    TextLine[] lines = v.getWrappedLines();
    v.uncacheLines();

    if (lines == null) {
      return null;
    }

    String next = null;

    if (lines.length > 1) {
      next = null;

      String caption = lines[0].getText();

      for (int i = 1; i < lines.length; i++) {
        if ((lines[i].y + 4) < v.getBounds().height) {
          caption += ("\n" + lines[i].getText());
        } else {
          if (next == null) {
            next = lines[i].getText();
          } else {
            next += ("\n" + lines[i].getText());
          }
        }
      }

      if (next != null) {
        v.setText(caption);
      }
    }

    return next;
  }
Example #2
0
  private TextView createView(Script script, String text, DisplayStyle css) {
    TextView e = new TextView(css);

    Cell cell = this.getComponent().getCell();

    if (cell == null) {
      e.setBounds(this.getComponent().getBounds());
    }

    e.setText(text);
    setBackgroundImageStyle(script, e);
    setLayoutRule(e, script);

    return e;
  }
Example #3
0
  private void setAutoSize(TextView e, Script script) {
    TextRule rule = this.getPrintStyle().getTextRule();

    if ((rule != null) && (rule.autoSize != null)) {
      rule.reset(script);

      if (rule.autoSize.is("width")) {
        e.setAutoWidth();
      } else if (rule.autoSize.is("height")) {
        e.setAutoHeight();
      } else if (rule.autoSize.is("breakable")) {
        this.unprinted = this.getNextText(e);
      }

      if (rule.maxWidth != null) {
        e.setMaxWidth(rule.maxWidth.intValue());
      }
    }
  }
Example #4
0
  /**
   * DOCUMENT ME!
   *
   * @param context DOCUMENT ME!
   * @return DOCUMENT ME!
   */
  public View print(Context context) {
    Script script = context.getScript();
    doBeforePrint(script);

    Label label = (Label) this.getComponent();
    TextView e = null;

    if (isVisible(script)) {
      DisplayStyle css = getDisplayStyle(script);

      String caption = getText(script);

      e = createView(script, caption, css);

      Hyperlink link = label.getHyperlink();

      if (link != null) {
        this.printHyperlink(script, e, link);
      }

      String tooltip = label.getTooltipText();

      if (tooltip != null) {
        this.printTooltipText(script, e, tooltip);
      }

      setAutoSize(e, script);

      this.setLayoutRule(e, script);
      e.setData(this.getLastValue());
    }

    doAfterPrint(script);

    this.done = this.unprinted == null;

    return e;
  }
Example #5
0
  /**
   * DOCUMENT ME!
   *
   * @param script DOCUMENT ME!
   * @param view DOCUMENT ME!
   * @param layout DOCUMENT ME!
   * @param down DOCUMENT ME!
   * @return DOCUMENT ME!
   */
  public View unitView(Script script, View view, PrinterLayout layout, boolean down) {
    TextRule rule = this.getPrintStyle().getTextRule();

    if ((rule != null) && (rule.unitedLevel != null)) {
      rule.reset(script);

      UnitedLevelManager levelManager = ((TablePrinterLayout) layout).getUnitedLevelManager();

      if (levelManager.isNew(rule.unitedLevel.intValue())) {
        lastView = null;
      }

      levelManager.useLevel(rule.unitedLevel.intValue());

      TextView e = (TextView) view;

      if (lastView != null) {
        if (down) {
          if ((lastView.getCell().row + lastView.getCell().rowSpan) == e.getCell().row) {
            String lastText = lastView.getText();
            String thisText = e.getText();
            boolean eq = (lastText != null) ? lastText.equals(thisText) : (thisText == null);

            if (eq) {
              lastView.getCell().rowSpan += e.getCell().rowSpan;

              return null;
            }
          }
        } else if ((lastView.getCell().column2() + 1) == e.getCell().column) {
          String lastText = lastView.getText();
          String thisText = e.getText();
          boolean eq = (lastText != null) ? lastText.equals(thisText) : (thisText == null);

          if (eq) {
            lastView.getCell().colSpan += e.getCell().colSpan;

            return null;
          }
        }
      }

      lastView = e;
      levelManager.newNext(rule.unitedLevel.intValue());

      return view;
    } else {
      return view;
    }
  }