Search in sources :

Example 1 with StyleBuilder

use of org.osate.ge.graphics.StyleBuilder in project osate2 by osate.

the class ConnectionHandler method getGraphicalConfiguration.

@Override
public Optional<GraphicalConfiguration> getGraphicalConfiguration(final GetGraphicalConfigurationContext ctx) {
    final BusinessObjectContext boc = ctx.getBusinessObjectContext();
    final QueryService queryService = ctx.getQueryService();
    final Connection c = boc.getBusinessObject(Connection.class).orElseThrow();
    final QueryResult src = queryService.getFirstResult(SRC_QUERY, boc, c).orElse(null);
    final QueryResult dst = queryService.getFirstResult(DST_QUERY, boc, c).orElse(null);
    final boolean partial = (src != null && src.isPartial()) || (dst != null && dst.isPartial());
    final StyleBuilder sb = StyleBuilder.create(AadlInheritanceUtil.isInherited(boc) ? Styles.INHERITED_ELEMENT : Style.EMPTY);
    if (partial) {
        sb.dotted();
    }
    return Optional.of(GraphicalConfigurationBuilder.create().graphic(GRAPHIC).style(sb.build()).source(src == null ? null : src.getBusinessObjectContext()).destination(dst == null ? null : dst.getBusinessObjectContext()).build());
}
Also used : QueryResult(org.osate.ge.query.QueryResult) QueryService(org.osate.ge.services.QueryService) Connection(org.osate.aadl2.Connection) StyleBuilder(org.osate.ge.graphics.StyleBuilder) BusinessObjectContext(org.osate.ge.BusinessObjectContext)

Example 2 with StyleBuilder

use of org.osate.ge.graphics.StyleBuilder in project osate2 by osate.

the class FlowSpecificationInstanceHandler method getGraphicalConfiguration.

@Override
public Optional<GraphicalConfiguration> getGraphicalConfiguration(final GetGraphicalConfigurationContext ctx) {
    final BusinessObjectContext boc = ctx.getBusinessObjectContext();
    final FlowSpecificationInstance fsi = boc.getBusinessObject(FlowSpecificationInstance.class).get();
    final QueryService queryService = ctx.getQueryService();
    final QueryResult srcResult = queryService.getFirstResult(SRC_QUERY, boc, fsi).orElse(null);
    final BusinessObjectContext src = srcResult == null ? null : srcResult.getBusinessObjectContext();
    boolean partial = (srcResult != null && srcResult.isPartial());
    BusinessObjectContext dst = null;
    if (fsi.getFlowSpecification().getKind() == FlowKind.PATH) {
        final QueryResult dstResult = queryService.getFirstResult(DST_QUERY, boc, fsi).orElse(null);
        dst = dstResult == null ? null : dstResult.getBusinessObjectContext();
        partial |= (dstResult != null && dstResult.isPartial());
    }
    final StyleBuilder sb = StyleBuilder.create(AadlInheritanceUtil.isInherited(boc) ? Styles.INHERITED_ELEMENT : Style.EMPTY);
    if (fsi.getFlowSpecification().getKind() == FlowKind.PATH) {
        sb.lineWidth(4.0);
    }
    if (partial) {
        sb.dotted();
    }
    return Optional.of(GraphicalConfigurationBuilder.create().graphic(AadlGraphics.getFlowSpecificationGraphic(fsi.getFlowSpecification())).style(sb.build()).source(src).destination(dst).build());
}
Also used : QueryResult(org.osate.ge.query.QueryResult) QueryService(org.osate.ge.services.QueryService) StyleBuilder(org.osate.ge.graphics.StyleBuilder) FlowSpecificationInstance(org.osate.aadl2.instance.FlowSpecificationInstance) BusinessObjectContext(org.osate.ge.BusinessObjectContext)

Example 3 with StyleBuilder

use of org.osate.ge.graphics.StyleBuilder in project osate2 by osate.

the class StyleCalculator method getDiagramConnectionStyle.

private static Style getDiagramConnectionStyle(final DiagramConfiguration config) {
    final StyleBuilder diagramConnectionStyleBuilder = StyleBuilder.create(Style.EMPTY);
    diagramConnectionStyleBuilder.primaryLabelVisible(config.getConnectionPrimaryLabelsVisible());
    return diagramConnectionStyleBuilder.build();
}
Also used : StyleBuilder(org.osate.ge.graphics.StyleBuilder)

Example 4 with StyleBuilder

use of org.osate.ge.graphics.StyleBuilder in project osate2 by osate.

the class ErrorFlowHandler method getGraphicalConfiguration.

@Override
public Optional<GraphicalConfiguration> getGraphicalConfiguration(final GetGraphicalConfigurationContext ctx) {
    final ErrorFlow bo = ctx.getBusinessObjectContext().getBusinessObject(ErrorFlow.class).get();
    final BusinessObjectContext classifierBoc = ctx.getBusinessObjectContext().getParent();
    if (classifierBoc == null) {
        return Optional.empty();
    }
    // Determine the type of graphic and the source and destination of the connection
    final ErrorFlowEnd src;
    final ErrorFlowEnd dst;
    final Graphic graphic;
    if (bo instanceof ErrorSource) {
        graphic = SOURCE_GRAPHIC;
        final ErrorSource es = (ErrorSource) bo;
        src = getErrorFlowEnd(ctx.getQueryService(), classifierBoc, es.isAll(), es.getSourceModelElement()).orElse(null);
        dst = null;
    } else if (bo instanceof ErrorSink) {
        graphic = SINK_GRAPHIC;
        final ErrorSink es = (ErrorSink) bo;
        src = getErrorFlowEnd(ctx.getQueryService(), classifierBoc, es.isAllIncoming(), es.getIncoming()).orElse(null);
        dst = null;
    } else if (bo instanceof ErrorPath) {
        graphic = PATH_GRAPHIC;
        final ErrorPath ep = (ErrorPath) bo;
        src = getErrorFlowEnd(ctx.getQueryService(), classifierBoc, ep.isAllIncoming(), ep.getIncoming()).orElse(null);
        dst = getErrorFlowEnd(ctx.getQueryService(), classifierBoc, ep.isAllOutgoing(), ep.getOutgoing()).orElse(null);
    } else {
        return Optional.empty();
    }
    // Determine style
    final StyleBuilder sb = StyleBuilder.create(GraphicalExtensionUtil.isInherited(ctx.getBusinessObjectContext()) ? GraphicalExtensionUtil.STYLE_INHERITED_ELEMENT : Style.EMPTY).lineWidth(4.0);
    final boolean partial = (src != null && src.partial) || (dst != null && dst.partial);
    if (partial) {
        sb.dotted();
    }
    return Optional.of(GraphicalConfigurationBuilder.create().graphic(graphic).style(sb.build()).defaultDockingPosition(DockingPosition.ANY).source(src == null ? null : src.boc).destination(dst == null ? null : dst.boc).build());
}
Also used : ErrorSource(org.osate.xtext.aadl2.errormodel.errorModel.ErrorSource) ErrorFlow(org.osate.xtext.aadl2.errormodel.errorModel.ErrorFlow) Graphic(org.osate.ge.graphics.Graphic) StyleBuilder(org.osate.ge.graphics.StyleBuilder) ErrorPath(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPath) BusinessObjectContext(org.osate.ge.BusinessObjectContext) ErrorSink(org.osate.xtext.aadl2.errormodel.errorModel.ErrorSink)

Example 5 with StyleBuilder

use of org.osate.ge.graphics.StyleBuilder in project osate2 by osate.

the class PropagationPathHandler method getGraphicalConfiguration.

@Override
public Optional<GraphicalConfiguration> getGraphicalConfiguration(final GetGraphicalConfigurationContext ctx) {
    final PropagationPath bo = ctx.getBusinessObjectContext().getBusinessObject(PropagationPath.class).get();
    final BusinessObjectContext classifierBoc = ctx.getBusinessObjectContext().getParent();
    if (classifierBoc == null) {
        return Optional.empty();
    }
    // Determine source and destination of the connection
    final QueryResult src = ctx.getQueryService().getFirstResult(PROPAGATION_POINT_QUERY, classifierBoc, bo.getSource()).orElse(null);
    final QueryResult dst = ctx.getQueryService().getFirstResult(PROPAGATION_POINT_QUERY, classifierBoc, bo.getTarget()).orElse(null);
    // Determine style
    final StyleBuilder sb = StyleBuilder.create(GraphicalExtensionUtil.isInherited(ctx.getBusinessObjectContext()) ? GraphicalExtensionUtil.STYLE_INHERITED_ELEMENT : Style.EMPTY).lineWidth(2.0);
    final boolean partial = (src != null && src.isPartial()) || (dst != null && dst.isPartial());
    if (partial) {
        sb.dotted();
    }
    return Optional.of(GraphicalConfigurationBuilder.create().graphic(GRAPHIC).style(sb.build()).defaultDockingPosition(DockingPosition.ANY).source(src == null ? null : src.getBusinessObjectContext()).destination(dst == null ? null : dst.getBusinessObjectContext()).build());
}
Also used : PropagationPath(org.osate.xtext.aadl2.errormodel.errorModel.PropagationPath) QueryResult(org.osate.ge.query.QueryResult) StyleBuilder(org.osate.ge.graphics.StyleBuilder) BusinessObjectContext(org.osate.ge.BusinessObjectContext)

Aggregations

StyleBuilder (org.osate.ge.graphics.StyleBuilder)6 BusinessObjectContext (org.osate.ge.BusinessObjectContext)5 QueryResult (org.osate.ge.query.QueryResult)4 QueryService (org.osate.ge.services.QueryService)3 Connection (org.osate.aadl2.Connection)1 FlowSpecification (org.osate.aadl2.FlowSpecification)1 FlowSpecificationInstance (org.osate.aadl2.instance.FlowSpecificationInstance)1 Graphic (org.osate.ge.graphics.Graphic)1 ErrorFlow (org.osate.xtext.aadl2.errormodel.errorModel.ErrorFlow)1 ErrorPath (org.osate.xtext.aadl2.errormodel.errorModel.ErrorPath)1 ErrorSink (org.osate.xtext.aadl2.errormodel.errorModel.ErrorSink)1 ErrorSource (org.osate.xtext.aadl2.errormodel.errorModel.ErrorSource)1 PropagationPath (org.osate.xtext.aadl2.errormodel.errorModel.PropagationPath)1