1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
|
package inVivo;
import java.awt.*;
import javax.swing.*;
import java.awt.image.*;
public class VelocityView extends JFrame
{
private Velocity graphVel;
private JPanel jPanel = null;
private JLabel jLabel = null;
private JLabel jLabel2 = null;
private JLabel jLabel3 = null;
private JButton jButton2 = null;
private TextField jTextField1 = null;
private Image img;
private Image img2;
private Image img3;
int width,height;
double[][] totalPixels;
int[] total;
public VelocityView (Velocity velocity,int w,int h,double[][] pixels)
{
width = w;
height = h;
graphVel = velocity;
totalPixels = pixels;
total = graphVel.pixel(w,h,pixels);
initialize();
}
private void initialize() {
setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/inVivo/logo.gif")));
setName("JFrame3");
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setBounds(20, 25, width*2+600, height+100);
setTitle("Velocity");
getContentPane().add(getJPanel());
img3 = graphVel.graphVelocity(width,height,totalPixels);
}
private JPanel getJPanel()
{
if (jPanel == null)
{
jPanel = new JPanel();
jPanel.setLayout(null);
jPanel.add(getJLabel());
jPanel.add(getJLabel2());
jPanel.add(getJLabel3());
jPanel.add(getTextField1());
jPanel.add(getJButton2());
}
return jPanel;
}
private JButton getJButton2()
{
if (jButton2 == null)
{
jButton2 = new JButton();
jButton2.setPreferredSize(new java.awt.Dimension(20,20));
jButton2.setBounds(300,500,50,50);
jButton2.setIcon(new ImageIcon(getClass().getResource("/inVivo/ouvrirdossier.png")));
jButton2.setToolTipText("Open and rectify (rectify + save) stk images contains in directory");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
System.out.print("COUCOU");
}
});
}
return jButton2;
}
private JLabel getJLabel()
{
if (jLabel == null)
{
Toolkit tk = Toolkit.getDefaultToolkit();
img = tk.createImage(new MemoryImageSource(width,height,total,0,width));
jLabel = new JLabel(new ImageIcon(img));
}
return jLabel;
}
private JLabel getJLabel2()
{
if (jLabel2 == null)
{
Toolkit tk = Toolkit.getDefaultToolkit();
img2 = tk.createImage(new MemoryImageSource(width,height,total,0,width));
jLabel2 = new JLabel(new ImageIcon(img));
}
return jLabel2;
}
private JLabel getJLabel3()
{
if (jLabel3 == null)
{
jLabel3 = new JLabel("colonne début : ");
jLabel3.setBounds(200,400,100,20);
}
return jLabel3;
}
private TextField getTextField1()
{
if (jTextField1 == null)
{
jTextField1 = new TextField(20);
jTextField1.setBounds(350,400,100,20);
}
return jTextField1;
}
public void paint(Graphics g)
{
g.drawImage(img,20,50,this);
g.drawImage(img2,600+width-20,50,this);
g.drawImage(img3,50+width-20,50,this);
}
} |
Partager