Search in sources :

Example 1 with DotShape

use of edu.mit.csail.sdg.alloy4graph.DotShape 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;
}
Also used : DotColor(edu.mit.csail.sdg.alloy4graph.DotColor) DotShape(edu.mit.csail.sdg.alloy4graph.DotShape) DotStyle(edu.mit.csail.sdg.alloy4graph.DotStyle) GraphNode(edu.mit.csail.sdg.alloy4graph.GraphNode)

Example 2 with DotShape

use of edu.mit.csail.sdg.alloy4graph.DotShape in project org.alloytools.alloy by AlloyTools.

the class MagicColor method assignNodeShape.

/**
 * Helper for nodeShape().
 */
private void assignNodeShape(final AlloyType t, final Set<AlloyType> subTypes, final boolean isTvisible, final List<DotShape> shapeFamily) {
    int index = 0;
    // shape for t, if visible
    if (isTvisible) {
        final DotShape shape = shapeFamily.get(index++);
        // log("AssignNodeShape " + t + " " + shape);
        vizState.shape.put(t, shape);
    }
    // shapes for visible subtypes
    for (final AlloyType subt : subTypes) {
        final DotShape shape = shapeFamily.get(index++);
        // log("AssignNodeShape " + subt + " " + shape);
        vizState.shape.put(subt, shape);
    }
}
Also used : DotShape(edu.mit.csail.sdg.alloy4graph.DotShape)

Example 3 with DotShape

use of edu.mit.csail.sdg.alloy4graph.DotShape 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));
}
Also used : DotColor(edu.mit.csail.sdg.alloy4graph.DotColor) DotShape(edu.mit.csail.sdg.alloy4graph.DotShape) OurCombobox(edu.mit.csail.sdg.alloy4.OurCombobox) JPanel(javax.swing.JPanel) JComboBox(javax.swing.JComboBox) DotStyle(edu.mit.csail.sdg.alloy4graph.DotStyle)

Aggregations

DotShape (edu.mit.csail.sdg.alloy4graph.DotShape)3 DotColor (edu.mit.csail.sdg.alloy4graph.DotColor)2 DotStyle (edu.mit.csail.sdg.alloy4graph.DotStyle)2 OurCombobox (edu.mit.csail.sdg.alloy4.OurCombobox)1 GraphNode (edu.mit.csail.sdg.alloy4graph.GraphNode)1 JComboBox (javax.swing.JComboBox)1 JPanel (javax.swing.JPanel)1