You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
898 B
58 lines
898 B
package mightypork.utils.math.constraints;
|
|
|
|
|
|
import mightypork.utils.math.coord.Coord;
|
|
|
|
|
|
/**
|
|
* A constraint based on a given {@link ConstraintContext}
|
|
*
|
|
* @author MightyPork
|
|
*/
|
|
public abstract class Constraint implements SettableContext {
|
|
|
|
private ConstraintContext context = null;
|
|
|
|
|
|
public Constraint(ConstraintContext context) {
|
|
this.context = context;
|
|
}
|
|
|
|
|
|
@Override
|
|
public void setContext(ConstraintContext context)
|
|
{
|
|
this.context = context;
|
|
}
|
|
|
|
|
|
/**
|
|
* @return the context
|
|
*/
|
|
public ConstraintContext getContext()
|
|
{
|
|
return context;
|
|
}
|
|
|
|
|
|
/**
|
|
* @return context rect origin
|
|
*/
|
|
protected Coord getOrigin()
|
|
{
|
|
if (context == null) return Coord.zero();
|
|
|
|
return context.getRect().getOrigin();
|
|
}
|
|
|
|
|
|
/**
|
|
* @return context rect size
|
|
*/
|
|
protected Coord getSize()
|
|
{
|
|
if (context == null) return Coord.zero();
|
|
|
|
return context.getRect().size();
|
|
}
|
|
}
|
|
|