bugged
stringlengths
6
599k
fixed
stringlengths
6
40.8M
__index_level_0__
int64
0
3.24M
public void startThread () { this.compilationThread = new Thread (this, "compilation thread"); //will call this.run() this.compilationThread.start(); }
public void startThread() { this.compilationThread = new Thread (this, "compilation thread"); //will call this.run() this.compilationThread.start(); }
3,241,210
public void startThread () { this.compilationThread = new Thread (this, "compilation thread"); //will call this.run() this.compilationThread.start(); }
public void startThread () { this.compilationThread = new Thread(this, "compilation thread"); //will call this.run() this.compilationThread.start(); }
3,241,211
public HTMLInfoPanel(InstallerFrame parent, InstallData idata) { super(parent, idata); // We initialize our layout layout = new GridBagLayout(); gbConstraints = new GridBagConstraints(); setLayout(layout); // We add the components infoLabel = new JLabel(parent.langpack.getString("InfoPanel.info"), parent.icons.getImageIcon("edit"), JLabel.TRAILING); parent.buildConstraints(gbConstraints, 0, 0, 1, 1, 1.0, 0.0); gbConstraints.insets = new Insets(5, 5, 5, 5); gbConstraints.fill = GridBagConstraints.NONE; gbConstraints.anchor = GridBagConstraints.SOUTHWEST; layout.addLayoutComponent(infoLabel, gbConstraints); add(infoLabel); try { textArea = new JEditorPane(); textArea.setEditable(false); textArea.addHyperlinkListener(this); JScrollPane scroller = new JScrollPane(textArea); textArea.setPage(loadInfo()); parent.buildConstraints(gbConstraints, 0, 1, 1, 1, 1.0, 1.0); gbConstraints.anchor = GridBagConstraints.CENTER; gbConstraints.fill = GridBagConstraints.BOTH; layout.addLayoutComponent(scroller, gbConstraints); add(scroller); } catch (Exception err) { err.printStackTrace(); } }
public HTMLInfoPanel(InstallerFrame parent, InstallData idata) { super(parent, idata); // We initialize our layout layout = new GridBagLayout(); gbConstraints = new GridBagConstraints(); setLayout(layout); // We add the components infoLabel = new JLabel(parent.langpack.getString("InfoPanel.info"), parent.icons.getImageIcon("edit"), JLabel.TRAILING); parent.buildConstraints(gbConstraints, 0, 0, 1, 1, 1.0, 0.0); gbConstraints.insets = new Insets(5, 5, 5, 5); gbConstraints.fill = GridBagConstraints.NONE; gbConstraints.anchor = GridBagConstraints.SOUTHWEST; layout.addLayoutComponent(infoLabel, gbConstraints); add(infoLabel); try { textArea = new JEditorPane(); textArea.setEditable(false); textArea.addHyperlinkListener(this); JScrollPane scroller = new JScrollPane(textArea); textArea.setPage(loadInfo()); parent.buildConstraints(gbConstraints, 0, 1, 1, 1, 1.0, 1.0); gbConstraints.anchor = GridBagConstraints.CENTER; gbConstraints.fill = GridBagConstraints.BOTH; layout.addLayoutComponent(scroller, gbConstraints); add(scroller); } catch (Exception err) { err.printStackTrace(); } }
3,241,212
public HTMLInfoPanel(InstallerFrame parent, InstallData idata) { super(parent, idata); // We initialize our layout layout = new GridBagLayout(); gbConstraints = new GridBagConstraints(); setLayout(layout); // We add the components infoLabel = new JLabel(parent.langpack.getString("InfoPanel.info"), parent.icons.getImageIcon("edit"), JLabel.TRAILING); parent.buildConstraints(gbConstraints, 0, 0, 1, 1, 1.0, 0.0); gbConstraints.insets = new Insets(5, 5, 5, 5); gbConstraints.fill = GridBagConstraints.NONE; gbConstraints.anchor = GridBagConstraints.SOUTHWEST; layout.addLayoutComponent(infoLabel, gbConstraints); add(infoLabel); try { textArea = new JEditorPane(); textArea.setEditable(false); textArea.addHyperlinkListener(this); JScrollPane scroller = new JScrollPane(textArea); textArea.setPage(loadInfo()); parent.buildConstraints(gbConstraints, 0, 1, 1, 1, 1.0, 1.0); gbConstraints.anchor = GridBagConstraints.CENTER; gbConstraints.fill = GridBagConstraints.BOTH; layout.addLayoutComponent(scroller, gbConstraints); add(scroller); } catch (Exception err) { err.printStackTrace(); } }
public HTMLInfoPanel(InstallerFrame parent, InstallData idata) { super(parent, idata); // We initialize our layout layout = new GridBagLayout(); gbConstraints = new GridBagConstraints(); setLayout(layout); // We add the components infoLabel = new JLabel(parent.langpack.getString("InfoPanel.info"), parent.icons.getImageIcon("edit"), JLabel.TRAILING); parent.buildConstraints(gbConstraints, 0, 0, 1, 1, 1.0, 0.0); gbConstraints.insets = new Insets(5, 5, 5, 5); gbConstraints.fill = GridBagConstraints.NONE; gbConstraints.anchor = GridBagConstraints.SOUTHWEST; layout.addLayoutComponent(infoLabel, gbConstraints); add(infoLabel); try { textArea = new JEditorPane(); textArea.setEditable(false); textArea.addHyperlinkListener(this); JScrollPane scroller = new JScrollPane(textArea); textArea.setPage(loadInfo()); parent.buildConstraints(gbConstraints, 0, 1, 1, 1, 1.0, 1.0); gbConstraints.anchor = GridBagConstraints.CENTER; gbConstraints.fill = GridBagConstraints.BOTH; layout.addLayoutComponent(scroller, gbConstraints); add(scroller); } catch (Exception err) { err.printStackTrace(); } }
3,241,213
public void hyperlinkUpdate(HyperlinkEvent e) { try { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) textArea.setPage(e.getURL()); } catch (Exception err) {} }
public void hyperlinkUpdate(HyperlinkEvent e) { try { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) textArea.setPage(e.getURL()); } catch (Exception err) {} }
3,241,214
private URL loadInfo() { String resNamePrifix = "HTMLInfoPanel.info"; try { return ResourceManager.getInstance().getURL(resNamePrifix); } catch (Exception ex) { ex.printStackTrace(); } return null; }
private URL loadInfo() { String resNamePrifix = "HTMLInfoPanel.info"; try { return ResourceManager.getInstance().getURL(resNamePrifix); } catch (Exception ex) { ex.printStackTrace(); } return null; }
3,241,215
private void executeMethod( boolean optimize ) throws FoundNoEdgeException { DirectedSparseEdge edge = null; Object[] outEdges = null; if ( _nextVertex.containsUserDatumKey( BACK_KEY ) && _history. size() >= 3 ) { Float probability = (Float)_nextVertex.getUserDatum( BACK_KEY ); int index = _radomGenerator.nextInt( 100 ); if ( index < ( probability.floatValue() * 100 ) ) { String str = (String)_history.removeLast(); _logger.debug( "Remove from history: " + str ); String nodeLabel = (String)_history.getLast(); _logger.debug( "Reversing a vertex. From: " + (String)_nextVertex.getUserDatum( LABEL_KEY ) + ", to: " + nodeLabel ); Object[] vertices = _graph.getVertices().toArray(); for ( int i = 0; i < vertices.length; i++ ) { DirectedSparseVertex vertex = (DirectedSparseVertex)vertices[ i ]; if ( nodeLabel == (String)vertex.getUserDatum( LABEL_KEY ) ) { try { _nextVertex = vertex; String label = "PressBackButton"; _logger.debug( "Invoke method for edge: \"" + label + "\"" ); invokeMethod( label ); label = nodeLabel; _logger.debug( "Invoke method for vertex: \"" + label + "\"" ); invokeMethod( label ); } catch( GoBackToPreviousVertexException e ) { throw new RuntimeException( "An GoBackToPreviousVertexException was thrown where it should not be thrown." ); } return; } } throw new RuntimeException( "An attempt was made to reverse to vertex: " + nodeLabel + ", and did not find it." ); } } _logger.debug( "Vertex = " + (String)_nextVertex.getUserDatum( LABEL_KEY ) ); outEdges = _nextVertex.getOutEdges().toArray(); _logger.debug( "Number of outgoing edges = " + outEdges.length ); outEdges = shuffle( outEdges ); if ( _shortestPathToVertex == null && _runUntilAllEdgesVisited == true ) { Vector unvisitedEdges = returnUnvisitedEdge(); if ( unvisitedEdges.size() == 0) { _logger.debug( "All edges has been visited!" ); return; } _logger.info( "Found " + unvisitedEdges.size() + " unvisited edges." ); Object[] shuffledList = shuffle( unvisitedEdges.toArray() ); DirectedSparseEdge e = (DirectedSparseEdge)shuffledList[ 0 ]; if ( e == null ) { throw new RuntimeException( "Found an empty edge!" ); } _logger.info( "Selecting edge: " + getCompleteEdgeName( e ) ); _shortestPathToVertex = new DijkstraShortestPath( _graph ).getPath( _nextVertex, e.getSource() ); _shortestPathToVertex.add( e ); _logger.info( "Intend to take the shortest path between: " + (String)_nextVertex.getUserDatum( LABEL_KEY ) + " ==> " + (String)e.getDest().getUserDatum( LABEL_KEY ) + " (from: " + (String)e.getSource().getUserDatum( LABEL_KEY ) + "), using " + _shortestPathToVertex.size() + " hops." ); String paths = ""; for (Iterator iter = _shortestPathToVertex.iterator(); iter.hasNext();) { DirectedSparseEdge item = (DirectedSparseEdge) iter.next(); paths += " ==> " + getCompleteEdgeName( item ); } _logger.info( paths ); } if ( _shortestPathToVertex != null && _shortestPathToVertex.size() > 0 ) { edge = (DirectedSparseEdge)_shortestPathToVertex.get( 0 ); _shortestPathToVertex.remove( 0 ); _logger.debug( "Removed edge: " + getCompleteEdgeName( edge ) + " from the shortest path list, " + _shortestPathToVertex.size() + " hops remaining." ); if ( _shortestPathToVertex.size() == 0 ) { _shortestPathToVertex = null; } } else if ( optimize ) { // Look for an edge that has not been visited yet. for ( int i = 0; i < outEdges.length; i++ ) { edge = (DirectedSparseEdge)outEdges[ i ]; Integer vistited = (Integer)edge.getUserDatum( VISITED_KEY ); if ( vistited.intValue() == 0 ) { if ( _rejectedEdge == edge ) { // This edge has been rejected, because some condition was not fullfilled. // Try with the next edge in the for-loop. // _rejectedEdge has to be set to null, because it can be valid next time. _rejectedEdge = null; } else { _logger.debug( "Found an edge which has not been visited yet: " + getCompleteEdgeName( edge ) ); break; } } edge = null; } if ( edge == null ) { _logger.debug( "All edges has been visited (" + outEdges.length + ")" ); edge = getWeightedEdge( _nextVertex ); } } else { edge = getWeightedEdge( _nextVertex ); } if ( edge == null ) { throw new RuntimeException( "Did not find any edge." ); } _logger.debug( "Edge = \"" + getCompleteEdgeName( edge ) + "\"" ); _prevVertex = _nextVertex; _nextVertex = (DirectedSparseVertex)edge.getDest(); try { String label = (String)edge.getUserDatum( LABEL_KEY ); _logger.debug( "Invoke method for edge: \"" + label + "\"" ); invokeMethod( label ); Integer vistited = (Integer)edge.getUserDatum( VISITED_KEY ); vistited = new Integer( vistited.intValue() + 1 ); edge.setUserDatum( VISITED_KEY, vistited, UserData.SHARED ); label = (String)edge.getDest().getUserDatum( LABEL_KEY ); _logger.debug( "Invoke method for vertex: \"" + label + "\"" ); invokeMethod( label ); vistited = (Integer)edge.getDest().getUserDatum( VISITED_KEY ); vistited = new Integer( vistited.intValue() + 1 ); edge.getDest().setUserDatum( VISITED_KEY, vistited, UserData.SHARED ); if ( ((String)edge.getDest().getUserDatum( LABEL_KEY )).equals( "Stop" ) ) { _logger.debug( "Clearing the history" ); _history.clear(); } if ( edge.containsUserDatumKey( NO_HISTORY ) == false ) { _logger.debug( "Add to history: " + getCompleteEdgeName( edge ) ); _history.add( (String)edge.getDest().getUserDatum( LABEL_KEY ) ); } } catch( GoBackToPreviousVertexException e ) { _logger.debug( "The edge: " + getCompleteEdgeName( edge ) + " can not be run due to unfullfilled conditions." ); _logger.debug( "Trying from vertex: " + (String)_prevVertex.getUserDatum( LABEL_KEY ) + " again." ); _rejectedEdge = edge; _nextVertex = _prevVertex; } }
private void executeMethod( boolean optimize ) throws FoundNoEdgeException { DirectedSparseEdge edge = null; Object[] outEdges = null; if ( _nextVertex.containsUserDatumKey( BACK_KEY ) && _history. size() >= 3 ) { Float probability = (Float)_nextVertex.getUserDatum( BACK_KEY ); int index = _radomGenerator.nextInt( 100 ); if ( index < ( probability.floatValue() * 100 ) ) { String str = (String)_history.removeLast(); _logger.debug( "Remove from history: " + str ); String nodeLabel = (String)_history.getLast(); _logger.debug( "Reversing a vertex. From: " + (String)_nextVertex.getUserDatum( LABEL_KEY ) + ", to: " + nodeLabel ); Object[] vertices = _graph.getVertices().toArray(); for ( int i = 0; i < vertices.length; i++ ) { DirectedSparseVertex vertex = (DirectedSparseVertex)vertices[ i ]; if ( nodeLabel == (String)vertex.getUserDatum( LABEL_KEY ) ) { try { _nextVertex = vertex; String label = "PressBackButton"; _logger.debug( "Invoke method for edge: \"" + label + "\"" ); invokeMethod( label ); label = nodeLabel; _logger.debug( "Invoke method for vertex: \"" + label + "\"" ); invokeMethod( label ); } catch( GoBackToPreviousVertexException e ) { throw new RuntimeException( "An GoBackToPreviousVertexException was thrown where it should not be thrown." ); } return; } } throw new RuntimeException( "An attempt was made to reverse to vertex: " + nodeLabel + ", and did not find it." ); } } _logger.debug( "Vertex = " + (String)_nextVertex.getUserDatum( LABEL_KEY ) ); outEdges = _nextVertex.getOutEdges().toArray(); _logger.debug( "Number of outgoing edges = " + outEdges.length ); outEdges = shuffle( outEdges ); if ( _shortestPathToVertex == null && _runUntilAllEdgesVisited == true ) { Vector unvisitedEdges = returnUnvisitedEdge(); if ( unvisitedEdges.size() == 0) { _logger.debug( "All edges has been visited!" ); return; } _logger.info( "Found " + unvisitedEdges.size() + " unvisited edges." ); Object[] shuffledList = shuffle( unvisitedEdges.toArray() ); DirectedSparseEdge e = (DirectedSparseEdge)shuffledList[ 0 ]; if ( e == null ) { throw new RuntimeException( "Found an empty edge!" ); } _logger.info( "Selecting edge: " + getCompleteEdgeName( e ) ); _shortestPathToVertex = new DijkstraShortestPath( _graph ).getPath( _nextVertex, e.getSource() ); _shortestPathToVertex.add( e ); _logger.info( "Intend to take the shortest path between: " + (String)_nextVertex.getUserDatum( LABEL_KEY ) + " ==> " + (String)e.getDest().getUserDatum( LABEL_KEY ) + " (from: " + (String)e.getSource().getUserDatum( LABEL_KEY ) + "), using " + _shortestPathToVertex.size() + " hops." ); String paths = ""; for (Iterator iter = _shortestPathToVertex.iterator(); iter.hasNext();) { DirectedSparseEdge item = (DirectedSparseEdge) iter.next(); paths += " ==> " + getCompleteEdgeName( item ); } _logger.info( paths ); } if ( _shortestPathToVertex != null && _shortestPathToVertex.size() > 0 ) { edge = (DirectedSparseEdge)_shortestPathToVertex.get( 0 ); _shortestPathToVertex.remove( 0 ); _logger.debug( "Removed edge: " + getCompleteEdgeName( edge ) + " from the shortest path list, " + _shortestPathToVertex.size() + " hops remaining." ); if ( _shortestPathToVertex.size() == 0 ) { _shortestPathToVertex = null; } } else if ( optimize ) { // Look for an edge that has not been visited yet. for ( int i = 0; i < outEdges.length; i++ ) { edge = (DirectedSparseEdge)outEdges[ i ]; Integer vistited = (Integer)edge.getUserDatum( VISITED_KEY ); if ( vistited.intValue() == 0 ) { if ( _rejectedEdge == edge ) { // This edge has been rejected, because some condition was not fullfilled. // Try with the next edge in the for-loop. // _rejectedEdge has to be set to null, because it can be valid next time. _rejectedEdge = null; } else { _logger.debug( "Found an edge which has not been visited yet: " + getCompleteEdgeName( edge ) ); break; } } edge = null; } if ( edge == null ) { _logger.debug( "All edges has been visited (" + outEdges.length + ")" ); edge = getWeightedEdge( _nextVertex ); } } else { edge = getWeightedEdge( _nextVertex ); } if ( edge == null ) { throw new RuntimeException( "Did not find any edge." ); } _logger.debug( "Edge = \"" + getCompleteEdgeName( edge ) + "\"" ); _prevVertex = _nextVertex; _nextVertex = (DirectedSparseVertex)edge.getDest(); try { String label = (String)edge.getUserDatum( LABEL_KEY ); _logger.debug( "Invoke method for edge: \"" + label + "\"" ); invokeMethod( label ); Integer vistited = (Integer)edge.getUserDatum( VISITED_KEY ); vistited = new Integer( vistited.intValue() + 1 ); edge.setUserDatum( VISITED_KEY, vistited, UserData.SHARED ); label = (String)edge.getDest().getUserDatum( LABEL_KEY ); _logger.debug( "Invoke method for vertex: \"" + label + "\"" ); invokeMethod( label ); vistited = (Integer)edge.getDest().getUserDatum( VISITED_KEY ); vistited = new Integer( vistited.intValue() + 1 ); edge.getDest().setUserDatum( VISITED_KEY, vistited, UserData.SHARED ); if ( ((String)edge.getDest().getUserDatum( LABEL_KEY )).equals( "Stop" ) ) { _logger.debug( "Clearing the history" ); _history.clear(); } if ( edge.containsUserDatumKey( NO_HISTORY ) == false ) { _logger.debug( "Add to history: " + getCompleteEdgeName( edge ) ); _history.add( (String)edge.getDest().getUserDatum( LABEL_KEY ) ); } } catch( GoBackToPreviousVertexException e ) { _logger.debug( "The edge: " + getCompleteEdgeName( edge ) + " can not be run due to unfullfilled conditions." ); _logger.debug( "Trying from vertex: " + (String)_prevVertex.getUserDatum( LABEL_KEY ) + " again." ); _rejectedEdge = edge; _nextVertex = _prevVertex; } }
3,241,216
private void executeMethod( boolean optimize ) throws FoundNoEdgeException { DirectedSparseEdge edge = null; Object[] outEdges = null; if ( _nextVertex.containsUserDatumKey( BACK_KEY ) && _history. size() >= 3 ) { Float probability = (Float)_nextVertex.getUserDatum( BACK_KEY ); int index = _radomGenerator.nextInt( 100 ); if ( index < ( probability.floatValue() * 100 ) ) { String str = (String)_history.removeLast(); _logger.debug( "Remove from history: " + str ); String nodeLabel = (String)_history.getLast(); _logger.debug( "Reversing a vertex. From: " + (String)_nextVertex.getUserDatum( LABEL_KEY ) + ", to: " + nodeLabel ); Object[] vertices = _graph.getVertices().toArray(); for ( int i = 0; i < vertices.length; i++ ) { DirectedSparseVertex vertex = (DirectedSparseVertex)vertices[ i ]; if ( nodeLabel == (String)vertex.getUserDatum( LABEL_KEY ) ) { try { _nextVertex = vertex; String label = "PressBackButton"; _logger.debug( "Invoke method for edge: \"" + label + "\"" ); invokeMethod( label ); label = nodeLabel; _logger.debug( "Invoke method for vertex: \"" + label + "\"" ); invokeMethod( label ); } catch( GoBackToPreviousVertexException e ) { throw new RuntimeException( "An GoBackToPreviousVertexException was thrown where it should not be thrown." ); } return; } } throw new RuntimeException( "An attempt was made to reverse to vertex: " + nodeLabel + ", and did not find it." ); } } _logger.debug( "Vertex = " + (String)_nextVertex.getUserDatum( LABEL_KEY ) ); outEdges = _nextVertex.getOutEdges().toArray(); _logger.debug( "Number of outgoing edges = " + outEdges.length ); outEdges = shuffle( outEdges ); if ( _shortestPathToVertex == null && _runUntilAllEdgesVisited == true ) { Vector unvisitedEdges = returnUnvisitedEdge(); if ( unvisitedEdges.size() == 0) { _logger.debug( "All edges has been visited!" ); return; } _logger.info( "Found " + unvisitedEdges.size() + " unvisited edges." ); Object[] shuffledList = shuffle( unvisitedEdges.toArray() ); DirectedSparseEdge e = (DirectedSparseEdge)shuffledList[ 0 ]; if ( e == null ) { throw new RuntimeException( "Found an empty edge!" ); } _logger.info( "Selecting edge: " + getCompleteEdgeName( e ) ); _shortestPathToVertex = new DijkstraShortestPath( _graph ).getPath( _nextVertex, e.getSource() ); _shortestPathToVertex.add( e ); _logger.info( "Intend to take the shortest path between: " + (String)_nextVertex.getUserDatum( LABEL_KEY ) + " ==> " + (String)e.getDest().getUserDatum( LABEL_KEY ) + " (from: " + (String)e.getSource().getUserDatum( LABEL_KEY ) + "), using " + _shortestPathToVertex.size() + " hops." ); String paths = ""; for (Iterator iter = _shortestPathToVertex.iterator(); iter.hasNext();) { DirectedSparseEdge item = (DirectedSparseEdge) iter.next(); paths += " ==> " + getCompleteEdgeName( item ); } _logger.info( paths ); } if ( _shortestPathToVertex != null && _shortestPathToVertex.size() > 0 ) { edge = (DirectedSparseEdge)_shortestPathToVertex.get( 0 ); _shortestPathToVertex.remove( 0 ); _logger.debug( "Removed edge: " + getCompleteEdgeName( edge ) + " from the shortest path list, " + _shortestPathToVertex.size() + " hops remaining." ); if ( _shortestPathToVertex.size() == 0 ) { _shortestPathToVertex = null; } } else if ( optimize ) { // Look for an edge that has not been visited yet. for ( int i = 0; i < outEdges.length; i++ ) { edge = (DirectedSparseEdge)outEdges[ i ]; Integer vistited = (Integer)edge.getUserDatum( VISITED_KEY ); if ( vistited.intValue() == 0 ) { if ( _rejectedEdge == edge ) { // This edge has been rejected, because some condition was not fullfilled. // Try with the next edge in the for-loop. // _rejectedEdge has to be set to null, because it can be valid next time. _rejectedEdge = null; } else { _logger.debug( "Found an edge which has not been visited yet: " + getCompleteEdgeName( edge ) ); break; } } edge = null; } if ( edge == null ) { _logger.debug( "All edges has been visited (" + outEdges.length + ")" ); edge = getWeightedEdge( _nextVertex ); } } else { edge = getWeightedEdge( _nextVertex ); } if ( edge == null ) { throw new RuntimeException( "Did not find any edge." ); } _logger.debug( "Edge = \"" + getCompleteEdgeName( edge ) + "\"" ); _prevVertex = _nextVertex; _nextVertex = (DirectedSparseVertex)edge.getDest(); try { String label = (String)edge.getUserDatum( LABEL_KEY ); _logger.debug( "Invoke method for edge: \"" + label + "\"" ); invokeMethod( label ); Integer vistited = (Integer)edge.getUserDatum( VISITED_KEY ); vistited = new Integer( vistited.intValue() + 1 ); edge.setUserDatum( VISITED_KEY, vistited, UserData.SHARED ); label = (String)edge.getDest().getUserDatum( LABEL_KEY ); _logger.debug( "Invoke method for vertex: \"" + label + "\"" ); invokeMethod( label ); vistited = (Integer)edge.getDest().getUserDatum( VISITED_KEY ); vistited = new Integer( vistited.intValue() + 1 ); edge.getDest().setUserDatum( VISITED_KEY, vistited, UserData.SHARED ); if ( ((String)edge.getDest().getUserDatum( LABEL_KEY )).equals( "Stop" ) ) { _logger.debug( "Clearing the history" ); _history.clear(); } if ( edge.containsUserDatumKey( NO_HISTORY ) == false ) { _logger.debug( "Add to history: " + getCompleteEdgeName( edge ) ); _history.add( (String)edge.getDest().getUserDatum( LABEL_KEY ) ); } } catch( GoBackToPreviousVertexException e ) { _logger.debug( "The edge: " + getCompleteEdgeName( edge ) + " can not be run due to unfullfilled conditions." ); _logger.debug( "Trying from vertex: " + (String)_prevVertex.getUserDatum( LABEL_KEY ) + " again." ); _rejectedEdge = edge; _nextVertex = _prevVertex; } }
private void executeMethod( boolean optimize ) throws FoundNoEdgeException { DirectedSparseEdge edge = null; Object[] outEdges = null; if ( _nextVertex.containsUserDatumKey( BACK_KEY ) && _history. size() >= 3 ) { Float probability = (Float)_nextVertex.getUserDatum( BACK_KEY ); int index = _radomGenerator.nextInt( 100 ); if ( index < ( probability.floatValue() * 100 ) ) { String str = (String)_history.removeLast(); _logger.debug( "Remove from history: " + str ); String nodeLabel = (String)_history.getLast(); _logger.debug( "Reversing a vertex. From: " + (String)_nextVertex.getUserDatum( LABEL_KEY ) + ", to: " + nodeLabel ); Object[] vertices = _graph.getVertices().toArray(); for ( int i = 0; i < vertices.length; i++ ) { DirectedSparseVertex vertex = (DirectedSparseVertex)vertices[ i ]; if ( nodeLabel == (String)vertex.getUserDatum( LABEL_KEY ) ) { try { _nextVertex = vertex; String label = "PressBackButton"; _logger.debug( "Invoke method for edge: \"" + label + "\"" ); invokeMethod( label ); label = nodeLabel; _logger.debug( "Invoke method for vertex: \"" + label + "\"" ); invokeMethod( label ); } catch( GoBackToPreviousVertexException e ) { throw new RuntimeException( "An GoBackToPreviousVertexException was thrown where it should not be thrown." ); } return; } } throw new RuntimeException( "An attempt was made to reverse to vertex: " + nodeLabel + ", and did not find it." ); } } _logger.debug( "Vertex = " + (String)_nextVertex.getUserDatum( LABEL_KEY ) ); outEdges = _nextVertex.getOutEdges().toArray(); _logger.debug( "Number of outgoing edges = " + outEdges.length ); outEdges = shuffle( outEdges ); if ( _shortestPathToVertex == null && _runUntilAllEdgesVisited == true ) { Vector unvisitedEdges = returnUnvisitedEdge(); if ( unvisitedEdges.size() == 0) { _logger.debug( "All edges has been visited!" ); return; } _logger.info( "Found " + unvisitedEdges.size() + " unvisited edges." ); Object[] shuffledList = shuffle( unvisitedEdges.toArray() ); DirectedSparseEdge e = (DirectedSparseEdge)shuffledList[ 0 ]; if ( e == null ) { throw new RuntimeException( "Found an empty edge!" ); } _logger.info( "Selecting edge: " + getCompleteEdgeName( e ) ); _shortestPathToVertex = new DijkstraShortestPath( _graph ).getPath( _nextVertex, e.getSource() ); _shortestPathToVertex.add( e ); _logger.info( "Intend to take the shortest path between: " + (String)_nextVertex.getUserDatum( LABEL_KEY ) + " ==> " + (String)e.getDest().getUserDatum( LABEL_KEY ) + " (from: " + (String)e.getSource().getUserDatum( LABEL_KEY ) + "), using " + _shortestPathToVertex.size() + " hops." ); String paths = ""; for (Iterator iter = _shortestPathToVertex.iterator(); iter.hasNext();) { DirectedSparseEdge item = (DirectedSparseEdge) iter.next(); paths += " ==> " + getCompleteEdgeName( item ); } _logger.info( paths ); } if ( _shortestPathToVertex != null && _shortestPathToVertex.size() > 0 ) { edge = (DirectedSparseEdge)_shortestPathToVertex.get( 0 ); _shortestPathToVertex.remove( 0 ); _logger.debug( "Removed edge: " + getCompleteEdgeName( edge ) + " from the shortest path list, " + _shortestPathToVertex.size() + " hops remaining." ); if ( _shortestPathToVertex.size() == 0 ) { _shortestPathToVertex = null; } } else if ( optimize ) { // Look for an edge that has not been visited yet. for ( int i = 0; i < outEdges.length; i++ ) { edge = (DirectedSparseEdge)outEdges[ i ]; Integer vistited = (Integer)edge.getUserDatum( VISITED_KEY ); if ( vistited.intValue() == 0 ) { if ( _rejectedEdge == edge ) { // This edge has been rejected, because some condition was not fullfilled. // Try with the next edge in the for-loop. // _rejectedEdge has to be set to null, because it can be valid next time. _rejectedEdge = null; } else { _logger.debug( "Found an edge which has not been visited yet: " + getCompleteEdgeName( edge ) ); break; } } edge = null; } if ( edge == null ) { _logger.debug( "All edges has been visited (" + outEdges.length + ")" ); edge = getWeightedEdge( _nextVertex ); } } else { edge = getWeightedEdge( _nextVertex ); } if ( edge == null ) { throw new RuntimeException( "Did not find any edge." ); } _logger.debug( "Edge = \"" + getCompleteEdgeName( edge ) + "\"" ); _prevVertex = _nextVertex; _nextVertex = (DirectedSparseVertex)edge.getDest(); try { String label = (String)edge.getUserDatum( LABEL_KEY ); _logger.debug( "Invoke method for edge: \"" + label + "\"" ); invokeMethod( label ); Integer vistited = (Integer)edge.getUserDatum( VISITED_KEY ); vistited = new Integer( vistited.intValue() + 1 ); edge.setUserDatum( VISITED_KEY, vistited, UserData.SHARED ); label = (String)edge.getDest().getUserDatum( LABEL_KEY ); _logger.debug( "Invoke method for vertex: \"" + label + "\"" ); invokeMethod( label ); vistited = (Integer)edge.getDest().getUserDatum( VISITED_KEY ); vistited = new Integer( vistited.intValue() + 1 ); edge.getDest().setUserDatum( VISITED_KEY, vistited, UserData.SHARED ); if ( ((String)edge.getDest().getUserDatum( LABEL_KEY )).equals( "Stop" ) ) { _logger.debug( "Clearing the history" ); _history.clear(); } if ( edge.containsUserDatumKey( NO_HISTORY ) == false ) { _logger.debug( "Add to history: " + getCompleteEdgeName( edge ) ); _history.add( (String)edge.getDest().getUserDatum( LABEL_KEY ) ); } } catch( GoBackToPreviousVertexException e ) { _logger.debug( "The edge: " + getCompleteEdgeName( edge ) + " can not be run due to unfullfilled conditions." ); _logger.debug( "Trying from vertex: " + (String)_prevVertex.getUserDatum( LABEL_KEY ) + " again." ); _rejectedEdge = edge; _nextVertex = _prevVertex; } }
3,241,217
private void executeMethod( boolean optimize ) throws FoundNoEdgeException { DirectedSparseEdge edge = null; Object[] outEdges = null; if ( _nextVertex.containsUserDatumKey( BACK_KEY ) && _history. size() >= 3 ) { Float probability = (Float)_nextVertex.getUserDatum( BACK_KEY ); int index = _radomGenerator.nextInt( 100 ); if ( index < ( probability.floatValue() * 100 ) ) { String str = (String)_history.removeLast(); _logger.debug( "Remove from history: " + str ); String nodeLabel = (String)_history.getLast(); _logger.debug( "Reversing a vertex. From: " + (String)_nextVertex.getUserDatum( LABEL_KEY ) + ", to: " + nodeLabel ); Object[] vertices = _graph.getVertices().toArray(); for ( int i = 0; i < vertices.length; i++ ) { DirectedSparseVertex vertex = (DirectedSparseVertex)vertices[ i ]; if ( nodeLabel == (String)vertex.getUserDatum( LABEL_KEY ) ) { try { _nextVertex = vertex; String label = "PressBackButton"; _logger.debug( "Invoke method for edge: \"" + label + "\"" ); invokeMethod( label ); label = nodeLabel; _logger.debug( "Invoke method for vertex: \"" + label + "\"" ); invokeMethod( label ); } catch( GoBackToPreviousVertexException e ) { throw new RuntimeException( "An GoBackToPreviousVertexException was thrown where it should not be thrown." ); } return; } } throw new RuntimeException( "An attempt was made to reverse to vertex: " + nodeLabel + ", and did not find it." ); } } _logger.debug( "Vertex = " + (String)_nextVertex.getUserDatum( LABEL_KEY ) ); outEdges = _nextVertex.getOutEdges().toArray(); _logger.debug( "Number of outgoing edges = " + outEdges.length ); outEdges = shuffle( outEdges ); if ( _shortestPathToVertex == null && _runUntilAllEdgesVisited == true ) { Vector unvisitedEdges = returnUnvisitedEdge(); if ( unvisitedEdges.size() == 0) { _logger.debug( "All edges has been visited!" ); return; } _logger.info( "Found " + unvisitedEdges.size() + " unvisited edges." ); Object[] shuffledList = shuffle( unvisitedEdges.toArray() ); DirectedSparseEdge e = (DirectedSparseEdge)shuffledList[ 0 ]; if ( e == null ) { throw new RuntimeException( "Found an empty edge!" ); } _logger.info( "Selecting edge: " + getCompleteEdgeName( e ) ); _shortestPathToVertex = new DijkstraShortestPath( _graph ).getPath( _nextVertex, e.getSource() ); _shortestPathToVertex.add( e ); _logger.info( "Intend to take the shortest path between: " + (String)_nextVertex.getUserDatum( LABEL_KEY ) + " ==> " + (String)e.getDest().getUserDatum( LABEL_KEY ) + " (from: " + (String)e.getSource().getUserDatum( LABEL_KEY ) + "), using " + _shortestPathToVertex.size() + " hops." ); String paths = ""; for (Iterator iter = _shortestPathToVertex.iterator(); iter.hasNext();) { DirectedSparseEdge item = (DirectedSparseEdge) iter.next(); paths += " ==> " + getCompleteEdgeName( item ); } _logger.info( paths ); } if ( _shortestPathToVertex != null && _shortestPathToVertex.size() > 0 ) { edge = (DirectedSparseEdge)_shortestPathToVertex.get( 0 ); _shortestPathToVertex.remove( 0 ); _logger.debug( "Removed edge: " + getCompleteEdgeName( edge ) + " from the shortest path list, " + _shortestPathToVertex.size() + " hops remaining." ); if ( _shortestPathToVertex.size() == 0 ) { _shortestPathToVertex = null; } } else if ( optimize ) { // Look for an edge that has not been visited yet. for ( int i = 0; i < outEdges.length; i++ ) { edge = (DirectedSparseEdge)outEdges[ i ]; Integer vistited = (Integer)edge.getUserDatum( VISITED_KEY ); if ( vistited.intValue() == 0 ) { if ( _rejectedEdge == edge ) { // This edge has been rejected, because some condition was not fullfilled. // Try with the next edge in the for-loop. // _rejectedEdge has to be set to null, because it can be valid next time. _rejectedEdge = null; } else { _logger.debug( "Found an edge which has not been visited yet: " + getCompleteEdgeName( edge ) ); break; } } edge = null; } if ( edge == null ) { _logger.debug( "All edges has been visited (" + outEdges.length + ")" ); edge = getWeightedEdge( _nextVertex ); } } else { edge = getWeightedEdge( _nextVertex ); } if ( edge == null ) { throw new RuntimeException( "Did not find any edge." ); } _logger.debug( "Edge = \"" + getCompleteEdgeName( edge ) + "\"" ); _prevVertex = _nextVertex; _nextVertex = (DirectedSparseVertex)edge.getDest(); try { String label = (String)edge.getUserDatum( LABEL_KEY ); _logger.debug( "Invoke method for edge: \"" + label + "\"" ); invokeMethod( label ); Integer vistited = (Integer)edge.getUserDatum( VISITED_KEY ); vistited = new Integer( vistited.intValue() + 1 ); edge.setUserDatum( VISITED_KEY, vistited, UserData.SHARED ); label = (String)edge.getDest().getUserDatum( LABEL_KEY ); _logger.debug( "Invoke method for vertex: \"" + label + "\"" ); invokeMethod( label ); vistited = (Integer)edge.getDest().getUserDatum( VISITED_KEY ); vistited = new Integer( vistited.intValue() + 1 ); edge.getDest().setUserDatum( VISITED_KEY, vistited, UserData.SHARED ); if ( ((String)edge.getDest().getUserDatum( LABEL_KEY )).equals( "Stop" ) ) { _logger.debug( "Clearing the history" ); _history.clear(); } if ( edge.containsUserDatumKey( NO_HISTORY ) == false ) { _logger.debug( "Add to history: " + getCompleteEdgeName( edge ) ); _history.add( (String)edge.getDest().getUserDatum( LABEL_KEY ) ); } } catch( GoBackToPreviousVertexException e ) { _logger.debug( "The edge: " + getCompleteEdgeName( edge ) + " can not be run due to unfullfilled conditions." ); _logger.debug( "Trying from vertex: " + (String)_prevVertex.getUserDatum( LABEL_KEY ) + " again." ); _rejectedEdge = edge; _nextVertex = _prevVertex; } }
private void executeMethod( boolean optimize ) throws FoundNoEdgeException { DirectedSparseEdge edge = null; Object[] outEdges = null; if ( _nextVertex.containsUserDatumKey( BACK_KEY ) && _history. size() >= 3 ) { Float probability = (Float)_nextVertex.getUserDatum( BACK_KEY ); int index = _radomGenerator.nextInt( 100 ); if ( index < ( probability.floatValue() * 100 ) ) { String str = (String)_history.removeLast(); _logger.debug( "Remove from history: " + str ); String nodeLabel = (String)_history.getLast(); _logger.debug( "Reversing a vertex. From: " + (String)_nextVertex.getUserDatum( LABEL_KEY ) + ", to: " + nodeLabel ); Object[] vertices = _graph.getVertices().toArray(); for ( int i = 0; i < vertices.length; i++ ) { DirectedSparseVertex vertex = (DirectedSparseVertex)vertices[ i ]; if ( nodeLabel == (String)vertex.getUserDatum( LABEL_KEY ) ) { try { _nextVertex = vertex; String label = "PressBackButton"; _logger.debug( "Invoke method for edge: \"" + label + "\"" ); invokeMethod( label ); label = nodeLabel; _logger.debug( "Invoke method for vertex: \"" + label + "\"" ); invokeMethod( label ); } catch( GoBackToPreviousVertexException e ) { throw new RuntimeException( "An GoBackToPreviousVertexException was thrown where it should not be thrown." ); } return; } } throw new RuntimeException( "An attempt was made to reverse to vertex: " + nodeLabel + ", and did not find it." ); } } _logger.debug( "Vertex = " + (String)_nextVertex.getUserDatum( LABEL_KEY ) ); outEdges = _nextVertex.getOutEdges().toArray(); _logger.debug( "Number of outgoing edges = " + outEdges.length ); outEdges = shuffle( outEdges ); if ( _shortestPathToVertex == null && _runUntilAllEdgesVisited == true ) { Vector unvisitedEdges = returnUnvisitedEdge(); if ( unvisitedEdges.size() == 0) { _logger.debug( "All edges has been visited!" ); return; } _logger.info( "Found " + unvisitedEdges.size() + " unvisited edges." ); Object[] shuffledList = shuffle( unvisitedEdges.toArray() ); DirectedSparseEdge e = (DirectedSparseEdge)shuffledList[ 0 ]; if ( e == null ) { throw new RuntimeException( "Found an empty edge!" ); } _logger.info( "Selecting edge: " + getCompleteEdgeName( e ) ); _shortestPathToVertex = new DijkstraShortestPath( _graph ).getPath( _nextVertex, e.getSource() ); _shortestPathToVertex.add( e ); _logger.info( "Intend to take the shortest path between: " + (String)_nextVertex.getUserDatum( LABEL_KEY ) + " ==> " + (String)e.getDest().getUserDatum( LABEL_KEY ) + " (from: " + (String)e.getSource().getUserDatum( LABEL_KEY ) + "), using " + _shortestPathToVertex.size() + " hops." ); String paths = ""; for (Iterator iter = _shortestPathToVertex.iterator(); iter.hasNext();) { DirectedSparseEdge item = (DirectedSparseEdge) iter.next(); paths += " ==> " + getCompleteEdgeName( item ); } _logger.info( paths ); } if ( _shortestPathToVertex != null && _shortestPathToVertex.size() > 0 ) { edge = (DirectedSparseEdge)_shortestPathToVertex.get( 0 ); _shortestPathToVertex.remove( 0 ); _logger.debug( "Removed edge: " + getCompleteEdgeName( edge ) + " from the shortest path list, " + _shortestPathToVertex.size() + " hops remaining." ); if ( _shortestPathToVertex.size() == 0 ) { _shortestPathToVertex = null; } } else if ( optimize ) { // Look for an edge that has not been visited yet. for ( int i = 0; i < outEdges.length; i++ ) { edge = (DirectedSparseEdge)outEdges[ i ]; Integer vistited = (Integer)edge.getUserDatum( VISITED_KEY ); if ( vistited.intValue() == 0 ) { if ( _rejectedEdge == edge ) { // This edge has been rejected, because some condition was not fullfilled. // Try with the next edge in the for-loop. // _rejectedEdge has to be set to null, because it can be valid next time. _rejectedEdge = null; } else { _logger.debug( "Found an edge which has not been visited yet: " + getCompleteEdgeName( edge ) ); break; } } edge = null; } if ( edge == null ) { _logger.debug( "All edges has been visited (" + outEdges.length + ")" ); edge = getWeightedEdge( _nextVertex ); } } else { edge = getWeightedEdge( _nextVertex ); } if ( edge == null ) { throw new RuntimeException( "Did not find any edge." ); } _logger.debug( "Edge = \"" + getCompleteEdgeName( edge ) + "\"" ); _prevVertex = _nextVertex; _nextVertex = (DirectedSparseVertex)edge.getDest(); try { String label = (String)edge.getUserDatum( LABEL_KEY ); _logger.debug( "Invoke method for edge: \"" + label + "\"" ); invokeMethod( label ); Integer vistited = (Integer)edge.getUserDatum( VISITED_KEY ); vistited = new Integer( vistited.intValue() + 1 ); edge.setUserDatum( VISITED_KEY, vistited, UserData.SHARED ); label = (String)edge.getDest().getUserDatum( LABEL_KEY ); _logger.debug( "Invoke method for vertex: \"" + label + "\"" ); invokeMethod( label ); vistited = (Integer)edge.getDest().getUserDatum( VISITED_KEY ); vistited = new Integer( vistited.intValue() + 1 ); edge.getDest().setUserDatum( VISITED_KEY, vistited, UserData.SHARED ); if ( ((String)edge.getDest().getUserDatum( LABEL_KEY )).equals( "Stop" ) ) { _logger.debug( "Clearing the history" ); _history.clear(); } if ( edge.containsUserDatumKey( NO_HISTORY ) == false ) { _logger.debug( "Add to history: " + getCompleteEdgeName( edge ) ); _history.add( (String)edge.getDest().getUserDatum( LABEL_KEY ) ); } } catch( GoBackToPreviousVertexException e ) { _logger.debug( "The edge: " + getCompleteEdgeName( edge ) + " can not be run due to unfullfilled conditions." ); _logger.debug( "Trying from vertex: " + (String)_prevVertex.getUserDatum( LABEL_KEY ) + " again." ); _rejectedEdge = edge; _nextVertex = _prevVertex; } }
3,241,218
private void parseFile( String fileName ) { try { _logger.info( "Parsing file: " + fileName ); _doc = _parser.build( fileName ); // Parse all vertices (nodes) Iterator iter = _doc.getDescendants( new ElementFilter( "node" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; if ( element.getAttributeValue( "yfiles.foldertype" ) != null ) { _logger.debug( "Excluded node: " + element.getAttributeValue( "yfiles.foldertype" ) ); continue; } _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "NodeLabel" ) ); while ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { Element nodeLabel = (Element)o2; _logger.debug( "Full name: " + nodeLabel.getQualifiedName() ); _logger.debug( "Name: " + nodeLabel.getTextTrim() ); DirectedSparseVertex v = (DirectedSparseVertex) _graph.addVertex( new DirectedSparseVertex() ); v.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); v.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); v.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); String str = nodeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label; if ( m.find( )) { label = m.group( 1 ); v.addUserDatum( LABEL_KEY, label, UserData.SHARED ); } else { throw new RuntimeException( "Label must be defined." ); } _logger.debug( "Added node: " + v.getUserDatum( LABEL_KEY ) ); // If no merge is defined, find it... // If defined, it means that when merging graphs, this specific vertex will not be merged. p = Pattern.compile( "(no merge)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { v.addUserDatum( NO_MERGE, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found no merge for edge: " + label ); } // NOTE: Only for html applications // In browsers, the usage of the 'Back'-button can be used. // If defined, with a value value, which depicts the probability for the edge // to be executed, tha back-button will be pressed in the browser. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(back=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find( ) ) { Float probability; String value = m.group( 2 ); try { probability = Float.valueOf( value.trim() ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", back is not a correct float value: " + error.toString() ); } v.addUserDatum( BACK_KEY, probability, UserData.SHARED ); } } } } } Object[] vertices = _graph.getVertices().toArray(); // Parse all edges (arrows or transtitions) iter = _doc.getDescendants( new ElementFilter( "edge" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "EdgeLabel" ) ); Element edgeLabel = null; if ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { edgeLabel = (Element)o2; _logger.debug( "Full name: " + edgeLabel.getQualifiedName() ); _logger.debug( "Name: " + edgeLabel.getTextTrim() ); } } _logger.debug( "source: " + element.getAttributeValue( "source" ) ); _logger.debug( "target: " + element.getAttributeValue( "target" ) ); DirectedSparseVertex source = null; DirectedSparseVertex dest = null; for ( int i = 0; i < vertices.length; i++ ) { DirectedSparseVertex vertex = (DirectedSparseVertex)vertices[ i ]; // Find source vertex if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "source" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { source = vertex; } if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "target" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { dest = vertex; } } if ( source == null ) { String msg = "Could not find starting node for edge. Name: " + element.getAttributeValue( "source" ); _logger.error( msg ); throw new RuntimeException( msg ); } if ( dest == null ) { String msg = "Could not find end node for edge. Name: " + element.getAttributeValue( "target" ); _logger.error( msg ); throw new RuntimeException( msg ); } DirectedSparseEdge e = new DirectedSparseEdge( source, dest ); _graph.addEdge( e ); e.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); e.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); if ( edgeLabel != null ) { String str = edgeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label = null; if ( m.find() ) { label = m.group( 1 ); e.addUserDatum( LABEL_KEY, label, UserData.SHARED ); _logger.debug( "Found label= " + label + " for edge id: " + edgeLabel.getQualifiedName() ); } else { throw new RuntimeException( "Label for edge must be defined." ); } // If weight is defined, find it... // weight must be associated with a value, which depicts the probability for the edge // to be executed. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(weight=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { Float weight; String value = m.group( 2 ); try { weight = Float.valueOf( value.trim() ); _logger.debug( "Found weight= " + weight + " for edge: " + label ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", weight is not a correct float value: " + error.toString() ); } e.addUserDatum( WEIGHT_KEY, weight, UserData.SHARED ); } // If No_history is defined, find it... // If defined, it means that when executing this edge, it shall not // be added to the history list of passed edgses. p = Pattern.compile( "(No_history)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { e.addUserDatum( NO_HISTORY, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found No_history for edge: " + label ); } // If condition used defined, find it... p = Pattern.compile( "(if: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); HashMap conditions = null; while ( m.find( ) ) { if ( conditions == null ) { conditions = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); conditions.put( variable, state ); _logger.debug( "Condition: " + variable + " = " + state ); } if ( conditions != null ) { e.addUserDatum( CONDITION_KEY, conditions, UserData.SHARED ); } // If state are defined, find them... HashMap states = null; p = Pattern.compile( "(state: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( states == null ) { states = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); states.put( variable, state ); _logger.debug( "State: " + variable + " = " + state ); } if ( states != null ) { e.addUserDatum( STATE_KEY, states, UserData.SHARED ); } // If string variables are defined, find them... HashMap variables = null; p = Pattern.compile( "(string: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); String variable = m.group( 3 ); variables.put( variableLabel, variable ); _logger.debug( "String variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(integer: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Integer variable = Integer.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Integer variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(float: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Float variable = Float.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Float variable: " + variableLabel + " = " + variable ); } if ( variables != null ) { e.addUserDatum( VARIABLE_KEY, variables, UserData.SHARED ); } } e.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); _logger.debug( "Adderade edge: \"" + e.getUserDatum( LABEL_KEY ) + "\"" ); } } } catch ( JDOMException e ) { _logger.error( e ); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } catch ( IOException e ) { e.printStackTrace(); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } }
private void parseFile( String fileName ) { try { _logger.info( "Parsing file: " + fileName ); _doc = _parser.build( fileName ); // Parse all vertices (nodes) Iterator iter = _doc.getDescendants( new ElementFilter( "node" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; if ( element.getAttributeValue( "yfiles.foldertype" ) != null ) { _logger.debug( "Excluded node: " + element.getAttributeValue( "yfiles.foldertype" ) ); continue; } _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "NodeLabel" ) ); while ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { Element nodeLabel = (Element)o2; _logger.debug( "Full name: " + nodeLabel.getQualifiedName() ); _logger.debug( "Name: " + nodeLabel.getTextTrim() ); DirectedSparseVertex v = (DirectedSparseVertex) _graph.addVertex( new DirectedSparseVertex() ); v.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); v.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); v.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); String str = nodeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label; if ( m.find( )) { label = m.group( 1 ); v.addUserDatum( LABEL_KEY, label, UserData.SHARED ); } else { throw new RuntimeException( "Label must be defined." ); } _logger.debug( "Added node: " + v.getUserDatum( LABEL_KEY ) ); // If no merge is defined, find it... // If defined, it means that when merging graphs, this specific vertex will not be merged. p = Pattern.compile( "(no merge)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { v.addUserDatum( NO_MERGE, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found no merge for edge: " + label ); } // NOTE: Only for html applications // In browsers, the usage of the 'Back'-button can be used. // If defined, with a value value, which depicts the probability for the edge // to be executed, tha back-button will be pressed in the browser. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(back=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find( ) ) { Float probability; String value = m.group( 2 ); try { probability = Float.valueOf( value.trim() ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", back is not a correct float value: " + error.toString() ); } v.addUserDatum( BACK_KEY, probability, UserData.SHARED ); } } } } } Object[] vertices = _graph.getVertices().toArray(); // Parse all edges (arrows or transtitions) iter = _doc.getDescendants( new ElementFilter( "edge" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "EdgeLabel" ) ); Element edgeLabel = null; if ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { edgeLabel = (Element)o2; _logger.debug( "Full name: " + edgeLabel.getQualifiedName() ); _logger.debug( "Name: " + edgeLabel.getTextTrim() ); } } _logger.debug( "source: " + element.getAttributeValue( "source" ) ); _logger.debug( "target: " + element.getAttributeValue( "target" ) ); DirectedSparseVertex source = null; DirectedSparseVertex dest = null; for ( int i = 0; i < vertices.length; i++ ) { DirectedSparseVertex vertex = (DirectedSparseVertex)vertices[ i ]; // Find source vertex if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "source" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { source = vertex; } if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "target" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { dest = vertex; } } if ( source == null ) { String msg = "Could not find starting node for edge. Name: " + element.getAttributeValue( "source" ); _logger.error( msg ); throw new RuntimeException( msg ); } if ( dest == null ) { String msg = "Could not find end node for edge. Name: " + element.getAttributeValue( "target" ); _logger.error( msg ); throw new RuntimeException( msg ); } DirectedSparseEdge e = new DirectedSparseEdge( source, dest ); _graph.addEdge( e ); e.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); e.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); if ( edgeLabel != null ) { String str = edgeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label = null; if ( m.find() ) { label = m.group( 1 ); e.addUserDatum( LABEL_KEY, label, UserData.SHARED ); _logger.debug( "Found label= " + label + " for edge id: " + edgeLabel.getQualifiedName() ); } else { throw new RuntimeException( "Label for edge must be defined." ); } // If weight is defined, find it... // weight must be associated with a value, which depicts the probability for the edge // to be executed. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(weight=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { Float weight; String value = m.group( 2 ); try { weight = Float.valueOf( value.trim() ); _logger.debug( "Found weight= " + weight + " for edge: " + label ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", weight is not a correct float value: " + error.toString() ); } e.addUserDatum( WEIGHT_KEY, weight, UserData.SHARED ); } // If No_history is defined, find it... // If defined, it means that when executing this edge, it shall not // be added to the history list of passed edgses. p = Pattern.compile( "(No_history)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { e.addUserDatum( NO_HISTORY, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found No_history for edge: " + label ); } // If condition used defined, find it... p = Pattern.compile( "(if: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); HashMap conditions = null; while ( m.find( ) ) { if ( conditions == null ) { conditions = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); conditions.put( variable, state ); _logger.debug( "Condition: " + variable + " = " + state ); } if ( conditions != null ) { e.addUserDatum( CONDITION_KEY, conditions, UserData.SHARED ); } // If state are defined, find them... HashMap states = null; p = Pattern.compile( "(state: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( states == null ) { states = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); states.put( variable, state ); _logger.debug( "State: " + variable + " = " + state ); } if ( states != null ) { e.addUserDatum( STATE_KEY, states, UserData.SHARED ); } // If string variables are defined, find them... HashMap variables = null; p = Pattern.compile( "(string: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); String variable = m.group( 3 ); variables.put( variableLabel, variable ); _logger.debug( "String variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(integer: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Integer variable = Integer.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Integer variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(float: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Float variable = Float.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Float variable: " + variableLabel + " = " + variable ); } if ( variables != null ) { e.addUserDatum( VARIABLE_KEY, variables, UserData.SHARED ); } } e.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); _logger.debug( "Adderade edge: \"" + e.getUserDatum( LABEL_KEY ) + "\"" ); } } } catch ( JDOMException e ) { _logger.error( e ); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } catch ( IOException e ) { e.printStackTrace(); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } }
3,241,220
private void parseFile( String fileName ) { try { _logger.info( "Parsing file: " + fileName ); _doc = _parser.build( fileName ); // Parse all vertices (nodes) Iterator iter = _doc.getDescendants( new ElementFilter( "node" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; if ( element.getAttributeValue( "yfiles.foldertype" ) != null ) { _logger.debug( "Excluded node: " + element.getAttributeValue( "yfiles.foldertype" ) ); continue; } _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "NodeLabel" ) ); while ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { Element nodeLabel = (Element)o2; _logger.debug( "Full name: " + nodeLabel.getQualifiedName() ); _logger.debug( "Name: " + nodeLabel.getTextTrim() ); DirectedSparseVertex v = (DirectedSparseVertex) _graph.addVertex( new DirectedSparseVertex() ); v.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); v.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); v.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); String str = nodeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label; if ( m.find( )) { label = m.group( 1 ); v.addUserDatum( LABEL_KEY, label, UserData.SHARED ); } else { throw new RuntimeException( "Label must be defined." ); } _logger.debug( "Added node: " + v.getUserDatum( LABEL_KEY ) ); // If no merge is defined, find it... // If defined, it means that when merging graphs, this specific vertex will not be merged. p = Pattern.compile( "(no merge)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { v.addUserDatum( NO_MERGE, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found no merge for edge: " + label ); } // NOTE: Only for html applications // In browsers, the usage of the 'Back'-button can be used. // If defined, with a value value, which depicts the probability for the edge // to be executed, tha back-button will be pressed in the browser. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(back=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find( ) ) { Float probability; String value = m.group( 2 ); try { probability = Float.valueOf( value.trim() ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", back is not a correct float value: " + error.toString() ); } v.addUserDatum( BACK_KEY, probability, UserData.SHARED ); } } } } } Object[] vertices = _graph.getVertices().toArray(); // Parse all edges (arrows or transtitions) iter = _doc.getDescendants( new ElementFilter( "edge" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "EdgeLabel" ) ); Element edgeLabel = null; if ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { edgeLabel = (Element)o2; _logger.debug( "Full name: " + edgeLabel.getQualifiedName() ); _logger.debug( "Name: " + edgeLabel.getTextTrim() ); } } _logger.debug( "source: " + element.getAttributeValue( "source" ) ); _logger.debug( "target: " + element.getAttributeValue( "target" ) ); DirectedSparseVertex source = null; DirectedSparseVertex dest = null; for ( int i = 0; i < vertices.length; i++ ) { DirectedSparseVertex vertex = (DirectedSparseVertex)vertices[ i ]; // Find source vertex if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "source" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { source = vertex; } if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "target" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { dest = vertex; } } if ( source == null ) { String msg = "Could not find starting node for edge. Name: " + element.getAttributeValue( "source" ); _logger.error( msg ); throw new RuntimeException( msg ); } if ( dest == null ) { String msg = "Could not find end node for edge. Name: " + element.getAttributeValue( "target" ); _logger.error( msg ); throw new RuntimeException( msg ); } DirectedSparseEdge e = new DirectedSparseEdge( source, dest ); _graph.addEdge( e ); e.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); e.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); if ( edgeLabel != null ) { String str = edgeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label = null; if ( m.find() ) { label = m.group( 1 ); e.addUserDatum( LABEL_KEY, label, UserData.SHARED ); _logger.debug( "Found label= " + label + " for edge id: " + edgeLabel.getQualifiedName() ); } else { throw new RuntimeException( "Label for edge must be defined." ); } // If weight is defined, find it... // weight must be associated with a value, which depicts the probability for the edge // to be executed. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(weight=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { Float weight; String value = m.group( 2 ); try { weight = Float.valueOf( value.trim() ); _logger.debug( "Found weight= " + weight + " for edge: " + label ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", weight is not a correct float value: " + error.toString() ); } e.addUserDatum( WEIGHT_KEY, weight, UserData.SHARED ); } // If No_history is defined, find it... // If defined, it means that when executing this edge, it shall not // be added to the history list of passed edgses. p = Pattern.compile( "(No_history)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { e.addUserDatum( NO_HISTORY, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found No_history for edge: " + label ); } // If condition used defined, find it... p = Pattern.compile( "(if: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); HashMap conditions = null; while ( m.find( ) ) { if ( conditions == null ) { conditions = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); conditions.put( variable, state ); _logger.debug( "Condition: " + variable + " = " + state ); } if ( conditions != null ) { e.addUserDatum( CONDITION_KEY, conditions, UserData.SHARED ); } // If state are defined, find them... HashMap states = null; p = Pattern.compile( "(state: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( states == null ) { states = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); states.put( variable, state ); _logger.debug( "State: " + variable + " = " + state ); } if ( states != null ) { e.addUserDatum( STATE_KEY, states, UserData.SHARED ); } // If string variables are defined, find them... HashMap variables = null; p = Pattern.compile( "(string: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); String variable = m.group( 3 ); variables.put( variableLabel, variable ); _logger.debug( "String variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(integer: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Integer variable = Integer.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Integer variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(float: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Float variable = Float.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Float variable: " + variableLabel + " = " + variable ); } if ( variables != null ) { e.addUserDatum( VARIABLE_KEY, variables, UserData.SHARED ); } } e.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); _logger.debug( "Adderade edge: \"" + e.getUserDatum( LABEL_KEY ) + "\"" ); } } } catch ( JDOMException e ) { _logger.error( e ); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } catch ( IOException e ) { e.printStackTrace(); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } }
private void parseFile( String fileName ) { try { _logger.info( "Parsing file: " + fileName ); _doc = _parser.build( fileName ); // Parse all vertices (nodes) Iterator iter = _doc.getDescendants( new ElementFilter( "node" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; if ( element.getAttributeValue( "yfiles.foldertype" ) != null ) { _logger.debug( "Excluded node: " + element.getAttributeValue( "yfiles.foldertype" ) ); continue; } _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "NodeLabel" ) ); while ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { Element nodeLabel = (Element)o2; _logger.debug( "Full name: " + nodeLabel.getQualifiedName() ); _logger.debug( "Name: " + nodeLabel.getTextTrim() ); DirectedSparseVertex v = (DirectedSparseVertex) _graph.addVertex( new DirectedSparseVertex() ); v.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); v.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); v.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); String str = nodeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label; if ( m.find( )) { label = m.group( 1 ); v.addUserDatum( LABEL_KEY, label, UserData.SHARED ); } else { throw new RuntimeException( "Label must be defined." ); } _logger.debug( "Added node: " + v.getUserDatum( LABEL_KEY ) ); // If no merge is defined, find it... // If defined, it means that when merging graphs, this specific vertex will not be merged. p = Pattern.compile( "(no merge)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { v.addUserDatum( NO_MERGE, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found no merge for edge: " + label ); } // NOTE: Only for html applications // In browsers, the usage of the 'Back'-button can be used. // If defined, with a value value, which depicts the probability for the edge // to be executed, tha back-button will be pressed in the browser. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(back=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find( ) ) { Float probability; String value = m.group( 2 ); try { probability = Float.valueOf( value.trim() ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", back is not a correct float value: " + error.toString() ); } v.addUserDatum( BACK_KEY, probability, UserData.SHARED ); } } } } } Object[] vertices = _graph.getVertices().toArray(); // Parse all edges (arrows or transtitions) iter = _doc.getDescendants( new ElementFilter( "edge" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "EdgeLabel" ) ); Element edgeLabel = null; if ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { edgeLabel = (Element)o2; _logger.debug( "Full name: " + edgeLabel.getQualifiedName() ); _logger.debug( "Name: " + edgeLabel.getTextTrim() ); } } _logger.debug( "source: " + element.getAttributeValue( "source" ) ); _logger.debug( "target: " + element.getAttributeValue( "target" ) ); DirectedSparseVertex source = null; DirectedSparseVertex dest = null; for ( int i = 0; i < vertices.length; i++ ) { DirectedSparseVertex vertex = (DirectedSparseVertex)vertices[ i ]; // Find source vertex if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "source" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { source = vertex; } if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "target" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { dest = vertex; } } if ( source == null ) { String msg = "Could not find starting node for edge. Name: " + element.getAttributeValue( "source" ); _logger.error( msg ); throw new RuntimeException( msg ); } if ( dest == null ) { String msg = "Could not find end node for edge. Name: " + element.getAttributeValue( "target" ); _logger.error( msg ); throw new RuntimeException( msg ); } DirectedSparseEdge e = new DirectedSparseEdge( source, dest ); _graph.addEdge( e ); e.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); e.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); if ( edgeLabel != null ) { String str = edgeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label = null; if ( m.find() ) { label = m.group( 1 ); e.addUserDatum( LABEL_KEY, label, UserData.SHARED ); _logger.debug( "Found label= " + label + " for edge id: " + edgeLabel.getQualifiedName() ); } else { throw new RuntimeException( "Label for edge must be defined." ); } // If weight is defined, find it... // weight must be associated with a value, which depicts the probability for the edge // to be executed. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(weight=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { Float weight; String value = m.group( 2 ); try { weight = Float.valueOf( value.trim() ); _logger.debug( "Found weight= " + weight + " for edge: " + label ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", weight is not a correct float value: " + error.toString() ); } e.addUserDatum( WEIGHT_KEY, weight, UserData.SHARED ); } // If No_history is defined, find it... // If defined, it means that when executing this edge, it shall not // be added to the history list of passed edgses. p = Pattern.compile( "(No_history)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { e.addUserDatum( NO_HISTORY, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found No_history for edge: " + label ); } // If condition used defined, find it... p = Pattern.compile( "(if: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); HashMap conditions = null; while ( m.find( ) ) { if ( conditions == null ) { conditions = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); conditions.put( variable, state ); _logger.debug( "Condition: " + variable + " = " + state ); } if ( conditions != null ) { e.addUserDatum( CONDITION_KEY, conditions, UserData.SHARED ); } // If state are defined, find them... HashMap states = null; p = Pattern.compile( "(state: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( states == null ) { states = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); states.put( variable, state ); _logger.debug( "State: " + variable + " = " + state ); } if ( states != null ) { e.addUserDatum( STATE_KEY, states, UserData.SHARED ); } // If string variables are defined, find them... HashMap variables = null; p = Pattern.compile( "(string: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); String variable = m.group( 3 ); variables.put( variableLabel, variable ); _logger.debug( "String variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(integer: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Integer variable = Integer.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Integer variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(float: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Float variable = Float.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Float variable: " + variableLabel + " = " + variable ); } if ( variables != null ) { e.addUserDatum( VARIABLE_KEY, variables, UserData.SHARED ); } } e.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); _logger.debug( "Adderade edge: \"" + e.getUserDatum( LABEL_KEY ) + "\"" ); } } } catch ( JDOMException e ) { _logger.error( e ); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } catch ( IOException e ) { e.printStackTrace(); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } }
3,241,221
private void parseFile( String fileName ) { try { _logger.info( "Parsing file: " + fileName ); _doc = _parser.build( fileName ); // Parse all vertices (nodes) Iterator iter = _doc.getDescendants( new ElementFilter( "node" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; if ( element.getAttributeValue( "yfiles.foldertype" ) != null ) { _logger.debug( "Excluded node: " + element.getAttributeValue( "yfiles.foldertype" ) ); continue; } _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "NodeLabel" ) ); while ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { Element nodeLabel = (Element)o2; _logger.debug( "Full name: " + nodeLabel.getQualifiedName() ); _logger.debug( "Name: " + nodeLabel.getTextTrim() ); DirectedSparseVertex v = (DirectedSparseVertex) _graph.addVertex( new DirectedSparseVertex() ); v.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); v.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); v.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); String str = nodeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label; if ( m.find( )) { label = m.group( 1 ); v.addUserDatum( LABEL_KEY, label, UserData.SHARED ); } else { throw new RuntimeException( "Label must be defined." ); } _logger.debug( "Added node: " + v.getUserDatum( LABEL_KEY ) ); // If no merge is defined, find it... // If defined, it means that when merging graphs, this specific vertex will not be merged. p = Pattern.compile( "(no merge)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { v.addUserDatum( NO_MERGE, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found no merge for edge: " + label ); } // NOTE: Only for html applications // In browsers, the usage of the 'Back'-button can be used. // If defined, with a value value, which depicts the probability for the edge // to be executed, tha back-button will be pressed in the browser. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(back=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find( ) ) { Float probability; String value = m.group( 2 ); try { probability = Float.valueOf( value.trim() ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", back is not a correct float value: " + error.toString() ); } v.addUserDatum( BACK_KEY, probability, UserData.SHARED ); } } } } } Object[] vertices = _graph.getVertices().toArray(); // Parse all edges (arrows or transtitions) iter = _doc.getDescendants( new ElementFilter( "edge" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "EdgeLabel" ) ); Element edgeLabel = null; if ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { edgeLabel = (Element)o2; _logger.debug( "Full name: " + edgeLabel.getQualifiedName() ); _logger.debug( "Name: " + edgeLabel.getTextTrim() ); } } _logger.debug( "source: " + element.getAttributeValue( "source" ) ); _logger.debug( "target: " + element.getAttributeValue( "target" ) ); DirectedSparseVertex source = null; DirectedSparseVertex dest = null; for ( int i = 0; i < vertices.length; i++ ) { DirectedSparseVertex vertex = (DirectedSparseVertex)vertices[ i ]; // Find source vertex if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "source" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { source = vertex; } if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "target" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { dest = vertex; } } if ( source == null ) { String msg = "Could not find starting node for edge. Name: " + element.getAttributeValue( "source" ); _logger.error( msg ); throw new RuntimeException( msg ); } if ( dest == null ) { String msg = "Could not find end node for edge. Name: " + element.getAttributeValue( "target" ); _logger.error( msg ); throw new RuntimeException( msg ); } DirectedSparseEdge e = new DirectedSparseEdge( source, dest ); _graph.addEdge( e ); e.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); e.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); if ( edgeLabel != null ) { String str = edgeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label = null; if ( m.find() ) { label = m.group( 1 ); e.addUserDatum( LABEL_KEY, label, UserData.SHARED ); _logger.debug( "Found label= " + label + " for edge id: " + edgeLabel.getQualifiedName() ); } else { throw new RuntimeException( "Label for edge must be defined." ); } // If weight is defined, find it... // weight must be associated with a value, which depicts the probability for the edge // to be executed. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(weight=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { Float weight; String value = m.group( 2 ); try { weight = Float.valueOf( value.trim() ); _logger.debug( "Found weight= " + weight + " for edge: " + label ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", weight is not a correct float value: " + error.toString() ); } e.addUserDatum( WEIGHT_KEY, weight, UserData.SHARED ); } // If No_history is defined, find it... // If defined, it means that when executing this edge, it shall not // be added to the history list of passed edgses. p = Pattern.compile( "(No_history)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { e.addUserDatum( NO_HISTORY, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found No_history for edge: " + label ); } // If condition used defined, find it... p = Pattern.compile( "(if: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); HashMap conditions = null; while ( m.find( ) ) { if ( conditions == null ) { conditions = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); conditions.put( variable, state ); _logger.debug( "Condition: " + variable + " = " + state ); } if ( conditions != null ) { e.addUserDatum( CONDITION_KEY, conditions, UserData.SHARED ); } // If state are defined, find them... HashMap states = null; p = Pattern.compile( "(state: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( states == null ) { states = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); states.put( variable, state ); _logger.debug( "State: " + variable + " = " + state ); } if ( states != null ) { e.addUserDatum( STATE_KEY, states, UserData.SHARED ); } // If string variables are defined, find them... HashMap variables = null; p = Pattern.compile( "(string: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); String variable = m.group( 3 ); variables.put( variableLabel, variable ); _logger.debug( "String variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(integer: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Integer variable = Integer.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Integer variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(float: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Float variable = Float.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Float variable: " + variableLabel + " = " + variable ); } if ( variables != null ) { e.addUserDatum( VARIABLE_KEY, variables, UserData.SHARED ); } } e.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); _logger.debug( "Adderade edge: \"" + e.getUserDatum( LABEL_KEY ) + "\"" ); } } } catch ( JDOMException e ) { _logger.error( e ); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } catch ( IOException e ) { e.printStackTrace(); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } }
private void parseFile( String fileName ) { try { _logger.info( "Parsing file: " + fileName ); _doc = _parser.build( fileName ); // Parse all vertices (nodes) Iterator iter = _doc.getDescendants( new ElementFilter( "node" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; if ( element.getAttributeValue( "yfiles.foldertype" ) != null ) { _logger.debug( "Excluded node: " + element.getAttributeValue( "yfiles.foldertype" ) ); continue; } _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "NodeLabel" ) ); while ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { Element nodeLabel = (Element)o2; _logger.debug( "Full name: " + nodeLabel.getQualifiedName() ); _logger.debug( "Name: " + nodeLabel.getTextTrim() ); DirectedSparseVertex v = (DirectedSparseVertex) _graph.addVertex( new DirectedSparseVertex() ); v.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); v.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); v.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); String str = nodeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label; if ( m.find( )) { label = m.group( 1 ); v.addUserDatum( LABEL_KEY, label, UserData.SHARED ); } else { throw new RuntimeException( "Label must be defined." ); } _logger.debug( "Added node: " + v.getUserDatum( LABEL_KEY ) ); // If no merge is defined, find it... // If defined, it means that when merging graphs, this specific vertex will not be merged. p = Pattern.compile( "(no merge)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { v.addUserDatum( NO_MERGE, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found no merge for edge: " + label ); } // NOTE: Only for html applications // In browsers, the usage of the 'Back'-button can be used. // If defined, with a value value, which depicts the probability for the edge // to be executed, tha back-button will be pressed in the browser. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(back=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find( ) ) { Float probability; String value = m.group( 2 ); try { probability = Float.valueOf( value.trim() ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", back is not a correct float value: " + error.toString() ); } v.addUserDatum( BACK_KEY, probability, UserData.SHARED ); } } } } } Object[] vertices = _graph.getVertices().toArray(); // Parse all edges (arrows or transtitions) iter = _doc.getDescendants( new ElementFilter( "edge" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "EdgeLabel" ) ); Element edgeLabel = null; if ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { edgeLabel = (Element)o2; _logger.debug( "Full name: " + edgeLabel.getQualifiedName() ); _logger.debug( "Name: " + edgeLabel.getTextTrim() ); } } _logger.debug( "source: " + element.getAttributeValue( "source" ) ); _logger.debug( "target: " + element.getAttributeValue( "target" ) ); DirectedSparseVertex source = null; DirectedSparseVertex dest = null; for ( int i = 0; i < vertices.length; i++ ) { DirectedSparseVertex vertex = (DirectedSparseVertex)vertices[ i ]; // Find source vertex if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "source" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { source = vertex; } if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "target" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { dest = vertex; } } if ( source == null ) { String msg = "Could not find starting node for edge. Name: " + element.getAttributeValue( "source" ); _logger.error( msg ); throw new RuntimeException( msg ); } if ( dest == null ) { String msg = "Could not find end node for edge. Name: " + element.getAttributeValue( "target" ); _logger.error( msg ); throw new RuntimeException( msg ); } DirectedSparseEdge e = new DirectedSparseEdge( source, dest ); _graph.addEdge( e ); e.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); e.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); if ( edgeLabel != null ) { String str = edgeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label = null; if ( m.find() ) { label = m.group( 1 ); e.addUserDatum( LABEL_KEY, label, UserData.SHARED ); _logger.debug( "Found label= " + label + " for edge id: " + edgeLabel.getQualifiedName() ); } else { throw new RuntimeException( "Label for edge must be defined." ); } // If weight is defined, find it... // weight must be associated with a value, which depicts the probability for the edge // to be executed. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(weight=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { Float weight; String value = m.group( 2 ); try { weight = Float.valueOf( value.trim() ); _logger.debug( "Found weight= " + weight + " for edge: " + label ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", weight is not a correct float value: " + error.toString() ); } e.addUserDatum( WEIGHT_KEY, weight, UserData.SHARED ); } // If No_history is defined, find it... // If defined, it means that when executing this edge, it shall not // be added to the history list of passed edgses. p = Pattern.compile( "(No_history)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { e.addUserDatum( NO_HISTORY, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found No_history for edge: " + label ); } // If condition used defined, find it... p = Pattern.compile( "(if: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); HashMap conditions = null; while ( m.find( ) ) { if ( conditions == null ) { conditions = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); conditions.put( variable, state ); _logger.debug( "Condition: " + variable + " = " + state ); } if ( conditions != null ) { e.addUserDatum( CONDITION_KEY, conditions, UserData.SHARED ); } // If state are defined, find them... HashMap states = null; p = Pattern.compile( "(state: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( states == null ) { states = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); states.put( variable, state ); _logger.debug( "State: " + variable + " = " + state ); } if ( states != null ) { e.addUserDatum( STATE_KEY, states, UserData.SHARED ); } // If string variables are defined, find them... HashMap variables = null; p = Pattern.compile( "(string: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); String variable = m.group( 3 ); variables.put( variableLabel, variable ); _logger.debug( "String variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(integer: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Integer variable = Integer.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Integer variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(float: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Float variable = Float.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Float variable: " + variableLabel + " = " + variable ); } if ( variables != null ) { e.addUserDatum( VARIABLE_KEY, variables, UserData.SHARED ); } } e.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); _logger.debug( "Adderade edge: \"" + e.getUserDatum( LABEL_KEY ) + "\"" ); } } } catch ( JDOMException e ) { _logger.error( e ); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } catch ( IOException e ) { e.printStackTrace(); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } }
3,241,222
private void parseFile( String fileName ) { try { _logger.info( "Parsing file: " + fileName ); _doc = _parser.build( fileName ); // Parse all vertices (nodes) Iterator iter = _doc.getDescendants( new ElementFilter( "node" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; if ( element.getAttributeValue( "yfiles.foldertype" ) != null ) { _logger.debug( "Excluded node: " + element.getAttributeValue( "yfiles.foldertype" ) ); continue; } _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "NodeLabel" ) ); while ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { Element nodeLabel = (Element)o2; _logger.debug( "Full name: " + nodeLabel.getQualifiedName() ); _logger.debug( "Name: " + nodeLabel.getTextTrim() ); DirectedSparseVertex v = (DirectedSparseVertex) _graph.addVertex( new DirectedSparseVertex() ); v.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); v.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); v.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); String str = nodeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label; if ( m.find( )) { label = m.group( 1 ); v.addUserDatum( LABEL_KEY, label, UserData.SHARED ); } else { throw new RuntimeException( "Label must be defined." ); } _logger.debug( "Added node: " + v.getUserDatum( LABEL_KEY ) ); // If no merge is defined, find it... // If defined, it means that when merging graphs, this specific vertex will not be merged. p = Pattern.compile( "(no merge)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { v.addUserDatum( NO_MERGE, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found no merge for edge: " + label ); } // NOTE: Only for html applications // In browsers, the usage of the 'Back'-button can be used. // If defined, with a value value, which depicts the probability for the edge // to be executed, tha back-button will be pressed in the browser. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(back=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find( ) ) { Float probability; String value = m.group( 2 ); try { probability = Float.valueOf( value.trim() ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", back is not a correct float value: " + error.toString() ); } v.addUserDatum( BACK_KEY, probability, UserData.SHARED ); } } } } } Object[] vertices = _graph.getVertices().toArray(); // Parse all edges (arrows or transtitions) iter = _doc.getDescendants( new ElementFilter( "edge" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "EdgeLabel" ) ); Element edgeLabel = null; if ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { edgeLabel = (Element)o2; _logger.debug( "Full name: " + edgeLabel.getQualifiedName() ); _logger.debug( "Name: " + edgeLabel.getTextTrim() ); } } _logger.debug( "source: " + element.getAttributeValue( "source" ) ); _logger.debug( "target: " + element.getAttributeValue( "target" ) ); DirectedSparseVertex source = null; DirectedSparseVertex dest = null; for ( int i = 0; i < vertices.length; i++ ) { DirectedSparseVertex vertex = (DirectedSparseVertex)vertices[ i ]; // Find source vertex if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "source" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { source = vertex; } if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "target" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { dest = vertex; } } if ( source == null ) { String msg = "Could not find starting node for edge. Name: " + element.getAttributeValue( "source" ); _logger.error( msg ); throw new RuntimeException( msg ); } if ( dest == null ) { String msg = "Could not find end node for edge. Name: " + element.getAttributeValue( "target" ); _logger.error( msg ); throw new RuntimeException( msg ); } DirectedSparseEdge e = new DirectedSparseEdge( source, dest ); _graph.addEdge( e ); e.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); e.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); if ( edgeLabel != null ) { String str = edgeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label = null; if ( m.find() ) { label = m.group( 1 ); e.addUserDatum( LABEL_KEY, label, UserData.SHARED ); _logger.debug( "Found label= " + label + " for edge id: " + edgeLabel.getQualifiedName() ); } else { throw new RuntimeException( "Label for edge must be defined." ); } // If weight is defined, find it... // weight must be associated with a value, which depicts the probability for the edge // to be executed. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(weight=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { Float weight; String value = m.group( 2 ); try { weight = Float.valueOf( value.trim() ); _logger.debug( "Found weight= " + weight + " for edge: " + label ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", weight is not a correct float value: " + error.toString() ); } e.addUserDatum( WEIGHT_KEY, weight, UserData.SHARED ); } // If No_history is defined, find it... // If defined, it means that when executing this edge, it shall not // be added to the history list of passed edgses. p = Pattern.compile( "(No_history)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { e.addUserDatum( NO_HISTORY, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found No_history for edge: " + label ); } // If condition used defined, find it... p = Pattern.compile( "(if: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); HashMap conditions = null; while ( m.find( ) ) { if ( conditions == null ) { conditions = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); conditions.put( variable, state ); _logger.debug( "Condition: " + variable + " = " + state ); } if ( conditions != null ) { e.addUserDatum( CONDITION_KEY, conditions, UserData.SHARED ); } // If state are defined, find them... HashMap states = null; p = Pattern.compile( "(state: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( states == null ) { states = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); states.put( variable, state ); _logger.debug( "State: " + variable + " = " + state ); } if ( states != null ) { e.addUserDatum( STATE_KEY, states, UserData.SHARED ); } // If string variables are defined, find them... HashMap variables = null; p = Pattern.compile( "(string: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); String variable = m.group( 3 ); variables.put( variableLabel, variable ); _logger.debug( "String variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(integer: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Integer variable = Integer.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Integer variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(float: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Float variable = Float.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Float variable: " + variableLabel + " = " + variable ); } if ( variables != null ) { e.addUserDatum( VARIABLE_KEY, variables, UserData.SHARED ); } } e.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); _logger.debug( "Adderade edge: \"" + e.getUserDatum( LABEL_KEY ) + "\"" ); } } } catch ( JDOMException e ) { _logger.error( e ); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } catch ( IOException e ) { e.printStackTrace(); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } }
private void parseFile( String fileName ) { try { _logger.info( "Parsing file: " + fileName ); _doc = _parser.build( fileName ); // Parse all vertices (nodes) Iterator iter = _doc.getDescendants( new ElementFilter( "node" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; if ( element.getAttributeValue( "yfiles.foldertype" ) != null ) { _logger.debug( "Excluded node: " + element.getAttributeValue( "yfiles.foldertype" ) ); continue; } _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "NodeLabel" ) ); while ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { Element nodeLabel = (Element)o2; _logger.debug( "Full name: " + nodeLabel.getQualifiedName() ); _logger.debug( "Name: " + nodeLabel.getTextTrim() ); DirectedSparseVertex v = (DirectedSparseVertex) _graph.addVertex( new DirectedSparseVertex() ); v.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); v.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); v.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); String str = nodeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label; if ( m.find( )) { label = m.group( 1 ); v.addUserDatum( LABEL_KEY, label, UserData.SHARED ); } else { throw new RuntimeException( "Label must be defined." ); } _logger.debug( "Added node: " + v.getUserDatum( LABEL_KEY ) ); // If no merge is defined, find it... // If defined, it means that when merging graphs, this specific vertex will not be merged. p = Pattern.compile( "(no merge)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { v.addUserDatum( NO_MERGE, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found no merge for edge: " + label ); } // NOTE: Only for html applications // In browsers, the usage of the 'Back'-button can be used. // If defined, with a value value, which depicts the probability for the edge // to be executed, tha back-button will be pressed in the browser. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(back=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find( ) ) { Float probability; String value = m.group( 2 ); try { probability = Float.valueOf( value.trim() ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", back is not a correct float value: " + error.toString() ); } v.addUserDatum( BACK_KEY, probability, UserData.SHARED ); } } } } } Object[] vertices = _graph.getVertices().toArray(); // Parse all edges (arrows or transtitions) iter = _doc.getDescendants( new ElementFilter( "edge" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "EdgeLabel" ) ); Element edgeLabel = null; if ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { edgeLabel = (Element)o2; _logger.debug( "Full name: " + edgeLabel.getQualifiedName() ); _logger.debug( "Name: " + edgeLabel.getTextTrim() ); } } _logger.debug( "source: " + element.getAttributeValue( "source" ) ); _logger.debug( "target: " + element.getAttributeValue( "target" ) ); DirectedSparseVertex source = null; DirectedSparseVertex dest = null; for ( int i = 0; i < vertices.length; i++ ) { DirectedSparseVertex vertex = (DirectedSparseVertex)vertices[ i ]; // Find source vertex if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "source" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { source = vertex; } if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "target" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { dest = vertex; } } if ( source == null ) { String msg = "Could not find starting node for edge. Name: " + element.getAttributeValue( "source" ); _logger.error( msg ); throw new RuntimeException( msg ); } if ( dest == null ) { String msg = "Could not find end node for edge. Name: " + element.getAttributeValue( "target" ); _logger.error( msg ); throw new RuntimeException( msg ); } DirectedSparseEdge e = new DirectedSparseEdge( source, dest ); _graph.addEdge( e ); e.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); e.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); if ( edgeLabel != null ) { String str = edgeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label = null; if ( m.find() ) { label = m.group( 1 ); e.addUserDatum( LABEL_KEY, label, UserData.SHARED ); _logger.debug( "Found label= " + label + " for edge id: " + edgeLabel.getQualifiedName() ); } else { throw new RuntimeException( "Label for edge must be defined." ); } // If weight is defined, find it... // weight must be associated with a value, which depicts the probability for the edge // to be executed. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(weight=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { Float weight; String value = m.group( 2 ); try { weight = Float.valueOf( value.trim() ); _logger.debug( "Found weight= " + weight + " for edge: " + label ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", weight is not a correct float value: " + error.toString() ); } e.addUserDatum( WEIGHT_KEY, weight, UserData.SHARED ); } // If No_history is defined, find it... // If defined, it means that when executing this edge, it shall not // be added to the history list of passed edgses. p = Pattern.compile( "(No_history)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { e.addUserDatum( NO_HISTORY, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found No_history for edge: " + label ); } // If condition used defined, find it... p = Pattern.compile( "(if: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); HashMap conditions = null; while ( m.find( ) ) { if ( conditions == null ) { conditions = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); conditions.put( variable, state ); _logger.debug( "Condition: " + variable + " = " + state ); } if ( conditions != null ) { e.addUserDatum( CONDITION_KEY, conditions, UserData.SHARED ); } // If state are defined, find them... HashMap states = null; p = Pattern.compile( "(state: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( states == null ) { states = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); states.put( variable, state ); _logger.debug( "State: " + variable + " = " + state ); } if ( states != null ) { e.addUserDatum( STATE_KEY, states, UserData.SHARED ); } // If string variables are defined, find them... HashMap variables = null; p = Pattern.compile( "(string: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); String variable = m.group( 3 ); variables.put( variableLabel, variable ); _logger.debug( "String variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(integer: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Integer variable = Integer.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Integer variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(float: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Float variable = Float.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Float variable: " + variableLabel + " = " + variable ); } if ( variables != null ) { e.addUserDatum( VARIABLE_KEY, variables, UserData.SHARED ); } } e.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); _logger.debug( "Adderade edge: \"" + e.getUserDatum( LABEL_KEY ) + "\"" ); } } } catch ( JDOMException e ) { _logger.error( e ); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } catch ( IOException e ) { e.printStackTrace(); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } }
3,241,223
private void parseFile( String fileName ) { try { _logger.info( "Parsing file: " + fileName ); _doc = _parser.build( fileName ); // Parse all vertices (nodes) Iterator iter = _doc.getDescendants( new ElementFilter( "node" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; if ( element.getAttributeValue( "yfiles.foldertype" ) != null ) { _logger.debug( "Excluded node: " + element.getAttributeValue( "yfiles.foldertype" ) ); continue; } _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "NodeLabel" ) ); while ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { Element nodeLabel = (Element)o2; _logger.debug( "Full name: " + nodeLabel.getQualifiedName() ); _logger.debug( "Name: " + nodeLabel.getTextTrim() ); DirectedSparseVertex v = (DirectedSparseVertex) _graph.addVertex( new DirectedSparseVertex() ); v.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); v.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); v.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); String str = nodeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label; if ( m.find( )) { label = m.group( 1 ); v.addUserDatum( LABEL_KEY, label, UserData.SHARED ); } else { throw new RuntimeException( "Label must be defined." ); } _logger.debug( "Added node: " + v.getUserDatum( LABEL_KEY ) ); // If no merge is defined, find it... // If defined, it means that when merging graphs, this specific vertex will not be merged. p = Pattern.compile( "(no merge)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { v.addUserDatum( NO_MERGE, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found no merge for edge: " + label ); } // NOTE: Only for html applications // In browsers, the usage of the 'Back'-button can be used. // If defined, with a value value, which depicts the probability for the edge // to be executed, tha back-button will be pressed in the browser. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(back=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find( ) ) { Float probability; String value = m.group( 2 ); try { probability = Float.valueOf( value.trim() ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", back is not a correct float value: " + error.toString() ); } v.addUserDatum( BACK_KEY, probability, UserData.SHARED ); } } } } } Object[] vertices = _graph.getVertices().toArray(); // Parse all edges (arrows or transtitions) iter = _doc.getDescendants( new ElementFilter( "edge" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "EdgeLabel" ) ); Element edgeLabel = null; if ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { edgeLabel = (Element)o2; _logger.debug( "Full name: " + edgeLabel.getQualifiedName() ); _logger.debug( "Name: " + edgeLabel.getTextTrim() ); } } _logger.debug( "source: " + element.getAttributeValue( "source" ) ); _logger.debug( "target: " + element.getAttributeValue( "target" ) ); DirectedSparseVertex source = null; DirectedSparseVertex dest = null; for ( int i = 0; i < vertices.length; i++ ) { DirectedSparseVertex vertex = (DirectedSparseVertex)vertices[ i ]; // Find source vertex if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "source" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { source = vertex; } if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "target" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { dest = vertex; } } if ( source == null ) { String msg = "Could not find starting node for edge. Name: " + element.getAttributeValue( "source" ); _logger.error( msg ); throw new RuntimeException( msg ); } if ( dest == null ) { String msg = "Could not find end node for edge. Name: " + element.getAttributeValue( "target" ); _logger.error( msg ); throw new RuntimeException( msg ); } DirectedSparseEdge e = new DirectedSparseEdge( source, dest ); _graph.addEdge( e ); e.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); e.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); if ( edgeLabel != null ) { String str = edgeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label = null; if ( m.find() ) { label = m.group( 1 ); e.addUserDatum( LABEL_KEY, label, UserData.SHARED ); _logger.debug( "Found label= " + label + " for edge id: " + edgeLabel.getQualifiedName() ); } else { throw new RuntimeException( "Label for edge must be defined." ); } // If weight is defined, find it... // weight must be associated with a value, which depicts the probability for the edge // to be executed. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(weight=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { Float weight; String value = m.group( 2 ); try { weight = Float.valueOf( value.trim() ); _logger.debug( "Found weight= " + weight + " for edge: " + label ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", weight is not a correct float value: " + error.toString() ); } e.addUserDatum( WEIGHT_KEY, weight, UserData.SHARED ); } // If No_history is defined, find it... // If defined, it means that when executing this edge, it shall not // be added to the history list of passed edgses. p = Pattern.compile( "(No_history)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { e.addUserDatum( NO_HISTORY, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found No_history for edge: " + label ); } // If condition used defined, find it... p = Pattern.compile( "(if: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); HashMap conditions = null; while ( m.find( ) ) { if ( conditions == null ) { conditions = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); conditions.put( variable, state ); _logger.debug( "Condition: " + variable + " = " + state ); } if ( conditions != null ) { e.addUserDatum( CONDITION_KEY, conditions, UserData.SHARED ); } // If state are defined, find them... HashMap states = null; p = Pattern.compile( "(state: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( states == null ) { states = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); states.put( variable, state ); _logger.debug( "State: " + variable + " = " + state ); } if ( states != null ) { e.addUserDatum( STATE_KEY, states, UserData.SHARED ); } // If string variables are defined, find them... HashMap variables = null; p = Pattern.compile( "(string: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); String variable = m.group( 3 ); variables.put( variableLabel, variable ); _logger.debug( "String variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(integer: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Integer variable = Integer.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Integer variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(float: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Float variable = Float.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Float variable: " + variableLabel + " = " + variable ); } if ( variables != null ) { e.addUserDatum( VARIABLE_KEY, variables, UserData.SHARED ); } } e.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); _logger.debug( "Adderade edge: \"" + e.getUserDatum( LABEL_KEY ) + "\"" ); } } } catch ( JDOMException e ) { _logger.error( e ); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } catch ( IOException e ) { e.printStackTrace(); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } }
private void parseFile( String fileName ) { try { _logger.info( "Parsing file: " + fileName ); _doc = _parser.build( fileName ); // Parse all vertices (nodes) Iterator iter = _doc.getDescendants( new ElementFilter( "node" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; if ( element.getAttributeValue( "yfiles.foldertype" ) != null ) { _logger.debug( "Excluded node: " + element.getAttributeValue( "yfiles.foldertype" ) ); continue; } _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "NodeLabel" ) ); while ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { Element nodeLabel = (Element)o2; _logger.debug( "Full name: " + nodeLabel.getQualifiedName() ); _logger.debug( "Name: " + nodeLabel.getTextTrim() ); DirectedSparseVertex v = (DirectedSparseVertex) _graph.addVertex( new DirectedSparseVertex() ); v.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); v.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); v.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); String str = nodeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label; if ( m.find( )) { label = m.group( 1 ); v.addUserDatum( LABEL_KEY, label, UserData.SHARED ); } else { throw new RuntimeException( "Label must be defined." ); } _logger.debug( "Added node: " + v.getUserDatum( LABEL_KEY ) ); // If no merge is defined, find it... // If defined, it means that when merging graphs, this specific vertex will not be merged. p = Pattern.compile( "(no merge)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { v.addUserDatum( NO_MERGE, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found no merge for edge: " + label ); } // NOTE: Only for html applications // In browsers, the usage of the 'Back'-button can be used. // If defined, with a value value, which depicts the probability for the edge // to be executed, tha back-button will be pressed in the browser. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(back=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find( ) ) { Float probability; String value = m.group( 2 ); try { probability = Float.valueOf( value.trim() ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", back is not a correct float value: " + error.toString() ); } v.addUserDatum( BACK_KEY, probability, UserData.SHARED ); } } } } } Object[] vertices = _graph.getVertices().toArray(); // Parse all edges (arrows or transtitions) iter = _doc.getDescendants( new ElementFilter( "edge" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "EdgeLabel" ) ); Element edgeLabel = null; if ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { edgeLabel = (Element)o2; _logger.debug( "Full name: " + edgeLabel.getQualifiedName() ); _logger.debug( "Name: " + edgeLabel.getTextTrim() ); } } _logger.debug( "source: " + element.getAttributeValue( "source" ) ); _logger.debug( "target: " + element.getAttributeValue( "target" ) ); DirectedSparseVertex source = null; DirectedSparseVertex dest = null; for ( int i = 0; i < vertices.length; i++ ) { DirectedSparseVertex vertex = (DirectedSparseVertex)vertices[ i ]; // Find source vertex if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "source" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { source = vertex; } if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "target" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { dest = vertex; } } if ( source == null ) { String msg = "Could not find starting node for edge. Name: " + element.getAttributeValue( "source" ); _logger.error( msg ); throw new RuntimeException( msg ); } if ( dest == null ) { String msg = "Could not find end node for edge. Name: " + element.getAttributeValue( "target" ); _logger.error( msg ); throw new RuntimeException( msg ); } DirectedSparseEdge e = new DirectedSparseEdge( source, dest ); _graph.addEdge( e ); e.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); e.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); if ( edgeLabel != null ) { String str = edgeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label = null; if ( m.find() ) { label = m.group( 1 ); e.addUserDatum( LABEL_KEY, label, UserData.SHARED ); _logger.debug( "Found label= " + label + " for edge id: " + edgeLabel.getQualifiedName() ); } else { throw new RuntimeException( "Label for edge must be defined." ); } // If weight is defined, find it... // weight must be associated with a value, which depicts the probability for the edge // to be executed. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(weight=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { Float weight; String value = m.group( 2 ); try { weight = Float.valueOf( value.trim() ); _logger.debug( "Found weight= " + weight + " for edge: " + label ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", weight is not a correct float value: " + error.toString() ); } e.addUserDatum( WEIGHT_KEY, weight, UserData.SHARED ); } // If No_history is defined, find it... // If defined, it means that when executing this edge, it shall not // be added to the history list of passed edgses. p = Pattern.compile( "(No_history)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { e.addUserDatum( NO_HISTORY, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found No_history for edge: " + label ); } // If condition used defined, find it... p = Pattern.compile( "(if: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); HashMap conditions = null; while ( m.find( ) ) { if ( conditions == null ) { conditions = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); conditions.put( variable, state ); _logger.debug( "Condition: " + variable + " = " + state ); } if ( conditions != null ) { e.addUserDatum( CONDITION_KEY, conditions, UserData.SHARED ); } // If state are defined, find them... HashMap states = null; p = Pattern.compile( "(state: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( states == null ) { states = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); states.put( variable, state ); _logger.debug( "State: " + variable + " = " + state ); } if ( states != null ) { e.addUserDatum( STATE_KEY, states, UserData.SHARED ); } // If string variables are defined, find them... HashMap variables = null; p = Pattern.compile( "(string: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); String variable = m.group( 3 ); variables.put( variableLabel, variable ); _logger.debug( "String variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(integer: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Integer variable = Integer.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Integer variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(float: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Float variable = Float.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Float variable: " + variableLabel + " = " + variable ); } if ( variables != null ) { e.addUserDatum( VARIABLE_KEY, variables, UserData.SHARED ); } } e.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); _logger.debug( "Adderade edge: \"" + e.getUserDatum( LABEL_KEY ) + "\"" ); } } } catch ( JDOMException e ) { _logger.error( e ); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } catch ( IOException e ) { e.printStackTrace(); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } }
3,241,224
private void parseFile( String fileName ) { try { _logger.info( "Parsing file: " + fileName ); _doc = _parser.build( fileName ); // Parse all vertices (nodes) Iterator iter = _doc.getDescendants( new ElementFilter( "node" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; if ( element.getAttributeValue( "yfiles.foldertype" ) != null ) { _logger.debug( "Excluded node: " + element.getAttributeValue( "yfiles.foldertype" ) ); continue; } _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "NodeLabel" ) ); while ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { Element nodeLabel = (Element)o2; _logger.debug( "Full name: " + nodeLabel.getQualifiedName() ); _logger.debug( "Name: " + nodeLabel.getTextTrim() ); DirectedSparseVertex v = (DirectedSparseVertex) _graph.addVertex( new DirectedSparseVertex() ); v.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); v.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); v.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); String str = nodeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label; if ( m.find( )) { label = m.group( 1 ); v.addUserDatum( LABEL_KEY, label, UserData.SHARED ); } else { throw new RuntimeException( "Label must be defined." ); } _logger.debug( "Added node: " + v.getUserDatum( LABEL_KEY ) ); // If no merge is defined, find it... // If defined, it means that when merging graphs, this specific vertex will not be merged. p = Pattern.compile( "(no merge)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { v.addUserDatum( NO_MERGE, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found no merge for edge: " + label ); } // NOTE: Only for html applications // In browsers, the usage of the 'Back'-button can be used. // If defined, with a value value, which depicts the probability for the edge // to be executed, tha back-button will be pressed in the browser. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(back=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find( ) ) { Float probability; String value = m.group( 2 ); try { probability = Float.valueOf( value.trim() ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", back is not a correct float value: " + error.toString() ); } v.addUserDatum( BACK_KEY, probability, UserData.SHARED ); } } } } } Object[] vertices = _graph.getVertices().toArray(); // Parse all edges (arrows or transtitions) iter = _doc.getDescendants( new ElementFilter( "edge" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "EdgeLabel" ) ); Element edgeLabel = null; if ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { edgeLabel = (Element)o2; _logger.debug( "Full name: " + edgeLabel.getQualifiedName() ); _logger.debug( "Name: " + edgeLabel.getTextTrim() ); } } _logger.debug( "source: " + element.getAttributeValue( "source" ) ); _logger.debug( "target: " + element.getAttributeValue( "target" ) ); DirectedSparseVertex source = null; DirectedSparseVertex dest = null; for ( int i = 0; i < vertices.length; i++ ) { DirectedSparseVertex vertex = (DirectedSparseVertex)vertices[ i ]; // Find source vertex if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "source" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { source = vertex; } if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "target" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { dest = vertex; } } if ( source == null ) { String msg = "Could not find starting node for edge. Name: " + element.getAttributeValue( "source" ); _logger.error( msg ); throw new RuntimeException( msg ); } if ( dest == null ) { String msg = "Could not find end node for edge. Name: " + element.getAttributeValue( "target" ); _logger.error( msg ); throw new RuntimeException( msg ); } DirectedSparseEdge e = new DirectedSparseEdge( source, dest ); _graph.addEdge( e ); e.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); e.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); if ( edgeLabel != null ) { String str = edgeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label = null; if ( m.find() ) { label = m.group( 1 ); e.addUserDatum( LABEL_KEY, label, UserData.SHARED ); _logger.debug( "Found label= " + label + " for edge id: " + edgeLabel.getQualifiedName() ); } else { throw new RuntimeException( "Label for edge must be defined." ); } // If weight is defined, find it... // weight must be associated with a value, which depicts the probability for the edge // to be executed. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(weight=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { Float weight; String value = m.group( 2 ); try { weight = Float.valueOf( value.trim() ); _logger.debug( "Found weight= " + weight + " for edge: " + label ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", weight is not a correct float value: " + error.toString() ); } e.addUserDatum( WEIGHT_KEY, weight, UserData.SHARED ); } // If No_history is defined, find it... // If defined, it means that when executing this edge, it shall not // be added to the history list of passed edgses. p = Pattern.compile( "(No_history)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { e.addUserDatum( NO_HISTORY, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found No_history for edge: " + label ); } // If condition used defined, find it... p = Pattern.compile( "(if: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); HashMap conditions = null; while ( m.find( ) ) { if ( conditions == null ) { conditions = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); conditions.put( variable, state ); _logger.debug( "Condition: " + variable + " = " + state ); } if ( conditions != null ) { e.addUserDatum( CONDITION_KEY, conditions, UserData.SHARED ); } // If state are defined, find them... HashMap states = null; p = Pattern.compile( "(state: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( states == null ) { states = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); states.put( variable, state ); _logger.debug( "State: " + variable + " = " + state ); } if ( states != null ) { e.addUserDatum( STATE_KEY, states, UserData.SHARED ); } // If string variables are defined, find them... HashMap variables = null; p = Pattern.compile( "(string: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); String variable = m.group( 3 ); variables.put( variableLabel, variable ); _logger.debug( "String variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(integer: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Integer variable = Integer.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Integer variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(float: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Float variable = Float.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Float variable: " + variableLabel + " = " + variable ); } if ( variables != null ) { e.addUserDatum( VARIABLE_KEY, variables, UserData.SHARED ); } } e.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); _logger.debug( "Adderade edge: \"" + e.getUserDatum( LABEL_KEY ) + "\"" ); } } } catch ( JDOMException e ) { _logger.error( e ); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } catch ( IOException e ) { e.printStackTrace(); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } }
private void parseFile( String fileName ) { try { _logger.info( "Parsing file: " + fileName ); _doc = _parser.build( fileName ); // Parse all vertices (nodes) Iterator iter = _doc.getDescendants( new ElementFilter( "node" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; if ( element.getAttributeValue( "yfiles.foldertype" ) != null ) { _logger.debug( "Excluded node: " + element.getAttributeValue( "yfiles.foldertype" ) ); continue; } _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "NodeLabel" ) ); while ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { Element nodeLabel = (Element)o2; _logger.debug( "Full name: " + nodeLabel.getQualifiedName() ); _logger.debug( "Name: " + nodeLabel.getTextTrim() ); DirectedSparseVertex v = (DirectedSparseVertex) _graph.addVertex( new DirectedSparseVertex() ); v.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); v.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); v.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); String str = nodeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label; if ( m.find( )) { label = m.group( 1 ); v.addUserDatum( LABEL_KEY, label, UserData.SHARED ); } else { throw new RuntimeException( "Label must be defined." ); } _logger.debug( "Added node: " + v.getUserDatum( LABEL_KEY ) ); // If no merge is defined, find it... // If defined, it means that when merging graphs, this specific vertex will not be merged. p = Pattern.compile( "(no merge)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { v.addUserDatum( NO_MERGE, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found no merge for edge: " + label ); } // NOTE: Only for html applications // In browsers, the usage of the 'Back'-button can be used. // If defined, with a value value, which depicts the probability for the edge // to be executed, tha back-button will be pressed in the browser. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(back=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find( ) ) { Float probability; String value = m.group( 2 ); try { probability = Float.valueOf( value.trim() ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", back is not a correct float value: " + error.toString() ); } v.addUserDatum( BACK_KEY, probability, UserData.SHARED ); } } } } } Object[] vertices = _graph.getVertices().toArray(); // Parse all edges (arrows or transtitions) iter = _doc.getDescendants( new ElementFilter( "edge" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "EdgeLabel" ) ); Element edgeLabel = null; if ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { edgeLabel = (Element)o2; _logger.debug( "Full name: " + edgeLabel.getQualifiedName() ); _logger.debug( "Name: " + edgeLabel.getTextTrim() ); } } _logger.debug( "source: " + element.getAttributeValue( "source" ) ); _logger.debug( "target: " + element.getAttributeValue( "target" ) ); DirectedSparseVertex source = null; DirectedSparseVertex dest = null; for ( int i = 0; i < vertices.length; i++ ) { DirectedSparseVertex vertex = (DirectedSparseVertex)vertices[ i ]; // Find source vertex if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "source" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { source = vertex; } if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "target" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { dest = vertex; } } if ( source == null ) { String msg = "Could not find starting node for edge. Name: " + element.getAttributeValue( "source" ); _logger.error( msg ); throw new RuntimeException( msg ); } if ( dest == null ) { String msg = "Could not find end node for edge. Name: " + element.getAttributeValue( "target" ); _logger.error( msg ); throw new RuntimeException( msg ); } DirectedSparseEdge e = new DirectedSparseEdge( source, dest ); _graph.addEdge( e ); e.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); e.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); if ( edgeLabel != null ) { String str = edgeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label = null; if ( m.find() ) { label = m.group( 1 ); e.addUserDatum( LABEL_KEY, label, UserData.SHARED ); _logger.debug( "Found label= " + label + " for edge id: " + edgeLabel.getQualifiedName() ); } else { throw new RuntimeException( "Label for edge must be defined." ); } // If weight is defined, find it... // weight must be associated with a value, which depicts the probability for the edge // to be executed. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(weight=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { Float weight; String value = m.group( 2 ); try { weight = Float.valueOf( value.trim() ); _logger.debug( "Found weight= " + weight + " for edge: " + label ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", weight is not a correct float value: " + error.toString() ); } e.addUserDatum( WEIGHT_KEY, weight, UserData.SHARED ); } // If No_history is defined, find it... // If defined, it means that when executing this edge, it shall not // be added to the history list of passed edgses. p = Pattern.compile( "(No_history)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { e.addUserDatum( NO_HISTORY, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found No_history for edge: " + label ); } // If condition used defined, find it... p = Pattern.compile( "(if: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); HashMap conditions = null; while ( m.find( ) ) { if ( conditions == null ) { conditions = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); conditions.put( variable, state ); _logger.debug( "Condition: " + variable + " = " + state ); } if ( conditions != null ) { e.addUserDatum( CONDITION_KEY, conditions, UserData.SHARED ); } // If state are defined, find them... HashMap states = null; p = Pattern.compile( "(state: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( states == null ) { states = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); states.put( variable, state ); _logger.debug( "State: " + variable + " = " + state ); } if ( states != null ) { e.addUserDatum( STATE_KEY, states, UserData.SHARED ); } // If string variables are defined, find them... HashMap variables = null; p = Pattern.compile( "(string: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); String variable = m.group( 3 ); variables.put( variableLabel, variable ); _logger.debug( "String variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(integer: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Integer variable = Integer.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Integer variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(float: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Float variable = Float.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Float variable: " + variableLabel + " = " + variable ); } if ( variables != null ) { e.addUserDatum( VARIABLE_KEY, variables, UserData.SHARED ); } } e.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); _logger.debug( "Adderade edge: \"" + e.getUserDatum( LABEL_KEY ) + "\"" ); } } } catch ( JDOMException e ) { _logger.error( e ); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } catch ( IOException e ) { e.printStackTrace(); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } }
3,241,225
private void parseFile( String fileName ) { try { _logger.info( "Parsing file: " + fileName ); _doc = _parser.build( fileName ); // Parse all vertices (nodes) Iterator iter = _doc.getDescendants( new ElementFilter( "node" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; if ( element.getAttributeValue( "yfiles.foldertype" ) != null ) { _logger.debug( "Excluded node: " + element.getAttributeValue( "yfiles.foldertype" ) ); continue; } _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "NodeLabel" ) ); while ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { Element nodeLabel = (Element)o2; _logger.debug( "Full name: " + nodeLabel.getQualifiedName() ); _logger.debug( "Name: " + nodeLabel.getTextTrim() ); DirectedSparseVertex v = (DirectedSparseVertex) _graph.addVertex( new DirectedSparseVertex() ); v.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); v.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); v.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); String str = nodeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label; if ( m.find( )) { label = m.group( 1 ); v.addUserDatum( LABEL_KEY, label, UserData.SHARED ); } else { throw new RuntimeException( "Label must be defined." ); } _logger.debug( "Added node: " + v.getUserDatum( LABEL_KEY ) ); // If no merge is defined, find it... // If defined, it means that when merging graphs, this specific vertex will not be merged. p = Pattern.compile( "(no merge)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { v.addUserDatum( NO_MERGE, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found no merge for edge: " + label ); } // NOTE: Only for html applications // In browsers, the usage of the 'Back'-button can be used. // If defined, with a value value, which depicts the probability for the edge // to be executed, tha back-button will be pressed in the browser. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(back=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find( ) ) { Float probability; String value = m.group( 2 ); try { probability = Float.valueOf( value.trim() ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", back is not a correct float value: " + error.toString() ); } v.addUserDatum( BACK_KEY, probability, UserData.SHARED ); } } } } } Object[] vertices = _graph.getVertices().toArray(); // Parse all edges (arrows or transtitions) iter = _doc.getDescendants( new ElementFilter( "edge" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "EdgeLabel" ) ); Element edgeLabel = null; if ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { edgeLabel = (Element)o2; _logger.debug( "Full name: " + edgeLabel.getQualifiedName() ); _logger.debug( "Name: " + edgeLabel.getTextTrim() ); } } _logger.debug( "source: " + element.getAttributeValue( "source" ) ); _logger.debug( "target: " + element.getAttributeValue( "target" ) ); DirectedSparseVertex source = null; DirectedSparseVertex dest = null; for ( int i = 0; i < vertices.length; i++ ) { DirectedSparseVertex vertex = (DirectedSparseVertex)vertices[ i ]; // Find source vertex if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "source" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { source = vertex; } if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "target" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { dest = vertex; } } if ( source == null ) { String msg = "Could not find starting node for edge. Name: " + element.getAttributeValue( "source" ); _logger.error( msg ); throw new RuntimeException( msg ); } if ( dest == null ) { String msg = "Could not find end node for edge. Name: " + element.getAttributeValue( "target" ); _logger.error( msg ); throw new RuntimeException( msg ); } DirectedSparseEdge e = new DirectedSparseEdge( source, dest ); _graph.addEdge( e ); e.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); e.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); if ( edgeLabel != null ) { String str = edgeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label = null; if ( m.find() ) { label = m.group( 1 ); e.addUserDatum( LABEL_KEY, label, UserData.SHARED ); _logger.debug( "Found label= " + label + " for edge id: " + edgeLabel.getQualifiedName() ); } else { throw new RuntimeException( "Label for edge must be defined." ); } // If weight is defined, find it... // weight must be associated with a value, which depicts the probability for the edge // to be executed. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(weight=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { Float weight; String value = m.group( 2 ); try { weight = Float.valueOf( value.trim() ); _logger.debug( "Found weight= " + weight + " for edge: " + label ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", weight is not a correct float value: " + error.toString() ); } e.addUserDatum( WEIGHT_KEY, weight, UserData.SHARED ); } // If No_history is defined, find it... // If defined, it means that when executing this edge, it shall not // be added to the history list of passed edgses. p = Pattern.compile( "(No_history)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { e.addUserDatum( NO_HISTORY, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found No_history for edge: " + label ); } // If condition used defined, find it... p = Pattern.compile( "(if: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); HashMap conditions = null; while ( m.find( ) ) { if ( conditions == null ) { conditions = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); conditions.put( variable, state ); _logger.debug( "Condition: " + variable + " = " + state ); } if ( conditions != null ) { e.addUserDatum( CONDITION_KEY, conditions, UserData.SHARED ); } // If state are defined, find them... HashMap states = null; p = Pattern.compile( "(state: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( states == null ) { states = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); states.put( variable, state ); _logger.debug( "State: " + variable + " = " + state ); } if ( states != null ) { e.addUserDatum( STATE_KEY, states, UserData.SHARED ); } // If string variables are defined, find them... HashMap variables = null; p = Pattern.compile( "(string: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); String variable = m.group( 3 ); variables.put( variableLabel, variable ); _logger.debug( "String variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(integer: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Integer variable = Integer.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Integer variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(float: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Float variable = Float.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Float variable: " + variableLabel + " = " + variable ); } if ( variables != null ) { e.addUserDatum( VARIABLE_KEY, variables, UserData.SHARED ); } } e.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); _logger.debug( "Adderade edge: \"" + e.getUserDatum( LABEL_KEY ) + "\"" ); } } } catch ( JDOMException e ) { _logger.error( e ); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } catch ( IOException e ) { e.printStackTrace(); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } }
private void parseFile( String fileName ) { try { _logger.info( "Parsing file: " + fileName ); _doc = _parser.build( fileName ); // Parse all vertices (nodes) Iterator iter = _doc.getDescendants( new ElementFilter( "node" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; if ( element.getAttributeValue( "yfiles.foldertype" ) != null ) { _logger.debug( "Excluded node: " + element.getAttributeValue( "yfiles.foldertype" ) ); continue; } _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "NodeLabel" ) ); while ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { Element nodeLabel = (Element)o2; _logger.debug( "Full name: " + nodeLabel.getQualifiedName() ); _logger.debug( "Name: " + nodeLabel.getTextTrim() ); DirectedSparseVertex v = (DirectedSparseVertex) _graph.addVertex( new DirectedSparseVertex() ); v.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); v.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); v.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); String str = nodeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label; if ( m.find( )) { label = m.group( 1 ); v.addUserDatum( LABEL_KEY, label, UserData.SHARED ); } else { throw new RuntimeException( "Label must be defined." ); } _logger.debug( "Added node: " + v.getUserDatum( LABEL_KEY ) ); // If no merge is defined, find it... // If defined, it means that when merging graphs, this specific vertex will not be merged. p = Pattern.compile( "(no merge)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { v.addUserDatum( NO_MERGE, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found no merge for edge: " + label ); } // NOTE: Only for html applications // In browsers, the usage of the 'Back'-button can be used. // If defined, with a value value, which depicts the probability for the edge // to be executed, tha back-button will be pressed in the browser. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(back=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find( ) ) { Float probability; String value = m.group( 2 ); try { probability = Float.valueOf( value.trim() ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", back is not a correct float value: " + error.toString() ); } v.addUserDatum( BACK_KEY, probability, UserData.SHARED ); } } } } } Object[] vertices = _graph.getVertices().toArray(); // Parse all edges (arrows or transtitions) iter = _doc.getDescendants( new ElementFilter( "edge" ) ); while ( iter.hasNext() ) { Object o = iter.next(); if ( o instanceof Element ) { Element element = (Element)o; _logger.debug( "id: " + element.getAttributeValue( "id" ) ); Iterator iter2 = element.getDescendants( new ElementFilter( "EdgeLabel" ) ); Element edgeLabel = null; if ( iter2.hasNext() ) { Object o2 = iter2.next(); if ( o2 instanceof Element ) { edgeLabel = (Element)o2; _logger.debug( "Full name: " + edgeLabel.getQualifiedName() ); _logger.debug( "Name: " + edgeLabel.getTextTrim() ); } } _logger.debug( "source: " + element.getAttributeValue( "source" ) ); _logger.debug( "target: " + element.getAttributeValue( "target" ) ); DirectedSparseVertex source = null; DirectedSparseVertex dest = null; for ( int i = 0; i < vertices.length; i++ ) { DirectedSparseVertex vertex = (DirectedSparseVertex)vertices[ i ]; // Find source vertex if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "source" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { source = vertex; } if ( vertex.getUserDatum( ID_KEY ).equals( element.getAttributeValue( "target" ) ) && vertex.getUserDatum( FILE_KEY ).equals( fileName ) ) { dest = vertex; } } if ( source == null ) { String msg = "Could not find starting node for edge. Name: " + element.getAttributeValue( "source" ); _logger.error( msg ); throw new RuntimeException( msg ); } if ( dest == null ) { String msg = "Could not find end node for edge. Name: " + element.getAttributeValue( "target" ); _logger.error( msg ); throw new RuntimeException( msg ); } DirectedSparseEdge e = new DirectedSparseEdge( source, dest ); _graph.addEdge( e ); e.addUserDatum( ID_KEY, element.getAttributeValue( "id" ), UserData.SHARED ); e.addUserDatum( FILE_KEY, fileName, UserData.SHARED ); if ( edgeLabel != null ) { String str = edgeLabel.getTextTrim(); Pattern p = Pattern.compile( "(.*)", Pattern.MULTILINE ); Matcher m = p.matcher( str ); String label = null; if ( m.find() ) { label = m.group( 1 ); e.addUserDatum( LABEL_KEY, label, UserData.SHARED ); _logger.debug( "Found label= " + label + " for edge id: " + edgeLabel.getQualifiedName() ); } else { throw new RuntimeException( "Label for edge must be defined." ); } // If weight is defined, find it... // weight must be associated with a value, which depicts the probability for the edge // to be executed. // A value of 0.05 is the same as 5% chance of going down this road. p = Pattern.compile( "(weight=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { Float weight; String value = m.group( 2 ); try { weight = Float.valueOf( value.trim() ); _logger.debug( "Found weight= " + weight + " for edge: " + label ); } catch ( NumberFormatException error ) { throw new RuntimeException( "For label: " + label + ", weight is not a correct float value: " + error.toString() ); } e.addUserDatum( WEIGHT_KEY, weight, UserData.SHARED ); } // If No_history is defined, find it... // If defined, it means that when executing this edge, it shall not // be added to the history list of passed edgses. p = Pattern.compile( "(No_history)", Pattern.MULTILINE ); m = p.matcher( str ); if ( m.find() ) { e.addUserDatum( NO_HISTORY, m.group( 1 ), UserData.SHARED ); _logger.debug( "Found No_history for edge: " + label ); } // If condition used defined, find it... p = Pattern.compile( "(if: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); HashMap conditions = null; while ( m.find( ) ) { if ( conditions == null ) { conditions = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); conditions.put( variable, state ); _logger.debug( "Condition: " + variable + " = " + state ); } if ( conditions != null ) { e.addUserDatum( CONDITION_KEY, conditions, UserData.SHARED ); } // If state are defined, find them... HashMap states = null; p = Pattern.compile( "(state: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( states == null ) { states = new HashMap(); } String variable = m.group( 2 ); Boolean state = Boolean.valueOf( m.group( 3 ) ); states.put( variable, state ); _logger.debug( "State: " + variable + " = " + state ); } if ( states != null ) { e.addUserDatum( STATE_KEY, states, UserData.SHARED ); } // If string variables are defined, find them... HashMap variables = null; p = Pattern.compile( "(string: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); String variable = m.group( 3 ); variables.put( variableLabel, variable ); _logger.debug( "String variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(integer: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Integer variable = Integer.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Integer variable: " + variableLabel + " = " + variable ); } // If integer variables are defined, find them... p = Pattern.compile( "(float: (.*)=(.*))", Pattern.MULTILINE ); m = p.matcher( str ); while ( m.find( ) ) { if ( variables == null ) { variables = new HashMap(); } String variableLabel = m.group( 2 ); Float variable = Float.valueOf( m.group( 3 ) ); variables.put( variableLabel, variable ); _logger.debug( "Float variable: " + variableLabel + " = " + variable ); } if ( variables != null ) { e.addUserDatum( VARIABLE_KEY, variables, UserData.SHARED ); } } e.addUserDatum( VISITED_KEY, new Integer( 0 ), UserData.SHARED ); _logger.debug( "Adderade edge: \"" + e.getUserDatum( LABEL_KEY ) + "\"" ); } } } catch ( JDOMException e ) { _logger.error( e ); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } catch ( IOException e ) { e.printStackTrace(); throw new RuntimeException( "Kunde inte skanna filen: " + fileName ); } }
3,241,226
private void readFiles() { File file = new File( _graphmlFileName ); if ( file.isFile() ) { parseFile( _graphmlFileName ); } else if ( file.isDirectory() ) { // Only accpets files which suffix is .graphml FilenameFilter filter = new FilenameFilter() { public boolean accept( File dir, String name ) { return name.endsWith( ".graphml" ); } }; File [] allChildren = file.listFiles( filter ); for ( int i = 0; i < allChildren.length; ++i ) { parseFile( allChildren[ i ].getAbsolutePath() ); } mergeVertices(); } else { throw new RuntimeException( "\"" + _graphmlFileName + "\" is not a file or a directory. Please specify a valid .graphml file or a directory containing .graphml files" ); } }
private void readFiles() { File file = new File( _graphmlFileName ); if ( file.isFile() ) { parseFile( _graphmlFileName ); } else if ( file.isDirectory() ) { // Only accpets files which suffix is .graphml FilenameFilter filter = new FilenameFilter() { public boolean accept( File dir, String name ) { return name.endsWith( ".graphml" ); } }; File [] allChildren = file.listFiles( filter ); for ( int i = 0; i < allChildren.length; ++i ) { parseFile( allChildren[ i ].getAbsolutePath() ); } mergeVertices(); } else { throw new RuntimeException( "\"" + _graphmlFileName + "\" is not a file or a directory. Please specify a valid .graphml file or a directory containing .graphml files" ); } }
3,241,228
private void readFiles() { File file = new File( _graphmlFileName ); if ( file.isFile() ) { parseFile( _graphmlFileName ); } else if ( file.isDirectory() ) { // Only accpets files which suffix is .graphml FilenameFilter filter = new FilenameFilter() { public boolean accept( File dir, String name ) { return name.endsWith( ".graphml" ); } }; File [] allChildren = file.listFiles( filter ); for ( int i = 0; i < allChildren.length; ++i ) { parseFile( allChildren[ i ].getAbsolutePath() ); } mergeVertices(); } else { throw new RuntimeException( "\"" + _graphmlFileName + "\" is not a file or a directory. Please specify a valid .graphml file or a directory containing .graphml files" ); } }
private void readFiles() { File file = new File( _graphmlFileName ); if ( file.isFile() ) { parseFile( _graphmlFileName ); } else if ( file.isDirectory() ) { // Only accpets files which suffix is .graphml FilenameFilter filter = new FilenameFilter() { public boolean accept( File dir, String name ) { return name.endsWith( ".graphml" ); } }; File [] allChildren = file.listFiles( filter ); for ( int i = 0; i < allChildren.length; ++i ) { parseFile( allChildren[ i ].getAbsolutePath() ); } mergeVertices(); } else { throw new RuntimeException( "\"" + _graphmlFileName + "\" is not a file or a directory. Please specify a valid .graphml file or a directory containing .graphml files" ); } }
3,241,229
private void readFiles() { File file = new File( _graphmlFileName ); if ( file.isFile() ) { parseFile( _graphmlFileName ); } else if ( file.isDirectory() ) { // Only accpets files which suffix is .graphml FilenameFilter filter = new FilenameFilter() { public boolean accept( File dir, String name ) { return name.endsWith( ".graphml" ); } }; File [] allChildren = file.listFiles( filter ); for ( int i = 0; i < allChildren.length; ++i ) { parseFile( allChildren[ i ].getAbsolutePath() ); } mergeVertices(); } else { throw new RuntimeException( "\"" + _graphmlFileName + "\" is not a file or a directory. Please specify a valid .graphml file or a directory containing .graphml files" ); } }
private void readFiles() { File file = new File( _graphmlFileName ); if ( file.isFile() ) { parseFile( _graphmlFileName ); } else if ( file.isDirectory() ) { // Only accpets files which suffix is .graphml FilenameFilter filter = new FilenameFilter() { public boolean accept( File dir, String name ) { return name.endsWith( ".graphml" ); } }; File [] allChildren = file.listFiles( filter ); for ( int i = 0; i < allChildren.length; ++i ) { parseFile( allChildren[ i ].getAbsolutePath() ); } mergeVertices(); } else { throw new RuntimeException( "\"" + _graphmlFileName + "\" is not a file or a directory. Please specify a valid .graphml file or a directory containing .graphml files" ); } }
3,241,230
public void writeGraph( String mergedGraphml_ ) { StringBuffer sourceFile = new StringBuffer(); try { FileWriter file = new FileWriter( mergedGraphml_ ); sourceFile.append( "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" ); sourceFile.append( "<graphml xmlns=\"http://graphml.graphdrawing.org/xmlns/graphml\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://graphml.graphdrawing.org/xmlns/graphml http://www.yworks.com/xml/schema/graphml/1.0/ygraphml.xsd\" xmlns:y=\"http://www.yworks.com/xml/graphml\">\n" ); sourceFile.append( " <key id=\"d0\" for=\"node\" yfiles.type=\"nodegraphics\"/>\n" ); sourceFile.append( " <key id=\"d1\" for=\"edge\" yfiles.type=\"edgegraphics\"/>\n" ); sourceFile.append( " <graph id=\"G\" edgedefault=\"directed\">\n" ); int numVertices = _graph.getVertices().size(); Indexer id = Indexer.getIndexer( _graph ); for ( int i = 0; i < numVertices; i++ ) { Vertex v = (Vertex) id.getVertex(i); int vId = i+1; sourceFile.append( " <node id=\"n" + vId + "\">\n" ); sourceFile.append( " <data key=\"d0\" >\n" ); sourceFile.append( " <y:ShapeNode >\n" ); sourceFile.append( " <y:Geometry x=\"241.875\" y=\"158.701171875\" width=\"95.0\" height=\"30.0\"/>\n" ); sourceFile.append( " <y:Fill color=\"#CCCCFF\" transparent=\"false\"/>\n" ); sourceFile.append( " <y:BorderStyle type=\"line\" width=\"1.0\" color=\"#000000\" />\n" ); sourceFile.append( " <y:NodeLabel x=\"1.5\" y=\"5.6494140625\" width=\"92.0\" height=\"18.701171875\" visible=\"true\" alignment=\"center\" fontFamily=\"Dialog\" fontSize=\"12\" fontStyle=\"plain\" textColor=\"#000000\" modelName=\"internal\" modelPosition=\"c\" autoSizePolicy=\"content\">" + v.getUserDatum( LABEL_KEY ) + "</y:NodeLabel>\n" ); sourceFile.append( " <y:Shape type=\"rectangle\"/>\n" ); sourceFile.append( " </y:ShapeNode>\n" ); sourceFile.append( " </data>\n" ); sourceFile.append( " </node>\n" ); } int i = 0; for ( Iterator edgeIterator = _graph.getEdges().iterator(); edgeIterator.hasNext(); ) { Edge e = (Edge) edgeIterator.next(); Pair p = e.getEndpoints(); Vertex src = (Vertex) p.getFirst(); Vertex dest = (Vertex) p.getSecond(); int srcId = id.getIndex(src)+1; int destId = id.getIndex(dest)+1; int nId = ++i; sourceFile.append( " <edge id=\"" + nId + "\" source=\"n" + srcId + "\" target=\"n" + destId + "\">\n" ); sourceFile.append( " <data key=\"d1\" >\n" ); sourceFile.append( " <y:PolyLineEdge >\n" ); sourceFile.append( " <y:Path sx=\"-23.75\" sy=\"15.0\" tx=\"-23.75\" ty=\"-15.0\">\n" ); sourceFile.append( " <y:Point x=\"273.3125\" y=\"95.0\"/>\n" ); sourceFile.append( " <y:Point x=\"209.5625\" y=\"95.0\"/>\n" ); sourceFile.append( " <y:Point x=\"209.5625\" y=\"143.701171875\"/>\n" ); sourceFile.append( " <y:Point x=\"265.625\" y=\"143.701171875\"/>\n" ); sourceFile.append( " </y:Path>\n" ); sourceFile.append( " <y:LineStyle type=\"line\" width=\"1.0\" color=\"#000000\" />\n" ); sourceFile.append( " <y:Arrows source=\"none\" target=\"standard\"/>\n" ); sourceFile.append( " <y:EdgeLabel x=\"-148.25\" y=\"30.000000000000014\" width=\"169.0\" height=\"18.701171875\" visible=\"true\" alignment=\"center\" fontFamily=\"Dialog\" fontSize=\"12\" fontStyle=\"plain\" textColor=\"#000000\" modelName=\"free\" modelPosition=\"anywhere\" preferredPlacement=\"on_edge\" distance=\"2.0\" ratio=\"0.5\">" + e.getUserDatum( LABEL_KEY ) + "</y:EdgeLabel>\n" ); sourceFile.append( " <y:BendStyle smoothed=\"false\"/>\n" ); sourceFile.append( " </y:PolyLineEdge>\n" ); sourceFile.append( " </data>\n" ); sourceFile.append( " </edge>\n" ); } sourceFile.append( " </graph>\n" ); sourceFile.append( "</graphml>\n" ); file.write( sourceFile.toString() ); file.flush(); _logger.info( "Wrote: " + mergedGraphml_ ); } catch (IOException e) { e.printStackTrace(); } }
public void writeGraph( String mergedGraphml_ ) { StringBuffer sourceFile = new StringBuffer(); try { FileWriter file = new FileWriter( mergedGraphml_ ); sourceFile.append( "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" ); sourceFile.append( "<graphml xmlns=\"http://graphml.graphdrawing.org/xmlns/graphml\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://graphml.graphdrawing.org/xmlns/graphml http://www.yworks.com/xml/schema/graphml/1.0/ygraphml.xsd\" xmlns:y=\"http://www.yworks.com/xml/graphml\">\n" ); sourceFile.append( " <key id=\"d0\" for=\"node\" yfiles.type=\"nodegraphics\"/>\n" ); sourceFile.append( " <key id=\"d1\" for=\"edge\" yfiles.type=\"edgegraphics\"/>\n" ); sourceFile.append( " <graph id=\"G\" edgedefault=\"directed\">\n" ); int numVertices = _graph.getVertices().size(); Indexer id = Indexer.getIndexer( _graph ); for ( int i = 0; i < numVertices; i++ ) { Vertex v = (Vertex) id.getVertex(i); int vId = i+1; sourceFile.append( " <node id=\"n" + vId + "\">\n" ); sourceFile.append( " <data key=\"d0\" >\n" ); sourceFile.append( " <y:ShapeNode >\n" ); sourceFile.append( " <y:Geometry x=\"241.875\" y=\"158.701171875\" width=\"95.0\" height=\"30.0\"/>\n" ); sourceFile.append( " <y:Fill color=\"#CCCCFF\" transparent=\"false\"/>\n" ); sourceFile.append( " <y:BorderStyle type=\"line\" width=\"1.0\" color=\"#000000\" />\n" ); sourceFile.append( " <y:NodeLabel x=\"1.5\" y=\"5.6494140625\" width=\"92.0\" height=\"18.701171875\" visible=\"true\" alignment=\"center\" fontFamily=\"Dialog\" fontSize=\"12\" fontStyle=\"plain\" textColor=\"#000000\" modelName=\"internal\" modelPosition=\"c\" autoSizePolicy=\"content\">" + v.getUserDatum( LABEL_KEY ) + "</y:NodeLabel>\n" ); sourceFile.append( " <y:Shape type=\"rectangle\"/>\n" ); sourceFile.append( " </y:ShapeNode>\n" ); sourceFile.append( " </data>\n" ); sourceFile.append( " </node>\n" ); } int i = 0; for ( Iterator edgeIterator = _graph.getEdges().iterator(); edgeIterator.hasNext(); ) { Edge e = (Edge) edgeIterator.next(); Pair p = e.getEndpoints(); Vertex src = (Vertex) p.getFirst(); Vertex dest = (Vertex) p.getSecond(); int srcId = id.getIndex(src)+1; int destId = id.getIndex(dest)+1; int nId = ++i; sourceFile.append( " <edge id=\"" + nId + "\" source=\"n" + srcId + "\" target=\"n" + destId + "\">\n" ); sourceFile.append( " <data key=\"d1\" >\n" ); sourceFile.append( " <y:PolyLineEdge >\n" ); sourceFile.append( " <y:Path sx=\"-23.75\" sy=\"15.0\" tx=\"-23.75\" ty=\"-15.0\">\n" ); sourceFile.append( " <y:Point x=\"273.3125\" y=\"95.0\"/>\n" ); sourceFile.append( " <y:Point x=\"209.5625\" y=\"95.0\"/>\n" ); sourceFile.append( " <y:Point x=\"209.5625\" y=\"143.701171875\"/>\n" ); sourceFile.append( " <y:Point x=\"265.625\" y=\"143.701171875\"/>\n" ); sourceFile.append( " </y:Path>\n" ); sourceFile.append( " <y:LineStyle type=\"line\" width=\"1.0\" color=\"#000000\" />\n" ); sourceFile.append( " <y:Arrows source=\"none\" target=\"standard\"/>\n" ); sourceFile.append( " <y:EdgeLabel x=\"-148.25\" y=\"30.000000000000014\" width=\"169.0\" height=\"18.701171875\" visible=\"true\" alignment=\"center\" fontFamily=\"Dialog\" fontSize=\"12\" fontStyle=\"plain\" textColor=\"#000000\" modelName=\"free\" modelPosition=\"anywhere\" preferredPlacement=\"on_edge\" distance=\"2.0\" ratio=\"0.5\">" + e.getUserDatum( LABEL_KEY ) + "</y:EdgeLabel>\n" ); sourceFile.append( " <y:BendStyle smoothed=\"false\"/>\n" ); sourceFile.append( " </y:PolyLineEdge>\n" ); sourceFile.append( " </data>\n" ); sourceFile.append( " </edge>\n" ); } sourceFile.append( " </graph>\n" ); sourceFile.append( "</graphml>\n" ); file.write( sourceFile.toString() ); file.flush(); _logger.info( "Wrote: " + mergedGraphml_ ); } catch (IOException e) { e.printStackTrace(); } }
3,241,231
public PathInputPanel(InstallerFrame parent, InstallData idata) { super(parent, idata); // Set default values emptyTargetMsg = getI18nStringForClass("empty_target", "TargetPanel"); warnMsg = getI18nStringForClass("warn", "TargetPanel"); // if( this.class.) // Customize the default GridBagConstraints. GridBagConstraints gbConstraint = getDefaultGridBagConstraints(); gbConstraint.gridwidth = GridBagConstraints.REMAINDER; this.setDefaultGridBagConstraints(gbConstraint); String introText = getI18nStringForClass("intro", "PathInputPanel"); if (introText == null || introText.startsWith("PathInputPanel.intro")) introText = ""; // Intro // Create and customize constraint for it. // row 0 column 0 gbConstraint = getNextYGridBagConstraints(); // Create component and add it to this panel. MultiLineLabel introLabel = createMultiLineLabel(introText); add(introLabel, gbConstraint); // Label for input // Create and customize constraint for it. // row 1 column 0; is the next Y gbConstraint = getNextYGridBagConstraints(); gbConstraint.gridwidth = GridBagConstraints.RELATIVE; gbConstraint.insets = new Insets(0, 0, 10, 0); // Create component and add it to this panel. JLabel infoLabel = createLabel(getI18nStringForClass("info", "TargetPanel"), "open", JLabel.LEFT); add(infoLabel, gbConstraint); // Create path selection components and add they to this panel. pathSelectionPanel = new PathSelectionPanel(this, idata); gbConstraint = getNextYGridBagConstraints(); gbConstraint.gridwidth = GridBagConstraints.REMAINDER; gbConstraint.fill = GridBagConstraints.HORIZONTAL; gbConstraint.insets = new Insets(0, 0, 0, 0); add(pathSelectionPanel, gbConstraint); createLayoutBottom(); // Place a footer as last component, if completeGridBagLayout(); }
public PathInputPanel(InstallerFrame parent, InstallData idata) { super(parent, idata); // Set default values emptyTargetMsg = getI18nStringForClass("empty_target", "TargetPanel"); warnMsg = getI18nStringForClass("warn", "TargetPanel"); // if( this.class.) // Customize the default GridBagConstraints. GridBagConstraints gbConstraint = getDefaultGridBagConstraints(); gbConstraint.gridwidth = GridBagConstraints.REMAINDER; this.setDefaultGridBagConstraints(gbConstraint); String introText = getI18nStringForClass("intro", "PathInputPanel"); if (introText == null || introText.startsWith("PathInputPanel.intro")) introText = ""; // Intro // Create and customize constraint for it. // row 0 column 0 gbConstraint = getNextYGridBagConstraints(); // Create component and add it to this panel. MultiLineLabel introLabel = createMultiLineLabel(introText); add(introLabel, gbConstraint); // Label for input // Create and customize constraint for it. // row 1 column 0; is the next Y gbConstraint = getNextYGridBagConstraints(); gbConstraint.gridwidth = GridBagConstraints.RELATIVE; gbConstraint.insets = new Insets(0, 0, 10, 0); // Create component and add it to this panel. JLabel infoLabel = createLabel("info", "TargetPanel", "open", JLabel.LEFT); add(infoLabel, gbConstraint); // Create path selection components and add they to this panel. pathSelectionPanel = new PathSelectionPanel(this, idata); gbConstraint = getNextYGridBagConstraints(); gbConstraint.gridwidth = GridBagConstraints.REMAINDER; gbConstraint.fill = GridBagConstraints.HORIZONTAL; gbConstraint.insets = new Insets(0, 0, 0, 0); add(pathSelectionPanel, gbConstraint); createLayoutBottom(); // Place a footer as last component, if completeGridBagLayout(); }
3,241,232
protected KeyedObjectPool makeEmptyPool(int mincapacity) { if (this.getClass() != TestBaseKeyedObjectPool.class) { throw new AssertionError("Subclasses of TestBaseKeyedObjectPool must reimplement this method."); } throw new UnsupportedOperationException("BaseKeyedObjectPool isn't a complete implementation."); }
protected KeyedObjectPool makeEmptyPool(KeyedPoolableObjectFactory factory) { if (this.getClass() != TestBaseKeyedObjectPool.class) { throw new AssertionError("Subclasses of TestBaseKeyedObjectPool must reimplement this method."); } throw new UnsupportedOperationException("BaseKeyedObjectPool isn't a complete implementation."); }
3,241,233
public StdKunststoffPackager(String outputFilename, PackagerListener plistener) throws Exception { super(outputFilename, plistener); // Copies the Kunststoff library sendMsg("Copying the Kunststoff library ..."); InputStream istream = getClass().getResourceAsStream("/lib/kunststoff.jar"); ZipInputStream skeleton_is; if (istream != null) { skeleton_is = new ZipInputStream(istream); } else { skeleton_is = new JarInputStream (new FileInputStream ( Compiler.IZPACK_HOME + "lib" + File.separator + "kunststoff.jar")); } ZipEntry zentry; while ((zentry = skeleton_is.getNextEntry()) != null) { // ugly hack: may not add a directory twice, therefore add no directories if (zentry.isDirectory()) continue; // Puts a new entry outJar.putNextEntry(new ZipEntry(zentry.getName())); // Copy the data copyStream(skeleton_is, outJar); outJar.closeEntry(); skeleton_is.closeEntry(); } }
public StdKunststoffPackager(String outputFilename, PackagerListener plistener) throws Exception { super(outputFilename, plistener); // Copies the Kunststoff library sendMsg("Copying the Kunststoff library ..."); InputStream istream = getClass().getResourceAsStream("/lib/kunststoff.jar"); ZipInputStream skeleton_is; if (istream != null) { skeleton_is = new ZipInputStream(istream); } else { skeleton_is = new JarInputStream (new FileInputStream ( Compiler.IZPACK_HOME + "lib" + File.separator + "kunststoff.jar")); } ZipEntry zentry; while ((zentry = skeleton_is.getNextEntry()) != null) { // ugly hack: may not add a directory twice, therefore add no directories if (zentry.isDirectory()) continue; // Puts a new entry outJar.putNextEntry(new ZipEntry(zentry.getName())); // Copy the data copyStream(skeleton_is, outJar); outJar.closeEntry(); skeleton_is.closeEntry(); } }
3,241,235
public StdKunststoffPackager(String outputFilename, PackagerListener plistener) throws Exception { super(outputFilename, plistener); // Copies the Kunststoff library sendMsg("Copying the Kunststoff library ..."); InputStream istream = getClass().getResourceAsStream("/lib/kunststoff.jar"); ZipInputStream skeleton_is; if (istream != null) { skeleton_is = new ZipInputStream(istream); } else { skeleton_is = new JarInputStream (new FileInputStream ( Compiler.IZPACK_HOME + "lib" + File.separator + "kunststoff.jar")); } ZipEntry zentry; while ((zentry = skeleton_is.getNextEntry()) != null) { // ugly hack: may not add a directory twice, therefore add no directories if (zentry.isDirectory()) continue; // Puts a new entry outJar.putNextEntry(new ZipEntry(zentry.getName())); // Copy the data copyStream(skeleton_is, outJar); outJar.closeEntry(); skeleton_is.closeEntry(); } }
public StdKunststoffPackager(String outputFilename, PackagerListener plistener) throws Exception { super(outputFilename, plistener); // Copies the Kunststoff library sendMsg("Copying the Kunststoff library ..."); InputStream istream = getClass().getResourceAsStream("/lib/kunststoff.jar"); ZipInputStream skeleton_is; if (istream != null) { skeleton_is = new ZipInputStream(istream); } else { skeleton_is = new JarInputStream (new FileInputStream ( Compiler.IZPACK_HOME + "lib" + File.separator + "kunststoff.jar")); } ZipEntry zentry; while ((zentry = skeleton_is.getNextEntry()) != null) { // ugly hack: may not add a directory twice, therefore add no directories if (zentry.isDirectory()) continue; // Puts a new entry outJar.putNextEntry(new ZipEntry(zentry.getName())); // Copy the data copyStream(skeleton_is, outJar); outJar.closeEntry(); skeleton_is.closeEntry(); } }
3,241,236
public StdKunststoffPackager(String outputFilename, PackagerListener plistener) throws Exception { super(outputFilename, plistener); // Copies the Kunststoff library sendMsg("Copying the Kunststoff library ..."); InputStream istream = getClass().getResourceAsStream("/lib/kunststoff.jar"); ZipInputStream skeleton_is; if (istream != null) { skeleton_is = new ZipInputStream(istream); } else { skeleton_is = new JarInputStream (new FileInputStream ( Compiler.IZPACK_HOME + "lib" + File.separator + "kunststoff.jar")); } ZipEntry zentry; while ((zentry = skeleton_is.getNextEntry()) != null) { // ugly hack: may not add a directory twice, therefore add no directories if (zentry.isDirectory()) continue; // Puts a new entry outJar.putNextEntry(new ZipEntry(zentry.getName())); // Copy the data copyStream(skeleton_is, outJar); outJar.closeEntry(); skeleton_is.closeEntry(); } }
public StdKunststoffPackager(String outputFilename, PackagerListener plistener) throws Exception { super(outputFilename, plistener); // Copies the Kunststoff library sendMsg("Copying the Kunststoff library ..."); InputStream istream = getClass().getResourceAsStream("/lib/kunststoff.jar"); ZipInputStream skeleton_is; if (istream != null) { skeleton_is = new ZipInputStream(istream); } else { skeleton_is = new JarInputStream (new FileInputStream ( Compiler.IZPACK_HOME + "lib" + File.separator + "kunststoff.jar")); } ZipEntry zentry; while ((zentry = skeleton_is.getNextEntry()) != null) { // ugly hack: may not add a directory twice, therefore add no directories if (zentry.isDirectory()) continue; // Puts a new entry outJar.putNextEntry(new ZipEntry(zentry.getName())); // Copy the data copyStream(skeleton_is, outJar); outJar.closeEntry(); skeleton_is.closeEntry(); } }
3,241,237
public StdKunststoffPackager(String outputFilename, PackagerListener plistener) throws Exception { super(outputFilename, plistener); // Copies the Kunststoff library sendMsg("Copying the Kunststoff library ..."); InputStream istream = getClass().getResourceAsStream("/lib/kunststoff.jar"); ZipInputStream skeleton_is; if (istream != null) { skeleton_is = new ZipInputStream(istream); } else { skeleton_is = new JarInputStream (new FileInputStream ( Compiler.IZPACK_HOME + "lib" + File.separator + "kunststoff.jar")); } ZipEntry zentry; while ((zentry = skeleton_is.getNextEntry()) != null) { // ugly hack: may not add a directory twice, therefore add no directories if (zentry.isDirectory()) continue; // Puts a new entry outJar.putNextEntry(new ZipEntry(zentry.getName())); // Copy the data copyStream(skeleton_is, outJar); outJar.closeEntry(); skeleton_is.closeEntry(); } }
public StdKunststoffPackager(String outputFilename, PackagerListener plistener) throws Exception { super(outputFilename, plistener); // Copies the Kunststoff library sendMsg("Copying the Kunststoff library ..."); InputStream istream = getClass().getResourceAsStream("/lib/kunststoff.jar"); ZipInputStream skeleton_is; if (istream != null) { skeleton_is = new ZipInputStream(istream); } else { skeleton_is = new JarInputStream (new FileInputStream ( Compiler.IZPACK_HOME + "lib" + File.separator + "kunststoff.jar")); } ZipEntry zentry; while ((zentry = skeleton_is.getNextEntry()) != null) { // ugly hack: may not add a directory twice, therefore add no directories if (zentry.isDirectory()) continue; // Puts a new entry outJar.putNextEntry(new ZipEntry(zentry.getName())); // Copy the data copyStream(skeleton_is, outJar); outJar.closeEntry(); skeleton_is.closeEntry(); } }
3,241,238
public StdKunststoffPackager(String outputFilename, PackagerListener plistener) throws Exception { super(outputFilename, plistener); // Copies the Kunststoff library sendMsg("Copying the Kunststoff library ..."); InputStream istream = getClass().getResourceAsStream("/lib/kunststoff.jar"); ZipInputStream skeleton_is; if (istream != null) { skeleton_is = new ZipInputStream(istream); } else { skeleton_is = new JarInputStream (new FileInputStream ( Compiler.IZPACK_HOME + "lib" + File.separator + "kunststoff.jar")); } ZipEntry zentry; while ((zentry = skeleton_is.getNextEntry()) != null) { // ugly hack: may not add a directory twice, therefore add no directories if (zentry.isDirectory()) continue; // Puts a new entry outJar.putNextEntry(new ZipEntry(zentry.getName())); // Copy the data copyStream(skeleton_is, outJar); outJar.closeEntry(); skeleton_is.closeEntry(); } }
public StdKunststoffPackager(String outputFilename, PackagerListener plistener) throws Exception { super(outputFilename, plistener); // Copies the Kunststoff library sendMsg("Copying the Kunststoff library ..."); InputStream istream = getClass().getResourceAsStream("/lib/kunststoff.jar"); ZipInputStream skeleton_is; if (istream != null) { skeleton_is = new ZipInputStream(istream); } else { skeleton_is = new JarInputStream (new FileInputStream ( Compiler.IZPACK_HOME + "lib" + File.separator + "kunststoff.jar")); } ZipEntry zentry; while ((zentry = skeleton_is.getNextEntry()) != null) { // ugly hack: may not add a directory twice, therefore add no directories if (zentry.isDirectory()) continue; // Puts a new entry outJar.putNextEntry(new ZipEntry(zentry.getName())); // Copy the data copyStream(skeleton_is, outJar); outJar.closeEntry(); skeleton_is.closeEntry(); } }
3,241,239
public static boolean supported(String method) { if (method.equals("getFreeSpace")) { if (OsVersion.IS_UNIX) return true; if (OsVersion.IS_WINDOWS) { // getFreeSpace do not work on Windows 98. if (System.getProperty("os.name").toLowerCase().indexOf("windows 9") > -1) return (false); return (true); } } else if (method.equals("chmod")) { if (OsVersion.IS_UNIX) return true; } else if (method.equals("copyFile")) { return true; } else if (method.equals("getPrimaryGroup")) { if (OsVersion.IS_UNIX) return true; } else if (method.equals("getenv")) { return true; } else { throw new RuntimeException("method name " + method + "not supported by this method"); } return false; }
public static boolean supported(String method) { if ("getFreeSpace".equals(method)) { if (OsVersion.IS_UNIX) return true; if (OsVersion.IS_WINDOWS) { // getFreeSpace do not work on Windows 98. if (System.getProperty("os.name").toLowerCase().indexOf("windows 9") > -1) return (false); return (true); } } else if (method.equals("chmod")) { if (OsVersion.IS_UNIX) return true; } else if (method.equals("copyFile")) { return true; } else if (method.equals("getPrimaryGroup")) { if (OsVersion.IS_UNIX) return true; } else if (method.equals("getenv")) { return true; } else { throw new RuntimeException("method name " + method + "not supported by this method"); } return false; }
3,241,240
public static boolean supported(String method) { if (method.equals("getFreeSpace")) { if (OsVersion.IS_UNIX) return true; if (OsVersion.IS_WINDOWS) { // getFreeSpace do not work on Windows 98. if (System.getProperty("os.name").toLowerCase().indexOf("windows 9") > -1) return (false); return (true); } } else if (method.equals("chmod")) { if (OsVersion.IS_UNIX) return true; } else if (method.equals("copyFile")) { return true; } else if (method.equals("getPrimaryGroup")) { if (OsVersion.IS_UNIX) return true; } else if (method.equals("getenv")) { return true; } else { throw new RuntimeException("method name " + method + "not supported by this method"); } return false; }
public static boolean supported(String method) { if (method.equals("getFreeSpace")) { if (OsVersion.IS_UNIX) return true; if (OsVersion.IS_WINDOWS) { // getFreeSpace do not work on Windows 98. if (System.getProperty("os.name").toLowerCase().indexOf("windows 9") > -1) return (false); return (true); } } else if ("chmod".equals(method)) { if (OsVersion.IS_UNIX) return true; } else if (method.equals("copyFile")) { return true; } else if (method.equals("getPrimaryGroup")) { if (OsVersion.IS_UNIX) return true; } else if (method.equals("getenv")) { return true; } else { throw new RuntimeException("method name " + method + "not supported by this method"); } return false; }
3,241,241
public static boolean supported(String method) { if (method.equals("getFreeSpace")) { if (OsVersion.IS_UNIX) return true; if (OsVersion.IS_WINDOWS) { // getFreeSpace do not work on Windows 98. if (System.getProperty("os.name").toLowerCase().indexOf("windows 9") > -1) return (false); return (true); } } else if (method.equals("chmod")) { if (OsVersion.IS_UNIX) return true; } else if (method.equals("copyFile")) { return true; } else if (method.equals("getPrimaryGroup")) { if (OsVersion.IS_UNIX) return true; } else if (method.equals("getenv")) { return true; } else { throw new RuntimeException("method name " + method + "not supported by this method"); } return false; }
public static boolean supported(String method) { if (method.equals("getFreeSpace")) { if (OsVersion.IS_UNIX) return true; if (OsVersion.IS_WINDOWS) { // getFreeSpace do not work on Windows 98. if (System.getProperty("os.name").toLowerCase().indexOf("windows 9") > -1) return (false); return (true); } } else if (method.equals("chmod")) { if (OsVersion.IS_UNIX) return true; } else if ("copyFile".equals(method)) { return true; } else if (method.equals("getPrimaryGroup")) { if (OsVersion.IS_UNIX) return true; } else if (method.equals("getenv")) { return true; } else { throw new RuntimeException("method name " + method + "not supported by this method"); } return false; }
3,241,242
public static boolean supported(String method) { if (method.equals("getFreeSpace")) { if (OsVersion.IS_UNIX) return true; if (OsVersion.IS_WINDOWS) { // getFreeSpace do not work on Windows 98. if (System.getProperty("os.name").toLowerCase().indexOf("windows 9") > -1) return (false); return (true); } } else if (method.equals("chmod")) { if (OsVersion.IS_UNIX) return true; } else if (method.equals("copyFile")) { return true; } else if (method.equals("getPrimaryGroup")) { if (OsVersion.IS_UNIX) return true; } else if (method.equals("getenv")) { return true; } else { throw new RuntimeException("method name " + method + "not supported by this method"); } return false; }
public static boolean supported(String method) { if (method.equals("getFreeSpace")) { if (OsVersion.IS_UNIX) return true; if (OsVersion.IS_WINDOWS) { // getFreeSpace do not work on Windows 98. if (System.getProperty("os.name").toLowerCase().indexOf("windows 9") > -1) return (false); return (true); } } else if (method.equals("chmod")) { if (OsVersion.IS_UNIX) return true; } else if (method.equals("copyFile")) { return true; } else if ("getPrimaryGroup".equals(method)) { if (OsVersion.IS_UNIX) return true; } else if (method.equals("getenv")) { return true; } else { throw new RuntimeException("method name " + method + "not supported by this method"); } return false; }
3,241,243
public static boolean supported(String method) { if (method.equals("getFreeSpace")) { if (OsVersion.IS_UNIX) return true; if (OsVersion.IS_WINDOWS) { // getFreeSpace do not work on Windows 98. if (System.getProperty("os.name").toLowerCase().indexOf("windows 9") > -1) return (false); return (true); } } else if (method.equals("chmod")) { if (OsVersion.IS_UNIX) return true; } else if (method.equals("copyFile")) { return true; } else if (method.equals("getPrimaryGroup")) { if (OsVersion.IS_UNIX) return true; } else if (method.equals("getenv")) { return true; } else { throw new RuntimeException("method name " + method + "not supported by this method"); } return false; }
public static boolean supported(String method) { if (method.equals("getFreeSpace")) { if (OsVersion.IS_UNIX) return true; if (OsVersion.IS_WINDOWS) { // getFreeSpace do not work on Windows 98. if (System.getProperty("os.name").toLowerCase().indexOf("windows 9") > -1) return (false); return (true); } } else if (method.equals("chmod")) { if (OsVersion.IS_UNIX) return true; } else if (method.equals("copyFile")) { return true; } else if (method.equals("getPrimaryGroup")) { if (OsVersion.IS_UNIX) return true; } else if ("getenv".equals(method)) { return true; } else { throw new RuntimeException("method name " + method + "not supported by this method"); } return false; }
3,241,244
public LinkedList generatePDepODEReactionList(ReactionModel p_reactionModel, SystemSnapshot p_beginStatus, Temperature p_temperature, Pressure p_pressure) { //#[ operation generatePDepODEReactionList(ReactionModel,SystemSnapshot,Temperature,Pressure) LinkedList nonPDepList = new LinkedList(); LinkedList pDepList = new LinkedList(); HashSet pDepStructureSet = new HashSet(); for (Iterator iter = PDepNetwork.getDictionary().values().iterator(); iter.hasNext(); ) { PDepNetwork pdn = (PDepNetwork)iter.next(); for (Iterator pdniter = pdn.getPDepNetReactionList(); pdniter.hasNext();) { PDepNetReaction pdnr = (PDepNetReaction)pdniter.next(); if (!pdnr.reactantEqualsProduct()) { if (p_reactionModel instanceof CoreEdgeReactionModel) { if (((CoreEdgeReactionModel)p_reactionModel).isReactedReaction(pdnr)) { pDepList.add(pdnr); pDepStructureSet.add(pdnr.getStructure()); } } else { pDepList.add(pdnr); pDepStructureSet.add(pdnr.getStructure()); } } } } //System.out.println("Total Number of pressure dependent reactions are "+ pDepList.size()); for (Iterator iter = p_reactionModel.getReactionSet().iterator(); iter.hasNext(); ) { Reaction r = (Reaction)iter.next(); if (!r.reactantEqualsProduct() && !(r instanceof ThirdBodyReaction) && !(r instanceof TROEReaction)) { Structure s = r.getStructure(); if (!pDepStructureSet.contains(s)) { nonPDepList.add(r); } } } //System.out.println("Total Number of non pressure dependent reactions are "+ nonPDepList.size()); int size = nonPDepList.size() + pDepList.size(); reactionList = new ODEReaction[size]; LinkedList all = new LinkedList(); int id = 0; //System.out.println("non p_dep reactions: " + nonPDepList.size() ); for (Iterator iter = nonPDepList.iterator(); iter.hasNext(); ) { Reaction r = (Reaction)iter.next(); if (!(r instanceof ThirdBodyReaction) && !(r instanceof TROEReaction)){ all.add(r); ODEReaction or = transferReaction(r, p_beginStatus, p_temperature, p_pressure); reactionList[id] = or; id++; } //double rate = r.calculateRate(p_temperature); //if (r instanceof TemplateReaction) rate = ((TemplateReaction)r).calculatePDepRate(p_temperature); //System.out.println(r.getStructure().toString()+"\t rate = \t"+ String.valueOf(rate)); //System.out.println(r.toChemkinString()); } //System.out.println("p_dep reactions: " + pDepList.size()); for (Iterator iter = pDepList.iterator(); iter.hasNext(); ) { Reaction r = (Reaction)iter.next(); all.add(r); ODEReaction or = transferReaction(r, p_beginStatus, p_temperature, p_pressure); reactionList[id] = or; //System.out.println(r.getStructure().toString() + "\t rate = \t" + Double.toString(or.getRate())); //System.out.println(r.toChemkinString()); id++; } return all; //#] }
public LinkedList generatePDepODEReactionList(ReactionModel p_reactionModel, SystemSnapshot p_beginStatus, Temperature p_temperature, Pressure p_pressure) { //#[ operation generatePDepODEReactionList(ReactionModel,SystemSnapshot,Temperature,Pressure) LinkedList nonPDepList = new LinkedList(); LinkedList pDepList = new LinkedList(); HashSet pDepStructureSet = new HashSet(); for (Iterator iter = PDepNetwork.getDictionary().values().iterator(); iter.hasNext(); ) { PDepNetwork pdn = (PDepNetwork)iter.next(); for (Iterator pdniter = pdn.getPDepNetReactionList(); pdniter.hasNext();) { PDepNetReaction pdnr = (PDepNetReaction)pdniter.next(); if (!pdnr.reactantEqualsProduct()) { if (p_reactionModel instanceof CoreEdgeReactionModel) { if (((CoreEdgeReactionModel)p_reactionModel).isReactedReaction(pdnr)) { pDepList.add(pdnr); pDepStructureSet.add(pdnr.getStructure()); } } else { pDepList.add(pdnr); pDepStructureSet.add(pdnr.getStructure()); } } } } //System.out.println("Total Number of pressure dependent reactions are "+ pDepList.size()); for (Iterator iter = p_reactionModel.getReactionSet().iterator(); iter.hasNext(); ) { Reaction r = (Reaction)iter.next(); if (!r.reactantEqualsProduct() && !(r instanceof ThirdBodyReaction) && !(r instanceof TROEReaction)) { Structure s = r.getStructure(); if (!pDepStructureSet.contains(s)) { nonPDepList.add(r); } } } //System.out.println("Total Number of non pressure dependent reactions are "+ nonPDepList.size()); int size = nonPDepList.size() + pDepList.size(); reactionList = new ODEReaction[size]; LinkedList all = new LinkedList(); int id = 0; //System.out.println("non p_dep reactions: " + nonPDepList.size() ); for (Iterator iter = nonPDepList.iterator(); iter.hasNext(); ) { Reaction r = (Reaction)iter.next(); if (!(r instanceof ThirdBodyReaction) && !(r instanceof TROEReaction)){ all.add(r); ODEReaction or = transferReaction(r, p_beginStatus, p_temperature, p_pressure); reactionList[id] = or; id++; } //double rate = r.calculateRate(p_temperature); //if (r instanceof TemplateReaction) rate = ((TemplateReaction)r).calculatePDepRate(p_temperature); //System.out.println(r.getStructure().toString()+"\t rate = \t"+ String.valueOf(rate)); //System.out.println(r.toChemkinString()); } //System.out.println("p_dep reactions: " + pDepList.size()); for (Iterator iter = pDepList.iterator(); iter.hasNext(); ) { Reaction r = (Reaction)iter.next(); all.add(r); ODEReaction or = transferReaction(r, p_beginStatus, p_temperature, p_pressure); reactionList[id] = or; //System.out.println(r.getStructure().toString() + "\t rate = \t" + Double.toString(or.getRate())); //System.out.println(r.toChemkinString()); id++; } return all; //#] }
3,241,245
public LinkedList generatePDepODEReactionList(ReactionModel p_reactionModel, SystemSnapshot p_beginStatus, Temperature p_temperature, Pressure p_pressure) { //#[ operation generatePDepODEReactionList(ReactionModel,SystemSnapshot,Temperature,Pressure) LinkedList nonPDepList = new LinkedList(); LinkedList pDepList = new LinkedList(); HashSet pDepStructureSet = new HashSet(); for (Iterator iter = PDepNetwork.getDictionary().values().iterator(); iter.hasNext(); ) { PDepNetwork pdn = (PDepNetwork)iter.next(); for (Iterator pdniter = pdn.getPDepNetReactionList(); pdniter.hasNext();) { PDepNetReaction pdnr = (PDepNetReaction)pdniter.next(); if (!pdnr.reactantEqualsProduct()) { if (p_reactionModel instanceof CoreEdgeReactionModel) { if (((CoreEdgeReactionModel)p_reactionModel).isReactedReaction(pdnr)) { pDepList.add(pdnr); pDepStructureSet.add(pdnr.getStructure()); } } else { pDepList.add(pdnr); pDepStructureSet.add(pdnr.getStructure()); } } } } //System.out.println("Total Number of pressure dependent reactions are "+ pDepList.size()); for (Iterator iter = p_reactionModel.getReactionSet().iterator(); iter.hasNext(); ) { Reaction r = (Reaction)iter.next(); if (!r.reactantEqualsProduct() && !(r instanceof ThirdBodyReaction) && !(r instanceof TROEReaction)) { Structure s = r.getStructure(); if (!pDepStructureSet.contains(s)) { nonPDepList.add(r); } } } //System.out.println("Total Number of non pressure dependent reactions are "+ nonPDepList.size()); int size = nonPDepList.size() + pDepList.size(); reactionList = new ODEReaction[size]; LinkedList all = new LinkedList(); int id = 0; //System.out.println("non p_dep reactions: " + nonPDepList.size() ); for (Iterator iter = nonPDepList.iterator(); iter.hasNext(); ) { Reaction r = (Reaction)iter.next(); if (!(r instanceof ThirdBodyReaction) && !(r instanceof TROEReaction)){ all.add(r); ODEReaction or = transferReaction(r, p_beginStatus, p_temperature, p_pressure); reactionList[id] = or; id++; } //double rate = r.calculateRate(p_temperature); //if (r instanceof TemplateReaction) rate = ((TemplateReaction)r).calculatePDepRate(p_temperature); //System.out.println(r.getStructure().toString()+"\t rate = \t"+ String.valueOf(rate)); //System.out.println(r.toChemkinString()); } //System.out.println("p_dep reactions: " + pDepList.size()); for (Iterator iter = pDepList.iterator(); iter.hasNext(); ) { Reaction r = (Reaction)iter.next(); all.add(r); ODEReaction or = transferReaction(r, p_beginStatus, p_temperature, p_pressure); reactionList[id] = or; //System.out.println(r.getStructure().toString() + "\t rate = \t" + Double.toString(or.getRate())); //System.out.println(r.toChemkinString()); id++; } return all; //#] }
public LinkedList generatePDepODEReactionList(ReactionModel p_reactionModel, SystemSnapshot p_beginStatus, Temperature p_temperature, Pressure p_pressure) { //#[ operation generatePDepODEReactionList(ReactionModel,SystemSnapshot,Temperature,Pressure) LinkedList nonPDepList = new LinkedList(); LinkedList pDepList = new LinkedList(); HashSet pDepStructureSet = new HashSet(); for (Iterator iter = PDepNetwork.getDictionary().values().iterator(); iter.hasNext(); ) { PDepNetwork pdn = (PDepNetwork)iter.next(); for (Iterator pdniter = pdn.getPDepNetReactionList(); pdniter.hasNext();) { PDepNetReaction pdnr = (PDepNetReaction)pdniter.next(); if (!pdnr.reactantEqualsProduct()) { if (p_reactionModel instanceof CoreEdgeReactionModel) { if (((CoreEdgeReactionModel)p_reactionModel).isReactedReaction(pdnr)) { pDepList.add(pdnr); pDepStructureSet.add(pdnr.getStructure()); } } else { pDepList.add(pdnr); pDepStructureSet.add(pdnr.getStructure()); } } } } //System.out.println("Total Number of pressure dependent reactions are "+ pDepList.size()); for (Iterator iter = p_reactionModel.getReactionSet().iterator(); iter.hasNext(); ) { Reaction r = (Reaction)iter.next(); if (!r.reactantEqualsProduct() && !(r instanceof ThirdBodyReaction) && !(r instanceof TROEReaction)) { Structure s = r.getStructure(); if (!pDepStructureSet.contains(s)) { nonPDepList.add(r); } } } //System.out.println("Total Number of non pressure dependent reactions are "+ nonPDepList.size()); int size = nonPDepList.size() + pDepList.size(); reactionList = new ODEReaction[size]; LinkedList all = new LinkedList(); int id = 0; //System.out.println("non p_dep reactions: " + nonPDepList.size() ); for (Iterator iter = nonPDepList.iterator(); iter.hasNext(); ) { Reaction r = (Reaction)iter.next(); if (!(r instanceof ThirdBodyReaction) && !(r instanceof TROEReaction)){ all.add(r); ODEReaction or = transferReaction(r, p_beginStatus, p_temperature, p_pressure); reactionList[id] = or; id++; } //double rate = r.calculateRate(p_temperature); //if (r instanceof TemplateReaction) rate = ((TemplateReaction)r).calculatePDepRate(p_temperature); //System.out.println(r.getStructure().toString()+"\t rate = \t"+ String.valueOf(rate)); //System.out.println(r.toChemkinString()); } //System.out.println("p_dep reactions: " + pDepList.size()); for (Iterator iter = pDepList.iterator(); iter.hasNext(); ) { Reaction r = (Reaction)iter.next(); all.add(r); ODEReaction or = transferReaction(r, p_beginStatus, p_temperature, p_pressure); reactionList[id] = or; //System.out.println(r.getStructure().toString() + "\t rate = \t" + Double.toString(or.getRate())); //System.out.println(r.toChemkinString()); id++; } return all; //#] }
3,241,246
public LinkedList generatePDepODEReactionList(ReactionModel p_reactionModel, SystemSnapshot p_beginStatus, Temperature p_temperature, Pressure p_pressure) { //#[ operation generatePDepODEReactionList(ReactionModel,SystemSnapshot,Temperature,Pressure) LinkedList nonPDepList = new LinkedList(); LinkedList pDepList = new LinkedList(); HashSet pDepStructureSet = new HashSet(); for (Iterator iter = PDepNetwork.getDictionary().values().iterator(); iter.hasNext(); ) { PDepNetwork pdn = (PDepNetwork)iter.next(); for (Iterator pdniter = pdn.getPDepNetReactionList(); pdniter.hasNext();) { PDepNetReaction pdnr = (PDepNetReaction)pdniter.next(); if (!pdnr.reactantEqualsProduct()) { if (p_reactionModel instanceof CoreEdgeReactionModel) { if (((CoreEdgeReactionModel)p_reactionModel).isReactedReaction(pdnr)) { pDepList.add(pdnr); pDepStructureSet.add(pdnr.getStructure()); } } else { pDepList.add(pdnr); pDepStructureSet.add(pdnr.getStructure()); } } } } //System.out.println("Total Number of pressure dependent reactions are "+ pDepList.size()); for (Iterator iter = p_reactionModel.getReactionSet().iterator(); iter.hasNext(); ) { Reaction r = (Reaction)iter.next(); if (!r.reactantEqualsProduct() && !(r instanceof ThirdBodyReaction) && !(r instanceof TROEReaction)) { Structure s = r.getStructure(); if (!pDepStructureSet.contains(s)) { nonPDepList.add(r); } } } //System.out.println("Total Number of non pressure dependent reactions are "+ nonPDepList.size()); int size = nonPDepList.size() + pDepList.size(); reactionList = new ODEReaction[size]; LinkedList all = new LinkedList(); int id = 0; //System.out.println("non p_dep reactions: " + nonPDepList.size() ); for (Iterator iter = nonPDepList.iterator(); iter.hasNext(); ) { Reaction r = (Reaction)iter.next(); if (!(r instanceof ThirdBodyReaction) && !(r instanceof TROEReaction)){ all.add(r); ODEReaction or = transferReaction(r, p_beginStatus, p_temperature, p_pressure); reactionList[id] = or; id++; } //double rate = r.calculateRate(p_temperature); //if (r instanceof TemplateReaction) rate = ((TemplateReaction)r).calculatePDepRate(p_temperature); //System.out.println(r.getStructure().toString()+"\t rate = \t"+ String.valueOf(rate)); //System.out.println(r.toChemkinString()); } //System.out.println("p_dep reactions: " + pDepList.size()); for (Iterator iter = pDepList.iterator(); iter.hasNext(); ) { Reaction r = (Reaction)iter.next(); all.add(r); ODEReaction or = transferReaction(r, p_beginStatus, p_temperature, p_pressure); reactionList[id] = or; //System.out.println(r.getStructure().toString() + "\t rate = \t" + Double.toString(or.getRate())); //System.out.println(r.toChemkinString()); id++; } return all; //#] }
public LinkedList generatePDepODEReactionList(ReactionModel p_reactionModel, SystemSnapshot p_beginStatus, Temperature p_temperature, Pressure p_pressure) { //#[ operation generatePDepODEReactionList(ReactionModel,SystemSnapshot,Temperature,Pressure) LinkedList nonPDepList = new LinkedList(); LinkedList pDepList = new LinkedList(); HashSet pDepStructureSet = new HashSet(); for (Iterator iter = PDepNetwork.getDictionary().values().iterator(); iter.hasNext(); ) { PDepNetwork pdn = (PDepNetwork)iter.next(); for (Iterator pdniter = pdn.getPDepNetReactionList(); pdniter.hasNext();) { PDepNetReaction pdnr = (PDepNetReaction)pdniter.next(); if (!pdnr.reactantEqualsProduct()) { if (p_reactionModel instanceof CoreEdgeReactionModel) { if (((CoreEdgeReactionModel)p_reactionModel).isReactedReaction(pdnr)) { pDepList.add(pdnr); pDepStructureSet.add(pdnr.getStructure()); } } else { pDepList.add(pdnr); pDepStructureSet.add(pdnr.getStructure()); } } } } //System.out.println("Total Number of pressure dependent reactions are "+ pDepList.size()); for (Iterator iter = p_reactionModel.getReactionSet().iterator(); iter.hasNext(); ) { Reaction r = (Reaction)iter.next(); if (!r.reactantEqualsProduct() && !(r instanceof ThirdBodyReaction) && !(r instanceof TROEReaction)) { Structure s = r.getStructure(); if (!pDepStructureSet.contains(s)) { nonPDepList.add(r); } } } //System.out.println("Total Number of non pressure dependent reactions are "+ nonPDepList.size()); int size = nonPDepList.size() + pDepList.size(); reactionList = new ODEReaction[size]; LinkedList all = new LinkedList(); int id = 0; //System.out.println("non p_dep reactions: " + nonPDepList.size() ); for (Iterator iter = nonPDepList.iterator(); iter.hasNext(); ) { Reaction r = (Reaction)iter.next(); if (!(r instanceof ThirdBodyReaction) && !(r instanceof TROEReaction)){ all.add(r); ODEReaction or = transferReaction(r, p_beginStatus, p_temperature, p_pressure); reactionList[id] = or; id++; } //double rate = r.calculateRate(p_temperature); //if (r instanceof TemplateReaction) rate = ((TemplateReaction)r).calculatePDepRate(p_temperature); //System.out.println(r.getStructure().toString()+"\t rate = \t"+ String.valueOf(rate)); //System.out.println(r.toChemkinString()); } //System.out.println("p_dep reactions: " + pDepList.size()); for (Iterator iter = pDepList.iterator(); iter.hasNext(); ) { Reaction r = (Reaction)iter.next(); all.add(r); ODEReaction or = transferReaction(r, p_beginStatus, p_temperature, p_pressure); reactionList[id] = or; //System.out.println(r.getStructure().toString() + "\t rate = \t" + Double.toString(or.getRate())); //System.out.println(r.toChemkinString()); id++; } return all; //#] }
3,241,247
private void generateTROEReactionList(ReactionModel p_reactionModel, SystemSnapshot p_beginStatus, Temperature p_temperature, Pressure p_pressure) { int size = p_reactionModel.getReactionSet().size(); TROEODEReaction [] result = new TROEODEReaction[size]; int thirdID = 0; Iterator iter = p_reactionModel.getReactionSet().iterator(); while (iter.hasNext()) { Reaction r = (Reaction)iter.next(); if (r instanceof TROEReaction) { thirdID++; TROEODEReaction or = (TROEODEReaction)transferReaction(r, p_beginStatus, p_temperature, p_pressure); result[thirdID-1] = or; } } troeReactionList = new TROEODEReaction[thirdID]; for (int i = 0; i < thirdID; i++) { troeReactionList[i] = result[i]; } return; }
private void generateTROEReactionList(ReactionModel p_reactionModel, SystemSnapshot p_beginStatus, Temperature p_temperature, Pressure p_pressure) { int size = p_reactionModel.getReactionSet().size(); TROEODEReaction [] result = new TROEODEReaction[size]; int thirdID = 0; Iterator iter = p_reactionModel.getReactionSet().iterator(); while (iter.hasNext()) { Reaction r = (Reaction)iter.next(); if (r instanceof TROEReaction) { thirdID++; TROEODEReaction or = (TROEODEReaction)transferReaction(r, p_beginStatus, p_temperature, p_pressure); result[thirdID-1] = or; } } troeReactionList = new TROEODEReaction[thirdID]; for (int i = 0; i < thirdID; i++) { troeReactionList[i] = result[i]; } return; }
3,241,248
public SystemSnapshot solve(boolean p_initialization, ReactionModel p_reactionModel, boolean p_reactionChanged, SystemSnapshot p_beginStatus, ReactionTime p_beginTime, ReactionTime p_endTime, Temperature p_temperature, Pressure p_pressure, boolean p_conditionChanged) { //#[ operation solve(boolean,ReactionModel,boolean,SystemSnapshot,ReactionTime,ReactionTime,Temperature,Pressure,boolean) ReactionTime rt = p_beginStatus.getTime(); if (!rt.equals(p_beginTime)) throw new InvalidBeginStatusException(); // set time double tBegin = p_beginTime.getStandardTime(); double tEnd = p_endTime.getStandardTime(); // set reaction set //if (p_initialization || p_reactionChanged || p_conditionChanged) { generateTROEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); generateThirdBodyReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); LinkedList rList = generatePDepODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //generateAllODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //p_reactionChanged = true; //} // set numbers //System.out.println("Total number of reactions to Daspk is "+rList.size()); int nState = p_reactionModel.getSpeciesNumber(); int nParameter = 0; LinkedList initialSpecies = new LinkedList();// if (parameterInfor!=null) nParameter = parameterInfor.length; if (parameterInfor != 0) { nParameter = rList.size()+thirdBodyReactionList.length; //svp if (initialStatus == null) System.out.println("initialStatus = null"); Iterator spe_iter = initialStatus.getSpeciesStatus(); while (spe_iter.hasNext()) { SpeciesStatus ss = (SpeciesStatus) spe_iter.next(); String name = ss.getSpecies().getName(); initialSpecies.add(name); nParameter++; } } int neq = nState*(nParameter+1); // set temperature and pressure double T = p_temperature.getK(); double P = p_pressure.getAtm(); // set initial value of y and yprime; double [] y = new double[neq]; double [] yprime = new double[neq]; //double numberOfReactedSpecies=0; // get the present status at t_begin, and set y and y' accordingly System.out.println("Before ODE: " + String.valueOf(tBegin) + "SEC"); System.out.println("End at : " + String.valueOf(tEnd) + "SEC"); for (Iterator iter = p_beginStatus.getSpeciesStatus(); iter.hasNext(); ) { SpeciesStatus ss = (SpeciesStatus)iter.next(); double conc = ss.getConcentration(); double flux = ss.getFlux(); if (ss.isReactedSpecies()) { Species spe = ss.getSpecies(); int id = getRealID(spe); System.out.println(String.valueOf(spe.getID()) + '\t' + spe.getName() + '\t' + String.valueOf(conc) + '\t' + String.valueOf(flux)); y[id-1] = conc; yprime[id-1] = flux; } } if (nParameter != 0){//svp parameterInforArray = new ParameterInfor[nParameter]; for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ parameterInforArray[i-1] = new ParameterInfor("k",i,0.00); } for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ parameterInforArray[i - 1] = new ParameterInfor("CO", nParameter, 0.00); } if (p_beginTime.getTime() == 0 || p_beginTime.getTime() == 0.00) { LinkedList sensitivityStatus = new LinkedList(); int reactionNumber = rList.size()+thirdBodyReactionList.length; int speciesNumber = p_reactionModel.getSpeciesNumber();// for (int i=0;i<reactionNumber*speciesNumber;i++){ for (int i=0; i<nParameter*speciesNumber;i++){ sensitivityStatus.add(i,null); } p_beginStatus.addSensitivity(sensitivityStatus); double sflux = 1; Iterator species_iter = p_reactionModel.getSpecies(); while (species_iter.hasNext()) { Species spe = (Species) species_iter.next(); int m = getRealID(spe); for (int p=0;p<nParameter;p++){ int k = m + (p+1) * speciesNumber - 1; //if (p >= rList.size()){ if (p >= reactionNumber){ int speciesNum = p-rList.size()-thirdBodyReactionList.length; String name = (String)initialSpecies.get(speciesNum); sflux = 0; SensitivityStatus senStatus; if (name.equalsIgnoreCase(spe.getName())){ senStatus = new SensitivityStatus(1, sflux, m, p + 1); y[k] = 1; } else{ senStatus = new SensitivityStatus(0,sflux,m,p+1); y[k]=0; } sensitivityStatus.add(k - p_reactionModel.getSpeciesNumber(), senStatus); p_beginStatus.putSensitivityStatus(k - speciesNumber, senStatus); yprime[k] = sflux; } else{ if (p < rList.size()){ Reaction rxn = (Reaction)rList.get(p); if (rxn.containsAsProduct(spe)) { sflux = 1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } if (rxn.containsAsReactant(spe)) { sflux = -1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } else { sflux = 0; } SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } } } } } else { for (int i = p_reactionModel.getSpeciesNumber(); i < y.length; i++) { SensitivityStatus ss = (SensitivityStatus) p_beginStatus. getSensitivityStatus(i-p_reactionModel.getSpeciesNumber()); double sens = ss.getSensitivity(); double sflux = ss.getSFlux(); int reactionNumber = rList.size(); int speciesNumber = p_reactionModel.getSpeciesNumber(); Iterator species_iter = p_reactionModel.getSpecies(); y[i] = sens; yprime[i] = sflux; } } } //System.out.println("Number of Reacted Species is " + numberOfReactedSpecies); int idid; HashMap speStatus = new HashMap(); LinkedList senStatus = new LinkedList(); double[] tPresent = {tBegin}; int temp = 1; if (nParameter==0) { idid = solveDAE(p_initialization, reactionList, true, thirdBodyReactionList, troeReactionList, nState, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid !=1 && idid != 2 && idid != 3) { System.out.println("The idid from DASPK was "+idid + " at time "+tPresent[0]); throw new DynamicSimulatorException("DASPK: SA off."); } System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, 0); } else { idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid != 2 && idid != 3) throw new DynamicSimulatorException("DASPK: SA on."); //speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); senStatus = generateSensitivityStatus(p_reactionModel,y,yprime,nParameter); SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, senStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); sss.setIDTranslator(IDTranslator); sss.setReactionList(rList); return sss; } SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CH4"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO2"), rList, sss, p_temperature); return sss; //#] }
public SystemSnapshot solve(boolean p_initialization, ReactionModel p_reactionModel, boolean p_reactionChanged, SystemSnapshot p_beginStatus, ReactionTime p_beginTime, ReactionTime p_endTime, Temperature p_temperature, Pressure p_pressure, boolean p_conditionChanged) { //#[ operation solve(boolean,ReactionModel,boolean,SystemSnapshot,ReactionTime,ReactionTime,Temperature,Pressure,boolean) ReactionTime rt = p_beginStatus.getTime(); if (!rt.equals(p_beginTime)) throw new InvalidBeginStatusException(); // set time double tBegin = p_beginTime.getStandardTime(); double tEnd = p_endTime.getStandardTime(); // set reaction set //if (p_initialization || p_reactionChanged || p_conditionChanged) { generateTROEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); generateThirdBodyReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); LinkedList rList = generatePDepODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //generateAllODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //p_reactionChanged = true; //} // set numbers //System.out.println("Total number of reactions to Daspk is "+rList.size()); int nState = p_reactionModel.getSpeciesNumber(); int nParameter = 0; LinkedList initialSpecies = new LinkedList();// if (parameterInfor!=null) nParameter = parameterInfor.length; if (parameterInfor != 0) { nParameter = rList.size()+thirdBodyReactionList.length+troeReactionList.length; //svp if (initialStatus == null) System.out.println("initialStatus = null"); Iterator spe_iter = initialStatus.getSpeciesStatus(); while (spe_iter.hasNext()) { SpeciesStatus ss = (SpeciesStatus) spe_iter.next(); String name = ss.getSpecies().getName(); initialSpecies.add(name); nParameter++; } } int neq = nState*(nParameter+1); // set temperature and pressure double T = p_temperature.getK(); double P = p_pressure.getAtm(); // set initial value of y and yprime; double [] y = new double[neq]; double [] yprime = new double[neq]; //double numberOfReactedSpecies=0; // get the present status at t_begin, and set y and y' accordingly System.out.println("Before ODE: " + String.valueOf(tBegin) + "SEC"); System.out.println("End at : " + String.valueOf(tEnd) + "SEC"); for (Iterator iter = p_beginStatus.getSpeciesStatus(); iter.hasNext(); ) { SpeciesStatus ss = (SpeciesStatus)iter.next(); double conc = ss.getConcentration(); double flux = ss.getFlux(); if (ss.isReactedSpecies()) { Species spe = ss.getSpecies(); int id = getRealID(spe); System.out.println(String.valueOf(spe.getID()) + '\t' + spe.getName() + '\t' + String.valueOf(conc) + '\t' + String.valueOf(flux)); y[id-1] = conc; yprime[id-1] = flux; } } if (nParameter != 0){//svp parameterInforArray = new ParameterInfor[nParameter]; for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ parameterInforArray[i-1] = new ParameterInfor("k",i,0.00); } for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ parameterInforArray[i - 1] = new ParameterInfor("CO", nParameter, 0.00); } if (p_beginTime.getTime() == 0 || p_beginTime.getTime() == 0.00) { LinkedList sensitivityStatus = new LinkedList(); int reactionNumber = rList.size()+thirdBodyReactionList.length; int speciesNumber = p_reactionModel.getSpeciesNumber();// for (int i=0;i<reactionNumber*speciesNumber;i++){ for (int i=0; i<nParameter*speciesNumber;i++){ sensitivityStatus.add(i,null); } p_beginStatus.addSensitivity(sensitivityStatus); double sflux = 1; Iterator species_iter = p_reactionModel.getSpecies(); while (species_iter.hasNext()) { Species spe = (Species) species_iter.next(); int m = getRealID(spe); for (int p=0;p<nParameter;p++){ int k = m + (p+1) * speciesNumber - 1; //if (p >= rList.size()){ if (p >= reactionNumber){ int speciesNum = p-rList.size()-thirdBodyReactionList.length; String name = (String)initialSpecies.get(speciesNum); sflux = 0; SensitivityStatus senStatus; if (name.equalsIgnoreCase(spe.getName())){ senStatus = new SensitivityStatus(1, sflux, m, p + 1); y[k] = 1; } else{ senStatus = new SensitivityStatus(0,sflux,m,p+1); y[k]=0; } sensitivityStatus.add(k - p_reactionModel.getSpeciesNumber(), senStatus); p_beginStatus.putSensitivityStatus(k - speciesNumber, senStatus); yprime[k] = sflux; } else{ if (p < rList.size()){ Reaction rxn = (Reaction)rList.get(p); if (rxn.containsAsProduct(spe)) { sflux = 1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } if (rxn.containsAsReactant(spe)) { sflux = -1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } else { sflux = 0; } SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } } } } } else { for (int i = p_reactionModel.getSpeciesNumber(); i < y.length; i++) { SensitivityStatus ss = (SensitivityStatus) p_beginStatus. getSensitivityStatus(i-p_reactionModel.getSpeciesNumber()); double sens = ss.getSensitivity(); double sflux = ss.getSFlux(); int reactionNumber = rList.size(); int speciesNumber = p_reactionModel.getSpeciesNumber(); Iterator species_iter = p_reactionModel.getSpecies(); y[i] = sens; yprime[i] = sflux; } } } //System.out.println("Number of Reacted Species is " + numberOfReactedSpecies); int idid; HashMap speStatus = new HashMap(); LinkedList senStatus = new LinkedList(); double[] tPresent = {tBegin}; int temp = 1; if (nParameter==0) { idid = solveDAE(p_initialization, reactionList, true, thirdBodyReactionList, troeReactionList, nState, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid !=1 && idid != 2 && idid != 3) { System.out.println("The idid from DASPK was "+idid + " at time "+tPresent[0]); throw new DynamicSimulatorException("DASPK: SA off."); } System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, 0); } else { idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid != 2 && idid != 3) throw new DynamicSimulatorException("DASPK: SA on."); //speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); senStatus = generateSensitivityStatus(p_reactionModel,y,yprime,nParameter); SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, senStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); sss.setIDTranslator(IDTranslator); sss.setReactionList(rList); return sss; } SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CH4"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO2"), rList, sss, p_temperature); return sss; //#] }
3,241,250
public SystemSnapshot solve(boolean p_initialization, ReactionModel p_reactionModel, boolean p_reactionChanged, SystemSnapshot p_beginStatus, ReactionTime p_beginTime, ReactionTime p_endTime, Temperature p_temperature, Pressure p_pressure, boolean p_conditionChanged) { //#[ operation solve(boolean,ReactionModel,boolean,SystemSnapshot,ReactionTime,ReactionTime,Temperature,Pressure,boolean) ReactionTime rt = p_beginStatus.getTime(); if (!rt.equals(p_beginTime)) throw new InvalidBeginStatusException(); // set time double tBegin = p_beginTime.getStandardTime(); double tEnd = p_endTime.getStandardTime(); // set reaction set //if (p_initialization || p_reactionChanged || p_conditionChanged) { generateTROEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); generateThirdBodyReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); LinkedList rList = generatePDepODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //generateAllODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //p_reactionChanged = true; //} // set numbers //System.out.println("Total number of reactions to Daspk is "+rList.size()); int nState = p_reactionModel.getSpeciesNumber(); int nParameter = 0; LinkedList initialSpecies = new LinkedList();// if (parameterInfor!=null) nParameter = parameterInfor.length; if (parameterInfor != 0) { nParameter = rList.size()+thirdBodyReactionList.length; //svp if (initialStatus == null) System.out.println("initialStatus = null"); Iterator spe_iter = initialStatus.getSpeciesStatus(); while (spe_iter.hasNext()) { SpeciesStatus ss = (SpeciesStatus) spe_iter.next(); String name = ss.getSpecies().getName(); initialSpecies.add(name); nParameter++; } } int neq = nState*(nParameter+1); // set temperature and pressure double T = p_temperature.getK(); double P = p_pressure.getAtm(); // set initial value of y and yprime; double [] y = new double[neq]; double [] yprime = new double[neq]; //double numberOfReactedSpecies=0; // get the present status at t_begin, and set y and y' accordingly System.out.println("Before ODE: " + String.valueOf(tBegin) + "SEC"); System.out.println("End at : " + String.valueOf(tEnd) + "SEC"); for (Iterator iter = p_beginStatus.getSpeciesStatus(); iter.hasNext(); ) { SpeciesStatus ss = (SpeciesStatus)iter.next(); double conc = ss.getConcentration(); double flux = ss.getFlux(); if (ss.isReactedSpecies()) { Species spe = ss.getSpecies(); int id = getRealID(spe); System.out.println(String.valueOf(spe.getID()) + '\t' + spe.getName() + '\t' + String.valueOf(conc) + '\t' + String.valueOf(flux)); y[id-1] = conc; yprime[id-1] = flux; } } if (nParameter != 0){//svp parameterInforArray = new ParameterInfor[nParameter]; for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ parameterInforArray[i-1] = new ParameterInfor("k",i,0.00); } for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ parameterInforArray[i - 1] = new ParameterInfor("CO", nParameter, 0.00); } if (p_beginTime.getTime() == 0 || p_beginTime.getTime() == 0.00) { LinkedList sensitivityStatus = new LinkedList(); int reactionNumber = rList.size()+thirdBodyReactionList.length; int speciesNumber = p_reactionModel.getSpeciesNumber();// for (int i=0;i<reactionNumber*speciesNumber;i++){ for (int i=0; i<nParameter*speciesNumber;i++){ sensitivityStatus.add(i,null); } p_beginStatus.addSensitivity(sensitivityStatus); double sflux = 1; Iterator species_iter = p_reactionModel.getSpecies(); while (species_iter.hasNext()) { Species spe = (Species) species_iter.next(); int m = getRealID(spe); for (int p=0;p<nParameter;p++){ int k = m + (p+1) * speciesNumber - 1; //if (p >= rList.size()){ if (p >= reactionNumber){ int speciesNum = p-rList.size()-thirdBodyReactionList.length; String name = (String)initialSpecies.get(speciesNum); sflux = 0; SensitivityStatus senStatus; if (name.equalsIgnoreCase(spe.getName())){ senStatus = new SensitivityStatus(1, sflux, m, p + 1); y[k] = 1; } else{ senStatus = new SensitivityStatus(0,sflux,m,p+1); y[k]=0; } sensitivityStatus.add(k - p_reactionModel.getSpeciesNumber(), senStatus); p_beginStatus.putSensitivityStatus(k - speciesNumber, senStatus); yprime[k] = sflux; } else{ if (p < rList.size()){ Reaction rxn = (Reaction)rList.get(p); if (rxn.containsAsProduct(spe)) { sflux = 1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } if (rxn.containsAsReactant(spe)) { sflux = -1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } else { sflux = 0; } SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } } } } } else { for (int i = p_reactionModel.getSpeciesNumber(); i < y.length; i++) { SensitivityStatus ss = (SensitivityStatus) p_beginStatus. getSensitivityStatus(i-p_reactionModel.getSpeciesNumber()); double sens = ss.getSensitivity(); double sflux = ss.getSFlux(); int reactionNumber = rList.size(); int speciesNumber = p_reactionModel.getSpeciesNumber(); Iterator species_iter = p_reactionModel.getSpecies(); y[i] = sens; yprime[i] = sflux; } } } //System.out.println("Number of Reacted Species is " + numberOfReactedSpecies); int idid; HashMap speStatus = new HashMap(); LinkedList senStatus = new LinkedList(); double[] tPresent = {tBegin}; int temp = 1; if (nParameter==0) { idid = solveDAE(p_initialization, reactionList, true, thirdBodyReactionList, troeReactionList, nState, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid !=1 && idid != 2 && idid != 3) { System.out.println("The idid from DASPK was "+idid + " at time "+tPresent[0]); throw new DynamicSimulatorException("DASPK: SA off."); } System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, 0); } else { idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid != 2 && idid != 3) throw new DynamicSimulatorException("DASPK: SA on."); //speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); senStatus = generateSensitivityStatus(p_reactionModel,y,yprime,nParameter); SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, senStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); sss.setIDTranslator(IDTranslator); sss.setReactionList(rList); return sss; } SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CH4"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO2"), rList, sss, p_temperature); return sss; //#] }
public SystemSnapshot solve(boolean p_initialization, ReactionModel p_reactionModel, boolean p_reactionChanged, SystemSnapshot p_beginStatus, ReactionTime p_beginTime, ReactionTime p_endTime, Temperature p_temperature, Pressure p_pressure, boolean p_conditionChanged) { //#[ operation solve(boolean,ReactionModel,boolean,SystemSnapshot,ReactionTime,ReactionTime,Temperature,Pressure,boolean) ReactionTime rt = p_beginStatus.getTime(); if (!rt.equals(p_beginTime)) throw new InvalidBeginStatusException(); // set time double tBegin = p_beginTime.getStandardTime(); double tEnd = p_endTime.getStandardTime(); // set reaction set //if (p_initialization || p_reactionChanged || p_conditionChanged) { generateTROEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); generateThirdBodyReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); LinkedList rList = generatePDepODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //generateAllODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //p_reactionChanged = true; //} // set numbers //System.out.println("Total number of reactions to Daspk is "+rList.size()); int nState = p_reactionModel.getSpeciesNumber(); int nParameter = 0; LinkedList initialSpecies = new LinkedList();// if (parameterInfor!=null) nParameter = parameterInfor.length; if (parameterInfor != 0) { nParameter = rList.size()+thirdBodyReactionList.length; //svp if (initialStatus == null) System.out.println("initialStatus = null"); Iterator spe_iter = initialStatus.getSpeciesStatus(); while (spe_iter.hasNext()) { SpeciesStatus ss = (SpeciesStatus) spe_iter.next(); String name = ss.getSpecies().getName(); initialSpecies.add(name); nParameter++; } } int neq = nState*(nParameter+1); // set temperature and pressure double T = p_temperature.getK(); double P = p_pressure.getAtm(); // set initial value of y and yprime; double [] y = new double[neq]; double [] yprime = new double[neq]; //double numberOfReactedSpecies=0; // get the present status at t_begin, and set y and y' accordingly System.out.println("Before ODE: " + String.valueOf(tBegin) + "SEC"); System.out.println("End at : " + String.valueOf(tEnd) + "SEC"); for (Iterator iter = p_beginStatus.getSpeciesStatus(); iter.hasNext(); ) { SpeciesStatus ss = (SpeciesStatus)iter.next(); double conc = ss.getConcentration(); double flux = ss.getFlux(); if (ss.isReactedSpecies()) { Species spe = ss.getSpecies(); int id = getRealID(spe); System.out.println(String.valueOf(spe.getID()) + '\t' + spe.getName() + '\t' + String.valueOf(conc) + '\t' + String.valueOf(flux)); y[id-1] = conc; yprime[id-1] = flux; } } if (nParameter != 0){//svp parameterInforArray = new ParameterInfor[nParameter]; for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ parameterInforArray[i-1] = new ParameterInfor("k",i,0.00); } for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ parameterInforArray[i - 1] = new ParameterInfor("CO", nParameter, 0.00); } if (p_beginTime.getTime() == 0 || p_beginTime.getTime() == 0.00) { LinkedList sensitivityStatus = new LinkedList(); int reactionNumber = rList.size()+thirdBodyReactionList.length; int speciesNumber = p_reactionModel.getSpeciesNumber();// for (int i=0;i<reactionNumber*speciesNumber;i++){ for (int i=0; i<nParameter*speciesNumber;i++){ sensitivityStatus.add(i,null); } p_beginStatus.addSensitivity(sensitivityStatus); double sflux = 1; Iterator species_iter = p_reactionModel.getSpecies(); while (species_iter.hasNext()) { Species spe = (Species) species_iter.next(); int m = getRealID(spe); for (int p=0;p<nParameter;p++){ int k = m + (p+1) * speciesNumber - 1; //if (p >= rList.size()){ if (p >= reactionNumber){ int speciesNum = p-rList.size()-thirdBodyReactionList.length; String name = (String)initialSpecies.get(speciesNum); sflux = 0; SensitivityStatus senStatus; if (name.equalsIgnoreCase(spe.getName())){ senStatus = new SensitivityStatus(1, sflux, m, p + 1); y[k] = 1; } else{ senStatus = new SensitivityStatus(0,sflux,m,p+1); y[k]=0; } sensitivityStatus.add(k - p_reactionModel.getSpeciesNumber(), senStatus); p_beginStatus.putSensitivityStatus(k - speciesNumber, senStatus); yprime[k] = sflux; } else{ if (p < rList.size()){ Reaction rxn = (Reaction)rList.get(p); if (rxn.containsAsProduct(spe)) { sflux = 1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } if (rxn.containsAsReactant(spe)) { sflux = -1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } else { sflux = 0; } SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } } } } } else { for (int i = p_reactionModel.getSpeciesNumber(); i < y.length; i++) { SensitivityStatus ss = (SensitivityStatus) p_beginStatus. getSensitivityStatus(i-p_reactionModel.getSpeciesNumber()); double sens = ss.getSensitivity(); double sflux = ss.getSFlux(); int reactionNumber = rList.size(); int speciesNumber = p_reactionModel.getSpeciesNumber(); Iterator species_iter = p_reactionModel.getSpecies(); y[i] = sens; yprime[i] = sflux; } } } //System.out.println("Number of Reacted Species is " + numberOfReactedSpecies); int idid; HashMap speStatus = new HashMap(); LinkedList senStatus = new LinkedList(); double[] tPresent = {tBegin}; int temp = 1; if (nParameter==0) { idid = solveDAE(p_initialization, reactionList, true, thirdBodyReactionList, troeReactionList, nState, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid !=1 && idid != 2 && idid != 3) { System.out.println("The idid from DASPK was "+idid + " at time "+tPresent[0]); throw new DynamicSimulatorException("DASPK: SA off."); } System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, 0); } else { idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid != 2 && idid != 3) throw new DynamicSimulatorException("DASPK: SA on."); //speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); senStatus = generateSensitivityStatus(p_reactionModel,y,yprime,nParameter); SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, senStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); sss.setIDTranslator(IDTranslator); sss.setReactionList(rList); return sss; } SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CH4"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO2"), rList, sss, p_temperature); return sss; //#] }
3,241,251
public SystemSnapshot solve(boolean p_initialization, ReactionModel p_reactionModel, boolean p_reactionChanged, SystemSnapshot p_beginStatus, ReactionTime p_beginTime, ReactionTime p_endTime, Temperature p_temperature, Pressure p_pressure, boolean p_conditionChanged) { //#[ operation solve(boolean,ReactionModel,boolean,SystemSnapshot,ReactionTime,ReactionTime,Temperature,Pressure,boolean) ReactionTime rt = p_beginStatus.getTime(); if (!rt.equals(p_beginTime)) throw new InvalidBeginStatusException(); // set time double tBegin = p_beginTime.getStandardTime(); double tEnd = p_endTime.getStandardTime(); // set reaction set //if (p_initialization || p_reactionChanged || p_conditionChanged) { generateTROEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); generateThirdBodyReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); LinkedList rList = generatePDepODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //generateAllODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //p_reactionChanged = true; //} // set numbers //System.out.println("Total number of reactions to Daspk is "+rList.size()); int nState = p_reactionModel.getSpeciesNumber(); int nParameter = 0; LinkedList initialSpecies = new LinkedList();// if (parameterInfor!=null) nParameter = parameterInfor.length; if (parameterInfor != 0) { nParameter = rList.size()+thirdBodyReactionList.length; //svp if (initialStatus == null) System.out.println("initialStatus = null"); Iterator spe_iter = initialStatus.getSpeciesStatus(); while (spe_iter.hasNext()) { SpeciesStatus ss = (SpeciesStatus) spe_iter.next(); String name = ss.getSpecies().getName(); initialSpecies.add(name); nParameter++; } } int neq = nState*(nParameter+1); // set temperature and pressure double T = p_temperature.getK(); double P = p_pressure.getAtm(); // set initial value of y and yprime; double [] y = new double[neq]; double [] yprime = new double[neq]; //double numberOfReactedSpecies=0; // get the present status at t_begin, and set y and y' accordingly System.out.println("Before ODE: " + String.valueOf(tBegin) + "SEC"); System.out.println("End at : " + String.valueOf(tEnd) + "SEC"); for (Iterator iter = p_beginStatus.getSpeciesStatus(); iter.hasNext(); ) { SpeciesStatus ss = (SpeciesStatus)iter.next(); double conc = ss.getConcentration(); double flux = ss.getFlux(); if (ss.isReactedSpecies()) { Species spe = ss.getSpecies(); int id = getRealID(spe); System.out.println(String.valueOf(spe.getID()) + '\t' + spe.getName() + '\t' + String.valueOf(conc) + '\t' + String.valueOf(flux)); y[id-1] = conc; yprime[id-1] = flux; } } if (nParameter != 0){//svp parameterInforArray = new ParameterInfor[nParameter]; for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ parameterInforArray[i-1] = new ParameterInfor("k",i,0.00); } for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ parameterInforArray[i - 1] = new ParameterInfor("CO", nParameter, 0.00); } if (p_beginTime.getTime() == 0 || p_beginTime.getTime() == 0.00) { LinkedList sensitivityStatus = new LinkedList(); int reactionNumber = rList.size()+thirdBodyReactionList.length; int speciesNumber = p_reactionModel.getSpeciesNumber();// for (int i=0;i<reactionNumber*speciesNumber;i++){ for (int i=0; i<nParameter*speciesNumber;i++){ sensitivityStatus.add(i,null); } p_beginStatus.addSensitivity(sensitivityStatus); double sflux = 1; Iterator species_iter = p_reactionModel.getSpecies(); while (species_iter.hasNext()) { Species spe = (Species) species_iter.next(); int m = getRealID(spe); for (int p=0;p<nParameter;p++){ int k = m + (p+1) * speciesNumber - 1; //if (p >= rList.size()){ if (p >= reactionNumber){ int speciesNum = p-rList.size()-thirdBodyReactionList.length; String name = (String)initialSpecies.get(speciesNum); sflux = 0; SensitivityStatus senStatus; if (name.equalsIgnoreCase(spe.getName())){ senStatus = new SensitivityStatus(1, sflux, m, p + 1); y[k] = 1; } else{ senStatus = new SensitivityStatus(0,sflux,m,p+1); y[k]=0; } sensitivityStatus.add(k - p_reactionModel.getSpeciesNumber(), senStatus); p_beginStatus.putSensitivityStatus(k - speciesNumber, senStatus); yprime[k] = sflux; } else{ if (p < rList.size()){ Reaction rxn = (Reaction)rList.get(p); if (rxn.containsAsProduct(spe)) { sflux = 1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } if (rxn.containsAsReactant(spe)) { sflux = -1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } else { sflux = 0; } SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } } } } } else { for (int i = p_reactionModel.getSpeciesNumber(); i < y.length; i++) { SensitivityStatus ss = (SensitivityStatus) p_beginStatus. getSensitivityStatus(i-p_reactionModel.getSpeciesNumber()); double sens = ss.getSensitivity(); double sflux = ss.getSFlux(); int reactionNumber = rList.size(); int speciesNumber = p_reactionModel.getSpeciesNumber(); Iterator species_iter = p_reactionModel.getSpecies(); y[i] = sens; yprime[i] = sflux; } } } //System.out.println("Number of Reacted Species is " + numberOfReactedSpecies); int idid; HashMap speStatus = new HashMap(); LinkedList senStatus = new LinkedList(); double[] tPresent = {tBegin}; int temp = 1; if (nParameter==0) { idid = solveDAE(p_initialization, reactionList, true, thirdBodyReactionList, troeReactionList, nState, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid !=1 && idid != 2 && idid != 3) { System.out.println("The idid from DASPK was "+idid + " at time "+tPresent[0]); throw new DynamicSimulatorException("DASPK: SA off."); } System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, 0); } else { idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid != 2 && idid != 3) throw new DynamicSimulatorException("DASPK: SA on."); //speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); senStatus = generateSensitivityStatus(p_reactionModel,y,yprime,nParameter); SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, senStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); sss.setIDTranslator(IDTranslator); sss.setReactionList(rList); return sss; } SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CH4"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO2"), rList, sss, p_temperature); return sss; //#] }
public SystemSnapshot solve(boolean p_initialization, ReactionModel p_reactionModel, boolean p_reactionChanged, SystemSnapshot p_beginStatus, ReactionTime p_beginTime, ReactionTime p_endTime, Temperature p_temperature, Pressure p_pressure, boolean p_conditionChanged) { //#[ operation solve(boolean,ReactionModel,boolean,SystemSnapshot,ReactionTime,ReactionTime,Temperature,Pressure,boolean) ReactionTime rt = p_beginStatus.getTime(); if (!rt.equals(p_beginTime)) throw new InvalidBeginStatusException(); // set time double tBegin = p_beginTime.getStandardTime(); double tEnd = p_endTime.getStandardTime(); // set reaction set //if (p_initialization || p_reactionChanged || p_conditionChanged) { generateTROEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); generateThirdBodyReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); LinkedList rList = generatePDepODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //generateAllODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //p_reactionChanged = true; //} // set numbers //System.out.println("Total number of reactions to Daspk is "+rList.size()); int nState = p_reactionModel.getSpeciesNumber(); int nParameter = 0; LinkedList initialSpecies = new LinkedList();// if (parameterInfor!=null) nParameter = parameterInfor.length; if (parameterInfor != 0) { nParameter = rList.size()+thirdBodyReactionList.length; //svp if (initialStatus == null) System.out.println("initialStatus = null"); Iterator spe_iter = initialStatus.getSpeciesStatus(); while (spe_iter.hasNext()) { SpeciesStatus ss = (SpeciesStatus) spe_iter.next(); String name = ss.getSpecies().getName(); initialSpecies.add(name); nParameter++; } } int neq = nState*(nParameter+1); // set temperature and pressure double T = p_temperature.getK(); double P = p_pressure.getAtm(); // set initial value of y and yprime; double [] y = new double[neq]; double [] yprime = new double[neq]; //double numberOfReactedSpecies=0; // get the present status at t_begin, and set y and y' accordingly System.out.println("Before ODE: " + String.valueOf(tBegin) + "SEC"); System.out.println("End at : " + String.valueOf(tEnd) + "SEC"); for (Iterator iter = p_beginStatus.getSpeciesStatus(); iter.hasNext(); ) { SpeciesStatus ss = (SpeciesStatus)iter.next(); double conc = ss.getConcentration(); double flux = ss.getFlux(); if (ss.isReactedSpecies()) { Species spe = ss.getSpecies(); int id = getRealID(spe); System.out.println(String.valueOf(spe.getID()) + '\t' + spe.getName() + '\t' + String.valueOf(conc) + '\t' + String.valueOf(flux)); y[id-1] = conc; yprime[id-1] = flux; } } if (nParameter != 0){//svp parameterInforArray = new ParameterInfor[nParameter]; for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ parameterInforArray[i-1] = new ParameterInfor("k",i,0.00); } for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ parameterInforArray[i - 1] = new ParameterInfor("CO", nParameter, 0.00); } if (p_beginTime.getTime() == 0 || p_beginTime.getTime() == 0.00) { LinkedList sensitivityStatus = new LinkedList(); int reactionNumber = rList.size()+thirdBodyReactionList.length; int speciesNumber = p_reactionModel.getSpeciesNumber();// for (int i=0;i<reactionNumber*speciesNumber;i++){ for (int i=0; i<nParameter*speciesNumber;i++){ sensitivityStatus.add(i,null); } p_beginStatus.addSensitivity(sensitivityStatus); double sflux = 1; Iterator species_iter = p_reactionModel.getSpecies(); while (species_iter.hasNext()) { Species spe = (Species) species_iter.next(); int m = getRealID(spe); for (int p=0;p<nParameter;p++){ int k = m + (p+1) * speciesNumber - 1; //if (p >= rList.size()){ if (p >= reactionNumber){ int speciesNum = p-rList.size()-thirdBodyReactionList.length; String name = (String)initialSpecies.get(speciesNum); sflux = 0; SensitivityStatus senStatus; if (name.equalsIgnoreCase(spe.getName())){ senStatus = new SensitivityStatus(1, sflux, m, p + 1); y[k] = 1; } else{ senStatus = new SensitivityStatus(0,sflux,m,p+1); y[k]=0; } sensitivityStatus.add(k - p_reactionModel.getSpeciesNumber(), senStatus); p_beginStatus.putSensitivityStatus(k - speciesNumber, senStatus); yprime[k] = sflux; } else{ if (p < rList.size()){ Reaction rxn = (Reaction)rList.get(p); if (rxn.containsAsProduct(spe)) { sflux = 1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } if (rxn.containsAsReactant(spe)) { sflux = -1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } else { sflux = 0; } SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } } } } } else { for (int i = p_reactionModel.getSpeciesNumber(); i < y.length; i++) { SensitivityStatus ss = (SensitivityStatus) p_beginStatus. getSensitivityStatus(i-p_reactionModel.getSpeciesNumber()); double sens = ss.getSensitivity(); double sflux = ss.getSFlux(); int reactionNumber = rList.size(); int speciesNumber = p_reactionModel.getSpeciesNumber(); Iterator species_iter = p_reactionModel.getSpecies(); y[i] = sens; yprime[i] = sflux; } } } //System.out.println("Number of Reacted Species is " + numberOfReactedSpecies); int idid; HashMap speStatus = new HashMap(); LinkedList senStatus = new LinkedList(); double[] tPresent = {tBegin}; int temp = 1; if (nParameter==0) { idid = solveDAE(p_initialization, reactionList, true, thirdBodyReactionList, troeReactionList, nState, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid !=1 && idid != 2 && idid != 3) { System.out.println("The idid from DASPK was "+idid + " at time "+tPresent[0]); throw new DynamicSimulatorException("DASPK: SA off."); } System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, 0); } else { idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid != 2 && idid != 3) throw new DynamicSimulatorException("DASPK: SA on."); //speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); senStatus = generateSensitivityStatus(p_reactionModel,y,yprime,nParameter); SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, senStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); sss.setIDTranslator(IDTranslator); sss.setReactionList(rList); return sss; } SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CH4"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO2"), rList, sss, p_temperature); return sss; //#] }
3,241,252
public SystemSnapshot solve(boolean p_initialization, ReactionModel p_reactionModel, boolean p_reactionChanged, SystemSnapshot p_beginStatus, ReactionTime p_beginTime, ReactionTime p_endTime, Temperature p_temperature, Pressure p_pressure, boolean p_conditionChanged) { //#[ operation solve(boolean,ReactionModel,boolean,SystemSnapshot,ReactionTime,ReactionTime,Temperature,Pressure,boolean) ReactionTime rt = p_beginStatus.getTime(); if (!rt.equals(p_beginTime)) throw new InvalidBeginStatusException(); // set time double tBegin = p_beginTime.getStandardTime(); double tEnd = p_endTime.getStandardTime(); // set reaction set //if (p_initialization || p_reactionChanged || p_conditionChanged) { generateTROEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); generateThirdBodyReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); LinkedList rList = generatePDepODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //generateAllODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //p_reactionChanged = true; //} // set numbers //System.out.println("Total number of reactions to Daspk is "+rList.size()); int nState = p_reactionModel.getSpeciesNumber(); int nParameter = 0; LinkedList initialSpecies = new LinkedList();// if (parameterInfor!=null) nParameter = parameterInfor.length; if (parameterInfor != 0) { nParameter = rList.size()+thirdBodyReactionList.length; //svp if (initialStatus == null) System.out.println("initialStatus = null"); Iterator spe_iter = initialStatus.getSpeciesStatus(); while (spe_iter.hasNext()) { SpeciesStatus ss = (SpeciesStatus) spe_iter.next(); String name = ss.getSpecies().getName(); initialSpecies.add(name); nParameter++; } } int neq = nState*(nParameter+1); // set temperature and pressure double T = p_temperature.getK(); double P = p_pressure.getAtm(); // set initial value of y and yprime; double [] y = new double[neq]; double [] yprime = new double[neq]; //double numberOfReactedSpecies=0; // get the present status at t_begin, and set y and y' accordingly System.out.println("Before ODE: " + String.valueOf(tBegin) + "SEC"); System.out.println("End at : " + String.valueOf(tEnd) + "SEC"); for (Iterator iter = p_beginStatus.getSpeciesStatus(); iter.hasNext(); ) { SpeciesStatus ss = (SpeciesStatus)iter.next(); double conc = ss.getConcentration(); double flux = ss.getFlux(); if (ss.isReactedSpecies()) { Species spe = ss.getSpecies(); int id = getRealID(spe); System.out.println(String.valueOf(spe.getID()) + '\t' + spe.getName() + '\t' + String.valueOf(conc) + '\t' + String.valueOf(flux)); y[id-1] = conc; yprime[id-1] = flux; } } if (nParameter != 0){//svp parameterInforArray = new ParameterInfor[nParameter]; for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ parameterInforArray[i-1] = new ParameterInfor("k",i,0.00); } for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ parameterInforArray[i - 1] = new ParameterInfor("CO", nParameter, 0.00); } if (p_beginTime.getTime() == 0 || p_beginTime.getTime() == 0.00) { LinkedList sensitivityStatus = new LinkedList(); int reactionNumber = rList.size()+thirdBodyReactionList.length; int speciesNumber = p_reactionModel.getSpeciesNumber();// for (int i=0;i<reactionNumber*speciesNumber;i++){ for (int i=0; i<nParameter*speciesNumber;i++){ sensitivityStatus.add(i,null); } p_beginStatus.addSensitivity(sensitivityStatus); double sflux = 1; Iterator species_iter = p_reactionModel.getSpecies(); while (species_iter.hasNext()) { Species spe = (Species) species_iter.next(); int m = getRealID(spe); for (int p=0;p<nParameter;p++){ int k = m + (p+1) * speciesNumber - 1; //if (p >= rList.size()){ if (p >= reactionNumber){ int speciesNum = p-rList.size()-thirdBodyReactionList.length; String name = (String)initialSpecies.get(speciesNum); sflux = 0; SensitivityStatus senStatus; if (name.equalsIgnoreCase(spe.getName())){ senStatus = new SensitivityStatus(1, sflux, m, p + 1); y[k] = 1; } else{ senStatus = new SensitivityStatus(0,sflux,m,p+1); y[k]=0; } sensitivityStatus.add(k - p_reactionModel.getSpeciesNumber(), senStatus); p_beginStatus.putSensitivityStatus(k - speciesNumber, senStatus); yprime[k] = sflux; } else{ if (p < rList.size()){ Reaction rxn = (Reaction)rList.get(p); if (rxn.containsAsProduct(spe)) { sflux = 1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } if (rxn.containsAsReactant(spe)) { sflux = -1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } else { sflux = 0; } SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } } } } } else { for (int i = p_reactionModel.getSpeciesNumber(); i < y.length; i++) { SensitivityStatus ss = (SensitivityStatus) p_beginStatus. getSensitivityStatus(i-p_reactionModel.getSpeciesNumber()); double sens = ss.getSensitivity(); double sflux = ss.getSFlux(); int reactionNumber = rList.size(); int speciesNumber = p_reactionModel.getSpeciesNumber(); Iterator species_iter = p_reactionModel.getSpecies(); y[i] = sens; yprime[i] = sflux; } } } //System.out.println("Number of Reacted Species is " + numberOfReactedSpecies); int idid; HashMap speStatus = new HashMap(); LinkedList senStatus = new LinkedList(); double[] tPresent = {tBegin}; int temp = 1; if (nParameter==0) { idid = solveDAE(p_initialization, reactionList, true, thirdBodyReactionList, troeReactionList, nState, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid !=1 && idid != 2 && idid != 3) { System.out.println("The idid from DASPK was "+idid + " at time "+tPresent[0]); throw new DynamicSimulatorException("DASPK: SA off."); } System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, 0); } else { idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid != 2 && idid != 3) throw new DynamicSimulatorException("DASPK: SA on."); //speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); senStatus = generateSensitivityStatus(p_reactionModel,y,yprime,nParameter); SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, senStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); sss.setIDTranslator(IDTranslator); sss.setReactionList(rList); return sss; } SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CH4"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO2"), rList, sss, p_temperature); return sss; //#] }
public SystemSnapshot solve(boolean p_initialization, ReactionModel p_reactionModel, boolean p_reactionChanged, SystemSnapshot p_beginStatus, ReactionTime p_beginTime, ReactionTime p_endTime, Temperature p_temperature, Pressure p_pressure, boolean p_conditionChanged) { //#[ operation solve(boolean,ReactionModel,boolean,SystemSnapshot,ReactionTime,ReactionTime,Temperature,Pressure,boolean) ReactionTime rt = p_beginStatus.getTime(); if (!rt.equals(p_beginTime)) throw new InvalidBeginStatusException(); // set time double tBegin = p_beginTime.getStandardTime(); double tEnd = p_endTime.getStandardTime(); // set reaction set //if (p_initialization || p_reactionChanged || p_conditionChanged) { generateTROEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); generateThirdBodyReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); LinkedList rList = generatePDepODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //generateAllODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //p_reactionChanged = true; //} // set numbers //System.out.println("Total number of reactions to Daspk is "+rList.size()); int nState = p_reactionModel.getSpeciesNumber(); int nParameter = 0; LinkedList initialSpecies = new LinkedList();// if (parameterInfor!=null) nParameter = parameterInfor.length; if (parameterInfor != 0) { nParameter = rList.size()+thirdBodyReactionList.length; //svp if (initialStatus == null) System.out.println("initialStatus = null"); Iterator spe_iter = initialStatus.getSpeciesStatus(); while (spe_iter.hasNext()) { SpeciesStatus ss = (SpeciesStatus) spe_iter.next(); String name = ss.getSpecies().getName(); initialSpecies.add(name); nParameter++; } } int neq = nState*(nParameter+1); // set temperature and pressure double T = p_temperature.getK(); double P = p_pressure.getAtm(); // set initial value of y and yprime; double [] y = new double[neq]; double [] yprime = new double[neq]; //double numberOfReactedSpecies=0; // get the present status at t_begin, and set y and y' accordingly System.out.println("Before ODE: " + String.valueOf(tBegin) + "SEC"); System.out.println("End at : " + String.valueOf(tEnd) + "SEC"); for (Iterator iter = p_beginStatus.getSpeciesStatus(); iter.hasNext(); ) { SpeciesStatus ss = (SpeciesStatus)iter.next(); double conc = ss.getConcentration(); double flux = ss.getFlux(); if (ss.isReactedSpecies()) { Species spe = ss.getSpecies(); int id = getRealID(spe); System.out.println(String.valueOf(spe.getID()) + '\t' + spe.getName() + '\t' + String.valueOf(conc) + '\t' + String.valueOf(flux)); y[id-1] = conc; yprime[id-1] = flux; } } if (nParameter != 0){//svp parameterInforArray = new ParameterInfor[nParameter]; for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ parameterInforArray[i-1] = new ParameterInfor("k",i,0.00); } for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ parameterInforArray[i - 1] = new ParameterInfor("CO", nParameter, 0.00); } if (p_beginTime.getTime() == 0 || p_beginTime.getTime() == 0.00) { LinkedList sensitivityStatus = new LinkedList(); int reactionNumber = rList.size()+thirdBodyReactionList.length; int speciesNumber = p_reactionModel.getSpeciesNumber();// for (int i=0;i<reactionNumber*speciesNumber;i++){ for (int i=0; i<nParameter*speciesNumber;i++){ sensitivityStatus.add(i,null); } p_beginStatus.addSensitivity(sensitivityStatus); double sflux = 1; Iterator species_iter = p_reactionModel.getSpecies(); while (species_iter.hasNext()) { Species spe = (Species) species_iter.next(); int m = getRealID(spe); for (int p=0;p<nParameter;p++){ int k = m + (p+1) * speciesNumber - 1; //if (p >= rList.size()){ if (p >= reactionNumber){ int speciesNum = p-rList.size()-thirdBodyReactionList.length; String name = (String)initialSpecies.get(speciesNum); sflux = 0; SensitivityStatus senStatus; if (name.equalsIgnoreCase(spe.getName())){ senStatus = new SensitivityStatus(1, sflux, m, p + 1); y[k] = 1; } else{ senStatus = new SensitivityStatus(0,sflux,m,p+1); y[k]=0; } sensitivityStatus.add(k - p_reactionModel.getSpeciesNumber(), senStatus); p_beginStatus.putSensitivityStatus(k - speciesNumber, senStatus); yprime[k] = sflux; } else{ if (p < rList.size()){ Reaction rxn = (Reaction)rList.get(p); if (rxn.containsAsProduct(spe)) { sflux = 1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } if (rxn.containsAsReactant(spe)) { sflux = -1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } else { sflux = 0; } SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } } } } } else { for (int i = p_reactionModel.getSpeciesNumber(); i < y.length; i++) { SensitivityStatus ss = (SensitivityStatus) p_beginStatus. getSensitivityStatus(i-p_reactionModel.getSpeciesNumber()); double sens = ss.getSensitivity(); double sflux = ss.getSFlux(); int reactionNumber = rList.size(); int speciesNumber = p_reactionModel.getSpeciesNumber(); Iterator species_iter = p_reactionModel.getSpecies(); y[i] = sens; yprime[i] = sflux; } } } //System.out.println("Number of Reacted Species is " + numberOfReactedSpecies); int idid; HashMap speStatus = new HashMap(); LinkedList senStatus = new LinkedList(); double[] tPresent = {tBegin}; int temp = 1; if (nParameter==0) { idid = solveDAE(p_initialization, reactionList, true, thirdBodyReactionList, troeReactionList, nState, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid !=1 && idid != 2 && idid != 3) { System.out.println("The idid from DASPK was "+idid + " at time "+tPresent[0]); throw new DynamicSimulatorException("DASPK: SA off."); } System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, 0); } else { idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid != 2 && idid != 3) throw new DynamicSimulatorException("DASPK: SA on."); //speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); senStatus = generateSensitivityStatus(p_reactionModel,y,yprime,nParameter); SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, senStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); sss.setIDTranslator(IDTranslator); sss.setReactionList(rList); return sss; } SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CH4"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO2"), rList, sss, p_temperature); return sss; //#] }
3,241,253
public SystemSnapshot solve(boolean p_initialization, ReactionModel p_reactionModel, boolean p_reactionChanged, SystemSnapshot p_beginStatus, ReactionTime p_beginTime, ReactionTime p_endTime, Temperature p_temperature, Pressure p_pressure, boolean p_conditionChanged) { //#[ operation solve(boolean,ReactionModel,boolean,SystemSnapshot,ReactionTime,ReactionTime,Temperature,Pressure,boolean) ReactionTime rt = p_beginStatus.getTime(); if (!rt.equals(p_beginTime)) throw new InvalidBeginStatusException(); // set time double tBegin = p_beginTime.getStandardTime(); double tEnd = p_endTime.getStandardTime(); // set reaction set //if (p_initialization || p_reactionChanged || p_conditionChanged) { generateTROEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); generateThirdBodyReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); LinkedList rList = generatePDepODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //generateAllODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //p_reactionChanged = true; //} // set numbers //System.out.println("Total number of reactions to Daspk is "+rList.size()); int nState = p_reactionModel.getSpeciesNumber(); int nParameter = 0; LinkedList initialSpecies = new LinkedList();// if (parameterInfor!=null) nParameter = parameterInfor.length; if (parameterInfor != 0) { nParameter = rList.size()+thirdBodyReactionList.length; //svp if (initialStatus == null) System.out.println("initialStatus = null"); Iterator spe_iter = initialStatus.getSpeciesStatus(); while (spe_iter.hasNext()) { SpeciesStatus ss = (SpeciesStatus) spe_iter.next(); String name = ss.getSpecies().getName(); initialSpecies.add(name); nParameter++; } } int neq = nState*(nParameter+1); // set temperature and pressure double T = p_temperature.getK(); double P = p_pressure.getAtm(); // set initial value of y and yprime; double [] y = new double[neq]; double [] yprime = new double[neq]; //double numberOfReactedSpecies=0; // get the present status at t_begin, and set y and y' accordingly System.out.println("Before ODE: " + String.valueOf(tBegin) + "SEC"); System.out.println("End at : " + String.valueOf(tEnd) + "SEC"); for (Iterator iter = p_beginStatus.getSpeciesStatus(); iter.hasNext(); ) { SpeciesStatus ss = (SpeciesStatus)iter.next(); double conc = ss.getConcentration(); double flux = ss.getFlux(); if (ss.isReactedSpecies()) { Species spe = ss.getSpecies(); int id = getRealID(spe); System.out.println(String.valueOf(spe.getID()) + '\t' + spe.getName() + '\t' + String.valueOf(conc) + '\t' + String.valueOf(flux)); y[id-1] = conc; yprime[id-1] = flux; } } if (nParameter != 0){//svp parameterInforArray = new ParameterInfor[nParameter]; for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ parameterInforArray[i-1] = new ParameterInfor("k",i,0.00); } for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ parameterInforArray[i - 1] = new ParameterInfor("CO", nParameter, 0.00); } if (p_beginTime.getTime() == 0 || p_beginTime.getTime() == 0.00) { LinkedList sensitivityStatus = new LinkedList(); int reactionNumber = rList.size()+thirdBodyReactionList.length; int speciesNumber = p_reactionModel.getSpeciesNumber();// for (int i=0;i<reactionNumber*speciesNumber;i++){ for (int i=0; i<nParameter*speciesNumber;i++){ sensitivityStatus.add(i,null); } p_beginStatus.addSensitivity(sensitivityStatus); double sflux = 1; Iterator species_iter = p_reactionModel.getSpecies(); while (species_iter.hasNext()) { Species spe = (Species) species_iter.next(); int m = getRealID(spe); for (int p=0;p<nParameter;p++){ int k = m + (p+1) * speciesNumber - 1; //if (p >= rList.size()){ if (p >= reactionNumber){ int speciesNum = p-rList.size()-thirdBodyReactionList.length; String name = (String)initialSpecies.get(speciesNum); sflux = 0; SensitivityStatus senStatus; if (name.equalsIgnoreCase(spe.getName())){ senStatus = new SensitivityStatus(1, sflux, m, p + 1); y[k] = 1; } else{ senStatus = new SensitivityStatus(0,sflux,m,p+1); y[k]=0; } sensitivityStatus.add(k - p_reactionModel.getSpeciesNumber(), senStatus); p_beginStatus.putSensitivityStatus(k - speciesNumber, senStatus); yprime[k] = sflux; } else{ if (p < rList.size()){ Reaction rxn = (Reaction)rList.get(p); if (rxn.containsAsProduct(spe)) { sflux = 1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } if (rxn.containsAsReactant(spe)) { sflux = -1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } else { sflux = 0; } SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } } } } } else { for (int i = p_reactionModel.getSpeciesNumber(); i < y.length; i++) { SensitivityStatus ss = (SensitivityStatus) p_beginStatus. getSensitivityStatus(i-p_reactionModel.getSpeciesNumber()); double sens = ss.getSensitivity(); double sflux = ss.getSFlux(); int reactionNumber = rList.size(); int speciesNumber = p_reactionModel.getSpeciesNumber(); Iterator species_iter = p_reactionModel.getSpecies(); y[i] = sens; yprime[i] = sflux; } } } //System.out.println("Number of Reacted Species is " + numberOfReactedSpecies); int idid; HashMap speStatus = new HashMap(); LinkedList senStatus = new LinkedList(); double[] tPresent = {tBegin}; int temp = 1; if (nParameter==0) { idid = solveDAE(p_initialization, reactionList, true, thirdBodyReactionList, troeReactionList, nState, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid !=1 && idid != 2 && idid != 3) { System.out.println("The idid from DASPK was "+idid + " at time "+tPresent[0]); throw new DynamicSimulatorException("DASPK: SA off."); } System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, 0); } else { idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid != 2 && idid != 3) throw new DynamicSimulatorException("DASPK: SA on."); //speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); senStatus = generateSensitivityStatus(p_reactionModel,y,yprime,nParameter); SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, senStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); sss.setIDTranslator(IDTranslator); sss.setReactionList(rList); return sss; } SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CH4"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO2"), rList, sss, p_temperature); return sss; //#] }
public SystemSnapshot solve(boolean p_initialization, ReactionModel p_reactionModel, boolean p_reactionChanged, SystemSnapshot p_beginStatus, ReactionTime p_beginTime, ReactionTime p_endTime, Temperature p_temperature, Pressure p_pressure, boolean p_conditionChanged) { //#[ operation solve(boolean,ReactionModel,boolean,SystemSnapshot,ReactionTime,ReactionTime,Temperature,Pressure,boolean) ReactionTime rt = p_beginStatus.getTime(); if (!rt.equals(p_beginTime)) throw new InvalidBeginStatusException(); // set time double tBegin = p_beginTime.getStandardTime(); double tEnd = p_endTime.getStandardTime(); // set reaction set //if (p_initialization || p_reactionChanged || p_conditionChanged) { generateTROEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); generateThirdBodyReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); LinkedList rList = generatePDepODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //generateAllODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //p_reactionChanged = true; //} // set numbers //System.out.println("Total number of reactions to Daspk is "+rList.size()); int nState = p_reactionModel.getSpeciesNumber(); int nParameter = 0; LinkedList initialSpecies = new LinkedList();// if (parameterInfor!=null) nParameter = parameterInfor.length; if (parameterInfor != 0) { nParameter = rList.size()+thirdBodyReactionList.length; //svp if (initialStatus == null) System.out.println("initialStatus = null"); Iterator spe_iter = initialStatus.getSpeciesStatus(); while (spe_iter.hasNext()) { SpeciesStatus ss = (SpeciesStatus) spe_iter.next(); String name = ss.getSpecies().getName(); initialSpecies.add(name); nParameter++; } } int neq = nState*(nParameter+1); // set temperature and pressure double T = p_temperature.getK(); double P = p_pressure.getAtm(); // set initial value of y and yprime; double [] y = new double[neq]; double [] yprime = new double[neq]; //double numberOfReactedSpecies=0; // get the present status at t_begin, and set y and y' accordingly System.out.println("Before ODE: " + String.valueOf(tBegin) + "SEC"); System.out.println("End at : " + String.valueOf(tEnd) + "SEC"); for (Iterator iter = p_beginStatus.getSpeciesStatus(); iter.hasNext(); ) { SpeciesStatus ss = (SpeciesStatus)iter.next(); double conc = ss.getConcentration(); double flux = ss.getFlux(); if (ss.isReactedSpecies()) { Species spe = ss.getSpecies(); int id = getRealID(spe); System.out.println(String.valueOf(spe.getID()) + '\t' + spe.getName() + '\t' + String.valueOf(conc) + '\t' + String.valueOf(flux)); y[id-1] = conc; yprime[id-1] = flux; } } if (nParameter != 0){//svp parameterInforArray = new ParameterInfor[nParameter]; for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ parameterInforArray[i-1] = new ParameterInfor("k",i,0.00); } for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ parameterInforArray[i - 1] = new ParameterInfor("CO", nParameter, 0.00); } if (p_beginTime.getTime() == 0 || p_beginTime.getTime() == 0.00) { LinkedList sensitivityStatus = new LinkedList(); int reactionNumber = rList.size()+thirdBodyReactionList.length; int speciesNumber = p_reactionModel.getSpeciesNumber();// for (int i=0;i<reactionNumber*speciesNumber;i++){ for (int i=0; i<nParameter*speciesNumber;i++){ sensitivityStatus.add(i,null); } p_beginStatus.addSensitivity(sensitivityStatus); double sflux = 1; Iterator species_iter = p_reactionModel.getSpecies(); while (species_iter.hasNext()) { Species spe = (Species) species_iter.next(); int m = getRealID(spe); for (int p=0;p<nParameter;p++){ int k = m + (p+1) * speciesNumber - 1; //if (p >= rList.size()){ if (p >= reactionNumber){ int speciesNum = p-rList.size()-thirdBodyReactionList.length; String name = (String)initialSpecies.get(speciesNum); sflux = 0; SensitivityStatus senStatus; if (name.equalsIgnoreCase(spe.getName())){ senStatus = new SensitivityStatus(1, sflux, m, p + 1); y[k] = 1; } else{ senStatus = new SensitivityStatus(0,sflux,m,p+1); y[k]=0; } sensitivityStatus.add(k - p_reactionModel.getSpeciesNumber(), senStatus); p_beginStatus.putSensitivityStatus(k - speciesNumber, senStatus); yprime[k] = sflux; } else{ if (p < rList.size()){ Reaction rxn = (Reaction)rList.get(p); if (rxn.containsAsProduct(spe)) { sflux = 1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } if (rxn.containsAsReactant(spe)) { sflux = -1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } else { sflux = 0; } SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } } } } } else { for (int i = p_reactionModel.getSpeciesNumber(); i < y.length; i++) { SensitivityStatus ss = (SensitivityStatus) p_beginStatus. getSensitivityStatus(i-p_reactionModel.getSpeciesNumber()); double sens = ss.getSensitivity(); double sflux = ss.getSFlux(); int reactionNumber = rList.size(); int speciesNumber = p_reactionModel.getSpeciesNumber(); Iterator species_iter = p_reactionModel.getSpecies(); y[i] = sens; yprime[i] = sflux; } } } //System.out.println("Number of Reacted Species is " + numberOfReactedSpecies); int idid; HashMap speStatus = new HashMap(); LinkedList senStatus = new LinkedList(); double[] tPresent = {tBegin}; int temp = 1; if (nParameter==0) { idid = solveDAE(p_initialization, reactionList, true, thirdBodyReactionList, troeReactionList, nState, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid !=1 && idid != 2 && idid != 3) { System.out.println("The idid from DASPK was "+idid + " at time "+tPresent[0]); throw new DynamicSimulatorException("DASPK: SA off."); } System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, 0); } else { idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid != 2 && idid != 3) throw new DynamicSimulatorException("DASPK: SA on."); //speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); senStatus = generateSensitivityStatus(p_reactionModel,y,yprime,nParameter); SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, senStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); sss.setIDTranslator(IDTranslator); sss.setReactionList(rList); return sss; } SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CH4"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO2"), rList, sss, p_temperature); return sss; //#] }
3,241,254
public SystemSnapshot solve(boolean p_initialization, ReactionModel p_reactionModel, boolean p_reactionChanged, SystemSnapshot p_beginStatus, ReactionTime p_beginTime, ReactionTime p_endTime, Temperature p_temperature, Pressure p_pressure, boolean p_conditionChanged) { //#[ operation solve(boolean,ReactionModel,boolean,SystemSnapshot,ReactionTime,ReactionTime,Temperature,Pressure,boolean) ReactionTime rt = p_beginStatus.getTime(); if (!rt.equals(p_beginTime)) throw new InvalidBeginStatusException(); // set time double tBegin = p_beginTime.getStandardTime(); double tEnd = p_endTime.getStandardTime(); // set reaction set //if (p_initialization || p_reactionChanged || p_conditionChanged) { generateTROEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); generateThirdBodyReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); LinkedList rList = generatePDepODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //generateAllODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //p_reactionChanged = true; //} // set numbers //System.out.println("Total number of reactions to Daspk is "+rList.size()); int nState = p_reactionModel.getSpeciesNumber(); int nParameter = 0; LinkedList initialSpecies = new LinkedList();// if (parameterInfor!=null) nParameter = parameterInfor.length; if (parameterInfor != 0) { nParameter = rList.size()+thirdBodyReactionList.length; //svp if (initialStatus == null) System.out.println("initialStatus = null"); Iterator spe_iter = initialStatus.getSpeciesStatus(); while (spe_iter.hasNext()) { SpeciesStatus ss = (SpeciesStatus) spe_iter.next(); String name = ss.getSpecies().getName(); initialSpecies.add(name); nParameter++; } } int neq = nState*(nParameter+1); // set temperature and pressure double T = p_temperature.getK(); double P = p_pressure.getAtm(); // set initial value of y and yprime; double [] y = new double[neq]; double [] yprime = new double[neq]; //double numberOfReactedSpecies=0; // get the present status at t_begin, and set y and y' accordingly System.out.println("Before ODE: " + String.valueOf(tBegin) + "SEC"); System.out.println("End at : " + String.valueOf(tEnd) + "SEC"); for (Iterator iter = p_beginStatus.getSpeciesStatus(); iter.hasNext(); ) { SpeciesStatus ss = (SpeciesStatus)iter.next(); double conc = ss.getConcentration(); double flux = ss.getFlux(); if (ss.isReactedSpecies()) { Species spe = ss.getSpecies(); int id = getRealID(spe); System.out.println(String.valueOf(spe.getID()) + '\t' + spe.getName() + '\t' + String.valueOf(conc) + '\t' + String.valueOf(flux)); y[id-1] = conc; yprime[id-1] = flux; } } if (nParameter != 0){//svp parameterInforArray = new ParameterInfor[nParameter]; for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ parameterInforArray[i-1] = new ParameterInfor("k",i,0.00); } for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ parameterInforArray[i - 1] = new ParameterInfor("CO", nParameter, 0.00); } if (p_beginTime.getTime() == 0 || p_beginTime.getTime() == 0.00) { LinkedList sensitivityStatus = new LinkedList(); int reactionNumber = rList.size()+thirdBodyReactionList.length; int speciesNumber = p_reactionModel.getSpeciesNumber();// for (int i=0;i<reactionNumber*speciesNumber;i++){ for (int i=0; i<nParameter*speciesNumber;i++){ sensitivityStatus.add(i,null); } p_beginStatus.addSensitivity(sensitivityStatus); double sflux = 1; Iterator species_iter = p_reactionModel.getSpecies(); while (species_iter.hasNext()) { Species spe = (Species) species_iter.next(); int m = getRealID(spe); for (int p=0;p<nParameter;p++){ int k = m + (p+1) * speciesNumber - 1; //if (p >= rList.size()){ if (p >= reactionNumber){ int speciesNum = p-rList.size()-thirdBodyReactionList.length; String name = (String)initialSpecies.get(speciesNum); sflux = 0; SensitivityStatus senStatus; if (name.equalsIgnoreCase(spe.getName())){ senStatus = new SensitivityStatus(1, sflux, m, p + 1); y[k] = 1; } else{ senStatus = new SensitivityStatus(0,sflux,m,p+1); y[k]=0; } sensitivityStatus.add(k - p_reactionModel.getSpeciesNumber(), senStatus); p_beginStatus.putSensitivityStatus(k - speciesNumber, senStatus); yprime[k] = sflux; } else{ if (p < rList.size()){ Reaction rxn = (Reaction)rList.get(p); if (rxn.containsAsProduct(spe)) { sflux = 1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } if (rxn.containsAsReactant(spe)) { sflux = -1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } else { sflux = 0; } SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } } } } } else { for (int i = p_reactionModel.getSpeciesNumber(); i < y.length; i++) { SensitivityStatus ss = (SensitivityStatus) p_beginStatus. getSensitivityStatus(i-p_reactionModel.getSpeciesNumber()); double sens = ss.getSensitivity(); double sflux = ss.getSFlux(); int reactionNumber = rList.size(); int speciesNumber = p_reactionModel.getSpeciesNumber(); Iterator species_iter = p_reactionModel.getSpecies(); y[i] = sens; yprime[i] = sflux; } } } //System.out.println("Number of Reacted Species is " + numberOfReactedSpecies); int idid; HashMap speStatus = new HashMap(); LinkedList senStatus = new LinkedList(); double[] tPresent = {tBegin}; int temp = 1; if (nParameter==0) { idid = solveDAE(p_initialization, reactionList, true, thirdBodyReactionList, troeReactionList, nState, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid !=1 && idid != 2 && idid != 3) { System.out.println("The idid from DASPK was "+idid + " at time "+tPresent[0]); throw new DynamicSimulatorException("DASPK: SA off."); } System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, 0); } else { idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid != 2 && idid != 3) throw new DynamicSimulatorException("DASPK: SA on."); //speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); senStatus = generateSensitivityStatus(p_reactionModel,y,yprime,nParameter); SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, senStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); sss.setIDTranslator(IDTranslator); sss.setReactionList(rList); return sss; } SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CH4"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO2"), rList, sss, p_temperature); return sss; //#] }
public SystemSnapshot solve(boolean p_initialization, ReactionModel p_reactionModel, boolean p_reactionChanged, SystemSnapshot p_beginStatus, ReactionTime p_beginTime, ReactionTime p_endTime, Temperature p_temperature, Pressure p_pressure, boolean p_conditionChanged) { //#[ operation solve(boolean,ReactionModel,boolean,SystemSnapshot,ReactionTime,ReactionTime,Temperature,Pressure,boolean) ReactionTime rt = p_beginStatus.getTime(); if (!rt.equals(p_beginTime)) throw new InvalidBeginStatusException(); // set time double tBegin = p_beginTime.getStandardTime(); double tEnd = p_endTime.getStandardTime(); // set reaction set //if (p_initialization || p_reactionChanged || p_conditionChanged) { generateTROEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); generateThirdBodyReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); LinkedList rList = generatePDepODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //generateAllODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //p_reactionChanged = true; //} // set numbers //System.out.println("Total number of reactions to Daspk is "+rList.size()); int nState = p_reactionModel.getSpeciesNumber(); int nParameter = 0; LinkedList initialSpecies = new LinkedList();// if (parameterInfor!=null) nParameter = parameterInfor.length; if (parameterInfor != 0) { nParameter = rList.size()+thirdBodyReactionList.length; //svp if (initialStatus == null) System.out.println("initialStatus = null"); Iterator spe_iter = initialStatus.getSpeciesStatus(); while (spe_iter.hasNext()) { SpeciesStatus ss = (SpeciesStatus) spe_iter.next(); String name = ss.getSpecies().getName(); initialSpecies.add(name); nParameter++; } } int neq = nState*(nParameter+1); // set temperature and pressure double T = p_temperature.getK(); double P = p_pressure.getAtm(); // set initial value of y and yprime; double [] y = new double[neq]; double [] yprime = new double[neq]; //double numberOfReactedSpecies=0; // get the present status at t_begin, and set y and y' accordingly System.out.println("Before ODE: " + String.valueOf(tBegin) + "SEC"); System.out.println("End at : " + String.valueOf(tEnd) + "SEC"); for (Iterator iter = p_beginStatus.getSpeciesStatus(); iter.hasNext(); ) { SpeciesStatus ss = (SpeciesStatus)iter.next(); double conc = ss.getConcentration(); double flux = ss.getFlux(); if (ss.isReactedSpecies()) { Species spe = ss.getSpecies(); int id = getRealID(spe); System.out.println(String.valueOf(spe.getID()) + '\t' + spe.getName() + '\t' + String.valueOf(conc) + '\t' + String.valueOf(flux)); y[id-1] = conc; yprime[id-1] = flux; } } if (nParameter != 0){//svp parameterInforArray = new ParameterInfor[nParameter]; for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ parameterInforArray[i-1] = new ParameterInfor("k",i,0.00); } for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ parameterInforArray[i - 1] = new ParameterInfor("CO", nParameter, 0.00); } if (p_beginTime.getTime() == 0 || p_beginTime.getTime() == 0.00) { LinkedList sensitivityStatus = new LinkedList(); int reactionNumber = rList.size()+thirdBodyReactionList.length; int speciesNumber = p_reactionModel.getSpeciesNumber();// for (int i=0;i<reactionNumber*speciesNumber;i++){ for (int i=0; i<nParameter*speciesNumber;i++){ sensitivityStatus.add(i,null); } p_beginStatus.addSensitivity(sensitivityStatus); double sflux = 1; Iterator species_iter = p_reactionModel.getSpecies(); while (species_iter.hasNext()) { Species spe = (Species) species_iter.next(); int m = getRealID(spe); for (int p=0;p<nParameter;p++){ int k = m + (p+1) * speciesNumber - 1; //if (p >= rList.size()){ if (p >= reactionNumber){ int speciesNum = p-rList.size()-thirdBodyReactionList.length; String name = (String)initialSpecies.get(speciesNum); sflux = 0; SensitivityStatus senStatus; if (name.equalsIgnoreCase(spe.getName())){ senStatus = new SensitivityStatus(1, sflux, m, p + 1); y[k] = 1; } else{ senStatus = new SensitivityStatus(0,sflux,m,p+1); y[k]=0; } sensitivityStatus.add(k - p_reactionModel.getSpeciesNumber(), senStatus); p_beginStatus.putSensitivityStatus(k - speciesNumber, senStatus); yprime[k] = sflux; } else{ if (p < rList.size()){ Reaction rxn = (Reaction)rList.get(p); if (rxn.containsAsProduct(spe)) { sflux = 1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } if (rxn.containsAsReactant(spe)) { sflux = -1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } else { sflux = 0; } SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } } } } } else { for (int i = p_reactionModel.getSpeciesNumber(); i < y.length; i++) { SensitivityStatus ss = (SensitivityStatus) p_beginStatus. getSensitivityStatus(i-p_reactionModel.getSpeciesNumber()); double sens = ss.getSensitivity(); double sflux = ss.getSFlux(); int reactionNumber = rList.size(); int speciesNumber = p_reactionModel.getSpeciesNumber(); Iterator species_iter = p_reactionModel.getSpecies(); y[i] = sens; yprime[i] = sflux; } } } //System.out.println("Number of Reacted Species is " + numberOfReactedSpecies); int idid; HashMap speStatus = new HashMap(); LinkedList senStatus = new LinkedList(); double[] tPresent = {tBegin}; int temp = 1; if (nParameter==0) { idid = solveDAE(p_initialization, reactionList, true, thirdBodyReactionList, troeReactionList, nState, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid !=1 && idid != 2 && idid != 3) { System.out.println("The idid from DASPK was "+idid + " at time "+tPresent[0]); throw new DynamicSimulatorException("DASPK: SA off."); } System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, 0); } else { idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid != 2 && idid != 3) throw new DynamicSimulatorException("DASPK: SA on."); //speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); senStatus = generateSensitivityStatus(p_reactionModel,y,yprime,nParameter); SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, senStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); sss.setIDTranslator(IDTranslator); sss.setReactionList(rList); return sss; } SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CH4"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO2"), rList, sss, p_temperature); return sss; //#] }
3,241,255
public SystemSnapshot solve(boolean p_initialization, ReactionModel p_reactionModel, boolean p_reactionChanged, SystemSnapshot p_beginStatus, ReactionTime p_beginTime, ReactionTime p_endTime, Temperature p_temperature, Pressure p_pressure, boolean p_conditionChanged) { //#[ operation solve(boolean,ReactionModel,boolean,SystemSnapshot,ReactionTime,ReactionTime,Temperature,Pressure,boolean) ReactionTime rt = p_beginStatus.getTime(); if (!rt.equals(p_beginTime)) throw new InvalidBeginStatusException(); // set time double tBegin = p_beginTime.getStandardTime(); double tEnd = p_endTime.getStandardTime(); // set reaction set //if (p_initialization || p_reactionChanged || p_conditionChanged) { generateTROEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); generateThirdBodyReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); LinkedList rList = generatePDepODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //generateAllODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //p_reactionChanged = true; //} // set numbers //System.out.println("Total number of reactions to Daspk is "+rList.size()); int nState = p_reactionModel.getSpeciesNumber(); int nParameter = 0; LinkedList initialSpecies = new LinkedList();// if (parameterInfor!=null) nParameter = parameterInfor.length; if (parameterInfor != 0) { nParameter = rList.size()+thirdBodyReactionList.length; //svp if (initialStatus == null) System.out.println("initialStatus = null"); Iterator spe_iter = initialStatus.getSpeciesStatus(); while (spe_iter.hasNext()) { SpeciesStatus ss = (SpeciesStatus) spe_iter.next(); String name = ss.getSpecies().getName(); initialSpecies.add(name); nParameter++; } } int neq = nState*(nParameter+1); // set temperature and pressure double T = p_temperature.getK(); double P = p_pressure.getAtm(); // set initial value of y and yprime; double [] y = new double[neq]; double [] yprime = new double[neq]; //double numberOfReactedSpecies=0; // get the present status at t_begin, and set y and y' accordingly System.out.println("Before ODE: " + String.valueOf(tBegin) + "SEC"); System.out.println("End at : " + String.valueOf(tEnd) + "SEC"); for (Iterator iter = p_beginStatus.getSpeciesStatus(); iter.hasNext(); ) { SpeciesStatus ss = (SpeciesStatus)iter.next(); double conc = ss.getConcentration(); double flux = ss.getFlux(); if (ss.isReactedSpecies()) { Species spe = ss.getSpecies(); int id = getRealID(spe); System.out.println(String.valueOf(spe.getID()) + '\t' + spe.getName() + '\t' + String.valueOf(conc) + '\t' + String.valueOf(flux)); y[id-1] = conc; yprime[id-1] = flux; } } if (nParameter != 0){//svp parameterInforArray = new ParameterInfor[nParameter]; for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ parameterInforArray[i-1] = new ParameterInfor("k",i,0.00); } for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ parameterInforArray[i - 1] = new ParameterInfor("CO", nParameter, 0.00); } if (p_beginTime.getTime() == 0 || p_beginTime.getTime() == 0.00) { LinkedList sensitivityStatus = new LinkedList(); int reactionNumber = rList.size()+thirdBodyReactionList.length; int speciesNumber = p_reactionModel.getSpeciesNumber();// for (int i=0;i<reactionNumber*speciesNumber;i++){ for (int i=0; i<nParameter*speciesNumber;i++){ sensitivityStatus.add(i,null); } p_beginStatus.addSensitivity(sensitivityStatus); double sflux = 1; Iterator species_iter = p_reactionModel.getSpecies(); while (species_iter.hasNext()) { Species spe = (Species) species_iter.next(); int m = getRealID(spe); for (int p=0;p<nParameter;p++){ int k = m + (p+1) * speciesNumber - 1; //if (p >= rList.size()){ if (p >= reactionNumber){ int speciesNum = p-rList.size()-thirdBodyReactionList.length; String name = (String)initialSpecies.get(speciesNum); sflux = 0; SensitivityStatus senStatus; if (name.equalsIgnoreCase(spe.getName())){ senStatus = new SensitivityStatus(1, sflux, m, p + 1); y[k] = 1; } else{ senStatus = new SensitivityStatus(0,sflux,m,p+1); y[k]=0; } sensitivityStatus.add(k - p_reactionModel.getSpeciesNumber(), senStatus); p_beginStatus.putSensitivityStatus(k - speciesNumber, senStatus); yprime[k] = sflux; } else{ if (p < rList.size()){ Reaction rxn = (Reaction)rList.get(p); if (rxn.containsAsProduct(spe)) { sflux = 1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } if (rxn.containsAsReactant(spe)) { sflux = -1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } else { sflux = 0; } SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } } } } } else { for (int i = p_reactionModel.getSpeciesNumber(); i < y.length; i++) { SensitivityStatus ss = (SensitivityStatus) p_beginStatus. getSensitivityStatus(i-p_reactionModel.getSpeciesNumber()); double sens = ss.getSensitivity(); double sflux = ss.getSFlux(); int reactionNumber = rList.size(); int speciesNumber = p_reactionModel.getSpeciesNumber(); Iterator species_iter = p_reactionModel.getSpecies(); y[i] = sens; yprime[i] = sflux; } } } //System.out.println("Number of Reacted Species is " + numberOfReactedSpecies); int idid; HashMap speStatus = new HashMap(); LinkedList senStatus = new LinkedList(); double[] tPresent = {tBegin}; int temp = 1; if (nParameter==0) { idid = solveDAE(p_initialization, reactionList, true, thirdBodyReactionList, troeReactionList, nState, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid !=1 && idid != 2 && idid != 3) { System.out.println("The idid from DASPK was "+idid + " at time "+tPresent[0]); throw new DynamicSimulatorException("DASPK: SA off."); } System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, 0); } else { idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid != 2 && idid != 3) throw new DynamicSimulatorException("DASPK: SA on."); //speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); senStatus = generateSensitivityStatus(p_reactionModel,y,yprime,nParameter); SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, senStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); sss.setIDTranslator(IDTranslator); sss.setReactionList(rList); return sss; } SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CH4"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO2"), rList, sss, p_temperature); return sss; //#] }
public SystemSnapshot solve(boolean p_initialization, ReactionModel p_reactionModel, boolean p_reactionChanged, SystemSnapshot p_beginStatus, ReactionTime p_beginTime, ReactionTime p_endTime, Temperature p_temperature, Pressure p_pressure, boolean p_conditionChanged) { //#[ operation solve(boolean,ReactionModel,boolean,SystemSnapshot,ReactionTime,ReactionTime,Temperature,Pressure,boolean) ReactionTime rt = p_beginStatus.getTime(); if (!rt.equals(p_beginTime)) throw new InvalidBeginStatusException(); // set time double tBegin = p_beginTime.getStandardTime(); double tEnd = p_endTime.getStandardTime(); // set reaction set //if (p_initialization || p_reactionChanged || p_conditionChanged) { generateTROEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); generateThirdBodyReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); LinkedList rList = generatePDepODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //generateAllODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //p_reactionChanged = true; //} // set numbers //System.out.println("Total number of reactions to Daspk is "+rList.size()); int nState = p_reactionModel.getSpeciesNumber(); int nParameter = 0; LinkedList initialSpecies = new LinkedList();// if (parameterInfor!=null) nParameter = parameterInfor.length; if (parameterInfor != 0) { nParameter = rList.size()+thirdBodyReactionList.length; //svp if (initialStatus == null) System.out.println("initialStatus = null"); Iterator spe_iter = initialStatus.getSpeciesStatus(); while (spe_iter.hasNext()) { SpeciesStatus ss = (SpeciesStatus) spe_iter.next(); String name = ss.getSpecies().getName(); initialSpecies.add(name); nParameter++; } } int neq = nState*(nParameter+1); // set temperature and pressure double T = p_temperature.getK(); double P = p_pressure.getAtm(); // set initial value of y and yprime; double [] y = new double[neq]; double [] yprime = new double[neq]; //double numberOfReactedSpecies=0; // get the present status at t_begin, and set y and y' accordingly System.out.println("Before ODE: " + String.valueOf(tBegin) + "SEC"); System.out.println("End at : " + String.valueOf(tEnd) + "SEC"); for (Iterator iter = p_beginStatus.getSpeciesStatus(); iter.hasNext(); ) { SpeciesStatus ss = (SpeciesStatus)iter.next(); double conc = ss.getConcentration(); double flux = ss.getFlux(); if (ss.isReactedSpecies()) { Species spe = ss.getSpecies(); int id = getRealID(spe); System.out.println(String.valueOf(spe.getID()) + '\t' + spe.getName() + '\t' + String.valueOf(conc) + '\t' + String.valueOf(flux)); y[id-1] = conc; yprime[id-1] = flux; } } if (nParameter != 0){//svp parameterInforArray = new ParameterInfor[nParameter]; for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ parameterInforArray[i-1] = new ParameterInfor("k",i,0.00); } for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ parameterInforArray[i - 1] = new ParameterInfor("CO", nParameter, 0.00); } if (p_beginTime.getTime() == 0 || p_beginTime.getTime() == 0.00) { LinkedList sensitivityStatus = new LinkedList(); int reactionNumber = rList.size()+thirdBodyReactionList.length; int speciesNumber = p_reactionModel.getSpeciesNumber();// for (int i=0;i<reactionNumber*speciesNumber;i++){ for (int i=0; i<nParameter*speciesNumber;i++){ sensitivityStatus.add(i,null); } p_beginStatus.addSensitivity(sensitivityStatus); double sflux = 1; Iterator species_iter = p_reactionModel.getSpecies(); while (species_iter.hasNext()) { Species spe = (Species) species_iter.next(); int m = getRealID(spe); for (int p=0;p<nParameter;p++){ int k = m + (p+1) * speciesNumber - 1; //if (p >= rList.size()){ if (p >= reactionNumber){ int speciesNum = p-rList.size()-thirdBodyReactionList.length; String name = (String)initialSpecies.get(speciesNum); sflux = 0; SensitivityStatus senStatus; if (name.equalsIgnoreCase(spe.getName())){ senStatus = new SensitivityStatus(1, sflux, m, p + 1); y[k] = 1; } else{ senStatus = new SensitivityStatus(0,sflux,m,p+1); y[k]=0; } sensitivityStatus.add(k - p_reactionModel.getSpeciesNumber(), senStatus); p_beginStatus.putSensitivityStatus(k - speciesNumber, senStatus); yprime[k] = sflux; } else{ if (p < rList.size()){ Reaction rxn = (Reaction)rList.get(p); if (rxn.containsAsProduct(spe)) { sflux = 1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } if (rxn.containsAsReactant(spe)) { sflux = -1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } else { sflux = 0; } SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } } } } } else { for (int i = p_reactionModel.getSpeciesNumber(); i < y.length; i++) { SensitivityStatus ss = (SensitivityStatus) p_beginStatus. getSensitivityStatus(i-p_reactionModel.getSpeciesNumber()); double sens = ss.getSensitivity(); double sflux = ss.getSFlux(); int reactionNumber = rList.size(); int speciesNumber = p_reactionModel.getSpeciesNumber(); Iterator species_iter = p_reactionModel.getSpecies(); y[i] = sens; yprime[i] = sflux; } } } //System.out.println("Number of Reacted Species is " + numberOfReactedSpecies); int idid; HashMap speStatus = new HashMap(); LinkedList senStatus = new LinkedList(); double[] tPresent = {tBegin}; int temp = 1; if (nParameter==0) { idid = solveDAE(p_initialization, reactionList, true, thirdBodyReactionList, troeReactionList, nState, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid !=1 && idid != 2 && idid != 3) { System.out.println("The idid from DASPK was "+idid + " at time "+tPresent[0]); throw new DynamicSimulatorException("DASPK: SA off."); } System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, 0); } else { idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid != 2 && idid != 3) throw new DynamicSimulatorException("DASPK: SA on."); //speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); senStatus = generateSensitivityStatus(p_reactionModel,y,yprime,nParameter); SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, senStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); sss.setIDTranslator(IDTranslator); sss.setReactionList(rList); return sss; } SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CH4"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO2"), rList, sss, p_temperature); return sss; //#] }
3,241,256
public SystemSnapshot solve(boolean p_initialization, ReactionModel p_reactionModel, boolean p_reactionChanged, SystemSnapshot p_beginStatus, ReactionTime p_beginTime, ReactionTime p_endTime, Temperature p_temperature, Pressure p_pressure, boolean p_conditionChanged) { //#[ operation solve(boolean,ReactionModel,boolean,SystemSnapshot,ReactionTime,ReactionTime,Temperature,Pressure,boolean) ReactionTime rt = p_beginStatus.getTime(); if (!rt.equals(p_beginTime)) throw new InvalidBeginStatusException(); // set time double tBegin = p_beginTime.getStandardTime(); double tEnd = p_endTime.getStandardTime(); // set reaction set //if (p_initialization || p_reactionChanged || p_conditionChanged) { generateTROEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); generateThirdBodyReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); LinkedList rList = generatePDepODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //generateAllODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //p_reactionChanged = true; //} // set numbers //System.out.println("Total number of reactions to Daspk is "+rList.size()); int nState = p_reactionModel.getSpeciesNumber(); int nParameter = 0; LinkedList initialSpecies = new LinkedList();// if (parameterInfor!=null) nParameter = parameterInfor.length; if (parameterInfor != 0) { nParameter = rList.size()+thirdBodyReactionList.length; //svp if (initialStatus == null) System.out.println("initialStatus = null"); Iterator spe_iter = initialStatus.getSpeciesStatus(); while (spe_iter.hasNext()) { SpeciesStatus ss = (SpeciesStatus) spe_iter.next(); String name = ss.getSpecies().getName(); initialSpecies.add(name); nParameter++; } } int neq = nState*(nParameter+1); // set temperature and pressure double T = p_temperature.getK(); double P = p_pressure.getAtm(); // set initial value of y and yprime; double [] y = new double[neq]; double [] yprime = new double[neq]; //double numberOfReactedSpecies=0; // get the present status at t_begin, and set y and y' accordingly System.out.println("Before ODE: " + String.valueOf(tBegin) + "SEC"); System.out.println("End at : " + String.valueOf(tEnd) + "SEC"); for (Iterator iter = p_beginStatus.getSpeciesStatus(); iter.hasNext(); ) { SpeciesStatus ss = (SpeciesStatus)iter.next(); double conc = ss.getConcentration(); double flux = ss.getFlux(); if (ss.isReactedSpecies()) { Species spe = ss.getSpecies(); int id = getRealID(spe); System.out.println(String.valueOf(spe.getID()) + '\t' + spe.getName() + '\t' + String.valueOf(conc) + '\t' + String.valueOf(flux)); y[id-1] = conc; yprime[id-1] = flux; } } if (nParameter != 0){//svp parameterInforArray = new ParameterInfor[nParameter]; for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ parameterInforArray[i-1] = new ParameterInfor("k",i,0.00); } for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ parameterInforArray[i - 1] = new ParameterInfor("CO", nParameter, 0.00); } if (p_beginTime.getTime() == 0 || p_beginTime.getTime() == 0.00) { LinkedList sensitivityStatus = new LinkedList(); int reactionNumber = rList.size()+thirdBodyReactionList.length; int speciesNumber = p_reactionModel.getSpeciesNumber();// for (int i=0;i<reactionNumber*speciesNumber;i++){ for (int i=0; i<nParameter*speciesNumber;i++){ sensitivityStatus.add(i,null); } p_beginStatus.addSensitivity(sensitivityStatus); double sflux = 1; Iterator species_iter = p_reactionModel.getSpecies(); while (species_iter.hasNext()) { Species spe = (Species) species_iter.next(); int m = getRealID(spe); for (int p=0;p<nParameter;p++){ int k = m + (p+1) * speciesNumber - 1; //if (p >= rList.size()){ if (p >= reactionNumber){ int speciesNum = p-rList.size()-thirdBodyReactionList.length; String name = (String)initialSpecies.get(speciesNum); sflux = 0; SensitivityStatus senStatus; if (name.equalsIgnoreCase(spe.getName())){ senStatus = new SensitivityStatus(1, sflux, m, p + 1); y[k] = 1; } else{ senStatus = new SensitivityStatus(0,sflux,m,p+1); y[k]=0; } sensitivityStatus.add(k - p_reactionModel.getSpeciesNumber(), senStatus); p_beginStatus.putSensitivityStatus(k - speciesNumber, senStatus); yprime[k] = sflux; } else{ if (p < rList.size()){ Reaction rxn = (Reaction)rList.get(p); if (rxn.containsAsProduct(spe)) { sflux = 1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } if (rxn.containsAsReactant(spe)) { sflux = -1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } else { sflux = 0; } SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } } } } } else { for (int i = p_reactionModel.getSpeciesNumber(); i < y.length; i++) { SensitivityStatus ss = (SensitivityStatus) p_beginStatus. getSensitivityStatus(i-p_reactionModel.getSpeciesNumber()); double sens = ss.getSensitivity(); double sflux = ss.getSFlux(); int reactionNumber = rList.size(); int speciesNumber = p_reactionModel.getSpeciesNumber(); Iterator species_iter = p_reactionModel.getSpecies(); y[i] = sens; yprime[i] = sflux; } } } //System.out.println("Number of Reacted Species is " + numberOfReactedSpecies); int idid; HashMap speStatus = new HashMap(); LinkedList senStatus = new LinkedList(); double[] tPresent = {tBegin}; int temp = 1; if (nParameter==0) { idid = solveDAE(p_initialization, reactionList, true, thirdBodyReactionList, troeReactionList, nState, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid !=1 && idid != 2 && idid != 3) { System.out.println("The idid from DASPK was "+idid + " at time "+tPresent[0]); throw new DynamicSimulatorException("DASPK: SA off."); } System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, 0); } else { idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid != 2 && idid != 3) throw new DynamicSimulatorException("DASPK: SA on."); //speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); senStatus = generateSensitivityStatus(p_reactionModel,y,yprime,nParameter); SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, senStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); sss.setIDTranslator(IDTranslator); sss.setReactionList(rList); return sss; } SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CH4"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO2"), rList, sss, p_temperature); return sss; //#] }
public SystemSnapshot solve(boolean p_initialization, ReactionModel p_reactionModel, boolean p_reactionChanged, SystemSnapshot p_beginStatus, ReactionTime p_beginTime, ReactionTime p_endTime, Temperature p_temperature, Pressure p_pressure, boolean p_conditionChanged) { //#[ operation solve(boolean,ReactionModel,boolean,SystemSnapshot,ReactionTime,ReactionTime,Temperature,Pressure,boolean) ReactionTime rt = p_beginStatus.getTime(); if (!rt.equals(p_beginTime)) throw new InvalidBeginStatusException(); // set time double tBegin = p_beginTime.getStandardTime(); double tEnd = p_endTime.getStandardTime(); // set reaction set //if (p_initialization || p_reactionChanged || p_conditionChanged) { generateTROEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); generateThirdBodyReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); LinkedList rList = generatePDepODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //generateAllODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //p_reactionChanged = true; //} // set numbers //System.out.println("Total number of reactions to Daspk is "+rList.size()); int nState = p_reactionModel.getSpeciesNumber(); int nParameter = 0; LinkedList initialSpecies = new LinkedList();// if (parameterInfor!=null) nParameter = parameterInfor.length; if (parameterInfor != 0) { nParameter = rList.size()+thirdBodyReactionList.length; //svp if (initialStatus == null) System.out.println("initialStatus = null"); Iterator spe_iter = initialStatus.getSpeciesStatus(); while (spe_iter.hasNext()) { SpeciesStatus ss = (SpeciesStatus) spe_iter.next(); String name = ss.getSpecies().getName(); initialSpecies.add(name); nParameter++; } } int neq = nState*(nParameter+1); // set temperature and pressure double T = p_temperature.getK(); double P = p_pressure.getAtm(); // set initial value of y and yprime; double [] y = new double[neq]; double [] yprime = new double[neq]; //double numberOfReactedSpecies=0; // get the present status at t_begin, and set y and y' accordingly System.out.println("Before ODE: " + String.valueOf(tBegin) + "SEC"); System.out.println("End at : " + String.valueOf(tEnd) + "SEC"); for (Iterator iter = p_beginStatus.getSpeciesStatus(); iter.hasNext(); ) { SpeciesStatus ss = (SpeciesStatus)iter.next(); double conc = ss.getConcentration(); double flux = ss.getFlux(); if (ss.isReactedSpecies()) { Species spe = ss.getSpecies(); int id = getRealID(spe); System.out.println(String.valueOf(spe.getID()) + '\t' + spe.getName() + '\t' + String.valueOf(conc) + '\t' + String.valueOf(flux)); y[id-1] = conc; yprime[id-1] = flux; } } if (nParameter != 0){//svp parameterInforArray = new ParameterInfor[nParameter]; for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ parameterInforArray[i-1] = new ParameterInfor("k",i,0.00); } for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ parameterInforArray[i - 1] = new ParameterInfor("CO", nParameter, 0.00); } if (p_beginTime.getTime() == 0 || p_beginTime.getTime() == 0.00) { LinkedList sensitivityStatus = new LinkedList(); int reactionNumber = rList.size()+thirdBodyReactionList.length; int speciesNumber = p_reactionModel.getSpeciesNumber();// for (int i=0;i<reactionNumber*speciesNumber;i++){ for (int i=0; i<nParameter*speciesNumber;i++){ sensitivityStatus.add(i,null); } p_beginStatus.addSensitivity(sensitivityStatus); double sflux = 1; Iterator species_iter = p_reactionModel.getSpecies(); while (species_iter.hasNext()) { Species spe = (Species) species_iter.next(); int m = getRealID(spe); for (int p=0;p<nParameter;p++){ int k = m + (p+1) * speciesNumber - 1; //if (p >= rList.size()){ if (p >= reactionNumber){ int speciesNum = p-rList.size()-thirdBodyReactionList.length; String name = (String)initialSpecies.get(speciesNum); sflux = 0; SensitivityStatus senStatus; if (name.equalsIgnoreCase(spe.getName())){ senStatus = new SensitivityStatus(1, sflux, m, p + 1); y[k] = 1; } else{ senStatus = new SensitivityStatus(0,sflux,m,p+1); y[k]=0; } sensitivityStatus.add(k - p_reactionModel.getSpeciesNumber(), senStatus); p_beginStatus.putSensitivityStatus(k - speciesNumber, senStatus); yprime[k] = sflux; } else{ if (p < rList.size()){ Reaction rxn = (Reaction)rList.get(p); if (rxn.containsAsProduct(spe)) { sflux = 1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } if (rxn.containsAsReactant(spe)) { sflux = -1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } else { sflux = 0; } SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } } } } } else { for (int i = p_reactionModel.getSpeciesNumber(); i < y.length; i++) { SensitivityStatus ss = (SensitivityStatus) p_beginStatus. getSensitivityStatus(i-p_reactionModel.getSpeciesNumber()); double sens = ss.getSensitivity(); double sflux = ss.getSFlux(); int reactionNumber = rList.size(); int speciesNumber = p_reactionModel.getSpeciesNumber(); Iterator species_iter = p_reactionModel.getSpecies(); y[i] = sens; yprime[i] = sflux; } } } //System.out.println("Number of Reacted Species is " + numberOfReactedSpecies); int idid; HashMap speStatus = new HashMap(); LinkedList senStatus = new LinkedList(); double[] tPresent = {tBegin}; int temp = 1; if (nParameter==0) { idid = solveDAE(p_initialization, reactionList, true, thirdBodyReactionList, troeReactionList, nState, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid !=1 && idid != 2 && idid != 3) { System.out.println("The idid from DASPK was "+idid + " at time "+tPresent[0]); throw new DynamicSimulatorException("DASPK: SA off."); } System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, 0); } else { idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid != 2 && idid != 3) throw new DynamicSimulatorException("DASPK: SA on."); //speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); senStatus = generateSensitivityStatus(p_reactionModel,y,yprime,nParameter); SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, senStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); sss.setIDTranslator(IDTranslator); sss.setReactionList(rList); return sss; } SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CH4"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO2"), rList, sss, p_temperature); return sss; //#] }
3,241,257
public SystemSnapshot solve(boolean p_initialization, ReactionModel p_reactionModel, boolean p_reactionChanged, SystemSnapshot p_beginStatus, ReactionTime p_beginTime, ReactionTime p_endTime, Temperature p_temperature, Pressure p_pressure, boolean p_conditionChanged) { //#[ operation solve(boolean,ReactionModel,boolean,SystemSnapshot,ReactionTime,ReactionTime,Temperature,Pressure,boolean) ReactionTime rt = p_beginStatus.getTime(); if (!rt.equals(p_beginTime)) throw new InvalidBeginStatusException(); // set time double tBegin = p_beginTime.getStandardTime(); double tEnd = p_endTime.getStandardTime(); // set reaction set //if (p_initialization || p_reactionChanged || p_conditionChanged) { generateTROEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); generateThirdBodyReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); LinkedList rList = generatePDepODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //generateAllODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //p_reactionChanged = true; //} // set numbers //System.out.println("Total number of reactions to Daspk is "+rList.size()); int nState = p_reactionModel.getSpeciesNumber(); int nParameter = 0; LinkedList initialSpecies = new LinkedList();// if (parameterInfor!=null) nParameter = parameterInfor.length; if (parameterInfor != 0) { nParameter = rList.size()+thirdBodyReactionList.length; //svp if (initialStatus == null) System.out.println("initialStatus = null"); Iterator spe_iter = initialStatus.getSpeciesStatus(); while (spe_iter.hasNext()) { SpeciesStatus ss = (SpeciesStatus) spe_iter.next(); String name = ss.getSpecies().getName(); initialSpecies.add(name); nParameter++; } } int neq = nState*(nParameter+1); // set temperature and pressure double T = p_temperature.getK(); double P = p_pressure.getAtm(); // set initial value of y and yprime; double [] y = new double[neq]; double [] yprime = new double[neq]; //double numberOfReactedSpecies=0; // get the present status at t_begin, and set y and y' accordingly System.out.println("Before ODE: " + String.valueOf(tBegin) + "SEC"); System.out.println("End at : " + String.valueOf(tEnd) + "SEC"); for (Iterator iter = p_beginStatus.getSpeciesStatus(); iter.hasNext(); ) { SpeciesStatus ss = (SpeciesStatus)iter.next(); double conc = ss.getConcentration(); double flux = ss.getFlux(); if (ss.isReactedSpecies()) { Species spe = ss.getSpecies(); int id = getRealID(spe); System.out.println(String.valueOf(spe.getID()) + '\t' + spe.getName() + '\t' + String.valueOf(conc) + '\t' + String.valueOf(flux)); y[id-1] = conc; yprime[id-1] = flux; } } if (nParameter != 0){//svp parameterInforArray = new ParameterInfor[nParameter]; for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ parameterInforArray[i-1] = new ParameterInfor("k",i,0.00); } for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ parameterInforArray[i - 1] = new ParameterInfor("CO", nParameter, 0.00); } if (p_beginTime.getTime() == 0 || p_beginTime.getTime() == 0.00) { LinkedList sensitivityStatus = new LinkedList(); int reactionNumber = rList.size()+thirdBodyReactionList.length; int speciesNumber = p_reactionModel.getSpeciesNumber();// for (int i=0;i<reactionNumber*speciesNumber;i++){ for (int i=0; i<nParameter*speciesNumber;i++){ sensitivityStatus.add(i,null); } p_beginStatus.addSensitivity(sensitivityStatus); double sflux = 1; Iterator species_iter = p_reactionModel.getSpecies(); while (species_iter.hasNext()) { Species spe = (Species) species_iter.next(); int m = getRealID(spe); for (int p=0;p<nParameter;p++){ int k = m + (p+1) * speciesNumber - 1; //if (p >= rList.size()){ if (p >= reactionNumber){ int speciesNum = p-rList.size()-thirdBodyReactionList.length; String name = (String)initialSpecies.get(speciesNum); sflux = 0; SensitivityStatus senStatus; if (name.equalsIgnoreCase(spe.getName())){ senStatus = new SensitivityStatus(1, sflux, m, p + 1); y[k] = 1; } else{ senStatus = new SensitivityStatus(0,sflux,m,p+1); y[k]=0; } sensitivityStatus.add(k - p_reactionModel.getSpeciesNumber(), senStatus); p_beginStatus.putSensitivityStatus(k - speciesNumber, senStatus); yprime[k] = sflux; } else{ if (p < rList.size()){ Reaction rxn = (Reaction)rList.get(p); if (rxn.containsAsProduct(spe)) { sflux = 1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } if (rxn.containsAsReactant(spe)) { sflux = -1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } else { sflux = 0; } SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } } } } } else { for (int i = p_reactionModel.getSpeciesNumber(); i < y.length; i++) { SensitivityStatus ss = (SensitivityStatus) p_beginStatus. getSensitivityStatus(i-p_reactionModel.getSpeciesNumber()); double sens = ss.getSensitivity(); double sflux = ss.getSFlux(); int reactionNumber = rList.size(); int speciesNumber = p_reactionModel.getSpeciesNumber(); Iterator species_iter = p_reactionModel.getSpecies(); y[i] = sens; yprime[i] = sflux; } } } //System.out.println("Number of Reacted Species is " + numberOfReactedSpecies); int idid; HashMap speStatus = new HashMap(); LinkedList senStatus = new LinkedList(); double[] tPresent = {tBegin}; int temp = 1; if (nParameter==0) { idid = solveDAE(p_initialization, reactionList, true, thirdBodyReactionList, troeReactionList, nState, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid !=1 && idid != 2 && idid != 3) { System.out.println("The idid from DASPK was "+idid + " at time "+tPresent[0]); throw new DynamicSimulatorException("DASPK: SA off."); } System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, 0); } else { idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid != 2 && idid != 3) throw new DynamicSimulatorException("DASPK: SA on."); //speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); senStatus = generateSensitivityStatus(p_reactionModel,y,yprime,nParameter); SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, senStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); sss.setIDTranslator(IDTranslator); sss.setReactionList(rList); return sss; } SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CH4"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO2"), rList, sss, p_temperature); return sss; //#] }
public SystemSnapshot solve(boolean p_initialization, ReactionModel p_reactionModel, boolean p_reactionChanged, SystemSnapshot p_beginStatus, ReactionTime p_beginTime, ReactionTime p_endTime, Temperature p_temperature, Pressure p_pressure, boolean p_conditionChanged) { //#[ operation solve(boolean,ReactionModel,boolean,SystemSnapshot,ReactionTime,ReactionTime,Temperature,Pressure,boolean) ReactionTime rt = p_beginStatus.getTime(); if (!rt.equals(p_beginTime)) throw new InvalidBeginStatusException(); // set time double tBegin = p_beginTime.getStandardTime(); double tEnd = p_endTime.getStandardTime(); // set reaction set //if (p_initialization || p_reactionChanged || p_conditionChanged) { generateTROEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); generateThirdBodyReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); LinkedList rList = generatePDepODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //generateAllODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //p_reactionChanged = true; //} // set numbers //System.out.println("Total number of reactions to Daspk is "+rList.size()); int nState = p_reactionModel.getSpeciesNumber(); int nParameter = 0; LinkedList initialSpecies = new LinkedList();// if (parameterInfor!=null) nParameter = parameterInfor.length; if (parameterInfor != 0) { nParameter = rList.size()+thirdBodyReactionList.length; //svp if (initialStatus == null) System.out.println("initialStatus = null"); Iterator spe_iter = initialStatus.getSpeciesStatus(); while (spe_iter.hasNext()) { SpeciesStatus ss = (SpeciesStatus) spe_iter.next(); String name = ss.getSpecies().getName(); initialSpecies.add(name); nParameter++; } } int neq = nState*(nParameter+1); // set temperature and pressure double T = p_temperature.getK(); double P = p_pressure.getAtm(); // set initial value of y and yprime; double [] y = new double[neq]; double [] yprime = new double[neq]; //double numberOfReactedSpecies=0; // get the present status at t_begin, and set y and y' accordingly System.out.println("Before ODE: " + String.valueOf(tBegin) + "SEC"); System.out.println("End at : " + String.valueOf(tEnd) + "SEC"); for (Iterator iter = p_beginStatus.getSpeciesStatus(); iter.hasNext(); ) { SpeciesStatus ss = (SpeciesStatus)iter.next(); double conc = ss.getConcentration(); double flux = ss.getFlux(); if (ss.isReactedSpecies()) { Species spe = ss.getSpecies(); int id = getRealID(spe); System.out.println(String.valueOf(spe.getID()) + '\t' + spe.getName() + '\t' + String.valueOf(conc) + '\t' + String.valueOf(flux)); y[id-1] = conc; yprime[id-1] = flux; } } if (nParameter != 0){//svp parameterInforArray = new ParameterInfor[nParameter]; for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ parameterInforArray[i-1] = new ParameterInfor("k",i,0.00); } for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ parameterInforArray[i - 1] = new ParameterInfor("CO", nParameter, 0.00); } if (p_beginTime.getTime() == 0 || p_beginTime.getTime() == 0.00) { LinkedList sensitivityStatus = new LinkedList(); int reactionNumber = rList.size()+thirdBodyReactionList.length; int speciesNumber = p_reactionModel.getSpeciesNumber();// for (int i=0;i<reactionNumber*speciesNumber;i++){ for (int i=0; i<nParameter*speciesNumber;i++){ sensitivityStatus.add(i,null); } p_beginStatus.addSensitivity(sensitivityStatus); double sflux = 1; Iterator species_iter = p_reactionModel.getSpecies(); while (species_iter.hasNext()) { Species spe = (Species) species_iter.next(); int m = getRealID(spe); for (int p=0;p<nParameter;p++){ int k = m + (p+1) * speciesNumber - 1; //if (p >= rList.size()){ if (p >= reactionNumber){ int speciesNum = p-rList.size()-thirdBodyReactionList.length; String name = (String)initialSpecies.get(speciesNum); sflux = 0; SensitivityStatus senStatus; if (name.equalsIgnoreCase(spe.getName())){ senStatus = new SensitivityStatus(1, sflux, m, p + 1); y[k] = 1; } else{ senStatus = new SensitivityStatus(0,sflux,m,p+1); y[k]=0; } sensitivityStatus.add(k - p_reactionModel.getSpeciesNumber(), senStatus); p_beginStatus.putSensitivityStatus(k - speciesNumber, senStatus); yprime[k] = sflux; } else{ if (p < rList.size()){ Reaction rxn = (Reaction)rList.get(p); if (rxn.containsAsProduct(spe)) { sflux = 1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } if (rxn.containsAsReactant(spe)) { sflux = -1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } else { sflux = 0; } SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } } } } } else { for (int i = p_reactionModel.getSpeciesNumber(); i < y.length; i++) { SensitivityStatus ss = (SensitivityStatus) p_beginStatus. getSensitivityStatus(i-p_reactionModel.getSpeciesNumber()); double sens = ss.getSensitivity(); double sflux = ss.getSFlux(); int reactionNumber = rList.size(); int speciesNumber = p_reactionModel.getSpeciesNumber(); Iterator species_iter = p_reactionModel.getSpecies(); y[i] = sens; yprime[i] = sflux; } } } //System.out.println("Number of Reacted Species is " + numberOfReactedSpecies); int idid; HashMap speStatus = new HashMap(); LinkedList senStatus = new LinkedList(); double[] tPresent = {tBegin}; int temp = 1; if (nParameter==0) { idid = solveDAE(p_initialization, reactionList, true, thirdBodyReactionList, troeReactionList, nState, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid !=1 && idid != 2 && idid != 3) { System.out.println("The idid from DASPK was "+idid + " at time "+tPresent[0]); throw new DynamicSimulatorException("DASPK: SA off."); } System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, 0); } else { idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid != 2 && idid != 3) throw new DynamicSimulatorException("DASPK: SA on."); //speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); senStatus = generateSensitivityStatus(p_reactionModel,y,yprime,nParameter); SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, senStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); sss.setIDTranslator(IDTranslator); sss.setReactionList(rList); return sss; } SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CH4"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO2"), rList, sss, p_temperature); return sss; //#] }
3,241,258
public SystemSnapshot solve(boolean p_initialization, ReactionModel p_reactionModel, boolean p_reactionChanged, SystemSnapshot p_beginStatus, ReactionTime p_beginTime, ReactionTime p_endTime, Temperature p_temperature, Pressure p_pressure, boolean p_conditionChanged) { //#[ operation solve(boolean,ReactionModel,boolean,SystemSnapshot,ReactionTime,ReactionTime,Temperature,Pressure,boolean) ReactionTime rt = p_beginStatus.getTime(); if (!rt.equals(p_beginTime)) throw new InvalidBeginStatusException(); // set time double tBegin = p_beginTime.getStandardTime(); double tEnd = p_endTime.getStandardTime(); // set reaction set //if (p_initialization || p_reactionChanged || p_conditionChanged) { generateTROEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); generateThirdBodyReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); LinkedList rList = generatePDepODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //generateAllODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //p_reactionChanged = true; //} // set numbers //System.out.println("Total number of reactions to Daspk is "+rList.size()); int nState = p_reactionModel.getSpeciesNumber(); int nParameter = 0; LinkedList initialSpecies = new LinkedList();// if (parameterInfor!=null) nParameter = parameterInfor.length; if (parameterInfor != 0) { nParameter = rList.size()+thirdBodyReactionList.length; //svp if (initialStatus == null) System.out.println("initialStatus = null"); Iterator spe_iter = initialStatus.getSpeciesStatus(); while (spe_iter.hasNext()) { SpeciesStatus ss = (SpeciesStatus) spe_iter.next(); String name = ss.getSpecies().getName(); initialSpecies.add(name); nParameter++; } } int neq = nState*(nParameter+1); // set temperature and pressure double T = p_temperature.getK(); double P = p_pressure.getAtm(); // set initial value of y and yprime; double [] y = new double[neq]; double [] yprime = new double[neq]; //double numberOfReactedSpecies=0; // get the present status at t_begin, and set y and y' accordingly System.out.println("Before ODE: " + String.valueOf(tBegin) + "SEC"); System.out.println("End at : " + String.valueOf(tEnd) + "SEC"); for (Iterator iter = p_beginStatus.getSpeciesStatus(); iter.hasNext(); ) { SpeciesStatus ss = (SpeciesStatus)iter.next(); double conc = ss.getConcentration(); double flux = ss.getFlux(); if (ss.isReactedSpecies()) { Species spe = ss.getSpecies(); int id = getRealID(spe); System.out.println(String.valueOf(spe.getID()) + '\t' + spe.getName() + '\t' + String.valueOf(conc) + '\t' + String.valueOf(flux)); y[id-1] = conc; yprime[id-1] = flux; } } if (nParameter != 0){//svp parameterInforArray = new ParameterInfor[nParameter]; for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ parameterInforArray[i-1] = new ParameterInfor("k",i,0.00); } for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ parameterInforArray[i - 1] = new ParameterInfor("CO", nParameter, 0.00); } if (p_beginTime.getTime() == 0 || p_beginTime.getTime() == 0.00) { LinkedList sensitivityStatus = new LinkedList(); int reactionNumber = rList.size()+thirdBodyReactionList.length; int speciesNumber = p_reactionModel.getSpeciesNumber();// for (int i=0;i<reactionNumber*speciesNumber;i++){ for (int i=0; i<nParameter*speciesNumber;i++){ sensitivityStatus.add(i,null); } p_beginStatus.addSensitivity(sensitivityStatus); double sflux = 1; Iterator species_iter = p_reactionModel.getSpecies(); while (species_iter.hasNext()) { Species spe = (Species) species_iter.next(); int m = getRealID(spe); for (int p=0;p<nParameter;p++){ int k = m + (p+1) * speciesNumber - 1; //if (p >= rList.size()){ if (p >= reactionNumber){ int speciesNum = p-rList.size()-thirdBodyReactionList.length; String name = (String)initialSpecies.get(speciesNum); sflux = 0; SensitivityStatus senStatus; if (name.equalsIgnoreCase(spe.getName())){ senStatus = new SensitivityStatus(1, sflux, m, p + 1); y[k] = 1; } else{ senStatus = new SensitivityStatus(0,sflux,m,p+1); y[k]=0; } sensitivityStatus.add(k - p_reactionModel.getSpeciesNumber(), senStatus); p_beginStatus.putSensitivityStatus(k - speciesNumber, senStatus); yprime[k] = sflux; } else{ if (p < rList.size()){ Reaction rxn = (Reaction)rList.get(p); if (rxn.containsAsProduct(spe)) { sflux = 1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } if (rxn.containsAsReactant(spe)) { sflux = -1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } else { sflux = 0; } SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } } } } } else { for (int i = p_reactionModel.getSpeciesNumber(); i < y.length; i++) { SensitivityStatus ss = (SensitivityStatus) p_beginStatus. getSensitivityStatus(i-p_reactionModel.getSpeciesNumber()); double sens = ss.getSensitivity(); double sflux = ss.getSFlux(); int reactionNumber = rList.size(); int speciesNumber = p_reactionModel.getSpeciesNumber(); Iterator species_iter = p_reactionModel.getSpecies(); y[i] = sens; yprime[i] = sflux; } } } //System.out.println("Number of Reacted Species is " + numberOfReactedSpecies); int idid; HashMap speStatus = new HashMap(); LinkedList senStatus = new LinkedList(); double[] tPresent = {tBegin}; int temp = 1; if (nParameter==0) { idid = solveDAE(p_initialization, reactionList, true, thirdBodyReactionList, troeReactionList, nState, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid !=1 && idid != 2 && idid != 3) { System.out.println("The idid from DASPK was "+idid + " at time "+tPresent[0]); throw new DynamicSimulatorException("DASPK: SA off."); } System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, 0); } else { idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid != 2 && idid != 3) throw new DynamicSimulatorException("DASPK: SA on."); //speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); senStatus = generateSensitivityStatus(p_reactionModel,y,yprime,nParameter); SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, senStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); sss.setIDTranslator(IDTranslator); sss.setReactionList(rList); return sss; } SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CH4"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO2"), rList, sss, p_temperature); return sss; //#] }
public SystemSnapshot solve(boolean p_initialization, ReactionModel p_reactionModel, boolean p_reactionChanged, SystemSnapshot p_beginStatus, ReactionTime p_beginTime, ReactionTime p_endTime, Temperature p_temperature, Pressure p_pressure, boolean p_conditionChanged) { //#[ operation solve(boolean,ReactionModel,boolean,SystemSnapshot,ReactionTime,ReactionTime,Temperature,Pressure,boolean) ReactionTime rt = p_beginStatus.getTime(); if (!rt.equals(p_beginTime)) throw new InvalidBeginStatusException(); // set time double tBegin = p_beginTime.getStandardTime(); double tEnd = p_endTime.getStandardTime(); // set reaction set //if (p_initialization || p_reactionChanged || p_conditionChanged) { generateTROEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); generateThirdBodyReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); LinkedList rList = generatePDepODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //generateAllODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //p_reactionChanged = true; //} // set numbers //System.out.println("Total number of reactions to Daspk is "+rList.size()); int nState = p_reactionModel.getSpeciesNumber(); int nParameter = 0; LinkedList initialSpecies = new LinkedList();// if (parameterInfor!=null) nParameter = parameterInfor.length; if (parameterInfor != 0) { nParameter = rList.size()+thirdBodyReactionList.length; //svp if (initialStatus == null) System.out.println("initialStatus = null"); Iterator spe_iter = initialStatus.getSpeciesStatus(); while (spe_iter.hasNext()) { SpeciesStatus ss = (SpeciesStatus) spe_iter.next(); String name = ss.getSpecies().getName(); initialSpecies.add(name); nParameter++; } } int neq = nState*(nParameter+1); // set temperature and pressure double T = p_temperature.getK(); double P = p_pressure.getAtm(); // set initial value of y and yprime; double [] y = new double[neq]; double [] yprime = new double[neq]; //double numberOfReactedSpecies=0; // get the present status at t_begin, and set y and y' accordingly System.out.println("Before ODE: " + String.valueOf(tBegin) + "SEC"); System.out.println("End at : " + String.valueOf(tEnd) + "SEC"); for (Iterator iter = p_beginStatus.getSpeciesStatus(); iter.hasNext(); ) { SpeciesStatus ss = (SpeciesStatus)iter.next(); double conc = ss.getConcentration(); double flux = ss.getFlux(); if (ss.isReactedSpecies()) { Species spe = ss.getSpecies(); int id = getRealID(spe); System.out.println(String.valueOf(spe.getID()) + '\t' + spe.getName() + '\t' + String.valueOf(conc) + '\t' + String.valueOf(flux)); y[id-1] = conc; yprime[id-1] = flux; } } if (nParameter != 0){//svp parameterInforArray = new ParameterInfor[nParameter]; for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ parameterInforArray[i-1] = new ParameterInfor("k",i,0.00); } for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ parameterInforArray[i - 1] = new ParameterInfor("CO", nParameter, 0.00); } if (p_beginTime.getTime() == 0 || p_beginTime.getTime() == 0.00) { LinkedList sensitivityStatus = new LinkedList(); int reactionNumber = rList.size()+thirdBodyReactionList.length; int speciesNumber = p_reactionModel.getSpeciesNumber();// for (int i=0;i<reactionNumber*speciesNumber;i++){ for (int i=0; i<nParameter*speciesNumber;i++){ sensitivityStatus.add(i,null); } p_beginStatus.addSensitivity(sensitivityStatus); double sflux = 1; Iterator species_iter = p_reactionModel.getSpecies(); while (species_iter.hasNext()) { Species spe = (Species) species_iter.next(); int m = getRealID(spe); for (int p=0;p<nParameter;p++){ int k = m + (p+1) * speciesNumber - 1; //if (p >= rList.size()){ if (p >= reactionNumber){ int speciesNum = p-rList.size()-thirdBodyReactionList.length; String name = (String)initialSpecies.get(speciesNum); sflux = 0; SensitivityStatus senStatus; if (name.equalsIgnoreCase(spe.getName())){ senStatus = new SensitivityStatus(1, sflux, m, p + 1); y[k] = 1; } else{ senStatus = new SensitivityStatus(0,sflux,m,p+1); y[k]=0; } sensitivityStatus.add(k - p_reactionModel.getSpeciesNumber(), senStatus); p_beginStatus.putSensitivityStatus(k - speciesNumber, senStatus); yprime[k] = sflux; } else{ if (p < rList.size()){ Reaction rxn = (Reaction)rList.get(p); if (rxn.containsAsProduct(spe)) { sflux = 1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } if (rxn.containsAsReactant(spe)) { sflux = -1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } else { sflux = 0; } SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } } } } } else { for (int i = p_reactionModel.getSpeciesNumber(); i < y.length; i++) { SensitivityStatus ss = (SensitivityStatus) p_beginStatus. getSensitivityStatus(i-p_reactionModel.getSpeciesNumber()); double sens = ss.getSensitivity(); double sflux = ss.getSFlux(); int reactionNumber = rList.size(); int speciesNumber = p_reactionModel.getSpeciesNumber(); Iterator species_iter = p_reactionModel.getSpecies(); y[i] = sens; yprime[i] = sflux; } } } //System.out.println("Number of Reacted Species is " + numberOfReactedSpecies); int idid; HashMap speStatus = new HashMap(); LinkedList senStatus = new LinkedList(); double[] tPresent = {tBegin}; int temp = 1; if (nParameter==0) { idid = solveDAE(p_initialization, reactionList, true, thirdBodyReactionList, troeReactionList, nState, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid !=1 && idid != 2 && idid != 3) { System.out.println("The idid from DASPK was "+idid + " at time "+tPresent[0]); throw new DynamicSimulatorException("DASPK: SA off."); } System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, 0); } else { idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid != 2 && idid != 3) throw new DynamicSimulatorException("DASPK: SA on."); //speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); senStatus = generateSensitivityStatus(p_reactionModel,y,yprime,nParameter); SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, senStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); sss.setIDTranslator(IDTranslator); sss.setReactionList(rList); return sss; } SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CH4"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO2"), rList, sss, p_temperature); return sss; //#] }
3,241,259
public SystemSnapshot solve(boolean p_initialization, ReactionModel p_reactionModel, boolean p_reactionChanged, SystemSnapshot p_beginStatus, ReactionTime p_beginTime, ReactionTime p_endTime, Temperature p_temperature, Pressure p_pressure, boolean p_conditionChanged) { //#[ operation solve(boolean,ReactionModel,boolean,SystemSnapshot,ReactionTime,ReactionTime,Temperature,Pressure,boolean) ReactionTime rt = p_beginStatus.getTime(); if (!rt.equals(p_beginTime)) throw new InvalidBeginStatusException(); // set time double tBegin = p_beginTime.getStandardTime(); double tEnd = p_endTime.getStandardTime(); // set reaction set //if (p_initialization || p_reactionChanged || p_conditionChanged) { generateTROEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); generateThirdBodyReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); LinkedList rList = generatePDepODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //generateAllODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //p_reactionChanged = true; //} // set numbers //System.out.println("Total number of reactions to Daspk is "+rList.size()); int nState = p_reactionModel.getSpeciesNumber(); int nParameter = 0; LinkedList initialSpecies = new LinkedList();// if (parameterInfor!=null) nParameter = parameterInfor.length; if (parameterInfor != 0) { nParameter = rList.size()+thirdBodyReactionList.length; //svp if (initialStatus == null) System.out.println("initialStatus = null"); Iterator spe_iter = initialStatus.getSpeciesStatus(); while (spe_iter.hasNext()) { SpeciesStatus ss = (SpeciesStatus) spe_iter.next(); String name = ss.getSpecies().getName(); initialSpecies.add(name); nParameter++; } } int neq = nState*(nParameter+1); // set temperature and pressure double T = p_temperature.getK(); double P = p_pressure.getAtm(); // set initial value of y and yprime; double [] y = new double[neq]; double [] yprime = new double[neq]; //double numberOfReactedSpecies=0; // get the present status at t_begin, and set y and y' accordingly System.out.println("Before ODE: " + String.valueOf(tBegin) + "SEC"); System.out.println("End at : " + String.valueOf(tEnd) + "SEC"); for (Iterator iter = p_beginStatus.getSpeciesStatus(); iter.hasNext(); ) { SpeciesStatus ss = (SpeciesStatus)iter.next(); double conc = ss.getConcentration(); double flux = ss.getFlux(); if (ss.isReactedSpecies()) { Species spe = ss.getSpecies(); int id = getRealID(spe); System.out.println(String.valueOf(spe.getID()) + '\t' + spe.getName() + '\t' + String.valueOf(conc) + '\t' + String.valueOf(flux)); y[id-1] = conc; yprime[id-1] = flux; } } if (nParameter != 0){//svp parameterInforArray = new ParameterInfor[nParameter]; for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ parameterInforArray[i-1] = new ParameterInfor("k",i,0.00); } for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ parameterInforArray[i - 1] = new ParameterInfor("CO", nParameter, 0.00); } if (p_beginTime.getTime() == 0 || p_beginTime.getTime() == 0.00) { LinkedList sensitivityStatus = new LinkedList(); int reactionNumber = rList.size()+thirdBodyReactionList.length; int speciesNumber = p_reactionModel.getSpeciesNumber();// for (int i=0;i<reactionNumber*speciesNumber;i++){ for (int i=0; i<nParameter*speciesNumber;i++){ sensitivityStatus.add(i,null); } p_beginStatus.addSensitivity(sensitivityStatus); double sflux = 1; Iterator species_iter = p_reactionModel.getSpecies(); while (species_iter.hasNext()) { Species spe = (Species) species_iter.next(); int m = getRealID(spe); for (int p=0;p<nParameter;p++){ int k = m + (p+1) * speciesNumber - 1; //if (p >= rList.size()){ if (p >= reactionNumber){ int speciesNum = p-rList.size()-thirdBodyReactionList.length; String name = (String)initialSpecies.get(speciesNum); sflux = 0; SensitivityStatus senStatus; if (name.equalsIgnoreCase(spe.getName())){ senStatus = new SensitivityStatus(1, sflux, m, p + 1); y[k] = 1; } else{ senStatus = new SensitivityStatus(0,sflux,m,p+1); y[k]=0; } sensitivityStatus.add(k - p_reactionModel.getSpeciesNumber(), senStatus); p_beginStatus.putSensitivityStatus(k - speciesNumber, senStatus); yprime[k] = sflux; } else{ if (p < rList.size()){ Reaction rxn = (Reaction)rList.get(p); if (rxn.containsAsProduct(spe)) { sflux = 1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } if (rxn.containsAsReactant(spe)) { sflux = -1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } else { sflux = 0; } SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } } } } } else { for (int i = p_reactionModel.getSpeciesNumber(); i < y.length; i++) { SensitivityStatus ss = (SensitivityStatus) p_beginStatus. getSensitivityStatus(i-p_reactionModel.getSpeciesNumber()); double sens = ss.getSensitivity(); double sflux = ss.getSFlux(); int reactionNumber = rList.size(); int speciesNumber = p_reactionModel.getSpeciesNumber(); Iterator species_iter = p_reactionModel.getSpecies(); y[i] = sens; yprime[i] = sflux; } } } //System.out.println("Number of Reacted Species is " + numberOfReactedSpecies); int idid; HashMap speStatus = new HashMap(); LinkedList senStatus = new LinkedList(); double[] tPresent = {tBegin}; int temp = 1; if (nParameter==0) { idid = solveDAE(p_initialization, reactionList, true, thirdBodyReactionList, troeReactionList, nState, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid !=1 && idid != 2 && idid != 3) { System.out.println("The idid from DASPK was "+idid + " at time "+tPresent[0]); throw new DynamicSimulatorException("DASPK: SA off."); } System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, 0); } else { idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid != 2 && idid != 3) throw new DynamicSimulatorException("DASPK: SA on."); //speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); senStatus = generateSensitivityStatus(p_reactionModel,y,yprime,nParameter); SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, senStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); sss.setIDTranslator(IDTranslator); sss.setReactionList(rList); return sss; } SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CH4"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO2"), rList, sss, p_temperature); return sss; //#] }
public SystemSnapshot solve(boolean p_initialization, ReactionModel p_reactionModel, boolean p_reactionChanged, SystemSnapshot p_beginStatus, ReactionTime p_beginTime, ReactionTime p_endTime, Temperature p_temperature, Pressure p_pressure, boolean p_conditionChanged) { //#[ operation solve(boolean,ReactionModel,boolean,SystemSnapshot,ReactionTime,ReactionTime,Temperature,Pressure,boolean) ReactionTime rt = p_beginStatus.getTime(); if (!rt.equals(p_beginTime)) throw new InvalidBeginStatusException(); // set time double tBegin = p_beginTime.getStandardTime(); double tEnd = p_endTime.getStandardTime(); // set reaction set //if (p_initialization || p_reactionChanged || p_conditionChanged) { generateTROEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); generateThirdBodyReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); LinkedList rList = generatePDepODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //generateAllODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //p_reactionChanged = true; //} // set numbers //System.out.println("Total number of reactions to Daspk is "+rList.size()); int nState = p_reactionModel.getSpeciesNumber(); int nParameter = 0; LinkedList initialSpecies = new LinkedList();// if (parameterInfor!=null) nParameter = parameterInfor.length; if (parameterInfor != 0) { nParameter = rList.size()+thirdBodyReactionList.length; //svp if (initialStatus == null) System.out.println("initialStatus = null"); Iterator spe_iter = initialStatus.getSpeciesStatus(); while (spe_iter.hasNext()) { SpeciesStatus ss = (SpeciesStatus) spe_iter.next(); String name = ss.getSpecies().getName(); initialSpecies.add(name); nParameter++; } } int neq = nState*(nParameter+1); // set temperature and pressure double T = p_temperature.getK(); double P = p_pressure.getAtm(); // set initial value of y and yprime; double [] y = new double[neq]; double [] yprime = new double[neq]; //double numberOfReactedSpecies=0; // get the present status at t_begin, and set y and y' accordingly System.out.println("Before ODE: " + String.valueOf(tBegin) + "SEC"); System.out.println("End at : " + String.valueOf(tEnd) + "SEC"); for (Iterator iter = p_beginStatus.getSpeciesStatus(); iter.hasNext(); ) { SpeciesStatus ss = (SpeciesStatus)iter.next(); double conc = ss.getConcentration(); double flux = ss.getFlux(); if (ss.isReactedSpecies()) { Species spe = ss.getSpecies(); int id = getRealID(spe); System.out.println(String.valueOf(spe.getID()) + '\t' + spe.getName() + '\t' + String.valueOf(conc) + '\t' + String.valueOf(flux)); y[id-1] = conc; yprime[id-1] = flux; } } if (nParameter != 0){//svp parameterInforArray = new ParameterInfor[nParameter]; for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ parameterInforArray[i-1] = new ParameterInfor("k",i,0.00); } for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ parameterInforArray[i - 1] = new ParameterInfor("CO", nParameter, 0.00); } if (p_beginTime.getTime() == 0 || p_beginTime.getTime() == 0.00) { LinkedList sensitivityStatus = new LinkedList(); int reactionNumber = rList.size()+thirdBodyReactionList.length; int speciesNumber = p_reactionModel.getSpeciesNumber();// for (int i=0;i<reactionNumber*speciesNumber;i++){ for (int i=0; i<nParameter*speciesNumber;i++){ sensitivityStatus.add(i,null); } p_beginStatus.addSensitivity(sensitivityStatus); double sflux = 1; Iterator species_iter = p_reactionModel.getSpecies(); while (species_iter.hasNext()) { Species spe = (Species) species_iter.next(); int m = getRealID(spe); for (int p=0;p<nParameter;p++){ int k = m + (p+1) * speciesNumber - 1; //if (p >= rList.size()){ if (p >= reactionNumber){ int speciesNum = p-rList.size()-thirdBodyReactionList.length; String name = (String)initialSpecies.get(speciesNum); sflux = 0; SensitivityStatus senStatus; if (name.equalsIgnoreCase(spe.getName())){ senStatus = new SensitivityStatus(1, sflux, m, p + 1); y[k] = 1; } else{ senStatus = new SensitivityStatus(0,sflux,m,p+1); y[k]=0; } sensitivityStatus.add(k - p_reactionModel.getSpeciesNumber(), senStatus); p_beginStatus.putSensitivityStatus(k - speciesNumber, senStatus); yprime[k] = sflux; } else{ if (p < rList.size()){ Reaction rxn = (Reaction)rList.get(p); if (rxn.containsAsProduct(spe)) { sflux = 1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } if (rxn.containsAsReactant(spe)) { sflux = -1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } else { sflux = 0; } SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } } } } } else { for (int i = p_reactionModel.getSpeciesNumber(); i < y.length; i++) { SensitivityStatus ss = (SensitivityStatus) p_beginStatus. getSensitivityStatus(i-p_reactionModel.getSpeciesNumber()); double sens = ss.getSensitivity(); double sflux = ss.getSFlux(); int reactionNumber = rList.size(); int speciesNumber = p_reactionModel.getSpeciesNumber(); Iterator species_iter = p_reactionModel.getSpecies(); y[i] = sens; yprime[i] = sflux; } } } //System.out.println("Number of Reacted Species is " + numberOfReactedSpecies); int idid; HashMap speStatus = new HashMap(); LinkedList senStatus = new LinkedList(); double[] tPresent = {tBegin}; int temp = 1; if (nParameter==0) { idid = solveDAE(p_initialization, reactionList, true, thirdBodyReactionList, troeReactionList, nState, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid !=1 && idid != 2 && idid != 3) { System.out.println("The idid from DASPK was "+idid + " at time "+tPresent[0]); throw new DynamicSimulatorException("DASPK: SA off."); } System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, 0); } else { idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid != 2 && idid != 3) throw new DynamicSimulatorException("DASPK: SA on."); //speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); senStatus = generateSensitivityStatus(p_reactionModel,y,yprime,nParameter); SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, senStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); sss.setIDTranslator(IDTranslator); sss.setReactionList(rList); return sss; } SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CH4"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO2"), rList, sss, p_temperature); return sss; //#] }
3,241,260
public SystemSnapshot solve(boolean p_initialization, ReactionModel p_reactionModel, boolean p_reactionChanged, SystemSnapshot p_beginStatus, ReactionTime p_beginTime, ReactionTime p_endTime, Temperature p_temperature, Pressure p_pressure, boolean p_conditionChanged) { //#[ operation solve(boolean,ReactionModel,boolean,SystemSnapshot,ReactionTime,ReactionTime,Temperature,Pressure,boolean) ReactionTime rt = p_beginStatus.getTime(); if (!rt.equals(p_beginTime)) throw new InvalidBeginStatusException(); // set time double tBegin = p_beginTime.getStandardTime(); double tEnd = p_endTime.getStandardTime(); // set reaction set //if (p_initialization || p_reactionChanged || p_conditionChanged) { generateTROEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); generateThirdBodyReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); LinkedList rList = generatePDepODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //generateAllODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //p_reactionChanged = true; //} // set numbers //System.out.println("Total number of reactions to Daspk is "+rList.size()); int nState = p_reactionModel.getSpeciesNumber(); int nParameter = 0; LinkedList initialSpecies = new LinkedList();// if (parameterInfor!=null) nParameter = parameterInfor.length; if (parameterInfor != 0) { nParameter = rList.size()+thirdBodyReactionList.length; //svp if (initialStatus == null) System.out.println("initialStatus = null"); Iterator spe_iter = initialStatus.getSpeciesStatus(); while (spe_iter.hasNext()) { SpeciesStatus ss = (SpeciesStatus) spe_iter.next(); String name = ss.getSpecies().getName(); initialSpecies.add(name); nParameter++; } } int neq = nState*(nParameter+1); // set temperature and pressure double T = p_temperature.getK(); double P = p_pressure.getAtm(); // set initial value of y and yprime; double [] y = new double[neq]; double [] yprime = new double[neq]; //double numberOfReactedSpecies=0; // get the present status at t_begin, and set y and y' accordingly System.out.println("Before ODE: " + String.valueOf(tBegin) + "SEC"); System.out.println("End at : " + String.valueOf(tEnd) + "SEC"); for (Iterator iter = p_beginStatus.getSpeciesStatus(); iter.hasNext(); ) { SpeciesStatus ss = (SpeciesStatus)iter.next(); double conc = ss.getConcentration(); double flux = ss.getFlux(); if (ss.isReactedSpecies()) { Species spe = ss.getSpecies(); int id = getRealID(spe); System.out.println(String.valueOf(spe.getID()) + '\t' + spe.getName() + '\t' + String.valueOf(conc) + '\t' + String.valueOf(flux)); y[id-1] = conc; yprime[id-1] = flux; } } if (nParameter != 0){//svp parameterInforArray = new ParameterInfor[nParameter]; for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ parameterInforArray[i-1] = new ParameterInfor("k",i,0.00); } for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ parameterInforArray[i - 1] = new ParameterInfor("CO", nParameter, 0.00); } if (p_beginTime.getTime() == 0 || p_beginTime.getTime() == 0.00) { LinkedList sensitivityStatus = new LinkedList(); int reactionNumber = rList.size()+thirdBodyReactionList.length; int speciesNumber = p_reactionModel.getSpeciesNumber();// for (int i=0;i<reactionNumber*speciesNumber;i++){ for (int i=0; i<nParameter*speciesNumber;i++){ sensitivityStatus.add(i,null); } p_beginStatus.addSensitivity(sensitivityStatus); double sflux = 1; Iterator species_iter = p_reactionModel.getSpecies(); while (species_iter.hasNext()) { Species spe = (Species) species_iter.next(); int m = getRealID(spe); for (int p=0;p<nParameter;p++){ int k = m + (p+1) * speciesNumber - 1; //if (p >= rList.size()){ if (p >= reactionNumber){ int speciesNum = p-rList.size()-thirdBodyReactionList.length; String name = (String)initialSpecies.get(speciesNum); sflux = 0; SensitivityStatus senStatus; if (name.equalsIgnoreCase(spe.getName())){ senStatus = new SensitivityStatus(1, sflux, m, p + 1); y[k] = 1; } else{ senStatus = new SensitivityStatus(0,sflux,m,p+1); y[k]=0; } sensitivityStatus.add(k - p_reactionModel.getSpeciesNumber(), senStatus); p_beginStatus.putSensitivityStatus(k - speciesNumber, senStatus); yprime[k] = sflux; } else{ if (p < rList.size()){ Reaction rxn = (Reaction)rList.get(p); if (rxn.containsAsProduct(spe)) { sflux = 1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } if (rxn.containsAsReactant(spe)) { sflux = -1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } else { sflux = 0; } SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } } } } } else { for (int i = p_reactionModel.getSpeciesNumber(); i < y.length; i++) { SensitivityStatus ss = (SensitivityStatus) p_beginStatus. getSensitivityStatus(i-p_reactionModel.getSpeciesNumber()); double sens = ss.getSensitivity(); double sflux = ss.getSFlux(); int reactionNumber = rList.size(); int speciesNumber = p_reactionModel.getSpeciesNumber(); Iterator species_iter = p_reactionModel.getSpecies(); y[i] = sens; yprime[i] = sflux; } } } //System.out.println("Number of Reacted Species is " + numberOfReactedSpecies); int idid; HashMap speStatus = new HashMap(); LinkedList senStatus = new LinkedList(); double[] tPresent = {tBegin}; int temp = 1; if (nParameter==0) { idid = solveDAE(p_initialization, reactionList, true, thirdBodyReactionList, troeReactionList, nState, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid !=1 && idid != 2 && idid != 3) { System.out.println("The idid from DASPK was "+idid + " at time "+tPresent[0]); throw new DynamicSimulatorException("DASPK: SA off."); } System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, 0); } else { idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid != 2 && idid != 3) throw new DynamicSimulatorException("DASPK: SA on."); //speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); senStatus = generateSensitivityStatus(p_reactionModel,y,yprime,nParameter); SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, senStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); sss.setIDTranslator(IDTranslator); sss.setReactionList(rList); return sss; } SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CH4"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO2"), rList, sss, p_temperature); return sss; //#] }
public SystemSnapshot solve(boolean p_initialization, ReactionModel p_reactionModel, boolean p_reactionChanged, SystemSnapshot p_beginStatus, ReactionTime p_beginTime, ReactionTime p_endTime, Temperature p_temperature, Pressure p_pressure, boolean p_conditionChanged) { //#[ operation solve(boolean,ReactionModel,boolean,SystemSnapshot,ReactionTime,ReactionTime,Temperature,Pressure,boolean) ReactionTime rt = p_beginStatus.getTime(); if (!rt.equals(p_beginTime)) throw new InvalidBeginStatusException(); // set time double tBegin = p_beginTime.getStandardTime(); double tEnd = p_endTime.getStandardTime(); // set reaction set //if (p_initialization || p_reactionChanged || p_conditionChanged) { generateTROEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); generateThirdBodyReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); LinkedList rList = generatePDepODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //generateAllODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //p_reactionChanged = true; //} // set numbers //System.out.println("Total number of reactions to Daspk is "+rList.size()); int nState = p_reactionModel.getSpeciesNumber(); int nParameter = 0; LinkedList initialSpecies = new LinkedList();// if (parameterInfor!=null) nParameter = parameterInfor.length; if (parameterInfor != 0) { nParameter = rList.size()+thirdBodyReactionList.length; //svp if (initialStatus == null) System.out.println("initialStatus = null"); Iterator spe_iter = initialStatus.getSpeciesStatus(); while (spe_iter.hasNext()) { SpeciesStatus ss = (SpeciesStatus) spe_iter.next(); String name = ss.getSpecies().getName(); initialSpecies.add(name); nParameter++; } } int neq = nState*(nParameter+1); // set temperature and pressure double T = p_temperature.getK(); double P = p_pressure.getAtm(); // set initial value of y and yprime; double [] y = new double[neq]; double [] yprime = new double[neq]; //double numberOfReactedSpecies=0; // get the present status at t_begin, and set y and y' accordingly System.out.println("Before ODE: " + String.valueOf(tBegin) + "SEC"); System.out.println("End at : " + String.valueOf(tEnd) + "SEC"); for (Iterator iter = p_beginStatus.getSpeciesStatus(); iter.hasNext(); ) { SpeciesStatus ss = (SpeciesStatus)iter.next(); double conc = ss.getConcentration(); double flux = ss.getFlux(); if (ss.isReactedSpecies()) { Species spe = ss.getSpecies(); int id = getRealID(spe); System.out.println(String.valueOf(spe.getID()) + '\t' + spe.getName() + '\t' + String.valueOf(conc) + '\t' + String.valueOf(flux)); y[id-1] = conc; yprime[id-1] = flux; } } if (nParameter != 0){//svp parameterInforArray = new ParameterInfor[nParameter]; for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ parameterInforArray[i-1] = new ParameterInfor("k",i,0.00); } for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ parameterInforArray[i - 1] = new ParameterInfor("CO", nParameter, 0.00); } if (p_beginTime.getTime() == 0 || p_beginTime.getTime() == 0.00) { LinkedList sensitivityStatus = new LinkedList(); int reactionNumber = rList.size()+thirdBodyReactionList.length; int speciesNumber = p_reactionModel.getSpeciesNumber();// for (int i=0;i<reactionNumber*speciesNumber;i++){ for (int i=0; i<nParameter*speciesNumber;i++){ sensitivityStatus.add(i,null); } p_beginStatus.addSensitivity(sensitivityStatus); double sflux = 1; Iterator species_iter = p_reactionModel.getSpecies(); while (species_iter.hasNext()) { Species spe = (Species) species_iter.next(); int m = getRealID(spe); for (int p=0;p<nParameter;p++){ int k = m + (p+1) * speciesNumber - 1; //if (p >= rList.size()){ if (p >= reactionNumber){ int speciesNum = p-rList.size()-thirdBodyReactionList.length; String name = (String)initialSpecies.get(speciesNum); sflux = 0; SensitivityStatus senStatus; if (name.equalsIgnoreCase(spe.getName())){ senStatus = new SensitivityStatus(1, sflux, m, p + 1); y[k] = 1; } else{ senStatus = new SensitivityStatus(0,sflux,m,p+1); y[k]=0; } sensitivityStatus.add(k - p_reactionModel.getSpeciesNumber(), senStatus); p_beginStatus.putSensitivityStatus(k - speciesNumber, senStatus); yprime[k] = sflux; } else{ if (p < rList.size()){ Reaction rxn = (Reaction)rList.get(p); if (rxn.containsAsProduct(spe)) { sflux = 1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } if (rxn.containsAsReactant(spe)) { sflux = -1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } else { sflux = 0; } SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } } } } } else { for (int i = p_reactionModel.getSpeciesNumber(); i < y.length; i++) { SensitivityStatus ss = (SensitivityStatus) p_beginStatus. getSensitivityStatus(i-p_reactionModel.getSpeciesNumber()); double sens = ss.getSensitivity(); double sflux = ss.getSFlux(); int reactionNumber = rList.size(); int speciesNumber = p_reactionModel.getSpeciesNumber(); Iterator species_iter = p_reactionModel.getSpecies(); y[i] = sens; yprime[i] = sflux; } } } //System.out.println("Number of Reacted Species is " + numberOfReactedSpecies); int idid; HashMap speStatus = new HashMap(); LinkedList senStatus = new LinkedList(); double[] tPresent = {tBegin}; int temp = 1; if (nParameter==0) { idid = solveDAE(p_initialization, reactionList, true, thirdBodyReactionList, troeReactionList, nState, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid !=1 && idid != 2 && idid != 3) { System.out.println("The idid from DASPK was "+idid + " at time "+tPresent[0]); throw new DynamicSimulatorException("DASPK: SA off."); } System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, 0); } else { idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, troeReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid != 2 && idid != 3) throw new DynamicSimulatorException("DASPK: SA on."); //speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); senStatus = generateSensitivityStatus(p_reactionModel,y,yprime,nParameter); SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, senStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); sss.setIDTranslator(IDTranslator); sss.setReactionList(rList); return sss; } SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CH4"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO2"), rList, sss, p_temperature); return sss; //#] }
3,241,261
public SystemSnapshot solve(boolean p_initialization, ReactionModel p_reactionModel, boolean p_reactionChanged, SystemSnapshot p_beginStatus, ReactionTime p_beginTime, ReactionTime p_endTime, Temperature p_temperature, Pressure p_pressure, boolean p_conditionChanged) { //#[ operation solve(boolean,ReactionModel,boolean,SystemSnapshot,ReactionTime,ReactionTime,Temperature,Pressure,boolean) ReactionTime rt = p_beginStatus.getTime(); if (!rt.equals(p_beginTime)) throw new InvalidBeginStatusException(); // set time double tBegin = p_beginTime.getStandardTime(); double tEnd = p_endTime.getStandardTime(); // set reaction set //if (p_initialization || p_reactionChanged || p_conditionChanged) { generateTROEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); generateThirdBodyReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); LinkedList rList = generatePDepODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //generateAllODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //p_reactionChanged = true; //} // set numbers //System.out.println("Total number of reactions to Daspk is "+rList.size()); int nState = p_reactionModel.getSpeciesNumber(); int nParameter = 0; LinkedList initialSpecies = new LinkedList();// if (parameterInfor!=null) nParameter = parameterInfor.length; if (parameterInfor != 0) { nParameter = rList.size()+thirdBodyReactionList.length; //svp if (initialStatus == null) System.out.println("initialStatus = null"); Iterator spe_iter = initialStatus.getSpeciesStatus(); while (spe_iter.hasNext()) { SpeciesStatus ss = (SpeciesStatus) spe_iter.next(); String name = ss.getSpecies().getName(); initialSpecies.add(name); nParameter++; } } int neq = nState*(nParameter+1); // set temperature and pressure double T = p_temperature.getK(); double P = p_pressure.getAtm(); // set initial value of y and yprime; double [] y = new double[neq]; double [] yprime = new double[neq]; //double numberOfReactedSpecies=0; // get the present status at t_begin, and set y and y' accordingly System.out.println("Before ODE: " + String.valueOf(tBegin) + "SEC"); System.out.println("End at : " + String.valueOf(tEnd) + "SEC"); for (Iterator iter = p_beginStatus.getSpeciesStatus(); iter.hasNext(); ) { SpeciesStatus ss = (SpeciesStatus)iter.next(); double conc = ss.getConcentration(); double flux = ss.getFlux(); if (ss.isReactedSpecies()) { Species spe = ss.getSpecies(); int id = getRealID(spe); System.out.println(String.valueOf(spe.getID()) + '\t' + spe.getName() + '\t' + String.valueOf(conc) + '\t' + String.valueOf(flux)); y[id-1] = conc; yprime[id-1] = flux; } } if (nParameter != 0){//svp parameterInforArray = new ParameterInfor[nParameter]; for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ parameterInforArray[i-1] = new ParameterInfor("k",i,0.00); } for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ parameterInforArray[i - 1] = new ParameterInfor("CO", nParameter, 0.00); } if (p_beginTime.getTime() == 0 || p_beginTime.getTime() == 0.00) { LinkedList sensitivityStatus = new LinkedList(); int reactionNumber = rList.size()+thirdBodyReactionList.length; int speciesNumber = p_reactionModel.getSpeciesNumber();// for (int i=0;i<reactionNumber*speciesNumber;i++){ for (int i=0; i<nParameter*speciesNumber;i++){ sensitivityStatus.add(i,null); } p_beginStatus.addSensitivity(sensitivityStatus); double sflux = 1; Iterator species_iter = p_reactionModel.getSpecies(); while (species_iter.hasNext()) { Species spe = (Species) species_iter.next(); int m = getRealID(spe); for (int p=0;p<nParameter;p++){ int k = m + (p+1) * speciesNumber - 1; //if (p >= rList.size()){ if (p >= reactionNumber){ int speciesNum = p-rList.size()-thirdBodyReactionList.length; String name = (String)initialSpecies.get(speciesNum); sflux = 0; SensitivityStatus senStatus; if (name.equalsIgnoreCase(spe.getName())){ senStatus = new SensitivityStatus(1, sflux, m, p + 1); y[k] = 1; } else{ senStatus = new SensitivityStatus(0,sflux,m,p+1); y[k]=0; } sensitivityStatus.add(k - p_reactionModel.getSpeciesNumber(), senStatus); p_beginStatus.putSensitivityStatus(k - speciesNumber, senStatus); yprime[k] = sflux; } else{ if (p < rList.size()){ Reaction rxn = (Reaction)rList.get(p); if (rxn.containsAsProduct(spe)) { sflux = 1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } if (rxn.containsAsReactant(spe)) { sflux = -1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } else { sflux = 0; } SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } } } } } else { for (int i = p_reactionModel.getSpeciesNumber(); i < y.length; i++) { SensitivityStatus ss = (SensitivityStatus) p_beginStatus. getSensitivityStatus(i-p_reactionModel.getSpeciesNumber()); double sens = ss.getSensitivity(); double sflux = ss.getSFlux(); int reactionNumber = rList.size(); int speciesNumber = p_reactionModel.getSpeciesNumber(); Iterator species_iter = p_reactionModel.getSpecies(); y[i] = sens; yprime[i] = sflux; } } } //System.out.println("Number of Reacted Species is " + numberOfReactedSpecies); int idid; HashMap speStatus = new HashMap(); LinkedList senStatus = new LinkedList(); double[] tPresent = {tBegin}; int temp = 1; if (nParameter==0) { idid = solveDAE(p_initialization, reactionList, true, thirdBodyReactionList, troeReactionList, nState, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid !=1 && idid != 2 && idid != 3) { System.out.println("The idid from DASPK was "+idid + " at time "+tPresent[0]); throw new DynamicSimulatorException("DASPK: SA off."); } System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, 0); } else { idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid != 2 && idid != 3) throw new DynamicSimulatorException("DASPK: SA on."); //speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); senStatus = generateSensitivityStatus(p_reactionModel,y,yprime,nParameter); SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, senStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); sss.setIDTranslator(IDTranslator); sss.setReactionList(rList); return sss; } SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CH4"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO2"), rList, sss, p_temperature); return sss; //#] }
public SystemSnapshot solve(boolean p_initialization, ReactionModel p_reactionModel, boolean p_reactionChanged, SystemSnapshot p_beginStatus, ReactionTime p_beginTime, ReactionTime p_endTime, Temperature p_temperature, Pressure p_pressure, boolean p_conditionChanged) { //#[ operation solve(boolean,ReactionModel,boolean,SystemSnapshot,ReactionTime,ReactionTime,Temperature,Pressure,boolean) ReactionTime rt = p_beginStatus.getTime(); if (!rt.equals(p_beginTime)) throw new InvalidBeginStatusException(); // set time double tBegin = p_beginTime.getStandardTime(); double tEnd = p_endTime.getStandardTime(); // set reaction set //if (p_initialization || p_reactionChanged || p_conditionChanged) { generateTROEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); generateThirdBodyReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); LinkedList rList = generatePDepODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //generateAllODEReactionList(p_reactionModel, p_beginStatus, p_temperature, p_pressure); //p_reactionChanged = true; //} // set numbers //System.out.println("Total number of reactions to Daspk is "+rList.size()); int nState = p_reactionModel.getSpeciesNumber(); int nParameter = 0; LinkedList initialSpecies = new LinkedList();// if (parameterInfor!=null) nParameter = parameterInfor.length; if (parameterInfor != 0) { nParameter = rList.size()+thirdBodyReactionList.length; //svp if (initialStatus == null) System.out.println("initialStatus = null"); Iterator spe_iter = initialStatus.getSpeciesStatus(); while (spe_iter.hasNext()) { SpeciesStatus ss = (SpeciesStatus) spe_iter.next(); String name = ss.getSpecies().getName(); initialSpecies.add(name); nParameter++; } } int neq = nState*(nParameter+1); // set temperature and pressure double T = p_temperature.getK(); double P = p_pressure.getAtm(); // set initial value of y and yprime; double [] y = new double[neq]; double [] yprime = new double[neq]; //double numberOfReactedSpecies=0; // get the present status at t_begin, and set y and y' accordingly System.out.println("Before ODE: " + String.valueOf(tBegin) + "SEC"); System.out.println("End at : " + String.valueOf(tEnd) + "SEC"); for (Iterator iter = p_beginStatus.getSpeciesStatus(); iter.hasNext(); ) { SpeciesStatus ss = (SpeciesStatus)iter.next(); double conc = ss.getConcentration(); double flux = ss.getFlux(); if (ss.isReactedSpecies()) { Species spe = ss.getSpecies(); int id = getRealID(spe); System.out.println(String.valueOf(spe.getID()) + '\t' + spe.getName() + '\t' + String.valueOf(conc) + '\t' + String.valueOf(flux)); y[id-1] = conc; yprime[id-1] = flux; } } if (nParameter != 0){//svp parameterInforArray = new ParameterInfor[nParameter]; for (int i = 1; i <= rList.size()+thirdBodyReactionList.length; i++){ parameterInforArray[i-1] = new ParameterInfor("k",i,0.00); } for (int i=rList.size()+1+thirdBodyReactionList.length; i<=nParameter;i++){ parameterInforArray[i - 1] = new ParameterInfor("CO", nParameter, 0.00); } if (p_beginTime.getTime() == 0 || p_beginTime.getTime() == 0.00) { LinkedList sensitivityStatus = new LinkedList(); int reactionNumber = rList.size()+thirdBodyReactionList.length; int speciesNumber = p_reactionModel.getSpeciesNumber();// for (int i=0;i<reactionNumber*speciesNumber;i++){ for (int i=0; i<nParameter*speciesNumber;i++){ sensitivityStatus.add(i,null); } p_beginStatus.addSensitivity(sensitivityStatus); double sflux = 1; Iterator species_iter = p_reactionModel.getSpecies(); while (species_iter.hasNext()) { Species spe = (Species) species_iter.next(); int m = getRealID(spe); for (int p=0;p<nParameter;p++){ int k = m + (p+1) * speciesNumber - 1; //if (p >= rList.size()){ if (p >= reactionNumber){ int speciesNum = p-rList.size()-thirdBodyReactionList.length; String name = (String)initialSpecies.get(speciesNum); sflux = 0; SensitivityStatus senStatus; if (name.equalsIgnoreCase(spe.getName())){ senStatus = new SensitivityStatus(1, sflux, m, p + 1); y[k] = 1; } else{ senStatus = new SensitivityStatus(0,sflux,m,p+1); y[k]=0; } sensitivityStatus.add(k - p_reactionModel.getSpeciesNumber(), senStatus); p_beginStatus.putSensitivityStatus(k - speciesNumber, senStatus); yprime[k] = sflux; } else{ if (p < rList.size()){ Reaction rxn = (Reaction)rList.get(p); if (rxn.containsAsProduct(spe)) { sflux = 1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } if (rxn.containsAsReactant(spe)) { sflux = -1; Iterator new_iter = rxn.getReactants(); while (new_iter.hasNext()) { ChemGraph cg = (ChemGraph) new_iter.next(); Species reactant = cg.getSpecies(); SpeciesStatus ss = p_beginStatus.getSpeciesStatus(reactant); if (ss != null) { sflux *= ss.getConcentration(); } else { sflux = 0; } } } else { sflux = 0; } SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } else { sflux = 0; SensitivityStatus senStatus = new SensitivityStatus(0, sflux, m, p+1); sensitivityStatus.add(k-p_reactionModel.getSpeciesNumber(),senStatus); p_beginStatus.putSensitivityStatus(k-speciesNumber,senStatus); y[k] = 0; yprime[k] = sflux; } } } } } else { for (int i = p_reactionModel.getSpeciesNumber(); i < y.length; i++) { SensitivityStatus ss = (SensitivityStatus) p_beginStatus. getSensitivityStatus(i-p_reactionModel.getSpeciesNumber()); double sens = ss.getSensitivity(); double sflux = ss.getSFlux(); int reactionNumber = rList.size(); int speciesNumber = p_reactionModel.getSpeciesNumber(); Iterator species_iter = p_reactionModel.getSpecies(); y[i] = sens; yprime[i] = sflux; } } } //System.out.println("Number of Reacted Species is " + numberOfReactedSpecies); int idid; HashMap speStatus = new HashMap(); LinkedList senStatus = new LinkedList(); double[] tPresent = {tBegin}; int temp = 1; if (nParameter==0) { idid = solveDAE(p_initialization, reactionList, true, thirdBodyReactionList, troeReactionList, nState, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid !=1 && idid != 2 && idid != 3) { System.out.println("The idid from DASPK was "+idid + " at time "+tPresent[0]); throw new DynamicSimulatorException("DASPK: SA off."); } System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, 0); } else { idid = solveSEN(p_initialization, reactionList, p_reactionChanged, thirdBodyReactionList, nState, nParameter, this.parameterInforArray, y, yprime, tBegin, tEnd, this.rtol, this.atol, T, P); if (idid != 2 && idid != 3) throw new DynamicSimulatorException("DASPK: SA on."); //speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); System.out.println("After ODE: from " + String.valueOf(tBegin) + " SEC to " + String.valueOf(tEnd) + "SEC"); speStatus = generateSpeciesStatus(p_reactionModel, y, yprime, nParameter); senStatus = generateSensitivityStatus(p_reactionModel,y,yprime,nParameter); SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, senStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); sss.setIDTranslator(IDTranslator); LinkedList reactionList = new LinkedList(); reactionList.addAll(rList); reactionList.addAll(thirdBody); reactionList.addAll(troe); sss.setReactionList(reactionList); return sss; } SystemSnapshot sss = new SystemSnapshot(p_endTime, speStatus, p_beginStatus.getTemperature(), p_beginStatus.getPressure()); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CH4"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO"), rList, sss, p_temperature); //ReactionSystem.outputAllPathways(SpeciesDictionary.getSpeciesFromName("CO2"), rList, sss, p_temperature); return sss; //#] }
3,241,262
public ODEReaction transferReaction(Reaction p_reaction, SystemSnapshot p_beginStatus, Temperature p_temperature, Pressure p_pressure) { //#[ operation transferReaction(Reaction,SystemSnapshot,Temperature,Pressure) double dT = 1; Temperature Tup = new Temperature(p_temperature.getStandard()+dT, Temperature.getStandardUnit()); Temperature Tlow = new Temperature(p_temperature.getStandard()-dT, Temperature.getStandardUnit()); int rnum = p_reaction.getReactantNumber(); int pnum = p_reaction.getProductNumber(); int [] rid = new int[rnum]; int index = 0; for (Iterator r_iter = p_reaction.getReactants(); r_iter.hasNext(); ) { Species s = ((ChemGraph)r_iter.next()).getSpecies(); rid[index] = getRealID(s); index++; } int [] pid = new int[pnum]; index = 0; for (Iterator p_iter = p_reaction.getProducts(); p_iter.hasNext(); ) { Species s = ((ChemGraph)p_iter.next()).getSpecies(); pid[index] = getRealID(s); index++; } //ODEReaction or; if(p_reaction instanceof PDepNetReaction) { double rate = ((PDepNetReaction)p_reaction).getRate(); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } else { double rate = 0; if (p_reaction instanceof TemplateReaction) { rate = ((TemplateReaction)p_reaction).calculatePDepRate(p_temperature); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } else if (p_reaction instanceof TROEReaction){//svp HashMap weightMap = ((ThirdBodyReaction)p_reaction).getWeightMap(); int weightMapSize = weightMap.size(); int [] colliders = new int[weightMapSize]; double [] efficiency = new double[weightMapSize]; Iterator colliderIter = weightMap.keySet().iterator(); int numCollider =0; for (int i=0; i<weightMapSize; i++){ String name = (String)colliderIter.next(); Species spe = SpeciesDictionary.getInstance().getSpeciesFromName(name); if (spe != null){ colliders[numCollider] = getRealID(spe); efficiency[numCollider] = ((Double)weightMap.get(name)).doubleValue(); numCollider++; } } double T2star, T3star, Tstar, a; T2star = ((TROEReaction)p_reaction).getT2star(); T3star = ((TROEReaction)p_reaction).getT3star(); Tstar = ((TROEReaction)p_reaction).getTstar(); a = ((TROEReaction)p_reaction).getA(); int direction = p_reaction.getDirection(); double Keq = p_reaction.calculateKeq(p_temperature); double lowRate = ((TROEReaction)p_reaction).getLow().calculateRate(p_temperature, -1); double highRate = ((TROEReaction)p_reaction).getKinetics().calculateRate(p_temperature, -1); double inertColliderEfficiency = ((ThirdBodyReaction)p_reaction).calculateThirdBodyCoefficientForInerts(p_beginStatus); boolean troe7 = ((TROEReaction)p_reaction).getTroe7(); TROEODEReaction or = new TROEODEReaction(rnum, pnum, rid, pid, direction, Keq, colliders, efficiency, numCollider, inertColliderEfficiency, T2star, T3star, Tstar, a, highRate, lowRate, troe7); return or; } else if (p_reaction instanceof ThirdBodyReaction){//svp HashMap weightMap = ((ThirdBodyReaction)p_reaction).getWeightMap(); int weightMapSize = weightMap.size(); int [] colliders = new int[weightMapSize]; double [] efficiency = new double[weightMapSize]; Iterator colliderIter = weightMap.keySet().iterator(); int numCollider =0; for (int i=0; i<weightMapSize; i++){ String name = (String)colliderIter.next(); Species spe = SpeciesDictionary.getInstance().getSpeciesFromName(name); if (spe != null){ colliders[numCollider] = getRealID(spe); efficiency[numCollider] = ((Double)weightMap.get(name)).doubleValue(); numCollider++; } } rate = p_reaction.calculateRate(p_temperature); double inertColliderEfficiency = ((ThirdBodyReaction)p_reaction).calculateThirdBodyCoefficientForInerts(p_beginStatus); ThirdBodyODEReaction or = new ThirdBodyODEReaction(rnum, pnum, rid, pid, rate, colliders, efficiency,numCollider, inertColliderEfficiency); return or; } else{ rate = p_reaction.calculateRate(p_temperature); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } } //#] }
public ODEReaction transferReaction(Reaction p_reaction, SystemSnapshot p_beginStatus, Temperature p_temperature, Pressure p_pressure) { //#[ operation transferReaction(Reaction,SystemSnapshot,Temperature,Pressure) double dT = 1; Temperature Tup = new Temperature(p_temperature.getStandard()+dT, Temperature.getStandardUnit()); Temperature Tlow = new Temperature(p_temperature.getStandard()-dT, Temperature.getStandardUnit()); int rnum = p_reaction.getReactantNumber(); int pnum = p_reaction.getProductNumber(); int [] rid = new int[rnum]; int index = 0; for (Iterator r_iter = p_reaction.getReactants(); r_iter.hasNext(); ) { Species s = ((ChemGraph)r_iter.next()).getSpecies(); rid[index] = getRealID(s); index++; } int [] pid = new int[pnum]; index = 0; for (Iterator p_iter = p_reaction.getProducts(); p_iter.hasNext(); ) { Species s = ((ChemGraph)p_iter.next()).getSpecies(); pid[index] = getRealID(s); index++; } //ODEReaction or; if(p_reaction instanceof PDepNetReaction) { double rate = ((PDepNetReaction)p_reaction).getRate(); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } else { double rate = 0; if (p_reaction instanceof TemplateReaction) { rate = ((TemplateReaction)p_reaction).calculatePDepRate(p_temperature); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } else if (p_reaction instanceof TROEReaction){//svp HashMap weightMap = ((ThirdBodyReaction)p_reaction).getWeightMap(); int weightMapSize = weightMap.size(); int [] colliders = new int[weightMapSize]; double [] efficiency = new double[weightMapSize]; Iterator colliderIter = weightMap.keySet().iterator(); int numCollider =0; for (int i=0; i<weightMapSize; i++){ String name = (String)colliderIter.next(); Species spe = SpeciesDictionary.getInstance().getSpeciesFromName(name); if (spe != null){ colliders[numCollider] = getRealID(spe); efficiency[numCollider] = ((Double)weightMap.get(name)).doubleValue(); numCollider++; } } double T2star, T3star, Tstar, a; T2star = ((TROEReaction)p_reaction).getT2star(); T3star = ((TROEReaction)p_reaction).getT3star(); Tstar = ((TROEReaction)p_reaction).getTstar(); a = ((TROEReaction)p_reaction).getA(); int direction = p_reaction.getDirection(); double Keq = p_reaction.calculateKeq(p_temperature); double lowRate = ((TROEReaction)p_reaction).getLow().calculateRate(p_temperature, -1); double highRate = ((TROEReaction)p_reaction).getKinetics().calculateRate(p_temperature, -1); double inertColliderEfficiency = ((ThirdBodyReaction)p_reaction).calculateThirdBodyCoefficientForInerts(p_beginStatus); boolean troe7 = ((TROEReaction)p_reaction).getTroe7(); TROEODEReaction or = new TROEODEReaction(rnum, pnum, rid, pid, direction, Keq, colliders, efficiency, numCollider, inertColliderEfficiency, T2star, T3star, Tstar, a, highRate, lowRate, troe7); return or; } else if (p_reaction instanceof ThirdBodyReaction){//svp HashMap weightMap = ((ThirdBodyReaction)p_reaction).getWeightMap(); int weightMapSize = weightMap.size(); int [] colliders = new int[weightMapSize]; double [] efficiency = new double[weightMapSize]; Iterator colliderIter = weightMap.keySet().iterator(); int numCollider =0; for (int i=0; i<weightMapSize; i++){ String name = (String)colliderIter.next(); Species spe = SpeciesDictionary.getInstance().getSpeciesFromName(name); if (spe != null){ colliders[numCollider] = getRealID(spe); efficiency[numCollider] = ((Double)weightMap.get(name)).doubleValue(); numCollider++; } } rate = p_reaction.calculateRate(p_temperature); double inertColliderEfficiency = ((ThirdBodyReaction)p_reaction).calculateThirdBodyCoefficientForInerts(p_beginStatus); ThirdBodyODEReaction or = new ThirdBodyODEReaction(rnum, pnum, rid, pid, rate, colliders, efficiency,numCollider, inertColliderEfficiency); return or; } else{ rate = p_reaction.calculateRate(p_temperature); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } } //#] }
3,241,263
public ODEReaction transferReaction(Reaction p_reaction, SystemSnapshot p_beginStatus, Temperature p_temperature, Pressure p_pressure) { //#[ operation transferReaction(Reaction,SystemSnapshot,Temperature,Pressure) double dT = 1; Temperature Tup = new Temperature(p_temperature.getStandard()+dT, Temperature.getStandardUnit()); Temperature Tlow = new Temperature(p_temperature.getStandard()-dT, Temperature.getStandardUnit()); int rnum = p_reaction.getReactantNumber(); int pnum = p_reaction.getProductNumber(); int [] rid = new int[rnum]; int index = 0; for (Iterator r_iter = p_reaction.getReactants(); r_iter.hasNext(); ) { Species s = ((ChemGraph)r_iter.next()).getSpecies(); rid[index] = getRealID(s); index++; } int [] pid = new int[pnum]; index = 0; for (Iterator p_iter = p_reaction.getProducts(); p_iter.hasNext(); ) { Species s = ((ChemGraph)p_iter.next()).getSpecies(); pid[index] = getRealID(s); index++; } //ODEReaction or; if(p_reaction instanceof PDepNetReaction) { double rate = ((PDepNetReaction)p_reaction).getRate(); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } else { double rate = 0; if (p_reaction instanceof TemplateReaction) { rate = ((TemplateReaction)p_reaction).calculatePDepRate(p_temperature); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } else if (p_reaction instanceof TROEReaction){//svp HashMap weightMap = ((ThirdBodyReaction)p_reaction).getWeightMap(); int weightMapSize = weightMap.size(); int [] colliders = new int[weightMapSize]; double [] efficiency = new double[weightMapSize]; Iterator colliderIter = weightMap.keySet().iterator(); int numCollider =0; for (int i=0; i<weightMapSize; i++){ String name = (String)colliderIter.next(); Species spe = SpeciesDictionary.getInstance().getSpeciesFromName(name); if (spe != null){ colliders[numCollider] = getRealID(spe); efficiency[numCollider] = ((Double)weightMap.get(name)).doubleValue(); numCollider++; } } double T2star, T3star, Tstar, a; T2star = ((TROEReaction)p_reaction).getT2star(); T3star = ((TROEReaction)p_reaction).getT3star(); Tstar = ((TROEReaction)p_reaction).getTstar(); a = ((TROEReaction)p_reaction).getA(); int direction = p_reaction.getDirection(); double Keq = p_reaction.calculateKeq(p_temperature); double lowRate = ((TROEReaction)p_reaction).getLow().calculateRate(p_temperature, -1); double highRate = ((TROEReaction)p_reaction).getKinetics().calculateRate(p_temperature, -1); double inertColliderEfficiency = ((ThirdBodyReaction)p_reaction).calculateThirdBodyCoefficientForInerts(p_beginStatus); boolean troe7 = ((TROEReaction)p_reaction).getTroe7(); TROEODEReaction or = new TROEODEReaction(rnum, pnum, rid, pid, direction, Keq, colliders, efficiency, numCollider, inertColliderEfficiency, T2star, T3star, Tstar, a, highRate, lowRate, troe7); return or; } else if (p_reaction instanceof ThirdBodyReaction){//svp HashMap weightMap = ((ThirdBodyReaction)p_reaction).getWeightMap(); int weightMapSize = weightMap.size(); int [] colliders = new int[weightMapSize]; double [] efficiency = new double[weightMapSize]; Iterator colliderIter = weightMap.keySet().iterator(); int numCollider =0; for (int i=0; i<weightMapSize; i++){ String name = (String)colliderIter.next(); Species spe = SpeciesDictionary.getInstance().getSpeciesFromName(name); if (spe != null){ colliders[numCollider] = getRealID(spe); efficiency[numCollider] = ((Double)weightMap.get(name)).doubleValue(); numCollider++; } } rate = p_reaction.calculateRate(p_temperature); double inertColliderEfficiency = ((ThirdBodyReaction)p_reaction).calculateThirdBodyCoefficientForInerts(p_beginStatus); ThirdBodyODEReaction or = new ThirdBodyODEReaction(rnum, pnum, rid, pid, rate, colliders, efficiency,numCollider, inertColliderEfficiency); return or; } else{ rate = p_reaction.calculateRate(p_temperature); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } } //#] }
public ODEReaction transferReaction(Reaction p_reaction, SystemSnapshot p_beginStatus, Temperature p_temperature, Pressure p_pressure) { //#[ operation transferReaction(Reaction,SystemSnapshot,Temperature,Pressure) double dT = 1; Temperature Tup = new Temperature(p_temperature.getStandard()+dT, Temperature.getStandardUnit()); Temperature Tlow = new Temperature(p_temperature.getStandard()-dT, Temperature.getStandardUnit()); int rnum = p_reaction.getReactantNumber(); int pnum = p_reaction.getProductNumber(); int [] rid = new int[rnum]; int index = 0; for (Iterator r_iter = p_reaction.getReactants(); r_iter.hasNext(); ) { Species s = ((ChemGraph)r_iter.next()).getSpecies(); rid[index] = getRealID(s); index++; } int [] pid = new int[pnum]; index = 0; for (Iterator p_iter = p_reaction.getProducts(); p_iter.hasNext(); ) { Species s = ((ChemGraph)p_iter.next()).getSpecies(); pid[index] = getRealID(s); index++; } //ODEReaction or; if(p_reaction instanceof PDepNetReaction) { double rate = ((PDepNetReaction)p_reaction).getRate(); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } else { double rate = 0; if (p_reaction instanceof TemplateReaction) { rate = ((TemplateReaction)p_reaction).calculatePDepRate(p_temperature); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } else if (p_reaction instanceof TROEReaction){//svp HashMap weightMap = ((ThirdBodyReaction)p_reaction).getWeightMap(); int weightMapSize = weightMap.size(); int [] colliders = new int[weightMapSize]; double [] efficiency = new double[weightMapSize]; Iterator colliderIter = weightMap.keySet().iterator(); int numCollider =0; for (int i=0; i<weightMapSize; i++){ String name = (String)colliderIter.next(); Species spe = SpeciesDictionary.getInstance().getSpeciesFromName(name); if (spe != null){ colliders[numCollider] = getRealID(spe); efficiency[numCollider] = ((Double)weightMap.get(name)).doubleValue(); numCollider++; } } double T2star, T3star, Tstar, a; T2star = ((TROEReaction)p_reaction).getT2star(); T3star = ((TROEReaction)p_reaction).getT3star(); Tstar = ((TROEReaction)p_reaction).getTstar(); a = ((TROEReaction)p_reaction).getA(); int direction = p_reaction.getDirection(); double Keq = p_reaction.calculateKeq(p_temperature); double lowRate = ((TROEReaction)p_reaction).getLow().calculateRate(p_temperature, -1); double highRate = ((TROEReaction)p_reaction).getKinetics().calculateRate(p_temperature, -1); double inertColliderEfficiency = ((ThirdBodyReaction)p_reaction).calculateThirdBodyCoefficientForInerts(p_beginStatus); boolean troe7 = ((TROEReaction)p_reaction).getTroe7(); TROEODEReaction or = new TROEODEReaction(rnum, pnum, rid, pid, direction, Keq, colliders, efficiency, numCollider, inertColliderEfficiency, T2star, T3star, Tstar, a, highRate, lowRate, troe7); return or; } else if (p_reaction instanceof ThirdBodyReaction){//svp HashMap weightMap = ((ThirdBodyReaction)p_reaction).getWeightMap(); int weightMapSize = weightMap.size(); int [] colliders = new int[weightMapSize]; double [] efficiency = new double[weightMapSize]; Iterator colliderIter = weightMap.keySet().iterator(); int numCollider =0; for (int i=0; i<weightMapSize; i++){ String name = (String)colliderIter.next(); Species spe = SpeciesDictionary.getInstance().getSpeciesFromName(name); if (spe != null){ colliders[numCollider] = getRealID(spe); efficiency[numCollider] = ((Double)weightMap.get(name)).doubleValue(); numCollider++; } } rate = p_reaction.calculateRate(p_temperature); double inertColliderEfficiency = ((ThirdBodyReaction)p_reaction).calculateThirdBodyCoefficientForInerts(p_beginStatus); ThirdBodyODEReaction or = new ThirdBodyODEReaction(rnum, pnum, rid, pid, rate, colliders, efficiency,numCollider, inertColliderEfficiency); return or; } else{ rate = p_reaction.calculateRate(p_temperature); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } } //#] }
3,241,264
public ODEReaction transferReaction(Reaction p_reaction, SystemSnapshot p_beginStatus, Temperature p_temperature, Pressure p_pressure) { //#[ operation transferReaction(Reaction,SystemSnapshot,Temperature,Pressure) double dT = 1; Temperature Tup = new Temperature(p_temperature.getStandard()+dT, Temperature.getStandardUnit()); Temperature Tlow = new Temperature(p_temperature.getStandard()-dT, Temperature.getStandardUnit()); int rnum = p_reaction.getReactantNumber(); int pnum = p_reaction.getProductNumber(); int [] rid = new int[rnum]; int index = 0; for (Iterator r_iter = p_reaction.getReactants(); r_iter.hasNext(); ) { Species s = ((ChemGraph)r_iter.next()).getSpecies(); rid[index] = getRealID(s); index++; } int [] pid = new int[pnum]; index = 0; for (Iterator p_iter = p_reaction.getProducts(); p_iter.hasNext(); ) { Species s = ((ChemGraph)p_iter.next()).getSpecies(); pid[index] = getRealID(s); index++; } //ODEReaction or; if(p_reaction instanceof PDepNetReaction) { double rate = ((PDepNetReaction)p_reaction).getRate(); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } else { double rate = 0; if (p_reaction instanceof TemplateReaction) { rate = ((TemplateReaction)p_reaction).calculatePDepRate(p_temperature); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } else if (p_reaction instanceof TROEReaction){//svp HashMap weightMap = ((ThirdBodyReaction)p_reaction).getWeightMap(); int weightMapSize = weightMap.size(); int [] colliders = new int[weightMapSize]; double [] efficiency = new double[weightMapSize]; Iterator colliderIter = weightMap.keySet().iterator(); int numCollider =0; for (int i=0; i<weightMapSize; i++){ String name = (String)colliderIter.next(); Species spe = SpeciesDictionary.getInstance().getSpeciesFromName(name); if (spe != null){ colliders[numCollider] = getRealID(spe); efficiency[numCollider] = ((Double)weightMap.get(name)).doubleValue(); numCollider++; } } double T2star, T3star, Tstar, a; T2star = ((TROEReaction)p_reaction).getT2star(); T3star = ((TROEReaction)p_reaction).getT3star(); Tstar = ((TROEReaction)p_reaction).getTstar(); a = ((TROEReaction)p_reaction).getA(); int direction = p_reaction.getDirection(); double Keq = p_reaction.calculateKeq(p_temperature); double lowRate = ((TROEReaction)p_reaction).getLow().calculateRate(p_temperature, -1); double highRate = ((TROEReaction)p_reaction).getKinetics().calculateRate(p_temperature, -1); double inertColliderEfficiency = ((ThirdBodyReaction)p_reaction).calculateThirdBodyCoefficientForInerts(p_beginStatus); boolean troe7 = ((TROEReaction)p_reaction).getTroe7(); TROEODEReaction or = new TROEODEReaction(rnum, pnum, rid, pid, direction, Keq, colliders, efficiency, numCollider, inertColliderEfficiency, T2star, T3star, Tstar, a, highRate, lowRate, troe7); return or; } else if (p_reaction instanceof ThirdBodyReaction){//svp HashMap weightMap = ((ThirdBodyReaction)p_reaction).getWeightMap(); int weightMapSize = weightMap.size(); int [] colliders = new int[weightMapSize]; double [] efficiency = new double[weightMapSize]; Iterator colliderIter = weightMap.keySet().iterator(); int numCollider =0; for (int i=0; i<weightMapSize; i++){ String name = (String)colliderIter.next(); Species spe = SpeciesDictionary.getInstance().getSpeciesFromName(name); if (spe != null){ colliders[numCollider] = getRealID(spe); efficiency[numCollider] = ((Double)weightMap.get(name)).doubleValue(); numCollider++; } } rate = p_reaction.calculateRate(p_temperature); double inertColliderEfficiency = ((ThirdBodyReaction)p_reaction).calculateThirdBodyCoefficientForInerts(p_beginStatus); ThirdBodyODEReaction or = new ThirdBodyODEReaction(rnum, pnum, rid, pid, rate, colliders, efficiency,numCollider, inertColliderEfficiency); return or; } else{ rate = p_reaction.calculateRate(p_temperature); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } } //#] }
public ODEReaction transferReaction(Reaction p_reaction, SystemSnapshot p_beginStatus, Temperature p_temperature, Pressure p_pressure) { //#[ operation transferReaction(Reaction,SystemSnapshot,Temperature,Pressure) double dT = 1; Temperature Tup = new Temperature(p_temperature.getStandard()+dT, Temperature.getStandardUnit()); Temperature Tlow = new Temperature(p_temperature.getStandard()-dT, Temperature.getStandardUnit()); int rnum = p_reaction.getReactantNumber(); int pnum = p_reaction.getProductNumber(); int [] rid = new int[rnum]; int index = 0; for (Iterator r_iter = p_reaction.getReactants(); r_iter.hasNext(); ) { Species s = ((ChemGraph)r_iter.next()).getSpecies(); rid[index] = getRealID(s); index++; } int [] pid = new int[pnum]; index = 0; for (Iterator p_iter = p_reaction.getProducts(); p_iter.hasNext(); ) { Species s = ((ChemGraph)p_iter.next()).getSpecies(); pid[index] = getRealID(s); index++; } //ODEReaction or; if(p_reaction instanceof PDepNetReaction) { double rate = ((PDepNetReaction)p_reaction).getRate(); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } else { double rate = 0; if (p_reaction instanceof TemplateReaction) { rate = ((TemplateReaction)p_reaction).calculatePDepRate(p_temperature); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } else if (p_reaction instanceof TROEReaction){//svp HashMap weightMap = ((ThirdBodyReaction)p_reaction).getWeightMap(); int weightMapSize = weightMap.size(); int [] colliders = new int[weightMapSize]; double [] efficiency = new double[weightMapSize]; Iterator colliderIter = weightMap.keySet().iterator(); int numCollider =0; for (int i=0; i<weightMapSize; i++){ String name = (String)colliderIter.next(); Species spe = SpeciesDictionary.getInstance().getSpeciesFromName(name); if (spe != null){ colliders[numCollider] = getRealID(spe); efficiency[numCollider] = ((Double)weightMap.get(name)).doubleValue(); numCollider++; } } double T2star, T3star, Tstar, a; T2star = ((TROEReaction)p_reaction).getT2star(); T3star = ((TROEReaction)p_reaction).getT3star(); Tstar = ((TROEReaction)p_reaction).getTstar(); a = ((TROEReaction)p_reaction).getA(); int direction = p_reaction.getDirection(); double Keq = p_reaction.calculateKeq(p_temperature); double lowRate = ((TROEReaction)p_reaction).getLow().calculateRate(p_temperature, -1); double highRate = ((TROEReaction)p_reaction).getKinetics().calculateRate(p_temperature, -1); double inertColliderEfficiency = ((ThirdBodyReaction)p_reaction).calculateThirdBodyCoefficientForInerts(p_beginStatus); boolean troe7 = ((TROEReaction)p_reaction).getTroe7(); TROEODEReaction or = new TROEODEReaction(rnum, pnum, rid, pid, direction, Keq, colliders, efficiency, numCollider, inertColliderEfficiency, T2star, T3star, Tstar, a, highRate, lowRate, troe7); return or; } else if (p_reaction instanceof ThirdBodyReaction){//svp HashMap weightMap = ((ThirdBodyReaction)p_reaction).getWeightMap(); int weightMapSize = weightMap.size(); int [] colliders = new int[weightMapSize]; double [] efficiency = new double[weightMapSize]; Iterator colliderIter = weightMap.keySet().iterator(); int numCollider =0; for (int i=0; i<weightMapSize; i++){ String name = (String)colliderIter.next(); Species spe = SpeciesDictionary.getInstance().getSpeciesFromName(name); if (spe != null){ colliders[numCollider] = getRealID(spe); efficiency[numCollider] = ((Double)weightMap.get(name)).doubleValue(); numCollider++; } } rate = p_reaction.calculateRate(p_temperature); double inertColliderEfficiency = ((ThirdBodyReaction)p_reaction).calculateThirdBodyCoefficientForInerts(p_beginStatus); ThirdBodyODEReaction or = new ThirdBodyODEReaction(rnum, pnum, rid, pid, rate, colliders, efficiency,numCollider, inertColliderEfficiency); return or; } else{ rate = p_reaction.calculateRate(p_temperature); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } } //#] }
3,241,265
public ODEReaction transferReaction(Reaction p_reaction, SystemSnapshot p_beginStatus, Temperature p_temperature, Pressure p_pressure) { //#[ operation transferReaction(Reaction,SystemSnapshot,Temperature,Pressure) double dT = 1; Temperature Tup = new Temperature(p_temperature.getStandard()+dT, Temperature.getStandardUnit()); Temperature Tlow = new Temperature(p_temperature.getStandard()-dT, Temperature.getStandardUnit()); int rnum = p_reaction.getReactantNumber(); int pnum = p_reaction.getProductNumber(); int [] rid = new int[rnum]; int index = 0; for (Iterator r_iter = p_reaction.getReactants(); r_iter.hasNext(); ) { Species s = ((ChemGraph)r_iter.next()).getSpecies(); rid[index] = getRealID(s); index++; } int [] pid = new int[pnum]; index = 0; for (Iterator p_iter = p_reaction.getProducts(); p_iter.hasNext(); ) { Species s = ((ChemGraph)p_iter.next()).getSpecies(); pid[index] = getRealID(s); index++; } //ODEReaction or; if(p_reaction instanceof PDepNetReaction) { double rate = ((PDepNetReaction)p_reaction).getRate(); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } else { double rate = 0; if (p_reaction instanceof TemplateReaction) { rate = ((TemplateReaction)p_reaction).calculatePDepRate(p_temperature); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } else if (p_reaction instanceof TROEReaction){//svp HashMap weightMap = ((ThirdBodyReaction)p_reaction).getWeightMap(); int weightMapSize = weightMap.size(); int [] colliders = new int[weightMapSize]; double [] efficiency = new double[weightMapSize]; Iterator colliderIter = weightMap.keySet().iterator(); int numCollider =0; for (int i=0; i<weightMapSize; i++){ String name = (String)colliderIter.next(); Species spe = SpeciesDictionary.getInstance().getSpeciesFromName(name); if (spe != null){ colliders[numCollider] = getRealID(spe); efficiency[numCollider] = ((Double)weightMap.get(name)).doubleValue(); numCollider++; } } double T2star, T3star, Tstar, a; T2star = ((TROEReaction)p_reaction).getT2star(); T3star = ((TROEReaction)p_reaction).getT3star(); Tstar = ((TROEReaction)p_reaction).getTstar(); a = ((TROEReaction)p_reaction).getA(); int direction = p_reaction.getDirection(); double Keq = p_reaction.calculateKeq(p_temperature); double lowRate = ((TROEReaction)p_reaction).getLow().calculateRate(p_temperature, -1); double highRate = ((TROEReaction)p_reaction).getKinetics().calculateRate(p_temperature, -1); double inertColliderEfficiency = ((ThirdBodyReaction)p_reaction).calculateThirdBodyCoefficientForInerts(p_beginStatus); boolean troe7 = ((TROEReaction)p_reaction).getTroe7(); TROEODEReaction or = new TROEODEReaction(rnum, pnum, rid, pid, direction, Keq, colliders, efficiency, numCollider, inertColliderEfficiency, T2star, T3star, Tstar, a, highRate, lowRate, troe7); return or; } else if (p_reaction instanceof ThirdBodyReaction){//svp HashMap weightMap = ((ThirdBodyReaction)p_reaction).getWeightMap(); int weightMapSize = weightMap.size(); int [] colliders = new int[weightMapSize]; double [] efficiency = new double[weightMapSize]; Iterator colliderIter = weightMap.keySet().iterator(); int numCollider =0; for (int i=0; i<weightMapSize; i++){ String name = (String)colliderIter.next(); Species spe = SpeciesDictionary.getInstance().getSpeciesFromName(name); if (spe != null){ colliders[numCollider] = getRealID(spe); efficiency[numCollider] = ((Double)weightMap.get(name)).doubleValue(); numCollider++; } } rate = p_reaction.calculateRate(p_temperature); double inertColliderEfficiency = ((ThirdBodyReaction)p_reaction).calculateThirdBodyCoefficientForInerts(p_beginStatus); ThirdBodyODEReaction or = new ThirdBodyODEReaction(rnum, pnum, rid, pid, rate, colliders, efficiency,numCollider, inertColliderEfficiency); return or; } else{ rate = p_reaction.calculateRate(p_temperature); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } } //#] }
public ODEReaction transferReaction(Reaction p_reaction, SystemSnapshot p_beginStatus, Temperature p_temperature, Pressure p_pressure) { //#[ operation transferReaction(Reaction,SystemSnapshot,Temperature,Pressure) double dT = 1; Temperature Tup = new Temperature(p_temperature.getStandard()+dT, Temperature.getStandardUnit()); Temperature Tlow = new Temperature(p_temperature.getStandard()-dT, Temperature.getStandardUnit()); int rnum = p_reaction.getReactantNumber(); int pnum = p_reaction.getProductNumber(); int [] rid = new int[rnum]; int index = 0; for (Iterator r_iter = p_reaction.getReactants(); r_iter.hasNext(); ) { Species s = ((ChemGraph)r_iter.next()).getSpecies(); rid[index] = getRealID(s); index++; } int [] pid = new int[pnum]; index = 0; for (Iterator p_iter = p_reaction.getProducts(); p_iter.hasNext(); ) { Species s = ((ChemGraph)p_iter.next()).getSpecies(); pid[index] = getRealID(s); index++; } //ODEReaction or; if(p_reaction instanceof PDepNetReaction) { double rate = ((PDepNetReaction)p_reaction).getRate(); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } else { double rate = 0; if (p_reaction instanceof TemplateReaction) { rate = ((TemplateReaction)p_reaction).calculatePDepRate(p_temperature); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } else if (p_reaction instanceof TROEReaction){//svp HashMap weightMap = ((ThirdBodyReaction)p_reaction).getWeightMap(); int weightMapSize = weightMap.size(); int [] colliders = new int[weightMapSize]; double [] efficiency = new double[weightMapSize]; Iterator colliderIter = weightMap.keySet().iterator(); int numCollider =0; for (int i=0; i<weightMapSize; i++){ String name = (String)colliderIter.next(); Species spe = SpeciesDictionary.getInstance().getSpeciesFromName(name); if (spe != null){ colliders[numCollider] = getRealID(spe); efficiency[numCollider] = ((Double)weightMap.get(name)).doubleValue(); numCollider++; } } double T2star, T3star, Tstar, a; T2star = ((TROEReaction)p_reaction).getT2star(); T3star = ((TROEReaction)p_reaction).getT3star(); Tstar = ((TROEReaction)p_reaction).getTstar(); a = ((TROEReaction)p_reaction).getA(); int direction = p_reaction.getDirection(); double Keq = p_reaction.calculateKeq(p_temperature); double lowRate = ((TROEReaction)p_reaction).getLow().calculateRate(p_temperature, -1); double highRate = ((TROEReaction)p_reaction).getKinetics().calculateRate(p_temperature, -1); double inertColliderEfficiency = ((ThirdBodyReaction)p_reaction).calculateThirdBodyCoefficientForInerts(p_beginStatus); boolean troe7 = ((TROEReaction)p_reaction).getTroe7(); TROEODEReaction or = new TROEODEReaction(rnum, pnum, rid, pid, direction, Keq, colliders, efficiency, numCollider, inertColliderEfficiency, T2star, T3star, Tstar, a, highRate, lowRate, troe7); return or; } else if (p_reaction instanceof ThirdBodyReaction){//svp HashMap weightMap = ((ThirdBodyReaction)p_reaction).getWeightMap(); int weightMapSize = weightMap.size(); int [] colliders = new int[weightMapSize]; double [] efficiency = new double[weightMapSize]; Iterator colliderIter = weightMap.keySet().iterator(); int numCollider =0; for (int i=0; i<weightMapSize; i++){ String name = (String)colliderIter.next(); Species spe = SpeciesDictionary.getInstance().getSpeciesFromName(name); if (spe != null){ colliders[numCollider] = getRealID(spe); efficiency[numCollider] = ((Double)weightMap.get(name)).doubleValue(); numCollider++; } } rate = p_reaction.calculateRate(p_temperature); double inertColliderEfficiency = ((ThirdBodyReaction)p_reaction).calculateThirdBodyCoefficientForInerts(p_beginStatus); ThirdBodyODEReaction or = new ThirdBodyODEReaction(rnum, pnum, rid, pid, rate, colliders, efficiency,numCollider, inertColliderEfficiency); return or; } else{ rate = p_reaction.calculateRate(p_temperature); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } } //#] }
3,241,266
public ODEReaction transferReaction(Reaction p_reaction, SystemSnapshot p_beginStatus, Temperature p_temperature, Pressure p_pressure) { //#[ operation transferReaction(Reaction,SystemSnapshot,Temperature,Pressure) double dT = 1; Temperature Tup = new Temperature(p_temperature.getStandard()+dT, Temperature.getStandardUnit()); Temperature Tlow = new Temperature(p_temperature.getStandard()-dT, Temperature.getStandardUnit()); int rnum = p_reaction.getReactantNumber(); int pnum = p_reaction.getProductNumber(); int [] rid = new int[rnum]; int index = 0; for (Iterator r_iter = p_reaction.getReactants(); r_iter.hasNext(); ) { Species s = ((ChemGraph)r_iter.next()).getSpecies(); rid[index] = getRealID(s); index++; } int [] pid = new int[pnum]; index = 0; for (Iterator p_iter = p_reaction.getProducts(); p_iter.hasNext(); ) { Species s = ((ChemGraph)p_iter.next()).getSpecies(); pid[index] = getRealID(s); index++; } //ODEReaction or; if(p_reaction instanceof PDepNetReaction) { double rate = ((PDepNetReaction)p_reaction).getRate(); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } else { double rate = 0; if (p_reaction instanceof TemplateReaction) { rate = ((TemplateReaction)p_reaction).calculatePDepRate(p_temperature); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } else if (p_reaction instanceof TROEReaction){//svp HashMap weightMap = ((ThirdBodyReaction)p_reaction).getWeightMap(); int weightMapSize = weightMap.size(); int [] colliders = new int[weightMapSize]; double [] efficiency = new double[weightMapSize]; Iterator colliderIter = weightMap.keySet().iterator(); int numCollider =0; for (int i=0; i<weightMapSize; i++){ String name = (String)colliderIter.next(); Species spe = SpeciesDictionary.getInstance().getSpeciesFromName(name); if (spe != null){ colliders[numCollider] = getRealID(spe); efficiency[numCollider] = ((Double)weightMap.get(name)).doubleValue(); numCollider++; } } double T2star, T3star, Tstar, a; T2star = ((TROEReaction)p_reaction).getT2star(); T3star = ((TROEReaction)p_reaction).getT3star(); Tstar = ((TROEReaction)p_reaction).getTstar(); a = ((TROEReaction)p_reaction).getA(); int direction = p_reaction.getDirection(); double Keq = p_reaction.calculateKeq(p_temperature); double lowRate = ((TROEReaction)p_reaction).getLow().calculateRate(p_temperature, -1); double highRate = ((TROEReaction)p_reaction).getKinetics().calculateRate(p_temperature, -1); double inertColliderEfficiency = ((ThirdBodyReaction)p_reaction).calculateThirdBodyCoefficientForInerts(p_beginStatus); boolean troe7 = ((TROEReaction)p_reaction).getTroe7(); TROEODEReaction or = new TROEODEReaction(rnum, pnum, rid, pid, direction, Keq, colliders, efficiency, numCollider, inertColliderEfficiency, T2star, T3star, Tstar, a, highRate, lowRate, troe7); return or; } else if (p_reaction instanceof ThirdBodyReaction){//svp HashMap weightMap = ((ThirdBodyReaction)p_reaction).getWeightMap(); int weightMapSize = weightMap.size(); int [] colliders = new int[weightMapSize]; double [] efficiency = new double[weightMapSize]; Iterator colliderIter = weightMap.keySet().iterator(); int numCollider =0; for (int i=0; i<weightMapSize; i++){ String name = (String)colliderIter.next(); Species spe = SpeciesDictionary.getInstance().getSpeciesFromName(name); if (spe != null){ colliders[numCollider] = getRealID(spe); efficiency[numCollider] = ((Double)weightMap.get(name)).doubleValue(); numCollider++; } } rate = p_reaction.calculateRate(p_temperature); double inertColliderEfficiency = ((ThirdBodyReaction)p_reaction).calculateThirdBodyCoefficientForInerts(p_beginStatus); ThirdBodyODEReaction or = new ThirdBodyODEReaction(rnum, pnum, rid, pid, rate, colliders, efficiency,numCollider, inertColliderEfficiency); return or; } else{ rate = p_reaction.calculateRate(p_temperature); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } } //#] }
public ODEReaction transferReaction(Reaction p_reaction, SystemSnapshot p_beginStatus, Temperature p_temperature, Pressure p_pressure) { //#[ operation transferReaction(Reaction,SystemSnapshot,Temperature,Pressure) double dT = 1; Temperature Tup = new Temperature(p_temperature.getStandard()+dT, Temperature.getStandardUnit()); Temperature Tlow = new Temperature(p_temperature.getStandard()-dT, Temperature.getStandardUnit()); int rnum = p_reaction.getReactantNumber(); int pnum = p_reaction.getProductNumber(); int [] rid = new int[rnum]; int index = 0; for (Iterator r_iter = p_reaction.getReactants(); r_iter.hasNext(); ) { Species s = ((ChemGraph)r_iter.next()).getSpecies(); rid[index] = getRealID(s); index++; } int [] pid = new int[pnum]; index = 0; for (Iterator p_iter = p_reaction.getProducts(); p_iter.hasNext(); ) { Species s = ((ChemGraph)p_iter.next()).getSpecies(); pid[index] = getRealID(s); index++; } //ODEReaction or; if(p_reaction instanceof PDepNetReaction) { double rate = ((PDepNetReaction)p_reaction).getRate(); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } else { double rate = 0; if (p_reaction instanceof TemplateReaction) { rate = ((TemplateReaction)p_reaction).calculatePDepRate(p_temperature); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } else if (p_reaction instanceof TROEReaction){//svp HashMap weightMap = ((ThirdBodyReaction)p_reaction).getWeightMap(); int weightMapSize = weightMap.size(); int [] colliders = new int[weightMapSize]; double [] efficiency = new double[weightMapSize]; Iterator colliderIter = weightMap.keySet().iterator(); int numCollider =0; for (int i=0; i<weightMapSize; i++){ String name = (String)colliderIter.next(); Species spe = SpeciesDictionary.getInstance().getSpeciesFromName(name); if (spe != null){ colliders[numCollider] = getRealID(spe); efficiency[numCollider] = ((Double)weightMap.get(name)).doubleValue(); numCollider++; } } double T2star, T3star, Tstar, a; T2star = ((TROEReaction)p_reaction).getT2star(); T3star = ((TROEReaction)p_reaction).getT3star(); Tstar = ((TROEReaction)p_reaction).getTstar(); a = ((TROEReaction)p_reaction).getA(); int direction = p_reaction.getDirection(); double Keq = p_reaction.calculateKeq(p_temperature); double lowRate = ((TROEReaction)p_reaction).getLow().calculateRate(p_temperature, -1); double highRate = ((TROEReaction)p_reaction).getKinetics().calculateRate(p_temperature, -1); double inertColliderEfficiency = ((ThirdBodyReaction)p_reaction).calculateThirdBodyCoefficientForInerts(p_beginStatus); boolean troe7 = ((TROEReaction)p_reaction).getTroe7(); TROEODEReaction or = new TROEODEReaction(rnum, pnum, rid, pid, direction, Keq, colliders, efficiency, numCollider, inertColliderEfficiency, T2star, T3star, Tstar, a, highRate, lowRate, troe7); return or; } else if (p_reaction instanceof ThirdBodyReaction){//svp HashMap weightMap = ((ThirdBodyReaction)p_reaction).getWeightMap(); int weightMapSize = weightMap.size(); int [] colliders = new int[weightMapSize]; double [] efficiency = new double[weightMapSize]; Iterator colliderIter = weightMap.keySet().iterator(); int numCollider =0; for (int i=0; i<weightMapSize; i++){ String name = (String)colliderIter.next(); Species spe = SpeciesDictionary.getInstance().getSpeciesFromName(name); if (spe != null){ colliders[numCollider] = getRealID(spe); efficiency[numCollider] = ((Double)weightMap.get(name)).doubleValue(); numCollider++; } } rate = p_reaction.calculateRate(p_temperature); double inertColliderEfficiency = ((ThirdBodyReaction)p_reaction).calculateThirdBodyCoefficientForInerts(p_beginStatus); ThirdBodyODEReaction or = new ThirdBodyODEReaction(rnum, pnum, rid, pid, rate, colliders, efficiency,numCollider, inertColliderEfficiency); return or; } else{ rate = p_reaction.calculateRate(p_temperature); ODEReaction or = new ODEReaction(rnum, pnum, rid, pid, rate); return or; } } //#] }
3,241,267
public synchronized void addObject() throws Exception { Object obj = _factory.makeObject(); _numActive++; // A little slimy - must do this because returnObject decrements it. this.returnObject(obj); }
public void addObject() throws Exception { Object obj = _factory.makeObject(); _numActive++; // A little slimy - must do this because returnObject decrements it. this.returnObject(obj); }
3,241,268
public synchronized void addObject() throws Exception { Object obj = _factory.makeObject(); _numActive++; // A little slimy - must do this because returnObject decrements it. this.returnObject(obj); }
public synchronized void addObject() throws Exception { Object obj = _factory.makeObject(); _numActive++; // A little slimy - must do this because returnObject decrements it. this.returnObject(obj); }
3,241,269
protected void createNormalLayout() { preLoadImages(); layout = new GridBagLayout(); gbConstraints = new GridBagConstraints(); setLayout(layout); // Create constraint for first component as standard constraint. parent.buildConstraints(gbConstraints, 0, 0, 1, 1, 0.25, 0.0); gbConstraints.insets = new Insets(5, 5, 5, 5); gbConstraints.anchor = GridBagConstraints.WEST; // Create the info label. createLabel("PacksPanel.info", "preferences", layout, gbConstraints); // Create the snap label. parent.buildConstraints(gbConstraints, 1, 0, 1, 1, 0.50, 0.0); createLabel("ImgPacksPanel.snap", "tip", layout, gbConstraints); // Create packs table with a scroller. tableScroller = new JScrollPane(); parent.buildConstraints(gbConstraints, 0, 1, 1, 2, 0.50, 0.0); gbConstraints.fill = GridBagConstraints.BOTH; packsTable = createPacksTable(250, tableScroller, layout, gbConstraints); // Create the image label with a scroller. imgLabel = new JLabel((ImageIcon) images.get(0)); JScrollPane imgScroller = new JScrollPane(imgLabel); imgScroller.setPreferredSize(getPreferredSizeFromImages()); parent.buildConstraints(gbConstraints, 1, 1, 1, 1, 0.5, 1.0); layout.addLayoutComponent(imgScroller, gbConstraints); add(imgScroller); // Create a vertical strut. Component strut = Box.createVerticalStrut(20); parent.buildConstraints(gbConstraints, 1, 2, 1, 3, 0.0, 0.0); layout.addLayoutComponent(strut, gbConstraints); add(strut); // Create the dependency area with a scroller. if (dependenciesExist) { JScrollPane depScroller = new JScrollPane(); depScroller.setPreferredSize(new Dimension(250, 40)); parent.buildConstraints(gbConstraints, 0, 3, 1, 1, 0.50, 0.50); dependencyArea = createTextArea("ImgPacksPanel.dependencyList", depScroller, layout, gbConstraints); } // Create the description area with a scroller. descriptionScroller = new JScrollPane(); descriptionScroller.setPreferredSize(new Dimension(200, 60)); descriptionScroller.setBorder(BorderFactory.createEmptyBorder()); parent.buildConstraints(gbConstraints, 1, 3, 1, 1, 0.50, 0.50); descriptionArea = createTextArea("PacksPanel.description", descriptionScroller, layout, gbConstraints); // Create the tip label. parent.buildConstraints(gbConstraints, 0, 4, 2, 1, 0.0, 0.0); createLabel("PacksPanel.tip", "tip", layout, gbConstraints); // Create the space label. parent.buildConstraints(gbConstraints, 0, 5, 2, 1, 0.0, 0.0); spaceLabel = createPanelWithLabel("PacksPanel.space", layout, gbConstraints); if (IoHelper.supported("getFreeSpace")) { // Create the free space label only if free space is supported. parent.buildConstraints(gbConstraints, 0, 6, 2, 1, 0.0, 0.0); freeSpaceLabel = createPanelWithLabel("PacksPanel.freespace", layout, gbConstraints); } }
protected void createNormalLayout() { preLoadImages(); layout = new GridBagLayout(); gbConstraints = new GridBagConstraints(); setLayout(layout); // Create constraint for first component as standard constraint. parent.buildConstraints(gbConstraints, 0, 0, 1, 1, 0.25, 0.0); gbConstraints.insets = new Insets(5, 5, 5, 5); gbConstraints.anchor = GridBagConstraints.WEST; // Create the info label. createLabel("PacksPanel.info", "preferences", layout, gbConstraints); // Create the snap label. parent.buildConstraints(gbConstraints, 1, 0, 1, 1, 0.50, 0.0); createLabel("ImgPacksPanel.snap", "tip", layout, gbConstraints); // Create packs table with a scroller. tableScroller = new JScrollPane(); parent.buildConstraints(gbConstraints, 0, 1, 1, 2, 0.50, 0.0); gbConstraints.fill = GridBagConstraints.BOTH; packsTable = createPacksTable(250, tableScroller, layout, gbConstraints); // Create the image label with a scroller. imgLabel = new JLabel((ImageIcon) images.get(0)); JScrollPane imgScroller = new JScrollPane(imgLabel); imgScroller.setPreferredSize(getPreferredSizeFromImages()); parent.buildConstraints(gbConstraints, 1, 1, 1, 1, 0.5, 1.0); layout.addLayoutComponent(imgScroller, gbConstraints); add(imgScroller); // Create a vertical strut. Component strut = Box.createVerticalStrut(20); parent.buildConstraints(gbConstraints, 1, 2, 1, 3, 0.0, 0.0); layout.addLayoutComponent(strut, gbConstraints); add(strut); // Create the dependency area with a scroller. if (dependenciesExist) { JScrollPane depScroller = new JScrollPane(); depScroller.setPreferredSize(new Dimension(250, 40)); parent.buildConstraints(gbConstraints, 0, 3, 1, 1, 0.50, 0.50); dependencyArea = createTextArea("ImgPacksPanel.dependencyList", depScroller, layout, gbConstraints); } // Create the description area with a scroller. descriptionScroller = new JScrollPane(); descriptionScroller.setPreferredSize(new Dimension(200, 60)); descriptionScroller.setBorder(BorderFactory.createEmptyBorder()); parent.buildConstraints(gbConstraints, 1, 3, 1, 1, 0.50, 0.50); descriptionArea = createTextArea("PacksPanel.description", descriptionScroller, layout, gbConstraints); // Create the tip label. parent.buildConstraints(gbConstraints, 0, 4, 2, 1, 0.0, 0.0); createLabel("PacksPanel.tip", "tip", layout, gbConstraints); // Create the space label. parent.buildConstraints(gbConstraints, 0, 5, 2, 1, 0.0, 0.0); spaceLabel = createPanelWithLabel("PacksPanel.space", layout, gbConstraints); if (IoHelper.supported("getFreeSpace")) { // Create the free space label only if free space is supported. parent.buildConstraints(gbConstraints, 0, 6, 2, 1, 0.0, 0.0); freeSpaceLabel = createPanelWithLabel("PacksPanel.freespace", layout, gbConstraints); } }
3,241,270
protected void createNormalLayout() { preLoadImages(); layout = new GridBagLayout(); gbConstraints = new GridBagConstraints(); setLayout(layout); // Create constraint for first component as standard constraint. parent.buildConstraints(gbConstraints, 0, 0, 1, 1, 0.25, 0.0); gbConstraints.insets = new Insets(5, 5, 5, 5); gbConstraints.anchor = GridBagConstraints.WEST; // Create the info label. createLabel("PacksPanel.info", "preferences", layout, gbConstraints); // Create the snap label. parent.buildConstraints(gbConstraints, 1, 0, 1, 1, 0.50, 0.0); createLabel("ImgPacksPanel.snap", "tip", layout, gbConstraints); // Create packs table with a scroller. tableScroller = new JScrollPane(); parent.buildConstraints(gbConstraints, 0, 1, 1, 2, 0.50, 0.0); gbConstraints.fill = GridBagConstraints.BOTH; packsTable = createPacksTable(250, tableScroller, layout, gbConstraints); // Create the image label with a scroller. imgLabel = new JLabel((ImageIcon) images.get(0)); JScrollPane imgScroller = new JScrollPane(imgLabel); imgScroller.setPreferredSize(getPreferredSizeFromImages()); parent.buildConstraints(gbConstraints, 1, 1, 1, 1, 0.5, 1.0); layout.addLayoutComponent(imgScroller, gbConstraints); add(imgScroller); // Create a vertical strut. Component strut = Box.createVerticalStrut(20); parent.buildConstraints(gbConstraints, 1, 2, 1, 3, 0.0, 0.0); layout.addLayoutComponent(strut, gbConstraints); add(strut); // Create the dependency area with a scroller. if (dependenciesExist) { JScrollPane depScroller = new JScrollPane(); depScroller.setPreferredSize(new Dimension(250, 40)); parent.buildConstraints(gbConstraints, 0, 3, 1, 1, 0.50, 0.50); dependencyArea = createTextArea("ImgPacksPanel.dependencyList", depScroller, layout, gbConstraints); } // Create the description area with a scroller. descriptionScroller = new JScrollPane(); descriptionScroller.setPreferredSize(new Dimension(200, 60)); descriptionScroller.setBorder(BorderFactory.createEmptyBorder()); parent.buildConstraints(gbConstraints, 1, 3, 1, 1, 0.50, 0.50); descriptionArea = createTextArea("PacksPanel.description", descriptionScroller, layout, gbConstraints); // Create the tip label. parent.buildConstraints(gbConstraints, 0, 4, 2, 1, 0.0, 0.0); createLabel("PacksPanel.tip", "tip", layout, gbConstraints); // Create the space label. parent.buildConstraints(gbConstraints, 0, 5, 2, 1, 0.0, 0.0); spaceLabel = createPanelWithLabel("PacksPanel.space", layout, gbConstraints); if (IoHelper.supported("getFreeSpace")) { // Create the free space label only if free space is supported. parent.buildConstraints(gbConstraints, 0, 6, 2, 1, 0.0, 0.0); freeSpaceLabel = createPanelWithLabel("PacksPanel.freespace", layout, gbConstraints); } }
protected void createNormalLayout() { preLoadImages(); layout = new GridBagLayout(); gbConstraints = new GridBagConstraints(); setLayout(layout); // Create constraint for first component as standard constraint. parent.buildConstraints(gbConstraints, 0, 0, 1, 1, 0.25, 0.0); gbConstraints.insets = new Insets(5, 5, 5, 5); gbConstraints.anchor = GridBagConstraints.WEST; // Create the info label. createLabel("PacksPanel.info", "preferences", layout, gbConstraints); // Create the snap label. parent.buildConstraints(gbConstraints, 1, 0, 1, 1, 0.50, 0.0); createLabel("ImgPacksPanel.snap", "tip", layout, gbConstraints); // Create packs table with a scroller. tableScroller = new JScrollPane(); parent.buildConstraints(gbConstraints, 0, 1, 1, 2, 0.50, 0.0); gbConstraints.fill = GridBagConstraints.BOTH; packsTable = createPacksTable(250, tableScroller, layout, gbConstraints); // Create the image label with a scroller. imgLabel = new JLabel((ImageIcon) images.get(0)); JScrollPane imgScroller = new JScrollPane(imgLabel); imgScroller.setPreferredSize(getPreferredSizeFromImages()); parent.buildConstraints(gbConstraints, 1, 1, 1, 1, 0.5, 1.0); layout.addLayoutComponent(imgScroller, gbConstraints); add(imgScroller); // Create a vertical strut. Component strut = Box.createVerticalStrut(20); parent.buildConstraints(gbConstraints, 1, 2, 1, 3, 0.0, 0.0); layout.addLayoutComponent(strut, gbConstraints); add(strut); // Create the dependency area with a scroller. if (dependenciesExist) { JScrollPane depScroller = new JScrollPane(); depScroller.setPreferredSize(new Dimension(250, 40)); parent.buildConstraints(gbConstraints, 0, 3, 1, 1, 0.50, 0.50); dependencyArea = createTextArea("ImgPacksPanel.dependencyList", depScroller, layout, gbConstraints); } // Create the description area with a scroller. JScrollPane descriptionScroller = new JScrollPane(); descriptionScroller.setPreferredSize(new Dimension(200, 60)); descriptionScroller.setBorder(BorderFactory.createEmptyBorder()); parent.buildConstraints(gbConstraints, 1, 3, 1, 1, 0.50, 0.50); descriptionArea = createTextArea("PacksPanel.description", descriptionScroller, layout, gbConstraints); // Create the tip label. parent.buildConstraints(gbConstraints, 0, 4, 2, 1, 0.0, 0.0); createLabel("PacksPanel.tip", "tip", layout, gbConstraints); // Create the space label. parent.buildConstraints(gbConstraints, 0, 5, 2, 1, 0.0, 0.0); spaceLabel = createPanelWithLabel("PacksPanel.space", layout, gbConstraints); if (IoHelper.supported("getFreeSpace")) { // Create the free space label only if free space is supported. parent.buildConstraints(gbConstraints, 0, 6, 2, 1, 0.0, 0.0); freeSpaceLabel = createPanelWithLabel("PacksPanel.freespace", layout, gbConstraints); } }
3,241,271
private Dimension getPreferredSizeFromImages() { int maxWidth = 80, maxHeight = 60; ImageIcon icon; for (Iterator it = images.iterator(); it.hasNext();) { icon = (ImageIcon) it.next(); maxWidth = Math.max(maxWidth, icon.getIconWidth()); maxHeight = Math.max(maxHeight, icon.getIconHeight()); } maxWidth = Math.min(maxWidth + 20, idata.guiPrefs.width - 150); maxHeight = Math.min(maxHeight + 20, idata.guiPrefs.height - 150); return new Dimension(maxWidth, maxHeight); }
private Dimension getPreferredSizeFromImages() { int maxWidth = 80; int maxHeight = 60; ImageIcon icon; for (Iterator it = images.iterator(); it.hasNext();) { icon = (ImageIcon) it.next(); maxWidth = Math.max(maxWidth, icon.getIconWidth()); maxHeight = Math.max(maxHeight, icon.getIconHeight()); } maxWidth = Math.min(maxWidth + 20, idata.guiPrefs.width - 150); maxHeight = Math.min(maxHeight + 20, idata.guiPrefs.height - 150); return new Dimension(maxWidth, maxHeight); }
3,241,272
private void buildGUI() { // We initialize our layout JPanel contentPane = (JPanel) getContentPane(); layout = new GridBagLayout(); contentPane.setLayout(layout); gbConstraints = new GridBagConstraints(); gbConstraints.insets = new Insets(5, 5, 5, 5); // We prepare our action handler ActionsHandler handler = new ActionsHandler(); // Prepares the glass pane to block gui interaction when needed JPanel glassPane = (JPanel) getGlassPane(); glassPane.addMouseListener(new MouseAdapter() {}); glassPane.addMouseMotionListener(new MouseMotionAdapter() {}); glassPane.addKeyListener(new KeyAdapter() {}); // We set-up the buttons factory ButtonFactory.useButtonIcons(); ButtonFactory.useHighlightButtons(); // We put our components warningLabel = new JLabel(langpack.getString("uninstaller.warning"), icons .getImageIcon("warning"), JLabel.TRAILING); buildConstraints(gbConstraints, 0, 0, 2, 1, 1.0, 0.0); gbConstraints.anchor = GridBagConstraints.WEST; gbConstraints.fill = GridBagConstraints.NONE; layout.addLayoutComponent(warningLabel, gbConstraints); contentPane.add(warningLabel); targetDestroyCheckbox = new JCheckBox(langpack.getString("uninstaller.destroytarget") + installPath, false); buildConstraints(gbConstraints, 0, 1, 2, 1, 1.0, 0.0); layout.addLayoutComponent(targetDestroyCheckbox, gbConstraints); contentPane.add(targetDestroyCheckbox); gbConstraints.fill = GridBagConstraints.HORIZONTAL; progressBar = new JProgressBar(); progressBar.setStringPainted(true); progressBar.setString(langpack.getString("InstallPanel.begin")); buildConstraints(gbConstraints, 0, 2, 2, 1, 1.0, 0.0); layout.addLayoutComponent(progressBar, gbConstraints); contentPane.add(progressBar); destroyButton = ButtonFactory.createButton(langpack.getString("uninstaller.uninstall"), icons.getImageIcon("delete"), buttonsHColor); destroyButton.addActionListener(handler); buildConstraints(gbConstraints, 0, 3, 1, 1, 0.5, 0.0); gbConstraints.fill = GridBagConstraints.NONE; gbConstraints.anchor = GridBagConstraints.WEST; layout.addLayoutComponent(destroyButton, gbConstraints); contentPane.add(destroyButton); quitButton = ButtonFactory.createButton(langpack.getString("installer.quit"), icons .getImageIcon("stop"), buttonsHColor); quitButton.addActionListener(handler); buildConstraints(gbConstraints, 1, 3, 1, 1, 0.5, 0.0); gbConstraints.anchor = GridBagConstraints.EAST; layout.addLayoutComponent(quitButton, gbConstraints); contentPane.add(quitButton); }
private void buildGUI() { // We initialize our layout JPanel contentPane = (JPanel) getContentPane(); GridBagLayout layout = new GridBagLayout(); contentPane.setLayout(layout); gbConstraints = new GridBagConstraints(); gbConstraints.insets = new Insets(5, 5, 5, 5); // We prepare our action handler ActionsHandler handler = new ActionsHandler(); // Prepares the glass pane to block gui interaction when needed JPanel glassPane = (JPanel) getGlassPane(); glassPane.addMouseListener(new MouseAdapter() {}); glassPane.addMouseMotionListener(new MouseMotionAdapter() {}); glassPane.addKeyListener(new KeyAdapter() {}); // We set-up the buttons factory ButtonFactory.useButtonIcons(); ButtonFactory.useHighlightButtons(); // We put our components warningLabel = new JLabel(langpack.getString("uninstaller.warning"), icons .getImageIcon("warning"), JLabel.TRAILING); buildConstraints(gbConstraints, 0, 0, 2, 1, 1.0, 0.0); gbConstraints.anchor = GridBagConstraints.WEST; gbConstraints.fill = GridBagConstraints.NONE; layout.addLayoutComponent(warningLabel, gbConstraints); contentPane.add(warningLabel); targetDestroyCheckbox = new JCheckBox(langpack.getString("uninstaller.destroytarget") + installPath, false); buildConstraints(gbConstraints, 0, 1, 2, 1, 1.0, 0.0); layout.addLayoutComponent(targetDestroyCheckbox, gbConstraints); contentPane.add(targetDestroyCheckbox); gbConstraints.fill = GridBagConstraints.HORIZONTAL; progressBar = new JProgressBar(); progressBar.setStringPainted(true); progressBar.setString(langpack.getString("InstallPanel.begin")); buildConstraints(gbConstraints, 0, 2, 2, 1, 1.0, 0.0); layout.addLayoutComponent(progressBar, gbConstraints); contentPane.add(progressBar); destroyButton = ButtonFactory.createButton(langpack.getString("uninstaller.uninstall"), icons.getImageIcon("delete"), buttonsHColor); destroyButton.addActionListener(handler); buildConstraints(gbConstraints, 0, 3, 1, 1, 0.5, 0.0); gbConstraints.fill = GridBagConstraints.NONE; gbConstraints.anchor = GridBagConstraints.WEST; layout.addLayoutComponent(destroyButton, gbConstraints); contentPane.add(destroyButton); quitButton = ButtonFactory.createButton(langpack.getString("installer.quit"), icons .getImageIcon("stop"), buttonsHColor); quitButton.addActionListener(handler); buildConstraints(gbConstraints, 1, 3, 1, 1, 0.5, 0.0); gbConstraints.anchor = GridBagConstraints.EAST; layout.addLayoutComponent(quitButton, gbConstraints); contentPane.add(quitButton); }
3,241,273
private void buildGUI() { // We initialize our layout JPanel contentPane = (JPanel) getContentPane(); layout = new GridBagLayout(); contentPane.setLayout(layout); gbConstraints = new GridBagConstraints(); gbConstraints.insets = new Insets(5, 5, 5, 5); // We prepare our action handler ActionsHandler handler = new ActionsHandler(); // Prepares the glass pane to block gui interaction when needed JPanel glassPane = (JPanel) getGlassPane(); glassPane.addMouseListener(new MouseAdapter() {}); glassPane.addMouseMotionListener(new MouseMotionAdapter() {}); glassPane.addKeyListener(new KeyAdapter() {}); // We set-up the buttons factory ButtonFactory.useButtonIcons(); ButtonFactory.useHighlightButtons(); // We put our components warningLabel = new JLabel(langpack.getString("uninstaller.warning"), icons .getImageIcon("warning"), JLabel.TRAILING); buildConstraints(gbConstraints, 0, 0, 2, 1, 1.0, 0.0); gbConstraints.anchor = GridBagConstraints.WEST; gbConstraints.fill = GridBagConstraints.NONE; layout.addLayoutComponent(warningLabel, gbConstraints); contentPane.add(warningLabel); targetDestroyCheckbox = new JCheckBox(langpack.getString("uninstaller.destroytarget") + installPath, false); buildConstraints(gbConstraints, 0, 1, 2, 1, 1.0, 0.0); layout.addLayoutComponent(targetDestroyCheckbox, gbConstraints); contentPane.add(targetDestroyCheckbox); gbConstraints.fill = GridBagConstraints.HORIZONTAL; progressBar = new JProgressBar(); progressBar.setStringPainted(true); progressBar.setString(langpack.getString("InstallPanel.begin")); buildConstraints(gbConstraints, 0, 2, 2, 1, 1.0, 0.0); layout.addLayoutComponent(progressBar, gbConstraints); contentPane.add(progressBar); destroyButton = ButtonFactory.createButton(langpack.getString("uninstaller.uninstall"), icons.getImageIcon("delete"), buttonsHColor); destroyButton.addActionListener(handler); buildConstraints(gbConstraints, 0, 3, 1, 1, 0.5, 0.0); gbConstraints.fill = GridBagConstraints.NONE; gbConstraints.anchor = GridBagConstraints.WEST; layout.addLayoutComponent(destroyButton, gbConstraints); contentPane.add(destroyButton); quitButton = ButtonFactory.createButton(langpack.getString("installer.quit"), icons .getImageIcon("stop"), buttonsHColor); quitButton.addActionListener(handler); buildConstraints(gbConstraints, 1, 3, 1, 1, 0.5, 0.0); gbConstraints.anchor = GridBagConstraints.EAST; layout.addLayoutComponent(quitButton, gbConstraints); contentPane.add(quitButton); }
private void buildGUI() { // We initialize our layout JPanel contentPane = (JPanel) getContentPane(); layout = new GridBagLayout(); contentPane.setLayout(layout); GridBagConstraints gbConstraints = new GridBagConstraints(); gbConstraints.insets = new Insets(5, 5, 5, 5); // We prepare our action handler ActionsHandler handler = new ActionsHandler(); // Prepares the glass pane to block gui interaction when needed JPanel glassPane = (JPanel) getGlassPane(); glassPane.addMouseListener(new MouseAdapter() {}); glassPane.addMouseMotionListener(new MouseMotionAdapter() {}); glassPane.addKeyListener(new KeyAdapter() {}); // We set-up the buttons factory ButtonFactory.useButtonIcons(); ButtonFactory.useHighlightButtons(); // We put our components warningLabel = new JLabel(langpack.getString("uninstaller.warning"), icons .getImageIcon("warning"), JLabel.TRAILING); buildConstraints(gbConstraints, 0, 0, 2, 1, 1.0, 0.0); gbConstraints.anchor = GridBagConstraints.WEST; gbConstraints.fill = GridBagConstraints.NONE; layout.addLayoutComponent(warningLabel, gbConstraints); contentPane.add(warningLabel); targetDestroyCheckbox = new JCheckBox(langpack.getString("uninstaller.destroytarget") + installPath, false); buildConstraints(gbConstraints, 0, 1, 2, 1, 1.0, 0.0); layout.addLayoutComponent(targetDestroyCheckbox, gbConstraints); contentPane.add(targetDestroyCheckbox); gbConstraints.fill = GridBagConstraints.HORIZONTAL; progressBar = new JProgressBar(); progressBar.setStringPainted(true); progressBar.setString(langpack.getString("InstallPanel.begin")); buildConstraints(gbConstraints, 0, 2, 2, 1, 1.0, 0.0); layout.addLayoutComponent(progressBar, gbConstraints); contentPane.add(progressBar); destroyButton = ButtonFactory.createButton(langpack.getString("uninstaller.uninstall"), icons.getImageIcon("delete"), buttonsHColor); destroyButton.addActionListener(handler); buildConstraints(gbConstraints, 0, 3, 1, 1, 0.5, 0.0); gbConstraints.fill = GridBagConstraints.NONE; gbConstraints.anchor = GridBagConstraints.WEST; layout.addLayoutComponent(destroyButton, gbConstraints); contentPane.add(destroyButton); quitButton = ButtonFactory.createButton(langpack.getString("installer.quit"), icons .getImageIcon("stop"), buttonsHColor); quitButton.addActionListener(handler); buildConstraints(gbConstraints, 1, 3, 1, 1, 0.5, 0.0); gbConstraints.anchor = GridBagConstraints.EAST; layout.addLayoutComponent(quitButton, gbConstraints); contentPane.add(quitButton); }
3,241,274
private void buildGUI() { // We initialize our layout JPanel contentPane = (JPanel) getContentPane(); layout = new GridBagLayout(); contentPane.setLayout(layout); gbConstraints = new GridBagConstraints(); gbConstraints.insets = new Insets(5, 5, 5, 5); // We prepare our action handler ActionsHandler handler = new ActionsHandler(); // Prepares the glass pane to block gui interaction when needed JPanel glassPane = (JPanel) getGlassPane(); glassPane.addMouseListener(new MouseAdapter() {}); glassPane.addMouseMotionListener(new MouseMotionAdapter() {}); glassPane.addKeyListener(new KeyAdapter() {}); // We set-up the buttons factory ButtonFactory.useButtonIcons(); ButtonFactory.useHighlightButtons(); // We put our components warningLabel = new JLabel(langpack.getString("uninstaller.warning"), icons .getImageIcon("warning"), JLabel.TRAILING); buildConstraints(gbConstraints, 0, 0, 2, 1, 1.0, 0.0); gbConstraints.anchor = GridBagConstraints.WEST; gbConstraints.fill = GridBagConstraints.NONE; layout.addLayoutComponent(warningLabel, gbConstraints); contentPane.add(warningLabel); targetDestroyCheckbox = new JCheckBox(langpack.getString("uninstaller.destroytarget") + installPath, false); buildConstraints(gbConstraints, 0, 1, 2, 1, 1.0, 0.0); layout.addLayoutComponent(targetDestroyCheckbox, gbConstraints); contentPane.add(targetDestroyCheckbox); gbConstraints.fill = GridBagConstraints.HORIZONTAL; progressBar = new JProgressBar(); progressBar.setStringPainted(true); progressBar.setString(langpack.getString("InstallPanel.begin")); buildConstraints(gbConstraints, 0, 2, 2, 1, 1.0, 0.0); layout.addLayoutComponent(progressBar, gbConstraints); contentPane.add(progressBar); destroyButton = ButtonFactory.createButton(langpack.getString("uninstaller.uninstall"), icons.getImageIcon("delete"), buttonsHColor); destroyButton.addActionListener(handler); buildConstraints(gbConstraints, 0, 3, 1, 1, 0.5, 0.0); gbConstraints.fill = GridBagConstraints.NONE; gbConstraints.anchor = GridBagConstraints.WEST; layout.addLayoutComponent(destroyButton, gbConstraints); contentPane.add(destroyButton); quitButton = ButtonFactory.createButton(langpack.getString("installer.quit"), icons .getImageIcon("stop"), buttonsHColor); quitButton.addActionListener(handler); buildConstraints(gbConstraints, 1, 3, 1, 1, 0.5, 0.0); gbConstraints.anchor = GridBagConstraints.EAST; layout.addLayoutComponent(quitButton, gbConstraints); contentPane.add(quitButton); }
private void buildGUI() { // We initialize our layout JPanel contentPane = (JPanel) getContentPane(); layout = new GridBagLayout(); contentPane.setLayout(layout); gbConstraints = new GridBagConstraints(); gbConstraints.insets = new Insets(5, 5, 5, 5); // We prepare our action handler ActionsHandler handler = new ActionsHandler(); // Prepares the glass pane to block gui interaction when needed JPanel glassPane = (JPanel) getGlassPane(); glassPane.addMouseListener(new MouseAdapter() {}); glassPane.addMouseMotionListener(new MouseMotionAdapter() {}); glassPane.addKeyListener(new KeyAdapter() {}); // We set-up the buttons factory ButtonFactory.useButtonIcons(); ButtonFactory.useHighlightButtons(); // We put our components JLabel warningLabel = new JLabel(langpack.getString("uninstaller.warning"), icons .getImageIcon("warning"), JLabel.TRAILING); buildConstraints(gbConstraints, 0, 0, 2, 1, 1.0, 0.0); gbConstraints.anchor = GridBagConstraints.WEST; gbConstraints.fill = GridBagConstraints.NONE; layout.addLayoutComponent(warningLabel, gbConstraints); contentPane.add(warningLabel); targetDestroyCheckbox = new JCheckBox(langpack.getString("uninstaller.destroytarget") + installPath, false); buildConstraints(gbConstraints, 0, 1, 2, 1, 1.0, 0.0); layout.addLayoutComponent(targetDestroyCheckbox, gbConstraints); contentPane.add(targetDestroyCheckbox); gbConstraints.fill = GridBagConstraints.HORIZONTAL; progressBar = new JProgressBar(); progressBar.setStringPainted(true); progressBar.setString(langpack.getString("InstallPanel.begin")); buildConstraints(gbConstraints, 0, 2, 2, 1, 1.0, 0.0); layout.addLayoutComponent(progressBar, gbConstraints); contentPane.add(progressBar); destroyButton = ButtonFactory.createButton(langpack.getString("uninstaller.uninstall"), icons.getImageIcon("delete"), buttonsHColor); destroyButton.addActionListener(handler); buildConstraints(gbConstraints, 0, 3, 1, 1, 0.5, 0.0); gbConstraints.fill = GridBagConstraints.NONE; gbConstraints.anchor = GridBagConstraints.WEST; layout.addLayoutComponent(destroyButton, gbConstraints); contentPane.add(destroyButton); quitButton = ButtonFactory.createButton(langpack.getString("installer.quit"), icons .getImageIcon("stop"), buttonsHColor); quitButton.addActionListener(handler); buildConstraints(gbConstraints, 1, 3, 1, 1, 0.5, 0.0); gbConstraints.anchor = GridBagConstraints.EAST; layout.addLayoutComponent(quitButton, gbConstraints); contentPane.add(quitButton); }
3,241,275
public String getBasePath() throws Exception { return shortcut.getLinkPath(shortcut.getUserType()); }
public String getBasePath() throws Exception { String result = shortcut.getLinkPath(shortcut.getUserType()); Debug.log( CLASS + myClass + ".getBasePath() '" + result + "'" ); return result; }
3,241,276
public String getDirectoryCreated() { return (shortcut.getDirectoryCreated()); }
public String getDirectoryCreated() { String directoryCreated = shortcut.getDirectoryCreated(); Debug.log( CLASS + myClass + ".getDirectoryCreated() '" + directoryCreated + "'" ); return( directoryCreated ); }
3,241,277
public String getFileName() { return (shortcut.getFileName()); }
public String getFileName() { String aFilename = shortcut.getFileName(); Debug.log( CLASS + myClass + ".getFileName() '" + aFilename + "'" ); return( aFilename ); }
3,241,278
public int getHotkey() { return shortcut.getHotkey(); }
public int getHotkey() { int result = shortcut.getHotkey(); Debug.log( CLASS + myClass + ".getHotkey() '" + result + "'" ); return result; }
3,241,279
public String getIconLocation() { return shortcut.getIconLocation(); }
public String getIconLocation() { String result = shortcut.getIconLocation(); Debug.log( CLASS + myClass + ".getIconLocation() '" + result + "'" ); return result; }
3,241,280
public int getLinkType() { int typ = shortcut.getLinkType(); switch (typ) { case ShellLink.DESKTOP: typ = DESKTOP; break; case ShellLink.PROGRAM_MENU: typ = APPLICATIONS; break; case ShellLink.START_MENU: typ = START_MENU; break; case ShellLink.STARTUP: typ = START_UP; break; default: break; } return typ; }
Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); publicDebug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); intDebug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); getLinkType()Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); {Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); intDebug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); typDebug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); =Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); shortcut.getLinkType();Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); switchDebug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); (typ)Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); {Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); caseDebug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); ShellLink.DESKTOP:Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); typDebug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); =Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); DESKTOP;Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); break;Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); caseDebug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); ShellLink.PROGRAM_MENU:Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); typDebug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); =Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); APPLICATIONS;Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); break;Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); caseDebug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); ShellLink.START_MENU:Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); typDebug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); =Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); START_MENU;Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); break;Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); caseDebug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); ShellLink.STARTUP:Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); typDebug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); =Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); START_UP;Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); break;Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); default:Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); break;Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); }Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); returnDebug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); typ;Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); Debug.log( CLASS + myClass + ".getLinkType() '" + typ + "'" ); }
3,241,281
public Vector getProgramGroups(int userType) { // ---------------------------------------------------- // translate the user type // ---------------------------------------------------- int type = ShellLink.CURRENT_USER; if (userType == ALL_USERS) { type = ShellLink.ALL_USERS; } else { type = ShellLink.CURRENT_USER; } // ---------------------------------------------------- // get a list of all files and directories that are // located at the link path. // ---------------------------------------------------- String linkPath = shortcut.getLinkPath(type); // in case there is a problem obtaining a path return // an empty vector (there are no preexisting program // groups) if (linkPath == null) { return (new Vector()); } File path = new File(linkPath); File[] file = path.listFiles(); // ---------------------------------------------------- // build a vector that contains only the names of // the directories. // ---------------------------------------------------- Vector groups = new Vector(); if (file != null) { for (int i = 0; i < file.length; i++) { if (file[i].isDirectory()) { groups.add(file[i].getName()); } } } return (groups); }
public Vector getProgramGroups(int userType) { // ---------------------------------------------------- // translate the user type // ---------------------------------------------------- int type = ShellLink.CURRENT_USER; if (userType == ALL_USERS) { type = ShellLink.ALL_USERS; } else { type = ShellLink.CURRENT_USER; } // ---------------------------------------------------- // get a list of all files and directories that are // located at the link path. // ---------------------------------------------------- String linkPath = shortcut.getLinkPath(type); // in case there is a problem obtaining a path return // an empty vector (there are no preexisting program // groups) if (linkPath == null) { return (new Vector()); } File path = new File(linkPath); File[] file = path.listFiles(); // ---------------------------------------------------- // build a vector that contains only the names of // the directories. // ---------------------------------------------------- Vector groups = new Vector(); if (file != null) { for (int i = 0; i < file.length; i++) { File aFile = file[i]; String aFilename = aFile.getName(); if (aFile.isDirectory()) { groups.add(file[i].getName()); } } } return (groups); }
3,241,282
public Vector getProgramGroups(int userType) { // ---------------------------------------------------- // translate the user type // ---------------------------------------------------- int type = ShellLink.CURRENT_USER; if (userType == ALL_USERS) { type = ShellLink.ALL_USERS; } else { type = ShellLink.CURRENT_USER; } // ---------------------------------------------------- // get a list of all files and directories that are // located at the link path. // ---------------------------------------------------- String linkPath = shortcut.getLinkPath(type); // in case there is a problem obtaining a path return // an empty vector (there are no preexisting program // groups) if (linkPath == null) { return (new Vector()); } File path = new File(linkPath); File[] file = path.listFiles(); // ---------------------------------------------------- // build a vector that contains only the names of // the directories. // ---------------------------------------------------- Vector groups = new Vector(); if (file != null) { for (int i = 0; i < file.length; i++) { if (file[i].isDirectory()) { groups.add(file[i].getName()); } } } return (groups); }
public Vector getProgramGroups(int userType) { // ---------------------------------------------------- // translate the user type // ---------------------------------------------------- int type = ShellLink.CURRENT_USER; if (userType == ALL_USERS) { type = ShellLink.ALL_USERS; } else { type = ShellLink.CURRENT_USER; } // ---------------------------------------------------- // get a list of all files and directories that are // located at the link path. // ---------------------------------------------------- String linkPath = shortcut.getLinkPath(type); // in case there is a problem obtaining a path return // an empty vector (there are no preexisting program // groups) if (linkPath == null) { return (new Vector()); } File path = new File(linkPath); File[] file = path.listFiles(); // ---------------------------------------------------- // build a vector that contains only the names of // the directories. // ---------------------------------------------------- Vector groups = new Vector(); if (file != null) { for (int i = 0; i < file.length; i++) { if (file[i].isDirectory()) { Debug.log( CLASS + myClass + ".getProgramGroups()-" + logentry++ + " '" + aFilename + "'" ); groups.add( aFilename ); } } } return (groups); }
3,241,283
public String getProgramsFolder(int current_user) { return shortcut.getLinkPath(current_user); }
public String getProgramsFolder(int current_user) { return shortcut.getLinkPath(current_user); }
3,241,285
public String getProgramsFolder(int current_user) { return shortcut.getLinkPath(current_user); }
public String getProgramsFolder(int current_user) { String result = null; try { result = new String( shortcut.getLinkPath(current_user).getBytes( StringTool.getPlatformEncoding() ), StringTool.getPlatformEncoding() ); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } Debug.log( CLASS + myClass + ".getProgramsFolder() '" + current_user + "', '" + result + "'" ); return result; }
3,241,286
public int getShowCommand() { int showCommand = shortcut.getShowCommand(); switch (showCommand) { case ShellLink.NORMAL: showCommand = NORMAL; break; // both MINNOACTIVE and MINIMIZED map to Shortcut.MINIMIZED case ShellLink.MINNOACTIVE: case ShellLink.MINIMIZED: showCommand = MINIMIZED; break; case ShellLink.MAXIMIZED: showCommand = MAXIMIZED; break; default: break; } return showCommand; }
public int getShowCommand() { int showCommand = shortcut.getShowCommand(); switch (showCommand) { case ShellLink.NORMAL: showCommand = NORMAL; break; // both MINNOACTIVE and MINIMIZED map to Shortcut.MINIMIZED case ShellLink.MINNOACTIVE: case ShellLink.MINIMIZED: showCommand = MINIMIZED; break; case ShellLink.MAXIMIZED: showCommand = MAXIMIZED; break; default: break; } return showCommand; }
3,241,287
public String getWorkingDirectory() { return shortcut.getWorkingDirectory(); }
public String getWorkingDirectory() { String result = shortcut.getWorkingDirectory(); Debug.log( CLASS + myClass + ".getWorkingDirectory() '" + result + "'" ); return result; }
3,241,290
public boolean multipleUsers() { // Win NT4 won't have PROGRAMS for CURRENT_USER. // Win 98 may not have 'Start Menu\Programs' for ALL_USERS String au = shortcut.getallUsersLinkPath(); String cu = shortcut.getcurrentUserLinkPath(); if (au == null || cu == null) return false; return (au.length() > 0 && cu.length() > 0); }
public boolean multipleUsers() { // Win NT4 won't have PROGRAMS for CURRENT_USER. // Win 98 may not have 'Start Menu\Programs' for ALL_USERS String au = shortcut.getallUsersLinkPath(); String cu = shortcut.getcurrentUserLinkPath(); if (au == null || cu == null) return false; return (au.length() > 0 && cu.length() > 0); }
3,241,292
public boolean multipleUsers() { // Win NT4 won't have PROGRAMS for CURRENT_USER. // Win 98 may not have 'Start Menu\Programs' for ALL_USERS String au = shortcut.getallUsersLinkPath(); String cu = shortcut.getcurrentUserLinkPath(); if (au == null || cu == null) return false; return (au.length() > 0 && cu.length() > 0); }
public boolean multipleUsers() { // Win NT4 won't have PROGRAMS for CURRENT_USER. // Win 98 may not have 'Start Menu\Programs' for ALL_USERS String au = shortcut.getallUsersLinkPath(); String cu = shortcut.getcurrentUserLinkPath(); if( allUsers == null || currentUsers == null ) result = false; else result = allUsers.length() > 0 && currentUsers.length() > 0; return (au.length() > 0 && cu.length() > 0); }
3,241,293
public boolean multipleUsers() { // Win NT4 won't have PROGRAMS for CURRENT_USER. // Win 98 may not have 'Start Menu\Programs' for ALL_USERS String au = shortcut.getallUsersLinkPath(); String cu = shortcut.getcurrentUserLinkPath(); if (au == null || cu == null) return false; return (au.length() > 0 && cu.length() > 0); }
public boolean multipleUsers() { // Win NT4 won't have PROGRAMS for CURRENT_USER. // Win 98 may not have 'Start Menu\Programs' for ALL_USERS String au = shortcut.getallUsersLinkPath(); String cu = shortcut.getcurrentUserLinkPath(); if (au == null || cu == null) return false; Debug.log( CLASS + myClass + ".multipleUsers()-3 '" + result + "'" ); return (result); }
3,241,294
public void setArguments(String arguments) { shortcut.setArguments(arguments); }
public void setArguments(String arguments) { Debug.log( CLASS + myClass + ".setArguments() '" + arguments + "'" ); shortcut.setArguments(arguments); }
3,241,296
public void setDescription(String description) { shortcut.setDescription(description); }
public void setDescription(String description) { Debug.log( CLASS + myClass + ".setDescription() '" + description + "'" ); shortcut.setDescription( description ); }
3,241,297
public void setIconLocation(String path, int index) { shortcut.setIconLocation(path, index); }
public void setIconLocation(String path, int index) { Debug.log( CLASS + myClass + ".setIconLocation() '" + path + "', '" + Integer.toString(index) + "'" ); shortcut.setIconLocation(path, index); }
3,241,299
public void setLinkType(int type) throws IllegalArgumentException { switch (type) { case DESKTOP: { shortcut.setLinkType(ShellLink.DESKTOP); break; } case APPLICATIONS: { shortcut.setLinkType(ShellLink.PROGRAM_MENU); break; } case START_MENU: { shortcut.setLinkType(ShellLink.START_MENU); break; } case START_UP: { shortcut.setLinkType(ShellLink.STARTUP); break; } default: { throw (new IllegalArgumentException(type + "is not recognized as a valid link type")); } } }
public void setLinkType(int type) throws IllegalArgumentException, UnsupportedEncodingException { switch (type) { case DESKTOP: { shortcut.setLinkType(ShellLink.DESKTOP); break; } case APPLICATIONS: { shortcut.setLinkType(ShellLink.PROGRAM_MENU); break; } case START_MENU: { shortcut.setLinkType(ShellLink.START_MENU); break; } case START_UP: { shortcut.setLinkType(ShellLink.STARTUP); break; } default: { throw (new IllegalArgumentException(type + "is not recognized as a valid link type")); } } }
3,241,301
public void setProgramGroup(String groupName) { shortcut.setProgramGroup(groupName); }
public void setProgramGroup(String groupName) { Debug.log( CLASS + myClass + ".setProgramGroup() '" + groupName + "'" ); shortcut.setProgramGroup(groupName); }
3,241,303
public void setShowCommand(int show) throws IllegalArgumentException { switch (show) { case HIDE: { shortcut.setShowCommand(ShellLink.MINNOACTIVE); break; } case NORMAL: { shortcut.setShowCommand(ShellLink.NORMAL); break; } case MINIMIZED: { shortcut.setShowCommand(ShellLink.MINNOACTIVE); break; } case MAXIMIZED: { shortcut.setShowCommand(ShellLink.MAXIMIZED); break; } default: { throw (new IllegalArgumentException(show + "is not recognized as a show command")); } } }
Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); publicDebug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); voidDebug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); setShowCommand(intDebug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); show)Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); throwsDebug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); IllegalArgumentExceptionDebug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); {Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); switchDebug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); (show)Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); {Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); caseDebug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); HIDE:Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); {Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); shortcut.setShowCommand(ShellLink.MINNOACTIVE);Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); break;Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); }Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); caseDebug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); NORMAL:Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); {Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); shortcut.setShowCommand(ShellLink.NORMAL);Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); break;Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); }Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); caseDebug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); MINIMIZED:Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); {Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); shortcut.setShowCommand(ShellLink.MINNOACTIVE);Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); break;Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); }Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); caseDebug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); MAXIMIZED:Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); {Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); shortcut.setShowCommand(ShellLink.MAXIMIZED);Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); break;Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); }Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); default:Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); {Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); throwDebug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); (newDebug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); IllegalArgumentException(showDebug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); +Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); "isDebug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); notDebug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); recognizedDebug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); asDebug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); aDebug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); showDebug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); command"));Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); }Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); }Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); Debug.log( CLASS + myClass + ".setShowCommand() '" + Integer.toString(show) + "'" ); }
3,241,304
public boolean supported() { return (true); }
public boolean supported() { return (true); }
3,241,308
private static void set16(byte[] b, int off, int value) { b[off+0] = (byte)value; b[off+1] = (byte)(value >> 8); }
private static void set16(byte[] b, int off, int value) { b[off+0] = (byte)value; b[off+1] = (byte)(value >> 8); }
3,241,309
public synchronized void clear(Object key) { LinkedList pool = (LinkedList)(_poolMap.remove(key)); if(null == pool) { return; } else { for(Iterator it = pool.iterator(); it.hasNext(); ) { try { _factory.destroyObject(key,((ObjectTimestampPair)(it.next())).value); } catch(Exception e) { // ignore error, keep destroying the rest } it.remove(); _totalIdle--; } } notifyAll(); }
public synchronized void clear(Object key) { LinkedList pool = (LinkedList)(_poolMap.remove(key)); if(null == pool) { return; } else { for(Iterator it = pool.iterator(); it.hasNext(); ) { try { _factory.destroyObject(key,((ObjectTimestampPair)(it.next())).value); } catch(Exception e) { // ignore error, keep destroying the rest } it.remove(); _totalIdle--; } } notifyAll(); }
3,241,310
public synchronized void clear(Object key) { LinkedList pool = (LinkedList)(_poolMap.remove(key)); if(null == pool) { return; } else { for(Iterator it = pool.iterator(); it.hasNext(); ) { try { _factory.destroyObject(key,((ObjectTimestampPair)(it.next())).value); } catch(Exception e) { // ignore error, keep destroying the rest } it.remove(); _totalIdle--; } } notifyAll(); }
public synchronized void clear(Object key) { LinkedList pool = (LinkedList)(_poolMap.remove(key)); if(null == pool) { return; } else { for(Iterator it = pool.iterator(); it.hasNext(); ) { try { _factory.destroyObject(key,((ObjectTimestampPair)(it.next())).value); } catch(Exception e) { // ignore error, keep destroying the rest } it.remove(); } } notifyAll(); }
3,241,311
private Object [] getCompilerListenerInstance( XMLElement var ) throws Exception { final String defaultRootPath = "com.izforge.izpack."; final String defaultCompilerPath = "compiler."; String className = var.getAttribute("compiler"); Class listener = null; Object instance = null; if( className == null ) return(null); // CustomAction files come in jars packaged IzPack String jarPath = "bin/customActions/" + className + ".jar"; URL url = findIzPackResource(jarPath, "CustomAction jar file", var); String fullName = getFullClassName(url, className); if( url != null ) { if(getClass().getResource("/" + jarPath) != null ) { // Oops, standalone, URLClassLoader will not work ... // Write the jar to a temp file. InputStream in = null; FileOutputStream outFile = null; byte[] buffer = new byte[5120]; File tf = null; try { tf = File. createTempFile("izpj", ".jar"); tf.deleteOnExit(); outFile = new FileOutputStream(tf); in = getClass().getResourceAsStream("/" + jarPath); long bytesCopied = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { outFile.write(buffer, 0, bytesInBuffer); bytesCopied += bytesInBuffer; } } finally { if( in != null ) in.close(); if( outFile != null ) outFile.close(); } url = tf.toURL(); } URLClassLoader ucl = new URLClassLoader( new URL[] {url} ); listener = ucl.loadClass(fullName); } if( listener != null ) instance = listener.newInstance(); else parseError(var, "Cannot find defined compiler listener " + className); if( ! CompilerListener.class.isInstance(instance) ) parseError(var, "'" + className + "' must be implemented " + CompilerListener.class.toString()); List constraints = OsConstraint.getOsList(var); return( new Object[] {instance, className, constraints} ); }
private Object [] getCompilerListenerInstance( XMLElement var ) throws Exception { final String defaultRootPath = "com.izforge.izpack."; final String defaultCompilerPath = "compiler."; String className = var.getAttribute("compiler"); Class listener = null; Object instance = null; if( className == null ) return(null); // CustomAction files come in jars packaged IzPack String jarPath = "bin/customActions/" + className + ".jar"; URL url = findIzPackResource(jarPath, "CustomAction jar file", var); String fullName = getFullClassName(url, className); if( url != null ) { if(getClass().getResource("/" + jarPath) != null ) { // Oops, standalone, URLClassLoader will not work ... // Write the jar to a temp file. InputStream in = null; FileOutputStream outFile = null; byte[] buffer = new byte[5120]; File tf = null; try { tf = File. createTempFile("izpj", ".jar"); tf.deleteOnExit(); outFile = new FileOutputStream(tf); in = getClass().getResourceAsStream("/" + jarPath); long bytesCopied = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { outFile.write(buffer, 0, bytesInBuffer); bytesCopied += bytesInBuffer; } } finally { if( in != null ) in.close(); if( outFile != null ) outFile.close(); } url = tf.toURL(); } URLClassLoader ucl = new URLClassLoader( new URL[] {url}, CompilerListener.class.getClassLoader() ); listener = ucl.loadClass(fullName); } if( listener != null ) instance = listener.newInstance(); else parseError(var, "Cannot find defined compiler listener " + className); if( ! CompilerListener.class.isInstance(instance) ) parseError(var, "'" + className + "' must be implemented " + CompilerListener.class.toString()); List constraints = OsConstraint.getOsList(var); return( new Object[] {instance, className, constraints} ); }
3,241,313
private Object [] getCompilerListenerInstance( XMLElement var ) throws Exception { final String defaultRootPath = "com.izforge.izpack."; final String defaultCompilerPath = "compiler."; String className = var.getAttribute("compiler"); Class listener = null; Object instance = null; if( className == null ) return(null); // CustomAction files come in jars packaged IzPack String jarPath = "bin/customActions/" + className + ".jar"; URL url = findIzPackResource(jarPath, "CustomAction jar file", var); String fullName = getFullClassName(url, className); if( url != null ) { if(getClass().getResource("/" + jarPath) != null ) { // Oops, standalone, URLClassLoader will not work ... // Write the jar to a temp file. InputStream in = null; FileOutputStream outFile = null; byte[] buffer = new byte[5120]; File tf = null; try { tf = File. createTempFile("izpj", ".jar"); tf.deleteOnExit(); outFile = new FileOutputStream(tf); in = getClass().getResourceAsStream("/" + jarPath); long bytesCopied = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { outFile.write(buffer, 0, bytesInBuffer); bytesCopied += bytesInBuffer; } } finally { if( in != null ) in.close(); if( outFile != null ) outFile.close(); } url = tf.toURL(); } URLClassLoader ucl = new URLClassLoader( new URL[] {url} ); listener = ucl.loadClass(fullName); } if( listener != null ) instance = listener.newInstance(); else parseError(var, "Cannot find defined compiler listener " + className); if( ! CompilerListener.class.isInstance(instance) ) parseError(var, "'" + className + "' must be implemented " + CompilerListener.class.toString()); List constraints = OsConstraint.getOsList(var); return( new Object[] {instance, className, constraints} ); }
privateObject[]getCompilerListenerInstance(XMLElementvar)throwsException{finalStringdefaultRootPath="com.izforge.izpack.";finalStringdefaultCompilerPath="compiler.";StringclassName=var.getAttribute("compiler");Classlistener=null;Objectinstance=null;if(className==null)return(null);//CustomActionfilescomeinjarspackagedIzPackStringjarPath="bin/customActions/"+className+".jar";URLurl=findIzPackResource(jarPath,"CustomActionjarfile",var);StringfullName=getFullClassName(url,className);if(url!=null){if(getClass().getResource("/"+jarPath)!=null){//Oops,standalone,URLClassLoaderwillnotwork...//Writethejartoatempfile.InputStreamin=null;FileOutputStreamoutFile=null;byte[]buffer=newbyte[5120];Filetf=null;try{tf=File.createTempFile("izpj",".jar");tf.deleteOnExit();outFile=newFileOutputStream(tf);in=getClass().getResourceAsStream("/"+jarPath);longbytesCopied=0;intbytesInBuffer;while((bytesInBuffer=in.read(buffer))!=-1){outFile.write(buffer,0,bytesInBuffer);bytesCopied+=bytesInBuffer;}}finally{if(in!=null)in.close();if(outFile!=null)outFile.close();}url=tf.toURL();}URLClassLoaderucl=newURLClassLoader(newURL[]{url});listener=ucl.loadClass(fullName);}if(listener!=null)instance=listener.newInstance();elseparseError(var,"Cannotfinddefinedcompilerlistener"+className);if(!CompilerListener.class.isInstance(instance))parseError(var,"'"+className+"'mustbeimplemented"+CompilerListener.class.toString());Listconstraints=OsConstraint.getOsList(var);return(newObject[]{instance,className,constraints});}
3,241,314
public void progress(int val, String msg) { float percentage = ((float)val)*100.0f/(float)this.job_max; String percent = (new Integer ((int)percentage)).toString()+'%'; String line = this.job_name + ": " + percent; int line_len = line.length(); System.out.print ("\r"+line); for (int i = line_len; i < this.last_line_len; i++) System.out.print (' '); this.last_line_len = line_len; }
public void progress(int val, String msg) { double percentage = ((double)val)*100.0d/(double)this.job_max; String percent = (new Integer ((int)percentage)).toString()+'%'; String line = this.job_name + ": " + percent; int line_len = line.length(); System.out.print ("\r"+line); for (int i = line_len; i < this.last_line_len; i++) System.out.print (' '); this.last_line_len = line_len; }
3,241,315
public void actionPerformed (ActionEvent event) { Object eventSource = event.getSource (); // ---------------------------------------------------- // create shortcut for the current user was selected // refresh the list of program groups accordingly and // reset the program group to the default setting. // ---------------------------------------------------- if (eventSource.equals (currentUser)) { groupList.setListData (shortcut.getProgramGroups (Shortcut.CURRENT_USER)); programGroup.setText (suggestedProgramGroup); shortcut.setUserType (Shortcut.CURRENT_USER); } // ---------------------------------------------------- // create shortcut for all users was selected // refresh the list of program groups accordingly and // reset the program group to the default setting. // ---------------------------------------------------- else if (eventSource.equals (allUsers)) { groupList.setListData (shortcut.getProgramGroups (Shortcut.ALL_USERS)); programGroup.setText (suggestedProgramGroup); shortcut.setUserType (Shortcut.ALL_USERS); } // ---------------------------------------------------- // The create button was pressed. // go ahead and create the shortcut(s) // ---------------------------------------------------- else if (eventSource.equals (createButton)) { try { groupName = programGroup.getText (); } catch (Throwable exception) { groupName = ""; } createShortcuts (); // add files and directories to the uninstaller addToUninstaller (); // Disables the createButton createButton.setEnabled(false); // when finished unlock the next button and lock // the previous button //parent.unlockNextButton (); parent.lockPrevButton (); } // ---------------------------------------------------- // The reset button was pressed. // - clear the selection in the list box, because the // selection is no longer valid // - refill the program group edit control with the // suggested program group name // ---------------------------------------------------- else if (eventSource.equals (defaultButton)) { groupList.getSelectionModel ().clearSelection (); programGroup.setText (suggestedProgramGroup); } // ---------------------------------------------------- // the save button was pressed. This is a request to // save shortcut information to a text file. // ---------------------------------------------------- else if (eventSource.equals (saveButton)) { saveToFile (); // add the file to the uninstaller addToUninstaller (); } }
public void actionPerformed (ActionEvent event) { Object eventSource = event.getSource (); // ---------------------------------------------------- // create shortcut for the current user was selected // refresh the list of program groups accordingly and // reset the program group to the default setting. // ---------------------------------------------------- if (eventSource.equals (currentUser)) { groupList.setListData (shortcut.getProgramGroups (Shortcut.CURRENT_USER)); programGroup.setText (suggestedProgramGroup); shortcut.setUserType (Shortcut.CURRENT_USER); } // ---------------------------------------------------- // create shortcut for all users was selected // refresh the list of program groups accordingly and // reset the program group to the default setting. // ---------------------------------------------------- else if (eventSource.equals (allUsers)) { groupList.setListData (shortcut.getProgramGroups (Shortcut.ALL_USERS)); programGroup.setText (suggestedProgramGroup); shortcut.setUserType (Shortcut.ALL_USERS); } // ---------------------------------------------------- // The create button was pressed. // go ahead and create the shortcut(s) // ---------------------------------------------------- else if (eventSource.equals (createButton)) { try { groupName = programGroup.getText (); } catch (Throwable exception) { groupName = ""; } createShortcuts (); // add files and directories to the uninstaller addToUninstaller (); // Disables the createButton // when finished unlock the next button and lock // the previous button //parent.unlockNextButton (); parent.lockPrevButton (); } // ---------------------------------------------------- // The reset button was pressed. // - clear the selection in the list box, because the // selection is no longer valid // - refill the program group edit control with the // suggested program group name // ---------------------------------------------------- else if (eventSource.equals (defaultButton)) { groupList.getSelectionModel ().clearSelection (); programGroup.setText (suggestedProgramGroup); } // ---------------------------------------------------- // the save button was pressed. This is a request to // save shortcut information to a text file. // ---------------------------------------------------- else if (eventSource.equals (saveButton)) { saveToFile (); // add the file to the uninstaller addToUninstaller (); } }
3,241,316
public void actionPerformed (ActionEvent event) { Object eventSource = event.getSource (); // ---------------------------------------------------- // create shortcut for the current user was selected // refresh the list of program groups accordingly and // reset the program group to the default setting. // ---------------------------------------------------- if (eventSource.equals (currentUser)) { groupList.setListData (shortcut.getProgramGroups (Shortcut.CURRENT_USER)); programGroup.setText (suggestedProgramGroup); shortcut.setUserType (Shortcut.CURRENT_USER); } // ---------------------------------------------------- // create shortcut for all users was selected // refresh the list of program groups accordingly and // reset the program group to the default setting. // ---------------------------------------------------- else if (eventSource.equals (allUsers)) { groupList.setListData (shortcut.getProgramGroups (Shortcut.ALL_USERS)); programGroup.setText (suggestedProgramGroup); shortcut.setUserType (Shortcut.ALL_USERS); } // ---------------------------------------------------- // The create button was pressed. // go ahead and create the shortcut(s) // ---------------------------------------------------- else if (eventSource.equals (createButton)) { try { groupName = programGroup.getText (); } catch (Throwable exception) { groupName = ""; } createShortcuts (); // add files and directories to the uninstaller addToUninstaller (); // Disables the createButton createButton.setEnabled(false); // when finished unlock the next button and lock // the previous button //parent.unlockNextButton (); parent.lockPrevButton (); } // ---------------------------------------------------- // The reset button was pressed. // - clear the selection in the list box, because the // selection is no longer valid // - refill the program group edit control with the // suggested program group name // ---------------------------------------------------- else if (eventSource.equals (defaultButton)) { groupList.getSelectionModel ().clearSelection (); programGroup.setText (suggestedProgramGroup); } // ---------------------------------------------------- // the save button was pressed. This is a request to // save shortcut information to a text file. // ---------------------------------------------------- else if (eventSource.equals (saveButton)) { saveToFile (); // add the file to the uninstaller addToUninstaller (); } }
parent.unlockNextButton (); parent.unlockNextButton (); publicparent.unlockNextButton (); voidparent.unlockNextButton (); actionPerformedparent.unlockNextButton (); (ActionEventparent.unlockNextButton (); event)parent.unlockNextButton (); parent.unlockNextButton (); {parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); Objectparent.unlockNextButton (); eventSourceparent.unlockNextButton (); =parent.unlockNextButton (); event.getSourceparent.unlockNextButton (); ();parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); //parent.unlockNextButton (); ----------------------------------------------------parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); //parent.unlockNextButton (); createparent.unlockNextButton (); shortcutparent.unlockNextButton (); forparent.unlockNextButton (); theparent.unlockNextButton (); currentparent.unlockNextButton (); userparent.unlockNextButton (); wasparent.unlockNextButton (); selectedparent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); //parent.unlockNextButton (); refreshparent.unlockNextButton (); theparent.unlockNextButton (); listparent.unlockNextButton (); ofparent.unlockNextButton (); programparent.unlockNextButton (); groupsparent.unlockNextButton (); accordinglyparent.unlockNextButton (); andparent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); //parent.unlockNextButton (); resetparent.unlockNextButton (); theparent.unlockNextButton (); programparent.unlockNextButton (); groupparent.unlockNextButton (); toparent.unlockNextButton (); theparent.unlockNextButton (); defaultparent.unlockNextButton (); setting.parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); //parent.unlockNextButton (); ----------------------------------------------------parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); ifparent.unlockNextButton (); (eventSource.equalsparent.unlockNextButton (); (currentUser))parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); {parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); groupList.setListDataparent.unlockNextButton (); (shortcut.getProgramGroupsparent.unlockNextButton (); (Shortcut.CURRENT_USER));parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); programGroup.setTextparent.unlockNextButton (); parent.unlockNextButton (); (suggestedProgramGroup);parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); shortcut.setUserTypeparent.unlockNextButton (); parent.unlockNextButton (); (Shortcut.CURRENT_USER);parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); }parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); //parent.unlockNextButton (); ----------------------------------------------------parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); //parent.unlockNextButton (); createparent.unlockNextButton (); shortcutparent.unlockNextButton (); forparent.unlockNextButton (); allparent.unlockNextButton (); usersparent.unlockNextButton (); wasparent.unlockNextButton (); selectedparent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); //parent.unlockNextButton (); refreshparent.unlockNextButton (); theparent.unlockNextButton (); listparent.unlockNextButton (); ofparent.unlockNextButton (); programparent.unlockNextButton (); groupsparent.unlockNextButton (); accordinglyparent.unlockNextButton (); andparent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); //parent.unlockNextButton (); resetparent.unlockNextButton (); theparent.unlockNextButton (); programparent.unlockNextButton (); groupparent.unlockNextButton (); toparent.unlockNextButton (); theparent.unlockNextButton (); defaultparent.unlockNextButton (); setting.parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); //parent.unlockNextButton (); ----------------------------------------------------parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); elseparent.unlockNextButton (); ifparent.unlockNextButton (); (eventSource.equalsparent.unlockNextButton (); (allUsers))parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); {parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); groupList.setListDataparent.unlockNextButton (); (shortcut.getProgramGroupsparent.unlockNextButton (); (Shortcut.ALL_USERS));parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); programGroup.setTextparent.unlockNextButton (); parent.unlockNextButton (); (suggestedProgramGroup);parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); shortcut.setUserTypeparent.unlockNextButton (); parent.unlockNextButton (); (Shortcut.ALL_USERS);parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); }parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); //parent.unlockNextButton (); ----------------------------------------------------parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); //parent.unlockNextButton (); Theparent.unlockNextButton (); createparent.unlockNextButton (); buttonparent.unlockNextButton (); wasparent.unlockNextButton (); pressed.parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); //parent.unlockNextButton (); goparent.unlockNextButton (); aheadparent.unlockNextButton (); andparent.unlockNextButton (); createparent.unlockNextButton (); theparent.unlockNextButton (); shortcut(s)parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); //parent.unlockNextButton (); ----------------------------------------------------parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); elseparent.unlockNextButton (); ifparent.unlockNextButton (); (eventSource.equalsparent.unlockNextButton (); (createButton))parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); {parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); tryparent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); {parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); groupNameparent.unlockNextButton (); =parent.unlockNextButton (); programGroup.getTextparent.unlockNextButton (); ();parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); }parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); catchparent.unlockNextButton (); (Throwableparent.unlockNextButton (); exception)parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); {parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); groupNameparent.unlockNextButton (); =parent.unlockNextButton (); "";parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); }parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); createShortcutsparent.unlockNextButton (); ();parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); //parent.unlockNextButton (); addparent.unlockNextButton (); filesparent.unlockNextButton (); andparent.unlockNextButton (); directoriesparent.unlockNextButton (); toparent.unlockNextButton (); theparent.unlockNextButton (); uninstallerparent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); addToUninstallerparent.unlockNextButton (); ();parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); //parent.unlockNextButton (); Disablesparent.unlockNextButton (); theparent.unlockNextButton (); createButtonparent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); createButton.setEnabled(false);parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); //parent.unlockNextButton (); whenparent.unlockNextButton (); finishedparent.unlockNextButton (); unlockparent.unlockNextButton (); theparent.unlockNextButton (); nextparent.unlockNextButton (); buttonparent.unlockNextButton (); andparent.unlockNextButton (); lockparent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); //parent.unlockNextButton (); theparent.unlockNextButton (); previousparent.unlockNextButton (); buttonparent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); //parent.unlockNextButtonparent.unlockNextButton (); ();parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.lockPrevButtonparent.unlockNextButton (); ();parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); }parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); //parent.unlockNextButton (); ----------------------------------------------------parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); //parent.unlockNextButton (); Theparent.unlockNextButton (); resetparent.unlockNextButton (); buttonparent.unlockNextButton (); wasparent.unlockNextButton (); pressed.parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); //parent.unlockNextButton (); -parent.unlockNextButton (); clearparent.unlockNextButton (); theparent.unlockNextButton (); selectionparent.unlockNextButton (); inparent.unlockNextButton (); theparent.unlockNextButton (); listparent.unlockNextButton (); box,parent.unlockNextButton (); becauseparent.unlockNextButton (); theparent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); //parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); selectionparent.unlockNextButton (); isparent.unlockNextButton (); noparent.unlockNextButton (); longerparent.unlockNextButton (); validparent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); //parent.unlockNextButton (); -parent.unlockNextButton (); refillparent.unlockNextButton (); theparent.unlockNextButton (); programparent.unlockNextButton (); groupparent.unlockNextButton (); editparent.unlockNextButton (); controlparent.unlockNextButton (); withparent.unlockNextButton (); theparent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); //parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); suggestedparent.unlockNextButton (); programparent.unlockNextButton (); groupparent.unlockNextButton (); nameparent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); //parent.unlockNextButton (); ----------------------------------------------------parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); elseparent.unlockNextButton (); ifparent.unlockNextButton (); (eventSource.equalsparent.unlockNextButton (); (defaultButton))parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); {parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); groupList.getSelectionModelparent.unlockNextButton (); ().clearSelectionparent.unlockNextButton (); ();parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); programGroup.setTextparent.unlockNextButton (); (suggestedProgramGroup);parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); }parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); //parent.unlockNextButton (); ----------------------------------------------------parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); //parent.unlockNextButton (); theparent.unlockNextButton (); saveparent.unlockNextButton (); buttonparent.unlockNextButton (); wasparent.unlockNextButton (); pressed.parent.unlockNextButton (); Thisparent.unlockNextButton (); isparent.unlockNextButton (); aparent.unlockNextButton (); requestparent.unlockNextButton (); toparent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); //parent.unlockNextButton (); saveparent.unlockNextButton (); shortcutparent.unlockNextButton (); informationparent.unlockNextButton (); toparent.unlockNextButton (); aparent.unlockNextButton (); textparent.unlockNextButton (); file.parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); //parent.unlockNextButton (); ----------------------------------------------------parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); elseparent.unlockNextButton (); ifparent.unlockNextButton (); (eventSource.equalsparent.unlockNextButton (); (saveButton))parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); {parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); saveToFileparent.unlockNextButton (); ();parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); //parent.unlockNextButton (); addparent.unlockNextButton (); theparent.unlockNextButton (); fileparent.unlockNextButton (); toparent.unlockNextButton (); theparent.unlockNextButton (); uninstallerparent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); addToUninstallerparent.unlockNextButton (); ();parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); parent.unlockNextButton (); }parent.unlockNextButton (); parent.unlockNextButton (); }
3,241,317
private void analyzeShortcutSpec () { if (!haveShortcutSpec) { shortcutsToCreate = false; return; } // ---------------------------------------------------- // find out if we should simulate a not supported // scenario // ---------------------------------------------------- XMLElement support = spec.getFirstChildNamed (SPEC_KEY_NOT_SUPPORTED); if (support != null) { simulteNotSupported = true; } // ---------------------------------------------------- // find out in which program group the shortcuts should // be placed and where this program group should be // located // ---------------------------------------------------- XMLElement group = spec.getFirstChildNamed (SPEC_KEY_PROGRAM_GROUP); String location = null; hasDesktopShortcuts = false; if (group != null) { suggestedProgramGroup = group.getAttribute (SPEC_ATTRIBUTE_DEFAULT_GROUP, ""); location = group.getAttribute (SPEC_ATTRIBUTE_LOCATION, SPEC_VALUE_APPLICATIONS); } else { suggestedProgramGroup = ""; location = SPEC_VALUE_APPLICATIONS; } if (location.equals (SPEC_VALUE_APPLICATIONS)) { groupLocation = Shortcut.APPLICATIONS; } else if (location.equals (SPEC_VALUE_START_MENU)) { groupLocation = Shortcut.START_MENU; } // ---------------------------------------------------- // create a list of all shortcuts that need to be // created, containing all details about each shortcut // ---------------------------------------------------- VariableSubstitutor substitutor = new VariableSubstitutor (idata.getVariableValueMap ()); String temp; Vector shortcutSpecs = spec.getChildrenNamed (SPEC_KEY_SHORTCUT); XMLElement shortcutSpec; ShortcutData data; for (int i = 0; i < shortcutSpecs.size (); i++) { shortcutSpec = (XMLElement)shortcutSpecs.elementAt (i); data = new ShortcutData (); data.addToGroup = false; data.name = shortcutSpec.getAttribute (SPEC_ATTRIBUTE_NAME); data.subgroup = shortcutSpec.getAttribute (SPEC_ATTRIBUTE_SUBGROUP); data.description = shortcutSpec.getAttribute (SPEC_ATTRIBUTE_DESCRIPTION, ""); temp = fixSeparatorChar (shortcutSpec.getAttribute (SPEC_ATTRIBUTE_TARGET, "")); data.target = substitutor.substitute (temp, null); temp = shortcutSpec.getAttribute (SPEC_ATTRIBUTE_COMMAND, ""); data.commandLine = substitutor.substitute (temp, null); temp = fixSeparatorChar (shortcutSpec.getAttribute (SPEC_ATTRIBUTE_ICON, "")); data.iconFile = substitutor.substitute (temp, null); data.iconIndex = Integer.parseInt (shortcutSpec.getAttribute (SPEC_ATTRIBUTE_ICON_INDEX, "0")); temp = fixSeparatorChar (shortcutSpec.getAttribute (SPEC_ATTRIBUTE_WORKING_DIR, "")); data.workingDirectory = substitutor.substitute (temp, null); String initialState = shortcutSpec.getAttribute (SPEC_ATTRIBUTE_INITIAL_STATE, ""); if (initialState.equals (SPEC_VALUE_NO_SHOW)) { data.initialState = Shortcut.HIDE; } else if (initialState.equals (SPEC_VALUE_NORMAL)) { data.initialState = Shortcut.NORMAL; } else if (initialState.equals (SPEC_VALUE_MAXIMIZED)) { data.initialState = Shortcut.MAXIMIZED; } else if (initialState.equals (SPEC_VALUE_MINIMIZED)) { data.initialState = Shortcut.MINIMIZED; } else { data.initialState = Shortcut.NORMAL; } // -------------------------------------------------- // if the minimal data requirements are met to create // the shortcut, create one entry each for each of // the requested types. // Eventually this will cause the creation of one // shortcut in each of the associated locations. // -------------------------------------------------- // without a name we can not create a shortcut if (data.name == null) { continue; } // without a target we can not create a shortcut if (data.target == null) { continue; } // the shortcut is not actually required for any of the selected packs Vector forPacks = shortcutSpec.getChildrenNamed (SPEC_KEY_PACKS); if (!shortcutRequiredFor (forPacks)) { continue; } // -------------------------------------------------- // This section is executed if we don't skip. // -------------------------------------------------- // For each of the categories set the type and if // the link should be placed in the program group, // then clone the data set to obtain an independent // instance and add this to the list of shortcuts // to be created. In this way, we will set up an // identical copy for each of the locations at which // a shortcut should be placed. Therefore you must // not use 'else if' statements! // -------------------------------------------------- { if (attributeIsTrue (shortcutSpec, SPEC_ATTRIBUTE_DESKTOP)) { hasDesktopShortcuts = true; data.type = Shortcut.DESKTOP; shortcuts.add (data.clone ()); } if (attributeIsTrue (shortcutSpec, SPEC_ATTRIBUTE_APPLICATIONS)) { data.type = Shortcut.APPLICATIONS; shortcuts.add (data.clone ()); } if (attributeIsTrue (shortcutSpec, SPEC_ATTRIBUTE_START_MENU)) { data.type = Shortcut.START_MENU; shortcuts.add (data.clone ()); } if (attributeIsTrue (shortcutSpec, SPEC_ATTRIBUTE_STARTUP)) { data.type = Shortcut.START_UP; shortcuts.add (data.clone ()); } if (attributeIsTrue (shortcutSpec, SPEC_ATTRIBUTE_PROGRAM_GROUP)) { data.addToGroup = true; data.type = Shortcut.APPLICATIONS; shortcuts.add (data.clone ()); } } } // ---------------------------------------------------- // signal if there are any shortcuts to create // ---------------------------------------------------- if (shortcuts.size () > 0) { shortcutsToCreate = true; } }
private void analyzeShortcutSpec () { if (!haveShortcutSpec) { shortcutsToCreate = false; return; } // ---------------------------------------------------- // find out if we should simulate a not supported // scenario // ---------------------------------------------------- XMLElement support = spec.getFirstChildNamed (SPEC_KEY_NOT_SUPPORTED); if (support != null) { simulteNotSupported = true; } // ---------------------------------------------------- // find out in which program group the shortcuts should // be placed and where this program group should be // located // ---------------------------------------------------- XMLElement group = spec.getFirstChildNamed (SPEC_KEY_PROGRAM_GROUP); String location = null; hasDesktopShortcuts = false; if (group != null) { suggestedProgramGroup = group.getAttribute (SPEC_ATTRIBUTE_DEFAULT_GROUP, ""); location = group.getAttribute (SPEC_ATTRIBUTE_LOCATION, SPEC_VALUE_APPLICATIONS); } else { suggestedProgramGroup = ""; location = SPEC_VALUE_APPLICATIONS; } if (location.equals (SPEC_VALUE_APPLICATIONS)) { groupLocation = Shortcut.APPLICATIONS; } else if (location.equals (SPEC_VALUE_START_MENU)) { groupLocation = Shortcut.START_MENU; } // ---------------------------------------------------- // create a list of all shortcuts that need to be // created, containing all details about each shortcut // ---------------------------------------------------- VariableSubstitutor substitutor = new VariableSubstitutor (idata.getVariableValueMap ()); String temp; Vector shortcutSpecs = spec.getChildrenNamed (SPEC_KEY_SHORTCUT); XMLElement shortcutSpec; ShortcutData data; for (int i = 0; i < shortcutSpecs.size (); i++) { shortcutSpec = (XMLElement)shortcutSpecs.elementAt (i); data = new ShortcutData (); data.name = shortcutSpec.getAttribute (SPEC_ATTRIBUTE_NAME); data.subgroup = shortcutSpec.getAttribute (SPEC_ATTRIBUTE_SUBGROUP); data.description = shortcutSpec.getAttribute (SPEC_ATTRIBUTE_DESCRIPTION, ""); temp = fixSeparatorChar (shortcutSpec.getAttribute (SPEC_ATTRIBUTE_TARGET, "")); data.target = substitutor.substitute (temp, null); temp = shortcutSpec.getAttribute (SPEC_ATTRIBUTE_COMMAND, ""); data.commandLine = substitutor.substitute (temp, null); temp = fixSeparatorChar (shortcutSpec.getAttribute (SPEC_ATTRIBUTE_ICON, "")); data.iconFile = substitutor.substitute (temp, null); data.iconIndex = Integer.parseInt (shortcutSpec.getAttribute (SPEC_ATTRIBUTE_ICON_INDEX, "0")); temp = fixSeparatorChar (shortcutSpec.getAttribute (SPEC_ATTRIBUTE_WORKING_DIR, "")); data.workingDirectory = substitutor.substitute (temp, null); String initialState = shortcutSpec.getAttribute (SPEC_ATTRIBUTE_INITIAL_STATE, ""); if (initialState.equals (SPEC_VALUE_NO_SHOW)) { data.initialState = Shortcut.HIDE; } else if (initialState.equals (SPEC_VALUE_NORMAL)) { data.initialState = Shortcut.NORMAL; } else if (initialState.equals (SPEC_VALUE_MAXIMIZED)) { data.initialState = Shortcut.MAXIMIZED; } else if (initialState.equals (SPEC_VALUE_MINIMIZED)) { data.initialState = Shortcut.MINIMIZED; } else { data.initialState = Shortcut.NORMAL; } // -------------------------------------------------- // if the minimal data requirements are met to create // the shortcut, create one entry each for each of // the requested types. // Eventually this will cause the creation of one // shortcut in each of the associated locations. // -------------------------------------------------- // without a name we can not create a shortcut if (data.name == null) { continue; } // without a target we can not create a shortcut if (data.target == null) { continue; } // the shortcut is not actually required for any of the selected packs Vector forPacks = shortcutSpec.getChildrenNamed (SPEC_KEY_PACKS); if (!shortcutRequiredFor (forPacks)) { continue; } // -------------------------------------------------- // This section is executed if we don't skip. // -------------------------------------------------- // For each of the categories set the type and if // the link should be placed in the program group, // then clone the data set to obtain an independent // instance and add this to the list of shortcuts // to be created. In this way, we will set up an // identical copy for each of the locations at which // a shortcut should be placed. Therefore you must // not use 'else if' statements! // -------------------------------------------------- { if (attributeIsTrue (shortcutSpec, SPEC_ATTRIBUTE_DESKTOP)) { hasDesktopShortcuts = true; data.type = Shortcut.DESKTOP; shortcuts.add (data.clone ()); } if (attributeIsTrue (shortcutSpec, SPEC_ATTRIBUTE_APPLICATIONS)) { data.type = Shortcut.APPLICATIONS; shortcuts.add (data.clone ()); } if (attributeIsTrue (shortcutSpec, SPEC_ATTRIBUTE_START_MENU)) { data.type = Shortcut.START_MENU; shortcuts.add (data.clone ()); } if (attributeIsTrue (shortcutSpec, SPEC_ATTRIBUTE_STARTUP)) { data.type = Shortcut.START_UP; shortcuts.add (data.clone ()); } if (attributeIsTrue (shortcutSpec, SPEC_ATTRIBUTE_PROGRAM_GROUP)) { data.addToGroup = true; data.type = Shortcut.APPLICATIONS; shortcuts.add (data.clone ()); } } } // ---------------------------------------------------- // signal if there are any shortcuts to create // ---------------------------------------------------- if (shortcuts.size () > 0) { shortcutsToCreate = true; } }
3,241,318
private void createShortcuts () { ShortcutData data; for (int i = 0; i < shortcuts.size (); i++) { data = (ShortcutData)shortcuts.elementAt (i); try { groupName = groupName + data.subgroup; shortcut.setLinkName (data.name); shortcut.setLinkType (data.type); shortcut.setArguments (data.commandLine); shortcut.setDescription (data.description); shortcut.setIconLocation (data.iconFile, data.iconIndex); shortcut.setShowCommand (data.initialState); shortcut.setTargetPath (data.target); shortcut.setWorkingDirectory (data.workingDirectory); if (data.addToGroup) { shortcut.setProgramGroup (groupName); } else { shortcut.setProgramGroup (""); } try { // ---------------------------------------------- // save the shortcut only if it is either not on // the desktop or if it is on the desktop and // the user has signalled that it is ok to place // shortcuts on the desktop. // ---------------------------------------------- if ( (data.type != Shortcut.DESKTOP) || ((data.type == Shortcut.DESKTOP) && allowDesktopShortcut.isSelected ()) ) { // save the shortcut shortcut.save (); // add the file and directory name to the file list String fileName = shortcut.getFileName (); String directoryName = shortcut.getDirectoryCreated (); files.add (fileName); if (!(directoryName == null)) { files.add (directoryName); } } } catch (Exception exception) { } } catch (Throwable exception) { continue; } } //parent.unlockNextButton(); shortcutsCreationDone = true; }
private void createShortcuts () { ShortcutData data; for (int i = 0; i < shortcuts.size (); i++) { data = (ShortcutData)shortcuts.elementAt (i); try { groupName = groupName + data.subgroup; shortcut.setLinkName (data.name); shortcut.setLinkType (data.type); shortcut.setArguments (data.commandLine); shortcut.setDescription (data.description); shortcut.setIconLocation (data.iconFile, data.iconIndex); shortcut.setShowCommand (data.initialState); shortcut.setTargetPath (data.target); shortcut.setWorkingDirectory (data.workingDirectory); if (data.addToGroup) { shortcut.setProgramGroup (groupName); } else { shortcut.setProgramGroup (""); } try { // ---------------------------------------------- // save the shortcut only if it is either not on // the desktop or if it is on the desktop and // the user has signalled that it is ok to place // shortcuts on the desktop. // ---------------------------------------------- if ( (data.type != Shortcut.DESKTOP) || ((data.type == Shortcut.DESKTOP) && allowDesktopShortcut.isSelected ()) ) { // save the shortcut shortcut.save (); // add the file and directory name to the file list String fileName = shortcut.getFileName (); String directoryName = shortcut.getDirectoryCreated (); files.add (fileName); if (!(directoryName == null)) { files.add (directoryName); } } } catch (Exception exception) { } } catch (Throwable exception) { continue; } } //parent.unlockNextButton(); parent.unlockNextButton(); }
3,241,320
public void makeXMLData (XMLElement panelRoot) { // ---------------------------------------------------- // if there are no shortcuts to create, shortcuts are // not supported, or we should simulate that they are // not supported, then we have nothing to add. Just // return // ---------------------------------------------------- if (!shortcutsToCreate || !shortcut.supported () || !shortcutsCreationDone || simulteNotSupported ) { return; } ShortcutData data; XMLElement dataElement; // ---------------------------------------------------- // add the item that defines the name of the program group // ---------------------------------------------------- dataElement = new XMLElement (AUTO_KEY_PROGRAM_GROUP); dataElement.setAttribute (AUTO_ATTRIBUTE_NAME, groupName); panelRoot.addChild (dataElement); // ---------------------------------------------------- // add the details for each of the shortcuts // ---------------------------------------------------- for (int i = 0; i < shortcuts.size (); i++) { data = (ShortcutData)shortcuts.elementAt (i); dataElement = new XMLElement (AUTO_KEY_SHORTCUT); dataElement.setAttribute (AUTO_ATTRIBUTE_NAME, data.name); dataElement.setAttribute (AUTO_ATTRIBUTE_GROUP, new Boolean (data.addToGroup).toString ()); dataElement.setAttribute (AUTO_ATTRIBUTE_TYPE, Integer.toString (data.type)); dataElement.setAttribute (AUTO_ATTRIBUTE_COMMAND, data.commandLine); dataElement.setAttribute (AUTO_ATTRIBUTE_DESCRIPTION, data.description); dataElement.setAttribute (AUTO_ATTRIBUTE_ICON, data.iconFile); dataElement.setAttribute (AUTO_ATTRIBUTE_ICON_INDEX, Integer.toString (data.iconIndex)); dataElement.setAttribute (AUTO_ATTRIBUTE_INITIAL_STATE, Integer.toString (data.initialState)); dataElement.setAttribute (AUTO_ATTRIBUTE_TARGET, data.target); dataElement.setAttribute (AUTO_ATTRIBUTE_WORKING_DIR, data.workingDirectory); // ---------------------------------------------- // add the shortcut only if it is either not on // the desktop or if it is on the desktop and // the user has signalled that it is ok to place // shortcuts on the desktop. // ---------------------------------------------- if ( (data.type != Shortcut.DESKTOP) || ((data.type == Shortcut.DESKTOP) && allowDesktopShortcut.isSelected ()) ) { panelRoot.addChild (dataElement); } } }
public void makeXMLData (XMLElement panelRoot) { // ---------------------------------------------------- // if there are no shortcuts to create, shortcuts are // not supported, or we should simulate that they are // not supported, then we have nothing to add. Just // return // ---------------------------------------------------- if (!shortcutsToCreate || !shortcut.supported () || simulteNotSupported ) { return; } ShortcutData data; XMLElement dataElement; // ---------------------------------------------------- // add the item that defines the name of the program group // ---------------------------------------------------- dataElement = new XMLElement (AUTO_KEY_PROGRAM_GROUP); dataElement.setAttribute (AUTO_ATTRIBUTE_NAME, groupName); panelRoot.addChild (dataElement); // ---------------------------------------------------- // add the details for each of the shortcuts // ---------------------------------------------------- for (int i = 0; i < shortcuts.size (); i++) { data = (ShortcutData)shortcuts.elementAt (i); dataElement = new XMLElement (AUTO_KEY_SHORTCUT); dataElement.setAttribute (AUTO_ATTRIBUTE_NAME, data.name); dataElement.setAttribute (AUTO_ATTRIBUTE_GROUP, new Boolean (data.addToGroup).toString ()); dataElement.setAttribute (AUTO_ATTRIBUTE_TYPE, Integer.toString (data.type)); dataElement.setAttribute (AUTO_ATTRIBUTE_COMMAND, data.commandLine); dataElement.setAttribute (AUTO_ATTRIBUTE_DESCRIPTION, data.description); dataElement.setAttribute (AUTO_ATTRIBUTE_ICON, data.iconFile); dataElement.setAttribute (AUTO_ATTRIBUTE_ICON_INDEX, Integer.toString (data.iconIndex)); dataElement.setAttribute (AUTO_ATTRIBUTE_INITIAL_STATE, Integer.toString (data.initialState)); dataElement.setAttribute (AUTO_ATTRIBUTE_TARGET, data.target); dataElement.setAttribute (AUTO_ATTRIBUTE_WORKING_DIR, data.workingDirectory); // ---------------------------------------------- // add the shortcut only if it is either not on // the desktop or if it is on the desktop and // the user has signalled that it is ok to place // shortcuts on the desktop. // ---------------------------------------------- if ( (data.type != Shortcut.DESKTOP) || ((data.type == Shortcut.DESKTOP) && allowDesktopShortcut.isSelected ()) ) { panelRoot.addChild (dataElement); } } }
3,241,321
public void panelActivate () { analyzeShortcutSpec (); if (shortcutsToCreate) { if (shortcut.supported () && !simulteNotSupported) { //parent.lockNextButton (); buildUI (shortcut.getProgramGroups (ShellLink.CURRENT_USER), true); // always start out with the current user } else { buildAlternateUI (); parent.unlockNextButton (); parent.lockPrevButton (); } } else { parent.skipPanel (); } }
parent.lockNextButton (); parent.lockNextButton (); publicparent.lockNextButton (); voidparent.lockNextButton (); panelActivateparent.lockNextButton (); ()parent.lockNextButton (); parent.lockNextButton (); {parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); analyzeShortcutSpecparent.lockNextButton (); ();parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); ifparent.lockNextButton (); (shortcutsToCreate)parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); {parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); ifparent.lockNextButton (); (shortcut.supportedparent.lockNextButton (); ()parent.lockNextButton (); &&parent.lockNextButton (); !simulteNotSupported)parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); {parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); //parent.lockNextButtonparent.lockNextButton (); ();parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); buildUIparent.lockNextButton (); (shortcut.getProgramGroupsparent.lockNextButton (); (ShellLink.CURRENT_USER),parent.lockNextButton (); true);parent.lockNextButton (); parent.lockNextButton (); //parent.lockNextButton (); alwaysparent.lockNextButton (); startparent.lockNextButton (); outparent.lockNextButton (); withparent.lockNextButton (); theparent.lockNextButton (); currentparent.lockNextButton (); userparent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); }parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); elseparent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); {parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); buildAlternateUIparent.lockNextButton (); ();parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.unlockNextButtonparent.lockNextButton (); ();parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockPrevButtonparent.lockNextButton (); ();parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); }parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); }parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); elseparent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); {parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.skipPanelparent.lockNextButton (); ();parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); parent.lockNextButton (); }parent.lockNextButton (); parent.lockNextButton (); }
3,241,322
public XInfoPanel(InstallerFrame parent, InstallData idata) { super(parent, idata); // We initialize our layout layout = new GridBagLayout(); gbConstraints = new GridBagConstraints(); setLayout(layout); // We add the components infoLabel = LabelFactory.create(parent.langpack.getString("InfoPanel.info"), parent.icons .getImageIcon("edit"), JLabel.TRAILING); parent.buildConstraints(gbConstraints, 0, 0, 1, 1, 1.0, 0.0); gbConstraints.insets = new Insets(5, 5, 5, 5); gbConstraints.fill = GridBagConstraints.BOTH; gbConstraints.anchor = GridBagConstraints.SOUTHWEST; layout.addLayoutComponent(infoLabel, gbConstraints); add(infoLabel); textArea = new JTextArea(); textArea.setEditable(false); JScrollPane scroller = new JScrollPane(textArea); parent.buildConstraints(gbConstraints, 0, 1, 1, 1, 1.0, 0.9); gbConstraints.anchor = GridBagConstraints.CENTER; layout.addLayoutComponent(scroller, gbConstraints); add(scroller); }
public XInfoPanel(InstallerFrame parent, InstallData idata) { super(parent, idata); // We initialize our layout layout = new GridBagLayout(); gbConstraints = new GridBagConstraints(); setLayout(layout); // We add the components infoLabel = LabelFactory.create(parent.langpack.getString("InfoPanel.info"), parent.icons .getImageIcon("edit"), JLabel.TRAILING); parent.buildConstraints(gbConstraints, 0, 0, 1, 1, 1.0, 0.0); gbConstraints.insets = new Insets(5, 5, 5, 5); gbConstraints.fill = GridBagConstraints.BOTH; gbConstraints.anchor = GridBagConstraints.SOUTHWEST; layout.addLayoutComponent(infoLabel, gbConstraints); add(infoLabel); textArea = new JTextArea(); textArea.setEditable(false); JScrollPane scroller = new JScrollPane(textArea); parent.buildConstraints(gbConstraints, 0, 1, 1, 1, 1.0, 0.9); gbConstraints.anchor = GridBagConstraints.CENTER; layout.addLayoutComponent(scroller, gbConstraints); add(scroller); }
3,241,323
public XInfoPanel(InstallerFrame parent, InstallData idata) { super(parent, idata); // We initialize our layout layout = new GridBagLayout(); gbConstraints = new GridBagConstraints(); setLayout(layout); // We add the components infoLabel = LabelFactory.create(parent.langpack.getString("InfoPanel.info"), parent.icons .getImageIcon("edit"), JLabel.TRAILING); parent.buildConstraints(gbConstraints, 0, 0, 1, 1, 1.0, 0.0); gbConstraints.insets = new Insets(5, 5, 5, 5); gbConstraints.fill = GridBagConstraints.BOTH; gbConstraints.anchor = GridBagConstraints.SOUTHWEST; layout.addLayoutComponent(infoLabel, gbConstraints); add(infoLabel); textArea = new JTextArea(); textArea.setEditable(false); JScrollPane scroller = new JScrollPane(textArea); parent.buildConstraints(gbConstraints, 0, 1, 1, 1, 1.0, 0.9); gbConstraints.anchor = GridBagConstraints.CENTER; layout.addLayoutComponent(scroller, gbConstraints); add(scroller); }
public XInfoPanel(InstallerFrame parent, InstallData idata) { super(parent, idata); // We initialize our layout layout = new GridBagLayout(); gbConstraints = new GridBagConstraints(); setLayout(layout); // We add the components JLabel infoLabel = LabelFactory.create(parent.langpack.getString("InfoPanel.info"), parent.icons .getImageIcon("edit"), JLabel.TRAILING); parent.buildConstraints(gbConstraints, 0, 0, 1, 1, 1.0, 0.0); gbConstraints.insets = new Insets(5, 5, 5, 5); gbConstraints.fill = GridBagConstraints.BOTH; gbConstraints.anchor = GridBagConstraints.SOUTHWEST; layout.addLayoutComponent(infoLabel, gbConstraints); add(infoLabel); textArea = new JTextArea(); textArea.setEditable(false); JScrollPane scroller = new JScrollPane(textArea); parent.buildConstraints(gbConstraints, 0, 1, 1, 1, 1.0, 0.9); gbConstraints.anchor = GridBagConstraints.CENTER; layout.addLayoutComponent(scroller, gbConstraints); add(scroller); }
3,241,324
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { // We avoid that the icon is gray while the combo isn't deployed if (index == -1) isSelected = true; // We put the label String iso3 = (String) value; setText(iso3); if (isSelected) { if (lnf.equalsIgnoreCase("swing")) setOpaque(true); else if (index == -1) setOpaque(false); else setOpaque(true); setForeground(list.getSelectionForeground()); setBackground(list.getSelectionBackground()); } else setOpaque(false); // We put the icon if (!icons.containsKey(iso3)) { ImageIcon icon = new ImageIcon(this.getClass().getResource("/res/flag." + iso3)); icons.put(iso3, icon); grayIcons.put(iso3, new ImageIcon(GrayFilter.createDisabledImage(icon.getImage()))); } if (isSelected) setIcon((ImageIcon) icons.get(iso3)); else setIcon((ImageIcon) grayIcons.get(iso3)); // We return return this; }
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { // We avoid that the icon is gray while the combo isn't deployed if (index == -1) isSelected = true; // We put the label String iso3 = (String) value; setText(iso3); if (isSelected) { if (lnf.equalsIgnoreCase("swing")) setOpaque(true); else if (index == -1) setOpaque(false); else setOpaque(true); setForeground(list.getSelectionForeground()); setBackground(list.getSelectionBackground()); } else setOpaque(false); // We put the icon if (!icons.containsKey(iso3)) { ImageIcon icon = new ImageIcon(this.getClass().getResource("/res/flag." + iso3)); icons.put(iso3, icon); grayIcons.put(iso3, new ImageIcon(GrayFilter.createDisabledImage(icon.getImage()))); } if (isSelected) setIcon((ImageIcon) icons.get(iso3)); else setIcon((ImageIcon) grayIcons.get(iso3)); // We return return this; }
3,241,325
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { // We avoid that the icon is gray while the combo isn't deployed if (index == -1) isSelected = true; // We put the label String iso3 = (String) value; setText(iso3); if (isSelected) { if (lnf.equalsIgnoreCase("swing")) setOpaque(true); else if (index == -1) setOpaque(false); else setOpaque(true); setForeground(list.getSelectionForeground()); setBackground(list.getSelectionBackground()); } else setOpaque(false); // We put the icon if (!icons.containsKey(iso3)) { ImageIcon icon = new ImageIcon(this.getClass().getResource("/res/flag." + iso3)); icons.put(iso3, icon); grayIcons.put(iso3, new ImageIcon(GrayFilter.createDisabledImage(icon.getImage()))); } if (isSelected) setIcon((ImageIcon) icons.get(iso3)); else setIcon((ImageIcon) grayIcons.get(iso3)); // We return return this; }
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { // We avoid that the icon is gray while the combo isn't deployed if (index == -1) isSelected = true; // We put the label String iso3 = (String) value; setText(iso3); if (isSelected) { if (lnf.equalsIgnoreCase("swing")) setOpaque(true); else if (index == -1) setOpaque(false); else setOpaque(true); setForeground(list.getSelectionForeground()); setBackground(list.getSelectionBackground()); } else setOpaque(false); // We put the icon if (!icons.containsKey(iso3)) { ImageIcon icon = new ImageIcon(this.getClass().getResource("/res/flag." + iso3)); icons.put(iso3, icon); grayIcons.put(iso3, new ImageIcon(GrayFilter.createDisabledImage(icon.getImage()))); } if (isSelected) setIcon((ImageIcon) icons.get(iso3)); else setIcon((ImageIcon) grayIcons.get(iso3)); // We return return this; }
3,241,326