-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProject.java
More file actions
85 lines (82 loc) · 3.09 KB
/
Project.java
File metadata and controls
85 lines (82 loc) · 3.09 KB
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 AdvancedProject;
import javafx.scene.shape.LineTo;
import javafx.scene.shape.MoveTo;
import javafx.scene.shape.Path;
import javafx.application.Application;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
import javafx.geometry.Insets;
import javafx.scene.Group;
import javafx.scene.Scene;
import static javafx.scene.effect.BlurType.GAUSSIAN;
import javafx.scene.effect.DropShadow;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Line;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Screen;
import javafx.stage.Stage;
import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.SAXException;
/*
Names :
1- Ahmed Ayman Abd El Fatah Elfeel 2000128
2- Fady Adel Botros Awdallah 2001388
3- Adham Mohamed Mohamed hassan 2001378
4- Shawky Ahmed Shawky 2002020
*/
public class Project extends Application {
@Override
public void start(Stage primaryStage)throws IOException, ParserConfigurationException, SAXException{
//Please put the destination of the file here
String filename = "F:/Electrical junior2/Advanced programming/Project/Example.mdl";
// Read the .mdl file as a string
String content = new String(Files.readAllBytes(Paths.get(filename)), Charset.defaultCharset());
String s="";
int start=content.indexOf("<System>");
int end =content.indexOf("</System>",start);
s = content.substring(start, end+"</System>".length());
Block B=new Block(s);
Rectangle []r=new Rectangle[B.getNoOfBlocks()];
Text []t =new Text[B.getNoOfBlocks()];
for(int i=0;i<B.getNoOfBlocks();i++){
r[i]=new Rectangle();
t[i]=new Text();
r[i].setX(B.getXCoordinate(i));
r[i].setY(B.getYCoordinate(i));
r[i].setWidth(B.getBlockWidth(i)*1.2);
r[i].setHeight(B.getBlockHeight(i)*1.2);
r[i].setStroke(Color.GREY);
r[i].setFill(Color.TRANSPARENT);
r[i].setEffect(new DropShadow(GAUSSIAN,Color.SKYBLUE,1,2,0,0));
t[i].setText(B.getBlockName(i));
t[i].setY(B.getYCoordinate(i)+B.getBlockHeight(i)+20);
t[i].setX(B.getXCoordinate(i));
t[i].setFont(new Font(10));
}
Lines l =new Lines(s);
l.setLines();
Path []p=l.getPaths();
Pane pane=new Pane();
pane.getChildren().addAll(t);
pane.getChildren().addAll(r);
pane.getChildren().add(p[0]);
pane.getChildren().add(p[1]);
pane.getChildren().add(p[3]);
pane.getChildren().add(p[5]);
Scene scene =new Scene(pane,B.getTotalBlocksWidth(),B.getTotalBlockHeight());
primaryStage.setScene(scene);
primaryStage.setTitle("Simulation");
primaryStage.show();
}
public static void main(String[] args) throws IOException {
Application.launch(args);
}
}