本文整理汇总了Java中edu.mit.csail.sdg.alloy4graph.GraphNode类的典型用法代码示例。如果您正苦于以下问题:Java GraphNode类的具体用法?Java GraphNode怎么用?Java GraphNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GraphNode类属于edu.mit.csail.sdg.alloy4graph包,在下文中一共展示了GraphNode类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: produceGraph
import edu.mit.csail.sdg.alloy4graph.GraphNode; //导入依赖的package包/类
/**
* Produces a single Graph from the given Instance and View and choice of
* Projection
*/
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);
}
示例2: produceGraph
import edu.mit.csail.sdg.alloy4graph.GraphNode; //导入依赖的package包/类
/** Produces a single Graph from the given Instance and View and choice of Projection */
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);
}
示例3: produceGraph
import edu.mit.csail.sdg.alloy4graph.GraphNode; //导入依赖的package包/类
public static JPanel produceGraph(Universe universe) throws ErrorFatal {
view = new State(universe);
// if (proj == null) proj = new AlloyProjection();
Graph graph = new Graph(view.getFontSize() / 12.0D);
new GraphMaker(graph, universe);
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);
}
示例4: createNode
import edu.mit.csail.sdg.alloy4graph.GraphNode; //导入依赖的package包/类
private GraphNode createNode(Atom atom) {
GraphNode node = atom2node.get(atom);
if (node != null)
return node;
if (/*
* (hidePrivate && atom.getType().isPrivate) || (hideMeta && atom.getType().isMeta) ||
*/!view.nodeVisible(atom))
return null;
DotColor color = view.nodeColor(atom);
DotStyle style = view.nodeStyle(atom);
DotShape shape = view.shape(atom);
String label = atomname(atom);
node = new GraphNode(graph, atom, label).set(shape).set(color.getColor(view.getNodePalette()))
.set(style);
// String setsLabel = "";
// boolean showLabelByDefault = view.showAsLabel.get(null);
// String x = view.label.get(atom.getLocatedIn());
// Boolean showLabel = view.showAsLabel.get(atom.getLocatedIn());
// if ((showLabel == null && showLabelByDefault)
// || (showLabel != null && showLabel.booleanValue()))
// setsLabel += ((setsLabel.length() > 0 ? ", " : "") + x);
// if (setsLabel.length() > 0) {
// Set<String> list = attribs.get(node);
// if (list == null)
// attribs.put(node, list = new TreeSet<String>());
// list.add("(" + setsLabel + ")");
// }
nodes.put(node, atom);
atom2node.put(atom, node);
return node;
}
示例5: createEdge
import edu.mit.csail.sdg.alloy4graph.GraphNode; //导入依赖的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;
}
示例6: createEdge
import edu.mit.csail.sdg.alloy4graph.GraphNode; //导入依赖的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;
}
示例7: createEdge
import edu.mit.csail.sdg.alloy4graph.GraphNode; //导入依赖的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;
}
示例8: createEdge
import edu.mit.csail.sdg.alloy4graph.GraphNode; //导入依赖的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;
}