Commits

shemnon committed 9b9d379

re-do scroll viz to be letters in a circle.
Color the visualizations

Comments (0)

Files changed (3)

src/main/java/touchyfxy/Controller.java

         super.initialize();
 
         rotateArc.visibleProperty().bind(vizRotateCB.selectedProperty());
-        scrollEndLabel.visibleProperty().bind(vizScrollCB.selectedProperty());
-        scrollInertiaLabel.visibleProperty().bind(vizScrollCB.selectedProperty());
-        scrollStartLabel.visibleProperty().bind(vizScrollCB.selectedProperty());
+        scrollEnd.visibleProperty().bind(vizScrollCB.selectedProperty());
+        scrollInertia.visibleProperty().bind(vizScrollCB.selectedProperty());
+        scrollStart.visibleProperty().bind(vizScrollCB.selectedProperty());
         swipeArrow.visibleProperty().bind(vizSwipeCB.selectedProperty());
         zoomSlider.visibleProperty().bind(vizZoomCB.selectedProperty());
 
+        sizeScrollCircles();
+
         swipeFade = new Timeline(
                 new KeyFrame(new Duration(1000),
                      new KeyValue(swipeArrow.opacityProperty(), 0)
         );
         scrollFade = new Timeline(
                 new KeyFrame(new Duration(1000),
-                    new KeyValue(scrollStartLabel.opacityProperty(), 0),
-                    new KeyValue(scrollEndLabel.opacityProperty(), 0),
-                    new KeyValue(scrollInertiaLabel.opacityProperty(), 0)
+                    new KeyValue(scrollStart.opacityProperty(), 0),
+                    new KeyValue(scrollEnd.opacityProperty(), 0),
+                    new KeyValue(scrollInertia.opacityProperty(), 0)
                 )
         );
     }
 
+    private void sizeScrollCircles() {
+        scrollEnd.layout();
+        scrollInertia.layout();
+        scrollStart.layout();
+        double radius = Math.max(
+                Math.sqrt(scrollEndLabel.prefWidth(-1) * scrollEndLabel.prefWidth(-1) + scrollEndLabel.prefHeight(-1) * scrollEndLabel.prefHeight(-1)),
+                Math.max(
+                        Math.sqrt(scrollInertiaLabel.prefWidth(-1) * scrollInertiaLabel.prefWidth(-1) + scrollInertiaLabel.prefHeight(-1) * scrollInertiaLabel.prefHeight(-1)),
+                        Math.sqrt(scrollStartLabel.prefWidth(-1) * scrollStartLabel.prefWidth(-1) + scrollStartLabel.prefHeight(-1) * scrollStartLabel.prefHeight(-1)))
+        ) / 2;
+
+        scrollEndCircle.setRadius(radius);
+        scrollInertiaCircle.setRadius(radius);
+        scrollStartCircle.setRadius(radius);
+        scrollEnd.layout();
+        scrollInertia.layout();
+        scrollStart.layout();
+    }
+
     @Override
     void swipeDown(SwipeEvent event) {
         swipeArrow.setRotate(180);
     void scroll(ScrollEvent event) {
         updateScroll(event);
         if (event.isInertia()) {
-            centerInBounds(event.getX(), event.getY(), scrollInertiaLabel);
-            scrollInertiaLabel.setOpacity(1.0);
-            scrollStartLabel.setOpacity(1.0);
-            scrollEndLabel.setOpacity(1.0);
+            centerInBounds(event.getX(), event.getY(), scrollInertia);
+            scrollInertia.setOpacity(1.0);
+            scrollStart.setOpacity(1.0);
+            scrollEnd.setOpacity(1.0);
             scrollFade.playFromStart();
         } else {
-            centerInBounds(event.getX(), event.getY(), scrollEndLabel);
+            centerInBounds(event.getX(), event.getY(), scrollEnd);
         }
     }
 
     @Override
     void scrollEnd(ScrollEvent event) {
         updateScroll(event);
-        centerInBounds(event.getX(), event.getY(), scrollEndLabel);
+        centerInBounds(event.getX(), event.getY(), scrollEnd);
         scrollFade.playFromStart();
     }
 
     void scrollStart(ScrollEvent event) {
         updateScroll(event);
 
-        centerInBounds(event.getX(), event.getY(), scrollStartLabel);
-        centerInBounds(event.getX(), event.getY(), scrollEndLabel);
+        centerInBounds(event.getX(), event.getY(), scrollStart);
+        centerInBounds(event.getX(), event.getY(), scrollEnd);
         scrollFade.stop();
         scrollFade.jumpTo(Duration.ZERO);
 
-        scrollStartLabel.setOpacity(1.0);
-        scrollEndLabel.setOpacity(1.0);
-        scrollInertiaLabel.setOpacity(0.0);
+        scrollStart.setOpacity(1.0);
+        scrollEnd.setOpacity(1.0);
+        scrollInertia.setOpacity(0.0);
 
     }
 
     private void updateScroll(ScrollEvent event) {
+        sizeScrollCircles();
         scrollXTF.setText(doubleFormat.format(event.getX()));
         scrollYTF.setText(doubleFormat.format(event.getY()));
         scrollDeltaXTF.setText(doubleFormat.format(event.getDeltaX()));

src/main/java/touchyfxy/ControllerGenerated.java

 import javafx.scene.input.TouchEvent;
 import javafx.scene.input.ZoomEvent;
 import javafx.scene.layout.GridPane;
+import javafx.scene.layout.StackPane;
 import javafx.scene.shape.Arc;
+import javafx.scene.shape.Circle;
 
 
 public class ControllerGenerated {
     CheckBox scrollDirectCB;
 
     @FXML
+    StackPane scrollEnd;
+
+    @FXML
+    Circle scrollEndCircle;
+
+    @FXML
     Label scrollEndLabel;
 
     @FXML
+    StackPane scrollInertia;
+
+    @FXML
     CheckBox scrollInertiaCB;
 
     @FXML
+    Circle scrollInertiaCircle;
+
+    @FXML
     Label scrollInertiaLabel;
 
     @FXML
+    StackPane scrollStart;
+
+    @FXML
+    Circle scrollStartCircle;
+
+    @FXML
     Label scrollStartLabel;
 
     @FXML
         assert scrollDeltaXTF != null : "fx:id=\"scrollDeltaXTF\" was not injected: check your FXML file 'touchyfxy.fxml'.";
         assert scrollDeltaYTF != null : "fx:id=\"scrollDeltaYTF\" was not injected: check your FXML file 'touchyfxy.fxml'.";
         assert scrollDirectCB != null : "fx:id=\"scrollDirectCB\" was not injected: check your FXML file 'touchyfxy.fxml'.";
+        assert scrollEnd != null : "fx:id=\"scrollEnd\" was not injected: check your FXML file 'touchyfxy.fxml'.";
+        assert scrollEndCircle != null : "fx:id=\"scrollEndCircle\" was not injected: check your FXML file 'touchyfxy.fxml'.";
         assert scrollEndLabel != null : "fx:id=\"scrollEndLabel\" was not injected: check your FXML file 'touchyfxy.fxml'.";
+        assert scrollInertia != null : "fx:id=\"scrollInertia\" was not injected: check your FXML file 'touchyfxy.fxml'.";
         assert scrollInertiaCB != null : "fx:id=\"scrollInertiaCB\" was not injected: check your FXML file 'touchyfxy.fxml'.";
+        assert scrollInertiaCircle != null : "fx:id=\"scrollInertiaCircle\" was not injected: check your FXML file 'touchyfxy.fxml'.";
         assert scrollInertiaLabel != null : "fx:id=\"scrollInertiaLabel\" was not injected: check your FXML file 'touchyfxy.fxml'.";
+        assert scrollStart != null : "fx:id=\"scrollStart\" was not injected: check your FXML file 'touchyfxy.fxml'.";
+        assert scrollStartCircle != null : "fx:id=\"scrollStartCircle\" was not injected: check your FXML file 'touchyfxy.fxml'.";
         assert scrollStartLabel != null : "fx:id=\"scrollStartLabel\" was not injected: check your FXML file 'touchyfxy.fxml'.";
         assert scrollTotalDeltaXTF != null : "fx:id=\"scrollTotalDeltaXTF\" was not injected: check your FXML file 'touchyfxy.fxml'.";
         assert scrollTotalDeltaYTF != null : "fx:id=\"scrollTotalDeltaYTF\" was not injected: check your FXML file 'touchyfxy.fxml'.";

src/main/resources/touchyfxy/touchyfxy.fxml

         </Text>
         <Pane prefHeight="200.0" prefWidth="200.0">
           <children>
-            <Arc fx:id="rotateArc" fill="GREY" layoutX="200.0" layoutY="200.0" length="-90.0" opacity="0.0" radiusX="100.0" radiusY="100.0" smooth="false" startAngle="90.0" stroke="GREY" strokeType="INSIDE" type="ROUND" visible="true" />
+            <Arc fx:id="rotateArc" fill="DODGERBLUE" layoutX="200.0" layoutY="200.0" length="-90.0" opacity="0.0" radiusX="100.0" radiusY="100.0" smooth="false" startAngle="90.0" stroke="DODGERBLUE" strokeType="INSIDE" type="ROUND" visible="true" />
             <Slider fx:id="zoomSlider" focusTraversable="false" layoutX="100.0" layoutY="0.0" majorTickUnit="1.0" max="2.0" min="0.0" opacity="0.0" orientation="VERTICAL" showTickLabels="false" showTickMarks="true" value="1.0" visible="true" />
             <Group id="Group" fx:id="swipeArrow" layoutX="100.0" layoutY="100.0" opacity="0.0">
               <children>
-                <Polygon fill="GREY" layoutX="25.0" layoutY="30.0" opacity="1.0" rotate="0.0" stroke="GREY" strokeType="INSIDE" visible="true">
+                <Polygon fill="ORANGE" layoutX="25.0" layoutY="30.0" opacity="1.0" rotate="0.0" stroke="ORANGE" strokeType="INSIDE" visible="true">
                   <points>
                     <Double fx:value="-25.0" />
                     <Double fx:value="20.0" />
                 <Line endX="12.5" layoutX="25.0" layoutY="25.0" startX="-12.5" />
               </children>
             </Group>
-            <Label id="dragStartLabel" fx:id="scrollStartLabel" layoutX="50.0" layoutY="100.0" opacity="0.0" text="S">
-              <font>
-                <Font name="Serif Regular" size="12.0" fx:id="x1" />
-              </font>
-            </Label>
-            <Label id="dragEndLabel" fx:id="scrollEndLabel" font="$x1" layoutX="50.0" layoutY="150.0" opacity="0.0" text="E" />
-            <Label id="dragInertiaLabel" fx:id="scrollInertiaLabel" font="$x1" layoutX="50.0" layoutY="200.0" opacity="0.0" text="I" />
+            <StackPane fx:id="scrollStart" layoutX="50.0" layoutY="100.0" opacity="0.0">
+              <Circle fx:id="scrollStartCircle" fill="GREEN" radius="10.0" stroke="GREEN" strokeType="INSIDE" />
+              <Label fx:id="scrollStartLabel" text="S" textFill="WHITE" />
+            </StackPane>
+            <StackPane fx:id="scrollEnd" layoutX="50.0" layoutY="150.0" opacity="0.0">
+              <Circle fx:id="scrollEndCircle" fill="RED" radius="10.0" stroke="RED" strokeType="INSIDE" />
+              <Label fx:id="scrollEndLabel" text="E" textFill="WHITE" />
+            </StackPane>
+            <StackPane fx:id="scrollInertia" layoutX="50.0" layoutY="200.0" opacity="0.0">
+              <Circle fx:id="scrollInertiaCircle" fill="YELLOW" radius="10.0" stroke="YELLOW" strokeType="INSIDE" />
+              <Label fx:id="scrollInertiaLabel" text="I" />
+            </StackPane>
           </children>
         </Pane>
       </children>