add meta for zoom shortcuts

This commit is contained in:
bancika
2020-09-18 21:24:04 +02:00
parent 9372858596
commit 7a5a6a469d
@@ -141,10 +141,18 @@ public class CanvasPanel extends JComponent implements Autoscroll {
.put(KeyStroke.getKeyStroke(KeyEvent.VK_ADD, KeyEvent.CTRL_DOWN_MASK), "zoomIn"); .put(KeyStroke.getKeyStroke(KeyEvent.VK_ADD, KeyEvent.CTRL_DOWN_MASK), "zoomIn");
getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
.put(KeyStroke.getKeyStroke(KeyEvent.VK_SUBTRACT, KeyEvent.CTRL_DOWN_MASK), "zoomOut"); .put(KeyStroke.getKeyStroke(KeyEvent.VK_SUBTRACT, KeyEvent.CTRL_DOWN_MASK), "zoomOut");
getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
.put(KeyStroke.getKeyStroke(KeyEvent.VK_ADD, KeyEvent.META_DOWN_MASK), "zoomIn");
getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
.put(KeyStroke.getKeyStroke(KeyEvent.VK_SUBTRACT, KeyEvent.META_DOWN_MASK), "zoomOut");
getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
.put(KeyStroke.getKeyStroke(KeyEvent.VK_0, KeyEvent.CTRL_DOWN_MASK), "resetZoom"); .put(KeyStroke.getKeyStroke(KeyEvent.VK_0, KeyEvent.CTRL_DOWN_MASK), "resetZoom");
getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
.put(KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD0, KeyEvent.CTRL_DOWN_MASK), "resetZoom"); .put(KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD0, KeyEvent.CTRL_DOWN_MASK), "resetZoom");
getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
.put(KeyStroke.getKeyStroke(KeyEvent.VK_0, KeyEvent.META_DOWN_MASK), "resetZoom");
getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
.put(KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD0, KeyEvent.META_DOWN_MASK), "resetZoom");
for (int i = 1; i <= 12; i++) { for (int i = 1; i <= 12; i++) {
final int x = i; final int x = i;
@@ -219,8 +227,8 @@ public class CanvasPanel extends JComponent implements Autoscroll {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
List<String> recent = (List<String>) configManager List<String> recent =
.readObject(IPlugInPort.RECENT_COMPONENTS_KEY, null); (List<String>) configManager.readObject(IPlugInPort.RECENT_COMPONENTS_KEY, null);
if (recent != null && !recent.isEmpty()) { if (recent != null && !recent.isEmpty()) {
String clazz = recent.get(0); String clazz = recent.get(0);
Map<String, List<ComponentType>> componentTypes = Map<String, List<ComponentType>> componentTypes =
@@ -242,7 +250,8 @@ public class CanvasPanel extends JComponent implements Autoscroll {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
protected void functionKeyPressed(int i) { protected void functionKeyPressed(int i) {
HashMap<String, String> shortcutMap = (HashMap<String, String>) configManager.readObject(TreePanel.COMPONENT_SHORTCUT_KEY, null); HashMap<String, String> shortcutMap =
(HashMap<String, String>) configManager.readObject(TreePanel.COMPONENT_SHORTCUT_KEY, null);
if (shortcutMap == null) if (shortcutMap == null)
return; return;
String typeName = shortcutMap.get("F" + i); String typeName = shortcutMap.get("F" + i);
@@ -313,8 +322,8 @@ public class CanvasPanel extends JComponent implements Autoscroll {
} }
Set<DrawOption> drawOptions = EnumSet.of(DrawOption.SELECTION, DrawOption.ZOOM, Set<DrawOption> drawOptions =
DrawOption.CONTROL_POINTS); EnumSet.of(DrawOption.SELECTION, DrawOption.ZOOM, DrawOption.CONTROL_POINTS);
if (configManager.readBoolean(IPlugInPort.ANTI_ALIASING_KEY, true)) { if (configManager.readBoolean(IPlugInPort.ANTI_ALIASING_KEY, true)) {
drawOptions.add(DrawOption.ANTIALIASING); drawOptions.add(DrawOption.ANTIALIASING);