|
18 | 18 | **/ |
19 | 19 | package com.t_oster.visicut.gui; |
20 | 20 |
|
| 21 | +import com.t_oster.liblasercut.LaserJob; |
| 22 | +import com.t_oster.liblasercut.VectorPart; |
21 | 23 | import com.t_oster.visicut.VisicutModel; |
22 | 24 | import com.t_oster.visicut.gui.beans.EditRectangle; |
23 | 25 | import com.t_oster.visicut.gui.beans.EditRectangle.Button; |
@@ -82,6 +84,7 @@ public class PreviewPanelKeyboardMouseHandler extends EditRectangleController im |
82 | 84 | private JMenuItem startPointSetMenuItem; |
83 | 85 | private JMenuItem startPointRemoveMenuItem; |
84 | 86 | private JMenuItem selectScreenshotMenuItem; |
| 87 | + private JMenuItem moveToPositionMenuItem; |
85 | 88 |
|
86 | 89 | public PreviewPanelKeyboardMouseHandler(PreviewPanel panel) |
87 | 90 | { |
@@ -109,6 +112,8 @@ private void buildMenu() |
109 | 112 | startPointSetMenuItem = new JMenuItem(bundle.getString("ADD_STARTPOINT")); |
110 | 113 | startPointRemoveMenuItem = new JMenuItem(bundle.getString("REMOVE_STARTPOINT")); |
111 | 114 | selectScreenshotMenuItem = new JMenuItem(bundle.getString("SELECT_SCREENSHOT")); |
| 115 | + //TODO: i10n |
| 116 | + moveToPositionMenuItem = new JMenuItem("MOVE TO POSITION"); |
112 | 117 |
|
113 | 118 | resetMenuItem.addActionListener(new ActionListener() |
114 | 119 | { |
@@ -274,6 +279,25 @@ public void actionPerformed(ActionEvent ae) |
274 | 279 | } |
275 | 280 | }); |
276 | 281 | backgroundMenu.add(selectScreenshotMenuItem); |
| 282 | + moveToPositionMenuItem.addActionListener(new ActionListener(){ |
| 283 | + |
| 284 | + public void actionPerformed(ActionEvent ae) |
| 285 | + { |
| 286 | + try |
| 287 | + { |
| 288 | + PreviewPanelKeyboardMouseHandler that = PreviewPanelKeyboardMouseHandler.this; |
| 289 | + Point2D.Double p = new Point2D.Double(that.lastMousePosition.x, that.lastMousePosition.y); |
| 290 | + that.previewPanel.getMmToPxTransform().createInverse().transform(p, p); |
| 291 | + VisicutModel.getInstance().moveHeadTo(p); |
| 292 | + } |
| 293 | + catch (NoninvertibleTransformException ex) |
| 294 | + { |
| 295 | + Logger.getLogger(PreviewPanelKeyboardMouseHandler.class.getName()).log(Level.SEVERE, null, ex); |
| 296 | + } |
| 297 | + } |
| 298 | + |
| 299 | + }); |
| 300 | + backgroundMenu.add(moveToPositionMenuItem); |
277 | 301 | } |
278 | 302 |
|
279 | 303 | private void flip(boolean horizontal) |
@@ -563,7 +587,7 @@ public void mouseClicked(MouseEvent me) |
563 | 587 | } |
564 | 588 | else if (me.getButton() == MouseEvent.BUTTON3) |
565 | 589 | { |
566 | | - if (getEditRect() != null) |
| 590 | + if (this.previewPanel.isHighlightSelection() && getEditRect() != null) |
567 | 591 | { |
568 | 592 | Rectangle2D bb = getSelectedPart().getBoundingBox(); |
569 | 593 | Rectangle2D e = Helper.transform(bb, this.previewPanel.getMmToPxTransform()); |
|
0 commit comments