Package geom

Examples of geom.Offset


    for (Box b : boxSet) { // Move boxes away from edges.
      Equation e = boxToEquation.get(b);
      if (e==null) continue;
      Position p = equationToPosition.get(e);
      if (p==null) continue;
      Offset inner = b.getInnerRectangle();
      double mx = panelRectangle.width-KetPanel.LEFT_BORDER_SIZE-KetPanel.RIGHT_BORDER_SIZE - inner.width;
      double my = panelRectangle.height-KetPanel.TOP_BORDER_SIZE-KetPanel.BOTTOM_BORDER_SIZE - inner.height - panelDecoration.getModeBoxHeight();
      //- p.x = bound(p.x, KetPanel.LEFT_BORDER_SIZE, mx);
      if (p.x<KetPanel.LEFT_BORDER_SIZE) {
        return true;
      } else if (p.x>mx) {
        return true;
      }
      //- p.y = bound(p.y, KetPanel.TOP_BORDER_SIZE, my);
      if (p.y<KetPanel.TOP_BORDER_SIZE) {
        return true;
      } else if (p.y>my) {
        return true;
      }
    }

    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


      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);
View Full Code Here

      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

    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);
View Full Code Here

    }
    return Collections.unmodifiableSet(set);
  }

  public Position suitableVoid(Box box, int boxIndex, Offset panelRectangle, Set<Box> set) {
    Offset inner = box.getInnerRectangle();
    if (inner==null) { // Never called, but just in case.
      inner = new Offset(0.0, 0.0);
    }
    double cx = KetPanel.LEFT_BORDER_SIZE;
    double mx = panelRectangle.width-KetPanel.LEFT_BORDER_SIZE-KetPanel.RIGHT_BORDER_SIZE-inner.width;
    //- double cy = KetPanel.TOP_BORDER_SIZE + inner.height;
    double cy = KetPanel.TOP_BORDER_SIZE;
View Full Code Here

   */
  private Offset afterBoxSetup(int fontSize, Offset panelRectangle) {
    double shapeWidth = panelRectangle.width - KetPanel.BORDER_OFFSET.width;
    afterRootBox.setupInnerRectangle(fontSize);
    double minimumHeight = afterRootBox.getInnerRectangle().height;
    Offset equationRectangle = new Offset(shapeWidth, minimumHeight);
    labelBox.setup(fontSize, equationRectangle);
    Offset windowWithoutLabel = calcWindowWithoutLabel(equationRectangle);
    afterRootBox.setupOuterRectangle(windowWithoutLabel);
    afterRootBox.calcRootOffset();
    return windowWithoutLabel;
  }
View Full Code Here

  private Offset calcEquationRectangle(Offset panelRectangle) {
    if (equationBox==null) { System.out.print(" #0291 "); return null; }
    double shapeWidth = panelRectangle.width - KetPanel.BORDER_OFFSET.width;
    if (equationBox.getInnerRectangle()==null) { System.out.print(" #4921 "); return null; } // <-- (1)
    double minimumHeight = equationBox.getInnerRectangle().height; // BUG: innterRectangle can be null!
    return new Offset(shapeWidth, minimumHeight);
  }
View Full Code Here

  private Offset calcWindowWithoutLabel(Offset equationRectangle) {
    if ( equationRectangle==null ) { System.out.print(" #1342 "); return null; } // BUG?
    if ( labelBox==null ) { System.out.print(" #4382 "); return null; } // BUG?
    if ( labelBox.getInnerRectangle()==null ) { System.out.print(" #9889 "); return null; } // BUG?
    return new Offset(equationRectangle.width-labelBox.getInnerRectangle().width, equationRectangle.height);
  }
View Full Code Here

      ids.put(a, n);
      nodes.add(n);
    }

    for (Node node : nodes) {
      Offset original = new Offset(node.x, node.y);
      Offset rotate = original.rotate(Math.PI/12.0)// 15 deg
      node.x = rotate.width;
      node.y = rotate.height;
    }

    relax(panelRectangle);
View Full Code Here

    equationBox = equation.toBox(colourScheme);
    repaint = false;
    equationBox.setupInnerRectangle(fontSize);
    double minimumHeight = equationBox.getInnerRectangle().height;
    double shapeWidth = panelRectangle.width - KetPanel.BORDER_OFFSET.width;
    Offset windowWithoutLabel = new Offset(shapeWidth, minimumHeight);
    equationBox.setupOuterRectangle(windowWithoutLabel);
    double panelHeightOfNextBox = KetPanel.TOP_BORDER_SIZE;
    actualEquationTopLeft = new Position(KetPanel.LEFT_BORDER_SIZE, panelHeightOfNextBox);
  }
View Full Code Here

TOP

Related Classes of geom.Offset

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.