1 /* 2 * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 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 javafx.scene.shape; 27 28 import com.sun.javafx.util.WeakReferenceQueue; 29 import com.sun.javafx.geom.Path2D; 30 import com.sun.javafx.sg.prism.NGPath; 31 import javafx.beans.property.BooleanProperty; 32 import javafx.beans.property.BooleanPropertyBase; 33 import javafx.scene.Node; 34 35 import java.util.Iterator; 36 37 38 /** 39 * The {@code PathElement} class represents an abstract element 40 * of the {@link Path} that can represent any geometric objects 41 * like straight lines, arcs, quadratic curves, cubic curves, etc. 42 * @since JavaFX 2.0 43 */ 44 public abstract class PathElement { 45 46 /** 47 * Defines the sequence of {@code Path} objects this path element 48 * is attached to. 49 */ 50 WeakReferenceQueue impl_nodes = new WeakReferenceQueue(); 51 52 void addNode(final Node n) { 53 impl_nodes.add(n); 54 } 55 56 void removeNode(final Node n) { 57 impl_nodes.remove(n); 58 } 59 60 void u() { 61 final Iterator iterator = impl_nodes.iterator(); 62 while (iterator.hasNext()) { 63 ((Path) iterator.next()).markPathDirty(); 64 } 65 } 66 67 abstract void addTo(NGPath pgPath); 68 69 /** 70 * @treatAsPrivate implementation detail 71 * @deprecated This is an internal API that is not intended for use and will be removed in the next version 72 */ 73 @Deprecated 74 public abstract void impl_addTo(Path2D path); 75 /** 76 * A flag that indicates whether the path coordinates are absolute or 77 * relative. A value of true indicates that the coordinates are absolute 78 * values. A value of false indicates that the values in this PathElement 79 * are added to the coordinates of the previous PathElement to compute the 80 * actual coordinates. 81 * 82 * @defaultValue true 83 */ 84 private BooleanProperty absolute; 85 86 87 public final void setAbsolute(boolean value) { 88 absoluteProperty().set(value); 89 } 90 91 public final boolean isAbsolute() { 92 return absolute == null || absolute.get(); 93 } 94 95 public final BooleanProperty absoluteProperty() { 96 if (absolute == null) { 97 absolute = new BooleanPropertyBase() { 98 @Override protected void invalidated() { 99 u(); 100 } 101 102 @Override 103 public Object getBean() { 104 return PathElement.this; 105 } 106 107 @Override 108 public String getName() { 109 return "absolute"; 110 } 111 }; 112 } 113 return absolute; 114 } 115 } 116