1 /* 2 * Copyright (c) 2005, 2020, 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 * (C) Copyright IBM Corp. 2005, All Rights Reserved. 27 */ 28 package java.awt.font; 29 30 import java.awt.geom.Point2D; 31 32 /** 33 * LayoutPath provides a mapping between locations relative to the 34 * baseline and points in user space. Locations consist of an advance 35 * along the baseline, and an offset perpendicular to the baseline at 36 * the advance. Positive values along the perpendicular are in the 37 * direction that is 90 degrees clockwise from the baseline vector. 38 * Locations are represented as a {@code Point2D}, where x is the advance and 39 * y is the offset. 40 * 41 * @since 1.6 42 */ 43 public abstract class LayoutPath { 44 45 /** 46 * Constructor for subclasses to call. 47 */ 48 public LayoutPath() {} 49 50 /** 51 * Convert a point in user space to a location relative to the 52 * path. The location is chosen so as to minimize the distance 53 * from the point to the path (e.g., the magnitude of the offset 54 * will be smallest). If there is more than one such location, 55 * the location with the smallest advance is chosen. 56 * @param point the point to convert. If it is not the same 57 * object as location, point will remain unmodified by this call. 58 * @param location a {@code Point2D} to hold the returned location. 59 * It can be the same object as point. 60 * @return true if the point is associated with the portion of the 61 * path preceding the location, false if it is associated with 62 * the portion following. The default, if the location is not at 63 * a break or sharp bend in the path, is to return true. 64 * @throws NullPointerException if point or location is null 65 * @since 1.6 66 */ 67 public abstract boolean pointToPath(Point2D point, Point2D location); 68 69 /** 70 * Convert a location relative to the path to a point in user 71 * coordinates. The path might bend abruptly or be disjoint at 72 * the location's advance. If this is the case, the value of 73 * 'preceding' is used to disambiguate the portion of the path 74 * whose location and slope is to be used to interpret the offset. 75 * @param location a {@code Point2D} representing the advance (in x) and 76 * offset (in y) of a location relative to the path. If location 77 * is not the same object as point, location will remain 78 * unmodified by this call. 79 * @param preceding if true, the portion preceding the advance 80 * should be used, if false the portion after should be used. 81 * This has no effect if the path does not break or bend sharply 82 * at the advance. 83 * @param point a {@code Point2D} to hold the returned point. It can be 84 * the same object as location. 85 * @throws NullPointerException if location or point is null 86 * @since 1.6 87 */ 88 public abstract void pathToPoint(Point2D location, boolean preceding, 89 Point2D point); 90 }