Beanshell:Setting North Arrow options

From OpenJUMP Wiki
Revision as of 23:56, 5 February 2010 by Beckerl (talk | contribs) (Created page with 'There are many options for the North Arrow Plugin, but no UI to set them. Beanshell to the rescue! == First we must get a reference to the NorthArrowRender == import org.open…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

There are many options for the North Arrow Plugin, but no UI to set them. Beanshell to the rescue!


First we must get a reference to the NorthArrowRender

import org.openjump.core.ui.plugin.view.NorthArrowRenderer;

NorthArrowRenderer renderer = (NorthArrowRenderer) wc.getLayerViewPanel().getRenderingManager().getRenderer(NorthArrowRenderer.CONTENT_ID);


To set the various styles of North Arrows:

renderer.setStyle(1); //the compass rose

renderer.setStyle(2); //the inverted V shape half filled narrower version

renderer.setStyle(3); //the inverted V shape half filled wider version

renderer.setStyle(0); //shaped like a backwards 4 filled with scale bar color


To set the position that the North Arrow appears in the layer view

renderer.setAlignment(0); //BOTTOM_RIGHT = 0, TOP_RIGHT = 1, TOP_LEFT = 2, BOTTOM_LEFT = 3

Miscellaneous settings

renderer.setARROW_SIZE(100);

renderer.setTEXT_FONT_SIZE(18);

renderer.setTEXT_BOTTOM_MARGIN(3);

A complete example

{ NorthArrowRenderer renderer = (NorthArrowRenderer) wc.getLayerViewPanel().getRenderingManager().getRenderer(NorthArrowRenderer.CONTENT_ID); renderer.setStyle(2); }