* org.emftrace.quarc.ui.zestgpraphbuilders.AbstractElementGraphBuilder#
* createTooltipFigure(org.emftrace.metamodel.QUARCModel.GSS.Element)
*/
@Override
protected IFigure createTooltipFigure(Element element) {
IFigure tooltipFigure = super.createTooltipFigure(element);
if (element instanceof ConstrainedElement) {
String ratingsString = "";
ratingsString += " Ratings:";
HashMap<String, AbstractCalculator> calculators = new HashMap<String, AbstractCalculator>();
List<Element> leafElementsGoalLayer = getCacheManager()
.getLeafApplicableElementElements(GSSLayer.layer1);
for (Element leafGoal : leafElementsGoalLayer) {
float rating = getCacheManager()
.getIndirectRatingWeight((ConstrainedElement) element, (Goal) leafGoal);
if (rating == 0.0f) continue;
ratingsString += "\n "
+ accessLayer.getAttributeValue(leafGoal, "name")
+ ": ";
ratingsString += String.format("%.2f", rating);
}
ratingsString += "\n";
List<Element> leafElementsPrincipleLayer = getCacheManager()
.getLeafApplicableElementElements(GSSLayer.layer3);
if (element instanceof SolutionInstrument) {
for (Element leafPrinciple : leafElementsPrincipleLayer) {
float rating = getCacheManager()
.getIndirectRatingWeight((ConstrainedElement) element, (Element) leafPrinciple);
if (rating == 0.0f) continue;
ratingsString += " \n "
+ accessLayer.getAttributeValue(leafPrinciple,
"name") + ": ";
ratingsString += String.format("%.2f", rating);
}
ratingsString += "\n";
}
ratingsString += "\n";
calculators.put("max", new MaxCalculator(leafElementsGoalLayer,
getCacheManager()));
calculators.put("min", new MinCalculator(leafElementsGoalLayer,
getCacheManager()));
calculators.put("avg", new AvgCalculator(leafElementsGoalLayer,
getCacheManager()));
if (!getCacheManager().getSelectedGoals().isEmpty()) {
calculators.put("weighted max", new WeightedMaxCalculator(
leafElementsGoalLayer, getCacheManager()));
calculators.put("weighted min", new WeightedMinCalculator(
leafElementsGoalLayer, getCacheManager()));
calculators.put("weighted avg", new WeightedAvgCalculator(
leafElementsGoalLayer, getCacheManager()));
}
if (element instanceof SolutionInstrument) {
calculators.put("max", new MaxCalculator(
leafElementsPrincipleLayer, getCacheManager()));
calculators.put("min", new MinCalculator(
leafElementsPrincipleLayer, getCacheManager()));
calculators.put("avg", new AvgCalculator(
leafElementsPrincipleLayer, getCacheManager()));
if (!getCacheManager().getSelectedPrinciples().isEmpty()) {
calculators.put("weighted max", new WeightedMaxCalculator(
leafElementsPrincipleLayer, getCacheManager()));
calculators.put("weighted min", new WeightedMinCalculator(
leafElementsPrincipleLayer, getCacheManager()));
calculators.put("weighted avg", new WeightedAvgCalculator(
leafElementsPrincipleLayer, getCacheManager()));
}
}
ratingsString += " Aggregations:";
for (Entry<String, AbstractCalculator> entry : calculators
.entrySet()) {
ratingsString += " \n " + entry.getKey() + ": ";
ratingsString += entry.getValue()
.calcAggregationAsString((ConstrainedElement) element);
}
org.eclipse.draw2d.Label ratingsLabel = new org.eclipse.draw2d.Label(
"\n" + ratingsString + "\n");
ratingsLabel.setFont(defaultLabelFont);
tooltipFigure.add(ratingsLabel);
tooltipFigure.setSize(-1, -1);
}
return tooltipFigure;
}