use of javax.swing.border.TitledBorder in project ChatGameFontificator by GlitchCog.
the class MessageCensorPanel method build.
@Override
protected void build() {
setBorder(new TitledBorder(ControlPanelBase.getBaseBorder(), "Message Censorship Configuration", TitledBorder.CENTER, TitledBorder.TOP));
setLayout(new GridBagLayout());
GridBagConstraints gbc = ControlPanelBase.getGbc();
enableCensorshipBox = new JCheckBox("Enable message censoring");
purgeOnTwitchBanBox = new JCheckBox("Purge messages on Twitch ban/timeout");
censorAllUrlsBox = new JCheckBox("Censor all messages containing URLs");
censorFirstPostUrlsBox = new JCheckBox("Censor messages containing URLs in a user's initial post");
censorUnknownCharsBox = new JCheckBox("Censor messages containing a specified percentage of extended characters:");
final String minLabel = "> 0";
// @formatter:off
unknownCharSlider = new LabeledSlider("", "%", ConfigCensor.MIN_UNKNOWN_CHAR_PCT, ConfigCensor.MAX_UNKNOWN_CHAR_PCT, Math.max(Math.max(Integer.toString(ConfigCensor.MIN_UNKNOWN_CHAR_PCT).length(), Integer.toString(ConfigCensor.MAX_UNKNOWN_CHAR_PCT).length()), minLabel.length())) {
// @formatter:on
private static final long serialVersionUID = 1L;
@Override
public String getValueString() {
if (getValue() == slider.getMinimum()) {
return minLabel;
} else {
return super.getValueString();
}
}
};
userWhitelist = new ListInput("User Whitelist", "Exempt from all censorship", this);
userBlacklist = new ListInput("User Blacklist", "Every message censored", this);
bannedWordList = new ListInput("Banned Words", "Containing censors message", this);
ActionListener bl = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updateConfig();
chat.repaint();
chat.initMessageRollout();
}
};
enableCensorshipBox.addActionListener(bl);
purgeOnTwitchBanBox.addActionListener(bl);
censorAllUrlsBox.addActionListener(bl);
censorFirstPostUrlsBox.addActionListener(bl);
censorUnknownCharsBox.addActionListener(bl);
unknownCharSlider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
config.setUnknownCharPercentage(unknownCharSlider.getValue());
}
});
messageList = new MessageCheckList(chat, this);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 1.0;
gbc.weighty = 0.0;
gbc.gridwidth = 3;
add(new JLabel("Censorship rules affect the visualization only; they don't influence the visibility of IRC posts."), gbc);
gbc.gridy++;
add(enableCensorshipBox, gbc);
gbc.gridy++;
add(purgeOnTwitchBanBox, gbc);
gbc.gridy++;
add(censorAllUrlsBox, gbc);
gbc.gridy++;
add(censorFirstPostUrlsBox, gbc);
gbc.gridy++;
JPanel unknownPanel = new JPanel(new GridBagLayout());
GridBagConstraints uGbc = getGbc();
uGbc.anchor = GridBagConstraints.WEST;
uGbc.weightx = 1.0;
uGbc.fill = GridBagConstraints.NONE;
unknownPanel.add(censorUnknownCharsBox, uGbc);
uGbc.gridy++;
uGbc.anchor = GridBagConstraints.EAST;
uGbc.weightx = 1.0;
uGbc.weighty = 1.0;
uGbc.fill = GridBagConstraints.BOTH;
unknownPanel.add(unknownCharSlider, uGbc);
add(unknownPanel, gbc);
gbc.gridy++;
gbc.weightx = 0.33;
gbc.gridwidth = 1;
add(userWhitelist, gbc);
gbc.gridx++;
add(userBlacklist, gbc);
gbc.gridx++;
add(bannedWordList, gbc);
gbc.gridx++;
gbc.gridy++;
gbc.gridx = 0;
gbc.gridwidth = 3;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.fill = GridBagConstraints.BOTH;
add(messageList, gbc);
gbc.gridy++;
}
use of javax.swing.border.TitledBorder in project ChatGameFontificator by GlitchCog.
the class ControlPanelChat method build.
@Override
protected void build() {
resizableBox = new JCheckBox("Resize Chat by Dragging");
scrollableBox = new JCheckBox("Mouse Wheel Scrolls Chat");
reverseScrollBox = new JCheckBox("Reverse Chat Order");
chatFromBottomBox = new JCheckBox("Chat Starts from Bottom");
widthInput = new LabeledInput("Width", 3);
heightInput = new LabeledInput("Height", 3);
DocumentListener chatSizeDocListener = new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
somethingChanged(e);
}
@Override
public void removeUpdate(DocumentEvent e) {
somethingChanged(e);
}
@Override
public void changedUpdate(DocumentEvent e) {
somethingChanged(e);
}
/**
* Something changed, so try to get the new width and height and set the updateSizeButton to enabled or
* disabled accordingly
*
* @param e
*/
private void somethingChanged(DocumentEvent e) {
try {
int w = Integer.parseInt(widthInput.getText());
int h = Integer.parseInt(heightInput.getText());
updateSizeButton.setEnabled(w != config.getWidth() || h != config.getHeight());
} catch (Exception ex) {
updateSizeButton.setEnabled(false);
}
}
};
DocumentListener chromaDocListener = new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
toggleChromaButtonEnabled();
}
@Override
public void removeUpdate(DocumentEvent e) {
toggleChromaButtonEnabled();
}
@Override
public void changedUpdate(DocumentEvent e) {
toggleChromaButtonEnabled();
}
};
widthInput.addDocumentListener(chatSizeDocListener);
heightInput.addDocumentListener(chatSizeDocListener);
updateSizeButton = new JButton("Update Chat Size");
chromaEnabledBox = new JCheckBox("Enable Chroma Key Border");
chromaInvertBox = new JCheckBox("Invert Chroma Key Border");
chromaCornerSlider = new LabeledSlider("Corner Radius", "pixels", ConfigChat.MIN_CHROMA_CORNER_RADIUS, ConfigChat.MAX_CHROMA_CORNER_RADIUS);
final String[] chromaLabels = new String[] { "Left", "Top", "Right", "Bottom" };
chromaBorderInput = new LabeledInput[chromaLabels.length];
for (int i = 0; i < chromaBorderInput.length; i++) {
chromaBorderInput[i] = new LabeledInput(chromaLabels[i], 4);
chromaBorderInput[i].addDocumentListener(chromaDocListener);
}
updateChromaSizeButton = new JButton("Update Chroma Border");
ActionListener boxListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JCheckBox source = (JCheckBox) e.getSource();
if (resizableBox.equals(source)) {
chatWindow.setResizable(resizableBox.isSelected());
config.setResizable(resizableBox.isSelected());
} else if (scrollableBox.equals(source)) {
config.setScrollable(scrollableBox.isSelected());
if (!scrollableBox.isSelected()) {
// No scrolling, so reset any existing scroll offset
chat.resetScrollOffset();
}
} else if (reverseScrollBox.equals(source)) {
config.setReverseScrolling(reverseScrollBox.isSelected());
} else if (chatFromBottomBox.equals(source)) {
// Reset scrolling to avoid having to translate it between chat-start top/bottom styles
chat.resetScrollOffset();
config.setChatFromBottom(chatFromBottomBox.isSelected());
} else if (chromaEnabledBox.equals(source)) {
config.setChromaEnabled(chromaEnabledBox.isSelected());
toggleChromaInputFields();
} else if (chromaInvertBox.equals(source)) {
config.setChromaInvert(chromaInvertBox.isSelected());
}
chat.repaint();
}
};
resizableBox.addActionListener(boxListener);
scrollableBox.addActionListener(boxListener);
reverseScrollBox.addActionListener(boxListener);
chatFromBottomBox.addActionListener(boxListener);
chromaEnabledBox.addActionListener(boxListener);
chromaInvertBox.addActionListener(boxListener);
ActionListener dimListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
LoadConfigReport report = new LoadConfigReport();
config.validateDimStrings(report, widthInput.getText(), heightInput.getText());
if (report.isErrorFree()) {
final int width = Integer.parseInt(widthInput.getText());
final int height = Integer.parseInt(heightInput.getText());
config.setWidth(width);
config.setHeight(height);
chatWindow.setSize(config.getWidth(), config.getHeight());
} else {
ChatWindow.popup.handleProblem(report);
}
} catch (Exception ex) {
ChatWindow.popup.handleProblem("Chat Width and Chat Height values could not be parsed", ex);
}
}
};
updateSizeButton.addActionListener(dimListener);
ActionListener chromaDimListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
LoadConfigReport report = new LoadConfigReport();
config.validateChromaDimStrings(report, chromaBorderInput[0].getText(), chromaBorderInput[1].getText(), chromaBorderInput[2].getText(), chromaBorderInput[3].getText());
if (report.isErrorFree()) {
inputToConfigChromaBorders();
chat.repaint();
} else {
ChatWindow.popup.handleProblem(report);
}
} catch (Exception ex) {
ChatWindow.popup.handleProblem("Chat Chroma border values could not be parsed", ex);
}
}
};
updateChromaSizeButton.addActionListener(chromaDimListener);
chromaCornerSlider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
config.setChromaCornerRadius(chromaCornerSlider.getValue());
chat.repaint();
}
});
JPanel chatDimPanel = new JPanel(new GridBagLayout());
JPanel chatOptionsPanel = new JPanel(new GridBagLayout());
JPanel chromaDimPanel = new JPanel(new GridBagLayout());
chatDimPanel.setBorder(new TitledBorder(baseBorder, "Chat Window Size", TitledBorder.CENTER, TitledBorder.TOP));
chatOptionsPanel.setBorder(new TitledBorder(baseBorder, "Chat Window Options", TitledBorder.CENTER, TitledBorder.TOP));
chromaDimPanel.setBorder(baseBorder);
GridBagConstraints dGbc = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, DEFAULT_INSETS, 0, 0);
dGbc.gridx = 0;
dGbc.gridy = 0;
dGbc.gridwidth = 1;
chatDimPanel.add(widthInput, dGbc);
dGbc.gridx++;
chatDimPanel.add(heightInput, dGbc);
dGbc.gridx = 0;
dGbc.gridy++;
dGbc.gridwidth = 2;
chatDimPanel.add(updateSizeButton, dGbc);
dGbc.gridy++;
chatDimPanel.add(resizableBox, dGbc);
dGbc.gridy++;
GridBagConstraints coGbc = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, DEFAULT_INSETS, 0, 0);
coGbc.anchor = GridBagConstraints.WEST;
chatOptionsPanel.add(scrollableBox, coGbc);
coGbc.gridy++;
chatOptionsPanel.add(reverseScrollBox, coGbc);
coGbc.gridy++;
chatOptionsPanel.add(chatFromBottomBox, coGbc);
coGbc.gridy++;
GridBagConstraints chromaGbc = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, NO_INSETS, 0, 0);
chromaGbc.gridwidth = 3;
chromaDimPanel.add(chromaEnabledBox, chromaGbc);
chromaGbc.gridy++;
chromaDimPanel.add(chromaBorderInput[1], chromaGbc);
chromaGbc.gridy++;
chromaGbc.gridwidth = 1;
chromaGbc.anchor = GridBagConstraints.EAST;
chromaDimPanel.add(chromaBorderInput[0], chromaGbc);
chromaGbc.gridx++;
chromaGbc.anchor = GridBagConstraints.CENTER;
chromaDimPanel.add(updateChromaSizeButton, chromaGbc);
chromaGbc.gridx++;
chromaGbc.anchor = GridBagConstraints.WEST;
chromaDimPanel.add(chromaBorderInput[2], chromaGbc);
chromaGbc.gridx = 0;
chromaGbc.anchor = GridBagConstraints.CENTER;
chromaGbc.gridy++;
chromaGbc.gridwidth = 3;
chromaDimPanel.add(chromaBorderInput[3], chromaGbc);
chromaGbc.gridy++;
chromaDimPanel.add(chromaInvertBox, chromaGbc);
chromaGbc.gridy++;
chromaDimPanel.add(chromaCornerSlider, chromaGbc);
JPanel everything = new JPanel(new GridBagLayout());
GridBagConstraints eGbc = new GridBagConstraints(0, 0, 1, 1, 0.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, NO_INSETS, 0, 0);
eGbc.weighty = 0.5;
eGbc.weightx = 0.5;
eGbc.fill = GridBagConstraints.HORIZONTAL;
eGbc.insets = new Insets(0, 3, 0, 3);
everything.add(chatDimPanel, eGbc);
eGbc.weightx = 0.5;
eGbc.gridx++;
everything.add(chatOptionsPanel, eGbc);
eGbc.weightx = 1.0;
eGbc.weighty = 0.0;
eGbc.gridx = 0;
eGbc.gridy++;
eGbc.gridwidth = 2;
eGbc.fill = GridBagConstraints.BOTH;
eGbc.anchor = GridBagConstraints.CENTER;
everything.add(chromaDimPanel, eGbc);
eGbc.gridy++;
gbc.anchor = GridBagConstraints.NORTH;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
add(everything, gbc);
}
use of javax.swing.border.TitledBorder in project ChatGameFontificator by GlitchCog.
the class ControlPanelColor method build.
@Override
protected void build() {
useTwitchBox = new JCheckBox("Override Palette with Twitch Username Colors when Available");
joinBox = new JCheckBox("Color Join Messages");
usernameBox = new JCheckBox("Color Usernames");
timestampBox = new JCheckBox("Color Timestamps");
messageBox = new JCheckBox("Color Messages");
ActionListener boxListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JCheckBox source = (JCheckBox) e.getSource();
if (useTwitchBox.equals(source)) {
config.setUseTwitchColors(source.isSelected());
} else if (joinBox.equals(source)) {
config.setColorJoin(source.isSelected());
} else if (usernameBox.equals(source)) {
config.setColorUsername(source.isSelected());
} else if (timestampBox.equals(source)) {
config.setColorTimestamp(source.isSelected());
} else if (messageBox.equals(source)) {
config.setColorMessage(source.isSelected());
}
chat.repaint();
}
};
useTwitchBox.addActionListener(boxListener);
joinBox.addActionListener(boxListener);
usernameBox.addActionListener(boxListener);
timestampBox.addActionListener(boxListener);
messageBox.addActionListener(boxListener);
bgColorButton = new ColorButton("Background", Color.BLACK, "Set the color of the background of the chat", this);
chromaColorButton = new ColorButton("Chroma Key", Color.GREEN, "Set the color for the chroma key border region", this);
fgColorButton = new ColorButton("Text Tint", Color.WHITE, "Set the color of the text of the chat", this);
borderColorButton = new ColorButton("Border Tint", Color.WHITE, "Set the color of the border of the chat", this);
highlightButton = new ColorButton("Highlight Tint", Color.YELLOW, "Set the default color used to highlight the text of the chat", this);
palette = new Palette(Color.BLACK, this);
JPanel topColorPanel = new JPanel(new GridLayout(2, 1));
JPanel botOptionsPanel = new JPanel(new GridBagLayout());
JPanel palettePanel = new JPanel(new GridBagLayout());
topColorPanel.setBorder(new TitledBorder(baseBorder, "Color Selections", TitledBorder.CENTER, TitledBorder.TOP));
palettePanel.setBorder(new TitledBorder(baseBorder, "Palette of Colors drawn from, per Username", TitledBorder.CENTER, TitledBorder.TOP));
botOptionsPanel.setBorder(new TitledBorder(baseBorder, "Color Options", TitledBorder.CENTER, TitledBorder.TOP));
JPanel colorPanelA = new JPanel(new GridLayout(1, 2));
colorPanelA.add(bgColorButton);
colorPanelA.add(chromaColorButton);
JPanel colorPanelB = new JPanel(new GridLayout(1, 3));
colorPanelB.add(fgColorButton);
colorPanelB.add(highlightButton);
colorPanelB.add(borderColorButton);
topColorPanel.add(colorPanelA);
topColorPanel.add(colorPanelB);
GridBagConstraints ppGbc = new GridBagConstraints(0, 0, 1, 1, 0.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, NO_INSETS, 0, 0);
palettePanel.add(palette, ppGbc);
ppGbc.gridy++;
palettePanel.add(useTwitchBox, ppGbc);
GridBagConstraints optionsGbc = new GridBagConstraints(0, 0, 1, 1, 0.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.NONE, DEFAULT_INSETS, 0, 0);
botOptionsPanel.add(joinBox, optionsGbc);
optionsGbc.gridx++;
botOptionsPanel.add(usernameBox, optionsGbc);
optionsGbc.gridx = 0;
optionsGbc.gridy++;
botOptionsPanel.add(timestampBox, optionsGbc);
optionsGbc.gridx++;
botOptionsPanel.add(messageBox, optionsGbc);
gbc.anchor = GridBagConstraints.NORTH;
gbc.weighty = 0.0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 1.0;
add(topColorPanel, gbc);
gbc.gridy++;
add(palettePanel, gbc);
gbc.gridy++;
add(botOptionsPanel, gbc);
// Filler panel
gbc.gridy++;
gbc.anchor = GridBagConstraints.SOUTH;
gbc.weighty = 1.0;
gbc.fill = GridBagConstraints.BOTH;
add(new JPanel(), gbc);
gbc.gridy++;
}
use of javax.swing.border.TitledBorder in project ChatGameFontificator by GlitchCog.
the class ControlPanelFont method build.
@Override
protected void build() {
sliderListener = new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
JSlider source = (JSlider) e.getSource();
if (fontScaleSlider.getSlider().equals(source)) {
config.setFontScale(fontScaleSlider.getScaledValue());
fontScaleSlider.setValueTextColor(((int) config.getFontScale() == config.getFontScale()) ? SCALE_EVEN : SCALE_UNEVEN);
} else if (borderScaleSlider.getSlider().equals(source)) {
config.setBorderScale(borderScaleSlider.getScaledValue());
borderScaleSlider.setValueTextColor(((int) config.getBorderScale() == config.getBorderScale()) ? SCALE_EVEN : SCALE_UNEVEN);
} else if (borderInsetXSlider.getSlider().equals(source)) {
config.setBorderInsetX(borderInsetXSlider.getValue());
} else if (borderInsetYSlider.getSlider().equals(source)) {
config.setBorderInsetY(borderInsetYSlider.getValue());
} else if (spaceWidthSlider.getSlider().equals(source)) {
config.setSpaceWidth(spaceWidthSlider.getValue());
} else if (baselineOffsetSlider.getSlider().equals(source)) {
config.setBaselineOffset(baselineOffsetSlider.getValue());
} else if (lineSpacingSlider.getSlider().equals(source)) {
config.setLineSpacing(lineSpacingSlider.getValue());
} else if (charSpacingSlider.getSlider().equals(source)) {
config.setCharSpacing(charSpacingSlider.getValue());
}
chat.repaint();
}
};
ActionListener fontAl = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JMenuItem source = (JMenuItem) e.getSource();
DropdownLabel key = new DropdownLabel(source.getText());
if (CUSTOM_KEY.equals(key)) {
int selectionResult = fontPngPicker.showDialog(ControlWindow.me, "Select Font PNG");
if (selectionResult == JFileChooser.APPROVE_OPTION) {
fontFilenameInput.setText(fontPngPicker.getSelectedFile().getAbsolutePath());
fontPresetDropdown.setSelectedText(fontPngPicker.getSelectedFile().getName());
}
} else {
fontFilenameInput.setText(PRESET_FONT_FILE_MAP.get(key).getFontFilename());
fontTypeCheckbox.setSelected(FontType.VARIABLE_WIDTH.equals(PRESET_FONT_FILE_MAP.get(key).getDefaultType()));
spaceWidthSlider.setEnabled(fontTypeCheckbox.isSelected());
}
updateFontOrBorder(true);
}
};
ActionListener borderAl = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JMenuItem source = (JMenuItem) e.getSource();
DropdownLabel key = new DropdownLabel(source.getText());
if (CUSTOM_KEY.equals(key)) {
int selectionResult = borderPngPicker.showDialog(ControlWindow.me, "Select Border PNG");
if (selectionResult == JFileChooser.APPROVE_OPTION) {
borderFilenameInput.setText(borderPngPicker.getSelectedFile().getAbsolutePath());
borderPresetDropdown.setSelectedText(borderPngPicker.getSelectedFile().getName());
}
} else {
DropdownBorder border = PRESET_BORDER_FILE_MAP.get(key);
borderFilenameInput.setText(border.getBorderFilename());
colorPanel.setBorderColor(border.getDefaultTint());
}
updateFontOrBorder(false);
}
};
fontTypeListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
config.setFontType(fontTypeCheckbox.isSelected() ? FontType.VARIABLE_WIDTH : FontType.FIXED_WIDTH);
spaceWidthSlider.setEnabled(fontTypeCheckbox.isSelected());
updateFontOrBorder(true);
}
};
extendedCharBox = new JCheckBox("Display Extended Characters");
extendedCharBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final boolean ecbSelected = extendedCharBox.isSelected();
config.setExtendedCharEnabled(ecbSelected);
unknownCharPopupButton.setEnabled(!ecbSelected);
unknownCharLabel.setEnabled(!ecbSelected);
chat.repaint();
}
});
unknownCharLabel = new JLabel("");
charPicker = new CharacterPicker(ControlWindow.me, fProps.getFontConfig(), unknownCharLabel, chat);
Map<String, List<String>> fontMenuMap = getMenuMapFromPresets(PRESET_FONT_FILE_MAP.keySet());
fontMenuMap.put(CUSTOM_KEY.getLabel(), null);
Map<String, List<String>> borderMenuMap = getMenuMapFromPresets(PRESET_BORDER_FILE_MAP.keySet());
borderMenuMap.put(CUSTOM_KEY.getLabel(), null);
fontTypeCheckbox = new JCheckBox("Variable Width Characters");
fontFilenameInput = new LabeledInput("Font Filename", 32);
fontPresetDropdown = new ComboMenuBar(fontMenuMap, fontAl);
borderFilenameInput = new LabeledInput("Border Filename", 32);
borderPresetDropdown = new ComboMenuBar(borderMenuMap, borderAl);
gridWidthInput = new LabeledInput("Grid Width", 4);
gridHeightInput = new LabeledInput("Grid Height", 4);
fontScaleSlider = new LabeledSlider("Font Scale", "x", ConfigFont.MIN_FONT_SCALE, ConfigFont.MAX_FONT_SCALE, ConfigFont.FONT_BORDER_SCALE_GRANULARITY);
borderScaleSlider = new LabeledSlider("Border Scale", "x", ConfigFont.MIN_BORDER_SCALE, ConfigFont.MAX_BORDER_SCALE, ConfigFont.FONT_BORDER_SCALE_GRANULARITY);
borderInsetXSlider = new LabeledSlider("X", "pixels", ConfigFont.MIN_BORDER_INSET, ConfigFont.MAX_BORDER_INSET);
borderInsetYSlider = new LabeledSlider("Y", "pixels", ConfigFont.MIN_BORDER_INSET, ConfigFont.MAX_BORDER_INSET);
characterKeyInput = new LabeledInput("Character Key", 32);
spaceWidthSlider = new LabeledSlider("Space Width", "%", ConfigFont.MIN_SPACE_WIDTH, ConfigFont.MAX_SPACE_WIDTH);
baselineOffsetSlider = new LabeledSlider("Baseline Height Offset", "pixels", ConfigFont.MIN_BASELINE_OFFSET, ConfigFont.MAX_BASELINE_OFFSET);
lineSpacingSlider = new LabeledSlider("Line Spacing", "pixels", ConfigFont.MIN_LINE_SPACING, ConfigFont.MAX_LINE_SPACING);
charSpacingSlider = new LabeledSlider("Char Spacing", "pixels", ConfigFont.MIN_CHAR_SPACING, ConfigFont.MAX_LINE_SPACING);
unknownCharPopupButton = new JButton("Select Missing Character");
unknownCharPopupButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
charPicker.setVisible(true);
}
});
fontFilenameInput.setEnabled(false);
borderFilenameInput.setEnabled(false);
fontScaleSlider.addChangeListener(sliderListener);
borderScaleSlider.addChangeListener(sliderListener);
borderInsetXSlider.addChangeListener(sliderListener);
borderInsetYSlider.addChangeListener(sliderListener);
spaceWidthSlider.addChangeListener(sliderListener);
baselineOffsetSlider.addChangeListener(sliderListener);
lineSpacingSlider.addChangeListener(sliderListener);
charSpacingSlider.addChangeListener(sliderListener);
JPanel fontPanel = new JPanel(new GridBagLayout());
JPanel borderPanel = new JPanel(new GridBagLayout());
JPanel unknownPanel = new JPanel(new GridBagLayout());
fontPanel.setBorder(new TitledBorder(baseBorder, "Font"));
borderPanel.setBorder(new TitledBorder(baseBorder, "Border"));
unknownPanel.setBorder(new TitledBorder(baseBorder, "Extended and Unicode Characters"));
GridBagConstraints fontGbc = new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, DEFAULT_INSETS, 0, 0);
GridBagConstraints borderGbc = new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, DEFAULT_INSETS, 0, 0);
GridBagConstraints unknownGbc = new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, DEFAULT_INSETS, 0, 0);
// Fields are still used and stored in properties files when saved, but the values are either fixed or meant to
// be filled by other components
// add(fontFilenameInput);
// add(borderFilenameInput);
// add(gridWidthInput);
// add(gridHeightInput);
// add(characterKeyInput);
fontPanel.add(fontPresetDropdown, fontGbc);
fontGbc.gridx++;
// This slider being on the same row as the preset dropdown keeps the combo menu bar from collapsing to no
// height in the layout
fontPanel.add(fontScaleSlider, fontGbc);
fontGbc.gridwidth = 2;
fontGbc.gridx = 0;
fontGbc.gridy++;
fontPanel.add(lineSpacingSlider, fontGbc);
fontGbc.gridy++;
fontPanel.add(charSpacingSlider, fontGbc);
fontGbc.gridy++;
JPanel variableWidthPanel = new JPanel(new GridBagLayout());
GridBagConstraints vwpGbc = getGbc();
vwpGbc.anchor = GridBagConstraints.EAST;
vwpGbc.weightx = 0.0;
vwpGbc.fill = GridBagConstraints.NONE;
variableWidthPanel.add(fontTypeCheckbox, vwpGbc);
vwpGbc.anchor = GridBagConstraints.WEST;
vwpGbc.weightx = 1.0;
vwpGbc.fill = GridBagConstraints.HORIZONTAL;
vwpGbc.gridx++;
variableWidthPanel.add(spaceWidthSlider, vwpGbc);
fontPanel.add(variableWidthPanel, fontGbc);
fontGbc.gridy++;
fontPanel.add(baselineOffsetSlider, fontGbc);
fontGbc.gridy++;
borderPanel.add(borderPresetDropdown, borderGbc);
borderGbc.gridx++;
// This slider being on the same row as the preset dropdown keeps the combo menu bar from collapsing to no
// height in the layout
borderPanel.add(borderScaleSlider, borderGbc);
borderGbc.gridwidth = 2;
borderGbc.gridx = 0;
borderGbc.gridy++;
borderGbc.anchor = GridBagConstraints.CENTER;
borderPanel.add(new JLabel("Font Insets Off Border"), borderGbc);
borderGbc.gridy++;
borderPanel.add(borderInsetXSlider, borderGbc);
borderGbc.gridy++;
borderPanel.add(borderInsetYSlider, borderGbc);
borderGbc.gridy++;
unknownPanel.add(extendedCharBox, unknownGbc);
unknownGbc.gridx++;
unknownPanel.add(unknownCharPopupButton, unknownGbc);
unknownGbc.gridx++;
unknownPanel.add(unknownCharLabel, unknownGbc);
unknownGbc.gridx++;
JPanel everything = new JPanel(new GridBagLayout());
GridBagConstraints eGbc = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, DEFAULT_INSETS, 10, 10);
everything.add(fontPanel, eGbc);
eGbc.gridy++;
everything.add(borderPanel, eGbc);
eGbc.gridy++;
everything.add(unknownPanel, eGbc);
gbc.fill = GridBagConstraints.BOTH;
gbc.anchor = GridBagConstraints.CENTER;
gbc.weightx = 1.0;
gbc.weighty = 0.0;
add(everything, gbc);
// Filler panel
gbc.gridy++;
gbc.weighty = 1.0;
gbc.anchor = GridBagConstraints.SOUTH;
add(new JPanel(), gbc);
}
use of javax.swing.border.TitledBorder in project JMRI by JMRI.
the class AddSignalMastPanel method dccUnLitPanel.
void dccUnLitPanel() {
dccUnLitPanel.setLayout(new BoxLayout(dccUnLitPanel, BoxLayout.Y_AXIS));
JPanel dccDetails = new JPanel();
dccDetails.add(new JLabel(Bundle.getMessage("DCCMastSetAspectId") + ":"));
dccDetails.add(unLitAspectField);
unLitAspectField.setText("31");
dccUnLitPanel.add(dccDetails);
TitledBorder border = BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black));
border.setTitle(Bundle.getMessage("DCCUnlitAspectNumber"));
dccUnLitPanel.setBorder(border);
unLitAspectField.addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
if (unLitAspectField.getText().equals("")) {
return;
}
if (!validateAspectId(unLitAspectField.getText())) {
unLitAspectField.requestFocusInWindow();
}
}
@Override
public void focusGained(FocusEvent e) {
}
});
}
Aggregations