public abstract class Main extends Object
Modifier and Type | Class and Description |
---|---|
private static class |
Main.DownloadParamType
The type of a command line parameter, to be used in switch statements.
|
static interface |
Main.InitStatusListener |
protected static class |
Main.MasterWindowListener
WindowListener, that is registered on all Windows of the application.
|
private static class |
Main.WindowPositionSizeListener |
static interface |
Main.WindowSwitchListener
Listener for window switch events.
|
Modifier and Type | Field and Description |
---|---|
static boolean |
applet
Set to
true , when in applet mode |
static String[] |
commandLineArgs
Command-line arguments used to run the application.
|
protected static JPanel |
contentPanePrivate |
static PleaseWaitProgressMonitor |
currentProgressMonitor
The progress monitor being currently displayed.
|
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
|
static String |
JOSM_WEBSITE
The JOSM website URL.
|
private static List<WeakReference<ProjectionChangeListener>> |
listeners |
static int |
logLevel
Logging level (4 = debug, 3 = info, 2 = warn, 1 = error, 0 = none).
|
static Main |
main
Global application.
|
static MapFrame |
map
The MapFrame.
|
private static Collection<MapFrameListener> |
mapFrameListeners |
MainMenu |
menu
The main menu bar at top of screen.
|
static String |
OSM_WEBSITE
The OSM website URL.
|
static JPanel |
panel
Global panel.
|
static Component |
parent
Global parent component for all dialogs and message boxes
|
static PrimitiveDeepCopy |
pasteBuffer
The global paste buffer.
|
static Layer |
pasteSource
The layer source from which
pasteBuffer data comes from. |
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
The commands undo/redo handler.
|
OsmValidator |
validator
The data validation handler.
|
protected static int |
windowState |
private static List<WeakReference<Main.WindowSwitchListener>> |
windowSwitchListeners |
static ExecutorService |
worker
The worker thread slave.
|
Constructor and Description |
---|
Main() |
Modifier and Type | Method and Description |
---|---|
void |
addLayer(Layer layer)
Add a new layer to the map.
|
protected static void |
addListener() |
static boolean |
addMapFrameListener(MapFrameListener listener)
Registers a new
MapFrameListener that will be notified of MapFrame changes |
static void |
addProjectionChangeListener(ProjectionChangeListener listener)
Register a projection change listener.
|
static void |
addWindowSwitchListener(Main.WindowSwitchListener listener)
Register a window switch listener.
|
static void |
checkJava6()
Checks that JOSM is at least running with Java 6.
|
void |
createMapFrame(Layer firstLayer,
NavigatableComponent.ViewportData viewportData) |
static void |
debug(String msg)
Prints a debug message if logging is on.
|
static void |
debug(String msg,
Object... objects)
Prints a formated debug message if logging is on.
|
static void |
determinePlatformHook()
Identifies the current operating system family and initializes the platform hook accordingly.
|
private static void |
downloadFromParamBounds(boolean rawGps,
Bounds b)
Download area specified as Bounds value.
|
private static void |
downloadFromParamBounds(boolean rawGps,
String s)
Download area specified on the command line as bounds string.
|
private static void |
downloadFromParamHttp(boolean rawGps,
String s)
Download area specified on the command line as OSM URL.
|
static void |
error(String msg)
Prints an error message if logging is on.
|
static void |
error(String msg,
Object... objects)
Prints a formated error message if logging is on.
|
static void |
error(Throwable t)
Prints an error message for the given Throwable.
|
static boolean |
exitJosm(boolean exit,
int exitCode)
Closes JOSM and optionally terminates the Java Virtual Machine (JVM).
|
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
|
private static String |
getErrorMessage(Throwable t) |
static Projection |
getProjection()
Replies the current projection.
|
static Action |
getRegisteredActionShortcut(Shortcut shortcut)
Replies the registered action for the given shortcut
|
boolean |
hasEditLayer()
Replies
true if there is an edit layer |
static void |
info(String msg)
Prints an informational message if logging is on.
|
static void |
info(String msg,
Object... objects)
Prints a formated informational message if logging is on.
|
static void |
initAppletPreferences(URL serverURL)
Initializes
Main.pref in applet context. |
static void |
initApplicationPreferences()
Initializes
Main.pref in normal application context. |
static boolean |
isDisplayingMapView()
Replies true if JOSM currently displays a map view.
|
private static Main.DownloadParamType |
paramType(String s)
Guess the type of a parameter string specified on the command line with --download= or --downloadgps.
|
protected static void |
postConstructorProcessCmdLine(Map<MainApplication.Option,Collection<String>> args) |
static void |
preConstructorInit(Map<MainApplication.Option,Collection<String>> args)
Should be called before the main constructor to setup some parameter stuff
|
static void |
redirectToMainContentPane(JComponent source) |
static void |
registerActionShortcut(Action action,
Shortcut shortcut) |
static void |
registerActionShortcut(JosmAction action) |
void |
removeLayer(Layer layer)
Remove the specified layer from the map.
|
static boolean |
removeMapFrameListener(MapFrameListener listener)
Unregisters the given
MapFrameListener from MapFrame changes |
static void |
removeProjectionChangeListener(ProjectionChangeListener listener)
Removes a projection change listener.
|
static void |
removeWindowSwitchListener(Main.WindowSwitchListener listener)
Removes a window switch listener.
|
static boolean |
saveUnsavedModifications()
Asks user to perform "save layer" operations (save .osm on disk and/or upload osm data to server) for all
OsmDataLayer before JOSM exits. |
static boolean |
saveUnsavedModifications(List<? extends Layer> selectedLayers,
boolean exit)
Asks user to perform "save layer" operations (save .osm on disk and/or upload osm data to server) before osm layers deletion.
|
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(Action action,
Shortcut shortcut) |
static void |
unregisterActionShortcut(JosmAction action) |
static void |
unregisterShortcut(Shortcut shortcut) |
static void |
warn(String msg)
Prints a warning message if logging is on.
|
static void |
warn(String msg,
Object... objects)
Prints a formated warning message if logging is on.
|
static void |
warn(Throwable t)
Prints a warning message for the given Throwable.
|
public static final String JOSM_WEBSITE
public static final String OSM_WEBSITE
public static String[] commandLineArgs
public static final ExecutorService worker
public static Preferences pref
public static final PrimitiveDeepCopy pasteBuffer
public static Layer pasteSource
pasteBuffer
data comes from.public static MapFrame map
setMapFrame(org.openstreetmap.josm.gui.MapFrame)
to set or clear it.public static boolean applet
true
, when in applet modepublic static ToolbarPreferences toolbar
public UndoRedoHandler undoRedo
public static PleaseWaitProgressMonitor currentProgressMonitor
public OsmValidator validator
private GettingStarted gettingStarted
private static final Collection<MapFrameListener> mapFrameListeners
public static int logLevel
public static PlatformHook platform
public static boolean isOpenjdk
private static Main.InitStatusListener initListener
protected static final JPanel contentPanePrivate
protected static WindowGeometry geometry
protected static int windowState
private final OsmDataLayer.CommandQueueListener redoUndoListener
private static Projection proj
getProjection()
and setProjection(Projection)
for access.
Use setProjection(Projection)
in order to trigger a projection change event.private static final List<WeakReference<ProjectionChangeListener>> listeners
private static final List<WeakReference<Main.WindowSwitchListener>> windowSwitchListeners
public Main()
public static boolean isDisplayingMapView()
true
if JOSM currently displays a map viewpublic static void error(String msg)
msg
- The message to print.public static void warn(String msg)
msg
- The message to print.public static void info(String msg)
msg
- The message to print.public static void debug(String msg)
msg
- The message to print.public static void error(String msg, Object... objects)
MessageFormat.format(java.lang.Object[], java.lang.StringBuffer, java.text.FieldPosition)
function to format text.msg
- The formated message to print.objects
- The objects to insert into format string.public static void warn(String msg, Object... objects)
MessageFormat.format(java.lang.Object[], java.lang.StringBuffer, java.text.FieldPosition)
function to format text.msg
- The formated message to print.objects
- The objects to insert into format string.public static void info(String msg, Object... objects)
MessageFormat.format(java.lang.Object[], java.lang.StringBuffer, java.text.FieldPosition)
function to format text.msg
- The formated message to print.objects
- The objects to insert into format string.public static void debug(String msg, Object... objects)
MessageFormat.format(java.lang.Object[], java.lang.StringBuffer, java.text.FieldPosition)
function to format text.msg
- The formated message to print.objects
- The objects to insert into format string.public static void error(Throwable t)
t
- The throwable object causing the errorpublic static void warn(Throwable t)
t
- The throwable object causing the errorprivate static String getErrorMessage(Throwable t)
public static void initAppletPreferences(URL serverURL)
Main.pref
in applet context.serverURL
- The server URL hosting the user preferences.public static void initApplicationPreferences()
Main.pref
in normal application context.public final void setMapFrame(MapFrame map)
null
) the map.map
- The map to set map
to. Can be null.public final void removeLayer(Layer layer)
layer
- The layer to removepublic static void setInitStatusListener(Main.InitStatusListener listener)
public final void addLayer(Layer layer)
public void createMapFrame(Layer firstLayer, NavigatableComponent.ViewportData viewportData)
public boolean hasEditLayer()
true
if there is an edit layertrue
if there is an edit layerpublic OsmDataLayer getEditLayer()
null
, if no current edit layer existspublic DataSet getCurrentDataSet()
null
, if no current data set existspublic Layer getActiveLayer()
null
, if currently no active layer existspublic static void redirectToMainContentPane(JComponent source)
public static void registerActionShortcut(JosmAction action)
public static void registerActionShortcut(Action action, Shortcut shortcut)
public static void unregisterShortcut(Shortcut shortcut)
public static void unregisterActionShortcut(JosmAction action)
public static void unregisterActionShortcut(Action action, Shortcut shortcut)
public static Action getRegisteredActionShortcut(Shortcut shortcut)
shortcut
- The shortcut to look forpublic static void preConstructorInit(Map<MainApplication.Option,Collection<String>> args)
args
- The parsed argument list.protected static void postConstructorProcessCmdLine(Map<MainApplication.Option,Collection<String>> args)
public static boolean saveUnsavedModifications()
OsmDataLayer
before JOSM exits.true
if there was nothing to save, or if the user wants to proceed to save operations. false
if the user cancels.public static boolean saveUnsavedModifications(List<? extends Layer> selectedLayers, boolean exit)
selectedLayers
- The layers to check. Only instances of OsmDataLayer
are considered.exit
- true
if JOSM is exiting, false
otherwise.true
if there was nothing to save, or if the user wants to proceed to save operations. false
if the user cancels.public static boolean exitJosm(boolean exit, int exitCode)
exit
- If true
, the JVM is terminated by running System.exit(int)
with a given return code.exitCode
- The return codetrue
if JOSM has been closed, false
if the user has cancelled the operation.private static Main.DownloadParamType paramType(String s)
s
- A parameter stringprivate static void downloadFromParamHttp(boolean rawGps, String s)
rawGps
- Flag to download raw GPS trackss
- The URL parameterprivate static void downloadFromParamBounds(boolean rawGps, String s)
rawGps
- Flag to download raw GPS trackss
- The bounds parameterprivate static void downloadFromParamBounds(boolean rawGps, Bounds b)
rawGps
- Flag to download raw GPS tracksb
- The bounds valuedownloadFromParamBounds(boolean, String)
,
downloadFromParamHttp(boolean, java.lang.String)
public static void determinePlatformHook()
protected static void addListener()
public static void checkJava6()
public static Projection getProjection()
public static void setProjection(Projection p)
p
- the projectionprivate static void fireProjectionChanged(Projection oldValue, Projection newValue, Bounds oldBounds)
public static void addProjectionChangeListener(ProjectionChangeListener listener)
listener
- the listener. Ignored if null
.public static void removeProjectionChangeListener(ProjectionChangeListener listener)
listener
- the listener. Ignored if null
.public static void addWindowSwitchListener(Main.WindowSwitchListener listener)
listener
- the listener. Ignored if null
.public static void removeWindowSwitchListener(Main.WindowSwitchListener listener)
listener
- the listener. Ignored if null
.public static boolean addMapFrameListener(MapFrameListener listener)
MapFrameListener
that will be notified of MapFrame changeslistener
- The MapFrameListenertrue
if the listeners collection changed as a result of the callpublic static boolean removeMapFrameListener(MapFrameListener listener)
MapFrameListener
from MapFrame changeslistener
- The MapFrameListenertrue
if the listeners collection changed as a result of the call