1 /* 2 * Copyright (c) 2011, 2013, 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.layout; 27 28 import javafx.geometry.BoundingBox; 29 import javafx.geometry.Bounds; 30 import javafx.scene.Parent; 31 32 import com.sun.javafx.scene.DirtyBits; 33 34 35 class MockResizable extends Parent { 36 private double minWidth = 0; 37 private double minHeight = 0; 38 private double prefWidth; 39 private double prefHeight; 40 private double maxWidth = 5000; 41 private double maxHeight = 5000; 42 private double width; 43 private double height; 44 45 public MockResizable(double prefWidth, double prefHeight) { 46 this.prefWidth = prefWidth; 47 this.prefHeight = prefHeight; 48 } 49 public MockResizable(double minWidth, double minHeight, double prefWidth, double prefHeight, double maxWidth, double maxHeight) { 50 this.minWidth = minWidth; 51 this.minHeight = minHeight; 52 this.prefWidth = prefWidth; 53 this.prefHeight = prefHeight; 54 this.maxWidth = maxWidth; 55 this.maxHeight = maxHeight; 56 } 57 @Override public boolean isResizable() { 58 return true; 59 } 60 public double getWidth() { 61 return width; 62 } 63 public double getHeight() { 64 return height; 65 } 66 @Override public void resize(double width, double height) { 67 this.width = width; 68 this.height = height; 69 impl_layoutBoundsChanged(); 70 impl_geomChanged(); 71 impl_markDirty(DirtyBits.NODE_GEOMETRY); 72 requestLayout(); 73 } 74 @Override public double getBaselineOffset() { 75 return Math.max(0, prefHeight - 10); 76 } 77 /** 78 * The layout bounds of this region: {@code 0, 0 width x height} 79 */ 80 @Override protected Bounds impl_computeLayoutBounds() { 81 return new BoundingBox(0, 0, 0, width, height, 0); 82 } 83 /** 84 * @treatAsPrivate implementation detail 85 * @deprecated This is an internal API that is not intended for use and will be removed in the next version 86 */ 87 @Deprecated 88 @Override protected void impl_notifyLayoutBoundsChanged() { 89 // change in geometric bounds does not necessarily change layoutBounds 90 } 91 @Override public double minWidth(double height) { 92 return minWidth; 93 } 94 @Override public double minHeight(double width) { 95 return minHeight; 96 } 97 @Override public double prefWidth(double height) { 98 return prefWidth; 99 } 100 @Override public double prefHeight(double width) { 101 return prefHeight; 102 } 103 @Override public double maxWidth(double height) { 104 return maxWidth; 105 } 106 @Override public double maxHeight(double width) { 107 return maxHeight; 108 } 109 }