public static void renderHoverableArea(Graphics2D graphics, Area area, net.runelite.api.Point mousePosition, Color fillColor, Color borderColor, Color borderHoverColor) { if (area != null) { if (area.contains(mousePosition.getX(), mousePosition.getY())) { graphics.setColor(borderHoverColor); } else { graphics.setColor(borderColor); } graphics.draw(area); graphics.setColor(fillColor); graphics.fill(area); } }
private void renderObject(GameObject object, Graphics2D graphics, Color color) { LocalPoint localLocation = client.getLocalPlayer().getLocalLocation(); Point mousePosition = client.getMouseCanvasPosition(); LocalPoint location = object.getLocalLocation(); if (localLocation.distanceTo(location) <= MAX_DISTANCE) { Area objectClickbox = object.getClickbox(); if (objectClickbox != null) { if (objectClickbox.contains(mousePosition.getX(), mousePosition.getY())) { graphics.setColor(color.darker()); } else { graphics.setColor(color); } graphics.draw(objectClickbox); graphics.setColor(new Color(0xFF, 0, 0, 20)); graphics.fill(objectClickbox); } } } }
if (objectClickbox != null) if (objectClickbox.contains(mousePosition.getX(), mousePosition.getY()))
if (objectClickbox.contains(mousePosition.getX(), mousePosition.getY()))
); if (geometry.contains(clickableRect))
public static boolean containsAllPoints(Area areaOutside, Area areaInside) { Area clone = (Area) areaOutside.clone(); IfcTools2D.enlargeSlightlyInPlace(clone); PathIterator iterator = areaInside.getPathIterator(null); double[] coords = new double[6]; boolean allInside = true; while (!iterator.isDone()) { iterator.currentSegment(coords); if (!clone.contains(new Point2D.Double(coords[0], coords[1]))) { allInside = false; break; } iterator.next(); } return allInside; }
/** Indicates the position of a point relative to the region. @param x The x-coordinate of the point. @param y The y-coordinate of the point. @return Value {@code true} if the point is on or inside the region, or {@code false} if it is outside the region. */ public boolean contains(final double x, final double y) { return area.contains(x,y); }
/** Indicates the position of a point relative to the region. @param point The point whose position relative to the region is to be tested. The point is treated as a 2D point. That is, only its x- and y-coordinate values are considered. @return The value {@link #contains(double,double) contains(point.x,point.y)}. @throws NullPointerException If {@code point} is {@code null}. */ public boolean contains(final Point point) { return area.contains(point.x,point.y); }
public Area getHoleAt(int x, int y) { for (Area area : holeList) { if (area.contains(x, y)) { return area; } } return null; }
public boolean contains(int x, int y) { for (AreaMeta meta : metaList) { if (meta.area.contains(x, y)) { return true; } } return false; }
@Override public int load(final int x, final int y, final int z) { if (z < 0 || z >= areas.size()) return 0; final List<Area> list = areas.get(z); if (list == null) return 0; for (final Area area : list) { if (area.contains(x, y)) return 0xff; }; return 0; }
public Token getMarkerAt(int x, int y) { List<TokenLocation> locationList = new ArrayList<TokenLocation>(); locationList.addAll(markerLocationList); Collections.reverse(locationList); for (TokenLocation location : locationList) { if (location.bounds.contains(x, y)) { return location.token; } } return null; }
public static void main(String[] args) throws Exception { Area area = new Area(new Rectangle(0, 0, 100, 100)); // The original object, NOT SERIALIZABLE ! System.out.println(area.contains(new Rectangle(1, 1, 10, 10))); // Good as new ! System.out.print("serializing..."); byte[] pojoBytes = Serializer.serialize(area); // Serialize System.out.println("done"); System.out.print("deserializing..."); area = (Area) Serializer.deserialize(pojoBytes); // Deserialize System.out.println("done"); System.out.println(area.contains(new Rectangle(1, 1, 10, 10))); // Good as new ! }
@Override public boolean check (Inter inter) { if (inter instanceof SentenceInter) { return false; } final Point center = inter.getCenter(); return gutterBounds.contains(center) && gutter.contains(center); } };
/* assuming a non-zero winding rule */ final Path2D boundary = new Path2D.Double(); /* initialize the boundary using moveTo, lineTo, quadTo, etc. */ final Area area = new Area(boundary); ... /* test for whether a point is inside */ if (area.contains(...)) { ... }
public AreaOcean getDeepestOceanAt(Point2D point) { if (meta != null && !meta.area.contains(point)) { return null; } // If the point is in an island, then let the island figure it out for (AreaIsland island : islandSet) { if (island.getBounds().contains(point)) { return island.getDeepestOceanAt(point); } } return this; }
/** Expects @param a in local coords. */ @Override public boolean intersects(final Area a) { if (null == aw) return a.contains(x, y); return M.intersects(a, aw.getArea()); }
@Override public boolean intersects(final Area area, final double z_first, final double z_last) { if (-1 == n_points) setupForDisplay(); for (int i=0; i<n_points; i++) { final double z = layer_set.getLayer(p_layer[i]).getZ(); if (z < z_first || z > z_last) continue; if (area.contains(p[0][i], p[1][i])) return true; } return false; }
boolean intersects(final Area area, final double z_first, final double z_last) { for (int i=0; i<n_points; i++) { final Layer la = layer_set.getLayer(p_layer[i]); if (la.getZ() >= z_first && la.getZ() <= z_last) { for (int k=0; k<n_points; k++) { if (area.contains(p[0][k], p[1][k])) return true; } } } return false; }
public static boolean contains(SpatialEntity e1, SpatialEntity e2) { if(e1 instanceof Point2D) return false; Area a1 = e1.getArea(); if(e2 instanceof Point2D) return a1.contains((Point2D) e2); Area a2 = e2.getArea(); a1.intersect(a2); return a1.equals(a2); }