Search in sources :

Example 1 with FxStyle

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();
}
Also used : IPath(org.eclipse.core.runtime.IPath) AgeGefRuntimeException(org.osate.ge.gef.AgeGefRuntimeException) FxStyle(org.osate.ge.gef.FxStyle)

Example 2 with FxStyle

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);
    }
}
Also used : EllipseNode(org.osate.ge.gef.EllipseNode) LabelNode(org.osate.ge.gef.LabelNode) Node(javafx.scene.Node) ConnectionNode(org.osate.ge.gef.ConnectionNode) FlowIndicatorNode(org.osate.ge.gef.FlowIndicatorNode) LineStyle(org.osate.ge.graphics.LineStyle) FxStyle(org.osate.ge.gef.FxStyle) Style(org.osate.ge.graphics.Style) FxStyle(org.osate.ge.gef.FxStyle)

Example 3 with 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);
    }
}
Also used : FxStyle(org.osate.ge.gef.FxStyle) Style(org.osate.ge.graphics.Style) FxStyle(org.osate.ge.gef.FxStyle)

Aggregations

FxStyle (org.osate.ge.gef.FxStyle)3 Style (org.osate.ge.graphics.Style)2 Node (javafx.scene.Node)1 IPath (org.eclipse.core.runtime.IPath)1 AgeGefRuntimeException (org.osate.ge.gef.AgeGefRuntimeException)1 ConnectionNode (org.osate.ge.gef.ConnectionNode)1 EllipseNode (org.osate.ge.gef.EllipseNode)1 FlowIndicatorNode (org.osate.ge.gef.FlowIndicatorNode)1 LabelNode (org.osate.ge.gef.LabelNode)1 LineStyle (org.osate.ge.graphics.LineStyle)1