Search in sources :

Example 11 with PointType

use of org.eclipse.smarthome.core.library.types.PointType in project smarthome by eclipse.

the class WeatherUndergroundDiscoveryService method startScan.

@Override
protected void startScan() {
    logger.debug("Starting Weather Underground discovery scan");
    PointType location = locationProvider.getLocation();
    if (location == null) {
        logger.debug("LocationProvider.getLocation() is not set -> Will not provide any discovery results");
        return;
    }
    createResults(location);
}
Also used : PointType(org.eclipse.smarthome.core.library.types.PointType)

Example 12 with PointType

use of org.eclipse.smarthome.core.library.types.PointType in project smarthome by eclipse.

the class MapviewRenderer method renderWidget.

@Override
public EList<Widget> renderWidget(Widget w, StringBuilder sb) throws RenderException {
    Mapview mapview = (Mapview) w;
    String snippet = getSnippet("mapview");
    snippet = preprocessSnippet(snippet, mapview);
    // Process the color tags
    snippet = processColor(w, snippet);
    State state = itemUIRegistry.getState(mapview);
    if (state instanceof PointType) {
        PointType pointState = (PointType) state;
        double latitude = pointState.getLatitude().doubleValue();
        double longitude = pointState.getLongitude().doubleValue();
        snippet = StringUtils.replace(snippet, "%lat%", Double.toString(latitude));
        snippet = StringUtils.replace(snippet, "%lon%", Double.toString(longitude));
        snippet = StringUtils.replace(snippet, "%lonminus%", Double.toString(longitude - 0.01));
        snippet = StringUtils.replace(snippet, "%lonplus%", Double.toString(longitude + 0.01));
        snippet = StringUtils.replace(snippet, "%latminus%", Double.toString(latitude - 0.01));
        snippet = StringUtils.replace(snippet, "%latplus%", Double.toString(latitude + 0.01));
    }
    int height = mapview.getHeight();
    if (height == 0) {
        // set default height to something viewable
        height = 4;
    }
    height = height * 36;
    snippet = StringUtils.replace(snippet, "%height%", Integer.toString(height));
    sb.append(snippet);
    return null;
}
Also used : Mapview(org.eclipse.smarthome.model.sitemap.Mapview) State(org.eclipse.smarthome.core.types.State) PointType(org.eclipse.smarthome.core.library.types.PointType)

Aggregations

PointType (org.eclipse.smarthome.core.library.types.PointType)12 Test (org.junit.Test)6 Locale (java.util.Locale)5 DecimalType (org.eclipse.smarthome.core.library.types.DecimalType)3 State (org.eclipse.smarthome.core.types.State)3 Mapview (org.eclipse.smarthome.model.sitemap.Mapview)2 Hashtable (java.util.Hashtable)1 LinkedList (java.util.LinkedList)1 Temperature (javax.measure.quantity.Temperature)1 DateTimeType (org.eclipse.smarthome.core.library.types.DateTimeType)1 HSBType (org.eclipse.smarthome.core.library.types.HSBType)1 PercentType (org.eclipse.smarthome.core.library.types.PercentType)1 QuantityType (org.eclipse.smarthome.core.library.types.QuantityType)1 RawType (org.eclipse.smarthome.core.library.types.RawType)1 StringListType (org.eclipse.smarthome.core.library.types.StringListType)1 StringType (org.eclipse.smarthome.core.library.types.StringType)1