View Javadoc

1   package org.textensor.vis;
2   
3   import java.awt.Color;
4   
5   
6   public final class IcingPoint {
7   
8   
9       public String id;
10  
11      IcingPoint parent;
12  
13      double x;
14      double y;
15      double z;
16      double r;
17  
18      double px;
19      double py;
20      double pz;
21      double pr;
22  
23      boolean minor;
24  
25      public boolean ball;
26  
27      String partof = null;
28      String label = "";
29  
30  
31      Color color;
32  
33      boolean colored3d = false;
34  
35      public static final int AUTO = 0;
36      public static final int TAPERED = 1;
37      public static final int UNIFORM = 2;
38      public int connectionStyle;
39  
40      /*
41      	public IcingPoint(TreePoint tp) {
42      		treePoint = tp;
43      		Ball b = tp.getBall();
44      		x = b.getX();
45      		y = b.getY();
46      		z = b.getZ();
47      		r = b.getRadius();
48      		minor = tp.minor;
49      		pickable = new PickablePoint(x, y, this);
50      		label = tp.getFirstLabel();
51      		partof = tp.getPartOf();
52      		color = Color.gray;
53      		ball = true;
54      	}
55      */
56  
57      public IcingPoint(double ax, double ay, double az, double ar) {
58          x = ax;
59          y = ay;
60          z = az;
61          r = ar;
62          minor = false;
63          color = Color.gray;
64          ball = true;
65      }
66  
67      public IcingPoint(double ax, double ay, double az, double ar, IcingPoint p) {
68          this(ax, ay, az, ar);
69          parent = p;
70      }
71  
72      public void checkDeBall() {
73          if (parent != null) {
74              double dx = px - x;
75              double dy = py - y;
76              double dz = pz - z;
77              double d = Math.sqrt(dx*dx + dy*dy + dz*dz);
78              if (d < r || (pr < r && pr * d <  r * r)) { // ADHOC
79                  ball = false;
80              }
81              if (d < pr || (!minor && r < pr && r * d < pr * pr)) {
82                  parent.ball = false;
83              }
84          }
85      }
86  
87  
88      public boolean isBall() {
89          return ball;
90      }
91  
92  
93      public String getID() {
94          return id;
95      }
96  
97      public void setLabel(String s) {
98          label = s;
99      }
100 
101     public String toString() {
102         return label + " " + String.format("(%d,%d,%d)", nr(x), nr(y), nr(z));
103     }
104 
105     private int nr(double d) {
106         return (int)(Math.round(d));
107     }
108 
109 
110 
111     public String getLabel() {
112         return label;
113     }
114 
115     public double getX() {
116         return x;
117     }
118 
119     public double getY() {
120         return y;
121     }
122 
123     public double getZ() {
124         return z;
125     }
126 
127     public double getR() {
128         return r;
129     }
130 
131     public IcingPoint getParent() {
132         return parent;
133     }
134 
135 
136     public void setParent(IcingPoint p) {
137         parent = p;
138         px = p.x;
139         py = p.y;
140         pz = p.z;
141 
142         if (minor) {
143             pr = r;
144         } else {
145             pr = p.r;
146         }
147 
148     }
149 
150 
151     public boolean isMinor() {
152         return minor;
153     }
154 
155 
156     public void setColored3d(boolean b) {
157         colored3d = b;
158     }
159 
160     public boolean isColored3d() {
161         return colored3d;
162     }
163 
164 
165     public Color getColor() {
166         return color;
167     }
168 
169     public boolean taper() {
170         return (connectionStyle == TAPERED);
171     }
172 
173     public boolean uniform() {
174         return (connectionStyle == UNIFORM);
175     }
176 
177     public boolean auto() {
178         return (connectionStyle == AUTO);
179     }
180 
181 }