Skip to content
Snippets Groups Projects
Commit 4d82a6d9 authored by NikolaBabic's avatar NikolaBabic
Browse files

Merge branch 'Base_System'

# Conflicts:
#	src/model/Modifier.java
parents f20478a2 e0d91a53
No related branches found
No related tags found
1 merge request!36Base system
*.iml
/.idea/*
/out/*
\ No newline at end of file
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("ui/main.fxml"));
primaryStage.setTitle("Main Window");
primaryStage.setScene(new Scene(root, 300, 275));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
package model;
import java.awt.*;
public class Action extends Hotkey implements InputEmulator{
/**
* Robot which simulates user key presses
*/
Robot robot;
/**
* Constructs an immutable hotkey.
* @param keyCode The virtual keycode of the hotkey.
* @param id The unique ID of the hotkey.
* @param modifier The modifier of the hotkey.
*/
public Action(int keyCode, int id, Modifier modifier) throws AWTException {
super(keyCode, id, modifier);
this.robot = new Robot();
}
/**
* Sends a given key to be emulated.
* @param keyCode The virtual keycode of the key.
* @param release True if the key is to be a key release input.
*/
@Override
public void sendKey(int keyCode, boolean release) {
if (release) {
robot.keyPress(this.getKeyCode());
robot.keyRelease(this.getKeyCode());
}
}
}
package model;
public class Binding {
/**
* Hotkey to be bound to an action
*/
Hotkey hotkey;
/**
* Action preformed when hotkey is pressed
*/
Action action;
/**
* The id of the hotkey and action pairing
*/
int id;
/**
* Constructor to bind the hotkey and the action together
* @param hotkey hotkey which is submitted
* @param action the action to be preformed when the hotkey is pressed
*/
public Binding(Hotkey hotkey, Action action){
this.hotkey = hotkey;
this.action = action;
this.id = hotkey.getID();
}
}
......@@ -23,52 +23,51 @@ public enum Modifier {
}
/**
* Outputs the combined values of two different given modifiers.
*
* @return The combined values of the given modifiers.
* Outputs the combined values of this and another modifier.
* @return The combined values of the modifiers.
* 0 if there are duplicate modifiers.
*/
public int combine(Modifier m1, Modifier m2) {
if (m1 == m2)
public int combine(Modifier m1) {
if (m1 == this)
return 0;
else
return m1.val() + m2.val();
return m1.val() + this.val();
}
/**
* Outputs the combined values of the three different given modifiers.
* @return The combined values of the given modifiers.
* Outputs the combined values of this and two other given modifiers.
* @return The combined values of the modifiers.
* 0 if there are duplicate modifiers.
*/
public int combine(Modifier m1, Modifier m2, Modifier m3) {
if (m1 == m2 || m1 == m3 || m2 == m3)
public int combine(Modifier m1, Modifier m2) {
if (this == m1 || this == m2 || m1 == m2)
return 0;
else
return m1.val() + m2.val() + m3.val();
return this.val() + m1.val() + m2.val();
}
/**
* Outputs the combined values of the four different given modifiers.
* @return The combined values of the given modifiers.
* Outputs the combined values of this and three different given modifiers.
* @return The combined values of the modifiers.
* 0 if there are duplicate modifiers.
*/
public int combine(Modifier m1, Modifier m2, Modifier m3, Modifier m4) {
if (m1 == m2 || m1 == m3 || m1 == m4 || m2 == m3 || m2 == m4 || m3 == m4)
public int combine(Modifier m1, Modifier m2, Modifier m3) {
if (this == m1 || this == m2 || this == m3 || m1 == m2 || m1 == m3 || m2 == m3)
return 0;
else
return m1.val() + m2.val() + m3.val() + m4.val();
return this.val() + m1.val() + m2.val() + m3.val();
}
/**
* Outputs the combined values of the five different given modifiers.
* Outputs the combined values of the this and four different given modifiers.
* @return The combined values of the given modifiers.
* 0 if there are duplicate modifiers.
*/
public int combine(Modifier m1, Modifier m2, Modifier m3, Modifier m4, Modifier m5) {
if (m1 == m2 || m1 == m3 || m1 == m4 || m1 == m5 || m2 == m3 || m2 == m4 ||
m2 == m5 || m3 == m4 || m4 == m5)
public int combine(Modifier m1, Modifier m2, Modifier m3, Modifier m4) {
if (this == m1 || this == m2 || this == m3 || this == m4 || m1 == m2 || m1 == m3 ||
m1 == m4 || m2 == m3 || m2 == m4 || m3 == m4)
return 0;
else
return m1.val() + m2.val() + m3.val() + m4.val() + m4.val();
return this.val() + m1.val() + m2.val() + m3.val() + m4.val();
}
}
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.*?>
<AnchorPane xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="Main"
prefHeight="400.0" prefWidth="600.0">
</AnchorPane>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment