Focal radial gradient raw edit fix

This commit is contained in:
2017-04-01 11:31:10 +02:00
parent bbb04921d6
commit 29f5c17767
6 changed files with 73 additions and 9 deletions
@@ -1201,8 +1201,7 @@ public class SWFOutputStream extends OutputStream {
if ((value.fillStyleType == FILLSTYLE.LINEAR_GRADIENT)
|| (value.fillStyleType == FILLSTYLE.RADIAL_GRADIENT)) {
writeGRADIENT(value.gradient, shapeNum);
}
if (value.fillStyleType == FILLSTYLE.FOCAL_RADIAL_GRADIENT) {
} else if (value.fillStyleType == FILLSTYLE.FOCAL_RADIAL_GRADIENT) {
writeFOCALGRADIENT((FOCALGRADIENT) value.gradient, shapeNum);
}
@@ -26,13 +26,14 @@ import com.jpexs.decompiler.flash.types.annotations.Internal;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.decompiler.flash.types.annotations.SWFVersion;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.util.Set;
/**
*
* @author JPEXS
*/
public class FILLSTYLE implements NeedsCharacters, Serializable {
public class FILLSTYLE implements NeedsCharacters, FieldChangeObserver, Serializable {
@SWFType(BasicType.UI8)
@EnumValue(value = SOLID, text = "Solid")
@@ -120,4 +121,26 @@ public class FILLSTYLE implements NeedsCharacters, Serializable {
}
return false;
}
@Override
public void fieldChanged(Field field) {
if ((fillStyleType == FILLSTYLE.LINEAR_GRADIENT)
|| (fillStyleType == FILLSTYLE.RADIAL_GRADIENT)) {
if (gradient instanceof FOCALGRADIENT) {
GRADIENT g = new GRADIENT();
g.spreadMode = gradient.spreadMode;
g.interpolationMode = gradient.interpolationMode;
g.gradientRecords = gradient.gradientRecords;
gradient = g;
}
} else if (fillStyleType == FILLSTYLE.FOCAL_RADIAL_GRADIENT) {
if (!(gradient instanceof FOCALGRADIENT)) {
FOCALGRADIENT g = new FOCALGRADIENT();
g.spreadMode = gradient.spreadMode;
g.interpolationMode = gradient.interpolationMode;
g.gradientRecords = gradient.gradientRecords;
gradient = g;
}
}
}
}
@@ -0,0 +1,28 @@
/*
* Copyright (C) 2010-2016 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.types;
import java.lang.reflect.Field;
/**
*
* @author JPEXS
*/
public interface FieldChangeObserver {
void fieldChanged(Field field);
}
@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.types.annotations.parser;
import com.jpexs.decompiler.flash.types.annotations.Conditional;
import com.jpexs.decompiler.flash.types.annotations.ConditionalType;
import java.io.IOException;
import java.io.StringReader;
import java.util.EmptyStackException;
@@ -31,10 +32,14 @@ import java.util.Stack;
*/
public class ConditionEvaluator {
private final Conditional cond;
private final String[] values;
public ConditionEvaluator(Conditional cond) {
this.cond = cond;
values = cond.value();
}
public ConditionEvaluator(ConditionalType cond) {
values = cond.value();
}
private void expressionRest(Map<String, Boolean> fields, Stack<Boolean> stack, ConditionLexer lex) throws IOException, AnnotationParseException {
@@ -114,7 +119,7 @@ public class ConditionEvaluator {
}
private String prepareCond() {
String[] vals = cond.value();
String[] vals = values;
if (vals == null || vals.length == 0) {
return "";
}