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 028 029import javafx.beans.property.DoubleProperty; 030import javafx.beans.property.DoublePropertyBase; 031 032import com.sun.javafx.geom.Path2D; 033import com.sun.javafx.sg.PGPath; 034 035 036/** 037 * Creates a vertical line path element from the current point to y. 038 * 039 * <p>For more information on path elements see the {@link Path} and 040 * {@link PathElement} classes. 041 * 042 * <p>Example: 043<PRE> 044import javafx.scene.shape.*; 045 046Path path = new Path(); 047path.getElements().add(new MoveTo(50.0f, 0.0f)); 048path.getElements().add(new VLineTo(50.0f)); 049</PRE> 050 */ 051public class VLineTo extends PathElement { 052 053 /** 054 * Creates an empty instance of VLineTo. 055 */ 056 public VLineTo() { 057 } 058 059 /** 060 * Creates an instance of VLineTo. 061 * @param y the vertical coordinate to line to 062 */ 063 public VLineTo(double y) { 064 setY(y); 065 } 066 067 /** 068 * Defines the Y coordinate. 069 * 070 * @defaultValue 0.0 071 */ 072 private DoubleProperty y = new DoublePropertyBase() { 073 074 @Override 075 public void invalidated() { 076 u(); 077 } 078 079 @Override 080 public Object getBean() { 081 return VLineTo.this; 082 } 083 084 @Override 085 public String getName() { 086 return "y"; 087 } 088 }; 089 090 091 public final void setY(double value) { 092 y.set(value); 093 } 094 095 public final double getY() { 096 return y.get(); 097 } 098 099 public final DoubleProperty yProperty() { 100 return y; 101 } 102 103 @Override 104 void addTo(PGPath pgPath) { 105 if (isAbsolute()) { 106 pgPath.addLineTo(pgPath.getCurrentX(), (float)getY()); 107 } else { 108 pgPath.addLineTo(pgPath.getCurrentX(), (float)(pgPath.getCurrentY() + getY())); 109 } 110 } 111 112 /** 113 * @treatAsPrivate implementation detail 114 * @deprecated This is an internal API that is not intended for use and will be removed in the next version 115 */ 116 @Deprecated 117 @Override 118 public void impl_addTo(Path2D path) { 119 if (isAbsolute()) { 120 path.lineTo(path.getCurrentX(), (float)getY()); 121 } else { 122 path.lineTo(path.getCurrentX(), (float)(path.getCurrentY() + getY())); 123 } 124 } 125 126 /** 127 * Returns a string representation of this {@code VLineTo} object. 128 * @return a string representation of this {@code VLineTo} object. 129 */ 130 @Override 131 public String toString() { 132 final StringBuilder sb = new StringBuilder("VLineTo["); 133 sb.append("y=").append(getY()); 134 return sb.append("]").toString(); 135 } 136}