private void addLocalReactions(final Set<Reaction<T>> list, final Reaction<T> r) { for (final Reaction<T> or : r.getNode()) { /* * If the reaction is not the current and it is already in this * graph */ if (or != r && hndlrs.containsKey(or)) { // NOPMD by danysk on 8/20/13 2:37 PM list.add(or); } } }
private void addNeighborhoodReactions(final Set<Reaction<T>> list, final Reaction<T> r) { for (final Node<T> n : env.getNeighborhood(r.getNode())) { for (final Reaction<T> or : n) { /* * If the reaction is already in this graph */ if (hndlrs.containsKey(or)) { list.add(or); } } } }
private void addExtendedNeighborhoodReactions(final Set<Reaction<T>> list, final Reaction<T> r) { for (final Node<T> n : env.getNeighborhood(r.getNode())) { for (final Node<T> neigh : env.getNeighborhood(n)) { for (final Reaction<T> or : neigh) { /* * If the reaction is not the current and it is already in this * graph */ if (or != r && hndlrs.containsKey(or)) { // NOPMD by danysk on 8/20/13 2:37 PM list.add(or); } } } } }
@Override public void stepDone(final Environment<T> env, final Reaction<T> exec, final Time time, final long step) { if (exec == null || exec.getNode().equals(n)) { final StringBuilder sb = new StringBuilder(stringLength); sb.append(POSITION); sb.append('\n'); sb.append(env.getPosition(n)); sb.append("\n\n\n"); sb.append(CONTENT); sb.append('\n'); sb.append(n.getContents().entrySet().stream() .map(e -> e.getKey().getName() + " > " + e.getValue() + '\n') .sorted() .collect(Collectors.joining()) ); sb.append("\n\n\n"); sb.append(PROGRAM); sb.append("\n\n"); for (final Reaction<T> r : n.getReactions()) { sb.append(r.toString()); sb.append("\n\n"); } stringLength = sb.length() + MARGIN; SwingUtilities.invokeLater(() -> { txt.setText(sb.toString()); }); } } }
/** * This method checks if there may be a dependency considering the * neighborhoods */ private static <T> boolean influenceNeighborCheck(final Environment<T> env, final Reaction<T> source, final Reaction<T> target, final Context in, final Context out) { final Neighborhood<T> sn = env.getNeighborhood(source.getNode()); final boolean scn = in.equals(Context.NEIGHBORHOOD); // If source reads from neighborhood and target is within if (scn && sn.contains(target.getNode())) { return true; } // If target writes in neighborhood and source is within final Neighborhood<T> tn = env.getNeighborhood(target.getNode()); final boolean tcn = out.equals(Context.NEIGHBORHOOD); if (tcn && tn.contains(source.getNode())) { return true; } // If source writes on the neighborhood, target reads on its // neighborhood and there is at least one common node return scn && tcn && commonNeighbor(env, sn, target.getNode()); }
private boolean mayInfluence(final Reaction<T> source, final Reaction<T> target) { final Context in = target.getInputContext(); final Context out = source.getOutputContext(); if (// Same node target.getNode().equals(source.getNode()) // If reaction writes something globally || out.equals(Context.GLOBAL) // If reaction reads something globally || in.equals(Context.GLOBAL)) { return true; } return influenceNeighborCheck(env, source, target, in, out); }