1 31 32 package org.antlr.works.visualization.graphics.primitive; 33 34 import org.antlr.works.visualization.graphics.GContext; 35 36 public class GPoint { 37 38 public String x = ""; 39 public String y = ""; 40 41 private float cacheX = Float.MIN_VALUE; 42 private float cacheY = Float.MIN_VALUE; 43 44 public GPoint() { 45 46 } 47 48 public GPoint(GPoint point) { 49 this.x = point.x; 50 this.y = point.y; 51 } 52 53 public void addX(String x) { 54 this.x = GLiteral.add(this.x, x); 55 } 56 57 public void addY(String y) { 58 this.y = GLiteral.add(this.y, y); 59 } 60 61 public void subY(String y) { 62 this.y = GLiteral.substract(this.y, y); 63 } 64 65 public float getX(GContext context) { 66 if(cacheX == Float.MIN_VALUE) 67 return context.getPixelValue(x); 68 else 69 return cacheX; 70 } 71 72 public float getY(GContext context) { 73 if(cacheY == Float.MIN_VALUE) 74 return context.getPixelValue(y); 75 else 76 return cacheY; 77 } 78 79 public void cache(GContext context, float ox, float oy) { 80 cacheX = context.getPixelValue(x)+ox; 81 cacheY = context.getPixelValue(y)+oy; 82 } 83 } 84 | Popular Tags |