public abstract class Main extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
(package private) static class |
Main.DownloadParamType
The type of a command line parameter, to be used in switch statements.
|
private static class |
Main.InitializationTask |
static interface |
Main.InitStatusListener
Initialization task listener.
|
protected static class |
Main.MasterWindowListener
WindowListener, that is registered on all Windows of the application.
|
static interface |
Main.WindowSwitchListener
Listener for window switch events.
|
Modifier and Type | Field and Description |
---|---|
protected static java.util.List<java.lang.String> |
COMMAND_LINE_ARGS
Command-line arguments used to run the application.
|
protected static javax.swing.JPanel |
contentPanePrivate |
static PleaseWaitProgressMonitor |
currentProgressMonitor
The progress monitor being currently displayed.
|
static FileWatcher |
fileWatcher
The file watcher service.
|
private static Main.InitStatusListener |
initListener |
private static java.lang.String |
JOSM_WEBSITE
The JOSM website URL.
|
private static MainLayerManager |
layerManager
Provides access to the layers displayed in the main view.
|
private static java.util.List<java.lang.ref.WeakReference<ProjectionChangeListener>> |
listeners |
static int |
logLevel
Deprecated.
Use
Logging class. |
static Main |
main
Global application.
|
protected static MainPanel |
mainPanel
The real main panel.
|
static MapFrame |
map
The MapFrame.
|
MainMenu |
menu
The main menu bar at top of screen.
|
protected static java.util.Map<java.lang.String,java.lang.Throwable> |
NETWORK_ERRORS |
private static java.util.Set<OnlineResource> |
OFFLINE_RESOURCES |
private static java.lang.String |
OSM_WEBSITE
The OSM website URL.
|
static javax.swing.JPanel |
panel
Global panel.
|
static java.awt.Component |
parent
Global parent component for all dialogs and message boxes
|
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.
|
private static java.util.List<java.lang.ref.WeakReference<Main.WindowSwitchListener>> |
windowSwitchListeners |
static java.util.concurrent.ExecutorService |
worker
The worker thread slave.
|
Constructor and Description |
---|
Main()
Constructs new
Main object. |
Modifier and Type | Method and Description |
---|---|
void |
addLayer(Layer layer,
ProjectionBounds bounds)
Add a new layer to the map.
|
void |
addLayer(Layer layer,
ViewportData viewport)
Add a new layer to the map.
|
static boolean |
addMapFrameListener(MapFrameListener listener)
Registers a new
MapFrameListener that will be notified of MapFrame changes |
static boolean |
addMapFrameListener(MapFrameListener listener,
boolean fireWhenMapViewPresent)
Registers a new
MapFrameListener that will be notified of MapFrame changes |
static java.lang.Throwable |
addNetworkError(java.lang.String url,
java.lang.Throwable t)
Adds a new network error that occur to give a hint about broken Internet connection.
|
static java.lang.Throwable |
addNetworkError(java.net.URL url,
java.lang.Throwable t)
Adds a new network error that occur to give a hint about broken Internet connection.
|
static void |
addProjectionChangeListener(ProjectionChangeListener listener)
Register a projection change listener.
|
static void |
addWindowSwitchListener(Main.WindowSwitchListener listener)
Register a window switch listener.
|
static void |
clearLastErrorAndWarnings()
Clears the list of last error and warning messages.
|
static void |
debug(java.lang.String msg)
Prints a debug message if logging is on.
|
static void |
debug(java.lang.String msg,
java.lang.Object... objects)
Prints a formatted debug message if logging is on.
|
static void |
debug(java.lang.Throwable t)
Prints a debug message for the given Throwable.
|
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.
|
static void |
error(java.lang.String msg)
Prints an error message if logging is on.
|
static void |
error(java.lang.String msg,
java.lang.Object... objects)
Prints a formatted error message if logging is on.
|
static void |
error(java.lang.Throwable t)
Prints an error message for the given Throwable.
|
static void |
error(java.lang.Throwable t,
boolean stackTrace)
Prints an error message for the given Throwable.
|
static void |
error(java.lang.Throwable t,
java.lang.String message)
Prints an error message for the given Throwable.
|
static boolean |
exitJosm(boolean exit,
int exitCode,
SaveLayersDialog.Reason reason)
Closes JOSM and optionally terminates the Java Virtual Machine (JVM).
|
private static void |
fireProjectionChanged(Projection oldValue,
Projection newValue,
Bounds oldBounds) |
static java.lang.String |
getBaseBrowseUrl()
Replies the base URL for browsing information about a primitive.
|
static java.lang.String |
getBaseUserUrl()
Replies the base URL for browsing information about a user.
|
static java.util.List<java.lang.String> |
getCommandLineArgs()
Returns the command-line arguments used to run the application.
|
static java.lang.String |
getErrorMessage(java.lang.Throwable t)
Returns a human-readable message of error, also usable for developers.
|
java.util.Collection<OsmPrimitive> |
getInProgressSelection()
Replies the current selected primitives, from a end-user point of view.
|
static java.lang.String |
getJOSMWebsite()
Returns the JOSM website URL.
|
static java.util.Collection<java.lang.String> |
getLastErrorAndWarnings()
Replies the first lines of last 5 error and warning messages, used for bug reports
|
static MainLayerManager |
getLayerManager()
Returns the main layer manager that is used by the map view.
|
static java.util.Map<java.lang.String,java.lang.Throwable> |
getNetworkErrors()
Returns the network errors that occured until now.
|
static java.util.Set<OnlineResource> |
getOfflineResources()
Replies the set of online resources currently offline.
|
static java.lang.String |
getOSMWebsite()
Returns the OSM website URL.
|
private static java.lang.String |
getOSMWebsiteDependingOnSelectedApi()
Returns the OSM website URL depending on the selected
OsmApi . |
static Projection |
getProjection()
Replies the current projection.
|
static javax.swing.Action |
getRegisteredActionShortcut(Shortcut shortcut)
Replies the registered action for the given shortcut
|
static java.lang.String |
getXMLBase()
Returns the JOSM XML URL.
|
static void |
info(java.lang.String msg)
Prints an informational message if logging is on.
|
static void |
info(java.lang.String msg,
java.lang.Object... objects)
Prints a formatted informational message if logging is on.
|
void |
initialize()
Initializes the main object.
|
protected void |
initializeMainWindow()
Called once at startup to initialize the main window content.
|
static boolean |
isDebugEnabled()
Determines if debug log level is enabled.
|
static boolean |
isDisplayingMapView()
Replies true if JOSM currently displays a map view.
|
static boolean |
isOffline(OnlineResource r)
Determines if the given online resource is currently offline.
|
static boolean |
isPlatformOsx()
Determines if we are currently running on OSX.
|
static boolean |
isPlatformWindows()
Determines if we are currently running on Windows.
|
static boolean |
isTraceEnabled()
Determines if trace log level is enabled.
|
protected static void |
postConstructorProcessCmdLine(ProgramArguments args) |
static void |
preConstructorInit()
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)
Registers an action and its shortcut.
|
static void |
registerActionShortcut(JosmAction action)
Registers a
JosmAction and its shortcut. |
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 void |
setInitStatusListener(Main.InitStatusListener listener)
Sets initialization task listener.
|
static boolean |
setOffline(OnlineResource r)
Sets the given online resource to offline state.
|
static boolean |
setOnline(OnlineResource r)
Sets the given online resource to online state.
|
static void |
setProjection(Projection p)
Sets the current projection
|
protected void |
shutdown() |
static void |
trace(java.lang.String msg)
Prints a trace message if logging is on.
|
static void |
trace(java.lang.String msg,
java.lang.Object... objects)
Prints a formatted trace message if logging is on.
|
static void |
trace(java.lang.Throwable t)
Prints a trace message for the given Throwable.
|
static void |
unregisterActionShortcut(javax.swing.Action action,
Shortcut shortcut)
Unregisters an action and its shortcut.
|
static void |
unregisterActionShortcut(JosmAction action)
Unregisters a
JosmAction and its shortcut. |
static void |
unregisterShortcut(Shortcut shortcut)
Unregisters a shortcut.
|
static void |
warn(java.lang.String msg)
Prints a warning message if logging is on.
|
static void |
warn(java.lang.String msg,
java.lang.Object... objects)
Prints a formatted warning message if logging is on.
|
static void |
warn(java.lang.Throwable t)
Prints a warning message for the given Throwable.
|
static void |
warn(java.lang.Throwable t,
boolean stackTrace)
Prints a warning message for the given Throwable.
|
static void |
warn(java.lang.Throwable t,
java.lang.String message)
Prints a warning message for the given Throwable.
|
private static final java.lang.String JOSM_WEBSITE
private static final java.lang.String OSM_WEBSITE
public static java.awt.Component parent
protected static final java.util.List<java.lang.String> COMMAND_LINE_ARGS
public static final java.util.concurrent.ExecutorService worker
public static final Preferences pref
public static MapFrame map
There should be no need to access this to access any map data. Use layerManager
instead.
MainPanel
private static final MainLayerManager layerManager
public static volatile ToolbarPreferences toolbar
public final UndoRedoHandler undoRedo
public static PleaseWaitProgressMonitor currentProgressMonitor
public static final FileWatcher fileWatcher
protected static final java.util.Map<java.lang.String,java.lang.Throwable> NETWORK_ERRORS
private static final java.util.Set<OnlineResource> OFFLINE_RESOURCES
@Deprecated public static int logLevel
Logging
class.protected static final MainPanel mainPanel
MainFrame
panel
public static volatile PlatformHook platform
private static volatile Main.InitStatusListener initListener
protected static final javax.swing.JPanel contentPanePrivate
public static final javax.swing.JPanel panel
private final OsmDataLayer.CommandQueueListener redoUndoListener
private static volatile Projection proj
getProjection()
and setProjection(Projection)
for access.
Use setProjection(Projection)
in order to trigger a projection change event.private static final java.util.List<java.lang.ref.WeakReference<ProjectionChangeListener>> listeners
private static final java.util.List<java.lang.ref.WeakReference<Main.WindowSwitchListener>> windowSwitchListeners
public Main()
Main
object.initialize()
public static boolean isDisplayingMapView()
You do not need this when accessing the layer manager. The layer manager will be empty if no map view is shown.
true
if JOSM currently displays a map viewpublic static final java.util.Collection<java.lang.String> getLastErrorAndWarnings()
public static void clearLastErrorAndWarnings()
public static void error(java.lang.String msg)
msg
- The message to print.public static void warn(java.lang.String msg)
msg
- The message to print.public static void info(java.lang.String msg)
msg
- The message to print.public static void debug(java.lang.String msg)
msg
- The message to print.public static void trace(java.lang.String msg)
msg
- The message to print.public static boolean isDebugEnabled()
true
if log level is at least debug, false
otherwisepublic static boolean isTraceEnabled()
true
if log level is at least trace, false
otherwisepublic static void error(java.lang.String msg, java.lang.Object... objects)
MessageFormat.format(java.lang.Object[], java.lang.StringBuffer, java.text.FieldPosition)
function to format text.msg
- The formatted message to print.objects
- The objects to insert into format string.public static void warn(java.lang.String msg, java.lang.Object... objects)
MessageFormat.format(java.lang.Object[], java.lang.StringBuffer, java.text.FieldPosition)
function to format text.msg
- The formatted message to print.objects
- The objects to insert into format string.public static void info(java.lang.String msg, java.lang.Object... objects)
MessageFormat.format(java.lang.Object[], java.lang.StringBuffer, java.text.FieldPosition)
function to format text.msg
- The formatted message to print.objects
- The objects to insert into format string.public static void debug(java.lang.String msg, java.lang.Object... objects)
MessageFormat.format(java.lang.Object[], java.lang.StringBuffer, java.text.FieldPosition)
function to format text.msg
- The formatted message to print.objects
- The objects to insert into format string.public static void trace(java.lang.String msg, java.lang.Object... objects)
MessageFormat.format(java.lang.Object[], java.lang.StringBuffer, java.text.FieldPosition)
function to format text.msg
- The formatted message to print.objects
- The objects to insert into format string.public static void error(java.lang.Throwable t)
t
- The throwable object causing the errorpublic static void warn(java.lang.Throwable t)
t
- The throwable object causing the errorpublic static void debug(java.lang.Throwable t)
t
- The throwable object causing the errorpublic static void trace(java.lang.Throwable t)
t
- The throwable object causing the errorpublic static void error(java.lang.Throwable t, boolean stackTrace)
t
- The throwable object causing the errorstackTrace
- true
, if the stacktrace should be displayedpublic static void error(java.lang.Throwable t, java.lang.String message)
t
- The throwable object causing the errormessage
- additional error messagepublic static void warn(java.lang.Throwable t, boolean stackTrace)
t
- The throwable object causing the errorstackTrace
- true
, if the stacktrace should be displayedpublic static void warn(java.lang.Throwable t, java.lang.String message)
t
- The throwable object causing the errormessage
- additional error messagepublic static java.lang.String getErrorMessage(java.lang.Throwable t)
t
- The errorpublic static void setInitStatusListener(Main.InitStatusListener listener)
listener
- initialization task listenerpublic void initialize()
protected void initializeMainWindow()
menu
public static MainLayerManager getLayerManager()
public final void addLayer(Layer layer, ProjectionBounds bounds)
layer
- the layerbounds
- the bounds of the layer (target zoom area); can be null, then
the viewport isn't changedpublic final void addLayer(Layer layer, ViewportData viewport)
layer
- the layerviewport
- the viewport to zoom to; can be null, then the viewport isn't changedpublic java.util.Collection<OsmPrimitive> getInProgressSelection()
DataSet.getSelected()
.
Indeed, if the user is currently in drawing mode, only the way currently being drawn is returned,
see DrawAction.getInProgressSelection()
.null
.public static void redirectToMainContentPane(javax.swing.JComponent source)
public static void registerActionShortcut(JosmAction action)
JosmAction
and its shortcut.action
- action defining its own shortcutpublic static void registerActionShortcut(javax.swing.Action action, Shortcut shortcut)
action
- action to registershortcut
- shortcut to associate to action
public static void unregisterShortcut(Shortcut shortcut)
shortcut
- shortcut to unregisterpublic static void unregisterActionShortcut(JosmAction action)
JosmAction
and its shortcut.action
- action to unregisterpublic static void unregisterActionShortcut(javax.swing.Action action, Shortcut shortcut)
action
- action to unregistershortcut
- shortcut to unregisterpublic static javax.swing.Action getRegisteredActionShortcut(Shortcut shortcut)
shortcut
- The shortcut to look forpublic static void preConstructorInit()
protected static void postConstructorProcessCmdLine(ProgramArguments args)
public static boolean exitJosm(boolean exit, int exitCode, SaveLayersDialog.Reason reason)
exit
- If true
, the JVM is terminated by running System.exit(int)
with a given return code.exitCode
- The return codereason
- the reason for exitingtrue
if JOSM has been closed, false
if the user has cancelled the operation.protected void shutdown()
private static void downloadFromParamBounds(boolean rawGps, Bounds b)
rawGps
- Flag to download raw GPS tracksb
- The bounds valuepublic static void determinePlatformHook()
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, boolean fireWhenMapViewPresent)
MapFrameListener
that will be notified of MapFrame changeslistener
- The MapFrameListenerfireWhenMapViewPresent
- If true, will fire an initial mapFrameInitialized event
when the MapFrame is present. Otherwise will only fire when the MapFrame is created
or destroyed.true
if the listeners collection changed as a result of the callpublic 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 callpublic static java.lang.Throwable addNetworkError(java.net.URL url, java.lang.Throwable t)
url
- The accessed URL that caused the errort
- The network errornull
public static java.lang.Throwable addNetworkError(java.lang.String url, java.lang.Throwable t)
url
- The accessed URL that caused the errort
- The network errornull
public static java.util.Map<java.lang.String,java.lang.Throwable> getNetworkErrors()
public static java.util.List<java.lang.String> getCommandLineArgs()
public static java.lang.String getJOSMWebsite()
public static java.lang.String getXMLBase()
public static java.lang.String getOSMWebsite()
private static java.lang.String getOSMWebsiteDependingOnSelectedApi()
OsmApi
.OsmApi
public static java.lang.String getBaseBrowseUrl()
public static java.lang.String getBaseUserUrl()
public static boolean isPlatformOsx()
true
if we are currently running on OSXpublic static boolean isPlatformWindows()
true
if we are currently running on Windowspublic static boolean isOffline(OnlineResource r)
r
- the online resourcetrue
if r
is offline and should not be accessedpublic static boolean setOffline(OnlineResource r)
r
- the online resourcetrue
if r
was not already offlinepublic static boolean setOnline(OnlineResource r)
r
- the online resourcetrue
if r
was offlinepublic static java.util.Set<OnlineResource> getOfflineResources()