use of catdata.mpl.MplStrict.Node 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;
}
Aggregations