Class MainApplication


  • public class MainApplication
    extends java.lang.Object
    Main window class application.
    • Constructor Detail

      • MainApplication

        public MainApplication()
        Constructs a new MainApplication without a window.
      • MainApplication

        public MainApplication​(MainFrame mainFrame)
        Constructs a main frame, ready sized and operating. Does not display the frame.
        Parameters:
        mainFrame - The main JFrame of the application
        Since:
        10340
    • Method Detail

      • registerCLIModule

        public static void registerCLIModule​(CLIModule module)
        Register a command line interface module.
        Parameters:
        module - the module
        Since:
        12886
      • askUpdate

        private static void askUpdate​(java.lang.String title,
                                      java.lang.String update,
                                      java.lang.String property,
                                      java.lang.String icon,
                                      java.lang.StringBuilder content,
                                      java.lang.String url)
      • askUpdateJava

        public static void askUpdateJava​(java.lang.String updVersion,
                                         java.lang.String url,
                                         java.lang.String eolDate,
                                         boolean major)
        Asks user to update its version of Java.
        Parameters:
        updVersion - target update version
        url - download URL
        major - true for a migration towards a major version of Java (8:11), false otherwise
        eolDate - the EOL/expiration date
        Since:
        12270
      • sanityCheckFailed

        public static void sanityCheckFailed​(java.lang.String title,
                                             boolean canContinue,
                                             java.lang.String... message)
        Tells the user that a sanity check failed
        Parameters:
        title - The title of the message to show
        canContinue - true if the failed sanity check(s) will not instantly kill JOSM when the user edits
        message - The message parts to show the user (as a list)
      • getMainFrame

        public static MainFrame getMainFrame()
        Returns the JOSM main frame.
        Returns:
        the JOSM main frame
        Since:
        14140
      • getCommandLineArgs

        public static java.util.List<java.lang.String> getCommandLineArgs()
        Returns the command-line arguments used to run the application.
        Returns:
        the command-line arguments used to run the application
        Since:
        11650
      • getLayerManager

        public static MainLayerManager 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

        public static MapFrame getMap()
        Returns the MapFrame.

        There should be no need to access this to access any map data. Use layerManager instead.

        Returns:
        the MapFrame
        Since:
        12630
        See Also:
        MainPanel
      • getMainPanel

        public static MainPanel getMainPanel()
        Returns the main panel.
        Returns:
        the main panel
        Since:
        12642
      • getMenu

        public static MainMenu getMenu()
        Returns the main menu, at top of screen.
        Returns:
        the main menu
        Since:
        12643 (as a replacement to MainApplication.getMenu())
      • getToolbar

        public static ToolbarPreferences getToolbar()
        Returns the toolbar preference control to register new actions.
        Returns:
        the toolbar preference control
        Since:
        12637
      • 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.

        You do not need this when accessing the layer manager. The layer manager will be empty if no map view is shown.

        Returns:
        true if JOSM currently displays a map view
        Since:
        12630 (as a replacement to Main.isDisplayingMapView())
      • exitJosm

        public static boolean exitJosm​(boolean exit,
                                       int exitCode,
                                       SaveLayersDialog.Reason reason)
        Closes JOSM and optionally terminates the Java Virtual Machine (JVM). If there are some unsaved data layers, asks first for user confirmation.
        Parameters:
        exit - If true, the JVM is terminated by running System.exit(int) with a given return code.
        exitCode - The return code
        reason - the reason for exiting
        Returns:
        true if JOSM has been closed, false if the user has cancelled the operation.
        Since:
        12636 (specialized version of Lifecycle.exitJosm(boolean, int))
      • redirectToMainContentPane

        public static void redirectToMainContentPane​(javax.swing.JComponent source)
        Redirects the key inputs from source to main content pane.
        Parameters:
        source - source component from which key inputs are redirected
      • addAndFireMapFrameListener

        public static boolean addAndFireMapFrameListener​(MapFrameListener listener)
        Registers a new MapFrameListener that 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:
        true if the listeners collection changed as a result of the call
        Since:
        12639 (as a replacement to Main.addAndFireMapFrameListener)
        See Also:
        addMapFrameListener(org.openstreetmap.josm.gui.MapFrameListener)
      • removeMapFrameListener

        public static boolean removeMapFrameListener​(MapFrameListener listener)
        Unregisters the given MapFrameListener from MapFrame changes
        Parameters:
        listener - The MapFrameListener
        Returns:
        true if the listeners collection changed as a result of the call
        Since:
        12639 (as a replacement to Main.removeMapFrameListener)
      • registerActionShortcut

        public static void registerActionShortcut​(JosmAction action)
        Registers a JosmAction and its shortcut.
        Parameters:
        action - action defining its own shortcut
        Since:
        12639 (as a replacement to Main.registerActionShortcut)
      • registerActionShortcut

        public static void registerActionShortcut​(javax.swing.Action action,
                                                  Shortcut shortcut)
        Registers an action and its shortcut.
        Parameters:
        action - action to register
        shortcut - shortcut to associate to action
        Since:
        12639 (as a replacement to Main.registerActionShortcut)
      • unregisterShortcut

        public static void unregisterShortcut​(Shortcut shortcut)
        Unregisters a shortcut.
        Parameters:
        shortcut - shortcut to unregister
        Since:
        12639 (as a replacement to Main.unregisterShortcut)
      • unregisterActionShortcut

        public static void unregisterActionShortcut​(JosmAction action)
        Unregisters a JosmAction and its shortcut.
        Parameters:
        action - action to unregister
        Since:
        12639 (as a replacement to Main.unregisterActionShortcut)
      • unregisterActionShortcut

        public static void unregisterActionShortcut​(javax.swing.Action action,
                                                    Shortcut shortcut)
        Unregisters an action and its shortcut.
        Parameters:
        action - action to unregister
        shortcut - shortcut to unregister
        Since:
        12639 (as a replacement to Main.unregisterActionShortcut)
      • getRegisteredActionShortcut

        public static javax.swing.Action getRegisteredActionShortcut​(Shortcut shortcut)
        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

        public static void showHelp()
        Displays help on the console
        Since:
        2748
      • getHelp

        static java.lang.String getHelp()
      • align

        private static java.lang.String align​(java.lang.String str)
      • main

        public static void main​(java.lang.String[] argArray)
        Main application Startup
        Parameters:
        argArray - Command-line arguments
      • mainJOSM

        public static void mainJOSM​(ProgramArguments args)
        Main method to run the JOSM GUI.
        Parameters:
        args - program arguments
      • updateSystemProperties

        private static void updateSystemProperties()
        Updates system properties with the current values in the preferences.
      • setupNadGridSources

        public static void setupNadGridSources()
        Setup the sources for NTV2 grid shift files for projection support.
        Since:
        12795
      • applyLaFWorkarounds

        static void applyLaFWorkarounds()
        Apply workarounds for LaF and platform specific issues. This must be called after the LaF is set.
      • scaleFonts

        private static void scaleFonts​(double factor,
                                       java.lang.String... fonts)
      • checkIPv6

        private static void 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

        static java.util.List<java.util.concurrent.Future<?>> downloadFromParamBounds​(boolean rawGps,
                                                                                      Bounds b)
        Download area specified as Bounds value.
        Parameters:
        rawGps - Flag to download raw GPS tracks
        b - The bounds value
        Returns:
        the complete download task (including post-download handler)
      • postConstructorProcessCmdLine

        static java.util.List<java.util.concurrent.Future<?>> postConstructorProcessCmdLine​(ProgramArguments args)
        Handle command line instructions after GUI has been initialized.
        Parameters:
        args - program arguments
        Returns:
        the list of submitted tasks