Package ket.display.box

Examples of ket.display.box.Box


  /**
   * Setup the box that represents the previous state.
   */
  private Box beforeBoxSetup(Graphics2D g2D, ColourScheme colourScheme, Argument before, int fontSize, Offset windowWithoutLabel) {
    Box beforeRootBox = before.toBox(0L, colourScheme);
    beforeRootBox.setupInnerRectangle(fontSize);
    beforeRootBox.setupOuterRectangle(windowWithoutLabel);
    beforeRootBox.calcRootOffset();
    return beforeRootBox;
  }
View Full Code Here


      modeString = "|" + modeString + "|";
    }
    this.modeBox = new BoxText(MODE, modeString, Box.BOLD_FONT);
    String details = ds.getDetails(); // An optional sub-heading to the label.
    if (details!=null) {
      Box detailsBox = new BoxText(MODE, details, 0L); // Subscript?
      this.modeBox = BoxTools.centredVerticalBoxList(MODE, 0L, this.modeBox, detailsBox);
    }
    this.modeBox = new BorderedBox(MODE, this.modeBox, Box.RIGHT_ALIGN|Box.BOTTOM_ALIGN, false, colourScheme);
  }
View Full Code Here

    //- if (equations!=null && !equations.contains(equation)) {
    if (equations!=null && !equation.isIn(equations)) {
      return 0.0;
    }

    Box box = equation.toBox(colourScheme);

    // Determine the minimum size of the box and use a scaled value it to set its dimensions.
    box.setupInnerRectangle(fontSize);
    double minimumHeight = box.getInnerRectangle().height;
    // TODO: Is this being done twice: here and in its parent or grandparent?
    double shapeWidth = panelRectangle.width - KetPanel.LEFT_BORDER_SIZE - KetPanel.RIGHT_BORDER_SIZE;
    Offset equationRectangle = new Offset(shapeWidth, FRACTIONAL_EQUATION_LIST_GAP*minimumHeight);

    // Generate the label so as to have a size in order to avoid
    // overlaps when drawing the rest of the equation.
    Box labelBox = equation.getLabelBox(colourScheme);

    labelBox.setProperty(Box.RIGHT_ALIGN);
    labelBox.setProperty(Box.Y_CENTRE_ALIGN);
    labelBox.setup(fontSize, equationRectangle);

    // TODO: Distinguish between equationRectangle versions?
    equationRectangle = new Offset(shapeWidth-labelBox.getInnerRectangle().width, FRACTIONAL_EQUATION_LIST_GAP*minimumHeight);

    box.setupOuterRectangle(equationRectangle);

    // NOTE: This over-generalizes box alignment by accepting box
    // sizes beyond the given limit.  This is an unfinished change,
View Full Code Here

  public Box toBox(long settings, ColourScheme colourScheme) {
    if (isBold()) { //?
      settings |= Box.BOLD_FONT;
    }
    //- Box box = new BoxWord(this, Symbol.HIDDEN.toUnicode(), settings, colourScheme.getBoxColour(this));
    Box box = new BoxWord(this, Symbol.HIDDEN.toUnicode(), settings);
    box.setArgument(this); //? Redundant?
    return box;
  }
View Full Code Here

    //- for (Argument a : family) {
    for (int count=0; count<family.size(); count++) {
      Argument a = family.get(count);
      int i = count / columns;
      int j = count % columns;
      Box box = a.toBox(0L, document.getColourScheme());
      box.setup(Box.DEFAULT_BOX_FONT_SIZE, new Offset(20, 20)); // Use a fixed icon size?
      BufferedImage image = ImageTools.paintInnerBoxToImage(box, false, document.getColourScheme());
      JButton button = new JButton();
      button.setIcon(new ImageIcon(image));
      //> button.setRolloverIcon(new ImageIcon()); // Highlighted or bold version?
      button2Arg.put(button, a);
View Full Code Here

   * inner rectangle, return that box.
   */
  @Override
  public Box findDeepestBox(Position p) {
    for (Box next : boxSet) {
      Box match = next.findDeepestBox(p);
      if (match!=null && match.getArgument()!=null) {
        return match;
      }
    }
    return null;
  }
View Full Code Here

      }
    }

    Vector<Box> bs = new Vector<Box>(boxSet);
    for (int i=0; i<bs.size(); i++) { // Move boxses apart.
      Box bA = bs.get(i);
      Equation eA = boxToEquation.get(bA);
      if (eA==null) continue;
      Position pA = equationToPosition.get(eA);
      if (pA==null) continue;
      Offset innerA = bA.getInnerRectangle();
      for (int j=i+1; j<bs.size(); j++) { // Move boxses apart.
        Box bB = bs.get(j);
        Equation eB = boxToEquation.get(bB);
        if (eB==null) continue;
        Position pB = equationToPosition.get(eB);
        if (pB==null) continue;
        Offset innerB = bB.getInnerRectangle();

        Position rA = bA.getPosition(pA);
        Position rB = bB.getPosition(pB);
        Offset iA = bA.getInnerRectangle();
        Offset iB = bB.getInnerRectangle();

        // Positive overlap values are errors.
        boolean overlap1 = rB.x + iB.width + ADDITIONAL_EQUATION_GAP > rA.x;
        boolean overlap2 = rA.x + iA.width + ADDITIONAL_EQUATION_GAP > rB.x;
        boolean overlap3 = rB.y + iB.height + ADDITIONAL_EQUATION_GAP > rA.y;
View Full Code Here

      boxText.setProperty(Box.BOLD_FONT);
    }
    BoxWord comma = new BoxWord(argument, ",", Box.PLAIN_FONT);
    switch (boxArgs.size()) {
      case 0:
        Box blank = new BoxWord(argument, "", 0L);
        Box brackets = BoxTools.roundBrackets(argument, blank, 0L, colourScheme);
        return BoxTools.centredHorizontalBoxList(argument, settings, boxText, brackets);

      case 1:
        Box brackettedArgument = BoxTools.roundBrackets(argument, boxArgs.firstElement(), 0L, colourScheme);
        Box singleArgumentFunction = BoxTools.centredHorizontalBoxList(argument, settings, boxText, brackettedArgument);
        boxText.setProperty(Box.RIGHT_ALIGN|Box.Y_CENTRE_ALIGN);
        brackettedArgument.setProperty(Box.LEFT_ALIGN|Box.Y_CENTRE_ALIGN);
        singleArgumentFunction.setProperty(Box.X_CENTRE_ALIGN|Box.Y_CENTRE_ALIGN);
        return singleArgumentFunction;

      default:
        Box separatedArgs = BoxTools.interpose(argument, comma, boxArgs);
        boxText.setProperty(Box.RIGHT_ALIGN|Box.Y_CENTRE_ALIGN);
        comma.setProperty(Box.LEFT_ALIGN|Box.Y_CENTRE_ALIGN);
        Box brackettedArgs = BoxTools.roundBrackets(argument, separatedArgs, 0L, colourScheme);
        return BoxTools.centredHorizontalBoxList(argument, settings, boxText, brackettedArgs);
    }
  }
View Full Code Here

    Vector<Position> ends = calcEnds(es, el);
    Vector<Box> theBoxes = new Vector<Box>();
    Vector<Equation> theEquations = new Vector<Equation>();
    Vector<Position> thePositions = new Vector<Position>();
    for (Map.Entry<Box,Equation> entry : es) {
      Box box = entry.getKey();
      Equation e = entry.getValue();
      if (e==null) {
        System.out.print("null");
        boxToEquation.remove(box);
        continue;
      }
      if (e.getEquationList()!=el) {
        System.out.print("e");
        boxToEquation.remove(box);
        continue;
      }
      Position p = equationToPosition.get(e);
      if (p==null) {
        System.out.print("p");
        boxToEquation.remove(box);
        continue;
      }
      theBoxes.add(box);
      theEquations.add(e);
      thePositions.add(p);
    }
    for (int loop=0; loop<n; loop++) {
      Vector<Position> allPs = new Vector<Position>();
      Vector<Position> allQs = new Vector<Position>();
      for (int i=0; i<theBoxes.size(); i++) {
        Box box = theBoxes.get(i);
        Equation e = theEquations.get(i);
        Position p = thePositions.get(i);
        Offset inner = box.getInnerRectangle();
        Position q = shift(p, scale);
        double costQ = calcCost(q, centre, ends, dx, dy, inner);
        double costP = calcCost(p, centre, ends, dx, dy, inner);
        if (costQ <= costP) {
          allPs.add(p);
          allQs.add(q);
        }
      }
      for (int i=0; i<allPs.size(); i++) {
        Position p = allPs.get(i);
        Position q = allQs.get(i);
        p.x = (1.0*q.x+2.0*p.x) / 3.0;
        p.y = (1.0*q.y+2.0*p.y) / 3.0;
      }
    }

    if (true) { //D
    for (Map.Entry<Box,Equation> entry : es) {
      Box box = entry.getKey();
      Equation e = entry.getValue();
      if (e==null) continue;
      Position p = equationToPosition.get(e);
      if (p==null) continue;
      Vector<Position> ps = e2ps.get(e);
View Full Code Here

  }

  public Vector<Position> calcEnds(Vector<Map.Entry<Box,Equation>> es, EquationList el) {
    Vector<Position> ends = new Vector<Position>();
    for (Map.Entry<Box,Equation> entry : es) {
      Box box = entry.getKey();
      Equation e = entry.getValue();
      if (e==null) continue;
      if (e.getEquationList()!=el) continue;
      Position p = equationToPosition.get(e);
      if (p==null) continue;
      Offset inner = box.getInnerRectangle();
      ends.add(new Position(p.x + inner.width/2.0, p.y + inner.height/2.0));
    }
    return ends;
  }
View Full Code Here

TOP

Related Classes of ket.display.box.Box

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.