From 5cb1aa885dcc8328afb415d0be8491d4dacc34ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Thu, 15 Dec 2022 23:08:54 +0100 Subject: [PATCH] Registration point enhancements --- .../flash/gui/BoundsChangeListener.java | 2 +- .../decompiler/flash/gui/ImagePanel.java | 33 ++++++++++++++---- .../decompiler/flash/gui/TransformPanel.java | 21 ++++++----- .../gui/graphics/transformregpoint16.png | Bin 591 -> 5457 bytes 4 files changed, 39 insertions(+), 17 deletions(-) diff --git a/src/com/jpexs/decompiler/flash/gui/BoundsChangeListener.java b/src/com/jpexs/decompiler/flash/gui/BoundsChangeListener.java index d041c7cbc..acb297919 100644 --- a/src/com/jpexs/decompiler/flash/gui/BoundsChangeListener.java +++ b/src/com/jpexs/decompiler/flash/gui/BoundsChangeListener.java @@ -24,5 +24,5 @@ import java.awt.geom.Rectangle2D; * @author JPEXS */ public interface BoundsChangeListener { - public void boundsChanged(Rectangle2D newBounds, Point2D registraionPoint); + public void boundsChanged(Rectangle2D newBounds, Point2D registrationPoint, RegistrationPointPosition registrationPointPosition); } diff --git a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java index ccad995aa..6fc79490b 100644 --- a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java @@ -245,6 +245,8 @@ public final class ImagePanel extends JPanel implements MediaDisplay { private boolean mutable = false; private boolean alwaysDisplay = false; + + private RegistrationPointPosition registrationPointPosition = RegistrationPointPosition.CENTER; private static Cursor loadCursor(String name, int x, int y) throws IOException { Toolkit toolkit = Toolkit.getDefaultToolkit(); @@ -265,9 +267,9 @@ public final class ImagePanel extends JPanel implements MediaDisplay { boundsChangeListeners.remove(listener); } - private void fireBoundsChange(Rectangle2D bounds, Point2D registrationPoint) { + private void fireBoundsChange(Rectangle2D bounds, Point2D registrationPoint, RegistrationPointPosition registrationPointPosition) { for (BoundsChangeListener listener:boundsChangeListeners) { - listener.boundsChanged(bounds, registrationPoint); + listener.boundsChanged(bounds, registrationPoint, registrationPointPosition); } } @@ -413,7 +415,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { transform = Matrix.getScaleInstance(1 / SWF.unitDivisor).concatenate(m).concatenate(new Matrix(ds.matrix)); Rectangle2D transformBounds = getTransformBounds(); - fireBoundsChange(transformBounds, new Point2D.Double(transformBounds.getCenterX(), transformBounds.getCenterY())); + fireBoundsChange(transformBounds, new Point2D.Double(transformBounds.getCenterX(), transformBounds.getCenterY()), registrationPointPosition); /*System.out.println("ds.matrix=" + ds.matrix); System.out.println("transform=" + transform); System.out.println("offset=" + offsetPoint); @@ -686,10 +688,13 @@ public final class ImagePanel extends JPanel implements MediaDisplay { if (freeTransformDepth > -1 && mode != Cursor.DEFAULT_CURSOR && registrationPointUpdated != null && transformUpdated != null) { synchronized (lock) { - registrationPoint = new Point2D.Double(registrationPointUpdated.getX(), registrationPointUpdated.getY()); + registrationPoint = new Point2D.Double(registrationPointUpdated.getX(), registrationPointUpdated.getY()); + if (mode == Cursor.HAND_CURSOR) { + registrationPointPosition = null; + } transform = new Matrix(transformUpdated); transformUpdated = null; - fireBoundsChange(getTransformBounds(), getTransformRegistrationPoint()); + fireBoundsChange(getTransformBounds(), getTransformRegistrationPoint(), registrationPointPosition); } repaint(); } @@ -1878,6 +1883,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { this.muted = muted; this.mutable = mutable; this.showObjectsUnderCursor = showObjectsUnderCursor; + this.registrationPointPosition = RegistrationPointPosition.CENTER; redraw(); if (autoPlay) { play(); @@ -3057,8 +3063,21 @@ public final class ImagePanel extends JPanel implements MediaDisplay { public void setRegistrationPoint(Point2D registrationPoint) { this.registrationPoint = toImageRegistrationPoint(registrationPoint); + this.registrationPointPosition = null; redraw(); - fireBoundsChange(getTransformBounds(), getTransformRegistrationPoint()); + fireBoundsChange(getTransformBounds(), getTransformRegistrationPoint(), registrationPointPosition); + } + + public void setRegistrationPointPosition(RegistrationPointPosition position) { + Rectangle2D transformBounds = getTransformBounds(); + Point2D newRegistrationPoint = new Point2D.Double( + transformBounds.getX() + transformBounds.getWidth() * position.getPositionX(), + transformBounds.getY() + transformBounds.getHeight() * position.getPositionY() + ); + this.registrationPoint = toImageRegistrationPoint(newRegistrationPoint); + this.registrationPointPosition = position; + redraw(); + fireBoundsChange(getTransformBounds(), getTransformRegistrationPoint(), position); } public void applyTransformMatrix(Matrix matrix) { @@ -3075,7 +3094,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { registrationPoint = newRegistrationPoint; redraw(); - fireBoundsChange(getTransformBounds(), getTransformRegistrationPoint()); + fireBoundsChange(getTransformBounds(), getTransformRegistrationPoint(), registrationPointPosition); } private Point2D getTransformRegistrationPoint() { diff --git a/src/com/jpexs/decompiler/flash/gui/TransformPanel.java b/src/com/jpexs/decompiler/flash/gui/TransformPanel.java index 1d1f0d540..d6a6a3aeb 100644 --- a/src/com/jpexs/decompiler/flash/gui/TransformPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/TransformPanel.java @@ -144,8 +144,8 @@ public class TransformPanel extends JPanel { imagePanel.addBoundsChangeListener(new BoundsChangeListener() { @Override - public void boundsChanged(Rectangle2D newBounds, Point2D registraionPoint) { - update(newBounds, registraionPoint); + public void boundsChanged(Rectangle2D newBounds, Point2D registraionPoint, RegistrationPointPosition registrationPointPosition) { + update(newBounds, registraionPoint, registrationPointPosition); } }); setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); @@ -384,9 +384,10 @@ public class TransformPanel extends JPanel { clearMatrixActionPerformed(null); } - private void update(Rectangle2D bounds, Point2D registraionPoint) { + private void update(Rectangle2D bounds, Point2D registraionPoint, RegistrationPointPosition registrationPointPosition) { this.bounds = bounds; this.registrationPoint = registraionPoint; + this.registrationPointPanel.setSelectedPosition(registrationPointPosition); if (!moveRelativeCheckBox.isSelected()) { moveHorizontalTextField.setText(formatDouble(convertUnit(bounds.getX(), Unit.TWIP, (Unit) moveUnitComboBox.getSelectedItem()))); moveVerticalTextField.setText(formatDouble(convertUnit(bounds.getY(), Unit.TWIP, (Unit) moveUnitComboBox.getSelectedItem()))); @@ -548,12 +549,7 @@ public class TransformPanel extends JPanel { } private void registrationPointChangedActionPerformed(ActionEvent e) { - RegistrationPointPosition position = registrationPointPanel.getSelectedPosition(); - Point2D newRegistrationPoint = new Point2D.Double( - bounds.getX() + bounds.getWidth() * position.getPositionX(), - bounds.getY() + bounds.getHeight() * position.getPositionY() - ); - imagePanel.setRegistrationPoint(newRegistrationPoint); + imagePanel.setRegistrationPointPosition(registrationPointPanel.getSelectedPosition()); } private void addJoinedRow(JPanel panel, int rownum, Component comp, int numCols) { @@ -665,6 +661,13 @@ class RegistrationPointPanel extends JPanel { public RegistrationPointPosition getSelectedPosition() { return selectedPosition; } + + public void setSelectedPosition(RegistrationPointPosition selectedPosition) { + this.selectedPosition = selectedPosition; + repaint(); + } + + public RegistrationPointPanel(ActionListener listener) { this.listener = listener; diff --git a/src/com/jpexs/decompiler/flash/gui/graphics/transformregpoint16.png b/src/com/jpexs/decompiler/flash/gui/graphics/transformregpoint16.png index cb14d7d69997e0970847e2476ec96e3a7d9d9a4f..cad1a875294cccc3eb94860d19b7c23dae51dbe3 100644 GIT binary patch literal 5457 zcmeHKdt4J&7LFo5up(7!eNc@-MTJQ+lY~4>Ku7`vi6W$cTPzHdNr;3@m>EdG7St9* z5X4$+wJNY$tzZ>vSKLw`tl|^fYQ;wdrHIyAf%<5LK4k9%#JF|s`ulDFlaOTYx!?KD zx!*nKPG)(;oRDE|+w!RN%g-6)IY5|^oqr6W-r+e#7!lNo2z z8CIN)+f4=*%l=KDy!wX&4?Nq4$K5&}m$z{G*4ES0mwun+zASr@_3$FEsMEKq56$!U9Ma)JOQ!w0=ZzCvs$aYC z%jG?k_ns@3=-PJtfIV8ZQ@!1*enF^w;poe*$3DNPsb%ey-9gGH-q!I0hZ_eUOHREb zu4w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