From 171421a7caa00ae80d9b0664db1c4292022831cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Thu, 15 Dec 2022 06:49:10 +0100 Subject: [PATCH] Apply Move action --- .../decompiler/flash/gui/ImagePanel.java | 21 ++++++++++++++++++- .../decompiler/flash/gui/TransformPanel.java | 13 +++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java index ac91e6c5f..119748b6d 100644 --- a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java @@ -328,6 +328,19 @@ public final class ImagePanel extends JPanel implements MediaDisplay { } } + private Matrix getNewToImageMatrix(MATRIX newMatrix) { + Matrix m = new Matrix(); + double zoomDouble = zoom.fit ? getZoomToFit() : zoom.value; + if (lowQuality) { + zoomDouble /= LQ_FACTOR; + } + double zoom = zoomDouble; + m.translate(-_viewRect.xMin * zoom, -_viewRect.yMin * zoom); + m.scale(zoom); + + return Matrix.getScaleInstance(1 / SWF.unitDivisor).concatenate(m).concatenate(new Matrix(newMatrix)); + } + public MATRIX getNewMatrix() { synchronized (lock) { DepthState ds = null; @@ -3042,10 +3055,16 @@ public final class ImagePanel extends JPanel implements MediaDisplay { } public void applyTransformMatrix(Matrix matrix) { - transform = transform.preConcatenate(matrix); + Matrix m = new Matrix(getNewMatrix()); + m = m.preConcatenate(matrix); + transform = getNewToImageMatrix(m.toMATRIX()); + Point2D newRegistrationPoint = new Point2D.Double(); matrix.toTransform().transform(registrationPoint, newRegistrationPoint); registrationPoint = newRegistrationPoint; + + redraw(); + fireBoundsChange(getTransformBounds()); } private Rectangle2D getTransformBounds() { diff --git a/src/com/jpexs/decompiler/flash/gui/TransformPanel.java b/src/com/jpexs/decompiler/flash/gui/TransformPanel.java index 14c09e84d..f86058534 100644 --- a/src/com/jpexs/decompiler/flash/gui/TransformPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/TransformPanel.java @@ -367,7 +367,18 @@ public class TransformPanel extends JPanel { } private void applyMoveActionPerformed(ActionEvent e) { - //TODO + Matrix matrix = new Matrix(); + try { + double moveHorizontal = convertUnit(Double.parseDouble(moveHorizontalTextField.getText()), (Unit)moveUnitComboBox.getSelectedItem(), Unit.TWIP); + double moveVertical = convertUnit(Double.parseDouble(moveVerticalTextField.getText()), (Unit)moveUnitComboBox.getSelectedItem(), Unit.TWIP); + if (!moveRelativeCheckBox.isSelected()) { + matrix.translate(-bounds.getX(), -bounds.getY()); + } + matrix.translate(moveHorizontal, moveVertical); + imagePanel.applyTransformMatrix(matrix); + } catch (NumberFormatException nfe) { + + } } private void clearScaleActionPerformed(ActionEvent e) {