/*
* Copyright (C) 2012 Gyver
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.gyver.matrixmover.gui.generator;
import com.gyver.matrixmover.generator.Textwriter;
import com.gyver.matrixmover.generator.enums.ScrollMode;
import com.gyver.matrixmover.generator.enums.TextwriterScrollMode;
import com.gyver.matrixmover.gui.Frame;
import com.gyver.matrixmover.gui.ColorMapDialog;
import com.gyver.matrixmover.gui.component.JTextFieldSlider;
import com.gyver.matrixmover.gui.listener.interfaces.TFSListener;
import java.awt.Font;
import javax.swing.DefaultComboBoxModel;
import javax.swing.event.ChangeEvent;
import say.swing.JFontChooser;
/**
* Configuration dialog for Textwriter generator
*
* @author Gyver
*/
public class TextwriterConfiguration extends javax.swing.JDialog {
private Textwriter generator = null;
/** Creates new form ColorTableDialog */
public TextwriterConfiguration(java.awt.Frame parent, boolean modal, Textwriter generator) {
super(parent, modal);
this.setTitle(generator.getName().toString() + " Configuration");
this.generator = generator;
initComponents();
tfsOffset.setValue(generator.getyOffset());
tfsSpeed.setValue(generator.getSpeed());
cbAntialias.setSelected(generator.isAntialiasing());
cbScrollMode.setModel(new DefaultComboBoxModel(ScrollMode.values()));
cbScrollMode.setSelectedItem(generator.getMode());
tfsOffset.addTFSListener(new TFSListener() {
@Override
public void stateChanged(ChangeEvent e) {
tpsOffsetStateChanged(e);
}
});
tfsSpeed.addTFSListener(new TFSListener() {
@Override
public void stateChanged(ChangeEvent e) {
tpsSpeedStateChanged(e);
}
});
setLocationRelativeTo(null);
}
private void tpsOffsetStateChanged(ChangeEvent e) {
int offset = ((JTextFieldSlider) e.getSource()).getValue();
generator.setyOffset(offset);
}
private void tpsSpeedStateChanged(ChangeEvent e) {
int speed = ((JTextFieldSlider) e.getSource()).getValue();
generator.setSpeed(speed);
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
bChangeFont = new javax.swing.JButton();
bSaveExit = new javax.swing.JButton();
tfsSpeed = new com.gyver.matrixmover.gui.component.JTextFieldSlider();
tfsOffset = new com.gyver.matrixmover.gui.component.JTextFieldSlider();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
tfText = new javax.swing.JTextField();
cbScrollMode = new javax.swing.JComboBox();
cbAntialias = new javax.swing.JCheckBox();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
getContentPane().setLayout(new java.awt.GridBagLayout());
bChangeFont.setText("Change Font");
bChangeFont.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bChangeFontActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridwidth = 2;
gridBagConstraints.ipadx = 50;
gridBagConstraints.anchor = java.awt.GridBagConstraints.FIRST_LINE_START;
gridBagConstraints.insets = new java.awt.Insets(10, 10, 5, 5);
getContentPane().add(bChangeFont, gridBagConstraints);
bSaveExit.setText("Save + Exit");
bSaveExit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bSaveExitActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 5;
gridBagConstraints.gridwidth = 3;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LAST_LINE_END;
gridBagConstraints.insets = new java.awt.Insets(5, 0, 10, 10);
getContentPane().add(bSaveExit, gridBagConstraints);
tfsSpeed.setMaximum(6000);
tfsSpeed.setMinimum(1);
tfsSpeed.setValue(120);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 3;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.weightx = 0.1;
gridBagConstraints.insets = new java.awt.Insets(5, 0, 5, 10);
getContentPane().add(tfsSpeed, gridBagConstraints);
tfsOffset.setMaximum(50);
tfsOffset.setMinimum(-50);
tfsOffset.setValue(0);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 4;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.weightx = 0.1;
gridBagConstraints.insets = new java.awt.Insets(5, 0, 5, 10);
getContentPane().add(tfsOffset, gridBagConstraints);
jLabel1.setText("Speed:");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 3;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
gridBagConstraints.insets = new java.awt.Insets(5, 10, 5, 5);
getContentPane().add(jLabel1, gridBagConstraints);
jLabel2.setText("Height Offset:");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 4;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 5);
getContentPane().add(jLabel2, gridBagConstraints);
jLabel3.setText("Scroll Mode:");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
gridBagConstraints.insets = new java.awt.Insets(5, 10, 5, 5);
getContentPane().add(jLabel3, gridBagConstraints);
jLabel4.setText("Text:");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
gridBagConstraints.insets = new java.awt.Insets(5, 10, 5, 5);
getContentPane().add(jLabel4, gridBagConstraints);
tfText.setText("jTextField1");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 2;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(5, 0, 5, 10);
getContentPane().add(tfText, gridBagConstraints);
cbScrollMode.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
cbScrollMode.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbScrollModeActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 1;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.ipadx = 150;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
gridBagConstraints.insets = new java.awt.Insets(5, 0, 5, 15);
getContentPane().add(cbScrollMode, gridBagConstraints);
cbAntialias.setText("Antialias");
cbAntialias.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbAntialiasActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
gridBagConstraints.insets = new java.awt.Insets(10, 10, 5, 5);
getContentPane().add(cbAntialias, gridBagConstraints);
pack();
}// </editor-fold>//GEN-END:initComponents
private void cbScrollModeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbScrollModeActionPerformed
generator.setMode((TextwriterScrollMode) cbScrollMode.getSelectedItem());
}//GEN-LAST:event_cbScrollModeActionPerformed
private void bChangeFontActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bChangeFontActionPerformed
Font currentFont = generator.getFont();
JFontChooser fchooser = new JFontChooser();
fchooser.setSelectedFont(currentFont);
int option = fchooser.showDialog(this);
if (option == JFontChooser.OK_OPTION) {
Font font = fchooser.getSelectedFont();
generator.setFont(font);
}
}//GEN-LAST:event_bChangeFontActionPerformed
private void bSaveExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bSaveExitActionPerformed
this.dispose();
}//GEN-LAST:event_bSaveExitActionPerformed
private void cbAntialiasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbAntialiasActionPerformed
generator.setAntialiasing(cbAntialias.isSelected());
}//GEN-LAST:event_cbAntialiasActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton bChangeFont;
private javax.swing.JButton bSaveExit;
private javax.swing.JCheckBox cbAntialias;
private javax.swing.JComboBox cbScrollMode;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JTextField tfText;
private com.gyver.matrixmover.gui.component.JTextFieldSlider tfsOffset;
private com.gyver.matrixmover.gui.component.JTextFieldSlider tfsSpeed;
// End of variables declaration//GEN-END:variables
}