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) { // 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 static void boxClient() { Box b = new Box(); System.out.println("Length = " + b.getLength()); System.out.println("Width = " + b.getWidth()); System.out.println("Height = " + b.getHeight()); System.out.println("Volume = " + b.volumeOfBox()); b.setLength(5); b.setWidth(5); b.setHeight(5); System.out.println("Length = " + b.getLength()); System.out.println("Width = " + b.getWidth()); System.out.println("Height = " + b.getHeight()); System.out.println("Volume = " + b.volumeOfBox()); Box b2 = new Box(6, 7, 8); System.out.println("Length = " + b2.getLength()); System.out.println("Width = " + b2.getWidth()); System.out.println("Height = " + b2.getHeight()); System.out.println("Volume = " + b2.volumeOfBox()); }
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; }
public void draw() { Graphics g = position.getGraphics(); int width = position.getWidth(); int height = position.getHeight(); g.fillOval(0, 0, width, height); }
public void drawBox(Graphics g) { for (Box i : boxList) { g.drawImage(i.getImage(), i.getX(), i.getY(), i.getWidth(), i.getHeight(), null); } }