Package org.eclipse.wb.draw2d.geometry

Examples of org.eclipse.wb.draw2d.geometry.Interval


      // prepare row interval
      if (rowIntervals[row] == null) {
        Object trElement = dom.getParent(td);
        Rectangle trBounds = state.getAbsoluteBounds(trElement);
        container.absoluteToRelative(trBounds);
        Interval trInterval = new Interval(trBounds.y, trBounds.height);
        if (rowSpan == 1) {
          rowIntervals[row] = trInterval;
        } else {
          Rectangle tdBounds = state.getAbsoluteBounds(td);
          Interval spannedInterval = new Interval(trBounds.y, tdBounds.height);
          spannedRowIntervals.put(new Interval(row, rowSpan), spannedInterval);
        }
      }
      // prepare column interval
      if (columnIntervals[column] == null) {
        Rectangle tdBounds = state.getAbsoluteBounds(td);
        container.absoluteToRelative(tdBounds);
        Interval columnInterval = new Interval(tdBounds.x, tdBounds.width);
        if (colSpan == 1) {
          columnIntervals[column] = columnInterval;
        } else {
          spannedColumnIntervals.put(new Interval(column, colSpan), columnInterval);
        }
      }
      //Object widgetElement = dom.getElementById(Container_Info.getID(widget));
    }
    // fix spanned columns/rows
View Full Code Here


   * It is possible that some columns don't have individual widgets in not spanned cells, so we can
   * not get exact columns intervals and have to approximate it.
   */
  private void fetchCells_fixSpannedColumns(Map<Interval, Interval> spannedColumnIntervals) {
    for (int column = 0; column < columnIntervals.length; column++) {
      Interval rowInterval = columnIntervals[column];
      if (rowInterval == null) {
        for (Map.Entry<Interval, Interval> spanEntry : spannedColumnIntervals.entrySet()) {
          if (spanEntry.getKey().contains(column)) {
            int x = spanEntry.getValue().begin;
            int width = spanEntry.getValue().length / spanEntry.getKey().length;
            for (int _column = 0; _column < spanEntry.getKey().length; _column++) {
              columnIntervals[column + _column] = new Interval(x, width);
              x += width;
            }
          }
        }
      }
View Full Code Here

   * It is possible that some rows don't have individual widgets in not spanned cells, so we can not
   * get exact row intervals and have to approximate it.
   */
  private void fetchCells_fixSpannedRows(Map<Interval, Interval> spannedRowIntervals) {
    for (int row = 0; row < rowIntervals.length; row++) {
      Interval rowInterval = rowIntervals[row];
      if (rowInterval == null) {
        for (Map.Entry<Interval, Interval> spanEntry : spannedRowIntervals.entrySet()) {
          if (spanEntry.getKey().contains(row)) {
            int y = spanEntry.getValue().begin;
            int height = spanEntry.getValue().length / spanEntry.getKey().length;
            for (int _row = 0; _row < spanEntry.getKey().length; _row++) {
              rowIntervals[row + _row] = new Interval(y, height);
              y += height;
            }
          }
        }
      }
View Full Code Here

    }
    // find existing column
    for (int columnIndex = 0; columnIndex < columnIntervals.length; columnIndex++) {
      boolean isFirst = columnIndex == 0;
      boolean isLast = columnIndex == columnIntervals.length - 1;
      Interval interval = columnIntervals[columnIndex];
      Interval nextInterval = !isLast ? columnIntervals[columnIndex + 1] : null;
      // before first
      if (isFirst) {
        boolean nearBegin = Math.abs(location.x - interval.begin()) < INSERT_COLUMN_SIZE;
        if (nearBegin) {
          m_target.m_column = 0;
          m_target.m_columnInsert = true;
          updateGridFeedback_column(new Interval(0, 0), interval);
          // stop
          break;
        }
      }
      // gap or near to end of interval
      if (!isLast) {
        int gap = nextInterval.begin - interval.end();
        boolean directGap = interval.end() <= location.x && location.x < nextInterval.begin;
        boolean narrowGap = gap < 2 * INSERT_COLUMN_SIZE;
        boolean nearEnd = Math.abs(location.x - interval.end()) < INSERT_COLUMN_SIZE;
        boolean nearBegin = Math.abs(location.x - nextInterval.begin) < INSERT_COLUMN_SIZE;
        if (directGap || narrowGap && (nearEnd || nearBegin)) {
          m_target.m_column = columnIndex + 1;
          m_target.m_columnInsert = true;
          updateGridFeedback_column(interval, nextInterval);
          // stop
          break;
        }
      }
      // prepare "append" parameters
      if (isLast) {
        boolean nearEnd = Math.abs(location.x - interval.end()) < INSERT_COLUMN_SIZE;
        if (nearEnd) {
          m_target.m_column = columnIndex + 1;
          m_target.m_columnInsert = false;
          updateGridFeedback_column(interval, new Interval(interval.end(), 0));
          // stop
          break;
        }
      }
      // column
      if (interval.contains(location.x)) {
        m_target.m_column = columnIndex;
        // feedback
        m_target.m_feedbackBounds.x = interval.begin;
        m_target.m_feedbackBounds.width = interval.length + 1;
        // stop
        break;
      }
    }
    // find existing row
    for (int rowIndex = 0; rowIndex < rowIntervals.length; rowIndex++) {
      boolean isFirst = rowIndex == 0;
      boolean isLast = rowIndex == rowIntervals.length - 1;
      Interval interval = rowIntervals[rowIndex];
      Interval nextInterval = !isLast ? rowIntervals[rowIndex + 1] : null;
      // before first
      if (isFirst) {
        boolean nearBegin = Math.abs(location.y - interval.begin()) < INSERT_ROW_SIZE;
        if (nearBegin) {
          m_target.m_row = 0;
          m_target.m_rowInsert = true;
          updateGridFeedback_row(new Interval(0, 0), interval);
          // stop
          break;
        }
      }
      // gap or near to end of interval
      if (!isLast) {
        int gap = nextInterval.begin - interval.end();
        boolean directGap = interval.end() <= location.y && location.y < nextInterval.begin;
        boolean narrowGap = gap < 2 * INSERT_ROW_SIZE;
        boolean nearEnd = Math.abs(location.y - interval.end()) < INSERT_ROW_SIZE;
        boolean nearBegin = Math.abs(location.y - nextInterval.begin) < INSERT_ROW_SIZE;
        if (directGap || narrowGap && (nearEnd || nearBegin)) {
          m_target.m_row = rowIndex + 1;
          m_target.m_rowInsert = true;
          updateGridFeedback_row(interval, nextInterval);
          // stop
          break;
        }
      }
      // prepare "append" parameters
      if (isLast) {
        boolean nearEnd = Math.abs(location.y - interval.end()) < 2 * INSERT_ROW_SIZE;
        if (nearEnd) {
          m_target.m_row = rowIndex + 1;
          m_target.m_rowInsert = false;
          updateGridFeedback_row(interval, new Interval(interval.end(), 0));
          // stop
          break;
        }
      }
      // row
View Full Code Here

    assertEquals(2, gridInfo.getRowCount());
    assertEquals(2, gridInfo.getColumnCount());
    {
      Interval[] intervals = gridInfo.getRowIntervals();
      assertEquals(2, intervals.length);
      assertEquals(new Interval(2, 100), intervals[0]);
      assertEquals(new Interval(2 + 100 + 2, 200), intervals[1]);
    }
    {
      Interval[] intervals = gridInfo.getColumnIntervals();
      assertEquals(2, intervals.length);
      assertEquals(new Interval(2, 100), intervals[0]);
      assertEquals(new Interval(2 + 100 + 2, 200), intervals[1]);
    }
    // cells rectangle
    {
      {
        Rectangle cells = new Rectangle(0, 0, 1, 1);
View Full Code Here

    IGridInfo gridInfo = panel.getGridInfo();
    assertEquals(2, gridInfo.getColumnCount());
    {
      Interval[] intervals = gridInfo.getColumnIntervals();
      assertEquals(2, intervals.length);
      assertEquals(new Interval(2, 100), intervals[0]);
      assertEquals(new Interval(2 + 100 + 2, 200), intervals[1]);
    }
    // low_getCellOfColumn()
    {
      assertEquals(0, panel.getStatus().getCellOfColumn(0, 0));
      assertEquals(1, panel.getStatus().getCellOfColumn(0, 1));
View Full Code Here

    IGridInfo gridInfo = panel.getGridInfo();
    assertEquals(2, gridInfo.getRowCount());
    {
      Interval[] intervals = gridInfo.getRowIntervals();
      assertEquals(2, intervals.length);
      assertEquals(new Interval(2, 100), intervals[0]);
      assertEquals(new Interval(2 + 100 + 2, 200), intervals[1]);
    }
  }
View Full Code Here

    assertEquals(3, gridInfo.getRowCount());
    assertEquals(3, gridInfo.getColumnCount());
    {
      Interval[] intervals = gridInfo.getRowIntervals();
      assertEquals(3, intervals.length);
      assertEquals(new Interval(RS, RA), intervals[0]);
      assertEquals(new Interval(RS + RA + RS, RA), intervals[1]);
      assertEquals(new Interval(RS + RA + RS + RA + RS, RA), intervals[2]);
    }
    {
      Interval[] intervals = gridInfo.getColumnIntervals();
      assertEquals(3, intervals.length);
      assertEquals(new Interval(CS, CA), intervals[0]);
      assertEquals(new Interval(CS + CA + CS, CA), intervals[1]);
      assertEquals(new Interval(CS + CA + CS + CA + CS, CA), intervals[2]);
    }
    // cells
    {
      List<WidgetInfo> widgets = panel.getChildrenWidgets();
      assertEquals(new Rectangle(0, 0, 1, 1), gridInfo.getComponentCells(widgets.get(0)));
View Full Code Here

    assertEquals(3, gridInfo.getRowCount());
    assertEquals(3, gridInfo.getColumnCount());
    {
      Interval[] intervals = gridInfo.getRowIntervals();
      assertEquals(3, intervals.length);
      assertEquals(new Interval(RS, RA), intervals[0]);
      assertEquals(new Interval(RS + RA + RS, RE), intervals[1]);
      assertEquals(new Interval(RS + RA + RS + RE + RS, RA), intervals[2]);
    }
    {
      Interval[] intervals = gridInfo.getColumnIntervals();
      assertEquals(3, intervals.length);
      assertEquals(new Interval(CS, CA), intervals[0]);
      assertEquals(new Interval(CS + CA + CS, CE), intervals[1]);
      assertEquals(new Interval(CS + CA + CS + CE + CS, CA), intervals[2]);
    }
    // cells
    {
      List<WidgetInfo> widgets = panel.getChildrenWidgets();
      assertEquals(new Rectangle(0, 0, 1, 1), gridInfo.getComponentCells(widgets.get(0)));
View Full Code Here

    IGridInfo gridInfo = panel.getGridInfo();
    // check intervals
    {
      Interval[] intervals = gridInfo.getRowIntervals();
      assertEquals(2, intervals.length);
      assertEquals(new Interval(RS, RA), intervals[0]);
      assertEquals(new Interval(RS + RA + RS, RA), intervals[1]);
    }
    {
      Interval[] intervals = gridInfo.getColumnIntervals();
      assertEquals(3, intervals.length);
      assertEquals(new Interval(CS, CE), intervals[0]);
      assertEquals(new Interval(CS + CE + CS, CA), intervals[1]);
      assertEquals(new Interval(CS + CE + CS + CA + CS, CA), intervals[2]);
    }
    // low_getCellOfColumn()
    {
      assertEquals(0, panel.getStatus().getCellOfColumn(0, 0));
      assertEquals(1, panel.getStatus().getCellOfColumn(0, 2));
View Full Code Here

TOP

Related Classes of org.eclipse.wb.draw2d.geometry.Interval

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.