Package org.eclipse.draw2d.geometry

Examples of org.eclipse.draw2d.geometry.Dimension


     */
    public void relocate(IFigure target) {
      Rectangle targetBounds = ColumnHelper.getColumnBounds(editPart,
          target);

      Dimension targetSize = target.getPreferredSize();

      targetBounds.x += (int) (targetBounds.width * relativeX - ((targetSize.width + 1) / 2));
      targetBounds.y += (int) (targetBounds.height * relativeY - ((targetSize.height + 1) / 2));
      targetBounds.setSize(targetSize);
      target.setBounds(targetBounds);
View Full Code Here


      return;
    }
    Rectangle exposeRegion = rect.getCopy();
    Rectangle portBounds = port.getBounds().getCopy();
    Point viewLocation = port.getViewLocation();
    Dimension diff = calculateDiff(portBounds, exposeRegion);
    if (diff != null) {
      viewLocation.x -= diff.width;
      viewLocation.y -= diff.height;
      canvas.scrollSmoothTo(viewLocation.x, viewLocation.y);
    }
View Full Code Here

   * @param exposeRegion
   * @param canvas
   * @param caretPoint
   */
  private Dimension calculateDiff(Rectangle portBounds, Rectangle caretRect) {
    Dimension diff = new Dimension(0, 0);
    diff.width = calculateX(portBounds, caretRect);
    diff.height = calculateY(portBounds, caretRect);
    return diff;
  }
View Full Code Here

    {
        super(hostPart, new CornerRelativeHandleLocator(hostPart.getFigure(), location));
    }

    protected void init() {
        setPreferredSize(new Dimension(8, 8));
    }
View Full Code Here

    // int suggestedWith = getSuggestedWidth(line, style, provider);
    // int suggestedHeight = getSuggestedHeight(line, style, provider);

    DimensionInfo resultInfo = provider.getPreferredDimension(
        suggestedWith, suggestedHeight);
    Dimension resultSize = resultInfo.getDimension();

    _widgetBox = new WidgetBox(); // ((CSSWidgetFigure)getFlowFigure()).getWidgetBox();
    // if (provider.isHandlingBorder() || style == null)
    // {
    _widgetBox.setWidth(resultSize.width);
View Full Code Here

    if (style != null) {
      borderInset = style.getBorderInsets();
      borderPaddingInset = borderInset.getAdded(style.getPaddingInsets());
    }

    Dimension d1 = _sub1.getPreferredDimension(-1, -1).getDimension();
    Dimension d2 = _sub2.getPreferredDimension(-1, -1).getDimension();

    int minWidth = d2.width + 2 * (borderInset.left + borderInset.right)
        + GAP;
    int prefWidth = d1.width + d2.width + 2
        * (borderPaddingInset.left + borderPaddingInset.right) + GAP;
View Full Code Here

      borderInset = style.getBorderInsets();
      paddingInset = style.getPaddingInsets();
      borderPaddingInset.add(borderInset).add(paddingInset);
    }

    Dimension d1 = _sub1.getPreferredDimension(-1, -1).getDimension();
    Dimension d2 = _sub2.getPreferredDimension(-1, -1).getDimension();
    int prefWidth = d1.width + d2.width + 2 * borderPaddingInset.left + 2
        * borderPaddingInset.right + GAP;
    if (rect.width < prefWidth) {
      paddingInset.left = 0;
      paddingInset.right = 0;
View Full Code Here

    List cells = _tableInfo.getCells();
    for (int i = 0, size = cells.size(); i < size; i++) {
      TableCellInfo cellinfo = (TableCellInfo) cells.get(i);
      if (cellinfo.getColSpan() == 1) {
        int column = cellinfo.getColumnIndex();
        Dimension mincw = cellinfo.getMinCWDimension();
        Dimension maxcw = cellinfo.getMaxCWDimension();
        if (maxcw.width < mincw.width) {
          maxcw.width = mincw.width;
        }
        if (mincw.width > columnMinWidths[column]) {
          columnMinWidths[column] = mincw.width;
        }
        if (maxcw.width > columnMaxWidths[column]) {
          columnMaxWidths[column] = maxcw.width;
        }
      }
    }
    // For caption, determine a maximum and minimum width from it.
    int captionWidth = 0;
    if (_tableInfo.getCaption() != null) {
      captionWidth = _tableInfo.getCaption().getDimension().width;
    }

    // For each cell that spans more than one column, increase the
    // minimum widths of the columns it spans so that together, they
    // are at least as wide as the cell. Do the same for the maximum
    // widths. If possible, widen all spanned columns by approximately
    // the same amount.
    for (int i = 0, size = cells.size(); i < size; i++) {
      TableCellInfo cellinfo = (TableCellInfo) cells.get(i);
      int colspan = cellinfo.getColSpan();
      if (colspan > 1) {
        int column = cellinfo.getColumnIndex();
        Dimension mincw = cellinfo.getMinCWDimension();
        Dimension maxcw = cellinfo.getMaxCWDimension();

        adjustWidth(column, colspan, mincw.width, columnMinWidths);
        adjustWidth(column, colspan, maxcw.width, columnMaxWidths);
      }
    }

    int sigmaMinWidth = 0;
    int sigmaMaxWidth = 0;
    for (int i = 0; i < columnMinWidths.length; i++) {
      sigmaMinWidth += columnMinWidths[i];
      if (columnMaxWidths[i] == Integer.MAX_VALUE) {
        sigmaMaxWidth = Integer.MAX_VALUE;
      } else if (sigmaMaxWidth != Integer.MAX_VALUE) {
        sigmaMaxWidth += columnMaxWidths[i];
        if (sigmaMaxWidth < 0) {
          sigmaMaxWidth = Integer.MAX_VALUE;
        }
      }
    }
    int spacingall = (columnMinWidths.length + 1) * _hspacing;
    sigmaMinWidth += spacingall;
    if (sigmaMaxWidth != Integer.MAX_VALUE) {
      sigmaMaxWidth += spacingall;
      if (sigmaMaxWidth < 0) {
        sigmaMaxWidth = Integer.MAX_VALUE;
      }
    }

    int tableWidth = _tableInfo.getTableWidth();
    if (tableWidth > 0) {
      // If the 'table' or 'inline-table' element's 'width' property has a
      // specified value (W) other than 'auto', the property's computed
      // value
      // is the greater of W and the minimum width required by all the
      // columns
      // plus cell spacing or borders (MIN). If W is greater than MIN, the
      // extra
      // width should be distributed over the columns.
      int maxMin = Math.max(captionWidth, sigmaMinWidth);
      if (maxMin >= tableWidth) {
        tableWidth = maxMin;
      }
      distribute(tableWidth - sigmaMinWidth, columnMinWidths,
          columnMaxWidths);
    } else {
      // If the 'table' or 'inline-table' element has 'width: auto', the
      // computed
      // table width is the greater of the table's containing block width
      // and MIN.
      // However, if the maximum width required by the columns plus cell
      // spacing or
      // borders (MAX) is less than that of the containing block, use MAX.
      // int availableWidth = this.getCurrentLine().getAvailableWidth();
      int maxMin = Math.max(captionWidth, sigmaMaxWidth);
      if (maxMin <= availableWidth) {
        // TODO: if _tableInfo.hasWidthPercentage, then we need take
        // that into consideration
        // to distribute the column width. Left to next version.
        tableWidth = maxMin;
        // columnMinWidths = columnMaxWidths;
      } else {
        tableWidth = availableWidth;
      }
      distribute(tableWidth - sigmaMinWidth, columnMinWidths,
          columnMaxWidths);
    }

    // now columnMinWidths contains width for each column
    _columnWidths = columnMinWidths;

    // ok, we have finished calculating column width.
    // next we need to find out row heights.
    _rowHeights = new int[_tableInfo.getRowCount()];

    // first find out those TR that has height settings and use them.
    List rows = _tableInfo.getRows();
    for (int i = 0, size = rows.size(); i < size && i < _rowHeights.length; i++) {
      TableRowInfo rowInfo = (TableRowInfo) rows.get(i);
      if (rowInfo.getSpecifiedRowHeight() > 0) {
        _rowHeights[i] = rowInfo.getSpecifiedRowHeight();
      }
    }

    // First the cells don't span multiple rows.
    cells = _tableInfo.getCells();
    for (int i = 0, size = cells.size(); i < size; i++) {
      TableCellInfo cellinfo = (TableCellInfo) cells.get(i);
      IFigure figure = cellinfo.getFigure();
      int rowspan = cellinfo.getRowSpan();
      if (rowspan == 1) {
        int cellWidth = getCellWidth(cellinfo, _columnWidths);
        Dimension d = figure.getPreferredSize(cellWidth, cellinfo
            .getHeight());
        if (d.height > _rowHeights[cellinfo.getRowIndex()]) {
          _rowHeights[cellinfo.getRowIndex()] = d.height;
        }
      }
    }

    // Next those cells span multiple rows.
    cells = _tableInfo.getCells();
    for (int i = 0, size = cells.size(); i < size; i++) {
      TableCellInfo cellinfo = (TableCellInfo) cells.get(i);
      IFigure figure = cellinfo.getFigure();
      int rowspan = cellinfo.getRowSpan();
      if (rowspan > 1) {
        int cellWidth = getCellWidth(cellinfo, _columnWidths);
        Dimension d = figure.getPreferredSize(cellWidth, cellinfo
            .getHeight());
        if (d.height > getCellHeight(cellinfo, _rowHeights)) {
          adjustHeight(cellinfo.getRowIndex(), rowspan, d.height,
              _rowHeights);
        }
View Full Code Here

   */
  public Dimension getMaxCWDimension() {
    ICSSFigure figure = getFigure();
    LayoutManager layout = figure.getLayoutManager();
    if (layout instanceof CSSTableCellLayout) {
      Dimension d = ((CSSTableCellLayout) layout).getMaxContentWidthSize(
          figure, _cellWidth, _cellHeight);
      return d;
    }

        // should not happen
View Full Code Here

          int x = 0;
          String skip = text.substring(frag._offset, partialStart);
          x = FlowUtilities.getTextExtents(skip, font).width;
          String todraw = text.substring(partialStart, partialEnd);
          if (todraw.length() > 0) {
            Dimension dimension = FlowUtilities.getTextExtents(skip
                + todraw, font);
            g.fillRectangle(frag._x + x, frag._y, dimension.width
                - x, dimension.height);
            g.drawText(skip + todraw, frag._x, frag._y);
            if (color != null) {
View Full Code Here

TOP

Related Classes of org.eclipse.draw2d.geometry.Dimension

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.