Пример #1
0
 /**
  * Return the one true type condition out of a conjunction of multiple conditions that constrain
  * by type in one way or another. The method returns null if no type is actually specified already
  * (this means all type conditions in the passed in set are using variables). If there is an
  * inconsistency b/w two type conditions so that the result set should be really empty, the method
  * returns and AtomTypeCondition with a null reference (i.e. "no type possible").
  *
  * @param graph
  * @param bytype
  * @return
  */
 public static Pair<AtomTypeCondition, TypeConditionAggregate> reduce(
     HyperGraph graph, Set<TypeCondition> bytype) {
   HGHandle typeHandle = null;
   TypeConditionAggregate taggr = new TypeConditionAggregate();
   for (TypeCondition c : bytype) {
     if (hg.isVar(c.getTypeReference())) {
       taggr.watchTypeReference(c); // ((Var<?>)c.getTypeReference());
       continue;
     }
     HGHandle th = null;
     if (c.getTypeReference().get() instanceof Class<?>) {
       th = graph.getTypeSystem().getTypeHandleIfDefined(c.getTypeReference().getClass());
       if (th == null) {
         taggr.watchTypeReference(c);
         continue;
       }
     } else th = (HGHandle) c.getTypeReference().get();
     if (typeHandle != null) {
       typeHandle = findMostSpecific(graph, typeHandle, th);
       if (typeHandle == null) // are they incompatible?
       return new Pair<AtomTypeCondition, TypeConditionAggregate>(
             new AtomTypeCondition((Ref<?>) null), taggr);
     } else typeHandle = th;
   }
   // At this point we have possibly found one most specific type handle
   // specified as part of the
   // conjunction and possibly several conditions with variable type or
   // unresolved Java class (which
   // for all intents and purposes are like variables right now.
   if (typeHandle != null)
     return new Pair<AtomTypeCondition, TypeConditionAggregate>(
         new AtomTypeCondition(hg.constant(typeHandle)), taggr);
   else return null;
 }
 /**
  * Adds the type to the type system for a graph.
  *
  * @param graph The graph to which to add the type system.
  */
 public static void initType(HyperGraph graph) {
   ValueWithUncertaintyElemFactoryType<?, ?> type = new ValueWithUncertaintyElemFactoryType();
   HGPersistentHandle typeHandle = graph.getHandleFactory().makeHandle();
   graph
       .getTypeSystem()
       .addPredefinedType(typeHandle, type, ValueWithUncertaintyElemFactory.class);
 }
Пример #3
0
 /**
  * Recalculates and reapplies all of the edge appearances. The visual attributes are calculated by
  * delegating to the EdgePainter member of the current visual style.
  */
 public void applyEdgeAppearances() {
   for (PEdgeView edgeView : edgeViewMap.values()) {
     FNode node = edgeView.getEdge().getSource();
     HGHandle h = graph.getTypeSystem().getTypeHandle(node.getHandle());
     EdgePainter p = getVisualStyle(true).getEdgePainter(h);
     if (p == null) p = def_edge_painter;
     p.paintEdge(edgeView);
   }
 }
Пример #4
0
 private NodePainter getPainter(HGHandle h, boolean return_default) {
   NodePainter p = getVisualStyle(true).getNodePainter(h);
   if (p == null && return_default) p = def_node_painter;
   if (p != null) return p;
   try {
     HGHandle typeH = graph.getTypeSystem().getTypeHandle(h);
     return getPainter(typeH, true);
   } catch (HGException ex) {
     // do nothing
     // the node handle pointed to some statically
     // defined HGHandleFactory.makeHandle()
     // with no value
     return def_node_painter;
   }
 }
 /**
  * Adds the type to the type system for a graph.
  *
  * @param graph The graph to which to add the type system.
  */
 public static void initType(HyperGraph graph) {
   EinsteinTensorElemType<?, ?, ?> type = new EinsteinTensorElemType();
   HGPersistentHandle typeHandle = graph.getHandleFactory().makeHandle();
   graph.getTypeSystem().addPredefinedType(typeHandle, type, EinsteinTensorElem.class);
 }
 /**
  * Adds the type to the type system for a graph.
  *
  * @param graph The graph to which to add the type system.
  */
 public static void initType(HyperGraph graph) {
   ComplexElemFactoryType<?, ?> type = new ComplexElemFactoryType();
   HGPersistentHandle typeHandle = graph.getHandleFactory().makeHandle();
   graph.getTypeSystem().addPredefinedType(typeHandle, type, ComplexElemFactory.class);
 }