changeset 10033:62d65bc20537 jdk-9+136

8165373: Ensemble8 uses setAccessible to access methods and fields of various classes Reviewed-by: vadim
author kcr
date Sat, 10 Sep 2016 06:41:47 -0700
parents b12a7e506f54
children 528557f41670 7e6a3f4211f2
files apps/samples/Ensemble8/src/app/java/ensemble/samplepage/PlaygroundTabs.java apps/samples/Ensemble8/src/samples/java/ensemble/samples/controls/text/textformatter/TextFormatterApp.java apps/samples/Ensemble8/src/samples/java/ensemble/samples/graphics2d/images/imageoperator/ImageOperationApp.java apps/samples/Ensemble8/src/samples/java/ensemble/samples/graphics3d/sphere/Simple3DSphereApp.java apps/samples/Ensemble8/src/samples/java/ensemble/samples/media/alphamediaplayer/AlphaMediaPlayerApp.java
diffstat 5 files changed, 66 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/apps/samples/Ensemble8/src/app/java/ensemble/samplepage/PlaygroundTabs.java	Sat Sep 10 06:41:38 2016 -0700
+++ b/apps/samples/Ensemble8/src/app/java/ensemble/samplepage/PlaygroundTabs.java	Sat Sep 10 06:41:47 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2014, Oracle and/or its affiliates.
+ * Copyright (c) 2008, 2016, Oracle and/or its affiliates.
  * All rights reserved. Use is subject to license terms.
  *
  * This file is available and licensed under the following license:
@@ -174,16 +174,7 @@
                 if (prop.propertyName.startsWith("get")) {
                     property = object.getClass().getMethod(prop.propertyName).invoke(object);
                 } else {
-                    for (Field f : object.getClass().getDeclaredFields()) {
-                        if (f.getName().equals(prop.propertyName)) {
-                            f.setAccessible(true);
-                            property = f.get(object);
-                            break;
-                        }
-                    }
-                    if (property == null) {
-                        property = object.getClass().getMethod(prop.propertyName + "Property").invoke(object);
-                    }
+                    property = object.getClass().getMethod(prop.propertyName + "Property").invoke(object);
                 }
                 if (object instanceof XYChart && prop.propertyName.equals("data")) {
                     needsDataTab = true;
--- a/apps/samples/Ensemble8/src/samples/java/ensemble/samples/controls/text/textformatter/TextFormatterApp.java	Sat Sep 10 06:41:38 2016 -0700
+++ b/apps/samples/Ensemble8/src/samples/java/ensemble/samples/controls/text/textformatter/TextFormatterApp.java	Sat Sep 10 06:41:47 2016 -0700
@@ -62,7 +62,10 @@
  */
 public class TextFormatterApp extends Application{
 
-    private DoubleProperty price = new SimpleDoubleProperty(1200.555);
+    private final DoubleProperty price = new SimpleDoubleProperty(1200.555);
+    public final DoubleProperty priceProperty() {
+        return price;
+    }
 
     public Parent createContent() {
         final NumberFormat currencyInstance = NumberFormat.getCurrencyInstance();
--- a/apps/samples/Ensemble8/src/samples/java/ensemble/samples/graphics2d/images/imageoperator/ImageOperationApp.java	Sat Sep 10 06:41:38 2016 -0700
+++ b/apps/samples/Ensemble8/src/samples/java/ensemble/samples/graphics2d/images/imageoperator/ImageOperationApp.java	Sat Sep 10 06:41:47 2016 -0700
@@ -34,6 +34,7 @@
 import javafx.application.Application;
 import javafx.beans.InvalidationListener;
 import javafx.beans.Observable;
+import javafx.beans.property.DoubleProperty;
 import javafx.beans.property.SimpleDoubleProperty;
 import javafx.scene.Parent;
 import javafx.scene.Scene;
@@ -64,9 +65,20 @@
  * @related /Graphics 2d/Images/Image Properties
  */
 public class ImageOperationApp extends Application {
-    private SimpleDoubleProperty gridSize = new SimpleDoubleProperty(3.0);
-    private SimpleDoubleProperty hueFactor = new SimpleDoubleProperty(12.0);
-    private SimpleDoubleProperty hueOffset = new SimpleDoubleProperty(240.0);
+    private final DoubleProperty gridSize = new SimpleDoubleProperty(3.0);
+    public final DoubleProperty gridSizeProperty() {
+        return gridSize;
+    }
+
+    private final DoubleProperty hueFactor = new SimpleDoubleProperty(12.0);
+    public final DoubleProperty hueFactorProperty() {
+        return hueFactor;
+    }
+
+    private final DoubleProperty hueOffset = new SimpleDoubleProperty(240.0);
+    public final DoubleProperty hueOffsetProperty() {
+        return hueOffset;
+    }
 
        private static void renderImage(WritableImage img, double gridSize,
                                        double hueFactor, double hueOffset) {
--- a/apps/samples/Ensemble8/src/samples/java/ensemble/samples/graphics3d/sphere/Simple3DSphereApp.java	Sat Sep 10 06:41:38 2016 -0700
+++ b/apps/samples/Ensemble8/src/samples/java/ensemble/samples/graphics3d/sphere/Simple3DSphereApp.java	Sat Sep 10 06:41:47 2016 -0700
@@ -100,12 +100,36 @@
     private Sphere earth;
     private PhongMaterial material;
     private PointLight sun;
+
     private final DoubleProperty sunDistance = new SimpleDoubleProperty(100);
+    public final DoubleProperty sunDistanceProperty() {
+        return sunDistance;
+    }
+
     private final BooleanProperty sunLight = new SimpleBooleanProperty(true);
+    public final BooleanProperty sunLightProperty() {
+        return sunLight;
+    }
+
     private final BooleanProperty diffuseMap = new SimpleBooleanProperty(true);
+    public final BooleanProperty diffuseMapProperty() {
+        return diffuseMap;
+    }
+
     private final BooleanProperty specularMap = new SimpleBooleanProperty(true);
+    public final BooleanProperty specularMapProperty() {
+        return specularMap;
+    }
+
     private final BooleanProperty bumpMap = new SimpleBooleanProperty(true);
+    public final BooleanProperty bumpMapProperty() {
+        return bumpMap;
+    }
+
     private final BooleanProperty selfIlluminationMap = new SimpleBooleanProperty(true);
+    public final BooleanProperty selfIlluminationMapProperty() {
+        return selfIlluminationMap;
+    }
 
     public Parent createContent() throws Exception {
 
--- a/apps/samples/Ensemble8/src/samples/java/ensemble/samples/media/alphamediaplayer/AlphaMediaPlayerApp.java	Sat Sep 10 06:41:38 2016 -0700
+++ b/apps/samples/Ensemble8/src/samples/java/ensemble/samples/media/alphamediaplayer/AlphaMediaPlayerApp.java	Sat Sep 10 06:41:47 2016 -0700
@@ -33,6 +33,7 @@
 
 import javafx.application.Application;
 import javafx.beans.Observable;
+import javafx.beans.property.DoubleProperty;
 import javafx.beans.property.SimpleDoubleProperty;
 import javafx.scene.Parent;
 import javafx.scene.media.Media;
@@ -63,10 +64,26 @@
     PlanetaryPlayerPane planetaryPlayerPane;
     private MediaPlayer arthPlayer;
     private MediaPlayer fierPlayer;
-    SimpleDoubleProperty arthPos = new SimpleDoubleProperty(-90.0);
-    SimpleDoubleProperty fierPos = new SimpleDoubleProperty(50.0);
-    SimpleDoubleProperty arthRate = new SimpleDoubleProperty(1.0);
-    SimpleDoubleProperty fierRate = new SimpleDoubleProperty(1.0);
+
+    private final DoubleProperty arthPos = new SimpleDoubleProperty(-90.0);
+    public final DoubleProperty arthPosProperty() {
+        return arthPos;
+    }
+
+    private final DoubleProperty fierPos = new SimpleDoubleProperty(50.0);
+    public final DoubleProperty fierPosProperty() {
+        return fierPos;
+    }
+
+    private final DoubleProperty arthRate = new SimpleDoubleProperty(1.0);
+    public final DoubleProperty arthRateProperty() {
+        return arthRate;
+    }
+
+    private final DoubleProperty fierRate = new SimpleDoubleProperty(1.0);
+    public final DoubleProperty fierRateProperty() {
+        return fierRate;
+    }
 
     public Parent createContent() {
         String ARTH_URL =