/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* BasicPreferences.java
*
* Created on Jun 20, 2011, 11:16:41 AM
*/
package org.clothocad.tool.sequenceview;
import java.awt.Color;
import javax.swing.JPanel;
import javax.swing.colorchooser.AbstractColorChooserPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
/**
*
* @author Henry
*/
public class BasicPreferences extends javax.swing.JFrame implements ChangeListener {
/** Creates new form BasicPreferences */
public BasicPreferences() {
initComponents();
}
public BasicPreferences(SequenceView sv) {
_sv = sv;
this.selectedUserHighlightColor = _sv.getUserHighlightColor();
this.selectedORFHighlightColor = _sv.getORFColor();
initComponents();
jColorChooser1.getSelectionModel().addChangeListener(this);
jColorChooser1.setPreviewPanel(new JPanel());
AbstractColorChooserPanel[] cc = jColorChooser1.getChooserPanels();
for (int i = 1; i < cc.length; i++) {
jColorChooser1.removeChooserPanel(cc[i]);
}
this.setSize(450, 330);
selectedColorPanel.setBackground(jColorChooser1.getColor());
selectedColorPanel.setVisible(true);
if (_sv.getMagicHighlight()) {
yesRadioButton.setSelected(true);
noRadioButton.setSelected(false);
} else {
yesRadioButton.setSelected(false);
noRadioButton.setSelected(true);
}
turnOnMagicHighlight = false;
}
/** 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() {
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
userHighlightColorLabel = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
changeUserHighlightsButton = new javax.swing.JButton();
changeORFHighlightsButton = new javax.swing.JButton();
saveButton = new javax.swing.JButton();
cancelButton = new javax.swing.JButton();
jColorChooser1 = new javax.swing.JColorChooser();
selectedColorPanel = new javax.swing.JPanel();
jLabel3 = new javax.swing.JLabel();
yesRadioButton = new javax.swing.JRadioButton();
noRadioButton = new javax.swing.JRadioButton();
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle(org.openide.util.NbBundle.getMessage(BasicPreferences.class, "BasicPreferences.title")); // NOI18N
setName("BasicPreferencesFrame"); // NOI18N
jLabel1.setText(org.openide.util.NbBundle.getMessage(BasicPreferences.class, "BasicPreferences.jLabel1.text")); // NOI18N
jLabel2.setText(org.openide.util.NbBundle.getMessage(BasicPreferences.class, "BasicPreferences.jLabel2.text")); // NOI18N
userHighlightColorLabel.setBackground(selectedUserHighlightColor);
userHighlightColorLabel.setText(org.openide.util.NbBundle.getMessage(BasicPreferences.class, "BasicPreferences.userHighlightColorLabel.text")); // NOI18N
userHighlightColorLabel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
userHighlightColorLabel.setMaximumSize(new java.awt.Dimension(20, 20));
userHighlightColorLabel.setMinimumSize(new java.awt.Dimension(20, 20));
userHighlightColorLabel.setOpaque(true);
userHighlightColorLabel.setPreferredSize(new java.awt.Dimension(20, 20));
userHighlightColorLabel.setRequestFocusEnabled(false);
jLabel4.setBackground(selectedORFHighlightColor);
jLabel4.setText(org.openide.util.NbBundle.getMessage(BasicPreferences.class, "BasicPreferences.jLabel4.text")); // NOI18N
jLabel4.setBorder(javax.swing.BorderFactory.createEtchedBorder());
jLabel4.setMaximumSize(new java.awt.Dimension(20, 20));
jLabel4.setMinimumSize(new java.awt.Dimension(20, 20));
jLabel4.setOpaque(true);
jLabel4.setPreferredSize(new java.awt.Dimension(20, 20));
changeUserHighlightsButton.setText(org.openide.util.NbBundle.getMessage(BasicPreferences.class, "BasicPreferences.changeUserHighlightsButton.text")); // NOI18N
changeUserHighlightsButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
changeUserHighlightsButtonActionPerformed(evt);
}
});
changeORFHighlightsButton.setText(org.openide.util.NbBundle.getMessage(BasicPreferences.class, "BasicPreferences.changeORFHighlightsButton.text")); // NOI18N
changeORFHighlightsButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
changeORFHighlightsButtonActionPerformed(evt);
}
});
saveButton.setText(org.openide.util.NbBundle.getMessage(BasicPreferences.class, "BasicPreferences.saveButton.text")); // NOI18N
saveButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
saveButtonActionPerformed(evt);
}
});
cancelButton.setText(org.openide.util.NbBundle.getMessage(BasicPreferences.class, "BasicPreferences.cancelButton.text")); // NOI18N
cancelButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancelButtonActionPerformed(evt);
}
});
jColorChooser1.setMinimumSize(new java.awt.Dimension(330, 200));
jColorChooser1.setPreferredSize(new java.awt.Dimension(330, 200));
selectedColorPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
selectedColorPanel.setMaximumSize(new java.awt.Dimension(80, 80));
selectedColorPanel.setMinimumSize(new java.awt.Dimension(80, 80));
javax.swing.GroupLayout selectedColorPanelLayout = new javax.swing.GroupLayout(selectedColorPanel);
selectedColorPanel.setLayout(selectedColorPanelLayout);
selectedColorPanelLayout.setHorizontalGroup(
selectedColorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 55, Short.MAX_VALUE)
);
selectedColorPanelLayout.setVerticalGroup(
selectedColorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 53, Short.MAX_VALUE)
);
jLabel3.setText(org.openide.util.NbBundle.getMessage(BasicPreferences.class, "BasicPreferences.jLabel3.text")); // NOI18N
yesRadioButton.setText(org.openide.util.NbBundle.getMessage(BasicPreferences.class, "BasicPreferences.yesRadioButton.text")); // NOI18N
yesRadioButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
yesRadioButtonActionPerformed(evt);
}
});
noRadioButton.setText(org.openide.util.NbBundle.getMessage(BasicPreferences.class, "BasicPreferences.noRadioButton.text")); // NOI18N
noRadioButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
noRadioButtonActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(userHighlightColorLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(changeUserHighlightsButton)
.addComponent(changeORFHighlightsButton))
.addGap(27, 27, 27)
.addComponent(selectedColorPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(yesRadioButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(noRadioButton))))
.addComponent(jColorChooser1, javax.swing.GroupLayout.PREFERRED_SIZE, 423, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(saveButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cancelButton)))
.addContainerGap(20, Short.MAX_VALUE))
);
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {changeORFHighlightsButton, changeUserHighlightsButton});
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel4, userHighlightColorLabel});
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1, jLabel2});
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(userHighlightColorLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(selectedColorPanel, javax.swing.GroupLayout.Alignment.LEADING, 0, 57, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(changeUserHighlightsButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(changeORFHighlightsButton))))
.addGap(49, 49, 49)
.addComponent(jColorChooser1, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cancelButton)
.addComponent(saveButton))
.addGap(105, 105, 105))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(yesRadioButton)
.addComponent(noRadioButton))
.addGap(279, 279, 279))))
);
layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {changeORFHighlightsButton, changeUserHighlightsButton});
layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jLabel4, userHighlightColorLabel});
layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jLabel1, jLabel2});
pack();
}// </editor-fold>//GEN-END:initComponents
private void changeORFHighlightsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_changeORFHighlightsButtonActionPerformed
selectedORFHighlightColor = jColorChooser1.getColor();
jLabel4.setBackground(selectedORFHighlightColor);
jLabel4.repaint();
}//GEN-LAST:event_changeORFHighlightsButtonActionPerformed
private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
this.dispose();
}//GEN-LAST:event_cancelButtonActionPerformed
private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveButtonActionPerformed
_sv.changeORFColor(selectedORFHighlightColor);
_sv.changeUserHighlightColor(selectedUserHighlightColor);
if(turnOnMagicHighlight) {
_sv.setMagicHighlight(turnOnMagicHighlight);
}
this.dispose();
}//GEN-LAST:event_saveButtonActionPerformed
private void changeUserHighlightsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_changeUserHighlightsButtonActionPerformed
selectedUserHighlightColor = jColorChooser1.getColor();
userHighlightColorLabel.setBackground(selectedUserHighlightColor);
userHighlightColorLabel.repaint();
}//GEN-LAST:event_changeUserHighlightsButtonActionPerformed
private void yesRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_yesRadioButtonActionPerformed
yesRadioButton.setSelected(true);
noRadioButton.setSelected(false);
turnOnMagicHighlight = true;
}//GEN-LAST:event_yesRadioButtonActionPerformed
private void noRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_noRadioButtonActionPerformed
yesRadioButton.setSelected(false);
noRadioButton.setSelected(true);
turnOnMagicHighlight = false;
}//GEN-LAST:event_noRadioButtonActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new BasicPreferences().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton cancelButton;
private javax.swing.JButton changeORFHighlightsButton;
private javax.swing.JButton changeUserHighlightsButton;
private javax.swing.JColorChooser jColorChooser1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JPanel jPanel1;
private javax.swing.JRadioButton noRadioButton;
private javax.swing.JButton saveButton;
private javax.swing.JPanel selectedColorPanel;
private javax.swing.JLabel userHighlightColorLabel;
private javax.swing.JRadioButton yesRadioButton;
// End of variables declaration//GEN-END:variables
private SequenceView _sv;
private Color selectedUserHighlightColor;
private Color selectedORFHighlightColor;
private boolean turnOnMagicHighlight;
@Override
public void stateChanged(ChangeEvent e) {
selectedColorPanel.setBackground(jColorChooser1.getColor());
selectedColorPanel.repaint();
;
}
}