asd
Alejandro Acuña
2024-09-16 816cb391a192e357426312ab8e591fd49d1d242e
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
package svgdevicestest.maps.SVG;
 
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.nio.file.Files;
import javax.swing.JFrame;
import javax.swing.Timer;
 
 
 
public class WindowMapSchema extends JFrame
{
    private PanelMapSchema panelMapSchema = null;
    private Timer timer = null;
    private long timestamp = 0;
    
    public WindowMapSchema()
    {
        try
        {
            ModelFile modelfile = new ModelFile();
            modelfile.folder = "c:/temp7";
            modelfile.name = "Corridor";
            modelfile.dataJAVA = Files.readAllBytes(new File("c:/temp7/Corridor.java").toPath());
            modelfile.dataSVG = Files.readAllBytes(new File("c:/temp7/Corridor.svg").toPath());
            timestamp = new File("c:/temp7/Corridor.java").lastModified();
            timestamp = Math.max(timestamp, new File("c:/temp7/Corridor.svg").lastModified());
 
            panelMapSchema = new PanelMapSchema();
            panelMapSchema.MapSchemaWindowPanel(modelfile);
            this.getContentPane().setLayout(new BorderLayout());
            this.getContentPane().add(panelMapSchema, BorderLayout.CENTER);
            this.setSize(1920, 1080);
            this.setLocation(1920, 0);
            this.setVisible(true);
            
            timer = new Timer(1000, new ActionListener() 
            {
                public void actionPerformed(ActionEvent evt) 
                {
                    try
                    {
                        long newtimestamp = new File("c:/temp7/Corridor.java").lastModified();
                        newtimestamp = Math.max(newtimestamp, new File("c:/temp7/Corridor.svg").lastModified());
                        
                        if (newtimestamp  > timestamp)
                        {
                            WindowMapSchema.this.getContentPane().remove(panelMapSchema);
 
                            ModelFile modelfile = new ModelFile();
                            modelfile.folder = "c:/temp7";
                            modelfile.name = "Corridor";
                            modelfile.dataJAVA = Files.readAllBytes(new File("c:/temp7/Corridor.java").toPath());
                            modelfile.dataSVG = Files.readAllBytes(new File("c:/temp7/Corridor.svg").toPath());
                            panelMapSchema = new PanelMapSchema();
                            panelMapSchema.MapSchemaWindowPanel(modelfile);
                            WindowMapSchema.this.getContentPane().add(panelMapSchema, BorderLayout.CENTER);
                            WindowMapSchema.this.revalidate();
                            WindowMapSchema.this.repaint();
                            timestamp = newtimestamp;
                        }
                    }
                    catch (Exception e)
                    {
                        e.printStackTrace();
                    }
                    
                    
                    panelMapSchema.timer();
                }
            });
            
            timer.start();
 
 
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
        
    }
}