/** * convenience method * * @return the region's center */ public Location getTarget() { return getCenter(); }
/** * Moves the region to the area, whose center is the given location * * @param loc the location which is the new center of the region * @return the region itself */ public Region setCenter(Location loc) { Location c = getCenter(); x = x - c.x + loc.x; y = y - c.y + loc.y; initScreen(null); return this; }
@Override public Visual setScale(float scale) { this.scale = scale; if (scale == 0) { int x = (int) (getTarget().getCenter().x - image.getWidth()/2); int y = (int) (getTarget().getCenter().y - image.getHeight()/2); setTarget(Region.create(x, y, image.getWidth(), image.getHeight())); } else { w = (int) (scale * image.getWidth()); h = (int) (scale * image.getHeight()); } return this; }
private static JFrame getFrame(Object point) { int x; int y; if (point instanceof Point) { x = ((Point) point).x; y = ((Point) point).y; } else { if (SX.isVersion1()) { x = ((Region) point).getCenter().x; y = ((Region) point).getCenter().y; } else { x = ((Element) point).getCenter().x; y = ((Element) point).getCenter().y; } } JFrame anchor = new JFrame(); anchor.setAlwaysOnTop(true); anchor.setUndecorated(true); anchor.setSize(1, 1); anchor.setLocation(x, y); anchor.setVisible(true); return anchor; }
public Visual arrow(Object from, Object to) { Visual gc = null; if (from instanceof Region) { gc = new SxArrow(((Region) from).getCenter().getPoint(), ((Region) to).getCenter().getPoint()); } else if (from instanceof Point || from instanceof Location) { gc = new SxArrow((Point) from, (Point) to); } else if (from instanceof Visual) { gc = new SxArrow((Visual) from, (Visual) to); } if (gc != null) { gc.setGuide(this); addToFront(gc); } else { Debug.log(2, "Guide.arrow: invalid arguments"); } return gc; }
protected <PSIMRL> Location getLocationFromTarget(PSIMRL target) throws FindFailed { if (target instanceof Pattern || target instanceof String || target instanceof Image) { Match m = find(target); if (m != null) { if (isOtherScreen()) { return m.getTarget().setOtherScreen(scr); } else { return m.getTarget(); } } return null; } if (target instanceof Match) { return ((Match) target).getTarget(); } if (target instanceof Region) { return ((Region) target).getCenter(); } if (target instanceof Location) { return new Location((Location) target); } return null; } //</editor-fold>