From f4ae40ab6d1f33df754d585516caa829ee6030d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Thu, 15 Dec 2022 23:34:36 +0100 Subject: [PATCH] Reseting registration point --- .../decompiler/flash/gui/ImagePanel.java | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java index 6fc79490b..d4bb12baf 100644 --- a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java @@ -688,12 +688,30 @@ 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()); - if (mode == Cursor.HAND_CURSOR) { - registrationPointPosition = null; - } + Rectangle2D transBoundsBefore = getTransformBounds(); + Point2D transRegPointBefore = getTransformRegistrationPoint(); + Point transRegPointBeforeTwip = new Point((int)Math.round(transRegPointBefore.getX() - transBoundsBefore.getX()), (int)Math.round(transRegPointBefore.getY()-transBoundsBefore.getY())); + Point2D transRegPointPercentBefore = new Point2D.Double(transRegPointBeforeTwip.getX() / transBoundsBefore.getWidth(), transRegPointBeforeTwip.getY() / transBoundsBefore.getHeight()); + registrationPoint = new Point2D.Double(registrationPointUpdated.getX(), registrationPointUpdated.getY()); + //System.out.println("transRegPointPercentBefore = "+transRegPointPercentBefore); + transform = new Matrix(transformUpdated); transformUpdated = null; + calcRect(); + + Rectangle2D transBoundsAfter = getTransformBounds(); + Point2D transRegPointAfter = getTransformRegistrationPoint(); + Point transRegPointAfterTwip = new Point((int)Math.round(transRegPointAfter.getX() - transBoundsAfter.getX()), (int)Math.round(transRegPointAfter.getY() - transBoundsAfter.getY())); + Point2D transRegPointPercentAfter = new Point2D.Double(transRegPointAfterTwip.getX() / transBoundsAfter.getWidth(), transRegPointAfterTwip.getY() / transBoundsAfter.getHeight()); + + //System.out.println("transRegPointPercentAfter = "+transRegPointPercentAfter); + + //TODO: Calculate registrationPoint precisely + if (!transRegPointPercentBefore.equals(transRegPointPercentAfter)) { + registrationPointPosition = null; + //System.out.println("set null"); + } + fireBoundsChange(getTransformBounds(), getTransformRegistrationPoint(), registrationPointPosition); } repaint();