Class StandardPirolPlugIn
- java.lang.Object
-
- com.vividsolutions.jump.workbench.plugin.AbstractPlugIn
-
- de.fho.jump.pirol.utilities.plugIns.StandardPirolPlugIn
-
- All Implemented Interfaces:
EnableChecked,Iconified,PlugIn,Recordable,ShortcutEnabled,ErrorHandler
public abstract class StandardPirolPlugIn extends AbstractPlugIn implements ErrorHandler
Overrides most of the abstract methods of the AbstractPlugIn to implement a default behavior, that fits the needs for a plugIn in the PIROL context. Also implements the ErrorHandler interface and offers methods to post error messages to the GUI.- Version:
- $Rev$
- Author:
- Ole Rahn, Stefan Ostermann
FH Osnabrück - University of Applied Sciences Osnabrück,
Project: PIROL (2005),
Subproject: Daten- und Wissensmanagement
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanbringUpMessagesAre errors to be shown in the statusbar (bringUpMessages = false, DEFAULT) or in an output window (bringUpMessages = true)?protected static EnableCheckFactorycheckFactoryprotected static org.locationtech.jts.geom.GeometryFactorygeometryFactoryprotected ImageIconiconsee description for method getIconString() for more informationprotected PersonalLoggerloggerlogger reference for use with the StandardPirolPlugIn.protected StringBuffermessagesbuffer for messages of errors that occured during execution - needed to implement the ErrorHandler interfaceprotected booleanuseToolIconSize-
Fields inherited from class com.vividsolutions.jump.workbench.plugin.AbstractPlugIn
shortcutKeys, shortcutModifiers
-
-
Constructor Summary
Constructors Constructor Description StandardPirolPlugIn(PersonalLogger logger)Please, use this constructor in the deriving class!
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static MultiEnableCheckcreateEnableCheck(WorkbenchContext workbenchContext, boolean needFence)abstract booleanexecute(PlugInContext context)This method is called to execute the PlugIn.protected booleanfinishExecution(PlugInContext context, boolean retVal)To be called, when leaving the execute()-method.StringgetCategoryName()The name of the category, a PlugIn can be found in - this method should be overridden by any derived class!static Feature[]getFeaturesInFenceOrInLayer(PlugInContext context, Layer layer)Get a List of Features (from the given Layer) that reside within the fence (if there is a fence) or just the features of the layer (if there is currently no fence)IcongetIcon()Method to load an icon from the surrounding jar-file if necessary.abstract StringgetIconString()Method to enable loading an icon from the surrounding jar-file if necessary.PersonalLoggergetLogger()static TaskMonitorDialoggetMonitor(PlugInContext context)StringgetName()Name of the PlugIn to be shown in the menus or as a tooltip in JUMP.
Looks for a key (the PlugIn's name with no path) in the i18n resources, if none is found the standard jump name generation will be used.static LayergetSelectedLayer(PlugInContext context)get one Layer that is selectedstatic Layer[]getSelectedLayers(PlugInContext context, int num)Get a given number of selected Layers.StringgetShortClassName()voidhandleThrowable(Throwable t)Note that this method may or may not be called from the AWT event-dispatch thread.voidinitialize(PlugInContext context)The PlugIn will be added to thePIROL Tools/[return value of getCategoryName()]menu and a standardEnableCheckis applied.voidinitialize(PlugInContext context, String subMenuName)Deprecated.protected voidpostMessagesToGui(PlugInContext context)static voidprintln(Class c, String function, String message)Deprecated.use logger instead!protected voidprintln(String function, String msg)Deprecated.use logger instead!voidsetLogger(PersonalLogger logger)Sets the personal logger - enables debug statement handlingvoidsetUseInToolbox(boolean toolboxUse)static voidwarnUser(PlugInContext context, String msg)Puts a warning message into the statusbar of JUMP-
Methods inherited from class com.vividsolutions.jump.workbench.plugin.AbstractPlugIn
addParameter, createName, execute, execute, getBooleanParam, getContext, getDoubleParam, getEnableCheck, getIcon, getIcon, getIntegerParam, getParameter, getParameters, getShortcutKeys, getShortcutKeyStroke, getShortcutModifiers, getStringParam, getWorkbenchContext, isRollingBackInvalidEdits, isShortcutEnabled, reportNothingToUndoYet, setParameters, setShortcutKeys, setShortcutModifiers, toActionListener, toString
-
-
-
-
Field Detail
-
messages
protected StringBuffer messages
buffer for messages of errors that occured during execution - needed to implement the ErrorHandler interface
-
bringUpMessages
protected boolean bringUpMessages
Are errors to be shown in the statusbar (bringUpMessages = false, DEFAULT) or in an output window (bringUpMessages = true)?
-
checkFactory
protected static EnableCheckFactory checkFactory
-
icon
protected ImageIcon icon
see description for method getIconString() for more information
-
useToolIconSize
protected boolean useToolIconSize
-
geometryFactory
protected static org.locationtech.jts.geom.GeometryFactory geometryFactory
-
logger
protected PersonalLogger logger
logger reference for use with the StandardPirolPlugIn. Since loggers are personalized, this member has to be initialized in derived classes by the programmer, before it can be used. For downward compatibility no abstract method or constructur parameter was introduced to do this.- Since:
- rev.1.12
-
-
Constructor Detail
-
StandardPirolPlugIn
public StandardPirolPlugIn(PersonalLogger logger)
Please, use this constructor in the deriving class!- Parameters:
logger- the logger that will controll console outputs- Since:
- rev.1.17
-
-
Method Detail
-
getShortClassName
public String getShortClassName()
-
createEnableCheck
public static MultiEnableCheck createEnableCheck(WorkbenchContext workbenchContext, boolean needFence)
-
getIconString
public abstract String getIconString()
Method to enable loading an icon from the surrounding jar-file if necessary. If the plugin doesn't need an icon, just returnnullelse return the file name, e.g. "xyz.png" and put the picture in the same folder (package) as the deriving class.- Returns:
- the filename of the icon or
nullif the plugin has no icon.
-
execute
public abstract boolean execute(PlugInContext context) throws Exception
This method is called to execute the PlugIn.- Specified by:
executein interfacePlugIn- Overrides:
executein classAbstractPlugIn- Parameters:
context- the snapshot of the current workbench.- Returns:
- always
true? - Throws:
Exception- if an Exception occurs- See Also:
AbstractPlugIn.execute(com.vividsolutions.jump.workbench.plugin.PlugInContext)
-
getName
public String getName()
Name of the PlugIn to be shown in the menus or as a tooltip in JUMP.
Looks for a key (the PlugIn's name with no path) in the i18n resources, if none is found the standard jump name generation will be used.- Specified by:
getNamein interfacePlugIn- Overrides:
getNamein classAbstractPlugIn- Returns:
- the class name, minus "PlugIn", with spaces inserted at the appropriate point before each uppercase+lowercase and lowercase+uppercase combination.
-
initialize
public void initialize(PlugInContext context) throws Exception
The PlugIn will be added to thePIROL Tools/[return value of getCategoryName()]menu and a standardEnableCheckis applied.- Specified by:
initializein interfacePlugIn- Overrides:
initializein classAbstractPlugIn- Parameters:
context- PlugInContext- Throws:
Exception- if an Exception occurs- See Also:
getCategoryName()
-
getCategoryName
public String getCategoryName()
The name of the category, a PlugIn can be found in - this method should be overridden by any derived class!- Returns:
- name of the category, a PlugIn can be found in
-
initialize
public void initialize(PlugInContext context, String subMenuName) throws Exception
Deprecated.Standard intialization: PlugIn is added to thePIROL Tools/subMenuName(or localized menu name) menu and a standardEnableCheckis applied.- Throws:
Exception
-
getMonitor
public static TaskMonitorDialog getMonitor(PlugInContext context)
- Parameters:
context- the current PlugIn context- Returns:
- a TaskMonitorDialog, to show progress information to the user
-
println
protected void println(String function, String msg)
Deprecated.use logger instead!Prints output to the stdout. Can be invoked by deriving classes.- Parameters:
function- the name of the method from within this one is called. E.g. "myMethod()".msg- the message String.- See Also:
println(Class, String, String)
-
println
public static void println(Class c, String function, String message)
Deprecated.use logger instead!Writes the given message and function string to the stdout. The output will be formated as "classname.function: message".- Parameters:
c- the calling classfunction- the method from within this one is called.message- the text with some useful information.
-
warnUser
public static void warnUser(PlugInContext context, String msg)
Puts a warning message into the statusbar of JUMP- Parameters:
context- curr. PlugInContextmsg- message to be shown to the user
-
getSelectedLayers
public static Layer[] getSelectedLayers(PlugInContext context, int num)
Get a given number of selected Layers.- Parameters:
context- the current PlugInContextnum- max. number of layers to return, -1 returns all selected layers- Returns:
- a given number of selected Layers, null if no Layers are selected
-
getSelectedLayer
public static Layer getSelectedLayer(PlugInContext context)
get one Layer that is selected- Parameters:
context- the current PlugInContext- Returns:
- one selected Layer, null if no Layers are selected
-
finishExecution
protected boolean finishExecution(PlugInContext context, boolean retVal)
To be called, when leaving the execute()-method. Puts out the error messages collected during execution if any and returns the given boolean value. Example:return finishExecution(context, true);
- Parameters:
context- the current PlugInContextretVal- the value to be returned by execute()- Returns:
- retVal
-
postMessagesToGui
protected void postMessagesToGui(PlugInContext context)
-
handleThrowable
public void handleThrowable(Throwable t)
Description copied from interface:ErrorHandlerNote that this method may or may not be called from the AWT event-dispatch thread.- Specified by:
handleThrowablein interfaceErrorHandler
-
getIcon
public Icon getIcon()
Method to load an icon from the surrounding jar-file if necessary.- Specified by:
getIconin interfaceIconified- Overrides:
getIconin classAbstractPlugIn- Returns:
- the icon or
nullif the getIconString() returned null (or problems occured)
-
getFeaturesInFenceOrInLayer
public static Feature[] getFeaturesInFenceOrInLayer(PlugInContext context, Layer layer)
Get a List of Features (from the given Layer) that reside within the fence (if there is a fence) or just the features of the layer (if there is currently no fence)- Parameters:
context- the plugIn contextlayer- the layer holding the features- Returns:
- List of features within fence if present or just within the layer
-
getLogger
public PersonalLogger getLogger()
- Returns:
- the personal logger
- See Also:
PersonalLogger
-
setLogger
public void setLogger(PersonalLogger logger)
Sets the personal logger - enables debug statement handling- Parameters:
logger- the new personal logger- See Also:
PersonalLogger
-
setUseInToolbox
public void setUseInToolbox(boolean toolboxUse)
-
-