use of edu.uci.ics.jung.visualization.control.DefaultModalGraphMouse in project fql by CategoricalData.
the class Mpl method doTermView.
@SuppressWarnings({ "unchecked", "rawtypes" })
private static <O, A> JComponent doTermView(Color src, Color dst, Graph<Node<O, A>, Integer> sgv) {
if (sgv.getVertexCount() == 0) {
return new JPanel();
}
Layout layout = new FRLayout<>(sgv);
layout.setSize(new Dimension(600, 400));
VisualizationViewer vv = new VisualizationViewer<>(layout);
Function<Node<O, A>, Color> vertexPaint = x -> {
if (x.isInput) {
return src;
}
return dst;
};
DefaultModalGraphMouse<String, String> gm = new DefaultModalGraphMouse<>();
gm.setMode(Mode.TRANSFORMING);
vv.setGraphMouse(gm);
gm.setMode(Mode.PICKING);
vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
Function<Node<O, A>, String> ttt = arg0 -> {
String w = arg0.isInput ? "in" : "out";
return arg0.term + " #" + arg0.which + " " + w;
};
vv.getRenderContext().setVertexLabelTransformer(ttt);
vv.getRenderContext().setEdgeLabelTransformer(xx -> "");
GraphZoomScrollPane zzz = new GraphZoomScrollPane(vv);
JPanel ret = new JPanel(new GridLayout(1, 1));
ret.add(zzz);
ret.setBorder(BorderFactory.createEtchedBorder());
return ret;
}
use of edu.uci.ics.jung.visualization.control.DefaultModalGraphMouse in project fql by CategoricalData.
the class XMapping method makeGraph.
private JComponent makeGraph() {
if (src.allTerms().size() > 128) {
return new JTextArea("Too large to display");
}
Graph<Chc<C, D>, Object> sgv = buildFromSig();
Layout<Chc<C, D>, Object> layout = new FRLayout<>(sgv);
layout.setSize(new Dimension(600, 400));
VisualizationViewer<Chc<C, D>, Object> vv = new VisualizationViewer<>(layout);
vv.getRenderContext().setLabelOffset(20);
DefaultModalGraphMouse<String, String> gm = new DefaultModalGraphMouse<>();
gm.setMode(Mode.TRANSFORMING);
vv.setGraphMouse(gm);
gm.setMode(Mode.PICKING);
Function<Chc<C, D>, Paint> vertexPaint = x -> {
if (x.left) {
return Color.BLUE;
}
return Color.GREEN;
};
vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
Function<Chc<C, D>, String> ttt = arg0 -> {
if (arg0.left) {
return arg0.l.toString();
}
return arg0.r.toString();
};
Function<Object, String> hhh = arg0 -> {
if (!(arg0 instanceof Chc)) {
return "";
}
@SuppressWarnings("rawtypes") Chc xxx = (Chc) arg0;
if (xxx.left) {
return xxx.l.toString();
}
return xxx.r.toString();
};
vv.getRenderContext().setVertexLabelTransformer(ttt);
vv.getRenderContext().setEdgeLabelTransformer(hhh);
float[] dash = { 10.0f };
Stroke edgeStroke = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash, 0.0f);
Stroke bs = new BasicStroke();
Function<Object, Stroke> edgeStrokeTransformer = (Object s) -> {
if (!(s instanceof Chc)) {
return edgeStroke;
}
return bs;
};
vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
vv.getRenderContext().setEdgeStrokeTransformer(edgeStrokeTransformer);
GraphZoomScrollPane zzz = new GraphZoomScrollPane(vv);
JPanel ret = new JPanel(new GridLayout(1, 1));
ret.add(zzz);
ret.setBorder(BorderFactory.createEtchedBorder());
return ret;
}
use of edu.uci.ics.jung.visualization.control.DefaultModalGraphMouse in project fql by CategoricalData.
the class CategoryOfElements method doView.
private static JPanel doView(Color clr, @SuppressWarnings("unused") Instance inst, Graph<Pair<Node, Object>, Pair<Path, Integer>> sgv, Map<Pair<Node, Object>, Map<Attribute<Node>, Object>> map0) {
JPanel cards = new JPanel(new CardLayout());
Layout<Pair<Node, Object>, Pair<Path, Integer>> layout = new FRLayout<>(sgv);
layout.setSize(new Dimension(600, 400));
VisualizationViewer<Pair<Node, Object>, Pair<Path, Integer>> vv = new VisualizationViewer<>(layout);
Function<Pair<Node, Object>, Paint> vertexPaint = (Pair<Node, Object> i) -> clr;
DefaultModalGraphMouse<String, String> gm = new DefaultModalGraphMouse<>();
gm.setMode(Mode.TRANSFORMING);
vv.setGraphMouse(gm);
gm.setMode(Mode.PICKING);
vv.getRenderContext().setVertexLabelRenderer(new MyVertexT(cards));
vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
vv.getRenderContext().setEdgeLabelTransformer((Pair<Path, Integer> t) -> t.first.toString());
vv.getRenderContext().setVertexLabelTransformer((Pair<Node, Object> t) -> t.second.toString());
JPanel ret = new JPanel(new GridLayout(1, 1));
JSplitPane pane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
for (Pair<Node, Object> n : sgv.getVertices()) {
Map<Attribute<Node>, Object> s = map0.get(n);
Object[] columnNames = new Object[s.keySet().size()];
Object[][] rowData = new Object[1][s.keySet().size()];
int i = 0;
for (Attribute<Node> a : s.keySet()) {
columnNames[i] = a.name;
rowData[0][i] = s.get(a);
i++;
}
JPanel p = new JPanel(new GridLayout(1, 1));
JTable table = new JTable(rowData, columnNames);
JScrollPane jsp = new JScrollPane(table);
p.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "Attributes for " + n.second));
p.add(jsp);
cards.add(p, n.second.toString());
}
cards.add(new JPanel(), "blank");
CardLayout cl = (CardLayout) (cards.getLayout());
cl.show(cards, "blank");
pane.add(new GraphZoomScrollPane(vv));
pane.add(cards);
pane.setResizeWeight(.8d);
ret.add(pane);
return ret;
}
use of edu.uci.ics.jung.visualization.control.DefaultModalGraphMouse in project fql by CategoricalData.
the class FqlDisplay method doView2.
@SuppressWarnings("unchecked")
private JComponent doView2(Graph<String, Object> sgv) {
try {
Class<?> c = Class.forName(FqlOptions.layout_prefix + DefunctGlobalOptions.debug.fql.schFlow_graph);
Constructor<?> x = c.getConstructor(Graph.class);
Layout<String, Object> layout = (Layout<String, Object>) x.newInstance(sgv);
layout.setSize(new Dimension(600, 540));
VisualizationViewer<String, Object> vv = new VisualizationViewer<>(layout);
Function<String, Paint> vertexPaint = (String i) -> prog.smap(new Var(i));
DefaultModalGraphMouse<String, String> gm = new DefaultModalGraphMouse<>();
gm.setMode(Mode.TRANSFORMING);
vv.setGraphMouse(gm);
gm.setMode(Mode.PICKING);
vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller());
vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
vv.getPickedVertexState().addItemListener((ItemEvent e) -> {
if (e.getStateChange() != ItemEvent.SELECTED) {
return;
}
vv.getPickedEdgeState().clear();
String str = ((String) e.getItem());
yyy.setSelectedValue(indices.get(str), true);
});
vv.getPickedEdgeState().addItemListener((ItemEvent e) -> {
if (e.getStateChange() != ItemEvent.SELECTED) {
return;
}
vv.getPickedVertexState().clear();
String str = ((String) e.getItem());
yyy.setSelectedValue(indices.get(str), true);
});
vv.getRenderContext().setLabelOffset(20);
GraphZoomScrollPane zzz = new GraphZoomScrollPane(vv);
JPanel ret = new JPanel(new GridLayout(1, 1));
ret.add(zzz);
ret.setBorder(BorderFactory.createEtchedBorder());
return ret;
} catch (Throwable cnf) {
cnf.printStackTrace();
throw new RuntimeException();
}
}
use of edu.uci.ics.jung.visualization.control.DefaultModalGraphMouse in project fql by CategoricalData.
the class FqlDisplay method doView.
@SuppressWarnings({ "unchecked" })
private JComponent doView(Graph<String, Object> sgv) {
try {
Class<?> c = Class.forName(FqlOptions.layout_prefix + DefunctGlobalOptions.debug.fql.instFlow_graph);
Constructor<?> x = c.getConstructor(Graph.class);
Layout<String, Object> layout = (Layout<String, Object>) x.newInstance(sgv);
layout.setSize(new Dimension(600, 540));
VisualizationViewer<String, Object> vv = new VisualizationViewer<>(layout);
Function<String, Paint> vertexPaint = prog.nmap::get;
DefaultModalGraphMouse<String, String> gm = new DefaultModalGraphMouse<>();
gm.setMode(Mode.TRANSFORMING);
vv.setGraphMouse(gm);
gm.setMode(Mode.PICKING);
vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
vv.getRenderContext().setEdgeLabelTransformer((Object arg0) -> ((Pair<?, ?>) arg0).second.toString());
vv.getPickedVertexState().addItemListener((ItemEvent e) -> {
if (e.getStateChange() != ItemEvent.SELECTED) {
return;
}
vv.getPickedEdgeState().clear();
String str = ((String) e.getItem());
yyy.setSelectedValue(indices.get(str), true);
});
vv.getPickedEdgeState().addItemListener((ItemEvent e) -> {
if (e.getStateChange() != ItemEvent.SELECTED) {
return;
}
vv.getPickedVertexState().clear();
Object o = ((Pair<?, ?>) e.getItem()).second;
handleInstanceFlowEdge(o);
});
vv.getRenderContext().setLabelOffset(20);
GraphZoomScrollPane zzz = new GraphZoomScrollPane(vv);
JPanel ret = new JPanel(new GridLayout(1, 1));
ret.add(zzz);
ret.setBorder(BorderFactory.createEtchedBorder());
return ret;
} catch (Throwable cnf) {
cnf.printStackTrace();
throw new RuntimeException();
}
}
Aggregations