public abstract class

Anchor

extends Object
java.lang.Object
   ↳ sofia.graphics.Anchor

Class Overview

An Anchor represents a point inside or on a bounding rectangle that is used to position a shape relative to another shape.

Pre-existing anchors are provided for the nine common anchor points that most people will want to use: TOP_LEFT, TOP, TOP_RIGHT; LEFT, CENTER, RIGHT; and BOTTOM_LEFT, BOTTOM, BOTTOM_RIGHT.

Since Anchor is an abstract class, users can easily implement their own custom anchors for different types of shapes. For example, a circle might provide anchors that lie on the curve itself rather than on its bounding box.

Summary

Fields
public static final Anchor BOTTOM Represents the bottom-center point of a bounding rectangle.
public static final Anchor BOTTOM_LEFT Represents the bottom-left point of a bounding rectangle.
public static final Anchor BOTTOM_RIGHT Represents the bottom-right point of a bounding rectangle.
public static final Anchor CENTER Represents the middle-center point of a bounding rectangle.
public static final Anchor LEFT Represents the middle-left point of a bounding rectangle.
public static final Anchor RIGHT Represents the middle-right point of a bounding rectangle.
public static final Anchor TOP Represents the top-center point of a bounding rectangle.
public static final Anchor TOP_LEFT Represents the top-left point of a bounding rectangle.
public static final Anchor TOP_RIGHT Represents the top-right point of a bounding rectangle.
Public Constructors
Anchor()
Public Methods
final PointAndAnchor anchoredAt(PointF point)
Gets a PointAndAnchor object that represents the notion of positioning a shape such that the receiving anchor point on that shape is located at the specified point.
final PointAndAnchor anchoredAt(float x, float y)
Gets a PointAndAnchor object that represents the notion of positioning a shape such that the receiving anchor point on that shape is located at the specified point.
abstract PointF getPoint(RectF bounds)
Gets the point in the specified rectangle that the receiving anchor represents.
final PointF of(View view)
Gets a point that represents the location of the receiver on the specified view.
final PointF of(Shape shape)
Gets a point that represents the location of the receiver on the specified shape.
[Expand]
Inherited Methods
From class java.lang.Object

Fields

public static final Anchor BOTTOM

Represents the bottom-center point of a bounding rectangle.

public static final Anchor BOTTOM_LEFT

Represents the bottom-left point of a bounding rectangle.

public static final Anchor BOTTOM_RIGHT

Represents the bottom-right point of a bounding rectangle.

public static final Anchor CENTER

Represents the middle-center point of a bounding rectangle.

public static final Anchor LEFT

Represents the middle-left point of a bounding rectangle.

public static final Anchor RIGHT

Represents the middle-right point of a bounding rectangle.

public static final Anchor TOP

Represents the top-center point of a bounding rectangle.

public static final Anchor TOP_LEFT

Represents the top-left point of a bounding rectangle.

public static final Anchor TOP_RIGHT

Represents the top-right point of a bounding rectangle.

Public Constructors

public Anchor ()

Public Methods

public final PointAndAnchor anchoredAt (PointF point)

Gets a PointAndAnchor object that represents the notion of positioning a shape such that the receiving anchor point on that shape is located at the specified point.

Parameters
point the point
Returns
  • a PointAndAnchor object

public final PointAndAnchor anchoredAt (float x, float y)

Gets a PointAndAnchor object that represents the notion of positioning a shape such that the receiving anchor point on that shape is located at the specified point.

Parameters
x The x-coordinate.
y The y-coordinate.
Returns
  • A PointAndAnchor object.

public abstract PointF getPoint (RectF bounds)

Gets the point in the specified rectangle that the receiving anchor represents.

Parameters
bounds the bounding rectangle
Returns
  • a PointF object that represents the location of the anchor

public final PointF of (View view)

Gets a point that represents the location of the receiver on the specified view.

Returns
  • A PointF object that represents the location of the receiver on the shape view.

public final PointF of (Shape shape)

Gets a point that represents the location of the receiver on the specified shape.

Parameters
shape The shape.
Returns
  • A PointF object that represents the location of the receiver on the shape.