本文整理汇总了Java中java.awt.Point.equals方法的典型用法代码示例。如果您正苦于以下问题:Java Point.equals方法的具体用法?Java Point.equals怎么用?Java Point.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Point
的用法示例。
在下文中一共展示了Point.equals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mouseReleased
import java.awt.Point; //导入方法依赖的package包/类
@Override
public void mouseReleased(MouseEvent e) {
dragging = false;
boolean bkp = isRaiseMuda();
if (bkp) {
setRaiseMuda(false);
}
super.mouseReleased(e);
if (bkp) {
setRaiseMuda(true);
}
if (jaSel) {
boolean combine = (getMaster().isShiftDown() || getMaster().isControlDown());
if (combine) {
getMaster().DiagramaDoSelecao(this, true, false);
}
}
Point enddown = new Point(e.getX(), e.getY());
if (!enddown.equals(getIniDown())) {
DoMuda();
}
}
示例2: swapCollideWithEnemies
import java.awt.Point; //导入方法依赖的package包/类
private void swapCollideWithEnemies(HackMan2State previousState, HackMan2State state) {
ArrayList<Enemy> aliveEnemies = getAliveEnemies();
for (HackMan2PlayerState playerState : state.getPlayerStates()) {
Point coord = playerState.getCoordinate();
Point previousCoord = previousState.getPlayerStateById(
playerState.getPlayerId()).getCoordinate();
for (Enemy enemy : aliveEnemies) {
Enemy previousEnemy = previousState.getBoard().getEnemyById(enemy.getId());
if (previousEnemy == null) continue;
Point enemyCoord = enemy.getCoordinate();
Point previousEnemyCoord = previousEnemy.getCoordinate();
if (coord.equals(previousEnemyCoord) && enemyCoord.equals(previousCoord)) {
hitPlayerWithEnemy(playerState);
enemy.kill(EnemyDeath.ATTACK);
}
}
}
}
示例3: startRegTest
import java.awt.Point; //导入方法依赖的package包/类
private static Thread startRegTest(final Frame f) {
Thread robot = new Thread(new Runnable() {
public void run() {
Robot r = Util.createRobot();
dragWindow(f, 100, 100, r);
// wait for the location to be set.
sleepFor(2000);
final Point l2 = f.getLocationOnScreen();
// double click should maximize the frame
doubleClick(r);
// wait for location again.
sleepFor(2000);
final Point l3 = f.getLocationOnScreen();
if (l3.equals(l2)) {
throw new RuntimeException("Bad location after maximize. Window location has not moved");
}
}
});
return robot;
}
示例4: computateAnchorPosition
import java.awt.Point; //导入方法依赖的package包/类
/**
* Computates the Anchorposition like the Rectangular anchor for a
* given widget as source/target and a controlpoint as opposit anchorposition
*/
private Point computateAnchorPosition(Widget relatedWidget, Point controlPoint) {
Rectangle bounds = relatedWidget.getBounds();
Point relatedLocation = relatedWidget.getLocation();//center of the widget
if (bounds.isEmpty () || relatedLocation.equals (controlPoint))
return relatedLocation;
float dx = controlPoint.x - relatedLocation.x;
float dy = controlPoint.y - relatedLocation.y;
float ddx = Math.abs (dx) / (float) bounds.width;
float ddy = Math.abs (dy) / (float) bounds.height;
float scale = 0.5f / Math.max (ddx, ddy);
Point point = new Point (Math.round (relatedLocation.x + scale * dx),
Math.round (relatedLocation.y + scale * dy));
return point;
}
示例5: compute
import java.awt.Point; //导入方法依赖的package包/类
@Override
public List<Point> compute(List<Point> points) {
ArrayList<Point> bestPoints = new ArrayList<Point> (points) ;
Point relatedLocation = getRelatedSceneLocation();
int direction = 1 ;
int index = 0 ;
//the related location is the center of this anchor. It is possible that
//the list of points started at the opposite anchor (other end of connection).
Point endPoint = bestPoints.get(index);
if (!endPoint.equals(relatedLocation)) {
index = bestPoints.size() - 1 ;
endPoint = bestPoints.get(index);
direction = -1 ;
}
Widget widget = getRelatedWidget();
Rectangle bounds = widget.getBounds();
bounds = widget.convertLocalToScene(bounds);
Point neighbor = bestPoints.get (index+direction) ;
//moving the end point to the end of the anchor from the interior
while (bounds.contains(neighbor)) {
bestPoints.remove(index) ;
endPoint = bestPoints.get (index);
neighbor = bestPoints.get (index+direction);
}
Result intersection = this.computeBoundaryIntersectionPoint(endPoint, neighbor);
bestPoints.remove(index) ;
bestPoints.add(index, intersection.getAnchorSceneLocation());
return bestPoints ;
}
示例6: computeBoundaryIntersectionPoint
import java.awt.Point; //导入方法依赖的package包/类
private Result computeBoundaryIntersectionPoint(Point relatedLocation, Point oppositeLocation) {
Widget widget = getRelatedWidget();
Rectangle bounds = widget.getBounds();
if (!includeBorders) {
Insets insets = widget.getBorder().getInsets();
bounds.x += insets.left;
bounds.y += insets.top;
bounds.width -= insets.left + insets.right;
bounds.height -= insets.top + insets.bottom;
}
bounds = widget.convertLocalToScene(bounds);
if (bounds.isEmpty() || relatedLocation.equals(oppositeLocation)) {
return null;
}
float dx = oppositeLocation.x - relatedLocation.x;
float dy = oppositeLocation.y - relatedLocation.y;
float ddx = Math.abs(dx) / (float) bounds.width;
float ddy = Math.abs(dy) / (float) bounds.height;
Anchor.Direction direction;
if (ddx >= ddy) {
direction = dx >= 0.0f ? Direction.RIGHT : Direction.LEFT;
} else {
direction = dy >= 0.0f ? Direction.BOTTOM : Direction.TOP;
}
float scale = 0.5f / Math.max(ddx, ddy);
Point point = new Point(Math.round(relatedLocation.x + scale * dx),
Math.round(relatedLocation.y + scale * dy));
return new Anchor.Result(point, direction);
}
示例7: setDirecaoTriangulo
import java.awt.Point; //导入方法依赖的package包/类
@Override
public void setDirecaoTriangulo(Direcao direcaoTriangulo) {
Point[] pts = getPontosDoTriangulo();
//evita outras formas de direção.
if (direcaoTriangulo.ordinal() > 3) {
direcaoTriangulo = Direcao.Up;
}
setDirecaoNaoNotifique(direcaoTriangulo);
DestruaRegiao();
Point[] pts2 = getPontosDoTriangulo();
ArrayList<PontoDeLinha> btns = getListaDePontosLigados();
for (PontoDeLinha pdl : btns) {
Point atual = pdl.getCentro();
int i = 0;
for (Point p : pts) {
if (atual.equals(p)) {
pdl.setCentro(pts2[i]);
break;
}
i++;
}
}
SendNotificacao(Constantes.Operacao.opReposicione);
InvalidateArea();
}
示例8: main
import java.awt.Point; //导入方法依赖的package包/类
public static void main(String[] args) throws AWTException
{
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gds = ge.getScreenDevices();
if (gds.length < 2) {
System.out.println("It's a multiscreen test... skipping!");
return;
}
for (int i = 0; i < gds.length; ++i) {
GraphicsDevice gd = gds[i];
GraphicsConfiguration gc = gd.getDefaultConfiguration();
Rectangle screen = gc.getBounds();
Robot robot = new Robot(gd);
// check Robot.mouseMove()
robot.mouseMove(screen.x + mouseOffset.x, screen.y + mouseOffset.y);
Point mouse = MouseInfo.getPointerInfo().getLocation();
Point point = screen.getLocation();
point.translate(mouseOffset.x, mouseOffset.y);
if (!point.equals(mouse)) {
throw new RuntimeException(getErrorText("Robot.mouseMove", i));
}
// check Robot.getPixelColor()
Frame frame = new Frame(gc);
frame.setUndecorated(true);
frame.setSize(100, 100);
frame.setLocation(screen.x + frameOffset.x, screen.y + frameOffset.y);
frame.setBackground(color);
frame.setVisible(true);
robot.waitForIdle();
Rectangle bounds = frame.getBounds();
if (!Util.testBoundsColor(bounds, color, 5, 1000, robot)) {
throw new RuntimeException(getErrorText("Robot.getPixelColor", i));
}
// check Robot.createScreenCapture()
BufferedImage image = robot.createScreenCapture(bounds);
int rgb = color.getRGB();
if (image.getRGB(0, 0) != rgb
|| image.getRGB(image.getWidth() - 1, 0) != rgb
|| image.getRGB(image.getWidth() - 1, image.getHeight() - 1) != rgb
|| image.getRGB(0, image.getHeight() - 1) != rgb) {
throw new RuntimeException(
getErrorText("Robot.createScreenCapture", i));
}
frame.dispose();
}
System.out.println("Test PASSED!");
}
示例9: scrollToPath
import java.awt.Point; //导入方法依赖的package包/类
public void scrollToPath(TreePath irPath) {
Point lrLocation = getLocationForPath(irPath);
if (!lrLocation.equals(new Point(-1, -1))) {
this.scrollToCell(lrLocation.y, lrLocation.x);
}
}
示例10: mouseReleased
import java.awt.Point; //导入方法依赖的package包/类
@Override
public void mouseReleased(MouseEvent e) {
isMouseDown = false;
DoRaizeReenquadreReposicione();
if (isPontosIsHide()) {
getMaster().HidePontosOnSelecao(false);
}
Point enddown = new Point(e.getX(), e.getY());
if (!enddown.equals(inidown)) {
DoMuda();
}
super.mouseReleased(e);
}
示例11: move
import java.awt.Point; //导入方法依赖的package包/类
/**
* Move the pin to a different location in the editor pane.
* @param line A new line
* @param location Coordinates of the new location
*/
public void move(int line, Point location) {
int oldLine = this.line;
this.line = line;
if (oldLine != line) {
pchs.firePropertyChange(PROP_LINE, oldLine, line);
}
Point oldLocation = this.location;
this.location = location;
if (!oldLocation.equals(location)) {
pchs.firePropertyChange(PROP_LOCATION, oldLocation, location);
}
}
示例12: mouseReleased
import java.awt.Point; //导入方法依赖的package包/类
@Override
public void mouseReleased(MouseEvent e) {
Point enddown = new Point(e.getX(), e.getY());
if (!enddown.equals(inidown)) {
getDono().DoMuda();
}
super.mouseReleased(e);
}
示例13: main
import java.awt.Point; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
Robot robot = new Robot();
for(int i = 0; i < 10; i++) {
Dialog dialog = new Dialog((Frame) null);
dialog.setLocation(100, 100);
Component panel = new Panel();
panel.setPreferredSize(new Dimension(200, 100));
dialog.add(panel);
dialog.pack();
dialog.setVisible(true);
robot.waitForIdle();
robot.delay(200);
Point frameLoc = dialog.getLocationOnScreen();
Point contentLoc = panel.getLocationOnScreen();
System.out.println("Decor location " + frameLoc);
System.out.println("Content location " + contentLoc);
dialog.setResizable(false);
robot.waitForIdle();
robot.delay(200);
Point l = dialog.getLocationOnScreen();
if (!l.equals(frameLoc)) {
dialog.dispose();
throw new RuntimeException("Decorated frame location moved " +
"after setResizable(false)" + l);
}
l = panel.getLocationOnScreen();
if (!l.equals(contentLoc)) {
dialog.dispose();
throw new RuntimeException("Content location moved after " +
"setResizable(false)" + l);
}
if (panel.getLocationOnScreen().y <
dialog.getLocationOnScreen().y + dialog.getInsets().top) {
dialog.dispose();
throw new RuntimeException(
"Wrong content position after setResizable(false)");
}
dialog.setResizable(true);
robot.waitForIdle();
robot.delay(200);
l = dialog.getLocationOnScreen();
if (!l.equals(frameLoc)) {
dialog.dispose();
throw new RuntimeException("Decorated frame location moved " +
"after setResizable(true)" + l);
}
l = panel.getLocationOnScreen();
if (!l.equals(contentLoc)) {
dialog.dispose();
throw new RuntimeException("Content location moved after " +
"setResizable(true)" + l);
}
if (panel.getLocationOnScreen().y <
dialog.getLocationOnScreen().y + dialog.getInsets().top) {
dialog.dispose();
throw new RuntimeException(
"Wrong content position after setResizable(true)");
}
dialog.dispose();
}
}
示例14: mouseReleased
import java.awt.Point; //导入方法依赖的package包/类
@Override
public void mouseReleased(MouseEvent e) {
isMouseDown = false;
FormaArea dono = regiao;
dono.Reenquadre();
dono.DoRaizeReenquadreReposicione();
Point enddown = new Point(e.getX(), e.getY());
if (!enddown.equals(inidown)) {
dono.DoMuda();
}
super.mouseReleased(e);
}
示例15: find
import java.awt.Point; //导入方法依赖的package包/类
@Override
public Collection<? extends Point> find(Point from, Point destination, DistanceComparator distanceComparator,
CollisionDetector collisionDetector)
{
Map<Point, Point> parents = new HashMap<>();
TreeSet<Point> openList = new TreeSet<>(distanceComparator);
HashSet<Point> closedList = new HashSet<>();
openList.add(from);
Point n = null;
Point closestNode = from;
while (!openList.isEmpty())
{
n = openList.pollFirst();
if(distanceComparator.compare(closestNode, n) > 0)
closestNode = n;
if (n.equals(destination))
return createPath(from, destination, parents);
closedList.add(n);
List<Point> successors = createSuccessors(n, collisionDetector);
for (Point successor: successors)
{
if (!closedList.contains(successor))
{
openList.add(successor);
if (!parents.containsKey(successor))
parents.put(successor, n);
}
}
}
return createPath(from, closestNode, parents);
}