Search in sources :

Example 1 with ColorButton

use of com.glitchcog.fontificator.gui.component.ColorButton 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++;
}
Also used : JCheckBox(javax.swing.JCheckBox) Palette(com.glitchcog.fontificator.gui.component.palette.Palette) JPanel(javax.swing.JPanel) GridLayout(java.awt.GridLayout) GridBagConstraints(java.awt.GridBagConstraints) ActionListener(java.awt.event.ActionListener) ColorButton(com.glitchcog.fontificator.gui.component.ColorButton) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) TitledBorder(javax.swing.border.TitledBorder)

Example 2 with ColorButton

use of com.glitchcog.fontificator.gui.component.ColorButton in project ChatGameFontificator by GlitchCog.

the class ControlPanelDebug method build.

@Override
protected void build() {
    postTestMessage = new JButton("Post Debug Message");
    postTestMessage.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            ctrlWindow.addManualMessage("Test", SpriteFont.NORMAL_ASCII_KEY);
        }
    });
    postMessagesButton = new JToggleButton("Post Messages");
    postRateSlider = new LabeledSlider("Post Rate ", " / min", 1, 120, 15, 3);
    postClock = new Timer(60000 / postRateSlider.getValue(), new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            postRandomMessage();
        }
    });
    postRateSlider.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            if (!((JSlider) e.getSource()).getValueIsAdjusting()) {
                postClock.setDelay(60000 / postRateSlider.getValue());
                if (postClock.isRunning()) {
                    postRandomMessage();
                    postClock.restart();
                }
            }
        }
    });
    postMessagesButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            postRandomMessage();
            if (postMessagesButton.isSelected()) {
                postClock.start();
            } else {
                postClock.stop();
            }
        }
    });
    drawTextGridBox = new JCheckBox("Draw Text Grid");
    textGridColorButton = new ColorButton("Text Grid Color", new Color(0x99FF88), "Color of the border grid", this);
    drawBorderGridBox = new JCheckBox("Draw Border Grid");
    borderGridColorButton = new ColorButton("Border Grid Color", new Color(0x9988FF), "Color of the border grid", this);
    ActionListener refreshListener = new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (chat != null) {
                chat.repaint();
            }
        }
    };
    drawTextGridBox.addActionListener(refreshListener);
    drawBorderGridBox.addActionListener(refreshListener);
    JPanel topPanel = new JPanel(new GridBagLayout());
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.fill = GridBagConstraints.NONE;
    topPanel.add(postTestMessage, gbc);
    gbc.gridx++;
    topPanel.add(postMessagesButton, gbc);
    gbc.gridx++;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    topPanel.add(postRateSlider, gbc);
    gbc.gridwidth = 4;
    gbc.gridx = 0;
    gbc.gridy = 0;
    add(topPanel, gbc);
    gbc.gridy++;
    gbc.gridwidth = 1;
    gbc.weightx = 0.5;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    add(drawTextGridBox, gbc);
    gbc.gridx++;
    add(textGridColorButton, gbc);
    gbc.gridx++;
    add(drawBorderGridBox, gbc);
    gbc.gridx++;
    add(borderGridColorButton, gbc);
    gbc.gridy++;
    gbc.gridx = 0;
    gbc.gridwidth = 4;
    gbc.weighty = 0.1;
    CollagePanel collagePanel = new CollagePanel(chat);
    add(collagePanel, gbc);
    gbc.gridy++;
    gbc.weightx = 1.0;
    gbc.weighty = 0.9;
    gbc.anchor = GridBagConstraints.SOUTH;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridwidth = 4;
    add(logBox, gbc);
}
Also used : JPanel(javax.swing.JPanel) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) Color(java.awt.Color) JButton(javax.swing.JButton) JCheckBox(javax.swing.JCheckBox) LabeledSlider(com.glitchcog.fontificator.gui.component.LabeledSlider) ActionListener(java.awt.event.ActionListener) JToggleButton(javax.swing.JToggleButton) Timer(javax.swing.Timer) ChangeEvent(javax.swing.event.ChangeEvent) ColorButton(com.glitchcog.fontificator.gui.component.ColorButton) JSlider(javax.swing.JSlider) ChangeListener(javax.swing.event.ChangeListener)

Aggregations

ColorButton (com.glitchcog.fontificator.gui.component.ColorButton)2 GridBagLayout (java.awt.GridBagLayout)2 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 JCheckBox (javax.swing.JCheckBox)2 JPanel (javax.swing.JPanel)2 LabeledSlider (com.glitchcog.fontificator.gui.component.LabeledSlider)1 Palette (com.glitchcog.fontificator.gui.component.palette.Palette)1 Color (java.awt.Color)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridLayout (java.awt.GridLayout)1 JButton (javax.swing.JButton)1 JSlider (javax.swing.JSlider)1 JToggleButton (javax.swing.JToggleButton)1 Timer (javax.swing.Timer)1 TitledBorder (javax.swing.border.TitledBorder)1 ChangeEvent (javax.swing.event.ChangeEvent)1 ChangeListener (javax.swing.event.ChangeListener)1