예제 #1
0
 public void selectElementsOnGrid(int x) {
   for (AbstractElement e : tweetFlow.getmElements().values()) {
     if (e instanceof ServiceRequest) {
       if (e.getMiddleX() == x) {
         tweetFlow.getmSelected().put(e.getId(), e);
         e.modeSelected();
       }
     }
   }
 }
예제 #2
0
  public int findGridHorizontal() {
    int x = tweetFlow.getTouchElement().getMiddleX();
    int xDiff = Integer.MAX_VALUE;
    int xNew = 0;

    for (AbstractElement e : tweetFlow.getmElements().values()) {
      if (e instanceof ServiceRequest) {
        if (tweetFlow.getTouchElement().getId() != e.getId()) {
          if ((Math.abs(x - e.getMiddleX())) < xDiff) {
            xDiff = Math.abs(x - e.getMiddleX());
            xNew = e.getMiddleX();
          }
        }
      }
    }

    return xNew;
  }
예제 #3
0
  public boolean isThereGridHorizontal() {
    int x = tweetFlow.getTouchElement().getMiddleX();
    int xDiff = Integer.MAX_VALUE;

    for (AbstractElement e : tweetFlow.getmElements().values()) {
      if (e instanceof ServiceRequest) {
        if (tweetFlow.getTouchElement().getId() != e.getId()) {
          if ((Math.abs(x - e.getMiddleX())) < xDiff) {
            xDiff = Math.abs(x - e.getMiddleX());
          }
        }
      }
    }

    if (xDiff < 30) return true;

    return false;
  }
예제 #4
0
 public ArrayList<ServiceRequest> getElementsOnGrid(int x) {
   ArrayList<ServiceRequest> gridElements = new ArrayList<ServiceRequest>();
   for (AbstractElement e : tweetFlow.getmElements().values()) {
     if (e instanceof ServiceRequest) {
       if (e.getMiddleX() == x) {
         gridElements.add((ServiceRequest) e);
       }
     }
   }
   return gridElements;
 }
예제 #5
0
  public int getTouchOnGrid(int xScaled) {
    int x = xScaled - mOffsetX;
    int xDiff = Integer.MAX_VALUE;
    int xNew = 0;

    for (AbstractElement e : tweetFlow.getmElements().values()) {
      if (e instanceof ServiceRequest) {
        if ((Math.abs(x - e.getMiddleX())) < xDiff) {
          xDiff = Math.abs(x - e.getMiddleX());
          xNew = e.getMiddleX();
        }
      }
    }

    return xNew;
  }
예제 #6
0
  public boolean isTouchOnGrid(int xScaled) {
    int x = xScaled - mOffsetX;
    int xDiff = Integer.MAX_VALUE;

    for (AbstractElement e : tweetFlow.getmElements().values()) {
      if (e instanceof ServiceRequest) {
        if ((Math.abs(x - e.getMiddleX())) < xDiff) {
          xDiff = Math.abs(x - e.getMiddleX());
        }
      }
    }

    if (xDiff < 30) return true;

    return false;
  }
예제 #7
0
  public int findGridNearGridHorizontal(ArrayList<ServiceRequest> gridElements) {
    int x = gridElements.get(0).getMiddleX();
    int xDiff = Integer.MAX_VALUE;
    int xNew = 0;

    for (AbstractElement e : tweetFlow.getmElements().values()) {
      if (e instanceof ServiceRequest) {
        if ((!gridElements.contains(e)) && ((Math.abs(x - e.getMiddleX())) < xDiff)) {
          xDiff = Math.abs(x - e.getMiddleX());
          xNew = e.getMiddleX();
        }
      }
    }

    return xNew;
  }
예제 #8
0
  public boolean isThereGridNearGridHorizontal(ArrayList<ServiceRequest> gridElements) {
    if (gridElements == null) return false;

    if (gridElements.isEmpty()) return false;

    int x = gridElements.get(0).getMiddleX();
    int xDiff = Integer.MAX_VALUE;

    for (AbstractElement e : tweetFlow.getmElements().values()) {
      if (e instanceof ServiceRequest) {
        if ((!gridElements.contains(e)) && ((Math.abs(x - e.getMiddleX())) < xDiff)) {
          xDiff = Math.abs(x - e.getMiddleX());
        }
      }
    }

    if (xDiff < 15) return true;

    return false;
  }
예제 #9
0
  public void draw(Canvas canvas) {
    if (rasterOn) {
      horizontalRasterCT = (canvas.getWidth() / RASTER_HORIZONTAL_WIDTH) + 3;

      Paint paint = new Paint();
      paint.setPathEffect(new DashPathEffect(new float[] {10, 3, 6, 3}, 1));
      float scale = editorView.getmScaleFactor();

      if ((snapMode == SNAP_OFF) || (snapMode == SNAP_RASTER)) {
        paint.setColor(Color.BLUE);

        ArrayList<Integer> gridLines = createRasterLines();

        for (int i = 0; i < gridLines.size(); i++) {
          canvas.drawLine(
              gridLines.get(i),
              (int) ((0 - mOffsetY) / scale),
              gridLines.get(i),
              (int) ((canvas.getHeight() - mOffsetY) / scale),
              paint);
        }
      }

      if (snapMode == SNAP_GRID) {
        paint.setColor(Color.RED);

        for (AbstractElement e : tweetFlow.getmElements().values()) {
          if (e instanceof ServiceRequest) {
            canvas.drawLine(
                e.getMiddleX(),
                (int) ((0 - mOffsetY) / scale),
                e.getMiddleX(),
                (int) ((canvas.getHeight() - mOffsetY) / scale),
                paint);
          }
        }
      }
    }
  }