mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-01 23:54:37 +00:00
merge
XML attributes fix, namespaces fixes
This commit is contained in:
@@ -55,6 +55,8 @@ import com.jpexs.decompiler.flash.ecma.Null;
|
||||
import com.jpexs.decompiler.flash.exporters.ExportRectangle;
|
||||
import com.jpexs.decompiler.flash.exporters.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.PathExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.exporters.modes.BinaryDataExportMode;
|
||||
import com.jpexs.decompiler.flash.exporters.modes.FontExportMode;
|
||||
import com.jpexs.decompiler.flash.exporters.modes.FramesExportMode;
|
||||
@@ -1512,7 +1514,7 @@ public final class SWF implements TreeItem, Timelined {
|
||||
}
|
||||
|
||||
public List<File> exportFrames(AbortRetryIgnoreHandler handler, String outdir, int containerId, List<Integer> frames, final FramesExportMode mode) throws IOException {
|
||||
List<File> ret = new ArrayList<>();
|
||||
final List<File> ret = new ArrayList<>();
|
||||
if (tags.isEmpty()) {
|
||||
return ret;
|
||||
}
|
||||
@@ -1553,6 +1555,25 @@ public final class SWF implements TreeItem, Timelined {
|
||||
}
|
||||
}
|
||||
|
||||
if (mode == FramesExportMode.SVG) {
|
||||
for (int i = 0; i < frames.size(); i++) {
|
||||
final int fi = i;
|
||||
final Timeline ftim = tim;
|
||||
final Color fbackgroundColor = backgroundColor;
|
||||
new RetryTask(new RunnableIOEx() {
|
||||
@Override
|
||||
public void run() throws IOException {
|
||||
int frame = fframes.get(fi);
|
||||
File f = new File(foutdir + File.separator + fframes.get(fi) + ".svg");
|
||||
try (FileOutputStream fos = new FileOutputStream(f)) {
|
||||
fos.write(Utf8Helper.getBytes(frameToSvgGet(ftim, frame, 0, null, 0, ftim.displayRect, new Matrix(), new ColorTransform(), fbackgroundColor)));
|
||||
}
|
||||
ret.add(f);
|
||||
}
|
||||
}, handler).run();
|
||||
}
|
||||
}
|
||||
|
||||
final List<BufferedImage> frameImages = new ArrayList<>();
|
||||
for (int frame : frames) {
|
||||
frameImages.add(frameToImageGet(tim, frame, 0, null, 0, tim.displayRect, new Matrix(), new ColorTransform(), backgroundColor).getBufferedImage());
|
||||
@@ -1562,7 +1583,9 @@ public final class SWF implements TreeItem, Timelined {
|
||||
new RetryTask(new RunnableIOEx() {
|
||||
@Override
|
||||
public void run() throws IOException {
|
||||
makeGIF(frameImages, frameRate, new File(foutdir + File.separator + "frames.gif"));
|
||||
File f = new File(foutdir + File.separator + "frames.gif");
|
||||
makeGIF(frameImages, frameRate, f);
|
||||
ret.add(f);
|
||||
}
|
||||
}, handler).run();
|
||||
break;
|
||||
@@ -1572,7 +1595,9 @@ public final class SWF implements TreeItem, Timelined {
|
||||
new RetryTask(new RunnableIOEx() {
|
||||
@Override
|
||||
public void run() throws IOException {
|
||||
ImageIO.write(frameImages.get(fi), "PNG", new File(foutdir + File.separator + fframes.get(fi) + ".png"));
|
||||
File f = new File(foutdir + File.separator + fframes.get(fi) + ".png");
|
||||
ImageIO.write(frameImages.get(fi), "PNG", f);
|
||||
ret.add(f);
|
||||
}
|
||||
}, handler).run();
|
||||
}
|
||||
@@ -1581,7 +1606,9 @@ public final class SWF implements TreeItem, Timelined {
|
||||
new RetryTask(new RunnableIOEx() {
|
||||
@Override
|
||||
public void run() throws IOException {
|
||||
makeAVI(frameImages, frameRate, new File(foutdir + File.separator + "frames.avi"));
|
||||
File f = new File(foutdir + File.separator + "frames.avi");
|
||||
makeAVI(frameImages, frameRate, f);
|
||||
ret.add(f);
|
||||
}
|
||||
}, handler).run();
|
||||
break;
|
||||
@@ -1843,7 +1870,7 @@ public final class SWF implements TreeItem, Timelined {
|
||||
switch (mode) {
|
||||
case SVG:
|
||||
try (FileOutputStream fos = new FileOutputStream(file)) {
|
||||
fos.write(Utf8Helper.getBytes(st.toSVG()));
|
||||
fos.write(Utf8Helper.getBytes(st.toSVG(new SVGExporterContext())));
|
||||
}
|
||||
break;
|
||||
case PNG:
|
||||
@@ -1898,7 +1925,7 @@ public final class SWF implements TreeItem, Timelined {
|
||||
switch (mode) {
|
||||
case SVG:
|
||||
try (FileOutputStream fos = new FileOutputStream(file)) {
|
||||
fos.write(Utf8Helper.getBytes(mst.toSVG()));
|
||||
fos.write(Utf8Helper.getBytes(mst.toSVG(new SVGExporterContext())));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -2557,6 +2584,102 @@ public final class SWF implements TreeItem, Timelined {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static String frameToSvgGet(Timeline timeline, int frame, int time, DepthState stateUnderCursor, int mouseButton, RECT displayRect, Matrix transformation, ColorTransform colorTransform, Color backGroundColor) {
|
||||
RECT rect = displayRect;
|
||||
SVGExporter exporter = new SVGExporter(timeline.swf, new ExportRectangle(rect), colorTransform);
|
||||
if (backGroundColor != null) {
|
||||
exporter.setBackGroundColor(backGroundColor);
|
||||
}
|
||||
Matrix m = new Matrix();
|
||||
m.translate(-rect.Xmin, -rect.Ymin);
|
||||
if (timeline.frames.isEmpty()) {
|
||||
frameToSvg(timeline, frame, time, stateUnderCursor, mouseButton, exporter, m, colorTransform);
|
||||
}
|
||||
return exporter.getSVG();
|
||||
}
|
||||
|
||||
public static void frameToSvg(Timeline timeline, int frame, int time, DepthState stateUnderCursor, int mouseButton, SVGExporter exporter, Matrix transformation, ColorTransform colorTransform) {
|
||||
float unzoom = (float) SWF.unitDivisor;
|
||||
if (timeline.frames.size() <= frame) {
|
||||
return;
|
||||
}
|
||||
Frame frameObj = timeline.frames.get(frame);
|
||||
// TODO g.setTransform(transformation.toTransform());
|
||||
List<Clip> clips = new ArrayList<>();
|
||||
List<Shape> prevClips = new ArrayList<>();
|
||||
|
||||
for (int i = 1; i <= timeline.getMaxDepth(); i++) {
|
||||
for (int c = 0; c < clips.size(); c++) {
|
||||
if (clips.get(c).depth == i) {
|
||||
// TODO exporter.setClip(prevClips.get(c));
|
||||
prevClips.remove(c);
|
||||
clips.remove(c);
|
||||
}
|
||||
}
|
||||
if (!frameObj.layers.containsKey(i)) {
|
||||
continue;
|
||||
}
|
||||
DepthState layer = frameObj.layers.get(i);
|
||||
if (!timeline.swf.characters.containsKey(layer.characterId)) {
|
||||
continue;
|
||||
}
|
||||
if (!layer.isVisible) {
|
||||
continue;
|
||||
}
|
||||
CharacterTag character = timeline.swf.characters.get(layer.characterId);
|
||||
Matrix mat = new Matrix(layer.matrix);
|
||||
mat = mat.preConcatenate(transformation);
|
||||
|
||||
if (colorTransform == null) {
|
||||
colorTransform = new ColorTransform();
|
||||
}
|
||||
|
||||
ColorTransform clrTrans = Helper.deepCopy(colorTransform);
|
||||
if (layer.colorTransForm != null && layer.blendMode <= 1) { //Normal blend mode
|
||||
clrTrans = colorTransform.merge(layer.colorTransForm);
|
||||
}
|
||||
|
||||
if (character instanceof DrawableTag) {
|
||||
DrawableTag drawable = (DrawableTag) character;
|
||||
Matrix drawMatrix = new Matrix();
|
||||
int dframe = (time + layer.time) % drawable.getNumFrames();
|
||||
if (character instanceof ButtonTag) {
|
||||
ButtonTag bt = (ButtonTag) character;
|
||||
dframe = ButtonTag.FRAME_UP;
|
||||
if (stateUnderCursor == layer) {
|
||||
if (mouseButton > 0) {
|
||||
dframe = ButtonTag.FRAME_DOWN;
|
||||
} else {
|
||||
dframe = ButtonTag.FRAME_OVER;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RECT boundRect = drawable.getRect();
|
||||
ExportRectangle rect = new ExportRectangle(boundRect);
|
||||
rect = mat.transform(rect);
|
||||
Matrix m = mat.clone();
|
||||
|
||||
m.translate(-rect.xMin, -rect.yMin);
|
||||
drawMatrix.translate(rect.xMin, rect.yMin);
|
||||
|
||||
//drawable.toSVG(dframe, layer.time + time, layer.ratio, stateUnderCursor, mouseButton, exporter, m, clrTrans);
|
||||
// TODO: drawable.toSVG();
|
||||
|
||||
// TODO: if (layer.filters != null)
|
||||
// TODO: if (layer.blendMode > 1)
|
||||
|
||||
drawMatrix.translateX /= unzoom;
|
||||
drawMatrix.translateY /= unzoom;
|
||||
AffineTransform trans = drawMatrix.toTransform();
|
||||
|
||||
// TODO: if (layer.clipDepth > -1)...
|
||||
// TODO: g.setTransform(trans);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static SerializableImage frameToImageGet(Timeline timeline, int frame, int time, DepthState stateUnderCursor, int mouseButton, RECT displayRect, Matrix transformation, ColorTransform colorTransform, Color backGroundColor) {
|
||||
String key = "frame_" + frame + "_" + timeline.id + "_" + timeline.swf.hashCode();
|
||||
SerializableImage image = getFromCache(key);
|
||||
|
||||
@@ -184,9 +184,23 @@ public class ActionScriptParser {
|
||||
ParsedSymbol s = lex();
|
||||
while (s.isType(SymbolType.DOT)) {
|
||||
s = lex();
|
||||
boolean attr = false;
|
||||
if(s.type == SymbolType.ATTRIBUTE){
|
||||
attr = true;
|
||||
s = lex();
|
||||
}
|
||||
expected(s, lexer.yyline(), SymbolType.IDENTIFIER);
|
||||
String propName = s.value.toString();
|
||||
s = lex();
|
||||
GraphTargetItem ns = null;
|
||||
if(s.type == SymbolType.NAMESPACE_OP){
|
||||
s = lex();
|
||||
expected(s, lexer.yyline(), SymbolType.IDENTIFIER);
|
||||
ns = new UnresolvedAVM2Item(new ArrayList<String>(), importedClasses, false, null, lexer.yyline(), propName, null, openedNamespaces);
|
||||
variables.add((UnresolvedAVM2Item)ns);
|
||||
propName = s.value.toString();
|
||||
s = lex();
|
||||
}
|
||||
GraphTargetItem index = null;
|
||||
if (s.type == SymbolType.BRACKET_OPEN) {
|
||||
index = expression(needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables);
|
||||
@@ -194,7 +208,12 @@ public class ActionScriptParser {
|
||||
} else {
|
||||
lexer.pushback(s);
|
||||
}
|
||||
ret = new PropertyAVM2Item(ret, propName, index, abc, otherABCs, openedNamespaces, new ArrayList<MethodBody>());
|
||||
if(ns!=null){
|
||||
ret = new NamespacedAVM2Item(index, ns, propName, ret,attr , openedNamespaces, null);
|
||||
}else{
|
||||
ret = new PropertyAVM2Item(ret, (attr?"@":"")+propName, index, abc, otherABCs, openedNamespaces, new ArrayList<MethodBody>());
|
||||
}
|
||||
s = lex();
|
||||
}
|
||||
lexer.pushback(s);
|
||||
return ret;
|
||||
@@ -210,9 +229,10 @@ public class ActionScriptParser {
|
||||
expected(s, lexer.yyline(), SymbolType.IDENTIFIER, SymbolType.THIS, SymbolType.SUPER, SymbolType.STRING_OP);
|
||||
name += s.value.toString();
|
||||
s = lex();
|
||||
while (s.type == SymbolType.DOT) {
|
||||
|
||||
while (s.isType(SymbolType.DOT)) {
|
||||
name += s.value.toString(); //. or ::
|
||||
s = lex();
|
||||
name += ".";
|
||||
if(s.type == SymbolType.ATTRIBUTE){
|
||||
name += "@";
|
||||
s = lex();
|
||||
@@ -225,11 +245,35 @@ public class ActionScriptParser {
|
||||
continue;
|
||||
}
|
||||
}else{
|
||||
expected(s, lexer.yyline(), SymbolType.IDENTIFIER);
|
||||
expected(s, lexer.yyline(), SymbolType.IDENTIFIER, SymbolType.NAMESPACE);
|
||||
name += s.value.toString();
|
||||
}
|
||||
s = lex();
|
||||
}
|
||||
String nsname = null;
|
||||
String nsprop = null;
|
||||
if(s.type == SymbolType.NAMESPACE_OP){
|
||||
if(name.contains(".")){
|
||||
nsname = name.substring(name.lastIndexOf(".")+1);
|
||||
}else{
|
||||
nsname = name;
|
||||
}
|
||||
s = lex();
|
||||
if(s.type == SymbolType.IDENTIFIER){
|
||||
nsprop = s.value.toString();
|
||||
}else{
|
||||
nsprop = null;
|
||||
lexer.pushback(s);
|
||||
}
|
||||
if(name.contains(".")){
|
||||
name = name.substring(0,name.lastIndexOf("."));
|
||||
}else{
|
||||
name = null;
|
||||
}
|
||||
s = lex();
|
||||
}
|
||||
|
||||
|
||||
List<String> params = new ArrayList<>();
|
||||
if (s.type == SymbolType.TYPENAME) {
|
||||
s = lex();
|
||||
@@ -259,9 +303,24 @@ public class ActionScriptParser {
|
||||
} else {
|
||||
lexer.pushback(s);
|
||||
}
|
||||
UnresolvedAVM2Item ret = new UnresolvedAVM2Item(params, importedClasses, typeOnly, null, lexer.yyline(), name, null, openedNamespaces);
|
||||
ret.setIndex(index);
|
||||
variables.add(ret);
|
||||
|
||||
|
||||
GraphTargetItem ret = null;
|
||||
if(name!=null){
|
||||
UnresolvedAVM2Item unr = new UnresolvedAVM2Item(params, importedClasses, typeOnly, null, lexer.yyline(), name, null, openedNamespaces);
|
||||
unr.setIndex(index);
|
||||
variables.add(unr);
|
||||
ret = unr;
|
||||
}
|
||||
if(nsname!=null){
|
||||
boolean attr= nsname.startsWith("@");
|
||||
if(attr){
|
||||
nsname = nsname.substring(1);
|
||||
}
|
||||
UnresolvedAVM2Item ns = new UnresolvedAVM2Item(params, importedClasses, typeOnly, null, lexer.yyline(), nsname, null, openedNamespaces);
|
||||
variables.add(ns);
|
||||
ret = new NamespacedAVM2Item(index, ns, nsprop, ret,attr, openedNamespaces, null);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1451,7 +1510,7 @@ public class ActionScriptParser {
|
||||
expectedType(SymbolType.PARENT_CLOSE);
|
||||
allowRemainder = true;
|
||||
break;
|
||||
case NAMESPACE_OP:
|
||||
/*case NAMESPACE_OP:
|
||||
s = lex();
|
||||
if (s.type == SymbolType.BRACKET_OPEN) {
|
||||
GraphTargetItem index = expression(needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables);
|
||||
@@ -1472,7 +1531,7 @@ public class ActionScriptParser {
|
||||
}
|
||||
ret = name;
|
||||
}
|
||||
break;
|
||||
break;*/
|
||||
case IN:
|
||||
ret = new InAVM2Item(null, expr, expression(needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables));
|
||||
break;
|
||||
|
||||
@@ -240,49 +240,16 @@ public class NameAVM2Item extends AssignableAVM2Item {
|
||||
if (definition && assignedValue == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
String name = variableName;
|
||||
boolean attr = false;
|
||||
if(name!=null && name.startsWith("@")){
|
||||
name = name.substring(1);
|
||||
attr = true;
|
||||
}
|
||||
AVM2SourceGenerator g = (AVM2SourceGenerator) generator;
|
||||
Reference<Integer> ns_temp = new Reference<>(-1);
|
||||
Reference<Integer> index_temp = new Reference<>(-1);
|
||||
Reference<Integer> ret_temp = new Reference<>(-1);
|
||||
|
||||
if (variableName == null && ns != null && index != null) {
|
||||
if (assignedValue != null) {
|
||||
return toSourceMerge(localData, generator,
|
||||
ns, generateCoerce(generator, new TypeItem("Namespace")), index, ins(new ConvertSIns()), ins(new FindPropertyStrictIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAMEL, 0, 0, 0, 0, new ArrayList<Integer>()), true)),
|
||||
ns, generateCoerce(generator, new TypeItem("Namespace")), index, ins(new ConvertSIns()), assignedValue,
|
||||
needsReturn ? dupSetTemp(localData, generator, ret_temp) : null,
|
||||
ins(new SetPropertyIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAMEL, 0, 0, 0, 0, new ArrayList<Integer>()), true)),
|
||||
needsReturn ? getTemp(localData, generator, ret_temp) : null,
|
||||
killTemp(localData, generator, Arrays.asList(ns_temp, index_temp, ret_temp))
|
||||
);
|
||||
} else {
|
||||
return toSourceMerge(localData, generator,
|
||||
ns, generateCoerce(generator, new TypeItem("Namespace")), index, ins(new ConvertSIns()), ins(new FindPropertyStrictIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAMEL, 0, 0, 0, 0, new ArrayList<Integer>()), true)),
|
||||
ns, generateCoerce(generator, new TypeItem("Namespace")), index, ins(new ConvertSIns()), ins(new GetPropertyIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAMEL, 0, 0, 0, 0, new ArrayList<Integer>()), true)),
|
||||
needsReturn ? null : ins(new PopIns()),
|
||||
killTemp(localData, generator, Arrays.asList(ns_temp, index_temp, ret_temp))
|
||||
);
|
||||
}
|
||||
}
|
||||
if (variableName != null && ns != null && index == null) {
|
||||
if (assignedValue != null) {
|
||||
return toSourceMerge(localData, generator,
|
||||
ns, generateCoerce(generator, new TypeItem("Namespace")), ins(new FindPropertyStrictIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAME, g.abc.constants.getStringId(variableName, true), 0, 0, 0, new ArrayList<Integer>()), true)),
|
||||
ns, generateCoerce(generator, new TypeItem("Namespace")), assignedValue,
|
||||
needsReturn ? dupSetTemp(localData, generator, ret_temp) : null,
|
||||
ins(new SetPropertyIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAME, g.abc.constants.getStringId(variableName, true), 0, 0, 0, new ArrayList<Integer>()), true)),
|
||||
needsReturn ? getTemp(localData, generator, ret_temp) : null,
|
||||
killTemp(localData, generator, Arrays.asList(ns_temp, index_temp, ret_temp))
|
||||
);
|
||||
} else {
|
||||
return toSourceMerge(localData, generator,
|
||||
ns, generateCoerce(generator, new TypeItem("Namespace")), ins(new FindPropertyStrictIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAME, g.abc.constants.getStringId(variableName, true), 0, 0, 0, new ArrayList<Integer>()), true)),
|
||||
ns, generateCoerce(generator, new TypeItem("Namespace")), ins(new GetPropertyIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAME, g.abc.constants.getStringId(variableName, true), 0, 0, 0, new ArrayList<Integer>()), true)),
|
||||
needsReturn ? null : ins(new PopIns()),
|
||||
killTemp(localData, generator, Arrays.asList(ns_temp, index_temp, ret_temp))
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference<Integer> ret_temp = new Reference<>(-1);
|
||||
|
||||
if (index != null) {
|
||||
if (assignedValue != null) {
|
||||
@@ -389,54 +356,7 @@ public class NameAVM2Item extends AssignableAVM2Item {
|
||||
|
||||
*/
|
||||
|
||||
if (variableName == null && ns != null && index != null) {
|
||||
return toSourceMerge(localData, generator,
|
||||
ns, generateCoerce(generator, new TypeItem("Namespace")), index, ins(new ConvertSIns()),
|
||||
ins(new FindPropertyStrictIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAMEL, 0, 0, 0, 0, new ArrayList<Integer>()), true)),
|
||||
dupSetTemp(localData, generator, name_temp),
|
||||
ns, generateCoerce(generator, new TypeItem("Namespace")),
|
||||
dupSetTemp(localData, generator, ns_temp),
|
||||
//getTemp(localData, generator, ns_temp), generateCoerce(generator, "Namespace"), getTemp(localData, generator, index_temp), ins(new ConvertSIns()),
|
||||
//Start get original
|
||||
//getTemp(localData, generator, ns_temp), generateCoerce(generator, "Namespace"), getTemp(localData, generator, index_temp), ins(new ConvertSIns()), ins(new FindPropertyStrictIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAMEL, 0, 0, 0, 0, new ArrayList<Integer>()), true)),
|
||||
//getTemp(localData, generator, ns_temp), generateCoerce(generator, "Namespace"), getTemp(localData, generator, index_temp), ins(new ConvertSIns()),
|
||||
ins(new GetPropertyIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.MULTINAMEL, 0, 0, allNsSet(g.abc), 0, new ArrayList<Integer>()), true)),
|
||||
!isInteger ? ins(new ConvertDIns()) : null,
|
||||
//End get original
|
||||
(!post) ? (decrement ? ins(isInteger ? new DecrementIIns() : new DecrementIns()) : ins(isInteger ? new IncrementIIns() : new IncrementIns())) : null,
|
||||
needsReturn ? ins(new DupIns()) : null,
|
||||
(post) ? (decrement ? ins(isInteger ? new DecrementIIns() : new DecrementIns()) : ins(isInteger ? new IncrementIIns() : new IncrementIns())) : null,
|
||||
setTemp(localData, generator, ret_temp),
|
||||
getTemp(localData, generator, name_temp),
|
||||
getTemp(localData, generator, ns_temp),
|
||||
getTemp(localData, generator, ret_temp),
|
||||
ins(new SetPropertyIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.MULTINAMEL, 0, 0, allNsSet(g.abc), 0, new ArrayList<Integer>()), true)),
|
||||
killTemp(localData, generator, Arrays.asList(ret_temp, name_temp, ns_temp)));
|
||||
}
|
||||
if (variableName != null && ns != null && index == null) {
|
||||
return toSourceMerge(localData, generator,
|
||||
ns, generateCoerce(generator, new TypeItem("Namespace")),
|
||||
ins(new FindPropertyStrictIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAME, g.abc.constants.getStringId(variableName, true), 0, 0, 0, new ArrayList<Integer>()), true)),
|
||||
dupSetTemp(localData, generator, name_temp),
|
||||
ns, generateCoerce(generator, new TypeItem("Namespace")),
|
||||
dupSetTemp(localData, generator, ns_temp),
|
||||
//Start get original
|
||||
//getTemp(localData, generator, ns_temp), generateCoerce(generator, "Namespace"), ins(new FindPropertyStrictIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAME, g.abc.constants.getStringId(variableName, true), 0, 0, 0, new ArrayList<Integer>()), true)),
|
||||
//getTemp(localData, generator, ns_temp), generateCoerce(generator, "Namespace"),
|
||||
ins(new GetPropertyIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.MULTINAMEL, 0, 0, allNsSet(g.abc), 0, new ArrayList<Integer>()), true)),
|
||||
!isInteger ? ins(new ConvertDIns()) : null,
|
||||
//End get original
|
||||
(!post) ? (decrement ? ins(isInteger ? new DecrementIIns() : new DecrementIns()) : ins(isInteger ? new IncrementIIns() : new IncrementIns())) : null,
|
||||
needsReturn ? ins(new DupIns()) : null,
|
||||
(post) ? (decrement ? ins(isInteger ? new DecrementIIns() : new DecrementIns()) : ins(isInteger ? new IncrementIIns() : new IncrementIns())) : null,
|
||||
setTemp(localData, generator, ret_temp),
|
||||
getTemp(localData, generator, name_temp),
|
||||
getTemp(localData, generator, ns_temp),
|
||||
getTemp(localData, generator, ret_temp),
|
||||
ins(new SetPropertyIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.MULTINAMEL, 0, 0, allNsSet(g.abc), 0, new ArrayList<Integer>()), true)),
|
||||
killTemp(localData, generator, Arrays.asList(ret_temp, name_temp, ns_temp))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if (index != null) {
|
||||
return toSourceMerge(localData, generator,
|
||||
|
||||
@@ -0,0 +1,226 @@
|
||||
/*
|
||||
* Copyright (C) 2014 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.jpexs.decompiler.flash.abc.avm2.parser.script;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.DecrementIIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.DecrementIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.IncrementIIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.IncrementIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.FindPropertyStrictIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.GetPropertyIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.SetPropertyIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.DupIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PopIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.types.ConvertDIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.types.ConvertSIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item;
|
||||
import static com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item.ins;
|
||||
import static com.jpexs.decompiler.flash.abc.avm2.parser.script.AssignableAVM2Item.dupSetTemp;
|
||||
import static com.jpexs.decompiler.flash.abc.avm2.parser.script.AssignableAVM2Item.getTemp;
|
||||
import static com.jpexs.decompiler.flash.abc.avm2.parser.script.AssignableAVM2Item.killTemp;
|
||||
import static com.jpexs.decompiler.flash.abc.avm2.parser.script.AssignableAVM2Item.setTemp;
|
||||
import static com.jpexs.decompiler.flash.abc.avm2.parser.script.NameAVM2Item.generateCoerce;
|
||||
import com.jpexs.decompiler.flash.abc.types.Multiname;
|
||||
import com.jpexs.decompiler.flash.abc.types.NamespaceSet;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import static com.jpexs.decompiler.graph.GraphTargetItem.toSourceMerge;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.TypeItem;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class NamespacedAVM2Item extends AssignableAVM2Item {
|
||||
|
||||
public GraphTargetItem index;
|
||||
public GraphTargetItem ns;
|
||||
public String name;
|
||||
public GraphTargetItem obj;
|
||||
public boolean attr;
|
||||
public List<Integer> openedNamespaces;
|
||||
|
||||
public NamespacedAVM2Item(GraphTargetItem index, GraphTargetItem ns, String name, GraphTargetItem obj, boolean attr, List<Integer> openedNamespaces, GraphTargetItem storeValue) {
|
||||
super(storeValue);
|
||||
this.index = index;
|
||||
this.ns = ns;
|
||||
this.name = name;
|
||||
this.obj = obj;
|
||||
this.attr = attr;
|
||||
this.openedNamespaces = openedNamespaces;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private int allNsSet(ABC abc) {
|
||||
int nssa[] = new int[openedNamespaces.size()];
|
||||
for (int i = 0; i < openedNamespaces.size(); i++) {
|
||||
nssa[i] = openedNamespaces.get(i);
|
||||
}
|
||||
return abc.constants.getNamespaceSetId(new NamespaceSet(nssa), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AssignableAVM2Item copy() {
|
||||
return new NamespacedAVM2Item(index, ns, name, obj, attr, openedNamespaces, assignedValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSourceChange(SourceGeneratorLocalData localData, SourceGenerator generator, boolean post, boolean decrement, boolean needsReturn) throws CompilationException {
|
||||
AVM2SourceGenerator g = (AVM2SourceGenerator)generator;
|
||||
boolean isInteger = returnType().toString().equals("int");
|
||||
Reference<Integer> ns_temp = new Reference<>(-1);
|
||||
Reference<Integer> name_temp = new Reference<>(-1);
|
||||
Reference<Integer> ret_temp = new Reference<>(-1);
|
||||
if (name == null && index != null) {
|
||||
return toSourceMerge(localData, generator,
|
||||
ns, generateCoerce(generator, new TypeItem("Namespace")), index, ins(new ConvertSIns()),
|
||||
ins(new FindPropertyStrictIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAMEL, 0, 0, 0, 0, new ArrayList<Integer>()), true)),
|
||||
dupSetTemp(localData, generator, name_temp),
|
||||
ns, generateCoerce(generator, new TypeItem("Namespace")),
|
||||
dupSetTemp(localData, generator, ns_temp),
|
||||
ins(new GetPropertyIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.MULTINAMEL, 0, 0, allNsSet(g.abc), 0, new ArrayList<Integer>()), true)),
|
||||
!isInteger ? ins(new ConvertDIns()) : null,
|
||||
//End get original
|
||||
(!post) ? (decrement ? ins(isInteger ? new DecrementIIns() : new DecrementIns()) : ins(isInteger ? new IncrementIIns() : new IncrementIns())) : null,
|
||||
needsReturn ? ins(new DupIns()) : null,
|
||||
(post) ? (decrement ? ins(isInteger ? new DecrementIIns() : new DecrementIns()) : ins(isInteger ? new IncrementIIns() : new IncrementIns())) : null,
|
||||
setTemp(localData, generator, ret_temp),
|
||||
getTemp(localData, generator, name_temp),
|
||||
getTemp(localData, generator, ns_temp),
|
||||
getTemp(localData, generator, ret_temp),
|
||||
ins(new SetPropertyIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.MULTINAMEL, 0, 0, allNsSet(g.abc), 0, new ArrayList<Integer>()), true)),
|
||||
killTemp(localData, generator, Arrays.asList(ret_temp, name_temp, ns_temp)));
|
||||
}else
|
||||
if (name != null && index == null) {
|
||||
return toSourceMerge(localData, generator,
|
||||
ns, generateCoerce(generator, new TypeItem("Namespace")),
|
||||
ins(new FindPropertyStrictIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAME, g.abc.constants.getStringId(name, true), 0, 0, 0, new ArrayList<Integer>()), true)),
|
||||
dupSetTemp(localData, generator, name_temp),
|
||||
ns, generateCoerce(generator, new TypeItem("Namespace")),
|
||||
dupSetTemp(localData, generator, ns_temp),
|
||||
//Start get original
|
||||
//getTemp(localData, generator, ns_temp), generateCoerce(generator, "Namespace"), ins(new FindPropertyStrictIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAME, g.abc.constants.getStringId(variableName, true), 0, 0, 0, new ArrayList<Integer>()), true)),
|
||||
//getTemp(localData, generator, ns_temp), generateCoerce(generator, "Namespace"),
|
||||
ins(new GetPropertyIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.MULTINAMEL, 0, 0, allNsSet(g.abc), 0, new ArrayList<Integer>()), true)),
|
||||
!isInteger ? ins(new ConvertDIns()) : null,
|
||||
//End get original
|
||||
(!post) ? (decrement ? ins(isInteger ? new DecrementIIns() : new DecrementIns()) : ins(isInteger ? new IncrementIIns() : new IncrementIns())) : null,
|
||||
needsReturn ? ins(new DupIns()) : null,
|
||||
(post) ? (decrement ? ins(isInteger ? new DecrementIIns() : new DecrementIns()) : ins(isInteger ? new IncrementIIns() : new IncrementIns())) : null,
|
||||
setTemp(localData, generator, ret_temp),
|
||||
getTemp(localData, generator, name_temp),
|
||||
getTemp(localData, generator, ns_temp),
|
||||
getTemp(localData, generator, ret_temp),
|
||||
ins(new SetPropertyIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.MULTINAMEL, 0, 0, allNsSet(g.abc), 0, new ArrayList<Integer>()), true)),
|
||||
killTemp(localData, generator, Arrays.asList(ret_temp, name_temp, ns_temp))
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem returnType() {
|
||||
return TypeItem.UNBOUNDED;
|
||||
}
|
||||
|
||||
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator, boolean needsReturn) throws CompilationException {
|
||||
AVM2SourceGenerator g = (AVM2SourceGenerator)generator;
|
||||
Reference<Integer> ns_temp = new Reference<>(-1);
|
||||
Reference<Integer> index_temp = new Reference<>(-1);
|
||||
Reference<Integer> ret_temp = new Reference<>(-1);
|
||||
if (name == null) {
|
||||
if (assignedValue != null) {
|
||||
return toSourceMerge(localData, generator,
|
||||
obj==null?ns:null, obj==null?generateCoerce(generator, new TypeItem("Namespace")):null, obj==null?index:null, ins(new ConvertSIns()), obj!=null?obj:ins(new FindPropertyStrictIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAMEL, 0, 0, 0, 0, new ArrayList<Integer>()), true)),
|
||||
ns, generateCoerce(generator, new TypeItem("Namespace")), index, ins(new ConvertSIns()), assignedValue,
|
||||
needsReturn ? dupSetTemp(localData, generator, ret_temp) : null,
|
||||
ins(new SetPropertyIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAMEL, 0, 0, 0, 0, new ArrayList<Integer>()), true)),
|
||||
needsReturn ? getTemp(localData, generator, ret_temp) : null,
|
||||
killTemp(localData, generator, Arrays.asList(ns_temp, index_temp, ret_temp))
|
||||
);
|
||||
} else {
|
||||
return toSourceMerge(localData, generator,
|
||||
obj==null?ns:null, obj==null?generateCoerce(generator, new TypeItem("Namespace")):null, obj==null?index:null, ins(new ConvertSIns()), obj!=null?obj:ins(new FindPropertyStrictIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAMEL, 0, 0, 0, 0, new ArrayList<Integer>()), true)),
|
||||
ns, generateCoerce(generator, new TypeItem("Namespace")), index, ins(new ConvertSIns()), ins(new GetPropertyIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAMEL, 0, 0, 0, 0, new ArrayList<Integer>()), true)),
|
||||
needsReturn ? null : ins(new PopIns()),
|
||||
killTemp(localData, generator, Arrays.asList(ns_temp, index_temp, ret_temp))
|
||||
);
|
||||
}
|
||||
}else{
|
||||
if (assignedValue != null) {
|
||||
return toSourceMerge(localData, generator,
|
||||
obj==null?ns:null, obj==null?generateCoerce(generator, new TypeItem("Namespace")):null, obj!=null?obj:ins(new FindPropertyStrictIns(), g.abc.constants.getMultinameId(new Multiname(attr?Multiname.RTQNAMEA:Multiname.RTQNAME, g.abc.constants.getStringId(name, true), 0, 0, 0, new ArrayList<Integer>()), true)),
|
||||
ns, generateCoerce(generator, new TypeItem("Namespace")), assignedValue,
|
||||
needsReturn ? dupSetTemp(localData, generator, ret_temp) : null,
|
||||
ins(new SetPropertyIns(), g.abc.constants.getMultinameId(new Multiname(attr?Multiname.RTQNAMEA:Multiname.RTQNAME, g.abc.constants.getStringId(name, true), 0, 0, 0, new ArrayList<Integer>()), true)),
|
||||
needsReturn ? getTemp(localData, generator, ret_temp) : null,
|
||||
killTemp(localData, generator, Arrays.asList(ns_temp, index_temp, ret_temp))
|
||||
);
|
||||
} else {
|
||||
return toSourceMerge(localData, generator,
|
||||
obj==null?ns:null, obj==null?generateCoerce(generator, new TypeItem("Namespace")):null, obj!=null?obj:ins(new FindPropertyStrictIns(), g.abc.constants.getMultinameId(new Multiname(attr?Multiname.RTQNAMEA:Multiname.RTQNAME, g.abc.constants.getStringId(name, true), 0, 0, 0, new ArrayList<Integer>()), true)),
|
||||
ns, generateCoerce(generator, new TypeItem("Namespace")), ins(new GetPropertyIns(), g.abc.constants.getMultinameId(new Multiname(attr?Multiname.RTQNAMEA:Multiname.RTQNAME, g.abc.constants.getStringId(name, true), 0, 0, 0, new ArrayList<Integer>()), true)),
|
||||
needsReturn ? null : ins(new PopIns()),
|
||||
killTemp(localData, generator, Arrays.asList(ns_temp, index_temp, ret_temp))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSource(localData, generator, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -64,7 +64,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
|
||||
private List<Integer> openedNamespaces;
|
||||
private List<MethodBody> callStack;
|
||||
public List<GraphTargetItem> scopeStack = new ArrayList<GraphTargetItem>();
|
||||
|
||||
|
||||
@Override
|
||||
public AssignableAVM2Item copy() {
|
||||
PropertyAVM2Item p = new PropertyAVM2Item(object, propertyName, index, abc, otherABCs, openedNamespaces, callStack);
|
||||
@@ -512,7 +512,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
|
||||
String targetType = propType.getVal();
|
||||
String srcType = assignedValue.returnType().toString();
|
||||
GraphTargetItem st = assignedValue;
|
||||
if (!targetType.equals(srcType)) {
|
||||
if (!targetType.equals(srcType) && !propertyName.startsWith("@")) {
|
||||
st = new CoerceAVM2Item(null, assignedValue, targetType);
|
||||
}
|
||||
return toSourceMerge(localData, generator, obj, index, st,
|
||||
@@ -543,6 +543,11 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
|
||||
return toSource(localData, generator, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ""+object+"."+propertyName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
|
||||
@@ -55,7 +55,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
|
||||
public List<Integer> openedNamespaces;
|
||||
public int line;
|
||||
public GraphTargetItem type;
|
||||
private GraphTargetItem ns = null;
|
||||
//private GraphTargetItem ns = null;
|
||||
public GraphTargetItem resolved;
|
||||
private boolean mustBeType;
|
||||
public List<String> importedClasses;
|
||||
@@ -65,7 +65,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
|
||||
@Override
|
||||
public AssignableAVM2Item copy() {
|
||||
UnresolvedAVM2Item c = new UnresolvedAVM2Item(subtypes, importedClasses, mustBeType, type, line, name, assignedValue, openedNamespaces);
|
||||
c.setNs(ns);
|
||||
//c.setNs(ns);
|
||||
c.nsKind = nsKind;
|
||||
c.setIndex(index);
|
||||
c.resolved = resolved;
|
||||
@@ -85,9 +85,9 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void setNs(GraphTargetItem ns) {
|
||||
/*public void setNs(GraphTargetItem ns) {
|
||||
this.ns = ns;
|
||||
}
|
||||
}*/
|
||||
|
||||
public void setRegNumber(int regNumber) {
|
||||
if (resolved instanceof NameAVM2Item) {
|
||||
@@ -114,11 +114,11 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
public GraphTargetItem getNs() {
|
||||
return ns;
|
||||
}
|
||||
|
||||
*/
|
||||
public void appendName(String name) {
|
||||
this.name += "." + name;
|
||||
}
|
||||
@@ -154,6 +154,12 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setVariableName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public UnresolvedAVM2Item(List<String> subtypes, List<String> importedClasses, boolean mustBeType, GraphTargetItem type, int line, String name, GraphTargetItem storeValue, List<Integer> openedNamespaces) {
|
||||
super(storeValue);
|
||||
this.name = name;
|
||||
@@ -216,7 +222,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
|
||||
ins = ins(new CoerceSIns());
|
||||
break;
|
||||
default:
|
||||
int type_index = AVM2SourceGenerator.resolveType(new TypeItem(type),((AVM2SourceGenerator) generator).abc);
|
||||
int type_index = AVM2SourceGenerator.resolveType(new TypeItem(type), ((AVM2SourceGenerator) generator).abc);
|
||||
ins = ins(new CoerceIns(), type_index);
|
||||
break;
|
||||
}
|
||||
@@ -296,15 +302,6 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
|
||||
parts.add(name);
|
||||
}
|
||||
|
||||
if (ns != null) {
|
||||
if (name.contains(".")) {
|
||||
throw new CompilationException("Invalid property name", line);
|
||||
}
|
||||
resolved = new NameAVM2Item(type, line, name, assignedValue, false, openedNamespaces);
|
||||
((NameAVM2Item) resolved).setNs(ns);
|
||||
((NameAVM2Item) resolved).setIndex(index);
|
||||
return resolved;
|
||||
}
|
||||
|
||||
if (scopeStack.isEmpty()) { //Everything is multiname property in with command
|
||||
|
||||
@@ -417,10 +414,10 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Search for types in opened namespaces
|
||||
for (int ni : openedNamespaces) {
|
||||
Namespace ons = abc.constants.getNamespace(ni);
|
||||
Namespace ons = abc.constants.getNamespace(ni);
|
||||
for (ABC a : allAbcs) {
|
||||
for (int c = 0; c < a.instance_info.size(); c++) {
|
||||
if ((a == abc && a.instance_info.get(c).getName(a.constants).namespace_index == ni) || (ons.kind != Namespace.KIND_PRIVATE && a.instance_info.get(c).getName(a.constants).getNamespace(a.constants).hasName(ons.getName(abc.constants), a.constants))) {
|
||||
@@ -480,7 +477,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
|
||||
return ret;
|
||||
}
|
||||
|
||||
if(!subtypes.isEmpty() && parts.size()==1 && parts.get(0).equals("Vector")){
|
||||
if (!subtypes.isEmpty() && parts.size() == 1 && parts.get(0).equals("Vector")) {
|
||||
TypeItem ret = new TypeItem("__AS3__.vec.Vector");
|
||||
for (String s : subtypes) {
|
||||
UnresolvedAVM2Item su = new UnresolvedAVM2Item(new ArrayList<String>(), importedClasses, true, null, line, s, null, openedNamespaces);
|
||||
@@ -494,8 +491,8 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
|
||||
resolved = ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
if(mustBeType){
|
||||
|
||||
if (mustBeType) {
|
||||
throw new CompilationException("Not a type", line);
|
||||
}
|
||||
resolved = null;
|
||||
|
||||
@@ -2,4 +2,5 @@ List of differences between FFDec and official compiler
|
||||
--------------------------------------------------------
|
||||
- Maximal stack count in method body can be lower in FFDec as official compiler in some cases calculates it wrong (e.g. increments and set/get property).
|
||||
- In names of type Multiname(L/LA), namespaceset can have namespaces in different order, this is because official compiler generates
|
||||
this based on constructor position inside class
|
||||
this based on constructor position inside class
|
||||
- XML literal has different rules for string addition
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.exporters;
|
||||
|
||||
import com.jpexs.decompiler.flash.exporters.shape.ShapeExporterBase;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.tags.base.ImageTag;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.exporters;
|
||||
|
||||
import com.jpexs.decompiler.flash.exporters.shape.ShapeExporterBase;
|
||||
import com.jpexs.decompiler.flash.types.ColorTransform;
|
||||
import com.jpexs.decompiler.flash.types.GRADRECORD;
|
||||
import com.jpexs.decompiler.flash.types.RGB;
|
||||
|
||||
115
trunk/src/com/jpexs/decompiler/flash/exporters/SVGExporter.java
Normal file
115
trunk/src/com/jpexs/decompiler/flash/exporters/SVGExporter.java
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.exporters;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.types.ColorTransform;
|
||||
import com.jpexs.decompiler.flash.types.RGBA;
|
||||
import java.awt.Color;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.transform.OutputKeys;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.DOMImplementation;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.DocumentType;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class SVGExporter {
|
||||
|
||||
protected static final String sNamespace = "http://www.w3.org/2000/svg";
|
||||
protected static final String xlinkNamespace = "http://www.w3.org/1999/xlink";
|
||||
|
||||
protected Document _svg;
|
||||
protected Element _svgDefs;
|
||||
protected Element _svgG;
|
||||
protected Element path;
|
||||
protected List<Element> gradients;
|
||||
protected int lastPatternId;
|
||||
private final SWF swf;
|
||||
private double maxLineWidth;
|
||||
private final ExportRectangle bounds;
|
||||
|
||||
public SVGExporter(SWF swf, ExportRectangle bounds, ColorTransform colorTransform) {
|
||||
this.swf = swf;
|
||||
this.bounds = bounds;
|
||||
|
||||
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
|
||||
try {
|
||||
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
|
||||
DOMImplementation impl = docBuilder.getDOMImplementation();
|
||||
DocumentType svgDocType = impl.createDocumentType("svg", "-//W3C//DTD SVG 1.0//EN",
|
||||
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd");
|
||||
_svg = impl.createDocument(sNamespace, "svg", svgDocType);
|
||||
Element svgRoot = _svg.getDocumentElement();
|
||||
svgRoot.setAttribute("xmlns:xlink", xlinkNamespace);
|
||||
_svgDefs = _svg.createElement("defs");
|
||||
svgRoot.appendChild(_svgDefs);
|
||||
_svgG = _svg.createElement("g");
|
||||
_svgG.setAttribute("transform", "matrix(1, 0, 0, 1, "
|
||||
+ roundPixels20(-bounds.xMin / (double) SWF.unitDivisor) + ", " + roundPixels20(-bounds.yMin / (double) SWF.unitDivisor) + ")");
|
||||
svgRoot.appendChild(_svgG);
|
||||
} catch (ParserConfigurationException ex) {
|
||||
Logger.getLogger(SVGExporter.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
gradients = new ArrayList<>();
|
||||
}
|
||||
|
||||
public String getSVG() {
|
||||
TransformerFactory transformerFactory = TransformerFactory.newInstance();
|
||||
StringWriter writer = new StringWriter();
|
||||
try {
|
||||
Transformer transformer = transformerFactory.newTransformer();
|
||||
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
|
||||
DOMSource source = new DOMSource(_svg);
|
||||
StreamResult result = new StreamResult(writer);
|
||||
transformer.transform(source, result);
|
||||
} catch (TransformerException ex) {
|
||||
Logger.getLogger(SVGExporter.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
public void setBackGroundColor(Color backGroundColor) {
|
||||
Attr attr = _svg.createAttribute("style");
|
||||
attr.setValue("background: " + new RGBA(backGroundColor).toHexARGB());
|
||||
}
|
||||
|
||||
protected static double roundPixels20(double pixels) {
|
||||
return Math.round(pixels * 100) / 100.0;
|
||||
}
|
||||
|
||||
protected static double roundPixels400(double pixels) {
|
||||
return Math.round(pixels * 10000) / 10000.0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.exporters;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class SVGExporterContext {
|
||||
|
||||
}
|
||||
@@ -24,5 +24,6 @@ public enum FramesExportMode {
|
||||
|
||||
PNG,
|
||||
GIF,
|
||||
AVI
|
||||
AVI,
|
||||
SVG
|
||||
}
|
||||
|
||||
@@ -14,7 +14,9 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.exporters;
|
||||
package com.jpexs.decompiler.flash.exporters.morphshape;
|
||||
|
||||
import com.jpexs.decompiler.flash.exporters.PointInt;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -14,9 +14,10 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.exporters;
|
||||
package com.jpexs.decompiler.flash.exporters.morphshape;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.exporters.Matrix;
|
||||
import com.jpexs.decompiler.flash.types.ColorTransform;
|
||||
import com.jpexs.decompiler.flash.types.GRADRECORD;
|
||||
import com.jpexs.decompiler.flash.types.RGB;
|
||||
@@ -70,7 +71,7 @@ public abstract class DefaultSVGMorphShapeExporter extends MorphShapeExporterBas
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beginGradientFill(int type, GRADRECORD[] gradientRecords, Matrix matrix, Matrix matrixEnd, int spreadMethod, int interpolationMethod, float focalPointRatio) {
|
||||
public void beginGradientFill(int type, GRADRECORD[] gradientRecords, GRADRECORD[] gradientRecordsEnd, Matrix matrix, Matrix matrixEnd, int spreadMethod, int interpolationMethod, float focalPointRatio) {
|
||||
finalizePath();
|
||||
}
|
||||
|
||||
@@ -90,7 +91,7 @@ public abstract class DefaultSVGMorphShapeExporter extends MorphShapeExporterBas
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lineGradientStyle(int type, GRADRECORD[] gradientRecords, Matrix matrix, Matrix matrixEnd, int spreadMethod, int interpolationMethod, float focalPointRatio) {
|
||||
public void lineGradientStyle(int type, GRADRECORD[] gradientRecords, GRADRECORD[] gradientRecordsEnd, Matrix matrix, Matrix matrixEnd, int spreadMethod, int interpolationMethod, float focalPointRatio) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -14,7 +14,9 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.exporters;
|
||||
package com.jpexs.decompiler.flash.exporters.morphshape;
|
||||
|
||||
import com.jpexs.decompiler.flash.exporters.PointInt;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -14,8 +14,9 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.exporters;
|
||||
package com.jpexs.decompiler.flash.exporters.morphshape;
|
||||
|
||||
import com.jpexs.decompiler.flash.exporters.Matrix;
|
||||
import com.jpexs.decompiler.flash.types.ColorTransform;
|
||||
import com.jpexs.decompiler.flash.types.GRADRECORD;
|
||||
import com.jpexs.decompiler.flash.types.RGB;
|
||||
@@ -40,7 +41,7 @@ public interface IMorphShapeExporter {
|
||||
|
||||
public void beginFill(RGB color, RGB colorEnd);
|
||||
|
||||
public void beginGradientFill(int type, GRADRECORD[] gradientRecords, Matrix matrix, Matrix matrixEnd, int spreadMethod, int interpolationMethod, float focalPointRatio);
|
||||
public void beginGradientFill(int type, GRADRECORD[] gradientRecords, GRADRECORD[] gradientRecordsEnd, Matrix matrix, Matrix matrixEnd, int spreadMethod, int interpolationMethod, float focalPointRatio);
|
||||
|
||||
public void beginBitmapFill(int bitmapId, Matrix matrix, boolean repeat, boolean smooth, ColorTransform colorTransform);
|
||||
|
||||
@@ -48,7 +49,7 @@ public interface IMorphShapeExporter {
|
||||
|
||||
public void lineStyle(double thickness, double thicknessEnd, RGB color, RGB colorEnd, boolean pixelHinting, String scaleMode, int startCaps, int endCaps, int joints, int miterLimit);
|
||||
|
||||
public void lineGradientStyle(int type, GRADRECORD[] gradientRecords, Matrix matrix, Matrix matrixEnd, int spreadMethod, int interpolationMethod, float focalPointRatio);
|
||||
public void lineGradientStyle(int type, GRADRECORD[] gradientRecords, GRADRECORD[] gradientRecordsEnd, Matrix matrix, Matrix matrixEnd, int spreadMethod, int interpolationMethod, float focalPointRatio);
|
||||
|
||||
public void moveTo(double x, double y, double x2, double y2);
|
||||
|
||||
@@ -14,8 +14,10 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.exporters;
|
||||
package com.jpexs.decompiler.flash.exporters.morphshape;
|
||||
|
||||
import com.jpexs.decompiler.flash.exporters.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.PointInt;
|
||||
import com.jpexs.decompiler.flash.types.ColorTransform;
|
||||
import com.jpexs.decompiler.flash.types.FILLSTYLE;
|
||||
import com.jpexs.decompiler.flash.types.FOCALGRADIENT;
|
||||
@@ -314,6 +316,7 @@ public abstract class MorphShapeExporterBase implements IMorphShapeExporter {
|
||||
beginGradientFill(
|
||||
fillStyle.fillStyleType,
|
||||
colorTransform.apply(fillStyle.gradient.gradientRecords),
|
||||
colorTransform.apply(fillStyleEnd.gradient.gradientRecords),
|
||||
matrix,
|
||||
matrixEnd,
|
||||
fillStyle.gradient.spreadMode,
|
||||
@@ -429,6 +432,7 @@ public abstract class MorphShapeExporterBase implements IMorphShapeExporter {
|
||||
lineGradientStyle(
|
||||
fillStyle.fillStyleType,
|
||||
fillStyle.gradient.gradientRecords,
|
||||
fillStyleEnd.gradient.gradientRecords,
|
||||
matrix,
|
||||
matrixEnd,
|
||||
fillStyle.gradient.spreadMode,
|
||||
@@ -14,9 +14,11 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.exporters;
|
||||
package com.jpexs.decompiler.flash.exporters.morphshape;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.exporters.ExportRectangle;
|
||||
import com.jpexs.decompiler.flash.exporters.Matrix;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.tags.base.ImageTag;
|
||||
import com.jpexs.decompiler.flash.types.ColorTransform;
|
||||
@@ -91,7 +93,7 @@ public class SVGMorphShapeExporter extends DefaultSVGMorphShapeExporter {
|
||||
StreamResult result = new StreamResult(writer);
|
||||
transformer.transform(source, result);
|
||||
} catch (TransformerException ex) {
|
||||
Logger.getLogger(SVGShapeExporter.class.getName()).log(Level.SEVERE, null, ex);
|
||||
Logger.getLogger(SVGMorphShapeExporter.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
return writer.toString();
|
||||
}
|
||||
@@ -114,7 +116,7 @@ public class SVGMorphShapeExporter extends DefaultSVGMorphShapeExporter {
|
||||
+ roundPixels20(-bounds.xMin / (double) SWF.unitDivisor) + ", " + roundPixels20(-bounds.yMin / (double) SWF.unitDivisor) + ")");
|
||||
svgRoot.appendChild(_svgG);
|
||||
} catch (ParserConfigurationException ex) {
|
||||
Logger.getLogger(SVGShapeExporter.class.getName()).log(Level.SEVERE, null, ex);
|
||||
Logger.getLogger(SVGMorphShapeExporter.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
gradients = new ArrayList<>();
|
||||
}
|
||||
@@ -130,22 +132,25 @@ public class SVGMorphShapeExporter extends DefaultSVGMorphShapeExporter {
|
||||
finalizePath();
|
||||
path.setAttribute("stroke", "none");
|
||||
path.setAttribute("fill", color.toHexRGB());
|
||||
path.setAttribute("fill-rule", "evenodd");
|
||||
path.appendChild(createAnimateElement("fill", color.toHexRGB(), colorEnd.toHexRGB()));
|
||||
if (color instanceof RGBA) {
|
||||
RGBA colorA = (RGBA) color;
|
||||
if (colorA.alpha != 255) {
|
||||
path.setAttribute("fill-opacity", Float.toString(colorA.getAlphaFloat()));
|
||||
}
|
||||
RGBA colorAEnd = (RGBA) colorEnd;
|
||||
path.appendChild(createAnimateElement("fill-opacity", colorA.getAlphaFloat(), colorAEnd.getAlphaFloat()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beginGradientFill(int type, GRADRECORD[] gradientRecords, Matrix matrix, Matrix matrixEnd, int spreadMethod, int interpolationMethod, float focalPointRatio) {
|
||||
public void beginGradientFill(int type, GRADRECORD[] gradientRecords, GRADRECORD[] gradientRecordsEnd, Matrix matrix, Matrix matrixEnd, int spreadMethod, int interpolationMethod, float focalPointRatio) {
|
||||
finalizePath();
|
||||
Element gradient = (type == FILLSTYLE.LINEAR_GRADIENT)
|
||||
? _svg.createElement("linearGradient")
|
||||
: _svg.createElement("radialGradient");
|
||||
populateGradientElement(gradient, type, gradientRecords, matrix, matrixEnd, spreadMethod, interpolationMethod, focalPointRatio);
|
||||
populateGradientElement(gradient, type, gradientRecords, gradientRecordsEnd, matrix, matrixEnd, spreadMethod, interpolationMethod, focalPointRatio);
|
||||
int id = gradients.indexOf(gradient);
|
||||
if (id < 0) {
|
||||
// todo: filter same gradients
|
||||
@@ -155,6 +160,7 @@ public class SVGMorphShapeExporter extends DefaultSVGMorphShapeExporter {
|
||||
gradient.setAttribute("id", "gradient" + id);
|
||||
path.setAttribute("stroke", "none");
|
||||
path.setAttribute("fill", "url(#gradient" + id + ")");
|
||||
path.setAttribute("fill-rule", "evenodd");
|
||||
_svgDefs.appendChild(gradient);
|
||||
}
|
||||
|
||||
@@ -271,12 +277,12 @@ public class SVGMorphShapeExporter extends DefaultSVGMorphShapeExporter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lineGradientStyle(int type, GRADRECORD[] gradientRecords, Matrix matrix, Matrix matrixEnd, int spreadMethod, int interpolationMethod, float focalPointRatio) {
|
||||
public void lineGradientStyle(int type, GRADRECORD[] gradientRecords, GRADRECORD[] gradientRecordsEnd, Matrix matrix, Matrix matrixEnd, int spreadMethod, int interpolationMethod, float focalPointRatio) {
|
||||
path.removeAttribute("stroke-opacity");
|
||||
Element gradient = (type == FILLSTYLE.LINEAR_GRADIENT)
|
||||
? _svg.createElement("linearGradient")
|
||||
: _svg.createElement("radialGradient");
|
||||
populateGradientElement(gradient, type, gradientRecords, matrix, matrixEnd, spreadMethod, interpolationMethod, focalPointRatio);
|
||||
populateGradientElement(gradient, type, gradientRecords, gradientRecordsEnd, matrix, matrixEnd, spreadMethod, interpolationMethod, focalPointRatio);
|
||||
int id = gradients.indexOf(gradient);
|
||||
if (id < 0) {
|
||||
// todo: filter same gradients
|
||||
@@ -309,7 +315,7 @@ public class SVGMorphShapeExporter extends DefaultSVGMorphShapeExporter {
|
||||
super.finalizePath();
|
||||
}
|
||||
|
||||
protected void populateGradientElement(Element gradient, int type, GRADRECORD[] gradientRecords, Matrix matrix, Matrix matrixEnd, int spreadMethod, int interpolationMethod, float focalPointRatio) {
|
||||
protected void populateGradientElement(Element gradient, int type, GRADRECORD[] gradientRecords, GRADRECORD[] gradientRecordsEnd, Matrix matrix, Matrix matrixEnd, int spreadMethod, int interpolationMethod, float focalPointRatio) {
|
||||
gradient.setAttribute("gradientUnits", "userSpaceOnUse");
|
||||
if (type == FILLSTYLE.LINEAR_GRADIENT) {
|
||||
gradient.setAttribute("x1", "-819.2");
|
||||
@@ -340,17 +346,23 @@ public class SVGMorphShapeExporter extends DefaultSVGMorphShapeExporter {
|
||||
if (matrix != null) {
|
||||
double translateX = roundPixels400(matrix.translateX / SWF.unitDivisor);
|
||||
double translateY = roundPixels400(matrix.translateY / SWF.unitDivisor);
|
||||
double rotateSkew0 = roundPixels400(matrix.rotateSkew0);
|
||||
double rotateSkew1 = roundPixels400(matrix.rotateSkew1);
|
||||
double scaleX = roundPixels400(matrix.scaleX);
|
||||
double scaleY = roundPixels400(matrix.scaleY);
|
||||
double a = roundPixels400(matrix.scaleX);
|
||||
double b = roundPixels400(matrix.rotateSkew1);
|
||||
double c = roundPixels400(matrix.rotateSkew0);
|
||||
double d = roundPixels400(matrix.scaleY);
|
||||
double rotate = Math.atan(c / d);
|
||||
double scaleX = Math.signum(a) * Math.sqrt(a * a + b * b);
|
||||
double scaleY = Math.signum(d) * Math.sqrt(c * c + d * d);
|
||||
|
||||
double translateXEnd = roundPixels400(matrixEnd.translateX / SWF.unitDivisor);
|
||||
double translateYEnd = roundPixels400(matrixEnd.translateY / SWF.unitDivisor);
|
||||
double rotateSkew0End = roundPixels400(matrixEnd.rotateSkew0);
|
||||
double rotateSkew1End = roundPixels400(matrixEnd.rotateSkew1);
|
||||
double scaleXEnd = roundPixels400(matrixEnd.scaleX);
|
||||
double scaleYEnd = roundPixels400(matrixEnd.scaleY);
|
||||
a = roundPixels400(matrixEnd.scaleX);
|
||||
b = roundPixels400(matrixEnd.rotateSkew1);
|
||||
c = roundPixels400(matrixEnd.rotateSkew0);
|
||||
d = roundPixels400(matrixEnd.scaleY);
|
||||
double rotateEnd = Math.atan(c / d);
|
||||
double scaleXEnd = Math.signum(a) * Math.sqrt(a * a + b * b);
|
||||
double scaleYEnd = Math.signum(d) * Math.sqrt(c * c + d * d);
|
||||
|
||||
Element animateRotate = _svg.createElement("animateTransform");
|
||||
animateRotate.setAttribute("dur", "2s"); // todo
|
||||
@@ -358,8 +370,8 @@ public class SVGMorphShapeExporter extends DefaultSVGMorphShapeExporter {
|
||||
animateRotate.setAttribute("attributeName", "gradientTransform");
|
||||
animateRotate.setAttribute("type", "rotate");
|
||||
animateRotate.setAttribute("additive", "sum");
|
||||
animateRotate.setAttribute("from", rotateSkew0 + " " + rotateSkew1);
|
||||
animateRotate.setAttribute("to", rotateSkew0End + " " + rotateSkew1End);
|
||||
animateRotate.setAttribute("from", Double.toString(rotate));
|
||||
animateRotate.setAttribute("to", Double.toString(rotateEnd));
|
||||
|
||||
Element animateScale = _svg.createElement("animateTransform");
|
||||
animateScale.setAttribute("dur", "2s"); // todo
|
||||
@@ -380,22 +392,28 @@ public class SVGMorphShapeExporter extends DefaultSVGMorphShapeExporter {
|
||||
animateTranslate.setAttribute("to", translateXEnd + " " + translateYEnd);
|
||||
|
||||
gradient.appendChild(animateTranslate);
|
||||
gradient.appendChild(animateRotate);
|
||||
gradient.appendChild(animateScale);
|
||||
gradient.appendChild(animateRotate);
|
||||
}
|
||||
for (int i = 0; i < gradientRecords.length; i++) {
|
||||
GRADRECORD record = gradientRecords[i];
|
||||
GRADRECORD recordEnd = gradientRecordsEnd[i];
|
||||
Element gradientEntry = _svg.createElement("stop");
|
||||
gradientEntry.setAttribute("offset", Double.toString(record.ratio / 255.0));
|
||||
gradientEntry.appendChild(createAnimateElement("offset", record.ratio / 255.0, recordEnd.ratio / 255.0));
|
||||
RGB color = record.color;
|
||||
RGB colorEnd = recordEnd.color;
|
||||
//if(colors.get(i) != 0) {
|
||||
gradientEntry.setAttribute("stop-color", color.toHexRGB());
|
||||
gradientEntry.appendChild(createAnimateElement("stop-color", color.toHexRGB(), colorEnd.toHexRGB()));
|
||||
//}
|
||||
if (color instanceof RGBA) {
|
||||
RGBA colorA = (RGBA) color;
|
||||
if (colorA.alpha != 255) {
|
||||
gradientEntry.setAttribute("stop-opacity", Float.toString(colorA.getAlphaFloat()));
|
||||
}
|
||||
RGBA colorAEnd = (RGBA) colorEnd;
|
||||
gradientEntry.appendChild(createAnimateElement("stop-opacity", colorA.getAlphaFloat(), colorAEnd.getAlphaFloat()));
|
||||
}
|
||||
gradient.appendChild(gradientEntry);
|
||||
}
|
||||
@@ -14,7 +14,9 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.exporters;
|
||||
package com.jpexs.decompiler.flash.exporters.morphshape;
|
||||
|
||||
import com.jpexs.decompiler.flash.exporters.PointInt;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -14,7 +14,9 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.exporters;
|
||||
package com.jpexs.decompiler.flash.exporters.shape;
|
||||
|
||||
import com.jpexs.decompiler.flash.exporters.PointInt;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -14,9 +14,10 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.exporters;
|
||||
package com.jpexs.decompiler.flash.exporters.shape;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.exporters.Matrix;
|
||||
import com.jpexs.decompiler.flash.types.ColorTransform;
|
||||
import com.jpexs.decompiler.flash.types.GRADRECORD;
|
||||
import com.jpexs.decompiler.flash.types.RGB;
|
||||
@@ -14,7 +14,9 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.exporters;
|
||||
package com.jpexs.decompiler.flash.exporters.shape;
|
||||
|
||||
import com.jpexs.decompiler.flash.exporters.PointInt;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -14,8 +14,9 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.exporters;
|
||||
package com.jpexs.decompiler.flash.exporters.shape;
|
||||
|
||||
import com.jpexs.decompiler.flash.exporters.Matrix;
|
||||
import com.jpexs.decompiler.flash.types.ColorTransform;
|
||||
import com.jpexs.decompiler.flash.types.GRADRECORD;
|
||||
import com.jpexs.decompiler.flash.types.RGB;
|
||||
@@ -14,9 +14,11 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.exporters;
|
||||
package com.jpexs.decompiler.flash.exporters.shape;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.exporters.ExportRectangle;
|
||||
import com.jpexs.decompiler.flash.exporters.Matrix;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.tags.base.ImageTag;
|
||||
import com.jpexs.decompiler.flash.types.ColorTransform;
|
||||
@@ -73,11 +75,17 @@ public class SVGShapeExporter extends DefaultSVGShapeExporter {
|
||||
private final SWF swf;
|
||||
private double maxLineWidth;
|
||||
private final ExportRectangle bounds;
|
||||
private final String shapeId;
|
||||
|
||||
public SVGShapeExporter(SWF swf, SHAPE shape, ExportRectangle bounds, ColorTransform colorTransform) {
|
||||
this(swf, shape, bounds, colorTransform, "");
|
||||
}
|
||||
|
||||
public SVGShapeExporter(SWF swf, SHAPE shape, ExportRectangle bounds, ColorTransform colorTransform, String shapeId) {
|
||||
super(shape, colorTransform);
|
||||
this.swf = swf;
|
||||
this.bounds = bounds;
|
||||
this.shapeId = shapeId;
|
||||
}
|
||||
|
||||
public String getSVG() {
|
||||
@@ -105,13 +113,13 @@ public class SVGShapeExporter extends DefaultSVGShapeExporter {
|
||||
DocumentType svgDocType = impl.createDocumentType("svg", "-//W3C//DTD SVG 1.0//EN",
|
||||
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd");
|
||||
_svg = impl.createDocument(sNamespace, "svg", svgDocType);
|
||||
_svgG.setAttribute("transform", "matrix(1, 0, 0, 1, "
|
||||
+ roundPixels20(-bounds.xMin / (double) SWF.unitDivisor) + ", " + roundPixels20(-bounds.yMin / (double) SWF.unitDivisor) + ")");
|
||||
Element svgRoot = _svg.getDocumentElement();
|
||||
svgRoot.setAttribute("xmlns:xlink", xlinkNamespace);
|
||||
_svgDefs = _svg.createElement("defs");
|
||||
svgRoot.appendChild(_svgDefs);
|
||||
_svgG = _svg.createElement("g");
|
||||
_svgG.setAttribute("transform", "matrix(1, 0, 0, 1, "
|
||||
+ roundPixels20(-bounds.xMin / (double) SWF.unitDivisor) + ", " + roundPixels20(-bounds.yMin / (double) SWF.unitDivisor) + ")");
|
||||
svgRoot.appendChild(_svgG);
|
||||
} catch (ParserConfigurationException ex) {
|
||||
Logger.getLogger(SVGShapeExporter.class.getName()).log(Level.SEVERE, null, ex);
|
||||
@@ -127,6 +135,7 @@ public class SVGShapeExporter extends DefaultSVGShapeExporter {
|
||||
finalizePath();
|
||||
path.setAttribute("stroke", "none");
|
||||
path.setAttribute("fill", color.toHexRGB());
|
||||
path.setAttribute("fill-rule", "evenodd");
|
||||
if (color instanceof RGBA) {
|
||||
RGBA colorA = (RGBA) color;
|
||||
if (colorA.alpha != 255) {
|
||||
@@ -148,9 +157,11 @@ public class SVGShapeExporter extends DefaultSVGShapeExporter {
|
||||
id = gradients.size();
|
||||
gradients.add(gradient);
|
||||
}
|
||||
gradient.setAttribute("id", "gradient" + id);
|
||||
String gradientId = "gradient" + shapeId + id;
|
||||
gradient.setAttribute("id", gradientId);
|
||||
path.setAttribute("stroke", "none");
|
||||
path.setAttribute("fill", "url(#gradient" + id + ")");
|
||||
path.setAttribute("fill", "url(#" + gradientId + ")");
|
||||
path.setAttribute("fill-rule", "evenodd");
|
||||
_svgDefs.appendChild(gradient);
|
||||
}
|
||||
|
||||
@@ -174,7 +185,11 @@ public class SVGShapeExporter extends DefaultSVGShapeExporter {
|
||||
int width = img.getWidth();
|
||||
int height = img.getHeight();
|
||||
lastPatternId++;
|
||||
String patternId = "PatternID_" + lastPatternId;
|
||||
String patternId = "PatternID_";
|
||||
if (!shapeId.isEmpty()) {
|
||||
patternId += shapeId + "_";
|
||||
}
|
||||
patternId += lastPatternId;
|
||||
String format = image.getImageFormat();
|
||||
InputStream imageStream = image.getImageData();
|
||||
byte[] imageData;
|
||||
@@ -14,8 +14,10 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.exporters;
|
||||
package com.jpexs.decompiler.flash.exporters.shape;
|
||||
|
||||
import com.jpexs.decompiler.flash.exporters.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.PointInt;
|
||||
import com.jpexs.decompiler.flash.types.ColorTransform;
|
||||
import com.jpexs.decompiler.flash.types.FILLSTYLE;
|
||||
import com.jpexs.decompiler.flash.types.FOCALGRADIENT;
|
||||
@@ -14,7 +14,9 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.exporters;
|
||||
package com.jpexs.decompiler.flash.exporters.shape;
|
||||
|
||||
import com.jpexs.decompiler.flash.exporters.PointInt;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -234,11 +234,9 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
private static final String ACTION_EXPAND_RECURSIVE = "EXPANDRECURSIVE";
|
||||
|
||||
// play morph shape in 2 second(s)
|
||||
// this settings should be synchronized with frameCount and frameRate
|
||||
// settings in MainPanel.createAndShowTempSwf
|
||||
static final int morphShapeAnimationLength = 2;
|
||||
public static final int morphShapeAnimationLength = 2;
|
||||
|
||||
static final int morphShapeAnimationFrameRate = 30;
|
||||
public static final int morphShapeAnimationFrameRate = 30;
|
||||
|
||||
private static final Logger logger = Logger.getLogger(MainPanel.class.getName());
|
||||
|
||||
|
||||
@@ -504,9 +504,8 @@ public class PreviewPanel extends JSplitPane implements ActionListener {
|
||||
}
|
||||
|
||||
if ((tagObj instanceof DefineMorphShapeTag) || (tagObj instanceof DefineMorphShape2Tag)) {
|
||||
// this setting should be synchronized with ImagePanel.morphShapeAnimationLength
|
||||
frameCount = 100;
|
||||
frameRate = 50;
|
||||
frameRate = MainPanel.morphShapeAnimationFrameRate;
|
||||
frameCount = MainPanel.morphShapeAnimationLength * frameRate;
|
||||
}
|
||||
|
||||
if (tagObj instanceof DefineSoundTag) {
|
||||
@@ -671,8 +670,7 @@ public class PreviewPanel extends JSplitPane implements ActionListener {
|
||||
} else if ((tagObj instanceof DefineMorphShapeTag) || (tagObj instanceof DefineMorphShape2Tag)) {
|
||||
new PlaceObject2Tag(swf, false, false, false, true, false, true, true, false, 1, chtId, mat, null, 0, null, 0, null).writeTag(sos2);
|
||||
new ShowFrameTag(swf).writeTag(sos2);
|
||||
int numFrames = 100;
|
||||
for (int ratio = 0; ratio < 65536; ratio += 65536 / numFrames) {
|
||||
for (int ratio = 0; ratio < 65536; ratio += 65536 / frameCount) {
|
||||
new PlaceObject2Tag(swf, false, false, false, true, false, true, false, true, 1, chtId, mat, null, ratio, null, 0, null).writeTag(sos2);
|
||||
new ShowFrameTag(swf).writeTag(sos2);
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@ frames = Frames
|
||||
frames.png = PNG
|
||||
frames.gif = GIF
|
||||
frames.avi = AVI
|
||||
frames.svg = SVG
|
||||
|
||||
fonts = Fonts
|
||||
fonts.ttf = TTF
|
||||
fonts.ttf = TTF
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
shapes = Alakzatok
|
||||
shapes.svg = SVG
|
||||
shapes.png = PNG
|
||||
|
||||
texts = Sz\u00f6vegek
|
||||
texts.plain = Egyszer\u0171 sz\u00f6veg
|
||||
@@ -21,6 +22,8 @@ texts.formatted = Form\u00e1zott sz\u00f6veg
|
||||
|
||||
images = K\u00e9pek
|
||||
images.png_jpeg = PNG/JPEG
|
||||
images.png = PNG
|
||||
images.jpeg = JPEG
|
||||
|
||||
movies = Mozg\u00f3k\u00e9pek
|
||||
movies.flv = FLV (Hang n\u00e9lk\u00fcl)
|
||||
@@ -28,14 +31,32 @@ movies.flv = FLV (Hang n\u00e9lk\u00fcl)
|
||||
sounds = Hangok
|
||||
sounds.mp3_wav_flv = MP3/WAV/FLV
|
||||
sounds.flv = FLV (Csak hang)
|
||||
sounds.mp3_wav = MP3/WAV
|
||||
sounds.wav = WAV
|
||||
|
||||
scripts = Scripts
|
||||
scripts = Szkriptek
|
||||
scripts.as = ActionScript
|
||||
scripts.pcode = P-code
|
||||
scripts.pcode_hex = P-code \u00e9s Hexa
|
||||
scripts.hex = Hexa
|
||||
|
||||
binaryData = Binary data
|
||||
binaryData.raw = Nyers
|
||||
|
||||
dialog.title = Export\u00e1l\u00e1s...
|
||||
|
||||
button.ok = OK
|
||||
button.cancel = M\u00e9gse
|
||||
|
||||
morphshapes = Morph alakzatok
|
||||
morphshapes.gif = GIF
|
||||
morphshapes.svg = SVG
|
||||
|
||||
frames = Keretek
|
||||
frames.png = PNG
|
||||
frames.gif = GIF
|
||||
frames.avi = AVI
|
||||
frames.svg = SVG
|
||||
|
||||
fonts = Bet\u0171t\u00edpusok
|
||||
fonts.ttf = TTF
|
||||
|
||||
@@ -455,3 +455,12 @@ generictag.array.insertend = %item% besz\u00far\u00e1sa a v\u00e9g\u00e9re
|
||||
#after version 2.0.0
|
||||
contextmenu.expandAll = Mindent kinyit
|
||||
binaryData.truncateWarning = %count% byte lev\u00e1gva.
|
||||
|
||||
filter.sounds = T\u00e1mogatott hang form\u00e1tumok (*.wav, *.mp3)
|
||||
filter.sounds.wav = Hanghull\u00e1m form\u00e1tum (*.wav)
|
||||
filter.sounds.mp3 = MP3 t\u00f6m\u00f6r\u00edtett form\u00e1tum (*.mp3)
|
||||
|
||||
error.sound.invalid = \u00c9rv\u00e9nytelen hang.
|
||||
|
||||
button.prev = El\u0151z\u0151
|
||||
button.next = K\u00f6vetkez\u0151
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.SWFInputStream;
|
||||
import com.jpexs.decompiler.flash.SWFOutputStream;
|
||||
import com.jpexs.decompiler.flash.exporters.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.Point;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.tags.base.FontTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.MissingCharacterHandler;
|
||||
import com.jpexs.decompiler.flash.tags.base.TextTag;
|
||||
@@ -937,6 +938,11 @@ public class DefineEditTextTag extends TextTag {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toSVG(SVGExporterContext exporterContext) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
private FontTag getFontTag() {
|
||||
FontTag font = null;
|
||||
for (Tag tag : swf.tags) {
|
||||
|
||||
@@ -23,7 +23,8 @@ import com.jpexs.decompiler.flash.exporters.BitmapExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.ExportRectangle;
|
||||
import com.jpexs.decompiler.flash.exporters.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.Point;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGMorphShapeExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.exporters.morphshape.SVGMorphShapeExporter;
|
||||
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.DrawableTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.MorphShapeTag;
|
||||
@@ -99,7 +100,7 @@ public class DefineMorphShape2Tag extends CharacterTag implements MorphShapeTag,
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toSVG() {
|
||||
public String toSVG(SVGExporterContext exporterContext) {
|
||||
ExportRectangle rect = new ExportRectangle(getRect());
|
||||
SHAPEWITHSTYLE beginShapes = getShapeAtRatio(0);
|
||||
SHAPEWITHSTYLE endShapes = getShapeAtRatio(65535);
|
||||
|
||||
@@ -23,7 +23,8 @@ import com.jpexs.decompiler.flash.exporters.BitmapExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.ExportRectangle;
|
||||
import com.jpexs.decompiler.flash.exporters.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.Point;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGMorphShapeExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.exporters.morphshape.SVGMorphShapeExporter;
|
||||
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.DrawableTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.MorphShapeTag;
|
||||
@@ -147,7 +148,7 @@ public class DefineMorphShapeTag extends CharacterTag implements MorphShapeTag,
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toSVG() {
|
||||
public String toSVG(SVGExporterContext exporterContext) {
|
||||
ExportRectangle rect = new ExportRectangle(getRect());
|
||||
SHAPEWITHSTYLE beginShapes = getShapeAtRatio(0);
|
||||
SHAPEWITHSTYLE endShapes = getShapeAtRatio(65535);
|
||||
|
||||
@@ -20,7 +20,8 @@ import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.SWFInputStream;
|
||||
import com.jpexs.decompiler.flash.exporters.ExportRectangle;
|
||||
import com.jpexs.decompiler.flash.exporters.Point;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGShapeExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.exporters.shape.SVGShapeExporter;
|
||||
import com.jpexs.decompiler.flash.tags.base.ShapeTag;
|
||||
import com.jpexs.decompiler.flash.types.BasicType;
|
||||
import com.jpexs.decompiler.flash.types.ColorTransform;
|
||||
@@ -60,7 +61,7 @@ public class DefineShape2Tag extends ShapeTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toSVG() {
|
||||
public String toSVG(SVGExporterContext exporterContext) {
|
||||
ExportRectangle rect = new ExportRectangle(getRect());
|
||||
SVGShapeExporter exporter = new SVGShapeExporter(swf, getShapes(), rect, new ColorTransform() /*FIXME?*/);
|
||||
exporter.export();
|
||||
|
||||
@@ -20,7 +20,8 @@ import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.SWFInputStream;
|
||||
import com.jpexs.decompiler.flash.exporters.ExportRectangle;
|
||||
import com.jpexs.decompiler.flash.exporters.Point;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGShapeExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.exporters.shape.SVGShapeExporter;
|
||||
import com.jpexs.decompiler.flash.tags.base.ShapeTag;
|
||||
import com.jpexs.decompiler.flash.types.BasicType;
|
||||
import com.jpexs.decompiler.flash.types.ColorTransform;
|
||||
@@ -65,7 +66,7 @@ public class DefineShape3Tag extends ShapeTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toSVG() {
|
||||
public String toSVG(SVGExporterContext exporterContext) {
|
||||
ExportRectangle rect = new ExportRectangle(getRect());
|
||||
SVGShapeExporter exporter = new SVGShapeExporter(swf, getShapes(), rect, new ColorTransform() /*FIXME?*/);
|
||||
exporter.export();
|
||||
|
||||
@@ -20,7 +20,8 @@ import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.SWFInputStream;
|
||||
import com.jpexs.decompiler.flash.exporters.ExportRectangle;
|
||||
import com.jpexs.decompiler.flash.exporters.Point;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGShapeExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.exporters.shape.SVGShapeExporter;
|
||||
import com.jpexs.decompiler.flash.tags.base.ShapeTag;
|
||||
import com.jpexs.decompiler.flash.types.BasicType;
|
||||
import com.jpexs.decompiler.flash.types.ColorTransform;
|
||||
@@ -68,7 +69,7 @@ public class DefineShape4Tag extends ShapeTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toSVG() {
|
||||
public String toSVG(SVGExporterContext exporterContext) {
|
||||
ExportRectangle rect = new ExportRectangle(getRect());
|
||||
SVGShapeExporter exporter = new SVGShapeExporter(swf, getShapes(), rect, new ColorTransform() /*FIXME?*/);
|
||||
exporter.export();
|
||||
|
||||
@@ -21,7 +21,8 @@ import com.jpexs.decompiler.flash.SWFInputStream;
|
||||
import com.jpexs.decompiler.flash.SWFOutputStream;
|
||||
import com.jpexs.decompiler.flash.exporters.ExportRectangle;
|
||||
import com.jpexs.decompiler.flash.exporters.Point;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGShapeExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.exporters.shape.SVGShapeExporter;
|
||||
import com.jpexs.decompiler.flash.tags.base.ShapeTag;
|
||||
import com.jpexs.decompiler.flash.types.BasicType;
|
||||
import com.jpexs.decompiler.flash.types.ColorTransform;
|
||||
@@ -93,7 +94,7 @@ public class DefineShapeTag extends ShapeTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toSVG() {
|
||||
public String toSVG(SVGExporterContext exporterContext) {
|
||||
ExportRectangle rect = new ExportRectangle(getRect());
|
||||
SVGShapeExporter exporter = new SVGShapeExporter(swf, getShapes(), rect, new ColorTransform() /*FIXME?*/);
|
||||
exporter.export();
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.jpexs.decompiler.flash.abc.CopyOutputStream;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.exporters.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.Point;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.Container;
|
||||
@@ -288,6 +289,11 @@ public class DefineSpriteTag extends CharacterTag implements Container, Drawable
|
||||
SWF.frameToImage(getTimeline(), frame, time, stateUnderCursor, mouseButton, image, transformation, colorTransform);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toSVG(SVGExporterContext exporterContext) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getImagePos(int frame) {
|
||||
return new Point(0, 0);
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.SWFInputStream;
|
||||
import com.jpexs.decompiler.flash.SWFOutputStream;
|
||||
import com.jpexs.decompiler.flash.exporters.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.Point;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.tags.base.FontTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.MissingCharacterHandler;
|
||||
import com.jpexs.decompiler.flash.tags.base.TextTag;
|
||||
@@ -492,6 +493,11 @@ public class DefineText2Tag extends TextTag {
|
||||
staticTextToImage(swf, textRecords, 2, image, getTextMatrix(), transformation, colorTransform);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toSVG(SVGExporterContext exporterContext) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getImagePos(int frame) {
|
||||
return new Point(textBounds.Xmin / 20, textBounds.Ymin / 20);
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.jpexs.decompiler.flash.SWFInputStream;
|
||||
import com.jpexs.decompiler.flash.SWFOutputStream;
|
||||
import com.jpexs.decompiler.flash.exporters.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.Point;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.tags.base.FontTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.MissingCharacterHandler;
|
||||
import com.jpexs.decompiler.flash.tags.base.TextTag;
|
||||
@@ -508,6 +509,11 @@ public class DefineTextTag extends TextTag {
|
||||
staticTextToImage(swf, textRecords, 1, image, getTextMatrix(), transformation, colorTransform);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toSVG(SVGExporterContext exporterContext) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getImagePos(int frame) {
|
||||
return new Point(textBounds.Xmin / SWF.unitDivisor, textBounds.Ymin / SWF.unitDivisor);
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.tags.base;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.exporters.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.tags.DefineButtonSoundTag;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.timeline.DepthState;
|
||||
@@ -57,6 +58,11 @@ public abstract class ButtonTag extends CharacterTag implements DrawableTag, Tim
|
||||
SWF.frameToImage(getTimeline(), frame, time, stateUnderCursor, mouseButton, image, transformation, colorTransform);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toSVG(SVGExporterContext exporterContext) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
public DefineButtonSoundTag getSounds() {
|
||||
for (Tag t : swf.tags) {
|
||||
if (t instanceof DefineButtonSoundTag) {
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.tags.base;
|
||||
|
||||
import com.jpexs.decompiler.flash.exporters.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.Point;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.timeline.DepthState;
|
||||
import com.jpexs.decompiler.flash.types.ColorTransform;
|
||||
import com.jpexs.helpers.SerializableImage;
|
||||
@@ -31,6 +32,8 @@ public interface DrawableTag extends BoundedTag {
|
||||
|
||||
public void toImage(int frame, int time, int ratio, DepthState stateUnderCursor, int mouseButton, SerializableImage image, Matrix transformation, ColorTransform colorTransform);
|
||||
|
||||
public String toSVG(SVGExporterContext exporterContext);
|
||||
|
||||
public Point getImagePos(int frame);
|
||||
|
||||
public int getNumFrames();
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.exporters.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.Point;
|
||||
import com.jpexs.decompiler.flash.exporters.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.helpers.FontHelper;
|
||||
import com.jpexs.decompiler.flash.tags.DefineFontNameTag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineText2Tag;
|
||||
@@ -258,6 +259,11 @@ public abstract class FontTag extends CharacterTag implements AloneTag, Drawable
|
||||
SHAPERECORD.shapeListToImage(swf, getGlyphShapeTable(), image, frame, Color.black, colorTransform);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toSVG(SVGExporterContext exporterContext) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getImagePos(int frame) {
|
||||
return new Point(0, 0);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.tags.base;
|
||||
|
||||
import com.jpexs.decompiler.flash.exporters.SVGExporterContext;
|
||||
import com.jpexs.decompiler.flash.types.MORPHFILLSTYLEARRAY;
|
||||
import com.jpexs.decompiler.flash.types.MORPHLINESTYLEARRAY;
|
||||
import com.jpexs.decompiler.flash.types.RECT;
|
||||
@@ -40,7 +41,7 @@ public interface MorphShapeTag {
|
||||
|
||||
public SHAPE getEndEdges();
|
||||
|
||||
public abstract String toSVG();
|
||||
public String toSVG(SVGExporterContext exporterContext);
|
||||
|
||||
public int getShapeNum();
|
||||
|
||||
|
||||
@@ -37,8 +37,6 @@ public abstract class ShapeTag extends CharacterTag implements BoundedTag, Drawa
|
||||
|
||||
public abstract SHAPEWITHSTYLE getShapes();
|
||||
|
||||
public abstract String toSVG();
|
||||
|
||||
public abstract int getShapeNum();
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user