Spec-Zone .ru
спецификации, руководства, описания, API
|
001/* 002 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 004 * 005 * This code is free software; you can redistribute it and/or modify it 006 * under the terms of the GNU General Public License version 2 only, as 007 * published by the Free Software Foundation. Oracle designates this 008 * particular file as subject to the "Classpath" exception as provided 009 * by Oracle in the LICENSE file that accompanied this code. 010 * 011 * This code is distributed in the hope that it will be useful, but WITHOUT 012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 014 * version 2 for more details (a copy is included in the LICENSE file that 015 * accompanied this code). 016 * 017 * You should have received a copy of the GNU General Public License version 018 * 2 along with this work; if not, write to the Free Software Foundation, 019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 020 * 021 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 022 * or visit www.oracle.com if you need additional information or have any 023 * questions. 024 */ 025 026package javafx.scene.shape; 027 028import java.util.Iterator; 029 030import javafx.beans.property.BooleanProperty; 031import javafx.beans.property.BooleanPropertyBase; 032import javafx.scene.Node; 033 034import com.sun.javafx.WeakReferenceQueue; 035import com.sun.javafx.geom.Path2D; 036import com.sun.javafx.sg.PGPath; 037 038 039/** 040 * The {@code PathElement} class represents an abstract element 041 * of the {@link Path} that can represent any geometric objects 042 * like straight lines, arcs, quadratic curves, cubic curves, etc. 043 */ 044public abstract class PathElement { 045 046 /** 047 * Defines the sequence of {@code Path} objects this path element 048 * is attached to. 049 */ 050 WeakReferenceQueue impl_nodes = new WeakReferenceQueue(); 051 052 void addNode(final Node n) { 053 impl_nodes.add(n); 054 } 055 056 void removeNode(final Node n) { 057 impl_nodes.remove(n); 058 } 059 060 void u() { 061 final Iterator iterator = impl_nodes.iterator(); 062 while (iterator.hasNext()) { 063 ((Path) iterator.next()).markPathDirty(); 064 } 065 } 066 067 abstract void addTo(PGPath pgPath); 068 069 /** 070 * @treatAsPrivate implementation detail 071 * @deprecated This is an internal API that is not intended for use and will be removed in the next version 072 */ 073 @Deprecated 074 public abstract void impl_addTo(Path2D path); 075 /** 076 * A flag that indicates whether the path coordinates are absolute or 077 * relative. A value of true indicates that the coordinates are absolute 078 * values. A value of false indicates that the values in this PathElement 079 * are added to the coordinates of the previous PathElement to compute the 080 * actual coordinates. 081 * 082 * @defaultValue true 083 */ 084 private BooleanProperty absolute; 085 086 087 public final void setAbsolute(boolean value) { 088 absoluteProperty().set(value); 089 } 090 091 public final boolean isAbsolute() { 092 return absolute == null || absolute.get(); 093 } 094 095 public final BooleanProperty absoluteProperty() { 096 if (absolute == null) { 097 absolute = new BooleanPropertyBase() { 098 @Override protected void invalidated() { 099 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