tag bounds fixed

This commit is contained in:
2015-01-31 16:58:17 +01:00
parent a805e70820
commit 1f09953178
28 changed files with 167 additions and 93 deletions
@@ -42,7 +42,6 @@ import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
@@ -289,7 +288,7 @@ public class FolderPreviewPanel extends JPanel {
height = imgSrc.getHeight();
} else if (treeItem instanceof BoundedTag) {
BoundedTag boundedTag = (BoundedTag) treeItem;
RECT rect = boundedTag.getRect(new HashSet<BoundedTag>());
RECT rect = boundedTag.getRect();
width = (int) (rect.getWidth() / SWF.unitDivisor) + 1;
height = (int) (rect.getHeight() / SWF.unitDivisor) + 1;
m.translate(-rect.Xmin, -rect.Ymin);
@@ -57,7 +57,6 @@ import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
@@ -253,7 +252,7 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis
Timeline tim = ((Timelined) timelined).getTimeline();
BoundedTag bounded = (BoundedTag) timelined;
RECT rect = bounded.getRect(new HashSet<BoundedTag>());
RECT rect = bounded.getRect();
int width = rect.getWidth();
double scale = 1.0;
/*if (width > swf.displayRect.getWidth()) {
@@ -464,7 +463,7 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis
@Override
public synchronized double getZoomToFit() {
if (timelined instanceof BoundedTag) {
RECT bounds = ((BoundedTag) timelined).getRect(new HashSet<BoundedTag>());
RECT bounds = ((BoundedTag) timelined).getRect();
double w1 = bounds.getWidth() / SWF.unitDivisor;
double h1 = bounds.getHeight() / SWF.unitDivisor;
@@ -577,7 +576,7 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis
double zoomDouble = zoom.fit ? getZoomToFit() : zoom.value;
RECT rect = textTag.getRect(new HashSet<BoundedTag>());
RECT rect = textTag.getRect();
int width = (int) (rect.getWidth() * zoomDouble);
int height = (int) (rect.getHeight() * zoomDouble);
SerializableImage image = new SerializableImage((int) (width / SWF.unitDivisor) + 1,
@@ -668,7 +667,7 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis
if (img == null) {
if (drawable instanceof BoundedTag) {
BoundedTag bounded = (BoundedTag) drawable;
RECT rect = bounded.getRect(new HashSet<BoundedTag>());
RECT rect = bounded.getRect();
if (rect == null) { //??? Why?
rect = new RECT(0, 0, 1, 1);
}
@@ -2502,7 +2502,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
DefineSpriteTag parentSprite = (DefineSpriteTag) fn.timeline.timelined;
controlTags = parentSprite.subTags;
containerId = parentSprite.spriteId;
rect = parentSprite.getRect(new HashSet<BoundedTag>());
rect = parentSprite.getRect();
totalFrameCount = parentSprite.frameCount;
timelined = parentSprite;
}
@@ -2650,7 +2650,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
if (tim != null) {
return tim;
}
tim = new Timeline(tag.getSwf(), null, new ArrayList<Tag>(), ((CharacterTag) tag).getCharacterId(), getRect(new HashSet<BoundedTag>()));
tim = new Timeline(tag.getSwf(), null, new ArrayList<Tag>(), ((CharacterTag) tag).getCharacterId(), getRect());
if (tag instanceof MorphShapeTag) {
tim.frameRate = MORPH_SHAPE_ANIMATION_FRAME_RATE;
int framesCnt = tim.frameRate * MORPH_SHAPE_ANIMATION_LENGTH;
@@ -2682,10 +2682,15 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
f.layers.put(1, ds);
tim.getFrames().add(f);
}
tim.displayRect = getRect(new HashSet<BoundedTag>());
tim.displayRect = getRect();
return tim;
}
@Override
public RECT getRect() {
return getRect(new HashSet<BoundedTag>());
}
@Override
public RECT getRect(Set<BoundedTag> added) {
BoundedTag bt = (BoundedTag) tag;
@@ -631,7 +631,7 @@ public class PreviewPanel extends JSplitPane implements ActionListener {
}
mat = Helper.deepCopy(mat);
if (parent instanceof BoundedTag) {
RECT r = ((BoundedTag) parent).getRect(new HashSet<BoundedTag>());
RECT r = ((BoundedTag) parent).getRect();
mat.translateX = mat.translateX + width / 2 - r.getWidth() / 2;
mat.translateY = mat.translateY + height / 2 - r.getHeight() / 2;
} else {
@@ -680,7 +680,7 @@ public class PreviewPanel extends JSplitPane implements ActionListener {
mat.translateX = 0;
mat.translateY = 0;
if (tagObj instanceof BoundedTag) {
RECT r = ((BoundedTag) tagObj).getRect(new HashSet<BoundedTag>());
RECT r = ((BoundedTag) tagObj).getRect();
mat.translateX = -r.Xmin;
mat.translateY = -r.Ymin;
mat.translateX = mat.translateX + width / 2 - r.getWidth() / 2;