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 com.sun.javafx.scene.layout; 27 28 import com.sun.javafx.scene.ParentHelper; 29 import com.sun.javafx.sg.prism.NGNode; 30 import com.sun.javafx.util.Utils; 31 import javafx.scene.Node; 32 import javafx.scene.layout.Region; 33 34 /** 35 * Used to access internal methods of Region. 36 */ 37 public class RegionHelper extends ParentHelper { 38 39 private static final RegionHelper theInstance; 40 private static RegionAccessor regionAccessor; 41 42 static { 43 theInstance = new RegionHelper(); 44 Utils.forceInit(Region.class); 45 } 46 47 private static RegionHelper getInstance() { 48 return theInstance; 49 } 50 51 public static void initHelper(Region region) { 52 setHelper(region, getInstance()); 53 } 54 55 @Override 56 protected NGNode createPeerImpl(Node node) { 57 return regionAccessor.doCreatePeer(node); 58 } 59 60 @Override 61 protected void updatePeerImpl(Node node) { 62 super.updatePeerImpl(node); 63 regionAccessor.doUpdatePeer(node); 64 } 65 66 public static void setRegionAccessor(final RegionAccessor newAccessor) { 67 if (regionAccessor != null) { 68 throw new IllegalStateException(); 69 } 70 71 regionAccessor = newAccessor; 72 } 73 74 public interface RegionAccessor { 75 void doUpdatePeer(Node node); 76 NGNode doCreatePeer(Node node); 77 } 78 79 } | 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 com.sun.javafx.scene.layout; 27 28 import com.sun.javafx.geom.BaseBounds; 29 import com.sun.javafx.geom.PickRay; 30 import com.sun.javafx.geom.transform.BaseTransform; 31 import com.sun.javafx.scene.ParentHelper; 32 import com.sun.javafx.scene.input.PickResultChooser; 33 import com.sun.javafx.sg.prism.NGNode; 34 import com.sun.javafx.util.Utils; 35 import javafx.geometry.Bounds; 36 import javafx.scene.Node; 37 import javafx.scene.layout.Region; 38 39 /** 40 * Used to access internal methods of Region. 41 */ 42 public class RegionHelper extends ParentHelper { 43 44 private static final RegionHelper theInstance; 45 private static RegionAccessor regionAccessor; 46 47 static { 48 theInstance = new RegionHelper(); 49 Utils.forceInit(Region.class); 50 } 51 52 private static RegionHelper getInstance() { 53 return theInstance; 54 } 55 56 public static void initHelper(Region region) { 57 setHelper(region, getInstance()); 58 } 59 60 @Override 61 protected NGNode createPeerImpl(Node node) { 62 return regionAccessor.doCreatePeer(node); 63 } 64 65 @Override 66 protected void updatePeerImpl(Node node) { 67 super.updatePeerImpl(node); 68 regionAccessor.doUpdatePeer(node); 69 } 70 71 @Override 72 protected Bounds computeLayoutBoundsImpl(Node node) { 73 return regionAccessor.doComputeLayoutBounds(node); 74 } 75 76 @Override 77 protected BaseBounds computeGeomBoundsImpl(Node node, BaseBounds bounds, 78 BaseTransform tx) { 79 regionAccessor.doComputeGeomBounds(node, bounds, tx); 80 // NOTE: Okay to call computeGeomBoundsImpl with tx even in the 3D case 81 // since Parent's computeGeomBoundsImpl does handle 3D correctly. 82 BaseBounds cb = super.computeGeomBoundsImpl(node, bounds, tx); 83 return regionAccessor.doComputeGeomBounds2(cb, node, bounds, tx); 84 } 85 86 @Override 87 protected boolean computeContainsImpl(Node node, double localX, double localY) { 88 return regionAccessor.doComputeContains(node, localX, localY); 89 } 90 91 @Override 92 protected void notifyLayoutBoundsChangedImpl(Node node) { 93 regionAccessor.doNotifyLayoutBoundsChanged(node); 94 } 95 @Override 96 protected void pickNodeLocalImpl(Node node, PickRay localPickRay, 97 PickResultChooser result) { 98 regionAccessor.doPickNodeLocal(node, localPickRay, result); 99 } 100 101 public static void setRegionAccessor(final RegionAccessor newAccessor) { 102 if (regionAccessor != null) { 103 throw new IllegalStateException(); 104 } 105 106 regionAccessor = newAccessor; 107 } 108 109 public interface RegionAccessor { 110 void doUpdatePeer(Node node); 111 NGNode doCreatePeer(Node node); 112 Bounds doComputeLayoutBounds(Node node); 113 BaseBounds doComputeGeomBounds(Node node, BaseBounds bounds, BaseTransform tx); 114 BaseBounds doComputeGeomBounds2(BaseBounds cb, Node node, BaseBounds bounds, BaseTransform tx); 115 boolean doComputeContains(Node node, double localX, double localY); 116 void doNotifyLayoutBoundsChanged(Node node); 117 void doPickNodeLocal(Node node, PickRay localPickRay, 118 PickResultChooser result); 119 } 120 121 } |