當前位置: 首頁>>代碼示例>>Java>>正文


Java GraphEdge類代碼示例

本文整理匯總了Java中edu.mit.csail.sdg.alloy4graph.GraphEdge的典型用法代碼示例。如果您正苦於以下問題:Java GraphEdge類的具體用法?Java GraphEdge怎麽用?Java GraphEdge使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


GraphEdge類屬於edu.mit.csail.sdg.alloy4graph包,在下文中一共展示了GraphEdge類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createEdge

import edu.mit.csail.sdg.alloy4graph.GraphEdge; //導入依賴的package包/類
/**
 * Create an edge for a given tuple from a relation (if neither start nor
 * end node is explicitly invisible)
 */
private boolean createEdge(final boolean hidePrivate, final boolean hideMeta, AlloyRelation rel, AlloyTuple tuple,
		boolean bidirectional, Color magicColor) {
	// This edge represents a given tuple from a given relation.
	//
	// If the tuple's arity==2, then the label is simply the label of the
	// relation.
	//
	// If the tuple's arity>2, then we append the node labels for all the
	// intermediate nodes.
	// eg. Say a given tuple is (A,B,C,D) from the relation R.
	// An edge will be drawn from A to D, with the label "R [B, C]"
	if ((hidePrivate && tuple.getStart().getType().isPrivate) || (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();
		List<AlloyAtom> atoms = tuple.getAtoms();
		for (int i = 1; i < atoms.size() - 1; i++) {
			if (i > 1)
				moreLabel.append(", ");
			moreLabel.append(atomname(atoms.get(i), false));
		}
		if (label.length() == 0) { /* label=moreLabel.toString(); */ } else {
			label = label + (" [" + moreLabel + "]");
		}
	}
	DotDirection dir = bidirectional ? DotDirection.BOTH : (layoutBack ? DotDirection.BACK : DotDirection.FORWARD);
	DotStyle style = view.edgeStyle.resolve(rel);
	DotColor color = view.edgeColor.resolve(rel);
	int weight = view.weight.get(rel);
	GraphEdge e = new GraphEdge((layoutBack ? end : start), (layoutBack ? start : end), tuple, label, rel);
	if (color == DotColor.MAGIC && magicColor != null)
		e.set(magicColor);
	else
		e.set(color.getColor(view.getEdgePalette()));
	e.set(style);
	e.set(dir != DotDirection.FORWARD, dir != DotDirection.BACK);
	e.set(weight < 1 ? 1 : (weight > 100 ? 10000 : 100 * weight));
	edges.put(e, tuple);
	return true;
}
 
開發者ID:AlloyTools,項目名稱:org.alloytools.alloy,代碼行數:55,代碼來源:StaticGraphMaker.java

示例2: createEdge

import edu.mit.csail.sdg.alloy4graph.GraphEdge; //導入依賴的package包/類
/** Create an edge for a given tuple from a relation (if neither start nor end node is explicitly invisible) */
private boolean createEdge(final boolean hidePrivate, final boolean hideMeta, AlloyRelation rel, AlloyTuple tuple, boolean bidirectional, Color magicColor) {
   // This edge represents a given tuple from a given relation.
   //
   // If the tuple's arity==2, then the label is simply the label of the relation.
   //
   // If the tuple's arity>2, then we append the node labels for all the intermediate nodes.
   // eg. Say a given tuple is (A,B,C,D) from the relation R.
   // An edge will be drawn from A to D, with the label "R [B, C]"
   if ((hidePrivate && tuple.getStart().getType().isPrivate)
         ||(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();
      List<AlloyAtom> atoms=tuple.getAtoms();
      for (int i=1; i<atoms.size()-1; i++) {
         if (i>1) moreLabel.append(", ");
         moreLabel.append(atomname(atoms.get(i),false));
      }
      if (label.length()==0) { /* label=moreLabel.toString(); */ }
      else { label=label+(" ["+moreLabel+"]"); }
   }
   DotDirection dir = bidirectional ? DotDirection.BOTH : (layoutBack ? DotDirection.BACK : DotDirection.FORWARD);
   DotStyle style = view.edgeStyle.resolve(rel);
   DotColor color = view.edgeColor.resolve(rel);
   int weight = view.weight.get(rel);
   GraphEdge e = new GraphEdge((layoutBack ? end : start), (layoutBack ? start : end), tuple, label, rel);
   if (color == DotColor.MAGIC && magicColor != null) e.set(magicColor); else e.set(color.getColor(view.getEdgePalette()));
   e.set(style);
   e.set(dir!=DotDirection.FORWARD, dir!=DotDirection.BACK);
   e.set(weight<1 ? 1 : (weight>100 ? 10000 : 100*weight));
   edges.put(e, tuple);
   return true;
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:43,代碼來源:StaticGraphMaker.java

示例3: createEdge

import edu.mit.csail.sdg.alloy4graph.GraphEdge; //導入依賴的package包/類
/**
 * Create an edge for a given tuple from a relation (if neither start nor end node is explicitly
 * invisible)
 */
private boolean createEdge(Relation rel, Tuple tuple, Color magicColor) {
  // This edge represents a given tuple from a given relation.
  //
  // If the tuple's arity==2, then the label is simply the label of the relation.
  //
  // If the tuple's arity>2, then we append the node labels for all the intermediate nodes.
  // eg. Say a given tuple is (A,B,C,D) from the relation R.
  // An edge will be drawn from A to D, with the label "R [B, C]"

  if (/*
       * (hidePrivate && tuple.getStart().getType().isPrivate) || (hideMeta &&
       * tuple.getStart().getType().isMeta) ||
       */!view.nodeVisible(tuple.getAtom(0)))
    return false;
  if (/*
       * (hidePrivate && tuple.getEnd().getType().isPrivate) || (hideMeta &&
       * tuple.getEnd().getType().isMeta) ||
       */!view.nodeVisible(tuple.getAtom(tuple.getAtomCount() - 1)))
    return false;
  GraphNode start = createNode(tuple.getAtom(0));
  GraphNode end = createNode(tuple.getAtom(tuple.getAtomCount() - 1));
  if (start == null || end == null)
    return false;
  boolean layoutBack = view.layoutBack.resolve(rel);
  String label = rel.getName();
  if (tuple.getArity() > 2) {
    StringBuilder moreLabel = new StringBuilder();
    List<Atom> atoms = tuple.getAtoms();
    for (int i = 1; i < atoms.size() - 1; i++) {
      if (i > 1)
        moreLabel.append(", ");
      moreLabel.append(atomname(atoms.get(i)));
    }
    if (label.length() == 0) {
      label = moreLabel.toString();
    } else {
      label = label + (" [" + moreLabel + "]");
    }
  }
  DotDirection dir = /* bidirectional ? DotDirection.BOTH : */(layoutBack ? DotDirection.BACK
      : DotDirection.FORWARD);
  DotStyle style = view.edgeStyle.resolve(rel);
  DotColor color = view.edgeColor.resolve(rel);
  int weight = view.weight.get(rel);
  GraphEdge e = new GraphEdge((start), (end), tuple, label, rel);

  e.set(magicColor);
  e.set(style);
  e.set(dir != DotDirection.FORWARD, dir != DotDirection.BACK);
  e.set(weight < 1 ? 1 : (weight > 100 ? 10000 : 100 * weight));
  edges.put(e, tuple);

  return true;
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:59,代碼來源:GraphMaker.java

示例4: createEdge

import edu.mit.csail.sdg.alloy4graph.GraphEdge; //導入依賴的package包/類
/** Create an edge for a given tuple from a relation (if neither start nor end node is explicitly invisible) */
private boolean createEdge(final boolean hidePrivate, final boolean hideMeta, AlloyRelation rel, AlloyTuple tuple, boolean bidirectional, Color magicColor) {
   // This edge represents a given tuple from a given relation.
   //
   // If the tuple's arity==2, then the label is simply the label of the relation.
   //
   // If the tuple's arity>2, then we append the node labels for all the intermediate nodes.
   // eg. Say a given tuple is (A,B,C,D) from the relation R.
   // An edge will be drawn from A to D, with the label "R [B, C]"
   if ((hidePrivate && tuple.getStart().getType().isPrivate)
         ||(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();
      List<AlloyAtom> atoms=tuple.getAtoms();
      for (int i=1; i<atoms.size()-1; i++) {
         if (i>1) moreLabel.append(", ");
         moreLabel.append(atomname(atoms.get(i),false));
      }
      if (label.length()==0) { /* label=moreLabel.toString(); */ }
      else { label=label+(" ["+moreLabel+"]"); }
   }
   DotDirection dir = bidirectional ? DotDirection.BOTH : (layoutBack ? DotDirection.BACK : DotDirection.FORWARD);
   DotStyle style = view.edgeStyle.resolve(rel);
   if (tuple.isDashed) {
     style = DotStyle.DASHED;
   }
   DotColor color = view.edgeColor.resolve(rel);
   int weight = view.weight.get(rel);
   GraphEdge e = new GraphEdge((layoutBack ? end : start), (layoutBack ? start : end), tuple, label, rel);
   if (color == DotColor.MAGIC && magicColor != null) e.set(magicColor); else e.set(color.getColor(view.getEdgePalette()));
   e.set(style);
   e.set(dir!=DotDirection.FORWARD, dir!=DotDirection.BACK);
   e.set(weight<1 ? 1 : (weight>100 ? 10000 : 100*weight));
   edges.put(e, tuple);
   return true;
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:46,代碼來源:StaticGraphMaker.java


注:本文中的edu.mit.csail.sdg.alloy4graph.GraphEdge類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。