Source for gnu.java.awt.font.opentype.truetype.Point

   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: import gnu.java.lang.CPStringBuilder;
  42: 
  43: /**
  44:  * Encapsulates information regarding one point on a glyph outline.
  45:  */
  46: public class Point
  47: {
  48:   public static final short FLAG_TOUCHED_X = 1;
  49:   public static final short FLAG_TOUCHED_Y = 2;
  50:   public static final short FLAG_ON_CURVE = 4;
  51:   public static final short FLAG_CONTOUR_END = 8;
  52:   public static final short FLAG_WEAK_INTERPOLATION = 16;
  53:   public static final short FLAG_INFLECTION = 32;
  54:   public static final short FLAG_DONE_X = 64;
  55:   public static final short FLAG_DONE_Y = 128;
  56: 
  57:   /**
  58:    * Right direction.
  59:    */
  60:   public static final int DIR_RIGHT = 1;
  61: 
  62:   /**
  63:    * Left direction.
  64:    */
  65:   public static final int DIR_LEFT = -1;
  66: 
  67:   /**
  68:    * Up direction.
  69:    */
  70:   public static final int DIR_UP = 2;
  71: 
  72:   /**
  73:    * Down direction.
  74:    */
  75:   public static final int DIR_DOWN = -2;
  76: 
  77:   /**
  78:    * The original x coordinate in font units.
  79:    */
  80:   int origX;
  81: 
  82:   /**
  83:    * The original y coordinate in font units.
  84:    */
  85:   int origY;
  86: 
  87:   /**
  88:    * The x coordinate scaled to the target.
  89:    */
  90:   int scaledX;
  91: 
  92:   /**
  93:    * The y coordinate scaled to the target.
  94:    */
  95:   int scaledY;
  96: 
  97:   /**
  98:    * The final hinted and scaled x coordinate.
  99:    */
 100:   int x;
 101: 
 102:   /**
 103:    * The final hinted and scaled y coordinate.
 104:    */
 105:   int y;
 106: 
 107:   int u;
 108:   int v;
 109: 
 110:   /**
 111:    * The glyph flags.
 112:    */
 113:   short flags;
 114: 
 115:   /**
 116:    * The previous point in the contour.
 117:    */
 118:   private Point prev;
 119: 
 120:   /**
 121:    * The next point in the contour.
 122:    */
 123:   private Point next;
 124: 
 125:   /**
 126:    * The in-direction of the point, according to the DIR_* constants of this
 127:    * class.
 128:    */
 129:   int inDir;
 130: 
 131:   /**
 132:    * The out-direction of the point, according to the DIR_* constants of this
 133:    * class.
 134:    */
 135:   int outDir;
 136: 
 137:   public Point getNext()
 138:   {
 139:     return next;
 140:   }
 141: 
 142:   public void setNext(Point next)
 143:   {
 144:     this.next = next;
 145:   }
 146: 
 147:   public Point getPrev()
 148:   {
 149:     return prev;
 150:   }
 151: 
 152:   public void setPrev(Point prev)
 153:   {
 154:     this.prev = prev;
 155:   }
 156: 
 157:   public int getOrigX()
 158:   {
 159:     return origX;
 160:   }
 161: 
 162:   public void setOrigX(int origX)
 163:   {
 164:     this.origX = origX;
 165:   }
 166: 
 167:   public int getOrigY()
 168:   {
 169:     return origY;
 170:   }
 171: 
 172:   public void setOrigY(int origY)
 173:   {
 174:     this.origY = origY;
 175:   }
 176: 
 177:   public int getInDir()
 178:   {
 179:     return inDir;
 180:   }
 181: 
 182:   public void setInDir(int inDir)
 183:   {
 184:     this.inDir = inDir;
 185:   }
 186: 
 187:   public int getOutDir()
 188:   {
 189:     return outDir;
 190:   }
 191: 
 192:   public void setOutDir(int outDir)
 193:   {
 194:     this.outDir = outDir;
 195:   }
 196: 
 197:   public short getFlags()
 198:   {
 199:     return flags;
 200:   }
 201: 
 202:   public void setFlags(short flags)
 203:   {
 204:     this.flags = flags;
 205:   }
 206: 
 207:   public void addFlags(short flags)
 208:   {
 209:     this.flags |= flags;
 210:   }
 211: 
 212:   public boolean isControlPoint()
 213:   {
 214:     return (flags & FLAG_ON_CURVE) == 0;
 215:   }
 216: 
 217:   public int getU()
 218:   {
 219:     return u;
 220:   }
 221: 
 222:   public void setU(int u)
 223:   {
 224:     this.u = u;
 225:   }
 226: 
 227:   public int getV()
 228:   {
 229:     return v;
 230:   }
 231: 
 232:   public void setV(int v)
 233:   {
 234:     this.v = v;
 235:   }
 236: 
 237:   public String toString()
 238:   {
 239:     CPStringBuilder s = new CPStringBuilder();
 240:     s.append("[Point] origX: ");
 241:     s.append(origX);
 242:     s.append(", origY: ");
 243:     s.append(origY);
 244:     // TODO: Add more info when needed.
 245:     return s.toString();
 246:   }
 247: 
 248:   public int getX()
 249:   {
 250:     return x;
 251:   }
 252: 
 253:   public void setX(int x)
 254:   {
 255:     this.x = x;
 256:   }
 257: 
 258:   public int getY()
 259:   {
 260:     return y;
 261:   }
 262: 
 263:   public void setY(int y)
 264:   {
 265:     this.y = y;
 266:   }
 267: 
 268:   public int getScaledX()
 269:   {
 270:     return scaledX;
 271:   }
 272: 
 273:   public void setScaledX(int scaledX)
 274:   {
 275:     this.scaledX = scaledX;
 276:   }
 277: 
 278:   public int getScaledY()
 279:   {
 280:     return scaledY;
 281:   }
 282: 
 283:   public void setScaledY(int scaledY)
 284:   {
 285:     this.scaledY = scaledY;
 286:   }
 287: }