Module josm

This module is auto-loaded by the scripting plugin. It provides the implementation of the global josm object.

Name Description
Properties
commands Replies the global command history.
layers accessor for JOSM layers
menu Replies an accessor for JOSMs menu bar.
version JOSM version string
Methods
alert display a message
open Opens one or more files in JOSM

Properties

commands:CommandHistory

Replies the global command history.

Use this object to undo/redo commands, or to clear the command history.

// undoes the last command 
josm.commands.undo();

// redoes two commands
josm.commands.redo(2);

layers:object

Replies the layers object.

josm.alert("num layers: " + josm.layers.length);

// name of first layer 
josm.alert("num layers: " + josm.layers.get(0).name);

Replies an accessor for JOSMs menu bar.

Use this object to inspect or modify the menu bar, i.e. to add additional menu items.

version:string

Replies the current JOSM version string.

josm.alert(josm.version);

Functions

alert

Displays an alert window with a message

Signatures
alert(message)
Displays an information message with an OK button.
alert(message, ?options)
Displays a message. The look and feel of the alert window depends on the options. The following options are supported:
title:string
(optional) the window title. A string is expected. Empty string if missing.
messageType
(optional) the message type. Use one of the following values: Default value is JOptionPane.INFORMATION_MESSAGE. String values are not case sensitive and leading and trailing white space is removed.

Examples

// display an information alert
josm.alert("Hello World!");

// display an error alert 
josm.alert("Got an error", {
   title: "Error Alert",
   messageType: "error"    
});

open

Opens one or more files in JOSM.

Accepts a variable number of files. Each argument is either a string (a file name) or a java.io.File.

Creates and opens layers in JOSM, depending on the kind of file opened:

  • creates a data layer for data files
  • creates a gpx layer for gpx files
  • creates an image layer for a directory with images
  • etc.
* @example // open a data file in a new data layer josm.open("/my/data/file.osm");