本文整理汇总了Java中java.awt.Point.translate方法的典型用法代码示例。如果您正苦于以下问题:Java Point.translate方法的具体用法?Java Point.translate怎么用?Java Point.translate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Point
的用法示例。
在下文中一共展示了Point.translate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import java.awt.Point; //导入方法依赖的package包/类
public static void main(final String[] args) throws Exception {
GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] sds = ge.getScreenDevices();
for (GraphicsDevice sd : sds) {
GraphicsConfiguration gc = sd.getDefaultConfiguration();
Rectangle bounds = gc.getBounds();
Point point = new Point(bounds.x, bounds.y);
Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc);
while (point.y < bounds.y + bounds.height - insets.bottom - SIZE) {
while (point.x
< bounds.x + bounds.width - insets.right - SIZE) {
test(point);
point.translate(bounds.width / 5, 0);
}
point.setLocation(bounds.x, point.y + bounds.height / 5);
}
}
}
示例2: scrollAnnotationToVisible
import java.awt.Point; //导入方法依赖的package包/类
public void scrollAnnotationToVisible(Annotation ann) {
// if at least part of the blinking section is visible then we
// need to do no scrolling
// this is required for long annotations that span more than a
// screen
Rectangle visibleView = scroller.getViewport().getViewRect();
int viewStart = textView.viewToModel(visibleView.getLocation());
Point endPoint = new Point(visibleView.getLocation());
endPoint.translate(visibleView.width, visibleView.height);
int viewEnd = textView.viewToModel(endPoint);
int annStart = ann.getStartNode().getOffset().intValue();
int annEnd = ann.getEndNode().getOffset().intValue();
if(annEnd < viewStart || viewEnd < annStart) {
try {
textView.scrollRectToVisible(textView.modelToView(annStart));
} catch(BadLocationException ble) {
// this should never happen
throw new GateRuntimeException(ble);
}
}
}
示例3: main
import java.awt.Point; //导入方法依赖的package包/类
public static void main(final String[] args) throws Exception {
try {
final Robot r = new Robot();
r.setAutoDelay(50);
r.mouseMove(100, 100);
Util.waitForIdle(r);
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
initAndShowUI();
}
});
final Point inside = new Point(frame.getLocationOnScreen());
inside.translate(20, SIZE / 2);
final Point outer = new Point(inside);
outer.translate(-40, 0);
r.mouseMove(inside.x, inside.y);
r.mousePress(InputEvent.BUTTON1_MASK);
try {
for (int i = 0; i < 3; ++i) {
Util.mouseMove(r, inside, outer);
Util.mouseMove(r, outer, inside);
}
} finally {
r.mouseRelease(InputEvent.BUTTON1_MASK);
}
sleep(r);
if (FAILED || !MOUSE_ENTERED || !MOUSE_ENTERED_DT || !MOUSE_EXIT
|| !MOUSE_EXIT_TD) {
throw new RuntimeException("Failed");
}
} finally {
if (frame != null) {
frame.dispose();
}
}
}
示例4: getCenterPoint
import java.awt.Point; //导入方法依赖的package包/类
private static Point getCenterPoint(Window window) {
Point centerPoint = window.getLocationOnScreen();
centerPoint.translate(window.getWidth() / 2, window.getHeight() / 2);
return centerPoint;
}
示例5: getPosition
import java.awt.Point; //导入方法依赖的package包/类
/**
* Returns the position of a component in the topmost parent
*
* @param point
* @param component
* @return Point
*/
public Point getPosition(Point point, Component component) {
point.translate(component.getX(), component.getY());
if (component.getParent() != null && !(component.getParent() instanceof JNodeContainer)) {
return getPosition(point, component.getParent());
}
return point;
}
示例6: dragWindow
import java.awt.Point; //导入方法依赖的package包/类
private static void dragWindow(Window w, int dx, int dy, Robot robot) {
Point p = Util.getTitlePoint(w);
rmove(robot, p);
rdown(robot);
p.translate(dx, dy);
rmove(robot, p);
rup(robot);
}
示例7: snapTo
import java.awt.Point; //导入方法依赖的package包/类
/**
* @return the nearest allowable point according to the {@link VASSAL.build.module.map.boardPicker.board.MapGrid} on
* the {@link Board} at this point
*
* @see Board#snapTo
* @see VASSAL.build.module.map.boardPicker.board.MapGrid#snapTo
*/
public Point snapTo(Point p) {
Point snap = new Point(p);
final Board b = findBoard(p);
if (b == null) return snap;
final Rectangle r = b.bounds();
snap.translate(-r.x, -r.y);
snap = b.snapTo(snap);
snap.translate(r.x, r.y);
// RFE 882378
// If we have snapped to a point 1 pixel off the edge of the map, move
// back
// onto the map.
if (findBoard(snap) == null) {
snap.translate(-r.x, -r.y);
if (snap.x == r.width) {
snap.x = r.width - 1;
}
else if (snap.x == -1) {
snap.x = 0;
}
if (snap.y == r.height) {
snap.y = r.height - 1;
}
else if (snap.y == -1) {
snap.y = 0;
}
snap.translate(r.x, r.y);
}
return snap;
}
示例8: mouseClicked
import java.awt.Point; //导入方法依赖的package包/类
public void mouseClicked(MouseEvent e) {
Point point = e.getPoint();
final GamePiece p = map.findPiece(point, PieceFinder.PIECE_IN_STACK);
if (p != null) {
Point rel = map.positionOf(p);
point.translate(-rel.x, -rel.y);
doClick(p, point);
}
}
示例9: drawBoards
import java.awt.Point; //导入方法依赖的package包/类
/**
* Draw the boards of the map at the given point and zoom factor onto
* the given Graphics object
*/
public void drawBoards(Graphics g, int xoffset, int yoffset, double zoom, Component obs) {
for (Board b : boards) {
Point p = getLocation(b, zoom);
p.translate(xoffset, yoffset);
b.draw(g, p.x, p.y, zoom, obs);
}
}
示例10: addPoints
import java.awt.Point; //导入方法依赖的package包/类
public static Point addPoints(Point... points) {
Point result = new Point();
for(Point point:points)
if(point!=null)
result.translate(point.x, point.y);
return result;
}
示例11: checkField
import java.awt.Point; //导入方法依赖的package包/类
ObjectType checkField(final Direction direction, final IAnt ant) {
ObjectType result = ObjectType.EMPTY_SQUARE;
final Point point = new Point(ant.getPosition());
point.translate(direction.getPositionChange().x, direction.getPositionChange().y);
final IWorldObject foundObject = this.world.getWorldObject(point);
if (foundObject instanceof AbstractAnt) {
final AbstractAnt otherAnt = (AbstractAnt) foundObject;
if (ant.isEnemy(otherAnt) && otherAnt.hasFood()) {
result = ObjectType.ENEMY_ANT_WITH_FOOD;
} else if (ant.isEnemy(otherAnt)) {
result = ObjectType.ENEMY_ANT;
} else if (otherAnt.hasFood()) {
result = ObjectType.ANT_WITH_FOOD;
} else {
result = ObjectType.ANT;
}
} else if (foundObject instanceof AbstractWarrior) {
final AbstractWarrior warrior = (AbstractWarrior) foundObject;
if (ant.isEnemy(warrior)) {
result = ObjectType.ENEMY_WARRIOR;
} else {
result = ObjectType.WARRIOR;
}
} else if (foundObject instanceof Hill) {
final Hill hill = (Hill) foundObject;
if (hill.equals(ant)) {
result = ObjectType.HILL;
} else {
result = ObjectType.ENEMY_HILL;
}
} else if (foundObject instanceof Food) {
result = ObjectType.FOOD;
} else if (foundObject instanceof WorldBorder) {
result = ObjectType.BORDER;
}
return result;
}
示例12: setGridNumberingOffsets
import java.awt.Point; //导入方法依赖的package包/类
@Override
void setGridNumberingOffsets(RegularGridNumbering numbering, MapSheet sheet) {
Point position = coordinatesToPosition(sheet.getField().x, sheet.getField().y, true);
position.translate(getDeltaX()/2, getDeltaY()/2);
int rowOffset = numbering.getColumn(position);
int colOffset = numbering.getRow(position);
rowOffset = -rowOffset + sheet.getTopLeftRow();
colOffset = -colOffset + sheet.getTopLeftCol();
numbering.setAttribute(RegularGridNumbering.H_OFF, rowOffset);
numbering.setAttribute(RegularGridNumbering.V_OFF, colOffset);
}
示例13: move
import java.awt.Point; //导入方法依赖的package包/类
public void move(int dx, int dy, JComponent c) {
final Point newP = new Point (getOrigin());
newP.translate(dx, dy);
if (myGrid.container.contains(newP)) {
moveOrigin(dx, dy);
}
return;
}
示例14: setNewLocation
import java.awt.Point; //导入方法依赖的package包/类
public void setNewLocation(Widget widget, Point location) {
if (selection.contains(widget)) {
// move entire selection
Point originalLocation = getOriginalLocation(widget);
int xOffset = location.x - originalLocation.x;
int yOffset = location.y - originalLocation.y;
for (Widget w : selection) {
Point p = new Point(w.getPreferredLocation());
p.translate(xOffset, yOffset);
w.setPreferredLocation(p);
}
} else {
widget.setPreferredLocation(location);
}
}
示例15: mousePressed
import java.awt.Point; //导入方法依赖的package包/类
@Override
public void mousePressed(MouseEvent e) {
dragged = (Component) e.getSource();
relativePosition = new Point(dragged.getX(), dragged.getY());
relativePosition.translate(-e.getLocationOnScreen().x, -e.getLocationOnScreen().y);
}