Search in sources :

Example 1 with DynamicImage

use of com.serotonin.m2m2.view.DynamicImage in project ma-modules-public by infiniteautomation.

the class GraphicalViewDwr method saveDynamicGraphicComponent.

@DwrPermission(user = true)
public ProcessResult saveDynamicGraphicComponent(String viewComponentId, double min, double max, boolean displayText, String dynamicImageId) {
    ProcessResult response = new ProcessResult();
    // Validate
    if (min >= max)
        response.addContextualMessage("graphicRendererDynamicMin", "viewEdit.graphic.invalidMinMax");
    DynamicImage dynamicImage = getDynamicImage(dynamicImageId);
    if (dynamicImage == null)
        response.addContextualMessage("graphicRendererDynamicImage", "viewEdit.graphic.missingDynamicImage");
    if (!response.getHasMessages()) {
        DynamicGraphicComponent c = (DynamicGraphicComponent) getViewComponent(viewComponentId);
        c.setMin(min);
        c.setMax(max);
        c.setDisplayText(displayText);
        c.tsetDynamicImage(dynamicImage);
        resetPointComponent(c);
    }
    return response;
}
Also used : DynamicGraphicComponent(com.serotonin.m2m2.gviews.component.DynamicGraphicComponent) DynamicImage(com.serotonin.m2m2.view.DynamicImage) ProcessResult(com.serotonin.m2m2.i18n.ProcessResult) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 2 with DynamicImage

use of com.serotonin.m2m2.view.DynamicImage in project ma-modules-public by infiniteautomation.

the class DynamicGraphicComponent method jsonRead.

@Override
public void jsonRead(JsonReader reader, JsonObject jsonObject) throws JsonException {
    super.jsonRead(reader, jsonObject);
    JsonValue jsonImageId = jsonObject.get("dynamicImage");
    if (jsonImageId != null) {
        String id = jsonImageId.toString();
        dynamicImage = Common.getDynamicImage(id);
        if (dynamicImage == null)
            throw new TranslatableJsonException("emport.error.component.unknownDynamicImage", id, Common.getDynamicImageIds());
    }
}
Also used : JsonValue(com.serotonin.json.type.JsonValue) TranslatableJsonException(com.serotonin.m2m2.i18n.TranslatableJsonException)

Aggregations

JsonValue (com.serotonin.json.type.JsonValue)1 DynamicGraphicComponent (com.serotonin.m2m2.gviews.component.DynamicGraphicComponent)1 ProcessResult (com.serotonin.m2m2.i18n.ProcessResult)1 TranslatableJsonException (com.serotonin.m2m2.i18n.TranslatableJsonException)1 DynamicImage (com.serotonin.m2m2.view.DynamicImage)1 DwrPermission (com.serotonin.m2m2.web.dwr.util.DwrPermission)1