Package de.lessvoid.nifty.effects

Source Code of de.lessvoid.nifty.effects.EffectPropertiesValues

package de.lessvoid.nifty.effects;

import java.util.ArrayList;
import java.util.List;

import de.lessvoid.nifty.tools.LinearInterpolator;
import de.lessvoid.xml.xpp3.Attributes;

public class EffectPropertiesValues {
  private List < Attributes > values = new ArrayList < Attributes > ();

  public void add(final Attributes p) {
    values.add(p);
  }

  public List < Attributes > getValues() {
    return values;
  }

  public LinearInterpolator toLinearInterpolator() {
    if (values.isEmpty()) {
      return null;
    }
    if (!containsTimeValues()) {
      return null;
    }
    LinearInterpolator interpolator = new LinearInterpolator();
    for (Attributes p : values) {
        interpolator.addPoint(p.getAsFloat("time"), p.getAsFloat("value"));
      }
    return interpolator;
  }

  public boolean containsTimeValues() {
    if (values.isEmpty()) {
      return false;
    }
    for (Attributes p : values) {
      if (p.isSet("time")) {
        return true;
      }
    }
    return false;
  }     
}
TOP

Related Classes of de.lessvoid.nifty.effects.EffectPropertiesValues

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.