< prev index next >

modules/graphics/src/main/java/javafx/scene/shape/Polyline.java

Print this page




  56     0.0, 0.0,
  57     20.0, 10.0,
  58     10.0, 20.0 });
  59 </PRE>
  60  * @since JavaFX 2.0
  61  */
  62 public  class Polyline extends Shape {
  63     static {
  64         PolylineHelper.setPolylineAccessor(new PolylineHelper.PolylineAccessor() {
  65             @Override
  66             public NGNode doCreatePeer(Node node) {
  67                 return ((Polyline) node).doCreatePeer();
  68             }
  69 
  70             @Override
  71             public void doUpdatePeer(Node node) {
  72                 ((Polyline) node).doUpdatePeer();
  73             }
  74 
  75             @Override






  76             public Paint doCssGetFillInitialValue(Shape shape) {
  77                 return ((Polyline) shape).doCssGetFillInitialValue();
  78             }
  79 
  80             @Override
  81             public Paint doCssGetStrokeInitialValue(Shape shape) {
  82                 return ((Polyline) shape).doCssGetStrokeInitialValue();
  83             }
  84 
  85             @Override
  86             public com.sun.javafx.geom.Shape doConfigShape(Shape shape) {
  87                 return ((Polyline) shape).doConfigShape();
  88             }
  89         });
  90     }
  91 
  92     private final Path2D shape = new Path2D();
  93 
  94     {
  95         // To initialize the class helper at the begining each constructor of this class


 112      * Creates a new instance of Polyline.
 113      * @param points the coordinates of the polyline segments
 114      */
 115     public Polyline(double... points) {
 116         if (points != null) {
 117             for (double p : points) {
 118                 this.getPoints().add(p);
 119             }
 120         }
 121     }
 122 
 123     /**
 124      * Defines the coordinates of the polyline segments.
 125      *
 126      * @defaultValue empty
 127      */
 128     private final ObservableList<Double> points = new TrackableObservableList<Double>() {
 129         @Override
 130         protected void onChanged(Change<Double> c) {
 131             NodeHelper.markDirty(Polyline.this, DirtyBits.NODE_GEOMETRY);
 132             impl_geomChanged();
 133         }
 134     };
 135 
 136     /**
 137      * Gets the coordinates of the {@code PolyLine} segments.
 138      * @return An observable list of points constituting segments of this
 139      * {@code PolyLine}
 140      */
 141     public final ObservableList<Double> getPoints() { return points; }
 142 
 143     /*
 144      * Note: This method MUST only be called via its accessor method.
 145      */
 146     private NGNode doCreatePeer() {
 147         return new NGPolyline();
 148     }
 149 
 150     /**
 151      * @treatAsPrivate implementation detail
 152      * @deprecated This is an internal API that is not intended for use and will be removed in the next version
 153      */
 154     @Deprecated
 155     public BaseBounds impl_computeGeomBounds(BaseBounds bounds, BaseTransform tx) {
 156         if (getMode() == NGShape.Mode.EMPTY || getPoints().size() <= 1) {
 157             return bounds.makeEmpty();
 158         }
 159 
 160         if (getPoints().size() == 2) {
 161             if (getMode() == NGShape.Mode.FILL || getStrokeType() == StrokeType.INSIDE) {
 162                 return bounds.makeEmpty();
 163             }
 164             double upad = getStrokeWidth();
 165             if (getStrokeType() == StrokeType.CENTERED) {
 166                 upad /= 2.0f;
 167             }
 168             return computeBounds(bounds, tx, upad, 0.5f,
 169                 getPoints().get(0), getPoints().get(1), 0.0f, 0.0f);
 170         } else {
 171             return computeShapeBounds(bounds, tx, ShapeHelper.configShape(this));
 172         }
 173     }
 174 
 175     /*




  56     0.0, 0.0,
  57     20.0, 10.0,
  58     10.0, 20.0 });
  59 </PRE>
  60  * @since JavaFX 2.0
  61  */
  62 public  class Polyline extends Shape {
  63     static {
  64         PolylineHelper.setPolylineAccessor(new PolylineHelper.PolylineAccessor() {
  65             @Override
  66             public NGNode doCreatePeer(Node node) {
  67                 return ((Polyline) node).doCreatePeer();
  68             }
  69 
  70             @Override
  71             public void doUpdatePeer(Node node) {
  72                 ((Polyline) node).doUpdatePeer();
  73             }
  74 
  75             @Override
  76             public BaseBounds doComputeGeomBounds(Node node,
  77             BaseBounds bounds, BaseTransform tx) {
  78                 return ((Polyline) node).doComputeGeomBounds(bounds, tx);
  79             }
  80 
  81             @Override
  82             public Paint doCssGetFillInitialValue(Shape shape) {
  83                 return ((Polyline) shape).doCssGetFillInitialValue();
  84             }
  85 
  86             @Override
  87             public Paint doCssGetStrokeInitialValue(Shape shape) {
  88                 return ((Polyline) shape).doCssGetStrokeInitialValue();
  89             }
  90 
  91             @Override
  92             public com.sun.javafx.geom.Shape doConfigShape(Shape shape) {
  93                 return ((Polyline) shape).doConfigShape();
  94             }
  95         });
  96     }
  97 
  98     private final Path2D shape = new Path2D();
  99 
 100     {
 101         // To initialize the class helper at the begining each constructor of this class


 118      * Creates a new instance of Polyline.
 119      * @param points the coordinates of the polyline segments
 120      */
 121     public Polyline(double... points) {
 122         if (points != null) {
 123             for (double p : points) {
 124                 this.getPoints().add(p);
 125             }
 126         }
 127     }
 128 
 129     /**
 130      * Defines the coordinates of the polyline segments.
 131      *
 132      * @defaultValue empty
 133      */
 134     private final ObservableList<Double> points = new TrackableObservableList<Double>() {
 135         @Override
 136         protected void onChanged(Change<Double> c) {
 137             NodeHelper.markDirty(Polyline.this, DirtyBits.NODE_GEOMETRY);
 138             NodeHelper.geomChanged(Polyline.this);
 139         }
 140     };
 141 
 142     /**
 143      * Gets the coordinates of the {@code PolyLine} segments.
 144      * @return An observable list of points constituting segments of this
 145      * {@code PolyLine}
 146      */
 147     public final ObservableList<Double> getPoints() { return points; }
 148 
 149     /*
 150      * Note: This method MUST only be called via its accessor method.
 151      */
 152     private NGNode doCreatePeer() {
 153         return new NGPolyline();
 154     }
 155 
 156     /*
 157      * Note: This method MUST only be called via its accessor method.

 158      */
 159     private BaseBounds doComputeGeomBounds(BaseBounds bounds, BaseTransform tx) {

 160         if (getMode() == NGShape.Mode.EMPTY || getPoints().size() <= 1) {
 161             return bounds.makeEmpty();
 162         }
 163 
 164         if (getPoints().size() == 2) {
 165             if (getMode() == NGShape.Mode.FILL || getStrokeType() == StrokeType.INSIDE) {
 166                 return bounds.makeEmpty();
 167             }
 168             double upad = getStrokeWidth();
 169             if (getStrokeType() == StrokeType.CENTERED) {
 170                 upad /= 2.0f;
 171             }
 172             return computeBounds(bounds, tx, upad, 0.5f,
 173                 getPoints().get(0), getPoints().get(1), 0.0f, 0.0f);
 174         } else {
 175             return computeShapeBounds(bounds, tx, ShapeHelper.configShape(this));
 176         }
 177     }
 178 
 179     /*


< prev index next >