public static Util getInstance(){ if (instance==null){ instance = new Util(); } return instance; }
private void computeAndaddToRootPanel() { // compute size and position of current marker int x; int y; int width; int height; if (selectedElements.size() > 0) { Point nwPoint = Util.getInstance().getNWPointFromElements(selectedElements); Point sePoint = Util.getInstance().getSEPointFromElements(selectedElements); x = (int) nwPoint.getX(); y = (int) nwPoint.getY(); width = (int) (sePoint.getX() - nwPoint.getX()); height= (int) (sePoint.getY() - nwPoint.getY()); this.setPixelSize(width, height); uiPanel.setSelectionMarker(this, x+uiPanel.getScrollLeft(), y+uiPanel.getScrollTop()); } }
Point targetCenterPoint = new Point(target.getAbsoluteLeft()+(target.getWidth()/2),target.getAbsoluteTop()+(target.getHeight()/2)); Point sourceIntersectionPoint = Util.getInstance().getClosestIntersectionPointForRectangle(sourceCenterPoint, targetCenterPoint, source.getAbsoluteLeft(), source.getAbsoluteTop(), (int)source.getWidth(), (int)source.getHeight()); Point targetIntersectionPoint = Util.getInstance().getClosestIntersectionPointForRectangle(targetCenterPoint, sourceCenterPoint, target.getAbsoluteLeft(), target.getAbsoluteTop(), (int)target.getWidth(), (int)target.getHeight()); sourceDistances.add(new MagnetDistance(m, Util.getInstance().getDistance(sourceIntersectionPoint.getX(), sourceIntersectionPoint.getY(), m.getAbsoluteLeft(), m.getAbsoluteTop()))); targetDistances.add(new MagnetDistance(m, Util.getInstance().getDistance(targetIntersectionPoint.getX(), targetIntersectionPoint.getY(), m.getAbsoluteLeft(), m.getAbsoluteTop())));
LinearFunction fn1 = this.getLinearFunctionFrom2Points(p1, p2); Point topItersection = this.getIntesectionPointFromLinearFn(fn1, fn2); Point bottomIntersection = this.getIntesectionPointFromLinearFn(fn1, fn3); Point closestPoint = this.getClosestPoint(p2, points,new Region(new Point(rx-1,ry-1),new Point(rx+rwidth+1,ry+rheight+1)));
public Region(IPoint iPoint,IPoint iPoint2) { Direction direction = Util.getInstance().getDirection((Point)iPoint,(Point)iPoint2);
Point intersectionPoint = Util.getInstance().getClosestIntersectionPointForRectangle( p1, p2,
Point nwPoint = Util.getInstance().getNWPointFromElements(elementsView); Point sePoint = Util.getInstance().getSEPointFromElements(elementsView);