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; }
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; }
public int findGridNearElementHorizontal(AbstractElement element) { int x = element.getMiddleX(); int xDiff = Integer.MAX_VALUE; int xNew = 0; for (AbstractElement e : tweetFlow.getmElements().values()) { if (e instanceof ServiceRequest) { if ((element.getId() != e.getId()) && ((Math.abs(x - e.getMiddleX())) < xDiff)) { xDiff = Math.abs(x - e.getMiddleX()); xNew = e.getMiddleX(); } } } return xNew; }
public boolean isThereGridNearElementHorizontal(AbstractElement element) { int x = element.getMiddleX(); int xDiff = Integer.MAX_VALUE; for (AbstractElement e : tweetFlow.getmElements().values()) { if (e instanceof ServiceRequest) { if ((element.getId() != e.getId()) && ((Math.abs(x - e.getMiddleX())) < xDiff)) { xDiff = Math.abs(x - e.getMiddleX()); } } } if (xDiff < 15) return true; return false; }
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; }
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(); } } } }
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; }
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; }
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); } } } } }