use of com.google.cloud.vision.v1p3beta1.Feature in project osate2 by osate.
the class AadlFeatureUtil method getAllFeatures.
public static EList<Feature> getAllFeatures(final FeatureGroupType fgt) {
final EList<Feature> owned = getAllOwnedFeatures(fgt);
final FeatureGroupType inverseFgt = fgt.getInverse();
if (owned.isEmpty() && !Aadl2Util.isNull(inverseFgt)) {
return getAllOwnedFeatures(inverseFgt);
}
return owned;
}
use of com.google.cloud.vision.v1p3beta1.Feature in project osate2 by osate.
the class FeatureInstanceTooltipContributor method addTooltipContents.
@Override
public void addTooltipContents(final TooltipContributorContext ctx) {
ctx.getBusinessObjectContext().getBusinessObject(FeatureInstance.class).ifPresent(featureInstance -> {
final Feature feature = featureInstance.getFeature();
if (feature instanceof Feature || feature instanceof InternalFeature || feature instanceof ProcessorFeature) {
// Determine the feature classifier
final Classifier featureClassifier;
if (feature instanceof EventDataSource) {
final EventDataSource aadlFeature = (EventDataSource) feature;
featureClassifier = aadlFeature.getDataClassifier();
} else if (feature instanceof PortProxy) {
final PortProxy aadlFeature = (PortProxy) feature;
featureClassifier = aadlFeature.getDataClassifier();
} else if (feature instanceof SubprogramProxy) {
final SubprogramProxy aadlFeature = (SubprogramProxy) feature;
featureClassifier = aadlFeature.getSubprogramClassifier();
} else if (feature instanceof Feature) {
final Feature aadlFeature = (Feature) feature;
featureClassifier = aadlFeature.getAllClassifier();
} else {
featureClassifier = null;
}
// Build the text to contribute to the tooltip
final StringBuffer tooltipContents = new StringBuffer();
if (featureClassifier instanceof ComponentClassifier) {
tooltipContents.append(((ComponentClassifier) featureClassifier).getCategory() + " " + featureClassifier.getQualifiedName());
} else if (featureClassifier instanceof FeatureGroupType) {
tooltipContents.append("feature group " + featureClassifier.getQualifiedName());
} else if (featureClassifier == null) {
tooltipContents.append("No Classifier");
} else {
tooltipContents.append(featureClassifier.getQualifiedName());
}
// Create the styled text describing the feature
final Label lbl = new Label(ctx.getTooltip(), SWT.NONE);
lbl.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
lbl.setText(tooltipContents.toString());
}
});
}
use of com.google.cloud.vision.v1p3beta1.Feature in project osate2 by osate.
the class AnalysisModel method getAllPropagationDestinationEnds.
/**
* return all feature (or for access component) instances that are the
* connection destination of the given feature instance The source and
* destinations are assumed to be components with error models
*
* @param fi
* @return list of ConnectionInstanceEnd
*/
public EList<ConnectionInstanceEnd> getAllPropagationDestinationEnds(ConnectionInstanceEnd fi) {
EList<ConnectionInstanceEnd> result = new BasicEList<ConnectionInstanceEnd>();
NamedElement f = null;
if (fi instanceof FeatureInstance) {
f = ((FeatureInstance) fi).getFeature();
} else {
f = ((ComponentInstance) fi).getSubcomponent();
}
for (PropagationPathRecord propagationPathRecord : propagationPaths) {
PropagationPathEnd src = propagationPathRecord.getPathSrc();
ErrorPropagation ep = src.getErrorPropagation();
Feature srcf = EMV2Util.getFeature(ep);
if (srcf != null && srcf == f) {
PropagationPathEnd dst = propagationPathRecord.pathDst;
ErrorPropagation dstep = dst.getErrorPropagation();
if (dstep != null) {
Feature dstf = EMV2Util.getFeature(dstep);
ComponentInstance dstCI = dst.getComponentInstance();
if (dstf != null) {
FeatureInstance dstfi = dstCI.findFeatureInstance(dstf);
result.add(dstfi);
} else if (EMV2Util.isAccess(dstep)) {
result.add(dstCI);
}
}
}
}
return result;
}
use of com.google.cloud.vision.v1p3beta1.Feature in project osate2 by osate.
the class GetProperties method sumElementsDataSize.
private static double sumElementsDataSize(final NamedElement ne, UnitLiteral unit, Property DataSize, Property SourceDataSize, int nesting) {
double res = 0.0;
Classifier cl = null;
if (ne instanceof Classifier) {
cl = (Classifier) ne;
} else if (ne instanceof FeatureInstance) {
cl = ((FeatureInstance) ne).getFeature().getAllClassifier();
} else if (ne instanceof Feature) {
cl = ((Feature) ne).getClassifier();
} else if (ne instanceof DataSubcomponent) {
cl = ((DataSubcomponent) ne).getClassifier();
}
if (cl != null) {
if (cl instanceof FeatureGroupType) {
EList<Feature> fl = ((FeatureGroupType) cl).getAllFeatures();
for (Feature f : fl) {
res = res + getDataSize(f, unit, DataSize, SourceDataSize, nesting);
}
} else if (cl instanceof DataImplementation) {
for (Subcomponent ds : ((DataImplementation) cl).getAllSubcomponents()) {
if (!AadlUtil.isSameOrExtends(cl, ds.getAllClassifier())) {
res = res + getDataSize(ds, unit, DataSize, SourceDataSize, nesting);
}
}
}
}
return res;
}
use of com.google.cloud.vision.v1p3beta1.Feature in project osate2 by osate.
the class CreateErrorPropagationPaletteCommand method getOperation.
@Override
public Optional<Operation> getOperation(final GetTargetedOperationContext ctx) {
final Object bo = ctx.getTarget().getBusinessObject();
if (bo instanceof Feature) {
return createPropgationCreationOperation(ctx.getTarget(), (newPropagation, subclause) -> {
// Find the feature in the context of the EMV subclause. This is needed for reliable serialization.
final List<URI> path = ErrorModelGeUtil.createQualifiedPropagationPointPath(ctx.getTarget(), ErrorModelGeUtil.getClassifierSourceBoc(ctx.getTarget()).get(), new ArrayList<>());
newPropagation.setFeatureorPPRef(buildFeatureReference(subclause.eResource().getResourceSet(), path));
});
} else if (bo instanceof KeywordPropagationPoint) {
final KeywordPropagationPoint kw = (KeywordPropagationPoint) bo;
if (kw.getType() != KeywordPropagationPointType.ALL) {
return createPropgationCreationOperation(ctx.getTarget(), (newPropagation, subclause) -> newPropagation.setKind(kw.getType().getKind()));
}
} else if (bo instanceof PropagationPoint) {
return createPropgationCreationOperation(ctx.getTarget(), (newPropagation, subclause) -> {
// Find the propagation in the context of the EMV subclause.
// Check inherited subclauses as well. This is needed for reliable serialization.
final CombinedErrorModelSubclause combined = CombinedErrorModelSubclause.create(subclause.getContainingClassifier());
final String boName = ((PropagationPoint) bo).getName();
final PropagationPoint pp = combined.getPoints().filter(p -> Objects.equal(p.getName(), boName)).findAny().orElseThrow(() -> new AadlGraphicalEditorException("Unable to find propagation point"));
final FeatureorPPReference ppRef = ErrorModelFactory.eINSTANCE.createFeatureorPPReference();
ppRef.setFeatureorPP(pp);
newPropagation.setFeatureorPPRef(ppRef);
});
}
return Optional.empty();
}
Aggregations