KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nightlabs > editor2d > viewer > action > ZoomAllAction


1 /* *****************************************************************************
2  * NightLabs Editor2D - Graphical editor framework *
3  * Copyright (C) 2004-2005 NightLabs - http://NightLabs.org *
4  * *
5  * This library is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU Lesser General Public *
7  * License as published by the Free Software Foundation; either *
8  * version 2.1 of the License, or (at your option) any later version. *
9  * *
10  * This library is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
13  * Lesser General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU Lesser General Public *
16  * License along with this library; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin St, Fifth Floor, *
19  * Boston, MA 02110-1301 USA *
20  * *
21  * Or get it online : *
22  * http://www.gnu.org/copyleft/lesser.html *
23  * *
24  * *
25  ******************************************************************************/

26
27 package org.nightlabs.editor2d.viewer.action;
28
29 import java.awt.Rectangle JavaDoc;
30
31 import org.apache.log4j.Logger;
32 import org.nightlabs.editor2d.viewer.IZoomSupport;
33 import org.nightlabs.editor2d.viewer.ViewerPlugin;
34 import org.nightlabs.editor2d.viewer.util.TransformUtil;
35
36 public class ZoomAllAction
37 extends ZoomAction
38 {
39     public static final String JavaDoc ID = ZoomAllAction.class.getName();
40     public static final Logger LOGGER = Logger.getLogger(ZoomAllAction.class);
41     
42     public ZoomAllAction() {
43         super();
44     }
45
46     public ZoomAllAction(IZoomSupport zoomSupport)
47     {
48         super(zoomSupport);
49         this.zoom = zoomSupport.getZoom();
50     }
51
52     public void init()
53     {
54         setId(ID);
55         setText(ViewerPlugin.getResourceString("action.zoomAll.text"));
56         setToolTipText(ViewerPlugin.getResourceString("action.zoomAll.tooltip"));
57     }
58
59     double zoom = 1.0d;
60     public void zoomChanged(double zoom) {
61         this.zoom = zoom;
62     }
63
64     public void run()
65     {
66 // getZoomSupport().zoomTo(getZoomSupport().getViewport().getRealBounds());
67
Rectangle JavaDoc bounds = getZoomSupport().getViewport().getRealBounds();
68         Rectangle JavaDoc absoluteRealBounds = TransformUtil.toAbsolute(bounds, zoom, true);
69 // Rectangle absoluteRealBounds = TransformUtil.toRelative(bounds, zoom, true);
70
getZoomSupport().zoomTo(absoluteRealBounds);
71         
72         LOGGER.debug("real bounds = "+bounds);
73         LOGGER.debug("view Bounds = "+getZoomSupport().getViewport().getViewBounds());
74         LOGGER.debug("zoom = "+zoom);
75         LOGGER.debug("absolute real bounds = "+absoluteRealBounds);
76     }
77 }
78
Popular Tags