Package geom

Examples of geom.Offset


  /**
   * Recursively set the current offset relative to that of its parent.
   */
  protected void calcRootOffset(Offset parentOffset) {
    Position rootPosition = getPosition(new Position(parentOffset));
    rootOffset = new Offset(rootPosition);
  }
View Full Code Here


  protected abstract void draw(Graphics2D g2D, Position topLeft, ColourScheme colourScheme);

  public Position getCentre(Position topLeft) {
    Position corner = getPosition(topLeft);
    Offset innerCentre = getInnerRectangle().getCentre();
    return corner.plus(innerCentre);
  }
View Full Code Here

    return image;
  }
 
  @Override
  protected void calcMinimumSize() {
    innerRectangle = new Offset(image.getWidth(), image.getHeight());
  }
View Full Code Here

  public void setupOuterRectangle(Offset actualSize) {
    double sx = actualSize.width / image.getWidth();
    double sy = actualSize.height / image.getHeight();
    if (sx<1.0 || sy<1.0) { // Scale to the smaller of the image dimensions.
      double scale = Math.min(sx, sy);
      innerRectangle = new Offset(scale*image.getWidth(), scale*image.getHeight());
    } else {
      innerRectangle = new Offset(image.getWidth(), image.getHeight());
    }
    super.setupOuterRectangle(actualSize);
  }
View Full Code Here

  }

  private void alignChildren() {
    for (Box child : children) {
      child.setupOuterRectangle(child.outerRectangle);
      child.parentalShift = new Offset(0.0, 0.0);
    }
    innerRectangle = new Offset(0, 0);
    for (Vector<Box> path : yAxis) {
      double x = 0;
      for (Box child : path) {
        x = Math.max(x, child.outerRectangle.width);
        child.parentalShift.width = innerRectangle.width;
View Full Code Here

    }
    // The actual outer box size is to the bottom right point on the last child box.
    Box last = children.lastElement();
    double horizontalOffset = last.getParentalShift().width + last.getAlignmentShift().width + last.getInnerRectangle().width;
    double verticalOffset = last.getParentalShift().height + last.getAlignmentShift().height + last.getInnerRectangle().height;
    this.outerRectangle = new Offset(horizontalOffset, verticalOffset);
  }
View Full Code Here

    // 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

    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

  public void dragTo(Equation e, Position p) {
    if (equationToPosition.containsKey(e)) {
      // Find the centre of the equation's box
      for (Box b : boxToEquation.keySet()) {
        if (boxToEquation.get(b)!=e) continue;
        Offset inner = b.getInnerRectangle();
        if (inner==null) continue;
        Position q = p.minus(inner.getCentre());
        equationToPosition.put(e, q);
        return;
      }
    }
    equationToPosition.put(e, p);
View Full Code Here

      if (equation==null) { System.out.print(" #2187 "); return false; }
      equationBox = equation.toBox(colourScheme);
      labelBox = equation.getLabelBox(colourScheme);
      labelBox.setProperty(Box.RIGHT_ALIGN);
      equationBox.setupInnerRectangle(fontSize);
      Offset equationRectangle = calcEquationRectangle(panelRectangle);
      if (equationRectangle==null) { System.out.print(" #9862 "); return false; }
      labelBox.setup(fontSize, equationRectangle);
      if (equationBox.getInnerRectangle()==null) { System.out.print(" #0391 "); return false; }
      Offset windowWithoutLabel = calcWindowWithoutLabel(equationRectangle);
      if (windowWithoutLabel==null) { System.out.print(" #9104 "); return false; }
      equationBox.setupOuterRectangle(windowWithoutLabel);
      equationBox.calcRootOffset();
    }
    if (update) {
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.