📄 mainui.java
字号:
/*
* MainUI.java
*
* Created on 2007年11月30日, 下午1:07
*/
package Compressor;
import java.util.regex.*;
import java.awt.*;
import java.io.*;
import javax.swing.*;
import myUtil.*;
/**
* main interface.
* @author yuhui_bear
*/
public class MainUI extends javax.swing.JFrame {
private Pattern exNameP ;
private File neuralFile;
private File targetFile;
private JFileChooser target_fc;
private JFileChooser neural_fc;
private Diagram diagram;
private NeuralFileEncoder encoder;
private int enOrde; //0 ,NA; 1 compress,2 decompress.
private final int ENCODE =1 , DECODE =2;
private double GOAL = 0;//0.0000007812;
/**
* Creates new form MainUI
* @param title title of the frame.
*/
public MainUI(String title) {
super(title);
enOrde = 1;
exNameP = Pattern.compile("\\.nc");
initComponents();
jRadioButton1.setSelected(true);
//custom iniate component.
target_fc = new JFileChooser ();
neural_fc = new JFileChooser();
diagram = new Diagram(400,300);
Diagram_Dialog.add(diagram , BorderLayout.CENTER);
Diagram_Dialog.pack();
pack();
}
/** 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.
*/
// <editor-fold defaultstate="collapsed" desc=" 生成的代码 ">//GEN-BEGIN:initComponents
private void initComponents() {
MSG_dialog = new javax.swing.JDialog();
jButton1 = new javax.swing.JButton();
jPanel1 = new javax.swing.JPanel();
MSG_lab = new javax.swing.JLabel();
Diagram_Dialog = new javax.swing.JDialog();
jButton2 = new javax.swing.JButton();
jPanel2 = new javax.swing.JPanel();
neural_tf = new javax.swing.JTextField();
chooseNet_bt = new javax.swing.JButton();
jPanel4 = new javax.swing.JPanel();
jRadioButton2 = new javax.swing.JRadioButton();
jRadioButton1 = new javax.swing.JRadioButton();
target_tf = new javax.swing.JTextField();
chooseTarget_bt = new javax.swing.JButton();
jToggleButton1 = new javax.swing.JToggleButton();
jPanel3 = new javax.swing.JPanel();
jProgressBar1 = new javax.swing.JProgressBar();
start_bt = new javax.swing.JButton();
MSG_dialog.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
MSG_dialog.setTitle("Need parameters.");
MSG_dialog.setModal(true);
MSG_dialog.getAccessibleContext().setAccessibleParent(this);
jButton1.setText("OK");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
MSG_lab.setFont(new java.awt.Font("宋体", 1, 14));
MSG_lab.setText("1.Need to specify neural net file.");
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(MSG_lab)
.addContainerGap(28, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(21, 21, 21)
.addComponent(MSG_lab)
.addContainerGap(22, Short.MAX_VALUE))
);
javax.swing.GroupLayout MSG_dialogLayout = new javax.swing.GroupLayout(MSG_dialog.getContentPane());
MSG_dialog.getContentPane().setLayout(MSG_dialogLayout);
MSG_dialogLayout.setHorizontalGroup(
MSG_dialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(MSG_dialogLayout.createSequentialGroup()
.addGap(119, 119, 119)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE))
);
MSG_dialogLayout.setVerticalGroup(
MSG_dialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(MSG_dialogLayout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton1)
.addGap(15, 15, 15))
);
Diagram_Dialog.setModal(true);
Diagram_Dialog.getAccessibleContext().setAccessibleParent(this);
jButton2.setText("Stop & Output");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
Diagram_Dialog.getContentPane().add(jButton2, java.awt.BorderLayout.SOUTH);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("NN Compressor");
setResizable(false);
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Choose Trained Neural Net"));
neural_tf.setColumns(15);
neural_tf.setEditable(false);
neural_tf.setText("jTextField1");
chooseNet_bt.setText("...");
chooseNet_bt.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
chooseNet_btActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addComponent(neural_tf, javax.swing.GroupLayout.PREFERRED_SIZE, 246, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(chooseNet_bt))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(neural_tf, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(chooseNet_bt))
);
jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Choose file "));
jRadioButton2.setText("Decode");
jRadioButton2.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
jRadioButton2.setMargin(new java.awt.Insets(0, 0, 0, 0));
jRadioButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton2ActionPerformed(evt);
}
});
jRadioButton1.setText("Encode");
jRadioButton1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
jRadioButton1.setMargin(new java.awt.Insets(0, 0, 0, 0));
jRadioButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton1ActionPerformed(evt);
}
});
target_tf.setColumns(15);
target_tf.setEditable(false);
target_tf.setText("jTextField2");
chooseTarget_bt.setText("...");
chooseTarget_bt.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
chooseTarget_btActionPerformed(evt);
}
});
jToggleButton1.setText("Graph");
jToggleButton1.setMargin(new java.awt.Insets(2, 5, 2, 5));
jToggleButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jToggleButton1ActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addComponent(target_tf, javax.swing.GroupLayout.PREFERRED_SIZE, 245, javax.swing.GroupLayout.PREFERRED_SIZE)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -