From b8b80ebe61df49f7a31067cfaf960a3b7dda9ccb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Fri, 16 Dec 2022 22:11:15 +0100 Subject: [PATCH] Basic transformations - flip and rotate 90 / 180 --- .../decompiler/flash/gui/TransformPanel.java | 58 +++++++++++++++++- .../flash/gui/graphics/transformbasic16.png | Bin 0 -> 597 bytes .../flash/gui/graphics/transformflipx16.png | Bin 0 -> 403 bytes .../flash/gui/graphics/transformflipy16.png | Bin 0 -> 418 bytes .../gui/graphics/transformrotate18016.png | Bin 0 -> 647 bytes .../graphics/transformrotate90anticlock16.png | Bin 0 -> 6508 bytes .../gui/graphics/transformrotate90clock16.png | Bin 0 -> 644 bytes 7 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 src/com/jpexs/decompiler/flash/gui/graphics/transformbasic16.png create mode 100644 src/com/jpexs/decompiler/flash/gui/graphics/transformflipx16.png create mode 100644 src/com/jpexs/decompiler/flash/gui/graphics/transformflipy16.png create mode 100644 src/com/jpexs/decompiler/flash/gui/graphics/transformrotate18016.png create mode 100644 src/com/jpexs/decompiler/flash/gui/graphics/transformrotate90anticlock16.png create mode 100644 src/com/jpexs/decompiler/flash/gui/graphics/transformrotate90clock16.png diff --git a/src/com/jpexs/decompiler/flash/gui/TransformPanel.java b/src/com/jpexs/decompiler/flash/gui/TransformPanel.java index f3caac957..6af797292 100644 --- a/src/com/jpexs/decompiler/flash/gui/TransformPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/TransformPanel.java @@ -55,6 +55,7 @@ import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.JToggleButton; +import javax.swing.SwingConstants; import javax.swing.SwingUtilities; import javax.swing.border.BevelBorder; @@ -163,6 +164,27 @@ public class TransformPanel extends JPanel { add(makeCard("Transformation point", "transformpoint16", registrationPointPanel)); + + JPanel basicPanel = new JPanel(new GridBagLayout()); + JButton flipHorizontallyButton = new JButton("Flip horizontally", View.getIcon("transformflipx16")); + flipHorizontallyButton.setHorizontalAlignment(SwingConstants.LEFT); + flipHorizontallyButton.addActionListener(this::flipHorizontallyActionPerformed); + JButton flipVerticallyButton = new JButton("Flip vertically", View.getIcon("transformflipy16")); + flipVerticallyButton.setHorizontalAlignment(SwingConstants.LEFT); + flipVerticallyButton.addActionListener(this::flipVerticallyActionPerformed); + JButton rotate90ClockwiseButton = new JButton("Rotate +90°", View.getIcon("transformrotate90clock16")); + rotate90ClockwiseButton.setHorizontalAlignment(SwingConstants.LEFT); + rotate90ClockwiseButton.addActionListener(this::rotate90ClockwiseActionPerformed); + JButton rotate90AntiClockwiseButton = new JButton("Rotate -90°", View.getIcon("transformrotate90anticlock16")); + rotate90AntiClockwiseButton.setHorizontalAlignment(SwingConstants.LEFT); + rotate90AntiClockwiseButton.addActionListener(this::rotate90AnticlockwiseActionPerformed); + JButton rotate180Button = new JButton("Rotate 180°", View.getIcon("transformrotate18016")); + rotate180Button.setHorizontalAlignment(SwingConstants.LEFT); + rotate180Button.addActionListener(this::rotate180ActionPerformed); + addRow(basicPanel, 0, flipHorizontallyButton, rotate90ClockwiseButton); + addRow(basicPanel, 1, flipVerticallyButton, rotate90AntiClockwiseButton, rotate180Button); + add(makeCard("Basic", "transformbasic16", basicPanel)); + JPanel movePanel = new JPanel(new GridBagLayout()); addRow(movePanel, 0, new JLabel("Horizontal:"), moveHorizontalTextField, moveUnitComboBox); addRow(movePanel, 1, new JLabel("Vertical:"), moveVerticalTextField); @@ -543,6 +565,40 @@ public class TransformPanel extends JPanel { } } + private void applyRotate(double degree) { + double rotateRad = convertUnit(degree, Unit.DEG, Unit.RAD); + Matrix matrix = new Matrix(AffineTransform.getRotateInstance(rotateRad, registrationPoint.getX(), registrationPoint.getY())); + imagePanel.applyTransformMatrix(matrix); + } + + private void rotate90ClockwiseActionPerformed(ActionEvent e) { + applyRotate(90); + } + + private void rotate90AnticlockwiseActionPerformed(ActionEvent e) { + applyRotate(-90); + } + + private void rotate180ActionPerformed(ActionEvent e) { + applyRotate(180); + } + + private void flipHorizontallyActionPerformed(ActionEvent e) { + Matrix matrix = new Matrix(); + matrix.translate(registrationPoint.getX(), registrationPoint.getY()); + matrix.scale(-1, 1); + matrix.translate(-registrationPoint.getX(), -registrationPoint.getY()); + imagePanel.applyTransformMatrix(matrix); + } + + private void flipVerticallyActionPerformed(ActionEvent e) { + Matrix matrix = new Matrix(); + matrix.translate(registrationPoint.getX(), registrationPoint.getY()); + matrix.scale(1, -1); + matrix.translate(-registrationPoint.getX(), -registrationPoint.getY()); + imagePanel.applyTransformMatrix(matrix); + } + private void registrationPointChangedActionPerformed(ActionEvent e) { imagePanel.setRegistrationPointPosition(registrationPointPanel.getSelectedPosition()); } @@ -811,5 +867,5 @@ class RegistrationPointPanel extends JPanel { g2d.draw(rects[x][y]); } } - } + } } \ No newline at end of file diff --git a/src/com/jpexs/decompiler/flash/gui/graphics/transformbasic16.png b/src/com/jpexs/decompiler/flash/gui/graphics/transformbasic16.png new file mode 100644 index 0000000000000000000000000000000000000000..00818f63635ef3b3c04260c0d8f160b19570cb62 GIT binary patch literal 597 zcmV-b0;>IqP)62!*BTExOSjY%3)*jT5svJpGKf=$3CUqKK-1RDzx8ymlZ zwS;W;-7_=ySiHB1u9f68hg;0tAIzK-5q6bH&%Yeqk1(r}i84|~$mldU469wb{r=gf zuYVfkh}abCXHiD56XS1@m(?2&*9kHq6O|^j@r%)9WR;gBSR*+^{BUiAhv zLTNl5-SWcMf`$Z#q6Tzk02$5(j=VTsw!_ijI|?3O5Ws14CO8uvli9}fO~g1=Dv?Sg z6QM+>P3O~zsHL}l?cjL#8yuEVU~n|V*x($S*`2dri>5x}hU56pjd4M7=H5jVf&jnh_YoHFW1pQh33@EE+GcT-uHR1*sID5Hzvg z6g2}hp<@K+0FD7#ACek+3k!>iLhA`|uU)j;i__)Z&Fgb3t?v-b7s4*agaQ+5 literal 0 HcmV?d00001 diff --git a/src/com/jpexs/decompiler/flash/gui/graphics/transformflipx16.png b/src/com/jpexs/decompiler/flash/gui/graphics/transformflipx16.png new file mode 100644 index 0000000000000000000000000000000000000000..8667c81f8b2ae38922a801bf8ad50ae8cfa7e7fb GIT binary patch literal 403 zcmV;E0c`$>P)+Q9Q4|H>Gx;$-G!ZQV78ZfoO&~77*3Nn$jc&kZKoCTmAc8K!LP4<=!NN2tOlc{Z zN$xqL$HGYbLH113OaYT)W33X5N`C}SuCsO{M4d)0!W1Bd zPzF|)%AK8~r}nqN@l_U#p4Mv-asy1$8wsx&u~-Jolx`n9hA#o5C(U{(u9g9#gDRe2 z!e}g*5zR(5HY)i99A1uEM(-{!M3@w(Q`3nM*_asR0^}go-P*tZD6~=(l~M=~!wKks x1gKbXqcC{MAPSU2?m_Ytz$O4h|MV~XCU1V{%3*(8NnQXpYiVPVoA5~c|!VPFV?AVO1l*q#wuVDF}{5Y`EMTa_P#5+JM* z7NrLtc5{G@^7nWG`CDHlY@FTuu<8=_lZ5psk-QoqP`Hx{VV$sN)+C(P0F{PBnQyZy zv3A)TEIq7N~!NGFz151St77tx49JDc?6PU}s zU^eqSJON>auuj<9wLVdFzOaAY#g6%o^o5I=?bdiJ&{?IkkvMg+S?VBl{)W}#Hm1{! za5rFVjj=`i=oRt2z*MRp{)mjN&{-$!O(tv6TOh1XtXGZyt1-&_0(6x6mpf9k1poj5 M07*qoM6N<$f}NJIe*gdg literal 0 HcmV?d00001 diff --git a/src/com/jpexs/decompiler/flash/gui/graphics/transformrotate18016.png b/src/com/jpexs/decompiler/flash/gui/graphics/transformrotate18016.png new file mode 100644 index 0000000000000000000000000000000000000000..6ee4b81552164056a006f36a388df388370bb114 GIT binary patch literal 647 zcmV;20(kw2P)^@RCwB)lgn!pQ543{%%s?5FuG6_ z1GYYDEU`178%v>T9^$47b>Xt$(v6@c#kAU(A_(qP`WL7hHAxLxQx{z%g4o20ii()T zG$lb7LNar2zmrZvh}MFK{BrL-kMB%w&M3a6|?c)vP6e~l=*I_^NzdU)8llxXl!HW z#ln8-wD@G8@l;KLY0?}!(2Tw>=Q7oDneIJI(enwP5o_!Ghlm|>p!=1Y6opji%-P@7 z(&~vw;{A(j0RvZ&q0LOPfTB1mOAAvdUetA6CPO|0YsN5)jmlEsIN0JkH&attMtk@8 z7K)}higj#VyTM*C(RSX=gGns!yXAd4Hh4@9y%Otf{cdzsx@wqgt1SdA4NFp@Z}( zo15?T^bM7ZKdAUIcVAmnj?#sp-oF>yb8o4N>0HSd=u0m9?Q>?~b~1c=7%yU830{wH`o>xK35oHO`l(1FJs0vFhO30) h68(qiosKmD1^_h!>J;r7xaR->002ovPDHLkV1gkHHKzao literal 0 HcmV?d00001 diff --git a/src/com/jpexs/decompiler/flash/gui/graphics/transformrotate90anticlock16.png b/src/com/jpexs/decompiler/flash/gui/graphics/transformrotate90anticlock16.png new file mode 100644 index 0000000000000000000000000000000000000000..dbcfce20e8f3f9ec2a5a7aae6c5c78423d0c41b3 GIT binary patch literal 6508 zcmeHLc|6o>+aJePwo;O`7^4l%K4#2hkRdZ=(4e$3%WuXoTQg&sipWW2X+epIibUb0 zC?pD}Izl>^CVSFwG64qX_ zQkeLBp~1%{%iakS)TUhN#InSwE19*C9X>@t4_?1?BmUvPnp(`rMty4ftT&_`vHQ+U zGiP>e^P|T}9tif)kWYib3;K#aMEu4Zgb{{ywGG+bZ%%CNGb7%azC0PNJBhMpIBxJg z?48i>fnJ%-Kzu-B2R^yfJfu%ksICYkv!_S&DbV*!Gf|kj z+iqlQN~aC5KL1w1K2k3(zw5)W6=~32QA>3rhMU%z=_jCQuum+8Pu+4Z&Ok zqieA;r(f-?2Ckv9cUM|RMmkCKSCE?8;E!794}2};Ps<-3FiF>h{^Dxvm}IMdk|sD| z_A1u&kErNL=C#lz6dj`UHM-Vhp8H_^>G^w|HO7tvBEG_YP zvNYyTz4{p^u|`rvq2$%PWZ&!n+PqcC9&c<~d~@>i@_Kts2?Ne?^t93zY3^>uvx__C zRLEcCJ&t0`wEH;0!e9pJ=2b!<$M{s$x~*n5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