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);
}
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();
}
}
Aggregations