/* * public HashMap getLeafElements() { HashMap map = new HashMap(); Object[] * elts = dataElements.values().toArray(); for (int j=0; j<elts.length; j++) * { PDMDataElement data = (PDMDataElement) elts[j]; * map.put(data.getID(),data); } Object[] ops = * operations.values().toArray(); for (int i=0; i<ops.length; i++){ * PDMOperation op = (PDMOperation) ops[i]; if * (!(op.getInputElements().isEmpty())){ HashMap outs = * op.getOutputElements(); Object[] outArray = outs.values().toArray(); for * (int j=0; j<outArray.length; j++) { PDMDataElement d = (PDMDataElement) * outArray[j]; map.remove(d.getID()); } } } return map; } */ public HashMap getLeafElements() { HashMap result = new HashMap(); HashSet leafOps = getLeafOperations(); if (!(leafOps.isEmpty())) { Iterator it = leafOps.iterator(); while (it.hasNext()) { PDMOperation op = (PDMOperation) it.next(); PDMDataElement data = op.getOutputElement(); result.put(data.getID(), data); } } else { Object[] elts = dataElements.values().toArray(); for (int j = 0; j < elts.length; j++) { PDMDataElement data = (PDMDataElement) elts[j]; result.put(data.getID(), data); } Object[] ops = operations.values().toArray(); for (int i = 0; i < ops.length; i++) { PDMOperation op = (PDMOperation) ops[i]; HashMap outs = op.getOutputElements(); Object[] outArray = outs.values().toArray(); for (int j = 0; j < outArray.length; j++) { PDMDataElement d = (PDMDataElement) outArray[j]; result.remove(d.getID()); } } } return result; }
// ## operation writeChemkinSpecies(ReactionModel,SystemSnapshot) public static String writeChemkinSpecies( ReactionModel p_reactionModel, SystemSnapshot p_beginStatus) { // #[ operation writeChemkinSpecies(ReactionModel,SystemSnapshot) StringBuilder result = new StringBuilder(); result.append("SPECIES\n"); CoreEdgeReactionModel cerm = (CoreEdgeReactionModel) p_reactionModel; // write inert gas for (Iterator iter = p_beginStatus.getInertGas(); iter.hasNext(); ) { String name = (String) iter.next(); result.append('\t' + name + '\n'); } // write species for (Iterator iter = cerm.getSpecies(); iter.hasNext(); ) { Species spe = (Species) iter.next(); result.append('\t' + spe.getChemkinName() + '\n'); } result.append("END\n"); return result.toString(); // #] }
public void display(Graphics2D g, AffineTransform a_trans) { Iterator i = createIterator(); while (i.hasNext()) { GlyphObject object = (GlyphObject) i.next(); object.display(g, a_trans); } // while }
public void selectNext() { Iterator i = new SelectionIterator(this); if (m_actives.size() == 1) { boolean isFound = false; // loop the iterator in reverse order of drawing while (i.hasNext()) { GlyphObject object = (GlyphObject) i.next(); if (m_actives.isSelected(object)) { isFound = true; continue; } // if if (!isFound) { continue; } // if m_actives.unselectAll(); m_actives.addActive(object); return; } // while i } // if i = new SelectionIterator(this); if (i.hasNext()) { GlyphObject object = (GlyphObject) i.next(); m_actives.unselectAll(); m_actives.addActive(object); return; } // if }
private String unirMapeos(LinkedHashMap<String, String> mapa, Object[] descripciones) { // mapa(llave,punto) // descripciones en el mismo orden que el mapeo String comillas = "\""; StringBuilder builder = new StringBuilder(); Iterator<String> iterador = mapa.keySet().iterator(); int indice = 0; while (iterador.hasNext()) { String llave = iterador.next(); String puntaje = mapa.get(llave); String descripcion = descripciones[indice].toString().equals("null") ? "" : descripciones[indice].toString(); builder.append(comillas + descripcion + comillas + "," + comillas + puntaje + comillas + ","); indice++; } return builder.toString(); }
// ## operation writeChemkinReactions(ReactionModel) // 10/26/07 gmagoon: changed to take temperature as parameter (it doesn't seem like this method is // currently used anywhere) public static String writeChemkinReactions( ReactionModel p_reactionModel, Temperature p_temperature) { // #[ operation writeChemkinReactions(ReactionModel) StringBuilder result = new StringBuilder(); result.append("REACTIONS KCAL/MOLE\n"); CoreEdgeReactionModel cerm = (CoreEdgeReactionModel) p_reactionModel; LinkedHashSet all = cerm.getReactedReactionSet(); HashSet hs = new HashSet(); int numfor = 0; int numrev = 0; int numdup = 0; int numnorev = 0; for (Iterator iter = all.iterator(); iter.hasNext(); ) { Reaction rxn = (Reaction) iter.next(); if (rxn.isForward()) { result.append( " " + rxn.toChemkinString(p_temperature) + "\n"); // 10/26/07 gmagoon: changed to avoid use of Global.temperature // result.append(" " + rxn.toChemkinString(Global.temperature) + "\n"); } } result.append("END\n"); return result.toString(); // #] }
/** * Reload the composite nodes of the circuit, this is recursive * * @param g the graphics that will paint the node * @throws CircuitLoadingException if the internal circuit can not be loaded */ public void reloadCompositeNodes(Graphics g) throws CircuitLoadingException { for (iterNodes = this.nodes.iterator(); iterNodes.hasNext(); ) { Node n = iterNodes.next(); if (n.getCategoryID() == Node.COMPOSITE) ((CompositeNode) n).reload(g); } }
/** * Method filterResources filters the given resources using the given working set. * * @param current * @param resources * @return ICVSRemoteResource[] */ public ICVSRemoteResource[] filterResources( IWorkingSet workingSet, ICVSRemoteResource[] resources) { if (workingSet == null) return resources; // get the projects associated with the working set IAdaptable[] adaptables = workingSet.getElements(); Set projects = new HashSet(); for (int i = 0; i < adaptables.length; i++) { IAdaptable adaptable = adaptables[i]; Object adapted = adaptable.getAdapter(IResource.class); if (adapted != null) { // Can this code be generalized? IProject project = ((IResource) adapted).getProject(); projects.add(project); } } List result = new ArrayList(); for (int i = 0; i < resources.length; i++) { ICVSRemoteResource resource = resources[i]; for (Iterator iter = projects.iterator(); iter.hasNext(); ) { IProject project = (IProject) iter.next(); if (project.getName().equals(resource.getName())) { result.add(resource); break; } } } return (ICVSRemoteResource[]) result.toArray(new ICVSRemoteResource[result.size()]); }
/** A repository root has been added. Notify any listeners. */ public void rootAdded(ICVSRepositoryLocation root) { Iterator it = listeners.iterator(); while (it.hasNext()) { IRepositoryListener listener = (IRepositoryListener) it.next(); listener.repositoryAdded(root); } }
/** * Writes the model to DOT. * * @param bw The writer * @throws IOException If writing fails */ public void writeToDot(Writer bw) throws IOException { // super.writeToDot(bw); // Preamble of dot file bw.write( "digraph G {ranksep=\".3\"; fontsize=\"8\"; remincross=true; margin=\"0.0,0.0\"; rankdir=TB; "); bw.write("fontname=\"Arial\"; \n"); bw.write("edge [arrowsize=\"0.5\"];\n"); bw.write("node [fontname=\"Arial\",fontsize=\"8\"];\n"); // Add the Data Element nodes Iterator it = getVerticeList().iterator(); while (it.hasNext()) { Object object = it.next(); if (object instanceof PDMDataElement) { ((PDMDataElement) object).writeToDot(bw, this); } } // Add all edges it = operations.values().iterator(); while (it.hasNext()) { Object object = it.next(); if (object instanceof PDMOperation) { ((PDMOperation) object).writeToDot(bw, this); } } bw.write("\n}\n"); }
public PDMState checkIfStateExists( PDMStateSpace statespace, HashSet data, HashSet exec, HashSet failed) { PDMState result = null; boolean bool = false; HashSet states = statespace.getStates(); Iterator it = states.iterator(); while (it.hasNext() && !bool) { PDMState state2 = (PDMState) it.next(); boolean one = false; boolean two = false; boolean three = false; HashSet data2 = state2.dataElements; HashSet exec2 = state2.executedOperations; HashSet failed2 = state2.failedOperations; one = hashSetContainsSameDataElements(data, data2); two = hashSetContainsSameOperations(exec, exec2); three = hashSetContainsSameOperations(failed, failed2); if (one && two && three) { bool = true; result = state2; } } return result; }
private void broadcastRepositoriesChanged(ICVSRepositoryLocation[] roots) { if (roots.length == 0) return; Iterator it = listeners.iterator(); while (it.hasNext()) { IRepositoryListener listener = (IRepositoryListener) it.next(); listener.repositoriesChanged(roots); } }
private QueryResult gatherResultInfoForSelectQuery( String queryString, int queryNr, boolean sorted, Document doc, String[] rows) { Element root = doc.getRootElement(); // Get head information Element child = root.getChild("head", Namespace.getNamespace("http://www.w3.org/2005/sparql-results#")); // Get result rows (<head>) List headChildren = child.getChildren( "variable", Namespace.getNamespace("http://www.w3.org/2005/sparql-results#")); Iterator it = headChildren.iterator(); ArrayList<String> headList = new ArrayList<String>(); while (it.hasNext()) { headList.add(((Element) it.next()).getAttributeValue("name")); } List resultChildren = root.getChild("results", Namespace.getNamespace("http://www.w3.org/2005/sparql-results#")) .getChildren( "result", Namespace.getNamespace("http://www.w3.org/2005/sparql-results#")); int nrResults = resultChildren.size(); QueryResult queryResult = new QueryResult(queryNr, queryString, nrResults, sorted, headList); it = resultChildren.iterator(); while (it.hasNext()) { Element resultElement = (Element) it.next(); String result = ""; // get the row values and paste it together to one String for (int i = 0; i < rows.length; i++) { List bindings = resultElement.getChildren( "binding", Namespace.getNamespace("http://www.w3.org/2005/sparql-results#")); String rowName = rows[i]; for (int j = 0; j < bindings.size(); j++) { Element binding = (Element) bindings.get(j); if (binding.getAttributeValue("name").equals(rowName)) if (result.equals("")) result += rowName + ": " + ((Element) binding.getChildren().get(0)).getTextNormalize(); else result += "\n" + rowName + ": " + ((Element) binding.getChildren().get(0)).getTextNormalize(); } } queryResult.addResult(result); } return queryResult; }
private void addDefaultValues(Map attributes, Map mappings) { if (mappings == null) return; Iterator i = mappings.entrySet().iterator(); while (i.hasNext()) { Map.Entry e = (Map.Entry) i.next(); TagMap.AttributeMapping m = (TagMap.AttributeMapping) e.getValue(); if (null != m && null != m.getDefaultValue() && null == attributes.get(m.getPropertyName())) attributes.put(m.getPropertyName(), m.getDefaultValue()); } }
public EdgeLayout getEdgeLayouts(String spid, String sid, String tpid, String tid) { Iterator<EdgeLayout> ee = edges.iterator(); EdgeLayout el; while (ee.hasNext()) { el = ee.next(); if (el.sourceNode.equals(sid) && el.targetNode.equals(tid)) { return el; } } return null; } // */
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { try { DateFormat df = DateFormat.getDateTimeInstance(); String titleStr = "C3P0 Status - " + df.format(new Date()); DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance(); DocumentBuilder db = fact.newDocumentBuilder(); Document doc = db.newDocument(); Element htmlElem = doc.createElement("html"); Element headElem = doc.createElement("head"); Element titleElem = doc.createElement("title"); titleElem.appendChild(doc.createTextNode(titleStr)); Element bodyElem = doc.createElement("body"); Element h1Elem = doc.createElement("h1"); h1Elem.appendChild(doc.createTextNode(titleStr)); Element h3Elem = doc.createElement("h3"); h3Elem.appendChild(doc.createTextNode("PooledDataSources")); Element pdsDlElem = doc.createElement("dl"); pdsDlElem.setAttribute("class", "PooledDataSources"); for (Iterator ii = C3P0Registry.getPooledDataSources().iterator(); ii.hasNext(); ) { PooledDataSource pds = (PooledDataSource) ii.next(); StatusReporter sr = findStatusReporter(pds, doc); pdsDlElem.appendChild(sr.reportDtElem()); pdsDlElem.appendChild(sr.reportDdElem()); } headElem.appendChild(titleElem); htmlElem.appendChild(headElem); bodyElem.appendChild(h1Elem); bodyElem.appendChild(h3Elem); bodyElem.appendChild(pdsDlElem); htmlElem.appendChild(bodyElem); res.setContentType("application/xhtml+xml"); TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); Source src = new DOMSource(doc); Result result = new StreamResult(res.getOutputStream()); transformer.transform(src, result); } catch (IOException e) { throw e; } catch (Exception e) { throw new ServletException(e); } }
/** * Get the outputable nodes of the circuit * * @return an hashset of the outputable nodes of the circuit */ public HashSet<Outputable> getOutputables() { HashSet<Outputable> outputs = new HashSet<Outputable>(); for (iterNodes = getNodesIterator(); iterNodes.hasNext(); ) { Node n = iterNodes.next(); if (n.getCategoryID() == Node.OUTPUT) outputs.add((Outputable) n); } return outputs; }
/** * Get the inputable nodes of the circuit * * @return an hashset of the inputable nodes of the circuit */ public HashSet<Inputable> getInputables() { HashSet<Inputable> inputs = new HashSet<Inputable>(); for (iterNodes = getNodesIterator(); iterNodes.hasNext(); ) { Node n = iterNodes.next(); if (n.getCategoryID() == Node.INPUT) inputs.add((Inputable) n); } return inputs; }
private void writeState(XMLWriter writer) { writer.startTag(RepositoriesViewContentHandler.REPOSITORIES_VIEW_TAG, null, true); // Write the repositories Collection repos = Arrays.asList(getKnownRepositoryLocations()); Iterator it = repos.iterator(); while (it.hasNext()) { CVSRepositoryLocation location = (CVSRepositoryLocation) it.next(); RepositoryRoot root = getRepositoryRootFor(location); root.writeState(writer); } writer.endTag(RepositoriesViewContentHandler.REPOSITORIES_VIEW_TAG); }
public String toString() { StringBuffer sb = new StringBuffer(); sb.append(sourcepid + "," + sourceNode + "," + targetpid + "," + targetNode + ","); Iterator<LayoutPoint> e = bends.iterator(); LayoutPoint b; while (e.hasNext()) { b = (LayoutPoint) e.next(); sb.append(b.x + "," + b.y + ","); } sb.append("\n"); return sb.toString(); }
/** * Convert dom4j attributes to SAX attributes. * * @param element dom4j Element * @return SAX Attributes */ public static Attributes getSAXAttributes(Element element) { final AttributesImpl result = new AttributesImpl(); for (Iterator i = element.attributeIterator(); i.hasNext(); ) { final org.dom4j.Attribute attribute = (org.dom4j.Attribute) i.next(); result.addAttribute( attribute.getNamespaceURI(), attribute.getName(), attribute.getQualifiedName(), ContentHandlerHelper.CDATA, attribute.getValue()); } return result; }
public String toBeautifiedString() { StringBuffer sb = new StringBuffer(); sb.append("sourcePID: " + sourcepid); sb.append(" sourceNodeId: " + sourceNode + "\n"); sb.append(" targetPID: " + targetpid); sb.append(" targetNodeId: " + targetNode + "\n"); Iterator<LayoutPoint> e = bends.iterator(); LayoutPoint b; while (e.hasNext()) { b = (LayoutPoint) e.next(); sb.append(" Bend Points: " + b.x + "," + b.y + " "); } sb.append("\n\n"); return sb.toString(); }
private void checkForRequiredAttributes(String tagName, Map attributes, Map mappings) throws ParserException { if (mappings == null) return; Iterator i = mappings.entrySet().iterator(); while (i.hasNext()) { Map.Entry e = (Map.Entry) i.next(); TagMap.AttributeMapping m = (TagMap.AttributeMapping) e.getValue(); if (null != m && m.getRequired()) if (null == mappings || null == attributes.get(m.getPropertyName())) throw new ParserException( "An attribute that maps to property name: " + m.getPropertyName() + " is required and was not specified for tag:" + tagName + "!"); } }
/** * converts this glyph into Shape. It could be called for root's preview mode or by include * invoke. Pushing either this GlyphFile or DIncludeInvoke should be handled before this. */ public Shape toShape(AffineTransform a_trans) { int ppem = k_defaultPixelSize; GeneralPath retval = new GeneralPath(); Iterator i = createIterator(); while (i.hasNext()) { GlyphObject object = (GlyphObject) i.next(); if (object instanceof EContourPoint || object instanceof EHint) { continue; } // if retval.append(object.toShape(a_trans, ppem), false); } // if return retval; }
private void nameLengthStatistics() { Iterator i = Person.iterator(); Person p; int l = Person.getMaxNameLength(); int lengthTable[] = new int[l + 1]; int j; System.out.println(); // System.out.println("Name length: Number of persons"); while (i.hasNext()) { p = (Person) i.next(); lengthTable[p.getName().length()]++; } for (j = 1; j <= l; j++) { System.out.print(j + ": " + lengthTable[j] + " "); if (j % 5 == 0) System.out.println(); } System.out.println(); }
private static final Skeleton parseSkeleton(Node skel_node) { Map name_to_bone_map = new HashMap(); Map initial_pose = AnimationLoader.parseFrame(ConvertToBinary.getNodeByName("init_pose", skel_node)); NodeList bone_list = ConvertToBinary.getNodeByName("bones", skel_node).getChildNodes(); Map bone_parent_map = new HashMap(); for (int i = 0; i < bone_list.getLength(); i++) { Node bone_node = bone_list.item(i); if (bone_node.getNodeName().equals("bone")) { String bone_name = bone_node.getAttributes().getNamedItem("name").getNodeValue(); String bone_parent_name = bone_node.getAttributes().getNamedItem("parent").getNodeValue(); // System.out.println("bone name = " + bone_name + " parent name = " + bone_parent_name); bone_parent_map.put(bone_name, bone_parent_name); } } Map bone_children_map = new HashMap(); Iterator it = bone_parent_map.keySet().iterator(); String root = null; while (it.hasNext()) { String name = (String) it.next(); String parent = (String) bone_parent_map.get(name); if (bone_parent_map.get(parent) == null) { if (root != null) { System.out.println( "WARNING: Multiple roots in skeleton, root = " + root + ", additional root = " + name); parent = root; bone_parent_map.put(name, parent); } else root = name; } List parent_children = (List) bone_children_map.get(parent); if (parent_children == null) { parent_children = new ArrayList(); bone_children_map.put(parent, parent_children); } parent_children.add(name); } Bone bone_root = buildBone((byte) 0, bone_children_map, root, name_to_bone_map); return new Skeleton(bone_root, initial_pose, name_to_bone_map); }
/** * Save the XML description of the circuit * * @param output an output stream to write in * @return true if the dump was successful, false either */ public boolean dumpToXml(OutputStream output) { Document doc; Element root; DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder; try { builder = factory.newDocumentBuilder(); doc = builder.newDocument(); } catch (ParserConfigurationException pce) { System.err.println("dumpToXmlFile: unable to write XML save file."); return false; } root = doc.createElement("Circuit"); root.setAttribute("name", this.getName()); for (iterNodes = this.nodes.iterator(); iterNodes.hasNext(); ) iterNodes.next().dumpToXml(doc, root); root.normalize(); doc.appendChild(root); try { TransformerFactory tffactory = TransformerFactory.newInstance(); Transformer transformer = tffactory.newTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); DOMSource source = new DOMSource(doc); StreamResult result = new StreamResult(output); transformer.transform(source, result); } catch (TransformerConfigurationException tce) { System.err.println("dumpToXmlFile: Configuration Transformer exception."); return false; } catch (TransformerException te) { System.err.println("dumpToXmlFile: Transformer exception."); return false; } return true; }
// convert coordinates to relative coordinates with the top-left one as (0,0) public void convertToRelativePositions() { LayoutBox box = getExactLayoutBox(); // System.out.println("Box // ("+box.topleft.x+","+box.topleft.y+");("+(box.topleft.x+box.width)+","+(box.topleft.y+box.height)); Iterator<NodeLayout> e = nodes.iterator(); NodeLayout nl; while (e.hasNext()) { nl = e.next(); /* Debug code if(nl.x<box.topleft.x || nl.y<box.topleft.y || nl.x>(box.topleft.x+box.width) || nl.y>(box.topleft.y+box.height)){ System.out.println("Invalid node "+nl.x+","+nl.y); } //*/ nl.x = nl.x - box.topleft.x; nl.y = nl.y - box.topleft.y; } Iterator<EdgeLayout> e2 = edges.iterator(); EdgeLayout el; while (e2.hasNext()) { el = e2.next(); for (LayoutPoint lp : el.bends) { lp.x = lp.x - box.topleft.x; lp.y = lp.y - box.topleft.y; } } }
public void flipLayoutLeftRight() { LayoutBox box = getExactLayoutBox(); Iterator<NodeLayout> ne = nodes.iterator(); while (ne.hasNext()) { NodeLayout nl = ne.next(); if (nl.processID.equals("null")) { nl.x = box.topleft.x + (box.width - (nl.x - box.topleft.x)) - 60; // minus 60 which is the width of process node's box, since using upperleft // coor } else if (isSecondary(nl)) { nl.x = box.topleft.x + (box.width - (nl.x - box.topleft.x)) - 60; } else { nl.x = box.topleft.x + (box.width - (nl.x - box.topleft.x)) - 20; } } Iterator<EdgeLayout> e2 = edges.iterator(); EdgeLayout el; while (e2.hasNext()) { el = e2.next(); for (LayoutPoint lp : el.bends) { lp.x = box.topleft.x + (box.width - (lp.x - box.topleft.x)); } } }
private void publicationCountStatistics() { Iterator i = Person.iterator(); Person p; int l = Person.getMaxPublCount(); int countTable[] = new int[l + 1]; int j, n; System.out.println(); System.out.println("Number of publications: Number of persons"); while (i.hasNext()) { p = (Person) i.next(); countTable[p.getCount()]++; } n = 0; for (j = 1; j <= l; j++) { if (countTable[j] == 0) continue; n++; System.out.print(j + ": " + countTable[j] + " "); if (n % 5 == 0) System.out.println(); } System.out.println(); }