Search in sources :

Example 6 with StyleBuilder

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

the class FlowSpecificationHandler method getGraphicalConfiguration.

@Override
public Optional<GraphicalConfiguration> getGraphicalConfiguration(final GetGraphicalConfigurationContext ctx) {
    final BusinessObjectContext boc = ctx.getBusinessObjectContext();
    final FlowSpecification fs = boc.getBusinessObject(FlowSpecification.class).orElseThrow();
    final QueryService queryService = ctx.getQueryService();
    final QueryResult srcResult = queryService.getFirstResult(SRC_QUERY, boc, fs).orElse(null);
    final BusinessObjectContext src = srcResult == null ? null : srcResult.getBusinessObjectContext();
    boolean partial = (srcResult != null && srcResult.isPartial());
    BusinessObjectContext dst = null;
    if (fs.getKind() == FlowKind.PATH) {
        final QueryResult dstResult = queryService.getFirstResult(DST_QUERY, boc, fs).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 (fs.getKind() == FlowKind.PATH) {
        sb.lineWidth(4.0);
    }
    if (partial) {
        sb.dotted();
    }
    return Optional.of(GraphicalConfigurationBuilder.create().graphic(AadlGraphics.getFlowSpecificationGraphic(fs)).style(sb.build()).source(src).destination(dst).build());
}
Also used : QueryResult(org.osate.ge.query.QueryResult) FlowSpecification(org.osate.aadl2.FlowSpecification) QueryService(org.osate.ge.services.QueryService) 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