< prev index next >

modules/graphics/src/main/java/com/sun/javafx/scene/shape/ShapeHelper.java

Print this page




   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.shape;
  27 




  28 import com.sun.javafx.scene.DirtyBits;
  29 import com.sun.javafx.scene.NodeHelper;
  30 import com.sun.javafx.sg.prism.NGNode;
  31 import com.sun.javafx.sg.prism.NGShape;
  32 import com.sun.javafx.util.Utils;
  33 import javafx.scene.Node;
  34 import javafx.scene.paint.Paint;
  35 import javafx.scene.shape.Shape;
  36 
  37 /**
  38  * Used to access internal methods of Shape.
  39  */
  40 public abstract class ShapeHelper extends NodeHelper {
  41     private static ShapeAccessor shapeAccessor;
  42 
  43     static {
  44         Utils.forceInit(Shape.class);
  45     }
  46 
  47     /*


  61     public static com.sun.javafx.geom.Shape configShape(Shape shape) {
  62         return ((ShapeHelper) getHelper(shape)).configShapeImpl(shape);
  63     }
  64 
  65     /*
  66      * Methods that will be overridden by subclasses
  67      */
  68 
  69     @Override
  70     protected void updatePeerImpl(Node node) {
  71         super.updatePeerImpl(node);
  72         shapeAccessor.doUpdatePeer(node);
  73     }
  74 
  75     @Override
  76     protected void markDirtyImpl(Node node, DirtyBits dirtyBit) {
  77         shapeAccessor.doMarkDirty(node, dirtyBit);
  78         super.markDirtyImpl(node, dirtyBit);
  79     }
  80 
















  81     protected Paint cssGetFillInitialValueImpl(Shape shape) {
  82         return shapeAccessor.doCssGetFillInitialValue(shape);
  83     }
  84 
  85     protected Paint cssGetStrokeInitialValueImpl(Shape shape) {
  86         return shapeAccessor.doCssGetStrokeInitialValue(shape);
  87     }
  88 
  89     protected abstract com.sun.javafx.geom.Shape configShapeImpl(Shape shape);
  90 
  91     /*
  92      * Methods used by Shape (base) class only
  93      */
  94 
  95     public static NGShape.Mode getMode(Shape shape) {
  96         return shapeAccessor.getMode(shape);
  97     }
  98 
  99     public static void setMode(Shape shape, NGShape.Mode mode) {
 100         shapeAccessor.setMode(shape, mode);
 101     }
 102 
 103     public static void setShapeChangeListener(Shape shape, Runnable listener) {
 104         shapeAccessor.setShapeChangeListener(shape, listener);
 105     }
 106 
 107     public static void setShapeAccessor(final ShapeAccessor newAccessor) {
 108         if (shapeAccessor != null) {
 109             throw new IllegalStateException();
 110         }
 111 
 112         shapeAccessor = newAccessor;
 113     }
 114 
 115     public interface ShapeAccessor {
 116         void doUpdatePeer(Node node);
 117         void doMarkDirty(Node node, DirtyBits dirtyBit);



 118         Paint doCssGetFillInitialValue(Shape shape);
 119         Paint doCssGetStrokeInitialValue(Shape shape);
 120         NGShape.Mode getMode(Shape shape);
 121         void setMode(Shape shape, NGShape.Mode mode);
 122         void setShapeChangeListener(Shape shape, Runnable listener);
 123     }
 124 
 125 }


   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.shape;
  27 
  28 import com.sun.javafx.geom.BaseBounds;
  29 import com.sun.javafx.geom.transform.BaseTransform;
  30 import com.sun.javafx.jmx.MXNodeAlgorithm;
  31 import com.sun.javafx.jmx.MXNodeAlgorithmContext;
  32 import com.sun.javafx.scene.DirtyBits;
  33 import com.sun.javafx.scene.NodeHelper;
  34 import com.sun.javafx.sg.prism.NGNode;
  35 import com.sun.javafx.sg.prism.NGShape;
  36 import com.sun.javafx.util.Utils;
  37 import javafx.scene.Node;
  38 import javafx.scene.paint.Paint;
  39 import javafx.scene.shape.Shape;
  40 
  41 /**
  42  * Used to access internal methods of Shape.
  43  */
  44 public abstract class ShapeHelper extends NodeHelper {
  45     private static ShapeAccessor shapeAccessor;
  46 
  47     static {
  48         Utils.forceInit(Shape.class);
  49     }
  50 
  51     /*


  65     public static com.sun.javafx.geom.Shape configShape(Shape shape) {
  66         return ((ShapeHelper) getHelper(shape)).configShapeImpl(shape);
  67     }
  68 
  69     /*
  70      * Methods that will be overridden by subclasses
  71      */
  72 
  73     @Override
  74     protected void updatePeerImpl(Node node) {
  75         super.updatePeerImpl(node);
  76         shapeAccessor.doUpdatePeer(node);
  77     }
  78 
  79     @Override
  80     protected void markDirtyImpl(Node node, DirtyBits dirtyBit) {
  81         shapeAccessor.doMarkDirty(node, dirtyBit);
  82         super.markDirtyImpl(node, dirtyBit);
  83     }
  84 
  85     @Override
  86     protected BaseBounds computeGeomBoundsImpl(Node node, BaseBounds bounds,
  87             BaseTransform tx) {
  88         return shapeAccessor.doComputeGeomBounds(node, bounds, tx);
  89     }
  90 
  91     @Override
  92     protected boolean computeContainsImpl(Node node, double localX, double localY) {
  93         return shapeAccessor.doComputeContains(node, localX, localY);
  94     }
  95 
  96     @Override
  97     protected Object processMXNodeImpl(Node node, MXNodeAlgorithm alg, MXNodeAlgorithmContext ctx) {
  98         return shapeAccessor.doProcessMXNode(node, alg, ctx);
  99     }
 100 
 101     protected Paint cssGetFillInitialValueImpl(Shape shape) {
 102         return shapeAccessor.doCssGetFillInitialValue(shape);
 103     }
 104 
 105     protected Paint cssGetStrokeInitialValueImpl(Shape shape) {
 106         return shapeAccessor.doCssGetStrokeInitialValue(shape);
 107     }
 108 
 109     protected abstract com.sun.javafx.geom.Shape configShapeImpl(Shape shape);
 110 
 111     /*
 112      * Methods used by Shape (base) class only
 113      */
 114 
 115     public static NGShape.Mode getMode(Shape shape) {
 116         return shapeAccessor.getMode(shape);
 117     }
 118 
 119     public static void setMode(Shape shape, NGShape.Mode mode) {
 120         shapeAccessor.setMode(shape, mode);
 121     }
 122 
 123     public static void setShapeChangeListener(Shape shape, Runnable listener) {
 124         shapeAccessor.setShapeChangeListener(shape, listener);
 125     }
 126 
 127     public static void setShapeAccessor(final ShapeAccessor newAccessor) {
 128         if (shapeAccessor != null) {
 129             throw new IllegalStateException();
 130         }
 131 
 132         shapeAccessor = newAccessor;
 133     }
 134 
 135     public interface ShapeAccessor {
 136         void doUpdatePeer(Node node);
 137         void doMarkDirty(Node node, DirtyBits dirtyBit);
 138         BaseBounds doComputeGeomBounds(Node node, BaseBounds bounds, BaseTransform tx);
 139         boolean doComputeContains(Node node, double localX, double localY);
 140         Object doProcessMXNode(Node node, MXNodeAlgorithm alg, MXNodeAlgorithmContext ctx);
 141         Paint doCssGetFillInitialValue(Shape shape);
 142         Paint doCssGetStrokeInitialValue(Shape shape);
 143         NGShape.Mode getMode(Shape shape);
 144         void setMode(Shape shape, NGShape.Mode mode);
 145         void setShapeChangeListener(Shape shape, Runnable listener);
 146     }
 147 
 148 }
< prev index next >