/**
   * 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/>"));
 }
Exemple #4
0
  /**
   * Return the list of AnnotationAttributes specific to this use-case.
   *
   * @return The list of AnnotationAttributes.
   * @exception IllegalActionException Thrown if there is a problem obtaining the use-case
   *     identifier for an annotation attribute.
   */
  private List<OntologyAnnotationAttribute> _getAnnotationAttributes()
      throws IllegalActionException {
    List<OntologyAnnotationAttribute> result = new LinkedList<OntologyAnnotationAttribute>();
    if (_component instanceof NamedObj) {

      for (Object attribute : ((NamedObj) _component).attributeList()) {

        if (attribute instanceof OntologyAnnotationAttribute) {
          String ontologySolverName =
              ((OntologyAnnotationAttribute) attribute).getOntologySolverIdentifier();

          // Check to make sure the use case name of the
          // AnnotationAttribute matches the name of the ontology
          // solver.
          if (_solver.getName().equals(ontologySolverName)) {
            result.add((OntologyAnnotationAttribute) attribute);
          }
        }
      }
    }
    return result;
  }
 /**
  * Highlight all property-able objects with the specified colors for their property values.
  *
  * @exception IllegalActionException If getting the resolved concept fails.
  */
 public void highlightConcepts() throws IllegalActionException {
   // Get the PropertySolver.
   OntologySolver solver = (OntologySolver) getContainer();
   highlightConcepts(solver.getAllPropertyables());
 }