Reorganise image settings and add adjustable image translation scrolling increment

pull/53/head v1.19.4
James Ball 2022-03-16 21:12:34 +00:00
rodzic 2be2006667
commit 88f3f25754
6 zmienionych plików z 91 dodań i 37 usunięć

Wyświetl plik

@ -6,7 +6,7 @@
<groupId>sh.ball</groupId>
<artifactId>osci-render</artifactId>
<version>1.19.3</version>
<version>1.19.4</version>
<name>osci-render</name>

Wyświetl plik

@ -19,10 +19,7 @@ import sh.ball.audio.midi.MidiNote;
import sh.ball.shapes.Vector2;
import java.net.URL;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle;
import java.util.function.Consumer;
@ -34,13 +31,14 @@ public class ImageController implements Initializable, SubController {
private static final double MAX_FREQUENCY = 12000;
private static final int DEFAULT_SAMPLE_RATE = 192000;
private static final double SCROLL_DELTA = 0.05;
private final RotateEffect rotateEffect;
private final TranslateEffect translateEffect;
private final DoubleProperty frequency;
private double scrollDelta = 0.05;
@FXML
private TextField translationXTextField;
@FXML
@ -105,6 +103,10 @@ public class ImageController implements Initializable, SubController {
translationYTextField.setText(MainController.FORMAT.format(translation.getY()));
}
public void setTranslationIncrement(double increment) {
this.scrollDelta = increment;
}
// changes the sinusoidal translation of the image rendered
private void updateTranslation() {
translateEffect.setTranslation(new Vector2(
@ -115,7 +117,7 @@ public class ImageController implements Initializable, SubController {
private void changeTranslation(boolean increase, TextField field) {
double old = tryParse(field.getText());
double delta = increase ? SCROLL_DELTA : -SCROLL_DELTA;
double delta = increase ? scrollDelta : -scrollDelta;
field.setText(MainController.FORMAT.format(old + delta));
}

Wyświetl plik

@ -122,6 +122,8 @@ public class MainController implements Initializable, FrequencyListener, MidiLis
@FXML
private Spinner<Integer> midiChannelSpinner;
@FXML
private Spinner<Double> translationIncrementSpinner;
@FXML
private ComboBox<PrintableSlider> sliderComboBox;
@FXML
private TextField sliderMinTextField;
@ -263,6 +265,9 @@ public class MainController implements Initializable, FrequencyListener, MidiLis
midiChannelSpinner.getEditor().setTextFormatter(new TextFormatter<>(new IntegerStringConverter(), 0, filter));
midiChannelSpinner.valueProperty().addListener((o, oldValue, newValue) -> audioPlayer.setMainMidiChannel(newValue));
translationIncrementSpinner.setValueFactory(new SpinnerValueFactory.DoubleSpinnerValueFactory(-2, 2, 0.05, 0.01));
translationIncrementSpinner.valueProperty().addListener((o, oldValue, newValue) -> imageController.setTranslationIncrement(newValue));
List<PrintableSlider> printableSliders = new ArrayList<>();
sliders.forEach(slider -> printableSliders.add(new PrintableSlider(slider)));
sliderComboBox.setItems(FXCollections.observableList(printableSliders));
@ -670,6 +675,10 @@ public class MainController implements Initializable, FrequencyListener, MidiLis
root.appendChild(flipX);
root.appendChild(flipY);
Element translationIncrement = document.createElement("translationIncrement");
translationIncrement.appendChild(document.createTextNode(translationIncrementSpinner.getValue().toString()));
root.appendChild(translationIncrement);
Element filesElement = document.createElement("files");
for (int i = 0; i < openFiles.size(); i++) {
Element fileElement = document.createElement("file");
@ -758,6 +767,11 @@ public class MainController implements Initializable, FrequencyListener, MidiLis
flipYCheckMenuItem.setSelected(Boolean.parseBoolean(flipY.getTextContent()));
}
Element translationIncrement = (Element) root.getElementsByTagName("translationIncrement").item(0);
if (translationIncrement != null) {
translationIncrementSpinner.getValueFactory().setValue(Double.parseDouble(translationIncrement.getTextContent()));
}
Element filesElement = (Element) root.getElementsByTagName("files").item(0);
List<byte[]> files = new ArrayList<>();
List<String> fileNames = new ArrayList<>();

Wyświetl plik

@ -288,4 +288,32 @@
/*** The context menu that contains a menu's menu items ***/
.context-menu {
-fx-background-color: -fx-my-menu-color;
}
.spinner .increment-arrow-button {
-fx-border-width: 1px 1px 0 0;
-fx-border-color: white;
}
.spinner .decrement-arrow-button {
-fx-border-width: 0 1px 1px 0;
-fx-border-color: white;
}
.spinner .increment-arrow-button,
.spinner .decrement-arrow-button {
-fx-background-color: very_dark;
-fx-background-radius: 0;
}
.spinner .increment-arrow-button:hover,
.spinner .decrement-arrow-button:hover {
-fx-background-color: grey_color;
}
.spinner .increment-arrow-button:hover:pressed,
.spinner .decrement-arrow-button:hover:pressed,
.spinner .increment-arrow-button:pressed,
.spinner .decrement-arrow-button:pressed {
-fx-background-color: white;
}
.spinner .increment-arrow-button .increment-arrow,
.spinner .decrement-arrow-button .decrement-arrow {
-fx-background-color: white;
}

Wyświetl plik

@ -12,25 +12,25 @@
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="329.0" prefWidth="576.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sh.ball.gui.controller.ImageController">
<children>
<CheckBox fx:id="translateEllipseCheckBox" layoutX="324.0" layoutY="19.0" mnemonicParsing="false" text="Ellipse" />
<Slider fx:id="rotateSpeedSlider" blockIncrement="0.05" layoutX="116.0" layoutY="159.0" majorTickUnit="1.0" max="10.0" prefHeight="42.0" prefWidth="254.0" showTickLabels="true" showTickMarks="true" />
<Label layoutX="12.0" layoutY="158.0" text="2D Rotate speed">
<Slider fx:id="rotateSpeedSlider" blockIncrement="0.05" layoutX="116.0" layoutY="199.0" majorTickUnit="1.0" max="10.0" prefHeight="42.0" prefWidth="254.0" showTickLabels="true" showTickMarks="true" />
<Label layoutX="12.0" layoutY="198.0" text="2D Rotate speed">
<font>
<Font size="13.0" />
</font>
</Label>
<Slider fx:id="translationSpeedSlider" blockIncrement="0.05" layoutX="116.0" layoutY="197.0" majorTickUnit="1.0" max="10.0" prefHeight="42.0" prefWidth="254.0" showTickLabels="true" showTickMarks="true" value="1.0" />
<Label layoutX="7.0" layoutY="196.0" text="Translation speed">
<Slider fx:id="translationSpeedSlider" blockIncrement="0.05" layoutX="116.0" layoutY="123.0" majorTickUnit="1.0" max="10.0" prefHeight="42.0" prefWidth="254.0" showTickLabels="true" showTickMarks="true" value="1.0" />
<Label layoutX="7.0" layoutY="122.0" text="Translation speed">
<font>
<Font size="13.0" />
</font>
</Label>
<Slider fx:id="volumeSlider" blockIncrement="0.05" layoutX="116.0" layoutY="236.0" majorTickUnit="1.0" max="10.0" prefHeight="42.0" prefWidth="253.0" showTickLabels="true" showTickMarks="true" value="3.0" />
<Label layoutX="33.0" layoutY="235.0" text="Volume scale">
<Slider fx:id="volumeSlider" blockIncrement="0.05" layoutX="116.0" layoutY="237.0" majorTickUnit="1.0" max="10.0" prefHeight="42.0" prefWidth="253.0" showTickLabels="true" showTickMarks="true" value="3.0" />
<Label layoutX="33.0" layoutY="236.0" text="Volume scale">
<font>
<Font size="13.0" />
</font>
</Label>
<Label layoutX="11.0" layoutY="119.0" text="Target frequency">
<Label layoutX="11.0" layoutY="160.0" text="Target frequency">
<font>
<Font size="13.0" />
</font>
@ -40,25 +40,21 @@
<Label layoutX="120.0" layoutY="18.0" text="x :" />
<Label layoutX="222.0" layoutY="18.0" text="y :" />
<TextField fx:id="translationYTextField" layoutX="241.0" layoutY="15.0" prefHeight="26.0" prefWidth="69.0" text="0.0" />
<Slider fx:id="frequencySlider" blockIncrement="0.001" layoutX="116.0" layoutY="114.0" majorTickUnit="0.07389" max="1.0" minorTickCount="2" prefHeight="42.0" prefWidth="253.0" showTickMarks="true" value="0.59269" />
<SVGPath fx:id="frequencyMidi" content="M20.15 8.26H22V15.74H20.15M13 8.26H18.43C19 8.26 19.3 8.74 19.3 9.3V14.81C19.3 15.5 19 15.74 18.38 15.74H13V11H14.87V13.91H17.5V9.95H13M10.32 8.26H12.14V15.74H10.32M2 8.26H8.55C9.1 8.26 9.41 8.74 9.41 9.3V15.74H7.59V10.15H6.5V15.74H4.87V10.15H3.83V15.74H2Z" fill="WHITE" layoutX="371.0" layoutY="118.0" pickOnBounds="true" />
<SVGPath fx:id="rotateSpeedMidi" content="M20.15 8.26H22V15.74H20.15M13 8.26H18.43C19 8.26 19.3 8.74 19.3 9.3V14.81C19.3 15.5 19 15.74 18.38 15.74H13V11H14.87V13.91H17.5V9.95H13M10.32 8.26H12.14V15.74H10.32M2 8.26H8.55C9.1 8.26 9.41 8.74 9.41 9.3V15.74H7.59V10.15H6.5V15.74H4.87V10.15H3.83V15.74H2Z" fill="WHITE" layoutX="371.0" layoutY="156.0" pickOnBounds="true" />
<SVGPath fx:id="translationSpeedMidi" content="M20.15 8.26H22V15.74H20.15M13 8.26H18.43C19 8.26 19.3 8.74 19.3 9.3V14.81C19.3 15.5 19 15.74 18.38 15.74H13V11H14.87V13.91H17.5V9.95H13M10.32 8.26H12.14V15.74H10.32M2 8.26H8.55C9.1 8.26 9.41 8.74 9.41 9.3V15.74H7.59V10.15H6.5V15.74H4.87V10.15H3.83V15.74H2Z" fill="WHITE" layoutX="371.0" layoutY="194.0" pickOnBounds="true" />
<SVGPath fx:id="volumeMidi" content="M20.15 8.26H22V15.74H20.15M13 8.26H18.43C19 8.26 19.3 8.74 19.3 9.3V14.81C19.3 15.5 19 15.74 18.38 15.74H13V11H14.87V13.91H17.5V9.95H13M10.32 8.26H12.14V15.74H10.32M2 8.26H8.55C9.1 8.26 9.41 8.74 9.41 9.3V15.74H7.59V10.15H6.5V15.74H4.87V10.15H3.83V15.74H2Z" fill="WHITE" layoutX="371.0" layoutY="233.0" pickOnBounds="true" />
<Label layoutX="257.0" layoutY="140.0" text="C4" />
<Label layoutX="239.0" layoutY="140.0" text="C3" />
<Label layoutX="222.0" layoutY="140.0" text="C2" />
<Label layoutX="193.0" layoutY="140.0" text="20" />
<Label layoutX="274.0" layoutY="140.0" text="C5" />
<Label layoutX="292.0" layoutY="140.0" text="C6" />
<Label layoutX="310.0" layoutY="140.0" text="C7" />
<Label layoutX="344.0" layoutY="140.0" text="12000">
<font>
<Font size="11.0" />
</font>
</Label>
<Label layoutX="162.0" layoutY="140.0" text="5" />
<Label layoutX="122.0" layoutY="140.0" text="0" />
<Slider fx:id="frequencySlider" blockIncrement="0.001" layoutX="116.0" layoutY="155.0" majorTickUnit="0.07389" max="1.0" minorTickCount="2" prefHeight="42.0" prefWidth="253.0" showTickMarks="true" value="0.59269" />
<SVGPath fx:id="frequencyMidi" content="M20.15 8.26H22V15.74H20.15M13 8.26H18.43C19 8.26 19.3 8.74 19.3 9.3V14.81C19.3 15.5 19 15.74 18.38 15.74H13V11H14.87V13.91H17.5V9.95H13M10.32 8.26H12.14V15.74H10.32M2 8.26H8.55C9.1 8.26 9.41 8.74 9.41 9.3V15.74H7.59V10.15H6.5V15.74H4.87V10.15H3.83V15.74H2Z" fill="WHITE" layoutX="371.0" layoutY="159.0" pickOnBounds="true" />
<SVGPath fx:id="rotateSpeedMidi" content="M20.15 8.26H22V15.74H20.15M13 8.26H18.43C19 8.26 19.3 8.74 19.3 9.3V14.81C19.3 15.5 19 15.74 18.38 15.74H13V11H14.87V13.91H17.5V9.95H13M10.32 8.26H12.14V15.74H10.32M2 8.26H8.55C9.1 8.26 9.41 8.74 9.41 9.3V15.74H7.59V10.15H6.5V15.74H4.87V10.15H3.83V15.74H2Z" fill="WHITE" layoutX="371.0" layoutY="196.0" pickOnBounds="true" />
<SVGPath fx:id="translationSpeedMidi" content="M20.15 8.26H22V15.74H20.15M13 8.26H18.43C19 8.26 19.3 8.74 19.3 9.3V14.81C19.3 15.5 19 15.74 18.38 15.74H13V11H14.87V13.91H17.5V9.95H13M10.32 8.26H12.14V15.74H10.32M2 8.26H8.55C9.1 8.26 9.41 8.74 9.41 9.3V15.74H7.59V10.15H6.5V15.74H4.87V10.15H3.83V15.74H2Z" fill="WHITE" layoutX="371.0" layoutY="120.0" pickOnBounds="true" />
<SVGPath fx:id="volumeMidi" content="M20.15 8.26H22V15.74H20.15M13 8.26H18.43C19 8.26 19.3 8.74 19.3 9.3V14.81C19.3 15.5 19 15.74 18.38 15.74H13V11H14.87V13.91H17.5V9.95H13M10.32 8.26H12.14V15.74H10.32M2 8.26H8.55C9.1 8.26 9.41 8.74 9.41 9.3V15.74H7.59V10.15H6.5V15.74H4.87V10.15H3.83V15.74H2Z" fill="WHITE" layoutX="371.0" layoutY="234.0" pickOnBounds="true" />
<Label layoutX="257.0" layoutY="181.0" text="C4" />
<Label layoutX="239.0" layoutY="181.0" text="C3" />
<Label layoutX="222.0" layoutY="181.0" text="C2" />
<Label layoutX="193.0" layoutY="181.0" text="20" />
<Label layoutX="274.0" layoutY="181.0" text="C5" />
<Label layoutX="292.0" layoutY="181.0" text="C6" />
<Label layoutX="310.0" layoutY="181.0" text="C7" />
<Label layoutX="345.0" layoutY="181.0" text="12000" />
<Label layoutX="162.0" layoutY="181.0" text="5" />
<Label layoutX="122.0" layoutY="181.0" text="0" />
<Label layoutX="24.0" layoutY="275.0" text="Image visibility">
<font>
<Font size="13.0" />
@ -75,11 +71,11 @@
</Label>
<SVGPath fx:id="translationScaleMidi" content="M20.15 8.26H22V15.74H20.15M13 8.26H18.43C19 8.26 19.3 8.74 19.3 9.3V14.81C19.3 15.5 19 15.74 18.38 15.74H13V11H14.87V13.91H17.5V9.95H13M10.32 8.26H12.14V15.74H10.32M2 8.26H8.55C9.1 8.26 9.41 8.74 9.41 9.3V15.74H7.59V10.15H6.5V15.74H4.87V10.15H3.83V15.74H2Z" fill="WHITE" layoutX="370.0" layoutY="80.0" pickOnBounds="true" />
<CheckBox fx:id="translationScaleMic" layoutX="408.0" layoutY="83.0" mnemonicParsing="false" text="Mic" />
<CheckBox fx:id="frequencyMic" layoutX="408.0" layoutY="121.0" mnemonicParsing="false" text="Mic" />
<CheckBox fx:id="rotateSpeedMic" layoutX="408.0" layoutY="159.0" mnemonicParsing="false" text="Mic" />
<CheckBox fx:id="translationSpeedMic" layoutX="408.0" layoutY="197.0" mnemonicParsing="false" text="Mic" />
<CheckBox fx:id="volumeMic" layoutX="408.0" layoutY="236.0" mnemonicParsing="false" text="Mic" />
<CheckBox fx:id="frequencyMic" layoutX="408.0" layoutY="162.0" mnemonicParsing="false" text="Mic" />
<CheckBox fx:id="rotateSpeedMic" layoutX="408.0" layoutY="199.0" mnemonicParsing="false" text="Mic" />
<CheckBox fx:id="translationSpeedMic" layoutX="408.0" layoutY="123.0" mnemonicParsing="false" text="Mic" />
<CheckBox fx:id="volumeMic" layoutX="408.0" layoutY="237.0" mnemonicParsing="false" text="Mic" />
<CheckBox fx:id="visibilityMic" layoutX="408.0" layoutY="276.0" mnemonicParsing="false" text="Mic" />
<Button fx:id="resetRotationButton" layoutX="13.0" layoutY="49.0" mnemonicParsing="false" text="Reset Rotation" />
<Button fx:id="resetRotationButton" layoutX="464.0" layoutY="195.0" mnemonicParsing="false" text="Reset Rotation" />
</children>
</AnchorPane>

Wyświetl plik

@ -62,6 +62,20 @@
<CheckMenuItem fx:id="flipYCheckMenuItem" mnemonicParsing="false" text="Flip Y Direction" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Controls">
<items>
<CustomMenuItem hideOnClick="false" mnemonicParsing="false" text="Translation Increment">
<content>
<AnchorPane>
<children>
<Label prefHeight="25.0" text="Translation Increment" textFill="WHITE" />
<Spinner fx:id="translationIncrementSpinner" editable="true" layoutY="25.0" />
</children>
</AnchorPane>
</content>
</CustomMenuItem>
</items>
</Menu>
</menus>
</MenuBar>
<TitledPane animated="false" collapsible="false" layoutX="7.0" layoutY="33.0" prefHeight="401.0" prefWidth="390.0" text="Main settings">