mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-30 20:11:28 +00:00
shape/sprite preview
This commit is contained in:
@@ -2233,11 +2233,7 @@ public final class SWF implements TreeItem, Timelined {
|
||||
RECT rect = displayRect;
|
||||
image = new SerializableImage((int) (rect.getWidth() / SWF.unitDivisor) + 1,
|
||||
(int) (rect.getHeight() / SWF.unitDivisor) + 1, SerializableImage.TYPE_INT_ARGB);
|
||||
//Make all pixels transparent
|
||||
Graphics2D g = (Graphics2D) image.getGraphics();
|
||||
g.setComposite(AlphaComposite.Src);
|
||||
g.setColor(new Color(0, 0, 0, 0f));
|
||||
g.fillRect(0, 0, image.getWidth(), image.getHeight());
|
||||
image.fillTransparent();
|
||||
Matrix m = new Matrix();
|
||||
m.translate(-rect.Xmin, -rect.Ymin);
|
||||
frameToImage(timeline, frame, displayRect, visited, image, m, colorTransform);
|
||||
@@ -2250,11 +2246,7 @@ public final class SWF implements TreeItem, Timelined {
|
||||
for (int f = 0; f < timeline.frames.size(); f++) {
|
||||
SerializableImage image = new SerializableImage((int) (rect.getWidth() / SWF.unitDivisor) + 1,
|
||||
(int) (rect.getHeight() / SWF.unitDivisor) + 1, SerializableImage.TYPE_INT_ARGB);
|
||||
// Make all pixels transparent
|
||||
Graphics2D g = (Graphics2D) image.getGraphics();
|
||||
g.setComposite(AlphaComposite.Src);
|
||||
g.setColor(new Color(0, 0, 0, 0f));
|
||||
g.fillRect(0, 0, image.getWidth(), image.getHeight());
|
||||
image.fillTransparent();
|
||||
Matrix m = new Matrix();
|
||||
m.translate(-rect.Xmin, -rect.Ymin);
|
||||
frameToImage(timeline, f, displayRect, visited, image, m, colorTransform);
|
||||
@@ -2343,29 +2335,26 @@ public final class SWF implements TreeItem, Timelined {
|
||||
rect.yMax += deltaYMax * SWF.unitDivisor;
|
||||
}
|
||||
|
||||
rect.xMin = Math.max(0, rect.xMin - 1);
|
||||
rect.yMin = Math.max(0, rect.yMin - 1);
|
||||
rect.xMin = Math.max(0, rect.xMin);
|
||||
rect.yMin = Math.max(0, rect.yMin);
|
||||
|
||||
int newWidth = (int) (rect.getWidth() / SWF.unitDivisor);
|
||||
int newHeight = (int) (rect.getHeight() / SWF.unitDivisor);
|
||||
int deltaX = (int) (rect.xMin / SWF.unitDivisor);
|
||||
int deltaY = (int) (rect.yMin / SWF.unitDivisor);
|
||||
newWidth = Math.min(image.getWidth() - deltaX, newWidth) + 2;
|
||||
newHeight = Math.min(image.getHeight() - deltaY, newHeight) + 2;
|
||||
newWidth = Math.min(image.getWidth() - deltaX, newWidth) + 1;
|
||||
newHeight = Math.min(image.getHeight() - deltaY, newHeight) + 1;
|
||||
|
||||
if (newWidth <= 0 || newHeight <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
img = new SerializableImage(newWidth, newHeight, SerializableImage.TYPE_INT_ARGB);
|
||||
img.fillTransparent();
|
||||
|
||||
m.translate(-rect.xMin, -rect.yMin);
|
||||
drawMatrix.translate(rect.xMin, rect.yMin);
|
||||
|
||||
//Make all pixels transparent
|
||||
Graphics2D gr = (Graphics2D) img.getGraphics();
|
||||
gr.setComposite(AlphaComposite.Src);
|
||||
gr.setColor(new Color(0, 0, 0, 0f));
|
||||
gr.fillRect(0, 0, img.getWidth(), img.getHeight());
|
||||
drawable.toImage(dframe, layer.ratio, timeline.swf.tags, timeline.characters, visited, img, m, clrTrans);
|
||||
} else if (drawable instanceof FontTag) {
|
||||
// only DefineFont tags
|
||||
|
||||
@@ -105,12 +105,9 @@ public class BitmapExporter extends ShapeExporterBase implements IShapeExporter
|
||||
double width = bounds.getWidth() / unitDivisor + 2 * (maxLineWidth + 1);
|
||||
double height = bounds.getHeight() / unitDivisor + 2 * (maxLineWidth + 1);
|
||||
image = new SerializableImage((int) width, (int) height, SerializableImage.TYPE_INT_ARGB);
|
||||
graphics = (Graphics2D) image.getGraphics();
|
||||
graphics.setComposite(AlphaComposite.Src);
|
||||
image.fillTransparent();
|
||||
|
||||
//Make all pixels transparent
|
||||
graphics.setColor(new Color(0, 0, 0, 0f));
|
||||
graphics.fillRect(0, 0, image.getWidth(), image.getHeight());
|
||||
graphics = (Graphics2D) image.getGraphics();
|
||||
|
||||
defaultStroke = graphics.getStroke();
|
||||
super.export();
|
||||
|
||||
@@ -143,11 +143,7 @@ public final class ImagePanel extends JPanel implements ActionListener, FlashDis
|
||||
RECT rect = bounded.getRect(characters, new Stack<Integer>());
|
||||
SerializableImage image = new SerializableImage((int) (rect.getWidth() / SWF.unitDivisor) + 1,
|
||||
(int) (rect.getHeight() / SWF.unitDivisor) + 1, SerializableImage.TYPE_INT_ARGB);
|
||||
//Make all pixels transparent
|
||||
Graphics2D g = (Graphics2D) image.getGraphics();
|
||||
g.setComposite(AlphaComposite.Src);
|
||||
g.setColor(new Color(0, 0, 0, 0f));
|
||||
g.fillRect(0, 0, image.getWidth(), image.getHeight());
|
||||
image.fillTransparent();
|
||||
Matrix m = new Matrix();
|
||||
m.translate(-rect.Xmin, -rect.Ymin);
|
||||
drawable.toImage(0, 0, swf.tags, characters, new Stack<Integer>(), image, m, new ColorTransform());
|
||||
@@ -225,11 +221,7 @@ public final class ImagePanel extends JPanel implements ActionListener, FlashDis
|
||||
}
|
||||
SerializableImage image = new SerializableImage((int) (rect.getWidth() / SWF.unitDivisor) + 1,
|
||||
(int) (rect.getHeight() / SWF.unitDivisor) + 1, SerializableImage.TYPE_INT_ARGB);
|
||||
//Make all pixels transparent
|
||||
Graphics2D g = (Graphics2D) image.getGraphics();
|
||||
g.setComposite(AlphaComposite.Src);
|
||||
g.setColor(new Color(0, 0, 0, 0f));
|
||||
g.fillRect(0, 0, image.getWidth(), image.getHeight());
|
||||
image.fillTransparent();
|
||||
Matrix m = new Matrix();
|
||||
m.translate(-rect.Xmin, -rect.Ymin);
|
||||
drawable.toImage(frame, frame, swf.tags, characters, new Stack<Integer>(), image, m, new ColorTransform());
|
||||
|
||||
@@ -41,6 +41,7 @@ import com.jpexs.decompiler.flash.gui.player.PlayerControls;
|
||||
import com.jpexs.decompiler.flash.gui.timeline.TimelineFrame;
|
||||
import com.jpexs.decompiler.flash.gui.treenodes.SWFBundleNode;
|
||||
import com.jpexs.decompiler.flash.gui.treenodes.SWFNode;
|
||||
import com.jpexs.decompiler.flash.gui.treenodes.StringNode;
|
||||
import com.jpexs.decompiler.flash.helpers.Freed;
|
||||
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag;
|
||||
@@ -82,6 +83,7 @@ import com.jpexs.decompiler.flash.tags.VideoFrameTag;
|
||||
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.ButtonTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.Container;
|
||||
import com.jpexs.decompiler.flash.tags.base.ContainerItem;
|
||||
@@ -89,13 +91,16 @@ 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.MissingCharacterHandler;
|
||||
import com.jpexs.decompiler.flash.tags.base.MorphShapeTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.ShapeTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.SoundStreamHeadTypeTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.TextTag;
|
||||
import com.jpexs.decompiler.flash.tags.gfx.DefineCompactedFont;
|
||||
import com.jpexs.decompiler.flash.tags.text.ParseException;
|
||||
import com.jpexs.decompiler.flash.timeline.Timeline;
|
||||
import com.jpexs.decompiler.flash.treeitems.FrameNodeItem;
|
||||
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.TagNode;
|
||||
@@ -214,6 +219,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
private ImagePanel imagePanel;
|
||||
private BinaryPanel binaryPanel;
|
||||
private GenericTagPanel genericTagPanel;
|
||||
private JPanel folderPreviewPanel;
|
||||
private final ImagePanel previewImagePanel;
|
||||
private final SWFPreviewPanel swfPreviewPanel;
|
||||
private boolean isWelcomeScreen = true;
|
||||
@@ -223,6 +229,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
private static final String CARDIMAGEPANEL = "Image card";
|
||||
private static final String CARDBINARYPANEL = "Binary card";
|
||||
private static final String CARDGENEICTAGPANEL = "Generic tag card";
|
||||
private static final String CARDFOLDERPREVIEWPANEL = "Folder preview card";
|
||||
private static final String CARDEMPTYPANEL = "Empty card";
|
||||
private static final String CARDACTIONSCRIPTPANEL = "ActionScript card";
|
||||
private static final String CARDACTIONSCRIPT3PANEL = "ActionScript3 card";
|
||||
@@ -526,12 +533,19 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
genericButtonsPanel.add(genericEditButton);
|
||||
genericButtonsPanel.add(genericSaveButton);
|
||||
genericButtonsPanel.add(genericCancelButton);
|
||||
// todo: honfika: temporary hide edit button
|
||||
genericTagCard.add(genericButtonsPanel, BorderLayout.SOUTH);
|
||||
|
||||
return genericTagCard;
|
||||
}
|
||||
|
||||
private JPanel createFolderPreviewCard() {
|
||||
JPanel folderPreviewCard = new JPanel(new BorderLayout());
|
||||
folderPreviewPanel = new JPanel();
|
||||
folderPreviewCard.add(folderPreviewPanel, BorderLayout.CENTER);
|
||||
|
||||
return folderPreviewCard;
|
||||
}
|
||||
|
||||
private void showHideImageReplaceButton(boolean show) {
|
||||
imageReplaceButton.setVisible(show);
|
||||
setImageButtonPanelVisibility();
|
||||
@@ -774,6 +788,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
displayPanel.add(createImagesCard(), CARDIMAGEPANEL);
|
||||
displayPanel.add(createBinaryCard(), CARDBINARYPANEL);
|
||||
displayPanel.add(createGenericTagCard(), CARDGENEICTAGPANEL);
|
||||
displayPanel.add(createFolderPreviewCard(), CARDFOLDERPREVIEWPANEL);
|
||||
|
||||
JPanel shapesCard = new JPanel(new BorderLayout());
|
||||
|
||||
@@ -2398,7 +2413,12 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
showDetail(DETAILCARDEMPTYPANEL);
|
||||
}
|
||||
|
||||
if (treeNode instanceof SWFNode) {
|
||||
if (treeNode instanceof StringNode) {
|
||||
StringNode stringNode = (StringNode) treeNode;
|
||||
StringItem item = stringNode.getItem();
|
||||
showCard(CARDFOLDERPREVIEWPANEL);
|
||||
showFolderPreview(item.getSwf(), item.getName());
|
||||
} else if (treeNode instanceof SWFNode) {
|
||||
SWFNode swfNode = (SWFNode) treeNode;
|
||||
SWF swf = swfNode.getItem();
|
||||
if (mainMenu.isInternalFlashViewerSelected()) {
|
||||
@@ -2452,13 +2472,13 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
showCard(CARDDRAWPREVIEWPANEL);
|
||||
previewImagePanel.setDrawable((DrawableTag) tag, tag.getSwf(), tag.getSwf().characters, 50/*FIXME*/);
|
||||
} else if ((tagObj instanceof FontTag) && (mainMenu.isInternalFlashViewerSelected())) {
|
||||
Tag tag = (Tag) tagObj;
|
||||
FontTag fontTag = (FontTag) tagObj;
|
||||
showCard(CARDFLASHPANEL);
|
||||
showFontTag((FontTag) tagObj);
|
||||
showFontTag(fontTag);
|
||||
} else if ((tagObj instanceof TextTag) && (mainMenu.isInternalFlashViewerSelected())) {
|
||||
Tag tag = (Tag) tagObj;
|
||||
TextTag textTag = (TextTag) tagObj;
|
||||
showCard(CARDFLASHPANEL);
|
||||
showTextTag((TextTag) tagObj);
|
||||
showTextTag(textTag);
|
||||
} else if (tagObj instanceof FrameNodeItem && ((FrameNodeItem) tagObj).isDisplayed() && (mainMenu.isInternalFlashViewerSelected())) {
|
||||
showCard(CARDDRAWPREVIEWPANEL);
|
||||
FrameNodeItem fn = (FrameNodeItem) tagObj;
|
||||
@@ -2908,6 +2928,96 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
textValue.setCaretPosition(0);
|
||||
}
|
||||
|
||||
private void showFolderPreview(SWF swf, String folderName) {
|
||||
folderPreviewPanel.removeAll();
|
||||
JPanel panel = folderPreviewPanel;
|
||||
//folderPreviewPanel.add(new JScrollPane(panel), BorderLayout.CENTER);
|
||||
switch (folderName) {
|
||||
case TagTreeModel.FOLDER_SHAPES:
|
||||
for (Tag tag : swf.tags) {
|
||||
if (tag instanceof ShapeTag) {
|
||||
Component c = PreviewImage.createFolderPreviewImage(tag);
|
||||
if (c != null) {
|
||||
panel.add(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TagTreeModel.FOLDER_MORPHSHAPES:
|
||||
for (Tag tag : swf.tags) {
|
||||
if (tag instanceof MorphShapeTag) {
|
||||
Component c = PreviewImage.createFolderPreviewImage(tag);
|
||||
if (c != null) {
|
||||
panel.add(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TagTreeModel.FOLDER_SPRITES:
|
||||
for (Tag tag : swf.tags) {
|
||||
if (tag instanceof DefineSpriteTag) {
|
||||
Component c = PreviewImage.createFolderPreviewImage(tag);
|
||||
if (c != null) {
|
||||
panel.add(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TagTreeModel.FOLDER_BUTTONS:
|
||||
for (Tag tag : swf.tags) {
|
||||
if (tag instanceof ButtonTag) {
|
||||
Component c = PreviewImage.createFolderPreviewImage(tag);
|
||||
if (c != null) {
|
||||
panel.add(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
/*case TagTreeModel.FOLDER_FONTS:
|
||||
for (Tag tag : swf.tags) {
|
||||
if (tag instanceof FontTag) {
|
||||
Component c = PreviewImage.createFolderPreviewImage(tag);
|
||||
if (c != null) {
|
||||
panel.add(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;*/
|
||||
/*case TagTreeModel.FOLDER_FRAMES:
|
||||
for (Tag tag : swf.tags) {
|
||||
if (tag instanceof FrameTag) {
|
||||
Component c = PreviewImage.createFolderPreviewImage(tag);
|
||||
if (c != null) {
|
||||
panel.add(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;*/
|
||||
/*case TagTreeModel.FOLDER_IMAGES:
|
||||
for (Tag tag : swf.tags) {
|
||||
if (tag instanceof ImageTag) {
|
||||
Component c = PreviewImage.createFolderPreviewImage(tag);
|
||||
if (c != null) {
|
||||
panel.add(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;*/
|
||||
case TagTreeModel.FOLDER_TEXTS:
|
||||
for (Tag tag : swf.tags) {
|
||||
if (tag instanceof TextTag) {
|
||||
Component c = PreviewImage.createFolderPreviewImage(tag);
|
||||
if (c != null) {
|
||||
panel.add(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
panel.revalidate();
|
||||
panel.repaint();
|
||||
}
|
||||
|
||||
public void expandSwfNodes() {
|
||||
TreeModel model = tagTree.getModel();
|
||||
Object node = model.getRoot();
|
||||
|
||||
127
trunk/src/com/jpexs/decompiler/flash/gui/PreviewImage.java
Normal file
127
trunk/src/com/jpexs/decompiler/flash/gui/PreviewImage.java
Normal file
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.exporters.Matrix;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.DrawableTag;
|
||||
import com.jpexs.decompiler.flash.types.ColorTransform;
|
||||
import com.jpexs.decompiler.flash.types.RECT;
|
||||
import com.jpexs.helpers.SerializableImage;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Image;
|
||||
import java.util.Stack;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class PreviewImage extends JPanel {
|
||||
|
||||
private static ExecutorService executor = Executors.newFixedThreadPool(1);
|
||||
private static final int PREVIEW_SIZE = 100;
|
||||
private Image image;
|
||||
private boolean rendering;
|
||||
private Tag tag;
|
||||
|
||||
public PreviewImage(Tag tag) {
|
||||
this.tag = tag;
|
||||
Dimension dim = new Dimension(PREVIEW_SIZE, PREVIEW_SIZE);
|
||||
setMinimumSize(dim);
|
||||
setMaximumSize(dim);
|
||||
setPreferredSize(dim);
|
||||
setSize(PREVIEW_SIZE, PREVIEW_SIZE);
|
||||
setLayout(null);
|
||||
setBorder(BorderFactory.createLineBorder(Color.black));
|
||||
}
|
||||
|
||||
private synchronized void renderImageTask(final Tag tag) {
|
||||
if (rendering) {
|
||||
return;
|
||||
}
|
||||
rendering = true;
|
||||
executor.submit(new Callable<Void>() {
|
||||
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
image = renderImage(tag.getSwf(), tag);
|
||||
View.execInEventDispatch(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Component parent = getParent();
|
||||
if (parent != null) {
|
||||
parent.repaint();
|
||||
}
|
||||
}
|
||||
});
|
||||
return null;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private Image renderImage(SWF swf, Tag tag) {
|
||||
BoundedTag boundedTag = (BoundedTag) tag;
|
||||
RECT rect = boundedTag.getRect(swf.characters, new Stack<Integer>());
|
||||
Matrix m = new Matrix();
|
||||
double scale = 1;
|
||||
if (rect.getWidth() > PREVIEW_SIZE * SWF.unitDivisor) {
|
||||
scale = PREVIEW_SIZE * SWF.unitDivisor / rect.getWidth();
|
||||
}
|
||||
if (rect.getHeight() > PREVIEW_SIZE * SWF.unitDivisor) {
|
||||
scale = Math.min(scale, PREVIEW_SIZE * SWF.unitDivisor / rect.getHeight());
|
||||
}
|
||||
m.translate(-rect.Xmin, -rect.Ymin);
|
||||
m = m.preConcatenate(Matrix.getScaleInstance(scale));
|
||||
int width = (int) (scale * rect.getWidth() / SWF.unitDivisor);
|
||||
int height = (int) (scale * rect.getHeight() / SWF.unitDivisor);
|
||||
if (width == 0 || height == 0) {
|
||||
return null;
|
||||
}
|
||||
SerializableImage image = new SerializableImage(width, height, SerializableImage.TYPE_INT_ARGB);
|
||||
image.fillTransparent();
|
||||
DrawableTag drawable = (DrawableTag) tag;
|
||||
drawable.toImage(0, 0, swf.tags, swf.characters, new Stack<Integer>(), image, m, new ColorTransform());
|
||||
return image.getBufferedImage();
|
||||
}
|
||||
|
||||
public static PreviewImage createFolderPreviewImage(Tag tag) {
|
||||
PreviewImage imagePanel = new PreviewImage(tag);
|
||||
return imagePanel;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
if (image != null) {
|
||||
g.drawImage(image, 0, 0, null);
|
||||
} else {
|
||||
renderImageTask(tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -47,6 +47,19 @@ import javax.swing.tree.TreePath;
|
||||
|
||||
public class TagTreeModel implements TreeModel {
|
||||
|
||||
public static final String FOLDER_TEXTS = "texts";
|
||||
public static final String FOLDER_IMAGES = "images";
|
||||
public static final String FOLDER_MOVIES = "movies";
|
||||
public static final String FOLDER_SOUNDS = "sounds";
|
||||
public static final String FOLDER_BINARY_DATA = "binaryData";
|
||||
public static final String FOLDER_FONTS = "fonts";
|
||||
public static final String FOLDER_SPRITES = "sprites";
|
||||
public static final String FOLDER_SHAPES = "shapes";
|
||||
public static final String FOLDER_MORPHSHAPES = "morphshapes";
|
||||
public static final String FOLDER_BUTTONS = "buttons";
|
||||
public static final String FOLDER_FRAMES = "frames";
|
||||
public static final String FOLDER_OTHERS = "others";
|
||||
public static final String FOLDER_SCRIPTS = "scripts";
|
||||
private final TagTreeRoot root = new TagTreeRoot();
|
||||
private final List<SWFContainerNode> swfs;
|
||||
private final Map<SWF, SWFNode> swfToSwfNode;
|
||||
@@ -165,47 +178,47 @@ public class TagTreeModel implements TreeModel {
|
||||
n.subNodes = createSubTagList(((DefineSpriteTag) n.getItem()).subTags, tag, swf, actionScriptTags);
|
||||
}
|
||||
|
||||
StringNode textsNode = new StringNode(new StringItem(translate("node.texts"), swf));
|
||||
StringNode textsNode = new StringNode(new StringItem(translate("node.texts"), FOLDER_TEXTS, swf));
|
||||
textsNode.subNodes.addAll(texts);
|
||||
|
||||
StringNode imagesNode = new StringNode(new StringItem(translate("node.images"), swf));
|
||||
StringNode imagesNode = new StringNode(new StringItem(translate("node.images"), FOLDER_IMAGES, swf));
|
||||
imagesNode.subNodes.addAll(images);
|
||||
|
||||
StringNode moviesNode = new StringNode(new StringItem(translate("node.movies"), swf));
|
||||
StringNode moviesNode = new StringNode(new StringItem(translate("node.movies"), FOLDER_MOVIES, swf));
|
||||
moviesNode.subNodes.addAll(movies);
|
||||
|
||||
StringNode soundsNode = new StringNode(new StringItem(translate("node.sounds"), swf));
|
||||
StringNode soundsNode = new StringNode(new StringItem(translate("node.sounds"), FOLDER_SOUNDS, swf));
|
||||
soundsNode.subNodes.addAll(sounds);
|
||||
|
||||
StringNode binaryDataNode = new StringNode(new StringItem(translate("node.binaryData"), swf));
|
||||
StringNode binaryDataNode = new StringNode(new StringItem(translate("node.binaryData"), FOLDER_BINARY_DATA, swf));
|
||||
binaryDataNode.subNodes.addAll(binaryData);
|
||||
|
||||
StringNode fontsNode = new StringNode(new StringItem(translate("node.fonts"), swf));
|
||||
StringNode fontsNode = new StringNode(new StringItem(translate("node.fonts"), FOLDER_FONTS, swf));
|
||||
fontsNode.subNodes.addAll(fonts);
|
||||
|
||||
StringNode spritesNode = new StringNode(new StringItem(translate("node.sprites"), swf));
|
||||
StringNode spritesNode = new StringNode(new StringItem(translate("node.sprites"), FOLDER_SPRITES, swf));
|
||||
spritesNode.subNodes.addAll(sprites);
|
||||
|
||||
StringNode shapesNode = new StringNode(new StringItem(translate("node.shapes"), swf));
|
||||
StringNode shapesNode = new StringNode(new StringItem(translate("node.shapes"), FOLDER_SHAPES, swf));
|
||||
shapesNode.subNodes.addAll(shapes);
|
||||
|
||||
StringNode morphShapesNode = new StringNode(new StringItem(translate("node.morphshapes"), swf));
|
||||
StringNode morphShapesNode = new StringNode(new StringItem(translate("node.morphshapes"), FOLDER_MORPHSHAPES, swf));
|
||||
morphShapesNode.subNodes.addAll(morphShapes);
|
||||
|
||||
StringNode buttonsNode = new StringNode(new StringItem(translate("node.buttons"), swf));
|
||||
StringNode buttonsNode = new StringNode(new StringItem(translate("node.buttons"), FOLDER_BUTTONS, swf));
|
||||
buttonsNode.subNodes.addAll(buttons);
|
||||
|
||||
StringNode framesNode = new StringNode(new StringItem(translate("node.frames"), swf));
|
||||
StringNode framesNode = new StringNode(new StringItem(translate("node.frames"), FOLDER_FRAMES, swf));
|
||||
framesNode.subNodes.addAll(frames);
|
||||
|
||||
StringNode otherNode = new StringNode(new StringItem(translate("node.others"), swf));
|
||||
StringNode otherNode = new StringNode(new StringItem(translate("node.others"), FOLDER_OTHERS, swf));
|
||||
otherNode.subNodes.addAll(others);
|
||||
|
||||
TreeNode actionScriptNode;
|
||||
if (hasAbc) {
|
||||
actionScriptNode = new ClassesListNode(classTreeModel);
|
||||
} else {
|
||||
actionScriptNode = new StringNode(new StringItem(translate("node.scripts"), swf));
|
||||
actionScriptNode = new StringNode(new StringItem(translate("node.scripts"), FOLDER_SCRIPTS, swf));
|
||||
actionScriptNode.subNodes.addAll(actionScript);
|
||||
}
|
||||
swfNode.scriptsNode = actionScriptNode;
|
||||
@@ -278,7 +291,7 @@ public class TagTreeModel implements TreeModel {
|
||||
ret.addAll(frames);
|
||||
|
||||
if (!others.isEmpty()) {
|
||||
StringNode otherNode = new StringNode(new StringItem(translate("node.others"), swf));
|
||||
StringNode otherNode = new StringNode(new StringItem(translate("node.others"), FOLDER_OTHERS, swf));
|
||||
otherNode.subNodes.addAll(others);
|
||||
ret.add(otherNode);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,6 @@ import com.jpexs.decompiler.flash.treenodes.TreeNode;
|
||||
public class TagTreeRoot extends TreeNode {
|
||||
|
||||
public TagTreeRoot() {
|
||||
super(new StringItem("root", null));
|
||||
super(new StringItem("root", "root", null));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,7 +306,9 @@ public class DefineEditTextTag extends TextTag {
|
||||
addCharacters(ret, txt, style);
|
||||
}
|
||||
};
|
||||
str = "<root>" + str + "</root>";
|
||||
str = "<!DOCTYPE html [\n" +
|
||||
" <!ENTITY nbsp \" \"> \n" +
|
||||
"]><root>" + str + "</root>";
|
||||
saxParser.parse(new ByteArrayInputStream(str.getBytes(Utf8Helper.charset)), handler);
|
||||
} catch (ParserConfigurationException | SAXException | IOException ex) {
|
||||
Logger.getLogger(DefineEditTextTag.class.getName()).log(Level.SEVERE, null, ex);
|
||||
|
||||
@@ -26,10 +26,16 @@ public class StringItem implements TreeItem {
|
||||
|
||||
public SWF swf;
|
||||
private final String str;
|
||||
private final String name;
|
||||
|
||||
public StringItem(String str, SWF swf) {
|
||||
public StringItem(String str, String name, SWF swf) {
|
||||
this.swf = swf;
|
||||
this.str = str;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -128,11 +128,7 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters, Seriali
|
||||
public static SerializableImage shapeListToImage(SWF swf, List<SHAPE> shapes, int prevWidth, int prevHeight, Color color, ColorTransform colorTransform) {
|
||||
if (shapes.isEmpty()) {
|
||||
SerializableImage image = new SerializableImage(1, 1, BufferedImage.TYPE_INT_RGB);
|
||||
//Make all pixels transparent
|
||||
Graphics2D g = (Graphics2D) image.getGraphics();
|
||||
g.setComposite(AlphaComposite.Src);
|
||||
g.setColor(new Color(0, 0, 0, 0f));
|
||||
g.fillRect(0, 0, image.getWidth(), image.getHeight());
|
||||
image.fillTransparent();
|
||||
return image;
|
||||
}
|
||||
SerializableImage ret = new SerializableImage(prevWidth, prevHeight, SerializableImage.TYPE_INT_ARGB);
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
*/
|
||||
package com.jpexs.helpers;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
@@ -23,6 +25,7 @@ import java.awt.image.BufferedImage;
|
||||
import java.awt.image.ColorModel;
|
||||
import java.awt.image.IndexColorModel;
|
||||
import java.awt.image.WritableRaster;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
@@ -72,6 +75,14 @@ public class SerializableImage implements Serializable {
|
||||
return image;
|
||||
}
|
||||
|
||||
public void fillTransparent() {
|
||||
// Make all pixels transparent
|
||||
Graphics2D g = (Graphics2D) getGraphics();
|
||||
g.setComposite(AlphaComposite.Src);
|
||||
g.setColor(new Color(0, 0, 0, 0f));
|
||||
g.fillRect(0, 0, getWidth(), getHeight());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object clone() throws CloneNotSupportedException {
|
||||
SerializableImage retImage = new SerializableImage();
|
||||
|
||||
Reference in New Issue
Block a user