Search in sources :

Example 1 with Icon

use of org.discotools.gwt.leaflet.client.types.Icon in project opennms by OpenNMS.

the class NodeMapConnector method initializeIcons.

private void initializeIcons() {
    if (m_icons == null) {
        m_icons = new HashMap<String, Icon>();
        for (final String severity : new String[] { "Normal", "Warning", "Minor", "Major", "Critical" }) {
            IconOptions options = new IconOptions();
            options.setIconSize(new Point(25, 41));
            options.setIconAnchor(new Point(12, 41));
            options.setPopupAnchor(new Point(1, -34));
            options.setShadowUrl(new Point(41, 41));
            String basePath = GWT.getModuleBaseForStaticFiles() + "images/";
            if (isRetina()) {
                options.setIconUrl(basePath + severity + "@2x.png");
            } else {
                options.setIconUrl(basePath + severity + ".png");
            }
            Icon icon = new Icon(options);
            m_icons.put(severity, icon);
        }
    }
}
Also used : Icon(org.discotools.gwt.leaflet.client.types.Icon) Point(org.discotools.gwt.leaflet.client.types.Point) IconOptions(org.discotools.gwt.leaflet.client.types.IconOptions)

Example 2 with Icon

use of org.discotools.gwt.leaflet.client.types.Icon in project activityinfo by bedatadriven.

the class LeafletMarkerFactory method createPieMapMarker.

public static Marker createPieMapMarker(PieMapMarker marker) {
    StringBuilder sb = new StringBuilder();
    sb.append("/icon?t=piechart&r=").append(marker.getRadius());
    for (SliceValue slice : marker.getSlices()) {
        sb.append("&value=").append(slice.getValue());
        sb.append("&color=").append(slice.getColor());
    }
    String iconUrl = sb.toString();
    int size = marker.getRadius() * 2;
    IconOptions iconOptions = new IconOptions();
    iconOptions.setIconUrl(iconUrl);
    iconOptions.setIconAnchor(new Point(marker.getRadius(), marker.getRadius()));
    iconOptions.setIconSize(new Point(size, size));
    Options markerOptions = new MarkerOptions();
    markerOptions.setProperty("icon", new Icon(iconOptions));
    setModel(markerOptions.getJSObject(), marker);
    return new Marker(toLatLng(marker), markerOptions);
}
Also used : IconOptions(org.discotools.gwt.leaflet.client.types.IconOptions) Options(org.discotools.gwt.leaflet.client.Options) MarkerOptions(org.discotools.gwt.leaflet.client.marker.MarkerOptions) MarkerOptions(org.discotools.gwt.leaflet.client.marker.MarkerOptions) SliceValue(org.activityinfo.legacy.shared.reports.content.PieMapMarker.SliceValue) Point(org.discotools.gwt.leaflet.client.types.Point) Icon(org.discotools.gwt.leaflet.client.types.Icon) MapIcon(org.activityinfo.legacy.shared.reports.model.MapIcon) BubbleMapMarker(org.activityinfo.legacy.shared.reports.content.BubbleMapMarker) PieMapMarker(org.activityinfo.legacy.shared.reports.content.PieMapMarker) CircleMarker(org.discotools.gwt.leaflet.client.marker.CircleMarker) IconMapMarker(org.activityinfo.legacy.shared.reports.content.IconMapMarker) MapMarker(org.activityinfo.legacy.shared.reports.content.MapMarker) Marker(org.discotools.gwt.leaflet.client.marker.Marker) Point(org.discotools.gwt.leaflet.client.types.Point) IconOptions(org.discotools.gwt.leaflet.client.types.IconOptions)

Example 3 with Icon

use of org.discotools.gwt.leaflet.client.types.Icon in project activityinfo by bedatadriven.

the class LeafletMarkerFactory method createIconMapMarker.

/**
 * Creates a Leaflet marker based on an ActivityInfo MapIcon
 */
public static Marker createIconMapMarker(IconMapMarker model) {
    MapIcon iconModel = model.getIcon();
    String iconUrl = "mapicons/" + iconModel.getName() + ".png";
    IconOptions iconOptions = new IconOptions();
    iconOptions.setIconUrl(iconUrl);
    iconOptions.setIconAnchor(new Point(iconModel.getAnchorX(), iconModel.getAnchorY()));
    iconOptions.setIconSize(new Point(iconModel.getWidth(), iconModel.getHeight()));
    Options markerOptions = new MarkerOptions();
    markerOptions.setProperty("icon", new Icon(iconOptions));
    setModel(markerOptions.getJSObject(), model);
    return new Marker(toLatLng(model), markerOptions);
}
Also used : IconOptions(org.discotools.gwt.leaflet.client.types.IconOptions) Options(org.discotools.gwt.leaflet.client.Options) MarkerOptions(org.discotools.gwt.leaflet.client.marker.MarkerOptions) MarkerOptions(org.discotools.gwt.leaflet.client.marker.MarkerOptions) MapIcon(org.activityinfo.legacy.shared.reports.model.MapIcon) Point(org.discotools.gwt.leaflet.client.types.Point) Icon(org.discotools.gwt.leaflet.client.types.Icon) MapIcon(org.activityinfo.legacy.shared.reports.model.MapIcon) BubbleMapMarker(org.activityinfo.legacy.shared.reports.content.BubbleMapMarker) PieMapMarker(org.activityinfo.legacy.shared.reports.content.PieMapMarker) CircleMarker(org.discotools.gwt.leaflet.client.marker.CircleMarker) IconMapMarker(org.activityinfo.legacy.shared.reports.content.IconMapMarker) MapMarker(org.activityinfo.legacy.shared.reports.content.MapMarker) Marker(org.discotools.gwt.leaflet.client.marker.Marker) IconOptions(org.discotools.gwt.leaflet.client.types.IconOptions)

Aggregations

Icon (org.discotools.gwt.leaflet.client.types.Icon)3 IconOptions (org.discotools.gwt.leaflet.client.types.IconOptions)3 Point (org.discotools.gwt.leaflet.client.types.Point)3 BubbleMapMarker (org.activityinfo.legacy.shared.reports.content.BubbleMapMarker)2 IconMapMarker (org.activityinfo.legacy.shared.reports.content.IconMapMarker)2 MapMarker (org.activityinfo.legacy.shared.reports.content.MapMarker)2 PieMapMarker (org.activityinfo.legacy.shared.reports.content.PieMapMarker)2 MapIcon (org.activityinfo.legacy.shared.reports.model.MapIcon)2 Options (org.discotools.gwt.leaflet.client.Options)2 CircleMarker (org.discotools.gwt.leaflet.client.marker.CircleMarker)2 Marker (org.discotools.gwt.leaflet.client.marker.Marker)2 MarkerOptions (org.discotools.gwt.leaflet.client.marker.MarkerOptions)2 SliceValue (org.activityinfo.legacy.shared.reports.content.PieMapMarker.SliceValue)1