/** * @return <code>true</code> if this controllers {@link #getRepeatType() repeat type} is * {@link ComplexSpatialController.RepeatType#CLAMP clamp} and its currently clamped at the maximum index. */ public boolean isClamped() { return isRepeatTypeClamp() && getIndex() == getMaximumIndex(); }
/** * @return <code>true</code> if this controllers {@link #getRepeatType() repeat type} is * {@link ComplexSpatialController.RepeatType#CLAMP clamp} and its currently clamped at the maximum index. */ public boolean isClamped() { return isRepeatTypeClamp() && getIndex() == getMaximumIndex(); }
/** * This method assumes the {@link #getIndex() index} has already been {@link #clampIndex() clamped} correctly. * * @return The control to interpolate from, will not be <code>null</code>. * @see #getControlTo() */ protected C getControlFrom() { C from = null; switch (getRepeatType()) { case CLAMP: if (getIndex() > getMaximumIndex()) { from = getControls().get(getMaximumIndex()); } else { from = getControls().get(getIndex()); } break; case CYCLE: from = getControls().get(getIndex()); break; case WRAP: from = getControls().get(getIndex()); break; } return from; }
/** * This method assumes the {@link #getIndex() index} has already been {@link #clampIndex() clamped} correctly. * * @return The control to interpolate from, will not be <code>null</code>. * @see #getControlTo() */ protected C getControlFrom() { C from = null; switch (getRepeatType()) { case CLAMP: if (getIndex() > getMaximumIndex()) { from = getControls().get(getMaximumIndex()); } else { from = getControls().get(getIndex()); } break; case CYCLE: from = getControls().get(getIndex()); break; case WRAP: from = getControls().get(getIndex()); break; } return from; }
/** * This method assumes the {@link #getIndex() index} has already been {@link #clampIndex() clamped} correctly. * * @return The control to interpolate to, will not be <code>null</code>. * @see #getControlFrom() */ protected C getControlTo() { C to = null; switch (getRepeatType()) { case CLAMP: if (getIndex() >= getMaximumIndex()) { to = getControls().get(getMaximumIndex()); } else { to = getControls().get(getIndex() + 1); } break; case CYCLE: if (isCycleForward()) { to = getControls().get(getIndex() + 1); } else { to = getControls().get(getIndex() - 1); } break; case WRAP: to = getControls().get(getIndex() + 1); break; } return to; }
/** * This method assumes the {@link #getIndex() index} has already been {@link #clampIndex() clamped} correctly. * * @return The control to interpolate to, will not be <code>null</code>. * @see #getControlFrom() */ protected C getControlTo() { C to = null; switch (getRepeatType()) { case CLAMP: if (getIndex() >= getMaximumIndex()) { to = getControls().get(getMaximumIndex()); } else { to = getControls().get(getIndex() + 1); } break; case CYCLE: if (isCycleForward()) { to = getControls().get(getIndex() + 1); } else { to = getControls().get(getIndex() - 1); } break; case WRAP: to = getControls().get(getIndex() + 1); break; } return to; }
/** * Interpolates on the set {@link #getControls() controls}. * <p> * It will only update the given object if this controller is {@link #isActive() active}, caller isn't * <code>null</code> and it's {@link #getSpeed() speed} is greater than zero. * </p> * * @param time * The passed since this controller was last called. * @param caller * The object to update, if this is <code>null</code> nothing will be updated. */ @Override public void update(final double time, final T caller) { if (shouldUpdate(time, caller)) { updateDeltaAndIndex(time); assert (getDelta() >= DELTA_MIN) : "delta is less than " + DELTA_MIN + ", updateDeltaAndIndex() has probably been overriden incorrectly"; assert (getDelta() <= DELTA_MAX) : "delta is greater than " + DELTA_MAX + ", updateDeltaAndIndex() has probably been overriden incorrectly"; clampIndex(); assert (getIndex() < getControls().size()) : "_index was greater than the number of controls, clampIndex() has probably been overriden incorrectly"; assert (getIndex() >= 0) : "_index was negative, clampIndex() has probably been overriden incorrectly"; interpolate(getControlFrom(), getControlTo(), getDelta(), caller); } }
/** * Interpolates on the set {@link #getControls() controls}. * <p> * It will only update the given object if this controller is {@link #isActive() active}, caller isn't * <code>null</code> and it's {@link #getSpeed() speed} is greater than zero. * </p> * * @param time * The passed since this controller was last called. * @param caller * The object to update, if this is <code>null</code> nothing will be updated. */ @Override public void update(final double time, final T caller) { if (shouldUpdate(time, caller)) { updateDeltaAndIndex(time); assert (getDelta() >= DELTA_MIN) : "delta is less than " + DELTA_MIN + ", updateDeltaAndIndex() has probably been overriden incorrectly"; assert (getDelta() <= DELTA_MAX) : "delta is greater than " + DELTA_MAX + ", updateDeltaAndIndex() has probably been overriden incorrectly"; clampIndex(); assert (getIndex() < getControls() .size()) : "_index was greater than the number of controls, clampIndex() has probably been overriden incorrectly"; assert (getIndex() >= 0) : "_index was negative, clampIndex() has probably been overriden incorrectly"; interpolate(getControlFrom(), getControlTo(), getDelta(), caller); } }
switch (getRepeatType()) { case CLAMP: if (getIndex() >= getMaximumIndex()) { if (getIndex() >= getMaximumIndex()) { setIndex(getMaximumIndex()); setCycleForward(false); if (getIndex() <= getMinimumIndex()) { setIndex(getMinimumIndex()); setCycleForward(true); if (getIndex() >= getMaximumIndex()) { setIndex(getMinimumIndex());
switch (getRepeatType()) { case CLAMP: if (getIndex() >= getMaximumIndex()) { if (getIndex() >= getMaximumIndex()) { setIndex(getMaximumIndex()); setCycleForward(false); if (getIndex() <= getMinimumIndex()) { setIndex(getMinimumIndex()); setCycleForward(true); if (getIndex() >= getMaximumIndex()) { setIndex(getMinimumIndex());