diff --git a/CHANGELOG.md b/CHANGELOG.md index 57ea3e8ba..7c3e93a48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ All notable changes to this project will be documented in this file. - [#1343] AS 1/2 direct editation critical bug - [#1348] Cannot properly export frame with cyrillic symbols to SVG - [#1354] Various FLA export problem fixes +- [#1367] Raw edit conditional type fix. ## [10.0.0] - 2016-12-24 ### Added diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/BitmapExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/BitmapExporter.java index 0f242649d..7af0c0510 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/BitmapExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/BitmapExporter.java @@ -46,6 +46,8 @@ import java.awt.geom.GeneralPath; import java.awt.geom.NoninvertibleTransformException; import java.util.ArrayList; import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; /** * @@ -85,6 +87,8 @@ public class BitmapExporter extends ShapeExporterBase { private Matrix strokeTransformation; + private static boolean linearGradientColorWarnignShown = false; + private class TransformedStroke implements Stroke { /** @@ -238,7 +242,17 @@ public class BitmapExporter extends ShapeExporterBase { cm = MultipleGradientPaint.CycleMethod.REPEAT; } - fillPaint = new LinearGradientPaint(POINT_NEG16384_0, POINT_16384_0, ratiosArr, colorsArr, cm, cstype, IDENTITY_TRANSFORM); + if (colorsArr.length >= 2) { + fillPaint = new LinearGradientPaint(POINT_NEG16384_0, POINT_16384_0, ratiosArr, colorsArr, cm, cstype, IDENTITY_TRANSFORM); + } else { + if (!linearGradientColorWarnignShown) { + Logger.getLogger(BitmapExporter.class.getName()).log(Level.WARNING, "Linear gradient fill should have at least 2 gradient records."); + linearGradientColorWarnignShown = true; + } + + fillPaint = null; + } + fillTransform = matrix.toTransform(); } break; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/Tag.java index c3e9a3aa2..bae51e888 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/Tag.java @@ -53,6 +53,7 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.logging.Logger; /** * Represents Tag inside SWF file @@ -61,6 +62,8 @@ import java.util.Set; */ public abstract class Tag implements NeedsCharacters, Exportable, Serializable { + private static final Logger logger = Logger.getLogger(Tag.class.getName()); + /** * Identifier of tag type */ diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/FILLSTYLE.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/FILLSTYLE.java index 4d305e6ca..0972138ab 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/FILLSTYLE.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/FILLSTYLE.java @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash.types; import com.jpexs.decompiler.flash.tags.DefineShape3Tag; +import com.jpexs.decompiler.flash.tags.DefineShape4Tag; import com.jpexs.decompiler.flash.tags.base.NeedsCharacters; import com.jpexs.decompiler.flash.types.annotations.Conditional; import com.jpexs.decompiler.flash.types.annotations.ConditionalType; @@ -66,7 +67,8 @@ public class FILLSTYLE implements NeedsCharacters, Serializable { @Internal public boolean inShape3; - @ConditionalType(type = RGBA.class, tags = DefineShape3Tag.ID) + @Conditional(value = "fillStyleType", options = {SOLID}) + @ConditionalType(type = RGBA.class, tags = {DefineShape3Tag.ID, DefineShape4Tag.ID}) public RGB color; @Conditional(value = "fillStyleType", options = {LINEAR_GRADIENT, RADIAL_GRADIENT, FOCAL_RADIAL_GRADIENT}) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/LINESTYLE.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/LINESTYLE.java index 172e5e810..26628ccd1 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/LINESTYLE.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/LINESTYLE.java @@ -33,7 +33,7 @@ public class LINESTYLE implements NeedsCharacters, Serializable { @SWFType(BasicType.UI16) public int width; - @ConditionalType(tags = {DefineShape3Tag.ID, DefineShape4Tag.ID}, type = RGBA.class) + @ConditionalType(type = RGBA.class, tags = {DefineShape3Tag.ID, DefineShape4Tag.ID}) public RGB color; @Override diff --git a/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java b/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java index 53a22d829..7d6e3f643 100644 --- a/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java @@ -34,6 +34,7 @@ import com.jpexs.decompiler.flash.types.BasicType; import com.jpexs.decompiler.flash.types.RGB; import com.jpexs.decompiler.flash.types.RGBA; import com.jpexs.decompiler.flash.types.annotations.Conditional; +import com.jpexs.decompiler.flash.types.annotations.ConditionalType; import com.jpexs.decompiler.flash.types.annotations.EnumValue; import com.jpexs.decompiler.flash.types.annotations.EnumValues; import com.jpexs.decompiler.flash.types.annotations.HideInRawEdit; @@ -478,13 +479,16 @@ public class GenericTagTreePanel extends GenericTagPanel { private static final class FieldNode extends DefaultMutableTreeNode { + private Tag tag; + private Object obj; private FieldSet fieldSet; private int index; - public FieldNode(Object obj, FieldSet fieldSet, int index) { + public FieldNode(Tag tag, Object obj, FieldSet fieldSet, int index) { + this.tag = tag; this.obj = obj; this.fieldSet = fieldSet; this.index = index; @@ -682,7 +686,28 @@ public class GenericTagTreePanel extends GenericTagPanel { Object val = ReflectionTools.getValue(obj, fieldSet.get(fieldIndex), index); if (val == null) { try { - val = ReflectionTools.newInstanceOf(fieldSet.get(fieldIndex).getType()); + Class type = fieldSet.get(fieldIndex).getType(); + ConditionalType cond = fieldSet.get(fieldIndex).getAnnotation(ConditionalType.class); + if (cond != null) { + boolean condEnabled = false; + int[] tags = cond.tags(); + if (tags != null && tags.length > 0) { + int tagId = tag.getId(); + for (int i = 0; i < tags.length; i++) { + if (tags[i] == tagId) { + condEnabled = true; + break; + } + } + } + + // todo: check other condition filters + if (condEnabled) { + type = cond.type(); + } + } + + val = ReflectionTools.newInstanceOf(type); ReflectionTools.setValue(obj, fieldSet.get(fieldIndex), index, val); } catch (InstantiationException | IllegalAccessException ex) { logger.log(Level.SEVERE, null, ex); @@ -725,7 +750,7 @@ public class GenericTagTreePanel extends GenericTagPanel { private static class MyTreeModel extends DefaultTreeModel { - private final Object mtroot; + private final Tag mtroot; private final List listeners = new ArrayList<>(); @@ -814,15 +839,15 @@ public class GenericTagTreePanel extends GenericTagPanel { private Object getChild(Object parent, int index, boolean limited) { if (parent == mtroot) { - return new FieldNode(mtroot, filterFields(this, mtroot.getClass().getSimpleName(), mtroot.getClass(), limited).get(index), -1); + return new FieldNode(mtroot, mtroot, filterFields(this, mtroot.getClass().getSimpleName(), mtroot.getClass(), limited).get(index), -1); } FieldNode fnode = (FieldNode) parent; Field field = fnode.fieldSet.get(FIELD_INDEX); if (ReflectionTools.needsIndex(field) && (fnode.index == -1)) { //Arrays ot Lists - return new FieldNode(fnode.obj, fnode.fieldSet, index); + return new FieldNode(mtroot, fnode.obj, fnode.fieldSet, index); } parent = fnode.getValue(FIELD_INDEX); - return new FieldNode(parent, filterFields(this, getNodePathName(fnode), parent.getClass(), limited).get(index), -1); + return new FieldNode(mtroot, parent, filterFields(this, getNodePathName(fnode), parent.getClass(), limited).get(index), -1); } @Override