use of org.jwildfire.create.tina.base.motion.MotionCurve in project JWildfire by thargor6.
the class AnimationService method _evalMotionCurves.
private static void _evalMotionCurves(Object pObject, double pFrame) throws IllegalAccessException {
Class<?> cls = pObject.getClass();
for (Field field : cls.getDeclaredFields()) {
field.setAccessible(true);
if (field.getType() == MotionCurve.class && field.getName().endsWith(Tools.CURVE_POSTFIX)) {
MotionCurve curve = (MotionCurve) field.get(pObject);
if (curve.isEnabled()) {
double value = evalCurve(pFrame, curve);
String propName = field.getName().substring(0, field.getName().length() - Tools.CURVE_POSTFIX.length());
curve.getChangeHandler().processValueChange(pObject, propName, value);
if (pObject instanceof RGBPalette) {
curve.getChangeHandler().processValueChange(pObject, "modified", 1.0);
}
// setPropertyValue(pObject, propName, value);
// System.out.println(propName + " " + value);
}
} else if (field.getType().isAssignableFrom(ArrayList.class)) {
List<?> childs = (List<?>) field.get(pObject);
for (Object child : childs) {
_evalMotionCurves(child, pFrame);
}
} else if (field.getType().isAssignableFrom(RGBPalette.class)) {
RGBPalette gradient = (RGBPalette) field.get(pObject);
_evalMotionCurves(gradient, pFrame);
} else if (field.getType().isAssignableFrom(SolidRenderSettings.class)) {
SolidRenderSettings settings = (SolidRenderSettings) field.get(pObject);
_evalMotionCurves(settings, pFrame);
}
}
if (pObject instanceof Variation) {
Variation var = (Variation) pObject;
VariationFunc func = var.getFunc();
for (String name : func.getParameterNames()) {
MotionCurve curve = var.getMotionCurve(name);
if (curve != null && curve.isEnabled()) {
double value = evalCurve(pFrame, curve);
try {
func.setParameter(name, value);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
}
}
use of org.jwildfire.create.tina.base.motion.MotionCurve in project JWildfire by thargor6.
the class EnvelopeDialog method findMotionCurve.
private MotionCurve findMotionCurve(Object pObject, List<String> pPath, int pPathIndex) {
String pathName;
String index;
{
String fullPathName = pPath.get(pPathIndex);
int p1 = fullPathName.lastIndexOf("[");
int p2 = fullPathName.indexOf("]", p1 + 1);
if (p1 > 0 && p2 > p1) {
pathName = fullPathName.substring(0, p1);
index = fullPathName.substring(p1 + 1, p2);
} else {
pathName = fullPathName;
index = "";
}
}
if (pPath.size() > 0) {
Class<?> cls = pObject.getClass();
if (pPathIndex == pPath.size() - 1) {
for (Field field : cls.getDeclaredFields()) {
field.setAccessible(true);
Object fieldValue;
try {
fieldValue = field.get(pObject);
} catch (Exception ex) {
fieldValue = null;
}
if (fieldValue != null && field.getName().equals(pathName)) {
if (fieldValue instanceof MotionCurve) {
return (MotionCurve) fieldValue;
} else if (fieldValue instanceof Map) {
Map<?, ?> map = (Map<?, ?>) fieldValue;
Object curve = map.get(index);
if (curve != null && curve instanceof MotionCurve) {
return (MotionCurve) curve;
}
}
}
}
} else {
for (Field field : cls.getDeclaredFields()) {
field.setAccessible(true);
Object fieldValue;
try {
fieldValue = field.get(pObject);
} catch (Exception ex) {
fieldValue = null;
}
if (fieldValue != null) {
if (fieldValue instanceof List && field.getName().equals(pathName) && index.length() > 0) {
List<?> list = (List<?>) fieldValue;
MotionCurve subResult = findMotionCurve(list.get(Integer.parseInt(index)), pPath, pPathIndex + 1);
if (subResult != null) {
return subResult;
}
} else if (fieldValue instanceof Map && field.getName().equals(pathName) && index.length() > 0) {
Map<?, ?> map = (Map<?, ?>) fieldValue;
MotionCurve subResult = findMotionCurve(map.get(index), pPath, pPathIndex + 1);
if (subResult != null) {
return subResult;
}
} else if (field.getName().equals(pathName)) {
MotionCurve subResult = findMotionCurve(fieldValue, pPath, pPathIndex + 1);
if (subResult != null) {
return subResult;
}
}
}
}
}
}
return null;
}
use of org.jwildfire.create.tina.base.motion.MotionCurve in project JWildfire by thargor6.
the class EnvelopeDialog method getFlame.
@Override
public Flame getFlame() {
if (flameToPreview != null) {
Flame res = flameToPreview.makeCopy();
res.setFrame(frameToPreview);
switch(flamePreviewType) {
case MOTION_CURVE:
if (curveToPreviewPropertyPath != null) {
MotionCurve curve = getMotionCurve(res, curveToPreviewPropertyPath);
if (curve != null) {
curve.setPoints(new int[] { frameToPreview }, new double[] { curveValueToPreview });
curve.setInterpolation(Interpolation.LINEAR);
curve.setEnabled(true);
}
}
break;
case COLOR_CURVE:
if (curveToPreviewPropertyPath != null) {
MotionCurve curve = getMotionCurve(res, curveToPreviewPropertyPath);
if (curve != null) {
curve.assignFromEnvelope(ctrl.getCurrEnvelope());
}
}
break;
default:
// nothing to do
break;
}
return res;
}
return null;
}
use of org.jwildfire.create.tina.base.motion.MotionCurve in project JWildfire by thargor6.
the class ChannelMixerPanelDelegate method notifyChange.
private void notifyChange(int pSelectedPoint, int pX, double pY) {
Flame flame = owner.getOwner().getCurrFlame();
if (owner.isUseUndoManager()) {
owner.getOwner().undoManager.saveUndoPoint(flame);
}
MotionCurve curve = getCurve(flame);
curve.assignFromEnvelope(ctrl.getCurrEnvelope());
owner.getOwner().refreshFlameImage(true, false, 1, true, true);
}
use of org.jwildfire.create.tina.base.motion.MotionCurve in project JWildfire by thargor6.
the class AbstractControlsDelegate method editMotionCurve.
protected void editMotionCurve(String pPropName, String pLabel) {
MotionCurve curve = getCurveToEdit(pPropName);
double initialValue;
try {
initialValue = getInitialValue(pPropName);
} catch (Exception ex) {
initialValue = 0.0;
}
editMotionCurve(curve, initialValue, pPropName, pLabel);
}
Aggregations