changeset 4040:4f129ab389e8

3DViewer: Added width, height and depth columns to hierarchy view.
author Alexander Kouznetsov
date Mon, 24 Jun 2013 10:44:55 -0700
parents 3822e5001c00
children d5897125de45
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, 70 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/apps/experiments/3DViewer/src/main/java/com/javafx/experiments/jfx3dviewer/SettingsController.java	Mon Jun 24 07:40:21 2013 -0400
+++ b/apps/experiments/3DViewer/src/main/java/com/javafx/experiments/jfx3dviewer/SettingsController.java	Mon Jun 24 10:44:55 2013 -0700
@@ -54,7 +54,9 @@
 import javafx.scene.control.TreeTableColumn;
 import javafx.scene.control.TreeTableView;
 import javafx.scene.control.cell.CheckBoxTreeTableCell;
+import javafx.scene.control.cell.TextFieldTreeTableCell;
 import javafx.util.Callback;
+import javafx.util.StringConverter;
 
 /**
  * Controller class for settings panel
@@ -94,6 +96,9 @@
     public TreeTableColumn<Node, String> nodeColumn;
     public TreeTableColumn<Node, String> idColumn;
     public TreeTableColumn<Node, Boolean> visibilityColumn;
+    public TreeTableColumn<Node, Double> widthColumn;
+    public TreeTableColumn<Node, Double> heightColumn;
+    public TreeTableColumn<Node, Double> depthColumn;
     
     @Override public void initialize(URL location, ResourceBundle resources) {
         // keep one pane open always
@@ -249,6 +254,53 @@
             }
         });
         visibilityColumn.setCellFactory(CheckBoxTreeTableCell.forTreeTableColumn(visibilityColumn));
+        widthColumn.setCellValueFactory(new Callback<TreeTableColumn.CellDataFeatures<Node, Double>, ObservableValue<Double>>() {
+            @Override
+            public ObservableValue<Double> call(final TreeTableColumn.CellDataFeatures<Node, Double> p) {
+                return new ObjectBinding<Double>() {
+                    {  bind(p.getValue().getValue().boundsInLocalProperty()); }
+                    @Override protected Double computeValue() {
+                        return p.getValue().getValue().getBoundsInLocal().getWidth();
+                    }
+                };
+            }
+        });
+        StringConverter<Double> niceDoubleStringConverter = new StringConverter<Double>() {
+            @Override
+            public String toString(Double t) {
+                return String.format("%.2f", t);
+            }
+
+            @Override
+            public Double fromString(String string) {
+                throw new UnsupportedOperationException("Not supported yet."); //Not needed so far
+            }
+        };
+        widthColumn.setCellFactory(TextFieldTreeTableCell.<Node, Double>forTreeTableColumn(niceDoubleStringConverter));
+        heightColumn.setCellFactory(TextFieldTreeTableCell.<Node, Double>forTreeTableColumn(niceDoubleStringConverter));
+        depthColumn.setCellFactory(TextFieldTreeTableCell.<Node, Double>forTreeTableColumn(niceDoubleStringConverter));
+        heightColumn.setCellValueFactory(new Callback<TreeTableColumn.CellDataFeatures<Node, Double>, ObservableValue<Double>>() {
+            @Override
+            public ObservableValue<Double> call(final TreeTableColumn.CellDataFeatures<Node, Double> p) {
+                return new ObjectBinding<Double>() {
+                    {  bind(p.getValue().getValue().boundsInLocalProperty()); }
+                    @Override protected Double computeValue() {
+                        return p.getValue().getValue().getBoundsInLocal().getHeight();
+                    }
+                };
+            }
+        });
+        depthColumn.setCellValueFactory(new Callback<TreeTableColumn.CellDataFeatures<Node, Double>, ObservableValue<Double>>() {
+            @Override
+            public ObservableValue<Double> call(final TreeTableColumn.CellDataFeatures<Node, Double> p) {
+                return new ObjectBinding<Double>() {
+                    {  bind(p.getValue().getValue().boundsInLocalProperty()); }
+                    @Override protected Double computeValue() {
+                        return p.getValue().getValue().getBoundsInLocal().getDepth();
+                    }
+                };
+            }
+        });
 
         SessionManager sessionManager = SessionManager.getSessionManager();
 
@@ -291,6 +343,19 @@
                     getChildren().add(new TreeItemImpl(n));
                 }
             }
+//            node.setOnMouseClicked(new EventHandler<MouseEvent>() {
+//
+//                @Override
+//                public void handle(MouseEvent t) {
+//                    System.out.println("node.setOnMouseClicked t = " + t);
+//                    TreeItem<Node> parent = getParent();
+//                    while (parent != null) {
+//                        parent.setExpanded(true);
+//                        parent = parent.getParent();
+//                    }
+//                    hierarachyTreeTable.getSelectionModel().select(TreeItemImpl.this);
+//                }
+//            });
         }
     }
 }
--- a/apps/experiments/3DViewer/src/main/java/com/javafx/experiments/jfx3dviewer/settings.fxml	Mon Jun 24 07:40:21 2013 -0400
+++ b/apps/experiments/3DViewer/src/main/java/com/javafx/experiments/jfx3dviewer/settings.fxml	Mon Jun 24 10:44:55 2013 -0700
@@ -51,8 +51,11 @@
         <TreeTableView fx:id="hierarachyTreeTable" editable="true" prefHeight="200.0" prefWidth="200.0">
           <columns>
             <TreeTableColumn fx:id="nodeColumn" editable="false" prefWidth="75.0" sortable="false" text="Node" />
-            <TreeTableColumn fx:id="idColumn" prefWidth="75.0" text="Id" />
-            <TreeTableColumn fx:id="visibilityColumn" editable="true" maxWidth="5000.0" minWidth="10.0" prefWidth="26.0" sortable="false" text="Visibility" />
+            <TreeTableColumn fx:id="idColumn" editable="false" prefWidth="75.0" text="Id" />
+            <TreeTableColumn fx:id="visibilityColumn" editable="true" text="Visibility" />
+            <TreeTableColumn fx:id="widthColumn" editable="false" text="W" />
+            <TreeTableColumn fx:id="heightColumn" editable="false" text="H" />
+            <TreeTableColumn fx:id="depthColumn" editable="false" text="D" />
           </columns>
         </TreeTableView>
       </content>