Author: mvw
Date: 2008-04-06 09:30:54-0700
New Revision: 14291
Added:
trunk/src/app/src/org/argouml/ui/cmd/ZoomActionProxy.java (contents, props changed)
Modified:
trunk/src/app/src/org/argouml/ui/ZoomSliderButton.java
trunk/src/app/src/org/argouml/ui/cmd/GenericArgoMenuBar.java
trunk/src/app/src/org/argouml/ui/cmd/ShortcutMgr.java
Log:
Fix for issue 2462: Patch as submitted by Bogdan Szanto.
Modified: trunk/src/app/src/org/argouml/ui/ZoomSliderButton.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/app/src/org/argouml/ui/ZoomSliderButton.java?view=diff&rev=14291&p1=trunk/src/app/src/org/argouml/ui/ZoomSliderButton.java&p2=trunk/src/app/src/org/argouml/ui/ZoomSliderButton.java&r1=14290&r2=14291
==============================================================================
--- trunk/src/app/src/org/argouml/ui/ZoomSliderButton.java (original)
+++ trunk/src/app/src/org/argouml/ui/ZoomSliderButton.java 2008-04-06 09:30:54-0700
@@ -77,14 +77,14 @@
private static final Font LABEL_FONT = new Font("Dialog", Font.PLAIN, 10);
/**
- * The minimum zoom magnification slider value.
+ * The minimum zoom slider value (as percentage).
*/
- private static final int MINIMUM_ZOOM = 0;
+ public static final int MINIMUM_ZOOM = 25;
/**
- * The maximum zoom magnification slider value.
+ * The minimum zoom slider value (as percentage).
*/
- private static final int MAXIMUM_ZOOM = 500;
+ public static final int MAXIMUM_ZOOM = 300;
/**
* The preferred height of the slider component.
@@ -121,7 +121,7 @@
*/
public ZoomSliderButton() {
super();
- setAction( new AbstractAction() {
+ setAction(new AbstractAction() {
public void actionPerformed(ActionEvent e) {
/* If action comes in with *no* modifiers, it is a pure
* keyboard event (e.g. spacebar), so do it. Anything else
@@ -155,8 +155,8 @@
MAXIMUM_ZOOM,
MINIMUM_ZOOM);
slider.setInverted(true);
- slider.setMajorTickSpacing(MAXIMUM_ZOOM / 10);
- slider.setMinorTickSpacing(MAXIMUM_ZOOM / 20);
+ slider.setMajorTickSpacing(25);
+ slider.setMinorTickSpacing(5);
slider.setPaintTicks(true);
slider.setPaintTrack(true);
int sliderBaseWidth = slider.getPreferredSize().width;
Modified: trunk/src/app/src/org/argouml/ui/cmd/GenericArgoMenuBar.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/app/src/org/argouml/ui/cmd/GenericArgoMenuBar.java?view=diff&rev=14291&p1=trunk/src/app/src/org/argouml/ui/cmd/GenericArgoMenuBar.java&p2=trunk/src/app/src/org/argouml/ui/cmd/GenericArgoMenuBar.java&r1=14290&r2=14291
==============================================================================
--- trunk/src/app/src/org/argouml/ui/cmd/GenericArgoMenuBar.java (original)
+++ trunk/src/app/src/org/argouml/ui/cmd/GenericArgoMenuBar.java 2008-04-06 09:30:54-0700
@@ -1,5 +1,5 @@
// $Id:GenericArgoMenuBar.java 13104 2007-07-21 18:29:31Z mvw $
-// Copyright (c) 1996-2007 The Regents of the University of California. All
+// Copyright (c) 1996-2008 The Regents of the University of California. All
// Rights Reserved. Permission to use, copy, modify, and distribute this
// software and its documentation without fee, and without a written
// agreement is hereby granted, provided that the above copyright notice
@@ -86,7 +86,6 @@
import org.tigris.gef.base.ReorderAction;
import org.tigris.gef.base.SelectAllAction;
import org.tigris.gef.base.SelectInvertAction;
-import org.tigris.gef.base.ZoomAction;
import org.tigris.toolbar.ToolBarFactory;
/**
@@ -555,16 +554,17 @@
JMenu zoom = (JMenu) view.add(new JMenu(menuLocalize("Zoom")));
setMnemonic(zoom, "Zoom");
- ZoomAction zoomOutAction = new ZoomAction(ZOOM_FACTOR);
+ ZoomActionProxy zoomOutAction = new ZoomActionProxy(ZOOM_FACTOR);
JMenuItem zoomOut = zoom.add(zoomOutAction);
setMnemonic(zoomOut, "Zoom Out");
ShortcutMgr.assignAccelerator(zoomOut, ShortcutMgr.ACTION_ZOOM_OUT);
- JMenuItem zoomReset = zoom.add(new ZoomAction(0.0));
+ JMenuItem zoomReset = zoom.add(new ZoomActionProxy(0.0));
setMnemonic(zoomReset, "Zoom Reset");
ShortcutMgr.assignAccelerator(zoomReset, ShortcutMgr.ACTION_ZOOM_RESET);
- ZoomAction zoomInAction = new ZoomAction((1.0) / (ZOOM_FACTOR));
+ ZoomActionProxy zoomInAction =
+ new ZoomActionProxy((1.0) / (ZOOM_FACTOR));
JMenuItem zoomIn = zoom.add(zoomInAction);
setMnemonic(zoomIn, "Zoom In");
ShortcutMgr.assignAccelerator(zoomIn, ShortcutMgr.ACTION_ZOOM_IN);
Modified: trunk/src/app/src/org/argouml/ui/cmd/ShortcutMgr.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/app/src/org/argouml/ui/cmd/ShortcutMgr.java?view=diff&rev=14291&p1=trunk/src/app/src/org/argouml/ui/cmd/ShortcutMgr.java&p2=trunk/src/app/src/org/argouml/ui/cmd/ShortcutMgr.java&r1=14290&r2=14291
==============================================================================
--- trunk/src/app/src/org/argouml/ui/cmd/ShortcutMgr.java (original)
+++ trunk/src/app/src/org/argouml/ui/cmd/ShortcutMgr.java 2008-04-06 09:30:54-0700
@@ -1,5 +1,5 @@
// $Id$
-// Copyright (c) 2006-2007 The Regents of the University of California. All
+// Copyright (c) 2006-2008 The Regents of the University of California. All
// Rights Reserved. Permission to use, copy, modify, and distribute this
// software and its documentation without fee, and without a written
// agreement is hereby granted, provided that the above copyright notice
@@ -618,12 +618,15 @@
putDefaultShortcut(ACTION_ADJUST_PAGE_BREAKS, null,
new AdjustPageBreaksAction());
putDefaultShortcut(ACTION_SHOW_XML_DUMP, null, new ActionShowXMLDump());
+
putDefaultShortcut(ACTION_ZOOM_IN, KeyStroke.getKeyStroke(
- KeyEvent.VK_PLUS, DEFAULT_MASK), new ZoomAction(
+ KeyEvent.VK_PLUS, DEFAULT_MASK), new ZoomActionProxy(
(1.0) / (GenericArgoMenuBar.ZOOM_FACTOR)));
+
putDefaultShortcut(ACTION_ZOOM_OUT, KeyStroke.getKeyStroke(
- KeyEvent.VK_MINUS, DEFAULT_MASK), new ZoomAction(
+ KeyEvent.VK_MINUS, DEFAULT_MASK), new ZoomActionProxy(
GenericArgoMenuBar.ZOOM_FACTOR));
+
putDefaultShortcut(ACTION_FIND, KeyStroke.getKeyStroke(KeyEvent.VK_F3,
0), new ActionFind());
Added: trunk/src/app/src/org/argouml/ui/cmd/ZoomActionProxy.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/app/src/org/argouml/ui/cmd/ZoomActionProxy.java?view=auto&rev=14291
==============================================================================
--- (empty file)
+++ trunk/src/app/src/org/argouml/ui/cmd/ZoomActionProxy.java 2008-04-06 09:30:54-0700
@@ -0,0 +1,77 @@
+// $Id$
+// Copyright (c) 2008 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.ui.cmd;
+
+import java.awt.event.ActionEvent;
+
+import org.argouml.ui.ZoomSliderButton;
+import org.tigris.gef.base.Editor;
+import org.tigris.gef.base.Globals;
+import org.tigris.gef.base.ZoomAction;
+
+/**
+ * An intermediate class used to check if zoom factor is within range before
+ * zooming.
+ *
+ * @author bszanto (Bogdan Szanto)
+ */
+public class ZoomActionProxy extends ZoomAction {
+
+ /**
+ * Local instance of the magnitude that alows computation of zoom factor
+ * before zooming.
+ */
+ private double zoomFactor;
+
+ /**
+ * Constructor calling the org.tigris.gef.base.ZoomAction constructor.
+ *
+ * @param zF The zoom factor.
+ */
+ public ZoomActionProxy(double zF) {
+ super(zF);
+ zoomFactor = zF;
+ }
+
+ /**
+ * Tests if zoom factor values are ok before zooming.
+ *
+ * @param arg0 The action event to be transmitted.
+ * @see org.tigris.gef.base.ZoomAction#actionPerformed(java.awt.event.ActionEvent)
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ Editor ed = Globals.curEditor();
+ if (ed == null) return;
+
+ if ((zoomFactor == 0)
+ || ((ed.getScale() * zoomFactor
+ < ZoomSliderButton.MINIMUM_ZOOM / 100)
+ && ed.getScale() * zoomFactor
+ < ZoomSliderButton.MAXIMUM_ZOOM / 100)) {
+ super.actionPerformed(arg0);
+ }
+ }
+
+}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.