8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package test.javafx.scene.bounds; 27 28 import com.sun.javafx.sg.prism.NGNode; 29 import com.sun.javafx.sg.prism.NGRectangle; 30 import javafx.beans.property.FloatProperty; 31 import javafx.beans.property.SimpleFloatProperty; 32 import javafx.scene.Node; 33 34 import com.sun.javafx.jmx.MXNodeAlgorithm; 35 import com.sun.javafx.jmx.MXNodeAlgorithmContext; 36 import test.com.sun.javafx.scene.bounds.PerfNodeHelper; 37 38 /** 39 * A special node used for performance tests to make sure that the minimum 40 * amount of bounds computation work happens as possible. 41 */ 42 public class PerfNode extends Node { 43 static { 44 // This is used by classes in different packages to get access to 45 // private and package private methods. 46 PerfNodeHelper.setPerfNodeAccessor(new PerfNodeHelper.PerfNodeAccessor() { 47 @Override 48 public NGNode doCreatePeer(Node node) { 49 return ((PerfNode) node).doCreatePeer(); 50 } 51 }); 52 } 53 54 { 55 // To initialize the class helper at the begining each constructor of this class 56 PerfNodeHelper.initHelper(this); 57 } 58 public PerfNode() { 59 } 60 61 public PerfNode(float x, float y, float width, float height) { 62 setX(x); 63 setY(y); 64 setWidth(width); 65 setHeight(height); 66 } 67 private FloatProperty x; 68 69 public final void setX(float value) { 70 xProperty().set(value); 71 } 72 73 public final float getX() { 74 return x == null ? 0 : x.get(); 75 } 76 77 public FloatProperty xProperty() { 78 if (x == null) { 79 x = new SimpleFloatProperty() { 80 81 @Override 82 protected void invalidated() { 83 impl_geomChanged(); 84 } 85 }; 86 } 87 return x; 88 } 89 private FloatProperty y; 90 91 public final void setY(float value) { 92 yProperty().set(value); 93 } 94 95 public final float getY() { 96 return y == null ? 0 : y.get(); 97 } 98 99 public FloatProperty yProperty() { 100 if (y == null) { 101 y = new SimpleFloatProperty() { 102 103 @Override 104 protected void invalidated() { 105 impl_geomChanged(); 106 } 107 }; 108 } 109 return y; 110 } 111 private FloatProperty width; 112 113 public final void setWidth(float value) { 114 widthProperty().set(value); 115 } 116 117 public final float getWidth() { 118 return width == null ? 100 : width.get(); 119 } 120 121 public FloatProperty widthProperty() { 122 if (width == null) { 123 width = new SimpleFloatProperty() { 124 125 @Override 126 protected void invalidated() { 127 impl_storeWidth(width, get()); 128 } 129 }; 130 } 131 return width; 132 } 133 134 protected void impl_storeWidth(FloatProperty model, float value) { 135 impl_geomChanged(); 136 } 137 138 private FloatProperty height; 139 140 public final void setHeight(float value) { 141 heightProperty().set(value); 142 } 143 144 public final float getHeight() { 145 return height == null ? 100 : height.get(); 146 } 147 148 public FloatProperty heightProperty() { 149 if (height == null) { 150 height = new SimpleFloatProperty() { 151 152 @Override 153 protected void invalidated() { 154 impl_storeHeight(height, get()); 155 } 156 }; 157 } 158 return height; 159 } 160 161 protected void impl_storeHeight(FloatProperty model, float value) { 162 impl_geomChanged(); 163 } 164 165 int geomComputeCount = 0; 166 167 public com.sun.javafx.geom.BaseBounds impl_computeGeomBounds(com.sun.javafx.geom.BaseBounds bounds, com.sun.javafx.geom.transform.BaseTransform tx) { 168 geomComputeCount++; 169 bounds = bounds.deriveWithNewBounds(0, 0, 0, 100, 100, 0); 170 return bounds; 171 } 172 173 @Override 174 protected boolean impl_computeContains(double localX, double localY) { 175 // Stub 176 return false; 177 } 178 179 private NGNode doCreatePeer() { 180 return new NGRectangle(); 181 } 182 183 @Override 184 public Object impl_processMXNode(MXNodeAlgorithm alg, MXNodeAlgorithmContext ctx) { 185 return null; 186 } 187 } | 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package test.javafx.scene.bounds; 27 28 import com.sun.javafx.geom.BaseBounds; 29 import com.sun.javafx.geom.transform.BaseTransform; 30 import com.sun.javafx.sg.prism.NGNode; 31 import com.sun.javafx.sg.prism.NGRectangle; 32 import javafx.beans.property.FloatProperty; 33 import javafx.beans.property.SimpleFloatProperty; 34 import javafx.scene.Node; 35 36 import com.sun.javafx.jmx.MXNodeAlgorithm; 37 import com.sun.javafx.jmx.MXNodeAlgorithmContext; 38 import com.sun.javafx.scene.NodeHelper; 39 import test.com.sun.javafx.scene.bounds.PerfNodeHelper; 40 41 /** 42 * A special node used for performance tests to make sure that the minimum 43 * amount of bounds computation work happens as possible. 44 */ 45 public class PerfNode extends Node { 46 static { 47 // This is used by classes in different packages to get access to 48 // private and package private methods. 49 PerfNodeHelper.setPerfNodeAccessor(new PerfNodeHelper.PerfNodeAccessor() { 50 @Override 51 public NGNode doCreatePeer(Node node) { 52 return ((PerfNode) node).doCreatePeer(); 53 } 54 55 @Override 56 public BaseBounds doComputeGeomBounds(Node node, 57 BaseBounds bounds, BaseTransform tx) { 58 return ((PerfNode) node).doComputeGeomBounds(bounds, tx); 59 } 60 61 @Override 62 public boolean doComputeContains(Node node, double localX, double localY) { 63 return ((PerfNode) node).doComputeContains(localX, localY); 64 } 65 66 @Override 67 public Object doProcessMXNode(Node node, MXNodeAlgorithm alg, MXNodeAlgorithmContext ctx) { 68 return ((PerfNode) node).doProcessMXNode(alg, ctx); 69 } 70 }); 71 } 72 73 { 74 // To initialize the class helper at the begining each constructor of this class 75 PerfNodeHelper.initHelper(this); 76 } 77 public PerfNode() { 78 } 79 80 public PerfNode(float x, float y, float width, float height) { 81 setX(x); 82 setY(y); 83 setWidth(width); 84 setHeight(height); 85 } 86 private FloatProperty x; 87 88 public final void setX(float value) { 89 xProperty().set(value); 90 } 91 92 public final float getX() { 93 return x == null ? 0 : x.get(); 94 } 95 96 public FloatProperty xProperty() { 97 if (x == null) { 98 x = new SimpleFloatProperty() { 99 100 @Override 101 protected void invalidated() { 102 NodeHelper.geomChanged(PerfNode.this); 103 } 104 }; 105 } 106 return x; 107 } 108 private FloatProperty y; 109 110 public final void setY(float value) { 111 yProperty().set(value); 112 } 113 114 public final float getY() { 115 return y == null ? 0 : y.get(); 116 } 117 118 public FloatProperty yProperty() { 119 if (y == null) { 120 y = new SimpleFloatProperty() { 121 122 @Override 123 protected void invalidated() { 124 NodeHelper.geomChanged(PerfNode.this); 125 } 126 }; 127 } 128 return y; 129 } 130 private FloatProperty width; 131 132 public final void setWidth(float value) { 133 widthProperty().set(value); 134 } 135 136 public final float getWidth() { 137 return width == null ? 100 : width.get(); 138 } 139 140 public FloatProperty widthProperty() { 141 if (width == null) { 142 width = new SimpleFloatProperty() { 143 144 @Override 145 protected void invalidated() { 146 impl_storeWidth(width, get()); 147 } 148 }; 149 } 150 return width; 151 } 152 153 protected void impl_storeWidth(FloatProperty model, float value) { 154 NodeHelper.geomChanged(this); 155 } 156 157 private FloatProperty height; 158 159 public final void setHeight(float value) { 160 heightProperty().set(value); 161 } 162 163 public final float getHeight() { 164 return height == null ? 100 : height.get(); 165 } 166 167 public FloatProperty heightProperty() { 168 if (height == null) { 169 height = new SimpleFloatProperty() { 170 171 @Override 172 protected void invalidated() { 173 impl_storeHeight(height, get()); 174 } 175 }; 176 } 177 return height; 178 } 179 180 protected void impl_storeHeight(FloatProperty model, float value) { 181 NodeHelper.geomChanged(this); 182 } 183 184 int geomComputeCount = 0; 185 186 /* 187 * Note: This method MUST only be called via its accessor method. 188 */ 189 private BaseBounds doComputeGeomBounds(com.sun.javafx.geom.BaseBounds bounds, com.sun.javafx.geom.transform.BaseTransform tx) { 190 geomComputeCount++; 191 bounds = bounds.deriveWithNewBounds(0, 0, 0, 100, 100, 0); 192 return bounds; 193 } 194 195 /* 196 * Note: This method MUST only be called via its accessor method. 197 */ 198 private boolean doComputeContains(double localX, double localY) { 199 // Stub 200 return false; 201 } 202 203 private NGNode doCreatePeer() { 204 return new NGRectangle(); 205 } 206 207 /* 208 * Note: This method MUST only be called via its accessor method. 209 */ 210 private Object doProcessMXNode(MXNodeAlgorithm alg, MXNodeAlgorithmContext ctx) { 211 return null; 212 } 213 } |