Package org.openstreetmap.josm.gui
Class MainApplication
java.lang.Object
org.openstreetmap.josm.gui.MainApplication
Main window class application.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classprivate static class -
Field Summary
FieldsModifier and TypeFieldDescriptionCommand-line arguments used to run the application.(package private) static JComponentThe private content pane ofMainFrame, required to be static for shortcut handling.static final CLIModuleDefault JOSM command line interface.static final NTV2GridShiftFileSourceSource of NTV2 shift files: Download from JOSM website.private static final MainLayerManagerProvides access to the layers displayed in the main view.private static final ProjectionBoundsProviderprivate static MainFrame(package private) static MainPanelThe main panel, required to be static forMapFrameListenerhandling.(package private) static MapFrameThe MapFrame.(package private) static MainMenuThe main menu bar at top of screen.private static final StringThe preference key for the startup failure counter(package private) final UndoRedoHandler.CommandQueueListenerListener that sets the enabled state of undo/redo menu entries.(package private) static ToolbarPreferencesThe toolbar preference control to register new actions.private static final LayerManager.LayerChangeListenerstatic final ExecutorServiceThe worker thread slave. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newMainApplicationwithout a window.MainApplication(MainFrame mainFrame) Constructs a main frame, ready sized and operating. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanaddAndFireMapFrameListener(MapFrameListener listener) Registers a newMapFrameListenerthat will be notified of MapFrame changes.static booleanaddMapFrameListener(MapFrameListener listener) Registers a newMapFrameListenerthat will be notified of MapFrame changesprivate static String(package private) static voidApply workarounds for LaF and platform specific issues.private static voidaskUpdate(String title, String update, String property, String icon, StringBuilder content, String url) static voidaskUpdateJava(String updVersion, String url, String eolDate, boolean major) Asks user to update its version of Java.private static voidCheck if IPv6 can be safely enabled and do so.private static MainFramecreateMainFrame(WindowGeometry geometry) downloadFromParamBounds(boolean rawGps, Bounds b) Download area specified as Bounds value.static booleanexitJosm(boolean exit, int exitCode, SaveLayersDialog.Reason reason) Closes JOSM and optionally terminates the Java Virtual Machine (JVM).Returns the command-line arguments used to run the application.(package private) static StringgetHelp()static MainLayerManagerReturns the main layer manager that is used by the map view.static MainFrameReturns the JOSM main frame.static MainPanelReturns the main panel.static MapFramegetMap()Returns the MapFrame.static MainMenugetMenu()Returns the main menu, at top of screen.static ActiongetRegisteredActionShortcut(Shortcut shortcut) Replies the registered action for the given shortcutstatic ToolbarPreferencesReturns the toolbar preference control to register new actions.protected voidCalled once at startup to initialize the main window content.static booleanReplies true if JOSM currently displays a map view.(package private) static voidloadLatePlugins(SplashScreen splash, SplashScreen.SplashProgressMonitor monitor, Collection<PluginInformation> pluginsToLoad) static voidMain application Startupstatic voidmainJOSM(ProgramArguments args) Main method to run the JOSM GUI.(package private) static voidnotifyNewMessages(UserInfo userInfo) Handle command line instructions after GUI has been initialized.private static voidstatic voidredirectToMainContentPane(JComponent source) Redirects the key inputs fromsourceto main content pane.static voidregisterActionShortcut(Action action, Shortcut shortcut) Registers an action and its shortcut.static voidregisterActionShortcut(JosmAction action) Registers aJosmActionand its shortcut.static voidregisterCLIModule(CLIModule module) Register a command line interface module.static booleanremoveMapFrameListener(MapFrameListener listener) Unregisters the givenMapFrameListenerfrom MapFrame changesstatic voidsanityCheckFailed(String title, boolean canContinue, String... message) Tells the user that a sanity check failedprivate static voidscaleFonts(double factor, String... fonts) (package private) static voidstatic voidSetup the sources for NTV2 grid shift files for projection support.private static void(package private) static voidSet up the UI managerstatic voidshowHelp()Displays help on the consolestatic voidunregisterActionShortcut(Action action, Shortcut shortcut) Unregisters an action and its shortcut.static voidunregisterActionShortcut(JosmAction action) Unregisters aJosmActionand its shortcut.static voidunregisterShortcut(Shortcut shortcut) Unregisters a shortcut.(package private) static Collection<PluginInformation>updateAndLoadEarlyPlugins(SplashScreen splash, SplashScreen.SplashProgressMonitor monitor) private static voidUpdates system properties with the current values in the preferences.
-
Field Details
-
commandLineArgs
Command-line arguments used to run the application. -
PREF_STARTUP_FAILURE_COUNTER
The preference key for the startup failure counter- See Also:
-
mainPanel
The main panel, required to be static forMapFrameListenerhandling. -
contentPanePrivate
The private content pane ofMainFrame, required to be static for shortcut handling. -
map
The MapFrame. -
toolbar
The toolbar preference control to register new actions. -
mainFrame
-
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.- Since:
- 12634 (as a replacement to
Main.worker)
-
layerManager
Provides access to the layers displayed in the main view. -
undoRedoCleaner
-
mainBoundsProvider
-
cliModules
-
JOSM_CLI_MODULE
Default JOSM command line interface.Runs JOSM and performs some action, depending on the options and positional arguments.
-
redoUndoListener
Listener that sets the enabled state of undo/redo menu entries. -
JOSM_WEBSITE_NTV2_SOURCE
Source of NTV2 shift files: Download from JOSM website.- Since:
- 12777
-
-
Constructor Details
-
MainApplication
public MainApplication()Constructs a newMainApplicationwithout a window. -
MainApplication
Constructs a main frame, ready sized and operating. Does not display the frame.- Parameters:
mainFrame- The main JFrame of the application- Since:
- 10340
-
-
Method Details
-
registerCLIModule
Register a command line interface module.- Parameters:
module- the module- Since:
- 12886
-
askUpdate
-
askUpdateJava
Asks user to update its version of Java.- Parameters:
updVersion- target update versionurl- download URLmajor- true for a migration towards a major version of Java (8:11), false otherwiseeolDate- the EOL/expiration date- Since:
- 12270
-
sanityCheckFailed
Tells the user that a sanity check failed- Parameters:
title- The title of the message to showcanContinue-trueif the failed sanity check(s) will not instantly kill JOSM when the user editsmessage- The message parts to show the user (as a list)
-
initializeMainWindow
-
getMainFrame
Returns the JOSM main frame.- Returns:
- the JOSM main frame
- Since:
- 14140
-
getCommandLineArgs
Returns the command-line arguments used to run the application.- Returns:
- the command-line arguments used to run the application
- Since:
- 11650
-
getLayerManager
Returns the main layer manager that is used by the map view.- Returns:
- The layer manager. The value returned will never change.
- Since:
- 12636 (as a replacement to
Main.getLayerManager())
-
getMap
Returns the MapFrame.There should be no need to access this to access any map data. Use
layerManagerinstead.- Returns:
- the MapFrame
- Since:
- 12630
- See Also:
-
getMainPanel
Returns the main panel.- Returns:
- the main panel
- Since:
- 12642
-
getMenu
Returns the main menu, at top of screen.- Returns:
- the main menu
- Since:
- 12643 (as a replacement to
MainApplication.getMenu())
-
getToolbar
Returns the toolbar preference control to register new actions.- Returns:
- the toolbar preference control
- Since:
- 12637
-
isDisplayingMapView
Replies true if JOSM currently displays a map view. False, if it doesn't, i.e. if it only shows the MOTD panel.You do not need this when accessing the layer manager. The layer manager will be empty if no map view is shown.
- Returns:
trueif JOSM currently displays a map view- Since:
- 12630 (as a replacement to
Main.isDisplayingMapView())
-
exitJosm
Closes JOSM and optionally terminates the Java Virtual Machine (JVM). If there are some unsaved data layers, asks first for user confirmation.- Parameters:
exit- Iftrue, the JVM is terminated by runningSystem.exit(int)with a given return code.exitCode- The return codereason- the reason for exiting- Returns:
trueif JOSM has been closed,falseif the user has cancelled the operation.- Since:
- 12636 (specialized version of
Lifecycle.exitJosm(boolean, int))
-
redirectToMainContentPane
Redirects the key inputs fromsourceto main content pane.- Parameters:
source- source component from which key inputs are redirected
-
addAndFireMapFrameListener
Registers a newMapFrameListenerthat will be notified of MapFrame changes.It will fire an initial mapFrameInitialized event when the MapFrame is present. Otherwise will only fire when the MapFrame is created or destroyed.
- Parameters:
listener- The MapFrameListener- Returns:
trueif the listeners collection changed as a result of the call- Since:
- 12639 (as a replacement to
Main.addAndFireMapFrameListener) - See Also:
-
addMapFrameListener
Registers a newMapFrameListenerthat will be notified of MapFrame changes- Parameters:
listener- The MapFrameListener- Returns:
trueif the listeners collection changed as a result of the call- Since:
- 12639 (as a replacement to
Main.addMapFrameListener) - See Also:
-
removeMapFrameListener
Unregisters the givenMapFrameListenerfrom MapFrame changes- Parameters:
listener- The MapFrameListener- Returns:
trueif the listeners collection changed as a result of the call- Since:
- 12639 (as a replacement to
Main.removeMapFrameListener)
-
registerActionShortcut
Registers aJosmActionand its shortcut.- Parameters:
action- action defining its own shortcut- Since:
- 12639 (as a replacement to
Main.registerActionShortcut)
-
registerActionShortcut
Registers an action and its shortcut.- Parameters:
action- action to registershortcut- shortcut to associate toaction- Since:
- 12639 (as a replacement to
Main.registerActionShortcut)
-
unregisterShortcut
Unregisters a shortcut.- Parameters:
shortcut- shortcut to unregister- Since:
- 12639 (as a replacement to
Main.unregisterShortcut)
-
unregisterActionShortcut
Unregisters aJosmActionand its shortcut.- Parameters:
action- action to unregister- Since:
- 12639 (as a replacement to
Main.unregisterActionShortcut)
-
unregisterActionShortcut
Unregisters an action and its shortcut.- Parameters:
action- action to unregistershortcut- shortcut to unregister- Since:
- 12639 (as a replacement to
Main.unregisterActionShortcut)
-
getRegisteredActionShortcut
Replies the registered action for the given shortcut- Parameters:
shortcut- The shortcut to look for- Returns:
- the registered action for the given shortcut
- Since:
- 12639 (as a replacement to
Main.getRegisteredActionShortcut)
-
showHelp
Displays help on the console- Since:
- 2748
-
getHelp
-
align
-
main
Main application Startup- Parameters:
argArray- Command-line arguments
-
mainJOSM
Main method to run the JOSM GUI.- Parameters:
args- program arguments
-
createMainFrame
-
updateSystemProperties
Updates system properties with the current values in the preferences. -
setupNadGridSources
Setup the sources for NTV2 grid shift files for projection support.- Since:
- 12795
-
applyLaFWorkarounds
Apply workarounds for LaF and platform specific issues. This must be called after the LaF is set. -
setupCallbacks
-
setupUIManager
Set up the UI manager -
scaleFonts
-
setupTextAntiAliasing
-
updateAndLoadEarlyPlugins
static Collection<PluginInformation> updateAndLoadEarlyPlugins(SplashScreen splash, SplashScreen.SplashProgressMonitor monitor) -
loadLatePlugins
static void loadLatePlugins(SplashScreen splash, SplashScreen.SplashProgressMonitor monitor, Collection<PluginInformation> pluginsToLoad) -
processOffline
-
checkIPv6
Check if IPv6 can be safely enabled and do so. Because this cannot be done after network activation, disabling or enabling IPV6 may only be done with next start. -
downloadFromParamBounds
Download area specified as Bounds value.- Parameters:
rawGps- Flag to download raw GPS tracksb- The bounds value- Returns:
- the complete download task (including post-download handler)
-
postConstructorProcessCmdLine
Handle command line instructions after GUI has been initialized.- Parameters:
args- program arguments- Returns:
- the list of submitted tasks
-
notifyNewMessages
-