# encoding: utf-8 import gvsig from java.awt import Font from java.awt import Color from org.gvsig.symbology import SymbologyLocator from org.gvsig.fmap.mapcontext import MapContext def main(*args): #print MapContext.getDistanceNames() layer = gvsig.currentLayer() symbologyManager = SymbologyLocator.getSymbologyManager() labeling = symbologyManager.createDefaultLabelingStrategy() labeling.setTextField("NOMBRE03") labeling.setUsesFixedColor(True) labeling.setUsesFixedSize(True) labeling.setHeightField(None) labeling.setRotationField(None) labeling.setFixedColor(Color(200,100,100)) # RGB labeling.setFont(Font("Arial", Font.PLAIN, 12)) labeling.setReferenceSystem(0) # WORLD = 0, PAPER=1 labeling.setFixedSize(2) labeling.setUnit(MapContext.getDistancePosition("Kilometros")) #labeling.setUnit(-1) # PIXELS layer.setLabelingStrategy(labeling) layer.setIsLabeled(True) # Forzamos el repintado (opcional) layer.getMapContext().invalidate()