KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > Map > ConnectedPointImpl


1 package Map;
2 /**
3  * <p>
4  * <ul>
5  * <li> <b>Java Class</b> ConnectedPointImpl
6  * <li> <b>Source File</b> ConnectedPointImpl.java
7  * <li> <b>IDL Source File</b> cpoint.idl
8  * <li> <b>IDL Absolute Name</b> ::ConnectedPoint
9  * <li> <b>Repository Identifier</b> IDL:ConnectedPoint:1.0
10  * </ul>
11  * <b>IDL definition:</b>
12  * <pre>
13  * valuetype ConnectedPoint : truncatable ::Point {
14  * ...
15  * };
16  * </pre>
17  * </p>
18  */

19 public class ConnectedPointImpl
20     extends ConnectedPoint
21 {
22     public ConnectedPointImpl() {}
23
24     public ConnectedPointImpl(int a_x, int a_y, String JavaDoc a_label, Point[] a_connected_points) {
25         x = a_x;
26         y = a_y;
27         label = a_label;
28         connected_points = a_connected_points;
29     }
30  
31     /**
32      * <p>
33      * Operation: <b>::Point::print</b>.
34      * <pre>
35      * void print ();
36      * </pre>
37      * </p>
38      */

39     public void print () {
40         System.out.println("Derived Point is [" + label + ": (" + x + ", " + y + ")]");
41         if (connected_points.length > 0) {
42             System.out.println("Connected to:");
43             for (int i = 0; i < connected_points.length; i++) {
44                 System.out.print("\t");
45                 connected_points[i].print();
46             }
47         }
48     }
49
50     /**
51      * <p>
52      * Operation: <b>::ConnectedPoint::add_connection</b>.
53      * <pre>
54      * void add_connection (in ::Point p);
55      * </pre>
56      * </p>
57      */

58     public void add_connection (
59                                 Point p
60                                 ) {
61         Point[] connected = new Point[connected_points.length + 1];
62         if (connected_points.length > 0) {
63             System.arraycopy(connected_points, 0, connected, 0, connected_points.length);
64         }
65
66         connected[connected_points.length] = p;
67         connected_points = connected;
68     }
69
70 }
71
Popular Tags