/** Wrap a tuple in a GaggleTuple and broadcast it */ public void broadcastTuple(Tuple tuple) { GaggleTuple gaggleTuple = new GaggleTuple(); gaggleTuple.setName(tuple.getName()); Tuple metadata = new Tuple(); gaggleTuple.setMetadata(metadata); gaggleTuple.setData(tuple); broadcastGaggleTuple(gaggleTuple); }
/** * Broadcasts a Cytoscape movie style tuple which assigns the value of a single attribute to the * nodes listed in allNames. [is this correct? -jcb] * * @param title * @param attributeName * @param allNames * @param allValues */ public void createAndBroadcastGaggleTuple( String title, String attributeName, String[] allNames, String[] allValues) { Class valueClass = getValueType(allValues); GaggleTuple gaggleTuple = new GaggleTuple(); gaggleTuple.setName(title); Tuple metadata = new Tuple(); metadata.addSingle(new Single(title)); gaggleTuple.setMetadata(metadata); Tuple dataTuple = new Tuple(); dataTuple.setName(title); gaggleTuple.setSpecies(defaultSpecies); for (int i = 0; i < allNames.length; i++) { Serializable value; if (valueClass.equals(Integer.class)) { value = Integer.valueOf(allValues[i]); } else if (valueClass.equals(Double.class)) { value = Double.valueOf(allValues[i]); } else { // string String s = allValues[i]; if (s.startsWith("|") && s.endsWith("|")) { value = s.substring(1, s.length() - 1); } else { value = allValues[i]; } } Tuple row = new Tuple(); row.addSingle(new Single(allNames[i])); row.addSingle(new Single(attributeName)); row.addSingle(new Single(value)); dataTuple.addSingle(new Single(row)); } gaggleTuple.setData(dataTuple); broadcastGaggleTuple(gaggleTuple); }