📄 abstractplugin.java
字号:
// **********************************************************************//// <copyright>//// BBN Technologies, a Verizon Company// 10 Moulton Street// Cambridge, MA 02138// (617) 873-8000//// Copyright (C) BBNT Solutions LLC. All rights reserved.//// </copyright>// **********************************************************************//// $Source: /cvs/distapps/openmap/src/openmap/com/bbn/openmap/plugin/AbstractPlugIn.java,v $// $RCSfile: AbstractPlugIn.java,v $// $Revision: 1.8.2.4 $// $Date: 2006/01/13 21:04:22 $// $Author: dietrick $//// **********************************************************************package com.bbn.openmap.plugin;import java.awt.Component;import java.awt.event.MouseEvent;import java.util.Properties;import com.bbn.openmap.Environment;import com.bbn.openmap.I18n;import com.bbn.openmap.Layer;import com.bbn.openmap.PropertyConsumer;import com.bbn.openmap.event.MapMouseListener;import com.bbn.openmap.event.SelectMouseMode;import com.bbn.openmap.omGraphics.OMGraphicList;import com.bbn.openmap.proj.Projection;import com.bbn.openmap.util.PropUtils;/** * This class is an abstract implementation of the PlugIn. It takes care of * setting up the layer, setting properties, etc. * * @see com.bbn.openmap.plugin.PlugInLayer * @see com.bbn.openmap.plugin.PlugIn */public abstract class AbstractPlugIn implements PlugIn, PropertyConsumer, MapMouseListener { /** * Property 'removable' to designate this layer as removable from the * application, or able to be deleted. True by default. */ public static final String RemovableProperty = "removable"; /** * Flag to designate the layer as removable or not. */ protected boolean removable = true; /** The parent component, usually the PlugInLayer. */ protected Component component = null; /** The prefix for the plugin's properties. */ protected String prefix = null; /** * The pretty name for a plugin, if it was set in the properties. */ protected String name = this.getClass().getName(); /** * The object handling mouse events for the plugin. By default, the Plugin * is it, but it doesn't have to be. */ protected MapMouseListener mml = this; /** * Flag to denote whether the plugin should be added to the bean context * (MapHandler). True by default. */ protected boolean addToBeanContext = true; /** * Internationalization */ public I18n i18n = Environment.getI18n(); public AbstractPlugIn() {} public AbstractPlugIn(Component comp) { setComponent(comp); } /** * Set the name of the plugin. If the parent component is a layer, set its * pretty name as well. */ public void setName(String name) { this.name = name; Component comp = getComponent(); if (comp != null) { comp.setName(name); } } /** * Get the pretty name of the plugin, which is really the pretty name of the * parent component if it's set. */ public String getName() { Component comp = getComponent(); if (comp != null) { name = comp.getName(); } return name; } /** * Set the component that this PlugIn uses as a grip to the map. */ public void setComponent(Component comp) { this.component = comp; } /** * Get the component that this plugin uses as a grip to the map. */ public Component getComponent() { return component; } /** * Call repaint on the parent component. */ public void repaint() { component.repaint(); } /** * Checks to see if the parent component is a PlugInLayer, and calls * doPrepare() on it if it is. */ public void doPrepare() { if (component instanceof PlugInLayer) { ((PlugInLayer) component).doPrepare(); } } /** * Set the MapMouseListener for this PlugIn. The MapMouseListener is * responsible for handling the MouseEvents that are occuring over the layer * using the PlugIn, as well as being able to let others know which * MouseModes are of interest to receive MouseEvents from. * * @param mml MapMouseListener. */ public void setMapMouseListener(MapMouseListener mml) { this.mml = mml; } /** * Returns the MapMouseListener that the plugin thinks should be used. */ public MapMouseListener getMapMouseListener() { return mml; } /** * The getRectangle call is the main call into the PlugIn module. The module * is expected to fill a graphics list with objects that are within the * screen parameters passed. It's assumed that the PlugIn will call * generate(projection) on the OMGraphics returned! If you don't call * generate on the OMGraphics, they will not be displayed on the map. * * @param p projection of the screen, holding scale, center coords, height, * width. May be null if the parent component hasn't been given a * projection. */ public abstract OMGraphicList getRectangle(Projection p); /** */ public Component getGUI() { return null; } public void setAddToBeanContext(boolean value) { addToBeanContext = value; } public boolean getAddToBeanContext() { return addToBeanContext; } /** * Mark the plugin (and layer) as removable, or one that can be deleted from * the application. What that means is up to the LayerHandler or other * application components. */ public void setRemovable(boolean set) { this.removable = set; Component comp = getComponent(); if ((comp != null) && (comp instanceof Layer)) { ((Layer) comp).setRemovable(set); } } /** * Check to see if the plugin (and layer) is marked as one that can be * removed from an application. * * @return true if plugin should be allowed to be deleted. */ public boolean isRemovable() { Component comp = getComponent(); if ((comp != null) && (comp instanceof Layer)) { this.removable = ((Layer) comp).isRemovable(); } return removable; } // //// PropertyConsumer Interface Methods /** * Method to set the properties in the PropertyConsumer. It is assumed that * the properties do not have a prefix associated with them, or that the * prefix has already been set. * * @param setList a properties object that the PropertyConsumer can use to * retrieve expected properties it can use for configuration. */ public void setProperties(Properties setList) { setProperties(null, setList); } /** * Method to set the properties in the PropertyConsumer. The prefix is a * string that should be prepended to each property key (in addition to a * separating '.') in order for the PropertyConsumer to uniquely identify * properies meant for it, in the midst of of Properties meant for several * objects.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -