use of org.osate.ge.gef.FxStyle in project osate2 by osate.
the class StyleToFx method createStyle.
/**
* Creates an {@link FxStyle} instance from a {@link Style} instance.
* @param style the style for which to create an {@link FxStyle}.
* @return the Java FX implementation specific style.
*/
public FxStyle createStyle(final Style style) {
if (!style.isComplete()) {
throw new AgeGefRuntimeException("Specified style must be complete");
}
final IPath imagePath = style.getShowAsImage() ? style.getImagePath() : null;
// Convert from pixels to points
final double fontSizeInPoints = style.getFontSize() * 96.0 / 72.0;
return new FxStyle.Builder().backgroundColor(convert(style.getBackgroundColor())).outlineColor(convert(style.getOutlineColor())).fontColor(convert(style.getFontColor())).font(Font.font("Arial", FontWeight.NORMAL, fontSizeInPoints)).strokeDashArray(getStrokeDashArray(style.getLineStyle())).lineWidth(style.getLineWidth()).horizontalLabelPosition(convert(style.getHorizontalLabelPosition())).verticalLabelPosition(convert(style.getVerticalLabelPosition())).primaryLabelsVisible(style.getPrimaryLabelVisible()).image(imagePath == null ? null : imageManager.getImageReference(imagePath.toFile().toPath())).build();
}
use of org.osate.ge.gef.FxStyle in project osate2 by osate.
the class AgeFxTest method refreshStyle.
private void refreshStyle() {
final Style style = StyleBuilder.create(baseStyle).lineStyle(dashed ? LineStyle.DASHED : LineStyle.SOLID).build();
final FxStyle fxStyle = styleToFx.createStyle(style);
for (final Node node : container.getChildrenUnmodifiable()) {
FxStyleApplier.applyStyle(node, fxStyle);
}
}
use of org.osate.ge.gef.FxStyle in project osate2 by osate.
the class GefAgeDiagram method calculateAndApplyStyle.
/**
* Determines the final style and applies it to the diagram element
* Assumes override style information has been updated using {@link #refreshOverrideStyles()}
* @param gefDiagramElement the GEF diagram element for which to refresh the style
* @param styleProvider the style provider which will be used to determine the final style for the diagram element
*/
private void calculateAndApplyStyle(final GefDiagramElement gefDiagramElement, final StyleProvider styleProvider) {
if (gefDiagramElement != null && gefDiagramElement.sceneNode != null) {
final Style style = styleProvider.getStyle(gefDiagramElement.diagramElement);
final FxStyle fxStyle = styleToFx.createStyle(style);
FxStyleApplier.applyStyle(gefDiagramElement.sceneNode, fxStyle);
}
}
Aggregations