Package ket.display.box

Examples of ket.display.box.Box


  public Set<Box> createBox(ColourScheme colourScheme, int fontSize, Offset panelRectangle) {
    Set<Box> set = Collections.synchronizedSet(new HashSet<Box>());
    for (int boxIndex=0; boxIndex<getNumberOfEquations(); boxIndex++) {
      Equation equation = getEquation(boxIndex);
      if (equation==null) continue;
      Box box = equation.toBox(colourScheme);
      box.setupInnerRectangle(fontSize);
      Offset equationRectangle = box.getInnerRectangle();
      box.setupOuterRectangle(equationRectangle);
      set.add(box);
      if (box==null) continue;
      if (!equationToPosition.containsKey(equation)) {
        Position p = suitableVoid(box, boxIndex, panelRectangle, set);
        equationToPosition.put(equation,  p);
View Full Code Here


    */
    equation.paint(g2D, topLeft, colourScheme);
  }

  public Box findDeepestBox(Position p) {
    Box equationMatch = equation.findDeepestBox(p);
    if (equationMatch!=null && equationMatch.getArgument()!=null) {
      return equationMatch;
    }
    Box labelMatch = label.findDeepestBox(p);
    if (labelMatch!=null && labelMatch.getArgument()!=null) {
      return equation;
    }
    return null;
  }
View Full Code Here

      label.actualX = centreX + label.x - large;
      label.actualY = centreY + label.y - large;

      BoxText content = new BoxText(null, " " + label.name + " " , Box.RIGHT_ALIGN|Box.BOTTOM_ALIGN);
      Color colour = colourScheme.getBorderColour(); // This doesn't appear appear to be used.
      Box border = new BorderedBox(null, content, Box.X_CENTRE_ALIGN|Box.Y_CENTRE_ALIGN, highlight, colourScheme);

      Position centre = new Position(label.actualX, label.actualY);
      border.setupAndPaint(g2D, colourScheme, Box.DEFAULT_BOX_FONT_SIZE, centre, new Offset(2*large, 2*large), background);
    }
  }
View Full Code Here

    ketPanel.updateForAnimatedDisplay();
  }

  private void saveAsImage(Equation currentEquation) {
    ColourScheme colourScheme = ColourScheme.WHITEBOARD; // TODO: Generalize.
    Box currentBox = currentEquation.toBox(colourScheme);
    BufferedImage image = ImageTools.boxToBufferedImage(currentBox, 800, 600, colourScheme);
    // If image name already ends with ".png", remove it.
    imageName = imageName.replace("\\.png$", "");
    String name = String.format(imageName+"%d.png", imageNumber++);
    Ket.out.println("Writing frame to '" + name + "'");
View Full Code Here

    // Border what the mouse is currently over.
    boolean normalMode = document.getModes().getDocumentState()==DocumentState.NORMAL;
    if (normalMode) {
      Position p = new Position(e.getX(), e.getY());
      Box deepest = ketPanel.findDeepestBox(p);
      ketPanel.markBorder(deepest);
      ketPanel.repaint();
    } else {
      if (responder==mode.getMouseResponder()) {
        mouseLoop.clear();
View Full Code Here

      for (double y=centre.y-step.height; y<=centre.y+step.height; y+=step.height) {
        Position point = new Position(x, y);
        if (!isWithinLoop(point, loop, clockwise, centre)) continue;
        areaCircled += step.area();
        grid.add(point);
        Box box = ketPanel.findDeepestBox(point);
        if (box==null) continue;
        Argument argument = box.getArgument();
        if (argument==null) continue;
        counter.increment(argument);
        if ( ! boxMap.containsKey(argument) ) {
          boxMap.put(argument, box);
        }
        for (Branch a : argument.getAncestors()) {
          counter.increment(a);
        }
      }
    }
    // Remove all keys associated with null boxes.
    for (Argument argument : counter.keyList()) {
      if (boxMap.get(argument)==null) {
        //- System.out.println("[remove " + argument + "]");
        counter.remove(argument);
      }
    }
    // Scale grids by the size of each box so larger boxes require
    // more area of the loop to be selected.
    double norm = 0.0;
    for (Argument argument : counter.keySet()) { // (box, argument, count)
      Box box = boxMap.get(argument);
      if (box==null) continue;
      double count = counter.get(argument);
      double selectedBoxArea = count*step.area();
      double fracCircled = selectedBoxArea/areaCircled;
      double fracBox = selectedBoxArea/box.getArea();
      double weight = fracCircled * fracBox * selectedBoxArea;
      /*-
      double boxFrac = selectedBoxArea / box.getArea(); // Frac area of box.
      //? double weight = boxFrac * selectedArea;
      double weight = boxFrac * selectedBoxArea;
 
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.