|
@@ -9,6 +9,7 @@ import com.jme3.gde.core.sceneexplorer.nodes.JmeTerrainQuad;
|
|
import com.jme3.gde.core.sceneexplorer.nodes.actions.AbstractToolAction;
|
|
import com.jme3.gde.core.sceneexplorer.nodes.actions.AbstractToolAction;
|
|
import com.jme3.gde.core.sceneexplorer.nodes.actions.ToolAction;
|
|
import com.jme3.gde.core.sceneexplorer.nodes.actions.ToolAction;
|
|
import com.jme3.scene.Node;
|
|
import com.jme3.scene.Node;
|
|
|
|
+import com.jme3.terrain.ProgressMonitor;
|
|
import com.jme3.terrain.geomipmap.TerrainQuad;
|
|
import com.jme3.terrain.geomipmap.TerrainQuad;
|
|
import org.netbeans.api.progress.ProgressHandle;
|
|
import org.netbeans.api.progress.ProgressHandle;
|
|
import org.netbeans.api.progress.ProgressHandleFactory;
|
|
import org.netbeans.api.progress.ProgressHandleFactory;
|
|
@@ -27,11 +28,33 @@ public class GenerateTerrainEntropiesAction extends AbstractToolAction {
|
|
@Override
|
|
@Override
|
|
protected Object doApplyTool(AbstractSceneExplorerNode rootNode) {
|
|
protected Object doApplyTool(AbstractSceneExplorerNode rootNode) {
|
|
Node terrain = rootNode.getLookup().lookup(Node.class);
|
|
Node terrain = rootNode.getLookup().lookup(Node.class);
|
|
- ProgressHandle progressHandle = ProgressHandleFactory.createHandle("Generating Entropies");
|
|
|
|
|
|
+ final ProgressHandle progressHandle = ProgressHandleFactory.createHandle("Generating Terrain Entropies");
|
|
progressHandle.start();
|
|
progressHandle.start();
|
|
try {
|
|
try {
|
|
if (terrain instanceof TerrainQuad) { // it should be terrain anyways
|
|
if (terrain instanceof TerrainQuad) { // it should be terrain anyways
|
|
- ((TerrainQuad) terrain).generateEntropy(null); //TODO hook up to progress monitor
|
|
|
|
|
|
+ ((TerrainQuad) terrain).generateEntropy(new ProgressMonitor() {
|
|
|
|
+
|
|
|
|
+ private float progress = 0;
|
|
|
|
+ private float max = 0;
|
|
|
|
+
|
|
|
|
+ public void incrementProgress(float f) {
|
|
|
|
+ progress += f;
|
|
|
|
+ progressHandle.progress((int) progress);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setMonitorMax(float f) {
|
|
|
|
+ max = f;
|
|
|
|
+ progressHandle.switchToDeterminate((int) (f));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public float getMonitorMax() {
|
|
|
|
+ return max;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void progressComplete() {
|
|
|
|
+ progressHandle.finish();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
}
|
|
}
|
|
} finally {
|
|
} finally {
|
|
progressHandle.finish();
|
|
progressHandle.finish();
|