Num/Rect/Vect Constructors for Bounds

v5stable
Ondřej Hruška 11 years ago
parent 0236e779c3
commit d96c1c1272
  1. 4
      src/mightypork/gamecore/control/timing/Poller.java
  2. 9
      src/mightypork/utils/math/constraints/num/Num.java
  3. 9
      src/mightypork/utils/math/constraints/num/NumBoundAdapter.java
  4. 7
      src/mightypork/utils/math/constraints/rect/Rect.java
  5. 11
      src/mightypork/utils/math/constraints/rect/RectBoundAdapter.java
  6. 7
      src/mightypork/utils/math/constraints/vect/Vect.java
  7. 9
      src/mightypork/utils/math/constraints/vect/VectBoundAdapter.java

@ -4,11 +4,9 @@ package mightypork.gamecore.control.timing;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.Set; import java.util.Set;
import mightypork.utils.math.constraints.RectCache;
/** /**
* Used to poll a number of {@link Pollable}s, such as {@link RectCache} * Used to poll a number of {@link Pollable}s
* *
* @author MightyPork * @author MightyPork
*/ */

@ -7,12 +7,17 @@ import mightypork.utils.math.Calc;
public abstract class Num implements NumBound { public abstract class Num implements NumBound {
static final double CMP_EPSILON = 0.0000001;
public static final NumConst ZERO = Num.make(0); public static final NumConst ZERO = Num.make(0);
public static final NumConst ONE = Num.make(1); public static final NumConst ONE = Num.make(1);
@FactoryMethod
public static Num make(NumBound bound)
{
return new NumBoundAdapter(bound);
}
@FactoryMethod @FactoryMethod
public static NumConst make(double value) public static NumConst make(double value)
{ {

@ -9,6 +9,15 @@ public class NumBoundAdapter extends NumAdapter implements PluggableNumBound {
private NumBound backing = null; private NumBound backing = null;
public NumBoundAdapter() {
}
public NumBoundAdapter(NumBound bound) {
backing = bound;
}
@Override @Override
public void setNum(NumBound rect) public void setNum(NumBound rect)
{ {

@ -36,6 +36,13 @@ public abstract class Rect implements RectBound {
} }
@FactoryMethod
public static Rect make(RectBound bound)
{
return new RectBoundAdapter(bound);
}
@FactoryMethod @FactoryMethod
public static Rect make(Num x, Num y, Num width, Num height) public static Rect make(Num x, Num y, Num width, Num height)
{ {

@ -10,11 +10,20 @@ import mightypork.utils.math.constraints.RectBound;
* *
* @author MightyPork * @author MightyPork
*/ */
public abstract class RectBoundAdapter extends RectAdapter implements PluggableRectBound { public class RectBoundAdapter extends RectAdapter implements PluggableRectBound {
private RectBound backing = null; private RectBound backing = null;
public RectBoundAdapter() {
}
public RectBoundAdapter(RectBound bound) {
backing = bound;
}
@Override @Override
public void setRect(RectBound rect) public void setRect(RectBound rect)
{ {

@ -35,6 +35,13 @@ public abstract class Vect implements VectBound {
} }
@FactoryMethod
public static Vect make(VectBound bound)
{
return new VectBoundAdapter(bound);
}
@FactoryMethod @FactoryMethod
public static VectConst make(NumConst xc, NumConst yc) public static VectConst make(NumConst xc, NumConst yc)
{ {

@ -10,6 +10,15 @@ public class VectBoundAdapter extends VectAdapter implements PluggableVectBound
private VectBound backing = null; private VectBound backing = null;
public VectBoundAdapter() {
}
public VectBoundAdapter(VectBound bound) {
backing = bound;
}
@Override @Override
public void setVect(VectBound rect) public void setVect(VectBound rect)
{ {

Loading…
Cancel
Save