From d4c138cf33ce23b810564339cd4e25e43c9d62e7 Mon Sep 17 00:00:00 2001 From: Dmitry Isaenko Date: Tue, 15 Oct 2019 04:31:19 +0300 Subject: [PATCH] More things for effects support --- .gitignore | 3 + .idea/vcs.xml | 6 - README.md | 4 +- .../Controllers/EffectsController.java | 131 +++++++++++++++++- .../java/logiled/Controllers/LoCodepage.java | 2 +- .../java/logiled/Controllers/LoEffects.java | 23 +++ .../logiled/Controllers/MainController.java | 5 +- src/main/resources/EffectsPane.fxml | 101 ++++---------- src/main/resources/light.css | 18 +-- 9 files changed, 200 insertions(+), 93 deletions(-) create mode 100644 .gitignore delete mode 100644 .idea/vcs.xml create mode 100644 src/main/java/logiled/Controllers/LoEffects.java diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..34e1547 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +target +.idea +*.iml \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/README.md b/README.md index 757ffdc..ff0b474 100644 --- a/README.md +++ b/README.md @@ -24,11 +24,11 @@ JRE/JDK 8u60 or higher. 1. Install JRE/JDK 8u60 or higher (openJDK is good. Oracle's one is also good). JavaFX not needed (it's embedded). -2. `root # java -jar /path/to/NS-USBloader.jar` +2. `root # java -jar /path/to/application.jar` 3. Optional. Add user to 'udev' rules to use NS not-from-root-account ``` -root # vim /etc/udev/rules.d/99-NS.rules +root # vim /etc/udev/rules.d/99-G513.rules SUBSYSTEM=="usb", ATTRS{idVendor}=="046D", ATTRS{idProduct}=="c33c", GROUP="plugdev" root # udevadm control --reload-rules && udevadm trigger ``` diff --git a/src/main/java/logiled/Controllers/EffectsController.java b/src/main/java/logiled/Controllers/EffectsController.java index 36411aa..db60126 100644 --- a/src/main/java/logiled/Controllers/EffectsController.java +++ b/src/main/java/logiled/Controllers/EffectsController.java @@ -1,20 +1,149 @@ package logiled.Controllers; +import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.fxml.Initializable; -import javafx.scene.control.ToggleGroup; +import javafx.scene.control.*; import java.net.URL; +import java.util.HashMap; import java.util.ResourceBundle; public class EffectsController implements Initializable { + @FXML + private MenuButton effectsMenu; + @FXML private ToggleGroup effectsToggleGrp; + @FXML + private RadioMenuItem disRMI, + constRMI, + breathRMI, + circlesOnPressRMI, + cycleRMI, + hWaveFrwRMI, + vWaveFrwRMI, + cntrToEdgWaveRMI, + hWaveBkwRMI, + vWaveBkwRMI, + edgToCntrWaveRMI; + + @FXML + private ColorPicker mainClrPkr; + + @FXML + private Slider mainSlide; + + @FXML + private Label mainSlideInfoLbl; + @Override public void initialize(URL url, ResourceBundle resourceBundle) { + mainSlide.valueProperty().addListener((observableValue, oldValue, newValue) -> mainSlideInfoLbl.setText(Long.toString(newValue.longValue()))); + mainSlideInfoLbl.setText(String.format("%.0f", mainSlide.getValue())); + effectsMenu.setText(((RadioMenuItem) effectsToggleGrp.getSelectedToggle()).getText()); } + @FXML + private void selectEffect(ActionEvent event){ + final RadioMenuItem item = (RadioMenuItem) event.getSource(); + effectsMenu.setText(item.getText()); + switch (item.getId()){ + case "disRMI": + mainClrPkr.setVisible(false); + mainSlide.setVisible(false); + mainSlideInfoLbl.setVisible(false); + break; + case "constRMI": + case "breathRMI": + mainClrPkr.setVisible(true); + mainSlide.setVisible(false); + mainSlideInfoLbl.setVisible(false); + break; + case "cycleRMI": + mainClrPkr.setVisible(false); + mainSlide.setVisible(true); + mainSlideInfoLbl.setVisible(true); + mainSlide.setMin(20.0); + mainSlide.setMax(200.0); + mainSlide.setMajorTickUnit(10.0); + mainSlide.setBlockIncrement(10.0); + mainSlide.setValue(20.0); + break; + case "circlesOnPressRMI": + mainClrPkr.setVisible(true); + mainSlide.setVisible(true); + mainSlideInfoLbl.setVisible(true); + mainSlide.setMin(1000.0); + mainSlide.setMax(5000.0); + mainSlide.setMajorTickUnit(1000.0); + mainSlide.setBlockIncrement(100.0); + mainSlide.setValue(1000.0); + break; + case "hWaveFrwRMI": + case "vWaveFrwRMI": + case "cntrToEdgWaveRMI": + case "hWaveBkwRMI": + case "vWaveBkwRMI": + case "edgToCntrWaveRMI": + mainClrPkr.setVisible(false); + mainSlide.setVisible(true); + mainSlideInfoLbl.setVisible(true); + mainSlide.setMin(1000.0); + mainSlide.setMax(5000.0); + mainSlide.setMajorTickUnit(1000.0); + mainSlide.setBlockIncrement(100.0); + mainSlide.setValue(1000.0); + break; + } + } + + public String getEffect(){ + final RadioMenuItem item = (RadioMenuItem) effectsToggleGrp.getSelectedToggle(); + /* + HashMap effectsSet = new HashMap<>(); + byte[] meta; + + switch (item.getId()){ + case "disRMI": + effectsSet.put(LoEffects.DISABLE, null); + break; + case "constRMI": + effectsSet.put(LoEffects.CONSTANT_COLOR, ); + break; + case "breathRMI": + effectsSet.put(LoEffects.BREATH, ); + break; + case "cycleRMI": + effectsSet.put(LoEffects.CYCLE, ); + break; + case "circlesOnPressRMI": + effectsSet.put(LoEffects.CIRCLES_ON_PRESS, ); + break; + case "hWaveFrwRMI": + effectsSet.put(LoEffects.WAVE_HORIZONTAL_FRW, ); + break; + case "vWaveFrwRMI": + effectsSet.put(LoEffects.WAVE_VERTICAL_FRW, ); + break; + case "cntrToEdgWaveRMI": + effectsSet.put(LoEffects.WAVE_CENTER_TO_EDGE, ); + break; + case "hWaveBkwRMI": + effectsSet.put(LoEffects.WAVE_HORIZONTAL_BKW, ); + break; + case "vWaveBkwRMI": + effectsSet.put(LoEffects.WAVE_VERTICAL_BKW, ); + break; + case "edgToCntrWaveRMI": + effectsSet.put(LoEffects.WAVE_EDGE_TO_CENTER, ); + break; + } + */ + //System.out.println(LoEffects.DISABLE.getValue()); + return item.getId(); + } } \ No newline at end of file diff --git a/src/main/java/logiled/Controllers/LoCodepage.java b/src/main/java/logiled/Controllers/LoCodepage.java index d8220a0..17e732e 100644 --- a/src/main/java/logiled/Controllers/LoCodepage.java +++ b/src/main/java/logiled/Controllers/LoCodepage.java @@ -1,5 +1,5 @@ package logiled.Controllers; - +// TODO: rewrite to ENUM class LoCodepage { static byte getCode(String id){ switch (id){ diff --git a/src/main/java/logiled/Controllers/LoEffects.java b/src/main/java/logiled/Controllers/LoEffects.java new file mode 100644 index 0000000..828cc86 --- /dev/null +++ b/src/main/java/logiled/Controllers/LoEffects.java @@ -0,0 +1,23 @@ +package logiled.Controllers; + +public enum LoEffects { + DISABLE ((byte) 0), + CONSTANT_COLOR ((byte) 1), + BREATH ((byte) 2), + CIRCLES_ON_PRESS ((byte) 3), + CYCLE ((byte) 4), + WAVE_HORIZONTAL_FRW ((byte) 5), + WAVE_VERTICAL_FRW ((byte) 6), + WAVE_CENTER_TO_EDGE ((byte) 7), + WAVE_HORIZONTAL_BKW ((byte) 8), + WAVE_VERTICAL_BKW ((byte) 9), + WAVE_EDGE_TO_CENTER ((byte) 10); + + private final byte value; + + private LoEffects(byte value){ + this.value = value; + } + + public byte getValue() { return value; } +} diff --git a/src/main/java/logiled/Controllers/MainController.java b/src/main/java/logiled/Controllers/MainController.java index bdbb6db..8319ed6 100644 --- a/src/main/java/logiled/Controllers/MainController.java +++ b/src/main/java/logiled/Controllers/MainController.java @@ -51,7 +51,10 @@ public class MainController implements Initializable { commThread.setDaemon(true); commThread.start(); } - //else if (MainTabPane.getSelectionModel().getSelectedItem().getId().equals("EffectsTab")) { // todo } + else if (MainTabPane.getSelectionModel().getSelectedItem().getId().equals("EffectsTab")) { + // TODO + System.out.println(EffectsController.getEffect()); + } }); } } diff --git a/src/main/resources/EffectsPane.fxml b/src/main/resources/EffectsPane.fxml index 48a2bc0..fd43adb 100644 --- a/src/main/resources/EffectsPane.fxml +++ b/src/main/resources/EffectsPane.fxml @@ -2,7 +2,9 @@ - + + + @@ -14,84 +16,35 @@ - - - + + + - - - + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + diff --git a/src/main/resources/light.css b/src/main/resources/light.css index da23df0..7060911 100644 --- a/src/main/resources/light.css +++ b/src/main/resources/light.css @@ -35,7 +35,7 @@ -fx-text-fill: #2c2c2c; -fx-effect: dropshadow(three-pass-box, #e82382, 2, 0, 0, 0); } -// -========================+ TextArea =====================- +/* -========================+ TextArea =====================- */ .text-area{ -fx-background-color: transparent; -fx-control-inner-background: #fefefe; @@ -71,11 +71,13 @@ -fx-padding: 10 5 10 5; } +/* -======================== ToolBar =========================- */ +/* .tool-bar{ -fx-background-color: transparent; } - -// -======================== Choice box =========================- +*/ +/* -======================== Choice box =========================- */ .choice-box { -fx-background-color: #fefefe; -fx-border-color: #fefefe; @@ -111,7 +113,7 @@ -fx-text-fill: #2c2c2c; } -// -======================== TAB PANE =========================- +/* -======================== TAB PANE =========================- */ .tab-pane .tab SVGPath{ -fx-fill: #2c2c2c; } @@ -152,7 +154,7 @@ .tab-pane > .tab-header-area > .headers-region > .tab { -fx-padding: 10; } -// -=========================== TABLE ======================- +/* -=========================== TABLE ======================- */ .table-view { -fx-background-color: #fefefe; -fx-background-image: url(app_logo.png); @@ -201,7 +203,7 @@ -fx-padding: 0.0em; /* 0 */ -fx-table-cell-border-color: #b0b0b0; } -// -========================== Context menu =====================- +/* -========================== Context menu =====================- */ .context-menu { -fx-background-color: #fefefe; -fx-cursor: hand; @@ -212,7 +214,7 @@ .context-menu .menu-item:focused .label { -fx-text-fill: white; } -// -========================== Text Field =====================- +/* -========================== Text Field =====================- */ .text-field { -fx-border-color: #289de8; -fx-border-width: 0 0 1 0; @@ -225,7 +227,7 @@ -fx-background-color: transparent; -fx-text-fill: #e82382; } -// -========================== footer pane =====================- +/* -========================== footer pane =====================- */ .footer{ -fx-background-color: #ffffff; }