Class MainApplication

java.lang.Object
org.openstreetmap.josm.gui.MainApplication

public class MainApplication extends Object
Main window class application.
  • Field Details

  • Constructor Details

    • 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 Details

    • registerCLIModule

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

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

      public static void askUpdateJava(String updVersion, String url, 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(String title, boolean canContinue, 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)
    • initializeMainWindow

      protected void initializeMainWindow()
      Called once at startup to initialize the main window content. Should set menu and mainPanel
    • getMainFrame

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

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

      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:
    • 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(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

      public static boolean addMapFrameListener(MapFrameListener listener)
      Registers a new MapFrameListener that will be notified of 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.addMapFrameListener)
      See Also:
    • 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(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(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 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 String getHelp()
    • align

      private static String align(String str)
    • main

      public static void main(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
    • createMainFrame

      private static MainFrame createMainFrame(WindowGeometry geometry)
    • 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.
    • setupCallbacks

      static void setupCallbacks()
    • setupUIManager

      static void setupUIManager()
      Set up the UI manager
    • scaleFonts

      private static void scaleFonts(double factor, String... fonts)
    • setupTextAntiAliasing

      private static void setupTextAntiAliasing()
    • updateAndLoadEarlyPlugins

    • loadLatePlugins

    • processOffline

      private static void processOffline(ProgramArguments args)
    • 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 List<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

      Handle command line instructions after GUI has been initialized.
      Parameters:
      args - program arguments
      Returns:
      the list of submitted tasks
    • notifyNewMessages

      static void notifyNewMessages(UserInfo userInfo)