001: /**
002: * ===========================================
003: * JFreeReport : a free Java reporting library
004: * ===========================================
005: *
006: * Project Info: http://reporting.pentaho.org/
007: *
008: * (C) Copyright 2001-2007, by Object Refinery Ltd, 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: * ZoomOutActionPlugin.java
027: * ------------
028: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
029: */package org.jfree.report.modules.gui.base.actions;
030:
031: import java.util.Locale;
032: import javax.swing.Icon;
033: import javax.swing.KeyStroke;
034:
035: import org.jfree.report.modules.gui.base.PreviewPane;
036: import org.jfree.report.modules.gui.base.SwingPreviewModule;
037: import org.jfree.report.modules.gui.base.internal.PreviewPaneUtilities;
038: import org.jfree.report.modules.gui.commonswing.AbstractActionPlugin;
039: import org.jfree.report.modules.gui.commonswing.SwingGuiContext;
040: import org.jfree.util.ResourceBundleSupport;
041:
042: /**
043: * Creation-Date: 16.11.2006, 18:52:30
044: *
045: * @author Thomas Morgner
046: */
047: public class ZoomOutActionPlugin extends AbstractActionPlugin implements
048: ControlActionPlugin {
049: private ResourceBundleSupport resources;
050:
051: public ZoomOutActionPlugin() {
052: }
053:
054: public boolean initialize(final SwingGuiContext context) {
055: super .initialize(context);
056: resources = new ResourceBundleSupport(context.getLocale(),
057: SwingPreviewModule.BUNDLE_NAME);
058: context.getEventSource().addPropertyChangeListener(
059: new PaginatedUpdateListener(this ));
060: setEnabled(context.getEventSource().isPaginated());
061: return true;
062: }
063:
064: protected String getConfigurationPrefix() {
065: return "org.jfree.report.modules.gui.base.zoom-out."; //$NON-NLS-1$
066: }
067:
068: /**
069: * Returns the display name for the export action.
070: *
071: * @return The display name.
072: */
073: public String getDisplayName() {
074: return resources.getString("action.zoomOut.name"); //$NON-NLS-1$
075: }
076:
077: /**
078: * Returns the short description for the export action.
079: *
080: * @return The short description.
081: */
082: public String getShortDescription() {
083: return resources.getString("action.zoomOut.description"); //$NON-NLS-1$
084: }
085:
086: /**
087: * Returns the small icon for the export action.
088: *
089: * @return The icon.
090: */
091: public Icon getSmallIcon() {
092: final Locale locale = getContext().getLocale();
093: return getIconTheme().getSmallIcon(locale,
094: "action.zoomOut.small-icon"); //$NON-NLS-1$
095: }
096:
097: /**
098: * Returns the large icon for the export action.
099: *
100: * @return The icon.
101: */
102: public Icon getLargeIcon() {
103: final Locale locale = getContext().getLocale();
104: return getIconTheme().getLargeIcon(locale,
105: "action.zoomOut.icon"); //$NON-NLS-1$
106: }
107:
108: /**
109: * Returns the accelerator key for the export action.
110: *
111: * @return The accelerator key.
112: */
113: public KeyStroke getAcceleratorKey() {
114: final String charAccelerator = resources
115: .getString("action.zoomOut.char-accelerator");
116: if (charAccelerator.length() > 0) {
117: return KeyStroke.getKeyStroke(charAccelerator.charAt(0));
118: }
119: return resources
120: .getOptionalKeyStroke("action.zoomOut.accelerator"); //$NON-NLS-1$
121: }
122:
123: /**
124: * Returns the mnemonic key code.
125: *
126: * @return The code.
127: */
128: public Integer getMnemonicKey() {
129: return resources.getOptionalMnemonic("action.zoomOut.mnemonic"); //$NON-NLS-1$
130: }
131:
132: public boolean configure(final PreviewPane reportPane) {
133: final double nextZoomOut = PreviewPaneUtilities.getNextZoomOut(
134: reportPane.getZoom(), reportPane.getZoomFactors());
135: if (nextZoomOut == 0) {
136: return false;
137: }
138: reportPane.setZoom(nextZoomOut);
139: return true;
140: }
141:
142: }
|