Package org.codemap.layers

Source Code of org.codemap.layers.LabelOverlay

package org.codemap.layers;

import org.codemap.Labeling;
import org.codemap.resources.MapValues;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Device;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.GC;


public class LabelOverlay extends Layer {

    public static final String ARIAL_NARROW = "Arial Narrow";

    @Override
    public void paintMap(MapValues map, GC gc) {
        Labeling labeling = map.labeling.getValue();
        if (labeling == null) return;
        paintLabels(labeling, gc);
    }
   
    public void paintLabels(Labeling labeling, GC gc) {
        Device device = gc.getDevice();
        String fname = ARIAL_NARROW;
        Font basefont = new Font(device, fname, 12, SWT.NORMAL);
       
        for (Label each: labeling.labels()) {
            FontData[] fontData = basefont.getFontData();
           
            each.render(gc, fontData);
        }
       
        basefont.dispose();
    }


}
TOP

Related Classes of org.codemap.layers.LabelOverlay

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.