Ejemplo n.º 1
0
 /**
  * synchronize frame shape and location (TextLayout only) ; this is called by syncShape(), so that
  * subclasser might override easily when only rectangular shapes are availables.
  */
 protected void syncFrame() {
   PicText te = (PicText) element;
   if (!te.isFramed()) {
     return;
   }
   AffineTransform tr =
       new AffineTransform(); // maps Image coordinates to Model coordinates (see paint)
   tr.setToIdentity(); // reset
   PicPoint anchor = te.getCtrlPt(TextEditable.P_ANCHOR, ptBuf);
   tr.rotate(getRotation(), anchor.x, anchor.y); // rotate along P_ANCHOR !
   shape = tr.createTransformedShape(te.getShapeOfFrame());
 }
Ejemplo n.º 2
0
  /** Synchronizes bounding box with the model ; */
  protected void syncBounds() {
    PicText te = (PicText) element;
    // [pending] Il faut tenir compte de la rotation !

    Rectangle2D latexBB =
        null; // BB relative to latex dimensions (including rotation) (without frame)
    Rectangle2D textLayoutBB =
        null; // BB relative to textLayout dimensions (including rotation) (without frame)
    Rectangle2D textBB = null; // BB of the text (including rotation), without frame

    if (areDimensionsComputed) { // compute latexBB
      Rectangle2D nonRotated =
          new Rectangle2D.Double(
              te.getLeftX(), te.getBottomY(), te.getWidth(), te.getHeight() + te.getDepth());
      AffineTransform tr =
          new AffineTransform(); // maps Image coordinates to Model coordinates (see paint)
      tr.setToIdentity(); // reset
      PicPoint anchor = te.getCtrlPt(TextEditable.P_ANCHOR, ptBuf);
      tr.rotate(getRotation(), anchor.x, anchor.y); // rotate along P_ANCHOR !
      latexBB = tr.createTransformedShape(nonRotated).getBounds2D();
    }

    if (image == null) { // compute textLayoutBB
      Rectangle2D nonRotated = textLayout.getBounds();
      textLayoutBB = text2ModelTr.createTransformedShape(nonRotated).getBounds2D();
    }

    // use textLayoutBB or latexBB or their union
    if (image != null) textBB = latexBB;
    else {
      if (!areDimensionsComputed) textBB = textLayoutBB;
      else {
        textBB = latexBB.createUnion(textLayoutBB);
      }
    }

    // union with frame BB
    if (te.isFramed()) {
      super.syncBounds(); // update bounds of the frame if necessary
      Rectangle2D.union(super.bounds, textBB, this.bounds);
    } else this.bounds = textBB;
  }