use of javax.swing.ButtonModel in project vcell by virtualcell.
the class ReactionCartoonEditorPanel method initialize.
private void initialize() {
try {
setName("CartoonPanel");
setPreferredSize(new Dimension(54, 425));
setLayout(new BorderLayout());
setSize(472, 422);
// setMinimumSize(new Dimension(54, 425));
add(getJScrollPane(), BorderLayout.CENTER);
viewPortStabilizer = new ViewPortStabilizer(getJScrollPane());
add(getJToolBar(), BorderLayout.NORTH);
initConnections();
// getModeButtonGroup().add(getStepButton());
// getModeButtonGroup().add(getFluxButton());
// getModeButtonGroup().add(getLineButton());
modeButtonGroup.add(getLineDirectedButton());
// modeButtonGroup.add(getLineCatalystButton());
modeButtonGroup.add(getSelectButton());
modeButtonGroup.add(getSpeciesButton());
modeButtonGroup.add(getFluxReactionButton());
modeButtonGroup.add(getStructureButton());
viewButtonGroup.add(getUngroupButton());
viewButtonGroup.add(getGroupMoleculeButton());
sizeOptionsButtonGroup.add(getEqualSizeButton());
sizeOptionsButtonGroup.add(getSizeByWeightButton());
sizeOptionsButtonGroup.add(getSizeByLengthButton());
// viewButtonGroup.add(getGroupRuleButton());
getReactionCartoonTool().setReactionCartoon(currentReactionCartoon);
getReactionCartoonTool().setGraphPane(getGraphPane());
getReactionCartoonTool().setButtonGroup(modeButtonGroup);
getReactionCartoonTool().setButtonGroup(viewButtonGroup);
// getGraphPane().setGraphModel(reactionCartoonFull);
// getGraphPane().setGraphModel(reactionCartoonMolecule);
// getGraphPane().setGraphModel(reactionCartoonRule);
getGraphPane().setGraphModel(currentReactionCartoon);
refreshButtons();
ButtonModel m = getEqualSizeButton().getModel();
sizeOptionsButtonGroup.setSelected(m, true);
// setViewMode(Mode.GROUP.getActionCommand());
} catch (Throwable throwable) {
handleException(throwable);
}
}
use of javax.swing.ButtonModel in project Universal-G-Code-Sender by winder.
the class BasicLinkButtonUI method paintText.
protected void paintText(Graphics g, JComponent com, Rectangle rect, String s) {
JLinkButton bn = (JLinkButton) com;
ButtonModel bnModel = bn.getModel();
if (bnModel.isEnabled()) {
if (bnModel.isPressed())
bn.setForeground(bn.getActiveLinkColor());
else if (bn.isLinkVisited())
bn.setForeground(bn.getVisitedLinkColor());
else
bn.setForeground(bn.getLinkColor());
} else {
if (bn.getDisabledLinkColor() != null)
bn.setForeground(bn.getDisabledLinkColor());
}
super.paintText(g, com, rect, s);
int behaviour = bn.getLinkBehavior();
boolean drawLine = false;
if (behaviour == JLinkButton.HOVER_UNDERLINE) {
if (bnModel.isRollover())
drawLine = true;
} else if (behaviour == JLinkButton.ALWAYS_UNDERLINE || behaviour == JLinkButton.SYSTEM_DEFAULT)
drawLine = true;
if (!drawLine)
return;
FontMetrics fm = g.getFontMetrics();
int x = rect.x + getTextShiftOffset();
int y = (rect.y + fm.getAscent() + fm.getDescent() + getTextShiftOffset()) - 1;
if (bnModel.isEnabled()) {
g.setColor(bn.getForeground());
g.drawLine(x, y, (x + rect.width) - 1, y);
} else {
g.setColor(bn.getBackground().brighter());
g.drawLine(x, y, (x + rect.width) - 1, y);
}
}
use of javax.swing.ButtonModel in project adempiere by adempiere.
the class CompiereToggleButtonUI method paint.
// update
/**
* Paint 3D Box
* @param g Graphics
* @param c Component
*/
public void paint(Graphics g, JComponent c) {
super.paint(g, c);
AbstractButton b = (AbstractButton) c;
ButtonModel model = b.getModel();
boolean in = model.isPressed() || model.isSelected();
//
CompiereUtils.paint3Deffect((Graphics2D) g, c, CompiereLookAndFeel.ROUND, !in);
}
use of javax.swing.ButtonModel in project adempiere by adempiere.
the class CompiereMenuItemUI method paintBackground.
// update
/**
* Paint Background
* @param g graphics
* @param menuItem menu
* @param bgColor bg color
*/
protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) {
ButtonModel model = menuItem.getModel();
if (model.isArmed())
super.paintBackground(g, menuItem, bgColor);
else {
CompiereColor bg = CompiereColor.getDefaultBackground();
bg.paint(g, menuItem);
}
}
use of javax.swing.ButtonModel in project knime-core by knime.
the class JavaScriptingPanel method loadSettingsFrom.
/**
* Load settings from arg.
* @param s To load from.
* @param spec The input spec.
*/
public void loadSettingsFrom(final JavaScriptingSettings s, final DataTableSpec spec) {
String exp = s.getExpression();
String header = s.getHeader();
String rType = s.getReturnType().getName();
boolean isArrayReturn = s.isArrayReturn();
String defaultNewName = m_customizer.getOutputIsVariable() ? "new variable" : "new column";
String newName = s.getColName();
boolean isReplace = s.isReplace();
boolean isTestCompilation = s.isTestCompilationOnDialogClose();
boolean isInsertMissingAsNull = s.isInsertMissingAsNull();
m_currentVersion = s.getExpressionVersion();
m_newNameField.setText("");
// will select newColName only if it is in the spec list
try {
m_replaceColumnCombo.update(spec, newName);
} catch (NotConfigurableException e1) {
NodeLogger.getLogger(getClass()).coding("Combo box throws " + "exception although content is not required", e1);
}
DefaultComboBoxModel cmbModel = (DefaultComboBoxModel) m_replaceVariableCombo.getModel();
cmbModel.removeAllElements();
final Map<String, FlowVariable> availableFlowVariables = m_varProvider.getAvailableFlowVariables();
for (FlowVariable v : availableFlowVariables.values()) {
switch(v.getScope()) {
case Flow:
cmbModel.addElement(v);
break;
default:
}
}
if (isReplace && availableFlowVariables.containsKey(newName)) {
m_replaceVariableCombo.setSelectedItem(availableFlowVariables.get(newName));
}
m_currentSpec = spec;
// whether there are variables or columns available
// -- which of two depends on the customizer
boolean fieldsAvailable;
if (m_customizer.getOutputIsVariable()) {
fieldsAvailable = m_replaceVariableCombo.getModel().getSize() > 0;
} else {
fieldsAvailable = m_replaceColumnCombo.getNrItemsInList() > 0;
}
if (isReplace && fieldsAvailable) {
m_replaceRadio.doClick();
} else {
m_appendRadio.doClick();
String newNameString = (newName != null ? newName : defaultNewName);
m_newNameField.setText(newNameString);
}
m_replaceRadio.setEnabled(fieldsAvailable);
m_headerEdit.setText(header);
m_expEdit.setText(exp);
m_expEdit.requestFocus();
ButtonModel firstButton = null;
for (Enumeration<?> e = m_returnTypeButtonGroup.getElements(); e.hasMoreElements(); ) {
AbstractButton b = (AbstractButton) e.nextElement();
if (firstButton == null) {
firstButton = b.getModel();
}
if (b.getActionCommand().equals(rType)) {
m_returnTypeButtonGroup.setSelected(b.getModel(), true);
}
}
if (m_returnTypeButtonGroup.getSelection() == null) {
m_returnTypeButtonGroup.setSelected(firstButton, true);
}
m_isArrayReturnChecker.setSelected(isArrayReturn);
DefaultListModel listModel = (DefaultListModel) m_colList.getModel();
listModel.removeAllElements();
if (m_currentVersion == Expression.VERSION_1X) {
listModel.addElement(Expression.ROWKEY);
listModel.addElement(Expression.ROWNUMBER);
} else {
listModel.addElement(Expression.ROWID);
listModel.addElement(Expression.ROWINDEX);
listModel.addElement(Expression.ROWCOUNT);
}
for (int i = 0; i < spec.getNumColumns(); i++) {
DataColumnSpec colSpec = spec.getColumnSpec(i);
listModel.addElement(colSpec);
}
DefaultListModel fvListModel = (DefaultListModel) m_flowVarsList.getModel();
fvListModel.removeAllElements();
for (FlowVariable v : availableFlowVariables.values()) {
fvListModel.addElement(v);
}
m_compileOnCloseChecker.setSelected(isTestCompilation);
m_insertMissingAsNullChecker.setSelected(isInsertMissingAsNull);
}
Aggregations