-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
209 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
...o.display.builder.model/src/org/csstudio/display/builder/model/widgets/EllipseWidget.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2015 Oak Ridge National Laboratory. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*******************************************************************************/ | ||
package org.csstudio.display.builder.model.widgets; | ||
|
||
import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.displayBackgroundColor; | ||
import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.displayLineColor; | ||
import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.displayLineWidth; | ||
import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.displayTransparent; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import org.csstudio.display.builder.model.BaseWidget; | ||
import org.csstudio.display.builder.model.Widget; | ||
import org.csstudio.display.builder.model.WidgetCategory; | ||
import org.csstudio.display.builder.model.WidgetDescriptor; | ||
import org.csstudio.display.builder.model.WidgetProperty; | ||
import org.csstudio.display.builder.model.properties.WidgetColor; | ||
|
||
/** Widget that displays a static ellipse | ||
* @author Kay Kasemir | ||
*/ | ||
@SuppressWarnings("nls") | ||
public class EllipseWidget extends BaseWidget | ||
{ | ||
/** Widget descriptor */ | ||
public static final WidgetDescriptor WIDGET_DESCRIPTOR = | ||
new WidgetDescriptor("ellipse", WidgetCategory.GRAPHIC, | ||
"Ellipse", | ||
"platform:/plugin/org.csstudio.display.builder.model/icons/ellipse.png", | ||
"An ellipse", | ||
Arrays.asList("org.csstudio.opibuilder.widgets.Ellipse")) | ||
{ | ||
@Override | ||
public Widget createWidget() | ||
{ | ||
return new EllipseWidget(); | ||
} | ||
}; | ||
|
||
private WidgetProperty<WidgetColor> background; | ||
private WidgetProperty<Boolean> transparent; | ||
private WidgetProperty<WidgetColor> line_color; | ||
private WidgetProperty<Integer> line_width; | ||
|
||
public EllipseWidget() | ||
{ | ||
super(WIDGET_DESCRIPTOR.getType()); | ||
} | ||
|
||
@Override | ||
protected void defineProperties(final List<WidgetProperty<?>> properties) | ||
{ | ||
super.defineProperties(properties); | ||
properties.add(background = displayBackgroundColor.createProperty(this, new WidgetColor(30, 144, 255))); | ||
properties.add(transparent = displayTransparent.createProperty(this, false)); | ||
properties.add(line_color = displayLineColor.createProperty(this, new WidgetColor(0, 0, 255))); | ||
properties.add(line_width = displayLineWidth.createProperty(this, 3)); | ||
} | ||
|
||
/** @return Display 'background_color' */ | ||
public WidgetProperty<WidgetColor> displayBackgroundColor() | ||
{ | ||
return background; | ||
} | ||
|
||
/** @return Display 'transparent' */ | ||
public WidgetProperty<Boolean> displayTransparent() | ||
{ | ||
return transparent; | ||
} | ||
|
||
/** @return Display 'line_color' */ | ||
public WidgetProperty<WidgetColor> displayLineColor() | ||
{ | ||
return line_color; | ||
} | ||
|
||
/** @return Display 'line_width' */ | ||
public WidgetProperty<Integer> displayLineWidth() | ||
{ | ||
return line_width; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
...src/org/csstudio/display/builder/representation/javafx/widgets/EllipseRepresentation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2015 Oak Ridge National Laboratory. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*******************************************************************************/ | ||
package org.csstudio.display.builder.representation.javafx.widgets; | ||
|
||
import org.csstudio.display.builder.model.DirtyFlag; | ||
import org.csstudio.display.builder.model.WidgetProperty; | ||
import org.csstudio.display.builder.model.widgets.EllipseWidget; | ||
import org.csstudio.display.builder.representation.javafx.JFXUtil; | ||
|
||
import javafx.scene.paint.Color; | ||
import javafx.scene.shape.Ellipse; | ||
import javafx.scene.shape.StrokeType; | ||
|
||
/** Creates JavaFX item for model widget | ||
* @author Kay Kasemir | ||
*/ | ||
public class EllipseRepresentation extends JFXBaseRepresentation<Ellipse, EllipseWidget> | ||
{ | ||
private final DirtyFlag dirty_position = new DirtyFlag(); | ||
private final DirtyFlag dirty_look = new DirtyFlag(); | ||
private Color background, line_color; | ||
|
||
@Override | ||
public Ellipse createJFXNode() throws Exception | ||
{ | ||
final Ellipse ellipse = new Ellipse(); | ||
updateColors(); | ||
return ellipse; | ||
} | ||
|
||
@Override | ||
protected void registerListeners() | ||
{ | ||
// JFX Ellipse is based on center, not top-left corner, | ||
// so can't use the default from super.registerListeners(); | ||
model_widget.positionVisible().addUntypedPropertyListener(this::positionChanged); | ||
model_widget.positionX().addUntypedPropertyListener(this::positionChanged); | ||
model_widget.positionY().addUntypedPropertyListener(this::positionChanged); | ||
model_widget.positionWidth().addUntypedPropertyListener(this::positionChanged); | ||
model_widget.positionHeight().addUntypedPropertyListener(this::positionChanged); | ||
|
||
model_widget.displayBackgroundColor().addUntypedPropertyListener(this::lookChanged); | ||
model_widget.displayTransparent().addUntypedPropertyListener(this::lookChanged); | ||
model_widget.displayLineColor().addUntypedPropertyListener(this::lookChanged); | ||
model_widget.displayLineWidth().addUntypedPropertyListener(this::lookChanged); | ||
} | ||
|
||
private void positionChanged(final WidgetProperty<?> property, final Object old_value, final Object new_value) | ||
{ | ||
dirty_position.mark(); | ||
toolkit.scheduleUpdate(this); | ||
} | ||
|
||
private void lookChanged(final WidgetProperty<?> property, final Object old_value, final Object new_value) | ||
{ | ||
updateColors(); | ||
dirty_look.mark(); | ||
toolkit.scheduleUpdate(this); | ||
} | ||
|
||
private void updateColors() | ||
{ | ||
background = model_widget.displayTransparent().getValue() | ||
? Color.TRANSPARENT | ||
: JFXUtil.convert(model_widget.displayBackgroundColor().getValue()); | ||
line_color = JFXUtil.convert(model_widget.displayLineColor().getValue()); | ||
} | ||
|
||
@Override | ||
public void updateChanges() | ||
{ | ||
// Not using default handling of X/Y super.updateChanges(); | ||
if (dirty_position.checkAndClear()) | ||
{ | ||
if (model_widget.positionVisible().getValue()) | ||
{ | ||
jfx_node.setVisible(true); | ||
final int x = model_widget.positionX().getValue(); | ||
final int y = model_widget.positionY().getValue(); | ||
final int w = model_widget.positionWidth().getValue(); | ||
final int h = model_widget.positionHeight().getValue(); | ||
jfx_node.setCenterX(x + w/2); | ||
jfx_node.setCenterY(y + h/2); | ||
jfx_node.setRadiusX(w/2); | ||
jfx_node.setRadiusY(h/2); | ||
} | ||
else | ||
jfx_node.setVisible(false); | ||
} | ||
if (dirty_look.checkAndClear()) | ||
{ | ||
jfx_node.setFill(background); | ||
jfx_node.setStroke(line_color); | ||
jfx_node.setStrokeWidth(model_widget.displayLineWidth().getValue()); | ||
jfx_node.setStrokeType(StrokeType.INSIDE); | ||
} | ||
} | ||
} |
5abd05b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following must be modified too in order to have the stand-alone editor working:
5abd05b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right.
Furthermore, the Ellipse widget itself is static, it has no runtime support other than the default runtime support for rules and scripts.
For basic PV-based scripts, the default runtime will already check for a "pv_name" property and a "value" property, connecting to the PV and updating the value.
Widgets that have multiple PVs or do something else at runtime need to
The extension points do not require any changes to the original sources, meaning a new 'o.c.my_site' plugin can contribute new widget models, representations and runtimes, add that plugin to the dropins/ folder of a CSS product, and it'll then have the new widgets.
The 'manual' registration to WidgetFactory, JFXRepresentation and maybe WidgetRuntimeFactory of course requires modifying those sources, since the standalone versions don't necessarily use OSGi.
Actually, the standalone application org.csstudio.display.builder.rcp.RuntimeApplication does use OSGi, but the more conveniently started RuntimeDemoJavaFX for use during development rely on the manually registered widgets.