/** * Gets a clip area which excludes the area of widgets which overlay the world map. * * @param baseRectangle The base area to clip from * @return An {@link Area} representing <code>baseRectangle</code>, with the area * of visible widgets overlaying the world map clipped from it. */ private Area getWorldMapClipArea(Rectangle baseRectangle) { final Widget overview = client.getWidget(WidgetInfo.WORLD_MAP_OVERVIEW_MAP); final Widget surfaceSelector = client.getWidget(WidgetInfo.WORLD_MAP_SURFACE_SELECTOR); Area clipArea = new Area(baseRectangle); if (overview != null && !overview.isHidden()) { clipArea.subtract(new Area(overview.getBounds())); } if (surfaceSelector != null && !surfaceSelector.isHidden()) { clipArea.subtract(new Area(surfaceSelector.getBounds())); } return clipArea; }
boolean collide = false; Area collide1 = new Area(area1); collide1.subtract(area2); if (!collide1.equals(area1)) { collide = true; Area collide2 = new Area(area2); collide2.subtract(area1); if (!collide2.equals(area2)) { collide = true; obstacles[0] = new Area(new Ellipse2D.Double(40, 40, 30, 30)); obstacles[1] = new Area(new Polygon(xTriangle, yTriangle, 3)); obstacles[2] = new Area(new Polygon(xDiamond, yDiamond, 4)); obstacles[3] = new Area(new Polygon(xOther, yOther, 4)); walls = new Area(new Rectangle(0,0,w,h)); y+=yDelta; int s = 15; Area player = new Area(new Ellipse2D.Double(x, y, s, s)); g.setColor(Color.GREEN);
private Area makeCornerClip(final int beforeRadius, final int startRadius, final AffineTransform transform) { Rectangle clipR = new Rectangle(0, 0, startRadius, beforeRadius); Area clip = new Area(clipR); Ellipse2D.Double e = new Ellipse2D.Double(); e.x = 0; e.y = 0; e.width = 2 * startRadius; e.height = 2 * beforeRadius; clip.subtract(new Area(e)); clip.transform(transform); return clip; }
@Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Graphics2D g2d = (Graphics2D) g; g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); RoundRectangle2D.Double rectangle = new RoundRectangle2D.Double(x, y, width - 1, height - 1, radius, radius); Area rectangleArea = new Area(rectangle); Area area = new Area(new Rectangle(0, 0, width, height)); area.subtract(rectangleArea); g2d.setClip(area); g2d.setColor(c.getParent().getBackground()); g2d.fillRect(0, 0, width, height); g2d.setClip(null); if (color == null) { g2d.setColor(c.getBackground()); } else { g2d.setColor(color); } g2d.setStroke(stroke); g2d.draw(rectangleArea); }
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); Area area = new Area(new Rectangle(0, 0, getWidth(), getHeight())); area.subtract(new Area(new RoundRectangle2D.Float(10, 10, getWidth() - 20, getHeight() - 20, 20, 20))); Graphics2D g2d = (Graphics2D) g.create(); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setColor(Color.BLACK); g2d.fill(area); g2d.dispose(); }
@Inject @Override public Area getClickbox() { Area clickbox = new Area(); Area clickboxA = Perspective.getClickbox(client, getModelA(), getOrientationA(), getLocalLocation()); Area clickboxB = Perspective.getClickbox(client, getModelB(), getOrientationB(), getLocalLocation()); if (clickboxA == null && clickboxB == null) { return null; } if (clickboxA != null) { clickbox.add(clickboxA); } if (clickboxB != null) { clickbox.add(clickboxB); } return clickbox; } }
if (toolTipsEnabled) { rect.setRect(xOffset - lineWidth / 2, highOffset, lineWidth, lowOffset - highOffset); toolTipArea = new Area(rect); xEnd - xStart, Math.abs(closeOffset - openOffset)); g.fill(rect); toolTipArea.add(new Area(rect)); if (toolTipsEnabled) { rect.setRect(xStart, openOffset - lineWidth / 2, xOffset - xStart, lineWidth); toolTipArea.add(new Area(rect)); rect.setRect(xOffset, closeOffset - lineWidth / 2, xEnd - xOffset, lineWidth); toolTipArea.add(new Area(rect));
private void paintCircle(Graphics2D g2, Color color, int size, double angle) { int n = Math.min(this.getHeight(), this.getWidth()); int dh = fullComponent ? n / 2 : waitHeight / 2; int dc = fullComponent ? n / nbCircle : circleSize / 2; int dx = fullComponent ? (this.getWidth() - n) / 2 : 0; int dy = fullComponent ? (this.getHeight() - n) / 2 : 0; Ellipse2D.Float e = new Ellipse2D.Float(dh - 2 * dc - deltaEcartement, -dc, size, size); AffineTransform af = new AffineTransform(); af.translate(dx, dy); af.translate(dh, dh); af.rotate(angle); g2.setColor(color); g2.fill(new Area(e).createTransformedArea(af)); }
/** * Modify the current clipping path by intersecting it with the given path. * @param area area to intersect with the clipping path */ public void intersectClippingPath(Area area) { // lazy cloning of clipping path for performance if (!isClippingPathDirty) { // deep copy (can't use clone() as it performs only a shallow copy) Area cloned = new Area(); cloned.add(clippingPath); clippingPath = cloned; isClippingPathDirty = true; } // intersection as usual clippingPath.intersect(area); }
/** Apply in place the @param ict to the Area @param a, but only for the part that intersects the roi. */ static final public void apply(final mpicbg.models.CoordinateTransform ict, final Area roi, final Area a) { final Area intersection = new Area(a); intersection.intersect(roi); a.subtract(intersection); a.add(M.transform(ict, intersection)); }
private Area createArm() { Area arm = new Area(new Arc2D.Float(cx, cy - radius/2, radius, radius, 0f, 180f, Arc2D.CHORD)); arm.add( new Area(new Ellipse2D.Float(cx + radius/2, cy - radius/4, radius/2, radius/2)) ); arm.subtract( new Area(new Ellipse2D.Float(cx, cy - radius/4, radius/2, radius/2)) ); // arm.add( new Area(new Arc2D.Float(cx + radius/2, cy - radius/4, radius/2, radius/2, 180f, 360f, Arc2D.CHORD)) ); // arm.subtract( new Area(new Arc2D.Float(cx, cy - radius/4, radius/2, radius/2, 0f, 180f, Arc2D.CHORD)) ); return arm; } }