Skip to content
Snippets Groups Projects
Commit c9978ab5 authored by Jan Kožusznik's avatar Jan Kožusznik
Browse files

lab07-efrei

parent 3ddb6d0b
Branches
No related merge requests found
README.md 100644 → 100755
File mode changed from 100644 to 100755
......@@ -3,7 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>vsb-cs-java1</groupId>
<artifactId>lab01</artifactId>
<artifactId>lab07-efrei</artifactId>
<version>0.0.1-SNAPHOST</version>
<packaging>jar</packaging>
<properties>
......
package lab;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
/**
* Class <b>App</b> - extends class Application and it is an entry point of the program
* @author Java I
*/
public class App extends Application {
public static void main(String[] args) {
launch(args);
}
private Canvas canvas;
@Override
public void start(Stage primaryStage) {
try {
//Construct a main window with a canvas.
Group root = new Group();
canvas = new Canvas(800, 400);
root.getChildren().add(canvas);
Scene scene = new Scene(root, 800, 400);
scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.resizableProperty().set(false);
primaryStage.setTitle("Java 1 - 1th laboratory");
primaryStage.show();
//Exit program when main window is closed
primaryStage.setOnCloseRequest(this::exitProgram);
//Draw scene on a separate thread to avoid blocking UI.
Platform.runLater(this::drawScene);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Draws objects into the canvas. Put you code here.
*
*@return nothing
*/
private void drawScene() {
//graphic context is used for a painting
GraphicsContext gc = canvas.getGraphicsContext2D();
// put your code here
// gc.setFill(Color.AQUA);
// gc.setStroke(Color.BLACK);
}
private void exitProgram(WindowEvent evt) {
System.exit(0);
}
}
\ No newline at end of file
/*******************************************************************************
* Kožusznik Jan
* Copyright (c) 2014 All Right Reserved, http://www.kozusznik.cz
*
* This file is subject to the terms and conditions defined in
* file 'LICENSE.txt', which is part of this source code package.
******************************************************************************/
package lab;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
/**
* @author Jan Kožusznik
* @version 0.1
*/
public class Book {
private final String data;
/**
*
*/
public Book() {
data = getText();
}
public Collection<String> getWords() {
String[] tokens = getText().split("[\\- \t\n.,;:()\\[\\]{}\"]+");
return new ArrayList<>(Arrays.asList(tokens));
}
@Override
public String toString() {
return data;
}
private String getText() {
StringBuilder sb = new StringBuilder();
try(BufferedReader br = new BufferedReader(new InputStreamReader(Book.class.getResourceAsStream("book.txt")))) {
String line;
while((line = br.readLine()) != null) {
sb.append(line).append('\n');
}
} catch (IOException e) {
e.printStackTrace();
return "";
}
return sb.toString();
}
}
module lab01 {
module lab07.efrei {
requires transitive javafx.controls;
requires javafx.fxml;
opens lab to javafx.fxml;
......
/* JavaFX CSS - Leave this comment until you have at least create one rule which uses -fx-Property */
\ No newline at end of file
This diff is collapsed.
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment