package uk.ac.vamsas.client.picking; /** * Message class that can be used to send mouse over events. */ public class MouseOverMessage extends Message { private String vorbaID; private int position; /** * Constructs a new mouse over message. * @param vorbaID the VAMSAS object ID of the event's source (usually an * alignment or alignment sequence) * @param position a position on the source in its coordinate system (ie a * column or nucleotide/residue position) */ public MouseOverMessage(String vorbaID, int position) { this.vorbaID = vorbaID; this.position = position; message = "MOUSEOVER\t" + "vorbaID=" + vorbaID + "\t" + "position=" + position; } /** * Constructs a new mouse over message from its underlying string format. * @param str the string representation of an instance of this object * @throws java.lang.Exception if the message cannot be reconstructed */ MouseOverMessage(String str) throws Exception { message = str; String[] elements = str.split("\t"); for (int i = 0; i < elements.length; i++) { if (elements[i].startsWith("vorbaID=")) vorbaID = elements[i].substring(8); else if (elements[i].startsWith("position=")) position = Integer.parseInt(elements[i].substring(9)); } } /** * Returns the VAMSAS object ID associated with this message. * @return the VAMSAS object ID associated with this message */ public String getVorbaID() { return vorbaID; } /** * Returns the position value associated with this message. * @return the position value associated with this message */ public int getPosition() { return position; } }