Sofia API Reference

  • Package Index
  • Class Index
  • Packages
  • sofia.app
  • sofia.content
  • sofia.data
  • sofia.graphics
    • Interfaces
    • Joint
    • PropertyTransformer
    • Classes
    • AbstractJoint
    • Anchor
    • Color
    • CoordinateSystem
    • DirectionalPad
    • DistanceJoint
    • ElasticInInterpolator
    • ElasticInOutInterpolator
    • ElasticOutInterpolator
    • FillableShape
    • FillableShape.Animator
    • Geometry
    • Image
    • LineShape
    • MotionStep
    • OvalShape
    • PointAndAnchor
    • Polygon
    • PolygonShape
    • Predicate
    • RectangleShape
    • RevoluteJoint
    • Shape
    • Shape.Animator
    • Shape.Filter
    • ShapeField
    • ShapeFilter
    • ShapeSet
    • ShapeView
    • SizeF
    • StrokedShape
    • StrokedShape.Animator
    • TextShape
    • TextShape.Animator
    • Timings
    • ViewEdges
    • ZIndexComparator
    • Enums
    • RepeatMode
    • ShapeMotion
  • sofia.util
  • sofia.view
  • sofia.widget

public abstract class
Anchor

extends Object

Inheritance

  • 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
static final Anchor BOTTOM Represents the bottom-center point of a bounding rectangle.
static final Anchor BOTTOM_LEFT Represents the bottom-left point of a bounding rectangle.
static final Anchor BOTTOM_RIGHT Represents the bottom-right point of a bounding rectangle.
static final Anchor CENTER Represents the middle-center point of a bounding rectangle.
static final Anchor LEFT Represents the middle-left point of a bounding rectangle.
static final Anchor RIGHT Represents the middle-right point of a bounding rectangle.
static final Anchor TOP Represents the top-center point of a bounding rectangle.
static final Anchor TOP_LEFT Represents the top-left point of a bounding rectangle.
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.
static Anchor fractional(float x, float y)
Gets an anchor that represents a relative position inside a bounding box.
abstract PointF getPoint(RectF bounds)
Gets the point in the specified rectangle that the receiving anchor represents.
final PointF of(Shape shape)
Gets a point that represents the location of the receiver on the specified shape.
final PointF of(View view)
Gets a point that represents the location of the receiver on the specified view.
Methods inherited from class java.lang.Object
Object clone()
boolean equals(Object arg0)
void finalize()
final Class<?> getClass()
int hashCode()
final void notify()
final void notifyAll()
String toString()
final void wait()
final void wait(long arg0, int arg1)
final void wait(long arg0)

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 static Anchor fractional (float x, float y)

Gets an anchor that represents a relative position inside a bounding box. The values x and y represent fractions of the width and height of the box, so 0.0 would represent the left/top and 1.0 would represent the right/bottom. Negative values and values greater than one would position the anchor outside the box.

Parameters
x
the fraction of the width of the box
y
the fraction of the height of the box
Returns

an Anchor representing the specified relative position inside the bounding box

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 (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.

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.