|
| 1 | +package org.csstudio.display.widget; |
| 2 | + |
| 3 | +import org.csstudio.display.builder.model.Widget; |
| 4 | +import org.csstudio.display.builder.model.WidgetCategory; |
| 5 | +import org.csstudio.display.builder.model.WidgetDescriptor; |
| 6 | +import org.csstudio.display.builder.model.WidgetProperty; |
| 7 | +import org.csstudio.display.builder.model.WidgetPropertyCategory; |
| 8 | +import org.csstudio.display.builder.model.WidgetPropertyDescriptor; |
| 9 | +import org.csstudio.display.builder.model.persist.NamedWidgetFonts; |
| 10 | +import org.csstudio.display.builder.model.persist.WidgetFontService; |
| 11 | +import org.csstudio.display.builder.model.properties.WidgetColor; |
| 12 | +import org.csstudio.display.builder.model.properties.WidgetFont; |
| 13 | +import org.csstudio.display.builder.model.widgets.WritablePVWidget; |
| 14 | + |
| 15 | +import java.util.Arrays; |
| 16 | +import java.util.List; |
| 17 | + |
| 18 | +import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.newBooleanPropertyDescriptor; |
| 19 | +import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.newColorPropertyDescriptor; |
| 20 | +import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.newIntegerPropertyDescriptor; |
| 21 | +import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.propBackgroundColor; |
| 22 | +import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.propEnabled; |
| 23 | +import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.propFont; |
| 24 | +import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.propForegroundColor; |
| 25 | +import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.propLimitsFromPV; |
| 26 | +import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.propMaximum; |
| 27 | +import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.propMinimum; |
| 28 | + |
| 29 | +public class ThumbwheelWidget extends WritablePVWidget { |
| 30 | + |
| 31 | + /** Widget descriptor */ |
| 32 | + public static final WidgetDescriptor WIDGET_DESCRIPTOR = |
| 33 | + new WidgetDescriptor("thumbwheel", WidgetCategory.MONITOR, |
| 34 | + "Thumbwheel", |
| 35 | + "/icons/thumbwheel.gif", |
| 36 | + "Display a thumbwheel", |
| 37 | + Arrays.asList("org.csstudio.opibuilder.widgets.ThumbWheel")) |
| 38 | + { |
| 39 | + @Override |
| 40 | + public Widget createWidget() |
| 41 | + { |
| 42 | + return new ThumbwheelWidget(); |
| 43 | + } |
| 44 | + }; |
| 45 | + |
| 46 | + public static final WidgetPropertyDescriptor<WidgetColor> propIncrementColor = newColorPropertyDescriptor(WidgetPropertyCategory.DISPLAY, "increment_color", "Increment Buttons Color"); |
| 47 | + public static final WidgetPropertyDescriptor<WidgetColor> propDecrementColor = newColorPropertyDescriptor(WidgetPropertyCategory.DISPLAY, "decrement_color", "Decrement Buttons Color"); |
| 48 | + public static final WidgetPropertyDescriptor<Boolean> propGraphicVisible = newBooleanPropertyDescriptor(WidgetPropertyCategory.DISPLAY, "graphic_visible", "Graphic Visible"); |
| 49 | + public static final WidgetPropertyDescriptor<Integer> propIntegerDigits = newIntegerPropertyDescriptor(WidgetPropertyCategory.DISPLAY, "integer_digits", "Integer Digits"); |
| 50 | + public static final WidgetPropertyDescriptor<Integer> propDecimalDigits = newIntegerPropertyDescriptor(WidgetPropertyCategory.DISPLAY, "decimal_digits", "Decimal Digits"); |
| 51 | + public static final WidgetPropertyDescriptor<WidgetColor> propInvalidColor = newColorPropertyDescriptor(WidgetPropertyCategory.DISPLAY, "invalid_color", "Invalid Color"); |
| 52 | + public static final WidgetPropertyDescriptor<Boolean> propScrollEnabled = newBooleanPropertyDescriptor(WidgetPropertyCategory.DISPLAY, "scroll_enabled", "Scroll Enabled"); |
| 53 | + public static final WidgetPropertyDescriptor<Boolean> propSpinnerShaped = newBooleanPropertyDescriptor(WidgetPropertyCategory.DISPLAY, "spinner_shaped", "Spinner Shaped"); |
| 54 | + |
| 55 | + public static final WidgetColor THUMBWHEEL_BACKGROUND_COLOR = new WidgetColor(26, 26, 26); |
| 56 | + public static final WidgetColor THUMBWHEEL_FOREGROUND_COLOR = new WidgetColor(242, 242, 242); |
| 57 | + public static final WidgetColor THUMBWHEEL_BUTTON_COLOR = new WidgetColor(0, 0, 0); |
| 58 | + public static final WidgetColor THUMBWHEEL_INVALID_COLOR = new WidgetColor(255, 0, 0); |
| 59 | + public static final double DEFAULT_MIN = 0.0; |
| 60 | + public static final double DEFAULT_MAX = 100.0; |
| 61 | + |
| 62 | + private volatile WidgetProperty<WidgetColor> background; |
| 63 | + private volatile WidgetProperty<WidgetColor> foreground; |
| 64 | + private volatile WidgetProperty<WidgetColor> increment_color; |
| 65 | + private volatile WidgetProperty<WidgetColor> decrement_color; |
| 66 | + private volatile WidgetProperty<Integer> integer_digits; |
| 67 | + private volatile WidgetProperty<Integer> decimal_digits; |
| 68 | + private volatile WidgetProperty<WidgetFont> font; |
| 69 | + private volatile WidgetProperty<Boolean> enabled; |
| 70 | + private volatile WidgetProperty<Boolean> graphic_visible; |
| 71 | + private volatile WidgetProperty<WidgetColor> invalid_color; |
| 72 | + private volatile WidgetProperty<Double> minimum; |
| 73 | + private volatile WidgetProperty<Double> maximum; |
| 74 | + private volatile WidgetProperty<Boolean> limits_from_pv; |
| 75 | + private volatile WidgetProperty<Boolean> scroll_enabled; |
| 76 | + private volatile WidgetProperty<Boolean> spinner_shaped; |
| 77 | + |
| 78 | + public ThumbwheelWidget() |
| 79 | + { |
| 80 | + super(WIDGET_DESCRIPTOR.getType(), 400, 100); |
| 81 | + } |
| 82 | + |
| 83 | + @Override |
| 84 | + protected void defineProperties(List<WidgetProperty<?>> properties) { |
| 85 | + super.defineProperties(properties); |
| 86 | + properties.add(background = propBackgroundColor.createProperty(this, THUMBWHEEL_BACKGROUND_COLOR)); |
| 87 | + properties.add(foreground = propForegroundColor.createProperty(this, THUMBWHEEL_FOREGROUND_COLOR)); |
| 88 | + properties.add(increment_color = propIncrementColor.createProperty(this, THUMBWHEEL_BUTTON_COLOR)); |
| 89 | + properties.add(decrement_color = propDecrementColor.createProperty(this, THUMBWHEEL_BUTTON_COLOR)); |
| 90 | + properties.add(invalid_color = propInvalidColor.createProperty(this, THUMBWHEEL_INVALID_COLOR)); |
| 91 | + |
| 92 | + properties.add(font = propFont.createProperty(this, WidgetFontService.get(NamedWidgetFonts.DEFAULT))); |
| 93 | + properties.add(decimal_digits = propDecimalDigits.createProperty(this, 2)); |
| 94 | + properties.add(integer_digits = propIntegerDigits.createProperty(this, 3)); |
| 95 | + properties.add(minimum = propMinimum.createProperty(this, DEFAULT_MIN)); |
| 96 | + properties.add(maximum = propMaximum.createProperty(this, DEFAULT_MAX)); |
| 97 | + |
| 98 | + properties.add(enabled = propEnabled.createProperty(this, true)); |
| 99 | + properties.add(graphic_visible = propGraphicVisible.createProperty(this, true)); |
| 100 | + properties.add(scroll_enabled = propScrollEnabled.createProperty(this, false)); |
| 101 | + properties.add(spinner_shaped = propSpinnerShaped.createProperty(this, false)); |
| 102 | + properties.add(limits_from_pv = propLimitsFromPV.createProperty(this, true)); |
| 103 | + } |
| 104 | + |
| 105 | + /** @return 'background_color' property */ |
| 106 | + public WidgetProperty<WidgetColor> propBackgroundColor() |
| 107 | + { |
| 108 | + return background; |
| 109 | + } |
| 110 | + |
| 111 | + /** @return 'foreground_color' property */ |
| 112 | + public WidgetProperty<WidgetColor> propForegroundColor() |
| 113 | + { |
| 114 | + return foreground; |
| 115 | + } |
| 116 | + |
| 117 | + /** @return 'increment_color' property */ |
| 118 | + public WidgetProperty<WidgetColor> propIncrementColor() |
| 119 | + { |
| 120 | + return increment_color; |
| 121 | + } |
| 122 | + |
| 123 | + /** @return 'decrement_color' property */ |
| 124 | + public WidgetProperty<WidgetColor> propDecrementColor() |
| 125 | + { |
| 126 | + return decrement_color; |
| 127 | + } |
| 128 | + |
| 129 | + /** @return 'integer_digits' property */ |
| 130 | + public WidgetProperty<Integer> propIntegerDigits() |
| 131 | + { |
| 132 | + return integer_digits; |
| 133 | + } |
| 134 | + |
| 135 | + /** @return 'decimal_digits' property */ |
| 136 | + public WidgetProperty<Integer> propDecimalDigits() |
| 137 | + { |
| 138 | + return decimal_digits; |
| 139 | + } |
| 140 | + |
| 141 | + /** @return 'font' property */ |
| 142 | + public WidgetProperty<WidgetFont> propFont() |
| 143 | + { |
| 144 | + return font; |
| 145 | + } |
| 146 | + |
| 147 | + /** @return 'graphic_visible' property */ |
| 148 | + public WidgetProperty<Boolean> propGraphicVisible() |
| 149 | + { |
| 150 | + return graphic_visible; |
| 151 | + } |
| 152 | + |
| 153 | + /** @return 'enabled' property */ |
| 154 | + public WidgetProperty<Boolean> propEnabled() |
| 155 | + { |
| 156 | + return enabled; |
| 157 | + } |
| 158 | + |
| 159 | + /** @return 'invalid_color' property */ |
| 160 | + public WidgetProperty<WidgetColor> propInvalidColor() |
| 161 | + { |
| 162 | + return invalid_color; |
| 163 | + } |
| 164 | + |
| 165 | + /** @return 'minimum' property */ |
| 166 | + public WidgetProperty<Double> propMinimum() |
| 167 | + { |
| 168 | + return minimum; |
| 169 | + } |
| 170 | + |
| 171 | + /** @return 'maximum' property */ |
| 172 | + public WidgetProperty<Double> propMaximum() |
| 173 | + { |
| 174 | + return maximum; |
| 175 | + } |
| 176 | + |
| 177 | + /** @return 'limits_from_pv' property */ |
| 178 | + public WidgetProperty<Boolean> propLimitsFromPV() |
| 179 | + { |
| 180 | + return limits_from_pv; |
| 181 | + } |
| 182 | + |
| 183 | + /** @return 'enabled' property */ |
| 184 | + public WidgetProperty<Boolean> propScrollEnabled() |
| 185 | + { |
| 186 | + return scroll_enabled; |
| 187 | + } |
| 188 | + |
| 189 | + /** @return 'enabled' property */ |
| 190 | + public WidgetProperty<Boolean> propSpinnerShaped() |
| 191 | + { |
| 192 | + return spinner_shaped; |
| 193 | + } |
| 194 | + |
| 195 | +} |
0 commit comments