Package edu.mit.csail.sdg.alloy4graph

Examples of edu.mit.csail.sdg.alloy4graph.GraphNode


   public static JPanel produceGraph(AlloyInstance instance, VizState view, AlloyProjection proj) throws ErrorFatal {
      view = new VizState(view);
      if (proj == null) proj = new AlloyProjection();
      Graph graph = new Graph(view.getFontSize() / 12.0D);
      new StaticGraphMaker(graph, instance, view, proj);
      if (graph.nodes.size()==0) new GraphNode(graph, "", "Due to your theme settings, every atom is hidden.", "Please click Theme and adjust your settings.");
      return new GraphViewer(graph);
   }
View Full Code Here


   /** Return the node for a specific AlloyAtom (create it if it doesn't exist yet).
    * @return null if the atom is explicitly marked as "Don't Show".
    */
   private GraphNode createNode(final boolean hidePrivate, final boolean hideMeta, final AlloyAtom atom) {
      GraphNode node = atom2node.get(atom);
      if (node!=null) return node;
      if ( (hidePrivate && atom.getType().isPrivate)
            || (hideMeta    && atom.getType().isMeta)
            || !view.nodeVisible(atom, instance)) return null;
      // Make the node
      DotColor color = view.nodeColor(atom, instance);
      DotStyle style = view.nodeStyle(atom, instance);
      DotShape shape = view.shape(atom, instance);
      String label = atomname(atom, false);
      node = new GraphNode(graph, atom, label).set(shape).set(color.getColor(view.getNodePalette())).set(style);
      // Get the label based on the sets and relations
      String setsLabel="";
      boolean showLabelByDefault = view.showAsLabel.get(null);
      for (AlloySet set: instance.atom2sets(atom)) {
         String x = view.label.get(set); if (x.length()==0) continue;
View Full Code Here

            ||(hideMeta    && tuple.getStart().getType().isMeta)
            || !view.nodeVisible(tuple.getStart(), instance)) return false;
      if ((hidePrivate && tuple.getEnd().getType().isPrivate)
            ||(hideMeta    && tuple.getEnd().getType().isMeta)
            || !view.nodeVisible(tuple.getEnd(), instance)) return false;
      GraphNode start = createNode(hidePrivate, hideMeta, tuple.getStart());
      GraphNode end = createNode(hidePrivate, hideMeta, tuple.getEnd());
      if (start==null || end==null) return false;
      boolean layoutBack = view.layoutBack.resolve(rel);
      String label = view.label.get(rel);
      if (tuple.getArity() > 2) {
         StringBuilder moreLabel = new StringBuilder();
View Full Code Here

      //   and SET2's "show in relational attribute" is on,
      //   then the A node would have a line that says "F: B (SET1, SET2)->C, D->E"
      //
      Map<GraphNode,String> map = new LinkedHashMap<GraphNode,String>();
      for (AlloyTuple tuple: instance.relation2tuples(rel)) {
         GraphNode start=atom2node.get(tuple.getStart());
         if (start==null) continue; // null means the node won't be shown, so we can't show any attributes
         String attr="";
         List<AlloyAtom> atoms=tuple.getAtoms();
         for (int i=1; i<atoms.size(); i++) {
            if (i>1) attr+="->";
            attr+=atomname(atoms.get(i),true);
         }
         if (attr.length()==0) continue;
         String oldattr=map.get(start);
         if (oldattr!=null && oldattr.length()>0) attr=oldattr+", "+attr;
         if (attr.length()>0) map.put(start,attr);
      }
      for (Map.Entry<GraphNode,String> e: map.entrySet()) {
         GraphNode node = e.getKey();
         Set<String> list = attribs.get(node);
         if (list==null) attribs.put(node, list=new TreeSet<String>());
         String attr = e.getValue();
         if (view.label.get(rel).length()>0) attr = view.label.get(rel) + ": " + attr;
         list.add(attr);
View Full Code Here

TOP

Related Classes of edu.mit.csail.sdg.alloy4graph.GraphNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.