Search in sources :

Example 1 with GraphViewer

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

the class StaticGraphMaker method produceGraph.

/**
 * 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);
}
Also used : Graph(edu.mit.csail.sdg.alloy4graph.Graph) GraphViewer(edu.mit.csail.sdg.alloy4graph.GraphViewer) GraphNode(edu.mit.csail.sdg.alloy4graph.GraphNode)

Example 2 with GraphViewer

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

the class VizGraphPanel method remakeAll.

/**
 * Regenerate the comboboxes and the graph.
 */
public void remakeAll() {
    Map<AlloyType, AlloyAtom> map = new LinkedHashMap<AlloyType, AlloyAtom>();
    navPanel.removeAll();
    for (AlloyType type : vizState.getProjectedTypes()) {
        List<AlloyAtom> atoms = vizState.getOriginalInstance().type2atoms(type);
        TypePanel tp = type2panel.get(type);
        if (tp != null && tp.getAlloyAtom() != null && !atoms.contains(tp.getAlloyAtom()))
            tp = null;
        if (tp != null && tp.getAlloyAtom() == null && atoms.size() > 0)
            tp = null;
        if (tp != null && !tp.upToDate(type, atoms))
            tp = null;
        if (tp == null)
            type2panel.put(type, tp = new TypePanel(type, atoms, null));
        navPanel.add(tp);
        map.put(tp.getAlloyType(), tp.getAlloyAtom());
    }
    currentProjection = new AlloyProjection(map);
    JPanel graph = vizState.getGraph(currentProjection);
    if (seeDot && (graph instanceof GraphViewer)) {
        viewer = null;
        JTextArea txt = OurUtil.textarea(graph.toString(), 10, 10, false, true, getFont());
        diagramScrollPanel.setViewportView(txt);
    } else {
        if (graph instanceof GraphViewer)
            viewer = (GraphViewer) graph;
        else
            viewer = null;
        graphPanel.removeAll();
        graphPanel.add(graph);
        diagramScrollPanel.setViewportView(graphPanel);
        diagramScrollPanel.invalidate();
        diagramScrollPanel.repaint();
        diagramScrollPanel.validate();
    }
}
Also used : JPanel(javax.swing.JPanel) GraphViewer(edu.mit.csail.sdg.alloy4graph.GraphViewer) JTextArea(javax.swing.JTextArea) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

GraphViewer (edu.mit.csail.sdg.alloy4graph.GraphViewer)2 Graph (edu.mit.csail.sdg.alloy4graph.Graph)1 GraphNode (edu.mit.csail.sdg.alloy4graph.GraphNode)1 LinkedHashMap (java.util.LinkedHashMap)1 JPanel (javax.swing.JPanel)1 JTextArea (javax.swing.JTextArea)1