/*
* The MIT License
*
* Copyright 2015 Jaafar EL Bakkali.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package ersn.openmc;
import static ersn.openmc.ERSNOpenMC_Table_of_nuclides.Crimson;
import java.awt.Color;
import jsyntaxpane.DefaultSyntaxKit;
import jsyntaxpane.util.Configuration;
/**
*
* @author elbakkali
*/
public class ERSNOpenMC_RGB_COLOR extends javax.swing.JFrame {
final static String DarkGreen="0x006400";
final static String DarkBlue ="0x00008B";
final static String Crimson="0xDC143C";
final static String SlateGray="0x708090";
final static String Salmon="0xFA8072";
int r = 0;
int g = 0;
int b = 0;
/**
* Creates new form about
*/
public ERSNOpenMC_RGB_COLOR() {
initComponents();
getContentPane().setBackground(new Color(0, 0, 128));
}
/**
* 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() {
jToolBar1 = new javax.swing.JToolBar();
btn_insert = new javax.swing.JButton();
panel = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
sred = new javax.swing.JSlider();
vred = new javax.swing.JTextField();
vgreen = new javax.swing.JTextField();
sgreen = new javax.swing.JSlider();
jLabel2 = new javax.swing.JLabel();
vblue = new javax.swing.JTextField();
sblue = new javax.swing.JSlider();
jLabel3 = new javax.swing.JLabel();
jSeparator1 = new javax.swing.JSeparator();
jScrollPane1 = new javax.swing.JScrollPane();
Target = new javax.swing.JEditorPane();
btn_close1 = new javax.swing.JButton();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jToolBar1.setRollover(true);
setTitle("ERSN-OpenMC_RGB_COLOR");
setBackground(java.awt.SystemColor.activeCaptionText);
setResizable(false);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowActivated(java.awt.event.WindowEvent evt) {
formWindowActivated(evt);
}
});
btn_insert.setFont(new java.awt.Font("Ubuntu", 0, 13)); // NOI18N
btn_insert.setText("generate code");
btn_insert.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn_insertActionPerformed(evt);
}
});
panel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
panel.setLayout(new java.awt.GridBagLayout());
jLabel1.setForeground(java.awt.Color.red);
jLabel1.setText("Red");
sred.setForeground(java.awt.Color.red);
sred.setMaximum(255);
sred.setValue(100);
sred.addMouseWheelListener(new java.awt.event.MouseWheelListener() {
public void mouseWheelMoved(java.awt.event.MouseWheelEvent evt) {
sredMouseWheelMoved(evt);
}
});
sred.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
sredStateChanged(evt);
}
});
vred.setBackground(java.awt.Color.red);
vred.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
vredActionPerformed(evt);
}
});
vgreen.setBackground(java.awt.Color.green);
sgreen.setForeground(new java.awt.Color(57, 191, 57));
sgreen.setMaximum(255);
sgreen.setValue(100);
sgreen.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
sgreenStateChanged(evt);
}
});
jLabel2.setForeground(new java.awt.Color(40, 195, 40));
jLabel2.setText("Green");
vblue.setBackground(new java.awt.Color(0, 92, 255));
vblue.setForeground(new java.awt.Color(255, 255, 255));
sblue.setForeground(java.awt.Color.blue);
sblue.setMaximum(255);
sblue.setValue(100);
sblue.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
sblueStateChanged(evt);
}
});
jLabel3.setForeground(java.awt.Color.blue);
jLabel3.setText("Blue");
Target.setPreferredSize(new java.awt.Dimension(60, 23));
jScrollPane1.setViewportView(Target);
btn_close1.setText("close");
btn_close1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn_close1ActionPerformed(evt);
}
});
jLabel4.setForeground(java.awt.Color.white);
jLabel4.setText("Copy and paste the generated line into plot.xml file");
jLabel5.setForeground(java.awt.Color.white);
jLabel5.setText("if plot_slice element has been chosen (Id must be entered).");
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.TRAILING)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 405, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 417, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(23, 23, 23)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(panel, javax.swing.GroupLayout.PREFERRED_SIZE, 207, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(jLabel2)
.addComponent(jLabel3))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(sblue, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(sgreen, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(sred, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
.addGap(35, 35, 35)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(vgreen, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(vblue, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(35, 35, 35))
.addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, 426, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(jScrollPane1)
.addContainerGap())
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(vred, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(33, 33, 33))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(btn_close1, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(36, 36, 36))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(btn_insert, javax.swing.GroupLayout.PREFERRED_SIZE, 162, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(130, 130, 130))))))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(panel, javax.swing.GroupLayout.PREFERRED_SIZE, 182, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(sred, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(vred, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(35, 35, 35)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2)
.addComponent(sgreen, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(vgreen, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(35, 35, 35)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3)
.addComponent(sblue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(vblue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(47, 47, 47)
.addComponent(btn_insert)
.addGap(6, 6, 6)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, 0)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel4)
.addGap(8, 8, 8)
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btn_close1)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
setSize(new java.awt.Dimension(448, 704));
setLocationRelativeTo(null);
}// </editor-fold>//GEN-END:initComponents
private void btn_insertActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_insertActionPerformed
// TODO add your handling code here:
Target.setText("<col_spec id=\"\" rgb=\""+r+" "+g+" "+b+" "+"\"> </col_spec> ");
}//GEN-LAST:event_btn_insertActionPerformed
private void formWindowActivated(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowActivated
Configuration config = DefaultSyntaxKit.getConfig(DefaultSyntaxKit.class);
config.put("Style.KEYWORD2",Crimson+",0");
config.put("Style.KEYWORD",DarkGreen+",3");
config.put("Style.STRING",DarkBlue+", 3");
config.put("Style.STRING2",DarkBlue+",0");
config.put("Style.IDENTIFIER",Crimson+", 0");
config.put("Style.TYPE2",SlateGray+", 3");
config.put("Style.COMMENT2",Salmon+", 3");
config.put("Style.COMMENT",Salmon+", 3");
config.put("LineNumbers.Foreground"," 0x009933, 3");
Target.setContentType("text/xhtml");
r = sred.getValue();
g = sgreen.getValue();
b = sblue.getValue();
Color colour = new Color(r,g,b);
panel.setBackground(colour);
vred.setText(""+r);
vgreen.setText(""+g);
vblue.setText(""+b);
}//GEN-LAST:event_formWindowActivated
private void btn_close1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_close1ActionPerformed
this.show(false);
}//GEN-LAST:event_btn_close1ActionPerformed
private void vredActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_vredActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_vredActionPerformed
private void sblueStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_sblueStateChanged
r= sred.getValue();
g = sgreen.getValue();
b = sblue.getValue();
Color colour = new Color(r,g,b);
panel.setBackground(colour);
vred.setText(""+r);
vgreen.setText(""+g);
vblue.setText(""+b);
}//GEN-LAST:event_sblueStateChanged
private void sgreenStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_sgreenStateChanged
r = sred.getValue();
g = sgreen.getValue();
b = sblue.getValue();
Color colour = new Color(r,g,b);
panel.setBackground(colour);
vred.setText(""+r);
vgreen.setText(""+g);
vblue.setText(""+b);
}//GEN-LAST:event_sgreenStateChanged
private void sredStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_sredStateChanged
int r = sred.getValue();
int g = sgreen.getValue();
int b = sblue.getValue();
Color colour = new Color(r,g,b);
panel.setBackground(colour);
vred.setText(""+r);
vgreen.setText(""+g);
vblue.setText(""+b);
}//GEN-LAST:event_sredStateChanged
private void sredMouseWheelMoved(java.awt.event.MouseWheelEvent evt) {//GEN-FIRST:event_sredMouseWheelMoved
r = sred.getValue();
g = sgreen.getValue();
b = sblue.getValue();
Color colour = new Color(r,g,b);
panel.setBackground(colour);
}//GEN-LAST:event_sredMouseWheelMoved
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(ERSNOpenMC_RGB_COLOR.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(ERSNOpenMC_RGB_COLOR.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(ERSNOpenMC_RGB_COLOR.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(ERSNOpenMC_RGB_COLOR.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
//</editor-fold>
//</editor-fold>
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new ERSNOpenMC_RGB_COLOR().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JEditorPane Target;
private javax.swing.JButton btn_close1;
private javax.swing.JButton btn_insert;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JToolBar jToolBar1;
private javax.swing.JPanel panel;
private javax.swing.JSlider sblue;
private javax.swing.JSlider sgreen;
private javax.swing.JSlider sred;
private javax.swing.JTextField vblue;
private javax.swing.JTextField vgreen;
private javax.swing.JTextField vred;
// End of variables declaration//GEN-END:variables
}