1 /***
2 * GrappaSupport.java
3 *
4 * Project: Dependency Tool
5 *
6 * WHEN WHO WHAT
7 * 06.06.2003 pko initial public release
8 *
9 * Copyright 2003 ELCA Informatique SA
10 * Av. de la Harpe 22-24, 1000 Lausanne 13, Switzerland
11 * www.elca.ch
12 *
13 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Lesser General Public License
15 * as published by the Free Software Foundation; either version 2.1 of
16 * the License, or (at your option) any later version.
17 *
18 * This library is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Lesser General Public License for more details.
22 *
23 * You should have received a copy of the GNU Lesser General Public
24 * License along with this library; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
26 * USA
27 */
28
29 package ch.elca.dependency.adapter.grappa;
30
31
32 import att.grappa.Element;
33 import att.grappa.Graph;
34 import att.grappa.GraphEnumeration;
35 import att.grappa.GrappaConstants;
36 import org.apache.log4j.Logger;
37 import java.io.StringWriter;
38 import java.util.Hashtable;
39
40 /***
41 * The original <code>att.grappa.GrappaSupport</code> lacks
42 * functionality, which is provided by this class (by the means of
43 * wrapping methods, adding functionality and forwarding method calls.
44 *
45 * @author Pawel Kowalski
46 * @version 1.0-beta
47 */
48 public class GrappaSupport implements GrappaConstants {
49
50 /***
51 * Log4j Logger.
52 */
53 private static final Logger LOG = Logger.getLogger(GrappaSupport.class);
54
55 /***
56 * The original
57 * <code>att.grappa.GrappaSupport.filterGraph(...)</code> method
58 * looses the <code>att.grappa.Element.object</code> instances
59 * after filtering the graph. This method wraps the original
60 * method, memorizes the <code>att.grappa.Element.object</code>
61 * information and restores it after filtering.
62 *
63 * @param graph an <code>att.grappa.Graph</code> value
64 * @param connector an <code>Object</code> value
65 * @return a <code>boolean</code> value
66 */
67 public static boolean filterGraph(Graph graph, Object connector) {
68
69 // memorize information
70 //
71 Hashtable tables = new Hashtable();
72 for (GraphEnumeration enum = graph.elements(); enum.hasMoreElements(); ) {
73 Element elem = enum.nextGraphElement();
74 if (elem.object == null) {
75 elem.object = new Hashtable();
76 }
77 tables.put(elem.toString(), elem.object);
78 elem.object = null;
79 }
80
81 if (false) {
82 StringWriter writer = new StringWriter();
83 graph.printGraph(writer);
84 LOG.debug("Before filtering:" + writer.toString());
85 }
86
87 // forward processing
88 //
89 boolean result = att.grappa.GrappaSupport.filterGraph(graph, connector);
90
91 if (false) {
92 StringWriter writer = new StringWriter();
93 graph.printGraph(writer);
94 LOG.debug("After filtering:" + writer.toString());
95 }
96
97
98 // recall memorized information
99 //
100 for (GraphEnumeration enum = graph.elements(); enum.hasMoreElements(); ) {
101 Element elem = enum.nextGraphElement();
102 elem.object = (Hashtable)tables.get(elem.toString());
103 }
104
105 return result;
106 }
107
108 /***
109 * Only a forwarding wrapper method to the
110 * <code>att.grappa.GrappaSupport.setHighlight(...)</code>
111 * method. This method forwards only the method call to the
112 * original method and does no processing on its own.
113 *
114 * @param elem an <code>Element</code> value
115 * @param mode an <code>int</code> value
116 * @param setting an <code>int</code> value
117 */
118 public static void setHighlight(Element elem, int mode, int setting) {
119 att.grappa.GrappaSupport.setHighlight(elem, mode, setting);
120 }
121 }
This page was automatically generated by Maven