Frames | No Frames |
1: /* Point.java -- Holds information for one point on a glyph outline 2: Copyright (C) 2006 Free Software Foundation, Inc. 3: 4: This file is part of GNU Classpath. 5: 6: GNU Classpath is free software; you can redistribute it and/or modify 7: it under the terms of the GNU General Public License as published by 8: the Free Software Foundation; either version 2, or (at your option) 9: any later version. 10: 11: GNU Classpath is distributed in the hope that it will be useful, but 12: WITHOUT ANY WARRANTY; without even the implied warranty of 13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14: General Public License for more details. 15: 16: You should have received a copy of the GNU General Public License 17: along with GNU Classpath; see the file COPYING. If not, write to the 18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19: 02110-1301 USA. 20: 21: Linking this library statically or dynamically with other modules is 22: making a combined work based on this library. Thus, the terms and 23: conditions of the GNU General Public License cover the whole 24: combination. 25: 26: As a special exception, the copyright holders of this library give you 27: permission to link this library with independent modules to produce an 28: executable, regardless of the license terms of these independent 29: modules, and to copy and distribute the resulting executable under 30: terms of your choice, provided that you also meet, for each linked 31: independent module, the terms and conditions of the license of that 32: module. An independent module is a module which is not derived from 33: or based on this library. If you modify this library, you may extend 34: this exception to your version of the library, but you are not 35: obligated to do so. If you do not wish to do so, delete this 36: exception statement from your version. */ 37: 38: 39: package gnu.java.awt.font.opentype.truetype; 40: 41: /** 42: * Encapsulates information regarding one point on a glyph outline. 43: */ 44: public class Point 45: { 46: public static final short FLAG_TOUCHED_X = 1; 47: public static final short FLAG_TOUCHED_Y = 2; 48: public static final short FLAG_ON_CURVE = 4; 49: public static final short FLAG_CONTOUR_END = 8; 50: public static final short FLAG_WEAK_INTERPOLATION = 16; 51: public static final short FLAG_INFLECTION = 32; 52: public static final short FLAG_DONE_X = 64; 53: public static final short FLAG_DONE_Y = 128; 54: 55: /** 56: * Right direction. 57: */ 58: public static final int DIR_RIGHT = 1; 59: 60: /** 61: * Left direction. 62: */ 63: public static final int DIR_LEFT = -1; 64: 65: /** 66: * Up direction. 67: */ 68: public static final int DIR_UP = 2; 69: 70: /** 71: * Down direction. 72: */ 73: public static final int DIR_DOWN = -2; 74: 75: /** 76: * The original x coordinate in font units. 77: */ 78: int origX; 79: 80: /** 81: * The original y coordinate in font units. 82: */ 83: int origY; 84: 85: /** 86: * The x coordinate scaled to the target. 87: */ 88: int scaledX; 89: 90: /** 91: * The y coordinate scaled to the target. 92: */ 93: int scaledY; 94: 95: /** 96: * The final hinted and scaled x coordinate. 97: */ 98: int x; 99: 100: /** 101: * The final hinted and scaled y coordinate. 102: */ 103: int y; 104: 105: int u; 106: int v; 107: 108: /** 109: * The glyph flags. 110: */ 111: short flags; 112: 113: /** 114: * The previous point in the contour. 115: */ 116: private Point prev; 117: 118: /** 119: * The next point in the contour. 120: */ 121: private Point next; 122: 123: /** 124: * The in-direction of the point, according to the DIR_* constants of this 125: * class. 126: */ 127: int inDir; 128: 129: /** 130: * The out-direction of the point, according to the DIR_* constants of this 131: * class. 132: */ 133: int outDir; 134: 135: public Point getNext() 136: { 137: return next; 138: } 139: 140: public void setNext(Point next) 141: { 142: this.next = next; 143: } 144: 145: public Point getPrev() 146: { 147: return prev; 148: } 149: 150: public void setPrev(Point prev) 151: { 152: this.prev = prev; 153: } 154: 155: public int getOrigX() 156: { 157: return origX; 158: } 159: 160: public void setOrigX(int origX) 161: { 162: this.origX = origX; 163: } 164: 165: public int getOrigY() 166: { 167: return origY; 168: } 169: 170: public void setOrigY(int origY) 171: { 172: this.origY = origY; 173: } 174: 175: public int getInDir() 176: { 177: return inDir; 178: } 179: 180: public void setInDir(int inDir) 181: { 182: this.inDir = inDir; 183: } 184: 185: public int getOutDir() 186: { 187: return outDir; 188: } 189: 190: public void setOutDir(int outDir) 191: { 192: this.outDir = outDir; 193: } 194: 195: public short getFlags() 196: { 197: return flags; 198: } 199: 200: public void setFlags(short flags) 201: { 202: this.flags = flags; 203: } 204: 205: public void addFlags(short flags) 206: { 207: this.flags |= flags; 208: } 209: 210: public boolean isControlPoint() 211: { 212: return (flags & FLAG_ON_CURVE) == 0; 213: } 214: 215: public int getU() 216: { 217: return u; 218: } 219: 220: public void setU(int u) 221: { 222: this.u = u; 223: } 224: 225: public int getV() 226: { 227: return v; 228: } 229: 230: public void setV(int v) 231: { 232: this.v = v; 233: } 234: 235: public String toString() 236: { 237: StringBuilder s = new StringBuilder(); 238: s.append("[Point] origX: "); 239: s.append(origX); 240: s.append(", origY: "); 241: s.append(origY); 242: // TODO: Add more info when needed. 243: return s.toString(); 244: } 245: 246: public int getX() 247: { 248: return x; 249: } 250: 251: public void setX(int x) 252: { 253: this.x = x; 254: } 255: 256: public int getY() 257: { 258: return y; 259: } 260: 261: public void setY(int y) 262: { 263: this.y = y; 264: } 265: 266: public int getScaledX() 267: { 268: return scaledX; 269: } 270: 271: public void setScaledX(int scaledX) 272: { 273: this.scaledX = scaledX; 274: } 275: 276: public int getScaledY() 277: { 278: return scaledY; 279: } 280: 281: public void setScaledY(int scaledY) 282: { 283: this.scaledY = scaledY; 284: } 285: }