Header display node (read only)

This commit is contained in:
Jindra Petřík
2014-07-20 10:07:51 +02:00
parent ab8cc63682
commit a14b1a392a
11 changed files with 320 additions and 51 deletions
+24 -1
View File
@@ -369,6 +369,29 @@ public final class SWF implements TreeItem, Timelined {
saveTo(os, compression);
}
public String getHeaderBytes() {
String ret = "";
if (compression == SWFCompression.LZMA) {
ret += 'Z';
} else if (compression == SWFCompression.ZLIB) {
ret += 'C';
} else {
if (gfx) {
ret += 'G';
} else {
ret += 'F';
}
}
if (gfx) {
ret += 'F';
ret += 'X';
} else {
ret += 'W';
ret += 'S';
}
return ret;
}
/**
* Saves this SWF into new file
*
@@ -1566,7 +1589,7 @@ public final class SWF implements TreeItem, Timelined {
new RetryTask(new RunnableIOEx() {
@Override
public void run() throws IOException {
File f = new File(foutdir + File.separator + (fframes.get(fi)+1) + ".png");
File f = new File(foutdir + File.separator + (fframes.get(fi) + 1) + ".png");
ImageIO.write(frameImages.next(), "PNG", f);
ret.add(f);
}
@@ -0,0 +1,108 @@
/*
* 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.gui;
import com.jpexs.decompiler.flash.AppStrings;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.gui.helpers.SpringUtilities;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SpringLayout;
/**
*
* @author JPEXS
*/
public class HeaderInfoPanel extends JPanel {
private final JLabel signatureLabel = new JLabel();
private final JLabel compressionLabel = new JLabel();
private final JLabel gfxLabel = new JLabel();
private final JLabel versionLabel = new JLabel();
private final JLabel fileSizeLabel = new JLabel();
private final JLabel frameRateLabel = new JLabel();
private final JLabel frameCountLabel = new JLabel();
private final JLabel displayRectTwipsLabel = new JLabel();
private final JLabel displayRectPixelsLabel = new JLabel();
public HeaderInfoPanel() {
setLayout(new SpringLayout());
add(new JLabel(AppStrings.translate("header.signature")));
add(signatureLabel);
add(new JLabel(AppStrings.translate("header.compression")));
add(compressionLabel);
add(new JLabel(AppStrings.translate("header.version")));
add(versionLabel);
add(new JLabel(AppStrings.translate("header.gfx")));
add(gfxLabel);
add(new JLabel(AppStrings.translate("header.filesize")));
add(fileSizeLabel);
add(new JLabel(AppStrings.translate("header.framerate")));
add(frameRateLabel);
add(new JLabel(AppStrings.translate("header.framecount")));
add(frameCountLabel);
add(new JLabel(AppStrings.translate("header.displayrect")));
add(displayRectTwipsLabel);
add(new JLabel(""));
add(displayRectPixelsLabel);
SpringUtilities.makeCompactGrid(this,
9, 2, //rows, cols
6, 6, //initX, initY
6, 6); //xPad, yPad
}
public void load(SWF swf) {
signatureLabel.setText(swf.getHeaderBytes());
switch (swf.compression) {
case LZMA:
compressionLabel.setText(AppStrings.translate("header.compression.lzma"));
break;
case ZLIB:
compressionLabel.setText(AppStrings.translate("header.compression.zlib"));
break;
case NONE:
compressionLabel.setText(AppStrings.translate("header.compression.none"));
break;
}
versionLabel.setText("" + swf.version);
gfxLabel.setText(swf.gfx ? AppStrings.translate("yes") : AppStrings.translate("no"));
fileSizeLabel.setText("" + swf.fileSize);
frameRateLabel.setText("" + swf.frameRate);
frameCountLabel.setText("" + swf.frameCount);
displayRectTwipsLabel.setText(AppStrings.translate("header.displayrect.value.twips")
.replace("%xmin%", ""+swf.displayRect.Xmin)
.replace("%ymin%", ""+swf.displayRect.Ymin)
.replace("%xmax%", ""+swf.displayRect.Xmax)
.replace("%ymax%", ""+swf.displayRect.Ymax));
displayRectPixelsLabel.setText(AppStrings.translate("header.displayrect.value.pixels")
.replace("%xmin%", ""+fmtDouble(swf.displayRect.Xmin/SWF.unitDivisor))
.replace("%ymin%", ""+fmtDouble(swf.displayRect.Ymin/SWF.unitDivisor))
.replace("%xmax%", ""+fmtDouble(swf.displayRect.Xmax/SWF.unitDivisor))
.replace("%ymax%", ""+fmtDouble(swf.displayRect.Ymax/SWF.unitDivisor)));
}
private String fmtDouble(double d){
String r = ""+d;
if(r.endsWith(".0")){
r = r.substring(0,r.length()-2);
}
return r;
}
}
@@ -123,6 +123,7 @@ import com.jpexs.decompiler.flash.treeitems.StringItem;
import com.jpexs.decompiler.flash.treeitems.TreeItem;
import com.jpexs.decompiler.flash.treenodes.ContainerNode;
import com.jpexs.decompiler.flash.treenodes.FrameNode;
import com.jpexs.decompiler.flash.treenodes.HeaderNode;
import com.jpexs.decompiler.flash.treenodes.TagNode;
import com.jpexs.decompiler.flash.treenodes.TreeNode;
import com.jpexs.decompiler.flash.types.MATRIX;
@@ -232,6 +233,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
private static final String CARDDUMPVIEW = "Dump view";
private static final String CARDACTIONSCRIPTPANEL = "ActionScript card";
private static final String CARDACTIONSCRIPT3PANEL = "ActionScript3 card";
private static final String CARDHEADER = "Header card";
private static final String DETAILCARDAS3NAVIGATOR = "Traits list";
private static final String DETAILCARDEMPTYPANEL = "Empty card";
private static final String SPLIT_PANE1 = "SPLITPANE1";
@@ -243,6 +245,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
private JTextField filterField = new MyTextField("");
private JPanel searchPanel;
private final PreviewPanel previewPanel;
private HeaderInfoPanel headerPanel;
private DumpViewPanel dumpViewPanel;
private final JPanel treePanel;
private TreePanelMode treePanelMode;
@@ -480,7 +483,10 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
displayPanel.add(previewPanel, CARDPREVIEWPANEL);
displayPanel.add(createFolderPreviewCard(), CARDFOLDERPREVIEWPANEL);
displayPanel.add(createDumpPreviewCard(), CARDDUMPVIEW);
headerPanel = new HeaderInfoPanel();
displayPanel.add(headerPanel,CARDHEADER);
displayPanel.add(new JPanel(), CARDEMPTYPANEL);
showCard(CARDEMPTYPANEL);
@@ -2244,7 +2250,10 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
previewPanel.setImageReplaceButtonVisible(false);
if (treeNode instanceof StringNode) {
if(treeNode instanceof HeaderNode) {
showCard(CARDHEADER);
headerPanel.load(((HeaderNode)treeNode).getItem().getSwf());
} else if (treeNode instanceof StringNode) {
showCard(CARDFOLDERPREVIEWPANEL);
showFolderPreview(treeNode);
} else if (treeNode instanceof SWFNode) {
@@ -59,6 +59,7 @@ import com.jpexs.decompiler.flash.timeline.Frame;
import com.jpexs.decompiler.flash.treeitems.AS2PackageNodeItem;
import com.jpexs.decompiler.flash.treeitems.AS3PackageNodeItem;
import com.jpexs.decompiler.flash.treeitems.FrameNodeItem;
import com.jpexs.decompiler.flash.treeitems.HeaderItem;
import com.jpexs.decompiler.flash.treeitems.SWFList;
import com.jpexs.decompiler.flash.treeitems.StringItem;
import com.jpexs.decompiler.flash.treeitems.TreeElementItem;
@@ -186,6 +187,11 @@ public class TagTree extends JTree implements ActionListener {
}
public static TreeNodeType getTreeNodeType(TreeItem t) {
if(t instanceof HeaderItem){
return TreeNodeType.HEADER;
}
if ((t instanceof DefineFontTag)
|| (t instanceof DefineFont2Tag)
|| (t instanceof DefineFont3Tag)
@@ -35,11 +35,13 @@ import com.jpexs.decompiler.flash.tags.base.SoundStreamHeadTypeTag;
import com.jpexs.decompiler.flash.timeline.Timeline;
import com.jpexs.decompiler.flash.timeline.Timelined;
import com.jpexs.decompiler.flash.treeitems.FrameNodeItem;
import com.jpexs.decompiler.flash.treeitems.HeaderItem;
import com.jpexs.decompiler.flash.treeitems.SWFList;
import com.jpexs.decompiler.flash.treeitems.StringItem;
import com.jpexs.decompiler.flash.treeitems.TreeElementItem;
import com.jpexs.decompiler.flash.treeitems.TreeItem;
import com.jpexs.decompiler.flash.treenodes.FrameNode;
import com.jpexs.decompiler.flash.treenodes.HeaderNode;
import com.jpexs.decompiler.flash.treenodes.TagNode;
import com.jpexs.decompiler.flash.treenodes.TreeNode;
import java.io.ByteArrayInputStream;
@@ -242,6 +244,9 @@ public class TagTreeModel implements TreeModel {
}
swfNode.scriptsNode = actionScriptNode;
ret.add(new HeaderNode(new HeaderItem(swf)));
if (!shapesNode.subNodes.isEmpty()) {
ret.add(shapesNode);
}
@@ -1,46 +1,47 @@
/*
* 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.gui;
/**
*
* @author JPEXS
*/
public enum TreeNodeType {
FLASH,
FONT,
TEXT,
IMAGE,
SHAPE,
MORPH_SHAPE,
SPRITE,
BUTTON,
AS,
PACKAGE,
FRAME,
SHOW_FRAME,
MOVIE,
SOUND,
BINARY_DATA,
OTHER_TAG,
FOLDER,
FOLDER_OPEN,
BUNDLE_ZIP,
BUNDLE_SWC,
BUNDLE_BINARY
}
/*
* 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.gui;
/**
*
* @author JPEXS
*/
public enum TreeNodeType {
FLASH,
FONT,
TEXT,
IMAGE,
SHAPE,
MORPH_SHAPE,
SPRITE,
BUTTON,
AS,
PACKAGE,
FRAME,
SHOW_FRAME,
MOVIE,
SOUND,
BINARY_DATA,
OTHER_TAG,
FOLDER,
FOLDER_OPEN,
BUNDLE_ZIP,
BUNDLE_SWC,
BUNDLE_BINARY,
HEADER
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 635 B

@@ -491,4 +491,20 @@ menu.settings.dumpView = Dump view
menu.view = View
menu.file.view.resources = Resources
menu.file.view.hex = Hex dump
menu.file.view.hex = Hex dump
node.header = header
header.signature = Signature:
header.compression = Compression:
header.compression.lzma = LZMA
header.compression.zlib = ZLIB
header.compression.none = No compression
header.version = SWF Version:
header.gfx = GFX:
header.filesize = File size:
header.framerate = Frame rate:
header.framecount = Frame count:
header.displayrect = Display rect:
header.displayrect.value.twips = %xmin%,%ymin% => %xmax%,%ymax% twips
header.displayrect.value.pixels = %xmin%,%ymin% => %xmax%,%ymax% pixels
@@ -482,4 +482,19 @@ abc.action.find-declaration = Naj\u00edt deklaraci
menu.view = Zobrazen\u00ed
menu.file.view.resources = Zdroje
menu.file.view.hex = Hex dump
menu.file.view.hex = Hex dump
node.header = hlavi\u010dka
header.signature = Signatura:
header.compression = Komprese:
header.compression.lzma = LZMA
header.compression.zlib = ZLIB
header.compression.none = Bez komprese
header.version = Verze SWF:
header.gfx = GFX:
header.filesize = Velikost souboru:
header.framerate = Frekvence sn\u00edmk\u016f:
header.framecount = Po\u010det sn\u00edmk\u016f:
header.displayrect = Zobrazen\u00fd obd\u00e9ln\u00edk:
header.displayrect.value.twips = %xmin%,%ymin% => %xmax%,%ymax% twip\u016f
header.displayrect.value.pixels = %xmin%,%ymin% => %xmax%,%ymax% pixel\u016f
@@ -0,0 +1,49 @@
/*
* 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.treeitems;
import com.jpexs.decompiler.flash.AppStrings;
import com.jpexs.decompiler.flash.SWF;
/**
*
* @author JPEXS
*/
public class HeaderItem implements TreeItem {
private SWF swf;
public HeaderItem(SWF swf) {
this.swf = swf;
}
@Override
public SWF getSwf() {
return swf;
}
@Override
public String toString() {
return AppStrings.translate("node.header");
}
}
@@ -0,0 +1,37 @@
/*
* 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.treenodes;
import com.jpexs.decompiler.flash.treeitems.HeaderItem;
/**
*
* @author JPEXS
*/
public class HeaderNode extends TreeNode {
public HeaderNode(HeaderItem item) {
super(item);
}
@Override
public HeaderItem getItem() {
return (HeaderItem) item;
}
}