Issue #168 Export command from context menu in the tree

Issue #202 Removing tags
This commit is contained in:
Jindra Petk
2013-07-08 22:44:19 +02:00
parent 2dcf679546
commit e79994b6da
43 changed files with 204 additions and 120 deletions

View File

@@ -113,6 +113,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.Stack;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
@@ -355,8 +356,8 @@ public class SWF {
for (Tag t : tags) {
if (t instanceof CharacterIdTag) {
CharacterIdTag ct = (CharacterIdTag) t;
if (exportNames.containsKey(ct.getCharacterID())) {
ct.setExportName(exportNames.get(ct.getCharacterID()));
if (exportNames.containsKey(ct.getCharacterId())) {
ct.setExportName(exportNames.get(ct.getCharacterId()));
}
}
}
@@ -377,8 +378,8 @@ public class SWF {
for (Tag t : tags) {
if (t instanceof CharacterIdTag) {
CharacterIdTag ct = (CharacterIdTag) t;
if (classes.containsKey(ct.getCharacterID())) {
ct.setClassName(classes.get(ct.getCharacterID()));
if (classes.containsKey(ct.getCharacterId())) {
ct.setClassName(classes.get(ct.getCharacterId()));
}
}
}
@@ -1204,7 +1205,7 @@ public class SWF {
}
for (Tag t : tags) {
if (t instanceof TextTag) {
File file = new File(outdir + File.separator + ((TextTag) t).getCharacterID() + ".txt");
File file = new File(outdir + File.separator + ((TextTag) t).getCharacterId() + ".txt");
try (FileOutputStream fos = new FileOutputStream(file)) {
if (formatted) {
fos.write(((TextTag) t).getFormattedText(this.tags).getBytes("UTF-8"));
@@ -1236,7 +1237,7 @@ public class SWF {
if (t instanceof ShapeTag) {
int characterID = 0;
if (t instanceof CharacterTag) {
characterID = ((CharacterTag) t).getCharacterID();
characterID = ((CharacterTag) t).getCharacterId();
}
File file = new File(outdir + File.separator + characterID + ".svg");
try (FileOutputStream fos = new FileOutputStream(file)) {
@@ -1260,7 +1261,7 @@ public class SWF {
}
for (Tag t : tags) {
if (t instanceof DefineBinaryDataTag) {
int characterID = ((DefineBinaryDataTag) t).getCharacterID();
int characterID = ((DefineBinaryDataTag) t).getCharacterId();
File file = new File(outdir + File.separator + characterID + ".bin");
try (FileOutputStream fos = new FileOutputStream(file)) {
fos.write(((DefineBinaryDataTag) t).binaryData);
@@ -1283,7 +1284,7 @@ public class SWF {
}
for (Tag t : tags) {
if (t instanceof ImageTag) {
File file = new File(outdir + File.separator + ((ImageTag) t).getCharacterID() + "." + ((ImageTag) t).getImageFormat());
File file = new File(outdir + File.separator + ((ImageTag) t).getCharacterId() + "." + ((ImageTag) t).getImageFormat());
ImageIO.write(((ImageTag) t).getImage(this.tags), ((ImageTag) t).getImageFormat().toUpperCase(Locale.ENGLISH), file);
ret.add(file);
}
@@ -2232,7 +2233,7 @@ public class SWF {
for (Tag t : allTags) {
if (t instanceof CharacterTag) {
CharacterTag ch = (CharacterTag) t;
characters.put(ch.getCharacterID(), ch);
characters.put(ch.getCharacterId(), ch);
}
}
@@ -2327,4 +2328,86 @@ public class SWF {
}
return;
}
public void removeTagFromTimeline(Tag toRemove, List<Tag> timeline) {
int characterId = 0;
if (toRemove instanceof CharacterTag) {
characterId = ((CharacterTag) toRemove).getCharacterId();
}
Map<Integer, Integer> stage = new HashMap<>();
Set<Integer> dependingChars = new HashSet<>();
if (characterId != 0) {
dependingChars.add(characterId);
for (int i = 0; i < timeline.size(); i++) {
Tag t = timeline.get(i);
if (t instanceof CharacterIdTag) {
CharacterIdTag c = (CharacterIdTag) t;
Set<Integer> needed = t.getNeededCharacters();
if (needed.contains(characterId)) {
dependingChars.add(c.getCharacterId());
}
}
}
}
for (int i = 0; i < timeline.size(); i++) {
Tag t = timeline.get(i);
if (t instanceof RemoveTag) {
RemoveTag rt = (RemoveTag) t;
int currentCharId = stage.get(rt.getDepth());
stage.remove(rt.getDepth());
if (dependingChars.contains(currentCharId)) {
timeline.remove(i);
i--;
continue;
}
}
if (t instanceof PlaceObjectTypeTag) {
PlaceObjectTypeTag po = (PlaceObjectTypeTag) t;
int placeCharId = po.getCharacterId();
int placeDepth = po.getDepth();
if (placeCharId != 0) {
stage.put(placeDepth, placeCharId);
}
int currentCharId = stage.get(placeDepth);
if (dependingChars.contains(currentCharId)) {
timeline.remove(i);
i--;
continue;
}
}
if (t instanceof CharacterIdTag) {
CharacterIdTag c = (CharacterIdTag) t;
if (dependingChars.contains(c.getCharacterId())) {
timeline.remove(i);
i--;
continue;
}
}
Set<Integer> needed = t.getNeededCharacters();
for (int dep : dependingChars) {
if (needed.contains(dep)) {
timeline.remove(i);
i--;
continue;
}
}
if (t == toRemove) {
timeline.remove(i);
i--;
continue;
}
if (t instanceof DefineSpriteTag) {
DefineSpriteTag spr = (DefineSpriteTag) t;
removeTagFromTimeline(toRemove, spr.subTags);
}
}
}
public void removeTag(Tag t) {
removeTagFromTimeline(t, tags);
}
}

View File

@@ -186,7 +186,7 @@ public class Main {
locswf = new SWF(bis, new PercentListener() {
@Override
public void percent(int p) {
startWork("Reading SWF", p);
startWork(translate("work.reading.swf"), p);
}
}, (Boolean) Configuration.getConfig("paralelSpeedUp", Boolean.TRUE));
locswf.addEventListener(new EventListener() {

View File

@@ -76,12 +76,14 @@ import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.decompiler.flash.tags.base.ASMSource;
import com.jpexs.decompiler.flash.tags.base.AloneTag;
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
import com.jpexs.decompiler.flash.tags.base.CharacterIdTag;
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
import com.jpexs.decompiler.flash.tags.base.Container;
import com.jpexs.decompiler.flash.tags.base.DrawableTag;
import com.jpexs.decompiler.flash.tags.base.FontTag;
import com.jpexs.decompiler.flash.tags.base.ImageTag;
import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag;
import com.jpexs.decompiler.flash.tags.base.RemoveTag;
import com.jpexs.decompiler.flash.tags.base.SoundStreamHeadTypeTag;
import com.jpexs.decompiler.flash.tags.base.TextTag;
import com.jpexs.decompiler.flash.tags.text.ParseException;
@@ -130,7 +132,9 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.Stack;
@@ -658,11 +662,16 @@ public class MainFrame extends AppFrame implements ActionListener, TreeSelection
});
}
});
final JPopupMenu spritePopupMenu = new JPopupMenu();
JMenuItem removeMenuItem = new JMenuItem(translate("contextmenu.remove"));
final JPopupMenu contextPopupMenu = new JPopupMenu();
final JMenuItem removeMenuItem = new JMenuItem(translate("contextmenu.remove"));
removeMenuItem.addActionListener(this);
removeMenuItem.setActionCommand("REMOVEITEM");
spritePopupMenu.add(removeMenuItem);
JMenuItem exportSelectionMenuItem = new JMenuItem(translate("menu.file.export.selection"));
exportSelectionMenuItem.setActionCommand("EXPORTSEL");
exportSelectionMenuItem.addActionListener(this);
contextPopupMenu.add(exportSelectionMenuItem);
contextPopupMenu.add(removeMenuItem);
tagTree.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
@@ -678,9 +687,8 @@ public class MainFrame extends AppFrame implements ActionListener, TreeSelection
if (tagObj instanceof TagNode) {
tagObj = ((TagNode) tagObj).tag;
}
if (tagObj instanceof DefineSpriteTag) {
spritePopupMenu.show(e.getComponent(), e.getX(), e.getY());
}
removeMenuItem.setVisible(tagObj instanceof Tag);
contextPopupMenu.show(e.getComponent(), e.getX(), e.getY());
}
}
});
@@ -1037,7 +1045,7 @@ public class MainFrame extends AppFrame implements ActionListener, TreeSelection
private void parseCharacters(List<Object> list) {
for (Object t : list) {
if (t instanceof CharacterTag) {
characters.put(((CharacterTag) t).getCharacterID(), (CharacterTag) t);
characters.put(((CharacterTag) t).getCharacterId(), (CharacterTag) t);
}
if (t instanceof Container) {
parseCharacters(((Container) t).getSubItems());
@@ -1762,33 +1770,12 @@ public class MainFrame extends AppFrame implements ActionListener, TreeSelection
if (tagObj instanceof TagNode) {
tagObj = ((TagNode) tagObj).tag;
}
if (tagObj instanceof DefineSpriteTag) {
DefineSpriteTag sprite = (DefineSpriteTag) tagObj;
for (int i = 0; i < swf.tags.size(); i++) {
Tag t = swf.tags.get(i);
if (t == sprite) {
swf.tags.remove(i);
i--;
} else if (t instanceof DefineSpriteTag) {
DefineSpriteTag st = (DefineSpriteTag) t;
for (int j = 0; j < st.subTags.size(); j++) {
Tag t2 = st.subTags.get(j);
Set<Integer> needed = t2.getNeededCharacters();
if (needed.contains(sprite.spriteId)) {
st.subTags.remove(j);
j--;
}
}
} else {
Set<Integer> needed = t.getNeededCharacters();
if (needed.contains(sprite.spriteId)) {
swf.tags.remove(i);
i--;
}
}
if (tagObj instanceof Tag) {
if (JOptionPane.showConfirmDialog(this, translate("message.confirm.remove").replace("%item%", tagObj.toString()), translate("message.confirm"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) {
swf.removeTag((Tag) tagObj);
showCard(CARDEMPTYPANEL);
refreshTree();
}
showCard(CARDEMPTYPANEL);
refreshTree();
}
break;
case "EDITTEXT":
@@ -2346,7 +2333,7 @@ public class MainFrame extends AppFrame implements ActionListener, TreeSelection
}
}
if (t instanceof CharacterTag) {
doneCharacters.add(((CharacterTag) t).getCharacterID());
doneCharacters.add(((CharacterTag) t).getCharacterId());
}
sos2.writeTag(t);
@@ -2392,7 +2379,7 @@ public class MainFrame extends AppFrame implements ActionListener, TreeSelection
int chtId = 0;
if (tagObj instanceof CharacterTag) {
chtId = ((CharacterTag) tagObj).getCharacterID();
chtId = ((CharacterTag) tagObj).getCharacterId();
}
MATRIX mat = new MATRIX();

View File

@@ -211,3 +211,5 @@ message.action.saved = Code successfully saved
error.action.save = %error% on line %line%
message.confirm.remove = Are you sure you want to remove %item% \n and all objects which depend on it ?

View File

@@ -209,4 +209,6 @@ action.edit.experimental = (Experiment\u00e1ln\u00ed)
message.action.saved = K\u00f3d \u00fasp\u011b\u0161n\u011b ulo\u017een
error.action.save = %error% na \u0159\u00e1dku %line%
error.action.save = %error% na \u0159\u00e1dku %line%
message.confirm.remove = Opravdu chcete odebrat %item%\n a v\u0161echny objekty kter\u00e9 na t\u00e9to polo\u017ece z\u00e1vis\u00ed ?

View File

@@ -60,7 +60,7 @@ public class DefineBinaryDataTag extends CharacterTag {
}
@Override
public int getCharacterID() {
public int getCharacterId() {
return tag;
}
}

View File

@@ -35,7 +35,7 @@ public class DefineBitsJPEG2Tag extends ImageTag implements AloneTag {
public static final int ID = 21;
@Override
public int getCharacterID() {
public int getCharacterId() {
return characterID;
}

View File

@@ -40,7 +40,7 @@ public class DefineBitsJPEG3Tag extends ImageTag implements AloneTag {
public static final int ID = 35;
@Override
public int getCharacterID() {
public int getCharacterId() {
return characterID;
}

View File

@@ -46,7 +46,7 @@ public class DefineBitsJPEG4Tag extends ImageTag implements AloneTag {
public static final int ID = 90;
@Override
public int getCharacterID() {
public int getCharacterId() {
return characterID;
}

View File

@@ -49,7 +49,7 @@ public class DefineBitsLossless2Tag extends ImageTag implements AloneTag {
public static final int ID = 36;
@Override
public int getCharacterID() {
public int getCharacterId() {
return characterID;
}

View File

@@ -125,7 +125,7 @@ public class DefineBitsLosslessTag extends ImageTag implements AloneTag {
}
@Override
public int getCharacterID() {
public int getCharacterId() {
return characterID;
}

View File

@@ -103,7 +103,7 @@ public class DefineBitsTag extends ImageTag {
}
@Override
public int getCharacterID() {
public int getCharacterId() {
return characterID;
}

View File

@@ -74,7 +74,7 @@ public class DefineButton2Tag extends CharacterTag implements Container, Bounded
public static final int ID = 34;
@Override
public int getCharacterID() {
public int getCharacterId() {
return buttonId;
}
@@ -216,7 +216,7 @@ public class DefineButton2Tag extends CharacterTag implements Container, Bounded
for (BUTTONRECORD r : characters) {
CharacterTag ch = allCharacters.get(r.characterId);
if (ch instanceof BoundedTag) {
if (visited.contains(ch.getCharacterID())) {
if (visited.contains(ch.getCharacterId())) {
continue;
}
RECT r2 = ((BoundedTag) ch).getRect(allCharacters, visited);

View File

@@ -44,7 +44,7 @@ public class DefineButtonSoundTag extends CharacterTag {
public static final int ID = 17;
@Override
public int getCharacterID() {
public int getCharacterId() {
return buttonId;
}

View File

@@ -72,7 +72,7 @@ public class DefineButtonTag extends CharacterTag implements ASMSource, BoundedT
public static final int ID = 7;
@Override
public int getCharacterID() {
public int getCharacterId() {
return buttonId;
}
private long hdrSize;
@@ -219,7 +219,7 @@ public class DefineButtonTag extends CharacterTag implements ASMSource, BoundedT
for (BUTTONRECORD r : characters) {
CharacterTag ch = allCharacters.get(r.characterId);
if (ch instanceof BoundedTag) {
if (visited.contains(ch.getCharacterID())) {
if (visited.contains(ch.getCharacterId())) {
continue;
}
RECT r2 = ((BoundedTag) ch).getRect(allCharacters, visited);

View File

@@ -388,7 +388,7 @@ public class DefineEditTextTag extends CharacterTag implements BoundedTag, TextT
}
@Override
public int getCharacterID() {
public int getCharacterId() {
return characterID;
}

View File

@@ -243,7 +243,7 @@ public class DefineFont2Tag extends CharacterTag implements FontTag {
}
@Override
public int getCharacterID() {
public int getCharacterId() {
return fontId;
}

View File

@@ -249,7 +249,7 @@ public class DefineFont3Tag extends CharacterTag implements FontTag {
}
@Override
public int getCharacterID() {
public int getCharacterId() {
return fontId;
}

View File

@@ -35,7 +35,7 @@ public class DefineFont4Tag extends CharacterTag {
public static final int ID = 91;
@Override
public int getCharacterID() {
public int getCharacterId() {
return fontID;
}

View File

@@ -158,7 +158,7 @@ public class DefineFontTag extends CharacterTag implements FontTag {
}
@Override
public int getCharacterID() {
public int getCharacterId() {
return fontId;
}

View File

@@ -87,7 +87,7 @@ public class DefineMorphShape2Tag extends CharacterTag implements BoundedTag, Mo
}
@Override
public int getCharacterID() {
public int getCharacterId() {
return characterId;
}

View File

@@ -73,7 +73,7 @@ public class DefineMorphShapeTag extends CharacterTag implements BoundedTag, Mor
}
@Override
public int getCharacterID() {
public int getCharacterId() {
return characterId;
}

View File

@@ -71,7 +71,7 @@ public class DefineShape2Tag extends CharacterTag implements BoundedTag, ShapeTa
}
@Override
public int getCharacterID() {
public int getCharacterId() {
return shapeId;
}

View File

@@ -76,7 +76,7 @@ public class DefineShape3Tag extends CharacterTag implements BoundedTag, ShapeTa
}
@Override
public int getCharacterID() {
public int getCharacterId() {
return shapeId;
}

View File

@@ -75,7 +75,7 @@ public class DefineShape4Tag extends CharacterTag implements BoundedTag, ShapeTa
}
@Override
public int getCharacterID() {
public int getCharacterId() {
return shapeId;
}

View File

@@ -69,7 +69,7 @@ public class DefineShapeTag extends CharacterTag implements BoundedTag, ShapeTag
}
@Override
public int getCharacterID() {
public int getCharacterId() {
return shapeId;
}

View File

@@ -49,7 +49,7 @@ public class DefineSoundTag extends CharacterTag {
public static final int ID = 14;
@Override
public int getCharacterID() {
public int getCharacterId() {
return soundId;
}

View File

@@ -64,7 +64,7 @@ public class DefineSpriteTag extends CharacterTag implements Container, BoundedT
public static final int ID = 39;
@Override
public int getCharacterID() {
public int getCharacterId() {
return spriteId;
}
@@ -80,7 +80,7 @@ public class DefineSpriteTag extends CharacterTag implements Container, BoundedT
RECT r = null;
if (t instanceof BoundedTag) {
if (t instanceof CharacterTag) {
if (visited.contains(((CharacterTag) t).getCharacterID())) {
if (visited.contains(((CharacterTag) t).getCharacterId())) {
continue;
}
}

View File

@@ -381,7 +381,7 @@ public class DefineText2Tag extends CharacterTag implements BoundedTag, TextTag,
}
@Override
public int getCharacterID() {
public int getCharacterId() {
return characterID;
}

View File

@@ -376,7 +376,7 @@ public class DefineTextTag extends CharacterTag implements BoundedTag, TextTag,
}
@Override
public int getCharacterID() {
public int getCharacterId() {
return characterID;
}

View File

@@ -45,7 +45,7 @@ public class DefineVideoStreamTag extends CharacterTag {
public static final int ID = 60;
@Override
public int getCharacterID() {
public int getCharacterId() {
return characterID;
}

View File

@@ -149,7 +149,7 @@ public class DoInitActionTag extends CharacterIdTag implements ASMSource {
}
@Override
public int getCharacterID() {
public int getCharacterId() {
return spriteId;
}
List<DisassemblyListener> listeners = new ArrayList<>();

View File

@@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.Configuration;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.abc.CopyOutputStream;
import com.jpexs.decompiler.flash.tags.base.CharacterIdTag;
import com.jpexs.decompiler.flash.tags.base.Container;
import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag;
import com.jpexs.decompiler.flash.types.CLIPACTIONS;
@@ -42,7 +43,7 @@ import java.util.Set;
*
* @author JPEXS
*/
public class PlaceObject2Tag extends Tag implements Container, PlaceObjectTypeTag {
public class PlaceObject2Tag extends CharacterIdTag implements Container, PlaceObjectTypeTag {
/**
* @since SWF 5 Has clip actions (sprite characters only)

View File

@@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.EndOfStreamException;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.abc.CopyOutputStream;
import com.jpexs.decompiler.flash.tags.base.CharacterIdTag;
import com.jpexs.decompiler.flash.tags.base.Container;
import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag;
import com.jpexs.decompiler.flash.types.CLIPACTIONS;
@@ -43,7 +44,7 @@ import java.util.Set;
*
* @author JPEXS
*/
public class PlaceObject3Tag extends Tag implements Container, PlaceObjectTypeTag {
public class PlaceObject3Tag extends CharacterIdTag implements Container, PlaceObjectTypeTag {
/**
* @since SWF 5 has clip actions (sprite characters only)

View File

@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.tags;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.tags.base.CharacterIdTag;
import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag;
import com.jpexs.decompiler.flash.types.CLIPACTIONS;
import com.jpexs.decompiler.flash.types.CXFORM;
@@ -38,7 +39,7 @@ import java.util.Set;
*
* @author JPEXS
*/
public class PlaceObjectTag extends Tag implements PlaceObjectTypeTag {
public class PlaceObjectTag extends CharacterIdTag implements PlaceObjectTypeTag {
/**
* ID of character to place

View File

@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.tags;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.tags.base.CharacterIdTag;
import com.jpexs.decompiler.flash.tags.base.RemoveTag;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -29,7 +30,7 @@ import java.io.OutputStream;
*
* @author JPEXS
*/
public class RemoveObjectTag extends Tag implements RemoveTag {
public class RemoveObjectTag extends CharacterIdTag implements RemoveTag {
/**
* ID of character to place
@@ -78,4 +79,9 @@ public class RemoveObjectTag extends Tag implements RemoveTag {
public int getDepth() {
return depth;
}
@Override
public int getCharacterId() {
return characterId;
}
}

View File

@@ -45,7 +45,7 @@ public class SoundStreamHead2Tag extends CharacterTag implements SoundStreamHead
public static final int ID = 45;
@Override
public int getCharacterID() {
public int getCharacterId() {
return virtualCharacterId;
}
@@ -104,6 +104,7 @@ public class SoundStreamHead2Tag extends CharacterTag implements SoundStreamHead
*
* @param data Data bytes
* @param version SWF version
* @param pos
* @throws IOException
*/
public SoundStreamHead2Tag(byte data[], int version, long pos) throws IOException {

View File

@@ -56,7 +56,7 @@ public class SoundStreamHeadTag extends CharacterTag implements SoundStreamHeadT
}
@Override
public int getCharacterID() {
public int getCharacterId() {
return virtualCharacterId;
}

View File

@@ -31,7 +31,7 @@ public abstract class CharacterIdTag extends Tag {
super(id, name, data, pos);
}
public abstract int getCharacterID();
public abstract int getCharacterId();
/**
* List of ExportAssetsTag used for converting to String
*/
@@ -60,16 +60,16 @@ public abstract class CharacterIdTag extends Tag {
if (className != null) {
nameAppend = ": " + className;
}
return super.getName() + " (" + getCharacterID() + nameAppend + ")";
return super.getName() + " (" + getCharacterId() + nameAppend + ")";
}
@Override
public String getExportFileName() {
return super.getName() + "_" + getCharacterID() + (((exportName != null) && (!exportName.equals(""))) ? "_" + exportName : "");
return super.getName() + "_" + getCharacterId() + (((exportName != null) && (!exportName.equals(""))) ? "_" + exportName : "");
}
public String getCharacterExportFileName() {
return getCharacterID() + (((exportName != null) && (!exportName.equals(""))) ? "_" + exportName : "");
return getCharacterId() + (((exportName != null) && (!exportName.equals(""))) ? "_" + exportName : "");
}
public String getExportName() {

View File

@@ -18,7 +18,7 @@ public interface SoundStreamHeadTypeTag {
public void setVirtualCharacterId(int ch);
public int getCharacterID();
public int getCharacterId();
public String getExportFormat();
}

View File

@@ -33,7 +33,7 @@ public interface TextTag {
public void setFormattedText(List<Tag> tags, String text) throws ParseException;
public int getCharacterID();
public int getCharacterId();
public RECT getBounds();

View File

@@ -165,7 +165,7 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters {
for (Tag t : tags) {
if (t instanceof ImageTag) {
ImageTag i = (ImageTag) t;
if (i.getCharacterID() == fillStyle0.bitmapId) {
if (i.getCharacterId() == fillStyle0.bitmapId) {
image = i;
break;
}

View File

@@ -290,7 +290,7 @@ public class XFLConverter {
CharacterTag bitmapCh = characters.get(fs.bitmapId);
if (bitmapCh instanceof ImageTag) {
ImageTag it = (ImageTag) bitmapCh;
ret += "bitmap" + bitmapCh.getCharacterID() + "." + it.getImageFormat();
ret += "bitmap" + bitmapCh.getCharacterId() + "." + it.getImageFormat();
}
ret += "\"";
@@ -828,8 +828,8 @@ public class XFLConverter {
for (Tag t : tags) {
if (t instanceof CharacterTag) {
CharacterTag ct = (CharacterTag) t;
if (ct.getCharacterID() > maxId) {
maxId = ct.getCharacterID();
if (ct.getCharacterId() > maxId) {
maxId = ct.getCharacterId();
}
}
}
@@ -840,7 +840,7 @@ public class XFLConverter {
}
if (t instanceof CharacterTag) {
CharacterTag ct = (CharacterTag) t;
ret.put(ct.getCharacterID(), ct);
ret.put(ct.getCharacterId(), ct);
}
}
return ret;
@@ -1034,7 +1034,7 @@ public class XFLConverter {
}
}
ret += "<DOMSymbolInstance libraryItemName=\"" + "Symbol " + tag.getCharacterID() + "\"";
ret += "<DOMSymbolInstance libraryItemName=\"" + "Symbol " + tag.getCharacterId() + "\"";
if (name != null) {
ret += " name=\"" + xmlString(name) + "\"";
}
@@ -1157,13 +1157,13 @@ public class XFLConverter {
List<String> symbols = new ArrayList<>();
for (int ch : characters.keySet()) {
CharacterTag symbol = characters.get(ch);
if ((symbol instanceof ShapeTag) && oneInstanceShapes.contains(symbol.getCharacterID())) {
if ((symbol instanceof ShapeTag) && oneInstanceShapes.contains(symbol.getCharacterId())) {
continue; //shapes with 1 ocurrence are not added to library
}
if ((symbol instanceof ShapeTag) || (symbol instanceof DefineSpriteTag) || (symbol instanceof ButtonTag)) {
String symbolStr = "";
symbolStr += "<DOMSymbolItem xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://ns.adobe.com/xfl/2008/\" name=\"Symbol " + symbol.getCharacterID() + "\" lastModified=\"" + getTimestamp() + "\""; //TODO:itemID
symbolStr += "<DOMSymbolItem xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://ns.adobe.com/xfl/2008/\" name=\"Symbol " + symbol.getCharacterId() + "\" lastModified=\"" + getTimestamp() + "\""; //TODO:itemID
if (symbol instanceof ShapeTag) {
symbolStr += " symbolType=\"graphic\"";
} else if (symbol instanceof ButtonTag) {
@@ -1173,13 +1173,13 @@ public class XFLConverter {
}
}
boolean linkageExportForAS = false;
if (characterClasses.containsKey(symbol.getCharacterID())) {
if (characterClasses.containsKey(symbol.getCharacterId())) {
linkageExportForAS = true;
symbolStr += " linkageClassName=\"" + xmlString(characterClasses.get(symbol.getCharacterID())) + "\"";
symbolStr += " linkageClassName=\"" + xmlString(characterClasses.get(symbol.getCharacterId())) + "\"";
}
if (characterVariables.containsKey(symbol.getCharacterID())) {
if (characterVariables.containsKey(symbol.getCharacterId())) {
linkageExportForAS = true;
symbolStr += " linkageIdentifier=\"" + xmlString(characterVariables.get(symbol.getCharacterID())) + "\"";
symbolStr += " linkageIdentifier=\"" + xmlString(characterVariables.get(symbol.getCharacterId())) + "\"";
}
if (linkageExportForAS) {
symbolStr += " linkageExportForAS=\"true\"";
@@ -1189,7 +1189,7 @@ public class XFLConverter {
String itemIcon = null;
if (symbol instanceof ButtonTag) {
itemIcon = "0";
symbolStr += "<DOMTimeline name=\"Symbol " + symbol.getCharacterID() + "\" currentFrame=\"0\">";
symbolStr += "<DOMTimeline name=\"Symbol " + symbol.getCharacterId() + "\" currentFrame=\"0\">";
symbolStr += "<layers>";
ButtonTag button = (ButtonTag) symbol;
@@ -1289,11 +1289,11 @@ public class XFLConverter {
if (sprite.subTags.isEmpty()) { //probably AS2 class
continue;
}
symbolStr += convertTimeline(sprite.spriteId, oneInstanceShapes, backgroundColor, tags, sprite.getSubTags(), characters, "Symbol " + symbol.getCharacterID());
symbolStr += convertTimeline(sprite.spriteId, oneInstanceShapes, backgroundColor, tags, sprite.getSubTags(), characters, "Symbol " + symbol.getCharacterId());
} else if (symbol instanceof ShapeTag) {
itemIcon = "1";
ShapeTag shape = (ShapeTag) symbol;
symbolStr += "<DOMTimeline name=\"Symbol " + symbol.getCharacterID() + "\" currentFrame=\"0\">";
symbolStr += "<DOMTimeline name=\"Symbol " + symbol.getCharacterId() + "\" currentFrame=\"0\">";
symbolStr += "<layers>";
symbolStr += convertShape(characters, null, shape);
symbolStr += "</layers>";
@@ -1302,7 +1302,7 @@ public class XFLConverter {
symbolStr += "</timeline>";
symbolStr += "</DOMSymbolItem>";
symbolStr = prettyFormatXML(symbolStr);
String symbolFile = "Symbol " + symbol.getCharacterID() + ".xml";
String symbolFile = "Symbol " + symbol.getCharacterId() + ".xml";
try {
files.put(symbolFile, symbolStr.getBytes("UTF-8"));
} catch (UnsupportedEncodingException ex) {
@@ -1325,7 +1325,7 @@ public class XFLConverter {
} catch (IOException ex) {
Logger.getLogger(XFLConverter.class.getName()).log(Level.SEVERE, null, ex);
}
String symbolFile = "bitmap" + symbol.getCharacterID() + "." + imageTag.getImageFormat();
String symbolFile = "bitmap" + symbol.getCharacterId() + "." + imageTag.getImageFormat();
files.put(symbolFile, baos.toByteArray());
String mediaLinkStr = "<DOMBitmapItem name=\"" + symbolFile + "\" sourceLastImported=\"" + getTimestamp() + "\" externalFileSize=\"" + baos.toByteArray().length + "\"";
if (format.equals("png") || format.equals("gif")) {
@@ -1333,8 +1333,8 @@ public class XFLConverter {
} else if (format.equals("jpg")) {
mediaLinkStr += " isJPEG=\"true\"";
}
if (characterClasses.containsKey(symbol.getCharacterID())) {
mediaLinkStr += " linkageExportForAS=\"true\" linkageClassName=\"" + characterClasses.get(symbol.getCharacterID()) + "\"";
if (characterClasses.containsKey(symbol.getCharacterId())) {
mediaLinkStr += " linkageExportForAS=\"true\" linkageClassName=\"" + characterClasses.get(symbol.getCharacterId()) + "\"";
}
mediaLinkStr += " quality=\"50\" href=\"" + symbolFile + "\" bitmapDataHRef=\"M " + (media.size() + 1) + " " + getTimestamp() + ".dat\" frameRight=\"" + image.getWidth() + "\" frameBottom=\"" + image.getHeight() + "\"/>\n";
media.add(mediaLinkStr);
@@ -1473,7 +1473,7 @@ public class XFLConverter {
Logger.getLogger(XFLConverter.class.getName()).log(Level.SEVERE, null, ex);
}
if (!exportFormat.equals("flv")) { //FLV import format unsupported
String symbolFile = "sound" + symbol.getCharacterID() + "." + exportFormat;
String symbolFile = "sound" + symbol.getCharacterId() + "." + exportFormat;
files.put(symbolFile, data);
String mediaLinkStr = "<DOMSoundItem name=\"" + symbolFile + "\" sourceLastImported=\"" + getTimestamp() + "\" externalFileSize=\"" + data.length + "\"";
mediaLinkStr += " href=\"" + symbolFile + "\"";
@@ -1484,12 +1484,12 @@ public class XFLConverter {
mediaLinkStr += "\"";
mediaLinkStr += " exportFormat=\"" + format + "\" exportBits=\"" + bits + "\" sampleCount=\"" + soundSampleCount + "\"";
if (characterClasses.containsKey(symbol.getCharacterID())) {
mediaLinkStr += " linkageExportForAS=\"true\" linkageClassName=\"" + characterClasses.get(symbol.getCharacterID()) + "\"";
if (characterClasses.containsKey(symbol.getCharacterId())) {
mediaLinkStr += " linkageExportForAS=\"true\" linkageClassName=\"" + characterClasses.get(symbol.getCharacterId()) + "\"";
}
if (characterVariables.containsKey(symbol.getCharacterID())) {
mediaLinkStr += " linkageExportForAS=\"true\" linkageIdentifier=\"" + xmlString(characterVariables.get(symbol.getCharacterID())) + "\"";
if (characterVariables.containsKey(symbol.getCharacterId())) {
mediaLinkStr += " linkageExportForAS=\"true\" linkageIdentifier=\"" + xmlString(characterVariables.get(symbol.getCharacterId())) + "\"";
}
mediaLinkStr += "/>\n";
@@ -1519,7 +1519,7 @@ public class XFLConverter {
} catch (IOException ex) {
Logger.getLogger(XFLConverter.class.getName()).log(Level.SEVERE, null, ex);
}
String symbolFile = "movie" + symbol.getCharacterID() + "." + "flv";
String symbolFile = "movie" + symbol.getCharacterId() + "." + "flv";
String mediaLinkStr = "";
if (data.length == 0) { //Video has zero length, this probably means it is "Video - Actionscript-controlled"
long ts = getTimestamp();
@@ -1551,11 +1551,11 @@ public class XFLConverter {
mediaLinkStr += " height=\"" + video.height + "\"";
double len = ((double) video.numFrames) / ((double) swf.frameRate);
mediaLinkStr += " length=\"" + len + "\"";
if (characterClasses.containsKey(symbol.getCharacterID())) {
mediaLinkStr += " linkageExportForAS=\"true\" linkageClassName=\"" + characterClasses.get(symbol.getCharacterID()) + "\"";
if (characterClasses.containsKey(symbol.getCharacterId())) {
mediaLinkStr += " linkageExportForAS=\"true\" linkageClassName=\"" + characterClasses.get(symbol.getCharacterId()) + "\"";
}
if (characterVariables.containsKey(symbol.getCharacterID())) {
mediaLinkStr += " linkageExportForAS=\"true\" linkageIdentifier=\"" + xmlString(characterVariables.get(symbol.getCharacterID())) + "\"";
if (characterVariables.containsKey(symbol.getCharacterId())) {
mediaLinkStr += " linkageExportForAS=\"true\" linkageIdentifier=\"" + xmlString(characterVariables.get(symbol.getCharacterId())) + "\"";
}
mediaLinkStr += "/>\n";
}
@@ -1636,7 +1636,7 @@ public class XFLConverter {
}
String soundEnvelopeStr = "";
if (soundStreamHead != null) {
ret += " soundName=\"sound" + soundStreamHead.getCharacterID() + "." + soundStreamHead.getExportFormat() + "\"";
ret += " soundName=\"sound" + soundStreamHead.getCharacterId() + "." + soundStreamHead.getExportFormat() + "\"";
ret += " soundSync=\"stream\"";
soundEnvelopeStr += "<SoundEnvelope>";
soundEnvelopeStr += "<SoundEnvelopePoint level0=\"32768\" level1=\"32768\"/>";
@@ -2163,7 +2163,7 @@ public class XFLConverter {
for (Tag t : tags) {
if (t instanceof CSMTextSettingsTag) {
CSMTextSettingsTag c = (CSMTextSettingsTag) t;
if (c.textID == tag.getCharacterID()) {
if (c.textID == tag.getCharacterId()) {
csmts = c;
break;
}
@@ -2511,7 +2511,7 @@ public class XFLConverter {
for (Tag t : swf.tags) {
if (t instanceof DoInitActionTag) {
DoInitActionTag dia = (DoInitActionTag) t;
int chid = dia.getCharacterID();
int chid = dia.getCharacterId();
if (characters.containsKey(chid)) {
if (characters.get(chid) instanceof DefineSpriteTag) {
DefineSpriteTag sprite = (DefineSpriteTag) characters.get(chid);