2cb85316b329de0d9530d6bbfade93ab0842642e
[vamsas.git] / src / uk / ac / vamsas / client / picking / MouseOverMessage.java
1 package uk.ac.vamsas.client.picking;\r
2 \r
3 /**\r
4  * Message class that can be used to send mouse over events.\r
5  */\r
6 public class MouseOverMessage extends Message\r
7 {\r
8         private String vorbaID;\r
9         private int position;\r
10         \r
11         /**\r
12          * Constructs a new mouse over message.\r
13          * @param vorbaID the VAMSAS object ID of the event's source (usually an\r
14          * alignment or alignment sequence)\r
15          * @param position a position on the source in its coordinate system (ie a\r
16          * column or nucleotide/residue position)\r
17          */\r
18         public MouseOverMessage(String vorbaID, int position)\r
19         {\r
20                 this.vorbaID = vorbaID;\r
21                 this.position = position;\r
22                 \r
23                 message = "MOUSEOVER\t"\r
24                         + "vorbaID=" + vorbaID + "\t" + "position=" + position;\r
25         }\r
26         \r
27         /**\r
28          * Constructs a new mouse over message from its underlying string format.\r
29          * @param str the string representation of an instance of this object\r
30          * @throws java.lang.Exception if the message cannot be reconstructed\r
31          */\r
32         MouseOverMessage(String str)\r
33                 throws Exception\r
34         {\r
35                 message = str;\r
36                 \r
37                 String[] elements = str.split("\t");\r
38                 \r
39                 for (int i = 0; i < elements.length; i++)\r
40                 {\r
41                         if (elements[i].startsWith("vorbaID="))\r
42                                 vorbaID = elements[i].substring(8);\r
43                         else if (elements[i].startsWith("position="))\r
44                                 position = Integer.parseInt(elements[i].substring(9));\r
45                 }\r
46         }\r
47         \r
48         /**\r
49          * Returns the VAMSAS object ID associated with this message.\r
50          * @return the VAMSAS object ID associated with this message\r
51          */\r
52         public String getVorbaID()\r
53                 { return vorbaID; }\r
54         \r
55         /**\r
56          * Returns the position value associated with this message.\r
57          * @return the position value associated with this message\r
58          */\r
59         public int getPosition()\r
60                 { return position; }\r
61 }