Dumps an element (either a node or an edge). @param elem element to be dumped @param toString function that returns string representation of elem @param labeler function that returns label of elem @param attributer function that returns attributes of elem @param <
(T elem,
Function<T, String> toString,
Function<T, String> labeler,
Function<T, DotAttributes> attributer)
| 165 | * @param <T> type of the element |
| 166 | */ |
| 167 | private <T> void dumpElement(T elem, |
| 168 | Function<T, String> toString, |
| 169 | Function<T, String> labeler, |
| 170 | Function<T, DotAttributes> attributer) { |
| 171 | out.print(INDENT); |
| 172 | out.print(toString.apply(elem)); |
| 173 | String label = labeler.apply(elem); |
| 174 | DotAttributes attrs = attributer.apply(elem); |
| 175 | if (label != null || attrs != null) { |
| 176 | out.print(" ["); |
| 177 | if (label != null) { |
| 178 | out.printf("label=\"%s\",", label); |
| 179 | } |
| 180 | if (attrs != null) { |
| 181 | out.print(attrs); |
| 182 | } |
| 183 | out.print(']'); |
| 184 | } |
| 185 | out.println(';'); |
| 186 | } |
| 187 | } |