Esempio n. 1
0
  public void vizExportHeader() {
    {
      VizInfo self = this;

      self.vizExportDotHeader();
    }
  }
Esempio n. 2
0
  public void vizExportConcept(LogicObject concept, Module module) {
    {
      VizInfo self = this;

      self.vizExportConceptToDot(concept, module);
    }
  }
Esempio n. 3
0
  public void vizExportTrailer() {
    {
      VizInfo self = this;

      self.vizExportDotTrailer();
    }
  }
Esempio n. 4
0
  public void vizExportModule(Module module) {
    {
      VizInfo self = this;

      Logic.plLog(
          OntosaurusUtil.KWD_MEDIUM,
          Cons.cons(
              StringWrapper.wrapString("powerloom-viz: exporting module: "),
              Cons.cons(module, Stella.NIL)));
      {
        Object old$Module$000 = Stella.$MODULE$.get();
        Object old$Context$000 = Stella.$CONTEXT$.get();

        try {
          Native.setSpecial(Stella.$MODULE$, module);
          Native.setSpecial(Stella.$CONTEXT$, ((Module) (Stella.$MODULE$.get())));
          self.vizExportConcepts(module);

        } finally {
          Stella.$CONTEXT$.set(old$Context$000);
          Stella.$MODULE$.set(old$Module$000);
        }
      }
    }
  }
Esempio n. 5
0
  public void vizExportConceptToDot(LogicObject concept, Module module) {
    {
      VizInfo self = this;

      self.vizConceptToDotNode(concept, module);
      self.vizConceptLinksToDotEdges(concept, module);
    }
  }
Esempio n. 6
0
  public boolean vizAllowedObjectP(Stella_Object renamed_Object) {
    {
      VizInfo self = this;

      return (((self.allowedObjects == null)
          ? (!self.vizExcludedModuleP(renamed_Object.homeModule()))
          : self.allowedObjects.memberP(renamed_Object)));
    }
  }
Esempio n. 7
0
  public void vizAllowObject(Stella_Object renamed_Object) {
    {
      VizInfo self = this;

      {
        HashSet allowedobjects = self.allowedObjects;

        if (allowedobjects == null) {
          allowedobjects = HashSet.newHashSet();
          self.allowedObjects = allowedobjects;
        }
        allowedobjects.insert(renamed_Object);
      }
    }
  }
Esempio n. 8
0
  public void vizConceptToDotNode(LogicObject concept, Module module) {
    {
      VizInfo self = this;

      {
        OutputStream stream = self.stream;
        String conceptname = OntosaurusUtil.vizDotObjectName(concept);
        String conceptcolor = self.nodeColor;
        String concepturl = self.vizGenerateOntosaurusHandle(concept);

        if (self.showAttributesP || self.showRulesP) {
          stream.nativeStream.print(
              "  \""
                  + conceptname
                  + "\" [shape=record, style=filled, fillcolor="
                  + conceptcolor
                  + ", URL=\"");
          stream.nativeStream.print(concepturl);
          stream.nativeStream.print("\", label=\"{" + conceptname + "|");
          if (self.showAttributesP) {
            self.vizAddConceptAttributesToDotNode(concept, module);
          }
          if (self.showRulesP) {
            if (self.showAttributesP) {
              stream.nativeStream.print("|");
            }
            self.vizAddConceptRulesToDotNode(concept, module);
          }
          stream.nativeStream.println("}\"]");
        } else {
          stream.nativeStream.print(
              "  \""
                  + conceptname
                  + "\" [shape=box, style=filled, fillcolor="
                  + conceptcolor
                  + ", URL=\""
                  + concepturl
                  + "\"]");
        }
      }
    }
  }
Esempio n. 9
0
  public void vizAddConceptAttributesToDotNode(LogicObject concept, Module module) {
    {
      VizInfo self = this;

      {
        OutputStream stream = self.stream;
        LogicObject range = null;

        {
          Object old$Module$000 = Stella.$MODULE$.get();
          Object old$Context$000 = Stella.$CONTEXT$.get();

          try {
            Native.setSpecial(Stella.$MODULE$, module);
            Native.setSpecial(Stella.$CONTEXT$, ((Module) (Stella.$MODULE$.get())));
            {
              LogicObject relation = null;
              Cons iter000 = self.vizGetBinaryRelationsOf(concept);

              for (; !(iter000 == Stella.NIL); iter000 = iter000.rest) {
                relation = ((LogicObject) (iter000.value));
                range = edu.isi.powerloom.PLI.getRange(relation);
                stream.nativeStream.print(
                    OntosaurusUtil.vizDotObjectName(relation)
                        + ": "
                        + OntosaurusUtil.vizDotObjectName(range)
                        + "\\l");
              }
            }

          } finally {
            Stella.$CONTEXT$.set(old$Context$000);
            Stella.$MODULE$.set(old$Module$000);
          }
        }
      }
    }
  }
Esempio n. 10
0
  public void vizExportConcepts(Module module) {
    {
      VizInfo self = this;

      {
        Stella_Object concept = null;
        edu.isi.powerloom.PlIterator iter000 =
            edu.isi.powerloom.PLI.getConceptInstances(
                ((LogicObject) (Logic.getInstance(OntosaurusUtil.SGT_PL_KERNEL_KB_CONCEPT))),
                module,
                null);

        while (iter000.nextP()) {
          concept = iter000.value;
          if (Surrogate.subtypeOfP(
              Stella_Object.safePrimaryType(concept), OntosaurusUtil.SGT_LOGIC_LOGIC_OBJECT)) {
            {
              LogicObject concept000 = ((LogicObject) (concept));

              if ((concept000.homeModule() == module) && self.vizAllowedObjectP(concept000)) {
                self.vizExportConcept(concept000, module);
              }
            }
          } else {
            {
              OutputStringStream stream000 = OutputStringStream.newOutputStringStream();

              stream000.nativeStream.print(
                  "viz-export-concepts: concept not handled: `" + concept + "'");
              throw ((StellaException)
                  (StellaException.newStellaException(stream000.theStringReader())
                      .fillInStackTrace()));
            }
          }
        }
      }
    }
  }
Esempio n. 11
0
  public static Stella_Object accessVizInfoSlotValue(
      VizInfo self, Symbol slotname, Stella_Object value, boolean setvalueP) {
    if (slotname == OntosaurusUtil.SYM_STELLA_STREAM) {
      if (setvalueP) {
        self.stream = ((OutputStream) (value));
      } else {
        value = self.stream;
      }
    } else if (slotname == OntosaurusUtil.SYM_ONTOSAURUS_ALLOWED_OBJECTS) {
      if (setvalueP) {
        self.allowedObjects = ((HashSet) (value));
      } else {
        value = self.allowedObjects;
      }
    } else if (slotname == OntosaurusUtil.SYM_ONTOSAURUS_SHOW_RELATIONSp) {
      if (setvalueP) {
        self.showRelationsP =
            BooleanWrapper.coerceWrappedBooleanToBoolean(((BooleanWrapper) (value)));
      } else {
        value = (self.showRelationsP ? Stella.TRUE_WRAPPER : Stella.FALSE_WRAPPER);
      }
    } else if (slotname == OntosaurusUtil.SYM_ONTOSAURUS_SHOW_ATTRIBUTESp) {
      if (setvalueP) {
        self.showAttributesP =
            BooleanWrapper.coerceWrappedBooleanToBoolean(((BooleanWrapper) (value)));
      } else {
        value = (self.showAttributesP ? Stella.TRUE_WRAPPER : Stella.FALSE_WRAPPER);
      }
    } else if (slotname == OntosaurusUtil.SYM_ONTOSAURUS_SHOW_RULESp) {
      if (setvalueP) {
        self.showRulesP = BooleanWrapper.coerceWrappedBooleanToBoolean(((BooleanWrapper) (value)));
      } else {
        value = (self.showRulesP ? Stella.TRUE_WRAPPER : Stella.FALSE_WRAPPER);
      }
    } else if (slotname == OntosaurusUtil.SYM_ONTOSAURUS_ADD_TOPp) {
      if (setvalueP) {
        self.addTopP = BooleanWrapper.coerceWrappedBooleanToBoolean(((BooleanWrapper) (value)));
      } else {
        value = (self.addTopP ? Stella.TRUE_WRAPPER : Stella.FALSE_WRAPPER);
      }
    } else if (slotname == OntosaurusUtil.SYM_ONTOSAURUS_NODE_COLOR) {
      if (setvalueP) {
        self.nodeColor = ((StringWrapper) (value)).wrapperValue;
      } else {
        value = StringWrapper.wrapString(self.nodeColor);
      }
    } else if (slotname == OntosaurusUtil.SYM_ONTOSAURUS_RELATION_COLOR) {
      if (setvalueP) {
        self.relationColor = ((StringWrapper) (value)).wrapperValue;
      } else {
        value = StringWrapper.wrapString(self.relationColor);
      }
    } else if (slotname == OntosaurusUtil.SYM_ONTOSAURUS_RELATION_STYLE) {
      if (setvalueP) {
        self.relationStyle = ((StringWrapper) (value)).wrapperValue;
      } else {
        value = StringWrapper.wrapString(self.relationStyle);
      }
    } else if (slotname == OntosaurusUtil.SYM_ONTOSAURUS_FONT_SIZE) {
      if (setvalueP) {
        self.fontSize = ((IntegerWrapper) (value)).wrapperValue;
      } else {
        value = IntegerWrapper.wrapInteger(self.fontSize);
      }
    } else {
      {
        OutputStringStream stream000 = OutputStringStream.newOutputStringStream();

        stream000.nativeStream.print("`" + slotname + "' is not a valid case option");
        throw ((StellaException)
            (StellaException.newStellaException(stream000.theStringReader()).fillInStackTrace()));
      }
    }
    return (value);
  }
Esempio n. 12
0
  public static VizInfo newVizInfo() {
    {
      VizInfo self = null;

      self = new VizInfo();
      self.fontSize = OntosaurusUtil.$VIZ_FONT_SIZE$;
      self.relationStyle = OntosaurusUtil.$VIZ_RELATION_STYLE$;
      self.relationColor = OntosaurusUtil.$VIZ_RELATION_COLOR$;
      self.nodeColor = OntosaurusUtil.$VIZ_NODE_COLOR$;
      self.addTopP = OntosaurusUtil.$VIZ_ADD_TOPp$;
      self.showRulesP = OntosaurusUtil.$VIZ_SHOW_RULESp$;
      self.showAttributesP = OntosaurusUtil.$VIZ_SHOW_ATTRIBUTESp$;
      self.showRelationsP = OntosaurusUtil.$VIZ_SHOW_RELATIONSp$;
      self.allowedObjects = null;
      self.stream = null;
      return (self);
    }
  }
Esempio n. 13
0
  public void vizConceptLinksToDotEdges(LogicObject concept, Module module) {
    {
      VizInfo self = this;

      {
        OutputStream stream = self.stream;
        int count = 0;

        {
          LogicObject renamed_Super = null;
          edu.isi.powerloom.PlIterator iter000 =
              edu.isi.powerloom.PLI.getDirectSuperrelations(concept, module, null);

          while (iter000.nextP()) {
            renamed_Super = ((LogicObject) (iter000.value));
            if (Surrogate.subtypeOfP(
                Stella_Object.safePrimaryType(renamed_Super),
                OntosaurusUtil.SGT_LOGIC_NAMED_DESCRIPTION)) {
              {
                NamedDescription super000 = ((NamedDescription) (renamed_Super));

                if (self.vizAllowedObjectP(super000)) {
                  stream.nativeStream.println(
                      "  \""
                          + OntosaurusUtil.vizDotObjectName(super000)
                          + "\" -> \""
                          + OntosaurusUtil.vizDotObjectName(concept)
                          + "\" [dir=back]");
                  count = count + 1;
                } else {
                  stream.nativeStream.print(
                      "  \""
                          + OntosaurusUtil.vizDotObjectName(super000)
                          + "\" [shape=box, style=filled, fillcolor=grey,URL=\""
                          + self.vizGenerateOntosaurusHandle(super000)
                          + "\"]");
                  stream.nativeStream.println(
                      "  \""
                          + OntosaurusUtil.vizDotObjectName(super000)
                          + "\" -> \""
                          + OntosaurusUtil.vizDotObjectName(concept)
                          + "\" [dir=back]");
                  count = count + 1;
                }
              }
            } else {
              {
                OutputStringStream stream000 = OutputStringStream.newOutputStringStream();

                stream000.nativeStream.print(
                    "viz-concept-links-to-dot-edges: unhandled super concept: `"
                        + renamed_Super
                        + "'");
                throw ((StellaException)
                    (StellaException.newStellaException(stream000.theStringReader())
                        .fillInStackTrace()));
              }
            }
          }
        }
        if ((count == 0) && self.addTopP) {
          stream.nativeStream.println(
              "  \""
                  + OntosaurusUtil.VIZ_TOP
                  + "\" -> \""
                  + OntosaurusUtil.vizDotObjectName(concept)
                  + "\" [dir=back]");
        }
        if (self.showRelationsP) {
          {
            LogicObject range = null;
            String relcolor = self.relationColor;
            String relstyle = self.relationStyle;

            {
              Object old$Module$000 = Stella.$MODULE$.get();
              Object old$Context$000 = Stella.$CONTEXT$.get();

              try {
                Native.setSpecial(Stella.$MODULE$, module);
                Native.setSpecial(Stella.$CONTEXT$, ((Module) (Stella.$MODULE$.get())));
                {
                  LogicObject relation = null;
                  Cons iter001 = self.vizGetBinaryRelationsOf(concept);

                  for (; !(iter001 == Stella.NIL); iter001 = iter001.rest) {
                    relation = ((LogicObject) (iter001.value));
                    range = edu.isi.powerloom.PLI.getRange(relation);
                    if (self.vizAllowedObjectP(relation)) {
                      stream.nativeStream.println(
                          "  \""
                              + OntosaurusUtil.vizDotObjectName(concept)
                              + "\" -> \""
                              + OntosaurusUtil.vizDotObjectName(range)
                              + "\" [label=\""
                              + OntosaurusUtil.vizDotObjectName(relation)
                              + "\", color="
                              + relcolor
                              + ", style="
                              + relstyle
                              + "]");
                    }
                  }
                }

              } finally {
                Stella.$CONTEXT$.set(old$Context$000);
                Stella.$MODULE$.set(old$Module$000);
              }
            }
          }
        }
      }
    }
  }
Esempio n. 14
0
  public void vizExportConceptTree(LogicObject concept, Module module) {
    {
      VizInfo self = this;

      self.nodeColor = "palegreen";
      self.vizExportConcept(concept, module);
      self.nodeColor = "yellow";
      self.vizAllowObject(concept);
      {
        LogicObject renamed_Super = null;
        edu.isi.powerloom.PlIterator iter000 =
            edu.isi.powerloom.PLI.getProperSuperrelations(concept, module, null);

        while (iter000.nextP()) {
          renamed_Super = ((LogicObject) (iter000.value));
          self.vizAllowObject(renamed_Super);
        }
      }
      {
        LogicObject sub = null;
        edu.isi.powerloom.PlIterator iter001 =
            edu.isi.powerloom.PLI.getProperSubrelations(concept, module, null);

        while (iter001.nextP()) {
          sub = ((LogicObject) (iter001.value));
          self.vizAllowObject(sub);
        }
      }
      {
        LogicObject renamed_Super = null;
        edu.isi.powerloom.PlIterator iter002 =
            edu.isi.powerloom.PLI.getProperSuperrelations(concept, module, null);

        while (iter002.nextP()) {
          renamed_Super = ((LogicObject) (iter002.value));
          if (Surrogate.subtypeOfP(
              Stella_Object.safePrimaryType(renamed_Super),
              OntosaurusUtil.SGT_LOGIC_LOGIC_OBJECT)) {
            {
              LogicObject super000 = ((LogicObject) (renamed_Super));

              self.vizExportConcept(super000, module);
            }
          } else {
            {
              OutputStringStream stream000 = OutputStringStream.newOutputStringStream();

              stream000.nativeStream.print(
                  "viz-export-concept-tree: concept not handled: `" + renamed_Super + "'");
              throw ((StellaException)
                  (StellaException.newStellaException(stream000.theStringReader())
                      .fillInStackTrace()));
            }
          }
        }
      }
      {
        LogicObject sub = null;
        edu.isi.powerloom.PlIterator iter003 =
            edu.isi.powerloom.PLI.getProperSubrelations(concept, module, null);

        while (iter003.nextP()) {
          sub = ((LogicObject) (iter003.value));
          if (Surrogate.subtypeOfP(
              Stella_Object.safePrimaryType(sub), OntosaurusUtil.SGT_LOGIC_LOGIC_OBJECT)) {
            {
              LogicObject sub000 = ((LogicObject) (sub));

              self.vizExportConcept(sub000, module);
            }
          } else {
            {
              OutputStringStream stream001 = OutputStringStream.newOutputStringStream();

              stream001.nativeStream.print(
                  "viz-export-concept-tree: concept not handled: `" + sub + "'");
              throw ((StellaException)
                  (StellaException.newStellaException(stream001.theStringReader())
                      .fillInStackTrace()));
            }
          }
        }
      }
    }
  }