use of com.serotonin.m2m2.view.text.NoneRenderer in project ma-modules-public by infiniteautomation.
the class TextRendererFactory method updateDataPoint.
/**
* @param data
* @param renderer
*/
public static void updateDataPoint(DataPointVO vo, BaseTextRendererModel<?> baseRendererModel) {
if (baseRendererModel.getType().equals(AnalogRenderer.getDefinition().getName())) {
AnalogTextRendererModel model = (AnalogTextRendererModel) baseRendererModel;
AnalogRenderer r = new AnalogRenderer();
r.setUseUnitAsSuffix(model.isUseUnitAsSuffix());
r.setUnit(UnitUtil.parseLocal(model.getUnit()));
r.setRenderedUnit(UnitUtil.parseLocal(model.getRenderedUnit()));
r.setFormat(model.getFormat());
r.setSuffix(model.getSuffix());
vo.setTextRenderer(r);
} else if (baseRendererModel.getType().equals(BinaryTextRenderer.getDefinition().getName())) {
BinaryTextRendererModel model = (BinaryTextRendererModel) baseRendererModel;
BinaryTextRenderer btr = new BinaryTextRenderer();
btr.setOneColour(model.getOneColour());
btr.setOneLabel(model.getOneLabel());
btr.setZeroColour(model.getZeroColour());
btr.setZeroLabel(model.getZeroLabel());
vo.setTextRenderer(btr);
} else if (baseRendererModel.getType().equals(MultistateRenderer.getDefinition().getName())) {
MultistateRenderer r = new MultistateRenderer();
MultistateTextRendererModel model = (MultistateTextRendererModel) baseRendererModel;
r.setMultistateValues(model.getMultistateValues());
vo.setTextRenderer(r);
} else if (baseRendererModel.getType().equals(NoneRenderer.getDefinition().getName())) {
NoneRenderer r = new NoneRenderer();
vo.setTextRenderer(r);
} else if (baseRendererModel.getType().equals(PlainRenderer.getDefinition().getName())) {
PlainTextRendererModel model = (PlainTextRendererModel) baseRendererModel;
PlainRenderer r = new PlainRenderer();
r.setUseUnitAsSuffix(model.isUseUnitAsSuffix());
r.setUnit(UnitUtil.parseLocal(model.getUnit()));
r.setRenderedUnit(UnitUtil.parseLocal(model.getRenderedUnit()));
r.setSuffix(model.getSuffix());
vo.setTextRenderer(r);
} else if (baseRendererModel.getType().equals(RangeRenderer.getDefinition().getName())) {
RangeTextRendererModel model = (RangeTextRendererModel) baseRendererModel;
RangeRenderer r = new RangeRenderer();
r.setUseUnitAsSuffix(model.isUseUnitAsSuffix());
r.setUnit(UnitUtil.parseLocal(model.getUnit()));
r.setRenderedUnit(UnitUtil.parseLocal(model.getRenderedUnit()));
r.setFormat(model.getFormat());
r.setRangeValues(model.getRangeValues());
vo.setTextRenderer(r);
} else if (baseRendererModel.getType().equals(TimeRenderer.getDefinition().getName())) {
TimeRenderer r = new TimeRenderer();
TimeTextRendererModel model = (TimeTextRendererModel) baseRendererModel;
r.setFormat(model.getFormat());
r.setConversionExponent(model.getConversionExponent());
vo.setTextRenderer(r);
} else {
throw new ShouldNeverHappenException("Unknown Text Renderer: " + baseRendererModel.getType());
}
}
Aggregations