/** * Check if a sprite contains the given point (x,y). * * @param elt The sprite. * @param x The point abscissa. * @param y The point ordinate. * @return True if (x,y) is in the given element. */ protected boolean spriteContains(GraphicElement elt, double x, double y) { Values size = elt.getStyle().getSize(); double w2 = metrics.lengthToPx(size, 0) / 2; double h2 = size.size() > 1 ? metrics.lengthToPx(size, 1) / 2 : w2; Point2D.Double dst = spritePositionPx((GraphicSprite) elt); // new // Point2D.Double( // elt.getX(), // elt.getY() // ); // Point2D.Double dst = new Point2D.Double(); // Tx.transform( src, dst ); dst.x -= metrics.viewport[0]; dst.y -= metrics.viewport[1]; double x1 = dst.x - w2; double x2 = dst.x + w2; double y1 = dst.y - h2; double y2 = dst.y + h2; if (x < x1) return false; if (y < y1) return false; if (x > x2) return false; if (y > y2) return false; return true; }