Package org.eclipse.wb.draw2d.geometry

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


   * 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 < m_columnIntervals.length; column++) {
      Interval columnInterval = m_columnIntervals[column];
      if (columnInterval == null) {
        for (Map.Entry<Interval, Interval> spanEntry : spannedColumnIntervals.entrySet()) {
          Interval spanRange = spanEntry.getKey();
          if (spanRange.contains(column)) {
            int x = spanEntry.getValue().begin;
            int width = spanEntry.getValue().length / spanRange.length;
            for (int _column = spanRange.begin(); _column < spanRange.end(); _column++) {
              if (_column == column) {
                m_columnIntervals[_column] = new Interval(x, width);
              }
              x += width;
            }
            break;
          }
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 < m_rowIntervals.length; row++) {
      Interval rowInterval = m_rowIntervals[row];
      if (rowInterval == null) {
        for (Map.Entry<Interval, Interval> spanEntry : spannedRowIntervals.entrySet()) {
          Interval spanRange = spanEntry.getKey();
          if (spanRange.contains(row)) {
            int y = spanEntry.getValue().begin;
            int height = spanEntry.getValue().length / spanRange.length;
            for (int _row = spanRange.begin(); _row < spanRange.end(); _row++) {
              if (_row == row) {
                m_rowIntervals[_row] = new Interval(y, height);
              }
              y += height;
            }
            break;
          }
View Full Code Here

      }
    }
    // find existing column
    for (int columnIndex = 0; columnIndex < columnIntervals.length; columnIndex++) {
      boolean isLast = columnIndex == columnIntervals.length - 1;
      Interval interval = columnIntervals[columnIndex];
      Interval nextInterval = !isLast ? columnIntervals[columnIndex + 1] : null;
      // before first
      if (location.x < columnIntervals[0].begin) {
        m_target.m_column = 0;
        m_target.m_columnInsert = true;
        // prepare parameters
        int[] parameters =
            getInsertFeedbackParameters(new Interval(0, 0), interval, INSERT_COLUMN_SIZE);
        // feedback
        m_target.m_feedbackBounds.x = parameters[3];
        m_target.m_feedbackBounds.width = parameters[4] - parameters[3];
        // insert
        m_target.m_columnInsertBounds.x = parameters[1];
        m_target.m_columnInsertBounds.width = parameters[2] - parameters[1];
        // 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;
          // prepare parameters
          int[] parameters =
              getInsertFeedbackParameters(interval, nextInterval, INSERT_COLUMN_SIZE);
          // feedback
          m_target.m_feedbackBounds.x = parameters[3];
          m_target.m_feedbackBounds.width = parameters[4] - parameters[3];
          // insert
          m_target.m_columnInsertBounds.x = parameters[1];
          m_target.m_columnInsertBounds.width = parameters[2] - parameters[1];
          // 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 virtual column
    if (m_target.m_column == -1) {
      int columnGap = gridInfo.getVirtualColumnGap();
      int columnSize = gridInfo.getVirtualColumnSize();
      //
      int newWidth = columnSize + columnGap;
      int newDelta = (location.x - lastX - columnGap / 2) / newWidth;
      //
      m_target.m_column = columnIntervals.length + newDelta;
      m_target.m_feedbackBounds.x = lastX + columnGap + newWidth * newDelta;
      m_target.m_feedbackBounds.width = columnSize + 1;
    }
    // find existing row
    for (int rowIndex = 0; rowIndex < rowIntervals.length; rowIndex++) {
      boolean isLast = rowIndex == rowIntervals.length - 1;
      Interval interval = rowIntervals[rowIndex];
      Interval nextInterval = !isLast ? rowIntervals[rowIndex + 1] : null;
      // before first
      if (location.y < rowIntervals[0].begin) {
        m_target.m_row = 0;
        m_target.m_rowInsert = true;
        // prepare parameters
        int[] parameters =
            getInsertFeedbackParameters(new Interval(0, 0), interval, INSERT_ROW_SIZE);
        // feedback
        m_target.m_feedbackBounds.y = parameters[3];
        m_target.m_feedbackBounds.height = parameters[4] - parameters[3];
        // insert
        m_target.m_rowInsertBounds.y = parameters[1];
View Full Code Here

    int x;
    int size;
    if (target != null) {
      index = target.getDimension().getIndex();
      // prepare previous interval
      Interval prevInterval;
      if (index == 0) {
        prevInterval = new Interval(0, 0);
      } else {
        prevInterval = columnIntervals[index - 1];
      }
      // prepare parameters
      int[] parameters =
View Full Code Here

    int y;
    int size;
    if (target != null) {
      index = target.getDimension().getIndex();
      // prepare previous interval
      Interval prevInterval;
      if (index == 0) {
        prevInterval = new Interval(0, 0);
      } else {
        prevInterval = rowIntervals[index - 1];
      }
      // prepare parameters
      int[] parameters =
View Full Code Here

  @Override
  protected void refreshVisuals() {
    super.refreshVisuals();
    // prepare column interval
    Interval interval;
    {
      int index = m_dimension.getIndex();
      IGridInfo gridInfo = m_layout.getGridInfo();
      interval = gridInfo.getRowIntervals()[index];
    }
View Full Code Here

      }
    }
    // find existing column
    for (int columnIndex = 0; columnIndex < columnIntervals.length; columnIndex++) {
      boolean isLast = columnIndex == columnIntervals.length - 1;
      Interval interval = columnIntervals[columnIndex];
      Interval nextInterval = !isLast ? columnIntervals[columnIndex + 1] : null;
      // before first
      if (location.x < columnIntervals[0].begin) {
        m_target.m_column = 0;
        m_target.m_columnInsert = true;
        // prepare parameters
        int[] parameters =
            getInsertFeedbackParameters(new Interval(0, 0), interval, INSERT_COLUMN_SIZE);
        // feedback
        m_target.m_feedbackBounds.x = parameters[3];
        m_target.m_feedbackBounds.width = parameters[4] - parameters[3];
        // insert
        m_target.m_columnInsertBounds.x = parameters[1];
        m_target.m_columnInsertBounds.width = parameters[2] - parameters[1];
        // 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;
          // prepare parameters
          int[] parameters =
              getInsertFeedbackParameters(interval, nextInterval, INSERT_COLUMN_SIZE);
          // feedback
          m_target.m_feedbackBounds.x = parameters[3];
          m_target.m_feedbackBounds.width = parameters[4] - parameters[3];
          // insert
          m_target.m_columnInsertBounds.x = parameters[1];
          m_target.m_columnInsertBounds.width = parameters[2] - parameters[1];
          // 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 virtual column
    if (m_target.m_column == -1) {
      int columnGap = gridInfo.getVirtualColumnGap();
      int columnSize = gridInfo.getVirtualColumnSize();
      //
      int newWidth = columnSize + columnGap;
      int newDelta = (location.x - lastX - columnGap / 2) / newWidth;
      //
      m_target.m_column = columnIntervals.length + newDelta;
      m_target.m_feedbackBounds.x = lastX + columnGap + newWidth * newDelta;
      m_target.m_feedbackBounds.width = columnSize + 1;
    }
    // find existing row
    for (int rowIndex = 0; rowIndex < rowIntervals.length; rowIndex++) {
      boolean isLast = rowIndex == rowIntervals.length - 1;
      Interval interval = rowIntervals[rowIndex];
      Interval nextInterval = !isLast ? rowIntervals[rowIndex + 1] : null;
      // before first
      if (location.y < rowIntervals[0].begin) {
        m_target.m_row = 0;
        m_target.m_rowInsert = true;
        // prepare parameters
        int[] parameters =
            getInsertFeedbackParameters(new Interval(0, 0), interval, INSERT_ROW_SIZE);
        // feedback
        m_target.m_feedbackBounds.y = parameters[3];
        m_target.m_feedbackBounds.height = parameters[4] - parameters[3];
        // insert
        m_target.m_rowInsertBounds.y = parameters[1];
View Full Code Here

  @Override
  protected void refreshVisuals() {
    super.refreshVisuals();
    // prepare column interval
    Interval interval;
    {
      int index = m_dimension.getIndex();
      IGridInfo gridInfo = m_layout.getGridInfo();
      interval = gridInfo.getColumnIntervals()[index];
    }
View Full Code Here

    int x;
    int size;
    if (target != null) {
      index = target.getDimension().getIndex();
      // prepare previous interval
      Interval prevInterval;
      if (index == 0) {
        prevInterval = new Interval(0, 0);
      } else {
        prevInterval = columnIntervals[index - 1];
      }
      // prepare parameters
      int[] parameters =
View Full Code Here

    int y;
    int size;
    if (target != null) {
      index = target.getDimension().getIndex();
      // prepare previous interval
      Interval prevInterval;
      if (index == 0) {
        prevInterval = new Interval(0, 0);
      } else {
        prevInterval = rowIntervals[index - 1];
      }
      // prepare parameters
      int[] parameters =
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.