/** * Returns true if a {@link IPoint} on the screen touches a {@link Layer.HasSize}. */ public static boolean hitTest(Layer.HasSize layer, IPoint point) { return hitTest(layer, point.x(), point.y()); }
@Override // from Transform public Point transform (IPoint p, Point into) { float x = p.x(), y = p.y(); return into.set(m00*x + m10*y + tx, m01*x + m11*y + ty); }
@Override // from Transform public Point transform (IPoint p, Point into) { float x = p.x(), y = p.y(); return into.set(m00*x + m10*y + tx, m01*x + m11*y + ty); }
/** * Returns the squared Euclidean distance between the given point and the nearest point inside * the bounds of the given rectangle. If the supplied point is inside the rectangle, the * distance will be zero. */ public static float pointRectDistanceSq (IRectangle r, IPoint p) { Point p2 = closestInteriorPoint(r, p); return Points.distanceSq(p.x(), p.y(), p2.x, p2.y); }
protected Texture (Symbol symbol) { _layer = new ImageLayer(symbol.tile); _layer.setOrigin(symbol.origin.x(), symbol.origin.y()); _symbol = symbol; }
/** * Returns the squared Euclidean distance between the given point and the nearest point inside * the bounds of the given rectangle. If the supplied point is inside the rectangle, the * distance will be zero. */ public static float pointRectDistanceSq (IRectangle r, IPoint p) { Point p2 = closestInteriorPoint(r, p); return Points.distanceSq(p.x(), p.y(), p2.x, p2.y); }
@Override // from Transform public Point inverseTransform (IPoint p, Point into) { float x = p.x() - tx, y = p.y() - ty; float det = m00 * m11 - m01 * m10; if (Math.abs(det) == 0f) { // determinant is zero; matrix is not invertible throw new NoninvertibleTransformException(this.toString()); } float rdet = 1 / det; return into.set((x * m11 - y * m10) * rdet, (y * m00 - x * m01) * rdet); }
@Override // from Transform public Point inverseTransform (IPoint p, Point into) { float x = p.x() - tx, y = p.y() - ty; float det = m00 * m11 - m01 * m10; if (Math.abs(det) == 0f) { // determinant is zero; matrix is not invertible throw new NoninvertibleTransformException(this.toString()); } float rdet = 1 / det; return into.set((x * m11 - y * m10) * rdet, (y * m00 - x * m01) * rdet); }
public Constraint (IPoint position, IDimension size, HAlign halign, VAlign valign) { this(BoxPoint.TL.offset(position.x(), position.y()), BoxPoint.TL.align(halign, valign), size); }
/** Updates the position of the content to match the flicker. If force is set, then the * relevant values will be updated even if there was no change. */ protected void update (boolean force) { IPoint pos = flicker.position(); boolean dx = hrange.set(pos.x()), dy = vrange.set(pos.y()); if (dx || dy || force) { _clippable.setPosition(-pos.x(), -pos.y()); // now check the child elements for visibility if (!force) updateVisibility(); firePositionChange(); if (_bars != null) _bars.updatePosition(); } }
@Override public Point inverseTransform(IPoint p, Point into) { float m00 = m00(), m01 = m01(), m10 = m10(), m11 = m11(); float x = p.x() - tx(), y = p.y() - ty(); float det = m00 * m11 - m01 * m10; if (Math.abs(det) == 0f) { // determinant is zero; matrix is not invertible throw new NoninvertibleTransformException(this.toString()); } float rdet = 1 / det; return into.set((x * m11 - y * m10) * rdet, (y * m00 - x * m01) * rdet); }
@Override public Point transform(IPoint p, Point into) { float x = p.x(), y = p.y(); return into.set(m00() * x + m10() * y + tx(), m01() * x + m11() * y + ty()); }
/** * Computes the point inside the bounds of the rectangle that's closest to the given point, * writing the result into {@code out}. * @return {@code out} for call chaining convenience. */ public static Point closestInteriorPoint (IRectangle r, IPoint p, Point out) { out.set(MathUtil.clamp(p.x(), r.minX(), r.maxX()), MathUtil.clamp(p.y(), r.minY(), r.maxY())); return out; }
@Override public void layout (Container<?> elems, float left, float top, float width, float height) { for (Element<?> elem : elems) { if (!elem.isVisible()) continue; Constraint c = constraint(elem); IDimension psize = c.psize(this, elem); // this should return a cached size IPoint pos = c.pos(width, height, psize); setBounds(elem, left + pos.x(), top + pos.y(), psize.width(), psize.height()); } }
/** * Computes the point inside the bounds of the rectangle that's closest to the given point, * writing the result into {@code out}. * @return {@code out} for call chaining convenience. */ public static Point closestInteriorPoint (IRectangle r, IPoint p, Point out) { out.set(MathUtil.clamp(p.x(), r.minX(), r.maxX()), MathUtil.clamp(p.y(), r.minY(), r.maxY())); return out; }
private Touch.Event[] toEvents (NSSet<UITouch> touches, UIEvent event, Touch.Event.Kind kind) { final Touch.Event[] events = new Touch.Event[touches.size()]; int idx = 0; for (UITouch touch : touches) { CGPoint loc = touch.getLocationInView(touch.getView()); // transform the point based on our current scale IPoint xloc = plat.graphics().transformTouch((float)loc.getX(), (float)loc.getY()); // on iOS the memory address of the UITouch object is the unique id int id = (int)touch.getHandle(); events[idx++] = new Touch.Event(0, touch.getTimestamp() * 1000, xloc.x(), xloc.y(), kind, id); } return events; } }
private Event.Impl toPointerEvent(NSSet<UITouch> touches, UIEvent event) { for (UITouch touch : touches) { long handle = touch.getHandle(); // if we have an active touch, we only care about that touch if (_active == 0 || handle == _active) { _active = handle; CGPoint loc = touch.getLocationInView(touch.getView()); // transform the point based on our current scale IPoint xloc = platform.graphics().transformTouch((float)loc.getX(), (float)loc.getY()); return new Event.Impl( new Events.Flags.Impl(), touch.getTimestamp() * 1000, xloc.x(), xloc.y(), true); } } return null; }
private Event.Impl[] toTouchEvents(NSSet<UITouch> touches, UIEvent event) { final Event.Impl[] events = new Event.Impl[touches.size()]; int idx = 0; for (UITouch touch : touches) { CGPoint loc = touch.getLocationInView(touch.getView()); // transform the point based on our current scale IPoint xloc = platform.graphics().transformTouch((float)loc.getX(), (float)loc.getY()); // on iOS the memory address of the UITouch object is the unique id int id = (int)touch.getHandle(); events[idx++] = new Event.Impl( new Events.Flags.Impl(), touch.getTimestamp() * 1000, xloc.x(), xloc.y(), id); } return events; } }