Skip to content

Commit a403730

Browse files
committed
TP1 - completed
1 parent 1a5d73a commit a403730

30 files changed

+2257
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/.vscode
2+
/.idea
3+
/target
4+
*.jar

dependency-reduced-pom.xml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.leonjr</groupId>
5+
<artifactId>computer_graphics</artifactId>
6+
<version>1.0</version>
7+
<build>
8+
<plugins>
9+
<plugin>
10+
<artifactId>maven-compiler-plugin</artifactId>
11+
<version>3.8.1</version>
12+
<configuration>
13+
<source>17</source>
14+
<target>17</target>
15+
<annotationProcessorPaths>
16+
<annotationProcessorPath>
17+
<groupId>org.projectlombok</groupId>
18+
<artifactId>lombok</artifactId>
19+
<version>1.18.32</version>
20+
</annotationProcessorPath>
21+
</annotationProcessorPaths>
22+
</configuration>
23+
</plugin>
24+
<plugin>
25+
<artifactId>maven-shade-plugin</artifactId>
26+
<version>3.2.4</version>
27+
<executions>
28+
<execution>
29+
<phase>package</phase>
30+
<goals>
31+
<goal>shade</goal>
32+
</goals>
33+
</execution>
34+
</executions>
35+
<configuration>
36+
<transformers>
37+
<transformer />
38+
</transformers>
39+
<transformers>
40+
<transformer>
41+
<mainClass>com.leonjr.Launcher</mainClass>
42+
</transformer>
43+
</transformers>
44+
</configuration>
45+
</plugin>
46+
<plugin>
47+
<groupId>org.openjfx</groupId>
48+
<artifactId>javafx-maven-plugin</artifactId>
49+
<version>0.0.8</version>
50+
<executions>
51+
<execution>
52+
<id>default-cli</id>
53+
<configuration>
54+
<mainClass>com.leonjr.MainApp</mainClass>
55+
</configuration>
56+
</execution>
57+
</executions>
58+
</plugin>
59+
</plugins>
60+
</build>
61+
<dependencies>
62+
<dependency>
63+
<groupId>org.projectlombok</groupId>
64+
<artifactId>lombok</artifactId>
65+
<version>1.18.32</version>
66+
<scope>provided</scope>
67+
</dependency>
68+
</dependencies>
69+
<properties>
70+
<maven.compiler.target>17</maven.compiler.target>
71+
<maven.compiler.source>17</maven.compiler.source>
72+
<javafx.version>22</javafx.version>
73+
</properties>
74+
</project>

pom.xml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>com.leonjr</groupId>
6+
<artifactId>computer_graphics</artifactId>
7+
<version>1.0</version>
8+
9+
<properties>
10+
<maven.compiler.source>17</maven.compiler.source>
11+
<maven.compiler.target>17</maven.compiler.target>
12+
<javafx.version>22</javafx.version>
13+
</properties>
14+
15+
<dependencies>
16+
<dependency>
17+
<groupId>org.projectlombok</groupId>
18+
<artifactId>lombok</artifactId>
19+
<version>1.18.32</version>
20+
<scope>provided</scope>
21+
</dependency>
22+
<dependency>
23+
<groupId>org.openjfx</groupId>
24+
<artifactId>javafx-controls</artifactId>
25+
<version>22</version>
26+
<classifier>win</classifier>
27+
</dependency>
28+
<dependency>
29+
<groupId>org.openjfx</groupId>
30+
<artifactId>javafx-fxml</artifactId>
31+
<version>22</version>
32+
<classifier>win</classifier>
33+
</dependency>
34+
<dependency>
35+
<groupId>org.openjfx</groupId>
36+
<artifactId>javafx-graphics</artifactId>
37+
<version>22</version>
38+
<classifier>win</classifier>
39+
</dependency>
40+
<dependency>
41+
<groupId>io.github.mkpaz</groupId>
42+
<artifactId>atlantafx-base</artifactId>
43+
<version>2.0.1</version>
44+
</dependency>
45+
<dependency>
46+
<groupId>org.kordamp.ikonli</groupId>
47+
<artifactId>ikonli-materialdesign2-pack</artifactId>
48+
<version>12.3.1</version>
49+
</dependency>
50+
<dependency>
51+
<groupId>org.kordamp.ikonli</groupId>
52+
<artifactId>ikonli-javafx</artifactId>
53+
<version>12.3.1</version>
54+
</dependency>
55+
<dependency>
56+
<groupId>org.openjfx</groupId>
57+
<artifactId>javafx-swing</artifactId>
58+
<version>22</version>
59+
<classifier>win</classifier>
60+
</dependency>
61+
</dependencies>
62+
63+
<build>
64+
<plugins>
65+
<plugin>
66+
<groupId>org.apache.maven.plugins</groupId>
67+
<artifactId>maven-compiler-plugin</artifactId>
68+
<version>3.8.1</version>
69+
<configuration>
70+
<source>17</source>
71+
<target>17</target>
72+
<annotationProcessorPaths>
73+
<annotationProcessorPath>
74+
<groupId>org.projectlombok</groupId>
75+
<artifactId>lombok</artifactId>
76+
<version>1.18.32</version>
77+
</annotationProcessorPath>
78+
</annotationProcessorPaths>
79+
</configuration>
80+
</plugin>
81+
<plugin>
82+
<groupId>org.apache.maven.plugins</groupId>
83+
<artifactId>maven-shade-plugin</artifactId>
84+
<version>3.2.4</version>
85+
<configuration>
86+
<transformers>
87+
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
88+
</transformers>
89+
<transformers>
90+
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
91+
<mainClass>com.leonjr.Launcher</mainClass>
92+
</transformer>
93+
</transformers>
94+
</configuration>
95+
<executions>
96+
<execution>
97+
<phase>package</phase>
98+
<goals>
99+
<goal>shade</goal>
100+
</goals>
101+
</execution>
102+
</executions>
103+
</plugin>
104+
<plugin>
105+
<groupId>org.openjfx</groupId>
106+
<artifactId>javafx-maven-plugin</artifactId>
107+
<version>0.0.8</version>
108+
<executions>
109+
<execution>
110+
<id>default-cli</id>
111+
<configuration>
112+
<mainClass>com.leonjr.MainApp</mainClass>
113+
</configuration>
114+
</execution>
115+
</executions>
116+
</plugin>
117+
</plugins>
118+
</build>
119+
</project>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.leonjr;
2+
3+
public class Launcher {
4+
public static void main(String[] args) {
5+
/**
6+
* Main Application Entry Point to be used by the JavaFX Launcher.
7+
* Do not modify this method. Do not try to run MainApp.main(args) directly.
8+
*/
9+
MainApp.main(args);
10+
}
11+
}

src/main/java/com/leonjr/MainApp.java

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
package com.leonjr;
2+
3+
import java.io.IOException;
4+
5+
import com.leonjr.controllers.PrimaryController;
6+
7+
import atlantafx.base.theme.Dracula;
8+
import javafx.application.Application;
9+
import javafx.fxml.FXMLLoader;
10+
import javafx.geometry.Rectangle2D;
11+
import javafx.scene.Scene;
12+
import javafx.scene.image.Image;
13+
import javafx.scene.paint.Color;
14+
import javafx.stage.Screen;
15+
import javafx.stage.Stage;
16+
17+
public class MainApp extends Application {
18+
19+
private static Scene scene;
20+
21+
@Override
22+
public void start(Stage stage) throws IOException {
23+
Application.setUserAgentStylesheet(new Dracula().getUserAgentStylesheet());
24+
FXMLLoader loader = loadFXML("primary");
25+
var screenSize = getComputerScreenSize();
26+
scene = new Scene(loader.load(), screenSize[0], screenSize[1]);
27+
scene.setFill(Color.TRANSPARENT);
28+
PrimaryController controller = loader.getController();
29+
controller.setStage(stage);
30+
controller.setLastWidth(screenSize[0] / 2);
31+
controller.setLastHeight(screenSize[1] / 2);
32+
Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
33+
controller.setLastX((primaryScreenBounds.getMaxX() / 2) - screenSize[0] / 4);
34+
controller.setLastY((primaryScreenBounds.getMaxY() / 2) - screenSize[1] / 4);
35+
stage.initStyle(javafx.stage.StageStyle.TRANSPARENT);
36+
stage.setScene(scene);
37+
stage.setTitle("Computer graphics pratical assignment - Leon Junio");
38+
stage.getIcons().add(loadImageAsset("logo.jpeg"));
39+
stage.setResizable(true);
40+
stage.show();
41+
controller.startKeyBindings();
42+
}
43+
44+
/**
45+
* Get the size of the computer screen.
46+
* Minimum size is 800x600.
47+
*
48+
* @return An array with the width and height of the screen.
49+
*/
50+
static double[] getComputerScreenSize() {
51+
double[] screenSize = new double[2];
52+
Rectangle2D screenBounds = Screen.getPrimary().getBounds();
53+
screenSize[0] = screenBounds.getWidth();
54+
screenSize[1] = screenBounds.getHeight();
55+
if (screenSize[0] < 800) {
56+
screenSize[0] = 800;
57+
}
58+
if (screenSize[1] < 600) {
59+
screenSize[1] = 600;
60+
}
61+
return screenSize;
62+
}
63+
64+
static void setRoot(String fxml) throws IOException {
65+
scene.setRoot(loadFXML(fxml).load());
66+
}
67+
68+
public static FXMLLoader loadFXML(String fxml) throws IOException {
69+
FXMLLoader fxmlLoader = new FXMLLoader(MainApp.class.getResource("/fxml/" + fxml + ".fxml"));
70+
return fxmlLoader;
71+
}
72+
73+
public static Image loadImageAsset(String assetName) {
74+
return new Image(MainApp.class.getResourceAsStream("/assets/" + assetName));
75+
}
76+
77+
public static Scene getScene() {
78+
return scene;
79+
}
80+
81+
public static void main(String[] args) {
82+
launch();
83+
}
84+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.leonjr.confs;
2+
3+
import java.io.Serializable;
4+
5+
import javafx.scene.paint.Color;
6+
7+
public class UserConfs implements Serializable {
8+
9+
public static final long serialVersionUID = 1L;
10+
11+
public static Color CANVAS_COLOR;
12+
public static int CANVAS_WIDTH = 800;
13+
public static int CANVAS_HEIGHT = 600;
14+
public static Color LINE_COLOR;
15+
16+
// renders and rasters
17+
public static boolean DDA_RASTER = true;
18+
19+
// clipping
20+
public static boolean COHEN_SUTHERLAND = false;
21+
22+
// Reflections
23+
public static byte REFLECTION_TYPE = 0;
24+
25+
}

0 commit comments

Comments
 (0)