use of edu.uci.ics.jung.visualization.VisualizationViewer in project fql by CategoricalData.
the class InstanceEditor method doView.
@SuppressWarnings({ "unchecked", "rawtypes" })
private JComponent doView(Color clr, /* final Color color */
Graph<String, String> sgv) {
try {
Class<?> c = Class.forName(FqlOptions.layout_prefix + DefunctGlobalOptions.debug.fql.inst_graph);
Constructor<?> x = c.getConstructor(Graph.class);
Layout<String, String> layout = (Layout<String, String>) x.newInstance(sgv);
layout.setSize(new Dimension(500, 340));
VisualizationViewer<String, String> vv = new VisualizationViewer<>(layout);
Function<String, Paint> vertexPaint = (String i) -> {
return thesig.isAttribute(i) ? UIManager.getColor("Panel.background") : clr;
// return color;
};
DefaultModalGraphMouse<String, String> gm = new DefaultModalGraphMouse<>();
// gm.setMode(ModalGraphMouse.Mode.TRANSFORMING);
vv.setGraphMouse(gm);
gm.setMode(Mode.PICKING);
vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
vv.getRenderContext().setVertexLabelTransformer((String str) -> {
if (thesig.isAttribute(str)) {
str = thesig.getTypeLabel(str);
}
return str;
});
vv.getPickedVertexState().addItemListener((ItemEvent e) -> {
if (e.getStateChange() != ItemEvent.SELECTED) {
return;
}
vv.getPickedEdgeState().clear();
String str = ((String) e.getItem());
if (thesig.isNode(str)) {
cards.show(vwr, str);
card = str;
}
});
vv.getRenderContext().setLabelOffset(20);
vv.getRenderContext().setEdgeLabelTransformer((String s) -> {
if (thesig.isAttribute(s)) {
return "";
}
return s;
});
float[] dash = { 1.0f };
Stroke edgeStroke = new BasicStroke(0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash, 10.0f);
Stroke bs = new BasicStroke();
Function<String, Stroke> edgeStrokeTransformer = (String s) -> {
if (thesig.isAttribute(s)) {
return edgeStroke;
}
return bs;
};
vv.getRenderContext().setEdgeStrokeTransformer(edgeStrokeTransformer);
vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
GraphZoomScrollPane zzz = new GraphZoomScrollPane(vv);
zzz.setPreferredSize(new Dimension(600, 400));
vwr.setPreferredSize(new Dimension(600, 200));
// JPanel newthing = new JPanel(new GridLayout(2,1));
JSplitPane newthing = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
newthing.setResizeWeight(.5d);
newthing.setDividerLocation(.5d);
// setDividerLocation(.9d);
newthing.add(zzz);
JPanel yyy = new JPanel(new FlowLayout(FlowLayout.LEFT));
JButton ar = new JButton("Add Row");
JButton dr = new JButton("Delete Rows");
ar.setPreferredSize(dr.getPreferredSize());
yyy.add(ar);
yyy.add(dr);
JPanel xxx = new JPanel(new BorderLayout());
xxx.add(vwr, BorderLayout.CENTER);
xxx.add(yyy, BorderLayout.SOUTH);
newthing.add(xxx);
newthing.resetToPreferredSizes();
dr.addActionListener((ActionEvent e) -> {
JTable t = joined.get(card);
int[] i = t.getSelectedRows();
int j = 0;
DefaultTableModel dtm = (DefaultTableModel) t.getModel();
for (int x1 : i) {
dtm.removeRow(t.convertRowIndexToModel(x1) - j);
j++;
}
joined2.get(card).setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), card + " (" + dtm.getRowCount() + " rows)"));
});
ar.addActionListener((ActionEvent e) -> {
JTable t = joined.get(card);
DefaultTableModel dtm = (DefaultTableModel) t.getModel();
dtm.addRow((Vector) null);
joined2.get(card).setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), card + " (" + dtm.getRowCount() + " rows)"));
});
// return xxx;
return newthing;
} catch (Throwable t) {
t.printStackTrace();
throw new RuntimeException();
}
}
use of edu.uci.ics.jung.visualization.VisualizationViewer in project fql by CategoricalData.
the class Instance method doView.
@SuppressWarnings({ "unchecked" })
private JPanel doView(Color clr, Graph<String, String> sgv) {
try {
Class<?> c = Class.forName(FqlOptions.layout_prefix + DefunctGlobalOptions.debug.fql.inst_graph);
Constructor<?> x = c.getConstructor(Graph.class);
Layout<String, String> layout = (Layout<String, String>) x.newInstance(sgv);
VisualizationViewer<String, String> vv = new VisualizationViewer<>(layout);
Function<String, Paint> vertexPaint = (String i) -> thesig.isAttribute(i) ? UIManager.getColor("Panel.background") : clr;
DefaultModalGraphMouse<String, String> gm = new DefaultModalGraphMouse<>();
vv.setGraphMouse(gm);
gm.setMode(Mode.PICKING);
vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
vv.getRenderContext().setVertexLabelTransformer((String str) -> {
if (thesig.isAttribute(str)) {
str = thesig.getTypeLabel(str);
}
return str;
});
vv.getPickedVertexState().addItemListener((ItemEvent e) -> {
if (e.getStateChange() != ItemEvent.SELECTED) {
return;
}
vv.getPickedEdgeState().clear();
String str = ((String) e.getItem());
prejoin();
if (thesig.isAttribute(str)) {
cards.show(vwr, "domain of " + str);
} else {
cards.show(vwr, str);
}
});
vv.getPickedEdgeState().addItemListener((ItemEvent e) -> {
if (e.getStateChange() != ItemEvent.SELECTED) {
return;
}
vv.getPickedVertexState().clear();
String str = ((String) e.getItem());
prejoin();
cards.show(vwr, str);
});
vv.getRenderContext().setLabelOffset(20);
vv.getRenderContext().setEdgeLabelTransformer((String s) -> {
if (thesig.isAttribute(s)) {
return "";
}
return s;
});
float[] dash = { 1.0f };
Stroke edgeStroke = new BasicStroke(0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash, 10.0f);
Stroke bs = new BasicStroke();
Function<String, Stroke> edgeStrokeTransformer = s -> {
if (thesig.isAttribute(s)) {
return edgeStroke;
}
return bs;
};
vv.getRenderContext().setEdgeStrokeTransformer(edgeStrokeTransformer);
vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
GraphZoomScrollPane zzz = new GraphZoomScrollPane(vv);
JSplitPane newthing = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
newthing.setResizeWeight(.8d);
newthing.add(zzz);
newthing.add(vwr);
JPanel xxx = new JPanel(new GridLayout(1, 1));
xxx.add(newthing);
layout.setSize(new Dimension(400, 400));
return xxx;
} catch (Throwable t) {
t.printStackTrace();
throw new RuntimeException();
}
}
use of edu.uci.ics.jung.visualization.VisualizationViewer in project fql by CategoricalData.
the class Query method lowerComp2.
public static JPanel lowerComp2(@SuppressWarnings("unused") FqlEnvironment env) {
Layout<String, String> layout = new ISOMLayout<>(legend());
layout.setSize(new Dimension(500, 100));
VisualizationViewer<String, String> vv = new VisualizationViewer<>(layout);
vv.setPreferredSize(new Dimension(500, 100));
DefaultModalGraphMouse<String, String> gm = new DefaultModalGraphMouse<>();
gm.setMode(Mode.TRANSFORMING);
vv.setGraphMouse(gm);
gm.setMode(Mode.PICKING);
vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller());
vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
return vv;
}
use of edu.uci.ics.jung.visualization.VisualizationViewer in project fql by CategoricalData.
the class FullQuery method doView.
@SuppressWarnings("unchecked")
private JComponent doView(/* final Environment env, */
Graph<Pair<FullQuery, Integer>, Integer> sgv) {
try {
Class<?> c = Class.forName(FqlOptions.layout_prefix + DefunctGlobalOptions.debug.fql.inst_graph);
Constructor<?> x = c.getConstructor(Graph.class);
Layout<Pair<FullQuery, Integer>, Integer> layout = (Layout<Pair<FullQuery, Integer>, Integer>) x.newInstance(sgv);
// Layout<V, E>, BasicVisualizationServer<V,E>
// Layout<String, String> layout = new FRLayout(sgv);
// Layout<Pair<FullQuery, Integer>, Integer> layout = new ISOMLayout<Pair<FullQuery, Integer>, Integer>(
// sgv);
// Layout<String, String> layout = new CircleLayout(sgv);
layout.setSize(new Dimension(600, 400));
// BasicVisualizationServer<String, String> vv = new
// BasicVisualizationServer<String, String>(
// layout);
VisualizationViewer<Pair<FullQuery, Integer>, Integer> vv = new VisualizationViewer<>(layout);
// vv.setPreferredSize(new Dimension(600, 400));
// Setup up a new vertex to paint transformer...
Function<Pair<FullQuery, Integer>, Paint> vertexPaint = (Pair<FullQuery, Integer> i) -> i.first.color();
DefaultModalGraphMouse<String, String> gm = new DefaultModalGraphMouse<>();
gm.setMode(Mode.TRANSFORMING);
vv.setGraphMouse(gm);
gm.setMode(Mode.PICKING);
// Set up a new stroke Transformer for the edges
// float dash[] = { 1.0f };
// final Stroke edgeStroke = new BasicStroke(0.5f, BasicStroke.CAP_BUTT,
// BasicStroke.JOIN_MITER, 10.0f, dash, 10.0f);
// Function<String, Stroke> edgeStrokeTransformer = new
// Function<String, Stroke>() {
// public Stroke transform(String s) {
// return edgeStroke;
// }
// };
vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
vv.getRenderContext().setVertexLabelRenderer(new MyVertexT());
vv.getRenderContext().setEdgeLabelTransformer((Integer ix) -> "");
// new ToStringLabeller());
// vv.getRenderer().getVertexRenderer().
// vv.getRenderContext().setLabelOffset(20);
// vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);
vv.getRenderContext().setVertexLabelTransformer((Pair<FullQuery, Integer> t) -> t.first.kind());
GraphZoomScrollPane zzz = new GraphZoomScrollPane(vv);
// JPanel ret = new JPanel(new GridLayout(1,1));
// ret.add(zzz);
JSplitPane newthing = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
// setDividerLocation(.9d);
newthing.setResizeWeight(.8d);
newthing.add(zzz);
newthing.add(new JScrollPane(cards));
cards.setWrapStyleWord(true);
JPanel xxx = new JPanel(new GridLayout(1, 1));
xxx.add(newthing);
xxx.setBorder(BorderFactory.createEtchedBorder());
// xxx.setMaximumSize(new Dimension(400,400));
return xxx;
} catch (Throwable e) {
e.printStackTrace();
throw new RuntimeException();
}
}
use of edu.uci.ics.jung.visualization.VisualizationViewer in project fql by CategoricalData.
the class Signature method doView.
@SuppressWarnings("unchecked")
private JComponent doView(Color clr, /* final Environment env, */
Graph<String, String> sgv) {
try {
Class<?> c = Class.forName(FqlOptions.layout_prefix + DefunctGlobalOptions.debug.fql.schema_graph);
Constructor<?> x = c.getConstructor(Graph.class);
Layout<String, String> layout = (Layout<String, String>) x.newInstance(sgv);
layout.setSize(new Dimension(600, 400));
VisualizationViewer<String, String> vv = new VisualizationViewer<>(layout);
Function<String, Paint> vertexPaints = (String name) -> isAttribute(name) ? UIManager.getColor("Panel.background") : clr;
DefaultModalGraphMouse<String, String> gm = new DefaultModalGraphMouse<>();
gm.setMode(Mode.TRANSFORMING);
vv.setGraphMouse(gm);
gm.setMode(Mode.PICKING);
float[] dash = { 1.0f };
Stroke edgeStroke = new BasicStroke(0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash, 10.0f);
Stroke bs = new BasicStroke();
Function<String, Stroke> edgeStrokeTransformer = (String name) -> (isAttribute(name)) ? edgeStroke : bs;
vv.getRenderContext().setVertexFillPaintTransformer(vertexPaints);
vv.getRenderContext().setEdgeStrokeTransformer(edgeStrokeTransformer);
vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller());
vv.getRenderContext().setVertexLabelTransformer((String t) -> (isAttribute(t)) ? getTypeLabel(t) : t);
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