/** * DOCUMENT ME! */ public void resetSelectionFlags() { if (this.objectType != NETWORK) { for (GraphObject gObj : graphObjects) { internalSelection.put(gObj.getIdentifier(), DEFAULT_FLAG); } } }
private void equationAction(final Equation input) { old_values = new ArrayList(objects.size()); new_values = new ArrayList(objects.size()); for (final Object o : objects) { final GraphObject go = (GraphObject)o; // Get the current value and set the old_value to it final Equation oldEquation = attrData.getEquation(go.getIdentifier(), attributeTo); if (oldEquation != null) old_values.add(oldEquation); else old_values.add(attrData.getAttribute(go.getIdentifier(), attributeTo)); attrData.setAttribute(go.getIdentifier(), attributeTo, input); new_values.add(input); } // iterator } // equationAction }
private void booleanAction(final Boolean input) { if ((action == DIV) || (action == MUL) || (action == ADD)) return; old_values = new ArrayList(objects.size()); new_values = new ArrayList(objects.size()); for (final Object o : objects) { GraphObject go = (GraphObject)o; // Get the current value and set the old_value to it final Equation oldEquation = attrData.getEquation(go.getIdentifier(), attributeTo); if (oldEquation != null) old_values.add(oldEquation); else old_values.add(attrData.getAttribute(go.getIdentifier(), attributeTo)); setAttributeValue(go.getIdentifier(), attributeTo, input); new_values.add(input); } // iterator } // booleanAction
protected Object getRangeValue(GraphObject obj) { if (obj == null) return null; final String nodeID = obj.getIdentifier(); final Map<String, Object> attrBundle = getAttrBundle(nodeID); attrBundle.put(AbstractCalculator.ID, obj.getIdentifier()); return getMapping(0).calculateRangeValue(attrBundle); }
private void mapAttributes(final GraphObject obj, final CyAttributes attrs, final Map<String, Object> attrMap) { for (String attrName : attrMap.keySet()) { final Object attrVal = attrMap.get(attrName); if (attrVal == null) continue; try { if (attrVal instanceof Double) { attrs.setAttribute(obj.getIdentifier(), attrName, (Double) attrVal); } else if (attrVal instanceof Integer) { attrs.setAttribute(obj.getIdentifier(), attrName, (Integer) attrVal); } else { attrs.setAttribute(obj.getIdentifier(), attrName, attrVal.toString()); } } catch (IllegalArgumentException e) { continue; } } }
/** * DOCUMENT ME! */ public void undo() { for (int i = 0; i < objects.size(); ++i) { GraphObject go = (GraphObject) objects.get(i); if (old_values.get(i) == null) { attrData.getMultiHashMap().removeAllAttributeValues(go.getIdentifier(), attributeTo); } else { setAttributeValue(go.getIdentifier(), attributeTo, old_values.get(i)); } } table.setTableData(); }
private void listAction() { if ((action == DIV) || (action == MUL)) return; old_values = new ArrayList(objects.size()); new_values = new ArrayList(objects.size()); for (final Object obj : objects) { final GraphObject go = (GraphObject)obj; // get the current value and set the old_value to it final String s = (String)attrData.getAttribute(go.getIdentifier(), attributeTo); old_values.add(s); final String new_v; if (action == SET) new_v = input; else if(action == ActionName.ADD_PREFIX) { new_v = s+input; } else if(action == ActionName.ADD_SUFFIX) { new_v = input+s; } else if(action == ActionName.REMOVE) { new_v = s.replaceAll(input, ""); } else if(action == ActionName.REPLACE) { new_v = s.replaceAll(input, ""); } else new_v = s.concat(input); new_values.add(new_v); setAttributeValue(go.getIdentifier(), attributeTo, new_v); } // iterator }
/** * Use the global edit variables to delete the values from the given * attribute. the deleted values will be stored in "old_values" */ private void deleteAtt() { new_values = new ArrayList(objects.size()); old_values = new ArrayList(objects.size()); // Check data compatibility for (final Object o : objects) { final GraphObject go = (GraphObject)o; final Object attr; final Equation equation = attrData.getEquation(go.getIdentifier(), attributeTo); if (equation != null) attr = equation; else attr = attrData.getAttribute(go.getIdentifier(), attributeTo); if (attr != null) { old_values.add(attr); attrData.getMultiHashMap().removeAllAttributeValues(go.getIdentifier(), attributeTo); new_values.add(null); } } }
/** * DOCUMENT ME! */ public void redo() { final int size = objects.size(); GraphObject go; for (int i = 0; i < size; ++i) { go = (GraphObject) objects.get(i); if (new_values.get(i) == null) { attrData.getMultiHashMap().removeAllAttributeValues(go.getIdentifier(), attributeTo); } else { setAttributeValue(go.getIdentifier(), attributeTo, new_values.get(i)); } } table.setTableData(); }
/** * Helper method for updateCell(). */ void setDataTableRow(final int rowIdx, final int skipIdx) { final Vector rowVector = (Vector) dataVector.elementAt(rowIdx); final int noOfColumns = attributeNames.contains(AttributeBrowser.ID) ? attributeNames.size() : attributeNames.size() + 1; final String id = graphObjects.get(rowIdx).getIdentifier(); for (int colIdx = 0; colIdx < noOfColumns; ++colIdx) { if (colIdx == skipIdx) continue; final String attribName = (String)columnIdentifiers.get(colIdx); if (attribName.equals(AttributeBrowser.ID)) continue; final byte type = data.getType(attribName); final ValidatedObjectAndEditString objectAndEditString = getValidatedObjectAndEditString(type, id, attribName); if (objectAndEditString != null) { final int actualColIdx = findColumn(attribName); rowVector.setElementAt(objectAndEditString, actualColIdx); } } }
final String s = (String) attrData.getAttribute(go.getIdentifier(), attributeTo); old_values.add(s); final Equation oldEquation = attrData.getEquation(go.getIdentifier(), attributeTo); if (oldEquation != null) old_values.add(oldEquation); else old_values.add(attrData.getAttribute(go.getIdentifier(), attributeTo)); setAttributeValue(go.getIdentifier(), attributeTo, input); new_values.add(input); } else { setAttributeValue(go.getIdentifier(), attributeTo, new_v);
/** * Output a tab-delimited table of attributes * * @param outputFile the file to output our attributes to * @param attrs the attributes we're going to use * @param objects the list of CyNodes or CyEdges to output * @param attrList the list of attributes we want to output * @param delim the delimiter to use */ public static int exportAttributes(File outputFile, CyAttributes attrs, List<GraphObject> objects, List<String>attrList, String delim) throws IOException { int lineCount = 0; // Create our output file BufferedWriter output = new BufferedWriter(new FileWriter(outputFile)); // Write out a header for (String attr: attrList) { if (attrs.getUserVisible(attr)) output.write(attr+delim); } output.newLine(); // For each object for (GraphObject obj: objects) { // Output a row exportRow(output, obj.getIdentifier(), attrs, attrList, delim); lineCount++; } output.close(); return lineCount; }
GraphObject graphObject = (GraphObject) iterator.next(); String[] values = CyAttributesUtil.getAttributeValues(attributes, graphObject.getIdentifier(), attributeKey);
final Equation oldEquation = attrData.getEquation(go.getIdentifier(), attributeTo); if (oldEquation != null) old_values.add(oldEquation); else old_values.add(attrData.getAttribute(go.getIdentifier(), attributeTo)); setAttributeValue(go.getIdentifier(), attributeTo, input); new_values.add(input); } else { final Double d = (Double) attrData.getAttribute(go.getIdentifier(), attributeTo); old_values.add(d); setAttributeValue(go.getIdentifier(), attributeTo, new Double(new_v));
public Iterable<String> getAssociatedIdentifiers() { final Set<String> ids = new HashSet<String>(); if (this == NODES) { final List<GraphObject> nodes = (List<GraphObject>)Cytoscape.getCyNodesList(); for (final GraphObject node : nodes) ids.add(node.getIdentifier()); return ids; } else if (this == EDGES) { final List<GraphObject> edges = (List<GraphObject>)Cytoscape.getCyEdgesList(); for (final GraphObject edge : edges) ids.add(edge.getIdentifier()); return ids; } else if (this == NETWORK) { final Set<CyNetwork> networks = Cytoscape.getNetworkSet(); for (final CyNetwork network : networks) ids.add(network.getIdentifier()); return ids; } return null; } }
final Equation oldEquation = attrData.getEquation(go.getIdentifier(), attributeTo); if (oldEquation != null) old_values.add(oldEquation); else old_values.add(attrData.getAttribute(go.getIdentifier(), attributeTo)); setAttributeValue(go.getIdentifier(), attributeTo, input); new_values.add(input); } else { final Integer i = (Integer)attrData.getAttribute(go.getIdentifier(), attributeTo); old_values.add(i); setAttributeValue(go.getIdentifier(), attributeTo, new Integer(new_v));
String id = new String(itNode.next().getIdentifier());
final GraphObject go = (GraphObject)o; final Equation equation = attrData.getEquation(go.getIdentifier(), attributeFrom); if (equation != null) { attrData.setAttribute(go.getIdentifier(), attributeTo, equation); new_values.add(equation); old_values.add(null); Object value = attrData.getAttribute(go.getIdentifier(), attributeFrom); new_values.add(value); value = new Double((Integer)value); setAttributeValue(go.getIdentifier(), attributeTo, value); old_values.add(null);
/** * Applies the visual bypass values specified in the node (edge) attributes * for the specified node (edge) to the node (edge). * * @param n The {@link Node} or {@link Edge} object that the visual bypass * should be applied to. */ public void applyBypass(final GraphObject n, List<VisualPropertyType> bypassedVPs) { if (n == null) return; if ( bypassedVPs == null || bypassedVPs.size() <= 0 ) return; final String id = n.getIdentifier(); CyAttributes attrs = null; if (n instanceof Node) attrs = Cytoscape.getNodeAttributes(); else if (n instanceof Edge) attrs = Cytoscape.getEdgeAttributes(); else return; for (VisualPropertyType type : bypassedVPs) { Object bypass = getBypass(attrs, id, type); if (bypass != null) vizProps.put(type,bypass); } }
String name = ((GraphObject) object).getIdentifier();