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
AbstractJoint

extends Object
implements Joint

Inheritance

  • java.lang.Object
    • sofia.graphics.AbstractJoint<JointType extends org.jbox2d.dynamics.joints.Joint, JointDefType extends org.jbox2d.dynamics.joints.JointDef>
Known Direct Subclasses
DistanceJoint, RevoluteJoint
DistanceJoint A joint that forces the distance between two shapes to always remain constant, or within a certain amount of each other (like a spring-damper). 
RevoluteJoint A joint that forces two shapes to share a common anchor point, allowing only the relative rotation between them to change. 

Class Overview

The abstract base class for all Sofia classes representing JBox2D joints. Most users will not need to use this class directly, unless they want to implement a type of joint that Sofia does not yet support.


Summary

Public Constructors
AbstractJoint(Shape firstShape, Shape secondShape)
Initializes a new joint with the specified shapes.
Public Methods
boolean canShapesCollide()
Gets a value indicating whether the two shapes connected by this joint are allowed to collide.
void connect()
Activates the joint.
void disconnect()
Deactivates the joint, releasing the connection between the two shapes.
JointType getB2Joint()
Gets the underlying JBox2D joint object.
JointDefType getB2JointDef()
Gets the underlying JBox2D joint definition object.
Shape getFirstShape()
Gets the first shape connected by this joint.
Shape getSecondShape()
Gets the second shape connected by this joint.
void setCanShapesCollide(boolean collide)
Sets a value indicating whether the two shapes connected by this joint are allowed to collide.
Protected Methods
abstract JointDefType createB2JointDef()
Subclasses must override this method to create the appropriate Box2D JointDef instance that represents the specific type of joint.
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)
Methods inherited from interface sofia.graphics.Joint
abstract void connect()
Activates the joint.
abstract void disconnect()
Deactivates the joint, releasing the connection between the two shapes.
abstract org.jbox2d.dynamics.joints.Joint getB2Joint()
Gets the underlying JBox2D joint object.
abstract org.jbox2d.dynamics.joints.JointDef getB2JointDef()
Gets the underlying JBox2D joint definition object.
abstract Shape getFirstShape()
Gets the first shape connected by this joint.
abstract Shape getSecondShape()
Gets the second shape connected by this joint.

Public Constructors

public AbstractJoint (Shape firstShape, Shape secondShape)

Initializes a new joint with the specified shapes.

Parameters
firstShape
the first shape connected by this joint
secondShape
the second shape connected by this joint

Public Methods

public boolean canShapesCollide ()

Gets a value indicating whether the two shapes connected by this joint are allowed to collide.

Returns

true if the two shapes connected by this joint are allowed to collide, otherwise false

public void connect ()

Activates the joint. You must call this method after creating the joint object if you want it to have any effect.

public void disconnect ()

Deactivates the joint, releasing the connection between the two shapes.

public JointType getB2Joint ()

Gets the underlying JBox2D joint object. For advanced usage only.

Returns

the underlying JBox2D joint object

public JointDefType getB2JointDef ()

Gets the underlying JBox2D joint definition object. For advanced usage only.

Returns

the underlying JBox2D joint definition object

public Shape getFirstShape ()

Gets the first shape connected by this joint.

Returns

the first shape connected by this joint

public Shape getSecondShape ()

Gets the second shape connected by this joint.

Returns

the second shape connected by this joint

public void setCanShapesCollide (boolean collide)

Sets a value indicating whether the two shapes connected by this joint are allowed to collide.

Parameters
collide
true if the two shapes connected by this joint are allowed to collide, otherwise false

Protected Methods

protected abstract JointDefType createB2JointDef ()

Subclasses must override this method to create the appropriate Box2D JointDef instance that represents the specific type of joint. This method should fill in all required properties of the joint, including the bodyA and bodyB references.

Returns

the subclass of JointDef that represents this specific type of joint