/** * Remove the highlighting and visible annotations for all property-able objects. * * @param colors True if the highlight colors should be cleared. * @param text True if the ontology concept annotation text should be cleared. * @exception IllegalActionException If getting the resolved concept fails. */ public void clearDisplay(boolean colors, boolean text) throws IllegalActionException { if (colors || text) { // Get the OntologySolver. OntologySolver solver = (OntologySolver) getContainer(); for (Object propertyable : solver.getAllPropertyables()) { if (propertyable instanceof NamedObj) { Concept concept = solver.getConcept(propertyable); if (concept != null || ((NamedObj) propertyable).getAttribute("_showInfo") != null && colors || ((NamedObj) propertyable).getAttribute("_highlightColor") != null && text) { String request = "<group>"; if (((NamedObj) propertyable).getAttribute("_showInfo") != null && text) { request += "<deleteProperty name=\"_showInfo\"/>"; } if (((NamedObj) propertyable).getAttribute("_highlightColor") != null && colors) { request += "<deleteProperty name=\"_highlightColor\"/>"; } request += "</group>"; MoMLChangeRequest change = new MoMLChangeRequest(this, (NamedObj) propertyable, request, false); ((NamedObj) propertyable).requestChange(change); } } } // Force a single repaint after all the above requests have been processed. solver.requestChange(new MoMLChangeRequest(this, solver, "<group/>")); } }
/** * Highlight concepts that have already been resolved, but do not run solver. Otherwise, do * nothing. * * @param objects The set of objects to highlight. * @exception IllegalActionException Thrown if there is an error getting the colors for the * resolved concept values. */ public void highlightConcepts(Set<Object> objects) throws IllegalActionException { if (objects != null) { // Get the PropertySolver. OntologySolver solver = (OntologySolver) getContainer(); for (Object object : objects) { if (object instanceof NamedObj) { Concept concept = solver.getConcept(object); if (concept != null) { ColorAttribute conceptColor = concept.getColor(); if (conceptColor != null) { String request = "<property name=\"_highlightColor\" " + "class=\"ptolemy.actor.gui.ColorAttribute\" value=\"" + conceptColor.getExpression() + "\"/>"; MoMLChangeRequest change = new MoMLChangeRequest(this, (NamedObj) object, request, false); ((NamedObj) object).requestChange(change); } } } } // Force a single repaint after all the above requests have been processed. solver.requestChange(new MoMLChangeRequest(this, solver, "<group/>")); } }
/** * Show all concept values as text annotations on each model element. * * @exception IllegalActionException If getting the resolved concept fails. */ public void showConceptAnnotations() throws IllegalActionException { // Get the PropertySolver. OntologySolver solver = (OntologySolver) getContainer(); for (Object propertyable : solver.getAllPropertyables()) { if (propertyable instanceof NamedObj) { Concept concept = solver.getConcept(propertyable); if (concept != null) { String request = "<property name=\"_showInfo\" class=\"ptolemy.data.expr.StringParameter\" value=\"" + concept.toString() + "\"/>"; MoMLChangeRequest change = new MoMLChangeRequest(this, (NamedObj) propertyable, request, false); ((NamedObj) propertyable).requestChange(change); } } } // Force a single repaint after all the above requests have been processed. solver.requestChange(new MoMLChangeRequest(this, solver, "<group/>")); }