001: /*
002: * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI
003: * for visualizing and manipulating spatial features with geometry and attributes.
004: *
005: * JUMP is Copyright (C) 2003 Vivid Solutions
006: *
007: * This program implements extensions to JUMP and is
008: * Copyright (C) Stefan Steiniger.
009: *
010: * This program is free software; you can redistribute it and/or
011: * modify it under the terms of the GNU General Public License
012: * as published by the Free Software Foundation; either version 2
013: * of the License, or (at your option) any later version.
014: *
015: * This program is distributed in the hope that it will be useful,
016: * but WITHOUT ANY WARRANTY; without even the implied warranty of
017: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
018: * GNU General Public License for more details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with this program; if not, write to the Free Software
022: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
023: *
024: * For more information, contact:
025: * Stefan Steiniger
026: * perriger@gmx.de
027: */
028: /*****************************************************
029: * created: original version by Vivid Solution
030: * last modified: 03.06.2005
031: *
032: * description:
033: * - initializes renderplugin
034: * - plugin calculates the actual scale and draws the text
035: * (and a white rectangle around) in the map window
036: * all things are done in ShowScaleRenderer
037: *
038: * @author sstein
039: * TODO how to put a mark on the menue item if tool is activated?
040: *****************************************************/package org.openjump.core.ui.plugin.view;
041:
042: import org.openjump.core.ui.plugin.view.helpclassescale.InstallShowScalePlugIn;
043: import org.openjump.core.ui.plugin.view.helpclassescale.ShowScaleRenderer;
044:
045: import com.vividsolutions.jump.I18N;
046: import com.vividsolutions.jump.workbench.WorkbenchContext;
047: import com.vividsolutions.jump.workbench.plugin.AbstractPlugIn;
048: import com.vividsolutions.jump.workbench.plugin.EnableCheckFactory;
049: import com.vividsolutions.jump.workbench.plugin.MultiEnableCheck;
050: import com.vividsolutions.jump.workbench.plugin.PlugInContext;
051: import com.vividsolutions.jump.workbench.ui.MenuNames;
052:
053: /**
054: * @description:
055: * - initializes renderplugin
056: * - plugin calculates the actual scale and draws the text
057: * (and a white rectangle around) in the map window
058: * all things are done in ShowScaleRenderer
059: *
060: * @author sstein
061: */
062: public class ShowScalePlugIn extends AbstractPlugIn {
063:
064: public void initialize(PlugInContext context) throws Exception {
065:
066: context
067: .getFeatureInstaller()
068: .addMainMenuItemWithJava14Fix(
069: this ,
070: new String[] { MenuNames.VIEW },
071: I18N
072: .get("org.openjump.core.ui.plugin.view.ShowScalePlugIn.show-scale")
073: + "{pos:14}",
074: false,
075: null,
076: createEnableCheck(context.getWorkbenchContext()));
077: InstallShowScalePlugIn myISSP = new InstallShowScalePlugIn();
078: myISSP.initialize(context);
079: }
080:
081: public static MultiEnableCheck createEnableCheck(
082: WorkbenchContext workbenchContext) {
083: EnableCheckFactory checkFactory = new EnableCheckFactory(
084: workbenchContext);
085:
086: return new MultiEnableCheck().add(checkFactory
087: .createAtLeastNLayersMustExistCheck(1));
088: }
089:
090: public boolean execute(PlugInContext context) throws Exception {
091: InstallShowScalePlugIn myInstallScalePlugIn = new InstallShowScalePlugIn();
092: reportNothingToUndoYet(context);
093: ShowScaleRenderer.setEnabled(!ShowScaleRenderer
094: .isEnabled(context.getLayerViewPanel()), context
095: .getLayerViewPanel());
096: context.getLayerViewPanel().getRenderingManager().render(
097: ShowScaleRenderer.CONTENT_ID);
098:
099: return true;
100: }
101: }
|