00001
00049
00050
00051
00052 import java.lang.*;
00053
00054 import java.awt.*;
00055 import java.awt.event.*;
00056 import java.io.*;
00057 import java.awt.image.*;
00058 import java.text.*;
00059
00060 import javax.swing.*;
00061 import javax.swing.event.*;
00062 import javax.swing.border.*;
00063
00064
00065 public class ITS_Graph3 {
00066
00067
00068 private int nb_TimelessClass;
00069
00070 private int nb_images;
00071
00072 private int nb_nodes;
00073
00074 private int nb_dim;
00075
00076 private static int dimx=100;
00077
00078 private static int dimy=100;
00079
00080 private int[] displayClass;
00081
00082
00083 private ImageIcon icon;
00084 private ImageIcon icon2MT;
00085 private ImageIcon iconClass;
00086 private ImageIcon iconClass2MT;
00087 private ImageIcon iconClassTL;
00088 private ImageIcon iconClassTL2MT;
00089
00090 private int currentTime = 1;
00091 private JLabel imageLabel;private JLabel imageLabel2MT;
00092 private JLabel classLabel; private JLabel classLabel2MT;
00093 private JLabel classLabelTL;private JLabel classLabelTL2MT;
00094 private JLabel graphLabel;
00095 private JButton button1;
00096 private JButton button2;
00097 private JButton button4;
00098 private JButton button5;
00099 private JButton buttonSB;
00100 private JButton buttonSB2;
00101 private JButton buttonSB3;
00102 private JButton buttonSB5;
00103 private JButton buttonClassA;private JButton buttonClassB;
00104 private JButton button3;
00105 private JLabel label;
00106 private JLabel label3;
00107 private JLabel label4;
00108 private Image im;
00109 private JLabel mouseCoordinates;
00110
00111
00112 private CoordinateArea imCoordinateArea;
00113 private CoordinateArea classfileArea;
00114 private CoordinateArea imCoordinateArea2MT;
00115 private CoordinateArea classfileArea2MT;
00116 private CoordinateArea graphCoordinateArea;
00117 private CoordinateArea dynaClassCoordinateArea;
00118 private CoordinateArea LinksCoordinateArea;
00119 private JPanel buttonArea;
00120 private JPanel buttonArea2;
00121 private JPanel buttonArea3;
00122 private JPanel buttonArea4;
00123
00124 private TimeNodes[] timeNodes;
00125 private float[][] MI;
00126 private float [] cardMT;
00127
00128 private TimeDelay irregularT;
00129 private Dates dates;
00130 private int sizeIm = 200;
00131 private int ofx = 5;
00132 private int ofy = 0;
00133 private int dx = 970;
00134 private int dy = 285;
00135 private int maxValue = 300;
00136 private int minValue =00;
00137 private int displayDim=2;
00138 private float SeuilDiv=5;
00139 private float SeuilFlow=50;
00140 private double[] zoom;
00141 private int [] barHeigh;
00142
00143
00144 private static DecimalFormat form2;
00145 private SBList sBList;
00146 private int indexList=0;
00147 private double INF=1e10;
00148
00149 private static String labelPrefix = "Sample:";
00150
00151 private static String IMAGEPATH = "../../data/";
00152
00153 private static String CLASSFILEPATH_MT = "../../data/MT.cl";
00154
00155 private static String CLASSFILEPATH_TL = "../../data/";
00156
00157 private void readGraphDataV2() {
00158
00159 String path= "../../data/grapheV2JAVA";
00160 String ligne = null;
00161 String[] value = null;
00162 int l=0;
00163 int indexNode;int indexNodePre;
00164 int divOrFlow=0;
00165
00166
00167 try{
00168 RandomAccessFile p= new RandomAccessFile(path,"r");
00169 ligne =p.readLine();
00170 value =ligne.split(" ");
00171
00172
00173
00174 nb_TimelessClass= (int) Float.parseFloat(value[0]);
00175 System.err.print("NB MT CLASSES ");System.err.println(nb_TimelessClass);
00176 nb_dim= (int) Float.parseFloat(value[1]);
00177 System.err.print("NB DIM FS ");System.err.println(nb_dim);
00178 nb_images= (int) Float.parseFloat(value[2]);
00179 System.err.print("NB IMAGE SAMPLES ");System.err.println(nb_images);
00180 MI=new float[nb_TimelessClass][nb_images-1];
00181 cardMT=new float[nb_TimelessClass];
00182 timeNodes= new TimeNodes[nb_images];
00183 for (int i=0;i<nb_images;i++){timeNodes[i]=new TimeNodes();}
00184 l=3;
00185 for (int kMT=0;kMT<nb_TimelessClass;kMT++) {
00186 l++;
00187 System.err.print("READING MT CLASS ");System.err.println(kMT);
00188 cardMT[kMT]=(float) Float.parseFloat(value[l]);l++;
00189 for (int t=0;t<nb_images;t++) {
00190
00191 l++;
00192 for (int i=0;i<nb_dim;i++){l++;}
00193 for (int i=0;i<nb_dim;i++){for (int j=0;j<nb_dim;j++){l++;}}
00194 nb_nodes= (int) Float.parseFloat(value[l]);l++ ;
00195 if (kMT==0){
00196 timeNodes[t].AllocateTimeNodes(nb_nodes);
00197 for (int kTL=0;kTL<timeNodes[t].totalTimeNb_node;kTL++){
00198 timeNodes[t].node[kTL].allocate(100);
00199 timeNodes[t].node[kTL].nbMultitempClass=0;
00200 }
00201 }
00202 for (int kTL=0;kTL<timeNodes[t].totalTimeNb_node;kTL++){
00203 indexNode=(int) Float.parseFloat(value[l]);l++;
00204 timeNodes[t].node[indexNode].nbMultitempClass++;
00205 timeNodes[t].node[indexNode].multitempClass[kMT]=kMT;
00206 l++;
00207 timeNodes[t].node[indexNode].divKullback[kMT]=(float) Float.parseFloat(value[l]);l++;
00208
00209 for (int i=0;i<nb_dim;i++){timeNodes[t].node[indexNode].mean[i]=(float) Float.parseFloat(value[l]);l++;}
00210 for (int i=0;i<nb_dim;i++){
00211 for (int j=0;j<nb_dim;j++){
00212 timeNodes[t].node[indexNode].cov[i][j]=(float) Float.parseFloat(value[l]);l++;
00213 }
00214 }
00215 if (t>0){
00216 if (kMT==0){timeNodes[t].node[indexNode].allocateEdges(timeNodes[t-1].totalTimeNb_node);}
00217 for (int kTLpre=0;kTLpre<timeNodes[t-1].totalTimeNb_node;kTLpre++){
00218 indexNodePre=(int) Float.parseFloat(value[l]);l++;
00219 timeNodes[t].node[indexNode].ingoingEdges[indexNodePre].indexNodeA=indexNodePre;
00220 timeNodes[t].node[indexNode].ingoingEdges[indexNodePre].indexNodeB=indexNode;
00221 if (kMT==0){timeNodes[t].node[indexNode].ingoingEdges[indexNodePre].flowAlloc(nb_TimelessClass);}
00222 timeNodes[t].node[indexNode].ingoingEdges[indexNodePre].flowSave[kMT]=(int) Float.parseFloat(value[l]);l++;
00223 timeNodes[t].node[indexNode].ingoingEdges[indexNodePre].flowMTindex[kMT]=(char)kMT;
00224 timeNodes[t].node[indexNode].ingoingEdges[indexNodePre].flow[kMT]=timeNodes[t].node[indexNode].ingoingEdges[indexNodePre].flowSave[kMT];
00225 l++;
00226 }
00227 }
00228 ligne=p.readLine();
00229 value =ligne.split(" ");
00230 l=0;
00231 }
00232 if (t>0){
00233 MI[kMT][t-1]=(float) Float.parseFloat(value[l]); l++;
00234 if (kMT<nb_TimelessClass-1||t<nb_images-1){
00235 ligne=p.readLine();
00236 value =ligne.split(" ");
00237 l=0;
00238 }
00239 }
00240 }
00241 }
00242 }
00243 catch (Exception e) {System.err.println("problem reading graphV2JAVA file\n");}
00244
00245 }
00246
00247
00248 public Component createButton() {
00249
00250 label = new JLabel(labelPrefix + "1");
00251 button1 = new JButton("Image+");
00252 button1.setMnemonic(KeyEvent.VK_I);
00253 button1.addActionListener(new ActionListener() {
00254 public void actionPerformed(ActionEvent e) {
00255
00256 currentTime++;
00257 icon=new ImageIcon(getImage1(currentTime));
00258 iconClassTL=new ImageIcon(getImage1(currentTime+1));
00259 classLabelTL.setIcon(iconClassTL);
00260 imageLabel.setIcon(icon);
00261 icon2MT=new ImageIcon(getImage1(currentTime));
00262 iconClassTL2MT=new ImageIcon(getImage1(currentTime));
00263 classLabelTL2MT.setIcon(iconClassTL2MT);
00264 imageLabel2MT.setIcon(icon2MT);
00265 label.setText(labelPrefix + currentTime);
00266 dynaClassCoordinateArea.repaint();
00267 graphCoordinateArea.repaint();
00268 classfileArea2MT.repaint();
00269 iconClass=new ImageIcon(getImage1(currentTime-1));
00270 classLabel.setIcon(iconClass);
00271
00272 }
00273 });
00274 label.setLabelFor(button1);
00275 button2 = new JButton("Image-");
00276 button2.setMnemonic(KeyEvent.VK_I);
00277 button2.addActionListener(new ActionListener() {
00278 public void actionPerformed(ActionEvent e) {
00279 currentTime--;
00280 icon=new ImageIcon(getImage1(currentTime));
00281 iconClassTL=new ImageIcon(getImage1(currentTime+1));
00282 imageLabel.setIcon(icon);
00283 classLabelTL.setIcon(iconClassTL);
00284 icon2MT=new ImageIcon(getImage1(currentTime));
00285 iconClassTL2MT=new ImageIcon(getImage1(currentTime));
00286 imageLabel2MT.setIcon(icon2MT);
00287 classLabelTL2MT.setIcon(iconClassTL2MT);
00288 label.setText(labelPrefix + currentTime);
00289 dynaClassCoordinateArea.repaint();
00290 graphCoordinateArea.repaint();
00291 classfileArea2MT.repaint();
00292 iconClass=new ImageIcon(getImage1(currentTime-1));
00293 classLabel.setIcon(iconClass);
00294 }
00295 });
00296 label.setLabelFor(button2);
00297 buttonClassB = new JButton("2nd MT+");
00298 buttonClassB.setMnemonic(KeyEvent.VK_I);
00299 buttonClassB.addActionListener(new ActionListener() {
00300 public void actionPerformed(ActionEvent e) {
00301 displayClass[1]=displayClass[1]+1;
00302 if (displayClass[1]>nb_TimelessClass){displayClass[1]=1;}
00303 label4.setText("Tresh:" +SeuilDiv+"/MT:"+displayClass[0]+"&"+displayClass[1]+"/");
00304 iconClassTL2MT=new ImageIcon(getImage1(currentTime));
00305 iconClass2MT=new ImageIcon(getImage1(currentTime));
00306 classLabelTL2MT.setIcon(iconClassTL2MT);
00307 label.setText(labelPrefix + currentTime);
00308
00309
00310 graphCoordinateArea.repaint();
00311 dynaClassCoordinateArea.repaint();
00312 classfileArea2MT.repaint();
00313 iconClass=new ImageIcon(getImage1(currentTime-1));
00314 classLabel.setIcon(iconClass);
00315
00316 }
00317 });
00318
00319 buttonArea =new JPanel();
00320 buttonArea.setLayout(new BorderLayout());
00321 buttonArea.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
00322 buttonArea.add(buttonClassB,BorderLayout.WEST);
00323 buttonArea.add(button1,BorderLayout.EAST);
00324 buttonArea.add(button2,BorderLayout.CENTER);
00325 buttonArea.add(mouseCoordinates,BorderLayout.SOUTH);
00326 buttonArea.add(label,BorderLayout.NORTH);
00327 return buttonArea;
00328 }
00329 public Component createButton4() {
00330 displayClass=new int[3];
00331 displayClass[0]=1;
00332 displayClass[1]=2;
00333 displayClass[2]=4;
00334
00335
00336
00337 label4 = new JLabel("Tresh:" +SeuilDiv+"/MT:"+displayClass[0]+"&"+displayClass[1]+"/");
00338 button4 = new JButton("DivTresh-");
00339 button4.setMnemonic(KeyEvent.VK_I);
00340 button4.addActionListener(new ActionListener() {
00341 public void actionPerformed(ActionEvent e) {
00342
00343 SeuilDiv=SeuilDiv-10;
00344 updateSeuil();
00345 label4.setText("Tresh:" +SeuilDiv+"/MT:"+displayClass[0]+"&"+displayClass[1]+"/");
00346 graphCoordinateArea.repaint();
00347 dynaClassCoordinateArea.repaint();
00348 classfileArea2MT.repaint();
00349 iconClass=new ImageIcon(getImage1(currentTime-1));
00350 classLabel.setIcon(iconClass);
00351
00352 }
00353 });
00354 label4.setLabelFor(button4);
00355
00356
00357 buttonSB3 = new JButton("SG++");
00358 buttonSB3.setMnemonic(KeyEvent.VK_I);
00359 buttonSB3.addActionListener(new ActionListener() {
00360 public void actionPerformed(ActionEvent e) {
00361
00362 indexList=indexList+(int)((float)sBList.size/(float)10);
00363 displayClass[0]=sBList.MTa[indexList]+1;
00364 displayClass[1]=sBList.MTb[indexList]+1;
00365 currentTime=sBList.time[indexList]+1;
00366 graphCoordinateArea.repaint();
00367 LinksCoordinateArea.repaint();
00368 dynaClassCoordinateArea.repaint();
00369 classfileArea2MT.repaint();
00370 iconClass=new ImageIcon(getImage1(currentTime-1));
00371 classLabel.setIcon(iconClass);
00372 label4.setText("Tresh:" +SeuilDiv+"/MT:"+displayClass[0]+"&"+displayClass[1]+"/");
00373 iconClassTL=new ImageIcon(getImage1(currentTime+1));
00374 iconClass=new ImageIcon(getImage1(currentTime-1));
00375 classLabelTL.setIcon(iconClassTL);
00376 classLabel.setIcon(iconClass);
00377 iconClassTL2MT=new ImageIcon(getImage1(currentTime));
00378 iconClass2MT=new ImageIcon(getImage1(currentTime));
00379 classLabelTL2MT.setIcon(iconClassTL2MT);
00380 icon=new ImageIcon(getImage1(currentTime));
00381 icon2MT=new ImageIcon(getImage1(currentTime));
00382 imageLabel.setIcon(icon);
00383 imageLabel2MT.setIcon(icon2MT);
00384 label.setText(labelPrefix + currentTime+"/Prob:"+(float)((int)(sBList.Prob[indexList]*(float)1000))/(float)1000);
00385 mouseCoordinates.setText("Post Mean/Var:"+(float)((int)(sBList.PostMean*(float)1000))/(float)1000+"/"+(float)((int)(sBList.PostVar*(float)1000))/(float)1000);
00386 }
00387 });
00388
00389
00390
00391
00392
00393
00394
00395
00396 buttonArea3 =new JPanel();
00397 buttonArea3.setLayout(new BorderLayout());
00398 buttonArea3.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
00399 buttonArea3.add(button4,BorderLayout.SOUTH);
00400 buttonArea3.add(buttonSB3,BorderLayout.CENTER);
00401 buttonArea3.add(label4,BorderLayout.NORTH);
00402 return buttonArea3;
00403 }
00404
00405 public Component createButton5() {
00406
00407
00408
00409 buttonSB = new JButton("Search");
00410 buttonSB.setMnemonic(KeyEvent.VK_I);
00411 sBList=new SBList();
00412 buttonSB.addActionListener(new ActionListener() {
00413 public void actionPerformed(ActionEvent e) {
00414
00415 sBList=new SBList();
00416 indexList=0;
00417 sBList.InitList();
00418 sBList.ReadList();
00419 for (int i=0;i<7;i++){barHeigh[i]=(int) ((float)sBList.ProbLink[i]*(float)10.);}
00420 displayClass[0]=sBList.MTa[indexList]+1;
00421 displayClass[1]=sBList.MTb[indexList]+1;
00422 currentTime=sBList.time[indexList]+1;
00423 graphCoordinateArea.repaint();
00424 dynaClassCoordinateArea.repaint();
00425 classfileArea2MT.repaint();
00426 iconClass=new ImageIcon(getImage1(currentTime-1));
00427 classLabel.setIcon(iconClass);
00428 LinksCoordinateArea.repaint();
00429 label4.setText("Tresh:" +SeuilDiv+"/MT:"+displayClass[0]+"&"+displayClass[1]+"/");
00430 iconClassTL=new ImageIcon(getImage1(currentTime+1));
00431 iconClass=new ImageIcon(getImage1(currentTime-1));
00432 classLabelTL.setIcon(iconClassTL);
00433 classLabel.setIcon(iconClass);
00434 iconClassTL2MT=new ImageIcon(getImage1(currentTime));
00435 iconClass2MT=new ImageIcon(getImage1(currentTime));
00436 classLabelTL2MT.setIcon(iconClassTL2MT);
00437 icon=new ImageIcon(getImage1(currentTime));
00438 icon2MT=new ImageIcon(getImage1(currentTime));
00439 imageLabel.setIcon(icon);
00440 imageLabel2MT.setIcon(icon2MT);
00441 label.setText(labelPrefix + currentTime+"/Prob:"+(float)((int)(sBList.Prob[indexList]*(float)1000))/(float)1000);
00442 mouseCoordinates.setText("Post Mean/Var:"+(float)((int)(sBList.PostMean*(float)1000))/(float)1000+"/"+(float)((int)(sBList.PostVar*(float)1000))/(float)1000);
00443 }
00444 });
00445
00446
00447 buttonSB5 = new JButton("SGorder-");
00448 buttonSB5.setMnemonic(KeyEvent.VK_I);
00449 sBList=new SBList();
00450 buttonSB5.addActionListener(new ActionListener() {
00451 public void actionPerformed(ActionEvent e) {
00452
00453 sBList=new SBList();
00454 indexList=0;
00455 sBList.InitList();
00456 sBList.ReadInvList();
00457 for (int i=0;i<7;i++){barHeigh[i]=(int)sBList.ProbLink[i]*10;}
00458 displayClass[0]=sBList.MTa[indexList]+1;
00459 displayClass[1]=sBList.MTb[indexList]+1;
00460 currentTime=sBList.time[indexList]+1;
00461 graphCoordinateArea.repaint();
00462 dynaClassCoordinateArea.repaint();
00463 classfileArea2MT.repaint();
00464 iconClass=new ImageIcon(getImage1(currentTime-1));
00465 classLabel.setIcon(iconClass);
00466 LinksCoordinateArea.repaint();
00467 label4.setText("Tresh:" +SeuilDiv+"/MT:"+displayClass[0]+"&"+displayClass[1]+"/");
00468 iconClassTL=new ImageIcon(getImage1(currentTime+1));
00469 iconClass=new ImageIcon(getImage1(currentTime-1));
00470 classLabelTL.setIcon(iconClassTL);
00471 classLabel.setIcon(iconClass);
00472 iconClassTL2MT=new ImageIcon(getImage1(currentTime));
00473 iconClass2MT=new ImageIcon(getImage1(currentTime));
00474 classLabelTL2MT.setIcon(iconClassTL2MT);
00475 icon=new ImageIcon(getImage1(currentTime));
00476 icon2MT=new ImageIcon(getImage1(currentTime));
00477 imageLabel.setIcon(icon);
00478 imageLabel2MT.setIcon(icon2MT);
00479 label.setText(labelPrefix + currentTime+"/Prob:"+(float)((int)(sBList.Prob[indexList]*(float)1000))/(float)1000);
00480 mouseCoordinates.setText("Post Mean/Var:"+(float)((int)(sBList.PostMean*(float)1000))/(float)1000+"/"+(float)((int)(sBList.PostVar*(float)1000))/(float)1000);
00481 }
00482 });
00483
00484 buttonSB2 = new JButton("Next");
00485 buttonSB2.setMnemonic(KeyEvent.VK_I);
00486 buttonSB2.addActionListener(new ActionListener() {
00487 public void actionPerformed(ActionEvent e) {
00488
00489 indexList++;
00490 displayClass[0]=sBList.MTa[indexList]+1;
00491 displayClass[1]=sBList.MTb[indexList]+1;
00492 currentTime=sBList.time[indexList]+1;
00493 graphCoordinateArea.repaint();
00494 dynaClassCoordinateArea.repaint();
00495 classfileArea2MT.repaint();
00496 iconClass=new ImageIcon(getImage1(currentTime-1));
00497 classLabel.setIcon(iconClass);
00498 LinksCoordinateArea.repaint();
00499 label4.setText("Tresh:" +SeuilDiv+"/MT:"+displayClass[0]+"&"+displayClass[1]+"/");
00500 iconClassTL=new ImageIcon(getImage1(currentTime+1));
00501 iconClass=new ImageIcon(getImage1(currentTime-1));
00502 classLabelTL.setIcon(iconClassTL);
00503 classLabel.setIcon(iconClass);
00504 iconClassTL2MT=new ImageIcon(getImage1(currentTime));
00505 iconClass2MT=new ImageIcon(getImage1(currentTime));
00506 classLabelTL2MT.setIcon(iconClassTL2MT);
00507 icon=new ImageIcon(getImage1(currentTime));
00508 icon2MT=new ImageIcon(getImage1(currentTime));
00509 imageLabel.setIcon(icon);
00510 imageLabel2MT.setIcon(icon2MT);
00511 label.setText(labelPrefix + currentTime+"/Prob:"+(float)((int)(sBList.Prob[indexList]*(float)1000))/(float)1000);
00512 mouseCoordinates.setText("Post Mean/Var:"+(float)((int)(sBList.PostMean*(float)1000))/(float)1000+"/"+(float)((int)(sBList.PostVar*(float)1000))/(float)1000);
00513
00514
00515 }
00516 });
00517
00518
00519 buttonArea4 =new JPanel();
00520 buttonArea4.setLayout(new BorderLayout());
00521 buttonArea4.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
00522 buttonArea4.add(buttonSB,BorderLayout.NORTH);
00523 buttonArea4.add(buttonSB2,BorderLayout.CENTER);
00524 buttonArea4.add(buttonSB5,BorderLayout.SOUTH);
00525
00526 return buttonArea4;
00527 }
00528 public Component createButton2() {
00529 label3 = new JLabel(" DimIndex : 1");
00530 button3 = new JButton(" Dim+");
00531 button3.setMnemonic(KeyEvent.VK_I);
00532 button3.addActionListener(new ActionListener() {
00533 public void actionPerformed(ActionEvent e) {
00534
00535 if (displayDim<nb_dim-1)
00536 displayDim++;
00537 else
00538 displayDim=0;
00539
00540 displayDim++;
00541 label3.setText(" Dim: "+displayDim);
00542 displayDim--;
00543 graphCoordinateArea.repaint();
00544 dynaClassCoordinateArea.repaint();
00545 classfileArea2MT.repaint();
00546 iconClass=new ImageIcon(getImage1(currentTime-1));
00547 classLabel.setIcon(iconClass);
00548 }
00549 });
00550
00551 label3.setLabelFor(button3);
00552
00553
00554
00555 button5 = new JButton("DivTresh+");
00556 button5.setMnemonic(KeyEvent.VK_I);
00557 button5.addActionListener(new ActionListener() {
00558 public void actionPerformed(ActionEvent e) {
00559 SeuilDiv=SeuilDiv+2;
00560 updateSeuil();
00561 label4.setText("Tresh:" +SeuilDiv+"/MT:"+displayClass[0]+"&"+displayClass[1]+"/");
00562 graphCoordinateArea.repaint();
00563 dynaClassCoordinateArea.repaint();
00564 classfileArea2MT.repaint();
00565 iconClass=new ImageIcon(getImage1(currentTime-1));
00566 classLabel.setIcon(iconClass);
00567 }
00568 });
00569
00570
00571
00572 buttonArea2 =new JPanel();
00573 buttonArea2.setLayout(new BorderLayout());
00574 buttonArea2.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
00575 buttonArea2.add(button5,BorderLayout.SOUTH);
00576 buttonArea2.add(button3,BorderLayout.CENTER);
00577 buttonArea2.add(label3,BorderLayout.NORTH);
00578
00579 return buttonArea2;
00580
00581 }
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595 public Component createComponentsIm() {
00596
00597
00598
00599 icon=new ImageIcon(getImage1(1));
00600 iconClassTL=new ImageIcon(getImage1(1));
00601 imageLabel=new JLabel("",icon,JLabel.CENTER);
00602 classLabelTL=new JLabel("",iconClassTL,JLabel.CENTER);
00603 imCoordinateArea.setLayout(new BorderLayout());
00604 imCoordinateArea.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
00605 imCoordinateArea.add(imageLabel,BorderLayout.WEST);
00606 imCoordinateArea.add(classLabelTL,BorderLayout.EAST);
00607 return imCoordinateArea;
00608 }
00609
00610 public Component createComponentsClass() throws IOException {
00611
00612 iconClass=new ImageIcon(getImage1(1));
00613 classLabel=new JLabel("",iconClass,JLabel.CENTER);
00614
00615 classfileArea.setLayout(new BorderLayout());
00616 classfileArea.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
00617 classfileArea.add(classLabel,BorderLayout.CENTER);
00618
00619 return classfileArea;
00620 }
00621
00622 public Component createComponentsIm2MT() {
00623
00624
00625 icon2MT=new ImageIcon(getImage1(1));
00626 iconClassTL2MT=new ImageIcon(getImage1(1));
00627 imageLabel2MT=new JLabel("",icon2MT,JLabel.CENTER);
00628 classLabelTL2MT=new JLabel("",iconClassTL2MT,JLabel.CENTER);
00629 imCoordinateArea2MT.setLayout(new BorderLayout());
00630 imCoordinateArea2MT.setBorder(BorderFactory.createEmptyBorder(0, 0, 0,40));
00631 barHeigh=new int[7];
00632 for (int i=0;i<7;i++){barHeigh[i]=0;}
00633 Component links = createComponentsLinks();
00634 buttonClassA = new JButton("1st MT+");
00635 buttonClassA.setMnemonic(KeyEvent.VK_I);
00636 buttonClassA.addActionListener(new ActionListener() {
00637 public void actionPerformed(ActionEvent e) {
00638
00639 displayClass[0]=displayClass[0]+1;
00640 if (displayClass[0]>nb_TimelessClass){displayClass[0]=1;}
00641 label4.setText("Tresh:" +SeuilDiv+"/MT:"+displayClass[0]+"&"+displayClass[1]+"/");
00642 iconClassTL=new ImageIcon(getImage1(currentTime+1));
00643 iconClass=new ImageIcon(getImage1(currentTime-1));
00644 classLabelTL.setIcon(iconClassTL);
00645 classLabel.setIcon(iconClass);
00646 label.setText(labelPrefix + currentTime);
00647
00648 graphCoordinateArea.repaint();
00649 dynaClassCoordinateArea.repaint();
00650 classfileArea2MT.repaint();
00651 iconClass=new ImageIcon(getImage1(currentTime-1));
00652 classLabel.setIcon(iconClass);
00653
00654
00655
00656
00657
00658 }
00659 });
00660 Component dynaClass = createComponentsDynaClass();
00661
00662 imCoordinateArea2MT.add(links,BorderLayout.WEST);
00663 imCoordinateArea2MT.add(dynaClass,BorderLayout.CENTER);
00664 imCoordinateArea2MT.add(buttonClassA,BorderLayout.EAST);
00665 return imCoordinateArea2MT;
00666 }
00667
00668 public Component createComponentsClass2MT() throws IOException {
00669
00670 classfileArea2MT.setOpaque(false);
00671 classfileArea2MT.setLayout(new FlowLayout() );
00672
00673 return classfileArea2MT;
00674 }
00675
00676 public Component createComponentsDynaClass() {
00677
00678 dynaClassCoordinateArea.setOpaque(false);
00679 dynaClassCoordinateArea.setLayout(new FlowLayout() );
00680
00681
00682 return dynaClassCoordinateArea;
00683 }
00684
00685
00686 public Component createComponentsGraph() {
00687
00688 graphCoordinateArea.setOpaque(false);
00689 graphCoordinateArea.setLayout(new FlowLayout() );
00690
00691
00692 return graphCoordinateArea;
00693 }
00694 public Component createComponentsLinks() {
00695
00696 LinksCoordinateArea.setOpaque(false);
00697 LinksCoordinateArea.setLayout(new FlowLayout() );
00698
00699
00700 return LinksCoordinateArea;
00701 }
00702 public void buildUI() {
00703
00704
00705 imCoordinateArea = new CoordinateArea(this);
00706 imCoordinateArea.preferredSize= new Dimension(400,sizeIm);
00707 imCoordinateArea2MT = new CoordinateArea(this);
00708 imCoordinateArea2MT.preferredSize= new Dimension(400,sizeIm);
00709
00710 mouseCoordinates= new JLabel("Click within the framed area.");
00711 classfileArea= new CoordinateArea(this);
00712 classfileArea.preferredSize= new Dimension(sizeIm,sizeIm);
00713
00714
00715 classfileArea2MT = new CoordinateArea(this){
00716 public void paintComponent(Graphics g) {
00717 Graphics2D gMT= (Graphics2D)g;
00718 buildMTClass(gMT);
00719 super.paintComponent(gMT);
00720 }
00721 };
00722 classfileArea2MT.preferredSize= new Dimension(sizeIm,sizeIm);
00723
00724
00725 irregularT=new TimeDelay();
00726 dates=new Dates();
00727
00728 readGraphDataV2();
00729 updateSeuil();
00730 graphCoordinateArea = new CoordinateArea(this){
00731 public void paintComponent(Graphics g) {
00732 Graphics2D g2 = (Graphics2D)g;
00733 buildGraph(g2);
00734 super.paintComponent(g2);
00735 }
00736 };
00737 graphCoordinateArea.preferredSize= new Dimension(980,290);
00738
00739 dynaClassCoordinateArea = new CoordinateArea(this){
00740 public void paintComponent(Graphics gDyna) {
00741 Graphics2D dyna = (Graphics2D)gDyna;
00742 buildDynaClass(dyna);
00743 super.paintComponent(dyna);
00744 }
00745 };
00746 dynaClassCoordinateArea.preferredSize= new Dimension(sizeIm,sizeIm);
00747
00748 LinksCoordinateArea = new CoordinateArea(this){
00749 public void paintComponent(Graphics g) {
00750 Graphics2D g2 = (Graphics2D)g;
00751 buildLinks(g2);
00752 super.paintComponent(g2);
00753 }
00754 };
00755 LinksCoordinateArea.preferredSize= new Dimension(sizeIm,sizeIm);
00756 }
00757
00758
00759 private void buildLinks(Graphics2D g2){
00760
00761
00762
00763 g2.setFont(new Font("Arial", Font.PLAIN,10));
00764 g2.setColor(Color.red);
00765 g2.drawString("weight",12,barHeigh[0]+10);
00766 g2.fillRect(12,0,25,barHeigh[0]);
00767 g2.setColor(Color.cyan);
00768 g2.drawString("pos",37,barHeigh[1]+20);
00769 g2.fillRect(37,0,25,barHeigh[1]);
00770 g2.setColor(Color.green);
00771 g2.drawString("flow",62,barHeigh[2]+10);
00772 g2.fillRect(62,0,25,barHeigh[2]);
00773 g2.setColor(Color.yellow);
00774 g2.drawString("change",87,barHeigh[3]+20);
00775 g2.fillRect(87,0,25,barHeigh[3]);
00776 g2.setColor(Color.blue);
00777 g2.drawString("MI",112,barHeigh[4]+10);
00778 g2.fillRect(112,0,25,barHeigh[4]);
00779 g2.setColor(Color.magenta);
00780 g2.drawString("2MT",137,barHeigh[5]+20);
00781 g2.fillRect(137,0,25,barHeigh[5]);
00782 g2.setColor(Color.pink);
00783 g2.drawString("time",162,barHeigh[6]+10);
00784 g2.fillRect(162,0,25,barHeigh[6]);
00785
00786 }
00787 private void buildMTClass(Graphics2D g2){
00788 try{
00789 g2.setColor(Color.white);
00790 g2.fillRect(0,0,sizeIm,sizeIm);
00791
00792 int[][] classAux;
00793 classAux=new int[dimx][dimy];
00794 Reader in;Reader in2;
00795 String path;String path2;
00796 path=CLASSFILEPATH_MT;
00797 in=new FileReader(path);
00798 for (int i=0;i<dimx;i++){
00799 for (int j=0;j<dimy;j++){
00800 classAux[i][j]=in.read();
00801
00802 if (classAux[i][j]==displayClass[0]-1){
00803 g2.setColor(Color.red);
00804 g2.drawLine(j,i,j,i);
00805 }
00806 if (classAux[i][j]==displayClass[1]-1){
00807 g2.setColor(Color.orange);
00808 g2.drawLine(j,i,j,i);
00809 }
00810 }
00811
00812 }
00813 }
00814 catch (Exception e) {System.err.println("problem reading MTdynaClass file\n");}
00815 }
00816 private void buildDynaClass(Graphics2D g2) {
00817 try{
00818 g2.setColor(Color.white);
00819 g2.fillRect(0,0,sizeIm,sizeIm);
00820
00821 int[][] classAux;
00822 classAux=new int[dimx][dimy];
00823 Reader in;
00824 String path;
00825 path=getClassfileTL(currentTime);
00826 in=new FileReader(path);
00827 double min1=INF;double min2=INF;int IndexMin1=256;int IndexMin2=256;
00828 if (SeuilDiv<0){
00829 for (int indexNode=0;indexNode<timeNodes[currentTime-1].totalTimeNb_node;indexNode++){
00830 if (timeNodes[currentTime-1].node[indexNode].divKullback[displayClass[1]-1]<min1){
00831 IndexMin1=indexNode;
00832 min1=timeNodes[currentTime-1].node[indexNode].divKullback[displayClass[1]-1];
00833 }
00834 if (timeNodes[currentTime-1].node[indexNode].divKullback[displayClass[0]-1]<min2){
00835 IndexMin2=indexNode;
00836 min2=timeNodes[currentTime-1].node[indexNode].divKullback[displayClass[0]-1];
00837 }
00838 }
00839 System.err.println(min1);System.err.println(IndexMin1);System.err.println(timeNodes[currentTime-1].totalTimeNb_node);
00840 for (int i=0;i<dimx;i++){
00841 for (int j=0;j<dimy;j++){
00842 classAux[i][j]=in.read();
00843
00844 if (IndexMin1==classAux[i][j]){
00845 g2.setColor(Color.orange);
00846 g2.drawLine(j,i,j,i);
00847 }
00848 if(IndexMin2==classAux[i][j]){
00849 g2.setColor(Color.red);
00850 g2.drawLine(j,i,j,i);
00851 }
00852 if (IndexMin1==classAux[i][j]&&IndexMin2==classAux[i][j]){
00853 g2.setColor(Color.black);
00854 g2.drawLine(j,i,j,i);
00855 }
00856 }
00857
00858 }
00859
00860 }
00861 else{
00862 for (int i=0;i<dimx;i++){
00863 for (int j=0;j<dimy;j++){
00864 classAux[i][j]=in.read();
00865
00866 if (timeNodes[currentTime-1].node[classAux[i][j]].divKullback[displayClass[1]-1]<=SeuilDiv){
00867
00868 g2.setColor(Color.orange);
00869 g2.drawLine(j,i,j,i);
00870 }
00871
00872 if (timeNodes[currentTime-1].node[classAux[i][j]].divKullback[displayClass[0]-1]<=SeuilDiv){
00873 g2.setColor(Color.red);
00874 g2.drawLine(j,i,j,i);
00875 if (timeNodes[currentTime-1].node[classAux[i][j]].divKullback[displayClass[1]-1]<=SeuilDiv){
00876 g2.setColor(Color.black);
00877 g2.drawLine(j,i,j,i);
00878 }
00879 }
00880
00881 }
00882 }
00883 }
00884 }
00885 catch (Exception e) {System.err.println("problem reading TLdynaClass file\n");}
00886 }
00887
00888
00889
00890
00891 private void buildGraph(Graphics2D g2){
00892
00893
00894
00895
00896
00897 g2.setColor(Color.black);
00898
00899 g2.setColor(new Color(255,255,255));
00900 g2.setFont(new Font("Arial", Font.PLAIN,12));
00901
00902 g2.fillRect(ofx,ofy,dx+ofx,dy+ofy);
00903 g2.setColor(Color.black);
00904 g2.drawLine(ofx, ofy, ofx, dy+ofy);
00905 g2.drawLine(ofx, dy+ofy , dx+ofx, dy+ofy);
00906
00907 g2.drawLine(ofx,ofy+dy, ofx+5, ofy+dy);
00908 g2.drawLine(ofx,ofy+(int)(dy*3/4), ofx+5, ofy+(int)(dy*3/4));
00909 g2.drawLine(ofx,ofy+(int)(dy/2), ofx+5, ofy+(int)(dy/2));
00910 g2.drawLine(ofx,ofy+(int)(dy/4), ofx+5, ofy+(int)(dy/4));
00911 g2.drawLine(ofx,ofy, ofx+5, ofy);
00912
00913 g2.drawLine(ofx+dx, ofy+dy,ofx+dx, ofy+dy-5);
00914 g2.drawLine(ofx+(int)(dx*3/4), ofy+dy,ofx+(int)(dx*3/4), ofy+dy-5);
00915 g2.drawLine(ofx+(int)(dx/2), ofy+dy,ofx+(int)(dx/2), ofy+dy-5);
00916 g2.drawLine(ofx+(int)(dx/4), ofy+dy,ofx+(int)(dx/4), ofy+dy-5);
00917 g2.drawLine(ofx, ofy+dy, ofx, ofy+dy-5);
00918
00919 g2.drawString("Date",ofx+dx-30,ofy+dy-10);
00920 g2.drawString("Feature ",ofx+15,ofy+20);
00921
00922
00923
00924
00925
00926
00927
00928 Stroke stroke;
00929 float thickness=1;
00930 int eps=1;
00931 int indexClas;
00932 int IndexMultitemp=-1,alpha=0;
00933 int disp1=0;
00934 int disp2=1;
00935
00936 zoom=new double[3];
00937 zoom[0]=1.3;
00938 zoom[1]=1.3;
00939 zoom[2]=0.9;
00940
00941 int [] IndexDivMin1=new int[nb_images];
00942 int [] IndexDivMin2=new int[nb_images];
00943
00944
00945 for (int t=0;t<nb_images;t++){
00946
00947 double min1=1e40;double min2=1e40;
00948 boolean minEdge=false;
00949 for (int nodeK=0;nodeK<timeNodes[t].totalTimeNb_node;nodeK++){
00950 if (timeNodes[t].node[nodeK].divKullback[(displayClass[disp1]-1)]<min1){
00951 IndexDivMin1[t]=nodeK;
00952 min1=timeNodes[t].node[nodeK].divKullback[(displayClass[disp1]-1)];
00953 }
00954 if (timeNodes[t].node[nodeK].divKullback[(displayClass[disp2]-1)]<min2){
00955 IndexDivMin2[t]=nodeK;
00956 min2=timeNodes[t].node[nodeK].divKullback[(displayClass[disp2]-1)];
00957 }
00958 }
00959 for (int nodeK=0;nodeK<timeNodes[t].totalTimeNb_node;nodeK++){
00960
00961 if (t>0){
00962
00963 for (int edgeK=0;edgeK<timeNodes[t].node[nodeK].nbIngoingEdges;edgeK++){
00964 thickness=(float)(Math.log((double)timeNodes[t].node[nodeK].ingoingEdges[edgeK].flow[(displayClass[disp1]-1)]+(double)1)/2.);
00965 minEdge=(IndexDivMin1[t]==nodeK)&&(IndexDivMin1[t-1]==timeNodes[t].node[nodeK].ingoingEdges[edgeK].indexNodeA);
00966 if (minEdge&&SeuilDiv<=0){
00967 thickness=(float)(Math.log((double)timeNodes[t].node[nodeK].ingoingEdges[edgeK].flowSave[(displayClass[disp1]-1)]+(double)1)/2.);
00968 }
00969 if (thickness!=0||minEdge){
00970
00971 if (minEdge&&thickness==0){
00972
00973 for (int kSB=0;kSB<sBList.size;kSB++) {
00974 if (t>sBList.time[kSB]&&t<(sBList.time[kSB]+sBList.tWindow)){
00975 if((displayClass[disp1]-1)==sBList.MTa[kSB]){
00976 if ((displayClass[disp2]-1)==sBList.MTb[kSB]){
00977 alpha=(int)(sBList.Prob[kSB]*255.);
00978 g2.setColor(new Color(10, 255, 10, alpha));
00979 g2.fillRect(irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images]+ofx,ofy,irregularT.irregularT[t+1]*dx/irregularT.irregularT[nb_images]-irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images], ofy+20);
00980 if (t==sBList.time[kSB]+1){g2.setColor(Color.black);g2.drawString(""+((float)(int)(sBList.Prob[kSB]*(float)100)/(float)100),irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images]+ofx,ofy+30);g2.drawString(""+irregularT.irregularT[t],irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images]+ofx,ofy+40);g2.setColor(new Color(10, 255, 10, alpha));}
00981 }
00982 }
00983 if((displayClass[disp2]-1)==sBList.MTa[kSB]){
00984 if ((displayClass[disp1]-1)==sBList.MTb[kSB]){
00985 alpha=(int)(sBList.Prob[kSB]*255.);
00986 g2.setColor(new Color(10, 255, 10, alpha));
00987 g2.fillRect(irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images]+ofx,ofy,irregularT.irregularT[t+1]*dx/irregularT.irregularT[nb_images]-irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images], ofy+20);
00988 if (t==sBList.time[kSB]+1){g2.setColor(Color.black);g2.drawString(""+((float)(int)(sBList.Prob[kSB]*(float)100)/(float)100),irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images]+ofx,ofy+30);g2.drawString(""+irregularT.irregularT[t],irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images]+ofx,ofy+40);g2.setColor(new Color(10, 255, 10, alpha));}
00989 }
00990 }
00991 }
00992 }
00993
00994
00995 g2.setColor(Color.red);
00996 float dash1[] = {10.0f};
00997 BasicStroke bs = new BasicStroke(1, BasicStroke.CAP_BUTT,BasicStroke.JOIN_MITER, 10.0f, dash1, 0.0f);
00998 g2.setStroke(bs);
00999 }
01000
01001 else{
01002
01003 for (int kSB=0;kSB<sBList.size;kSB++) {
01004 if (t>sBList.time[kSB]&&t<(sBList.time[kSB]+sBList.tWindow)){
01005 if((displayClass[disp1]-1)==sBList.MTa[kSB]){
01006 if ((displayClass[disp2]-1)==sBList.MTb[kSB]){
01007 alpha=(int)(sBList.Prob[kSB]*255.);
01008 g2.setColor(new Color(10, 255, 10, alpha));
01009 g2.fillRect(irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images]+ofx,ofy,irregularT.irregularT[t+1]*dx/irregularT.irregularT[nb_images]-irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images], ofy+20);
01010 if (t==sBList.time[kSB]+1){g2.setColor(Color.black);g2.drawString(""+((float)(int)(sBList.Prob[kSB]*(float)100)/(float)100),irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images]+ofx,ofy+30);g2.drawString(""+irregularT.irregularT[t],irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images]+ofx,ofy+40);g2.setColor(new Color(10, 255, 10, alpha));}
01011 }
01012 }
01013 if((displayClass[disp2]-1)==sBList.MTa[kSB]){
01014 if ((displayClass[disp1]-1)==sBList.MTb[kSB]){
01015 alpha=(int)(sBList.Prob[kSB]*255.);
01016 g2.setColor(new Color(10, 255, 10, alpha));
01017 g2.fillRect(irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images]+ofx,ofy,irregularT.irregularT[t+1]*dx/irregularT.irregularT[nb_images]-irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images], ofy+20);
01018 if (t==sBList.time[kSB]+1){g2.setColor(Color.black);g2.drawString(""+((float)(int)(sBList.Prob[kSB]*(float)100)/(float)100),irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images]+ofx,ofy+30);g2.drawString(""+irregularT.irregularT[t],irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images]+ofx,ofy+40);g2.setColor(new Color(10, 255, 10, alpha));}
01019 }
01020 }
01021 }
01022 }
01023
01024 g2.setColor(Color.red);
01025 stroke = new BasicStroke(thickness, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
01026 g2.setStroke(stroke);
01027 }
01028
01029 g2.drawLine(irregularT.irregularT[t+1]*dx/irregularT.irregularT[nb_images]+ofx,(int)(dy+ofy-(timeNodes[t].node[nodeK].mean[displayDim]-minValue)*zoom[displayDim]), irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images]+ofx+eps, (int)(dy+ofy-(timeNodes[t-1].node[timeNodes[t].node[nodeK].ingoingEdges[edgeK].indexNodeA].mean[displayDim]-minValue)*zoom[displayDim]));
01030
01031 }
01032
01033
01034
01035 thickness=(float)(Math.log((double)timeNodes[t].node[nodeK].ingoingEdges[edgeK].flow[(displayClass[disp2]-1)]+(double)1)/2.);
01036 minEdge=(IndexDivMin2[t]==nodeK)&&(IndexDivMin2[t-1]==timeNodes[t].node[nodeK].ingoingEdges[edgeK].indexNodeA);
01037 if (minEdge&&SeuilDiv<=0){
01038 thickness=(float)(Math.log((double)timeNodes[t].node[nodeK].ingoingEdges[edgeK].flowSave[(displayClass[disp2]-1)]+(double)1)/2.);
01039 }
01040 if (thickness!=0||minEdge){
01041
01042 if (minEdge&&thickness==0){
01043
01044 for (int kSB=0;kSB<sBList.size;kSB++) {
01045 if (t>sBList.time[kSB]&&t<(sBList.time[kSB]+sBList.tWindow)){
01046 if((displayClass[disp1]-1)==sBList.MTa[kSB]){
01047 if ((displayClass[disp2]-1)==sBList.MTb[kSB]){
01048 alpha=(int)(sBList.Prob[kSB]*255.);
01049 g2.setColor(new Color(10, 255, 10, alpha));
01050 g2.fillRect(irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images]+ofx,ofy,irregularT.irregularT[t+1]*dx/irregularT.irregularT[nb_images]-irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images], ofy+20);
01051 if (t==sBList.time[kSB]+1){g2.setColor(Color.black);g2.drawString(""+((float)(int)(sBList.Prob[kSB]*(float)100)/(float)100),irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images]+ofx,ofy+30);g2.drawString(""+irregularT.irregularT[t],irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images]+ofx,ofy+40);g2.setColor(new Color(10, 255, 10, alpha));}
01052 }
01053 }
01054 if((displayClass[disp2]-1)==sBList.MTa[kSB]){
01055 if ((displayClass[disp1]-1)==sBList.MTb[kSB]){
01056 alpha=(int)(sBList.Prob[kSB]*255.);
01057 g2.setColor(new Color(10, 255, 10, alpha));
01058 g2.fillRect(irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images]+ofx,ofy,irregularT.irregularT[t+1]*dx/irregularT.irregularT[nb_images]-irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images], ofy+20);
01059 if (t==sBList.time[kSB]+1){g2.setColor(Color.black);g2.drawString(""+((float)(int)(sBList.Prob[kSB]*(float)100)/(float)100),irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images]+ofx,ofy+30);g2.drawString(""+irregularT.irregularT[t],irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images]+ofx,ofy+40);g2.setColor(new Color(10, 255, 10, alpha));}
01060
01061 }
01062 }
01063 }
01064 }
01065
01066 g2.setColor(Color.orange);
01067 float dash1[] = {10.0f};
01068 BasicStroke bs = new BasicStroke(1, BasicStroke.CAP_BUTT,BasicStroke.JOIN_MITER, 10.0f, dash1, 0.0f);
01069 g2.setStroke(bs);
01070 }
01071
01072 else{
01073
01074 for (int kSB=0;kSB<sBList.size;kSB++) {
01075 if (t>sBList.time[kSB]&&t<(sBList.time[kSB]+sBList.tWindow)){
01076 if((displayClass[disp1]-1)==sBList.MTa[kSB]){
01077 if ((displayClass[disp2]-1)==sBList.MTb[kSB]){
01078 alpha=(int)(sBList.Prob[kSB]*255.);
01079 g2.setColor(new Color(10, 255, 10, alpha));
01080 g2.fillRect(irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images]+ofx,ofy,irregularT.irregularT[t+1]*dx/irregularT.irregularT[nb_images]-irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images], ofy+20);
01081 if (t==sBList.time[kSB]+1){g2.setColor(Color.black);g2.drawString(""+((float)(int)(sBList.Prob[kSB]*(float)100)/(float)100),irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images]+ofx,ofy+30);g2.drawString(""+irregularT.irregularT[t],irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images]+ofx,ofy+40);g2.setColor(new Color(10, 255, 10, alpha));}
01082 }
01083 }
01084 if((displayClass[disp2]-1)==sBList.MTa[kSB]){
01085 if ((displayClass[disp1]-1)==sBList.MTb[kSB]){
01086 alpha=(int)(sBList.Prob[kSB]*255.);
01087 g2.setColor(new Color(10, 255, 10, alpha));
01088 g2.fillRect(irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images]+ofx,ofy,irregularT.irregularT[t+1]*dx/irregularT.irregularT[nb_images]-irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images], ofy+20);
01089 if (t==sBList.time[kSB]+1){g2.setColor(Color.black);g2.drawString(""+((float)(int)(sBList.Prob[kSB]*(float)100)/(float)100),irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images]+ofx,ofy+30);g2.drawString(""+irregularT.irregularT[t],irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images]+ofx,ofy+40);g2.setColor(new Color(10, 255, 10, alpha));}
01090 }
01091 }
01092
01093
01094 }
01095 }
01096
01097 g2.setColor(Color.orange);
01098 stroke = new BasicStroke(thickness, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
01099 g2.setStroke(stroke);
01100 }
01101
01102
01103 g2.drawLine(irregularT.irregularT[t+1]*dx/irregularT.irregularT[nb_images]+ofx,(int)(dy+ofy-(timeNodes[t].node[nodeK].mean[displayDim]-minValue)*zoom[displayDim]), irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images]+ofx+eps, (int)(dy+ofy-(timeNodes[t-1].node[timeNodes[t].node[nodeK].ingoingEdges[edgeK].indexNodeA].mean[displayDim]-minValue)*zoom[displayDim]));
01104 }
01105 }
01106
01107
01108 if (sBList.size!=0){
01109 if (t>sBList.time[indexList]&&t<(sBList.time[indexList]+sBList.tWindow)){
01110 if((displayClass[disp1]-1)==sBList.MTa[indexList]){
01111 if ((displayClass[disp2]-1)==sBList.MTb[indexList]){
01112 alpha=(int)(sBList.Prob[indexList]*255.);
01113 g2.setColor(new Color(255, 255, 10, alpha));
01114 g2.fillRect(irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images]+ofx,ofy,irregularT.irregularT[t+1]*dx/irregularT.irregularT[nb_images]-irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images], ofy+20);
01115
01116 }
01117 }
01118 if((displayClass[disp2]-1)==sBList.MTa[indexList]){
01119 if ((displayClass[disp1]-1)==sBList.MTb[indexList]){
01120 alpha=(int)(sBList.Prob[indexList]*255.);
01121 g2.setColor(new Color(255, 255, 10, alpha));
01122 g2.fillRect(irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images]+ofx,ofy,irregularT.irregularT[t+1]*dx/irregularT.irregularT[nb_images]-irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images], ofy+20);
01123
01124 }
01125 }
01126 }
01127 }
01128
01129
01130
01131
01132 }
01133
01134
01135
01136
01137
01138
01139 if (timeNodes[t].node[nodeK].divKullback[(displayClass[disp1]-1)]<SeuilDiv||IndexDivMin1[t]==nodeK){
01140 alpha=255-(int)(timeNodes[t].node[nodeK].divKullback[(displayClass[disp1]-1)]*10);
01141 if (alpha>255){alpha=255;}
01142 if (alpha<0){alpha=100;}
01143 g2.setColor(new Color(255, 10, 255, alpha));
01144 stroke = new BasicStroke(5, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
01145 g2.setStroke(stroke);
01146 g2.drawLine(irregularT.irregularT[t+1]*dx/irregularT.irregularT[nb_images]+ofx,(int)(dy+ofy-((timeNodes[t].node[nodeK].mean[displayDim]-minValue)*zoom[displayDim]-1.5*Math.sqrt(timeNodes[t].node[nodeK].cov[displayDim][displayDim])*zoom[displayDim])),irregularT.irregularT[t+1]*dx/irregularT.irregularT[nb_images]+ofx,(int)(dy+ofy-((timeNodes[t].node[nodeK].mean[displayDim]-minValue)*zoom[displayDim]+1.5*Math.sqrt(timeNodes[t].node[nodeK].cov[displayDim][displayDim])*zoom[displayDim])));
01147 }
01148 if (timeNodes[t].node[nodeK].divKullback[(displayClass[disp2]-1)]<SeuilDiv||IndexDivMin2[t]==nodeK){
01149 alpha=255-(int)(timeNodes[t].node[nodeK].divKullback[(displayClass[disp2]-1)]*10);
01150 if (alpha>255){alpha=255;}
01151 if (alpha<0){alpha=100;}
01152 g2.setColor(new Color(10, 10, 255, alpha));
01153 stroke = new BasicStroke(5, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
01154 g2.setStroke(stroke);
01155 g2.drawLine(irregularT.irregularT[t+1]*dx/irregularT.irregularT[nb_images]+ofx,(int)(dy+ofy-((timeNodes[t].node[nodeK].mean[displayDim]-minValue)*zoom[displayDim]-1.5*Math.sqrt(timeNodes[t].node[nodeK].cov[displayDim][displayDim])*zoom[displayDim])),irregularT.irregularT[t+1]*dx/irregularT.irregularT[nb_images]+ofx,(int)(dy+ofy-((timeNodes[t].node[nodeK].mean[displayDim]-minValue)*zoom[displayDim]+1.5*Math.sqrt(timeNodes[t].node[nodeK].cov[displayDim][displayDim])*zoom[displayDim])));
01156 }
01157 }
01158
01159
01160 if (t>0){
01161 g2.setColor(Color.red);
01162 stroke = new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
01163 g2.setStroke(stroke);
01164 g2.drawLine(irregularT.irregularT[t+1]*dx/irregularT.irregularT[nb_images]+ofx,(int)(dy+ofy-(int)(MI[(displayClass[disp1]-1)][t-1]*10.)),irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images]+ofx,(int)(dy+ofy-(int)(MI[(displayClass[disp1]-1)][t-1]*10.)));
01165
01166 g2.setColor(Color.orange);
01167 stroke = new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
01168 g2.setStroke(stroke);
01169 g2.drawLine(irregularT.irregularT[t+1]*dx/irregularT.irregularT[nb_images]+ofx,(int)(dy+ofy-(int)(MI[(displayClass[disp2]-1)][t-1]*10.)),irregularT.irregularT[t]*dx/irregularT.irregularT[nb_images]+ofx,(int)(dy+ofy-(int)(MI[(displayClass[disp2]-1)][t-1]*10.)));
01170 }
01171
01172 }
01173 int vertLine= irregularT.irregularT[currentTime]*dx/irregularT.irregularT[nb_images];
01174 g2.setColor(Color.black);
01175 g2.drawLine(vertLine+ofx, ofy,vertLine+ofx, dy+ofy);
01176 g2.drawString(dates.imageDate[currentTime],vertLine+ofx,ofy+dy-10);
01177
01178
01179
01180
01181 }
01182
01183
01184
01185 public void updateSeuil(){
01186
01187 for (int kMT=0;kMT<nb_TimelessClass;kMT++) {
01188 for (int t=0;t<nb_images;t++) {
01189 for (int indexNode=0;indexNode<timeNodes[t].totalTimeNb_node;indexNode++){
01190 if (t>0){
01191 for (int indexNodePre=0;indexNodePre<timeNodes[t-1].totalTimeNb_node;indexNodePre++){
01192 timeNodes[t].node[indexNode].ingoingEdges[indexNodePre].flow[kMT]=timeNodes[t].node[indexNode].ingoingEdges[indexNodePre].flowSave[kMT];
01193 if (timeNodes[t].node[indexNode].divKullback[kMT]>SeuilDiv||timeNodes[t-1].node[indexNodePre].divKullback[kMT]>SeuilDiv){
01194 timeNodes[t].node[indexNode].ingoingEdges[indexNodePre].flow[kMT]=0;
01195 }
01196 if (timeNodes[t].node[indexNode].ingoingEdges[indexNodePre].flow[kMT]<SeuilFlow){
01197 timeNodes[t].node[indexNode].ingoingEdges[indexNodePre].flow[kMT]=0;
01198 }
01199 }
01200 }
01201 }
01202 }
01203 }
01204
01205 }
01206 public void updateLabel(Point point, CoordinateArea ca) throws IOException {
01207
01208
01209
01210
01211 updateSeuil();
01212 double aux=1e3;
01213 double auxCur;
01214 int auxIndex=0;
01215 float auxi;
01216 double scale=(double)dx/(double)irregularT.irregularT[nb_images];
01217
01218 if (ca==graphCoordinateArea){
01219 if (point.x<(dx+ofx) && point.x>ofx && point.y<(ofy+dy) && point.y>(ofy)){
01220 for (int t=0;t<nb_images;t++){
01221 auxCur=((double)irregularT.irregularT[t+1]*(double)scale+(double)ofx-(double)point.x);
01222 if ((auxCur*auxCur)<(aux*aux))
01223 {
01224 aux=auxCur;
01225 auxIndex=t;
01226 }
01227
01228 }
01229 auxIndex++;
01230 currentTime=auxIndex;
01231 auxi=(float)(ofy+dy-point.y)/(float)zoom[displayDim];
01232 label3.setText(" Dim:"+displayDim+"/Day:"+ irregularT.irregularT[auxIndex]+ "/Val:" + (int)auxi);
01233 icon=new ImageIcon(getImage1(auxIndex));
01234 iconClassTL=new ImageIcon(getImage1(currentTime+1));
01235 imageLabel.setIcon(icon);
01236 classLabelTL.setIcon(iconClassTL);
01237 icon2MT=new ImageIcon(getImage1(auxIndex));
01238 iconClassTL2MT=new ImageIcon(getImage1(currentTime));
01239 imageLabel2MT.setIcon(icon2MT);
01240 classLabelTL2MT.setIcon(iconClassTL2MT);
01241 label.setText(labelPrefix + auxIndex);
01242
01243 }
01244 point.x=0; point.y=0;
01245 dynaClassCoordinateArea.repaint();
01246 graphCoordinateArea.repaint();
01247 classfileArea2MT.repaint();
01248 iconClass=new ImageIcon(getImage1(currentTime-1));
01249 classLabel.setIcon(iconClass);
01250 }
01251
01252
01253
01254 int[][] classAux;
01255 Reader in;
01256 String path;
01257 int inside=0;
01258 int x,y;
01259 boolean continu=true;
01260 if (ca==imCoordinateArea){
01261
01262 x=point.x-0;
01263 y=point.y-0;
01264 auxIndex=currentTime;
01265 if (point.x<(dimx+ofx) && point.x>ofx && point.y>(0) && point.y<(0+dimy)){
01266
01267 mouseCoordinates.setText("("+x+ ","+y+")");
01268 classAux=new int[dimx][dimy];
01269
01270
01271
01272 path=CLASSFILEPATH_MT;
01273 in=new FileReader(path);
01274 for (int i=0;i<dimx;i++)
01275 for (int j=0;j<dimy;j++)
01276 classAux[j][i]=in.read();
01277
01278
01279 displayClass[0]=classAux[x][y]+1;
01280
01281
01282 label4.setText("Tresh:" +SeuilDiv+"/MT:"+displayClass[0]+"&"+displayClass[1]+"/");
01283 iconClassTL=new ImageIcon(getImage1(currentTime+1));
01284 iconClass=new ImageIcon(getImage1(currentTime-1));
01285 classLabelTL.setIcon(iconClassTL);
01286 classLabel.setIcon(iconClass);
01287 label.setText(labelPrefix + currentTime);
01288
01289 graphCoordinateArea.repaint();
01290 dynaClassCoordinateArea.repaint();
01291 classfileArea2MT.repaint();
01292 iconClass=new ImageIcon(getImage1(currentTime-1));
01293 classLabel.setIcon(iconClass);
01294
01295 point.x=0; point.y=0;
01296
01297
01298
01299
01300
01301 }
01302 if (point.x<(2*dimx+ofx) && point.x>(dimx+ofx) && point.y>(0) && point.y<(0+dimy)){
01303
01304 x=x-dimx;
01305 mouseCoordinates.setText("("+x+ ","+y+")");
01306 classAux=new int[dimx][dimy];
01307
01308
01309
01310 path=CLASSFILEPATH_MT;
01311 in=new FileReader(path);
01312 for (int i=0;i<dimx;i++)
01313 for (int j=0;j<dimy;j++)
01314 classAux[j][i]=in.read();
01315
01316
01317
01318 displayClass[1]=classAux[x][y]+1;
01319
01320 label4.setText("Tresh:" +SeuilDiv+"/MT:"+displayClass[0]+"&"+displayClass[1]+"/");
01321 iconClassTL=new ImageIcon(getImage1(currentTime+1));
01322 iconClass=new ImageIcon(getImage1(currentTime-1));
01323 classLabelTL.setIcon(iconClassTL);
01324 classLabel.setIcon(iconClass);
01325 label.setText(labelPrefix + currentTime);
01326
01327 iconClassTL2MT=new ImageIcon(getImage1(currentTime));
01328 iconClass2MT=new ImageIcon(getImage1(currentTime));
01329 classLabelTL2MT.setIcon(iconClassTL2MT);
01330 label.setText(labelPrefix + currentTime);
01331
01332 graphCoordinateArea.repaint();
01333 dynaClassCoordinateArea.repaint();
01334 classfileArea2MT.repaint();
01335 iconClass=new ImageIcon(getImage1(currentTime-1));
01336 classLabel.setIcon(iconClass);
01337
01338
01339 point.x=0; point.y=0;
01340
01341
01342
01343
01344
01345 }
01346 }
01347 if (ca==classfileArea){
01348 auxIndex=currentTime;
01349 x=point.x-0;
01350 y=point.y-0;
01351 if (point.x<(dimx+ofx) && point.x>ofx && point.y>(0) && point.y<(0+dimy)){
01352
01353 mouseCoordinates.setText(" Coordinates : ("+x+ " , "+y+") ");
01354 classAux=new int[dimx][dimy];
01355
01356
01357
01358 path=CLASSFILEPATH_MT;
01359 in=new FileReader(path);
01360 for (int i=0;i<dimx;i++)
01361 for (int j=0;j<dimy;j++)
01362 classAux[j][i]=in.read();
01363
01364
01365 displayClass[0]=classAux[x][y]+1;
01366
01367
01368 label4.setText("Tresh:" +SeuilDiv+"/MT:"+displayClass[0]+"&"+displayClass[1]+"/");
01369 iconClassTL=new ImageIcon(getImage1(currentTime+1));
01370 iconClass=new ImageIcon(getImage1(currentTime-1));
01371 classLabelTL.setIcon(iconClassTL);
01372 classLabel.setIcon(iconClass);
01373 label.setText(labelPrefix + currentTime);
01374
01375 graphCoordinateArea.repaint();
01376 dynaClassCoordinateArea.repaint();
01377 classfileArea2MT.repaint();
01378 iconClass=new ImageIcon(getImage1(currentTime-1));
01379 classLabel.setIcon(iconClass);
01380
01381
01382 point.x=0; point.y=0;
01383
01384
01385
01386
01387
01388 }
01389 }
01390
01391
01392 }
01393 public static void main(String[] args) throws Exception{
01394
01395 form2 = new DecimalFormat("00");
01396
01397 try {
01398 UIManager.setLookAndFeel(
01399 UIManager.getCrossPlatformLookAndFeelClassName());
01400 } catch (Exception e) { }
01401 JFrame frame = new JFrame("TimeSeriesDisplay Application");
01402 ITS_Graph3 controller = new ITS_Graph3();
01403
01404 frame.addWindowListener(new WindowAdapter() {
01405 public void windowClosing(WindowEvent e) {
01406 System.exit(0);
01407 }
01408 });
01409 controller.buildUI();
01410
01411 Component buttonContents = controller.createButton();
01412 Component buttonContents2=controller.createButton2();
01413 Component buttonContents3=controller.createButton4();
01414 Component contents = controller.createComponentsIm();
01415 Component contents2 = controller.createComponentsClass();
01416 Component contents2MT = controller.createComponentsIm2MT();
01417 Component contents2MT2 = controller.createComponentsClass2MT();
01418 Component graph = controller.createComponentsGraph();
01419 Component buttonContents4=controller.createButton5();
01420
01421 JPanel subPanel=new JPanel();
01422 subPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
01423 subPanel.setLayout(new BorderLayout());
01424 subPanel.add(contents,BorderLayout.CENTER);
01425 subPanel.add(buttonContents,BorderLayout.EAST);
01426 subPanel.add(contents2,BorderLayout.WEST);
01427 JPanel subPanel2MT=new JPanel();
01428 subPanel2MT.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
01429 subPanel2MT.setLayout(new BorderLayout());
01430 subPanel2MT.add(contents2MT,BorderLayout.CENTER);
01431 subPanel2MT.add(buttonContents,BorderLayout.EAST);
01432 subPanel2MT.add(contents2MT2,BorderLayout.WEST);
01433 JPanel subPanel3=new JPanel();
01434 subPanel3.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
01435 subPanel3.setLayout(new BorderLayout());
01436 subPanel3.add(buttonContents2,BorderLayout.EAST);
01437 subPanel3.add(buttonContents3,BorderLayout.CENTER);
01438 subPanel3.add(buttonContents4,BorderLayout.WEST);
01439
01440 frame.getContentPane().add(subPanel,BorderLayout.WEST);
01441 frame.getContentPane().add(subPanel2MT,BorderLayout.SOUTH);
01442 frame.getContentPane().add(subPanel3,BorderLayout.EAST);
01443 frame.getContentPane().add(graph,BorderLayout.NORTH);
01444 frame.pack();
01445 frame.setVisible(true);
01446 }
01447
01448 private String getImage1 (int index) {
01449 String result = new String();
01450 DecimalFormat form = new DecimalFormat("00");
01451 result = IMAGEPATH + dates.imageDate[index] + ".jpg";
01452 return(result);
01453 }
01454
01455 private String getClassfileTL (int index1) {
01456 String result = new String();
01457 result=CLASSFILEPATH_TL+dates.imageDate[index1]+".cl";
01458 return(result);
01459 }
01460
01461 }
01462
01463
01464
01465
01466
01467
01468
01469
01470
01471
01472
01473
01474
01475
01476
01477
01478