コード例 #1
0
ファイル: TextViewHybrid.java プロジェクト: zukov/Jpicedt
  /** 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;
  }
コード例 #2
0
ファイル: EdgeRenderer.java プロジェクト: mongkie/mongkie
 /** @see prefuse.render.Renderer#setBounds(prefuse.visual.VisualItem) */
 @Override
 public void setBounds(VisualItem item) {
   if (!m_manageBounds) {
     return;
   }
   Shape shape = getShape(item);
   if (shape == null) {
     item.setBounds(item.getX(), item.getY(), 0, 0);
     return;
   }
   //        GraphicsLib.setBounds(item, shape, getStroke(item));
   //        if (m_curArrow != null) {
   //            Rectangle2D bbox = (Rectangle2D) item.get(VisualItem.BOUNDS);
   //            Rectangle2D.union(bbox, m_curArrow.getBounds2D(), bbox);
   //        }
   GraphicsLib.getBounds(m_tmpBounds, shape, getStroke(item));
   if (m_curArrow != null) {
     Rectangle2D.union(m_tmpBounds, m_curArrow.getBounds2D(), m_tmpBounds);
   }
   item.setBounds(
       m_tmpBounds.getX(), m_tmpBounds.getY(), m_tmpBounds.getWidth(), m_tmpBounds.getHeight());
 }