use of edu.uci.ics.jung.visualization.control.DefaultModalGraphMouse in project fql by CategoricalData.
the class FqlppDisplay method doNTView.
@SuppressWarnings("unchecked")
private <X, Y> JComponent doNTView(Transform fn, JPanel p, Color clr, Graph<X, Y> sgv) {
// Layout<X, Y> layout = new FRLayout<>(sgv);
Layout<X, Y> layout = new FRLayout(sgv);
layout.setSize(new Dimension(600, 400));
VisualizationViewer<X, Y> vv = new VisualizationViewer<>(layout);
Function<X, Paint> vertexPaint = z -> clr;
DefaultModalGraphMouse<String, String> gm = new DefaultModalGraphMouse<>();
gm.setMode(Mode.TRANSFORMING);
vv.setGraphMouse(gm);
gm.setMode(Mode.PICKING);
vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
Function www = arg0 -> Util.nice(arg0.toString());
vv.getRenderContext().setVertexLabelTransformer(www);
vv.getRenderContext().setEdgeLabelTransformer(www);
vv.getPickedVertexState().addItemListener((ItemEvent e) -> {
if (e.getStateChange() != ItemEvent.SELECTED) {
return;
}
vv.getPickedEdgeState().clear();
X str = ((X) e.getItem());
Object y = fn.apply(str);
p.removeAll();
if (y instanceof Functor) {
Functor ttt = (Functor) y;
JPanel sss = showFtr(ttt, getColor(ttt.source), null);
p.add(sss);
} else if (y instanceof Fn) {
Fn ttt = (Fn) y;
JPanel sss = showFn(ttt, getColor(ttt.source), getColor(ttt.target));
p.add(sss);
} else if (y instanceof Transform) {
Transform ttt = (Transform) y;
JPanel sss = showTrans(ttt, getColor(ttt.source));
p.add(sss);
} else {
String sss = Util.nice(y.toString());
p.add(new CodeTextPanel(BorderFactory.createEtchedBorder(), null, sss));
}
p.revalidate();
});
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 FqlppDisplay method doCatView.
@SuppressWarnings("unchecked")
private static <X, Y> JComponent doCatView(Color clr, Graph<X, Y> sgv) {
Layout<X, Y> layout = new FRLayout<>(sgv);
layout.setSize(new Dimension(600, 400));
VisualizationViewer<X, Y> vv = new VisualizationViewer<>(layout);
Function<X, Paint> vertexPaint = x -> clr;
DefaultModalGraphMouse<String, String> gm = new DefaultModalGraphMouse<>();
gm.setMode(Mode.TRANSFORMING);
vv.setGraphMouse(gm);
gm.setMode(Mode.PICKING);
vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
Function ttt = arg0 -> Util.nice(arg0.toString());
vv.getRenderContext().setVertexLabelTransformer(ttt);
vv.getRenderContext().setEdgeLabelTransformer(ttt);
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 FqlppDisplay method doElementsView.
private static JComponent doElementsView(Color clr, Graph<Pair, Triple> sgv) {
Layout<Pair, Triple> layout = new FRLayout<>(sgv);
layout.setSize(new Dimension(600, 400));
VisualizationViewer<Pair, Triple> vv = new VisualizationViewer<>(layout);
Function<Pair, Paint> vertexPaint = z -> clr;
DefaultModalGraphMouse<String, String> gm = new DefaultModalGraphMouse<>();
gm.setMode(Mode.TRANSFORMING);
vv.setGraphMouse(gm);
gm.setMode(Mode.PICKING);
vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
Function<Pair, String> ttt1 = arg0 -> Util.nice(arg0.second.toString());
vv.getRenderContext().setVertexLabelTransformer(ttt1);
Function<Triple, String> ttt2 = arg0 -> Util.nice(arg0.first.toString());
vv.getRenderContext().setEdgeLabelTransformer(ttt2);
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 FqlppDisplay method doFNView2.
@SuppressWarnings("unchecked")
private static <X, Y> JComponent doFNView2(Functor fn, JPanel p, Color clr, Graph<X, Y> sgv, Signature sig) {
Layout<X, Y> layout = new FRLayout<>(sgv);
layout.setSize(new Dimension(600, 400));
VisualizationViewer<X, Y> vv = new VisualizationViewer<>(layout);
Function<X, Paint> vertexPaint = z -> clr;
DefaultModalGraphMouse<String, String> gm = new DefaultModalGraphMouse<>();
gm.setMode(Mode.TRANSFORMING);
vv.setGraphMouse(gm);
gm.setMode(Mode.PICKING);
vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
Function ttt = arg0 -> Util.nice(arg0.toString());
vv.getRenderContext().setVertexLabelTransformer(ttt);
vv.getRenderContext().setEdgeLabelTransformer(ttt);
// javac again
Map<Object, JPanel> map = (Map<Object, JPanel>) makeJoined(sig, fn).second;
vv.getPickedVertexState().addItemListener((ItemEvent e) -> {
if (e.getStateChange() != ItemEvent.SELECTED) {
return;
}
vv.getPickedEdgeState().clear();
X str = ((X) e.getItem());
// Object y = fn.applyO(str);
p.removeAll();
p.add(map.get(str));
p.revalidate();
});
vv.getPickedEdgeState().addItemListener((ItemEvent e) -> {
if (e.getStateChange() != ItemEvent.SELECTED) {
return;
}
vv.getPickedVertexState().clear();
X str = ((X) e.getItem());
// Object y = fn.applyA(str);
p.removeAll();
p.add(map.get(str));
p.revalidate();
});
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 OplExp method doSchemaView.
private static JComponent doSchemaView(Color clr, Graph sgv, Set entities) {
if (sgv.getVertexCount() == 0) {
return new JPanel();
}
Layout layout = new FRLayout<>(sgv);
layout.setSize(new Dimension(600, 400));
VisualizationViewer vv = new VisualizationViewer<>(layout);
Function vertexPaint = x -> entities.contains(x) ? clr : null;
DefaultModalGraphMouse<String, String> gm = new DefaultModalGraphMouse<>();
gm.setMode(Mode.TRANSFORMING);
vv.setGraphMouse(gm);
gm.setMode(Mode.PICKING);
vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
Function ttt = arg0 -> OplTerm.strip(arg0.toString());
vv.getRenderContext().setVertexLabelTransformer(ttt);
vv.getRenderContext().setEdgeLabelTransformer(ttt);
GraphZoomScrollPane zzz = new GraphZoomScrollPane(vv);
JPanel ret = new JPanel(new GridLayout(1, 1));
ret.add(zzz);
ret.setBorder(BorderFactory.createEtchedBorder());
return ret;
}
Aggregations