JOSM/Plugins/RasterFilters/DevelopingFilters
Developing New Filters
Introduction
Every developer can implement his own filter and integrate it into RF plugin. Here you may find step-by-step guide which helps you to develop new filters and make it usable for other JOSM users.
In the table of existing filters you can find some info about every filter: name, author and description. Also there are the links in the column of filters' names. These links point to the pages which contains meta-information about every filter. This meta-information is used by plugin for adding filters to the JOSM.
Implementing your custom filter
Java implementation
Every filter you want to add to the list of existing filters should implement org.openstreetmap.josm.plugins.rasterfilters.filters.Filter
interface.
All implementations of filters have to be archived in the .jar
files which every developer should append when adding new filter. These jars are stored in the attachments on the Image Filters page.
Meta Information
Every instance of meta-information is primarily JSON and it must necessary contain next fields and corresponding values:
"classname": "org.openstreetmap.josm.plugins.rasterfilters.filters.YourFilterImpl"
- This field contains information about Java class of your custom filter; this class has to be stored in the
linktoyourattachment.jar
which is defined by the next field of meta-information.
- This field contains information about Java class of your custom filter; this class has to be stored in the
"binaries": "https://josm.openstreetmap.de/raw-attachment/wiki/ImageFilters/linktoyourattachment.jar"
- The field
"binaries"
contains the link to the.jar
attachment which contains your filter.
- The field
"name": "yourfiltername"
- The name of your filter.
"title": "YourFilterTitle"
- The title of your filter as you want to see it in the select list of Choose Filters Dialog.
"controls": [jsonarrayofyourcontrols]
- The field
"controls"
contains JSON descriptons of controls which your filter implementation requires. Read more about possible controls in the next section of the guide.
- The field
Controls
Every control is a JSON object which contains all information about this type of control. There are some types of the controls in the RasterFilters plugin. Here is the list of all types of controls which RasterFilters plugin maintain with required fields of the JSON description of every type of control.
"type"
field can take next values:
"linear_slider"
:- Usual JSlider; the value's type of
"linear_slider"
is specified in the"value_type"
field and may take the following values:"integer"
or"float"
. The range of values is defined by"scale"
: the value for this field is an array, for example, for the"value_type": "integer"
the field"scale"
may be the next"scale": [0, 10]
. It is not necessary for the"float"
type dot separator if it is not required. Also there is defined"default"
field for the"linear_slider"
, value is inside"scale"
array.
- Usual JSlider; the value's type of
"checkbox"
:- JCheckBox which can be checked or unchecked. The field
"value_type"
for checkbox may be only"boolean"
;"default"
field may taketrue
orfalse
values. - Note that values of checkbox item is typed without quotes otherwise it will be not boolean but String type of value!
- JCheckBox which can be checked or unchecked. The field
"select"
:- Select list; the value type is only String by default; all needed values of this select should be inside the field
"values"
which is array of Strings, example"values": ["one", "two", "three"]
.
- Select list; the value type is only String by default; all needed values of this select should be inside the field
"colorpicker"
- The value type is
"value_type": "color"
, the"default"
field contains RGB JSON, for example:"default": {"red": 0,"green": 0,"blue": 0}
'
- The value type is
The examples of meta-informations you may find on this link.