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());
}
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());
}
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();
}
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());
}
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());
}
Aggregations