Point myPoint = new Point( 0, 0 ); System.out.println( myPoint ); myPoint.setLocation( 1.0, 0.0 ); System.out.println( myPoint ); String myString = new String( "old String" ); System.out.println( myString ); myString.replaceAll( "old", "new" ); System.out.println( myString );
private void recenterMouse(final Component component) { if (robot != null) { eventsSinceRecenter = 0; isRecentering = true; centerLocation.setLocation(component.getWidth() / 2, component.getHeight() / 2); centerLocationOnScreen.setLocation(centerLocation); SwingUtilities.convertPointToScreen(centerLocationOnScreen, component); robot.mouseMove(centerLocationOnScreen.x, centerLocationOnScreen.y); } }
/** * This method calculates ellipse intersection with line * @param shape Bounds of this shape used to calculate parameters of inscribed into this bounds ellipse. * @param line * @return Intersection point */ private static Point getEllipseIntersection(Shape shape, Line2D.Double line) { double angle = Math.atan2(line.y2 - line.y1, line.x2 - line.x1); double x = shape.getBounds2D().getWidth() / 2 * Math.cos(angle) + shape.getBounds2D().getCenterX(); double y = shape.getBounds2D().getHeight() / 2 * Math.sin(angle) + shape.getBounds2D().getCenterY(); Point p = new Point(); p.setLocation(x, y); return p; }
vp.translate(pp.x-cp.x, pp.y-cp.y); image.scrollRectToVisible(new Rectangle(vp, vport.getSize())); pp.setLocation(cp); pp.setLocation(e.getPoint());
ypoints[npoints-1] = Math.min(ypoints[npoints-1], scaledY); lastPointOfOptimisation.setLocation(scaledX, scaledY); lastPointWasOptimised = true;
@Override public MouseEvent mouseDragged(MouseEvent mouseEvent) { if (!inOverlayDraggingMode) { return mouseEvent; } final Point mousePoint = mouseEvent.getPoint(); mousePosition.setLocation(mousePoint); final Rectangle canvasRect = new Rectangle(client.getRealDimensions()); if (!canvasRect.contains(mousePoint)) { return mouseEvent; } if (movedOverlay != null) { final Dimension realDimension = client.getRealDimensions(); mousePoint.translate(-overlayOffset.x, -overlayOffset.y); mousePoint.x = Ints.constrainToRange(mousePoint.x, 0, realDimension.width - movedOverlay.getBounds().width); mousePoint.y = Ints.constrainToRange(mousePoint.y, 0, realDimension.height - movedOverlay.getBounds().height); movedOverlay.setPreferredPosition(null); movedOverlay.setPreferredLocation(mousePoint); mouseEvent.consume(); } return mouseEvent; }
mousePosition.setLocation(mousePoint); overlayOffset.setLocation(offset);
mousePosition.setLocation(-1, -1);
location.setLocation(snapCorner.getX() + translation.x, snapCorner.getY() + translation.y); final Point padding = OverlayUtil.padPosition(overlayPosition, dimension, PADDING); snapCorner.translate(padding.x, padding.y); location.setLocation(preferredLocation);
/** * This method calculates intersections of two lines. * @param a Line 1 * @param b Line 2 * @return Intersection point */ private static Point getLinesIntersection(Line2D a, Line2D b) { double d = (a.getX1() - a.getX2()) * (b.getY2() - b.getY1()) - (a.getY1() - a.getY2()) * (b.getX2() - b.getX1()); double da = (a.getX1() - b.getX1()) * (b.getY2() - b.getY1()) - (a.getY1() - b.getY1()) * (b.getX2() - b.getX1()); double ta = da / d; Point p = new Point(); p.setLocation(a.getX1() + ta * (a.getX2() - a.getX1()), a.getY1() + ta * (a.getY2() - a.getY1())); return p; } }
/** * Records the map position of the mouse event in case this button press is the beginning of a * mouse drag * * @param ev the mouse event */ @Override public void onMousePressed(MapMouseEvent ev) { startPosDevice.setLocation(ev.getPoint()); startPosWorld.setLocation(ev.getWorldPos()); }
camelLoc.setLocation(0,0);
AudioFeedback.this.config.store(); currentMixPoint.setLocation(newX, newY); audioFeedbackFrame.repaint();
/** Called after the base image has been dragged. Sets the new map area and transforms */ protected void afterImageMoved() { paramsLock.writeLock().lock(); try { int dx = imageOrigin.x; int dy = imageOrigin.y; DirectPosition2D newPos = new DirectPosition2D(dx, dy); mapContent.getViewport().getScreenToWorld().transform(newPos, newPos); ReferencedEnvelope env = new ReferencedEnvelope(mapContent.getViewport().getBounds()); env.translate(env.getMinimum(0) - newPos.x, env.getMaximum(1) - newPos.y); doSetDisplayArea(env); imageOrigin.setLocation(0, 0); baseImageMoved.set(false); } finally { paramsLock.writeLock().unlock(); } }
currentMixPoint.setLocation(x,y);
int dx = e.getX() - mousePt.x; int dy = e.getY() - mousePt.y; textPt.setLocation(textPt.x + dx, textPt.y + dy); mousePt = e.getPoint(); repaint();
point.setLocation(0, 0); blocks = 0; update();
point.setLocation(baseX + (maxCul - currentAttachmentCol) * Math.max(permWithAttachments.getWidth() / 10, ATTACHMENTS_MIN_DX_OFFSET), rectangleBaseCard.getY()); rectangleBaseCard.setLocation(point);
@Override public void mouseDragged(MouseEvent e) { Point newPos = e.getPoint(); SwingUtilities.convertPointToScreen(newPos, SizeGrip.this); int xDelta = newPos.x - origPos.x; int yDelta = newPos.y - origPos.y; Window wind = SwingUtilities.getWindowAncestor(SizeGrip.this); if (wind!=null) { // Should always be true if (getComponentOrientation().isLeftToRight()) { int w = wind.getWidth(); if (newPos.x>=wind.getX()) { w += xDelta; } int h = wind.getHeight(); if (newPos.y>=wind.getY()) { h += yDelta; } wind.setSize(w,h); } else { // RTL int newW = Math.max(1, wind.getWidth()-xDelta); int newH = Math.max(1, wind.getHeight()+yDelta); wind.setBounds(newPos.x, wind.getY(), newW, newH); } // invalidate()/validate() needed pre-1.6. wind.invalidate(); wind.validate(); } origPos.setLocation(newPos); }
input = new Point(); input.setLocation(-1, -1); return input; // Match hidden in a fold input.setLocation(caretPosition, offset); return input; token.getLanguageIndex()==languageIndex) { if (numEmbedded==0) { input.setLocation(caretPosition, offset); return input;