use of edu.mit.csail.sdg.alloy4.OurCombobox in project org.alloytools.alloy by AlloyTools.
the class VizCustomizationPanel method makeEdgeOptionsPanel.
// =============================================================================================================//
/**
* Generates the edge settings widgets for the given relation, and add them to
* "parent".
*/
private void makeEdgeOptionsPanel(final JPanel parent, final AlloyRelation rel) {
final JTextField labelText = OurUtil.textfield(vizState.label.get(rel), 10);
labelText.setMaximumSize(new Dimension(100, 25));
labelText.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
vizState.label.put(rel, labelText.getText());
}
});
labelText.addActionListener(new ActionListener() {
@Override
public final void actionPerformed(ActionEvent e) {
vizState.label.put(rel, labelText.getText());
}
});
labelText.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
vizState.label.put(rel, labelText.getText());
}
});
final JLabel weightLabel = OurUtil.label("Weight:");
final JSpinner weightSpinner = new JSpinner(new SpinnerNumberModel(vizState.weight.get(rel), 0, 999, 1));
weightSpinner.setMaximumSize(weightSpinner.getPreferredSize());
weightSpinner.setToolTipText("A higher weight will cause the edge to be shorter and straighter.");
weightSpinner.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
vizState.weight.put(rel, (Integer) (weightSpinner.getValue()));
}
});
weightSpinner.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
vizState.weight.put(rel, (Integer) (weightSpinner.getValue()));
}
@Override
public void mousePressed(MouseEvent e) {
vizState.weight.put(rel, (Integer) (weightSpinner.getValue()));
}
@Override
public void mouseReleased(MouseEvent e) {
vizState.weight.put(rel, (Integer) (weightSpinner.getValue()));
}
});
weightSpinner.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
vizState.weight.put(rel, (Integer) (weightSpinner.getValue()));
}
});
JPanel weightPanel = OurUtil.makeH(weightLabel, 5, weightSpinner);
weightPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
weightPanel.setAlignmentY(0.5f);
weightPanel.setToolTipText("A higher weight will cause the edge to be shorter and straighter.");
OurCombobox color = new OurCombobox(true, DotColor.valuesWithout(DotColor.WHITE), 110, 35, vizState.edgeColor.get(rel)) {
private static final long serialVersionUID = 0;
@Override
public String do_getText(Object value) {
return value == null ? "Inherit" : ((DotColor) value).getDisplayedText();
}
@Override
public Icon do_getIcon(Object value) {
if (value == null)
value = vizState.edgeColor.get(null);
return value == null ? null : ((DotColor) value).getIcon(vizState.getEdgePalette());
}
@Override
public void do_changed(Object value) {
vizState.edgeColor.put(rel, (DotColor) value);
}
};
OurCombobox style = new OurCombobox(true, DotStyle.values(), 105, 35, vizState.edgeStyle.get(rel)) {
private static final long serialVersionUID = 0;
@Override
public String do_getText(Object value) {
return value == null ? "Inherit" : ((DotStyle) value).getDisplayedText();
}
@Override
public Icon do_getIcon(Object value) {
if (value == null)
value = vizState.edgeStyle.get(null);
return value == null ? null : ((DotStyle) value).getIcon();
}
@Override
public void do_changed(Object value) {
vizState.edgeStyle.put(rel, (DotStyle) value);
}
};
JPanel visible = vizState.edgeVisible.pick(rel, "Show as arcs", "Show relation as arcs");
JPanel attr = vizState.attribute.pick(rel, "Show as attribute", "Additionally display this relation as an attribute on the nodes' labels");
JPanel back = vizState.layoutBack.pick(rel, "Layout backwards", "Layout graph as if arcs were reversed");
JPanel merge = vizState.mergeArrows.pick(rel, "Merge arrows", "Merge opposing arrows between the same nodes as one bidirectional arrow");
JPanel constraint = vizState.constraint.pick(rel, "Influence layout", "Whether this edge influences the graph layout");
JPanel panel1 = OurUtil.makeVR(wcolor, visible, attr, constraint);
JPanel panel2 = OurUtil.makeVR(wcolor, back, merge);
parent.add(makelabel("<html> " + Util.encode(rel.toString()) + "</html>"));
parent.add(OurUtil.makeH(10, labelText, wcolor, 5, color, 5, style, 3, weightPanel, 2, null));
parent.add(OurUtil.makeHT(wcolor, 10, panel1, 15, panel2, 2, null));
}
use of edu.mit.csail.sdg.alloy4.OurCombobox in project org.alloytools.alloy by AlloyTools.
the class VizCustomizationPanel method createDefaultEdgeWidget.
// =============================================================================================================//
/**
* Generates the "default relation settings" widgets, and add them to "parent".
*/
private void createDefaultEdgeWidget(JPanel parent) {
JComboBox colorComboE = new OurCombobox(false, DotColor.valuesWithout(DotColor.WHITE), 110, 35, vizState.edgeColor.get(null)) {
private static final long serialVersionUID = 0;
@Override
public String do_getText(Object value) {
return ((DotColor) value).getDisplayedText();
}
@Override
public Icon do_getIcon(Object value) {
return ((DotColor) value).getIcon(vizState.getEdgePalette());
}
@Override
public void do_changed(Object value) {
vizState.edgeColor.put(null, (DotColor) value);
}
};
JComboBox outlineComboE = new OurCombobox(false, DotStyle.values(), 110, 35, vizState.edgeStyle.get(null)) {
private static final long serialVersionUID = 0;
@Override
public String do_getText(Object value) {
return ((DotStyle) value).getDisplayedText();
}
@Override
public Icon do_getIcon(Object value) {
return ((DotStyle) value).getIcon();
}
@Override
public void do_changed(Object value) {
vizState.edgeStyle.put(null, (DotStyle) value);
}
};
JPanel dispCBE = vizState.edgeVisible.pick("Show as arcs", "Show relations as arcs");
JPanel mergeCBE = vizState.mergeArrows.pick("Merge arrows", "Merge opposing arrows of the same relation");
JPanel constraintCBE = vizState.constraint.pick("Influence layout", "Whether this edge influences the graph layout");
JPanel attrCBE = vizState.attribute.pick("Show as attributes", "Show relations as attributes on nodes");
JPanel laybackCBE = vizState.layoutBack.pick("Layout backwards", "Layout graph as if arcs were reversed");
parent.add(makelabel(" Default Relation Settings:"));
parent.add(OurUtil.makeH(wcolor, 10, colorComboE, 8, outlineComboE, 2, null));
JPanel a = OurUtil.makeVL(wcolor, dispCBE, attrCBE, constraintCBE, 10), b = OurUtil.makeVL(wcolor, laybackCBE, mergeCBE);
parent.add(OurUtil.makeHT(wcolor, 10, a, 10, b, 2, null));
}
use of edu.mit.csail.sdg.alloy4.OurCombobox in project org.alloytools.alloy by AlloyTools.
the class VizCustomizationPanel method createGeneralWidget.
// =============================================================================================================//
/**
* Generates the "general graph settings" widgets, and add them to "parent".
*/
private void createGeneralWidget(JPanel parent) {
final List<Integer> fontSizes = Util.asList(9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 32, 36, 40, 44, 48, 54, 60, 66, 72);
JLabel nLabel = OurUtil.label("Node Color Palette:");
JLabel eLabel = OurUtil.label("Edge Color Palette:");
JLabel aLabel = OurUtil.label("Use original atom names:");
JLabel pLabel = OurUtil.label("Hide private sigs/relations:");
JLabel mLabel = OurUtil.label("Hide meta sigs/relations:");
JLabel fLabel = OurUtil.label("Font Size:");
JComboBox fontSize = new OurCombobox(false, fontSizes.toArray(), 60, 32, vizState.getFontSize()) {
private static final long serialVersionUID = 0;
@Override
public void do_changed(Object value) {
if (fontSizes.contains(value))
vizState.setFontSize((Integer) value);
}
};
JComboBox nodepal = new OurCombobox(false, DotPalette.values(), 100, 32, vizState.getNodePalette()) {
private static final long serialVersionUID = 0;
@Override
public String do_getText(Object value) {
return ((DotPalette) value).getDisplayedText();
}
@Override
public void do_changed(Object value) {
vizState.setNodePalette((DotPalette) value);
}
};
JComboBox edgepal = new OurCombobox(false, DotPalette.values(), 100, 32, vizState.getEdgePalette()) {
private static final long serialVersionUID = 0;
@Override
public String do_getText(Object value) {
return ((DotPalette) value).getDisplayedText();
}
@Override
public void do_changed(Object value) {
vizState.setEdgePalette((DotPalette) value);
}
};
JPanel name = new OurCheckbox("", "Whether the visualizer should use the original atom names as-is.", vizState.useOriginalName() ? OurCheckbox.ON : OurCheckbox.OFF) {
private static final long serialVersionUID = 0;
@Override
public Icon do_action() {
boolean x = vizState.useOriginalName();
vizState.useOriginalName(!x);
return (!x ? ON : OFF);
}
};
JPanel priv = new OurCheckbox("", "Whether the visualizer should hide private sigs, sets, and relations by default.", vizState.hidePrivate() ? OurCheckbox.ON : OurCheckbox.OFF) {
private static final long serialVersionUID = 0;
@Override
public Icon do_action() {
boolean x = vizState.hidePrivate();
vizState.hidePrivate(!x);
remakeAll();
return (!x ? ON : OFF);
}
};
JPanel meta = new OurCheckbox("", "Whether the visualizer should hide meta sigs, sets, and relations by default.", vizState.hideMeta() ? OurCheckbox.ON : OurCheckbox.OFF) {
private static final long serialVersionUID = 0;
@Override
public Icon do_action() {
boolean x = vizState.hideMeta();
vizState.hideMeta(!x);
remakeAll();
return (!x ? ON : OFF);
}
};
parent.add(makelabel(" General Graph Settings:"));
parent.add(OurUtil.makeH(wcolor, new Dimension(6, 6)));
parent.add(OurUtil.makeH(wcolor, 25, nLabel, 5, nodepal, 8, aLabel, 5, name, 2, null));
parent.add(OurUtil.makeH(wcolor, 25, eLabel, 5, edgepal, 8, fLabel, 5, fontSize, 2, null));
parent.add(OurUtil.makeH(wcolor, 25, pLabel, 5, priv, 2, null));
parent.add(OurUtil.makeH(wcolor, 25, mLabel, 5, meta, 2, null));
}
use of edu.mit.csail.sdg.alloy4.OurCombobox in project org.alloytools.alloy by AlloyTools.
the class VizCustomizationPanel method createDefaultNodeWidget.
// =============================================================================================================//
/**
* Generates the "default type and set settings" widgets, and add them to
* "parent".
*/
private void createDefaultNodeWidget(JPanel parent) {
JComboBox color = new OurCombobox(false, DotColor.valuesWithout(DotColor.MAGIC), 110, 35, vizState.nodeColor.get(null)) {
private static final long serialVersionUID = 0;
@Override
public String do_getText(Object value) {
return ((DotColor) value).getDisplayedText();
}
@Override
public Icon do_getIcon(Object value) {
return ((DotColor) value).getIcon(vizState.getNodePalette());
}
@Override
public void do_changed(Object value) {
vizState.nodeColor.put(null, (DotColor) value);
}
};
JComboBox shape = new OurCombobox(false, DotShape.values(), 135, 35, vizState.shape.get(null)) {
private static final long serialVersionUID = 0;
@Override
public String do_getText(Object value) {
return ((DotShape) value).getDisplayedText();
}
@Override
public Icon do_getIcon(Object value) {
return ((DotShape) value).getIcon();
}
@Override
public void do_changed(Object value) {
vizState.shape.put(null, (DotShape) value);
}
};
JComboBox style = new OurCombobox(false, DotStyle.values(), 110, 35, vizState.nodeStyle.get(null)) {
private static final long serialVersionUID = 0;
@Override
public String do_getText(Object value) {
return ((DotStyle) value).getDisplayedText();
}
@Override
public Icon do_getIcon(Object value) {
return ((DotStyle) value).getIcon();
}
@Override
public void do_changed(Object value) {
vizState.nodeStyle.put(null, (DotStyle) value);
}
};
JPanel vis = vizState.nodeVisible.pick("Show", "Show members of type as nodes");
JPanel hide = vizState.hideUnconnected.pick("Hide unconnected nodes", "Hide nodes without arcs");
JPanel num = vizState.number.pick("Number nodes", "Attach atom number to node label as suffix");
JPanel label = vizState.showAsLabel.pick("Show as labels", "Show members as labels");
JPanel attr = vizState.showAsAttr.pick("Show in relation attributes", "Show set membership of endpoints when relation attributes are enabled");
parent.add(makelabel(" Default Type and Set Settings:"));
parent.add(OurUtil.makeH(wcolor, 10, color, 7, style, 7, shape, 2, null));
JPanel a = OurUtil.makeVL(wcolor, vis, num, label), b = OurUtil.makeVL(wcolor, hide, attr);
parent.add(OurUtil.makeHT(wcolor, 10, a, 10, b, 2, null));
}
use of edu.mit.csail.sdg.alloy4.OurCombobox in project org.alloytools.alloy by AlloyTools.
the class VizCustomizationPanel method makeNodeOptionsPanel.
// =============================================================================================================//
/**
* Generates the node settings widgets for the given type or set, and add them
* to "parent".
*/
private void makeNodeOptionsPanel(final JPanel answer, final AlloyNodeElement elt) {
final boolean enabled = !(elt instanceof AlloyType) || (vizState.getCurrentModel().hasType((AlloyType) elt));
answer.add(makelabel((elt instanceof AlloyType) ? (" " + typename((AlloyType) elt)) : (" " + elt)));
final JTextField labelText = OurUtil.textfield(vizState.label.get(elt), 10);
labelText.setMaximumSize(new Dimension(100, 25));
labelText.addKeyListener(new KeyAdapter() {
@Override
public final void keyReleased(KeyEvent e) {
vizState.label.put(elt, labelText.getText());
}
});
labelText.addActionListener(new ActionListener() {
@Override
public final void actionPerformed(ActionEvent e) {
vizState.label.put(elt, labelText.getText());
}
});
labelText.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
vizState.label.put(elt, labelText.getText());
}
});
final AlloyModel model = vizState.getCurrentModel();
final AlloyNodeElement elt2;
if (elt instanceof AlloyType)
elt2 = model.getSuperType((AlloyType) elt);
else if (elt instanceof AlloySet)
elt2 = ((AlloySet) elt).getType();
else
elt2 = null;
JComboBox color = new OurCombobox(true, DotColor.valuesWithout(DotColor.MAGIC), 100, 35, vizState.nodeColor.get(elt)) {
private static final long serialVersionUID = 0;
@Override
public String do_getText(Object value) {
if (value == null)
return "Inherit";
else
return ((DotColor) value).getDisplayedText();
}
@Override
public Icon do_getIcon(Object value) {
if (value == null)
value = vizState.nodeColor.resolve(elt2);
return value == null ? null : ((DotColor) value).getIcon(vizState.getNodePalette());
}
@Override
public void do_changed(Object value) {
vizState.nodeColor.put(elt, (DotColor) value);
}
};
JComboBox shape = new OurCombobox(true, DotShape.values(), 125, 35, vizState.shape.get(elt)) {
private static final long serialVersionUID = 0;
@Override
public String do_getText(Object value) {
if (value == null)
return "Inherit";
else
return ((DotShape) value).getDisplayedText();
}
@Override
public Icon do_getIcon(Object value) {
if (value == null)
value = vizState.shape.resolve(elt2);
return value == null ? null : ((DotShape) value).getIcon();
}
@Override
public void do_changed(Object value) {
vizState.shape.put(elt, (DotShape) value);
}
};
JComboBox style = new OurCombobox(true, DotStyle.values(), 95, 35, vizState.nodeStyle.get(elt)) {
private static final long serialVersionUID = 0;
@Override
public String do_getText(Object value) {
if (value == null)
return "Inherit";
else
return ((DotStyle) value).getDisplayedText();
}
@Override
public Icon do_getIcon(Object value) {
if (value == null)
value = vizState.nodeStyle.resolve(elt2);
return value == null ? null : ((DotStyle) value).getIcon();
}
@Override
public void do_changed(Object value) {
vizState.nodeStyle.put(elt, (DotStyle) value);
}
};
//
answer.add(OurUtil.makeH(10, labelText, wcolor, color, style, shape, 2, null));
if (elt instanceof AlloyType) {
JPanel vis = vizState.nodeVisible.pick(elt, "Show", "Display members as nodes");
JPanel con = vizState.hideUnconnected.pick(elt, "Hide unconnected nodes", "Hide nodes without arcs");
JPanel num = vizState.number.pick(elt, "Number nodes", "Attach atom number to node label as suffix");
JPanel proj = null;
if (vizState.canProject((AlloyType) elt))
proj = new OurCheckbox("Project over this sig", "Click here to " + (enabled ? "" : "un") + "project over this signature", enabled ? OurCheckbox.ALL_OFF : OurCheckbox.ALL_ON) {
private static final long serialVersionUID = 0;
@Override
public Icon do_action() {
if (enabled)
projectAlloyType((AlloyType) elt);
else
deprojectAlloyType((AlloyType) elt);
lastElement = elt;
return enabled ? ALL_ON : ALL_OFF;
}
};
labelText.setEnabled(enabled && !vizState.useOriginalName());
color.setEnabled(enabled);
shape.setEnabled(enabled);
style.setEnabled(enabled);
vis.setEnabled(enabled);
con.setEnabled(enabled);
num.setEnabled(enabled && !vizState.useOriginalName());
JPanel a = OurUtil.makeVR(wcolor, vis, num), b;
if (proj != null)
b = OurUtil.makeVR(wcolor, con, proj);
else
b = OurUtil.makeVR(wcolor, con);
answer.add(OurUtil.makeHT(wcolor, 15, a, 15, b, 2, null));
} else {
JPanel vis = vizState.nodeVisible.pick(elt, "Show", "Include members of set as nodes");
JPanel attr = vizState.showAsAttr.pick(elt, "Show in relation attributes", "Show set membership in relation attributes");
JPanel lab = vizState.showAsLabel.pick(elt, "Show as labels", "Show membership in set by labeling nodes");
JPanel con = vizState.hideUnconnected.pick(elt, "Hide unconnected nodes", "Hide nodes without arcs");
JPanel a = OurUtil.makeVR(wcolor, vis, lab), b = OurUtil.makeVR(wcolor, con, attr);
answer.add(OurUtil.makeHT(wcolor, 15, a, 15, b, 2, null));
}
}
Aggregations