diff --git a/Automata/.idea/artifacts/Java_lab_5_jar.xml b/Automata/.idea/artifacts/Java_lab_5_jar.xml new file mode 100644 index 0000000..37247ea --- /dev/null +++ b/Automata/.idea/artifacts/Java_lab_5_jar.xml @@ -0,0 +1,8 @@ + + + $PROJECT_DIR$/out/artifacts/Java_lab_5_jar + + + + + \ No newline at end of file diff --git a/Automata/.idea/compiler.xml b/Automata/.idea/compiler.xml new file mode 100644 index 0000000..217af47 --- /dev/null +++ b/Automata/.idea/compiler.xml @@ -0,0 +1,23 @@ + + + + + + diff --git a/Automata/.idea/description.html b/Automata/.idea/description.html new file mode 100644 index 0000000..cc10d56 --- /dev/null +++ b/Automata/.idea/description.html @@ -0,0 +1,2 @@ +Simple JavaFX 2.0 application that includes simple .fxml file with attached controller and Main class to quick start. Artifact to build JavaFX application is provided. + \ No newline at end of file diff --git a/Automata/.idea/encodings.xml b/Automata/.idea/encodings.xml new file mode 100644 index 0000000..97626ba --- /dev/null +++ b/Automata/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Automata/.idea/gradle.xml b/Automata/.idea/gradle.xml new file mode 100644 index 0000000..3e3960b --- /dev/null +++ b/Automata/.idea/gradle.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Automata/.idea/misc.xml b/Automata/.idea/misc.xml new file mode 100644 index 0000000..4e6e724 --- /dev/null +++ b/Automata/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/Automata/.idea/modules.xml b/Automata/.idea/modules.xml new file mode 100644 index 0000000..96b462c --- /dev/null +++ b/Automata/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Automata/.idea/uiDesigner.xml b/Automata/.idea/uiDesigner.xml new file mode 100644 index 0000000..3b00020 --- /dev/null +++ b/Automata/.idea/uiDesigner.xml @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Automata/.idea/vcs.xml b/Automata/.idea/vcs.xml new file mode 100644 index 0000000..def6a6a --- /dev/null +++ b/Automata/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Automata/.idea/workspace.xml b/Automata/.idea/workspace.xml new file mode 100644 index 0000000..3d3c989 --- /dev/null +++ b/Automata/.idea/workspace.xml @@ -0,0 +1,270 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + localhost + 5050 + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1359379246138 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Automata/Java-lab-5.iml b/Automata/Java-lab-5.iml new file mode 100644 index 0000000..d5c0743 --- /dev/null +++ b/Automata/Java-lab-5.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/Automata/out/artifacts/Java_lab_5_jar/Java-lab-5.jar b/Automata/out/artifacts/Java_lab_5_jar/Java-lab-5.jar new file mode 100644 index 0000000..b6e1409 Binary files /dev/null and b/Automata/out/artifacts/Java_lab_5_jar/Java-lab-5.jar differ diff --git a/Automata/out/production/Java-lab-5/Automata/Automata$States.class b/Automata/out/production/Java-lab-5/Automata/Automata$States.class new file mode 100644 index 0000000..477eabf Binary files /dev/null and b/Automata/out/production/Java-lab-5/Automata/Automata$States.class differ diff --git a/Automata/out/production/Java-lab-5/Automata/Automata.class b/Automata/out/production/Java-lab-5/Automata/Automata.class new file mode 100644 index 0000000..1f0ca91 Binary files /dev/null and b/Automata/out/production/Java-lab-5/Automata/Automata.class differ diff --git a/Automata/out/production/Java-lab-5/Automata/Controller.class b/Automata/out/production/Java-lab-5/Automata/Controller.class new file mode 100644 index 0000000..f9ae772 Binary files /dev/null and b/Automata/out/production/Java-lab-5/Automata/Controller.class differ diff --git a/Automata/out/production/Java-lab-5/Automata/Main.class b/Automata/out/production/Java-lab-5/Automata/Main.class new file mode 100644 index 0000000..866d22f Binary files /dev/null and b/Automata/out/production/Java-lab-5/Automata/Main.class differ diff --git a/Automata/out/production/Java-lab-5/Automata/coffee.png b/Automata/out/production/Java-lab-5/Automata/coffee.png new file mode 100644 index 0000000..199b88d Binary files /dev/null and b/Automata/out/production/Java-lab-5/Automata/coffee.png differ diff --git a/Automata/out/production/Java-lab-5/Automata/sample.fxml b/Automata/out/production/Java-lab-5/Automata/sample.fxml new file mode 100644 index 0000000..7400a39 --- /dev/null +++ b/Automata/out/production/Java-lab-5/Automata/sample.fxml @@ -0,0 +1,358 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Automata/out/production/Java-lab-5/Clock/Clock.class b/Automata/out/production/Java-lab-5/Clock/Clock.class new file mode 100644 index 0000000..97c9eb9 Binary files /dev/null and b/Automata/out/production/Java-lab-5/Clock/Clock.class differ diff --git a/Automata/out/production/Java-lab-5/Clock/Clock.jpg b/Automata/out/production/Java-lab-5/Clock/Clock.jpg new file mode 100644 index 0000000..ae0df05 Binary files /dev/null and b/Automata/out/production/Java-lab-5/Clock/Clock.jpg differ diff --git a/Automata/out/production/Java-lab-5/Clock/Controller$1.class b/Automata/out/production/Java-lab-5/Clock/Controller$1.class new file mode 100644 index 0000000..f57a57f Binary files /dev/null and b/Automata/out/production/Java-lab-5/Clock/Controller$1.class differ diff --git a/Automata/out/production/Java-lab-5/Clock/Controller.class b/Automata/out/production/Java-lab-5/Clock/Controller.class new file mode 100644 index 0000000..682cf97 Binary files /dev/null and b/Automata/out/production/Java-lab-5/Clock/Controller.class differ diff --git a/Automata/out/production/Java-lab-5/Clock/Main.class b/Automata/out/production/Java-lab-5/Clock/Main.class new file mode 100644 index 0000000..d6feed9 Binary files /dev/null and b/Automata/out/production/Java-lab-5/Clock/Main.class differ diff --git a/Automata/out/production/Java-lab-5/Clock/sample.fxml b/Automata/out/production/Java-lab-5/Clock/sample.fxml new file mode 100644 index 0000000..77ebd37 --- /dev/null +++ b/Automata/out/production/Java-lab-5/Clock/sample.fxml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/Automata/out/production/Java-lab-5/META-INF/Java-lab-5.kotlin_module b/Automata/out/production/Java-lab-5/META-INF/Java-lab-5.kotlin_module new file mode 100644 index 0000000..a49347a Binary files /dev/null and b/Automata/out/production/Java-lab-5/META-INF/Java-lab-5.kotlin_module differ diff --git a/Automata/out/production/Java-lab-5/META-INF/MANIFEST.MF b/Automata/out/production/Java-lab-5/META-INF/MANIFEST.MF new file mode 100644 index 0000000..faae846 --- /dev/null +++ b/Automata/out/production/Java-lab-5/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: Automata.Main + diff --git a/Automata/src/Automata/Automata.java b/Automata/src/Automata/Automata.java new file mode 100644 index 0000000..7dccf56 --- /dev/null +++ b/Automata/src/Automata/Automata.java @@ -0,0 +1,164 @@ +package Automata; + +import javafx.animation.PauseTransition; +import javafx.scene.control.Label; +import javafx.util.Duration; + +import java.util.ArrayList; + +public class Automata { + + private int cash; + private ArrayList menu = new ArrayList(); + private ArrayList prices = new ArrayList(); + + private Label condition; + private Label balance; + private Label prompt; + + public void setCondition(Label lab){ condition = lab;} + public void setBalance(Label lab){ balance = lab;} + public void setPrompt(Label lab){ prompt = lab;} + + public enum States { + OFF, + WAIT, + ACCEPT, + CHECK, + COOK + } + + States state; + + public Automata() { + this.cash = 0; + this.menu.add("Coffee"); + this.menu.add("Latte"); + this.menu.add("Cappuccino"); + this.menu.add("Mocaccino"); + this.menu.add("Chocolate"); + this.menu.add("Tea"); + this.prices.add(75); + this.prices.add(75); + this.prices.add(75); + this.prices.add(75); + this.prices.add(75); + this.prices.add(50); + this.state = States.OFF; + } + + public Integer getterCash() { return cash;} + public ArrayList getterMenu() { return menu;} + public ArrayList getterPrice() { return prices;} + + public void on() { //включение автомата; + if (state == States.OFF) { + state = States.WAIT; + condition.setText(state + "..."); + } + else + condition.setText(state + "..."); + } + + public void off() { //выключение автомата; + if (state == States.WAIT && cash == 0) { + state = States.OFF; + condition.setText(state + "..."); + } + } + + public void coin(int EntCash) { //занесение денег на счёт пользователем; + if (state == States.WAIT || state == States.ACCEPT) { + cash = cash + EntCash; + state = States.ACCEPT; + condition.setText(state + "..."); + prompt.setText("Choose a beverage!"); + } + } + + public boolean choice(int i) { //выбор напитка пользователем; + if (state == States.ACCEPT || state == States.WAIT) { + prompt.setText("Your choice is a " + menu.get(i - 1)); + state = States.CHECK; + condition.setText(state + "..."); + + } + else { + prompt.setText("Error!"); + return false; + } + + if (check(i-1) == true) { + PauseTransition pause = new PauseTransition(Duration.seconds(3)); + pause.setOnFinished(event -> { + cash = cash - prices.get(i - 1); + balance.setText(Integer.toString(cash)); + cook(i - 1); + }); + pause.play(); + + return true; + } + else + return false; + } + + private boolean check(int i) { //проверка наличия необходимой суммы; + if (state == States.CHECK && (cash - prices.get(i)) >= 0) { + prompt.setText("Check is over!"); + state = States.COOK; + return true; + } + else { + state = States.ACCEPT; + prompt.setText("Not enough money!"); + + PauseTransition pause = new PauseTransition(Duration.seconds(3)); + pause.setOnFinished(event -> { + prompt.setText("Add cash or push Return money!"); + }); + pause.play(); + return false; + } + } + + public void cancel() { //отмена сеанса обслуживания пользователем; + if (state == States.ACCEPT && cash != 0) { + prompt.setText("Return " + cash + "!"); + cash = 0; + balance.setText(Integer.toString(cash)); + state = States.WAIT; + condition.setText(state + "..."); + } + } + + private void cook(int choice) { //имитация процесса приготовления напитка; + if (state == States.COOK) { + prompt.setText("Cooking a " + menu.get(choice)); + state = States.CHECK; + + PauseTransition pause = new PauseTransition(Duration.seconds(3)); + pause.setOnFinished(event -> { + finish(); + }); + pause.play(); + } + } + + private void finish() { // завершение обслуживания пользователя. + if (cash != 0) { + prompt.setText("Return money " + cash + "!"); + cash = 0; + } + PauseTransition pause = new PauseTransition(Duration.seconds(3)); + pause.setOnFinished(event -> { + prompt.setText("Your order is over!\nTake a drink!\nThank you!"); + state = States.WAIT; + }); + pause.play(); + + balance.setText(Integer.toString(cash)); + } +} + + diff --git a/Automata/src/Automata/Controller.java b/Automata/src/Automata/Controller.java new file mode 100644 index 0000000..6425a34 --- /dev/null +++ b/Automata/src/Automata/Controller.java @@ -0,0 +1,148 @@ +package Automata; + +import javafx.fxml.FXML; +import javafx.fxml.Initializable; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.TextField; +import javafx.scene.layout.Pane; + +import java.net.URL; +import java.util.ResourceBundle; + +public class Controller implements Initializable { + + @FXML + private Pane View; + @FXML + private Button OnOff; + @FXML + private Button Buy1; + @FXML + private Button Buy2; + @FXML + private Button Buy3; + @FXML + private Button Buy4; + @FXML + private Button Buy5; + @FXML + private Button Buy6; + @FXML + private Button Enter; + @FXML + private Button Get; + @FXML + private Button ReturnCash; + @FXML + private TextField tfCash; + @FXML + private Label Bever1; + @FXML + private Label Bever2; + @FXML + private Label Bever3; + @FXML + private Label Bever4; + @FXML + private Label Bever5; + @FXML + private Label Bever6; + @FXML + private Label Price1; + @FXML + private Label Price2; + @FXML + private Label Price3; + @FXML + private Label Price4; + @FXML + private Label Price5; + @FXML + private Label Price6; + @FXML + private Label State; + @FXML + private Label Balance; + @FXML + private Label Prompt; + + Automata auto = new Automata(); + + @Override + public void initialize(URL location, ResourceBundle resources) { + Bever1.setText(auto.getterMenu().get(0)); + Bever2.setText(auto.getterMenu().get(1)); + Bever3.setText(auto.getterMenu().get(2)); + Bever4.setText(auto.getterMenu().get(3)); + Bever5.setText(auto.getterMenu().get(4)); + Bever6.setText(auto.getterMenu().get(5)); + + Price1.setText(auto.getterPrice().get(0).toString()); + Price2.setText(auto.getterPrice().get(1).toString()); + Price3.setText(auto.getterPrice().get(2).toString()); + Price4.setText(auto.getterPrice().get(3).toString()); + Price5.setText(auto.getterPrice().get(4).toString()); + Price6.setText(auto.getterPrice().get(5).toString()); + + auto.setCondition(State); + auto.setBalance(Balance); + auto.setPrompt(Prompt); + } + + @FXML + public void onOff() { + if (auto.state == Automata.States.OFF) { + auto.on(); + } else if (auto.state == Automata.States.WAIT) { + auto.off(); + } + } + + @FXML + public void enter() { + if (auto.state != Automata.States.OFF) { + auto.coin(Integer.parseInt(tfCash.getText().trim())); + System.out.println(Integer.parseInt(tfCash.getText().trim())); + Balance.setText(auto.getterCash().toString()); + tfCash.clear(); + } + } + + @FXML + public void buy1() { + auto.choice(1); + } + @FXML + public void buy2() { + auto.choice(2); + Balance.setText(auto.getterCash().toString());} + @FXML + public void buy3() { + auto.choice(3); + Balance.setText(auto.getterCash().toString()); + } + @FXML + public void buy4() { + auto.choice(4); + Balance.setText(auto.getterCash().toString());} + @FXML + public void buy5() { + auto.choice(5); + Balance.setText(auto.getterCash().toString());} + @FXML + public void buy6() { + auto.choice(6); + Balance.setText(auto.getterCash().toString());} + + public void cancel(){ + auto.cancel(); + } + + + + + +} + + diff --git a/Automata/src/Automata/Main.java b/Automata/src/Automata/Main.java new file mode 100644 index 0000000..a397770 --- /dev/null +++ b/Automata/src/Automata/Main.java @@ -0,0 +1,23 @@ +package Automata; + +import javafx.application.Application; +import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.stage.Stage; + +public class Main extends Application { + + @Override + public void start(Stage primaryStage) throws Exception{ + Parent root = FXMLLoader.load(getClass().getResource("sample.fxml")); + primaryStage.setTitle("Automata"); + primaryStage.setScene(new Scene(root)); + primaryStage.show(); + } + + + public static void main(String[] args) { + launch(args); + } +} diff --git a/Automata/src/Automata/coffee.png b/Automata/src/Automata/coffee.png new file mode 100644 index 0000000..199b88d Binary files /dev/null and b/Automata/src/Automata/coffee.png differ diff --git a/Automata/src/Automata/sample.fxml b/Automata/src/Automata/sample.fxml new file mode 100644 index 0000000..7400a39 --- /dev/null +++ b/Automata/src/Automata/sample.fxml @@ -0,0 +1,358 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Automata/src/Clock/Clock.java b/Automata/src/Clock/Clock.java new file mode 100644 index 0000000..b3ac4ee --- /dev/null +++ b/Automata/src/Clock/Clock.java @@ -0,0 +1,5 @@ +package Clock; + +public class Clock { + +} diff --git a/Automata/src/Clock/Clock.jpg b/Automata/src/Clock/Clock.jpg new file mode 100644 index 0000000..ae0df05 Binary files /dev/null and b/Automata/src/Clock/Clock.jpg differ diff --git a/Automata/src/Clock/Controller.java b/Automata/src/Clock/Controller.java new file mode 100644 index 0000000..34db063 --- /dev/null +++ b/Automata/src/Clock/Controller.java @@ -0,0 +1,81 @@ +package Clock; + +import javafx.animation.KeyFrame; +import javafx.animation.Timeline; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.fxml.FXML; +import javafx.scene.shape.Line; +import javafx.scene.transform.Rotate; +import javafx.util.Duration; + +import java.util.Calendar; +import java.util.GregorianCalendar; + +public class Controller { + @FXML + private Line secondHand; + @FXML + private Line minuteHand; + @FXML + private Line hourHand; + + int X = -600; + int Y = 0; + + Calendar calendar = new GregorianCalendar(); + + @FXML + private void initialize() { + oneSecondCheckState.setCycleCount(Timeline.INDEFINITE); + oneSecondCheckState.play(); + + int seconds=calendar.get(Calendar.SECOND); + int minutes=calendar.get(Calendar.MINUTE); + int hours=calendar.get(Calendar.HOUR); + + Rotate rotateSecond = new Rotate(); + rotateSecond.setAngle((double)(360/60)*(double)seconds); + rotateSecond.setPivotX(X); + rotateSecond.setPivotY(Y); + secondHand.getTransforms().addAll(rotateSecond); + + Rotate rotateMinute = new Rotate(); + rotateMinute.setAngle((double)(360/60)*((double)minutes+(double)seconds/(double)60)); + rotateMinute.setPivotX(X); + rotateMinute.setPivotY(Y); + minuteHand.getTransforms().addAll(rotateMinute); + + Rotate rotateHour = new Rotate(); + rotateHour.setAngle((double)(360/12)*((double)hours+(double)minutes/(double)60+(double)seconds/(double)3600)); + rotateHour.setPivotX(X); + rotateHour.setPivotY(Y); + hourHand.getTransforms().addAll(rotateHour); +} + + Timeline oneSecondCheckState = new Timeline(new KeyFrame(Duration.seconds(1), new EventHandler() { + + @Override + public void handle(ActionEvent event) { + Rotate rotateSecond = new Rotate(); + rotateSecond.setAngle(360/60); + rotateSecond.setPivotX(X); + rotateSecond.setPivotY(Y); + secondHand.getTransforms().addAll(rotateSecond); + + Rotate rotateMinute = new Rotate(); + rotateMinute.setAngle((double)360/(double)(60*60)); + rotateMinute.setPivotX(X); + rotateMinute.setPivotY(Y); + minuteHand.getTransforms().addAll(rotateMinute); + + Rotate rotateHour = new Rotate(); + rotateHour.setAngle((double)360/(double)(12*60*60)); + rotateHour.setPivotX(X); + rotateHour.setPivotY(Y); + hourHand.getTransforms().addAll(rotateHour); + + calendar.add(Calendar.SECOND, +1); + } + })); +} diff --git a/Automata/src/Clock/Main.java b/Automata/src/Clock/Main.java new file mode 100644 index 0000000..b92559c --- /dev/null +++ b/Automata/src/Clock/Main.java @@ -0,0 +1,23 @@ +package Clock; + +import javafx.application.Application; +import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.stage.Stage; + +public class Main extends Application { + + @Override + public void start(Stage primaryStage) throws Exception{ + Parent root = FXMLLoader.load(getClass().getResource("sample.fxml")); + primaryStage.setTitle("Clock"); + primaryStage.setScene(new Scene(root)); + primaryStage.show(); + } + + + public static void main(String[] args) { + launch(args); + } +} diff --git a/Automata/src/Clock/sample.fxml b/Automata/src/Clock/sample.fxml new file mode 100644 index 0000000..77ebd37 --- /dev/null +++ b/Automata/src/Clock/sample.fxml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/Automata/src/META-INF/MANIFEST.MF b/Automata/src/META-INF/MANIFEST.MF new file mode 100644 index 0000000..faae846 --- /dev/null +++ b/Automata/src/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: Automata.Main + diff --git a/Clock/.idea/artifacts/Java_lab_5_Clock_jar.xml b/Clock/.idea/artifacts/Java_lab_5_Clock_jar.xml new file mode 100644 index 0000000..66819f6 --- /dev/null +++ b/Clock/.idea/artifacts/Java_lab_5_Clock_jar.xml @@ -0,0 +1,8 @@ + + + $PROJECT_DIR$/out/artifacts/Java_lab_5_Clock_jar + + + + + \ No newline at end of file diff --git a/Clock/.idea/compiler.xml b/Clock/.idea/compiler.xml new file mode 100644 index 0000000..217af47 --- /dev/null +++ b/Clock/.idea/compiler.xml @@ -0,0 +1,23 @@ + + + + + + diff --git a/Clock/.idea/description.html b/Clock/.idea/description.html new file mode 100644 index 0000000..cc10d56 --- /dev/null +++ b/Clock/.idea/description.html @@ -0,0 +1,2 @@ +Simple JavaFX 2.0 application that includes simple .fxml file with attached controller and Main class to quick start. Artifact to build JavaFX application is provided. + \ No newline at end of file diff --git a/Clock/.idea/encodings.xml b/Clock/.idea/encodings.xml new file mode 100644 index 0000000..97626ba --- /dev/null +++ b/Clock/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Clock/.idea/gradle.xml b/Clock/.idea/gradle.xml new file mode 100644 index 0000000..3e3960b --- /dev/null +++ b/Clock/.idea/gradle.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Clock/.idea/misc.xml b/Clock/.idea/misc.xml new file mode 100644 index 0000000..4e6e724 --- /dev/null +++ b/Clock/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/Clock/.idea/modules.xml b/Clock/.idea/modules.xml new file mode 100644 index 0000000..507fd6a --- /dev/null +++ b/Clock/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Clock/.idea/uiDesigner.xml b/Clock/.idea/uiDesigner.xml new file mode 100644 index 0000000..3b00020 --- /dev/null +++ b/Clock/.idea/uiDesigner.xml @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Clock/.idea/vcs.xml b/Clock/.idea/vcs.xml new file mode 100644 index 0000000..def6a6a --- /dev/null +++ b/Clock/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Clock/.idea/workspace.xml b/Clock/.idea/workspace.xml new file mode 100644 index 0000000..d530074 --- /dev/null +++ b/Clock/.idea/workspace.xml @@ -0,0 +1,232 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + localhost + 5050 + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1359379246138 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Clock/Java-lab-5-Clock.iml b/Clock/Java-lab-5-Clock.iml new file mode 100644 index 0000000..d5c0743 --- /dev/null +++ b/Clock/Java-lab-5-Clock.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/Clock/out/artifacts/Java_lab_5_Clock_jar/Java-lab-5-Clock.jar b/Clock/out/artifacts/Java_lab_5_Clock_jar/Java-lab-5-Clock.jar new file mode 100644 index 0000000..ac08b9d Binary files /dev/null and b/Clock/out/artifacts/Java_lab_5_Clock_jar/Java-lab-5-Clock.jar differ diff --git a/Clock/out/production/Java-lab-5-Clock/META-INF/MANIFEST.MF b/Clock/out/production/Java-lab-5-Clock/META-INF/MANIFEST.MF new file mode 100644 index 0000000..440fa71 --- /dev/null +++ b/Clock/out/production/Java-lab-5-Clock/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: sample.Main + diff --git a/Clock/out/production/Java-lab-5-Clock/sample/Clock.jpg b/Clock/out/production/Java-lab-5-Clock/sample/Clock.jpg new file mode 100644 index 0000000..e3c8b7a Binary files /dev/null and b/Clock/out/production/Java-lab-5-Clock/sample/Clock.jpg differ diff --git a/Clock/out/production/Java-lab-5-Clock/sample/Controller$1.class b/Clock/out/production/Java-lab-5-Clock/sample/Controller$1.class new file mode 100644 index 0000000..d751746 Binary files /dev/null and b/Clock/out/production/Java-lab-5-Clock/sample/Controller$1.class differ diff --git a/Clock/out/production/Java-lab-5-Clock/sample/Controller.class b/Clock/out/production/Java-lab-5-Clock/sample/Controller.class new file mode 100644 index 0000000..f2bf936 Binary files /dev/null and b/Clock/out/production/Java-lab-5-Clock/sample/Controller.class differ diff --git a/Clock/out/production/Java-lab-5-Clock/sample/Main.class b/Clock/out/production/Java-lab-5-Clock/sample/Main.class new file mode 100644 index 0000000..6a8c659 Binary files /dev/null and b/Clock/out/production/Java-lab-5-Clock/sample/Main.class differ diff --git a/Clock/out/production/Java-lab-5-Clock/sample/sample.fxml b/Clock/out/production/Java-lab-5-Clock/sample/sample.fxml new file mode 100644 index 0000000..69b52e7 --- /dev/null +++ b/Clock/out/production/Java-lab-5-Clock/sample/sample.fxml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/Clock/src/META-INF/MANIFEST.MF b/Clock/src/META-INF/MANIFEST.MF new file mode 100644 index 0000000..440fa71 --- /dev/null +++ b/Clock/src/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: sample.Main + diff --git a/Clock/src/sample/Clock.jpg b/Clock/src/sample/Clock.jpg new file mode 100644 index 0000000..e3c8b7a Binary files /dev/null and b/Clock/src/sample/Clock.jpg differ diff --git a/Clock/src/sample/Controller.java b/Clock/src/sample/Controller.java new file mode 100644 index 0000000..a744b0a --- /dev/null +++ b/Clock/src/sample/Controller.java @@ -0,0 +1,81 @@ +package sample; + +import javafx.animation.KeyFrame; +import javafx.animation.Timeline; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.fxml.FXML; +import javafx.scene.shape.Line; +import javafx.scene.transform.Rotate; +import javafx.util.Duration; + +import java.util.Calendar; +import java.util.GregorianCalendar; + +public class Controller { + @FXML + private Line secondHand; + @FXML + private Line minuteHand; + @FXML + private Line hourHand; + + int X = 410; + int Y = 400; + + Calendar calendar = new GregorianCalendar(); + + @FXML + private void initialize() { + oneSecondCheckState.setCycleCount(Timeline.INDEFINITE); + oneSecondCheckState.play(); + + int seconds=calendar.get(Calendar.SECOND); + int minutes=calendar.get(Calendar.MINUTE); + int hours=calendar.get(Calendar.HOUR); + + Rotate rotateSecond = new Rotate(); + rotateSecond.setAngle((double)(360/60)*(double)seconds); + rotateSecond.setPivotX(X); + rotateSecond.setPivotY(Y); + secondHand.getTransforms().addAll(rotateSecond); + + Rotate rotateMinute = new Rotate(); + rotateMinute.setAngle((double)(360/60)*((double)minutes+(double)seconds/(double)60)); + rotateMinute.setPivotX(X); + rotateMinute.setPivotY(Y); + minuteHand.getTransforms().addAll(rotateMinute); + + Rotate rotateHour = new Rotate(); + rotateHour.setAngle((double)(360/12)*((double)hours+(double)minutes/(double)60+(double)seconds/(double)3600)); + rotateHour.setPivotX(X); + rotateHour.setPivotY(Y); + hourHand.getTransforms().addAll(rotateHour); + } + + Timeline oneSecondCheckState = new Timeline(new KeyFrame(Duration.seconds(1), new EventHandler() { + + @Override + public void handle(ActionEvent event) { + Rotate rotateSecond = new Rotate(); + rotateSecond.setAngle(360/60); + rotateSecond.setPivotX(X); + rotateSecond.setPivotY(Y); + secondHand.getTransforms().addAll(rotateSecond); + + Rotate rotateMinute = new Rotate(); + rotateMinute.setAngle((double)360/(double)(60*60)); + rotateMinute.setPivotX(X); + rotateMinute.setPivotY(Y); + minuteHand.getTransforms().addAll(rotateMinute); + + Rotate rotateHour = new Rotate(); + rotateHour.setAngle((double)360/(double)(12*60*60)); + rotateHour.setPivotX(X); + rotateHour.setPivotY(Y); + hourHand.getTransforms().addAll(rotateHour); + + calendar.add(Calendar.SECOND, +1); + } + })); +} \ No newline at end of file diff --git a/Clock/src/sample/Main.java b/Clock/src/sample/Main.java new file mode 100644 index 0000000..6a162e1 --- /dev/null +++ b/Clock/src/sample/Main.java @@ -0,0 +1,23 @@ +package sample; + +import javafx.application.Application; +import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.stage.Stage; + +public class Main extends Application { + + @Override + public void start(Stage primaryStage) throws Exception{ + Parent root = FXMLLoader.load(getClass().getResource("sample.fxml")); + primaryStage.setTitle("Clock"); + primaryStage.setScene(new Scene(root)); + primaryStage.show(); + } + + + public static void main(String[] args) { + launch(args); + } +} diff --git a/Clock/src/sample/sample.fxml b/Clock/src/sample/sample.fxml new file mode 100644 index 0000000..69b52e7 --- /dev/null +++ b/Clock/src/sample/sample.fxml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + +