Source Code Cross Referenced for GraphDistanceFilter.java in  » Database-Client » prefuse » prefuse » action » filter » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database Client » prefuse » prefuse.action.filter 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package prefuse.action.filter;
002:
003:        import java.util.Iterator;
004:
005:        import prefuse.Constants;
006:        import prefuse.Visualization;
007:        import prefuse.action.GroupAction;
008:        import prefuse.data.Graph;
009:        import prefuse.data.expression.Predicate;
010:        import prefuse.data.tuple.TupleSet;
011:        import prefuse.data.util.BreadthFirstIterator;
012:        import prefuse.data.util.FilterIterator;
013:        import prefuse.util.PrefuseLib;
014:        import prefuse.visual.VisualItem;
015:        import prefuse.visual.expression.InGroupPredicate;
016:
017:        /**
018:         * Filter Action that sets visible all items within a specified graph distance
019:         * from a set of focus items; all other items will be set to invisible.
020:         * 
021:         * @author <a href="http://jheer.org">jeffrey heer</a>
022:         */
023:        public class GraphDistanceFilter extends GroupAction {
024:
025:            protected int m_distance;
026:            protected String m_sources;
027:            protected Predicate m_groupP;
028:            protected BreadthFirstIterator m_bfs;
029:
030:            /**
031:             * Create a new GraphDistanceFilter that processes the given data group
032:             * and uses a graph distance of 1. By default, the
033:             * {@link prefuse.Visualization#FOCUS_ITEMS} group will be used as the
034:             * source nodes from which to measure the distance.
035:             * @param group the group to process. This group should resolve to a
036:             * Graph instance, otherwise exceptions will be thrown when this
037:             * Action is run.
038:             */
039:            public GraphDistanceFilter(String group) {
040:                this (group, 1);
041:            }
042:
043:            /**
044:             * Create a new GraphDistanceFilter that processes the given data group
045:             * and uses the given graph distance. By default, the
046:             * {@link prefuse.Visualization#FOCUS_ITEMS} group will be used as the
047:             * source nodes from which to measure the distance.
048:             * @param group the group to process. This group should resolve to a
049:             * Graph instance, otherwise exceptions will be thrown when this
050:             * Action is run.
051:             * @param distance the graph distance within which items will be
052:             * visible.
053:             */
054:            public GraphDistanceFilter(String group, int distance) {
055:                this (group, Visualization.FOCUS_ITEMS, distance);
056:            }
057:
058:            /**
059:             * Create a new GraphDistanceFilter that processes the given data group
060:             * and uses the given graph distance.
061:             * @param group the group to process. This group should resolve to a
062:             * Graph instance, otherwise exceptions will be thrown when this
063:             * Action is run.
064:             * @param sources the group to use as source nodes for measuring
065:             * graph distance.
066:             * @param distance the graph distance within which items will be
067:             * visible.
068:             */
069:            public GraphDistanceFilter(String group, String sources,
070:                    int distance) {
071:                super (group);
072:                m_sources = sources;
073:                m_distance = distance;
074:                m_groupP = new InGroupPredicate(PrefuseLib.getGroupName(group,
075:                        Graph.NODES));
076:                m_bfs = new BreadthFirstIterator();
077:            }
078:
079:            /**
080:             * Return the graph distance threshold used by this filter.
081:             * @return the graph distance threshold
082:             */
083:            public int getDistance() {
084:                return m_distance;
085:            }
086:
087:            /**
088:             * Set the graph distance threshold used by this filter.
089:             * @param distance the graph distance threshold to use
090:             */
091:            public void setDistance(int distance) {
092:                m_distance = distance;
093:            }
094:
095:            /**
096:             * Get the name of the group to use as source nodes for measuring
097:             * graph distance. These form the roots from which the graph distance
098:             * is measured.
099:             * @return the source data group
100:             */
101:            public String getSources() {
102:                return m_sources;
103:            }
104:
105:            /**
106:             * Set the name of the group to use as source nodes for measuring
107:             * graph distance. These form the roots from which the graph distance
108:             * is measured.
109:             * @param sources the source data group
110:             */
111:            public void setSources(String sources) {
112:                m_sources = sources;
113:            }
114:
115:            /**
116:             * @see prefuse.action.GroupAction#run(double)
117:             */
118:            public void run(double frac) {
119:                // mark the items
120:                Iterator items = m_vis.visibleItems(m_group);
121:                while (items.hasNext()) {
122:                    VisualItem item = (VisualItem) items.next();
123:                    item.setDOI(Constants.MINIMUM_DOI);
124:                }
125:
126:                // set up the graph traversal
127:                TupleSet src = m_vis.getGroup(m_sources);
128:                Iterator srcs = new FilterIterator(src.tuples(), m_groupP);
129:                m_bfs.init(srcs, m_distance, Constants.NODE_AND_EDGE_TRAVERSAL);
130:
131:                // traverse the graph
132:                while (m_bfs.hasNext()) {
133:                    VisualItem item = (VisualItem) m_bfs.next();
134:                    int d = m_bfs.getDepth(item);
135:                    PrefuseLib.updateVisible(item, true);
136:                    item.setDOI(-d);
137:                    item.setExpanded(d < m_distance);
138:                }
139:
140:                // mark unreached items
141:                items = m_vis.visibleItems(m_group);
142:                while (items.hasNext()) {
143:                    VisualItem item = (VisualItem) items.next();
144:                    if (item.getDOI() == Constants.MINIMUM_DOI) {
145:                        PrefuseLib.updateVisible(item, false);
146:                        item.setExpanded(false);
147:                    }
148:                }
149:            }
150:
151:        } // end of class GraphDistanceFilter
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.