changeset 4025:fa8ff5a5b9e6

3DViewer: Refactored loadedUrl stuff. Disabled debug output.
author Alexander Kouznetsov
date Thu, 20 Jun 2013 17:22:41 -0700
parents b792789577f4
children 9c4360ee5f10
files apps/experiments/3DViewer/src/main/java/com/javafx/experiments/jfx3dviewer/ContentModel.java apps/experiments/3DViewer/src/main/java/com/javafx/experiments/jfx3dviewer/MainController.java
diffstat 2 files changed, 10 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/apps/experiments/3DViewer/src/main/java/com/javafx/experiments/jfx3dviewer/ContentModel.java	Thu Jun 20 17:07:08 2013 -0700
+++ b/apps/experiments/3DViewer/src/main/java/com/javafx/experiments/jfx3dviewer/ContentModel.java	Thu Jun 20 17:22:41 2013 -0700
@@ -141,7 +141,6 @@
     private int subdivisionLevel = 0;
     private SubDivision.BoundaryMode boundaryMode = SubDivision.BoundaryMode.CREASE_EDGES;
     private SubDivision.MapBorderMode mapBorderMode = SubDivision.MapBorderMode.NOT_SMOOTH;
-    private String loadedUrl = null;
 
     public ContentModel() {
         subScene = new SubScene(root3D,400,400,true,false);
@@ -202,10 +201,6 @@
         sessionManager.bind(cameraYRotate.angleProperty(), "cameraYRotate");
     }
 
-    public String getLoadedUrl() {
-        return loadedUrl;
-    }
-
     public boolean getAmbientLightEnabled() {
         return ambientLightEnabled.get();
     }
--- a/apps/experiments/3DViewer/src/main/java/com/javafx/experiments/jfx3dviewer/MainController.java	Thu Jun 20 17:07:08 2013 -0700
+++ b/apps/experiments/3DViewer/src/main/java/com/javafx/experiments/jfx3dviewer/MainController.java	Thu Jun 20 17:22:41 2013 -0700
@@ -97,7 +97,8 @@
     private int meshCount = 0;
     private int triangleCount = 0;
     private final ContentModel contentModel = Jfx3dViewerApp.getContentModel();
-    private File loadedPath = null;
+    private File loadedPath;
+    private String loadedURL;
     private String[] supportedFormatRegex;
     private TimelineController timelineController;
     private SessionManager sessionManager = SessionManager.getSessionManager();
@@ -122,7 +123,7 @@
         supportedFormatRegex = Importer3D.getSupportedFormatExtensionFilters();
         for (int i=0; i< supportedFormatRegex.length; i++) {
             supportedFormatRegex[i] = "."+supportedFormatRegex[i].replaceAll("\\.","\\.");
-            System.out.println("supportedFormatRegex[i] = " + supportedFormatRegex[i]);
+//            System.out.println("supportedFormatRegex[i] = " + supportedFormatRegex[i]);
         }
         contentModel.getSubScene().setOnDragOver(
                 new EventHandler<DragEvent>() {
@@ -216,15 +217,17 @@
     }
 
     private void doLoad(String fileUrl) {
+        loadedURL = fileUrl;
         sessionManager.getProperties().setProperty(Jfx3dViewerApp.FILE_URL_PROPERTY, fileUrl);
         try {
             Pair<Node,Timeline> content = Importer3D.loadIncludingAnimation(
                     fileUrl, loadAsPolygonsCheckBox.isSelected());
             Timeline timeline = content.getValue();
+            Node root = content.getKey();
             if (optimizeCheckBox.isSelected()) {
-                new Optimizer(timeline,content.getKey()).optimize();
+                new Optimizer(timeline, root, true).optimize();
             }
-            contentModel.set3dContent(content.getKey());
+            contentModel.set3dContent(root);
             contentModel.setTimeline(timeline);
 
             if (timeline != null) {
@@ -306,9 +309,10 @@
         File newFile = chooser.showSaveDialog(openMenuBtn.getScene().getWindow());
         if (newFile != null) {
             String extension = newFile.getName().substring(newFile.getName().lastIndexOf('.')+1,newFile.getName().length()).toLowerCase();
-            System.out.println("extension = " + extension);
+//            System.out.println("extension = " + extension);
             if ("java".equals(extension)) {
-                final String url = contentModel.getLoadedUrl();
+                final String url = loadedURL;
+//                System.out.println("url = " + loadedPath);
                 final String baseUrl = url.substring(0, url.lastIndexOf('/'));
 
                 JavaSourceExporter javaSourceExporter = new JavaSourceExporter(