Example #1
0
  public Box createBox(TeXEnvironment env) {
    // first create a simple square root construction

    TeXFont tf = env.getTeXFont();
    int style = env.getStyle();
    // calculate minimum clearance clr
    float clr, drt = tf.getDefaultRuleThickness(style);
    if (style < TeXConstants.STYLE_TEXT)
      clr = tf.getXHeight(style, tf.getChar(sqrtSymbol, style).getFontCode());
    else clr = drt;
    clr = drt + Math.abs(clr) / 4;

    // cramped style for the formula under the root sign
    Box bs = base.createBox(env.crampStyle());
    HorizontalBox b = new HorizontalBox(bs);
    b.add(new SpaceAtom(TeXConstants.UNIT_MU, 1, 0, 0).createBox(env.crampStyle()));
    // create root sign
    float totalH = b.getHeight() + b.getDepth();
    Box rootSign = DelimiterFactory.create(sqrtSymbol, env, totalH + clr + drt);

    // add half the excess to clr
    float delta = rootSign.getDepth() - (totalH + clr);
    clr += delta / 2;

    // create total box
    rootSign.setShift(-(b.getHeight() + clr));
    OverBar ob = new OverBar(b, clr, rootSign.getHeight());
    ob.setShift(-(b.getHeight() + clr + drt));
    HorizontalBox squareRoot = new HorizontalBox(rootSign);
    squareRoot.add(ob);

    if (root == null)
      // simple square root
      return squareRoot;
    else { // nthRoot, not a simple square root

      // create box from root
      Box r = root.createBox(env.rootStyle());

      // shift root up
      float bottomShift = FACTOR * (squareRoot.getHeight() + squareRoot.getDepth());
      r.setShift(squareRoot.getDepth() - r.getDepth() - bottomShift);

      // negative kern
      Box negativeKern = new SpaceAtom(TeXConstants.UNIT_MU, -10f, 0, 0).createBox(env);

      // arrange both boxes together with the negative kern
      Box res = new HorizontalBox();
      float pos = r.getWidth() + negativeKern.getWidth();
      if (pos < 0) res.add(new StrutBox(-pos, 0, 0, 0));

      res.add(r);
      res.add(negativeKern);
      res.add(squareRoot);
      return res;
    }
  }
 public Box createBox(TeXEnvironment env) {
   boolean prev = env.getSmallCap();
   env.setSmallCap(true);
   Box box = base.createBox(env);
   env.setSmallCap(prev);
   return box;
 }
  public Box createBox(TeXEnvironment env) {
    TeXFont tf = env.getTeXFont();
    int style = env.getStyle();
    Box b = base != null ? base.createBox(env) : new StrutBox(0, 0, 0, 0);
    float sep = new SpaceAtom(TeXConstants.UNIT_POINT, 1f, 0, 0).createBox(env).getWidth();
    Box arrow;

    if (dble) {
      arrow = XLeftRightArrowFactory.create(env, b.getWidth());
      sep = 4 * sep;
    } else {
      arrow = XLeftRightArrowFactory.create(left, env, b.getWidth());
      sep = -sep;
    }

    VerticalBox vb = new VerticalBox();
    if (over) {
      vb.add(arrow);
      vb.add(new HorizontalBox(b, arrow.getWidth(), TeXConstants.ALIGN_CENTER));
      float h = vb.getDepth() + vb.getHeight();
      vb.setDepth(b.getDepth());
      vb.setHeight(h - b.getDepth());
    } else {
      vb.add(new HorizontalBox(b, arrow.getWidth(), TeXConstants.ALIGN_CENTER));
      vb.add(new StrutBox(0, sep, 0, 0));
      vb.add(arrow);
      float h = vb.getDepth() + vb.getHeight();
      vb.setDepth(h - b.getHeight());
      vb.setHeight(b.getHeight());
    }

    return vb;
  }
  public Box createBox(TeXEnvironment env) {
    Box sp = new StrutBox(coeff * thin.createBox(env).getWidth(), 0, 0, 0);
    HorizontalBox db = new HorizontalBox(sp);
    db.add(ldotp.createBox(env));
    db.add(sp);
    Box b;
    if (w != 0) {
      float dw = db.getWidth();
      b = new HorizontalBox(db);
      while (b.getWidth() < w) {
        b.add(db);
      }
      b = new HorizontalBox(b, w, TeXConstants.ALIGN_CENTER);
    } else {
      b = db;
    }

    b.type = TeXConstants.TYPE_MULTICOLUMN;
    return b;
  }
Example #5
0
  public Box createBox(TeXEnvironment env) {
    Box box;
    if (base != null) {
      env = env.copy(env.getTeXFont().copy());
      env.getTeXFont().setRoman(true);
      box = base.createBox(env);
    } else {
      box = new StrutBox(0, 0, 0, 0);
    }

    return box;
  }
  public Box createBox(TeXEnvironment env) {
    double tw = env.getTextwidth();
    if (tw == Float.POSITIVE_INFINITY || type == GATHERED) {
      return new MatrixAtom(isPartial, column, "").createBox(env);
    }

    VerticalBox vb = new VerticalBox();
    Atom at = column.array.get(0).get(0);
    int alignment = type == GATHER ? TeXConstants.ALIGN_CENTER : TeXConstants.ALIGN_LEFT;
    if (at.alignment != -1) {
      alignment = at.alignment;
    }
    vb.add(new HorizontalBox(at.createBox(env), tw, alignment));
    Box Vsep = vsep_in.createBox(env);
    for (int i = 1; i < column.row - 1; i++) {
      at = column.array.get(i).get(0);
      alignment = TeXConstants.ALIGN_CENTER;
      if (at.alignment != -1) {
        alignment = at.alignment;
      }
      vb.add(Vsep);
      vb.add(new HorizontalBox(at.createBox(env), tw, alignment));
    }

    if (column.row > 1) {
      at = column.array.get(column.row - 1).get(0);
      alignment = type == GATHER ? TeXConstants.ALIGN_CENTER : TeXConstants.ALIGN_RIGHT;
      if (at.alignment != -1) {
        alignment = at.alignment;
      }
      vb.add(Vsep);
      vb.add(new HorizontalBox(at.createBox(env), tw, alignment));
    }

    double height = vb.getHeight() + vb.getDepth();
    vb.setHeight(height / 2);
    vb.setDepth(height / 2);

    return vb;
  }
  public Box createBox(TeXEnvironment env) {
    float drt = env.getTeXFont().getDefaultRuleThickness(env.getStyle());

    // cramp the style of the formula to be overlined and create vertical box
    Box b = (base == null ? new StrutBox(0, 0, 0, 0) : base.createBox(env.crampStyle()));
    OverBar ob = new OverBar(b, 3 * drt, drt);

    // baseline vertical box = baseline box b
    ob.setDepth(b.getDepth());
    ob.setHeight(b.getHeight() + 5 * drt);

    return ob;
  }
Example #8
0
  public Box createBox(TeXEnvironment env) {
    TeXFont tf = env.getTeXFont();
    int style = env.getStyle();

    // set base in cramped style
    Box b = (base == null ? new StrutBox(0, 0, 0, 0) : base.createBox(env.crampStyle()));

    float u = b.getWidth();
    float s = 0;
    if (base instanceof CharSymbol) s = tf.getSkew(((CharSymbol) base).getCharFont(tf), style);

    // retrieve best Char from the accent symbol
    Char ch = tf.getChar(accent.getName(), style);
    while (tf.hasNextLarger(ch)) {
      Char larger = tf.getNextLarger(ch, style);
      if (larger.getWidth() <= u) ch = larger;
      else break;
    }

    // calculate delta
    float delta = Math.min(b.getHeight(), tf.getXHeight(style, ch.getFontCode()));

    // create vertical box
    VerticalBox vBox = new VerticalBox();

    // accent
    Box y;
    float italic = ch.getItalic();
    if (italic > TeXFormula.PREC) {
      y = new HorizontalBox(new CharBox(ch));
      y.add(new StrutBox(italic, 0, 0, 0));
    } else y = new CharBox(ch);

    // if diff > 0, center accent, otherwise center base
    float diff = (u - y.getWidth()) / 2;
    y.setShift(s + (diff > 0 ? diff : 0));
    if (diff < 0) b = new HorizontalBox(b, y.getWidth(), TeXConstants.ALIGN_CENTER);
    vBox.add(y);

    // kern
    vBox.add(new StrutBox(0, -delta, 0, 0));
    // base
    vBox.add(b);

    // set height and depth vertical box
    float total = vBox.getHeight() + vBox.getDepth(), d = b.getDepth();
    vBox.setDepth(d);
    vBox.setHeight(total - d);
    return vBox;
  }