org.openstreetmap.josm
Class Main

java.lang.Object
  extended by org.openstreetmap.josm.Main
Direct Known Subclasses:
MainApplet.MainCaller, MainApplication

public abstract class Main
extends java.lang.Object


Nested Class Summary
private static class Main.DownloadParamType
          The type of a command line parameter, to be used in switch statements.
static interface Main.InitStatusListener
           
private static class Main.WindowPositionSizeListener
           
 
Field Summary
static boolean applet
          Set to true, when in applet mode
protected static javax.swing.JPanel contentPanePrivate
           
static PleaseWaitProgressMonitor currentProgressMonitor
           
protected static WindowGeometry geometry
           
private  GettingStarted gettingStarted
          The MOTD Layer.
private static Main.InitStatusListener initListener
           
static boolean isOpenjdk
          Whether or not the java vm is openjdk We use this to work around openjdk bugs
private static java.util.ArrayList<java.lang.ref.WeakReference<ProjectionChangeListener>> listeners
           
static int log_level
          Logging level (3 = debug, 2 = info, 1 = warn, 0 = none).
static Main main
          Global application.
static MapFrame map
          The MapFrame.
 MainMenu menu
          The main menu bar at top of screen.
static javax.swing.JPanel panel
           
static java.awt.Component parent
          Global parent component for all dialogs and message boxes
static PrimitiveDeepCopy pasteBuffer
          The global paste buffer.
static Layer pasteSource
           
static PlatformHook platform
          Platform specific code goes in here.
static Preferences pref
          Global application preferences
private static Projection proj
          The projection method used.
private  OsmDataLayer.CommandQueueListener redoUndoListener
           
static ToolbarPreferences toolbar
          The toolbar preference control to register new actions.
 UndoRedoHandler undoRedo
           
 OsmValidator validator
          The data validation handler.
protected static int windowState
           
static java.util.concurrent.ExecutorService worker
          The worker thread slave.
 
Constructor Summary
Main()
           
 
Method Summary
 void addLayer(Layer layer)
          Add a new layer to the map.
static void addListener()
           
static void addProjectionChangeListener(ProjectionChangeListener listener)
          Register a projection change listener
static void checkJava6()
           
static void debug(java.lang.String msg)
          Print an debug message if logging is on.
static void debug(java.lang.String msg, java.lang.Object... objects)
          Print a formated debug message if logging is on.
static void determinePlatformHook()
           
private static void downloadFromParamBounds(boolean rawGps, Bounds b)
          Download area specified as Bounds value.
private static void downloadFromParamBounds(boolean rawGps, java.lang.String s)
          Download area specified on the command line as bounds string.
private static void downloadFromParamHttp(boolean rawGps, java.lang.String s)
          Download area specified on the command line as OSM URL.
static boolean exitJosm(boolean exit)
           
private static void fireProjectionChanged(Projection oldValue, Projection newValue, Bounds oldBounds)
           
 Layer getActiveLayer()
          Returns the currently active layer
 DataSet getCurrentDataSet()
          Replies the current data set.
 OsmDataLayer getEditLayer()
          Replies the current edit layer
static Projection getProjection()
          Replies the current projection.
 boolean hasEditLayer()
          Replies true if there is an edit layer
static void info(java.lang.String msg)
          Print an informational message if logging is on.
static void info(java.lang.String msg, java.lang.Object... objects)
          Print a formated informational message if logging is on.
static boolean isDisplayingMapView()
          Replies true if JOSM currently displays a map view.
private  Main.DownloadParamType paramType(java.lang.String s)
          Guess the type of a parameter string specified on the command line with --download= or --downloadgps.
 void postConstructorProcessCmdLine(java.util.Map<MainApplication.Option,java.util.Collection<java.lang.String>> args)
           
static void preConstructorInit(java.util.Map<MainApplication.Option,java.util.Collection<java.lang.String>> args)
          Should be called before the main constructor to setup some parameter stuff
static void redirectToMainContentPane(javax.swing.JComponent source)
           
static void registerActionShortcut(javax.swing.Action action, Shortcut shortcut)
           
static void registerActionShortcut(JosmAction action)
           
 void removeLayer(Layer layer)
          Remove the specified layer from the map.
static void removeProjectionChangeListener(ProjectionChangeListener listener)
          Removes a projection change listener
static boolean saveUnsavedModifications()
           
static void setInitStatusListener(Main.InitStatusListener listener)
           
 void setMapFrame(MapFrame map)
          Set or clear (if passed null) the map.
static void setProjection(Projection p)
          Sets the current projection
static void unregisterActionShortcut(javax.swing.Action action, Shortcut shortcut)
           
static void unregisterActionShortcut(JosmAction action)
           
static void unregisterShortcut(Shortcut shortcut)
           
static void warn(java.lang.String msg)
          Print a warning message if logging is on.
static void warn(java.lang.String msg, java.lang.Object... objects)
          Print a formated warning message if logging is on.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parent

public static java.awt.Component parent
Global parent component for all dialogs and message boxes


main

public static Main main
Global application.


worker

public static final java.util.concurrent.ExecutorService worker
The worker thread slave. This is for executing all long and intensive calculations. The executed runnables are guaranteed to be executed separately and sequential.


pref

public static Preferences pref
Global application preferences


pasteBuffer

public static final PrimitiveDeepCopy pasteBuffer
The global paste buffer.


pasteSource

public static Layer pasteSource

map

public static MapFrame map
The MapFrame. Use setMapFrame to set or clear it.


applet

public static boolean applet
Set to true, when in applet mode


toolbar

public static ToolbarPreferences toolbar
The toolbar preference control to register new actions.


undoRedo

public UndoRedoHandler undoRedo

currentProgressMonitor

public static PleaseWaitProgressMonitor currentProgressMonitor

menu

public MainMenu menu
The main menu bar at top of screen.


validator

public OsmValidator validator
The data validation handler.


gettingStarted

private GettingStarted gettingStarted
The MOTD Layer.


log_level

public static int log_level
Logging level (3 = debug, 2 = info, 1 = warn, 0 = none).


platform

public static PlatformHook platform
Platform specific code goes in here. Plugins may replace it, however, some hooks will be called before any plugins have been loeaded. So if you need to hook into those early ones, split your class and send the one with the early hooks to the JOSM team for inclusion.


isOpenjdk

public static boolean isOpenjdk
Whether or not the java vm is openjdk We use this to work around openjdk bugs


initListener

private static Main.InitStatusListener initListener

contentPanePrivate

protected static final javax.swing.JPanel contentPanePrivate

panel

public static final javax.swing.JPanel panel

geometry

protected static WindowGeometry geometry

windowState

protected static int windowState

redoUndoListener

private final OsmDataLayer.CommandQueueListener redoUndoListener

proj

private static Projection proj
The projection method used. use getProjection() and setProjection(Projection) for access. Use setProjection(Projection) in order to trigger a projection change event.


listeners

private static final java.util.ArrayList<java.lang.ref.WeakReference<ProjectionChangeListener>> listeners
Constructor Detail

Main

public Main()
Method Detail

isDisplayingMapView

public static boolean isDisplayingMapView()
Replies true if JOSM currently displays a map view. False, if it doesn't, i.e. if it only shows the MOTD panel.

Returns:
true if JOSM currently displays a map view

warn

public static void warn(java.lang.String msg)
Print a warning message if logging is on.

Parameters:
msg - The message to print.

info

public static void info(java.lang.String msg)
Print an informational message if logging is on.

Parameters:
msg - The message to print.

debug

public static void debug(java.lang.String msg)
Print an debug message if logging is on.

Parameters:
msg - The message to print.

warn

public static void warn(java.lang.String msg,
                        java.lang.Object... objects)
Print a formated warning message if logging is on. Calls MessageFormat.format(java.lang.Object[], java.lang.StringBuffer, java.text.FieldPosition) function to format text.

Parameters:
msg - The formated message to print.
objects - The objects to insert into format string.

info

public static void info(java.lang.String msg,
                        java.lang.Object... objects)
Print a formated informational message if logging is on. Calls MessageFormat.format(java.lang.Object[], java.lang.StringBuffer, java.text.FieldPosition) function to format text.

Parameters:
msg - The formated message to print.
objects - The objects to insert into format string.

debug

public static void debug(java.lang.String msg,
                         java.lang.Object... objects)
Print a formated debug message if logging is on. Calls MessageFormat.format(java.lang.Object[], java.lang.StringBuffer, java.text.FieldPosition) function to format text.

Parameters:
msg - The formated message to print.
objects - The objects to insert into format string.

setMapFrame

public final void setMapFrame(MapFrame map)
Set or clear (if passed null) the map.


removeLayer

public final void removeLayer(Layer layer)
Remove the specified layer from the map. If it is the last layer, remove the map as well.


setInitStatusListener

public static void setInitStatusListener(Main.InitStatusListener listener)

addLayer

public final void addLayer(Layer layer)
Add a new layer to the map. If no map exists, create one.


hasEditLayer

public boolean hasEditLayer()
Replies true if there is an edit layer

Returns:
true if there is an edit layer

getEditLayer

public OsmDataLayer getEditLayer()
Replies the current edit layer

Returns:
the current edit layer. null, if no current edit layer exists

getCurrentDataSet

public DataSet getCurrentDataSet()
Replies the current data set.

Returns:
the current data set. null, if no current data set exists

getActiveLayer

public Layer getActiveLayer()
Returns the currently active layer

Returns:
the currently active layer. null, if currently no active layer exists

redirectToMainContentPane

public static void redirectToMainContentPane(javax.swing.JComponent source)

registerActionShortcut

public static void registerActionShortcut(JosmAction action)

registerActionShortcut

public static void registerActionShortcut(javax.swing.Action action,
                                          Shortcut shortcut)

unregisterShortcut

public static void unregisterShortcut(Shortcut shortcut)

unregisterActionShortcut

public static void unregisterActionShortcut(JosmAction action)

unregisterActionShortcut

public static void unregisterActionShortcut(javax.swing.Action action,
                                            Shortcut shortcut)

preConstructorInit

public static void preConstructorInit(java.util.Map<MainApplication.Option,java.util.Collection<java.lang.String>> args)
Should be called before the main constructor to setup some parameter stuff

Parameters:
args - The parsed argument list.

postConstructorProcessCmdLine

public void postConstructorProcessCmdLine(java.util.Map<MainApplication.Option,java.util.Collection<java.lang.String>> args)

saveUnsavedModifications

public static boolean saveUnsavedModifications()

exitJosm

public static boolean exitJosm(boolean exit)

paramType

private Main.DownloadParamType paramType(java.lang.String s)
Guess the type of a parameter string specified on the command line with --download= or --downloadgps.

Parameters:
s - A parameter string
Returns:
The guessed parameter type

downloadFromParamHttp

private static void downloadFromParamHttp(boolean rawGps,
                                          java.lang.String s)
Download area specified on the command line as OSM URL.

Parameters:
rawGps - Flag to download raw GPS tracks
s - The URL parameter

downloadFromParamBounds

private static void downloadFromParamBounds(boolean rawGps,
                                            java.lang.String s)
Download area specified on the command line as bounds string.

Parameters:
rawGps - Flag to download raw GPS tracks
s - The bounds parameter

downloadFromParamBounds

private static void downloadFromParamBounds(boolean rawGps,
                                            Bounds b)
Download area specified as Bounds value.

Parameters:
rawGps - Flag to download raw GPS tracks
b - The bounds value
See Also:
downloadFromParamBounds(boolean, String), downloadFromParamHttp(boolean, java.lang.String)

determinePlatformHook

public static void determinePlatformHook()

addListener

public static void addListener()

checkJava6

public static void checkJava6()

getProjection

public static Projection getProjection()
Replies the current projection.

Returns:
the currently active projection

setProjection

public static void setProjection(Projection p)
Sets the current projection

Parameters:
p - the projection

fireProjectionChanged

private static void fireProjectionChanged(Projection oldValue,
                                          Projection newValue,
                                          Bounds oldBounds)

addProjectionChangeListener

public static void addProjectionChangeListener(ProjectionChangeListener listener)
Register a projection change listener

Parameters:
listener - the listener. Ignored if null.

removeProjectionChangeListener

public static void removeProjectionChangeListener(ProjectionChangeListener listener)
Removes a projection change listener

Parameters:
listener - the listener. Ignored if null.


JOSM