changeset 4041:d5897125de45

3DViewer: Added transforms view.
author Alexander Kouznetsov
date Mon, 24 Jun 2013 10:49:25 -0700
parents 4f129ab389e8
children 35ed9cc8cfb0
files apps/experiments/3DViewer/src/main/java/com/javafx/experiments/jfx3dviewer/SettingsController.java apps/experiments/3DViewer/src/main/java/com/javafx/experiments/jfx3dviewer/settings.fxml
diffstat 2 files changed, 63 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/apps/experiments/3DViewer/src/main/java/com/javafx/experiments/jfx3dviewer/SettingsController.java	Mon Jun 24 10:44:55 2013 -0700
+++ b/apps/experiments/3DViewer/src/main/java/com/javafx/experiments/jfx3dviewer/SettingsController.java	Mon Jun 24 10:49:25 2013 -0700
@@ -48,13 +48,20 @@
 import javafx.scene.paint.Color;
 import com.javafx.experiments.shape3d.SubDivision;
 import javafx.beans.binding.ObjectBinding;
+import javafx.event.EventHandler;
 import javafx.scene.Node;
 import javafx.scene.Parent;
+import javafx.scene.control.Label;
+import javafx.scene.control.ListView;
 import javafx.scene.control.TreeItem;
 import javafx.scene.control.TreeTableColumn;
 import javafx.scene.control.TreeTableView;
 import javafx.scene.control.cell.CheckBoxTreeTableCell;
 import javafx.scene.control.cell.TextFieldTreeTableCell;
+import javafx.scene.input.KeyCode;
+import javafx.scene.input.KeyEvent;
+import javafx.scene.input.MouseEvent;
+import javafx.scene.transform.Transform;
 import javafx.util.Callback;
 import javafx.util.StringConverter;
 
@@ -99,6 +106,9 @@
     public TreeTableColumn<Node, Double> widthColumn;
     public TreeTableColumn<Node, Double> heightColumn;
     public TreeTableColumn<Node, Double> depthColumn;
+    public ListView<Transform> transformsList;
+    public TitledPane x6;
+    public Label selectedNodeLabel;
     
     @Override public void initialize(URL location, ResourceBundle resources) {
         // keep one pane open always
@@ -232,6 +242,47 @@
                 }
             }
         });
+        hierarachyTreeTable.setOnMouseClicked(new EventHandler<MouseEvent>() {
+
+            @Override
+            public void handle(MouseEvent t) {
+                if (t.getClickCount() == 2) {
+                    settings.setExpandedPane(x6);
+                    t.consume();
+                }
+            }
+        });
+        hierarachyTreeTable.setOnKeyPressed(new EventHandler<KeyEvent>() {
+
+            @Override
+            public void handle(KeyEvent t) {
+                if (t.getCode() == KeyCode.SPACE) {
+                    TreeItem<Node> selectedItem = hierarachyTreeTable.getSelectionModel().getSelectedItem();
+                    if (selectedItem != null) {
+                        Node node = selectedItem.getValue();
+                        node.setVisible(!node.isVisible());
+                    }
+                    t.consume();
+                }
+            }
+        });
+        x6.expandedProperty().addListener(new ChangeListener<Boolean>() {
+
+            @Override
+            public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) {
+                if (t1) {
+                    TreeItem<Node> selectedItem = hierarachyTreeTable.getSelectionModel().getSelectedItem();
+                    if (selectedItem == null) {
+                        transformsList.setItems(null);
+                        selectedNodeLabel.setText("");
+                    } else {
+                        Node node = selectedItem.getValue();
+                        transformsList.setItems(node.getTransforms());
+                        selectedNodeLabel.setText(node.toString());
+                    }
+                }
+            }
+        });
         nodeColumn.setCellValueFactory(new Callback<TreeTableColumn.CellDataFeatures<Node, String>, ObservableValue<String>>() {
 
             @Override
--- a/apps/experiments/3DViewer/src/main/java/com/javafx/experiments/jfx3dviewer/settings.fxml	Mon Jun 24 10:44:55 2013 -0700
+++ b/apps/experiments/3DViewer/src/main/java/com/javafx/experiments/jfx3dviewer/settings.fxml	Mon Jun 24 10:49:25 2013 -0700
@@ -266,5 +266,17 @@
       </content>
     </TitledPane>
     <fx:reference source="x5" />
+    <TitledPane fx:id="x6" animated="false" expanded="false" text="Transforms">
+      <content>
+        <VBox>
+          <children>
+            <Label fx:id="selectedNodeLabel"/>
+            <ListView fx:id="transformsList" prefHeight="200.0" prefWidth="200.0">
+                <VBox.vgrow>ALWAYS</VBox.vgrow>
+            </ListView>
+          </children>
+        </VBox>
+      </content>
+    </TitledPane>
   </panes>
 </Accordion>