Examples of mxRectangle


Examples of com.mxgraph.util.mxRectangle

   * (non-Javadoc)
   * @see com.mxgraph.canvas.mxICanvas#drawLabel()
   */
  public Object drawLabel(String label, mxCellState state, boolean html)
  {
    mxRectangle bounds = state.getLabelBounds();

    if (drawLabels && bounds != null)
    {
      int x = (int) bounds.getX() + translate.x;
      int y = (int) bounds.getY() + translate.y;
      int w = (int) bounds.getWidth();
      int h = (int) bounds.getHeight();
      Map<String, Object> style = state.getStyle();

      return drawText(label, x, y, w, h, style);
    }

View Full Code Here

Examples of com.mxgraph.util.mxRectangle

              mxConstants.STYLE_IMAGE_HEIGHT,
              mxConstants.DEFAULT_IMAGESIZE) * scale);
          int spacing = (int) (mxUtils.getInt(style,
              mxConstants.STYLE_SPACING, 2) * scale);

          mxRectangle imageBounds = new mxRectangle(x, y, w, h);

          if (imgAlign.equals(mxConstants.ALIGN_CENTER))
          {
            imageBounds.setX(imageBounds.getX()
                + (imageBounds.getWidth() - imgWidth) / 2);
          }
          else if (imgAlign.equals(mxConstants.ALIGN_RIGHT))
          {
            imageBounds.setX(imageBounds.getX()
                + imageBounds.getWidth() - imgWidth - spacing
                - 2);
          }
          else
          // LEFT
          {
            imageBounds.setX(imageBounds.getX() + spacing + 4);
          }

          if (imgValign.equals(mxConstants.ALIGN_TOP))
          {
            imageBounds.setY(imageBounds.getY() + spacing);
          }
          else if (imgValign.equals(mxConstants.ALIGN_BOTTOM))
          {
            imageBounds
                .setY(imageBounds.getY()
                    + imageBounds.getHeight() - imgHeight
                    - spacing);
          }
          else
          // MIDDLE
          {
            imageBounds.setY(imageBounds.getY()
                + (imageBounds.getHeight() - imgHeight) / 2);
          }

          imageBounds.setWidth(imgWidth);
          imageBounds.setHeight(imgHeight);

          elem = document.createElement("g");
          elem.appendChild(background);

          Element imageElement = createImageElement(
              imageBounds.getX(), imageBounds.getY(),
              imageBounds.getWidth(), imageBounds.getHeight(),
              img, false, false, false, isEmbedded());

          if (opacity != 100)
          {
            String value = String.valueOf(opacity / 100);
View Full Code Here

Examples of com.mxgraph.util.mxRectangle

   * @param cells
   * @return Returns the bounding box for the given cells.
   */
  public mxRectangle getBounds(Object[] cells, boolean boundingBox)
  {
    mxRectangle result = null;

    if (cells != null && cells.length > 0)
    {
      mxIGraphModel model = graph.getModel();

      for (int i = 0; i < cells.length; i++)
      {
        if (model.isVertex(cells[i]) || model.isEdge(cells[i]))
        {
          mxCellState state = getState(cells[i]);

          if (state != null)
          {
            mxRectangle tmp = (boundingBox) ? state
                .getBoundingBox() : state;

            if (tmp != null)
            {
              if (result == null)
              {
                result = new mxRectangle(tmp);
              }
              else
              {
                result.add(tmp);
              }
View Full Code Here

Examples of com.mxgraph.util.mxRectangle

        .getRoot();

    if (cell != null)
    {
      validateBounds(null, cell);
      mxRectangle bounds = validatePoints(null, cell);

      if (bounds == null)
      {
        bounds = new mxRectangle();
      }

      setGraphBounds(bounds);
    }
  }
View Full Code Here

Examples of com.mxgraph.util.mxRectangle

   */
  public mxRectangle validatePoints(mxCellState parentState, Object cell)
  {
    mxIGraphModel model = graph.getModel();
    mxCellState state = getState(cell);
    mxRectangle bbox = null;

    if (state != null)
    {
      if (state.isInvalid())
      {
        mxGeometry geo = graph.getCellGeometry(cell);

        if (geo != null && model.isEdge(cell))
        {
          // Updates the points on the source terminal if its an edge
          mxCellState source = getState(getVisibleTerminal(cell, true));

          if (source != null && model.isEdge(source.getCell())
              && !model.isAncestor(source, cell))
          {
            mxCellState tmp = getState(model.getParent(source
                .getCell()));
            validatePoints(tmp, source);
          }

          // Updates the points on the source terminal if its an edge
          mxCellState target = getState(getVisibleTerminal(cell,
              false));

          if (target != null && model.isEdge(target.getCell())
              && !model.isAncestor(target, cell))
          {
            mxCellState tmp = getState(model.getParent(target
                .getCell()));
            validatePoints(tmp, target);
          }

          updateFixedTerminalPoints(state, source, target);
          updatePoints(state, geo.getPoints(), source, target);
          updateFloatingTerminalPoints(state, source, target);
          updateEdgeBounds(state);
          state.setAbsoluteOffset(getPoint(state, geo));
        }
        else if (geo != null && geo.isRelative() && parentState != null
            && model.isEdge(parentState.getCell()))
        {
          mxPoint origin = getPoint(parentState, geo);

          if (origin != null)
          {
            state.setX(origin.getX());
            state.setY(origin.getY());

            origin.setX((origin.getX() / scale) - translate.getX());
            origin.setY((origin.getY() / scale) - translate.getY());
            state.setOrigin(origin);

            childMoved(parentState, state);
          }
        }

        state.setInvalid(false);
      }

      if (model.isEdge(cell) || model.isVertex(cell))
      {
        updateLabelBounds(state);
        bbox = new mxRectangle(updateBoundingBox(state));
      }
    }

    if (state != null
        && (!graph.isCellCollapsed(cell) || cell == currentRoot))
    {
      int childCount = model.getChildCount(cell);

      for (int i = 0; i < childCount; i++)
      {
        Object child = model.getChildAt(cell, i);
        mxRectangle bounds = validatePoints(state, child);

        if (bounds != null)
        {
          if (bbox == null)
          {
View Full Code Here

Examples of com.mxgraph.util.mxRectangle

    Map<String, Object> style = state.getStyle();

    if (mxUtils.getString(style, mxConstants.STYLE_OVERFLOW, "").equals(
        "fill"))
    {
      state.setLabelBounds(new mxRectangle(state));
    }
    else if (state.getLabel() != null)
    {
      mxRectangle vertexBounds = (!graph.getModel().isEdge(cell)) ? state
          : null;
      state.setLabelBounds(mxUtils.getLabelPaintBounds(state.getLabel(),
          style, graph.isHtmlLabel(cell), state.getAbsoluteOffset(),
          vertexBounds, scale));
    }
View Full Code Here

Examples of com.mxgraph.util.mxRectangle

   * updated.
   */
  public mxRectangle updateBoundingBox(mxCellState state)
  {
    // Gets the cell bounds and adds shadows and markers
    mxRectangle rect = new mxRectangle(state);
    Map<String, Object> style = state.getStyle();

    // Adds extra pixels for the marker and stroke assuming
    // that the border stroke is centered around the bounds
    // and the first pixel is drawn inside the bounds
    double strokeWidth = Math.max(
        1,
        Math.round(mxUtils.getInt(style, mxConstants.STYLE_STROKEWIDTH,
            1) * scale));
    strokeWidth -= Math.max(1, strokeWidth / 2);

    if (graph.getModel().isEdge(state.getCell()))
    {
      int ms = 0;

      if (style.containsKey(mxConstants.STYLE_ENDARROW)
          || style.containsKey(mxConstants.STYLE_STARTARROW))
      {
        ms = (int) Math.round(mxConstants.DEFAULT_MARKERSIZE * scale);
      }

      // Adds the strokewidth
      rect.grow(ms + strokeWidth);

      // Adds worst case border for an arrow shape
      if (mxUtils.getString(style, mxConstants.STYLE_SHAPE, "").equals(
          mxConstants.SHAPE_ARROW))
      {
        rect.grow(mxConstants.ARROW_WIDTH / 2);
      }
    }
    else
    {
      rect.grow(strokeWidth);
    }

    // Adds extra pixels for the shadow
    if (mxUtils.isTrue(style, mxConstants.STYLE_SHADOW))
    {
      rect.setWidth(rect.getWidth() + mxConstants.SHADOW_OFFSETX);
      rect.setHeight(rect.getHeight() + mxConstants.SHADOW_OFFSETY);
    }

    // Adds oversize images in labels
    if (mxUtils.getString(style, mxConstants.STYLE_SHAPE, "").equals(
        mxConstants.SHAPE_LABEL))
    {
      if (mxUtils.getString(style, mxConstants.STYLE_IMAGE) != null)
      {
        double w = mxUtils.getInt(style, mxConstants.STYLE_IMAGE_WIDTH,
            mxConstants.DEFAULT_IMAGESIZE) * scale;
        double h = mxUtils.getInt(style,
            mxConstants.STYLE_IMAGE_HEIGHT,
            mxConstants.DEFAULT_IMAGESIZE)
            * scale;

        double x = state.getX();
        double y = 0;

        String imgAlign = mxUtils.getString(style,
            mxConstants.STYLE_IMAGE_ALIGN, mxConstants.ALIGN_LEFT);
        String imgValign = mxUtils.getString(style,
            mxConstants.STYLE_IMAGE_VERTICAL_ALIGN,
            mxConstants.ALIGN_MIDDLE);

        if (imgAlign.equals(mxConstants.ALIGN_RIGHT))
        {
          x += state.getWidth() - w;
        }
        else if (imgAlign.equals(mxConstants.ALIGN_CENTER))
        {
          x += (state.getWidth() - w) / 2;
        }

        if (imgValign.equals(mxConstants.ALIGN_TOP))
        {
          y = state.getY();
        }
        else if (imgValign.equals(mxConstants.ALIGN_BOTTOM))
        {
          y = state.getY() + state.getHeight() - h;
        }
        else
        // MIDDLE
        {
          y = state.getY() + (state.getHeight() - h) / 2;
        }

        rect.add(new mxRectangle(x, y, w, h));
      }
    }

    // Adds the rotated bounds to the bounding box if the
    // shape is rotated
    double rotation = mxUtils.getDouble(style, mxConstants.STYLE_ROTATION);
    mxRectangle bbox = mxUtils.getBoundingBox(rect, rotation);

    // Add the rotated bounding box to the non-rotated so
    // that all handles are also covered
    rect.add(bbox);

View Full Code Here

Examples of com.mxgraph.util.mxRectangle

    {
      mxPerimeterFunction perimeter = getPerimeterFunction(terminal);

      if (perimeter != null && next != null)
      {
        mxRectangle bounds = getPerimeterBounds(terminal, border);

        if (bounds.getWidth() > 0 || bounds.getHeight() > 0)
        {
          point = perimeter.apply(bounds, terminal, next, orthogonal);
        }
      }
View Full Code Here

Examples of com.mxgraph.util.mxRectangle

    for (mxGraphAbstractHierarchyCell cell : rank)
    {
      if (cell.isVertex())
      {
        mxGraphHierarchyNode node = (mxGraphHierarchyNode) cell;
        mxRectangle bounds = layout.getVertexBounds(node.cell);

        if (bounds != null)
        {
          if (orientation == SwingConstants.NORTH
              || orientation == SwingConstants.SOUTH)
          {
            cell.width = bounds.getWidth();
            cell.height = bounds.getHeight();
          }
          else
          {
            cell.width = bounds.getHeight();
            cell.height = bounds.getWidth();
          }
        }
        else
        {
          boundsWarning = true;
View Full Code Here

Examples of com.mxgraph.util.mxRectangle

        mxGraphAbstractHierarchyCell cell = iter.next();

        if (cell.isVertex())
        {
          mxGraphHierarchyNode node = (mxGraphHierarchyNode) cell;
          mxRectangle bounds = layout.getVertexBounds(node.cell);

          if (bounds != null)
          {
            if (orientation == SwingConstants.NORTH
                || orientation == SwingConstants.SOUTH)
            {
              cell.width = bounds.getWidth();
              cell.height = bounds.getHeight();
            }
            else
            {
              cell.width = bounds.getHeight();
              cell.height = bounds.getWidth();
            }
          }
          else
          {
            boundsWarning = true;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.