001 /**
002 * ========================================
003 * JFreeReport : a free Java report library
004 * ========================================
005 *
006 * Project Info: http://reporting.pentaho.org/
007 *
008 * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
009 *
010 * This library is free software; you can redistribute it and/or modify it under the terms
011 * of the GNU Lesser General Public License as published by the Free Software Foundation;
012 * either version 2.1 of the License, or (at your option) any later version.
013 *
014 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
015 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016 * See the GNU Lesser General Public License for more details.
017 *
018 * You should have received a copy of the GNU Lesser General Public License along with this
019 * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
020 * Boston, MA 02111-1307, USA.
021 *
022 * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
023 * in the United States and other countries.]
024 *
025 * ------------
026 * $Id: ZoomOutActionPlugin.java,v 1.4 2007/06/10 15:54:22 taqua Exp $
027 * ------------
028 * (C) Copyright 2000-2005, by Object Refinery Limited.
029 * (C) Copyright 2005-2007, by Pentaho Corporation.
030 */
031
032 package org.jfree.report.modules.gui.swing.preview.actions;
033
034 import java.util.Locale;
035 import javax.swing.Icon;
036 import javax.swing.KeyStroke;
037
038 import org.jfree.report.modules.gui.swing.common.AbstractActionPlugin;
039 import org.jfree.report.modules.gui.swing.common.SwingGuiContext;
040 import org.jfree.report.modules.gui.swing.preview.PreviewPane;
041 import org.jfree.report.modules.gui.swing.preview.PreviewPaneUtilities;
042 import org.jfree.report.modules.gui.swing.preview.SwingPreviewModule;
043 import org.jfree.util.ResourceBundleSupport;
044
045 /**
046 * Creation-Date: 16.11.2006, 18:52:30
047 *
048 * @author Thomas Morgner
049 */
050 public class ZoomOutActionPlugin extends AbstractActionPlugin
051 implements ControlActionPlugin
052 {
053 private ResourceBundleSupport resources;
054
055 public ZoomOutActionPlugin()
056 {
057 }
058
059 public boolean initialize(SwingGuiContext context)
060 {
061 super.initialize(context);
062 resources = new ResourceBundleSupport(context.getLocale(),
063 SwingPreviewModule.BUNDLE_NAME);
064 return true;
065 }
066
067 protected String getConfigurationPrefix()
068 {
069 return "org.jfree.report.modules.gui.swing.preview.zoom-out.";
070 }
071
072 /**
073 * Returns the display name for the export action.
074 *
075 * @return The display name.
076 */
077 public String getDisplayName()
078 {
079 return resources.getString("action.zoomOut.name");
080 }
081
082 /**
083 * Returns the short description for the export action.
084 *
085 * @return The short description.
086 */
087 public String getShortDescription()
088 {
089 return resources.getString("action.zoomOut.description");
090 }
091
092 /**
093 * Returns the small icon for the export action.
094 *
095 * @return The icon.
096 */
097 public Icon getSmallIcon()
098 {
099 final Locale locale = getContext().getLocale();
100 return getIconTheme().getSmallIcon(locale, "action.zoomOut.small-icon");
101 }
102
103 /**
104 * Returns the large icon for the export action.
105 *
106 * @return The icon.
107 */
108 public Icon getLargeIcon()
109 {
110 final Locale locale = getContext().getLocale();
111 return getIconTheme().getLargeIcon(locale, "action.zoomOut.icon");
112 }
113
114 /**
115 * Returns the accelerator key for the export action.
116 *
117 * @return The accelerator key.
118 */
119 public KeyStroke getAcceleratorKey()
120 {
121 return resources.getOptionalKeyStroke("action.zoomOut.accelerator");
122 }
123
124 /**
125 * Returns the mnemonic key code.
126 *
127 * @return The code.
128 */
129 public Integer getMnemonicKey()
130 {
131 return resources.getOptionalMnemonic("action.zoomOut.mnemonic");
132 }
133
134 public boolean configure(PreviewPane reportPane)
135 {
136 final double nextZoomOut = PreviewPaneUtilities.getNextZoomOut
137 (reportPane.getZoom(), reportPane.getZoomFactors());
138 if (nextZoomOut == 0)
139 {
140 return false;
141 }
142 reportPane.setZoom(nextZoomOut);
143 return true;
144 }
145
146 }