use of edu.mit.csail.sdg.alloy4graph.DotColor in project org.alloytools.alloy by AlloyTools.
the class VizCustomizationPanel method createDefaultEdgeWidget.
// =============================================================================================================//
/**
* Generates the "default relation settings" widgets, and add them to "parent".
*/
private void createDefaultEdgeWidget(JPanel parent) {
JComboBox colorComboE = new OurCombobox(false, DotColor.valuesWithout(DotColor.WHITE), 110, 35, vizState.edgeColor.get(null)) {
private static final long serialVersionUID = 0;
@Override
public String do_getText(Object value) {
return ((DotColor) value).getDisplayedText();
}
@Override
public Icon do_getIcon(Object value) {
return ((DotColor) value).getIcon(vizState.getEdgePalette());
}
@Override
public void do_changed(Object value) {
vizState.edgeColor.put(null, (DotColor) value);
}
};
JComboBox outlineComboE = new OurCombobox(false, DotStyle.values(), 110, 35, vizState.edgeStyle.get(null)) {
private static final long serialVersionUID = 0;
@Override
public String do_getText(Object value) {
return ((DotStyle) value).getDisplayedText();
}
@Override
public Icon do_getIcon(Object value) {
return ((DotStyle) value).getIcon();
}
@Override
public void do_changed(Object value) {
vizState.edgeStyle.put(null, (DotStyle) value);
}
};
JPanel dispCBE = vizState.edgeVisible.pick("Show as arcs", "Show relations as arcs");
JPanel mergeCBE = vizState.mergeArrows.pick("Merge arrows", "Merge opposing arrows of the same relation");
JPanel constraintCBE = vizState.constraint.pick("Influence layout", "Whether this edge influences the graph layout");
JPanel attrCBE = vizState.attribute.pick("Show as attributes", "Show relations as attributes on nodes");
JPanel laybackCBE = vizState.layoutBack.pick("Layout backwards", "Layout graph as if arcs were reversed");
parent.add(makelabel(" Default Relation Settings:"));
parent.add(OurUtil.makeH(wcolor, 10, colorComboE, 8, outlineComboE, 2, null));
JPanel a = OurUtil.makeVL(wcolor, dispCBE, attrCBE, constraintCBE, 10), b = OurUtil.makeVL(wcolor, laybackCBE, mergeCBE);
parent.add(OurUtil.makeHT(wcolor, 10, a, 10, b, 2, null));
}
use of edu.mit.csail.sdg.alloy4graph.DotColor in project org.alloytools.alloy by AlloyTools.
the class StaticGraphMaker method createEdge.
/**
* 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) {
// 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;
}
use of edu.mit.csail.sdg.alloy4graph.DotColor in project org.alloytools.alloy by AlloyTools.
the class StaticGraphMaker method createNode.
/**
* 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;
Boolean showLabel = view.showAsLabel.get(set);
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;
}
use of edu.mit.csail.sdg.alloy4graph.DotColor in project org.alloytools.alloy by AlloyTools.
the class VizCustomizationPanel method createDefaultNodeWidget.
// =============================================================================================================//
/**
* Generates the "default type and set settings" widgets, and add them to
* "parent".
*/
private void createDefaultNodeWidget(JPanel parent) {
JComboBox color = new OurCombobox(false, DotColor.valuesWithout(DotColor.MAGIC), 110, 35, vizState.nodeColor.get(null)) {
private static final long serialVersionUID = 0;
@Override
public String do_getText(Object value) {
return ((DotColor) value).getDisplayedText();
}
@Override
public Icon do_getIcon(Object value) {
return ((DotColor) value).getIcon(vizState.getNodePalette());
}
@Override
public void do_changed(Object value) {
vizState.nodeColor.put(null, (DotColor) value);
}
};
JComboBox shape = new OurCombobox(false, DotShape.values(), 135, 35, vizState.shape.get(null)) {
private static final long serialVersionUID = 0;
@Override
public String do_getText(Object value) {
return ((DotShape) value).getDisplayedText();
}
@Override
public Icon do_getIcon(Object value) {
return ((DotShape) value).getIcon();
}
@Override
public void do_changed(Object value) {
vizState.shape.put(null, (DotShape) value);
}
};
JComboBox style = new OurCombobox(false, DotStyle.values(), 110, 35, vizState.nodeStyle.get(null)) {
private static final long serialVersionUID = 0;
@Override
public String do_getText(Object value) {
return ((DotStyle) value).getDisplayedText();
}
@Override
public Icon do_getIcon(Object value) {
return ((DotStyle) value).getIcon();
}
@Override
public void do_changed(Object value) {
vizState.nodeStyle.put(null, (DotStyle) value);
}
};
JPanel vis = vizState.nodeVisible.pick("Show", "Show members of type as nodes");
JPanel hide = vizState.hideUnconnected.pick("Hide unconnected nodes", "Hide nodes without arcs");
JPanel num = vizState.number.pick("Number nodes", "Attach atom number to node label as suffix");
JPanel label = vizState.showAsLabel.pick("Show as labels", "Show members as labels");
JPanel attr = vizState.showAsAttr.pick("Show in relation attributes", "Show set membership of endpoints when relation attributes are enabled");
parent.add(makelabel(" Default Type and Set Settings:"));
parent.add(OurUtil.makeH(wcolor, 10, color, 7, style, 7, shape, 2, null));
JPanel a = OurUtil.makeVL(wcolor, vis, num, label), b = OurUtil.makeVL(wcolor, hide, attr);
parent.add(OurUtil.makeHT(wcolor, 10, a, 10, b, 2, null));
}
Aggregations