use of org.csstudio.display.builder.model.properties.WidgetColor in project org.csstudio.display.builder by kasemir.
the class JFXRepresentation method updateBackground.
/**
* Update background, using background color and grid information from model
*/
private void updateBackground() {
final WidgetColor background = model.propBackgroundColor().getValue();
// Setting the "-fx-background:" of the root node propagates
// to all child nodes in the scene graph.
//
// if (isEditMode())
// model_root.setStyle("-fx-background: linear-gradient(from 0px 0px to 10px 10px, reflect, #D2A2A2 48%, #D2A2A2 2%, #D2D2A2 48% #D2D2A2 2%)");
// else
// model_root.setStyle("-fx-background: " + JFXUtil.webRGB(background));
//
// In edit mode, this results in error messages because the linear-gradient doesn't "work" for all nodes:
//
// javafx.scene.CssStyleHelper (calculateValue)
// Caught java.lang.ClassCastException: javafx.scene.paint.LinearGradient cannot be cast to javafx.scene.paint.Color
// while converting value for
// '-fx-background-color' from rule '*.text-input' in stylesheet ..jfxrt.jar!/com/sun/javafx/scene/control/skin/modena/modena.bss
// '-fx-effect' from rule '*.scroll-bar:vertical>*.increment-button>*.increment-arrow' in StyleSheet ... jfxrt.jar!/com/sun/javafx/scene/control/skin/modena/modena.bss
// '-fx-effect' from rule '*.scroll-bar:vertical>*.decrement-button>*.decrement-arrow' in stylesheet ... modena.bss
// '-fx-effect' from rule '*.scroll-bar:horizontal>*.increment-button>*.increment-arrow' in stylesheet ... modena.bss
//
// In the runtime, the background color style is applied to for example the TextEntryRepresentation,
// overriding its jfx_node.setBackground(..) setting.
// Setting just the scroll body background to a plain color or grid image provides basic color control.
// In edit mode, the horiz_bound, vert_bound lines and grid provide sufficient
// visual indication of the display size.
final Color backgroundColor = new Color(background.getRed(), background.getGreen(), background.getBlue());
final boolean gridVisible = isEditMode() ? model.propGridVisible().getValue() : false;
final int gridStepX = model.propGridStepX().getValue(), gridStepY = model.propGridStepY().getValue();
final WidgetColor grid_rgb = model.propGridColor().getValue();
final Color gridColor = new Color(grid_rgb.getRed(), grid_rgb.getGreen(), grid_rgb.getBlue());
final BufferedImage image = new BufferedImage(gridStepX, gridStepY, BufferedImage.TYPE_INT_ARGB);
final Graphics2D g2d = image.createGraphics();
g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
g2d.setBackground(backgroundColor);
g2d.clearRect(0, 0, gridStepX, gridStepY);
if (gridVisible) {
g2d.setColor(gridColor);
g2d.setStroke(new BasicStroke(GRID_LINE_WIDTH));
g2d.drawLine(0, 0, gridStepX, 0);
g2d.drawLine(0, 0, 0, gridStepY);
}
final WritableImage wimage = new WritableImage(gridStepX, gridStepY);
SwingFXUtils.toFXImage(image, wimage);
final ImagePattern pattern = new ImagePattern(wimage, 0, 0, gridStepX, gridStepY, false);
widget_parent.setBackground(new Background(new BackgroundFill(pattern, CornerRadii.EMPTY, Insets.EMPTY)));
}
use of org.csstudio.display.builder.model.properties.WidgetColor in project org.csstudio.display.builder by kasemir.
the class MenuButtonDemo method start.
@Override
public void start(final Stage stage) {
final MenuButton button1 = new MenuButton("Plain Button", null, new MenuItem("Item 1"), new MenuItem("Item 2"));
button1.getStyleClass().add("action_button");
final MenuItem item = new MenuItem("Action Button Item");
item.getStyleClass().add("action_button_item");
final MenuButton button2 = new MenuButton("Dark Button", null, item, new MenuItem("Plain Item"));
button2.setStyle(JFXUtil.shadedStyle(new WidgetColor(100, 0, 0)));
button2.setTextFill(Color.YELLOW);
button2.getStyleClass().add("action_button");
final HBox box = new HBox(button1, button2);
final Scene scene = new Scene(box, 800, 700);
// XXX Enable scenic view to debug styles
// ScenicView.show(scene);
JFXRepresentation.setSceneStyle(scene);
stage.setScene(scene);
stage.setTitle("MenuButtons");
stage.show();
}
use of org.csstudio.display.builder.model.properties.WidgetColor in project org.csstudio.display.builder by kasemir.
the class ClockWidget method defineProperties.
@Override
protected void defineProperties(final List<WidgetProperty<?>> properties) {
super.defineProperties(properties);
properties.add(skin = propSkin.createProperty(this, Skin.PLAIN));
properties.add(background_color = propBackgroundColor.createProperty(this, new WidgetColor(230, 230, 153)));
properties.add(transparent = propTransparent.createProperty(this, false));
properties.add(discreteHours = propDiscreteHours.createProperty(this, false));
properties.add(discreteMinutes = propDiscreteMinutes.createProperty(this, false));
properties.add(discreteSeconds = propDiscreteSeconds.createProperty(this, false));
properties.add(borderColor = propBorderColor.createProperty(this, new WidgetColor(153, 230, 230)));
properties.add(borderWidth = propBorderWidth.createProperty(this, 0.0));
properties.add(dateColor = propDateColor.createProperty(this, new WidgetColor(102, 51, 102)));
properties.add(hourColor = propHourColor.createProperty(this, new WidgetColor(255, 127, 80)));
properties.add(hourTickMarkColor = propHourTickMarkColor.createProperty(this, new WidgetColor(196, 127, 80)));
properties.add(hourTickMarkVisible = propHourTickMarkVisible.createProperty(this, true));
properties.add(knobColor = propKnobColor.createProperty(this, new WidgetColor(196, 127, 80)));
properties.add(minuteColor = propMinuteColor.createProperty(this, new WidgetColor(255, 136, 98)));
properties.add(minuteTickMarkColor = propMinuteTickMarkColor.createProperty(this, new WidgetColor(196, 136, 98)));
properties.add(minuteTickMarkVisible = propMinuteTickMarkVisible.createProperty(this, true));
properties.add(secondColor = propSecondColor.createProperty(this, new WidgetColor(98, 196, 136)));
properties.add(textColor = propTextColor.createProperty(this, new WidgetColor(136, 196, 136)));
properties.add(textVisible = propTextVisible.createProperty(this, false));
properties.add(tickLabelColor = propTickLabelColor.createProperty(this, new WidgetColor(196, 136, 136)));
properties.add(tickLabelsVisible = propTickLabelsVisible.createProperty(this, true));
properties.add(titleColor = propTitleColor.createProperty(this, new WidgetColor(136, 196, 136)));
}
use of org.csstudio.display.builder.model.properties.WidgetColor in project org.csstudio.display.builder by kasemir.
the class ProgressBarWidget method defineProperties.
@Override
protected void defineProperties(final List<WidgetProperty<?>> properties) {
super.defineProperties(properties);
properties.add(fill_color = propFillColor.createProperty(this, new WidgetColor(60, 255, 60)));
properties.add(limits_from_pv = propLimitsFromPV.createProperty(this, true));
properties.add(minimum = propMinimum.createProperty(this, 0.0));
properties.add(maximum = propMaximum.createProperty(this, 100.0));
properties.add(horizontal = propHorizontal.createProperty(this, true));
}
use of org.csstudio.display.builder.model.properties.WidgetColor in project org.csstudio.display.builder by kasemir.
the class KnobWidget method defineProperties.
@Override
protected void defineProperties(final List<WidgetProperty<?>> properties) {
super.defineProperties(properties);
properties.add(readback_pv_name = propReadbackPVName.createProperty(this, ""));
properties.add(readback_pv_value = propReadbackPVValue.createProperty(this, RUNTIME_VALUE_NO_PV));
properties.add(background_color = propBackgroundColor.createProperty(this, new WidgetColor(255, 254, 253)));
properties.add(color = propColor.createProperty(this, new WidgetColor(66, 71, 79)));
properties.add(precision = propPrecision.createProperty(this, -1));
properties.add(extrema_visible = propExtremaVisible.createProperty(this, false));
properties.add(level_hihi = propLevelHiHi.createProperty(this, 90.0));
properties.add(level_high = propLevelHigh.createProperty(this, 80.0));
properties.add(level_lolo = propLevelLoLo.createProperty(this, 10.0));
properties.add(level_low = propLevelLow.createProperty(this, 20.0));
properties.add(show_hihi = propShowHiHi.createProperty(this, true));
properties.add(show_high = propShowHigh.createProperty(this, true));
properties.add(show_ok = propShowOK.createProperty(this, true));
properties.add(show_low = propShowLow.createProperty(this, true));
properties.add(show_lolo = propShowLoLo.createProperty(this, true));
properties.add(tag_color = propTagColor.createProperty(this, new WidgetColor(204, 102, 80)));
properties.add(tag_visible = propTagVisible.createProperty(this, false));
properties.add(target_visible = propTargetVisible.createProperty(this, true));
properties.add(text_color = propTextColor.createProperty(this, new WidgetColor(255, 255, 255)));
properties.add(thumb_color = propThumbColor.createProperty(this, new WidgetColor(46, 50, 55)));
properties.add(transparent = propTransparent.createProperty(this, true));
properties.add(unit = propUnit.createProperty(this, ""));
properties.add(value_color = propValueColor.createProperty(this, new WidgetColor(0, 22, 0, 153)));
properties.add(drag_disabled = propDragDisabled.createProperty(this, false));
properties.add(enabled = propEnabled.createProperty(this, true));
properties.add(limits_from_pv = propLimitsFromPV.createProperty(this, true));
properties.add(minimum = propMinimum.createProperty(this, 0.0));
properties.add(maximum = propMaximum.createProperty(this, 100.0));
properties.add(synced_knob = propSyncedKnob.createProperty(this, false));
properties.add(unit_from_pv = propUnitFromPV.createProperty(this, true));
properties.add(write_on_release = propWriteOnRelease.createProperty(this, true));
properties.add(zero_detent_enabled = propZeroDetentEnabled.createProperty(this, false));
}
Aggregations