// Walks the tree, checking to make sure that we haven't violated any // logical constraints. This is a method for debugging. public boolean check() { String path = pathLabel(); if (suffixLink != null) { String suffixPath = suffixLink.pathLabel(); if (!path.substring(1, path.length()).equals(suffixPath)) { logger.log( Level.SEVERE, String.format("Suffix Link for node (%s) didn't match: %s", path, suffixPath)); return false; } } for (char c : childEdges.keySet()) { TreeEdge e = childEdges.get(c); if (!e.check()) { return false; } } for (int k : terminalEdges.keySet()) { TreeEdge e = terminalEdges.get(k); if (!e.check()) { return false; } } return true; }
public void collectSuffixes(Set<StringSuffix> suffices) { suffices.addAll(suffixes); for (char key : childEdges.keySet()) { childEdges.get(key).tailNode.collectSuffixes(suffices); } for (int key : terminalEdges.keySet()) { terminalEdges.get(key).tailNode.collectSuffixes(suffices); } }
/** @param aProperties the updated properties. */ @SuppressWarnings("rawtypes") final void setProperties(final Dictionary aProperties) { final Map<String, String> newProps = new HashMap<String, String>(); Enumeration keys = aProperties.keys(); while (keys.hasMoreElements()) { final String key = (String) keys.nextElement(); if (!KNOWN_KEYS.contains(key) && !IGNORED_KEYS.contains(key)) { LOG.log(Level.WARNING, "Unknown/unsupported profile key: " + key); continue; } final String value = aProperties.get(key).toString(); newProps.put(key, value.trim()); } // Verify whether all known keys are defined... final List<String> checkedKeys = new ArrayList<String>(KNOWN_KEYS); checkedKeys.removeAll(newProps.keySet()); if (!checkedKeys.isEmpty()) { throw new IllegalArgumentException( "Profile settings not complete! Missing keys are: " + checkedKeys.toString()); } this.properties.putAll(newProps); LOG.log( Level.INFO, "New device profile settings applied for {1} ({0}) ...", // new Object[] {getType(), getDescription()}); }
public void addSelection(Point p) { ExprPoint ep = null; int minDist = -1; for (ExprPoint ex : points) { int sd = ex.screenDist(p); if (ep == null || sd < minDist) { ep = ex; minDist = sd; } } if (ep != null) { Set<Point> remove = new HashSet<Point>(); for (Point rp : selections.keySet()) { if (selections.get(rp).equals(ep)) { remove.add(rp); } } selections.put(p, ep); for (Point rp : remove) { selections.remove(rp); } } }
public void print(int indent, PrintStream ps) { if (isLeaf()) { printSuffixes(ps); ps.println(); } else { int i = 0; for (char c : childEdges.keySet()) { TreeEdge edge = childEdges.get(c); edge.print(indent, i != 0, ps); i++; } for (int k : terminalEdges.keySet()) { TreeEdge edge = terminalEdges.get(k); edge.print(indent, i != 0, ps); i++; } } }
public Map<String, Rxn> getReactions(String compartment) { TreeMap<String, Rxn> crxns = new TreeMap<String, Rxn>(); for (String rn : reactions.keySet()) { Rxn r = reactions.get(rn); if (r.getLocation().equals(compartment)) { crxns.put(rn, r); } } return crxns; }
public Set<String> getOutputReactions(Rxn r) { TreeSet<String> rxns = new TreeSet<String>(); for (String rn : reactions.keySet()) { Rxn rxn = reactions.get(rn); if (r.connects(rxn)) { rxns.add(rn); } } return rxns; }
public void paintRegion(Graphics2D g, int x1, int y1, int w, int h) { int h2 = h / 2; int rad = 3; int diam = rad * 2; Color lg = Color.cyan; Color dg = Color.orange; lg = new Color(lg.getRed(), lg.getGreen(), lg.getBlue(), 75); dg = new Color(dg.getRed(), dg.getGreen(), dg.getBlue(), 75); /* * Draw the Baseline */ g.setColor(Color.black); g.drawLine(x1, y1 + h, x1 + w, y1 + h); Stroke oldStroke = g.getStroke(); g.setStroke(new BasicStroke((float) 2.0)); /* * Draw the datapoints */ for (ExprPoint ep : points) { if (ep.strand == '+') { g.setColor(lg); } else { g.setColor(dg); } g.drawOval(x1 + ep.x - rad, y1 + ep.y - rad, diam, diam); } g.setStroke(oldStroke); /* * Paint the hash marks... */ if (!displayOppositeChannel) { g.setColor(Color.black); boolean flipper = true; for (int value = 100; value <= scale.getMax(); value *= (flipper ? 5 : 2), flipper = !flipper) { int yoff = getYOffset((double) value); String line = String.format("%d", value); int uy = y1 + h2 - yoff, ly = y1 + h2 + yoff; g.drawLine(x1, uy, x1 + 10, uy); g.drawString(line, x1 + 12, uy + 5); g.drawLine(x1, ly, x1 + 10, ly); g.drawString(line, x1 + 12, ly + 5); } } /* * Draw any selections. */ g.setColor(Color.black); for (Point p : selections.keySet()) { ExprPoint ep = selections.get(p); g.drawLine(p.x, p.y, ep.x, ep.y); g.drawString(ep.getLabel(), p.x, p.y); } /* * Draw the label in the upper-right hand corner. */ g.setColor(Color.black); Font oldFont = g.getFont(); Font newFont = new Font("Arial", Font.BOLD, 24); g.setFont(newFont); FontMetrics fm = g.getFontMetrics(); int lblHeight = fm.getAscent() + fm.getDescent(); int lblWidth = fm.charsWidth(label.toCharArray(), 0, label.length()); int padding = 5; int lblx = x1 + w - lblWidth - padding; int lbly = y1 + lblHeight + padding; g.drawString(label, lblx, lbly); g.setFont(oldFont); }
public Set<String> getReactionAbbreviations() { return reactions.keySet(); }