Skip to content

Commit

Permalink
Automated merge with ssh://jfxsrc.us.oracle.com//javafx/8.0/MASTER/jf…
Browse files Browse the repository at this point in the history
…x/rt
  • Loading branch information
Jennifer Godinez committed May 14, 2013
2 parents ae0efd3 + 1564966 commit 516b7ad
Show file tree
Hide file tree
Showing 11,318 changed files with 2,287,942 additions and 2,796 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
24 changes: 24 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,37 @@
<classpathentry kind="src" path="prism-util/src"/>

<classpathentry kind="src" path="test-stub-toolkit/src"/>

<classpathentry kind="src" path="webview/src"/>
<classpathentry kind="src" path="webview/build/builders"/>

<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="lib" path="../import/antlr-3.1.3/antlr-3.1.3/lib/antlr-3.1.3.jar"/>
<classpathentry kind="lib" path="../import/findbugs-2.0.1/findbugs-2.0.1/lib/ant.jar"/>

<classpathentry kind="src" path="/rt-closed"/>
<classpathentry combineaccessrules="false" kind="src" path="/media">
<attributes>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="../caches/sdk/build/lib/desktop/jfxmedia.jar">
<attributes>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry combineaccessrules="false" kind="src" path="/webnode">
<attributes>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="../caches/sdk/build/lib/desktop/jfxwebkit.jar">
<attributes>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>

<classpathentry kind="src" path="/org.eclipse.swt">
<attributes>
<attribute name="optional" value="true"/>
Expand Down
2 changes: 2 additions & 0 deletions .hgignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ syntax: glob
*/Release/*
*/Debug/*
*~
webview/native/WebKitBuild
webview/native/WebKitLibraries/import
2 changes: 1 addition & 1 deletion apps/experiments/3DViewer/3D Viewer.iml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build" />
<excludeFolder url="file://$MODULE_DIR$/nbproject" />
</content>
<orderEntry type="inheritedJdk" />
Expand Down Expand Up @@ -43,7 +44,6 @@
<orderEntry type="module" module-name="javafx-ui-controls" />
<orderEntry type="module" module-name="javafx-ui-desktop" />
<orderEntry type="module" module-name="javafx-ui-quantum" />
<orderEntry type="module" module-name="javafx-ui-webnode" />
<orderEntry type="module" module-name="javafx-util-converter" />
<orderEntry type="module" module-name="jfxmedia" />
<orderEntry type="module" module-name="pisces" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import javafx.fxml.FXMLLoader;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.shape.MeshView;
import javafx.scene.shape.TriangleMesh;
import com.javafx.experiments.importers.max.MaxLoader;
import com.javafx.experiments.importers.maya.MayaGroup;
import com.javafx.experiments.importers.maya.MayaImporter;
Expand Down Expand Up @@ -47,7 +49,13 @@ public static Node load(String fileUrl) throws IOException {
case "obj":
return loadObjFile(fileUrl);
case "fxml":
return FXMLLoader.load(new URL(fileUrl));
Object fxmlRoot = FXMLLoader.load(new URL(fileUrl));
if (fxmlRoot instanceof Node) {
return (Node)fxmlRoot;
} else if (fxmlRoot instanceof TriangleMesh) {
return new MeshView((TriangleMesh)fxmlRoot);
}
throw new IOException("Unknown object in FXML file ["+fxmlRoot.getClass().getName()+"]");
default:
throw new IOException("Unknown 3D file format ["+extension+"]");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
package com.javafx.experiments.jfx3dviewer;

import java.util.List;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.geometry.Bounds;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.transform.Scale;
import javafx.scene.transform.Translate;

/**
* A Group that auto scales its self to fit its content in a given size box.
*/
public class AutoScalingGroup extends Group {
private double size;
private double twoSize;
private Translate translate = new Translate(0,0,0);
private Scale scale = new Scale(1,1,1,0,0,0);
private SimpleBooleanProperty enabled = new SimpleBooleanProperty(true) {
@Override protected void invalidated() {
if (get()) {
getTransforms().setAll(scale, translate);
} else {
getTransforms().clear();
}
}
};

/**
* Create AutoScalingGroup
*
* @param size half of width/height/depth of box to fit content into
*/
public AutoScalingGroup(double size) {
this.size = size;
this.twoSize = size * 2;
getTransforms().addAll(scale,translate);
}

/**
* Get is auto scaling enabled
*
* @return true if auto scaling is enabled
*/
public boolean isEnabled() {
return enabled.get();
}

/**
* Get enabled property
*
* @return enabled property
*/
public SimpleBooleanProperty enabledProperty() {
return enabled;
}

/**
* Set is auto scaling enabled
*
* @param enabled true if auto scaling is enabled
*/
public void setEnabled(boolean enabled) {
this.enabled.set(enabled);
}

@Override protected void layoutChildren() {
List<Node> children = getChildren();
double minX = Double.MAX_VALUE, minY = Double.MAX_VALUE, minZ = Double.MAX_VALUE;
double maxX = Double.MIN_VALUE, maxY = Double.MIN_VALUE, maxZ = Double.MIN_VALUE;
boolean first = true;
for (int i=0, max=children.size(); i<max; i++) {
final Node node = children.get(i);
if (node.isVisible()) {
Bounds bounds = node.getBoundsInLocal();
// if the bounds of the child are invalid, we don't want
// to use those in the remaining computations.
if (bounds.isEmpty()) continue;
if (first) {
minX = bounds.getMinX();
minY = bounds.getMinY();
minZ = bounds.getMinZ();
maxX = bounds.getMaxX();
maxY = bounds.getMaxY();
maxZ = bounds.getMaxZ();
first = false;
} else {
minX = Math.min(bounds.getMinX(), minX);
minY = Math.min(bounds.getMinY(), minY);
minZ = Math.min(bounds.getMinZ(), minZ);
maxX = Math.max(bounds.getMaxX(), maxX);
maxY = Math.max(bounds.getMaxY(), maxY);
maxZ = Math.max(bounds.getMaxZ(), maxZ);
}
}
}

final double w = maxX-minX;
final double h = maxY-minY;
final double d = maxZ-minZ;

final double centerX = minX + (w/2);
final double centerY = minY + (h/2);
final double centerZ = minZ + (d/2);

double scaleX = twoSize/w;
double scaleY = twoSize/h;
double scaleZ = twoSize/d;

double scale = Math.min(scaleX, Math.min(scaleY,scaleZ));
this.scale.setX(scale);
this.scale.setY(scale);
this.scale.setZ(scale);

this.translate.setX(-centerX);
this.translate.setY(-centerY);
this.translate.setZ(-centerZ);
}
}
Loading

0 comments on commit 516b7ad

Please sign in to comment.