id
int32
0
12.9k
code
sequencelengths
2
264k
10,100
[ "<s>", "package", "org", ".", "nju", ".", "artemis", ".", "aejb", ".", "management", ".", "client", ";", "import", "java", ".", "util", ".", "Collection", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "Map", ".", "Entry", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "org", ".", "jboss", ".", "logging", ".", "Logger", ";", "import", "org", ".", "nju", ".", "artemis", ".", "aejb", ".", "component", ".", "AEjbUtilities", ";", "import", "org", ".", "nju", ".", "artemis", ".", "aejb", ".", "component", ".", "AcContainer", ";", "public", "class", "AEjbClientImpl", "implements", "AEjbClient", "{", "private", "static", "final", "long", "serialVersionUID", "=", "1L", ";", "Logger", "log", "=", "Logger", ".", "getLogger", "(", "AEjbClientImpl", ".", "class", ")", ";", "private", "Map", "<", "String", ",", "String", "[", "]", ">", "aejbInfos", "=", "new", "HashMap", "<", "String", ",", "String", "[", "]", ">", "(", ")", ";", "private", "Set", "<", "String", ">", "aejbNames", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "private", "Map", "<", "String", ",", "AEjbStatus", ">", "aejbStatus", "=", "new", "HashMap", "<", "String", ",", "AEjbStatus", ">", "(", ")", ";", "private", "Map", "<", "String", ",", "String", ">", "switchMap", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "private", "Map", "<", "String", ",", "String", ">", "protocols", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "public", "static", "final", "AEjbClientImpl", "INSTANCE", "=", "new", "AEjbClientImpl", "(", ")", ";", "public", "enum", "AEjbStatus", "{", "BLOCKING", ",", "RESUMING", ",", "}", "private", "AEjbClientImpl", "(", ")", "{", "}", "public", "Map", "<", "String", ",", "String", "[", "]", ">", "listAEjbs", "(", ")", "{", "return", "aejbInfos", ";", "}", "void", "refreshAEjbsInfo", "(", ")", "{", "Map", "<", "String", ",", "Map", "<", "String", ",", "AcContainer", ">", ">", "deploymentUnits", "=", "AEjbUtilities", ".", "getAllAEjbsInfo", "(", ")", ";", "Iterator", "<", "Entry", "<", "String", ",", "Map", "<", "String", ",", "AcContainer", ">", ">", ">", "iterator", "=", "deploymentUnits", ".", "entrySet", "(", ")", ".", "iterator", "(", ")", ";", "reset", "(", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "Entry", "<", "String", ",", "Map", "<", "String", ",", "AcContainer", ">", ">", "entry", "=", "iterator", ".", "next", "(", ")", ";", "Map", "<", "String", ",", "AcContainer", ">", "aejbs", "=", "entry", ".", "getValue", "(", ")", ";", "int", "size", "=", "aejbs", ".", "size", "(", ")", ";", "Collection", "<", "String", ">", "aejbNames", "=", "new", "HashSet", "<", "String", ">", "(", "aejbs", ".", "keySet", "(", ")", ")", ";", "aejbInfos", ".", "put", "(", "entry", ".", "getKey", "(", ")", ",", "aejbs", ".", "keySet", "(", ")", ".", "toArray", "(", "new", "String", "[", "size", "]", ")", ")", ";", "this", ".", "aejbNames", ".", "addAll", "(", "aejbNames", ")", ";", "}", "}", "private", "void", "reset", "(", ")", "{", "aejbInfos", ".", "clear", "(", ")", ";", "aejbNames", ".", "clear", "(", ")", ";", "}", "public", "boolean", "blockAEjb", "(", "String", "aejbName", ")", "{", "if", "(", "aejbStatus", ".", "containsKey", "(", "aejbName", ")", "&&", "aejbStatus", ".", "get", "(", "aejbName", ")", "==", "AEjbStatus", ".", "BLOCKING", ")", "return", "true", ";", "else", "if", "(", "aejbStatus", ".", "containsKey", "(", "aejbName", ")", "||", "aejbNames", ".", "contains", "(", "aejbName", ")", ")", "{", "aejbStatus", ".", "put", "(", "aejbName", ",", "AEjbStatus", ".", "BLOCKING", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}", "public", "Map", "<", "String", ",", "AEjbStatus", ">", "getAEjbStatus", "(", ")", "{", "return", "aejbStatus", ";", "}", "public", "AEjbStatus", "getAEjbStatus", "(", "String", "aejbName", ")", "{", "return", "aejbStatus", ".", "get", "(", "aejbName", ")", ";", "}", "public", "void", "clearAEjbStatus", "(", ")", "{", "aejbStatus", ".", "clear", "(", ")", ";", "}", "public", "void", "clearSwitchMap", "(", ")", "{", "switchMap", ".", "clear", "(", ")", ";", "}", "@", "Override", "public", "boolean", "resumeAEjb", "(", "String", "aejbName", ")", "{", "if", "(", "aejbStatus", ".", "containsKey", "(", "aejbName", ")", "&&", "aejbStatus", ".", "get", "(", "aejbName", ")", "==", "AEjbStatus", ".", "RESUMING", ")", "return", "true", ";", "else", "if", "(", "aejbStatus", ".", "containsKey", "(", "aejbName", ")", "||", "aejbNames", ".", "contains", "(", "aejbName", ")", ")", "{", "aejbStatus", ".", "put", "(", "aejbName", ",", "AEjbStatus", ".", "RESUMING", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}", "@", "Override", "public", "boolean", "switchAEjb", "(", "String", "fromName", ",", "String", "toName", ",", "String", "protocol", ")", "{", "if", "(", "switchMap", ".", "containsKey", "(", "fromName", ")", "&&", "toName", ".", "equals", "(", "switchMap", ".", "get", "(", "fromName", ")", ")", ")", "{", "protocols", ".", "put", "(", "fromName", ",", "protocol", ")", ";", "return", "true", ";", "}", "if", "(", "aejbNames", ".", "contains", "(", "fromName", ")", "&&", "aejbNames", ".", "contains", "(", "toName", ")", ")", "{", "switchMap", ".", "put", "(", "fromName", ",", "toName", ")", ";", "protocols", ".", "put", "(", "fromName", ",", "protocol", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}", "@", "Override", "public", "Map", "<", "String", ",", "String", ">", "getSwitchMap", "(", ")", "{", "return", "switchMap", ";", "}", "@", "Override", "public", "String", "getProtocol", "(", "String", "name", ")", "{", "return", "protocols", ".", "get", "(", "name", ")", ";", "}", "@", "Override", "public", "boolean", "replaceAEjb", "(", "String", "fromName", ",", "String", "toName", ",", "String", "protocol", ")", "{", "return", "false", ";", "}", "}", "</s>" ]
10,101
[ "<s>", "package", "org", ".", "nju", ".", "artemis", ".", "aejb", ".", "management", ".", "client", ";", "import", "java", ".", "io", ".", "Serializable", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "nju", ".", "artemis", ".", "aejb", ".", "management", ".", "client", ".", "AEjbClientImpl", ".", "AEjbStatus", ";", "public", "interface", "AEjbClient", "extends", "Serializable", "{", "Map", "<", "String", ",", "String", "[", "]", ">", "listAEjbs", "(", ")", ";", "Map", "<", "String", ",", "AEjbStatus", ">", "getAEjbStatus", "(", ")", ";", "AEjbStatus", "getAEjbStatus", "(", "String", "aejbName", ")", ";", "boolean", "blockAEjb", "(", "String", "aejbName", ")", ";", "boolean", "resumeAEjb", "(", "String", "aejbName", ")", ";", "void", "clearAEjbStatus", "(", ")", ";", "void", "clearSwitchMap", "(", ")", ";", "boolean", "switchAEjb", "(", "String", "fromName", ",", "String", "toName", ",", "String", "protocol", ")", ";", "Map", "<", "String", ",", "String", ">", "getSwitchMap", "(", ")", ";", "String", "getProtocol", "(", "String", "name", ")", ";", "boolean", "replaceAEjb", "(", "String", "fromName", ",", "String", "toName", ",", "String", "protocol", ")", ";", "}", "</s>" ]
10,102
[ "<s>", "package", "org", ".", "nju", ".", "artemis", ".", "aejb", ";", "import", "junit", ".", "framework", ".", "Test", ";", "import", "junit", ".", "framework", ".", "TestCase", ";", "import", "junit", ".", "framework", ".", "TestSuite", ";", "public", "class", "AppTest", "extends", "TestCase", "{", "public", "AppTest", "(", "String", "testName", ")", "{", "super", "(", "testName", ")", ";", "}", "public", "static", "Test", "suite", "(", ")", "{", "return", "new", "TestSuite", "(", "AppTest", ".", "class", ")", ";", "}", "public", "void", "testApp", "(", ")", "{", "assertTrue", "(", "true", ")", ";", "}", "}", "</s>" ]
10,103
[ "<s>", "package", "org", ".", "nju", ".", "artemis", ".", "aejb", ".", "preprocessor", ";", "import", "java", ".", "util", ".", "LinkedList", ";", "import", "java", ".", "util", ".", "List", ";", "public", "class", "StateMachine", "{", "private", "int", "start", ";", "private", "int", "end", ";", "private", "List", "states", "=", "new", "LinkedList", "(", ")", ";", "private", "List", "<", "Event", ">", "events", "=", "new", "LinkedList", "<", "Event", ">", "(", ")", ";", "public", "StateMachine", "(", ")", "{", "}", "public", "int", "getStart", "(", ")", "{", "return", "start", ";", "}", "public", "void", "setStart", "(", "int", "start", ")", "{", "this", ".", "start", "=", "start", ";", "}", "public", "int", "getEnd", "(", ")", "{", "return", "end", ";", "}", "public", "void", "setEnd", "(", "int", "end", ")", "{", "this", ".", "end", "=", "end", ";", "}", "public", "List", "getStates", "(", ")", "{", "return", "states", ";", "}", "public", "void", "setStates", "(", "List", "states", ")", "{", "this", ".", "states", "=", "states", ";", "}", "public", "int", "getstate", "(", "int", "head", ",", "String", "event", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "events", ".", "size", "(", ")", ";", "i", "++", ")", "{", "Event", "e", "=", "events", ".", "get", "(", "i", ")", ";", "if", "(", "e", ".", "getHead", "(", ")", "==", "head", "&&", "e", ".", "getEvent", "(", ")", ".", "equals", "(", "event", ")", ")", "return", "e", ".", "getTail", "(", ")", ";", "}", "return", "-", "1", ";", "}", "public", "int", "stateindex", "(", "int", "index", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "states", ".", "size", "(", ")", ";", "i", "++", ")", "{", "if", "(", "(", "Integer", ")", "states", ".", "get", "(", "i", ")", "==", "index", ")", "return", "i", ";", "}", "return", "-", "1", ";", "}", "public", "void", "addState", "(", "int", "state", ")", "{", "states", ".", "add", "(", "state", ")", ";", "}", "public", "void", "deleteState", "(", "int", "state", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "states", ".", "size", "(", ")", ";", "i", "++", ")", "{", "if", "(", "(", "Integer", ")", "states", ".", "get", "(", "i", ")", "==", "state", ")", "states", ".", "remove", "(", "i", ")", ";", "}", "}", "public", "void", "mergeStates", "(", "int", "s1", ",", "int", "s2", ")", "{", "int", "s1_index", "=", "states", ".", "indexOf", "(", "s1", ")", ";", "states", ".", "remove", "(", "s1_index", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "events", ".", "size", "(", ")", ";", "i", "++", ")", "{", "Event", "e", "=", "events", ".", "get", "(", "i", ")", ";", "if", "(", "e", ".", "getTail", "(", ")", "==", "s1", ")", "{", "e", ".", "setTail", "(", "s2", ")", ";", "}", "}", "}", "public", "int", "getStatesCount", "(", ")", "{", "return", "states", ".", "size", "(", ")", ";", "}", "public", "void", "addEvent", "(", "Event", "event", ")", "{", "events", ".", "add", "(", "event", ")", ";", "}", "public", "void", "deleteEvent", "(", "Event", "event", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "events", ".", "size", "(", ")", ";", "i", "++", ")", "{", "if", "(", "event", ".", "getEvent", "(", ")", ".", "equals", "(", "events", ".", "get", "(", "i", ")", ".", "getEvent", "(", ")", ")", ")", "events", ".", "remove", "(", "i", ")", ";", "}", "}", "public", "List", "<", "Event", ">", "getEvents", "(", ")", "{", "return", "events", ";", "}", "}", "</s>" ]
10,104
[ "<s>", "package", "org", ".", "nju", ".", "artemis", ".", "aejb", ".", "preprocessor", ";", "import", "java", ".", "io", ".", "BufferedOutputStream", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileInputStream", ";", "import", "java", ".", "io", ".", "FileOutputStream", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "util", ".", "jar", ".", "Attributes", ";", "import", "java", ".", "util", ".", "jar", ".", "JarEntry", ";", "import", "java", ".", "util", ".", "jar", ".", "JarInputStream", ";", "import", "java", ".", "util", ".", "jar", ".", "JarOutputStream", ";", "import", "java", ".", "util", ".", "jar", ".", "Manifest", ";", "public", "class", "JarTool", "{", "private", "static", "final", "int", "BUFFER_SIZE", "=", "2156", ";", "private", "static", "String", "MAIN_CLASS", ";", "private", "byte", "[", "]", "mBuffer", "=", "new", "byte", "[", "BUFFER_SIZE", "]", ";", "private", "int", "mByteCount", "=", "0", ";", "private", "boolean", "mVerbose", "=", "false", ";", "private", "String", "mDestJarName", "=", "\"\"", ";", "public", "JarTool", "(", ")", "{", "}", "public", "void", "jarDir", "(", "File", "dirOrFile2Jar", ",", "File", "destJar", ")", "throws", "IOException", "{", "if", "(", "dirOrFile2Jar", "==", "null", "||", "destJar", "==", "null", ")", "throw", "new", "IllegalArgumentException", "(", ")", ";", "mDestJarName", "=", "destJar", ".", "getCanonicalPath", "(", ")", ";", "FileOutputStream", "fout", "=", "new", "FileOutputStream", "(", "destJar", ")", ";", "JarOutputStream", "jout", ";", "if", "(", "MAIN_CLASS", "!=", "null", ")", "{", "Manifest", "manifest", "=", "new", "Manifest", "(", ")", ";", "Attributes", "attrs", "=", "manifest", ".", "getMainAttributes", "(", ")", ";", "attrs", ".", "putValue", "(", "\"\"", ",", "\"1.0\"", ")", ";", "attrs", ".", "putValue", "(", "\"Class-Path\"", ",", "\".\"", ")", ";", "attrs", ".", "putValue", "(", "\"Main-Class\"", ",", "MAIN_CLASS", ")", ";", "jout", "=", "new", "JarOutputStream", "(", "fout", ",", "manifest", ")", ";", "}", "else", "{", "jout", "=", "new", "JarOutputStream", "(", "fout", ")", ";", "}", "try", "{", "jarDir", "(", "dirOrFile2Jar", ",", "jout", ",", "null", ")", ";", "}", "catch", "(", "IOException", "ioe", ")", "{", "throw", "ioe", ";", "}", "finally", "{", "jout", ".", "close", "(", ")", ";", "fout", ".", "close", "(", ")", ";", "}", "}", "public", "void", "unjarDir", "(", "File", "jarFile", ",", "File", "destDir", ")", "throws", "IOException", "{", "BufferedOutputStream", "dest", "=", "null", ";", "FileInputStream", "fis", "=", "new", "FileInputStream", "(", "jarFile", ")", ";", "unjar", "(", "fis", ",", "destDir", ")", ";", "}", "public", "void", "unjar", "(", "InputStream", "in", ",", "File", "destDir", ")", "throws", "IOException", "{", "BufferedOutputStream", "dest", "=", "null", ";", "JarInputStream", "jis", "=", "new", "JarInputStream", "(", "in", ")", ";", "JarEntry", "entry", ";", "while", "(", "(", "entry", "=", "jis", ".", "getNextJarEntry", "(", ")", ")", "!=", "null", ")", "{", "if", "(", "entry", ".", "isDirectory", "(", ")", ")", "{", "File", "dir", "=", "new", "File", "(", "destDir", ",", "entry", ".", "getName", "(", ")", ")", ";", "dir", ".", "mkdir", "(", ")", ";", "if", "(", "entry", ".", "getTime", "(", ")", "!=", "-", "1", ")", "dir", ".", "setLastModified", "(", "entry", ".", "getTime", "(", ")", ")", ";", "continue", ";", "}", "String", "name", "=", "entry", ".", "getName", "(", ")", ";", "while", "(", "name", ".", "contains", "(", "\"/\"", ")", "||", "name", ".", "contains", "(", "\"//\"", ")", ")", "{", "File", "fdir", "=", "new", "File", "(", "destDir", ".", "getCanonicalPath", "(", ")", "+", "\"/\"", "+", "name", ".", "split", "(", "\"/\"", ")", "[", "0", "]", ")", ";", "int", "index", "=", "name", ".", "indexOf", "(", "\"/\"", ")", ";", "if", "(", "!", "fdir", ".", "exists", "(", ")", ")", "fdir", ".", "mkdir", "(", ")", ";", "name", "=", "name", ".", "substring", "(", "index", "+", "1", ")", ";", "}", "int", "count", ";", "byte", "data", "[", "]", "=", "new", "byte", "[", "BUFFER_SIZE", "]", ";", "File", "destFile", "=", "new", "File", "(", "destDir", ",", "entry", ".", "getName", "(", ")", ")", ";", "if", "(", "mVerbose", ")", "System", ".", "out", ".", "println", "(", "\"unjarring", "\"", "+", "destFile", "+", "\"", "from", "\"", "+", "entry", ".", "getName", "(", ")", ")", ";", "FileOutputStream", "fos", "=", "new", "FileOutputStream", "(", "destFile", ")", ";", "dest", "=", "new", "BufferedOutputStream", "(", "fos", ",", "BUFFER_SIZE", ")", ";", "while", "(", "(", "count", "=", "jis", ".", "read", "(", "data", ",", "0", ",", "BUFFER_SIZE", ")", ")", "!=", "-", "1", ")", "{", "dest", ".", "write", "(", "data", ",", "0", ",", "count", ")", ";", "}", "dest", ".", "flush", "(", ")", ";", "dest", ".", "close", "(", ")", ";", "if", "(", "entry", ".", "getTime", "(", ")", "!=", "-", "1", ")", "destFile", ".", "setLastModified", "(", "entry", ".", "getTime", "(", ")", ")", ";", "}", "jis", ".", "close", "(", ")", ";", "}", "public", "void", "setVerbose", "(", "boolean", "b", ")", "{", "mVerbose", "=", "b", ";", "}", "private", "static", "final", "char", "SEP", "=", "'/'", ";", "private", "void", "jarDir", "(", "File", "dirOrFile2jar", ",", "JarOutputStream", "jos", ",", "String", "path", ")", "throws", "IOException", "{", "if", "(", "mVerbose", ")", "System", ".", "out", ".", "println", "(", "\"checking", "\"", "+", "dirOrFile2jar", ")", ";", "if", "(", "dirOrFile2jar", ".", "isDirectory", "(", ")", ")", "{", "String", "[", "]", "dirList", "=", "dirOrFile2jar", ".", "list", "(", ")", ";", "String", "subPath", "=", "(", "path", "==", "null", ")", "?", "\"\"", ":", "(", "path", "+", "dirOrFile2jar", ".", "getName", "(", ")", "+", "SEP", ")", ";", "if", "(", "path", "!=", "null", ")", "{", "JarEntry", "je", "=", "new", "JarEntry", "(", "subPath", ")", ";", "je", ".", "setTime", "(", "dirOrFile2jar", ".", "lastModified", "(", ")", ")", ";", "jos", ".", "putNextEntry", "(", "je", ")", ";", "jos", ".", "flush", "(", ")", ";", "jos", ".", "closeEntry", "(", ")", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "dirList", ".", "length", ";", "i", "++", ")", "{", "File", "f", "=", "new", "File", "(", "dirOrFile2jar", ",", "dirList", "[", "i", "]", ")", ";", "jarDir", "(", "f", ",", "jos", ",", "subPath", ")", ";", "}", "}", "else", "{", "if", "(", "dirOrFile2jar", ".", "getCanonicalPath", "(", ")", ".", "equals", "(", "mDestJarName", ")", ")", "{", "if", "(", "mVerbose", ")", "System", ".", "out", ".", "println", "(", "\"skipping", "\"", "+", "dirOrFile2jar", ".", "getPath", "(", ")", ")", ";", "return", ";", "}", "if", "(", "mVerbose", ")", "System", ".", "out", ".", "println", "(", "\"adding", "\"", "+", "dirOrFile2jar", ".", "getPath", "(", ")", ")", ";", "FileInputStream", "fis", "=", "new", "FileInputStream", "(", "dirOrFile2jar", ")", ";", "try", "{", "JarEntry", "entry", "=", "new", "JarEntry", "(", "path", "+", "dirOrFile2jar", ".", "getName", "(", ")", ")", ";", "entry", ".", "setTime", "(", "dirOrFile2jar", ".", "lastModified", "(", ")", ")", ";", "jos", ".", "putNextEntry", "(", "entry", ")", ";", "while", "(", "(", "mByteCount", "=", "fis", ".", "read", "(", "mBuffer", ")", ")", "!=", "-", "1", ")", "{", "jos", ".", "write", "(", "mBuffer", ",", "0", ",", "mByteCount", ")", ";", "if", "(", "mVerbose", ")", "System", ".", "out", ".", "println", "(", "\"wrote", "\"", "+", "mByteCount", "+", "\"", "bytes\"", ")", ";", "}", "jos", ".", "flush", "(", ")", ";", "jos", ".", "closeEntry", "(", ")", ";", "}", "catch", "(", "IOException", "ioe", ")", "{", "throw", "ioe", ";", "}", "finally", "{", "fis", ".", "close", "(", ")", ";", "}", "}", "}", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "throws", "IOException", "{", "JarTool", "jarHelper", "=", "new", "JarTool", "(", ")", ";", "jarHelper", ".", "mVerbose", "=", "true", ";", "File", "destJar", "=", "new", "File", "(", "\"E:\\\\a.jar\"", ")", ";", "File", "dirOrFile2Jar", "=", "new", "File", "(", "\"e:\\\\bbb.jar\"", ")", ";", "File", "jar2Dir", "=", "new", "File", "(", "\"E:\\\\result\"", ")", ";", "jar2Dir", ".", "mkdir", "(", ")", ";", "jarHelper", ".", "unjarDir", "(", "destJar", ",", "jar2Dir", ")", ";", "jarHelper", ".", "jarDir", "(", "jar2Dir", ",", "dirOrFile2Jar", ")", ";", "}", "}", "</s>" ]
10,105
[ "<s>", "package", "org", ".", "nju", ".", "artemis", ".", "aejb", ".", "preprocessor", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "LinkedList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "tree", ".", "AbstractInsnNode", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "tree", ".", "MethodNode", ";", "public", "class", "ControlFlow", "{", "List", "<", "flow", ">", "con", "=", "new", "LinkedList", "<", "flow", ">", "(", ")", ";", "public", "flow", "getFlow", "(", "int", "src", ")", "{", "Iterator", "<", "flow", ">", "f", "=", "con", ".", "iterator", "(", ")", ";", "while", "(", "f", ".", "hasNext", "(", ")", ")", "{", "flow", "fn", "=", "f", ".", "next", "(", ")", ";", "if", "(", "fn", ".", "src", "==", "src", ")", "{", "return", "fn", ";", "}", "}", "return", "null", ";", "}", "public", "void", "addFlow", "(", "int", "src", ",", "int", "dst", ")", "{", "flow", "fl", "=", "getFlow", "(", "src", ")", ";", "if", "(", "fl", "!=", "null", ")", "{", "fl", ".", "setDst", "(", "dst", ")", ";", "}", "else", "{", "con", ".", "add", "(", "new", "flow", "(", "src", ",", "dst", ")", ")", ";", "}", "}", "public", "int", "getDstSize", "(", "int", "src", ")", "{", "return", "getFlow", "(", "src", ")", ".", "dst", ".", "size", "(", ")", ";", "}", "public", "List", "getDst", "(", "int", "src", ")", "{", "return", "getFlow", "(", "src", ")", ".", "getDst", "(", ")", ";", "}", "public", "List", "<", "AbstractInsnNode", ">", "getDstNode", "(", "MethodNode", "mn", ",", "int", "src", ")", "{", "List", "<", "AbstractInsnNode", ">", "dstnode", "=", "new", "LinkedList", "<", "AbstractInsnNode", ">", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "getDstSize", "(", "src", ")", ";", "i", "++", ")", "{", "dstnode", ".", "add", "(", "(", "AbstractInsnNode", ")", "mn", ".", "instructions", ".", "get", "(", "(", "Integer", ")", "getDst", "(", "src", ")", ".", "get", "(", "i", ")", ")", ")", ";", "}", "return", "dstnode", ";", "}", "public", "void", "showControlFlow", "(", ")", "{", "Iterator", "<", "flow", ">", "f", "=", "con", ".", "iterator", "(", ")", ";", "while", "(", "f", ".", "hasNext", "(", ")", ")", "{", "flow", "fn", "=", "f", ".", "next", "(", ")", ";", "System", ".", "out", ".", "print", "(", "fn", ".", "src", "+", "\"->\"", ")", ";", "List", "d", "=", "getDst", "(", "fn", ".", "src", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "d", ".", "size", "(", ")", ";", "i", "++", ")", "{", "System", ".", "out", ".", "print", "(", "d", ".", "get", "(", "i", ")", "+", "\",\"", ")", ";", "}", "System", ".", "out", ".", "println", "(", ")", ";", "}", "}", "}", "class", "flow", "{", "int", "src", ";", "boolean", "isWhile", ";", "List", "dst", "=", "new", "LinkedList", "(", ")", ";", "public", "flow", "(", "int", "src", ",", "int", "dst", ")", "{", "this", ".", "src", "=", "src", ";", "this", ".", "dst", ".", "add", "(", "dst", ")", ";", "isWhile", "=", "false", ";", "}", "public", "void", "setSrc", "(", "int", "s", ")", "{", "src", "=", "s", ";", "}", "public", "void", "setDst", "(", "int", "d", ")", "{", "dst", ".", "add", "(", "d", ")", ";", "}", "public", "int", "getSrc", "(", ")", "{", "return", "src", ";", "}", "public", "List", "getDst", "(", ")", "{", "return", "dst", ";", "}", "public", "boolean", "getIsWhile", "(", ")", "{", "return", "isWhile", ";", "}", "public", "void", "setIsWhile", "(", "boolean", "w", ")", "{", "isWhile", "=", "w", ";", "}", "}", "</s>" ]
10,106
[ "<s>", "package", "org", ".", "nju", ".", "artemis", ".", "aejb", ".", "preprocessor", ";", "public", "class", "Event", "{", "private", "int", "head", ";", "private", "int", "tail", ";", "private", "String", "event", ";", "public", "Event", "(", "int", "head", ",", "int", "tail", ",", "String", "event", ")", "{", "super", "(", ")", ";", "this", ".", "head", "=", "head", ";", "this", ".", "tail", "=", "tail", ";", "this", ".", "event", "=", "event", ";", "System", ".", "out", ".", "println", "(", "head", "+", "\"-\"", "+", "event", "+", "\"-\"", "+", "tail", ")", ";", "}", "public", "int", "getHead", "(", ")", "{", "return", "head", ";", "}", "public", "void", "setHead", "(", "int", "head", ")", "{", "this", ".", "head", "=", "head", ";", "}", "public", "int", "getTail", "(", ")", "{", "return", "tail", ";", "}", "public", "void", "setTail", "(", "int", "tail", ")", "{", "this", ".", "tail", "=", "tail", ";", "}", "public", "String", "getEvent", "(", ")", "{", "return", "event", ";", "}", "public", "void", "setEvent", "(", "String", "event", ")", "{", "this", ".", "event", "=", "event", ";", "}", "public", "String", "getPort", "(", ")", "{", "if", "(", "event", ".", "contains", "(", "\"Ejb\"", ")", ")", "{", "return", "event", ".", "split", "(", "\"\\\\.\"", ")", "[", "1", "]", ";", "}", "return", "null", ";", "}", "}", "</s>" ]
10,107
[ "<s>", "package", "org", ".", "nju", ".", "artemis", ".", "aejb", ".", "preprocessor", ";", "import", "static", "org", ".", "objectweb", ".", "asm", ".", "Opcodes", ".", "*", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileInputStream", ";", "import", "java", ".", "io", ".", "FileOutputStream", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "io", ".", "PrintWriter", ";", "import", "java", ".", "util", ".", "Enumeration", ";", "import", "java", ".", "util", ".", "Hashtable", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "LinkedList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "StringTokenizer", ";", "import", "java", ".", "util", ".", "jar", ".", "*", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "ClassReader", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "ClassVisitor", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "ClassWriter", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "Opcodes", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "tree", ".", "AbstractInsnNode", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "tree", ".", "AnnotationNode", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "tree", ".", "ClassNode", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "tree", ".", "FieldNode", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "tree", ".", "FrameNode", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "tree", ".", "InsnList", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "tree", ".", "InsnNode", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "tree", ".", "JumpInsnNode", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "tree", ".", "LabelNode", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "tree", ".", "LdcInsnNode", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "tree", ".", "MethodInsnNode", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "tree", ".", "MethodNode", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "tree", ".", "TryCatchBlockNode", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "tree", ".", "TypeInsnNode", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "tree", ".", "VarInsnNode", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "tree", ".", "analysis", ".", "Analyzer", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "tree", ".", "analysis", ".", "AnalyzerException", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "tree", ".", "analysis", ".", "BasicInterpreter", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "util", ".", "TraceClassVisitor", ";", "public", "class", "ProgramAnalyzer", "{", "private", "List", "<", "String", ">", "ejbs", "=", "new", "LinkedList", "(", ")", ";", "StateMachine", "stateMachine", "=", "new", "StateMachine", "(", ")", ";", "ControlFlow", "controlflow", "=", "new", "ControlFlow", "(", ")", ";", "List", "[", "]", "past", ";", "List", "[", "]", "future", ";", "Hashtable", "<", "AbstractInsnNode", ",", "String", ">", "jumpinf", "=", "new", "Hashtable", "<", "AbstractInsnNode", ",", "String", ">", "(", ")", ";", "List", "<", "String", ">", "next", "=", "new", "LinkedList", "(", ")", ";", "List", "<", "String", ">", "stateall", "=", "new", "LinkedList", "(", ")", ";", "public", "void", "transform", "(", "ClassNode", "cn", ")", "{", "if", "(", "(", "cn", ".", "access", "&", "ACC_INTERFACE", ")", "==", "0", ")", "{", "setEjbs", "(", "cn", ")", ";", "if", "(", "!", "ejbs", ".", "isEmpty", "(", ")", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", "+", "cn", ".", "name", ")", ";", "for", "(", "MethodNode", "mn", ":", "(", "List", "<", "MethodNode", ">", ")", "cn", ".", "methods", ")", "{", "if", "(", "isTransaction", "(", "mn", ",", "\"\"", ")", ")", "{", "InsnList", "insns", "=", "mn", ".", "instructions", ";", "stateMachine", ".", "setStart", "(", "0", ")", ";", "stateMachine", ".", "setEnd", "(", "mn", ".", "instructions", ".", "size", "(", ")", ")", ";", "try", "{", "ExtractControlFlow", "(", "cn", ".", "name", ",", "mn", ")", ";", "}", "catch", "(", "AnalyzerException", "ignored", ")", "{", "}", "recognize_state", "(", "0", ",", "0", ",", "mn", ".", "instructions", ")", ";", "mergeState", "(", ")", ";", "ExtractMetaData", "(", ")", ";", "setNext", "(", ")", ";", "Iterator", "<", "AnnotationNode", ">", "iter", "=", "mn", ".", "visibleAnnotations", ".", "iterator", "(", ")", ";", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "AnnotationNode", "an", "=", "iter", ".", "next", "(", ")", ";", "if", "(", "an", ".", "desc", ".", "equals", "(", "\"\"", ")", ")", "{", "List", "<", "Object", ">", "valuenew", "=", "new", "LinkedList", "<", "Object", ">", "(", ")", ";", "valuenew", ".", "add", "(", "\"name\"", ")", ";", "valuenew", ".", "add", "(", "mn", ".", "name", ")", ";", "valuenew", ".", "add", "(", "\"states\"", ")", ";", "valuenew", ".", "add", "(", "stateall", ")", ";", "valuenew", ".", "add", "(", "\"next\"", ")", ";", "valuenew", ".", "add", "(", "next", ")", ";", "an", ".", "values", "=", "valuenew", ";", "System", ".", "out", ".", "println", "(", "an", ".", "values", ")", ";", "}", "}", "LabelNode", "lb0", "=", "new", "LabelNode", "(", ")", ";", "LabelNode", "lb1", "=", "new", "LabelNode", "(", ")", ";", "LabelNode", "lb2", "=", "new", "LabelNode", "(", ")", ";", "LabelNode", "lb3", "=", "new", "LabelNode", "(", ")", ";", "LabelNode", "lb4", "=", "new", "LabelNode", "(", ")", ";", "LabelNode", "lb5", "=", "new", "LabelNode", "(", ")", ";", "LabelNode", "lb6", "=", "new", "LabelNode", "(", ")", ";", "mn", ".", "tryCatchBlocks", ".", "add", "(", "new", "TryCatchBlockNode", "(", "lb0", ",", "lb1", ",", "lb2", ",", "\"\"", ")", ")", ";", "InsnList", "begin", "=", "new", "InsnList", "(", ")", ";", "int", "localnum", "=", "mn", ".", "localVariables", ".", "size", "(", ")", ";", "begin", ".", "add", "(", "lb3", ")", ";", "begin", ".", "add", "(", "new", "InsnNode", "(", "ACONST_NULL", ")", ")", ";", "begin", ".", "add", "(", "new", "VarInsnNode", "(", "ASTORE", ",", "localnum", ")", ")", ";", "begin", ".", "add", "(", "lb0", ")", ";", "begin", ".", "add", "(", "new", "TypeInsnNode", "(", "NEW", ",", "\"\"", ")", ")", ";", "begin", ".", "add", "(", "new", "InsnNode", "(", "DUP", ")", ")", ";", "begin", ".", "add", "(", "new", "MethodInsnNode", "(", "INVOKESPECIAL", ",", "\"\"", ",", "\"<init>\"", ",", "\"()V\"", ")", ")", ";", "begin", ".", "add", "(", "new", "VarInsnNode", "(", "ASTORE", ",", "localnum", "+", "1", ")", ")", ";", "begin", ".", "add", "(", "lb4", ")", ";", "begin", ".", "add", "(", "new", "VarInsnNode", "(", "ALOAD", ",", "localnum", "+", "1", ")", ")", ";", "begin", ".", "add", "(", "new", "LdcInsnNode", "(", "\"\"", "+", "mn", ".", "name", ")", ")", ";", "begin", ".", "add", "(", "new", "MethodInsnNode", "(", "INVOKEINTERFACE", ",", "\"\"", ",", "\"lookup\"", ",", "\"\"", ")", ")", ";", "begin", ".", "add", "(", "new", "TypeInsnNode", "(", "CHECKCAST", ",", "\"\"", ")", ")", ";", "begin", ".", "add", "(", "new", "VarInsnNode", "(", "ASTORE", ",", "localnum", ")", ")", ";", "begin", ".", "add", "(", "lb1", ")", ";", "begin", ".", "add", "(", "new", "JumpInsnNode", "(", "GOTO", ",", "lb5", ")", ")", ";", "begin", ".", "add", "(", "lb2", ")", ";", "begin", ".", "add", "(", "new", "FrameNode", "(", "Opcodes", ".", "F_FULL", ",", "2", ",", "new", "Object", "[", "]", "{", "mn", ".", "name", ",", "\"\"", "}", ",", "1", ",", "new", "Object", "[", "]", "{", "\"\"", "}", ")", ")", ";", "begin", ".", "add", "(", "new", "VarInsnNode", "(", "ASTORE", ",", "localnum", "+", "1", ")", ")", ";", "begin", ".", "add", "(", "lb6", ")", ";", "begin", ".", "add", "(", "new", "VarInsnNode", "(", "ALOAD", ",", "localnum", "+", "1", ")", ")", ";", "begin", ".", "add", "(", "new", "MethodInsnNode", "(", "INVOKEVIRTUAL", ",", "\"\"", ",", "\"\"", ",", "\"()V\"", ")", ")", ";", "begin", ".", "add", "(", "lb5", ")", ";", "Iterator", "<", "AbstractInsnNode", ">", "i", "=", "insns", ".", "iterator", "(", ")", ";", "int", "src", "=", "0", ";", "while", "(", "i", ".", "hasNext", "(", ")", ")", "{", "AbstractInsnNode", "i1", "=", "i", ".", "next", "(", ")", ";", "if", "(", "i1", "instanceof", "MethodInsnNode", ")", "{", "String", "owner", "=", "(", "(", "MethodInsnNode", ")", "i1", ")", ".", "owner", ";", "if", "(", "ejbs", ".", "contains", "(", "owner", ")", ")", "{", "String", "e", "=", "\"Ejb.\"", "+", "owner", "+", "\".\"", "+", "(", "(", "MethodInsnNode", ")", "i1", ")", ".", "name", ";", "InsnList", "il", "=", "new", "InsnList", "(", ")", ";", "il", ".", "add", "(", "new", "TypeInsnNode", "(", "NEW", ",", "\"\"", ")", ")", ";", "il", ".", "add", "(", "new", "InsnNode", "(", "DUP", ")", ")", ";", "il", ".", "add", "(", "new", "LdcInsnNode", "(", "mn", ".", "name", "+", "\"/\"", ")", ")", ";", "il", ".", "add", "(", "new", "MethodInsnNode", "(", "INVOKESPECIAL", ",", "\"\"", ",", "\"<init>\"", ",", "\"\"", ")", ")", ";", "il", ".", "add", "(", "new", "VarInsnNode", "(", "ALOAD", ",", "0", ")", ")", ";", "il", ".", "add", "(", "new", "MethodInsnNode", "(", "INVOKEVIRTUAL", ",", "\"\"", ",", "\"toString\"", ",", "\"\"", ")", ")", ";", "il", ".", "add", "(", "new", "MethodInsnNode", "(", "INVOKEVIRTUAL", ",", "\"\"", ",", "\"append\"", ",", "\"\"", ")", ")", ";", "il", ".", "add", "(", "new", "MethodInsnNode", "(", "INVOKEVIRTUAL", ",", "\"\"", ",", "\"toString\"", ",", "\"\"", ")", ")", ";", "insns", ".", "insert", "(", "i1", ".", "getPrevious", "(", ")", ",", "il", ")", ";", "InsnList", "trig", "=", "new", "InsnList", "(", ")", ";", "trig", ".", "add", "(", "new", "VarInsnNode", "(", "ALOAD", ",", "localnum", ")", ")", ";", "trig", ".", "add", "(", "new", "VarInsnNode", "(", "ALOAD", ",", "0", ")", ")", ";", "trig", ".", "add", "(", "new", "MethodInsnNode", "(", "INVOKEVIRTUAL", ",", "\"\"", ",", "\"toString\"", ",", "\"\"", ")", ")", ";", "trig", ".", "add", "(", "new", "LdcInsnNode", "(", "e", ")", ")", ";", "trig", ".", "add", "(", "new", "MethodInsnNode", "(", "INVOKEVIRTUAL", ",", "\"\"", ",", "\"trigger\"", ",", "\"\"", ")", ")", ";", "if", "(", "i1", ".", "getNext", "(", ")", ".", "getOpcode", "(", ")", "==", "ISTORE", ")", "{", "insns", ".", "insert", "(", "i1", ".", "getNext", "(", ")", ",", "trig", ")", ";", "}", "else", "{", "insns", ".", "insert", "(", "i1", ",", "trig", ")", ";", "}", "insns", ".", "insert", "(", "i1", ".", "getPrevious", "(", ")", ",", "new", "MethodInsnNode", "(", "INVOKEVIRTUAL", ",", "(", "(", "MethodInsnNode", ")", "i1", ")", ".", "owner", ",", "(", "(", "MethodInsnNode", ")", "i1", ")", ".", "name", ",", "(", "(", "MethodInsnNode", ")", "i1", ")", ".", "desc", ".", "replace", "(", "\"(\"", ",", "\"\"", ")", ")", ")", ";", "insns", ".", "remove", "(", "i1", ")", ";", "}", "}", "else", "{", "if", "(", "jumpinf", ".", "containsKey", "(", "i1", ")", ")", "{", "InsnList", "trig", "=", "new", "InsnList", "(", ")", ";", "trig", ".", "add", "(", "new", "VarInsnNode", "(", "ALOAD", ",", "localnum", ")", ")", ";", "trig", ".", "add", "(", "new", "VarInsnNode", "(", "ALOAD", ",", "0", ")", ")", ";", "trig", ".", "add", "(", "new", "MethodInsnNode", "(", "INVOKEVIRTUAL", ",", "\"\"", ",", "\"toString\"", ",", "\"\"", ")", ")", ";", "trig", ".", "add", "(", "new", "LdcInsnNode", "(", "jumpinf", ".", "get", "(", "i1", ")", ")", ")", ";", "trig", ".", "add", "(", "new", "MethodInsnNode", "(", "INVOKEVIRTUAL", ",", "\"\"", ",", "\"trigger\"", ",", "\"\"", ")", ")", ";", "insns", ".", "insert", "(", "i1", ".", "getNext", "(", ")", ",", "trig", ")", ";", "}", "else", "{", "if", "(", "i1", ".", "getOpcode", "(", ")", ">=", "IRETURN", "&&", "i1", ".", "getOpcode", "(", ")", "<=", "RETURN", ")", "{", "InsnList", "trig", "=", "new", "InsnList", "(", ")", ";", "trig", ".", "add", "(", "new", "VarInsnNode", "(", "ALOAD", ",", "localnum", ")", ")", ";", "trig", ".", "add", "(", "new", "VarInsnNode", "(", "ALOAD", ",", "0", ")", ")", ";", "trig", ".", "add", "(", "new", "MethodInsnNode", "(", "INVOKEVIRTUAL", ",", "\"\"", ",", "\"toString\"", ",", "\"\"", ")", ")", ";", "trig", ".", "add", "(", "new", "MethodInsnNode", "(", "INVOKEVIRTUAL", ",", "\"\"", ",", "\"trigger\"", ",", "\"\"", ")", ")", ";", "insns", ".", "insert", "(", "i1", ".", "getPrevious", "(", ")", ",", "trig", ")", ";", "}", "}", "}", "}", "insns", ".", "insert", "(", "insns", ".", "getFirst", "(", ")", ",", "begin", ")", ";", "}", "else", "{", "InsnList", "insns", "=", "mn", ".", "instructions", ";", "Iterator", "<", "AbstractInsnNode", ">", "i", "=", "insns", ".", "iterator", "(", ")", ";", "while", "(", "i", ".", "hasNext", "(", ")", ")", "{", "AbstractInsnNode", "i1", "=", "i", ".", "next", "(", ")", ";", "if", "(", "i1", "instanceof", "MethodInsnNode", ")", "{", "String", "owner", "=", "(", "(", "MethodInsnNode", ")", "i1", ")", ".", "owner", ";", "if", "(", "ejbs", ".", "contains", "(", "owner", ")", ")", "{", "InsnList", "il", "=", "new", "InsnList", "(", ")", ";", "il", ".", "add", "(", "new", "TypeInsnNode", "(", "NEW", ",", "\"\"", ")", ")", ";", "il", ".", "add", "(", "new", "InsnNode", "(", "DUP", ")", ")", ";", "il", ".", "add", "(", "new", "LdcInsnNode", "(", "\"/\"", ")", ")", ";", "il", ".", "add", "(", "new", "MethodInsnNode", "(", "INVOKESPECIAL", ",", "\"\"", ",", "\"<init>\"", ",", "\"\"", ")", ")", ";", "il", ".", "add", "(", "new", "VarInsnNode", "(", "ALOAD", ",", "0", ")", ")", ";", "il", ".", "add", "(", "new", "MethodInsnNode", "(", "INVOKEVIRTUAL", ",", "\"\"", ",", "\"toString\"", ",", "\"\"", ")", ")", ";", "il", ".", "add", "(", "new", "MethodInsnNode", "(", "INVOKEVIRTUAL", ",", "\"\"", ",", "\"append\"", ",", "\"\"", ")", ")", ";", "il", ".", "add", "(", "new", "MethodInsnNode", "(", "INVOKEVIRTUAL", ",", "\"\"", ",", "\"toString\"", ",", "\"\"", ")", ")", ";", "insns", ".", "insert", "(", "i1", ".", "getPrevious", "(", ")", ",", "il", ")", ";", "insns", ".", "insert", "(", "i1", ".", "getPrevious", "(", ")", ",", "new", "MethodInsnNode", "(", "INVOKEVIRTUAL", ",", "(", "(", "MethodInsnNode", ")", "i1", ")", ".", "owner", ",", "(", "(", "MethodInsnNode", ")", "i1", ")", ".", "name", ",", "(", "(", "MethodInsnNode", ")", "i1", ")", ".", "desc", ".", "replace", "(", "\"(\"", ",", "\"\"", ")", ")", ")", ";", "insns", ".", "remove", "(", "i1", ")", ";", "}", "}", "}", "}", "}", "}", "}", "}", "public", "void", "setNext", "(", ")", "{", "List", "<", "Event", ">", "event", "=", "stateMachine", ".", "getEvents", "(", ")", ";", "List", "state", "=", "stateMachine", ".", "getStates", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "stateMachine", ".", "getStatesCount", "(", ")", ";", "i", "++", ")", "{", "String", "nexts", "=", "\"\"", ";", "int", "sn", "=", "(", "Integer", ")", "state", ".", "get", "(", "i", ")", ";", "int", "j", ";", "for", "(", "j", "=", "0", ";", "j", "<", "event", ".", "size", "(", ")", ";", "j", "++", ")", "{", "if", "(", "sn", "==", "event", ".", "get", "(", "j", ")", ".", "getHead", "(", ")", ")", "{", "nexts", "=", "nexts", "+", "event", ".", "get", "(", "j", ")", ".", "getEvent", "(", ")", "+", "\"-\"", "+", "state", ".", "indexOf", "(", "event", ".", "get", "(", "j", ")", ".", "getTail", "(", ")", ")", "+", "\",\"", ";", "}", "}", "if", "(", "nexts", ".", "length", "(", ")", ">", "1", ")", "{", "nexts", ".", "subSequence", "(", "0", ",", "nexts", ".", "length", "(", ")", "-", "2", ")", ";", "}", "next", ".", "add", "(", "nexts", ")", ";", "System", ".", "out", ".", "println", "(", "i", "+", "\"next:\"", "+", "nexts", ")", ";", "}", "}", "public", "boolean", "isTransaction", "(", "MethodNode", "mn", ",", "String", "annotationDesc", ")", "{", "if", "(", "mn", ".", "visibleAnnotations", "!=", "null", ")", "{", "Iterator", "<", "AnnotationNode", ">", "i", "=", "mn", ".", "visibleAnnotations", ".", "iterator", "(", ")", ";", "while", "(", "i", ".", "hasNext", "(", ")", ")", "{", "AnnotationNode", "an", "=", "i", ".", "next", "(", ")", ";", "if", "(", "annotationDesc", ".", "equals", "(", "an", ".", "desc", ")", ")", "{", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}", "public", "void", "setEjbs", "(", "ClassNode", "cn", ")", "{", "if", "(", "cn", ".", "visibleAnnotations", "!=", "null", ")", "{", "Iterator", "<", "AnnotationNode", ">", "i", "=", "cn", ".", "visibleAnnotations", ".", "iterator", "(", ")", ";", "while", "(", "i", ".", "hasNext", "(", ")", ")", "{", "AnnotationNode", "an", "=", "i", ".", "next", "(", ")", ";", "if", "(", "an", ".", "desc", ".", "contains", "(", "\"AEjb\"", ")", "||", "an", ".", "desc", ".", "contains", "(", "\"Ejb\"", ")", ")", "{", "String", "ejb", "=", "an", ".", "values", ".", "get", "(", "1", ")", ".", "toString", "(", ")", ".", "split", "(", "\"/\"", ")", "[", "0", "]", ";", "ejbs", ".", "add", "(", "ejb", ")", ";", "}", "}", "}", "for", "(", "FieldNode", "fn", ":", "(", "List", "<", "FieldNode", ">", ")", "cn", ".", "fields", ")", "{", "if", "(", "fn", ".", "visibleAnnotations", "!=", "null", ")", "{", "Iterator", "<", "AnnotationNode", ">", "fi", "=", "fn", ".", "visibleAnnotations", ".", "iterator", "(", ")", ";", "while", "(", "fi", ".", "hasNext", "(", ")", ")", "{", "AnnotationNode", "fa", "=", "fi", ".", "next", "(", ")", ";", "if", "(", "fa", ".", "desc", ".", "contains", "(", "\"AEjb\"", ")", "||", "fa", ".", "desc", ".", "contains", "(", "\"Ejb\"", ")", ")", "{", "String", "ejb", "=", "fa", ".", "values", ".", "get", "(", "1", ")", ".", "toString", "(", ")", ".", "split", "(", "\"/\"", ")", "[", "0", "]", ";", "ejbs", ".", "add", "(", "ejb", ")", ";", "}", "}", "}", "}", "}", "public", "void", "ExtractControlFlow", "(", "String", "owner", ",", "final", "MethodNode", "mn", ")", "throws", "AnalyzerException", "{", "Analyzer", "a", "=", "new", "Analyzer", "(", "new", "BasicInterpreter", "(", ")", ")", "{", "@", "Override", "protected", "void", "newControlFlowEdge", "(", "int", "src", ",", "int", "dst", ")", "{", "controlflow", ".", "addFlow", "(", "src", ",", "dst", ")", ";", "if", "(", "src", ">", "dst", ")", "{", "controlflow", ".", "getFlow", "(", "src", ")", ".", "setIsWhile", "(", "true", ")", ";", "}", "}", "}", ";", "a", ".", "analyze", "(", "owner", ",", "mn", ")", ";", "}", "public", "void", "recognize_state", "(", "int", "src", ",", "int", "last_state", ",", "InsnList", "insns", ")", "{", "if", "(", "src", "<", "stateMachine", ".", "getEnd", "(", ")", ")", "{", "if", "(", "stateMachine", ".", "getStates", "(", ")", ".", "contains", "(", "src", ")", ")", "{", "stateMachine", ".", "addEvent", "(", "new", "Event", "(", "last_state", ",", "src", ",", "\"\"", ")", ")", ";", "}", "else", "{", "AbstractInsnNode", "an", "=", "insns", ".", "get", "(", "src", ")", ";", "if", "(", "an", "instanceof", "MethodInsnNode", ")", "{", "String", "owner", "=", "(", "(", "MethodInsnNode", ")", "an", ")", ".", "owner", ";", "String", "e", "=", "\"Ejb.\"", "+", "owner", "+", "\".\"", "+", "(", "(", "MethodInsnNode", ")", "an", ")", ".", "name", ";", "if", "(", "ejbs", ".", "contains", "(", "owner", ")", ")", "{", "stateMachine", ".", "addState", "(", "src", ")", ";", "stateMachine", ".", "addEvent", "(", "new", "Event", "(", "last_state", ",", "src", ",", "e", ")", ")", ";", "last_state", "=", "src", ";", "recognize_state", "(", "src", "+", "1", ",", "last_state", ",", "insns", ")", ";", "}", "}", "else", "{", "if", "(", "an", "instanceof", "JumpInsnNode", ")", "{", "int", "dst", "=", "-", "1", ";", "if", "(", "an", ".", "getOpcode", "(", ")", "==", "GOTO", ")", "{", "dst", "=", "(", "Integer", ")", "controlflow", ".", "getFlow", "(", "src", ")", ".", "dst", ".", "get", "(", "0", ")", ";", "recognize_state", "(", "dst", "+", "1", ",", "last_state", ",", "insns", ")", ";", "}", "else", "{", "stateMachine", ".", "addState", "(", "src", ")", ";", "stateMachine", ".", "addEvent", "(", "new", "Event", "(", "last_state", ",", "src", ",", "\"\"", ")", ")", ";", "if", "(", "controlflow", ".", "getFlow", "(", "src", ")", ".", "isWhile", ")", "{", "for", "(", "int", "k", "=", "0", ";", "k", "<", "controlflow", ".", "getDstSize", "(", "src", ")", ";", "k", "++", ")", "{", "dst", "=", "(", "Integer", ")", "controlflow", ".", "getDst", "(", "src", ")", ".", "get", "(", "k", ")", ";", "if", "(", "src", "<", "dst", ")", "{", "stateMachine", ".", "addState", "(", "dst", ")", ";", "stateMachine", ".", "addEvent", "(", "new", "Event", "(", "src", ",", "dst", ",", "\"while(\"", "+", "src", "+", "\")F\"", ")", ")", ";", "jumpinf", ".", "put", "(", "insns", ".", "get", "(", "dst", ")", ",", "\"while(\"", "+", "src", "+", "\")F\"", ")", ";", "recognize_state", "(", "dst", "+", "1", ",", "dst", ",", "insns", ")", ";", "}", "else", "{", "stateMachine", ".", "addState", "(", "dst", ")", ";", "stateMachine", ".", "addEvent", "(", "new", "Event", "(", "src", ",", "dst", ",", "\"while(\"", "+", "src", "+", "\")T\"", ")", ")", ";", "jumpinf", ".", "put", "(", "insns", ".", "get", "(", "dst", ")", ",", "\"while(\"", "+", "src", "+", "\")T\"", ")", ";", "recognize_state", "(", "dst", "+", "1", ",", "dst", ",", "insns", ")", ";", "}", "}", "}", "else", "{", "for", "(", "int", "k", "=", "0", ";", "k", "<", "controlflow", ".", "getDstSize", "(", "src", ")", ";", "k", "++", ")", "{", "dst", "=", "(", "Integer", ")", "controlflow", ".", "getDst", "(", "src", ")", ".", "get", "(", "k", ")", ";", "stateMachine", ".", "addState", "(", "dst", ")", ";", "stateMachine", ".", "addEvent", "(", "new", "Event", "(", "src", ",", "dst", ",", "\"if(\"", "+", "src", "+", "\")\"", "+", "k", ")", ")", ";", "jumpinf", ".", "put", "(", "insns", ".", "get", "(", "dst", ")", ",", "\"if(\"", "+", "src", "+", "\")\"", "+", "k", ")", ";", "recognize_state", "(", "dst", "+", "1", ",", "dst", ",", "insns", ")", ";", "}", "}", "}", "}", "else", "{", "if", "(", "an", ".", "getOpcode", "(", ")", ">=", "IRETURN", "&&", "an", ".", "getOpcode", "(", ")", "<=", "RETURN", ")", "{", "stateMachine", ".", "addState", "(", "src", ")", ";", "stateMachine", ".", "addEvent", "(", "new", "Event", "(", "last_state", ",", "src", ",", "\"end\"", ")", ")", ";", "}", "else", "{", "recognize_state", "(", "src", "+", "1", ",", "last_state", ",", "insns", ")", ";", "}", "}", "}", "}", "}", "else", "{", "stateMachine", ".", "addState", "(", "stateMachine", ".", "getEnd", "(", ")", ")", ";", "stateMachine", ".", "addEvent", "(", "new", "Event", "(", "last_state", ",", "src", ",", "\"end\"", ")", ")", ";", "}", "}", "public", "void", "mergeState", "(", ")", "{", "stateMachine", ".", "getStates", "(", ")", ".", "add", "(", "0", ",", "stateMachine", ".", "getStart", "(", ")", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "stateMachine", ".", "getEvents", "(", ")", ".", "size", "(", ")", ";", "i", "++", ")", "{", "Event", "event", "=", "stateMachine", ".", "getEvents", "(", ")", ".", "get", "(", "i", ")", ";", "if", "(", "event", ".", "getEvent", "(", ")", ".", "isEmpty", "(", ")", "||", "event", ".", "getEvent", "(", ")", ".", "contains", "(", "\"end\"", ")", ")", "{", "int", "src", "=", "event", ".", "getHead", "(", ")", ";", "int", "dst", "=", "event", ".", "getTail", "(", ")", ";", "stateMachine", ".", "mergeStates", "(", "src", ",", "dst", ")", ";", "stateMachine", ".", "getEvents", "(", ")", ".", "remove", "(", "i", ")", ";", "}", "}", "}", "public", "void", "showEvent", "(", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "stateMachine", ".", "getEvents", "(", ")", ".", "size", "(", ")", ";", "i", "++", ")", "{", "Event", "event", "=", "stateMachine", ".", "getEvents", "(", ")", ".", "get", "(", "i", ")", ";", "int", "src", "=", "event", ".", "getHead", "(", ")", ";", "int", "dst", "=", "event", ".", "getTail", "(", ")", ";", "System", ".", "out", ".", "println", "(", "src", "+", "\"-\"", "+", "event", ".", "getEvent", "(", ")", "+", "\"-\"", "+", "dst", ")", ";", "}", "}", "public", "void", "ExtractMetaData", "(", ")", "{", "int", "states_count", "=", "stateMachine", ".", "getStatesCount", "(", ")", ";", "List", "[", "]", "state", "=", "new", "LinkedList", "[", "states_count", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "states_count", ";", "i", "++", ")", "state", "[", "i", "]", "=", "new", "LinkedList", "(", ")", ";", "List", "s", "=", "stateMachine", ".", "getStates", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "states_count", ";", "i", "++", ")", "{", "System", ".", "out", ".", "println", "(", "i", "+", "\":\"", "+", "s", ".", "get", "(", "i", ")", ")", ";", "}", "List", "<", "Event", ">", "e", "=", "stateMachine", ".", "getEvents", "(", ")", ";", "past", "=", "new", "LinkedList", "[", "states_count", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "states_count", ";", "i", "++", ")", "past", "[", "i", "]", "=", "new", "LinkedList", "(", ")", ";", "future", "=", "new", "LinkedList", "[", "states_count", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "states_count", ";", "i", "++", ")", "future", "[", "i", "]", "=", "new", "LinkedList", "(", ")", ";", "boolean", "changed", "=", "true", ";", "while", "(", "changed", ")", "{", "changed", "=", "false", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "e", ".", "size", "(", ")", ";", "i", "++", ")", "{", "Event", "event", "=", "(", "Event", ")", "e", ".", "get", "(", "i", ")", ";", "int", "head", "=", "event", ".", "getHead", "(", ")", ";", "int", "tail", "=", "event", ".", "getTail", "(", ")", ";", "String", "port", "=", "event", ".", "getPort", "(", ")", ";", "int", "headindex", "=", "s", ".", "indexOf", "(", "head", ")", ";", "int", "tailindex", "=", "s", ".", "indexOf", "(", "tail", ")", ";", "if", "(", "port", "!=", "null", "&&", "!", "past", "[", "tailindex", "]", ".", "contains", "(", "port", ")", ")", "{", "past", "[", "tailindex", "]", ".", "add", "(", "port", ")", ";", "changed", "=", "true", ";", "}", "if", "(", "head", "!=", "stateMachine", ".", "getStart", "(", ")", "&&", "headindex", "!=", "-", "1", ")", "for", "(", "int", "j", "=", "0", ";", "j", "<", "past", "[", "headindex", "]", ".", "size", "(", ")", ";", "j", "++", ")", "{", "if", "(", "!", "past", "[", "tailindex", "]", ".", "contains", "(", "past", "[", "headindex", "]", ".", "get", "(", "j", ")", ")", ")", "{", "past", "[", "tailindex", "]", ".", "add", "(", "past", "[", "headindex", "]", ".", "get", "(", "j", ")", ")", ";", "changed", "=", "true", ";", "}", "}", "}", "}", "changed", "=", "true", ";", "while", "(", "changed", ")", "{", "changed", "=", "false", ";", "for", "(", "int", "i", "=", "e", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "Event", "event", "=", "(", "Event", ")", "e", ".", "get", "(", "i", ")", ";", "int", "head", "=", "event", ".", "getHead", "(", ")", ";", "int", "tail", "=", "event", ".", "getTail", "(", ")", ";", "String", "port", "=", "event", ".", "getPort", "(", ")", ";", "int", "headindex", "=", "s", ".", "indexOf", "(", "head", ")", ";", "int", "tailindex", "=", "s", ".", "indexOf", "(", "tail", ")", ";", "if", "(", "port", "!=", "null", "&&", "!", "future", "[", "headindex", "]", ".", "contains", "(", "port", ")", ")", "{", "future", "[", "headindex", "]", ".", "add", "(", "port", ")", ";", "changed", "=", "true", ";", "}", "if", "(", "tail", "!=", "stateMachine", ".", "getEnd", "(", ")", ")", "for", "(", "int", "j", "=", "0", ";", "j", "<", "future", "[", "tailindex", "]", ".", "size", "(", ")", ";", "j", "++", ")", "{", "if", "(", "!", "future", "[", "headindex", "]", ".", "contains", "(", "future", "[", "tailindex", "]", ".", "get", "(", "j", ")", ")", ")", "{", "future", "[", "headindex", "]", ".", "add", "(", "future", "[", "tailindex", "]", ".", "get", "(", "j", ")", ")", ";", "changed", "=", "true", ";", "}", "}", "}", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "states_count", ";", "i", "++", ")", "{", "int", "k", "=", "0", ",", "p", "=", "0", ";", "String", "sall", "=", "\"\"", ";", "if", "(", "future", "[", "i", "]", ".", "size", "(", ")", ">", "0", ")", "{", "for", "(", "k", "=", "0", ";", "k", "<", "future", "[", "i", "]", ".", "size", "(", ")", "-", "1", ";", "k", "++", ")", "{", "sall", "=", "sall", "+", "future", "[", "i", "]", ".", "get", "(", "k", ")", "+", "\",\"", ";", "}", "sall", "=", "sall", "+", "future", "[", "i", "]", ".", "get", "(", "k", ")", ";", "}", "sall", "=", "sall", "+", "\";\"", ";", "if", "(", "past", "[", "i", "]", ".", "size", "(", ")", ">", "0", ")", "{", "for", "(", "p", "=", "0", ";", "p", "<", "past", "[", "i", "]", ".", "size", "(", ")", "-", "1", ";", "p", "++", ")", "{", "sall", "=", "sall", "+", "past", "[", "i", "]", ".", "get", "(", "p", ")", "+", "\",\"", ";", "}", "sall", "=", "sall", "+", "past", "[", "i", "]", ".", "get", "(", "p", ")", ";", "}", "System", ".", "out", ".", "println", "(", "i", "+", "\":\"", "+", "sall", ")", ";", "stateall", ".", "add", "(", "sall", ")", ";", "}", "}", "public", "static", "void", "showClassSource", "(", "String", "file", ")", "{", "FileInputStream", "is", ";", "ClassReader", "cr", ";", "try", "{", "is", "=", "new", "FileInputStream", "(", "file", ")", ";", "cr", "=", "new", "ClassReader", "(", "is", ")", ";", "TraceClassVisitor", "trace", "=", "new", "TraceClassVisitor", "(", "new", "PrintWriter", "(", "System", ".", "out", ")", ")", ";", "cr", ".", "accept", "(", "trace", ",", "ClassReader", ".", "EXPAND_FRAMES", ")", ";", "is", ".", "close", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "public", "ClassVisitor", "getClassAdapter", "(", "final", "ClassVisitor", "cvr", ")", "{", "return", "new", "ClassNode", "(", ")", "{", "@", "Override", "public", "void", "visitEnd", "(", ")", "{", "transform", "(", "this", ")", ";", "this", ".", "accept", "(", "cvr", ")", ";", "}", "}", ";", "}", "protected", "static", "void", "begin_analyze", "(", "File", "tempFile", ")", "{", "if", "(", "tempFile", ".", "isDirectory", "(", ")", ")", "{", "File", "file", "[", "]", "=", "tempFile", ".", "listFiles", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "file", ".", "length", ";", "i", "++", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", "+", "file", "[", "i", "]", ".", "getName", "(", ")", ")", ";", "begin_analyze", "(", "file", "[", "i", "]", ")", ";", "}", "}", "else", "{", "try", "{", "if", "(", "tempFile", ".", "getName", "(", ")", ".", "endsWith", "(", "\".class\"", ")", ")", "{", "System", ".", "out", ".", "println", "(", "tempFile", ".", "getName", "(", ")", ")", ";", "FileInputStream", "input", "=", "new", "FileInputStream", "(", "tempFile", ".", "getAbsolutePath", "(", ")", ")", ";", "ProgramAnalyzer", "t", "=", "new", "ProgramAnalyzer", "(", ")", ";", "ClassReader", "cr", "=", "new", "ClassReader", "(", "input", ")", ";", "ClassWriter", "cw", "=", "new", "ClassWriter", "(", "ClassWriter", ".", "COMPUTE_FRAMES", ")", ";", "ClassVisitor", "cv", "=", "t", ".", "getClassAdapter", "(", "cw", ")", ";", "cr", ".", "accept", "(", "cv", ",", "0", ")", ";", "byte", "[", "]", "b", "=", "cw", ".", "toByteArray", "(", ")", ";", "FileOutputStream", "fout", "=", "new", "FileOutputStream", "(", "new", "File", "(", "tempFile", ".", "getAbsolutePath", "(", ")", ")", ")", ";", "fout", ".", "write", "(", "b", ")", ";", "fout", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "}", "public", "static", "void", "main", "(", "String", "args", "[", "]", ")", "{", "try", "{", "JarTool", "jarHelper", "=", "new", "JarTool", "(", ")", ";", "File", "srcJar", "=", "new", "File", "(", "\"E:\\\\a.jar\"", ")", ";", "File", "tempFile", "=", "new", "File", "(", "\"e:\\\\temp\"", ")", ";", "tempFile", ".", "mkdir", "(", ")", ";", "File", "destJar", "=", "new", "File", "(", "\"E:\\\\bb.jar\"", ")", ";", "jarHelper", ".", "unjarDir", "(", "srcJar", ",", "tempFile", ")", ";", "ProgramAnalyzer", ".", "begin_analyze", "(", "tempFile", ")", ";", "jarHelper", ".", "jarDir", "(", "tempFile", ",", "destJar", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "}", "</s>" ]
10,108
[ "<s>", "package", "javax", ".", "aejb", ";", "import", "static", "java", ".", "lang", ".", "annotation", ".", "RetentionPolicy", ".", "RUNTIME", ";", "import", "java", ".", "lang", ".", "annotation", ".", "ElementType", ";", "import", "java", ".", "lang", ".", "annotation", ".", "Retention", ";", "import", "java", ".", "lang", ".", "annotation", ".", "Target", ";", "@", "Retention", "(", "RUNTIME", ")", "@", "Target", "(", "ElementType", ".", "METHOD", ")", "public", "@", "interface", "Transaction", "{", "String", "name", "(", ")", "default", "\"\"", ";", "String", "[", "]", "states", "(", ")", "default", "{", "\"\"", "}", ";", "String", "[", "]", "next", "(", ")", "default", "{", "\"\"", "}", ";", "}", "</s>" ]
10,109
[ "<s>", "package", "javax", ".", "aejb", ";", "public", "interface", "TransactionTrigger", "{", "void", "trigger", "(", "String", "objectId", ",", "String", "eventName", ")", ";", "void", "trigger", "(", "String", "objectId", ")", ";", "}", "</s>" ]
10,110
[ "<s>", "package", "javax", ".", "aejb", ";", "import", "java", ".", "lang", ".", "annotation", ".", "ElementType", ";", "import", "java", ".", "lang", ".", "annotation", ".", "Retention", ";", "import", "java", ".", "lang", ".", "annotation", ".", "Target", ";", "import", "java", ".", "lang", ".", "annotation", ".", "RetentionPolicy", ";", "@", "Target", "(", "ElementType", ".", "TYPE", ")", "@", "Retention", "(", "RetentionPolicy", ".", "RUNTIME", ")", "public", "@", "interface", "Adaptive", "{", "}", "</s>" ]
10,111
[ "<s>", "package", "javax", ".", "aejb", ";", "import", "static", "java", ".", "lang", ".", "annotation", ".", "ElementType", ".", "FIELD", ";", "import", "static", "java", ".", "lang", ".", "annotation", ".", "RetentionPolicy", ".", "RUNTIME", ";", "import", "java", ".", "lang", ".", "annotation", ".", "Retention", ";", "import", "java", ".", "lang", ".", "annotation", ".", "Target", ";", "@", "Retention", "(", "RUNTIME", ")", "@", "Target", "(", "FIELD", ")", "public", "@", "interface", "AEjb", "{", "String", "name", "(", ")", "default", "\"\"", ";", "Class", "beanInterface", "(", ")", "default", "java", ".", "lang", ".", "Object", ".", "class", ";", "String", "beanName", "(", ")", "default", "\"\"", ";", "String", "lookup", "(", ")", "default", "\"\"", ";", "String", "mappedName", "(", ")", "default", "\"\"", ";", "String", "description", "(", ")", "default", "\"\"", ";", "}", "</s>" ]
10,112
[ "<s>", "package", "org", ".", "nju", ".", "artemis", ".", "aejb", ".", "client", ";", "import", "java", ".", "lang", ".", "reflect", ".", "InvocationTargetException", ";", "import", "javax", ".", "ejb", ".", "Remote", ";", "import", "javax", ".", "ejb", ".", "Stateless", ";", "import", "javax", ".", "naming", ".", "InitialContext", ";", "import", "javax", ".", "naming", ".", "NamingException", ";", "@", "Stateless", "@", "Remote", "(", "AEjbClient", ".", "class", ")", "public", "class", "AEjbClientBean", "implements", "AEjbClient", "{", "private", "Object", "createAEjbClient", "(", ")", "{", "try", "{", "return", "new", "InitialContext", "(", ")", ".", "lookup", "(", "\"\"", ")", ";", "}", "catch", "(", "NamingException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "return", "null", ";", "}", "@", "Override", "public", "Object", "getAEjbClient", "(", ")", "{", "return", "createAEjbClient", "(", ")", ";", "}", "@", "Override", "public", "boolean", "blockAEjb", "(", "String", "aejbName", ")", "{", "Object", "client", "=", "createAEjbClient", "(", ")", ";", "try", "{", "return", "(", "Boolean", ")", "client", ".", "getClass", "(", ")", ".", "getDeclaredMethod", "(", "\"blockAEjb\"", ",", "String", ".", "class", ")", ".", "invoke", "(", "client", ",", "aejbName", ")", ";", "}", "catch", "(", "IllegalArgumentException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "catch", "(", "SecurityException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "catch", "(", "IllegalAccessException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "catch", "(", "InvocationTargetException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "catch", "(", "NoSuchMethodException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "return", "false", ";", "}", "@", "Override", "public", "boolean", "resumeAEjb", "(", "String", "aejbName", ")", "{", "Object", "client", "=", "createAEjbClient", "(", ")", ";", "try", "{", "return", "(", "Boolean", ")", "client", ".", "getClass", "(", ")", ".", "getDeclaredMethod", "(", "\"resumeAEjb\"", ",", "String", ".", "class", ")", ".", "invoke", "(", "client", ",", "aejbName", ")", ";", "}", "catch", "(", "IllegalArgumentException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "catch", "(", "SecurityException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "catch", "(", "IllegalAccessException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "catch", "(", "InvocationTargetException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "catch", "(", "NoSuchMethodException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "return", "false", ";", "}", "@", "Override", "public", "boolean", "switchAEjb", "(", "String", "fromName", ",", "String", "toName", ",", "String", "protocol", ")", "{", "Object", "client", "=", "createAEjbClient", "(", ")", ";", "try", "{", "return", "(", "Boolean", ")", "client", ".", "getClass", "(", ")", ".", "getDeclaredMethod", "(", "\"switchAEjb\"", ",", "String", ".", "class", ",", "String", ".", "class", ",", "String", ".", "class", ")", ".", "invoke", "(", "client", ",", "fromName", ",", "toName", ",", "protocol", ")", ";", "}", "catch", "(", "IllegalArgumentException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "catch", "(", "SecurityException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "catch", "(", "IllegalAccessException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "catch", "(", "InvocationTargetException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "catch", "(", "NoSuchMethodException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "return", "false", ";", "}", "@", "Override", "public", "boolean", "replaceAEjb", "(", "String", "fromName", ",", "String", "toName", ",", "String", "protocol", ")", "{", "return", "false", ";", "}", "}", "</s>" ]
10,113
[ "<s>", "package", "org", ".", "nju", ".", "artemis", ".", "aejb", ".", "client", ";", "public", "interface", "AEjbClient", "{", "Object", "getAEjbClient", "(", ")", ";", "boolean", "blockAEjb", "(", "String", "aejbName", ")", ";", "boolean", "resumeAEjb", "(", "String", "aejbName", ")", ";", "boolean", "switchAEjb", "(", "String", "fromName", ",", "String", "toName", ",", "String", "protocol", ")", ";", "boolean", "replaceAEjb", "(", "String", "fromName", ",", "String", "toName", ",", "String", "protocol", ")", ";", "}", "</s>" ]
10,114
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "tests", ";", "import", "junit", ".", "framework", ".", "TestCase", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "BorderLayout", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Ellipse", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "IFigure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Label", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "IStructuredContentProvider", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "LabelProvider", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "Viewer", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Shell", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "GraphViewer", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "IFigureProvider", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "IGraphContentProvider", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "custom", ".", "CGraphNode", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "GraphViewerTests", ".", "SampleGraphContentProvider", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "GraphViewerTests", ".", "SampleGraphEntityContentProvider", ";", "public", "class", "IFigureProviderTests", "extends", "TestCase", "{", "private", "GraphViewer", "viewer", ";", "private", "Shell", "shell", ";", "public", "void", "setUp", "(", ")", "{", "shell", "=", "new", "Shell", "(", ")", ";", "viewer", "=", "new", "GraphViewer", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "}", "public", "void", "testWithDestinationProvider", "(", ")", "{", "testWith", "(", "new", "DestinationContentProvider", "(", ")", ")", ";", "}", "public", "void", "testWithSourceProvider", "(", ")", "{", "testWith", "(", "new", "SourceContentProvider", "(", ")", ")", ";", "}", "public", "void", "testWithGraphProvider", "(", ")", "{", "testWith", "(", "new", "SampleGraphEntityContentProvider", "(", ")", ")", ";", "}", "public", "void", "testWithGraphEntityProvider", "(", ")", "{", "testWith", "(", "new", "SampleGraphContentProvider", "(", ")", ")", ";", "}", "private", "void", "testWith", "(", "IStructuredContentProvider", "contentProvider", ")", "{", "viewer", ".", "setContentProvider", "(", "contentProvider", ")", ";", "viewer", ".", "setLabelProvider", "(", "new", "CustomLabelProvider", "(", ")", ")", ";", "viewer", ".", "setInput", "(", "new", "Object", "(", ")", ")", ";", "StringBuffer", "buffer", "=", "new", "StringBuffer", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "viewer", ".", "getGraphControl", "(", ")", ".", "getNodes", "(", ")", ".", "size", "(", ")", ";", "i", "++", ")", "{", "CGraphNode", "n", "=", "(", "CGraphNode", ")", "viewer", ".", "getGraphControl", "(", ")", ".", "getNodes", "(", ")", ".", "get", "(", "i", ")", ";", "buffer", ".", "append", "(", "(", "(", "Label", ")", "n", ".", "getFigure", "(", ")", ".", "getChildren", "(", ")", ".", "get", "(", "0", ")", ")", ".", "getText", "(", ")", ")", ";", "}", "String", "string", "=", "buffer", ".", "toString", "(", ")", ";", "assertTrue", "(", "\"\"", ",", "string", ".", "contains", "(", "\"1\"", ")", ")", ";", "assertTrue", "(", "\"\"", ",", "string", ".", "contains", "(", "\"2\"", ")", ")", ";", "assertTrue", "(", "\"\"", ",", "string", ".", "contains", "(", "\"3\"", ")", ")", ";", "}", "private", "class", "DestinationContentProvider", "implements", "IGraphContentProvider", "{", "public", "void", "dispose", "(", ")", "{", "}", "public", "void", "inputChanged", "(", "Viewer", "arg0", ",", "Object", "arg1", ",", "Object", "arg2", ")", "{", "}", "public", "Object", "getDestination", "(", "Object", "r", ")", "{", "if", "(", "r", ".", "equals", "(", "\"1to2\"", ")", ")", "return", "\"2\"", ";", "if", "(", "r", ".", "equals", "(", "\"2to3\"", ")", ")", "return", "\"3\"", ";", "if", "(", "r", ".", "equals", "(", "\"3to1\"", ")", ")", "return", "\"1\"", ";", "return", "null", ";", "}", "public", "Object", "[", "]", "getElements", "(", "Object", "arg0", ")", "{", "return", "new", "String", "[", "]", "{", "\"1to2\"", ",", "\"2to3\"", ",", "\"3to1\"", "}", ";", "}", "public", "Object", "getSource", "(", "Object", "r", ")", "{", "return", "null", ";", "}", "}", "private", "class", "SourceContentProvider", "implements", "IGraphContentProvider", "{", "public", "void", "dispose", "(", ")", "{", "}", "public", "void", "inputChanged", "(", "Viewer", "arg0", ",", "Object", "arg1", ",", "Object", "arg2", ")", "{", "}", "public", "Object", "getDestination", "(", "Object", "r", ")", "{", "return", "null", ";", "}", "public", "Object", "[", "]", "getElements", "(", "Object", "arg0", ")", "{", "return", "new", "String", "[", "]", "{", "\"1to2\"", ",", "\"2to3\"", ",", "\"3to1\"", "}", ";", "}", "public", "Object", "getSource", "(", "Object", "r", ")", "{", "if", "(", "r", ".", "equals", "(", "\"1to2\"", ")", ")", "return", "\"1\"", ";", "if", "(", "r", ".", "equals", "(", "\"2to3\"", ")", ")", "return", "\"2\"", ";", "if", "(", "r", ".", "equals", "(", "\"3to1\"", ")", ")", "return", "\"3\"", ";", "return", "null", ";", "}", "}", "private", "class", "CustomLabelProvider", "extends", "LabelProvider", "implements", "IFigureProvider", "{", "public", "String", "getText", "(", "Object", "node", ")", "{", "return", "node", ".", "toString", "(", ")", ";", "}", "public", "IFigure", "getFigure", "(", "Object", "node", ")", "{", "Ellipse", "e", "=", "new", "Ellipse", "(", ")", ";", "e", ".", "setSize", "(", "40", ",", "40", ")", ";", "e", ".", "setLayoutManager", "(", "new", "BorderLayout", "(", ")", ")", ";", "e", ".", "add", "(", "new", "Label", "(", "node", ".", "toString", "(", ")", ")", ",", "BorderLayout", ".", "CENTER", ")", ";", "return", "e", ";", "}", "}", "}", "</s>" ]
10,115
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "tests", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "cloudio", ".", "TagCloudTests", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "cloudio", ".", "TagCloudViewerTests", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ".", "DotExportSuite", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ".", "DotImportSuite", ";", "import", "org", ".", "junit", ".", "runner", ".", "RunWith", ";", "import", "org", ".", "junit", ".", "runners", ".", "Suite", ";", "@", "RunWith", "(", "Suite", ".", "class", ")", "@", "Suite", ".", "SuiteClasses", "(", "{", "GraphTests", ".", "class", ",", "GraphSelectionTests", ".", "class", ",", "GraphViewerTests", ".", "class", ",", "IFigureProviderTests", ".", "class", ",", "LayoutAlgorithmTests", ".", "class", ",", "DotExportSuite", ".", "class", ",", "DotImportSuite", ".", "class", ",", "TagCloudTests", ".", "class", ",", "TagCloudViewerTests", ".", "class", "}", ")", "public", "final", "class", "AllHeadlessTests", "{", "}", "</s>" ]
10,116
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "tests", ";", "import", "junit", ".", "framework", ".", "Assert", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "Platform", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ".", "TestDotDirStore", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ".", "TestDotExtractor", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ".", "TestZestGraphView", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "runner", ".", "RunWith", ";", "import", "org", ".", "junit", ".", "runners", ".", "Suite", ";", "@", "RunWith", "(", "Suite", ".", "class", ")", "@", "Suite", ".", "SuiteClasses", "(", "{", "TestDotDirStore", ".", "class", ",", "TestDotExtractor", ".", "class", ",", "TestZestGraphView", ".", "class", "}", ")", "public", "final", "class", "AllUiTests", "{", "@", "Before", "public", "void", "setup", "(", ")", "{", "if", "(", "!", "Platform", ".", "isRunning", "(", ")", ")", "{", "Assert", ".", "fail", "(", "\"\"", ")", ";", "}", "}", "}", "</s>" ]
10,117
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "tests", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "junit", ".", "framework", ".", "Assert", ";", "import", "junit", ".", "framework", ".", "TestCase", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "util", ".", "DelegatingDragAdapter", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "IContentProvider", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "ISelectionChangedListener", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "SelectionChangedEvent", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "StructuredSelection", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "Viewer", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "ViewerFilter", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "dnd", ".", "DND", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "dnd", ".", "DropTarget", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "dnd", ".", "TextTransfer", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "dnd", ".", "Transfer", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Event", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Shell", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "GraphViewer", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "IGraphContentProvider", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "IGraphEntityContentProvider", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "Graph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphConnection", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphItem", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphNode", ";", "public", "class", "GraphViewerTests", "extends", "TestCase", "{", "private", "GraphViewer", "viewer", ";", "private", "Shell", "shell", ";", "public", "void", "setUp", "(", ")", "{", "shell", "=", "new", "Shell", "(", ")", ";", "viewer", "=", "new", "GraphViewer", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "}", "public", "void", "testDisposalWithDropTarget", "(", ")", "{", "new", "DropTarget", "(", "viewer", ".", "getGraphControl", "(", ")", ",", "DND", ".", "DROP_MOVE", "|", "DND", ".", "DROP_COPY", ")", ";", "shell", ".", "dispose", "(", ")", ";", "Assert", ".", "assertTrue", "(", "\"\"", ",", "viewer", ".", "getControl", "(", ")", ".", "isDisposed", "(", ")", ")", ";", "}", "public", "void", "testDisposalWithDragSource", "(", ")", "{", "viewer", ".", "addDragSupport", "(", "DND", ".", "DROP_MOVE", ",", "new", "Transfer", "[", "]", "{", "TextTransfer", ".", "getInstance", "(", ")", "}", ",", "new", "DelegatingDragAdapter", "(", ")", ")", ";", "shell", ".", "dispose", "(", ")", ";", "Assert", ".", "assertTrue", "(", "\"\"", ",", "viewer", ".", "getControl", "(", ")", ".", "isDisposed", "(", ")", ")", ";", "}", "public", "void", "testCreateFromGraph", "(", ")", "{", "Graph", "g", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ")", ",", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ")", ")", ";", "GraphViewer", "v", "=", "new", "GraphViewer", "(", "g", ")", ";", "Assert", ".", "assertEquals", "(", "2", ",", "v", ".", "getGraphControl", "(", ")", ".", "getNodes", "(", ")", ".", "size", "(", ")", ")", ";", "Assert", ".", "assertEquals", "(", "1", ",", "v", ".", "getGraphControl", "(", ")", ".", "getConnections", "(", ")", ".", "size", "(", ")", ")", ";", "}", "public", "void", "testFindGraphItem", "(", ")", "{", "Assert", ".", "assertNull", "(", "\"\"", ",", "viewer", ".", "findGraphItem", "(", "new", "Integer", "(", "5", ")", ")", ")", ";", "}", "public", "void", "testValidSelection", "(", ")", "{", "Graph", "graph", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "GraphNode", "n1", "=", "new", "GraphNode", "(", "graph", ",", "SWT", ".", "NONE", ")", ";", "GraphNode", "n2", "=", "new", "GraphNode", "(", "graph", ",", "SWT", ".", "NONE", ")", ";", "GraphConnection", "c", "=", "new", "GraphConnection", "(", "graph", ",", "SWT", ".", "NONE", ",", "n1", ",", "n2", ")", ";", "graph", ".", "setSelection", "(", "new", "GraphItem", "[", "]", "{", "n1", ",", "n2", ",", "c", "}", ")", ";", "GraphViewer", "viewer", "=", "new", "GraphViewer", "(", "graph", ")", ";", "assertEquals", "(", "\"\"", ",", "0", ",", "(", "(", "StructuredSelection", ")", "viewer", ".", "getSelection", "(", ")", ")", ".", "size", "(", ")", ")", ";", "n1", ".", "setData", "(", "\"1\"", ")", ";", "n2", ".", "setData", "(", "\"2\"", ")", ";", "assertEquals", "(", "\"\"", ",", "2", ",", "(", "(", "StructuredSelection", ")", "viewer", ".", "getSelection", "(", ")", ")", ".", "size", "(", ")", ")", ";", "}", "public", "void", "testPostSelectionListener", "(", ")", "{", "final", "List", "<", "SelectionChangedEvent", ">", "selected", "=", "new", "ArrayList", "<", "SelectionChangedEvent", ">", "(", ")", ";", "viewer", ".", "addPostSelectionChangedListener", "(", "new", "ISelectionChangedListener", "(", ")", "{", "public", "void", "selectionChanged", "(", "SelectionChangedEvent", "event", ")", "{", "selected", ".", "add", "(", "event", ")", ";", "}", "}", ")", ";", "viewer", ".", "getControl", "(", ")", ".", "notifyListeners", "(", "SWT", ".", "Selection", ",", "new", "Event", "(", ")", ")", ";", "assertFalse", "(", "\"\"", ",", "selected", ".", "isEmpty", "(", ")", ")", ";", "}", "public", "void", "testViewerFilterWithGraphEntityContentProvider", "(", ")", "{", "testViewerFilter", "(", "new", "SampleGraphEntityContentProvider", "(", ")", ")", ";", "}", "public", "void", "testViewerFilterWithGraphContentProvider", "(", ")", "{", "testViewerFilter", "(", "new", "SampleGraphContentProvider", "(", ")", ")", ";", "}", "public", "void", "testViewerFilter", "(", "IContentProvider", "contentProvider", ")", "{", "viewer", ".", "setContentProvider", "(", "contentProvider", ")", ";", "viewer", ".", "setInput", "(", "new", "Object", "(", ")", ")", ";", "assertNodesAndConnections", "(", "3", ",", "3", ")", ";", "viewer", ".", "setFilters", "(", "new", "ViewerFilter", "[", "]", "{", "new", "SampleBooleanFilter", "(", "false", ")", "}", ")", ";", "assertNodesAndConnections", "(", "0", ",", "0", ")", ";", "viewer", ".", "setFilters", "(", "new", "ViewerFilter", "[", "]", "{", "new", "SampleBooleanFilter", "(", "true", ")", "}", ")", ";", "assertNodesAndConnections", "(", "3", ",", "3", ")", ";", "}", "private", "void", "assertNodesAndConnections", "(", "int", "nodes", ",", "int", "connections", ")", "{", "assertEquals", "(", "nodes", ",", "viewer", ".", "getGraphControl", "(", ")", ".", "getNodes", "(", ")", ".", "size", "(", ")", ")", ";", "assertEquals", "(", "connections", ",", "viewer", ".", "getGraphControl", "(", ")", ".", "getConnections", "(", ")", ".", "size", "(", ")", ")", ";", "}", "static", "class", "SampleBooleanFilter", "extends", "ViewerFilter", "{", "private", "final", "boolean", "filter", ";", "SampleBooleanFilter", "(", "boolean", "filter", ")", "{", "this", ".", "filter", "=", "filter", ";", "}", "@", "Override", "public", "boolean", "select", "(", "Viewer", "viewer", ",", "Object", "parentElement", ",", "Object", "element", ")", "{", "return", "filter", ";", "}", "}", "static", "class", "SampleGraphContentProvider", "implements", "IGraphContentProvider", "{", "public", "void", "dispose", "(", ")", "{", "}", "public", "void", "inputChanged", "(", "Viewer", "arg0", ",", "Object", "arg1", ",", "Object", "arg2", ")", "{", "}", "public", "Object", "getDestination", "(", "Object", "r", ")", "{", "if", "(", "r", ".", "equals", "(", "\"1to2\"", ")", ")", "return", "\"2\"", ";", "if", "(", "r", ".", "equals", "(", "\"2to3\"", ")", ")", "return", "\"3\"", ";", "if", "(", "r", ".", "equals", "(", "\"3to1\"", ")", ")", "return", "\"1\"", ";", "return", "null", ";", "}", "public", "Object", "[", "]", "getElements", "(", "Object", "arg0", ")", "{", "return", "new", "String", "[", "]", "{", "\"1to2\"", ",", "\"2to3\"", ",", "\"3to1\"", "}", ";", "}", "public", "Object", "getSource", "(", "Object", "r", ")", "{", "if", "(", "r", ".", "equals", "(", "\"1to2\"", ")", ")", "return", "\"1\"", ";", "if", "(", "r", ".", "equals", "(", "\"2to3\"", ")", ")", "return", "\"2\"", ";", "if", "(", "r", ".", "equals", "(", "\"3to1\"", ")", ")", "return", "\"3\"", ";", "return", "null", ";", "}", "}", "static", "class", "SampleGraphEntityContentProvider", "implements", "IGraphEntityContentProvider", "{", "public", "Object", "[", "]", "getConnectedTo", "(", "Object", "entity", ")", "{", "if", "(", "entity", ".", "equals", "(", "\"1\"", ")", ")", "{", "return", "new", "Object", "[", "]", "{", "\"2\"", "}", ";", "}", "if", "(", "entity", ".", "equals", "(", "\"2\"", ")", ")", "{", "return", "new", "Object", "[", "]", "{", "\"3\"", "}", ";", "}", "if", "(", "entity", ".", "equals", "(", "\"3\"", ")", ")", "{", "return", "new", "Object", "[", "]", "{", "\"2\"", "}", ";", "}", "return", "null", ";", "}", "public", "Object", "[", "]", "getElements", "(", "Object", "inputElement", ")", "{", "return", "new", "String", "[", "]", "{", "\"1\"", ",", "\"2\"", ",", "\"3\"", "}", ";", "}", "public", "double", "getWeight", "(", "Object", "entity1", ",", "Object", "entity2", ")", "{", "return", "0", ";", "}", "public", "void", "dispose", "(", ")", "{", "}", "public", "void", "inputChanged", "(", "Viewer", "viewer", ",", "Object", "oldInput", ",", "Object", "newInput", ")", "{", "}", "}", "}", "</s>" ]
10,118
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ";", "import", "junit", ".", "framework", ".", "Assert", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "layout", ".", "FillLayout", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Shell", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "Graph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphConnection", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphNode", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "ZestStyles", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "internal", ".", "dot", ".", "DotImport", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "internal", ".", "dot", ".", "GraphCreatorInterpreter", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "TreeLayoutAlgorithm", ";", "import", "org", ".", "junit", ".", "Test", ";", "public", "final", "class", "TestSnippetDotImport", "{", "private", "final", "GraphCreatorInterpreter", "interpreter", "=", "new", "GraphCreatorInterpreter", "(", ")", ";", "@", "Test", "public", "void", "sampleUsage", "(", ")", "{", "Shell", "shell", "=", "new", "Shell", "(", ")", ";", "Graph", "graph", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "new", "DotImport", "(", "\"\"", ")", ".", "into", "(", "graph", ")", ";", "assertNodesEdgesCount", "(", "3", ",", "2", ",", "graph", ")", ";", "new", "DotImport", "(", "\"\"", ")", ".", "into", "(", "graph", ")", ";", "assertNodesEdgesCount", "(", "5", ",", "4", ",", "graph", ")", ";", "}", "@", "Test", "public", "void", "addToEmptyGraph", "(", ")", "{", "Shell", "shell", "=", "new", "Shell", "(", ")", ";", "Graph", "graph", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "graph", ".", "setLayoutAlgorithm", "(", "new", "TreeLayoutAlgorithm", "(", ")", ",", "true", ")", ";", "Assert", ".", "assertEquals", "(", "0", ",", "graph", ".", "getNodes", "(", ")", ".", "size", "(", ")", ")", ";", "Assert", ".", "assertEquals", "(", "0", ",", "graph", ".", "getConnections", "(", ")", ".", "size", "(", ")", ")", ";", "new", "DotImport", "(", "\"1->2\"", ")", ".", "into", "(", "graph", ")", ";", "assertNodesEdgesCount", "(", "2", ",", "1", ",", "graph", ")", ";", "new", "DotImport", "(", "\"3;4\"", ")", ".", "into", "(", "graph", ")", ";", "assertNodesEdgesCount", "(", "4", ",", "1", ",", "graph", ")", ";", "new", "DotImport", "(", "\"5->6\"", ")", ".", "into", "(", "graph", ")", ";", "assertNodesEdgesCount", "(", "6", ",", "2", ",", "graph", ")", ";", "Assert", ".", "assertEquals", "(", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "graph", ".", "getConnectionStyle", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "useExistingNodes", "(", ")", "{", "Shell", "shell", "=", "new", "Shell", "(", ")", ";", "Graph", "graph", "=", "new", "DotImport", "(", "\"\"", ")", ".", "newGraphInstance", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "assertNodesEdgesCount", "(", "2", ",", "1", ",", "graph", ")", ";", "new", "DotImport", "(", "\"1->3\"", ")", ".", "into", "(", "graph", ")", ";", "assertNodesEdgesCount", "(", "3", ",", "2", ",", "graph", ")", ";", "new", "DotImport", "(", "\"3->4\"", ")", ".", "into", "(", "graph", ")", ";", "assertNodesEdgesCount", "(", "4", ",", "3", ",", "graph", ")", ";", "}", "@", "Test", "public", "void", "useExistingLabeledNodes", "(", ")", "{", "Shell", "shell", "=", "new", "Shell", "(", ")", ";", "Graph", "graph", "=", "new", "DotImport", "(", "\"\"", ")", ".", "newGraphInstance", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "assertNodesEdgesCount", "(", "2", ",", "0", ",", "graph", ")", ";", "new", "DotImport", "(", "\"1->2\"", ")", ".", "into", "(", "graph", ")", ";", "assertNodesEdgesCount", "(", "2", ",", "1", ",", "graph", ")", ";", "new", "DotImport", "(", "\"1->3\"", ")", ".", "into", "(", "graph", ")", ";", "assertNodesEdgesCount", "(", "3", ",", "2", ",", "graph", ")", ";", "Assert", ".", "assertEquals", "(", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "graph", ".", "getConnectionStyle", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "undirectedEdgeDotSyntax", "(", ")", "{", "Shell", "shell", "=", "new", "Shell", "(", ")", ";", "Graph", "graph", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "new", "DotImport", "(", "\"1--2\"", ")", ".", "into", "(", "graph", ")", ";", "assertNodesEdgesCount", "(", "2", ",", "1", ",", "graph", ")", ";", "new", "DotImport", "(", "\"1--3\"", ")", ".", "into", "(", "graph", ")", ";", "assertNodesEdgesCount", "(", "3", ",", "2", ",", "graph", ")", ";", "Assert", ".", "assertEquals", "(", "ZestStyles", ".", "CONNECTIONS_SOLID", ",", "graph", ".", "getConnectionStyle", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "addLayoutAlgorithm", "(", ")", "{", "Shell", "shell", "=", "new", "Shell", "(", ")", ";", "Graph", "graph", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "Assert", ".", "assertEquals", "(", "null", ",", "graph", ".", "getLayoutAlgorithm", "(", ")", ")", ";", "new", "DotImport", "(", "\"rankdir=LR\"", ")", ".", "into", "(", "graph", ")", ";", "Assert", ".", "assertEquals", "(", "TreeLayoutAlgorithm", ".", "class", ",", "graph", ".", "getLayoutAlgorithm", "(", ")", ".", "getClass", "(", ")", ")", ";", "Assert", ".", "assertEquals", "(", "TreeLayoutAlgorithm", ".", "LEFT_RIGHT", ",", "(", "(", "TreeLayoutAlgorithm", ")", "(", "graph", ".", "getLayoutAlgorithm", "(", ")", ")", ")", ".", "getDirection", "(", ")", ")", ";", "new", "DotImport", "(", "\"rankdir=TD\"", ")", ".", "into", "(", "graph", ")", ";", "Assert", ".", "assertEquals", "(", "TreeLayoutAlgorithm", ".", "class", ",", "graph", ".", "getLayoutAlgorithm", "(", ")", ".", "getClass", "(", ")", ")", ";", "Assert", ".", "assertEquals", "(", "TreeLayoutAlgorithm", ".", "TOP_DOWN", ",", "(", "(", "TreeLayoutAlgorithm", ")", "(", "graph", ".", "getLayoutAlgorithm", "(", ")", ")", ")", ".", "getDirection", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "addStyledEdge", "(", ")", "{", "Shell", "shell", "=", "new", "Shell", "(", ")", ";", "Graph", "graph", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "Assert", ".", "assertEquals", "(", "ZestStyles", ".", "NONE", ",", "graph", ".", "getConnectionStyle", "(", ")", ")", ";", "assertNodesEdgesCount", "(", "0", ",", "0", ",", "graph", ")", ";", "new", "DotImport", "(", "\"\"", ")", ".", "into", "(", "graph", ")", ";", "assertNodesEdgesCount", "(", "2", ",", "1", ",", "graph", ")", ";", "GraphConnection", "edge", "=", "(", "GraphConnection", ")", "graph", ".", "getConnections", "(", ")", ".", "get", "(", "0", ")", ";", "Assert", ".", "assertEquals", "(", "SWT", ".", "LINE_DASH", ",", "edge", ".", "getLineStyle", "(", ")", ")", ";", "Assert", ".", "assertEquals", "(", "\"dashed\"", ",", "edge", ".", "getText", "(", ")", ")", ";", "new", "DotImport", "(", "\"\"", ")", ".", "into", "(", "graph", ")", ";", "assertNodesEdgesCount", "(", "3", ",", "2", ",", "graph", ")", ";", "edge", "=", "(", "GraphConnection", ")", "graph", ".", "getConnections", "(", ")", ".", "get", "(", "1", ")", ";", "Assert", ".", "assertEquals", "(", "SWT", ".", "LINE_DOT", ",", "edge", ".", "getLineStyle", "(", ")", ")", ";", "Assert", ".", "assertEquals", "(", "\"dotted\"", ",", "edge", ".", "getText", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "addStyledNode", "(", ")", "{", "Shell", "shell", "=", "new", "Shell", "(", ")", ";", "Graph", "graph", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "Assert", ".", "assertEquals", "(", "ZestStyles", ".", "NONE", ",", "graph", ".", "getConnectionStyle", "(", ")", ")", ";", "assertNodesEdgesCount", "(", "0", ",", "0", ",", "graph", ")", ";", "new", "DotImport", "(", "\"1[label=one]\"", ")", ".", "into", "(", "graph", ")", ";", "assertNodesEdgesCount", "(", "1", ",", "0", ",", "graph", ")", ";", "GraphNode", "node", "=", "(", "GraphNode", ")", "graph", ".", "getNodes", "(", ")", ".", "get", "(", "0", ")", ";", "Assert", ".", "assertEquals", "(", "\"one\"", ",", "node", ".", "getText", "(", ")", ")", ";", "new", "DotImport", "(", "\"\"", ")", ".", "into", "(", "graph", ")", ";", "assertNodesEdgesCount", "(", "3", ",", "0", ",", "graph", ")", ";", "Assert", ".", "assertEquals", "(", "\"two\"", ",", "(", "(", "GraphNode", ")", "graph", ".", "getNodes", "(", ")", ".", "get", "(", "1", ")", ")", ".", "getText", "(", ")", ")", ";", "Assert", ".", "assertEquals", "(", "\"three\"", ",", "(", "(", "GraphNode", ")", "graph", ".", "getNodes", "(", ")", ".", "get", "(", "2", ")", ")", ".", "getText", "(", ")", ")", ";", "}", "private", "void", "assertNodesEdgesCount", "(", "int", "n", ",", "int", "e", ",", "Graph", "graph", ")", "{", "Assert", ".", "assertEquals", "(", "n", ",", "graph", ".", "getNodes", "(", ")", ".", "size", "(", ")", ")", ";", "Assert", ".", "assertEquals", "(", "e", ",", "graph", ".", "getConnections", "(", ")", ".", "size", "(", ")", ")", ";", "}", "static", "void", "open", "(", "final", "Shell", "shell", ")", "{", "shell", ".", "setText", "(", "\"Testing\"", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "200", ",", "250", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "shell", ".", "getDisplay", "(", ")", ".", "readAndDispatch", "(", ")", ")", "{", "shell", ".", "getDisplay", "(", ")", ".", "sleep", "(", ")", ";", "}", "}", "}", "}", "</s>" ]
10,119
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ";", "import", "static", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ".", "DotImportTestUtils", ".", "RESOURCES_TESTS", ";", "import", "static", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ".", "DotImportTestUtils", ".", "importFrom", ";", "import", "java", ".", "io", ".", "File", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Shell", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "internal", ".", "dot", ".", "DotImport", ";", "import", "org", ".", "junit", ".", "Test", ";", "public", "final", "class", "TestBasicDotImport", "{", "@", "Test", "public", "void", "sampleGraph", "(", ")", "{", "importFrom", "(", "new", "File", "(", "RESOURCES_TESTS", "+", "\"\"", ")", ")", ";", "}", "@", "Test", "public", "void", "basicGraph", "(", ")", "{", "importFrom", "(", "new", "File", "(", "RESOURCES_TESTS", "+", "\"\"", ")", ")", ";", "}", "@", "Test", "public", "void", "directedGraph", "(", ")", "{", "importFrom", "(", "new", "File", "(", "RESOURCES_TESTS", "+", "\"\"", ")", ")", ";", "}", "@", "Test", "public", "void", "undirectedGraph", "(", ")", "{", "importFrom", "(", "new", "File", "(", "RESOURCES_TESTS", "+", "\"\"", ")", ")", ";", "}", "@", "Test", "public", "void", "labeledGraph", "(", ")", "{", "importFrom", "(", "new", "File", "(", "RESOURCES_TESTS", "+", "\"\"", ")", ")", ";", "}", "@", "Test", "public", "void", "styledGraph", "(", ")", "{", "importFrom", "(", "new", "File", "(", "RESOURCES_TESTS", "+", "\"\"", ")", ")", ";", "}", "@", "Test", "public", "void", "globalNodeGraph", "(", ")", "{", "importFrom", "(", "new", "File", "(", "RESOURCES_TESTS", "+", "\"\"", ")", ")", ";", "}", "@", "Test", "public", "void", "globalEdgeGraph", "(", ")", "{", "importFrom", "(", "new", "File", "(", "RESOURCES_TESTS", "+", "\"\"", ")", ")", ";", "}", "@", "Test", "public", "void", "attributesGraph", "(", ")", "{", "importFrom", "(", "new", "File", "(", "RESOURCES_TESTS", "+", "\"\"", ")", ")", ";", "}", "@", "Test", "(", "expected", "=", "IllegalArgumentException", ".", "class", ")", "public", "void", "faultyGraphInstance", "(", ")", "{", "new", "DotImport", "(", "\"\"", ")", ".", "newGraphInstance", "(", "new", "Shell", "(", ")", ",", "SWT", ".", "NONE", ")", ";", "}", "@", "Test", "(", "expected", "=", "IllegalArgumentException", ".", "class", ")", "public", "void", "faultyGraphClass", "(", ")", "{", "new", "DotImport", "(", "\"\"", ")", ".", "newGraphInstance", "(", "new", "Shell", "(", ")", ",", "SWT", ".", "NONE", ")", ";", "}", "}", "</s>" ]
10,120
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertEquals", ";", "import", "junit", ".", "framework", ".", "Assert", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "layout", ".", "FillLayout", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Shell", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "Graph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "dot", ".", "DotGraph", ";", "import", "org", ".", "junit", ".", "Test", ";", "public", "final", "class", "TestDotGraph", "{", "@", "Test", "public", "void", "sampleUsage", "(", ")", "{", "Shell", "shell", "=", "new", "Shell", "(", ")", ";", "DotGraph", "graph", "=", "new", "DotGraph", "(", "\"\"", ",", "shell", ",", "SWT", ".", "NONE", ")", ";", "assertNodesEdgesCount", "(", "2", ",", "1", ",", "graph", ")", ";", "graph", ".", "add", "(", "\"\"", ")", ";", "assertNodesEdgesCount", "(", "4", ",", "3", ",", "graph", ")", ";", "graph", ".", "add", "(", "\"\"", ")", ";", "assertNodesEdgesCount", "(", "6", ",", "5", ",", "graph", ")", ";", "}", "@", "Test", "public", "void", "graphAttributesToDataMapping", "(", ")", "{", "String", "dotInput", "=", "\"\"", ";", "DotGraph", "graph", "=", "new", "DotGraph", "(", "dotInput", ",", "new", "Shell", "(", ")", ",", "SWT", ".", "NONE", ")", ";", "assertEquals", "(", "\"graph_value1\"", ",", "graph", ".", "getGraph", "(", ")", ".", "getData", "(", "\"key1\"", ")", ")", ";", "assertEquals", "(", "\"graph_value2\"", ",", "graph", ".", "getGraph", "(", ")", ".", "getData", "(", "\"key2\"", ")", ")", ";", "}", "private", "void", "assertNodesEdgesCount", "(", "int", "n", ",", "int", "e", ",", "Graph", "graph", ")", "{", "Assert", ".", "assertEquals", "(", "n", ",", "graph", ".", "getNodes", "(", ")", ".", "size", "(", ")", ")", ";", "Assert", ".", "assertEquals", "(", "e", ",", "graph", ".", "getConnections", "(", ")", ".", "size", "(", ")", ")", ";", "}", "static", "void", "open", "(", "final", "Shell", "shell", ")", "{", "shell", ".", "setText", "(", "\"Testing\"", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "200", ",", "250", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "shell", ".", "getDisplay", "(", ")", ".", "readAndDispatch", "(", ")", ")", "{", "shell", ".", "getDisplay", "(", ")", ".", "sleep", "(", ")", ";", "}", "}", "}", "}", "</s>" ]
10,121
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "plugin", ".", "AbstractUIPlugin", ";", "import", "org", ".", "osgi", ".", "framework", ".", "BundleContext", ";", "public", "class", "DotUiTestsActivator", "extends", "AbstractUIPlugin", "{", "public", "static", "final", "String", "PLUGIN_ID", "=", "\"\"", ";", "private", "static", "DotUiTestsActivator", "plugin", ";", "public", "DotUiTestsActivator", "(", ")", "{", "}", "public", "void", "start", "(", "BundleContext", "context", ")", "throws", "Exception", "{", "super", ".", "start", "(", "context", ")", ";", "plugin", "=", "this", ";", "}", "public", "void", "stop", "(", "BundleContext", "context", ")", "throws", "Exception", "{", "plugin", "=", "null", ";", "super", ".", "stop", "(", "context", ")", ";", "}", "public", "static", "DotUiTestsActivator", "getDefault", "(", ")", "{", "return", "plugin", ";", "}", "}", "</s>" ]
10,122
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ";", "import", "java", ".", "io", ".", "File", ";", "import", "junit", ".", "framework", ".", "Assert", ";", "public", "final", "class", "DotTestUtils", "{", "private", "DotTestUtils", "(", ")", "{", "}", "public", "static", "void", "wipeOutput", "(", "final", "File", "location", ",", "final", "String", "suffix", ")", "{", "String", "[", "]", "files", "=", "location", ".", "list", "(", ")", ";", "int", "deleted", "=", "0", ";", "if", "(", "files", "!=", "null", "&&", "files", ".", "length", ">", "0", ")", "{", "for", "(", "String", "file", ":", "files", ")", "{", "File", "deletionCandidate", "=", "new", "File", "(", "location", ",", "file", ")", ";", "if", "(", "!", "deletionCandidate", ".", "isHidden", "(", ")", "&&", "!", "deletionCandidate", ".", "getName", "(", ")", ".", "startsWith", "(", "\".\"", ")", ")", "{", "boolean", "delete", "=", "deletionCandidate", ".", "delete", "(", ")", ";", "if", "(", "delete", ")", "{", "deleted", "++", ";", "}", "}", "}", "int", "dotFiles", "=", "countFilesWithSuffix", "(", "location", ",", "suffix", ")", ";", "Assert", ".", "assertEquals", "(", "\"\"", ",", "0", ",", "dotFiles", ")", ";", "System", ".", "out", ".", "println", "(", "String", ".", "format", "(", "\"\"", ",", "deleted", ",", "location", ")", ")", ";", "}", "}", "private", "static", "int", "countFilesWithSuffix", "(", "final", "File", "folder", ",", "final", "String", "suffix", ")", "{", "String", "[", "]", "list", "=", "folder", ".", "list", "(", ")", ";", "int", "dotFiles", "=", "0", ";", "for", "(", "String", "name", ":", "list", ")", "{", "if", "(", "name", ".", "endsWith", "(", "suffix", ")", ")", "{", "dotFiles", "++", ";", "}", "}", "return", "dotFiles", ";", "}", "}", "</s>" ]
10,123
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ".", "test_data", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "layout", ".", "FillLayout", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Composite", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Shell", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "Graph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphConnection", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphNode", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "ZestStyles", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "TreeLayoutAlgorithm", ";", "public", "class", "SimpleDigraph", "extends", "Graph", "{", "public", "SimpleDigraph", "(", "final", "Composite", "parent", ",", "final", "int", "style", ")", "{", "super", "(", "parent", ",", "style", ")", ";", "setConnectionStyle", "(", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ")", ";", "setLayoutAlgorithm", "(", "new", "TreeLayoutAlgorithm", "(", ")", ",", "true", ")", ";", "GraphNode", "n1", "=", "new", "GraphNode", "(", "this", ",", "SWT", ".", "NONE", ",", "\"1\"", ")", ";", "GraphNode", "n2", "=", "new", "GraphNode", "(", "this", ",", "SWT", ".", "NONE", ",", "\"2\"", ")", ";", "GraphNode", "n3", "=", "new", "GraphNode", "(", "this", ",", "SWT", ".", "NONE", ",", "\"3\"", ")", ";", "new", "GraphConnection", "(", "this", ",", "SWT", ".", "NONE", ",", "n1", ",", "n2", ")", ";", "new", "GraphConnection", "(", "this", ",", "SWT", ".", "NONE", ",", "n2", ",", "n3", ")", ";", "}", "public", "static", "void", "main", "(", "final", "String", "[", "]", "args", ")", "{", "Display", "d", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setText", "(", "SimpleDigraph", ".", "class", ".", "getSimpleName", "(", ")", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "200", ",", "250", ")", ";", "new", "SimpleDigraph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "}", "}", "</s>" ]
10,124
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ".", "test_data", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "layout", ".", "FillLayout", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Composite", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Shell", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "Graph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphConnection", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphNode", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "TreeLayoutAlgorithm", ";", "public", "class", "SimpleGraph", "extends", "Graph", "{", "public", "SimpleGraph", "(", "final", "Composite", "parent", ",", "final", "int", "style", ")", "{", "super", "(", "parent", ",", "style", ")", ";", "setLayoutAlgorithm", "(", "new", "TreeLayoutAlgorithm", "(", ")", ",", "true", ")", ";", "GraphNode", "n1", "=", "new", "GraphNode", "(", "this", ",", "SWT", ".", "NONE", ",", "\"1\"", ")", ";", "GraphNode", "n2", "=", "new", "GraphNode", "(", "this", ",", "SWT", ".", "NONE", ",", "\"2\"", ")", ";", "GraphNode", "n3", "=", "new", "GraphNode", "(", "this", ",", "SWT", ".", "NONE", ",", "\"3\"", ")", ";", "new", "GraphConnection", "(", "this", ",", "SWT", ".", "NONE", ",", "n1", ",", "n2", ")", ";", "new", "GraphConnection", "(", "this", ",", "SWT", ".", "NONE", ",", "n1", ",", "n3", ")", ";", "}", "public", "static", "void", "main", "(", "final", "String", "[", "]", "args", ")", "{", "Display", "d", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setText", "(", "SimpleGraph", ".", "class", ".", "getSimpleName", "(", ")", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "200", ",", "250", ")", ";", "new", "SimpleGraph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "}", "}", "</s>" ]
10,125
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ".", "test_data", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "layout", ".", "FillLayout", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Composite", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Shell", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "Graph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphConnection", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphNode", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "ZestStyles", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "TreeLayoutAlgorithm", ";", "public", "class", "SampleGraph", "extends", "Graph", "{", "public", "SampleGraph", "(", "final", "Composite", "parent", ",", "final", "int", "style", ")", "{", "super", "(", "parent", ",", "style", ")", ";", "setConnectionStyle", "(", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ")", ";", "setLayoutAlgorithm", "(", "new", "TreeLayoutAlgorithm", "(", ")", ",", "true", ")", ";", "GraphNode", "n1", "=", "new", "GraphNode", "(", "this", ",", "SWT", ".", "NONE", ",", "\"Node\"", ")", ";", "GraphNode", "n2", "=", "new", "GraphNode", "(", "this", ",", "SWT", ".", "NONE", ",", "\"Node\"", ")", ";", "GraphNode", "n3", "=", "new", "GraphNode", "(", "this", ",", "SWT", ".", "NONE", ",", "\"Leaf1\"", ")", ";", "GraphNode", "n4", "=", "new", "GraphNode", "(", "this", ",", "SWT", ".", "NONE", ",", "\"Leaf2\"", ")", ";", "GraphConnection", "n1n2", "=", "new", "GraphConnection", "(", "this", ",", "SWT", ".", "NONE", ",", "n1", ",", "n2", ")", ";", "n1n2", ".", "setText", "(", "\"Edge\"", ")", ";", "n1n2", ".", "setLineStyle", "(", "SWT", ".", "LINE_DASH", ")", ";", "GraphConnection", "n2n3", "=", "new", "GraphConnection", "(", "this", ",", "SWT", ".", "NONE", ",", "n2", ",", "n3", ")", ";", "n2n3", ".", "setText", "(", "\"Edge\"", ")", ";", "n2n3", ".", "setLineStyle", "(", "SWT", ".", "LINE_DASH", ")", ";", "GraphConnection", "n2n4", "=", "new", "GraphConnection", "(", "this", ",", "SWT", ".", "NONE", ",", "n2", ",", "n4", ")", ";", "n2n4", ".", "setText", "(", "\"Dotted\"", ")", ";", "n2n4", ".", "setLineStyle", "(", "SWT", ".", "LINE_DOT", ")", ";", "}", "public", "static", "void", "main", "(", "final", "String", "[", "]", "args", ")", "{", "Display", "d", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setText", "(", "SampleGraph", ".", "class", ".", "getSimpleName", "(", ")", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "200", ",", "250", ")", ";", "new", "SampleGraph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "}", "}", "</s>" ]
10,126
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ".", "test_data", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "layout", ".", "FillLayout", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Composite", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Shell", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "Graph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphConnection", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphNode", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "ZestStyles", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "TreeLayoutAlgorithm", ";", "public", "class", "StyledGraph", "extends", "Graph", "{", "public", "StyledGraph", "(", "final", "Composite", "parent", ",", "final", "int", "style", ")", "{", "super", "(", "parent", ",", "style", ")", ";", "setConnectionStyle", "(", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ")", ";", "setLayoutAlgorithm", "(", "new", "TreeLayoutAlgorithm", "(", ")", ",", "true", ")", ";", "GraphNode", "n1", "=", "new", "GraphNode", "(", "this", ",", "SWT", ".", "NONE", ",", "\"1\"", ")", ";", "GraphNode", "n2", "=", "new", "GraphNode", "(", "this", ",", "SWT", ".", "NONE", ",", "\"2\"", ")", ";", "GraphNode", "n3", "=", "new", "GraphNode", "(", "this", ",", "SWT", ".", "NONE", ",", "\"3\"", ")", ";", "GraphNode", "n4", "=", "new", "GraphNode", "(", "this", ",", "SWT", ".", "NONE", ",", "\"4\"", ")", ";", "GraphNode", "n5", "=", "new", "GraphNode", "(", "this", ",", "SWT", ".", "NONE", ",", "\"5\"", ")", ";", "GraphConnection", "n1n2", "=", "new", "GraphConnection", "(", "this", ",", "SWT", ".", "NONE", ",", "n1", ",", "n2", ")", ";", "n1n2", ".", "setLineStyle", "(", "SWT", ".", "LINE_DASH", ")", ";", "GraphConnection", "n2n3", "=", "new", "GraphConnection", "(", "this", ",", "SWT", ".", "NONE", ",", "n2", ",", "n3", ")", ";", "n2n3", ".", "setLineStyle", "(", "SWT", ".", "LINE_DOT", ")", ";", "GraphConnection", "n3n4", "=", "new", "GraphConnection", "(", "this", ",", "SWT", ".", "NONE", ",", "n3", ",", "n4", ")", ";", "n3n4", ".", "setLineStyle", "(", "SWT", ".", "LINE_DASHDOT", ")", ";", "GraphConnection", "n3n5", "=", "new", "GraphConnection", "(", "this", ",", "SWT", ".", "NONE", ",", "n3", ",", "n5", ")", ";", "n3n5", ".", "setLineStyle", "(", "SWT", ".", "LINE_SOLID", ")", ";", "}", "public", "static", "void", "main", "(", "final", "String", "[", "]", "args", ")", "{", "Display", "d", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setText", "(", "StyledGraph", ".", "class", ".", "getSimpleName", "(", ")", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "200", ",", "250", ")", ";", "new", "StyledGraph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "}", "}", "</s>" ]
10,127
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ".", "test_data", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "layout", ".", "FillLayout", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Composite", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Shell", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "Graph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphConnection", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphNode", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "ZestStyles", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "TreeLayoutAlgorithm", ";", "public", "class", "LabeledGraph", "extends", "Graph", "{", "public", "LabeledGraph", "(", "final", "Composite", "parent", ",", "final", "int", "style", ")", "{", "super", "(", "parent", ",", "style", ")", ";", "setConnectionStyle", "(", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ")", ";", "setLayoutAlgorithm", "(", "new", "TreeLayoutAlgorithm", "(", ")", ",", "true", ")", ";", "GraphNode", "n1", "=", "new", "GraphNode", "(", "this", ",", "SWT", ".", "NONE", ",", "\"One\"", ")", ";", "GraphNode", "n2", "=", "new", "GraphNode", "(", "this", ",", "SWT", ".", "NONE", ",", "\"Two\"", ")", ";", "GraphNode", "n3", "=", "new", "GraphNode", "(", "this", ",", "SWT", ".", "NONE", ",", "\"3\"", ")", ";", "GraphNode", "n4", "=", "new", "GraphNode", "(", "this", ",", "SWT", ".", "NONE", ",", "\"4\"", ")", ";", "GraphConnection", "n1n2", "=", "new", "GraphConnection", "(", "this", ",", "SWT", ".", "NONE", ",", "n1", ",", "n2", ")", ";", "n1n2", ".", "setText", "(", "\"+1\"", ")", ";", "GraphConnection", "n1n3", "=", "new", "GraphConnection", "(", "this", ",", "SWT", ".", "NONE", ",", "n1", ",", "n3", ")", ";", "n1n3", ".", "setText", "(", "\"+2\"", ")", ";", "new", "GraphConnection", "(", "this", ",", "SWT", ".", "NONE", ",", "n3", ",", "n4", ")", ";", "}", "public", "static", "void", "main", "(", "final", "String", "[", "]", "args", ")", "{", "Display", "d", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setText", "(", "LabeledGraph", ".", "class", ".", "getSimpleName", "(", ")", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "200", ",", "250", ")", ";", "new", "LabeledGraph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "}", "}", "</s>" ]
10,128
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ";", "import", "java", ".", "io", ".", "File", ";", "import", "junit", ".", "framework", ".", "Assert", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "Platform", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "internal", ".", "dot", ".", "DotDirStore", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "internal", ".", "dot", ".", "DotUiActivator", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "Test", ";", "public", "final", "class", "TestDotDirStore", "{", "@", "Before", "public", "void", "setup", "(", ")", "{", "if", "(", "!", "Platform", ".", "isRunning", "(", ")", ")", "{", "Assert", ".", "fail", "(", "\"\"", ")", ";", "}", "Assert", ".", "assertNotNull", "(", "\"\"", ",", "TestImageExport", ".", "dotBinDir", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "askForDotDir", "(", ")", "{", "DotUiActivator", ".", "getDefault", "(", ")", ".", "getPreferenceStore", "(", ")", ".", "setValue", "(", "DotDirStore", ".", "DOTPATH_KEY", ",", "TestImageExport", ".", "dotBinDir", "(", ")", ")", ";", "check", "(", "DotDirStore", ".", "getDotDirPath", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "getDotDirFromPrefs", "(", ")", "{", "check", "(", "DotDirStore", ".", "getDotDirPath", "(", ")", ")", ";", "}", "public", "void", "check", "(", "final", "String", "path", ")", "{", "Assert", ".", "assertNotNull", "(", "\"\"", ",", "path", ")", ";", "System", ".", "out", ".", "println", "(", "\"\"", "+", "path", ")", ";", "Assert", ".", "assertTrue", "(", "\"\"", ",", "path", ".", "trim", "(", ")", ".", "length", "(", ")", ">", "0", ")", ";", "Assert", ".", "assertTrue", "(", "\"\"", ",", "new", "File", "(", "path", ")", ".", "exists", "(", ")", ")", ";", "Assert", ".", "assertTrue", "(", "\"\"", ",", "new", "File", "(", "path", ")", ".", "isDirectory", "(", ")", ")", ";", "}", "}", "</s>" ]
10,129
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IProject", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IWorkspaceRoot", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "ResourcesPlugin", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "CoreException", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "IPath", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "Path", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "Platform", ";", "import", "org", ".", "junit", ".", "Assert", ";", "public", "final", "class", "ProjectHelper", "{", "static", "final", "String", "PROJECT_NAME", "=", "\"ZestTest\"", ";", "static", "final", "Path", "PROJECT_PATH", "=", "new", "Path", "(", "Platform", ".", "getLocation", "(", ")", ".", "toString", "(", ")", "+", "\"/\"", "+", "PROJECT_NAME", ")", ";", "private", "ProjectHelper", "(", ")", "{", "}", "static", "void", "assertProjectDoesntExist", "(", "final", "IPath", "path", ")", "{", "Assert", ".", "assertFalse", "(", "\"\"", "+", "path", ".", "toFile", "(", ")", ",", "path", ".", "toFile", "(", ")", ".", "exists", "(", ")", ")", ";", "}", "static", "void", "assertProjectExists", "(", "final", "IPath", "path", ")", "{", "Assert", ".", "assertTrue", "(", "\"\"", "+", "path", ".", "toFile", "(", ")", ",", "path", ".", "toFile", "(", ")", ".", "exists", "(", ")", ")", ";", "}", "static", "IProject", "createProject", "(", "final", "String", "projectName", ")", "{", "IWorkspaceRoot", "root", "=", "ResourcesPlugin", ".", "getWorkspace", "(", ")", ".", "getRoot", "(", ")", ";", "IProject", "project", "=", "root", ".", "getProject", "(", "projectName", ")", ";", "try", "{", "project", ".", "refreshLocal", "(", "-", "1", ",", "null", ")", ";", "if", "(", "project", ".", "exists", "(", ")", ")", "{", "project", ".", "delete", "(", "true", ",", "null", ")", ";", "assertProjectDoesntExist", "(", "project", ".", "getLocation", "(", ")", ")", ";", "}", "project", ".", "create", "(", "null", ")", ";", "if", "(", "!", "project", ".", "isOpen", "(", ")", ")", "{", "project", ".", "open", "(", "null", ")", ";", "}", "}", "catch", "(", "CoreException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "assertProjectExists", "(", "project", ".", "getLocation", "(", ")", ")", ";", "return", "project", ";", "}", "static", "void", "deleteProject", "(", "final", "IProject", "project", ")", "{", "try", "{", "project", ".", "refreshLocal", "(", "-", "1", ",", "null", ")", ";", "project", ".", "delete", "(", "true", ",", "true", ",", "null", ")", ";", "}", "catch", "(", "CoreException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "}", "</s>" ]
10,130
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertEquals", ";", "import", "junit", ".", "framework", ".", "Assert", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "layout", ".", "FillLayout", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Item", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Shell", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "Graph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphConnection", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphContainer", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphNode", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "ZestStyles", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "dot", ".", "DotGraph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "internal", ".", "dot", ".", "DotAst", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "internal", ".", "dot", ".", "DotImport", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "internal", ".", "dot", ".", "GraphCreatorInterpreter", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "GridLayoutAlgorithm", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "RadialLayoutAlgorithm", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "SpringLayoutAlgorithm", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "TreeLayoutAlgorithm", ";", "import", "org", ".", "junit", ".", "Test", ";", "public", "final", "class", "TestGraphInstanceDotImport", "{", "private", "final", "GraphCreatorInterpreter", "interpreter", "=", "new", "GraphCreatorInterpreter", "(", ")", ";", "@", "Test", "public", "void", "minimalUsage", "(", ")", "{", "Shell", "shell", "=", "new", "Shell", "(", ")", ";", "DotImport", "dotImport", "=", "new", "DotImport", "(", "\"\"", ")", ";", "Graph", "graph", "=", "dotImport", ".", "newGraphInstance", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "System", ".", "out", ".", "println", "(", "graph", ")", ";", "}", "@", "Test", "public", "void", "dotImport", "(", ")", "{", "Shell", "shell", "=", "new", "Shell", "(", ")", ";", "DotImport", "importer", "=", "new", "DotImport", "(", "\"\"", ")", ";", "Graph", "graph", "=", "importer", ".", "newGraphInstance", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "Assert", ".", "assertNotNull", "(", "\"\"", ",", "graph", ")", ";", "Assert", ".", "assertEquals", "(", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "graph", ".", "getConnectionStyle", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "undeclaredNodes", "(", ")", "{", "Graph", "graph", "=", "new", "DotImport", "(", "\"\"", ")", ".", "newGraphInstance", "(", "new", "Shell", "(", ")", ",", "SWT", ".", "NONE", ")", ";", "Assert", ".", "assertEquals", "(", "3", ",", "graph", ".", "getNodes", "(", ")", ".", "size", "(", ")", ")", ";", "Assert", ".", "assertEquals", "(", "2", ",", "graph", ".", "getConnections", "(", ")", ".", "size", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "subgraphs", "(", ")", "{", "Shell", "shell", "=", "new", "Shell", "(", ")", ";", "DotImport", "dotImport", "=", "new", "DotImport", "(", "\"\"", ")", ";", "Graph", "graph", "=", "dotImport", ".", "newGraphInstance", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "assertEquals", "(", "\"\"", ",", "3", ",", "graph", ".", "getNodes", "(", ")", ".", "size", "(", ")", ")", ";", "assertEquals", "(", "2", ",", "graph", ".", "getConnections", "(", ")", ".", "size", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "clusterSubgraphs", "(", ")", "{", "Shell", "shell", "=", "new", "Shell", "(", ")", ";", "DotImport", "dotImport", "=", "new", "DotImport", "(", "\"\"", ")", ";", "Graph", "graph", "=", "dotImport", ".", "newGraphInstance", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "assertEquals", "(", "\"\"", ",", "2", ",", "graph", ".", "getNodes", "(", ")", ".", "size", "(", ")", ")", ";", "assertEquals", "(", "GraphContainer", ".", "class", ",", "graph", ".", "getNodes", "(", ")", ".", "get", "(", "0", ")", ".", "getClass", "(", ")", ")", ";", "assertEquals", "(", "GraphContainer", ".", "class", ",", "graph", ".", "getNodes", "(", ")", ".", "get", "(", "1", ")", ".", "getClass", "(", ")", ")", ";", "assertEquals", "(", "2", ",", "graph", ".", "getConnections", "(", ")", ".", "size", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "labeledClusterSubgraph", "(", ")", "{", "Shell", "shell", "=", "new", "Shell", "(", ")", ";", "DotImport", "dotImport", "=", "new", "DotImport", "(", "\"digraph{\"", "+", "\"\"", "+", "\"\"", ")", ";", "Graph", "graph", "=", "dotImport", ".", "newGraphInstance", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "assertEquals", "(", "4", ",", "graph", ".", "getConnections", "(", ")", ".", "size", "(", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "2", ",", "graph", ".", "getNodes", "(", ")", ".", "size", "(", ")", ")", ";", "assertEquals", "(", "\"left\"", ",", "(", "(", "Item", ")", "graph", ".", "getNodes", "(", ")", ".", "get", "(", "0", ")", ")", ".", "getText", "(", ")", ")", ";", "assertEquals", "(", "\"right\"", ",", "(", "(", "Item", ")", "graph", ".", "getNodes", "(", ")", ".", "get", "(", "1", ")", ")", ".", "getText", "(", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "GraphContainer", ".", "class", ",", "graph", ".", "getNodes", "(", ")", ".", "get", "(", "0", ")", ".", "getClass", "(", ")", ")", ";", "assertEquals", "(", "2", ",", "(", "(", "GraphContainer", ")", "graph", ".", "getNodes", "(", ")", ".", "get", "(", "0", ")", ")", ".", "getNodes", "(", ")", ".", "size", "(", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "GraphContainer", ".", "class", ",", "graph", ".", "getNodes", "(", ")", ".", "get", "(", "1", ")", ".", "getClass", "(", ")", ")", ";", "assertEquals", "(", "3", ",", "(", "(", "GraphContainer", ")", "graph", ".", "getNodes", "(", ")", ".", "get", "(", "1", ")", ")", ".", "getNodes", "(", ")", ".", "size", "(", ")", ")", ";", "assertEquals", "(", "RadialLayoutAlgorithm", ".", "class", ",", "(", "(", "GraphContainer", ")", "graph", ".", "getNodes", "(", ")", ".", "get", "(", "0", ")", ")", ".", "getLayoutAlgorithm", "(", ")", ".", "getClass", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "layoutClusterSubgraph", "(", ")", "{", "Shell", "shell", "=", "new", "Shell", "(", ")", ";", "Graph", "graph", "=", "new", "DotGraph", "(", "\"digraph{\"", "+", "\"\"", "+", "\"\"", ",", "shell", ",", "SWT", ".", "NONE", ")", ";", "assertEquals", "(", "\"\"", ",", "GraphContainer", ".", "class", ",", "graph", ".", "getNodes", "(", ")", ".", "get", "(", "0", ")", ".", "getClass", "(", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "GraphContainer", ".", "class", ",", "graph", ".", "getNodes", "(", ")", ".", "get", "(", "1", ")", ".", "getClass", "(", ")", ")", ";", "assertEquals", "(", "RadialLayoutAlgorithm", ".", "class", ",", "(", "(", "GraphContainer", ")", "graph", ".", "getNodes", "(", ")", ".", "get", "(", "0", ")", ")", ".", "getLayoutAlgorithm", "(", ")", ".", "getClass", "(", ")", ")", ";", "assertEquals", "(", "TreeLayoutAlgorithm", ".", "class", ",", "(", "(", "GraphContainer", ")", "graph", ".", "getNodes", "(", ")", ".", "get", "(", "1", ")", ")", ".", "getLayoutAlgorithm", "(", ")", ".", "getClass", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "digraphType", "(", ")", "{", "Shell", "shell", "=", "new", "Shell", "(", ")", ";", "Graph", "graph", "=", "interpreter", ".", "create", "(", "shell", ",", "SWT", ".", "NONE", ",", "parse", "(", "\"\"", ")", ")", ";", "Assert", ".", "assertNotNull", "(", "\"\"", ",", "graph", ")", ";", "Assert", ".", "assertEquals", "(", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "graph", ".", "getConnectionStyle", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "graphType", "(", ")", "{", "Shell", "shell", "=", "new", "Shell", "(", ")", ";", "Graph", "graph", "=", "interpreter", ".", "create", "(", "shell", ",", "SWT", ".", "NONE", ",", "parse", "(", "\"\"", ")", ")", ";", "Assert", ".", "assertNotNull", "(", "\"\"", ",", "graph", ")", ";", "Assert", ".", "assertNotSame", "(", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "graph", ".", "getConnectionStyle", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "nodeDefaultLabel", "(", ")", "{", "Graph", "graph", "=", "interpreter", ".", "create", "(", "new", "Shell", "(", ")", ",", "SWT", ".", "NONE", ",", "parse", "(", "\"\"", ")", ")", ";", "Assert", ".", "assertNotNull", "(", "\"\"", ",", "graph", ")", ";", "Assert", ".", "assertEquals", "(", "\"1\"", ",", "(", "(", "GraphNode", ")", "graph", ".", "getNodes", "(", ")", ".", "get", "(", "0", ")", ")", ".", "getText", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "nodeCount", "(", ")", "{", "Graph", "graph", "=", "interpreter", ".", "create", "(", "new", "Shell", "(", ")", ",", "SWT", ".", "NONE", ",", "parse", "(", "\"\"", ")", ")", ";", "Assert", ".", "assertNotNull", "(", "\"\"", ",", "graph", ")", ";", "Assert", ".", "assertEquals", "(", "2", ",", "graph", ".", "getNodes", "(", ")", ".", "size", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "edgeCount", "(", ")", "{", "Graph", "graph", "=", "interpreter", ".", "create", "(", "new", "Shell", "(", ")", ",", "SWT", ".", "NONE", ",", "parse", "(", "\"\"", ")", ")", ";", "Assert", ".", "assertNotNull", "(", "\"\"", ",", "graph", ")", ";", "Assert", ".", "assertEquals", "(", "3", ",", "graph", ".", "getConnections", "(", ")", ".", "size", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "nodeLabel", "(", ")", "{", "Graph", "graph", "=", "interpreter", ".", "create", "(", "new", "Shell", "(", ")", ",", "SWT", ".", "NONE", ",", "parse", "(", "\"\"", ")", ")", ";", "Assert", ".", "assertNotNull", "(", "\"\"", ",", "graph", ")", ";", "Assert", ".", "assertEquals", "(", "\"Node1\"", ",", "(", "(", "GraphNode", ")", "graph", ".", "getNodes", "(", ")", ".", "get", "(", "0", ")", ")", ".", "getText", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "edgeLabel", "(", ")", "{", "Graph", "graph", "=", "interpreter", ".", "create", "(", "new", "Shell", "(", ")", ",", "SWT", ".", "NONE", ",", "parse", "(", "\"\"", ")", ")", ";", "Assert", ".", "assertNotNull", "(", "\"\"", ",", "graph", ")", ";", "Assert", ".", "assertEquals", "(", "\"Edge1\"", ",", "(", "(", "GraphConnection", ")", "graph", ".", "getConnections", "(", ")", ".", "get", "(", "0", ")", ")", ".", "getText", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "edgeStyle", "(", ")", "{", "Shell", "parent", "=", "new", "Shell", "(", ")", ";", "Graph", "graph", "=", "interpreter", ".", "create", "(", "parent", ",", "SWT", ".", "NONE", ",", "parse", "(", "\"\"", ")", ")", ";", "Assert", ".", "assertNotNull", "(", "\"\"", ",", "graph", ")", ";", "Assert", ".", "assertEquals", "(", "SWT", ".", "LINE_DASH", ",", "(", "(", "GraphConnection", ")", "graph", ".", "getConnections", "(", ")", ".", "get", "(", "0", ")", ")", ".", "getLineStyle", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "globalEdgeStyle", "(", ")", "{", "Shell", "parent", "=", "new", "Shell", "(", ")", ";", "Graph", "graph", "=", "interpreter", ".", "create", "(", "parent", ",", "SWT", ".", "NONE", ",", "parse", "(", "\"\"", ")", ")", ";", "Assert", ".", "assertNotNull", "(", "\"\"", ",", "graph", ")", ";", "Assert", ".", "assertEquals", "(", "SWT", ".", "LINE_DASH", ",", "(", "(", "GraphConnection", ")", "graph", ".", "getConnections", "(", ")", ".", "get", "(", "0", ")", ")", ".", "getLineStyle", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "globalEdgeLabel", "(", ")", "{", "Graph", "graph", "=", "interpreter", ".", "create", "(", "new", "Shell", "(", ")", ",", "SWT", ".", "NONE", ",", "parse", "(", "\"\"", ")", ")", ";", "Assert", ".", "assertNotNull", "(", "\"\"", ",", "graph", ")", ";", "Assert", ".", "assertEquals", "(", "\"Edge1\"", ",", "(", "(", "GraphConnection", ")", "graph", ".", "getConnections", "(", ")", ".", "get", "(", "0", ")", ")", ".", "getText", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "globalNodeLabel", "(", ")", "{", "Graph", "graph", "=", "interpreter", ".", "create", "(", "new", "Shell", "(", ")", ",", "SWT", ".", "NONE", ",", "parse", "(", "\"\"", ")", ")", ";", "Assert", ".", "assertNotNull", "(", "\"\"", ",", "graph", ")", ";", "Assert", ".", "assertEquals", "(", "\"Node1\"", ",", "(", "(", "GraphNode", ")", "graph", ".", "getNodes", "(", ")", ".", "get", "(", "0", ")", ")", ".", "getText", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "layoutSpring", "(", ")", "{", "Graph", "graph", "=", "interpreter", ".", "create", "(", "new", "Shell", "(", ")", ",", "SWT", ".", "NONE", ",", "parse", "(", "\"\"", ")", ")", ";", "Assert", ".", "assertNotNull", "(", "\"\"", ",", "graph", ")", ";", "Assert", ".", "assertEquals", "(", "SpringLayoutAlgorithm", ".", "class", ",", "graph", ".", "getLayoutAlgorithm", "(", ")", ".", "getClass", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "layoutGrid", "(", ")", "{", "Graph", "graph", "=", "interpreter", ".", "create", "(", "new", "Shell", "(", ")", ",", "SWT", ".", "NONE", ",", "parse", "(", "\"\"", ")", ")", ";", "Assert", ".", "assertNotNull", "(", "\"\"", ",", "graph", ")", ";", "Assert", ".", "assertEquals", "(", "GridLayoutAlgorithm", ".", "class", ",", "graph", ".", "getLayoutAlgorithm", "(", ")", ".", "getClass", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "layoutRadial", "(", ")", "{", "Graph", "graph", "=", "interpreter", ".", "create", "(", "new", "Shell", "(", ")", ",", "SWT", ".", "NONE", ",", "parse", "(", "\"\"", ")", ")", ";", "Assert", ".", "assertNotNull", "(", "\"\"", ",", "graph", ")", ";", "Assert", ".", "assertEquals", "(", "RadialLayoutAlgorithm", ".", "class", ",", "graph", ".", "getLayoutAlgorithm", "(", ")", ".", "getClass", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "layoutTree", "(", ")", "{", "Graph", "graph", "=", "interpreter", ".", "create", "(", "new", "Shell", "(", ")", ",", "SWT", ".", "NONE", ",", "parse", "(", "\"\"", ")", ")", ";", "Assert", ".", "assertNotNull", "(", "\"\"", ",", "graph", ")", ";", "Assert", ".", "assertEquals", "(", "TreeLayoutAlgorithm", ".", "class", ",", "graph", ".", "getLayoutAlgorithm", "(", ")", ".", "getClass", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "layoutHorizontalTreeViaLayout", "(", ")", "{", "Graph", "graph", "=", "interpreter", ".", "create", "(", "new", "Shell", "(", ")", ",", "SWT", ".", "NONE", ",", "parse", "(", "\"\"", ")", ")", ";", "Assert", ".", "assertNotNull", "(", "\"\"", ",", "graph", ")", ";", "Assert", ".", "assertEquals", "(", "TreeLayoutAlgorithm", ".", "class", ",", "graph", ".", "getLayoutAlgorithm", "(", ")", ".", "getClass", "(", ")", ")", ";", "Assert", ".", "assertEquals", "(", "TreeLayoutAlgorithm", ".", "LEFT_RIGHT", ",", "(", "(", "TreeLayoutAlgorithm", ")", "(", "graph", ".", "getLayoutAlgorithm", "(", ")", ")", ")", ".", "getDirection", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "layoutHorizontalTreeViaAttribute", "(", ")", "{", "Graph", "graph", "=", "interpreter", ".", "create", "(", "new", "Shell", "(", ")", ",", "SWT", ".", "NONE", ",", "parse", "(", "\"\"", ")", ")", ";", "Assert", ".", "assertNotNull", "(", "\"\"", ",", "graph", ")", ";", "Assert", ".", "assertEquals", "(", "TreeLayoutAlgorithm", ".", "class", ",", "graph", ".", "getLayoutAlgorithm", "(", ")", ".", "getClass", "(", ")", ")", ";", "Assert", ".", "assertEquals", "(", "TreeLayoutAlgorithm", ".", "LEFT_RIGHT", ",", "(", "(", "TreeLayoutAlgorithm", ")", "(", "graph", ".", "getLayoutAlgorithm", "(", ")", ")", ")", ".", "getDirection", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "globalNodeAttributeAdHocNodes", "(", ")", "{", "Graph", "graph", "=", "interpreter", ".", "create", "(", "new", "Shell", "(", ")", ",", "SWT", ".", "NONE", ",", "parse", "(", "\"\"", ")", ")", ";", "Assert", ".", "assertNotNull", "(", "\"\"", ",", "graph", ")", ";", "Assert", ".", "assertEquals", "(", "\"TEXT\"", ",", "(", "(", "GraphNode", ")", "graph", ".", "getNodes", "(", ")", ".", "get", "(", "0", ")", ")", ".", "getText", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "globalEdgeAttributeAdHocNodes", "(", ")", "{", "Graph", "graph", "=", "interpreter", ".", "create", "(", "new", "Shell", "(", ")", ",", "SWT", ".", "NONE", ",", "parse", "(", "\"\"", ")", ")", ";", "Assert", ".", "assertNotNull", "(", "\"\"", ",", "graph", ")", ";", "Assert", ".", "assertEquals", "(", "\"TEXT\"", ",", "(", "(", "GraphConnection", ")", "graph", ".", "getConnections", "(", ")", ".", "get", "(", "0", ")", ")", ".", "getText", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "headerCommentGraph", "(", ")", "{", "Graph", "graph", "=", "interpreter", ".", "create", "(", "new", "Shell", "(", ")", ",", "SWT", ".", "NONE", ",", "parse", "(", "\"\"", ")", ")", ";", "Assert", ".", "assertNotNull", "(", "\"\"", ",", "graph", ")", ";", "Assert", ".", "assertEquals", "(", "2", ",", "graph", ".", "getNodes", "(", ")", ".", "size", "(", ")", ")", ";", "Assert", ".", "assertEquals", "(", "1", ",", "graph", ".", "getConnections", "(", ")", ".", "size", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "nodesBeforeEdges", "(", ")", "{", "Graph", "graph", "=", "interpreter", ".", "create", "(", "new", "Shell", "(", ")", ",", "SWT", ".", "NONE", ",", "parse", "(", "\"\"", ")", ")", ";", "Assert", ".", "assertNotNull", "(", "\"\"", ",", "graph", ")", ";", "Assert", ".", "assertEquals", "(", "4", ",", "graph", ".", "getNodes", "(", ")", ".", "size", "(", ")", ")", ";", "Assert", ".", "assertEquals", "(", "3", ",", "graph", ".", "getConnections", "(", ")", ".", "size", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "nodesAfterEdges", "(", ")", "{", "Graph", "graph", "=", "interpreter", ".", "create", "(", "new", "Shell", "(", ")", ",", "SWT", ".", "NONE", ",", "parse", "(", "\"\"", ")", ")", ";", "Assert", ".", "assertNotNull", "(", "\"\"", ",", "graph", ")", ";", "Assert", ".", "assertEquals", "(", "4", ",", "graph", ".", "getNodes", "(", ")", ".", "size", "(", ")", ")", ";", "Assert", ".", "assertEquals", "(", "3", ",", "graph", ".", "getConnections", "(", ")", ".", "size", "(", ")", ")", ";", "Assert", ".", "assertEquals", "(", "\"node\"", ",", "(", "(", "GraphNode", ")", "graph", ".", "getNodes", "(", ")", ".", "get", "(", "0", ")", ")", ".", "getText", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "useInterpreterTwice", "(", ")", "{", "String", "dot", "=", "\"\"", ";", "Graph", "graph", "=", "interpreter", ".", "create", "(", "new", "Shell", "(", ")", ",", "SWT", ".", "NONE", ",", "parse", "(", "dot", ")", ")", ";", "graph", "=", "interpreter", ".", "create", "(", "new", "Shell", "(", ")", ",", "SWT", ".", "NONE", ",", "parse", "(", "dot", ")", ")", ";", "Assert", ".", "assertNotNull", "(", "\"\"", ",", "graph", ")", ";", "Assert", ".", "assertEquals", "(", "4", ",", "graph", ".", "getNodes", "(", ")", ".", "size", "(", ")", ")", ";", "Assert", ".", "assertEquals", "(", "3", ",", "graph", ".", "getConnections", "(", ")", ".", "size", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "idsWithQuotes", "(", ")", "{", "String", "dot", "=", "\"\"", ";", "Graph", "graph", "=", "interpreter", ".", "create", "(", "new", "Shell", "(", ")", ",", "SWT", ".", "NONE", ",", "parse", "(", "dot", ")", ")", ";", "Assert", ".", "assertNotNull", "(", "\"\"", ",", "graph", ")", ";", "Assert", ".", "assertEquals", "(", "\"node", "1\"", ",", "(", "(", "GraphNode", ")", "graph", ".", "getNodes", "(", ")", ".", "get", "(", "0", ")", ")", ".", "getText", "(", ")", ")", ";", "Assert", ".", "assertEquals", "(", "\"node", "2\"", ",", "(", "(", "GraphNode", ")", "graph", ".", "getNodes", "(", ")", ".", "get", "(", "1", ")", ")", ".", "getText", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "escapedQuotes", "(", ")", "{", "String", "dot", "=", "\"\"", ";", "Graph", "graph", "=", "interpreter", ".", "create", "(", "new", "Shell", "(", ")", ",", "SWT", ".", "NONE", ",", "parse", "(", "dot", ")", ")", ";", "Assert", ".", "assertNotNull", "(", "\"\"", ",", "graph", ")", ";", "Assert", ".", "assertEquals", "(", "\"node", "\\\"1\\\"\"", ",", "(", "(", "GraphNode", ")", "graph", ".", "getNodes", "(", ")", ".", "get", "(", "0", ")", ")", ".", "getText", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "fullyQuoted", "(", ")", "{", "String", "dot", "=", "\"\"", ";", "Graph", "graph", "=", "interpreter", ".", "create", "(", "new", "Shell", "(", ")", ",", "SWT", ".", "NONE", ",", "parse", "(", "dot", ")", ")", ";", "Assert", ".", "assertNotNull", "(", "\"\"", ",", "graph", ")", ";", "Assert", ".", "assertEquals", "(", "2", ",", "graph", ".", "getNodes", "(", ")", ".", "size", "(", ")", ")", ";", "Assert", ".", "assertEquals", "(", "1", ",", "graph", ".", "getConnections", "(", ")", ".", "size", "(", ")", ")", ";", "Assert", ".", "assertEquals", "(", "\"n1\"", ",", "(", "(", "GraphNode", ")", "graph", ".", "getNodes", "(", ")", ".", "get", "(", "0", ")", ")", ".", "getText", "(", ")", ")", ";", "Assert", ".", "assertEquals", "(", "\"n2\"", ",", "(", "(", "GraphNode", ")", "graph", ".", "getNodes", "(", ")", ".", "get", "(", "1", ")", ")", ".", "getText", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "labelsWithQuotes", "(", ")", "{", "String", "dot", "=", "\"\"", ";", "Graph", "graph", "=", "interpreter", ".", "create", "(", "new", "Shell", "(", ")", ",", "SWT", ".", "NONE", ",", "parse", "(", "dot", ")", ")", ";", "Assert", ".", "assertNotNull", "(", "\"\"", ",", "graph", ")", ";", "Assert", ".", "assertEquals", "(", "\"node", "1\"", ",", "(", "(", "GraphNode", ")", "graph", ".", "getNodes", "(", ")", ".", "get", "(", "0", ")", ")", ".", "getText", "(", ")", ")", ";", "Assert", ".", "assertEquals", "(", "\"node", "2\"", ",", "(", "(", "GraphNode", ")", "graph", ".", "getNodes", "(", ")", ".", "get", "(", "1", ")", ")", ".", "getText", "(", ")", ")", ";", "Assert", ".", "assertEquals", "(", "\"edge", "1\"", ",", "(", "(", "GraphConnection", ")", "graph", ".", "getConnections", "(", ")", ".", "get", "(", "0", ")", ")", ".", "getText", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "newLinesInLabels", "(", ")", "{", "String", "dot", "=", "\"\"", ";", "Graph", "graph", "=", "interpreter", ".", "create", "(", "new", "Shell", "(", ")", ",", "SWT", ".", "NONE", ",", "parse", "(", "dot", ")", ")", ";", "Assert", ".", "assertNotNull", "(", "\"\"", ",", "graph", ")", ";", "Assert", ".", "assertEquals", "(", "\"noden1\"", ",", "(", "(", "GraphNode", ")", "graph", ".", "getNodes", "(", ")", ".", "get", "(", "0", ")", ")", ".", "getText", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "multiEdgeStatements", "(", ")", "{", "Graph", "graph", "=", "new", "DotGraph", "(", "\"\"", ",", "new", "Shell", "(", ")", ",", "SWT", ".", "NONE", ")", ";", "assertEquals", "(", "4", ",", "graph", ".", "getNodes", "(", ")", ".", "size", "(", ")", ")", ";", "assertEquals", "(", "3", ",", "graph", ".", "getConnections", "(", ")", ".", "size", "(", ")", ")", ";", "assertEquals", "(", "1", ",", "(", "(", "GraphNode", ")", "graph", ".", "getNodes", "(", ")", ".", "get", "(", "0", ")", ")", ".", "getSourceConnections", "(", ")", ".", "size", "(", ")", ")", ";", "assertEquals", "(", "1", ",", "(", "(", "GraphNode", ")", "graph", ".", "getNodes", "(", ")", ".", "get", "(", "1", ")", ")", ".", "getSourceConnections", "(", ")", ".", "size", "(", ")", ")", ";", "assertEquals", "(", "1", ",", "(", "(", "GraphNode", ")", "graph", ".", "getNodes", "(", ")", ".", "get", "(", "2", ")", ")", ".", "getSourceConnections", "(", ")", ".", "size", "(", ")", ")", ";", "}", "@", "Test", "(", "expected", "=", "IllegalArgumentException", ".", "class", ")", "public", "void", "faultyLayout", "(", ")", "{", "interpreter", ".", "create", "(", "new", "Shell", "(", ")", ",", "SWT", ".", "NONE", ",", "parse", "(", "\"\"", ")", ")", ";", "}", "@", "Test", "(", "expected", "=", "IllegalArgumentException", ".", "class", ")", "public", "void", "faultyStyle", "(", ")", "{", "interpreter", ".", "create", "(", "new", "Shell", "(", ")", ",", "SWT", ".", "NONE", ",", "parse", "(", "\"\"", ")", ")", ";", "}", "private", "DotAst", "parse", "(", "String", "dot", ")", "{", "return", "new", "DotImport", "(", "dot", ")", ".", "getDotAst", "(", ")", ";", "}", "@", "SuppressWarnings", "(", "\"unused\"", ")", "private", "void", "open", "(", "final", "Shell", "shell", ")", "{", "shell", ".", "setText", "(", "\"Testing\"", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "600", ",", "300", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "shell", ".", "getDisplay", "(", ")", ".", "readAndDispatch", "(", ")", ")", "{", "shell", ".", "getDisplay", "(", ")", ".", "sleep", "(", ")", ";", "}", "}", "}", "}", "</s>" ]
10,131
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "internal", ".", "dot", ".", "DotExtractor", ";", "import", "org", ".", "junit", ".", "Assert", ";", "import", "org", ".", "junit", ".", "Test", ";", "@", "SuppressWarnings", "(", "\"serial\"", ")", "public", "class", "TestDotExtractor", "{", "Map", "<", "String", ",", "String", ">", "values", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", "{", "{", "put", "(", "\"\"", ",", "\"\"", ")", ";", "put", "(", "\"\"", ",", "\"\"", ")", ";", "put", "(", "\"\"", ",", "\"\"", ")", ";", "put", "(", "\"\"", ",", "\"\"", ")", ";", "put", "(", "\"\"", ",", "\"\"", ")", ";", "put", "(", "\"\"", ",", "\"\"", ")", ";", "put", "(", "\"\"", ",", "\"\"", ")", ";", "put", "(", "\"\"", ",", "\"\"", ")", ";", "}", "}", ";", "@", "Test", "public", "void", "extractDot", "(", ")", "{", "for", "(", "String", "input", ":", "values", ".", "keySet", "(", ")", ")", "{", "String", "expected", "=", "values", ".", "get", "(", "input", ")", ";", "String", "output", "=", "new", "DotExtractor", "(", "input", ")", ".", "getDotString", "(", ")", ";", "Assert", ".", "assertEquals", "(", "expected", ",", "output", ")", ";", "}", "}", "}", "</s>" ]
10,132
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ";", "import", "org", ".", "junit", ".", "runner", ".", "RunWith", ";", "import", "org", ".", "junit", ".", "runners", ".", "Suite", ";", "@", "RunWith", "(", "Suite", ".", "class", ")", "@", "Suite", ".", "SuiteClasses", "(", "{", "TestBasicDotImport", ".", "class", ",", "TestLayoutDotImport", ".", "class", ",", "TestAnimationDotImport", ".", "class", ",", "TestGraphInstanceDotImport", ".", "class", ",", "TestSnippetDotImport", ".", "class", ",", "TestDotGraph", ".", "class", ",", "TestDotAst", ".", "class", ",", "SampleUsage", ".", "class", "}", ")", "public", "final", "class", "DotImportSuite", "{", "private", "DotImportSuite", "(", ")", "{", "}", "}", "</s>" ]
10,133
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ";", "import", "static", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ".", "DotImportTestUtils", ".", "RESOURCES_TESTS", ";", "import", "static", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ".", "DotImportTestUtils", ".", "importFrom", ";", "import", "java", ".", "io", ".", "File", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "internal", ".", "dot", ".", "DotImport", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "GridLayoutAlgorithm", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "RadialLayoutAlgorithm", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "SpringLayoutAlgorithm", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "TreeLayoutAlgorithm", ";", "import", "org", ".", "junit", ".", "Test", ";", "public", "final", "class", "TestLayoutDotImport", "{", "@", "Test", "public", "void", "treeLayout", "(", ")", "{", "importFrom", "(", "new", "File", "(", "RESOURCES_TESTS", "+", "\"\"", ")", ")", ";", "}", "@", "Test", "public", "void", "springLayout", "(", ")", "{", "importFrom", "(", "new", "File", "(", "RESOURCES_TESTS", "+", "\"\"", ")", ")", ";", "}", "@", "Test", "public", "void", "radialLayout", "(", ")", "{", "importFrom", "(", "new", "File", "(", "RESOURCES_TESTS", "+", "\"\"", ")", ")", ";", "}", "@", "Test", "public", "void", "gridLayout", "(", ")", "{", "importFrom", "(", "new", "File", "(", "RESOURCES_TESTS", "+", "\"\"", ")", ")", ";", "}", "}", "</s>" ]
10,134
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "util", ".", "Properties", ";", "import", "junit", ".", "framework", ".", "Assert", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "Graph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "internal", ".", "dot", ".", "DotExport", ";", "import", "org", ".", "junit", ".", "BeforeClass", ";", "public", "class", "TestImageExport", "extends", "TestDotTemplate", "{", "private", "static", "String", "dotDir", "=", "null", ";", "@", "BeforeClass", "public", "static", "void", "setup", "(", ")", "throws", "IOException", "{", "dotDir", "=", "dotBinDir", "(", ")", ";", "}", "public", "static", "String", "dotBinDir", "(", ")", "{", "if", "(", "dotDir", "==", "null", ")", "{", "Properties", "props", "=", "new", "Properties", "(", ")", ";", "InputStream", "stream", "=", "TestImageExport", ".", "class", ".", "getResourceAsStream", "(", "\"\"", ")", ";", "if", "(", "stream", "==", "null", ")", "{", "System", ".", "err", ".", "println", "(", "\"\"", "+", "TestImageExport", ".", "class", ".", "getSimpleName", "(", ")", ")", ";", "}", "else", "try", "{", "props", ".", "load", "(", "stream", ")", ";", "dotDir", "=", "props", ".", "getProperty", "(", "DotExport", ".", "DOT_BIN_DIR_KEY", ")", ";", "if", "(", "dotDir", "==", "null", "||", "dotDir", ".", "trim", "(", ")", ".", "length", "(", ")", "==", "0", ")", "{", "System", ".", "err", ".", "println", "(", "\"\"", ")", ";", "}", "else", "stream", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "return", "null", ";", "}", "}", "return", "dotDir", ";", "}", "@", "Override", "protected", "void", "testDotGeneration", "(", "final", "Graph", "graph", ")", "{", "if", "(", "dotDir", "!=", "null", ")", "{", "super", ".", "testDotGeneration", "(", "graph", ")", ";", "File", "image", "=", "new", "DotExport", "(", "graph", ")", ".", "toImage", "(", "dotDir", ",", "null", ")", ";", "Assert", ".", "assertNotNull", "(", "\"\"", ",", "image", ")", ";", "System", ".", "out", ".", "println", "(", "\"\"", "+", "image", ")", ";", "Assert", ".", "assertTrue", "(", "\"\"", ",", "image", ".", "exists", "(", ")", ")", ";", "}", "}", "}", "</s>" ]
10,135
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ";", "import", "java", ".", "io", ".", "File", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "layout", ".", "FillLayout", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Shell", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "Graph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphConnection", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphNode", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "ZestStyles", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "internal", ".", "dot", ".", "DotExport", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "TreeLayoutAlgorithm", ";", "public", "final", "class", "DotExportSample", "{", "public", "static", "void", "main", "(", "final", "String", "[", "]", "args", ")", "{", "Display", "d", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "Graph", "graph", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "graph", ".", "setConnectionStyle", "(", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ")", ";", "GraphConnection", "edge", "=", "new", "GraphConnection", "(", "graph", ",", "SWT", ".", "NONE", ",", "new", "GraphNode", "(", "graph", ",", "SWT", ".", "NONE", ",", "\"Node", "1\"", ")", ",", "new", "GraphNode", "(", "graph", ",", "SWT", ".", "NONE", ",", "\"Node", "2\"", ")", ")", ";", "edge", ".", "setText", "(", "\"\"", ")", ";", "edge", ".", "setLineStyle", "(", "SWT", ".", "LINE_DOT", ")", ";", "DotExport", "dotExport", "=", "new", "DotExport", "(", "graph", ")", ";", "System", ".", "out", ".", "println", "(", "dotExport", ".", "toDotString", "(", ")", ")", ";", "dotExport", ".", "toDotFile", "(", "new", "File", "(", "\"\"", ")", ")", ";", "graph", ".", "setLayoutAlgorithm", "(", "new", "TreeLayoutAlgorithm", "(", ")", ",", "true", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "200", ",", "250", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "}", "private", "DotExportSample", "(", ")", "{", "}", "}", "</s>" ]
10,136
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ";", "import", "java", ".", "io", ".", "File", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Shell", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "Graph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "internal", ".", "dot", ".", "DotImport", ";", "import", "org", ".", "junit", ".", "Assert", ";", "public", "final", "class", "DotImportTestUtils", "{", "private", "DotImportTestUtils", "(", ")", "{", "}", "static", "final", "String", "RESOURCES_TESTS", "=", "\"\"", ";", "static", "void", "importFrom", "(", "final", "File", "dotFile", ")", "{", "Assert", ".", "assertTrue", "(", "\"\"", "+", "dotFile", ",", "dotFile", ".", "exists", "(", ")", ")", ";", "Graph", "zest", "=", "new", "DotImport", "(", "dotFile", ")", ".", "newGraphInstance", "(", "new", "Shell", "(", ")", ",", "SWT", ".", "NONE", ")", ";", "Assert", ".", "assertNotNull", "(", "\"\"", ",", "zest", ")", ";", "System", ".", "out", ".", "println", "(", "String", ".", "format", "(", "\"\"", ",", "dotFile", ",", "zest", ")", ")", ";", "}", "}", "</s>" ]
10,137
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ".", "DotTestUtils", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ".", "TestDotExport", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ".", "TestDotTemplate", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ".", "TestImageExport", ";", "import", "org", ".", "junit", ".", "BeforeClass", ";", "import", "org", ".", "junit", ".", "runner", ".", "RunWith", ";", "import", "org", ".", "junit", ".", "runners", ".", "Suite", ";", "@", "RunWith", "(", "Suite", ".", "class", ")", "@", "Suite", ".", "SuiteClasses", "(", "{", "TestDotTemplate", ".", "class", ",", "TestDotExport", ".", "class", ",", "TestImageExport", ".", "class", "}", ")", "public", "final", "class", "DotExportSuite", "{", "private", "DotExportSuite", "(", ")", "{", "}", "@", "BeforeClass", "public", "static", "void", "wipe", "(", ")", "{", "DotTestUtils", ".", "wipeOutput", "(", "TestDotExport", ".", "OUTPUT", ",", "\".dot\"", ")", ";", "}", "}", "</s>" ]
10,138
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertTrue", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileNotFoundException", ";", "import", "java", ".", "util", ".", "Scanner", ";", "import", "junit", ".", "framework", ".", "Assert", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Shell", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "Graph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphContainer", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphNode", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "dot", ".", "DotGraph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "internal", ".", "dot", ".", "DotExport", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "GridLayoutAlgorithm", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "RadialLayoutAlgorithm", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "SpringLayoutAlgorithm", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "TreeLayoutAlgorithm", ";", "import", "org", ".", "junit", ".", "Test", ";", "public", "class", "TestDotExport", "extends", "TestDotTemplate", "{", "public", "static", "final", "File", "OUTPUT", "=", "new", "File", "(", "\"\"", ")", ";", "@", "Override", "protected", "void", "testDotGeneration", "(", "final", "Graph", "graph", ")", "{", "super", ".", "testDotGeneration", "(", "graph", ")", ";", "DotExport", "dotExport", "=", "new", "DotExport", "(", "graph", ")", ";", "String", "dot", "=", "dotExport", ".", "toDotString", "(", ")", ";", "assertNoBlankLines", "(", "dot", ")", ";", "System", ".", "out", ".", "println", "(", "dot", ")", ";", "File", "file", "=", "new", "File", "(", "OUTPUT", ",", "new", "DotExport", "(", "graph", ")", ".", "toString", "(", ")", "+", "\".dot\"", ")", ";", "dotExport", ".", "toDotFile", "(", "file", ")", ";", "Assert", ".", "assertTrue", "(", "\"\"", ",", "file", ".", "exists", "(", ")", ")", ";", "String", "dotRead", "=", "read", "(", "file", ")", ";", "Assert", ".", "assertTrue", "(", "\"\"", ",", "dotRead", ".", "contains", "(", "graph", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", ")", ")", ";", "Assert", ".", "assertEquals", "(", "\"\"", ",", "dot", ",", "dotRead", ")", ";", "}", "@", "Test", "public", "void", "graphContainerExport", "(", ")", "{", "Graph", "graph", "=", "new", "Graph", "(", "new", "Shell", "(", ")", ",", "SWT", ".", "NONE", ")", ";", "GraphContainer", "container", "=", "new", "GraphContainer", "(", "graph", ",", "SWT", ".", "NONE", ")", ";", "GraphNode", "node", "=", "new", "GraphNode", "(", "container", ",", "SWT", ".", "NONE", ")", ";", "String", "nodeLabel", "=", "\"\"", ";", "String", "containerLabel", "=", "\"\"", ";", "node", ".", "setText", "(", "nodeLabel", ")", ";", "container", ".", "setText", "(", "containerLabel", ")", ";", "String", "dot", "=", "new", "DotExport", "(", "graph", ")", ".", "toDotString", "(", ")", ";", "Assert", ".", "assertTrue", "(", "\"\"", ",", "!", "dot", ".", "contains", "(", "containerLabel", ")", ")", ";", "Assert", ".", "assertTrue", "(", "\"\"", ",", "dot", ".", "contains", "(", "nodeLabel", ")", ")", ";", "}", "@", "Test", "public", "void", "zestToGraphvizLayoutMapping", "(", ")", "{", "DotGraph", "graph", "=", "new", "DotGraph", "(", "new", "Shell", "(", ")", ",", "SWT", ".", "NONE", ")", ";", "graph", ".", "setLayoutAlgorithm", "(", "new", "TreeLayoutAlgorithm", "(", ")", ",", "false", ")", ";", "assertTrue", "(", "\"\"", ",", "graph", ".", "toDot", "(", ")", ".", "contains", "(", "\"\"", ")", ")", ";", "graph", ".", "setLayoutAlgorithm", "(", "new", "RadialLayoutAlgorithm", "(", ")", ",", "false", ")", ";", "assertTrue", "(", "\"\"", ",", "graph", ".", "toDot", "(", ")", ".", "contains", "(", "\"\"", ")", ")", ";", "graph", ".", "setLayoutAlgorithm", "(", "new", "GridLayoutAlgorithm", "(", ")", ",", "false", ")", ";", "assertTrue", "(", "\"\"", ",", "graph", ".", "toDot", "(", ")", ".", "contains", "(", "\"\"", ")", ")", ";", "graph", ".", "setLayoutAlgorithm", "(", "new", "SpringLayoutAlgorithm", "(", ")", ",", "false", ")", ";", "assertTrue", "(", "\"\"", ",", "graph", ".", "toDot", "(", ")", ".", "contains", "(", "\"\"", ")", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "100", ";", "i", "++", ")", "{", "new", "GraphNode", "(", "graph", ",", "SWT", ".", "NONE", ")", ";", "}", "assertTrue", "(", "\"\"", ",", "graph", ".", "toDot", "(", ")", ".", "contains", "(", "\"\"", ")", ")", ";", "}", "private", "void", "assertNoBlankLines", "(", "final", "String", "dot", ")", "{", "Scanner", "scanner", "=", "new", "Scanner", "(", "dot", ")", ";", "while", "(", "scanner", ".", "hasNextLine", "(", ")", ")", "{", "if", "(", "scanner", ".", "nextLine", "(", ")", ".", "trim", "(", ")", ".", "equals", "(", "\"\"", ")", ")", "{", "Assert", ".", "fail", "(", "\"\"", ")", ";", "}", "}", "}", "private", "String", "read", "(", "final", "File", "file", ")", "{", "try", "{", "Scanner", "scanner", "=", "new", "Scanner", "(", "file", ")", ";", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", ")", ";", "while", "(", "scanner", ".", "hasNextLine", "(", ")", ")", "{", "builder", ".", "append", "(", "scanner", ".", "nextLine", "(", ")", "+", "\"n\"", ")", ";", "}", "return", "builder", ".", "toString", "(", ")", ";", "}", "catch", "(", "FileNotFoundException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "return", "null", ";", "}", "}", "</s>" ]
10,139
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "junit", ".", "framework", ".", "Assert", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "Platform", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "IWorkbenchPage", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "PartInitException", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "PlatformUI", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "Graph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "internal", ".", "dot", ".", "DotExport", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "internal", ".", "dot", ".", "ZestGraphView", ";", "import", "org", ".", "junit", ".", "BeforeClass", ";", "import", "org", ".", "junit", ".", "Test", ";", "public", "final", "class", "TestZestGraphView", "{", "private", "static", "final", "String", "DOT", "=", "\"\"", ";", "@", "BeforeClass", "public", "static", "void", "setup", "(", ")", "{", "if", "(", "!", "Platform", ".", "isRunning", "(", ")", ")", "{", "Assert", ".", "fail", "(", "\"\"", ")", ";", "}", "}", "@", "Test", "public", "void", "loadGraphFromDot", "(", ")", "throws", "PartInitException", ",", "InterruptedException", ",", "IOException", "{", "Graph", "g", "=", "loadGraphInView", "(", "DOT", ")", ";", "Assert", ".", "assertEquals", "(", "2", ",", "g", ".", "getNodes", "(", ")", ".", "size", "(", ")", ")", ";", "Assert", ".", "assertEquals", "(", "1", ",", "g", ".", "getConnections", "(", ")", ".", "size", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "experimentalSwtImageExport", "(", ")", "throws", "PartInitException", ",", "InterruptedException", ",", "IOException", "{", "Graph", "g", "=", "loadGraphInView", "(", "DOT", ")", ";", "DotExport", "export", "=", "new", "DotExport", "(", "g", ")", ";", "File", "image", "=", "export", ".", "toImage", "(", "File", ".", "createTempFile", "(", "\"zest\"", ",", "\".png\"", ")", ".", "getAbsolutePath", "(", ")", ")", ";", "Assert", ".", "assertTrue", "(", "image", ".", "exists", "(", ")", ")", ";", "}", "private", "Graph", "loadGraphInView", "(", "String", "dot", ")", "throws", "PartInitException", "{", "IWorkbenchPage", "page", "=", "PlatformUI", ".", "getWorkbench", "(", ")", ".", "getActiveWorkbenchWindow", "(", ")", ".", "getActivePage", "(", ")", ";", "ZestGraphView", "graphView", "=", "(", "ZestGraphView", ")", "page", ".", "showView", "(", "ZestGraphView", ".", "ID", ")", ";", "graphView", ".", "setGraph", "(", "dot", ",", "false", ")", ";", "Graph", "g", "=", "graphView", ".", "getGraph", "(", ")", ";", "return", "g", ";", "}", "}", "</s>" ]
10,140
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ";", "import", "java", ".", "io", ".", "File", ";", "import", "junit", ".", "framework", ".", "Assert", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "internal", ".", "dot", ".", "DotAst", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "internal", ".", "dot", ".", "DotFileUtils", ";", "import", "org", ".", "junit", ".", "Test", ";", "public", "class", "TestDotAst", "{", "private", "static", "final", "DotAst", "DOT_AST", "=", "new", "DotAst", "(", "DotFileUtils", ".", "read", "(", "new", "File", "(", "DotImportTestUtils", ".", "RESOURCES_TESTS", "+", "\"\"", ")", ")", ")", ";", "@", "Test", "public", "void", "parseName", "(", ")", "{", "Assert", ".", "assertEquals", "(", "\"SampleGraph\"", ",", "DOT_AST", ".", "graphName", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "parseErrors", "(", ")", "{", "Assert", ".", "assertEquals", "(", "0", ",", "DOT_AST", ".", "errors", "(", ")", ".", "size", "(", ")", ")", ";", "}", "}", "</s>" ]
10,141
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ";", "import", "static", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ".", "DotImportTestUtils", ".", "RESOURCES_TESTS", ";", "import", "static", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ".", "DotImportTestUtils", ".", "importFrom", ";", "import", "java", ".", "io", ".", "File", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "internal", ".", "dot", ".", "DotImport", ";", "import", "org", ".", "junit", ".", "Test", ";", "public", "final", "class", "TestAnimationDotImport", "{", "@", "Test", "public", "void", "simple", "(", ")", "{", "importFrom", "(", "new", "File", "(", "RESOURCES_TESTS", "+", "\"\"", ")", ")", ";", "}", "@", "Test", "public", "void", "binTree", "(", ")", "{", "importFrom", "(", "new", "File", "(", "RESOURCES_TESTS", "+", "\"\"", ")", ")", ";", "}", "@", "Test", "public", "void", "layout", "(", ")", "{", "importFrom", "(", "new", "File", "(", "RESOURCES_TESTS", "+", "\"\"", ")", ")", ";", "}", "@", "Test", "public", "void", "full", "(", ")", "{", "importFrom", "(", "new", "File", "(", "RESOURCES_TESTS", "+", "\"\"", ")", ")", ";", "}", "}", "</s>" ]
10,142
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ";", "import", "junit", ".", "framework", ".", "Assert", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Shell", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "Graph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphConnection", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphNode", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "ZestStyles", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "internal", ".", "dot", ".", "DotTemplate", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "TreeLayoutAlgorithm", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ".", "test_data", ".", "LabeledGraph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ".", "test_data", ".", "SampleGraph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ".", "test_data", ".", "SimpleDigraph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ".", "test_data", ".", "SimpleGraph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ".", "test_data", ".", "StyledGraph", ";", "import", "org", ".", "junit", ".", "Test", ";", "public", "class", "TestDotTemplate", "{", "private", "static", "Shell", "shell", "=", "new", "Shell", "(", ")", ";", "@", "Test", "public", "void", "zestGraph", "(", ")", "{", "Graph", "graph", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "graph", ".", "setLayoutAlgorithm", "(", "new", "TreeLayoutAlgorithm", "(", "TreeLayoutAlgorithm", ".", "LEFT_RIGHT", ")", ",", "true", ")", ";", "graph", ".", "setConnectionStyle", "(", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ")", ";", "GraphConnection", "edge", "=", "new", "GraphConnection", "(", "graph", ",", "SWT", ".", "NONE", ",", "new", "GraphNode", "(", "graph", ",", "SWT", ".", "NONE", ",", "\"Node", "1\"", ")", ",", "new", "GraphNode", "(", "graph", ",", "SWT", ".", "NONE", ",", "\"Node", "2\"", ")", ")", ";", "edge", ".", "setText", "(", "\"\"", ")", ";", "edge", ".", "setLineStyle", "(", "SWT", ".", "LINE_DOT", ")", ";", "String", "dot", "=", "new", "DotTemplate", "(", ")", ".", "generate", "(", "graph", ")", ";", "Assert", ".", "assertTrue", "(", "\"\"", ",", "dot", ".", "contains", "(", "\"rankdir=LR\"", ")", ")", ";", "testDotGeneration", "(", "graph", ")", ";", "}", "@", "Test", "public", "void", "sampleGraph", "(", ")", "{", "testDotGeneration", "(", "new", "SampleGraph", "(", "shell", ",", "SWT", ".", "NONE", ")", ")", ";", "}", "@", "Test", "public", "void", "simpleGraph", "(", ")", "{", "testDotGeneration", "(", "new", "SimpleGraph", "(", "shell", ",", "SWT", ".", "NONE", ")", ")", ";", "}", "@", "Test", "public", "void", "directedGraph", "(", ")", "{", "testDotGeneration", "(", "new", "SimpleDigraph", "(", "shell", ",", "SWT", ".", "NONE", ")", ")", ";", "}", "@", "Test", "public", "void", "labeledGraph", "(", ")", "{", "testDotGeneration", "(", "new", "LabeledGraph", "(", "shell", ",", "SWT", ".", "NONE", ")", ")", ";", "}", "@", "Test", "public", "void", "styledGraph", "(", ")", "{", "testDotGeneration", "(", "new", "StyledGraph", "(", "shell", ",", "SWT", ".", "NONE", ")", ")", ";", "}", "protected", "void", "testDotGeneration", "(", "final", "Graph", "graph", ")", "{", "String", "dot", "=", "new", "DotTemplate", "(", ")", ".", "generate", "(", "graph", ")", ";", "Assert", ".", "assertFalse", "(", "\"\"", ",", "dot", ".", "contains", "(", "\"graph", "Graph\"", ")", ")", ";", "Assert", ".", "assertTrue", "(", "\"\"", ",", "dot", ".", "contains", "(", "graph", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", ")", ")", ";", "Assert", ".", "assertTrue", "(", "graph", ".", "getConnectionStyle", "(", ")", "==", "ZestStyles", ".", "CONNECTIONS_DIRECTED", "?", "dot", ".", "contains", "(", "\"digraph\"", ")", ":", "!", "dot", ".", "contains", "(", "\"digraph\"", ")", ")", ";", "System", ".", "out", ".", "println", "(", "dot", ")", ";", "}", "}", "</s>" ]
10,143
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Constructor", ";", "import", "java", ".", "lang", ".", "reflect", ".", "InvocationTargetException", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "java", ".", "net", ".", "URLClassLoader", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Composite", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "Graph", ";", "final", "class", "ExperimentalDotImport", "{", "private", "ExperimentalDotImport", "(", ")", "{", "}", "static", "Graph", "loadGraph", "(", "final", "String", "graphName", ",", "final", "URL", "outputDirUrl", ",", "final", "Composite", "parent", ",", "final", "int", "style", ")", "{", "try", "{", "URLClassLoader", "ucl", "=", "getUrlClassLoader", "(", "outputDirUrl", ")", ";", "Class", "<", "?", ">", "clazz", "=", "Class", ".", "forName", "(", "\"\"", "+", "graphName", ",", "true", ",", "ucl", ")", ";", "for", "(", "Constructor", "<", "?", ">", "c", ":", "clazz", ".", "getConstructors", "(", ")", ")", "{", "if", "(", "c", ".", "getParameterTypes", "(", ")", ".", "length", "==", "2", ")", "{", "Object", "object", "=", "c", ".", "newInstance", "(", "parent", ",", "(", "Integer", ")", "style", ")", ";", "return", "(", "Graph", ")", "object", ";", "}", "}", "}", "catch", "(", "ClassNotFoundException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "catch", "(", "IllegalArgumentException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "catch", "(", "InstantiationException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "catch", "(", "IllegalAccessException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "catch", "(", "InvocationTargetException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "return", "null", ";", "}", "private", "static", "URLClassLoader", "getUrlClassLoader", "(", "final", "URL", "outputDirUrl", ")", "{", "URL", "[", "]", "urls", ";", "List", "<", "URL", ">", "urlList", "=", "new", "ArrayList", "<", "URL", ">", "(", ")", ";", "if", "(", "outputDirUrl", "!=", "null", ")", "{", "urlList", ".", "add", "(", "outputDirUrl", ")", ";", "}", "urls", "=", "urlList", ".", "toArray", "(", "new", "URL", "[", "]", "{", "}", ")", ";", "ClassLoader", "loader", "=", "Thread", ".", "currentThread", "(", ")", ".", "getContextClassLoader", "(", ")", ";", "URLClassLoader", "ucl", "=", "new", "URLClassLoader", "(", "urls", ",", "loader", ")", ";", "return", "ucl", ";", "}", "}", "</s>" ]
10,144
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "dot", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "layout", ".", "FillLayout", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Shell", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "dot", ".", "DotGraph", ";", "import", "org", ".", "junit", ".", "Test", ";", "public", "class", "SampleUsage", "{", "@", "Test", "public", "void", "sampleUsage", "(", ")", "{", "Shell", "shell", "=", "new", "Shell", "(", ")", ";", "DotGraph", "graph", "=", "new", "DotGraph", "(", "\"\"", ",", "shell", ",", "SWT", ".", "NONE", ")", ";", "graph", ".", "add", "(", "\"2->3\"", ")", ".", "add", "(", "\"2->4\"", ")", ";", "graph", ".", "add", "(", "\"\"", ")", ";", "String", "dot", "=", "graph", ".", "toDot", "(", ")", ";", "System", ".", "out", ".", "println", "(", "graph", ")", ";", "System", ".", "out", ".", "println", "(", "dot", ")", ";", "}", "@", "SuppressWarnings", "(", "\"unused\"", ")", "private", "void", "open", "(", "final", "Shell", "shell", ")", "{", "shell", ".", "setText", "(", "DotGraph", ".", "class", ".", "getSimpleName", "(", ")", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "600", ",", "300", ")", ";", "shell", ".", "open", "(", ")", ";", "Display", "display", "=", "shell", ".", "getDisplay", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "if", "(", "!", "display", ".", "readAndDispatch", "(", ")", ")", "display", ".", "sleep", "(", ")", ";", "display", ".", "dispose", "(", ")", ";", "}", "}", "</s>" ]
10,145
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "tests", ";", "import", "junit", ".", "framework", ".", "TestCase", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Figure", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Shell", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "Graph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphConnection", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphItem", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphNode", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "internal", ".", "ZestRootLayer", ";", "public", "class", "GraphTests", "extends", "TestCase", "{", "private", "static", "final", "int", "STYLE", "=", "SWT", ".", "NONE", ";", "private", "GraphNode", "[", "]", "nodes", ";", "private", "Graph", "graph", ";", "private", "GraphConnection", "connection", ";", "Shell", "shell", ";", "protected", "void", "setUp", "(", ")", "throws", "Exception", "{", "shell", "=", "new", "Shell", "(", ")", ";", "graph", "=", "new", "Graph", "(", "shell", ",", "STYLE", ")", ";", "nodes", "=", "new", "GraphNode", "[", "]", "{", "new", "GraphNode", "(", "graph", ",", "STYLE", ")", ",", "new", "GraphNode", "(", "graph", ",", "STYLE", ")", "}", ";", "connection", "=", "new", "GraphConnection", "(", "graph", ",", "STYLE", ",", "nodes", "[", "0", "]", ",", "nodes", "[", "1", "]", ")", ";", "}", "public", "void", "testGraphData", "(", ")", "{", "graph", ".", "setData", "(", "\"graph", "data\"", ")", ";", "assertEquals", "(", "\"graph", "data\"", ",", "graph", ".", "getData", "(", ")", ")", ";", "}", "public", "void", "testNodeItemData", "(", ")", "{", "GraphItem", "item", "=", "(", "GraphNode", ")", "graph", ".", "getNodes", "(", ")", ".", "get", "(", "0", ")", ";", "item", ".", "setData", "(", "\"\"", ")", ";", "assertEquals", "(", "\"\"", ",", "item", ".", "getData", "(", ")", ")", ";", "}", "public", "void", "testConnectionItemData", "(", ")", "{", "GraphItem", "item", "=", "(", "GraphConnection", ")", "graph", ".", "getConnections", "(", ")", ".", "get", "(", "0", ")", ";", "item", ".", "setData", "(", "\"\"", ")", ";", "assertEquals", "(", "\"\"", ",", "item", ".", "getData", "(", ")", ")", ";", "}", "public", "void", "testDisposeGraphWithDisposedNode", "(", ")", "{", "nodes", "[", "0", "]", ".", "dispose", "(", ")", ";", "graph", ".", "getNodes", "(", ")", ".", "add", "(", "nodes", "[", "0", "]", ")", ";", "assertTrue", "(", "\"\"", ",", "nodes", "[", "0", "]", ".", "isDisposed", "(", ")", ")", ";", "graph", ".", "dispose", "(", ")", ";", "assertTrue", "(", "\"\"", ",", "graph", ".", "isDisposed", "(", ")", ")", ";", "}", "public", "void", "testDisposeGraphWithDisposedConnection", "(", ")", "{", "connection", ".", "dispose", "(", ")", ";", "graph", ".", "getConnections", "(", ")", ".", "add", "(", "connection", ")", ";", "assertTrue", "(", "\"\"", ",", "connection", ".", "isDisposed", "(", ")", ")", ";", "graph", ".", "dispose", "(", ")", ";", "assertTrue", "(", "\"\"", ",", "graph", ".", "isDisposed", "(", ")", ")", ";", "}", "public", "void", "testUnHighlightNode", "(", ")", "{", "new", "ZestRootLayer", "(", ")", ".", "unHighlightNode", "(", "new", "Figure", "(", ")", ")", ";", "}", "public", "void", "testUnHighlightConnection", "(", ")", "{", "new", "ZestRootLayer", "(", ")", ".", "unHighlightConnection", "(", "new", "Figure", "(", ")", ")", ";", "}", "public", "void", "testDisposal", "(", ")", "{", "GraphNode", "n", "=", "(", "GraphNode", ")", "graph", ".", "getNodes", "(", ")", ".", "get", "(", "0", ")", ";", "GraphConnection", "c", "=", "(", "GraphConnection", ")", "graph", ".", "getConnections", "(", ")", ".", "get", "(", "0", ")", ";", "shell", ".", "dispose", "(", ")", ";", "assertTrue", "(", "\"\"", ",", "n", ".", "isDisposed", "(", ")", ")", ";", "assertTrue", "(", "\"\"", ",", "c", ".", "isDisposed", "(", ")", ")", ";", "}", "}", "</s>" ]
10,146
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "tests", ";", "import", "junit", ".", "framework", ".", "Assert", ";", "import", "junit", ".", "framework", ".", "TestCase", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Item", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Shell", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "DAGExpandCollapseManager", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "DefaultSubgraph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "Graph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphConnection", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphItem", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphNode", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "LayoutFilter", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "LayoutAlgorithm", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "GridLayoutAlgorithm", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "LayoutContext", ";", "public", "class", "LayoutAlgorithmTests", "extends", "TestCase", "{", "public", "void", "testCustomLayoutSimpleItemAccess", "(", ")", "{", "Graph", "graph", "=", "new", "Graph", "(", "new", "Shell", "(", ")", ",", "SWT", ".", "NONE", ")", ";", "new", "GraphNode", "(", "graph", ",", "SWT", ".", "NONE", ")", ";", "graph", ".", "setLayoutAlgorithm", "(", "new", "LayoutAlgorithm", "(", ")", "{", "public", "void", "setLayoutContext", "(", "LayoutContext", "context", ")", "{", "Item", "[", "]", "all", "=", "context", ".", "getEntities", "(", ")", "[", "0", "]", ".", "getItems", "(", ")", ";", "Item", "[", "]", "nodes", "=", "context", ".", "getNodes", "(", ")", "[", "0", "]", ".", "getItems", "(", ")", ";", "Assert", ".", "assertEquals", "(", "1", ",", "all", ".", "length", ")", ";", "Assert", ".", "assertEquals", "(", "1", ",", "nodes", ".", "length", ")", ";", "Assert", ".", "assertTrue", "(", "\"\"", ",", "all", "instanceof", "GraphNode", "[", "]", ")", ";", "Assert", ".", "assertTrue", "(", "\"\"", ",", "nodes", "instanceof", "GraphNode", "[", "]", ")", ";", "Assert", ".", "assertTrue", "(", "\"\"", ",", "all", "[", "0", "]", "instanceof", "GraphNode", ")", ";", "Assert", ".", "assertTrue", "(", "\"\"", ",", "nodes", "[", "0", "]", "instanceof", "GraphNode", ")", ";", "}", "public", "void", "applyLayout", "(", "boolean", "clean", ")", "{", "}", "}", ",", "true", ")", ";", "}", "public", "void", "testCustomLayoutSubgraphItemAccess", "(", ")", "{", "Graph", "graph", "=", "new", "Graph", "(", "new", "Shell", "(", ")", ",", "SWT", ".", "NONE", ")", ";", "graph", ".", "setSubgraphFactory", "(", "new", "DefaultSubgraph", ".", "PrunedSuccessorsSubgraphFactory", "(", ")", ")", ";", "graph", ".", "setExpandCollapseManager", "(", "new", "DAGExpandCollapseManager", "(", ")", ")", ";", "GraphNode", "n1", "=", "new", "GraphNode", "(", "graph", ",", "SWT", ".", "NONE", ")", ";", "GraphNode", "n2", "=", "new", "GraphNode", "(", "graph", ",", "SWT", ".", "NONE", ")", ";", "GraphNode", "n3", "=", "new", "GraphNode", "(", "graph", ",", "SWT", ".", "NONE", ")", ";", "new", "GraphConnection", "(", "graph", ",", "SWT", ".", "NONE", ",", "n1", ",", "n2", ")", ";", "new", "GraphConnection", "(", "graph", ",", "SWT", ".", "NONE", ",", "n1", ",", "n3", ")", ";", "graph", ".", "setLayoutAlgorithm", "(", "new", "LayoutAlgorithm", "(", ")", "{", "public", "void", "setLayoutContext", "(", "LayoutContext", "context", ")", "{", "Assert", ".", "assertEquals", "(", "1", ",", "context", ".", "getSubgraphs", "(", ")", ".", "length", ")", ";", "Item", "[", "]", "sub", "=", "context", ".", "getSubgraphs", "(", ")", "[", "0", "]", ".", "getItems", "(", ")", ";", "Assert", ".", "assertEquals", "(", "3", ",", "sub", ".", "length", ")", ";", "Assert", ".", "assertTrue", "(", "\"\"", ",", "sub", "instanceof", "GraphNode", "[", "]", ")", ";", "Assert", ".", "assertTrue", "(", "\"\"", ",", "sub", "[", "0", "]", "instanceof", "GraphNode", ")", ";", "}", "public", "void", "applyLayout", "(", "boolean", "clean", ")", "{", "}", "}", ",", "true", ")", ";", "}", "public", "void", "testCustomLayoutSubgraphFilteredAccess", "(", ")", "{", "Graph", "graph", "=", "new", "Graph", "(", "new", "Shell", "(", ")", ",", "SWT", ".", "NONE", ")", ";", "graph", ".", "setSubgraphFactory", "(", "new", "DefaultSubgraph", ".", "PrunedSuccessorsSubgraphFactory", "(", ")", ")", ";", "graph", ".", "setExpandCollapseManager", "(", "new", "DAGExpandCollapseManager", "(", ")", ")", ";", "GraphNode", "n1", "=", "new", "GraphNode", "(", "graph", ",", "SWT", ".", "NONE", ")", ";", "GraphNode", "n2", "=", "new", "GraphNode", "(", "graph", ",", "SWT", ".", "NONE", ",", "\"filter\"", ")", ";", "GraphNode", "n3", "=", "new", "GraphNode", "(", "graph", ",", "SWT", ".", "NONE", ")", ";", "new", "GraphConnection", "(", "graph", ",", "SWT", ".", "NONE", ",", "n1", ",", "n2", ")", ";", "new", "GraphConnection", "(", "graph", ",", "SWT", ".", "NONE", ",", "n1", ",", "n3", ")", ";", "graph", ".", "addLayoutFilter", "(", "new", "LayoutFilter", "(", ")", "{", "public", "boolean", "isObjectFiltered", "(", "GraphItem", "item", ")", "{", "if", "(", "item", "instanceof", "GraphNode", ")", "{", "GraphNode", "node", "=", "(", "GraphNode", ")", "item", ";", "if", "(", "node", ".", "getText", "(", ")", ".", "equals", "(", "\"filter\"", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}", "}", ")", ";", "graph", ".", "setLayoutAlgorithm", "(", "new", "LayoutAlgorithm", "(", ")", "{", "public", "void", "setLayoutContext", "(", "LayoutContext", "context", ")", "{", "Assert", ".", "assertEquals", "(", "1", ",", "context", ".", "getSubgraphs", "(", ")", ".", "length", ")", ";", "Item", "[", "]", "sub", "=", "context", ".", "getSubgraphs", "(", ")", "[", "0", "]", ".", "getItems", "(", ")", ";", "Assert", ".", "assertEquals", "(", "2", ",", "sub", ".", "length", ")", ";", "}", "public", "void", "applyLayout", "(", "boolean", "clean", ")", "{", "}", "}", ",", "true", ")", ";", "}", "public", "void", "testGridLayoutAlgorithmEmptyGraph", "(", ")", "{", "Graph", "graph", "=", "new", "Graph", "(", "new", "Shell", "(", ")", ",", "SWT", ".", "NONE", ")", ";", "graph", ".", "setLayoutAlgorithm", "(", "new", "GridLayoutAlgorithm", "(", ")", ",", "true", ")", ";", "Assert", ".", "assertEquals", "(", "GridLayoutAlgorithm", ".", "class", ",", "graph", ".", "getLayoutAlgorithm", "(", ")", ".", "getClass", "(", ")", ")", ";", "}", "}", "</s>" ]
10,147
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "cloudio", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "BaseLabelProvider", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Color", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "FontData", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "RGB", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "cloudio", ".", "ICloudLabelProvider", ";", "public", "class", "TestLabelProvider", "extends", "BaseLabelProvider", "implements", "ICloudLabelProvider", "{", "public", "static", "final", "double", "WEIGHT", "=", "0.987D", ";", "public", "static", "final", "float", "ANGLE", "=", "12.34F", ";", "public", "static", "Color", "COLOR", "=", "new", "Color", "(", "Display", ".", "getDefault", "(", ")", ",", "new", "RGB", "(", "100", ",", "100", ",", "100", ")", ")", ";", "public", "static", "FontData", "[", "]", "FONT_DATA", "=", "Display", ".", "getDefault", "(", ")", ".", "getShells", "(", ")", "[", "0", "]", ".", "getFont", "(", ")", ".", "getFontData", "(", ")", ";", "public", "String", "getLabel", "(", "Object", "element", ")", "{", "return", "element", ".", "toString", "(", ")", ";", "}", "public", "double", "getWeight", "(", "Object", "element", ")", "{", "return", "WEIGHT", ";", "}", "public", "Color", "getColor", "(", "Object", "element", ")", "{", "return", "COLOR", ";", "}", "public", "FontData", "[", "]", "getFontData", "(", "Object", "element", ")", "{", "return", "FONT_DATA", ".", "clone", "(", ")", ";", "}", "public", "float", "getAngle", "(", "Object", "element", ")", "{", "return", "ANGLE", ";", "}", "public", "String", "getToolTip", "(", "Object", "element", ")", "{", "return", "getLabel", "(", "element", ")", ";", "}", "}", "</s>" ]
10,148
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "cloudio", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "junit", ".", "framework", ".", "Assert", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "MouseEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "MouseListener", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "MouseMoveListener", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "MouseTrackListener", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "MouseWheelListener", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionListener", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Color", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Rectangle", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "layout", ".", "FillLayout", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Composite", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Event", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Shell", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "cloudio", ".", "TagCloud", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "cloudio", ".", "Word", ";", "import", "org", ".", "junit", ".", "After", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "Test", ";", "public", "class", "TagCloudTests", "{", "private", "Display", "display", ";", "private", "boolean", "createdDisplay", "=", "false", ";", "private", "Composite", "composite", ";", "@", "Before", "public", "void", "setUp", "(", ")", "throws", "Exception", "{", "display", "=", "Display", ".", "getCurrent", "(", ")", ";", "if", "(", "display", "==", "null", ")", "{", "display", "=", "new", "Display", "(", ")", ";", "createdDisplay", "=", "true", ";", "}", "composite", "=", "new", "Shell", "(", "display", ")", ";", "composite", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "}", "@", "After", "public", "void", "tearDown", "(", ")", "throws", "Exception", "{", "composite", ".", "dispose", "(", ")", ";", "if", "(", "createdDisplay", ")", "{", "display", ".", "dispose", "(", ")", ";", "}", "}", "@", "Test", "(", "expected", "=", "IllegalArgumentException", ".", "class", ")", "public", "void", "testConstructor_NullParent", "(", ")", "{", "new", "TagCloud", "(", "null", ",", "SWT", ".", "NONE", ")", ";", "}", "@", "Test", "public", "void", "testConstructor_ValidParent", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "Assert", ".", "assertNotNull", "(", "cloud", ")", ";", "}", "@", "Test", "public", "void", "testDispose", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "cloud", ".", "dispose", "(", ")", ";", "Assert", ".", "assertTrue", "(", "cloud", ".", "isDisposed", "(", ")", ")", ";", "}", "@", "Test", "(", "expected", "=", "IllegalArgumentException", ".", "class", ")", "public", "void", "testSetInvalidBackgroundColor", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "cloud", ".", "setBackground", "(", "null", ")", ";", "}", "@", "Test", "public", "void", "testSetValidBackgroundColor", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "Color", "color", "=", "Display", ".", "getCurrent", "(", ")", ".", "getSystemColor", "(", "SWT", ".", "COLOR_RED", ")", ";", "cloud", ".", "setBackground", "(", "color", ")", ";", "Assert", ".", "assertEquals", "(", "color", ",", "cloud", ".", "getBackground", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testDefaultBackgroundColor", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "Assert", ".", "assertNotNull", "(", "cloud", ".", "getBackground", "(", ")", ")", ";", "}", "@", "Test", "(", "expected", "=", "IllegalArgumentException", ".", "class", ")", "public", "void", "testSetInvalidSelectionColor", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "cloud", ".", "setSelectionColor", "(", "null", ")", ";", "}", "@", "Test", "public", "void", "testSetValidSelectionColor", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "Color", "color", "=", "Display", ".", "getCurrent", "(", ")", ".", "getSystemColor", "(", "SWT", ".", "COLOR_RED", ")", ";", "cloud", ".", "setSelectionColor", "(", "color", ")", ";", "Assert", ".", "assertEquals", "(", "color", ",", "cloud", ".", "getSelectionColor", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testDefaultSelectionColor", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "Assert", ".", "assertNotNull", "(", "cloud", ".", "getSelectionColor", "(", ")", ")", ";", "}", "@", "Test", "(", "expected", "=", "IllegalArgumentException", ".", "class", ")", "public", "void", "testSetInvalidMaxFontSize", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "cloud", ".", "setMaxFontSize", "(", "0", ")", ";", "}", "@", "Test", "(", "expected", "=", "IllegalArgumentException", ".", "class", ")", "public", "void", "testSetInvalidMinFontSize", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "cloud", ".", "setMinFontSize", "(", "0", ")", ";", "}", "@", "Test", "public", "void", "testSetValidMaxFontSize", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "int", "size", "=", "cloud", ".", "getMaxFontSize", "(", ")", "+", "1", ";", "cloud", ".", "setMaxFontSize", "(", "size", "*", "2", ")", ";", "Assert", ".", "assertEquals", "(", "size", "*", "2", ",", "cloud", ".", "getMaxFontSize", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testSetValidMinFontSize", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "int", "size", "=", "cloud", ".", "getMinFontSize", "(", ")", "+", "1", ";", "cloud", ".", "setMinFontSize", "(", "size", "*", "2", ")", ";", "Assert", ".", "assertEquals", "(", "size", "*", "2", ",", "cloud", ".", "getMinFontSize", "(", ")", ")", ";", "}", "@", "Test", "(", "expected", "=", "IllegalArgumentException", ".", "class", ")", "public", "void", "testSetIllegalWords1", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "cloud", ".", "setWords", "(", "null", ",", "null", ")", ";", "}", "@", "Test", "(", "expected", "=", "IllegalArgumentException", ".", "class", ")", "public", "void", "testSetIllegalWords2", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "List", "<", "Word", ">", "words", "=", "new", "ArrayList", "<", "Word", ">", "(", ")", ";", "words", ".", "add", "(", "null", ")", ";", "cloud", ".", "setWords", "(", "words", ",", "null", ")", ";", "}", "@", "Test", "(", "expected", "=", "IllegalArgumentException", ".", "class", ")", "public", "void", "testSetIllegalWords3", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "List", "<", "Word", ">", "words", "=", "new", "ArrayList", "<", "Word", ">", "(", ")", ";", "Word", "w", "=", "new", "Word", "(", "\"Word\"", ")", ";", "w", ".", "setFontData", "(", "composite", ".", "getFont", "(", ")", ".", "getFontData", "(", ")", ")", ";", "w", ".", "weight", "=", "Math", ".", "random", "(", ")", ";", "words", ".", "add", "(", "w", ")", ";", "cloud", ".", "setWords", "(", "words", ",", "null", ")", ";", "}", "@", "Test", "(", "expected", "=", "IllegalArgumentException", ".", "class", ")", "public", "void", "testSetIllegalWords4", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "List", "<", "Word", ">", "words", "=", "new", "ArrayList", "<", "Word", ">", "(", ")", ";", "Word", "w", "=", "new", "Word", "(", "\"Word\"", ")", ";", "w", ".", "setColor", "(", "Display", ".", "getDefault", "(", ")", ".", "getSystemColor", "(", "SWT", ".", "COLOR_RED", ")", ")", ";", "w", ".", "weight", "=", "Math", ".", "random", "(", ")", ";", "words", ".", "add", "(", "w", ")", ";", "cloud", ".", "setWords", "(", "words", ",", "null", ")", ";", "}", "@", "Test", "(", "expected", "=", "IllegalArgumentException", ".", "class", ")", "public", "void", "testSetIllegalWords5", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "List", "<", "Word", ">", "words", "=", "new", "ArrayList", "<", "Word", ">", "(", ")", ";", "Word", "word", "=", "getWord", "(", ")", ";", "word", ".", "angle", "=", "-", "180", ";", "words", ".", "add", "(", "word", ")", ";", "cloud", ".", "setWords", "(", "words", ",", "null", ")", ";", "}", "@", "Test", "(", "expected", "=", "IllegalArgumentException", ".", "class", ")", "public", "void", "testSetIllegalWords6", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "List", "<", "Word", ">", "words", "=", "new", "ArrayList", "<", "Word", ">", "(", ")", ";", "Word", "word", "=", "getWord", "(", ")", ";", "word", ".", "angle", "=", "180", ";", "words", ".", "add", "(", "word", ")", ";", "cloud", ".", "setWords", "(", "words", ",", "null", ")", ";", "}", "@", "Test", "(", "expected", "=", "IllegalArgumentException", ".", "class", ")", "public", "void", "testSetIllegalWords7", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "List", "<", "Word", ">", "words", "=", "new", "ArrayList", "<", "Word", ">", "(", ")", ";", "Word", "word", "=", "getWord", "(", ")", ";", "word", ".", "weight", "=", "-", "1", ";", "words", ".", "add", "(", "word", ")", ";", "cloud", ".", "setWords", "(", "words", ",", "null", ")", ";", "}", "@", "Test", "(", "expected", "=", "IllegalArgumentException", ".", "class", ")", "public", "void", "testSetIllegalWords8", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "List", "<", "Word", ">", "words", "=", "new", "ArrayList", "<", "Word", ">", "(", ")", ";", "Word", "word", "=", "getWord", "(", ")", ";", "word", ".", "weight", "=", "2", ";", "words", ".", "add", "(", "word", ")", ";", "cloud", ".", "setWords", "(", "words", ",", "null", ")", ";", "}", "@", "Test", "(", "expected", "=", "IllegalArgumentException", ".", "class", ")", "public", "void", "testSetIllegalWords9", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "List", "<", "Word", ">", "words", "=", "new", "ArrayList", "<", "Word", ">", "(", ")", ";", "Word", "word", "=", "new", "Word", "(", "null", ")", ";", "words", ".", "add", "(", "word", ")", ";", "cloud", ".", "setWords", "(", "words", ",", "null", ")", ";", "}", "private", "Word", "getWord", "(", ")", "{", "Word", "w", "=", "new", "Word", "(", "\"Word\"", ")", ";", "w", ".", "setColor", "(", "Display", ".", "getDefault", "(", ")", ".", "getSystemColor", "(", "SWT", ".", "COLOR_GRAY", ")", ")", ";", "w", ".", "setFontData", "(", "composite", ".", "getFont", "(", ")", ".", "getFontData", "(", ")", ")", ";", "w", ".", "weight", "=", "1", ";", "return", "w", ";", "}", "@", "Test", "public", "void", "testSetEmptyWordList", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "List", "<", "Word", ">", "words", "=", "new", "ArrayList", "<", "Word", ">", "(", ")", ";", "int", "placed", "=", "cloud", ".", "setWords", "(", "words", ",", "null", ")", ";", "Assert", ".", "assertEquals", "(", "0", ",", "placed", ")", ";", "}", "@", "Test", "public", "void", "testSetWordList", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "List", "<", "Word", ">", "words", "=", "new", "ArrayList", "<", "Word", ">", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "10", ";", "i", "++", ")", "{", "words", ".", "add", "(", "getWord", "(", ")", ")", ";", "}", "int", "placed", "=", "cloud", ".", "setWords", "(", "words", ",", "null", ")", ";", "Assert", ".", "assertEquals", "(", "10", ",", "placed", ")", ";", "}", "@", "Test", "(", "expected", "=", "IllegalArgumentException", ".", "class", ")", "public", "void", "testSetInvalidOpacity1", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "cloud", ".", "setOpacity", "(", "-", "1", ")", ";", "}", "@", "Test", "(", "expected", "=", "IllegalArgumentException", ".", "class", ")", "public", "void", "testSetInvalidOpacity2", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "cloud", ".", "setOpacity", "(", "256", ")", ";", "}", "@", "Test", "(", "expected", "=", "IllegalArgumentException", ".", "class", ")", "public", "void", "testSetInvalidLayouter", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "cloud", ".", "setLayouter", "(", "null", ")", ";", "}", "@", "Test", "public", "void", "testZoomIn", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "cloud", ".", "setWords", "(", "Arrays", ".", "asList", "(", "getWord", "(", ")", ")", ",", "null", ")", ";", "double", "zoom", "=", "cloud", ".", "getZoom", "(", ")", ";", "cloud", ".", "zoomIn", "(", ")", ";", "Assert", ".", "assertTrue", "(", "cloud", ".", "getZoom", "(", ")", ">", "zoom", ")", ";", "}", "@", "Test", "public", "void", "testZoomReset", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "cloud", ".", "setWords", "(", "Arrays", ".", "asList", "(", "getWord", "(", ")", ")", ",", "null", ")", ";", "double", "zoom", "=", "cloud", ".", "getZoom", "(", ")", ";", "cloud", ".", "zoomReset", "(", ")", ";", "Assert", ".", "assertTrue", "(", "cloud", ".", "getZoom", "(", ")", ">", "zoom", ")", ";", "Assert", ".", "assertEquals", "(", "cloud", ".", "getZoom", "(", ")", ",", "1.0", ")", ";", "}", "@", "Test", "public", "void", "testZoomOut", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "cloud", ".", "setWords", "(", "Arrays", ".", "asList", "(", "getWord", "(", ")", ")", ",", "null", ")", ";", "cloud", ".", "zoomReset", "(", ")", ";", "double", "zoom", "=", "cloud", ".", "getZoom", "(", ")", ";", "cloud", ".", "zoomOut", "(", ")", ";", "Assert", ".", "assertTrue", "(", "cloud", ".", "getZoom", "(", ")", "<", "zoom", ")", ";", "}", "@", "Test", "public", "void", "testZoomFit", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "V_SCROLL", "|", "SWT", ".", "H_SCROLL", ")", ";", "cloud", ".", "setWords", "(", "Arrays", ".", "asList", "(", "getWord", "(", ")", ")", ",", "null", ")", ";", "cloud", ".", "zoomReset", "(", ")", ";", "double", "zoom", "=", "cloud", ".", "getZoom", "(", ")", ";", "cloud", ".", "zoomFit", "(", ")", ";", "Assert", ".", "assertTrue", "(", "cloud", ".", "getZoom", "(", ")", "<", "zoom", ")", ";", "}", "@", "Test", "public", "void", "testGetImageData", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "Assert", ".", "assertNotNull", "(", "cloud", ".", "getImageData", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testInitialSelection", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "Set", "<", "Word", ">", "selection", "=", "cloud", ".", "getSelection", "(", ")", ";", "Assert", ".", "assertNotNull", "(", "selection", ")", ";", "Assert", ".", "assertTrue", "(", "selection", ".", "isEmpty", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testSetSelection", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "List", "<", "Word", ">", "words", "=", "new", "ArrayList", "<", "Word", ">", "(", ")", ";", "words", ".", "add", "(", "getWord", "(", ")", ")", ";", "words", ".", "add", "(", "getWord", "(", ")", ")", ";", "cloud", ".", "setWords", "(", "words", ",", "null", ")", ";", "Set", "<", "Word", ">", "sel", "=", "new", "HashSet", "<", "Word", ">", "(", ")", ";", "sel", ".", "add", "(", "words", ".", "get", "(", "0", ")", ")", ";", "cloud", ".", "setSelection", "(", "sel", ")", ";", "Set", "<", "Word", ">", "selection", "=", "cloud", ".", "getSelection", "(", ")", ";", "Assert", ".", "assertEquals", "(", "sel", ",", "selection", ")", ";", "cloud", ".", "setSelection", "(", "new", "HashSet", "<", "Word", ">", "(", ")", ")", ";", "selection", "=", "cloud", ".", "getSelection", "(", ")", ";", "Assert", ".", "assertTrue", "(", "selection", ".", "isEmpty", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testSetNotExistingSelection1", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "List", "<", "Word", ">", "words", "=", "new", "ArrayList", "<", "Word", ">", "(", ")", ";", "words", ".", "add", "(", "getWord", "(", ")", ")", ";", "words", ".", "add", "(", "getWord", "(", ")", ")", ";", "cloud", ".", "setWords", "(", "words", ",", "null", ")", ";", "Set", "<", "Word", ">", "sel", "=", "new", "HashSet", "<", "Word", ">", "(", ")", ";", "sel", ".", "add", "(", "getWord", "(", ")", ")", ";", "cloud", ".", "setSelection", "(", "sel", ")", ";", "Set", "<", "Word", ">", "selection", "=", "cloud", ".", "getSelection", "(", ")", ";", "Assert", ".", "assertTrue", "(", "selection", ".", "isEmpty", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testSetNotExistingSelection2", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "Set", "<", "Word", ">", "sel", "=", "new", "HashSet", "<", "Word", ">", "(", ")", ";", "sel", ".", "add", "(", "getWord", "(", ")", ")", ";", "cloud", ".", "setSelection", "(", "sel", ")", ";", "Set", "<", "Word", ">", "selection", "=", "cloud", ".", "getSelection", "(", ")", ";", "Assert", ".", "assertTrue", "(", "selection", ".", "isEmpty", "(", ")", ")", ";", "}", "@", "Test", "(", "expected", "=", "IllegalArgumentException", ".", "class", ")", "public", "void", "testSetInvalidBoost", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "cloud", ".", "setBoost", "(", "-", "1", ")", ";", "}", "@", "Test", "public", "void", "testSetValidBoost", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "Assert", ".", "assertEquals", "(", "0", ",", "cloud", ".", "getBoost", "(", ")", ")", ";", "cloud", ".", "setBoost", "(", "3", ")", ";", "Assert", ".", "assertEquals", "(", "3", ",", "cloud", ".", "getBoost", "(", ")", ")", ";", "}", "@", "Test", "(", "expected", "=", "IllegalArgumentException", ".", "class", ")", "public", "void", "testSetInvalidBoostFactor", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "cloud", ".", "setBoostFactor", "(", "0", ")", ";", "}", "@", "Test", "public", "void", "testSetValidBoostFactor", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "cloud", ".", "setBoostFactor", "(", "3.3F", ")", ";", "Assert", ".", "assertEquals", "(", "3.3F", ",", "cloud", ".", "getBoostFactor", "(", ")", ")", ";", "cloud", ".", "setBoostFactor", "(", "-", "2.2F", ")", ";", "Assert", ".", "assertEquals", "(", "-", "2.2F", ",", "cloud", ".", "getBoostFactor", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testLayout", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "List", "<", "Word", ">", "words", "=", "new", "ArrayList", "<", "Word", ">", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "10", ";", "i", "++", ")", "{", "words", ".", "add", "(", "getWord", "(", ")", ")", ";", "}", "for", "(", "Word", "word", ":", "words", ")", "{", "Assert", ".", "assertTrue", "(", "word", ".", "x", "==", "0", ")", ";", "Assert", ".", "assertTrue", "(", "word", ".", "y", "==", "0", ")", ";", "}", "cloud", ".", "setWords", "(", "words", ",", "null", ")", ";", "List", "<", "Rectangle", ">", "rects", "=", "new", "ArrayList", "<", "Rectangle", ">", "(", ")", ";", "for", "(", "Word", "word", ":", "words", ")", "{", "Assert", ".", "assertTrue", "(", "word", ".", "x", "!=", "0", ")", ";", "Assert", ".", "assertTrue", "(", "word", ".", "y", "!=", "0", ")", ";", "word", ".", "angle", "=", "45f", ";", "rects", ".", "add", "(", "new", "Rectangle", "(", "word", ".", "x", ",", "word", ".", "y", ",", "word", ".", "width", ",", "word", ".", "height", ")", ")", ";", "}", "cloud", ".", "layoutCloud", "(", "null", ",", "false", ")", ";", "boolean", "posChanged", "=", "false", ";", "boolean", "rectChanged", "=", "false", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "words", ".", "size", "(", ")", ";", "i", "++", ")", "{", "Word", "w", "=", "words", ".", "get", "(", "i", ")", ";", "Rectangle", "r", "=", "rects", ".", "get", "(", "i", ")", ";", "if", "(", "w", ".", "x", "!=", "r", ".", "x", "||", "w", ".", "y", "!=", "r", ".", "y", ")", "{", "posChanged", "=", "true", ";", "}", "if", "(", "w", ".", "width", "!=", "r", ".", "width", "||", "w", ".", "height", "!=", "r", ".", "height", ")", "{", "rectChanged", "=", "true", ";", "}", "}", "Assert", ".", "assertTrue", "(", "posChanged", ")", ";", "Assert", ".", "assertFalse", "(", "rectChanged", ")", ";", "cloud", ".", "layoutCloud", "(", "null", ",", "true", ")", ";", "posChanged", "=", "false", ";", "rectChanged", "=", "false", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "words", ".", "size", "(", ")", ";", "i", "++", ")", "{", "Word", "w", "=", "words", ".", "get", "(", "i", ")", ";", "Rectangle", "r", "=", "rects", ".", "get", "(", "i", ")", ";", "if", "(", "w", ".", "x", "!=", "r", ".", "x", "||", "w", ".", "y", "!=", "r", ".", "y", ")", "{", "posChanged", "=", "true", ";", "}", "if", "(", "w", ".", "width", "!=", "r", ".", "width", "||", "w", ".", "height", "!=", "r", ".", "height", ")", "{", "rectChanged", "=", "true", ";", "}", "}", "Assert", ".", "assertTrue", "(", "posChanged", ")", ";", "Assert", ".", "assertTrue", "(", "rectChanged", ")", ";", "}", "class", "UniversalListener", "implements", "MouseListener", ",", "MouseTrackListener", ",", "MouseWheelListener", ",", "MouseMoveListener", ",", "SelectionListener", "{", "private", "int", "mouseUp", ";", "private", "int", "mouseDown", ";", "private", "int", "mouseDC", ";", "private", "int", "mouseMove", ";", "private", "int", "mouseScrolled", ";", "private", "int", "mouseExit", ";", "private", "int", "mouseEnter", ";", "private", "int", "mouseHover", ";", "private", "Set", "<", "Word", ">", "selection", ";", "public", "void", "mouseUp", "(", "MouseEvent", "e", ")", "{", "mouseUp", "++", ";", "}", "public", "void", "mouseDown", "(", "MouseEvent", "e", ")", "{", "mouseDown", "++", ";", "}", "public", "void", "mouseDoubleClick", "(", "MouseEvent", "e", ")", "{", "mouseDC", "++", ";", "}", "public", "void", "mouseMove", "(", "MouseEvent", "e", ")", "{", "mouseMove", "++", ";", "System", ".", "out", ".", "println", "(", "\"MOVE\"", ")", ";", "}", "public", "void", "mouseScrolled", "(", "MouseEvent", "e", ")", "{", "mouseScrolled", "++", ";", "}", "public", "void", "mouseEnter", "(", "MouseEvent", "e", ")", "{", "mouseEnter", "++", ";", "}", "public", "void", "mouseExit", "(", "MouseEvent", "e", ")", "{", "mouseExit", "++", ";", "}", "public", "void", "mouseHover", "(", "MouseEvent", "e", ")", "{", "mouseHover", "++", ";", "}", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "this", ".", "selection", "=", "(", "Set", "<", "Word", ">", ")", "e", ".", "data", ";", "}", "public", "void", "widgetDefaultSelected", "(", "SelectionEvent", "e", ")", "{", "}", "}", "@", "Test", "public", "void", "testMouseListener", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "UniversalListener", "ml", "=", "new", "UniversalListener", "(", ")", ";", "List", "<", "Word", ">", "words", "=", "new", "ArrayList", "<", "Word", ">", "(", ")", ";", "Word", "word", "=", "getWord", "(", ")", ";", "words", ".", "add", "(", "word", ")", ";", "cloud", ".", "setWords", "(", "words", ",", "null", ")", ";", "Event", "e", "=", "new", "Event", "(", ")", ";", "cloud", ".", "addMouseListener", "(", "ml", ")", ";", "cloud", ".", "notifyListeners", "(", "SWT", ".", "MouseUp", ",", "e", ")", ";", "cloud", ".", "notifyListeners", "(", "SWT", ".", "MouseDoubleClick", ",", "e", ")", ";", "cloud", ".", "notifyListeners", "(", "SWT", ".", "MouseDown", ",", "e", ")", ";", "Assert", ".", "assertEquals", "(", "1", ",", "ml", ".", "mouseUp", ")", ";", "Assert", ".", "assertEquals", "(", "1", ",", "ml", ".", "mouseDC", ")", ";", "Assert", ".", "assertEquals", "(", "1", ",", "ml", ".", "mouseDown", ")", ";", "cloud", ".", "removeMouseListener", "(", "ml", ")", ";", "cloud", ".", "notifyListeners", "(", "SWT", ".", "MouseUp", ",", "e", ")", ";", "cloud", ".", "notifyListeners", "(", "SWT", ".", "MouseDoubleClick", ",", "e", ")", ";", "cloud", ".", "notifyListeners", "(", "SWT", ".", "MouseDown", ",", "e", ")", ";", "Assert", ".", "assertEquals", "(", "1", ",", "ml", ".", "mouseUp", ")", ";", "Assert", ".", "assertEquals", "(", "1", ",", "ml", ".", "mouseDC", ")", ";", "Assert", ".", "assertEquals", "(", "1", ",", "ml", ".", "mouseDown", ")", ";", "}", "@", "Test", "public", "void", "testMouseMoveListener", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "List", "<", "Word", ">", "words", "=", "new", "ArrayList", "<", "Word", ">", "(", ")", ";", "Word", "word", "=", "getWord", "(", ")", ";", "words", ".", "add", "(", "word", ")", ";", "cloud", ".", "setWords", "(", "words", ",", "null", ")", ";", "Event", "e", "=", "new", "Event", "(", ")", ";", "e", ".", "x", "=", "word", ".", "x", ";", "e", ".", "y", "=", "word", ".", "y", ";", "UniversalListener", "ml", "=", "new", "UniversalListener", "(", ")", ";", "cloud", ".", "addMouseMoveListener", "(", "ml", ")", ";", "cloud", ".", "notifyListeners", "(", "SWT", ".", "MouseMove", ",", "e", ")", ";", "Assert", ".", "assertEquals", "(", "1", ",", "ml", ".", "mouseMove", ")", ";", "cloud", ".", "removeMouseMoveListener", "(", "ml", ")", ";", "cloud", ".", "notifyListeners", "(", "SWT", ".", "MouseMove", ",", "e", ")", ";", "Assert", ".", "assertEquals", "(", "1", ",", "ml", ".", "mouseMove", ")", ";", "}", "@", "Test", "public", "void", "testMouseWheelListener", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "UniversalListener", "ml", "=", "new", "UniversalListener", "(", ")", ";", "cloud", ".", "addMouseWheelListener", "(", "ml", ")", ";", "cloud", ".", "notifyListeners", "(", "SWT", ".", "MouseWheel", ",", "new", "Event", "(", ")", ")", ";", "Assert", ".", "assertEquals", "(", "1", ",", "ml", ".", "mouseScrolled", ")", ";", "cloud", ".", "removeMouseWheelListener", "(", "ml", ")", ";", "cloud", ".", "notifyListeners", "(", "SWT", ".", "MouseWheel", ",", "new", "Event", "(", ")", ")", ";", "Assert", ".", "assertEquals", "(", "1", ",", "ml", ".", "mouseScrolled", ")", ";", "}", "@", "Test", "public", "void", "testSelectionListener", "(", ")", "{", "TagCloud", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "List", "<", "Word", ">", "words", "=", "new", "ArrayList", "<", "Word", ">", "(", ")", ";", "Word", "word", "=", "getWord", "(", ")", ";", "words", ".", "add", "(", "word", ")", ";", "cloud", ".", "setWords", "(", "words", ",", "null", ")", ";", "UniversalListener", "sl", "=", "new", "UniversalListener", "(", ")", ";", "cloud", ".", "addSelectionListener", "(", "sl", ")", ";", "cloud", ".", "setSelection", "(", "new", "HashSet", "<", "Word", ">", "(", "words", ")", ")", ";", "Assert", ".", "assertEquals", "(", "1", ",", "sl", ".", "selection", ".", "size", "(", ")", ")", ";", "cloud", ".", "setSelection", "(", "new", "HashSet", "<", "Word", ">", "(", ")", ")", ";", "Assert", ".", "assertEquals", "(", "0", ",", "sl", ".", "selection", ".", "size", "(", ")", ")", ";", "cloud", ".", "removeSelectionListener", "(", "sl", ")", ";", "cloud", ".", "setSelection", "(", "new", "HashSet", "<", "Word", ">", "(", "words", ")", ")", ";", "Assert", ".", "assertEquals", "(", "0", ",", "sl", ".", "selection", ".", "size", "(", ")", ")", ";", "}", "}", "</s>" ]
10,149
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "tests", ".", "cloudio", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "junit", ".", "framework", ".", "Assert", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "BaseLabelProvider", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "IContentProvider", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "ITreeContentProvider", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "Viewer", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "layout", ".", "FillLayout", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Composite", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Shell", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "cloudio", ".", "TagCloud", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "cloudio", ".", "TagCloudViewer", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "cloudio", ".", "Word", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "cloudio", ".", "layout", ".", "DefaultLayouter", ";", "import", "org", ".", "junit", ".", "After", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "Test", ";", "public", "class", "TagCloudViewerTests", "{", "private", "Display", "display", ";", "private", "boolean", "createdDisplay", "=", "false", ";", "private", "Composite", "composite", ";", "private", "TagCloud", "cloud", ";", "@", "Before", "public", "void", "setUp", "(", ")", "throws", "Exception", "{", "display", "=", "Display", ".", "getCurrent", "(", ")", ";", "if", "(", "display", "==", "null", ")", "{", "display", "=", "new", "Display", "(", ")", ";", "createdDisplay", "=", "true", ";", "}", "composite", "=", "new", "Shell", "(", "display", ")", ";", "composite", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "cloud", "=", "new", "TagCloud", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "}", "@", "After", "public", "void", "tearDown", "(", ")", "throws", "Exception", "{", "composite", ".", "dispose", "(", ")", ";", "if", "(", "createdDisplay", ")", "{", "display", ".", "dispose", "(", ")", ";", "}", "}", "@", "Test", "(", "expected", "=", "IllegalArgumentException", ".", "class", ")", "public", "void", "testConstructor_NullCloud", "(", ")", "{", "new", "TagCloudViewer", "(", "null", ")", ";", "}", "@", "Test", "(", "expected", "=", "IllegalArgumentException", ".", "class", ")", "public", "void", "testConstructor_DisposedCloud", "(", ")", "{", "cloud", ".", "dispose", "(", ")", ";", "new", "TagCloudViewer", "(", "cloud", ")", ";", "}", "@", "Test", "public", "void", "testConstructor_ValidCloud", "(", ")", "{", "TagCloudViewer", "viewer", "=", "new", "TagCloudViewer", "(", "cloud", ")", ";", "TagCloud", "cloud", "=", "viewer", ".", "getCloud", "(", ")", ";", "Assert", ".", "assertNotNull", "(", "cloud", ")", ";", "Assert", ".", "assertEquals", "(", "this", ".", "cloud", ",", "cloud", ")", ";", "Assert", ".", "assertTrue", "(", "viewer", ".", "getSelection", "(", ")", "!=", "null", ")", ";", "Assert", ".", "assertTrue", "(", "viewer", ".", "getSelection", "(", ")", ".", "isEmpty", "(", ")", ")", ";", "}", "@", "Test", "(", "expected", "=", "IllegalArgumentException", ".", "class", ")", "public", "void", "testInvalidLabelProvider", "(", ")", "{", "TagCloudViewer", "viewer", "=", "new", "TagCloudViewer", "(", "cloud", ")", ";", "viewer", ".", "setLabelProvider", "(", "null", ")", ";", "}", "@", "Test", "(", "expected", "=", "IllegalArgumentException", ".", "class", ")", "public", "void", "testInvalidLabelProvider2", "(", ")", "{", "TagCloudViewer", "viewer", "=", "new", "TagCloudViewer", "(", "cloud", ")", ";", "viewer", ".", "setLabelProvider", "(", "new", "BaseLabelProvider", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testValidLabelProvider", "(", ")", "{", "TagCloudViewer", "viewer", "=", "new", "TagCloudViewer", "(", "cloud", ")", ";", "TestLabelProvider", "labelProvider", "=", "new", "TestLabelProvider", "(", ")", ";", "viewer", ".", "setLabelProvider", "(", "labelProvider", ")", ";", "Assert", ".", "assertEquals", "(", "labelProvider", ",", "viewer", ".", "getLabelProvider", "(", ")", ")", ";", "}", "@", "Test", "(", "expected", "=", "IllegalArgumentException", ".", "class", ")", "public", "void", "testInvalidContentProvider", "(", ")", "{", "TagCloudViewer", "viewer", "=", "new", "TagCloudViewer", "(", "cloud", ")", ";", "viewer", ".", "setContentProvider", "(", "null", ")", ";", "}", "@", "Test", "(", "expected", "=", "IllegalArgumentException", ".", "class", ")", "public", "void", "testInvalidContentProvider2", "(", ")", "{", "TagCloudViewer", "viewer", "=", "new", "TagCloudViewer", "(", "cloud", ")", ";", "viewer", ".", "setContentProvider", "(", "new", "IContentProvider", "(", ")", "{", "public", "void", "inputChanged", "(", "Viewer", "viewer", ",", "Object", "oldInput", ",", "Object", "newInput", ")", "{", "}", "public", "void", "dispose", "(", ")", "{", "}", "}", ")", ";", "}", "private", "static", "class", "ListContentProvider", "implements", "ITreeContentProvider", "{", "public", "void", "dispose", "(", ")", "{", "}", "public", "void", "inputChanged", "(", "Viewer", "viewer", ",", "Object", "oldInput", ",", "Object", "newInput", ")", "{", "}", "public", "Object", "[", "]", "getElements", "(", "Object", "inputElement", ")", "{", "return", "(", "(", "List", "<", "?", ">", ")", "inputElement", ")", ".", "toArray", "(", ")", ";", "}", "public", "Object", "[", "]", "getChildren", "(", "Object", "parentElement", ")", "{", "return", "null", ";", "}", "public", "Object", "getParent", "(", "Object", "element", ")", "{", "return", "null", ";", "}", "public", "boolean", "hasChildren", "(", "Object", "element", ")", "{", "return", "false", ";", "}", "}", "@", "Test", "public", "void", "testValidContentProvider", "(", ")", "{", "TagCloudViewer", "viewer", "=", "new", "TagCloudViewer", "(", "cloud", ")", ";", "ListContentProvider", "provider", "=", "new", "ListContentProvider", "(", ")", ";", "viewer", ".", "setContentProvider", "(", "provider", ")", ";", "Assert", ".", "assertEquals", "(", "provider", ",", "viewer", ".", "getContentProvider", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testValidLabelAsignment", "(", ")", "{", "TagCloudViewer", "viewer", "=", "new", "TagCloudViewer", "(", "cloud", ")", ";", "ListContentProvider", "provider", "=", "new", "ListContentProvider", "(", ")", ";", "viewer", ".", "setContentProvider", "(", "provider", ")", ";", "TestLabelProvider", "labelProvider", "=", "new", "TestLabelProvider", "(", ")", ";", "viewer", ".", "setLabelProvider", "(", "labelProvider", ")", ";", "List", "<", "String", ">", "data", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "data", ".", "add", "(", "\"Hello\"", ")", ";", "data", ".", "add", "(", "\"World\"", ")", ";", "viewer", ".", "setInput", "(", "data", ")", ";", "List", "<", "Word", ">", "words", "=", "viewer", ".", "getCloud", "(", ")", ".", "getWords", "(", ")", ";", "for", "(", "Word", "word", ":", "words", ")", "{", "Assert", ".", "assertEquals", "(", "TestLabelProvider", ".", "COLOR", ",", "word", ".", "getColor", "(", ")", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "TestLabelProvider", ".", "FONT_DATA", ".", "length", ";", "i", "++", ")", "{", "Assert", ".", "assertEquals", "(", "TestLabelProvider", ".", "FONT_DATA", "[", "i", "]", ",", "word", ".", "getFontData", "(", ")", "[", "i", "]", ")", ";", "}", "Assert", ".", "assertEquals", "(", "TestLabelProvider", ".", "ANGLE", ",", "word", ".", "angle", ")", ";", "Assert", ".", "assertEquals", "(", "TestLabelProvider", ".", "WEIGHT", ",", "word", ".", "weight", ")", ";", "Assert", ".", "assertTrue", "(", "word", ".", "x", "!=", "0", ")", ";", "Assert", ".", "assertTrue", "(", "word", ".", "y", "!=", "0", ")", ";", "Assert", ".", "assertTrue", "(", "word", ".", "width", "!=", "0", ")", ";", "Assert", ".", "assertTrue", "(", "word", ".", "height", "!=", "0", ")", ";", "}", "}", "@", "Test", "(", "expected", "=", "IllegalArgumentException", ".", "class", ")", "public", "void", "testInvalidLayouter", "(", ")", "{", "TagCloudViewer", "viewer", "=", "new", "TagCloudViewer", "(", "cloud", ")", ";", "viewer", ".", "setLayouter", "(", "null", ")", ";", "}", "@", "Test", "public", "void", "testValidLayouter", "(", ")", "{", "TagCloudViewer", "viewer", "=", "new", "TagCloudViewer", "(", "cloud", ")", ";", "DefaultLayouter", "layouter", "=", "new", "DefaultLayouter", "(", "5", ",", "5", ")", ";", "viewer", ".", "setLayouter", "(", "layouter", ")", ";", "Assert", ".", "assertEquals", "(", "layouter", ",", "viewer", ".", "getLayouter", "(", ")", ")", ";", "}", "}", "</s>" ]
10,150
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "tests", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "List", ";", "import", "junit", ".", "framework", ".", "TestCase", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionListener", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Event", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Shell", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "Graph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphConnection", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphNode", ";", "public", "class", "GraphSelectionTests", "extends", "TestCase", "{", "private", "static", "final", "int", "STYLE", "=", "SWT", ".", "NONE", ";", "private", "GraphNode", "[", "]", "nodes", ";", "private", "Graph", "graph", ";", "protected", "void", "setUp", "(", ")", "throws", "Exception", "{", "graph", "=", "new", "Graph", "(", "new", "Shell", "(", ")", ",", "STYLE", ")", ";", "nodes", "=", "new", "GraphNode", "[", "]", "{", "new", "GraphNode", "(", "graph", ",", "STYLE", ")", ",", "new", "GraphNode", "(", "graph", ",", "STYLE", ")", "}", ";", "new", "GraphConnection", "(", "graph", ",", "STYLE", ",", "nodes", "[", "0", "]", ",", "nodes", "[", "1", "]", ")", ";", "}", "public", "void", "testSetSelectionGetSelection", "(", ")", "{", "graph", ".", "setSelection", "(", "new", "GraphNode", "[", "]", "{", "}", ")", ";", "assertEquals", "(", "0", ",", "graph", ".", "getSelection", "(", ")", ".", "size", "(", ")", ")", ";", "graph", ".", "setSelection", "(", "nodes", ")", ";", "assertEquals", "(", "2", ",", "graph", ".", "getSelection", "(", ")", ".", "size", "(", ")", ")", ";", "}", "public", "void", "testSelectAllGetSelection", "(", ")", "{", "graph", ".", "selectAll", "(", ")", ";", "assertEquals", "(", "2", ",", "graph", ".", "getSelection", "(", ")", ".", "size", "(", ")", ")", ";", "}", "public", "void", "testAddSelectionListenerEventIdentity", "(", ")", "{", "final", "List", "selectionEvents", "=", "new", "ArrayList", "(", ")", ";", "graph", ".", "addSelectionListener", "(", "setupListener", "(", "selectionEvents", ")", ")", ";", "graph", ".", "addSelectionListener", "(", "setupListener", "(", "selectionEvents", ")", ")", ";", "Event", "event", "=", "new", "Event", "(", ")", ";", "event", ".", "widget", "=", "nodes", "[", "0", "]", ";", "graph", ".", "notifyListeners", "(", "SWT", ".", "Selection", ",", "event", ")", ";", "assertEquals", "(", "\"\"", ",", "2", ",", "selectionEvents", ".", "size", "(", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "selectionEvents", ".", "get", "(", "0", ")", ",", "selectionEvents", ".", "get", "(", "1", ")", ")", ";", "}", "public", "void", "testSelectedNodeDisposal", "(", ")", "{", "graph", ".", "setSelection", "(", "nodes", ")", ";", "nodes", "[", "0", "]", ".", "dispose", "(", ")", ";", "graph", ".", "layout", "(", ")", ";", "assertEquals", "(", "\"\"", ",", "1", ",", "graph", ".", "getSelection", "(", ")", ".", "size", "(", ")", ")", ";", "}", "public", "void", "testAddSelectionListenerSetSelection", "(", ")", "{", "final", "List", "selectionEvents", "=", "new", "ArrayList", "(", ")", ";", "graph", ".", "addSelectionListener", "(", "setupListener", "(", "selectionEvents", ")", ")", ";", "graph", ".", "setSelection", "(", "nodes", ")", ";", "assertEquals", "(", "\"\"", ",", "0", ",", "selectionEvents", ".", "size", "(", ")", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "nodes", ".", "length", ";", "i", "++", ")", "{", "GraphNode", "node", "=", "nodes", "[", "i", "]", ";", "assertTrue", "(", "\"\"", ",", "node", ".", "isSelected", "(", ")", ")", ";", "}", "graph", ".", "setSelection", "(", "new", "GraphNode", "[", "]", "{", "nodes", "[", "0", "]", "}", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "nodes", ".", "length", ";", "i", "++", ")", "{", "GraphNode", "node", "=", "nodes", "[", "i", "]", ";", "assertFalse", "(", "\"\"", ",", "node", ".", "isSelected", "(", ")", ")", ";", "}", "}", "public", "void", "testAddSelectionListenerSelectAll", "(", ")", "{", "final", "List", "selectionEvents", "=", "new", "ArrayList", "(", ")", ";", "graph", ".", "addSelectionListener", "(", "setupListener", "(", "selectionEvents", ")", ")", ";", "graph", ".", "selectAll", "(", ")", ";", "assertEquals", "(", "\"\"", ",", "0", ",", "selectionEvents", ".", "size", "(", ")", ")", ";", "for", "(", "Iterator", "iterator", "=", "graph", ".", "getNodes", "(", ")", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "GraphNode", "node", "=", "(", "GraphNode", ")", "iterator", ".", "next", "(", ")", ";", "assertTrue", "(", "\"\"", ",", "node", ".", "isSelected", "(", ")", ")", ";", "}", "}", "public", "void", "testAddSelectionListenerNotifyListeners", "(", ")", "{", "final", "List", "selectionEvents", "=", "new", "ArrayList", "(", ")", ";", "graph", ".", "addSelectionListener", "(", "setupListener", "(", "selectionEvents", ")", ")", ";", "graph", ".", "setSelection", "(", "nodes", ")", ";", "Event", "event", "=", "new", "Event", "(", ")", ";", "event", ".", "widget", "=", "graph", ";", "graph", ".", "notifyListeners", "(", "SWT", ".", "Dispose", ",", "event", ")", ";", "assertEquals", "(", "\"\"", ",", "0", ",", "selectionEvents", ".", "size", "(", ")", ")", ";", "graph", ".", "notifyListeners", "(", "SWT", ".", "Selection", ",", "event", ")", ";", "assertEquals", "(", "\"\"", ",", "1", ",", "selectionEvents", ".", "size", "(", ")", ")", ";", "}", "public", "void", "testClearGraphCheckSelection", "(", ")", "throws", "Exception", "{", "graph", ".", "setSelection", "(", "nodes", ")", ";", "assertEquals", "(", "2", ",", "graph", ".", "getSelection", "(", ")", ".", "size", "(", ")", ")", ";", "graph", ".", "clear", "(", ")", ";", "assertEquals", "(", "0", ",", "graph", ".", "getNodes", "(", ")", ".", "size", "(", ")", ")", ";", "assertEquals", "(", "0", ",", "graph", ".", "getConnections", "(", ")", ".", "size", "(", ")", ")", ";", "assertEquals", "(", "0", ",", "graph", ".", "getSelection", "(", ")", ".", "size", "(", ")", ")", ";", "setUp", "(", ")", ";", "assertEquals", "(", "2", ",", "graph", ".", "getNodes", "(", ")", ".", "size", "(", ")", ")", ";", "assertEquals", "(", "1", ",", "graph", ".", "getConnections", "(", ")", ".", "size", "(", ")", ")", ";", "}", "private", "SelectionListener", "setupListener", "(", "final", "List", "events", ")", "{", "return", "new", "SelectionListener", "(", ")", "{", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "events", ".", "add", "(", "e", ")", ";", "}", "public", "void", "widgetDefaultSelected", "(", "SelectionEvent", "e", ")", "{", "}", "}", ";", "}", "}", "</s>" ]
10,151
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "tests", ";", "import", "junit", ".", "framework", ".", "Assert", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "Platform", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "runner", ".", "RunWith", ";", "import", "org", ".", "junit", ".", "runners", ".", "Suite", ";", "@", "RunWith", "(", "Suite", ".", "class", ")", "@", "Suite", ".", "SuiteClasses", "(", "{", "AllHeadlessTests", ".", "class", ",", "AllUiTests", ".", "class", "}", ")", "public", "final", "class", "AllTests", "{", "@", "Before", "public", "void", "setup", "(", ")", "{", "if", "(", "!", "Platform", ".", "isRunning", "(", ")", ")", "{", "Assert", ".", "fail", "(", "\"\"", ")", ";", "}", "}", "}", "</s>" ]
10,152
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "internal", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "AbstractStructuredGraphViewer", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "IFigureProvider", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "IGraphContentProvider", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "Graph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphConnection", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphNode", ";", "public", "class", "GraphModelFactory", "extends", "AbstractStylingModelFactory", "{", "AbstractStructuredGraphViewer", "viewer", "=", "null", ";", "public", "GraphModelFactory", "(", "AbstractStructuredGraphViewer", "viewer", ")", "{", "super", "(", "viewer", ")", ";", "this", ".", "viewer", "=", "viewer", ";", "}", "public", "Graph", "createGraphModel", "(", "Graph", "model", ")", "{", "doBuildGraph", "(", "model", ")", ";", "return", "model", ";", "}", "protected", "void", "doBuildGraph", "(", "Graph", "model", ")", "{", "super", ".", "doBuildGraph", "(", "model", ")", ";", "Object", "rels", "[", "]", "=", "getContentProvider", "(", ")", ".", "getElements", "(", "getViewer", "(", ")", ".", "getInput", "(", ")", ")", ";", "if", "(", "rels", "!=", "null", ")", "{", "IFigureProvider", "figureProvider", "=", "null", ";", "if", "(", "getLabelProvider", "(", ")", "instanceof", "IFigureProvider", ")", "{", "figureProvider", "=", "(", "IFigureProvider", ")", "getLabelProvider", "(", ")", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "rels", ".", "length", ";", "i", "++", ")", "{", "Object", "source", "=", "getCastedContent", "(", ")", ".", "getSource", "(", "rels", "[", "i", "]", ")", ";", "source", "=", "filterElement", "(", "getViewer", "(", ")", ".", "getInput", "(", ")", ",", "source", ")", "?", "null", ":", "source", ";", "Object", "dest", "=", "getCastedContent", "(", ")", ".", "getDestination", "(", "rels", "[", "i", "]", ")", ";", "dest", "=", "filterElement", "(", "getViewer", "(", ")", ".", "getInput", "(", ")", ",", "dest", ")", "?", "null", ":", "dest", ";", "if", "(", "source", "==", "null", ")", "{", "if", "(", "dest", "!=", "null", ")", "{", "if", "(", "figureProvider", "!=", "null", ")", "{", "createNode", "(", "model", ",", "dest", ",", "figureProvider", ".", "getFigure", "(", "dest", ")", ")", ";", "}", "else", "{", "createNode", "(", "model", ",", "dest", ")", ";", "}", "}", "continue", ";", "}", "else", "if", "(", "dest", "==", "null", ")", "{", "if", "(", "source", "!=", "null", ")", "{", "if", "(", "figureProvider", "!=", "null", ")", "{", "createNode", "(", "model", ",", "source", ",", "figureProvider", ".", "getFigure", "(", "source", ")", ")", ";", "}", "else", "{", "createNode", "(", "model", ",", "source", ")", ";", "}", "}", "continue", ";", "}", "if", "(", "source", "!=", "null", "&&", "dest", "!=", "null", "&&", "!", "filterElement", "(", "getViewer", "(", ")", ".", "getInput", "(", ")", ",", "rels", "[", "i", "]", ")", ")", "{", "createConnection", "(", "model", ",", "rels", "[", "i", "]", ",", "getCastedContent", "(", ")", ".", "getSource", "(", "rels", "[", "i", "]", ")", ",", "getCastedContent", "(", ")", ".", "getDestination", "(", "rels", "[", "i", "]", ")", ")", ";", "}", "}", "}", "}", "private", "IGraphContentProvider", "getCastedContent", "(", ")", "{", "return", "(", "IGraphContentProvider", ")", "getContentProvider", "(", ")", ";", "}", "public", "void", "refresh", "(", "Graph", "graph", ",", "Object", "element", ")", "{", "refresh", "(", "graph", ",", "element", ",", "false", ")", ";", "}", "public", "void", "refresh", "(", "Graph", "graph", ",", "Object", "element", ",", "boolean", "updateLabels", ")", "{", "GraphConnection", "conn", "=", "viewer", ".", "getGraphModelConnection", "(", "element", ")", ";", "if", "(", "conn", "==", "null", ")", "{", "GraphNode", "node", "=", "viewer", ".", "getGraphModelNode", "(", "element", ")", ";", "if", "(", "node", "!=", "null", ")", "{", "List", "connections", "=", "node", ".", "getSourceConnections", "(", ")", ";", "for", "(", "Iterator", "it", "=", "connections", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "GraphConnection", "c", "=", "(", "GraphConnection", ")", "it", ".", "next", "(", ")", ";", "refresh", "(", "graph", ",", "c", ".", "getExternalConnection", "(", ")", ",", "updateLabels", ")", ";", "}", "connections", "=", "node", ".", "getTargetConnections", "(", ")", ";", "for", "(", "Iterator", "it", "=", "connections", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "GraphConnection", "c", "=", "(", "GraphConnection", ")", "it", ".", "next", "(", ")", ";", "refresh", "(", "graph", ",", "c", ".", "getExternalConnection", "(", ")", ",", "updateLabels", ")", ";", "}", "}", "return", ";", "}", "Object", "oldSource", "=", "conn", ".", "getSource", "(", ")", ".", "getData", "(", ")", ";", "Object", "oldDest", "=", "conn", ".", "getDestination", "(", ")", ".", "getData", "(", ")", ";", "Object", "newSource", "=", "getCastedContent", "(", ")", ".", "getSource", "(", "element", ")", ";", "Object", "newDest", "=", "getCastedContent", "(", ")", ".", "getDestination", "(", "element", ")", ";", "if", "(", "!", "(", "oldSource", ".", "equals", "(", "newSource", ")", "&&", "oldDest", ".", "equals", "(", "newDest", ")", ")", ")", "{", "GraphNode", "internalSource", "=", "viewer", ".", "getGraphModelNode", "(", "newSource", ")", ";", "GraphNode", "internalDest", "=", "viewer", ".", "getGraphModelNode", "(", "newDest", ")", ";", "if", "(", "internalSource", "==", "null", ")", "{", "internalSource", "=", "createNode", "(", "graph", ",", "newSource", ")", ";", "}", "else", "if", "(", "updateLabels", ")", "{", "styleItem", "(", "internalSource", ")", ";", "}", "if", "(", "internalDest", "==", "null", ")", "{", "internalDest", "=", "createNode", "(", "graph", ",", "newDest", ")", ";", "}", "else", "if", "(", "updateLabels", ")", "{", "styleItem", "(", "internalDest", ")", ";", "}", "if", "(", "updateLabels", ")", "{", "styleItem", "(", "conn", ")", ";", "}", "}", "}", "}", "</s>" ]
10,153
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "internal", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ConnectionRouter", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "IFigure", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "IBaseLabelProvider", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "IColorProvider", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "IFontProvider", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "ILabelProvider", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWTError", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Color", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "IConnectionStyleProvider", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "IEntityConnectionStyleProvider", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "IEntityStyleProvider", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "ISelfStyleProvider", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphConnection", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphItem", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphNode", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "ZestStyles", ";", "public", "class", "GraphItemStyler", "{", "public", "static", "void", "styleItem", "(", "GraphItem", "item", ",", "final", "IBaseLabelProvider", "labelProvider", ")", "{", "if", "(", "item", "instanceof", "GraphNode", ")", "{", "GraphNode", "node", "=", "(", "GraphNode", ")", "item", ";", "if", "(", "node", ".", "getGraphModel", "(", ")", ".", "getNodeStyle", "(", ")", "!=", "ZestStyles", ".", "NONE", ")", "{", "node", ".", "setNodeStyle", "(", "node", ".", "getGraphModel", "(", ")", ".", "getNodeStyle", "(", ")", ")", ";", "}", "else", "{", "node", ".", "setNodeStyle", "(", "SWT", ".", "NONE", ")", ";", "}", "Object", "entity", "=", "node", ".", "getData", "(", ")", ";", "if", "(", "labelProvider", "instanceof", "IEntityStyleProvider", ")", "{", "styleNode", "(", "node", ",", "(", "IEntityStyleProvider", ")", "labelProvider", ")", ";", "}", "if", "(", "labelProvider", "instanceof", "IColorProvider", ")", "{", "IColorProvider", "colorProvider", "=", "(", "IColorProvider", ")", "labelProvider", ";", "node", ".", "setForegroundColor", "(", "colorProvider", ".", "getForeground", "(", "entity", ")", ")", ";", "node", ".", "setBackgroundColor", "(", "colorProvider", ".", "getBackground", "(", "entity", ")", ")", ";", "}", "if", "(", "labelProvider", "instanceof", "IFontProvider", ")", "{", "IFontProvider", "fontProvider", "=", "(", "IFontProvider", ")", "labelProvider", ";", "node", ".", "setFont", "(", "fontProvider", ".", "getFont", "(", "entity", ")", ")", ";", "}", "if", "(", "labelProvider", "instanceof", "ILabelProvider", ")", "{", "String", "text", "=", "(", "(", "ILabelProvider", ")", "labelProvider", ")", ".", "getText", "(", "node", ".", "getData", "(", ")", ")", ";", "node", ".", "setText", "(", "(", "text", "!=", "null", ")", "?", "text", ":", "\"\"", ")", ";", "node", ".", "setImage", "(", "(", "(", "ILabelProvider", ")", "labelProvider", ")", ".", "getImage", "(", "node", ".", "getData", "(", ")", ")", ")", ";", "}", "if", "(", "labelProvider", "instanceof", "ISelfStyleProvider", ")", "{", "(", "(", "ISelfStyleProvider", ")", "labelProvider", ")", ".", "selfStyleNode", "(", "entity", ",", "node", ")", ";", "}", "}", "else", "if", "(", "item", "instanceof", "GraphConnection", ")", "{", "GraphConnection", "conn", "=", "(", "GraphConnection", ")", "item", ";", "if", "(", "conn", ".", "getGraphModel", "(", ")", ".", "getConnectionStyle", "(", ")", "!=", "ZestStyles", ".", "NONE", ")", "{", "int", "s", "=", "conn", ".", "getGraphModel", "(", ")", ".", "getConnectionStyle", "(", ")", ";", "conn", ".", "setConnectionStyle", "(", "s", ")", ";", "}", "else", "{", "conn", ".", "setConnectionStyle", "(", "SWT", ".", "NONE", ")", ";", "}", "if", "(", "labelProvider", "instanceof", "ILabelProvider", ")", "{", "String", "text", "=", "(", "(", "ILabelProvider", ")", "labelProvider", ")", ".", "getText", "(", "conn", ".", "getExternalConnection", "(", ")", ")", ";", "conn", ".", "setText", "(", "(", "text", "!=", "null", ")", "?", "text", ":", "\"\"", ")", ";", "conn", ".", "setImage", "(", "(", "(", "ILabelProvider", ")", "labelProvider", ")", ".", "getImage", "(", "conn", ".", "getExternalConnection", "(", ")", ")", ")", ";", "}", "if", "(", "labelProvider", "instanceof", "IEntityConnectionStyleProvider", ")", "{", "styleEntityConnection", "(", "conn", ",", "(", "IEntityConnectionStyleProvider", ")", "labelProvider", ")", ";", "}", "else", "if", "(", "labelProvider", "instanceof", "IConnectionStyleProvider", ")", "{", "styleConnection", "(", "conn", ",", "(", "IConnectionStyleProvider", ")", "labelProvider", ")", ";", "}", "int", "swt", "=", "getLineStyleForZestStyle", "(", "conn", ".", "getConnectionStyle", "(", ")", ")", ";", "conn", ".", "setLineStyle", "(", "swt", ")", ";", "if", "(", "labelProvider", "instanceof", "ISelfStyleProvider", ")", "{", "(", "(", "ISelfStyleProvider", ")", "labelProvider", ")", ".", "selfStyleConnection", "(", "conn", ".", "getData", "(", ")", ",", "conn", ")", ";", "}", "}", "}", "private", "static", "void", "styleConnection", "(", "GraphConnection", "conn", ",", "IConnectionStyleProvider", "provider", ")", "{", "Object", "rel", "=", "conn", ".", "getExternalConnection", "(", ")", ";", "Color", "c", ";", "int", "style", "=", "provider", ".", "getConnectionStyle", "(", "rel", ")", ";", "if", "(", "!", "ZestStyles", ".", "validateConnectionStyle", "(", "style", ")", ")", "{", "throw", "new", "SWTError", "(", "SWT", ".", "ERROR_INVALID_ARGUMENT", ")", ";", "}", "if", "(", "style", "!=", "ZestStyles", ".", "NONE", ")", "{", "conn", ".", "setConnectionStyle", "(", "style", ")", ";", "}", "if", "(", "(", "c", "=", "provider", ".", "getHighlightColor", "(", "rel", ")", ")", "!=", "null", ")", "{", "conn", ".", "setHighlightColor", "(", "c", ")", ";", "}", "if", "(", "(", "c", "=", "provider", ".", "getColor", "(", "rel", ")", ")", "!=", "null", ")", "{", "conn", ".", "setLineColor", "(", "c", ")", ";", "}", "IFigure", "tooltip", ";", "if", "(", "(", "tooltip", "=", "provider", ".", "getTooltip", "(", "rel", ")", ")", "!=", "null", ")", "{", "conn", ".", "setTooltip", "(", "tooltip", ")", ";", "}", "int", "w", "=", "-", "1", ";", "if", "(", "(", "w", "=", "provider", ".", "getLineWidth", "(", "rel", ")", ")", ">=", "0", ")", "{", "conn", ".", "setLineWidth", "(", "w", ")", ";", "}", "ConnectionRouter", "cr", ";", "if", "(", "(", "cr", "=", "provider", ".", "getRouter", "(", "rel", ")", ")", "!=", "null", ")", "{", "conn", ".", "setRouter", "(", "cr", ")", ";", "}", "}", "private", "static", "void", "styleEntityConnection", "(", "GraphConnection", "conn", ",", "IEntityConnectionStyleProvider", "provider", ")", "{", "Object", "src", "=", "conn", ".", "getSource", "(", ")", ".", "getData", "(", ")", ";", "Object", "dest", "=", "conn", ".", "getDestination", "(", ")", ".", "getData", "(", ")", ";", "Color", "c", ";", "int", "style", "=", "provider", ".", "getConnectionStyle", "(", "src", ",", "dest", ")", ";", "if", "(", "!", "ZestStyles", ".", "validateConnectionStyle", "(", "style", ")", ")", "{", "throw", "new", "SWTError", "(", "SWT", ".", "ERROR_INVALID_ARGUMENT", ")", ";", "}", "if", "(", "style", "!=", "ZestStyles", ".", "NONE", ")", "{", "conn", ".", "setConnectionStyle", "(", "style", ")", ";", "}", "if", "(", "(", "c", "=", "provider", ".", "getColor", "(", "src", ",", "dest", ")", ")", "!=", "null", ")", "{", "conn", ".", "setLineColor", "(", "c", ")", ";", "}", "if", "(", "(", "c", "=", "provider", ".", "getHighlightColor", "(", "src", ",", "dest", ")", ")", "!=", "null", ")", "{", "conn", ".", "setHighlightColor", "(", "c", ")", ";", "}", "int", "w", "=", "-", "1", ";", "if", "(", "(", "w", "=", "provider", ".", "getLineWidth", "(", "src", ",", "dest", ")", ")", ">=", "0", ")", "{", "conn", ".", "setLineWidth", "(", "w", ")", ";", "}", "ConnectionRouter", "cr", ";", "if", "(", "(", "cr", "=", "provider", ".", "getRouter", "(", "src", ",", "dest", ")", ")", "!=", "null", ")", "{", "conn", ".", "setRouter", "(", "cr", ")", ";", "}", "}", "private", "static", "void", "styleNode", "(", "GraphNode", "node", ",", "IEntityStyleProvider", "provider", ")", "{", "Object", "entity", "=", "node", ".", "getData", "(", ")", ";", "Color", "c", ";", "IFigure", "figure", ";", "int", "width", "=", "-", "1", ";", "if", "(", "provider", ".", "fisheyeNode", "(", "entity", ")", "==", "true", ")", "{", "node", ".", "setNodeStyle", "(", "node", ".", "getNodeStyle", "(", ")", "|", "ZestStyles", ".", "NODES_FISHEYE", ")", ";", "}", "if", "(", "(", "c", "=", "provider", ".", "getBorderColor", "(", "entity", ")", ")", "!=", "null", ")", "{", "node", ".", "setBorderColor", "(", "c", ")", ";", "}", "if", "(", "(", "c", "=", "provider", ".", "getBorderHighlightColor", "(", "entity", ")", ")", "!=", "null", ")", "{", "node", ".", "setBorderHighlightColor", "(", "c", ")", ";", "}", "if", "(", "(", "c", "=", "provider", ".", "getNodeHighlightColor", "(", "entity", ")", ")", "!=", "null", ")", "{", "node", ".", "setHighlightColor", "(", "c", ")", ";", "}", "if", "(", "(", "c", "=", "provider", ".", "getBackgroundColour", "(", "entity", ")", ")", "!=", "null", ")", "{", "node", ".", "setBackgroundColor", "(", "c", ")", ";", "}", "if", "(", "(", "c", "=", "provider", ".", "getForegroundColour", "(", "entity", ")", ")", "!=", "null", ")", "{", "node", ".", "setForegroundColor", "(", "c", ")", ";", "}", "if", "(", "(", "width", "=", "provider", ".", "getBorderWidth", "(", "entity", ")", ")", ">=", "0", ")", "{", "node", ".", "setBorderWidth", "(", "width", ")", ";", "}", "if", "(", "(", "figure", "=", "provider", ".", "getTooltip", "(", "entity", ")", ")", "!=", "null", ")", "{", "node", ".", "setTooltip", "(", "figure", ")", ";", "}", "}", "public", "static", "int", "getLineStyleForZestStyle", "(", "int", "style", ")", "{", "int", "lineStyles", "=", "ZestStyles", ".", "CONNECTIONS_DASH_DOT", "|", "ZestStyles", ".", "CONNECTIONS_DASH", "|", "ZestStyles", ".", "CONNECTIONS_DOT", "|", "ZestStyles", ".", "CONNECTIONS_SOLID", ";", "style", "=", "style", "&", "lineStyles", ";", "if", "(", "style", "==", "0", ")", "{", "style", "=", "ZestStyles", ".", "CONNECTIONS_SOLID", ";", "}", "switch", "(", "style", ")", "{", "case", "ZestStyles", ".", "CONNECTIONS_DASH_DOT", ":", "return", "SWT", ".", "LINE_DASHDOT", ";", "case", "ZestStyles", ".", "CONNECTIONS_DASH", ":", "return", "SWT", ".", "LINE_DASH", ";", "case", "ZestStyles", ".", "CONNECTIONS_DOT", ":", "return", "SWT", ".", "LINE_DOT", ";", "}", "return", "SWT", ".", "LINE_SOLID", ";", "}", "}", "</s>" ]
10,154
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "internal", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "ITreeContentProvider", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "AbstractStructuredGraphViewer", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "EntityConnectionData", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "Graph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphConnection", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphNode", ";", "public", "class", "TreeModelEntityFactory", "extends", "AbstractStylingModelFactory", "{", "AbstractStructuredGraphViewer", "viewer", "=", "null", ";", "public", "TreeModelEntityFactory", "(", "AbstractStructuredGraphViewer", "viewer", ")", "{", "super", "(", "viewer", ")", ";", "this", ".", "viewer", "=", "viewer", ";", "}", "@", "Override", "public", "Graph", "createGraphModel", "(", "Graph", "model", ")", "{", "doBuildGraph", "(", "model", ")", ";", "return", "model", ";", "}", "@", "Override", "protected", "void", "doBuildGraph", "(", "Graph", "model", ")", "{", "super", ".", "doBuildGraph", "(", "model", ")", ";", "Object", "inputElement", "=", "getViewer", "(", ")", ".", "getInput", "(", ")", ";", "ITreeContentProvider", "provider", "=", "(", "ITreeContentProvider", ")", "getContentProvider", "(", ")", ";", "Object", "[", "]", "entities", "=", "provider", ".", "getElements", "(", "inputElement", ")", ";", "if", "(", "entities", "==", "null", ")", "return", ";", "for", "(", "Object", "data", ":", "entities", ")", "{", "createGraphNodes", "(", "model", ",", "data", ",", "provider", ")", ";", "}", "}", "private", "GraphNode", "createGraphNodes", "(", "Graph", "model", ",", "Object", "data", ",", "ITreeContentProvider", "provider", ")", "{", "GraphNode", "node", "=", "createNode", "(", "model", ",", "data", ")", ";", "if", "(", "provider", ".", "hasChildren", "(", "data", ")", ")", "{", "for", "(", "Object", "child", ":", "provider", ".", "getChildren", "(", "data", ")", ")", "{", "GraphNode", "childNode", "=", "createGraphNodes", "(", "model", ",", "child", ",", "provider", ")", ";", "EntityConnectionData", "connectionData", "=", "new", "EntityConnectionData", "(", "node", ",", "childNode", ")", ";", "createConnection", "(", "model", ",", "connectionData", ",", "data", ",", "child", ")", ";", "}", "}", "return", "node", ";", "}", "@", "Override", "public", "void", "refresh", "(", "Graph", "graph", ",", "Object", "element", ",", "boolean", "updateLabels", ")", "{", "if", "(", "element", "==", "null", ")", "{", "return", ";", "}", "GraphNode", "node", "=", "viewer", ".", "getGraphModelNode", "(", "element", ")", ";", "if", "(", "node", "==", "null", ")", "{", "GraphConnection", "conn", "=", "viewer", ".", "getGraphModelConnection", "(", "element", ")", ";", "if", "(", "conn", "!=", "null", ")", "{", "refresh", "(", "graph", ",", "conn", ".", "getSource", "(", ")", ".", "getData", "(", ")", ",", "updateLabels", ")", ";", "refresh", "(", "graph", ",", "conn", ".", "getDestination", "(", ")", ".", "getData", "(", ")", ",", "updateLabels", ")", ";", "return", ";", "}", "}", "if", "(", "node", "==", "null", ")", "return", ";", "reconnect", "(", "graph", ",", "element", ",", "updateLabels", ")", ";", "if", "(", "updateLabels", ")", "update", "(", "node", ")", ";", "}", "private", "void", "reconnect", "(", "Graph", "graph", ",", "Object", "element", ",", "boolean", "updateLabels", ")", "{", "GraphNode", "sourceNode", "=", "viewer", ".", "getGraphModelNode", "(", "element", ")", ";", "Object", "[", "]", "children", "=", "(", "(", "ITreeContentProvider", ")", "getContentProvider", "(", ")", ")", ".", "getChildren", "(", "element", ")", ";", "EntityConnectionData", "data", "=", "null", ";", "GraphConnection", "oldConnection", "=", "null", ";", "GraphConnection", "newConnection", "=", "null", ";", "for", "(", "Object", "child", ":", "children", ")", "{", "GraphNode", "destNode", "=", "viewer", ".", "getGraphModelNode", "(", "child", ")", ";", "data", "=", "new", "EntityConnectionData", "(", "sourceNode", ",", "destNode", ")", ";", "oldConnection", "=", "viewer", ".", "getGraphModelConnection", "(", "data", ")", ";", "if", "(", "oldConnection", "!=", "null", ")", "{", "viewer", ".", "removeGraphModelConnection", "(", "oldConnection", ")", ";", "newConnection", "=", "createConnection", "(", "graph", ",", "data", ",", "sourceNode", ".", "getData", "(", ")", ",", "destNode", ".", "getData", "(", ")", ")", ";", "if", "(", "updateLabels", ")", "{", "styleItem", "(", "newConnection", ")", ";", "}", "}", "refresh", "(", "graph", ",", "child", ",", "updateLabels", ")", ";", "}", "}", "}", "</s>" ]
10,155
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "internal", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "LinkedList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "AbstractStructuredGraphViewer", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "EntityConnectionData", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "IGraphEntityContentProvider", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "Graph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphConnection", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphItem", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphNode", ";", "public", "class", "GraphModelEntityFactory", "extends", "AbstractStylingModelFactory", "{", "AbstractStructuredGraphViewer", "viewer", "=", "null", ";", "public", "GraphModelEntityFactory", "(", "AbstractStructuredGraphViewer", "viewer", ")", "{", "super", "(", "viewer", ")", ";", "this", ".", "viewer", "=", "viewer", ";", "}", "public", "Graph", "createGraphModel", "(", "Graph", "model", ")", "{", "doBuildGraph", "(", "model", ")", ";", "return", "model", ";", "}", "protected", "void", "doBuildGraph", "(", "Graph", "model", ")", "{", "super", ".", "doBuildGraph", "(", "model", ")", ";", "Object", "inputElement", "=", "getViewer", "(", ")", ".", "getInput", "(", ")", ";", "Object", "entities", "[", "]", "=", "getContentProvider", "(", ")", ".", "getElements", "(", "inputElement", ")", ";", "if", "(", "entities", "==", "null", ")", "{", "return", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "entities", ".", "length", ";", "i", "++", ")", "{", "Object", "data", "=", "entities", "[", "i", "]", ";", "if", "(", "!", "filterElement", "(", "inputElement", ",", "data", ")", ")", "{", "createNode", "(", "model", ",", "data", ")", ";", "}", "}", "Set", "keySet", "=", "(", "(", "AbstractStructuredGraphViewer", ")", "getViewer", "(", ")", ")", ".", "getNodesMap", "(", ")", ".", "keySet", "(", ")", ";", "entities", "=", "keySet", ".", "toArray", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "entities", ".", "length", ";", "i", "++", ")", "{", "Object", "data", "=", "entities", "[", "i", "]", ";", "if", "(", "filterElement", "(", "inputElement", ",", "data", ")", ")", "{", "continue", ";", "}", "Object", "[", "]", "related", "=", "(", "(", "IGraphEntityContentProvider", ")", "getContentProvider", "(", ")", ")", ".", "getConnectedTo", "(", "data", ")", ";", "if", "(", "related", "!=", "null", ")", "{", "for", "(", "int", "j", "=", "0", ";", "j", "<", "related", ".", "length", ";", "j", "++", ")", "{", "if", "(", "filterElement", "(", "inputElement", ",", "related", "[", "j", "]", ")", ")", "{", "continue", ";", "}", "EntityConnectionData", "connectionData", "=", "new", "EntityConnectionData", "(", "data", ",", "related", "[", "j", "]", ")", ";", "if", "(", "filterElement", "(", "inputElement", ",", "connectionData", ")", ")", "{", "continue", ";", "}", "createConnection", "(", "model", ",", "connectionData", ",", "data", ",", "related", "[", "j", "]", ")", ";", "}", "}", "}", "}", "public", "void", "refresh", "(", "Graph", "graph", ",", "Object", "element", ",", "boolean", "refreshLabels", ")", "{", "if", "(", "element", "==", "null", ")", "{", "return", ";", "}", "GraphNode", "node", "=", "viewer", ".", "getGraphModelNode", "(", "element", ")", ";", "if", "(", "node", "==", "null", ")", "{", "GraphConnection", "conn", "=", "viewer", ".", "getGraphModelConnection", "(", "element", ")", ";", "if", "(", "conn", "!=", "null", ")", "{", "refresh", "(", "graph", ",", "conn", ".", "getSource", "(", ")", ".", "getData", "(", ")", ",", "refreshLabels", ")", ";", "refresh", "(", "graph", ",", "conn", ".", "getDestination", "(", ")", ".", "getData", "(", ")", ",", "refreshLabels", ")", ";", "return", ";", "}", "}", "if", "(", "node", "==", "null", ")", "{", "return", ";", "}", "reconnect", "(", "graph", ",", "element", ",", "refreshLabels", ")", ";", "if", "(", "refreshLabels", ")", "{", "update", "(", "node", ")", ";", "for", "(", "Iterator", "it", "=", "node", ".", "getSourceConnections", "(", ")", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "update", "(", "(", "GraphItem", ")", "it", ".", "next", "(", ")", ")", ";", "}", "for", "(", "Iterator", "it", "=", "node", ".", "getTargetConnections", "(", ")", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "update", "(", "(", "GraphItem", ")", "it", ".", "next", "(", ")", ")", ";", "}", "}", "}", "private", "void", "reconnect", "(", "Graph", "graph", ",", "Object", "element", ",", "boolean", "refreshLabels", ")", "{", "GraphNode", "node", "=", "viewer", ".", "getGraphModelNode", "(", "element", ")", ";", "Object", "[", "]", "related", "=", "(", "(", "IGraphEntityContentProvider", ")", "getContentProvider", "(", ")", ")", ".", "getConnectedTo", "(", "element", ")", ";", "List", "connections", "=", "node", ".", "getSourceConnections", "(", ")", ";", "LinkedList", "toAdd", "=", "new", "LinkedList", "(", ")", ";", "LinkedList", "toDelete", "=", "new", "LinkedList", "(", ")", ";", "LinkedList", "toKeep", "=", "new", "LinkedList", "(", ")", ";", "HashSet", "oldExternalConnections", "=", "new", "HashSet", "(", ")", ";", "HashSet", "newExternalConnections", "=", "new", "HashSet", "(", ")", ";", "for", "(", "Iterator", "it", "=", "connections", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "oldExternalConnections", ".", "add", "(", "(", "(", "GraphConnection", ")", "it", ".", "next", "(", ")", ")", ".", "getExternalConnection", "(", ")", ")", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "related", ".", "length", ";", "i", "++", ")", "{", "newExternalConnections", ".", "add", "(", "new", "EntityConnectionData", "(", "element", ",", "related", "[", "i", "]", ")", ")", ";", "}", "for", "(", "Iterator", "it", "=", "oldExternalConnections", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "Object", "next", "=", "it", ".", "next", "(", ")", ";", "if", "(", "!", "newExternalConnections", ".", "contains", "(", "next", ")", ")", "{", "toDelete", ".", "add", "(", "next", ")", ";", "}", "else", "{", "toKeep", ".", "add", "(", "next", ")", ";", "}", "}", "for", "(", "Iterator", "it", "=", "newExternalConnections", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "Object", "next", "=", "it", ".", "next", "(", ")", ";", "if", "(", "!", "oldExternalConnections", ".", "contains", "(", "next", ")", ")", "{", "toAdd", ".", "add", "(", "next", ")", ";", "}", "}", "for", "(", "Iterator", "it", "=", "toDelete", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "viewer", ".", "removeGraphModelConnection", "(", "it", ".", "next", "(", ")", ")", ";", "}", "toDelete", ".", "clear", "(", ")", ";", "LinkedList", "newNodeList", "=", "new", "LinkedList", "(", ")", ";", "for", "(", "Iterator", "it", "=", "toAdd", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "EntityConnectionData", "data", "=", "(", "EntityConnectionData", ")", "it", ".", "next", "(", ")", ";", "GraphNode", "dest", "=", "viewer", ".", "getGraphModelNode", "(", "data", ".", "dest", ")", ";", "if", "(", "dest", "==", "null", ")", "{", "newNodeList", ".", "add", "(", "data", ".", "dest", ")", ";", "}", "createConnection", "(", "graph", ",", "data", ",", "data", ".", "source", ",", "data", ".", "dest", ")", ";", "}", "toAdd", ".", "clear", "(", ")", ";", "if", "(", "refreshLabels", ")", "{", "for", "(", "Iterator", "i", "=", "toKeep", ".", "iterator", "(", ")", ";", "i", ".", "hasNext", "(", ")", ";", ")", "{", "styleItem", "(", "viewer", ".", "getGraphModelConnection", "(", "i", ".", "next", "(", ")", ")", ")", ";", "}", "}", "for", "(", "Iterator", "it", "=", "newNodeList", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "refresh", "(", "graph", ",", "it", ".", "next", "(", ")", ")", ";", "}", "}", "public", "void", "refresh", "(", "Graph", "graph", ",", "Object", "element", ")", "{", "refresh", "(", "graph", ",", "element", ",", "false", ")", ";", "}", "}", "</s>" ]
10,156
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "internal", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "IBaseLabelProvider", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "IStructuredContentProvider", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "StructuredViewer", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "Graph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphConnection", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphItem", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphNode", ";", "public", "interface", "IStylingGraphModelFactory", "{", "public", "IBaseLabelProvider", "getLabelProvider", "(", ")", ";", "public", "IStructuredContentProvider", "getContentProvider", "(", ")", ";", "public", "Graph", "createGraphModel", "(", "Graph", "model", ")", ";", "public", "GraphNode", "createNode", "(", "Graph", "graph", ",", "Object", "element", ")", ";", "public", "GraphConnection", "createConnection", "(", "Graph", "graph", ",", "Object", "element", ",", "Object", "source", ",", "Object", "dest", ")", ";", "public", "void", "update", "(", "GraphItem", "[", "]", "items", ")", ";", "public", "void", "update", "(", "GraphItem", "item", ")", ";", "public", "void", "refresh", "(", "Graph", "graph", ",", "Object", "element", ")", ";", "public", "void", "refresh", "(", "Graph", "graph", ",", "Object", "element", ",", "boolean", "updateLabels", ")", ";", "public", "void", "refreshGraph", "(", "Graph", "graph", ")", ";", "public", "StructuredViewer", "getViewer", "(", ")", ";", "public", "void", "setConnectionStyle", "(", "int", "style", ")", ";", "public", "int", "getConnectionStyle", "(", ")", ";", "public", "void", "setNodeStyle", "(", "int", "style", ")", ";", "public", "int", "getNodeStyle", "(", ")", ";", "}", "</s>" ]
10,157
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "internal", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "AbstractStructuredGraphViewer", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "IGraphEntityRelationshipContentProvider", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "Graph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphContainer", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphNode", ";", "public", "class", "GraphModelEntityRelationshipFactory", "extends", "AbstractStylingModelFactory", "{", "public", "GraphModelEntityRelationshipFactory", "(", "AbstractStructuredGraphViewer", "viewer", ")", "{", "super", "(", "viewer", ")", ";", "if", "(", "!", "(", "viewer", ".", "getContentProvider", "(", ")", "instanceof", "IGraphEntityRelationshipContentProvider", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"\"", ")", ";", "}", "}", "public", "Graph", "createGraphModel", "(", "Graph", "model", ")", "{", "doBuildGraph", "(", "model", ")", ";", "return", "model", ";", "}", "protected", "void", "doBuildGraph", "(", "Graph", "model", ")", "{", "super", ".", "doBuildGraph", "(", "model", ")", ";", "Object", "[", "]", "nodes", "=", "getContentProvider", "(", ")", ".", "getElements", "(", "getViewer", "(", ")", ".", "getInput", "(", ")", ")", ";", "nodes", "=", "filter", "(", "getViewer", "(", ")", ".", "getInput", "(", ")", ",", "nodes", ")", ";", "createModelNodes", "(", "model", ",", "nodes", ")", ";", "createModelRelationships", "(", "model", ")", ";", "}", "private", "void", "createModelRelationships", "(", "Graph", "model", ")", "{", "GraphNode", "[", "]", "modelNodes", "=", "getNodesArray", "(", "model", ")", ";", "List", "listOfNodes", "=", "new", "ArrayList", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "modelNodes", ".", "length", ";", "i", "++", ")", "{", "listOfNodes", ".", "add", "(", "modelNodes", "[", "i", "]", ")", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "listOfNodes", ".", "size", "(", ")", ";", "i", "++", ")", "{", "GraphNode", "node", "=", "(", "GraphNode", ")", "listOfNodes", ".", "get", "(", "i", ")", ";", "if", "(", "node", "instanceof", "GraphContainer", ")", "{", "List", "childNodes", "=", "(", "(", "GraphContainer", ")", "node", ")", ".", "getNodes", "(", ")", ";", "listOfNodes", ".", "addAll", "(", "childNodes", ")", ";", "}", "}", "modelNodes", "=", "(", "GraphNode", "[", "]", ")", "listOfNodes", ".", "toArray", "(", "new", "GraphNode", "[", "listOfNodes", ".", "size", "(", ")", "]", ")", ";", "IGraphEntityRelationshipContentProvider", "content", "=", "getCastedContent", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "modelNodes", ".", "length", ";", "i", "++", ")", "{", "for", "(", "int", "j", "=", "0", ";", "j", "<", "modelNodes", ".", "length", ";", "j", "++", ")", "{", "Object", "[", "]", "rels", "=", "content", ".", "getRelationships", "(", "modelNodes", "[", "i", "]", ".", "getData", "(", ")", ",", "modelNodes", "[", "j", "]", ".", "getData", "(", ")", ")", ";", "if", "(", "rels", "!=", "null", ")", "{", "rels", "=", "filter", "(", "getViewer", "(", ")", ".", "getInput", "(", ")", ",", "rels", ")", ";", "for", "(", "int", "r", "=", "0", ";", "r", "<", "rels", ".", "length", ";", "r", "++", ")", "{", "createConnection", "(", "model", ",", "rels", "[", "r", "]", ",", "modelNodes", "[", "i", "]", ".", "getData", "(", ")", ",", "modelNodes", "[", "j", "]", ".", "getData", "(", ")", ")", ";", "}", "}", "}", "}", "}", "private", "void", "createModelNodes", "(", "Graph", "model", ",", "Object", "[", "]", "nodes", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "nodes", ".", "length", ";", "i", "++", ")", "{", "createNode", "(", "model", ",", "nodes", "[", "i", "]", ")", ";", "}", "}", "public", "void", "refresh", "(", "Graph", "graph", ",", "Object", "element", ")", "{", "refresh", "(", "graph", ",", "element", ",", "false", ")", ";", "}", "public", "void", "refresh", "(", "Graph", "graph", ",", "Object", "element", ",", "boolean", "updateLabels", ")", "{", "refreshGraph", "(", "graph", ")", ";", "}", "private", "IGraphEntityRelationshipContentProvider", "getCastedContent", "(", ")", "{", "return", "(", "IGraphEntityRelationshipContentProvider", ")", "getContentProvider", "(", ")", ";", "}", "}", "</s>" ]
10,158
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "internal", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "LinkedList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "IFigure", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "IBaseLabelProvider", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "IStructuredContentProvider", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "StructuredViewer", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "ViewerFilter", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "AbstractStructuredGraphViewer", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "IFigureProvider", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "INestedContentProvider", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "Graph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphConnection", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphContainer", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphItem", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphNode", ";", "public", "abstract", "class", "AbstractStylingModelFactory", "implements", "IStylingGraphModelFactory", "{", "private", "AbstractStructuredGraphViewer", "viewer", ";", "private", "int", "connectionStyle", ";", "private", "int", "nodeStyle", ";", "public", "AbstractStylingModelFactory", "(", "AbstractStructuredGraphViewer", "viewer", ")", "{", "this", ".", "viewer", "=", "viewer", ";", "this", ".", "connectionStyle", "=", "SWT", ".", "NONE", ";", "this", ".", "nodeStyle", "=", "SWT", ".", "NONE", ";", "}", "public", "void", "styleConnection", "(", "GraphConnection", "conn", ")", "{", "GraphNode", "source", "=", "conn", ".", "getSource", "(", ")", ";", "GraphNode", "dest", "=", "conn", ".", "getDestination", "(", ")", ";", "LinkedList", "rightList", "=", "getConnectionList", "(", "source", ",", "dest", ")", ";", "LinkedList", "leftList", "=", "null", ";", "if", "(", "dest", "!=", "source", ")", "{", "leftList", "=", "getConnectionList", "(", "dest", ",", "source", ")", ";", "}", "int", "size", "=", "(", "leftList", "!=", "null", ")", "?", "leftList", ".", "size", "(", ")", "+", "rightList", ".", "size", "(", ")", ":", "rightList", ".", "size", "(", ")", ";", "adjustCurves", "(", "rightList", ",", "size", ")", ";", "if", "(", "leftList", "!=", "null", ")", "{", "adjustCurves", "(", "leftList", ",", "size", ")", ";", "}", "}", "protected", "void", "adjustCurves", "(", "List", "connections", ",", "int", "size", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "connections", ".", "size", "(", ")", ";", "i", "++", ")", "{", "GraphConnection", "conn", "=", "(", "GraphConnection", ")", "connections", ".", "get", "(", "i", ")", ";", "int", "radius", "=", "20", ";", "if", "(", "conn", ".", "getSource", "(", ")", "==", "conn", ".", "getDestination", "(", ")", ")", "{", "radius", "=", "40", ";", "}", "else", "if", "(", "size", "<", "2", ")", "{", "radius", "=", "0", ";", "}", "conn", ".", "setCurveDepth", "(", "(", "i", "+", "1", ")", "*", "radius", ")", ";", "}", "}", "private", "LinkedList", "getConnectionList", "(", "GraphNode", "source", ",", "GraphNode", "dest", ")", "{", "LinkedList", "list", "=", "new", "LinkedList", "(", ")", ";", "Iterator", "i", "=", "source", ".", "getSourceConnections", "(", ")", ".", "iterator", "(", ")", ";", "while", "(", "i", ".", "hasNext", "(", ")", ")", "{", "GraphConnection", "c", "=", "(", "GraphConnection", ")", "i", ".", "next", "(", ")", ";", "if", "(", "c", ".", "getDestination", "(", ")", "==", "dest", ")", "{", "list", ".", "add", "(", "c", ")", ";", "}", "}", "return", "list", ";", "}", "public", "void", "styleItem", "(", "GraphItem", "item", ")", "{", "GraphItemStyler", ".", "styleItem", "(", "item", ",", "getLabelProvider", "(", ")", ")", ";", "if", "(", "item", "instanceof", "GraphConnection", ")", "{", "styleConnection", "(", "(", "GraphConnection", ")", "item", ")", ";", "}", "}", "public", "StructuredViewer", "getViewer", "(", ")", "{", "return", "viewer", ";", "}", "public", "IBaseLabelProvider", "getLabelProvider", "(", ")", "{", "return", "viewer", ".", "getLabelProvider", "(", ")", ";", "}", "public", "IStructuredContentProvider", "getContentProvider", "(", ")", "{", "return", "(", "IStructuredContentProvider", ")", "viewer", ".", "getContentProvider", "(", ")", ";", "}", "public", "GraphConnection", "createConnection", "(", "Graph", "graph", ",", "Object", "element", ",", "Object", "source", ",", "Object", "dest", ")", "{", "if", "(", "source", "==", "null", "||", "dest", "==", "null", ")", "{", "return", "null", ";", "}", "GraphConnection", "oldConnection", "=", "viewer", ".", "getGraphModelConnection", "(", "element", ")", ";", "GraphNode", "sn", "=", "viewer", ".", "getGraphModelNode", "(", "source", ")", ";", "GraphNode", "dn", "=", "viewer", ".", "getGraphModelNode", "(", "dest", ")", ";", "if", "(", "oldConnection", "!=", "null", ")", "{", "if", "(", "sn", "!=", "oldConnection", ".", "getSource", "(", ")", "||", "dn", "!=", "oldConnection", ".", "getDestination", "(", ")", ")", "{", "viewer", ".", "removeGraphModelConnection", "(", "oldConnection", ")", ";", "}", "else", "{", "styleItem", "(", "oldConnection", ")", ";", "return", "oldConnection", ";", "}", "}", "if", "(", "sn", "==", "null", ")", "{", "sn", "=", "createNode", "(", "graph", ",", "source", ")", ";", "}", "if", "(", "dn", "==", "null", ")", "{", "dn", "=", "createNode", "(", "graph", ",", "dest", ")", ";", "}", "GraphConnection", "c", "=", "viewer", ".", "addGraphModelConnection", "(", "element", ",", "sn", ",", "dn", ")", ";", "styleItem", "(", "c", ")", ";", "return", "c", ";", "}", "public", "GraphNode", "createNode", "(", "Graph", "graph", ",", "Object", "element", ",", "IFigure", "figure", ")", "{", "GraphNode", "node", "=", "null", ";", "if", "(", "getContentProvider", "(", ")", "instanceof", "INestedContentProvider", ")", "{", "boolean", "isContainer", "=", "(", "(", "INestedContentProvider", ")", "getContentProvider", "(", ")", ")", ".", "hasChildren", "(", "element", ")", ";", "if", "(", "isContainer", ")", "{", "node", "=", "viewer", ".", "addGraphModelContainer", "(", "element", ")", ";", "styleItem", "(", "node", ")", ";", "Object", "[", "]", "childNodes", "=", "(", "(", "INestedContentProvider", ")", "getContentProvider", "(", ")", ")", ".", "getChildren", "(", "element", ")", ";", "childNodes", "=", "filter", "(", "getViewer", "(", ")", ".", "getInput", "(", ")", ",", "childNodes", ")", ";", "if", "(", "childNodes", "==", "null", ")", "{", "return", "node", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "childNodes", ".", "length", ";", "i", "++", ")", "{", "GraphNode", "childNode", "=", "viewer", ".", "addGraphModelNode", "(", "(", "GraphContainer", ")", "node", ",", "childNodes", "[", "i", "]", ")", ";", "styleItem", "(", "childNode", ")", ";", "}", "(", "(", "GraphContainer", ")", "node", ")", ".", "applyLayout", "(", ")", ";", "return", "node", ";", "}", "}", "node", "=", "viewer", ".", "addGraphModelNode", "(", "element", ",", "figure", ")", ";", "styleItem", "(", "node", ")", ";", "return", "node", ";", "}", "public", "GraphNode", "createNode", "(", "Graph", "graph", ",", "Object", "element", ")", "{", "IFigure", "nodeFigure", "=", "null", ";", "if", "(", "getLabelProvider", "(", ")", "instanceof", "IFigureProvider", ")", "{", "nodeFigure", "=", "(", "(", "IFigureProvider", ")", "getLabelProvider", "(", ")", ")", ".", "getFigure", "(", "element", ")", ";", "}", "return", "this", ".", "createNode", "(", "graph", ",", "element", ",", "nodeFigure", ")", ";", "}", "public", "void", "setConnectionStyle", "(", "int", "style", ")", "{", "this", ".", "connectionStyle", "=", "style", ";", "}", "public", "int", "getConnectionStyle", "(", ")", "{", "return", "connectionStyle", ";", "}", "public", "void", "setNodeStyle", "(", "int", "style", ")", "{", "this", ".", "nodeStyle", "=", "style", ";", "}", "public", "int", "getNodeStyle", "(", ")", "{", "return", "nodeStyle", ";", "}", "public", "void", "update", "(", "GraphItem", "item", ")", "{", "styleItem", "(", "item", ")", ";", "}", "public", "void", "update", "(", "GraphItem", "[", "]", "items", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "items", ".", "length", ";", "i", "++", ")", "{", "styleItem", "(", "items", "[", "i", "]", ")", ";", "}", "}", "public", "void", "refreshGraph", "(", "Graph", "graph", ")", "{", "Map", "oldMap", "=", "viewer", ".", "getNodesMap", "(", ")", ";", "HashMap", "nodesMap", "=", "new", "HashMap", "(", ")", ";", "for", "(", "Iterator", "keys", "=", "oldMap", ".", "keySet", "(", ")", ".", "iterator", "(", ")", ";", "keys", ".", "hasNext", "(", ")", ";", ")", "{", "Object", "key", "=", "keys", ".", "next", "(", ")", ";", "nodesMap", ".", "put", "(", "key", ",", "oldMap", ".", "get", "(", "key", ")", ")", ";", "}", "clearGraph", "(", "graph", ")", ";", "doBuildGraph", "(", "graph", ")", ";", "GraphNode", "[", "]", "nodes", "=", "getNodesArray", "(", "graph", ")", ";", "if", "(", "nodes", ".", "length", "<", "nodesMap", ".", "keySet", "(", ")", ".", "size", "(", ")", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "nodes", ".", "length", ";", "i", "++", ")", "{", "GraphNode", "oldNode", "=", "(", "GraphNode", ")", "nodesMap", ".", "get", "(", "nodes", "[", "i", "]", ".", "getData", "(", ")", ")", ";", "if", "(", "oldNode", "!=", "null", ")", "{", "nodes", "[", "i", "]", ".", "setLocation", "(", "oldNode", ".", "getLocation", "(", ")", ".", "x", ",", "oldNode", ".", "getLocation", "(", ")", ".", "y", ")", ";", "if", "(", "oldNode", ".", "isSizeFixed", "(", ")", ")", "{", "nodes", "[", "i", "]", ".", "setSize", "(", "oldNode", ".", "getSize", "(", ")", ".", "width", ",", "oldNode", ".", "getSize", "(", ")", ".", "height", ")", ";", "}", "}", "}", "}", "else", "{", "for", "(", "Iterator", "i", "=", "nodesMap", ".", "keySet", "(", ")", ".", "iterator", "(", ")", ";", "i", ".", "hasNext", "(", ")", ";", ")", "{", "Object", "key", "=", "i", ".", "next", "(", ")", ";", "GraphNode", "node", "=", "viewer", ".", "getGraphModelNode", "(", "key", ")", ";", "if", "(", "node", "!=", "null", ")", "{", "GraphNode", "oldNode", "=", "(", "GraphNode", ")", "nodesMap", ".", "get", "(", "key", ")", ";", "node", ".", "setLocation", "(", "oldNode", ".", "getLocation", "(", ")", ".", "x", ",", "oldNode", ".", "getLocation", "(", ")", ".", "y", ")", ";", "if", "(", "oldNode", ".", "isSizeFixed", "(", ")", ")", "{", "node", ".", "setSize", "(", "oldNode", ".", "getSize", "(", ")", ".", "width", ",", "oldNode", ".", "getSize", "(", ")", ".", "height", ")", ";", "}", "}", "}", "}", "}", "public", "void", "clearGraph", "(", "Graph", "graph", ")", "{", "graph", ".", "setSelection", "(", "null", ")", ";", "Object", "[", "]", "nodeElements", "=", "viewer", ".", "getNodeElements", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "nodeElements", ".", "length", ";", "i", "++", ")", "{", "viewer", ".", "removeGraphModelNode", "(", "nodeElements", "[", "i", "]", ")", ";", "}", "Object", "[", "]", "connectionElements", "=", "viewer", ".", "getConnectionElements", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "connectionElements", ".", "length", ";", "i", "++", ")", "{", "viewer", ".", "removeGraphModelConnection", "(", "connectionElements", "[", "i", "]", ")", ";", "}", "}", "protected", "void", "doBuildGraph", "(", "Graph", "model", ")", "{", "clearGraph", "(", "model", ")", ";", "model", ".", "setConnectionStyle", "(", "getConnectionStyle", "(", ")", ")", ";", "model", ".", "setNodeStyle", "(", "getNodeStyle", "(", ")", ")", ";", "}", "protected", "boolean", "filterElement", "(", "Object", "parent", ",", "Object", "element", ")", "{", "ViewerFilter", "[", "]", "filters", "=", "getViewer", "(", ")", ".", "getFilters", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "filters", ".", "length", ";", "i", "++", ")", "{", "boolean", "selected", "=", "filters", "[", "i", "]", ".", "select", "(", "viewer", ",", "parent", ",", "element", ")", ";", "if", "(", "!", "selected", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}", "protected", "Object", "[", "]", "filter", "(", "Object", "parent", ",", "Object", "[", "]", "elements", ")", "{", "Object", "[", "]", "result", "=", "elements", ";", "ViewerFilter", "[", "]", "filters", "=", "getViewer", "(", ")", ".", "getFilters", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "filters", ".", "length", ";", "i", "++", ")", "{", "result", "=", "filters", "[", "i", "]", ".", "filter", "(", "viewer", ",", "parent", ",", "result", ")", ";", "}", "return", "result", ";", "}", "public", "void", "refresh", "(", "Graph", "graph", ",", "Object", "element", ")", "{", "refresh", "(", "graph", ",", "element", ",", "false", ")", ";", "}", "protected", "GraphNode", "[", "]", "getNodesArray", "(", "Graph", "graph", ")", "{", "GraphNode", "[", "]", "nodesArray", "=", "new", "GraphNode", "[", "graph", ".", "getNodes", "(", ")", ".", "size", "(", ")", "]", ";", "nodesArray", "=", "(", "GraphNode", "[", "]", ")", "graph", ".", "getNodes", "(", ")", ".", "toArray", "(", "nodesArray", ")", ";", "return", "nodesArray", ";", "}", "protected", "GraphConnection", "[", "]", "getConnectionArray", "(", "Graph", "graph", ")", "{", "GraphConnection", "[", "]", "connectionArray", "=", "new", "GraphConnection", "[", "graph", ".", "getConnections", "(", ")", ".", "size", "(", ")", "]", ";", "connectionArray", "=", "(", "GraphConnection", "[", "]", ")", "graph", ".", "getConnections", "(", ")", ".", "toArray", "(", "connectionArray", ")", ";", "return", "connectionArray", ";", "}", "}", "</s>" ]
10,159
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "IStructuredContentProvider", ";", "public", "interface", "IGraphEntityContentProvider", "extends", "IStructuredContentProvider", "{", "public", "Object", "[", "]", "getElements", "(", "Object", "inputElement", ")", ";", "public", "Object", "[", "]", "getConnectedTo", "(", "Object", "entity", ")", ";", "}", "</s>" ]
10,160
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphConnection", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphNode", ";", "public", "interface", "ISelfStyleProvider", "{", "public", "void", "selfStyleConnection", "(", "Object", "element", ",", "GraphConnection", "connection", ")", ";", "public", "void", "selfStyleNode", "(", "Object", "element", ",", "GraphNode", "node", ")", ";", "}", "</s>" ]
10,161
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "IStructuredContentProvider", ";", "public", "interface", "IGraphContentProvider", "extends", "IStructuredContentProvider", "{", "public", "Object", "getSource", "(", "Object", "rel", ")", ";", "public", "Object", "getDestination", "(", "Object", "rel", ")", ";", "public", "Object", "[", "]", "getElements", "(", "Object", "input", ")", ";", "}", "</s>" ]
10,162
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "action", ".", "ContributionItem", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "MenuAdapter", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "MenuEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionAdapter", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Combo", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Composite", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "CoolBar", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "CoolItem", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Menu", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "MenuItem", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "ToolBar", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "ToolItem", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "zooming", ".", "ZoomListener", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "zooming", ".", "ZoomManager", ";", "public", "class", "ZoomContributionViewItem", "extends", "ContributionItem", "implements", "ZoomListener", "{", "public", "static", "final", "String", "FIT_WIDTH", "=", "ZoomManager", ".", "FIT_WIDTH", ";", "public", "static", "final", "String", "FIT_HEIGHT", "=", "ZoomManager", ".", "FIT_HEIGHT", ";", "public", "static", "final", "String", "FIT_ALL", "=", "ZoomManager", ".", "FIT_ALL", ";", "private", "String", "[", "]", "zoomLevels", ";", "private", "ZoomManager", "zoomManager", ";", "private", "Combo", "combo", ";", "private", "Menu", "fMenu", ";", "private", "MenuAdapter", "menuAdapter", "=", "new", "MenuAdapter", "(", ")", "{", "public", "void", "menuShown", "(", "MenuEvent", "e", ")", "{", "refresh", "(", "true", ")", ";", "}", "}", ";", "public", "ZoomContributionViewItem", "(", "IZoomableWorkbenchPart", "part", ")", "{", "zoomManager", "=", "part", ".", "getZoomableViewer", "(", ")", ".", "getZoomManager", "(", ")", ";", "zoomManager", ".", "addZoomListener", "(", "this", ")", ";", "}", "public", "void", "fill", "(", "Menu", "menu", ",", "int", "index", ")", "{", "if", "(", "this", ".", "fMenu", "==", "null", "||", "this", ".", "fMenu", "!=", "menu", ")", "{", "if", "(", "this", ".", "fMenu", "!=", "null", ")", "{", "this", ".", "fMenu", ".", "removeMenuListener", "(", "menuAdapter", ")", ";", "this", ".", "fMenu", "=", "null", ";", "}", "this", ".", "fMenu", "=", "menu", ";", "menu", ".", "addMenuListener", "(", "menuAdapter", ")", ";", "}", "}", "public", "void", "fill", "(", "CoolBar", "parent", ",", "int", "index", ")", "{", "CoolItem", "item", "=", "new", "CoolItem", "(", "parent", ",", "SWT", ".", "DROP_DOWN", ")", ";", "Combo", "combo", "=", "createCombo", "(", "parent", ")", ";", "item", ".", "setControl", "(", "combo", ")", ";", "}", "public", "void", "fill", "(", "ToolBar", "parent", ",", "int", "index", ")", "{", "ToolItem", "item", "=", "new", "ToolItem", "(", "parent", ",", "SWT", ".", "SEPARATOR", ")", ";", "Combo", "combo", "=", "createCombo", "(", "parent", ")", ";", "item", ".", "setControl", "(", "combo", ")", ";", "item", ".", "setWidth", "(", "combo", ".", "computeSize", "(", "SWT", ".", "DEFAULT", ",", "SWT", ".", "DEFAULT", ",", "true", ")", ".", "x", ")", ";", "refreshCombo", "(", "false", ")", ";", "}", "private", "Combo", "createCombo", "(", "Composite", "parent", ")", "{", "this", ".", "combo", "=", "new", "Combo", "(", "parent", ",", "SWT", ".", "NONE", ")", ";", "zoomLevels", "=", "zoomManager", ".", "getZoomLevelsAsText", "(", ")", ";", "this", ".", "combo", ".", "setItems", "(", "zoomLevels", ")", ";", "this", ".", "combo", ".", "addSelectionListener", "(", "new", "SelectionAdapter", "(", ")", "{", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "int", "selection", "=", "combo", ".", "getSelectionIndex", "(", ")", ";", "if", "(", "selection", ">", "0", ")", "{", "doZoom", "(", "combo", ".", "getItem", "(", "selection", ")", ")", ";", "}", "else", "{", "doZoom", "(", "combo", ".", "getItem", "(", "0", ")", ")", ";", "}", "}", "}", ")", ";", "return", "this", ".", "combo", ";", "}", "private", "void", "doZoom", "(", "String", "zoom", ")", "{", "if", "(", "zoomManager", "!=", "null", ")", "{", "zoomManager", ".", "setZoomAsText", "(", "zoom", ")", ";", "}", "}", "private", "void", "refresh", "(", "boolean", "rebuild", ")", "{", "if", "(", "combo", "!=", "null", "&&", "!", "combo", ".", "isDisposed", "(", ")", ")", "{", "refreshCombo", "(", "rebuild", ")", ";", "}", "if", "(", "fMenu", "!=", "null", "&&", "!", "fMenu", ".", "isDisposed", "(", ")", ")", "{", "refreshMenu", "(", "rebuild", ")", ";", "}", "}", "private", "void", "refreshMenu", "(", "boolean", "rebuild", ")", "{", "fMenu", ".", "setEnabled", "(", "false", ")", ";", "if", "(", "zoomManager", "==", "null", ")", "{", "return", ";", "}", "if", "(", "rebuild", ")", "{", "zoomLevels", "=", "zoomManager", ".", "getZoomLevelsAsText", "(", ")", ";", "MenuItem", "[", "]", "oldItems", "=", "fMenu", ".", "getItems", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "oldItems", ".", "length", ";", "i", "++", ")", "{", "if", "(", "oldItems", "[", "i", "]", ".", "getData", "(", ")", "==", "this", ")", "{", "oldItems", "[", "i", "]", ".", "dispose", "(", ")", ";", "}", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "zoomLevels", ".", "length", ";", "i", "++", ")", "{", "MenuItem", "item", "=", "new", "MenuItem", "(", "fMenu", ",", "SWT", ".", "RADIO", ")", ";", "item", ".", "setText", "(", "zoomLevels", "[", "i", "]", ")", ";", "item", ".", "setData", "(", "this", ")", ";", "item", ".", "addSelectionListener", "(", "new", "SelectionAdapter", "(", ")", "{", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "MenuItem", "source", "=", "(", "MenuItem", ")", "e", ".", "getSource", "(", ")", ";", "doZoom", "(", "source", ".", "getText", "(", ")", ")", ";", "}", "}", ")", ";", "}", "}", "String", "zoom", "=", "zoomManager", ".", "getZoomAsText", "(", ")", ";", "MenuItem", "[", "]", "items", "=", "fMenu", ".", "getItems", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "items", ".", "length", ";", "i", "++", ")", "{", "MenuItem", "item", "=", "items", "[", "i", "]", ";", "if", "(", "item", ".", "getData", "(", ")", "==", "this", ")", "{", "item", ".", "setSelection", "(", "false", ")", ";", "if", "(", "zoom", ".", "equalsIgnoreCase", "(", "item", ".", "getText", "(", ")", ")", ")", "{", "item", ".", "setSelection", "(", "true", ")", ";", "}", "}", "}", "fMenu", ".", "setEnabled", "(", "true", ")", ";", "}", "private", "void", "refreshCombo", "(", "boolean", "rebuild", ")", "{", "combo", ".", "setEnabled", "(", "false", ")", ";", "if", "(", "zoomManager", "==", "null", ")", "{", "return", ";", "}", "if", "(", "rebuild", ")", "{", "combo", ".", "setItems", "(", "zoomManager", ".", "getZoomLevelsAsText", "(", ")", ")", ";", "}", "String", "zoom", "=", "zoomManager", ".", "getZoomAsText", "(", ")", ";", "int", "index", "=", "combo", ".", "indexOf", "(", "zoom", ")", ";", "if", "(", "index", ">", "0", ")", "{", "combo", ".", "select", "(", "index", ")", ";", "}", "else", "{", "int", "no", "=", "zoomLevels", ".", "length", ";", "if", "(", "combo", ".", "getItemCount", "(", ")", ">", "no", ")", "{", "combo", ".", "remove", "(", "no", ")", ";", "}", "combo", ".", "add", "(", "zoom", ",", "no", ")", ";", "combo", ".", "select", "(", "no", ")", ";", "}", "combo", ".", "setEnabled", "(", "true", ")", ";", "}", "public", "void", "zoomChanged", "(", "double", "z", ")", "{", "refresh", "(", "false", ")", ";", "}", "public", "void", "dispose", "(", ")", "{", "if", "(", "combo", "!=", "null", ")", "{", "combo", "=", "null", ";", "}", "if", "(", "fMenu", "!=", "null", ")", "{", "fMenu", "=", "null", ";", "}", "if", "(", "zoomManager", "!=", "null", ")", "{", "zoomManager", ".", "removeZoomListener", "(", "this", ")", ";", "}", "super", ".", "dispose", "(", ")", ";", "}", "}", "</s>" ]
10,163
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ";", "public", "interface", "IZoomableWorkbenchPart", "{", "AbstractZoomableViewer", "getZoomableViewer", "(", ")", ";", "}", "</s>" ]
10,164
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "IFigure", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Color", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "services", ".", "IDisposable", ";", "public", "interface", "IEntityStyleProvider", "extends", "IDisposable", "{", "public", "Color", "getNodeHighlightColor", "(", "Object", "entity", ")", ";", "public", "Color", "getBorderColor", "(", "Object", "entity", ")", ";", "public", "Color", "getBorderHighlightColor", "(", "Object", "entity", ")", ";", "public", "int", "getBorderWidth", "(", "Object", "entity", ")", ";", "public", "Color", "getBackgroundColour", "(", "Object", "entity", ")", ";", "public", "Color", "getForegroundColour", "(", "Object", "entity", ")", ";", "public", "IFigure", "getTooltip", "(", "Object", "entity", ")", ";", "public", "boolean", "fisheyeNode", "(", "Object", "entity", ")", ";", "}", "</s>" ]
10,165
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ConnectionRouter", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "IFigure", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Color", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "services", ".", "IDisposable", ";", "public", "interface", "IEntityConnectionStyleProvider", "extends", "IDisposable", "{", "public", "int", "getConnectionStyle", "(", "Object", "src", ",", "Object", "dest", ")", ";", "public", "Color", "getColor", "(", "Object", "src", ",", "Object", "dest", ")", ";", "public", "Color", "getHighlightColor", "(", "Object", "src", ",", "Object", "dest", ")", ";", "public", "int", "getLineWidth", "(", "Object", "src", ",", "Object", "dest", ")", ";", "public", "IFigure", "getTooltip", "(", "Object", "src", ",", "Object", "dest", ")", ";", "public", "ConnectionRouter", "getRouter", "(", "Object", "src", ",", "Object", "dest", ")", ";", "}", "</s>" ]
10,166
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Rectangle", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "StructuredViewer", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "zooming", ".", "ZoomManager", ";", "public", "abstract", "class", "AbstractZoomableViewer", "extends", "StructuredViewer", "{", "protected", "abstract", "ZoomManager", "getZoomManager", "(", ")", ";", "public", "void", "zoomTo", "(", "int", "x", ",", "int", "y", ",", "int", "width", ",", "int", "height", ")", "{", "Rectangle", "r", "=", "new", "Rectangle", "(", "x", ",", "y", ",", "width", ",", "height", ")", ";", "if", "(", "r", ".", "isEmpty", "(", ")", ")", "{", "getZoomManager", "(", ")", ".", "setZoomAsText", "(", "\"100%\"", ")", ";", "}", "else", "{", "getZoomManager", "(", ")", ".", "zoomTo", "(", "r", ")", ";", "}", "}", "}", "</s>" ]
10,167
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ConnectionRouter", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "IFigure", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Color", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "services", ".", "IDisposable", ";", "public", "interface", "IConnectionStyleProvider", "extends", "IDisposable", "{", "public", "int", "getConnectionStyle", "(", "Object", "rel", ")", ";", "public", "Color", "getColor", "(", "Object", "rel", ")", ";", "public", "Color", "getHighlightColor", "(", "Object", "rel", ")", ";", "public", "int", "getLineWidth", "(", "Object", "rel", ")", ";", "public", "IFigure", "getTooltip", "(", "Object", "rel", ")", ";", "public", "ConnectionRouter", "getRouter", "(", "Object", "rel", ")", ";", "}", "</s>" ]
10,168
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "IFigure", ";", "public", "interface", "IFigureProvider", "{", "public", "IFigure", "getFigure", "(", "Object", "element", ")", ";", "}", "</s>" ]
10,169
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "DoubleClickEvent", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "IContentProvider", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "ISelection", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "ISelectionChangedListener", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "ISelectionProvider", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "ITreeContentProvider", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "SelectionChangedEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "MouseEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "MouseListener", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionAdapter", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Composite", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Control", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Widget", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "internal", ".", "GraphModelEntityFactory", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "internal", ".", "GraphModelEntityRelationshipFactory", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "internal", ".", "GraphModelFactory", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "internal", ".", "IStylingGraphModelFactory", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "internal", ".", "TreeModelEntityFactory", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "Graph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphItem", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "ZestStyles", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "zooming", ".", "ZoomManager", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "LayoutAlgorithm", ";", "public", "class", "GraphViewer", "extends", "AbstractStructuredGraphViewer", "implements", "ISelectionProvider", "{", "protected", "Graph", "graph", "=", "null", ";", "private", "IStylingGraphModelFactory", "modelFactory", "=", "null", ";", "private", "List", "selectionChangedListeners", "=", "null", ";", "public", "GraphViewer", "(", "Composite", "composite", ",", "int", "style", ")", "{", "super", "(", "style", ")", ";", "this", ".", "graph", "=", "new", "Graph", "(", "composite", ",", "style", ")", ";", "hookControl", "(", "this", ".", "graph", ")", ";", "}", "public", "GraphViewer", "(", "Graph", "graph", ")", "{", "super", "(", "graph", ".", "getStyle", "(", ")", ")", ";", "this", ".", "graph", "=", "graph", ";", "hookControl", "(", "this", ".", "graph", ")", ";", "}", "protected", "void", "hookControl", "(", "Control", "control", ")", "{", "super", ".", "hookControl", "(", "control", ")", ";", "selectionChangedListeners", "=", "new", "ArrayList", "(", ")", ";", "getGraphControl", "(", ")", ".", "addSelectionListener", "(", "new", "SelectionAdapter", "(", ")", "{", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "Iterator", "iterator", "=", "selectionChangedListeners", ".", "iterator", "(", ")", ";", "ISelection", "structuredSelection", "=", "getSelection", "(", ")", ";", "SelectionChangedEvent", "event", "=", "new", "SelectionChangedEvent", "(", "GraphViewer", ".", "this", ",", "structuredSelection", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "ISelectionChangedListener", "listener", "=", "(", "ISelectionChangedListener", ")", "iterator", ".", "next", "(", ")", ";", "listener", ".", "selectionChanged", "(", "event", ")", ";", "}", "firePostSelectionChanged", "(", "event", ")", ";", "}", "}", ")", ";", "control", ".", "addMouseListener", "(", "new", "MouseListener", "(", ")", "{", "public", "void", "mouseDoubleClick", "(", "MouseEvent", "e", ")", "{", "DoubleClickEvent", "doubleClickEvent", "=", "new", "DoubleClickEvent", "(", "GraphViewer", ".", "this", ",", "getSelection", "(", ")", ")", ";", "fireDoubleClick", "(", "doubleClickEvent", ")", ";", "}", "public", "void", "mouseDown", "(", "MouseEvent", "e", ")", "{", "}", "public", "void", "mouseUp", "(", "MouseEvent", "e", ")", "{", "}", "}", ")", ";", "}", "protected", "void", "inputChanged", "(", "Object", "input", ",", "Object", "oldInput", ")", "{", "graph", ".", "setDynamicLayout", "(", "false", ")", ";", "super", ".", "inputChanged", "(", "input", ",", "oldInput", ")", ";", "graph", ".", "setDynamicLayout", "(", "true", ")", ";", "graph", ".", "applyLayout", "(", ")", ";", "}", "public", "int", "getStyle", "(", ")", "{", "return", "this", ".", "graph", ".", "getStyle", "(", ")", ";", "}", "public", "Graph", "getGraphControl", "(", ")", "{", "return", "super", ".", "getGraphControl", "(", ")", ";", "}", ";", "public", "void", "setLayoutAlgorithm", "(", "LayoutAlgorithm", "algorithm", ",", "boolean", "runLayout", ")", "{", "graph", ".", "setLayoutAlgorithm", "(", "algorithm", ",", "runLayout", ")", ";", "}", "public", "void", "setLayoutAlgorithm", "(", "LayoutAlgorithm", "algorithm", ")", "{", "super", ".", "setLayoutAlgorithm", "(", "algorithm", ")", ";", "}", "public", "void", "setNodeStyle", "(", "int", "nodeStyle", ")", "{", "super", ".", "setNodeStyle", "(", "nodeStyle", ")", ";", "this", ".", "graph", ".", "setNodeStyle", "(", "nodeStyle", ")", ";", "}", "public", "void", "setContentProvider", "(", "IContentProvider", "contentProvider", ")", "{", "if", "(", "contentProvider", "instanceof", "IGraphContentProvider", ")", "{", "super", ".", "setContentProvider", "(", "contentProvider", ")", ";", "}", "else", "if", "(", "contentProvider", "instanceof", "IGraphEntityContentProvider", ")", "{", "super", ".", "setContentProvider", "(", "contentProvider", ")", ";", "}", "else", "if", "(", "contentProvider", "instanceof", "IGraphEntityRelationshipContentProvider", ")", "{", "super", ".", "setContentProvider", "(", "contentProvider", ")", ";", "}", "else", "if", "(", "contentProvider", "instanceof", "ITreeContentProvider", ")", "{", "super", ".", "setContentProvider", "(", "contentProvider", ")", ";", "}", "else", "{", "throw", "new", "IllegalArgumentException", "(", "\"\"", ")", ";", "}", "}", "public", "GraphItem", "findGraphItem", "(", "Object", "element", ")", "{", "Widget", "[", "]", "result", "=", "findItems", "(", "element", ")", ";", "return", "(", "result", ".", "length", "==", "0", "||", "!", "(", "result", "[", "0", "]", "instanceof", "GraphItem", ")", ")", "?", "null", ":", "(", "GraphItem", ")", "result", "[", "0", "]", ";", "}", "public", "void", "applyLayout", "(", ")", "{", "graph", ".", "applyLayout", "(", ")", ";", "}", "protected", "void", "setSelectionToWidget", "(", "List", "l", ",", "boolean", "reveal", ")", "{", "GraphItem", "[", "]", "listOfItems", "=", "findItems", "(", "l", ")", ";", "graph", ".", "setSelection", "(", "listOfItems", ")", ";", "}", "public", "Control", "getControl", "(", ")", "{", "return", "graph", ";", "}", "public", "Object", "[", "]", "getNodeElements", "(", ")", "{", "return", "super", ".", "getNodeElements", "(", ")", ";", "}", "public", "Object", "[", "]", "getConnectionElements", "(", ")", "{", "return", "super", ".", "getConnectionElements", "(", ")", ";", "}", "public", "void", "reveal", "(", "Object", "element", ")", "{", "super", ".", "reveal", "(", "element", ")", ";", "}", "public", "void", "setConnectionStyle", "(", "int", "connectionStyle", ")", "{", "super", ".", "setConnectionStyle", "(", "connectionStyle", ")", ";", "}", "public", "void", "unReveal", "(", "Object", "element", ")", "{", "super", ".", "unReveal", "(", "element", ")", ";", "}", "public", "void", "addSelectionChangedListener", "(", "ISelectionChangedListener", "listener", ")", "{", "if", "(", "!", "selectionChangedListeners", ".", "contains", "(", "listener", ")", ")", "{", "selectionChangedListeners", ".", "add", "(", "listener", ")", ";", "}", "}", "public", "void", "removeSelectionChangedListener", "(", "ISelectionChangedListener", "listener", ")", "{", "if", "(", "selectionChangedListeners", ".", "contains", "(", "listener", ")", ")", "{", "selectionChangedListeners", ".", "remove", "(", "listener", ")", ";", "}", "}", "public", "void", "refresh", "(", "Object", "element", ")", "{", "boolean", "dynamicLayoutEnabled", "=", "graph", ".", "isDynamicLayoutEnabled", "(", ")", ";", "graph", ".", "setDynamicLayout", "(", "false", ")", ";", "super", ".", "refresh", "(", "element", ")", ";", "graph", ".", "setDynamicLayout", "(", "dynamicLayoutEnabled", ")", ";", "}", "public", "void", "refresh", "(", "Object", "element", ",", "boolean", "updateLabels", ")", "{", "boolean", "dynamicLayoutEnabled", "=", "graph", ".", "isDynamicLayoutEnabled", "(", ")", ";", "graph", ".", "setDynamicLayout", "(", "false", ")", ";", "super", ".", "refresh", "(", "element", ",", "updateLabels", ")", ";", "graph", ".", "setDynamicLayout", "(", "dynamicLayoutEnabled", ")", ";", "}", "public", "void", "update", "(", "Object", "element", ",", "String", "[", "]", "properties", ")", "{", "boolean", "dynamicLayoutEnabled", "=", "graph", ".", "isDynamicLayoutEnabled", "(", ")", ";", "graph", ".", "setDynamicLayout", "(", "false", ")", ";", "super", ".", "update", "(", "element", ",", "properties", ")", ";", "graph", ".", "setDynamicLayout", "(", "dynamicLayoutEnabled", ")", ";", "}", "public", "void", "update", "(", "Object", "[", "]", "elements", ",", "String", "[", "]", "properties", ")", "{", "boolean", "dynamicLayoutEnabled", "=", "graph", ".", "isDynamicLayoutEnabled", "(", ")", ";", "graph", ".", "setDynamicLayout", "(", "false", ")", ";", "super", ".", "update", "(", "elements", ",", "properties", ")", ";", "graph", ".", "setDynamicLayout", "(", "dynamicLayoutEnabled", ")", ";", "}", "protected", "ZoomManager", "getZoomManager", "(", ")", "{", "return", "getGraphControl", "(", ")", ".", "getZoomManager", "(", ")", ";", "}", "protected", "IStylingGraphModelFactory", "getFactory", "(", ")", "{", "if", "(", "modelFactory", "==", "null", ")", "{", "if", "(", "getContentProvider", "(", ")", "instanceof", "IGraphContentProvider", ")", "{", "modelFactory", "=", "new", "GraphModelFactory", "(", "this", ")", ";", "}", "else", "if", "(", "getContentProvider", "(", ")", "instanceof", "IGraphEntityContentProvider", ")", "{", "modelFactory", "=", "new", "GraphModelEntityFactory", "(", "this", ")", ";", "}", "else", "if", "(", "getContentProvider", "(", ")", "instanceof", "IGraphEntityRelationshipContentProvider", ")", "{", "modelFactory", "=", "new", "GraphModelEntityRelationshipFactory", "(", "this", ")", ";", "}", "else", "if", "(", "getContentProvider", "(", ")", "instanceof", "ITreeContentProvider", ")", "{", "modelFactory", "=", "new", "TreeModelEntityFactory", "(", "this", ")", ";", "}", "}", "return", "modelFactory", ";", "}", "protected", "LayoutAlgorithm", "getLayoutAlgorithm", "(", ")", "{", "return", "graph", ".", "getLayoutAlgorithm", "(", ")", ";", "}", "}", "</s>" ]
10,170
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "IStructuredContentProvider", ";", "public", "interface", "IGraphEntityRelationshipContentProvider", "extends", "IStructuredContentProvider", "{", "public", "Object", "[", "]", "getRelationships", "(", "Object", "source", ",", "Object", "dest", ")", ";", "}", "</s>" ]
10,171
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Comparator", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "LinkedList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "TreeSet", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "IFigure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Point", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWTError", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Widget", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "internal", ".", "IStylingGraphModelFactory", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "Graph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphConnection", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphContainer", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphItem", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphNode", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "ZestStyles", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "custom", ".", "CGraphNode", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "LayoutAlgorithm", ";", "public", "abstract", "class", "AbstractStructuredGraphViewer", "extends", "AbstractZoomableViewer", "{", "private", "int", "graphStyle", ";", "private", "int", "nodeStyle", ";", "private", "int", "connectionStyle", ";", "private", "HashMap", "nodesMap", "=", "new", "HashMap", "(", ")", ";", "private", "HashMap", "connectionsMap", "=", "new", "HashMap", "(", ")", ";", "private", "class", "SimpleGraphComparator", "implements", "Comparator", "{", "TreeSet", "storedStrings", ";", "public", "SimpleGraphComparator", "(", ")", "{", "this", ".", "storedStrings", "=", "new", "TreeSet", "(", ")", ";", "}", "public", "int", "compare", "(", "Object", "arg0", ",", "Object", "arg1", ")", "{", "if", "(", "arg0", "instanceof", "GraphNode", "&&", "arg1", "instanceof", "GraphConnection", ")", "{", "return", "1", ";", "}", "else", "if", "(", "arg0", "instanceof", "GraphConnection", "&&", "arg1", "instanceof", "GraphNode", ")", "{", "return", "-", "1", ";", "}", "if", "(", "arg0", ".", "equals", "(", "arg1", ")", ")", "{", "return", "0", ";", "}", "return", "getObjectString", "(", "arg0", ")", ".", "compareTo", "(", "getObjectString", "(", "arg1", ")", ")", ";", "}", "private", "String", "getObjectString", "(", "Object", "o", ")", "{", "String", "s", "=", "o", ".", "getClass", "(", ")", ".", "getName", "(", ")", "+", "\"@\"", "+", "Integer", ".", "toHexString", "(", "o", ".", "hashCode", "(", ")", ")", ";", "while", "(", "storedStrings", ".", "contains", "(", "s", ")", ")", "{", "s", "=", "s", "+", "'X'", ";", "}", "return", "s", ";", "}", "}", "protected", "AbstractStructuredGraphViewer", "(", "int", "graphStyle", ")", "{", "this", ".", "graphStyle", "=", "graphStyle", ";", "this", ".", "connectionStyle", "=", "SWT", ".", "NONE", ";", "this", ".", "nodeStyle", "=", "SWT", ".", "NONE", ";", "}", "public", "void", "setNodeStyle", "(", "int", "nodeStyle", ")", "{", "if", "(", "getInput", "(", ")", "!=", "null", ")", "{", "throw", "new", "SWTError", "(", "SWT", ".", "ERROR_UNSPECIFIED", ")", ";", "}", "this", ".", "nodeStyle", "=", "nodeStyle", ";", "}", "public", "void", "setConnectionStyle", "(", "int", "connectionStyle", ")", "{", "if", "(", "getInput", "(", ")", "!=", "null", ")", "{", "throw", "new", "SWTError", "(", "SWT", ".", "ERROR_UNSPECIFIED", ")", ";", "}", "if", "(", "!", "ZestStyles", ".", "validateConnectionStyle", "(", "connectionStyle", ")", ")", "{", "throw", "new", "SWTError", "(", "SWT", ".", "ERROR_INVALID_ARGUMENT", ")", ";", "}", "this", ".", "connectionStyle", "=", "connectionStyle", ";", "}", "public", "int", "getGraphStyle", "(", ")", "{", "return", "graphStyle", ";", "}", "public", "int", "getNodeStyle", "(", ")", "{", "return", "nodeStyle", ";", "}", "public", "Graph", "getGraphControl", "(", ")", "{", "return", "(", "Graph", ")", "getControl", "(", ")", ";", "}", "public", "int", "getConnectionStyle", "(", ")", "{", "return", "connectionStyle", ";", "}", "public", "abstract", "void", "setLayoutAlgorithm", "(", "LayoutAlgorithm", "algorithm", ",", "boolean", "run", ")", ";", "protected", "abstract", "LayoutAlgorithm", "getLayoutAlgorithm", "(", ")", ";", "public", "void", "setLayoutAlgorithm", "(", "LayoutAlgorithm", "algorithm", ")", "{", "setLayoutAlgorithm", "(", "algorithm", ",", "false", ")", ";", "}", "public", "Object", "[", "]", "getNodeElements", "(", ")", "{", "return", "this", ".", "nodesMap", ".", "keySet", "(", ")", ".", "toArray", "(", ")", ";", "}", "public", "Object", "[", "]", "getConnectionElements", "(", ")", "{", "return", "this", ".", "connectionsMap", ".", "keySet", "(", ")", ".", "toArray", "(", ")", ";", "}", "public", "HashMap", "getNodesMap", "(", ")", "{", "return", "this", ".", "nodesMap", ";", "}", "public", "GraphNode", "addGraphModelContainer", "(", "Object", "element", ")", "{", "GraphNode", "node", "=", "this", ".", "getGraphModelNode", "(", "element", ")", ";", "if", "(", "node", "==", "null", ")", "{", "node", "=", "new", "GraphContainer", "(", "(", "Graph", ")", "getControl", "(", ")", ",", "SWT", ".", "NONE", ")", ";", "this", ".", "nodesMap", ".", "put", "(", "element", ",", "node", ")", ";", "node", ".", "setData", "(", "element", ")", ";", "}", "return", "node", ";", "}", "public", "GraphNode", "addGraphModelNode", "(", "GraphContainer", "container", ",", "Object", "element", ")", "{", "GraphNode", "node", "=", "this", ".", "getGraphModelNode", "(", "element", ")", ";", "if", "(", "node", "==", "null", ")", "{", "node", "=", "new", "GraphNode", "(", "container", ",", "SWT", ".", "NONE", ")", ";", "this", ".", "nodesMap", ".", "put", "(", "element", ",", "node", ")", ";", "node", ".", "setData", "(", "element", ")", ";", "}", "return", "node", ";", "}", "public", "GraphNode", "addGraphModelNode", "(", "Object", "element", ",", "IFigure", "figure", ")", "{", "GraphNode", "node", "=", "this", ".", "getGraphModelNode", "(", "element", ")", ";", "if", "(", "node", "==", "null", ")", "{", "if", "(", "figure", "!=", "null", ")", "{", "node", "=", "new", "CGraphNode", "(", "(", "Graph", ")", "getControl", "(", ")", ",", "SWT", ".", "NONE", ",", "figure", ")", ";", "this", ".", "nodesMap", ".", "put", "(", "element", ",", "node", ")", ";", "node", ".", "setData", "(", "element", ")", ";", "}", "else", "{", "node", "=", "new", "GraphNode", "(", "(", "Graph", ")", "getControl", "(", ")", ",", "SWT", ".", "NONE", ")", ";", "this", ".", "nodesMap", ".", "put", "(", "element", ",", "node", ")", ";", "node", ".", "setData", "(", "element", ")", ";", "}", "}", "return", "node", ";", "}", "public", "GraphConnection", "addGraphModelConnection", "(", "Object", "element", ",", "GraphNode", "source", ",", "GraphNode", "target", ")", "{", "GraphConnection", "connection", "=", "this", ".", "getGraphModelConnection", "(", "element", ")", ";", "if", "(", "connection", "==", "null", ")", "{", "connection", "=", "new", "GraphConnection", "(", "(", "Graph", ")", "getControl", "(", ")", ",", "SWT", ".", "NONE", ",", "source", ",", "target", ")", ";", "this", ".", "connectionsMap", ".", "put", "(", "element", ",", "connection", ")", ";", "connection", ".", "setData", "(", "element", ")", ";", "}", "return", "connection", ";", "}", "public", "GraphConnection", "getGraphModelConnection", "(", "Object", "obj", ")", "{", "return", "(", "GraphConnection", ")", "this", ".", "connectionsMap", ".", "get", "(", "obj", ")", ";", "}", "public", "GraphNode", "getGraphModelNode", "(", "Object", "obj", ")", "{", "return", "(", "GraphNode", ")", "this", ".", "nodesMap", ".", "get", "(", "obj", ")", ";", "}", "public", "void", "removeGraphModelConnection", "(", "Object", "obj", ")", "{", "GraphConnection", "connection", "=", "(", "GraphConnection", ")", "connectionsMap", ".", "get", "(", "obj", ")", ";", "if", "(", "connection", "!=", "null", ")", "{", "connectionsMap", ".", "remove", "(", "obj", ")", ";", "if", "(", "!", "connection", ".", "isDisposed", "(", ")", ")", "{", "connection", ".", "dispose", "(", ")", ";", "}", "}", "}", "public", "void", "removeGraphModelNode", "(", "Object", "obj", ")", "{", "GraphNode", "node", "=", "(", "GraphNode", ")", "nodesMap", ".", "get", "(", "obj", ")", ";", "if", "(", "node", "!=", "null", ")", "{", "nodesMap", ".", "remove", "(", "obj", ")", ";", "if", "(", "!", "node", ".", "isDisposed", "(", ")", ")", "{", "node", ".", "dispose", "(", ")", ";", "}", "}", "}", "protected", "void", "internalRefresh", "(", "Object", "element", ")", "{", "if", "(", "getInput", "(", ")", "==", "null", ")", "{", "return", ";", "}", "if", "(", "element", "==", "getInput", "(", ")", ")", "{", "getFactory", "(", ")", ".", "refreshGraph", "(", "getGraphControl", "(", ")", ")", ";", "}", "else", "{", "getFactory", "(", ")", ".", "refresh", "(", "getGraphControl", "(", ")", ",", "element", ")", ";", "}", "getGraphControl", "(", ")", ".", "getLightweightSystem", "(", ")", ".", "getUpdateManager", "(", ")", ".", "performUpdate", "(", ")", ";", "}", "protected", "void", "doUpdateItem", "(", "Widget", "item", ",", "Object", "element", ",", "boolean", "fullMap", ")", "{", "if", "(", "item", "==", "getGraphControl", "(", ")", ")", "{", "getFactory", "(", ")", ".", "update", "(", "getNodesArray", "(", "getGraphControl", "(", ")", ")", ")", ";", "getFactory", "(", ")", ".", "update", "(", "getConnectionsArray", "(", "getGraphControl", "(", ")", ")", ")", ";", "}", "else", "if", "(", "item", "instanceof", "GraphItem", ")", "{", "getFactory", "(", ")", ".", "update", "(", "(", "GraphItem", ")", "item", ")", ";", "}", "}", "protected", "Widget", "doFindInputItem", "(", "Object", "element", ")", "{", "if", "(", "element", "==", "getInput", "(", ")", "&&", "element", "instanceof", "Widget", ")", "{", "return", "(", "Widget", ")", "element", ";", "}", "return", "null", ";", "}", "protected", "Widget", "doFindItem", "(", "Object", "element", ")", "{", "Widget", "node", "=", "(", "Widget", ")", "nodesMap", ".", "get", "(", "element", ")", ";", "Widget", "connection", "=", "(", "Widget", ")", "connectionsMap", ".", "get", "(", "element", ")", ";", "return", "(", "node", "!=", "null", ")", "?", "node", ":", "connection", ";", "}", "protected", "List", "getSelectionFromWidget", "(", ")", "{", "List", "internalSelection", "=", "getWidgetSelection", "(", ")", ";", "LinkedList", "externalSelection", "=", "new", "LinkedList", "(", ")", ";", "for", "(", "Iterator", "i", "=", "internalSelection", ".", "iterator", "(", ")", ";", "i", ".", "hasNext", "(", ")", ";", ")", "{", "Object", "data", "=", "(", "(", "GraphItem", ")", "i", ".", "next", "(", ")", ")", ".", "getData", "(", ")", ";", "if", "(", "data", "!=", "null", ")", "{", "externalSelection", ".", "add", "(", "data", ")", ";", "}", "}", "return", "externalSelection", ";", "}", "protected", "GraphItem", "[", "]", "findItems", "(", "List", "l", ")", "{", "if", "(", "l", "==", "null", ")", "{", "return", "new", "GraphItem", "[", "0", "]", ";", "}", "ArrayList", "list", "=", "new", "ArrayList", "(", ")", ";", "Iterator", "iterator", "=", "l", ".", "iterator", "(", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "GraphItem", "w", "=", "(", "GraphItem", ")", "findItem", "(", "iterator", ".", "next", "(", ")", ")", ";", "list", ".", "add", "(", "w", ")", ";", "}", "return", "(", "GraphItem", "[", "]", ")", "list", ".", "toArray", "(", "new", "GraphItem", "[", "list", ".", "size", "(", ")", "]", ")", ";", "}", "protected", "void", "setSelectionToWidget", "(", "List", "l", ",", "boolean", "reveal", ")", "{", "Graph", "control", "=", "(", "Graph", ")", "getControl", "(", ")", ";", "List", "selection", "=", "new", "LinkedList", "(", ")", ";", "for", "(", "Iterator", "i", "=", "l", ".", "iterator", "(", ")", ";", "i", ".", "hasNext", "(", ")", ";", ")", "{", "Object", "obj", "=", "i", ".", "next", "(", ")", ";", "GraphNode", "node", "=", "(", "GraphNode", ")", "nodesMap", ".", "get", "(", "obj", ")", ";", "GraphConnection", "conn", "=", "(", "GraphConnection", ")", "connectionsMap", ".", "get", "(", "obj", ")", ";", "if", "(", "node", "!=", "null", ")", "{", "selection", ".", "add", "(", "node", ")", ";", "}", "if", "(", "conn", "!=", "null", ")", "{", "selection", ".", "add", "(", "conn", ")", ";", "}", "}", "control", ".", "setSelection", "(", "(", "GraphNode", "[", "]", ")", "selection", ".", "toArray", "(", "new", "GraphNode", "[", "selection", ".", "size", "(", ")", "]", ")", ")", ";", "}", "protected", "List", "getWidgetSelection", "(", ")", "{", "Graph", "control", "=", "(", "Graph", ")", "getControl", "(", ")", ";", "return", "control", ".", "getSelection", "(", ")", ";", "}", "protected", "void", "inputChanged", "(", "Object", "input", ",", "Object", "oldInput", ")", "{", "IStylingGraphModelFactory", "factory", "=", "getFactory", "(", ")", ";", "factory", ".", "setConnectionStyle", "(", "getConnectionStyle", "(", ")", ")", ";", "factory", ".", "setNodeStyle", "(", "getNodeStyle", "(", ")", ")", ";", "Map", "oldNodesMap", "=", "nodesMap", ";", "Graph", "graph", "=", "(", "Graph", ")", "getControl", "(", ")", ";", "graph", ".", "setSelection", "(", "new", "GraphNode", "[", "0", "]", ")", ";", "Iterator", "iterator", "=", "nodesMap", ".", "values", "(", ")", ".", "iterator", "(", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "GraphNode", "node", "=", "(", "GraphNode", ")", "iterator", ".", "next", "(", ")", ";", "if", "(", "!", "node", ".", "isDisposed", "(", ")", ")", "{", "node", ".", "dispose", "(", ")", ";", "}", "}", "iterator", "=", "connectionsMap", ".", "values", "(", ")", ".", "iterator", "(", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "GraphConnection", "connection", "=", "(", "GraphConnection", ")", "iterator", ".", "next", "(", ")", ";", "if", "(", "!", "connection", ".", "isDisposed", "(", ")", ")", "{", "connection", ".", "dispose", "(", ")", ";", "}", "}", "nodesMap", "=", "new", "HashMap", "(", ")", ";", "connectionsMap", "=", "new", "HashMap", "(", ")", ";", "graph", "=", "factory", ".", "createGraphModel", "(", "graph", ")", ";", "(", "(", "Graph", ")", "getControl", "(", ")", ")", ".", "setNodeStyle", "(", "getNodeStyle", "(", ")", ")", ";", "(", "(", "Graph", ")", "getControl", "(", ")", ")", ".", "setConnectionStyle", "(", "getConnectionStyle", "(", ")", ")", ";", "for", "(", "Iterator", "iter", "=", "oldNodesMap", ".", "keySet", "(", ")", ".", "iterator", "(", ")", ";", "iter", ".", "hasNext", "(", ")", ";", ")", "{", "Object", "data", "=", "iter", ".", "next", "(", ")", ";", "GraphNode", "newNode", "=", "(", "GraphNode", ")", "nodesMap", ".", "get", "(", "data", ")", ";", "if", "(", "newNode", "!=", "null", ")", "{", "GraphNode", "oldNode", "=", "(", "GraphNode", ")", "oldNodesMap", ".", "get", "(", "data", ")", ";", "newNode", ".", "setLocation", "(", "oldNode", ".", "getLocation", "(", ")", ".", "x", ",", "oldNode", ".", "getLocation", "(", ")", ".", "y", ")", ";", "if", "(", "oldNode", ".", "isSizeFixed", "(", ")", ")", "{", "newNode", ".", "setSize", "(", "oldNode", ".", "getSize", "(", ")", ".", "width", ",", "oldNode", ".", "getSize", "(", ")", ".", "height", ")", ";", "}", "}", "}", "}", "protected", "abstract", "IStylingGraphModelFactory", "getFactory", "(", ")", ";", "protected", "void", "filterVisuals", "(", ")", "{", "if", "(", "getGraphControl", "(", ")", "==", "null", ")", "{", "return", ";", "}", "Object", "[", "]", "filtered", "=", "getFilteredChildren", "(", "getInput", "(", ")", ")", ";", "SimpleGraphComparator", "comparator", "=", "new", "SimpleGraphComparator", "(", ")", ";", "TreeSet", "filteredElements", "=", "new", "TreeSet", "(", "comparator", ")", ";", "TreeSet", "unfilteredElements", "=", "new", "TreeSet", "(", "comparator", ")", ";", "List", "connections", "=", "getGraphControl", "(", ")", ".", "getConnections", "(", ")", ";", "List", "nodes", "=", "getGraphControl", "(", ")", ".", "getNodes", "(", ")", ";", "if", "(", "filtered", ".", "length", "==", "0", ")", "{", "for", "(", "Iterator", "i", "=", "connections", ".", "iterator", "(", ")", ";", "i", ".", "hasNext", "(", ")", ";", ")", "{", "GraphConnection", "c", "=", "(", "GraphConnection", ")", "i", ".", "next", "(", ")", ";", "c", ".", "setVisible", "(", "false", ")", ";", "}", "for", "(", "Iterator", "i", "=", "nodes", ".", "iterator", "(", ")", ";", "i", ".", "hasNext", "(", ")", ";", ")", "{", "GraphNode", "n", "=", "(", "GraphNode", ")", "i", ".", "next", "(", ")", ";", "n", ".", "setVisible", "(", "false", ")", ";", "}", "return", ";", "}", "for", "(", "Iterator", "i", "=", "connections", ".", "iterator", "(", ")", ";", "i", ".", "hasNext", "(", ")", ";", ")", "{", "GraphConnection", "c", "=", "(", "GraphConnection", ")", "i", ".", "next", "(", ")", ";", "if", "(", "c", ".", "getExternalConnection", "(", ")", "!=", "null", ")", "{", "unfilteredElements", ".", "add", "(", "c", ")", ";", "}", "}", "for", "(", "Iterator", "i", "=", "nodes", ".", "iterator", "(", ")", ";", "i", ".", "hasNext", "(", ")", ";", ")", "{", "GraphNode", "n", "=", "(", "GraphNode", ")", "i", ".", "next", "(", ")", ";", "if", "(", "n", ".", "getData", "(", ")", "!=", "null", ")", "{", "unfilteredElements", ".", "add", "(", "n", ")", ";", "}", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "filtered", ".", "length", ";", "i", "++", ")", "{", "Object", "modelElement", "=", "connectionsMap", ".", "get", "(", "filtered", "[", "i", "]", ")", ";", "if", "(", "modelElement", "==", "null", ")", "{", "modelElement", "=", "nodesMap", ".", "get", "(", "filtered", "[", "i", "]", ")", ";", "}", "if", "(", "modelElement", "!=", "null", ")", "{", "filteredElements", ".", "add", "(", "modelElement", ")", ";", "}", "}", "unfilteredElements", ".", "removeAll", "(", "filteredElements", ")", ";", "while", "(", "unfilteredElements", ".", "size", "(", ")", ">", "0", ")", "{", "GraphItem", "i", "=", "(", "GraphItem", ")", "unfilteredElements", ".", "first", "(", ")", ";", "i", ".", "setVisible", "(", "false", ")", ";", "unfilteredElements", ".", "remove", "(", "i", ")", ";", "}", "while", "(", "filteredElements", ".", "size", "(", ")", ">", "0", ")", "{", "GraphItem", "i", "=", "(", "GraphItem", ")", "filteredElements", ".", "first", "(", ")", ";", "i", ".", "setVisible", "(", "true", ")", ";", "filteredElements", ".", "remove", "(", "i", ")", ";", "}", "}", "protected", "Object", "[", "]", "getRawChildren", "(", "Object", "parent", ")", "{", "if", "(", "parent", "==", "getInput", "(", ")", ")", "{", "LinkedList", "children", "=", "new", "LinkedList", "(", ")", ";", "if", "(", "getGraphControl", "(", ")", "!=", "null", ")", "{", "List", "connections", "=", "getGraphControl", "(", ")", ".", "getConnections", "(", ")", ";", "List", "nodes", "=", "getGraphControl", "(", ")", ".", "getNodes", "(", ")", ";", "for", "(", "Iterator", "i", "=", "connections", ".", "iterator", "(", ")", ";", "i", ".", "hasNext", "(", ")", ";", ")", "{", "GraphConnection", "c", "=", "(", "GraphConnection", ")", "i", ".", "next", "(", ")", ";", "if", "(", "c", ".", "getExternalConnection", "(", ")", "!=", "null", ")", "{", "children", ".", "add", "(", "c", ".", "getExternalConnection", "(", ")", ")", ";", "}", "}", "for", "(", "Iterator", "i", "=", "nodes", ".", "iterator", "(", ")", ";", "i", ".", "hasNext", "(", ")", ";", ")", "{", "GraphNode", "n", "=", "(", "GraphNode", ")", "i", ".", "next", "(", ")", ";", "if", "(", "n", ".", "getData", "(", ")", "!=", "null", ")", "{", "children", ".", "add", "(", "n", ".", "getData", "(", ")", ")", ";", "}", "}", "return", "children", ".", "toArray", "(", ")", ";", "}", "}", "return", "super", ".", "getRawChildren", "(", "parent", ")", ";", "}", "public", "void", "reveal", "(", "Object", "element", ")", "{", "Widget", "[", "]", "items", "=", "this", ".", "findItems", "(", "element", ")", ";", "Point", "location", "=", "null", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "items", ".", "length", ";", "i", "++", ")", "{", "Widget", "item", "=", "items", "[", "i", "]", ";", "if", "(", "item", "instanceof", "GraphNode", ")", "{", "GraphNode", "graphModelNode", "=", "(", "GraphNode", ")", "item", ";", "graphModelNode", ".", "highlight", "(", ")", ";", "location", "=", "getTopLeftBoundary", "(", "graphModelNode", ".", "getLocation", "(", ")", ",", "location", ")", ";", "}", "else", "if", "(", "item", "instanceof", "GraphConnection", ")", "{", "GraphConnection", "graphModelConnection", "=", "(", "GraphConnection", ")", "item", ";", "graphModelConnection", ".", "highlight", "(", ")", ";", "location", "=", "getTopLeftBoundary", "(", "graphModelConnection", ".", "getSource", "(", ")", ".", "getLocation", "(", ")", ",", "location", ")", ";", "location", "=", "getTopLeftBoundary", "(", "graphModelConnection", ".", "getDestination", "(", ")", ".", "getLocation", "(", ")", ",", "location", ")", ";", "}", "}", "if", "(", "location", "!=", "null", ")", "{", "getGraphControl", "(", ")", ".", "scrollSmoothTo", "(", "location", ".", "x", ",", "location", ".", "y", ")", ";", "}", "}", "private", "Point", "getTopLeftBoundary", "(", "Point", "point1", ",", "Point", "point2", ")", "{", "if", "(", "point2", "!=", "null", ")", "{", "return", "new", "Point", "(", "Math", ".", "min", "(", "point1", ".", "x", ",", "point2", ".", "x", ")", ",", "Math", ".", "min", "(", "point1", ".", "y", ",", "point2", ".", "y", ")", ")", ";", "}", "else", "{", "return", "point1", ";", "}", "}", "public", "void", "unReveal", "(", "Object", "element", ")", "{", "Widget", "[", "]", "items", "=", "this", ".", "findItems", "(", "element", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "items", ".", "length", ";", "i", "++", ")", "{", "Widget", "item", "=", "items", "[", "i", "]", ";", "if", "(", "item", "instanceof", "GraphNode", ")", "{", "GraphNode", "graphModelNode", "=", "(", "GraphNode", ")", "item", ";", "graphModelNode", ".", "unhighlight", "(", ")", ";", "}", "else", "if", "(", "item", "instanceof", "GraphConnection", ")", "{", "GraphConnection", "graphModelConnection", "=", "(", "GraphConnection", ")", "item", ";", "graphModelConnection", ".", "unhighlight", "(", ")", ";", "}", "}", "}", "public", "abstract", "void", "applyLayout", "(", ")", ";", "public", "void", "removeRelationship", "(", "Object", "connection", ")", "{", "GraphConnection", "relationship", "=", "(", "GraphConnection", ")", "connectionsMap", ".", "get", "(", "connection", ")", ";", "if", "(", "relationship", "!=", "null", ")", "{", "relationship", ".", "dispose", "(", ")", ";", "}", "}", "public", "void", "addNode", "(", "Object", "element", ")", "{", "if", "(", "nodesMap", ".", "get", "(", "element", ")", "==", "null", ")", "{", "getFactory", "(", ")", ".", "createNode", "(", "getGraphControl", "(", ")", ",", "element", ")", ";", "}", "}", "public", "void", "removeNode", "(", "Object", "element", ")", "{", "GraphNode", "node", "=", "(", "GraphNode", ")", "nodesMap", ".", "get", "(", "element", ")", ";", "if", "(", "node", "!=", "null", ")", "{", "node", ".", "dispose", "(", ")", ";", "}", "}", "public", "void", "addRelationship", "(", "Object", "connection", ",", "Object", "srcNode", ",", "Object", "destNode", ")", "{", "IStylingGraphModelFactory", "modelFactory", "=", "getFactory", "(", ")", ";", "modelFactory", ".", "createConnection", "(", "getGraphControl", "(", ")", ",", "connection", ",", "srcNode", ",", "destNode", ")", ";", "}", "public", "void", "addRelationship", "(", "Object", "connection", ")", "{", "IStylingGraphModelFactory", "modelFactory", "=", "getFactory", "(", ")", ";", "if", "(", "connectionsMap", ".", "get", "(", "connection", ")", "==", "null", ")", "{", "if", "(", "modelFactory", ".", "getContentProvider", "(", ")", "instanceof", "IGraphContentProvider", ")", "{", "IGraphContentProvider", "content", "=", "(", "(", "IGraphContentProvider", ")", "modelFactory", ".", "getContentProvider", "(", ")", ")", ";", "Object", "source", "=", "content", ".", "getSource", "(", "connection", ")", ";", "Object", "dest", "=", "content", ".", "getDestination", "(", "connection", ")", ";", "modelFactory", ".", "createConnection", "(", "getGraphControl", "(", ")", ",", "connection", ",", "source", ",", "dest", ")", ";", "}", "else", "{", "throw", "new", "UnsupportedOperationException", "(", ")", ";", "}", "}", "}", "protected", "GraphConnection", "[", "]", "getConnectionsArray", "(", "Graph", "graph", ")", "{", "GraphConnection", "[", "]", "connsArray", "=", "new", "GraphConnection", "[", "graph", ".", "getConnections", "(", ")", ".", "size", "(", ")", "]", ";", "connsArray", "=", "(", "GraphConnection", "[", "]", ")", "graph", ".", "getConnections", "(", ")", ".", "toArray", "(", "connsArray", ")", ";", "return", "connsArray", ";", "}", "protected", "GraphNode", "[", "]", "getNodesArray", "(", "Graph", "graph", ")", "{", "GraphNode", "[", "]", "nodesArray", "=", "new", "GraphNode", "[", "graph", ".", "getNodes", "(", ")", ".", "size", "(", ")", "]", ";", "nodesArray", "=", "(", "GraphNode", "[", "]", ")", "graph", ".", "getNodes", "(", ")", ".", "toArray", "(", "nodesArray", ")", ";", "return", "nodesArray", ";", "}", "}", "</s>" ]
10,172
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ";", "public", "interface", "INestedContentProvider", "{", "public", "boolean", "hasChildren", "(", "Object", "element", ")", ";", "public", "Object", "[", "]", "getChildren", "(", "Object", "element", ")", ";", "}", "</s>" ]
10,173
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ";", "public", "final", "class", "EntityConnectionData", "{", "public", "final", "Object", "source", ";", "public", "final", "Object", "dest", ";", "public", "EntityConnectionData", "(", "Object", "source", ",", "Object", "dest", ")", "{", "this", ".", "source", "=", "source", ";", "this", ".", "dest", "=", "dest", ";", "}", "public", "boolean", "equals", "(", "Object", "obj", ")", "{", "if", "(", "!", "(", "obj", "instanceof", "EntityConnectionData", ")", ")", "{", "return", "false", ";", "}", "EntityConnectionData", "that", "=", "(", "EntityConnectionData", ")", "obj", ";", "return", "(", "this", ".", "source", ".", "equals", "(", "that", ".", "source", ")", "&&", "this", ".", "dest", ".", "equals", "(", "that", ".", "dest", ")", ")", ";", "}", "public", "int", "hashCode", "(", ")", "{", "return", "this", ".", "source", ".", "hashCode", "(", ")", "+", "this", ".", "dest", ".", "hashCode", "(", ")", ";", "}", "}", "</s>" ]
10,174
[ "<s>", "class", "Node", "{", "Node", "parent", ";", "Node", "left", ";", "Node", "right", ";", "}", "</s>" ]
10,175
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "internal", ".", "dot", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "net", ".", "MalformedURLException", ";", "import", "java", ".", "util", ".", "regex", ".", "Matcher", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IFile", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "DotUiMessages", ";", "public", "final", "class", "DotExtractor", "{", "public", "static", "final", "String", "NO_DOT", "=", "\"\"", "+", "DotUiMessages", ".", "DotExtractor_0", "+", "\"\\\"]}\"", ";", "private", "String", "input", "=", "NO_DOT", ";", "public", "DotExtractor", "(", "final", "String", "input", ")", "{", "this", ".", "input", "=", "input", ";", "}", "public", "DotExtractor", "(", "final", "IFile", "file", ")", "throws", "MalformedURLException", "{", "this", "(", "DotFileUtils", ".", "read", "(", "DotFileUtils", ".", "resolve", "(", "file", ".", "getLocationURI", "(", ")", ".", "toURL", "(", ")", ")", ")", ")", ";", "}", "public", "DotExtractor", "(", "final", "File", "file", ")", "{", "this", "(", "DotFileUtils", ".", "read", "(", "file", ")", ")", ";", "}", "public", "String", "getDotString", "(", ")", "{", "return", "trimNonDotSuffix", "(", "trimNonDotPrefix", "(", ")", ")", ";", "}", "private", "String", "trimNonDotPrefix", "(", ")", "{", "Matcher", "m", "=", "Pattern", ".", "compile", "(", "\"\"", ",", "Pattern", ".", "DOTALL", ")", ".", "matcher", "(", "input", ")", ";", "String", "dotSubstring", "=", "m", ".", "find", "(", ")", "?", "m", ".", "group", "(", "1", ")", ":", "NO_DOT", ";", "return", "dotSubstring", ";", "}", "private", "String", "trimNonDotSuffix", "(", "String", "dot", ")", "{", "int", "first", "=", "dot", ".", "indexOf", "(", "'{'", ")", "+", "1", ";", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", "dot", ".", "substring", "(", "0", ",", "first", ")", ")", ";", "int", "count", "=", "1", ";", "int", "index", "=", "first", ";", "while", "(", "count", ">", "0", "&&", "index", "<", "dot", ".", "length", "(", ")", ")", "{", "char", "c", "=", "dot", ".", "charAt", "(", "index", ")", ";", "builder", ".", "append", "(", "c", ")", ";", "count", "=", "(", "c", "==", "'{'", ")", "?", "count", "+", "1", ":", "(", "c", "==", "'}'", ")", "?", "count", "-", "1", ":", "count", ";", "index", "++", ";", "}", "return", "builder", ".", "toString", "(", ")", ".", "trim", "(", ")", ";", "}", "}", "</s>" ]
10,176
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "internal", ".", "dot", ".", "parser", ".", "ui", ".", "labeling", ";", "import", "org", ".", "eclipse", ".", "emf", ".", "edit", ".", "ui", ".", "provider", ".", "AdapterFactoryLabelProvider", ";", "import", "org", ".", "eclipse", ".", "xtext", ".", "ui", ".", "label", ".", "DefaultEObjectLabelProvider", ";", "import", "com", ".", "google", ".", "inject", ".", "Inject", ";", "public", "class", "DotLabelProvider", "extends", "DefaultEObjectLabelProvider", "{", "@", "Inject", "public", "DotLabelProvider", "(", "AdapterFactoryLabelProvider", "delegate", ")", "{", "super", "(", "delegate", ")", ";", "}", "}", "</s>" ]
10,177
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "internal", ".", "dot", ".", "parser", ".", "ui", ".", "labeling", ";", "import", "org", ".", "eclipse", ".", "xtext", ".", "ui", ".", "label", ".", "DefaultDescriptionLabelProvider", ";", "public", "class", "DotDescriptionLabelProvider", "extends", "DefaultDescriptionLabelProvider", "{", "}", "</s>" ]
10,178
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "internal", ".", "dot", ".", "parser", ".", "ui", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "plugin", ".", "AbstractUIPlugin", ";", "public", "class", "DotUiModule", "extends", "org", ".", "eclipse", ".", "zest", ".", "internal", ".", "dot", ".", "parser", ".", "ui", ".", "AbstractDotUiModule", "{", "public", "DotUiModule", "(", "AbstractUIPlugin", "plugin", ")", "{", "super", "(", "plugin", ")", ";", "}", "}", "</s>" ]
10,179
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "internal", ".", "dot", ".", "parser", ".", "ui", ".", "outline", ";", "import", "org", ".", "eclipse", ".", "xtext", ".", "ui", ".", "editor", ".", "outline", ".", "impl", ".", "DefaultOutlineTreeProvider", ";", "public", "class", "DotOutlineTreeProvider", "extends", "DefaultOutlineTreeProvider", "{", "}", "</s>" ]
10,180
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "internal", ".", "dot", ".", "parser", ".", "ui", ".", "contentassist", ";", "public", "class", "DotProposalProvider", "extends", "AbstractDotProposalProvider", "{", "}", "</s>" ]
10,181
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "internal", ".", "dot", ".", "parser", ".", "ui", ".", "quickfix", ";", "import", "org", ".", "eclipse", ".", "xtext", ".", "ui", ".", "editor", ".", "quickfix", ".", "DefaultQuickfixProvider", ";", "public", "class", "DotQuickfixProvider", "extends", "DefaultQuickfixProvider", "{", "}", "</s>" ]
10,182
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "internal", ".", "dot", ";", "import", "java", ".", "io", ".", "File", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "dialogs", ".", "MessageDialog", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "DirectoryDialog", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "IWorkbenchWindow", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "PlatformUI", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "DotUiMessages", ";", "public", "final", "class", "DotDirStore", "{", "private", "DotDirStore", "(", ")", "{", "}", "public", "static", "final", "String", "DOTPATH_KEY", "=", "DotUiActivator", ".", "PLUGIN_ID", "+", "\".dotpath\"", ";", "private", "enum", "Caption", "{", "DOT_SELECT_SHORT", "(", "DotUiMessages", ".", "DotDirStore_0", ")", ",", "DOT_SELECT_LONG", "(", "DotUiMessages", ".", "DotDirStore_1", ")", ",", "NOT_FOUND_LONG", "(", "DotUiMessages", ".", "DotDirStore_2", ")", ",", "NOT_FOUND_SHORT", "(", "DotUiMessages", ".", "DotDirStore_3", ")", ";", "private", "String", "s", ";", "Caption", "(", "final", "String", "s", ")", "{", "this", ".", "s", "=", "s", ";", "}", "}", "public", "static", "String", "getDotDirPath", "(", ")", "{", "if", "(", "dotPathFromPreferences", "(", ")", ".", "length", "(", ")", "==", "0", ")", "{", "setDotDirPath", "(", ")", ";", "}", "return", "dotPathFromPreferences", "(", ")", ";", "}", "public", "static", "void", "setDotDirPath", "(", ")", "{", "IWorkbenchWindow", "parent", "=", "PlatformUI", ".", "getWorkbench", "(", ")", ".", "getActiveWorkbenchWindow", "(", ")", ";", "DirectoryDialog", "dialog", "=", "new", "DirectoryDialog", "(", "parent", ".", "getShell", "(", ")", ")", ";", "dialog", ".", "setMessage", "(", "Caption", ".", "DOT_SELECT_LONG", ".", "s", ")", ";", "dialog", ".", "setText", "(", "Caption", ".", "DOT_SELECT_SHORT", ".", "s", ")", ";", "processUserInput", "(", "parent", ",", "dialog", ")", ";", "}", "private", "static", "void", "processUserInput", "(", "final", "IWorkbenchWindow", "parent", ",", "final", "DirectoryDialog", "dialog", ")", "{", "String", "selectedPath", "=", "dialog", ".", "open", "(", ")", ";", "if", "(", "selectedPath", "!=", "null", ")", "{", "if", "(", "!", "containsDot", "(", "new", "File", "(", "selectedPath", ")", ")", ")", "{", "MessageDialog", ".", "openError", "(", "parent", ".", "getShell", "(", ")", ",", "Caption", ".", "NOT_FOUND_SHORT", ".", "s", ",", "Caption", ".", "NOT_FOUND_LONG", ".", "s", ")", ";", "}", "else", "{", "DotUiActivator", ".", "getDefault", "(", ")", ".", "getPreferenceStore", "(", ")", ".", "setValue", "(", "DOTPATH_KEY", ",", "selectedPath", "+", "File", ".", "separator", ")", ";", "}", "}", "}", "private", "static", "boolean", "containsDot", "(", "final", "File", "folder", ")", "{", "String", "[", "]", "files", "=", "folder", ".", "list", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "files", ".", "length", ";", "i", "++", ")", "{", "if", "(", "files", "[", "i", "]", ".", "equals", "(", "\"dot\"", ")", "||", "files", "[", "i", "]", ".", "equals", "(", "\"dot.exe\"", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}", "private", "static", "String", "dotPathFromPreferences", "(", ")", "{", "return", "DotUiActivator", ".", "getDefault", "(", ")", ".", "getPreferenceStore", "(", ")", ".", "getString", "(", "DOTPATH_KEY", ")", ";", "}", "}", "</s>" ]
10,183
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "internal", ".", "dot", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "net", ".", "MalformedURLException", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "org", ".", "eclipse", ".", "core", ".", "filesystem", ".", "EFS", ";", "import", "org", ".", "eclipse", ".", "core", ".", "filesystem", ".", "IFileStore", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IFile", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IResource", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IResourceChangeEvent", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IResourceChangeListener", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IResourceDelta", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IResourceDeltaVisitor", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IWorkspace", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IWorkspaceRoot", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "IWorkspaceRunnable", ";", "import", "org", ".", "eclipse", ".", "core", ".", "resources", ".", "ResourcesPlugin", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "CoreException", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "IPath", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "IProgressMonitor", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "Path", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "Status", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "action", ".", "Action", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "action", ".", "ActionContributionItem", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "action", ".", "IContributionItem", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "action", ".", "IToolBarManager", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "action", ".", "Separator", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "dialogs", ".", "MessageDialog", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "resource", ".", "JFaceResources", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Color", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "RGB", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "layout", ".", "GridData", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "layout", ".", "GridLayout", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Composite", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Shell", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "IEditorDescriptor", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "IEditorRegistry", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "IWorkbenchPage", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "PartInitException", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "PlatformUI", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "dialogs", ".", "ResourceListSelectionDialog", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "ide", ".", "IDE", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "part", ".", "FileEditorInput", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "part", ".", "ViewPart", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "DotUiMessages", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "Graph", ";", "public", "final", "class", "ZestGraphView", "extends", "ViewPart", "{", "public", "static", "final", "String", "ID", "=", "\"\"", ";", "private", "static", "final", "RGB", "BACKGROUND", "=", "JFaceResources", ".", "getColorRegistry", "(", ")", ".", "getRGB", "(", "\"\"", ")", ";", "private", "static", "final", "String", "ADD_EXPORT_QUESTION", "=", "DotUiMessages", ".", "ZestGraphView_0", ";", "private", "static", "final", "String", "ADD_EXPORT_MESSAGE", "=", "DotUiMessages", ".", "ZestGraphView_1", "+", "DotUiMessages", ".", "ZestGraphView_2", "+", "DotUiMessages", ".", "ZestGraphView_3", ";", "private", "static", "final", "String", "LOAD", "=", "DotUiMessages", ".", "ZestGraphView_4", ";", "private", "static", "final", "String", "RESET", "=", "DotUiMessages", ".", "ZestGraphView_5", ";", "private", "static", "final", "String", "LAYOUT", "=", "DotUiMessages", ".", "ZestGraphView_6", ";", "private", "static", "final", "String", "EXPORT", "=", "DotUiMessages", ".", "ZestGraphView_7", ";", "private", "static", "final", "String", "EXPORT_MODE", "=", "DotUiMessages", ".", "ZestGraphView_8", ";", "private", "static", "final", "String", "UPDATE_MODE", "=", "DotUiMessages", ".", "ZestGraphView_9", ";", "private", "static", "final", "String", "LINK_MODE", "=", "DotUiMessages", ".", "ZestGraphView_10", ";", "private", "static", "final", "String", "RESOURCES_ICONS_OPEN_GIF", "=", "\"\"", ";", "private", "static", "final", "String", "RESOURCES_ICONS_EXPORT_GIF", "=", "\"\"", ";", "private", "static", "final", "String", "RESOURCES_ICONS_RESET", "=", "\"\"", ";", "private", "static", "final", "String", "RESOURCES_ICONS_LAYOUT", "=", "\"\"", ";", "private", "static", "final", "String", "RESOURCES_ICONS_EXPORT_MODE", "=", "\"\"", ";", "private", "static", "final", "String", "RESOURCES_ICONS_UPDATE_MODE", "=", "\"\"", ";", "private", "static", "final", "String", "RESOURCES_ICONS_LINK_MODE", "=", "\"\"", ";", "private", "static", "final", "String", "EXTENSION", "=", "\"dot\"", ";", "private", "static", "final", "String", "FORMAT_PDF", "=", "\"pdf\"", ";", "private", "static", "final", "String", "FORMAT_PNG", "=", "\"png\"", ";", "private", "boolean", "exportFromZestGraph", "=", "true", ";", "private", "boolean", "listenToDotContent", "=", "false", ";", "private", "boolean", "linkImage", "=", "false", ";", "private", "Composite", "composite", ";", "private", "Graph", "graph", ";", "private", "IFile", "file", ";", "private", "String", "dotString", "=", "\"\"", ";", "private", "boolean", "addReference", "=", "true", ";", "private", "IResourceChangeListener", "resourceChangeListener", "=", "new", "IResourceChangeListener", "(", ")", "{", "public", "void", "resourceChanged", "(", "final", "IResourceChangeEvent", "event", ")", "{", "if", "(", "event", ".", "getType", "(", ")", "!=", "IResourceChangeEvent", ".", "POST_BUILD", "&&", "event", ".", "getType", "(", ")", "!=", "IResourceChangeEvent", ".", "POST_CHANGE", ")", "{", "return", ";", "}", "IResourceDelta", "rootDelta", "=", "event", ".", "getDelta", "(", ")", ";", "try", "{", "rootDelta", ".", "accept", "(", "resourceVisitor", ")", ";", "}", "catch", "(", "CoreException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "}", ";", "private", "IResourceDeltaVisitor", "resourceVisitor", "=", "new", "IResourceDeltaVisitor", "(", ")", "{", "public", "boolean", "visit", "(", "final", "IResourceDelta", "delta", ")", "{", "IResource", "resource", "=", "delta", ".", "getResource", "(", ")", ";", "if", "(", "resource", ".", "getType", "(", ")", "==", "IResource", ".", "FILE", ")", "{", "try", "{", "final", "IFile", "f", "=", "(", "IFile", ")", "resource", ";", "if", "(", "!", "listenToDotContent", "&&", "!", "f", ".", "getLocation", "(", ")", ".", "toString", "(", ")", ".", "endsWith", "(", "EXTENSION", ")", ")", "{", "return", "true", ";", "}", "IWorkspaceRunnable", "workspaceRunnable", "=", "new", "IWorkspaceRunnable", "(", ")", "{", "public", "void", "run", "(", "final", "IProgressMonitor", "monitor", ")", "throws", "CoreException", "{", "setGraph", "(", "f", ")", ";", "}", "}", ";", "IWorkspace", "workspace", "=", "ResourcesPlugin", ".", "getWorkspace", "(", ")", ";", "if", "(", "!", "workspace", ".", "isTreeLocked", "(", ")", ")", "{", "workspace", ".", "run", "(", "workspaceRunnable", ",", "null", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "return", "true", ";", "}", "}", ";", "public", "void", "createPartControl", "(", "final", "Composite", "parent", ")", "{", "composite", "=", "new", "Composite", "(", "parent", ",", "SWT", ".", "NULL", ")", ";", "GridLayout", "layout", "=", "new", "GridLayout", "(", ")", ";", "composite", ".", "setLayout", "(", "layout", ")", ";", "composite", ".", "setBackground", "(", "new", "Color", "(", "composite", ".", "getDisplay", "(", ")", ",", "BACKGROUND", ")", ")", ";", "if", "(", "file", "!=", "null", ")", "{", "try", "{", "updateGraph", "(", ")", ";", "}", "catch", "(", "MalformedURLException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "addUpdateModeButton", "(", ")", ";", "addLoadButton", "(", ")", ";", "addLayoutButton", "(", ")", ";", "addResetButton", "(", ")", ";", "addExportModeButton", "(", ")", ";", "addExportButton", "(", ")", ";", "addLinkModeButton", "(", ")", ";", "}", "public", "Graph", "getGraph", "(", ")", "{", "return", "graph", ";", "}", "public", "void", "setGraph", "(", "final", "String", "dot", ",", "boolean", "async", ")", "{", "dotString", "=", "dot", ";", "Runnable", "runnable", "=", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "updateZestGraph", "(", "dot", ")", ";", "}", "private", "void", "updateZestGraph", "(", "final", "String", "currentDot", ")", "{", "if", "(", "graph", "!=", "null", ")", "{", "graph", ".", "dispose", "(", ")", ";", "}", "if", "(", "composite", "!=", "null", ")", "{", "DotImport", "dotImport", "=", "new", "DotImport", "(", "dotString", ")", ";", "if", "(", "dotImport", ".", "getErrors", "(", ")", ".", "size", "(", ")", ">", "0", ")", "{", "String", "message", "=", "String", ".", "format", "(", "\"\"", ",", "dotImport", ".", "getErrors", "(", ")", ",", "dotString", ")", ";", "DotUiActivator", ".", "getDefault", "(", ")", ".", "getLog", "(", ")", ".", "log", "(", "new", "Status", "(", "Status", ".", "ERROR", ",", "DotUiActivator", ".", "PLUGIN_ID", ",", "message", ")", ")", ";", "return", ";", "}", "graph", "=", "dotImport", ".", "newGraphInstance", "(", "composite", ",", "SWT", ".", "NONE", ")", ";", "setupLayout", "(", ")", ";", "composite", ".", "layout", "(", ")", ";", "graph", ".", "applyLayout", "(", ")", ";", "}", "handleWikiText", "(", "currentDot", ")", ";", "linkCorrespondingImage", "(", ")", ";", "}", "}", ";", "Display", "display", "=", "getViewSite", "(", ")", ".", "getShell", "(", ")", ".", "getDisplay", "(", ")", ";", "if", "(", "async", ")", "{", "display", ".", "asyncExec", "(", "runnable", ")", ";", "}", "else", "{", "display", ".", "syncExec", "(", "runnable", ")", ";", "}", "}", "protected", "void", "linkCorrespondingImage", "(", ")", "{", "boolean", "canExportFromZest", "=", "exportFromZestGraph", "&&", "graph", "!=", "null", ";", "boolean", "canExportFromDot", "=", "!", "exportFromZestGraph", "&&", "dotString", "!=", "null", ";", "if", "(", "linkImage", "&&", "(", "canExportFromZest", "||", "canExportFromDot", ")", ")", "{", "File", "image", "=", "generateImageFromGraph", "(", "true", ",", "FORMAT_PNG", ")", ";", "openFile", "(", "image", ")", ";", "}", "}", "private", "void", "addUpdateModeButton", "(", ")", "{", "Action", "toggleUpdateModeAction", "=", "new", "Action", "(", "UPDATE_MODE", ",", "SWT", ".", "TOGGLE", ")", "{", "public", "void", "run", "(", ")", "{", "listenToDotContent", "=", "toggle", "(", "this", ",", "listenToDotContent", ")", ";", "toggleResourceListener", "(", ")", ";", "}", "private", "void", "toggleResourceListener", "(", ")", "{", "IWorkspace", "workspace", "=", "ResourcesPlugin", ".", "getWorkspace", "(", ")", ";", "if", "(", "listenToDotContent", ")", "{", "workspace", ".", "addResourceChangeListener", "(", "resourceChangeListener", ",", "IResourceChangeEvent", ".", "POST_BUILD", "|", "IResourceChangeEvent", ".", "POST_CHANGE", ")", ";", "}", "else", "{", "workspace", ".", "removeResourceChangeListener", "(", "resourceChangeListener", ")", ";", "}", "}", "}", ";", "toggleUpdateModeAction", ".", "setId", "(", "toggleUpdateModeAction", ".", "getText", "(", ")", ")", ";", "toggleUpdateModeAction", ".", "setImageDescriptor", "(", "DotUiActivator", ".", "getImageDescriptor", "(", "RESOURCES_ICONS_UPDATE_MODE", ")", ")", ";", "IToolBarManager", "mgr", "=", "getViewSite", "(", ")", ".", "getActionBars", "(", ")", ".", "getToolBarManager", "(", ")", ";", "mgr", ".", "add", "(", "toggleUpdateModeAction", ")", ";", "}", "private", "void", "addExportModeButton", "(", ")", "{", "Action", "toggleRenderingAction", "=", "new", "Action", "(", "EXPORT_MODE", ",", "SWT", ".", "TOGGLE", ")", "{", "public", "void", "run", "(", ")", "{", "exportFromZestGraph", "=", "toggle", "(", "this", ",", "exportFromZestGraph", ")", ";", "}", "}", ";", "toggleRenderingAction", ".", "setId", "(", "toggleRenderingAction", ".", "getText", "(", ")", ")", ";", "toggleRenderingAction", ".", "setImageDescriptor", "(", "DotUiActivator", ".", "getImageDescriptor", "(", "RESOURCES_ICONS_EXPORT_MODE", ")", ")", ";", "IToolBarManager", "mgr", "=", "getViewSite", "(", ")", ".", "getActionBars", "(", ")", ".", "getToolBarManager", "(", ")", ";", "mgr", ".", "add", "(", "toggleRenderingAction", ")", ";", "}", "private", "boolean", "toggle", "(", "Action", "action", ",", "boolean", "input", ")", "{", "action", ".", "setChecked", "(", "!", "action", ".", "isChecked", "(", ")", ")", ";", "IToolBarManager", "mgr", "=", "getViewSite", "(", ")", ".", "getActionBars", "(", ")", ".", "getToolBarManager", "(", ")", ";", "for", "(", "IContributionItem", "item", ":", "mgr", ".", "getItems", "(", ")", ")", "{", "if", "(", "item", ".", "getId", "(", ")", "!=", "null", "&&", "item", ".", "getId", "(", ")", ".", "equals", "(", "action", ".", "getText", "(", ")", ")", ")", "{", "ActionContributionItem", "i", "=", "(", "ActionContributionItem", ")", "item", ";", "i", ".", "getAction", "(", ")", ".", "setChecked", "(", "!", "i", ".", "getAction", "(", ")", ".", "isChecked", "(", ")", ")", ";", "return", "!", "input", ";", "}", "}", "return", "input", ";", "}", "private", "void", "addLayoutButton", "(", ")", "{", "Action", "layoutAction", "=", "new", "Action", "(", "LAYOUT", ")", "{", "public", "void", "run", "(", ")", "{", "if", "(", "graph", "!=", "null", ")", "{", "graph", ".", "applyLayout", "(", ")", ";", "}", "}", "}", ";", "layoutAction", ".", "setImageDescriptor", "(", "DotUiActivator", ".", "getImageDescriptor", "(", "RESOURCES_ICONS_LAYOUT", ")", ")", ";", "IToolBarManager", "mgr", "=", "getViewSite", "(", ")", ".", "getActionBars", "(", ")", ".", "getToolBarManager", "(", ")", ";", "mgr", ".", "add", "(", "layoutAction", ")", ";", "mgr", ".", "add", "(", "new", "Separator", "(", ")", ")", ";", "}", "private", "void", "addExportButton", "(", ")", "{", "Action", "exportAction", "=", "new", "Action", "(", "EXPORT", ")", "{", "public", "void", "run", "(", ")", "{", "if", "(", "(", "exportFromZestGraph", "&&", "graph", "!=", "null", ")", "||", "(", "!", "exportFromZestGraph", "&&", "dotString", "!=", "null", ")", ")", "{", "File", "image", "=", "generateImageFromGraph", "(", "true", ",", "FORMAT_PDF", ")", ";", "openFile", "(", "image", ")", ";", "}", "}", "}", ";", "exportAction", ".", "setImageDescriptor", "(", "DotUiActivator", ".", "getImageDescriptor", "(", "RESOURCES_ICONS_EXPORT_GIF", ")", ")", ";", "getViewSite", "(", ")", ".", "getActionBars", "(", ")", ".", "getToolBarManager", "(", ")", ".", "add", "(", "exportAction", ")", ";", "}", "private", "void", "openFile", "(", "File", "file", ")", "{", "if", "(", "this", ".", "file", "==", "null", ")", "{", "IFileStore", "fileStore", "=", "EFS", ".", "getLocalFileSystem", "(", ")", ".", "getStore", "(", "new", "Path", "(", "\"\"", ")", ")", ";", "fileStore", "=", "fileStore", ".", "getChild", "(", "file", ".", "getAbsolutePath", "(", ")", ")", ";", "if", "(", "!", "fileStore", ".", "fetchInfo", "(", ")", ".", "isDirectory", "(", ")", "&&", "fileStore", ".", "fetchInfo", "(", ")", ".", "exists", "(", ")", ")", "{", "IWorkbenchPage", "page", "=", "getSite", "(", ")", ".", "getPage", "(", ")", ";", "try", "{", "IDE", ".", "openEditorOnFileStore", "(", "page", ",", "fileStore", ")", ";", "}", "catch", "(", "PartInitException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "}", "else", "{", "IWorkspace", "workspace", "=", "ResourcesPlugin", ".", "getWorkspace", "(", ")", ";", "IPath", "location", "=", "Path", ".", "fromOSString", "(", "file", ".", "getAbsolutePath", "(", ")", ")", ";", "IFile", "copy", "=", "workspace", ".", "getRoot", "(", ")", ".", "getFileForLocation", "(", "location", ")", ";", "IEditorRegistry", "registry", "=", "PlatformUI", ".", "getWorkbench", "(", ")", ".", "getEditorRegistry", "(", ")", ";", "if", "(", "registry", ".", "isSystemExternalEditorAvailable", "(", "copy", ".", "getName", "(", ")", ")", ")", "{", "try", "{", "getViewSite", "(", ")", ".", "getPage", "(", ")", ".", "openEditor", "(", "new", "FileEditorInput", "(", "copy", ")", ",", "IEditorRegistry", ".", "SYSTEM_EXTERNAL_EDITOR_ID", ")", ";", "}", "catch", "(", "PartInitException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "}", "}", "private", "void", "addLinkModeButton", "(", ")", "{", "Action", "linkModeAction", "=", "new", "Action", "(", "LINK_MODE", ",", "SWT", ".", "TOGGLE", ")", "{", "public", "void", "run", "(", ")", "{", "linkImage", "=", "toggle", "(", "this", ",", "linkImage", ")", ";", "}", "}", ";", "linkModeAction", ".", "setId", "(", "linkModeAction", ".", "getText", "(", ")", ")", ";", "linkModeAction", ".", "setImageDescriptor", "(", "DotUiActivator", ".", "getImageDescriptor", "(", "RESOURCES_ICONS_LINK_MODE", ")", ")", ";", "getViewSite", "(", ")", ".", "getActionBars", "(", ")", ".", "getToolBarManager", "(", ")", ".", "add", "(", "linkModeAction", ")", ";", "}", "private", "void", "addResetButton", "(", ")", "{", "Action", "resetAction", "=", "new", "Action", "(", "RESET", ")", "{", "public", "void", "run", "(", ")", "{", "DotDirStore", ".", "setDotDirPath", "(", ")", ";", "}", "}", ";", "resetAction", ".", "setImageDescriptor", "(", "DotUiActivator", ".", "getImageDescriptor", "(", "RESOURCES_ICONS_RESET", ")", ")", ";", "getViewSite", "(", ")", ".", "getActionBars", "(", ")", ".", "getToolBarManager", "(", ")", ".", "add", "(", "resetAction", ")", ";", "}", "private", "void", "addLoadButton", "(", ")", "{", "Action", "loadAction", "=", "new", "Action", "(", "LOAD", ")", "{", "public", "void", "run", "(", ")", "{", "Shell", "shell", "=", "PlatformUI", ".", "getWorkbench", "(", ")", ".", "getActiveWorkbenchWindow", "(", ")", ".", "getShell", "(", ")", ";", "IWorkspaceRoot", "root", "=", "ResourcesPlugin", ".", "getWorkspace", "(", ")", ".", "getRoot", "(", ")", ";", "ResourceListSelectionDialog", "dialog", "=", "new", "ResourceListSelectionDialog", "(", "shell", ",", "root", ",", "IResource", ".", "FILE", ")", ";", "if", "(", "dialog", ".", "open", "(", ")", "==", "ResourceListSelectionDialog", ".", "OK", ")", "{", "Object", "[", "]", "selected", "=", "dialog", ".", "getResult", "(", ")", ";", "if", "(", "selected", "!=", "null", ")", "{", "file", "=", "(", "IFile", ")", "selected", "[", "0", "]", ";", "setGraph", "(", "file", ")", ";", "}", "}", "}", "}", ";", "loadAction", ".", "setImageDescriptor", "(", "DotUiActivator", ".", "getImageDescriptor", "(", "RESOURCES_ICONS_OPEN_GIF", ")", ")", ";", "getViewSite", "(", ")", ".", "getActionBars", "(", ")", ".", "getToolBarManager", "(", ")", ".", "add", "(", "loadAction", ")", ";", "}", "private", "void", "setGraph", "(", "final", "IFile", "file", ")", "{", "this", ".", "file", "=", "file", ";", "try", "{", "updateGraph", "(", ")", ";", "}", "catch", "(", "MalformedURLException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "private", "void", "updateGraph", "(", ")", "throws", "MalformedURLException", "{", "if", "(", "file", "==", "null", "||", "file", ".", "getLocationURI", "(", ")", "==", "null", "||", "!", "file", ".", "exists", "(", ")", ")", "{", "return", ";", "}", "final", "String", "currentDot", "=", "dotExtraction", "(", ")", "?", "new", "DotExtractor", "(", "file", ")", ".", "getDotString", "(", ")", ":", "DotFileUtils", ".", "read", "(", "DotFileUtils", ".", "resolve", "(", "file", ".", "getLocationURI", "(", ")", ".", "toURL", "(", ")", ")", ")", ";", "if", "(", "currentDot", ".", "equals", "(", "dotString", ")", "||", "currentDot", ".", "equals", "(", "DotExtractor", ".", "NO_DOT", ")", ")", "{", "return", ";", "}", "setGraph", "(", "currentDot", ",", "true", ")", ";", "}", "private", "boolean", "dotExtraction", "(", ")", "{", "return", "!", "file", ".", "getName", "(", ")", ".", "endsWith", "(", "EXTENSION", ")", ";", "}", "private", "void", "handleWikiText", "(", "final", "String", "dot", ")", "{", "if", "(", "file", "==", "null", ")", "{", "return", ";", "}", "try", "{", "IEditorDescriptor", "editor", "=", "IDE", ".", "getEditorDescriptor", "(", "file", ")", ";", "if", "(", "editor", ".", "getId", "(", ")", ".", "equals", "(", "\"\"", ")", ")", "{", "try", "{", "File", "image", "=", "generateImageFromGraph", "(", "true", ",", "FORMAT_PNG", ")", ";", "File", "wikiFile", "=", "DotFileUtils", ".", "resolve", "(", "file", ".", "getLocationURI", "(", ")", ".", "toURL", "(", ")", ")", ";", "String", "imageLinkWiki", "=", "createImageLinkMarkup", "(", "image", ")", ";", "if", "(", "!", "DotFileUtils", ".", "read", "(", "wikiFile", ")", ".", "contains", "(", "imageLinkWiki", ")", "&&", "addReference", "&&", "supported", "(", "file", ")", ")", "{", "String", "message", "=", "String", ".", "format", "(", "ADD_EXPORT_MESSAGE", ",", "file", ".", "getName", "(", ")", ")", ";", "if", "(", "MessageDialog", ".", "openQuestion", "(", "getSite", "(", ")", ".", "getShell", "(", ")", ",", "ADD_EXPORT_QUESTION", ",", "message", ")", ")", "{", "addReference", "(", "dot", ",", "wikiFile", ",", "imageLinkWiki", ")", ";", "}", "else", "{", "addReference", "=", "false", ";", "}", "}", "refreshParent", "(", "file", ")", ";", "}", "catch", "(", "MalformedURLException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "}", "catch", "(", "PartInitException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "private", "boolean", "supported", "(", "final", "IFile", "wikiFile", ")", "{", "return", "wikiFile", ".", "getFileExtension", "(", ")", ".", "endsWith", "(", "\"textile\"", ")", ";", "}", "private", "String", "createImageLinkMarkup", "(", "final", "File", "image", ")", "{", "return", "String", ".", "format", "(", "\"n!%s!n\"", ",", "image", ".", "getName", "(", ")", ")", ";", "}", "private", "void", "addReference", "(", "final", "String", "dot", ",", "final", "File", "wikiFile", ",", "final", "String", "imageLinkWiki", ")", "{", "String", "content", "=", "DotFileUtils", ".", "read", "(", "wikiFile", ")", ".", "replace", "(", "dot", ",", "dot", "+", "\"n\"", "+", "imageLinkWiki", ")", ";", "DotFileUtils", ".", "write", "(", "content", ",", "wikiFile", ")", ";", "}", "private", "void", "setupLayout", "(", ")", "{", "if", "(", "graph", "!=", "null", ")", "{", "GridData", "gd", "=", "new", "GridData", "(", "GridData", ".", "FILL_BOTH", ")", ";", "graph", ".", "setLayout", "(", "new", "GridLayout", "(", ")", ")", ";", "graph", ".", "setLayoutData", "(", "gd", ")", ";", "Color", "color", "=", "new", "Color", "(", "graph", ".", "getDisplay", "(", ")", ",", "BACKGROUND", ")", ";", "graph", ".", "setBackground", "(", "color", ")", ";", "graph", ".", "getParent", "(", ")", ".", "setBackground", "(", "color", ")", ";", "}", "}", "private", "File", "generateImageFromGraph", "(", "final", "boolean", "refresh", ",", "final", "String", "format", ")", "{", "DotExport", "dotExport", "=", "exportFromZestGraph", "?", "new", "DotExport", "(", "graph", ")", ":", "new", "DotExport", "(", "dotString", ")", ";", "File", "image", "=", "dotExport", ".", "toImage", "(", "DotDirStore", ".", "getDotDirPath", "(", ")", ",", "format", ",", "null", ")", ";", "if", "(", "file", "==", "null", ")", "{", "return", "image", ";", "}", "try", "{", "URL", "url", "=", "file", ".", "getParent", "(", ")", ".", "getLocationURI", "(", ")", ".", "toURL", "(", ")", ";", "File", "copy", "=", "DotFileUtils", ".", "copySingleFile", "(", "DotFileUtils", ".", "resolve", "(", "url", ")", ",", "file", ".", "getName", "(", ")", "+", "\".\"", "+", "format", ",", "image", ")", ";", "return", "copy", ";", "}", "catch", "(", "MalformedURLException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "if", "(", "refresh", ")", "{", "refreshParent", "(", "file", ")", ";", "}", "return", "image", ";", "}", "private", "void", "refreshParent", "(", "final", "IFile", "file", ")", "{", "try", "{", "file", ".", "getParent", "(", ")", ".", "refreshLocal", "(", "IResource", ".", "DEPTH_ONE", ",", "null", ")", ";", "}", "catch", "(", "CoreException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "public", "void", "dispose", "(", ")", "{", "super", ".", "dispose", "(", ")", ";", "ResourcesPlugin", ".", "getWorkspace", "(", ")", ".", "removeResourceChangeListener", "(", "resourceChangeListener", ")", ";", "if", "(", "graph", "!=", "null", ")", "{", "graph", ".", "dispose", "(", ")", ";", "}", "if", "(", "composite", "!=", "null", ")", "{", "composite", ".", "dispose", "(", ")", ";", "}", "}", "public", "void", "setFocus", "(", ")", "{", "if", "(", "graph", "!=", "null", "&&", "!", "graph", ".", "isDisposed", "(", ")", ")", "{", "graph", ".", "setFocus", "(", ")", ";", "}", "}", "}", "</s>" ]
10,184
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "internal", ".", "dot", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "resource", ".", "ImageDescriptor", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "plugin", ".", "AbstractUIPlugin", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "internal", ".", "dot", ".", "parser", ".", "DotParserActivator", ";", "import", "org", ".", "osgi", ".", "framework", ".", "BundleContext", ";", "public", "final", "class", "DotUiActivator", "extends", "AbstractUIPlugin", "{", "public", "static", "final", "String", "PLUGIN_ID", "=", "\"\"", ";", "private", "static", "DotUiActivator", "plugin", ";", "private", "DotParserActivator", "parserActivator", ";", "public", "DotUiActivator", "(", ")", "{", "parserActivator", "=", "new", "DotParserActivator", "(", ")", ";", "}", "public", "void", "start", "(", "final", "BundleContext", "context", ")", "throws", "Exception", "{", "super", ".", "start", "(", "context", ")", ";", "parserActivator", ".", "start", "(", "context", ")", ";", "plugin", "=", "this", ";", "}", "public", "void", "stop", "(", "final", "BundleContext", "context", ")", "throws", "Exception", "{", "plugin", "=", "null", ";", "super", ".", "stop", "(", "context", ")", ";", "parserActivator", ".", "stop", "(", "context", ")", ";", "}", "public", "static", "DotUiActivator", "getDefault", "(", ")", "{", "return", "plugin", ";", "}", "public", "static", "ImageDescriptor", "getImageDescriptor", "(", "final", "String", "path", ")", "{", "return", "AbstractUIPlugin", ".", "imageDescriptorFromPlugin", "(", "PLUGIN_ID", ",", "path", ")", ";", "}", "}", "</s>" ]
10,185
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ";", "import", "org", ".", "eclipse", ".", "osgi", ".", "util", ".", "NLS", ";", "public", "class", "DotUiMessages", "extends", "NLS", "{", "private", "static", "final", "String", "BUNDLE_NAME", "=", "\"\"", ";", "public", "static", "String", "DotDirStore_0", ";", "public", "static", "String", "DotDirStore_1", ";", "public", "static", "String", "DotDirStore_2", ";", "public", "static", "String", "DotDirStore_3", ";", "public", "static", "String", "ZestGraphWizard_0", ";", "public", "static", "String", "ZestGraphWizard_1", ";", "public", "static", "String", "ZestGraphWizard_2", ";", "public", "static", "String", "ZestGraphWizard_3", ";", "public", "static", "String", "ZestGraphWizard_4", ";", "public", "static", "String", "ZestGraphWizard_5", ";", "public", "static", "String", "DotExtractor_0", ";", "public", "static", "String", "GraphWizardPageTemplateSelection_0", ";", "public", "static", "String", "GraphWizardPageTemplateSelection_1", ";", "public", "static", "String", "GraphWizardPageTemplateSelection_2", ";", "public", "static", "String", "GraphWizardPageTemplateSelection_3", ";", "public", "static", "String", "GraphWizardPageTemplateSelection_4", ";", "public", "static", "String", "GraphWizardPageTemplateSelection_5", ";", "public", "static", "String", "GraphWizardPageTemplateSelection_6", ";", "public", "static", "String", "GraphWizardPageTemplateSelection_7", ";", "public", "static", "String", "GraphWizardPageTemplateSelection_8", ";", "public", "static", "String", "GraphWizardPageTemplateSelection_9", ";", "public", "static", "String", "GraphWizardPageTemplateSelection_10", ";", "public", "static", "String", "ZestGraphView_0", ";", "public", "static", "String", "ZestGraphView_1", ";", "public", "static", "String", "ZestGraphView_2", ";", "public", "static", "String", "ZestGraphView_3", ";", "public", "static", "String", "ZestGraphView_4", ";", "public", "static", "String", "ZestGraphView_5", ";", "public", "static", "String", "ZestGraphView_6", ";", "public", "static", "String", "ZestGraphView_7", ";", "public", "static", "String", "ZestGraphView_8", ";", "public", "static", "String", "ZestGraphView_9", ";", "public", "static", "String", "ZestGraphView_10", ";", "public", "static", "String", "ZestGraphWizardPageCustomize_0", ";", "public", "static", "String", "ZestGraphWizardPageCustomize_1", ";", "public", "static", "String", "ZestGraphWizardPageCustomize_2", ";", "public", "static", "String", "ZestProjectWizard_0", ";", "public", "static", "String", "ZestProjectWizard_1", ";", "public", "static", "String", "ZestProjectWizard_2", ";", "public", "static", "String", "ZestProjectWizard_3", ";", "public", "static", "String", "ZestProjectWizard_4", ";", "public", "static", "String", "ZestProjectWizard_5", ";", "public", "static", "String", "ZestProjectWizard_6", ";", "public", "static", "String", "ZestProjectWizard_7", ";", "static", "{", "NLS", ".", "initializeMessages", "(", "BUNDLE_NAME", ",", "DotUiMessages", ".", "class", ")", ";", "}", "private", "DotUiMessages", "(", ")", "{", "}", "}", "</s>" ]
10,186
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "cloudio", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "Collection", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "Assert", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "ColumnLabelProvider", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "IStructuredSelection", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "ITreeContentProvider", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "TreeViewer", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "Viewer", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionListener", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Color", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "FontData", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "GC", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Image", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "RGB", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "layout", ".", "GridData", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "layout", ".", "GridLayout", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "layout", ".", "RowLayout", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Button", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "ColorDialog", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Combo", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Composite", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "FontDialog", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Group", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Label", ";", "public", "class", "CloudOptionsComposite", "extends", "Composite", "{", "protected", "TagCloudViewer", "viewer", ";", "protected", "List", "<", "RGB", ">", "colors", "=", "new", "ArrayList", "<", "RGB", ">", "(", ")", ";", "protected", "List", "<", "FontData", ">", "fonts", "=", "new", "ArrayList", "<", "FontData", ">", "(", ")", ";", "protected", "List", "<", "List", "<", "RGB", ">", ">", "colorSchemes", "=", "new", "ArrayList", "<", "List", "<", "RGB", ">", ">", "(", ")", ";", "protected", "int", "currentScheme", ";", "private", "static", "class", "ListContentProvider", "implements", "ITreeContentProvider", "{", "@", "Override", "public", "void", "dispose", "(", ")", "{", "}", "@", "Override", "public", "void", "inputChanged", "(", "Viewer", "viewer", ",", "Object", "oldInput", ",", "Object", "newInput", ")", "{", "}", "@", "Override", "public", "Object", "[", "]", "getElements", "(", "Object", "inputElement", ")", "{", "return", "(", "(", "List", "<", "?", ">", ")", "inputElement", ")", ".", "toArray", "(", ")", ";", "}", "@", "Override", "public", "Object", "[", "]", "getChildren", "(", "Object", "parentElement", ")", "{", "return", "null", ";", "}", "@", "Override", "public", "Object", "getParent", "(", "Object", "element", ")", "{", "return", "null", ";", "}", "@", "Override", "public", "boolean", "hasChildren", "(", "Object", "element", ")", "{", "return", "false", ";", "}", "}", "public", "CloudOptionsComposite", "(", "Composite", "parent", ",", "int", "style", ",", "TagCloudViewer", "viewer", ")", "{", "super", "(", "parent", ",", "style", ")", ";", "Assert", ".", "isLegal", "(", "viewer", ".", "getLabelProvider", "(", ")", "instanceof", "IEditableCloudLabelProvider", ",", "\"\"", "+", "IEditableCloudLabelProvider", ".", "class", ")", ";", "this", ".", "viewer", "=", "viewer", ";", "setLayout", "(", "new", "GridLayout", "(", ")", ")", ";", "addGroups", "(", ")", ";", "}", "protected", "void", "addGroups", "(", ")", "{", "addLayoutButtons", "(", "this", ")", ";", "addColorButtons", "(", "this", ")", ";", "addFontButtons", "(", "this", ")", ";", "}", "protected", "void", "addScheme", "(", "RGB", "...", "rgbs", ")", "{", "List", "<", "RGB", ">", "colors", "=", "new", "ArrayList", "<", "RGB", ">", "(", ")", ";", "for", "(", "RGB", "rgb", ":", "rgbs", ")", "{", "colors", ".", "add", "(", "rgb", ")", ";", "}", "colorSchemes", ".", "add", "(", "colors", ")", ";", "}", "protected", "void", "updateColors", "(", ")", "{", "IEditableCloudLabelProvider", "lp", "=", "(", "IEditableCloudLabelProvider", ")", "viewer", ".", "getLabelProvider", "(", ")", ";", "lp", ".", "setColors", "(", "colors", ")", ";", "List", "<", "Word", ">", "words", "=", "viewer", ".", "getCloud", "(", ")", ".", "getWords", "(", ")", ";", "for", "(", "Word", "word", ":", "words", ")", "{", "word", ".", "setColor", "(", "lp", ".", "getColor", "(", "word", ".", "data", ")", ")", ";", "}", "viewer", ".", "getCloud", "(", ")", ".", "redrawTextLayerImage", "(", ")", ";", "}", "protected", "void", "updateFonts", "(", ")", "{", "IEditableCloudLabelProvider", "lp", "=", "(", "IEditableCloudLabelProvider", ")", "viewer", ".", "getLabelProvider", "(", ")", ";", "lp", ".", "setFonts", "(", "fonts", ")", ";", "}", "protected", "void", "initColors", "(", ")", "{", "addScheme", "(", "new", "RGB", "(", "222", ",", "177", ",", "17", ")", ",", "new", "RGB", "(", "97", ",", "28", ",", "24", ")", ",", "new", "RGB", "(", "102", ",", "109", ",", "17", ")", ",", "new", "RGB", "(", "189", ",", "112", ",", "20", ")", ",", "new", "RGB", "(", "111", ",", "92", ",", "16", ")", ",", "new", "RGB", "(", "111", ",", "32", ",", "27", ")", ")", ";", "addScheme", "(", "new", "RGB", "(", "1", ",", "175", ",", "255", ")", ",", "new", "RGB", "(", "57", ",", "99", ",", "213", ")", ",", "new", "RGB", "(", "21", ",", "49", ",", "213", ")", ",", "new", "RGB", "(", "30", ",", "125", ",", "42", ")", ")", ";", "addScheme", "(", "new", "RGB", "(", "255", ",", "92", ",", "93", ")", ",", "new", "RGB", "(", "255", ",", "0", ",", "0", ")", ",", "new", "RGB", "(", "255", ",", "41", ",", "43", ")", ",", "new", "RGB", "(", "182", ",", "31", ",", "32", ")", ",", "new", "RGB", "(", "153", ",", "0", ",", "0", ")", ")", ";", "addScheme", "(", "new", "RGB", "(", "255", ",", "157", ",", "0", ")", ",", "new", "RGB", "(", "255", ",", "206", ",", "0", ")", ",", "new", "RGB", "(", "40", ",", "0", ",", "159", ")", ",", "new", "RGB", "(", "0", ",", "41", ",", "156", ")", ")", ";", "addScheme", "(", "new", "RGB", "(", "255", ",", "46", ",", "0", ")", ",", "new", "RGB", "(", "255", ",", "255", ",", "14", ")", ",", "new", "RGB", "(", "183", ",", "183", ",", "183", ")", ",", "new", "RGB", "(", "122", ",", "122", ",", "122", ")", ",", "new", "RGB", "(", "81", ",", "81", ",", "81", ")", ",", "new", "RGB", "(", "61", ",", "61", ",", "61", ")", ",", "new", "RGB", "(", "165", ",", "165", ",", "165", ")", ")", ";", "addScheme", "(", "new", "RGB", "(", "255", ",", "0", ",", "206", ")", ",", "new", "RGB", "(", "255", ",", "220", ",", "0", ")", ",", "new", "RGB", "(", "0", ",", "255", ",", "42", ")", ")", ";", "addScheme", "(", "new", "RGB", "(", "89", ",", "79", ",", "69", ")", ",", "new", "RGB", "(", "168", ",", "165", ",", "126", ")", ",", "new", "RGB", "(", "68", ",", "49", ",", "14", ")", ",", "new", "RGB", "(", "86", ",", "68", ",", "34", ")", ",", "new", "RGB", "(", "148", ",", "141", ",", "129", ")", ",", "new", "RGB", "(", "92", ",", "90", ",", "41", ")", ")", ";", "addScheme", "(", "new", "RGB", "(", "66", ",", "71", ",", "37", ")", ",", "new", "RGB", "(", "85", ",", "122", ",", "18", ")", ",", "new", "RGB", "(", "117", ",", "131", ",", "49", ")", ",", "new", "RGB", "(", "49", ",", "45", ",", "17", ")", ")", ";", "addScheme", "(", "new", "RGB", "(", "254", ",", "213", ",", "44", ")", ",", "new", "RGB", "(", "255", ",", "177", ",", "10", ")", ",", "new", "RGB", "(", "233", ",", "121", ",", "0", ")", ",", "new", "RGB", "(", "229", ",", "109", ",", "3", ")", ",", "new", "RGB", "(", "202", ",", "80", ",", "8", ")", ",", "new", "RGB", "(", "129", ",", "52", ",", "7", ")", ",", "new", "RGB", "(", "89", ",", "47", ",", "14", ")", ")", ";", "addScheme", "(", "new", "RGB", "(", "139", ",", "124", ",", "115", ")", ",", "new", "RGB", "(", "91", ",", "95", ",", "129", ")", ",", "new", "RGB", "(", "50", ",", "23", ",", "18", ")", ",", "new", "RGB", "(", "255", ",", "251", ",", "237", ")", ")", ";", "nextColors", "(", ")", ";", "}", "protected", "void", "nextColors", "(", ")", "{", "currentScheme", "=", "(", "currentScheme", "+", "1", ")", "%", "colorSchemes", ".", "size", "(", ")", ";", "colors", "=", "colorSchemes", ".", "get", "(", "currentScheme", ")", ";", "}", "protected", "Group", "addFontButtons", "(", "final", "Composite", "parent", ")", "{", "Group", "buttons", "=", "new", "Group", "(", "parent", ",", "SWT", ".", "SHADOW_IN", ")", ";", "buttons", ".", "setLayout", "(", "new", "GridLayout", "(", "2", ",", "false", ")", ")", ";", "buttons", ".", "setLayoutData", "(", "new", "GridData", "(", "SWT", ".", "FILL", ",", "SWT", ".", "TOP", ",", "true", ",", "false", ")", ")", ";", "Label", "l", "=", "new", "Label", "(", "buttons", ",", "SWT", ".", "NONE", ")", ";", "l", ".", "setText", "(", "\"Fonts\"", ")", ";", "GridData", "gd", "=", "new", "GridData", "(", ")", ";", "gd", ".", "horizontalSpan", "=", "2", ";", "l", ".", "setLayoutData", "(", "gd", ")", ";", "final", "TreeViewer", "tv", "=", "new", "TreeViewer", "(", "buttons", ")", ";", "Composite", "comp", "=", "new", "Composite", "(", "buttons", ",", "SWT", ".", "NONE", ")", ";", "comp", ".", "setLayoutData", "(", "new", "GridData", "(", "SWT", ".", "FILL", ",", "SWT", ".", "TOP", ",", "false", ",", "true", ")", ")", ";", "comp", ".", "setLayout", "(", "new", "RowLayout", "(", "SWT", ".", "VERTICAL", ")", ")", ";", "tv", ".", "getTree", "(", ")", ".", "setLayoutData", "(", "new", "GridData", "(", "SWT", ".", "FILL", ",", "SWT", ".", "FILL", ",", "true", ",", "true", ")", ")", ";", "ListContentProvider", "cp", "=", "new", "ListContentProvider", "(", ")", ";", "tv", ".", "setContentProvider", "(", "cp", ")", ";", "tv", ".", "setLabelProvider", "(", "new", "ColumnLabelProvider", "(", ")", "{", "@", "Override", "public", "String", "getText", "(", "Object", "element", ")", "{", "FontData", "fd", "=", "(", "FontData", ")", "element", ";", "return", "fd", ".", "getName", "(", ")", ";", "}", "}", ")", ";", "fonts", ".", "add", "(", "getFont", "(", ")", ".", "getFontData", "(", ")", "[", "0", "]", ")", ";", "tv", ".", "setInput", "(", "fonts", ")", ";", "Button", "add", "=", "new", "Button", "(", "comp", ",", "SWT", ".", "FLAT", ")", ";", "add", ".", "setImage", "(", "Activator", ".", "getDefault", "(", ")", ".", "getImageRegistry", "(", ")", ".", "get", "(", "Activator", ".", "ADD", ")", ")", ";", "add", ".", "setToolTipText", "(", "\"Add", "font...\"", ")", ";", "add", ".", "addSelectionListener", "(", "new", "SelectionListener", "(", ")", "{", "@", "Override", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "FontDialog", "fd", "=", "new", "FontDialog", "(", "parent", ".", "getShell", "(", ")", ")", ";", "FontData", "fontData", "=", "fd", ".", "open", "(", ")", ";", "if", "(", "fontData", "!=", "null", ")", "{", "fonts", ".", "add", "(", "fontData", ")", ";", "tv", ".", "setInput", "(", "fonts", ")", ";", "updateFonts", "(", ")", ";", "}", "}", "@", "Override", "public", "void", "widgetDefaultSelected", "(", "SelectionEvent", "e", ")", "{", "}", "}", ")", ";", "Button", "remove", "=", "new", "Button", "(", "comp", ",", "SWT", ".", "FLAT", ")", ";", "remove", ".", "setToolTipText", "(", "\"\"", ")", ";", "remove", ".", "addSelectionListener", "(", "new", "SelectionListener", "(", ")", "{", "@", "Override", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "IStructuredSelection", "selection", "=", "(", "IStructuredSelection", ")", "tv", ".", "getSelection", "(", ")", ";", "fonts", ".", "removeAll", "(", "selection", ".", "toList", "(", ")", ")", ";", "tv", ".", "setInput", "(", "fonts", ")", ";", "updateFonts", "(", ")", ";", "}", "@", "Override", "public", "void", "widgetDefaultSelected", "(", "SelectionEvent", "e", ")", "{", "}", "}", ")", ";", "remove", ".", "setImage", "(", "Activator", ".", "getDefault", "(", ")", ".", "getImageRegistry", "(", ")", ".", "get", "(", "Activator", ".", "REMOVE", ")", ")", ";", "return", "buttons", ";", "}", "protected", "Image", "createImageFromColor", "(", "RGB", "rgb", ",", "int", "size", ")", "{", "Image", "image", ";", "Color", "color", "=", "new", "Color", "(", "Display", ".", "getDefault", "(", ")", ",", "rgb", ")", ";", "image", "=", "new", "Image", "(", "Display", ".", "getDefault", "(", ")", ",", "size", ",", "size", ")", ";", "GC", "gc", "=", "new", "GC", "(", "image", ")", ";", "gc", ".", "setBackground", "(", "color", ")", ";", "gc", ".", "fillRoundRectangle", "(", "0", ",", "0", ",", "size", ",", "size", ",", "3", ",", "3", ")", ";", "color", ".", "dispose", "(", ")", ";", "gc", ".", "dispose", "(", ")", ";", "return", "image", ";", "}", "protected", "Group", "addColorButtons", "(", "final", "Composite", "parent", ")", "{", "Group", "buttons", "=", "new", "Group", "(", "parent", ",", "SWT", ".", "SHADOW_IN", ")", ";", "buttons", ".", "setLayout", "(", "new", "GridLayout", "(", "2", ",", "false", ")", ")", ";", "buttons", ".", "setLayoutData", "(", "new", "GridData", "(", "SWT", ".", "FILL", ",", "SWT", ".", "TOP", ",", "true", ",", "false", ")", ")", ";", "Label", "l", "=", "new", "Label", "(", "buttons", ",", "SWT", ".", "NONE", ")", ";", "l", ".", "setText", "(", "\"Colors\"", ")", ";", "GridData", "gd", "=", "new", "GridData", "(", ")", ";", "gd", ".", "horizontalSpan", "=", "2", ";", "l", ".", "setLayoutData", "(", "gd", ")", ";", "final", "TreeViewer", "tv", "=", "new", "TreeViewer", "(", "buttons", ")", ";", "Composite", "comp", "=", "new", "Composite", "(", "buttons", ",", "SWT", ".", "NONE", ")", ";", "comp", ".", "setLayout", "(", "new", "RowLayout", "(", "SWT", ".", "VERTICAL", ")", ")", ";", "comp", ".", "setLayoutData", "(", "new", "GridData", "(", "SWT", ".", "FILL", ",", "SWT", ".", "TOP", ",", "false", ",", "true", ")", ")", ";", "tv", ".", "getTree", "(", ")", ".", "setLayoutData", "(", "new", "GridData", "(", "SWT", ".", "FILL", ",", "SWT", ".", "FILL", ",", "true", ",", "true", ")", ")", ";", "ListContentProvider", "cp", "=", "new", "ListContentProvider", "(", ")", ";", "tv", ".", "setContentProvider", "(", "cp", ")", ";", "tv", ".", "setLabelProvider", "(", "new", "ColumnLabelProvider", "(", ")", "{", "private", "Map", "<", "Object", ",", "Image", ">", "images", "=", "new", "HashMap", "<", "Object", ",", "Image", ">", "(", ")", ";", "@", "Override", "public", "Image", "getImage", "(", "Object", "element", ")", "{", "Image", "image", "=", "images", ".", "get", "(", "element", ")", ";", "if", "(", "image", "==", "null", ")", "{", "RGB", "rgb", "=", "(", "RGB", ")", "element", ";", "image", "=", "createImageFromColor", "(", "rgb", ",", "24", ")", ";", "images", ".", "put", "(", "element", ",", "image", ")", ";", "}", "return", "image", ";", "}", "@", "Override", "public", "void", "dispose", "(", ")", "{", "Collection", "<", "Image", ">", "images", "=", "this", ".", "images", ".", "values", "(", ")", ";", "for", "(", "Image", "image", ":", "images", ")", "{", "image", ".", "dispose", "(", ")", ";", "}", "this", ".", "images", ".", "clear", "(", ")", ";", "}", "}", ")", ";", "initColors", "(", ")", ";", "tv", ".", "setInput", "(", "colors", ")", ";", "Button", "add", "=", "new", "Button", "(", "comp", ",", "SWT", ".", "FLAT", ")", ";", "add", ".", "setImage", "(", "Activator", ".", "getDefault", "(", ")", ".", "getImageRegistry", "(", ")", ".", "get", "(", "Activator", ".", "ADD", ")", ")", ";", "add", ".", "setToolTipText", "(", "\"Add", "color...\"", ")", ";", "add", ".", "addSelectionListener", "(", "new", "SelectionListener", "(", ")", "{", "@", "Override", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "ColorDialog", "cd", "=", "new", "ColorDialog", "(", "parent", ".", "getShell", "(", ")", ")", ";", "RGB", "color", "=", "cd", ".", "open", "(", ")", ";", "if", "(", "color", "!=", "null", ")", "{", "colors", ".", "add", "(", "color", ")", ";", "tv", ".", "setInput", "(", "colors", ")", ";", "updateColors", "(", ")", ";", "}", "}", "@", "Override", "public", "void", "widgetDefaultSelected", "(", "SelectionEvent", "e", ")", "{", "}", "}", ")", ";", "Button", "remove", "=", "new", "Button", "(", "comp", ",", "SWT", ".", "FLAT", ")", ";", "remove", ".", "setToolTipText", "(", "\"\"", ")", ";", "remove", ".", "addSelectionListener", "(", "new", "SelectionListener", "(", ")", "{", "@", "Override", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "IStructuredSelection", "selection", "=", "(", "IStructuredSelection", ")", "tv", ".", "getSelection", "(", ")", ";", "colors", ".", "removeAll", "(", "selection", ".", "toList", "(", ")", ")", ";", "tv", ".", "setInput", "(", "colors", ")", ";", "updateColors", "(", ")", ";", "}", "@", "Override", "public", "void", "widgetDefaultSelected", "(", "SelectionEvent", "e", ")", "{", "}", "}", ")", ";", "remove", ".", "setImage", "(", "Activator", ".", "getDefault", "(", ")", ".", "getImageRegistry", "(", ")", ".", "get", "(", "Activator", ".", "REMOVE", ")", ")", ";", "Button", "toggle", "=", "new", "Button", "(", "comp", ",", "SWT", ".", "FLAT", ")", ";", "toggle", ".", "setToolTipText", "(", "\"\"", ")", ";", "toggle", ".", "addSelectionListener", "(", "new", "SelectionListener", "(", ")", "{", "@", "Override", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "nextColors", "(", ")", ";", "tv", ".", "setInput", "(", "colors", ")", ";", "updateColors", "(", ")", ";", "}", "@", "Override", "public", "void", "widgetDefaultSelected", "(", "SelectionEvent", "e", ")", "{", "}", "}", ")", ";", "toggle", ".", "setImage", "(", "Activator", ".", "getDefault", "(", ")", ".", "getImageRegistry", "(", ")", ".", "get", "(", "Activator", ".", "TOGGLE_COLORS", ")", ")", ";", "comp", "=", "new", "Composite", "(", "buttons", ",", "SWT", ".", "NONE", ")", ";", "gd", "=", "new", "GridData", "(", "SWT", ".", "FILL", ",", "SWT", ".", "FILL", ",", "true", ",", "false", ")", ";", "gd", ".", "horizontalSpan", "=", "2", ";", "comp", ".", "setLayout", "(", "new", "GridLayout", "(", "2", ",", "true", ")", ")", ";", "comp", ".", "setLayoutData", "(", "gd", ")", ";", "final", "Button", "bg", "=", "new", "Button", "(", "comp", ",", "SWT", ".", "FLAT", ")", ";", "bg", ".", "setLayoutData", "(", "new", "GridData", "(", "SWT", ".", "FILL", ",", "SWT", ".", "FILL", ",", "true", ",", "false", ")", ")", ";", "bg", ".", "setText", "(", "\"Background\"", ")", ";", "bg", ".", "setImage", "(", "createImageFromColor", "(", "viewer", ".", "getCloud", "(", ")", ".", "getBackground", "(", ")", ".", "getRGB", "(", ")", ",", "16", ")", ")", ";", "bg", ".", "addSelectionListener", "(", "new", "SelectionListener", "(", ")", "{", "@", "Override", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "ColorDialog", "cd", "=", "new", "ColorDialog", "(", "parent", ".", "getShell", "(", ")", ")", ";", "RGB", "color", "=", "cd", ".", "open", "(", ")", ";", "if", "(", "color", "==", "null", ")", "return", ";", "Color", "old", "=", "viewer", ".", "getCloud", "(", ")", ".", "getBackground", "(", ")", ";", "Color", "c", "=", "new", "Color", "(", "Display", ".", "getDefault", "(", ")", ",", "color", ")", ";", "viewer", ".", "getCloud", "(", ")", ".", "setBackground", "(", "c", ")", ";", "old", ".", "dispose", "(", ")", ";", "viewer", ".", "getCloud", "(", ")", ".", "redrawTextLayerImage", "(", ")", ";", "Image", "oldImage", "=", "bg", ".", "getImage", "(", ")", ";", "Image", "newImage", "=", "createImageFromColor", "(", "color", ",", "16", ")", ";", "bg", ".", "setImage", "(", "newImage", ")", ";", "oldImage", ".", "dispose", "(", ")", ";", "}", "@", "Override", "public", "void", "widgetDefaultSelected", "(", "SelectionEvent", "e", ")", "{", "}", "}", ")", ";", "final", "Button", "sel", "=", "new", "Button", "(", "comp", ",", "SWT", ".", "FLAT", ")", ";", "sel", ".", "setLayoutData", "(", "new", "GridData", "(", "SWT", ".", "FILL", ",", "SWT", ".", "FILL", ",", "true", ",", "false", ")", ")", ";", "sel", ".", "setText", "(", "\"Selection\"", ")", ";", "sel", ".", "setImage", "(", "createImageFromColor", "(", "viewer", ".", "getCloud", "(", ")", ".", "getSelectionColor", "(", ")", ".", "getRGB", "(", ")", ",", "16", ")", ")", ";", "sel", ".", "addSelectionListener", "(", "new", "SelectionListener", "(", ")", "{", "@", "Override", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "ColorDialog", "cd", "=", "new", "ColorDialog", "(", "parent", ".", "getShell", "(", ")", ")", ";", "RGB", "color", "=", "cd", ".", "open", "(", ")", ";", "if", "(", "color", "==", "null", ")", "return", ";", "Color", "old", "=", "viewer", ".", "getCloud", "(", ")", ".", "getSelectionColor", "(", ")", ";", "Color", "c", "=", "new", "Color", "(", "Display", ".", "getDefault", "(", ")", ",", "color", ")", ";", "viewer", ".", "getCloud", "(", ")", ".", "setSelectionColor", "(", "c", ")", ";", "old", ".", "dispose", "(", ")", ";", "viewer", ".", "getCloud", "(", ")", ".", "redrawTextLayerImage", "(", ")", ";", "Image", "oldImage", "=", "sel", ".", "getImage", "(", ")", ";", "Image", "newImage", "=", "createImageFromColor", "(", "color", ",", "16", ")", ";", "sel", ".", "setImage", "(", "newImage", ")", ";", "oldImage", ".", "dispose", "(", ")", ";", "}", "@", "Override", "public", "void", "widgetDefaultSelected", "(", "SelectionEvent", "e", ")", "{", "}", "}", ")", ";", "return", "buttons", ";", "}", "protected", "Group", "addLayoutButtons", "(", "Composite", "parent", ")", "{", "Group", "buttons", "=", "new", "Group", "(", "parent", ",", "SWT", ".", "SHADOW_IN", ")", ";", "buttons", ".", "setLayout", "(", "new", "GridLayout", "(", "2", ",", "true", ")", ")", ";", "buttons", ".", "setLayoutData", "(", "new", "GridData", "(", "SWT", ".", "FILL", ",", "SWT", ".", "TOP", ",", "true", ",", "false", ")", ")", ";", "Label", "l", "=", "new", "Label", "(", "buttons", ",", "SWT", ".", "NONE", ")", ";", "l", ".", "setText", "(", "\"\"", ")", ";", "final", "Combo", "words", "=", "new", "Combo", "(", "buttons", ",", "SWT", ".", "DROP_DOWN", "|", "SWT", ".", "READ_ONLY", ")", ";", "words", ".", "setLayoutData", "(", "new", "GridData", "(", "SWT", ".", "FILL", ",", "SWT", ".", "TOP", ",", "true", ",", "false", ")", ")", ";", "words", ".", "setItems", "(", "new", "String", "[", "]", "{", "\"100\"", ",", "\"200\"", ",", "\"300\"", ",", "\"400\"", ",", "\"500\"", ",", "\"600\"", ",", "\"700\"", ",", "\"800\"", ",", "\"900\"", ",", "\"1000\"", ",", "\"1100\"", ",", "\"1200\"", ",", "\"1300\"", ",", "\"1400\"", ",", "\"1500\"", ",", "\"1600\"", ",", "\"1700\"", ",", "\"1800\"", ",", "\"1900\"", ",", "\"2000\"", "}", ")", ";", "words", ".", "select", "(", "2", ")", ";", "words", ".", "addSelectionListener", "(", "new", "SelectionListener", "(", ")", "{", "@", "Override", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "String", "item", "=", "words", ".", "getItem", "(", "words", ".", "getSelectionIndex", "(", ")", ")", ";", "viewer", ".", "setMaxWords", "(", "Integer", ".", "parseInt", "(", "item", ")", ")", ";", "}", "@", "Override", "public", "void", "widgetDefaultSelected", "(", "SelectionEvent", "e", ")", "{", "}", "}", ")", ";", "l", "=", "new", "Label", "(", "buttons", ",", "SWT", ".", "NONE", ")", ";", "l", ".", "setText", "(", "\"\"", ")", ";", "final", "Combo", "font", "=", "new", "Combo", "(", "buttons", ",", "SWT", ".", "DROP_DOWN", "|", "SWT", ".", "READ_ONLY", ")", ";", "font", ".", "setLayoutData", "(", "new", "GridData", "(", "SWT", ".", "FILL", ",", "SWT", ".", "TOP", ",", "true", ",", "false", ")", ")", ";", "font", ".", "setItems", "(", "new", "String", "[", "]", "{", "\"50\"", ",", "\"100\"", ",", "\"150\"", ",", "\"200\"", ",", "\"250\"", ",", "\"300\"", ",", "\"350\"", ",", "\"400\"", ",", "\"450\"", ",", "\"500\"", "}", ")", ";", "font", ".", "select", "(", "1", ")", ";", "font", ".", "addSelectionListener", "(", "new", "SelectionListener", "(", ")", "{", "@", "Override", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "String", "item", "=", "font", ".", "getItem", "(", "font", ".", "getSelectionIndex", "(", ")", ")", ";", "viewer", ".", "getCloud", "(", ")", ".", "setMaxFontSize", "(", "Integer", ".", "parseInt", "(", "item", ")", ")", ";", "}", "@", "Override", "public", "void", "widgetDefaultSelected", "(", "SelectionEvent", "e", ")", "{", "}", "}", ")", ";", "l", "=", "new", "Label", "(", "buttons", ",", "SWT", ".", "NONE", ")", ";", "l", ".", "setText", "(", "\"\"", ")", ";", "final", "Combo", "minFont", "=", "new", "Combo", "(", "buttons", ",", "SWT", ".", "DROP_DOWN", "|", "SWT", ".", "READ_ONLY", ")", ";", "minFont", ".", "setLayoutData", "(", "new", "GridData", "(", "SWT", ".", "FILL", ",", "SWT", ".", "TOP", ",", "true", ",", "false", ")", ")", ";", "minFont", ".", "setItems", "(", "new", "String", "[", "]", "{", "\"10\"", ",", "\"15\"", ",", "\"20\"", ",", "\"25\"", ",", "\"30\"", ",", "\"35\"", ",", "\"40\"", ",", "\"45\"", ",", "\"50\"", "}", ")", ";", "minFont", ".", "select", "(", "1", ")", ";", "minFont", ".", "addSelectionListener", "(", "new", "SelectionListener", "(", ")", "{", "@", "Override", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "String", "item", "=", "minFont", ".", "getItem", "(", "minFont", ".", "getSelectionIndex", "(", ")", ")", ";", "viewer", ".", "getCloud", "(", ")", ".", "setMinFontSize", "(", "Integer", ".", "parseInt", "(", "item", ")", ")", ";", "}", "@", "Override", "public", "void", "widgetDefaultSelected", "(", "SelectionEvent", "e", ")", "{", "}", "}", ")", ";", "l", "=", "new", "Label", "(", "buttons", ",", "SWT", ".", "NONE", ")", ";", "l", ".", "setText", "(", "\"Boost\"", ")", ";", "final", "Combo", "boost", "=", "new", "Combo", "(", "buttons", ",", "SWT", ".", "DROP_DOWN", "|", "SWT", ".", "READ_ONLY", ")", ";", "boost", ".", "setLayoutData", "(", "new", "GridData", "(", "SWT", ".", "FILL", ",", "SWT", ".", "TOP", ",", "true", ",", "false", ")", ")", ";", "boost", ".", "setItems", "(", "new", "String", "[", "]", "{", "\"0\"", ",", "\"1\"", ",", "\"2\"", ",", "\"3\"", ",", "\"4\"", ",", "\"5\"", ",", "\"6\"", ",", "\"7\"", ",", "\"8\"", ",", "\"9\"", ",", "\"10\"", "}", ")", ";", "boost", ".", "select", "(", "0", ")", ";", "boost", ".", "addSelectionListener", "(", "new", "SelectionListener", "(", ")", "{", "@", "Override", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "String", "item", "=", "boost", ".", "getItem", "(", "boost", ".", "getSelectionIndex", "(", ")", ")", ";", "viewer", ".", "setBoost", "(", "Integer", ".", "parseInt", "(", "item", ")", ")", ";", "}", "@", "Override", "public", "void", "widgetDefaultSelected", "(", "SelectionEvent", "e", ")", "{", "}", "}", ")", ";", "l", "=", "new", "Label", "(", "buttons", ",", "SWT", ".", "NONE", ")", ";", "l", ".", "setText", "(", "\"Boost", "Factor\"", ")", ";", "final", "Combo", "boostFactor", "=", "new", "Combo", "(", "buttons", ",", "SWT", ".", "DROP_DOWN", "|", "SWT", ".", "READ_ONLY", ")", ";", "boostFactor", ".", "setLayoutData", "(", "new", "GridData", "(", "SWT", ".", "FILL", ",", "SWT", ".", "TOP", ",", "true", ",", "false", ")", ")", ";", "boostFactor", ".", "setItems", "(", "new", "String", "[", "]", "{", "\"1\"", ",", "\"1.5\"", ",", "\"2\"", ",", "\"2.5\"", ",", "\"3\"", ",", "\"3.5\"", ",", "\"4\"", ",", "\"4.5\"", ",", "\"5\"", "}", ")", ";", "boostFactor", ".", "select", "(", "0", ")", ";", "boostFactor", ".", "addSelectionListener", "(", "new", "SelectionListener", "(", ")", "{", "@", "Override", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "String", "item", "=", "boostFactor", ".", "getItem", "(", "boostFactor", ".", "getSelectionIndex", "(", ")", ")", ";", "viewer", ".", "setBoostFactor", "(", "Float", ".", "parseFloat", "(", "item", ")", ")", ";", "}", "@", "Override", "public", "void", "widgetDefaultSelected", "(", "SelectionEvent", "e", ")", "{", "}", "}", ")", ";", "if", "(", "viewer", ".", "getLabelProvider", "(", ")", "instanceof", "IEditableCloudLabelProvider", ")", "{", "}", "l", "=", "new", "Label", "(", "buttons", ",", "SWT", ".", "NONE", ")", ";", "l", ".", "setText", "(", "\"Angles\"", ")", ";", "final", "Combo", "angles", "=", "new", "Combo", "(", "buttons", ",", "SWT", ".", "DROP_DOWN", "|", "SWT", ".", "READ_ONLY", ")", ";", "angles", ".", "setLayoutData", "(", "new", "GridData", "(", "SWT", ".", "FILL", ",", "SWT", ".", "TOP", ",", "true", ",", "false", ")", ")", ";", "angles", ".", "setItems", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"\"", ",", "\"\"", ",", "\"\"", ",", "\"45", "Degrees\"", ",", "\"Random\"", "}", ")", ";", "final", "List", "<", "List", "<", "Float", ">", ">", "anglesLists", "=", "new", "ArrayList", "<", "List", "<", "Float", ">", ">", "(", ")", ";", "anglesLists", ".", "add", "(", "Arrays", ".", "asList", "(", "0F", ")", ")", ";", "anglesLists", ".", "add", "(", "Arrays", ".", "asList", "(", "-", "90F", ",", "90F", ")", ")", ";", "anglesLists", ".", "add", "(", "Arrays", ".", "asList", "(", "0F", ",", "-", "90F", ",", "0F", ",", "90F", ")", ")", ";", "anglesLists", ".", "add", "(", "Arrays", ".", "asList", "(", "0F", ",", "-", "90F", ",", "-", "45F", ",", "0F", ",", "45F", ",", "90F", ",", "0F", ",", "0F", ",", "0F", ",", "0F", ")", ")", ";", "anglesLists", ".", "add", "(", "Arrays", ".", "asList", "(", "-", "90F", ",", "-", "45F", ",", "0F", ",", "45F", ",", "90F", ")", ")", ";", "List", "<", "Float", ">", "tmp", "=", "new", "ArrayList", "<", "Float", ">", "(", ")", ";", "for", "(", "int", "i", "=", "-", "90", ";", "i", "<=", "90", ";", "i", "++", ")", "{", "tmp", ".", "add", "(", "(", "float", ")", "i", ")", ";", "}", "anglesLists", ".", "add", "(", "tmp", ")", ";", "angles", ".", "select", "(", "0", ")", ";", "angles", ".", "addSelectionListener", "(", "new", "SelectionListener", "(", ")", "{", "@", "Override", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "int", "index", "=", "angles", ".", "getSelectionIndex", "(", ")", ";", "IEditableCloudLabelProvider", "lp", "=", "(", "IEditableCloudLabelProvider", ")", "viewer", ".", "getLabelProvider", "(", ")", ";", "lp", ".", "setAngles", "(", "anglesLists", ".", "get", "(", "index", ")", ")", ";", "}", "@", "Override", "public", "void", "widgetDefaultSelected", "(", "SelectionEvent", "e", ")", "{", "}", "}", ")", ";", "return", "buttons", ";", "}", "public", "List", "<", "RGB", ">", "getColors", "(", ")", "{", "return", "colors", ";", "}", "public", "List", "<", "FontData", ">", "getFonts", "(", ")", "{", "return", "fonts", ";", "}", "}", "</s>" ]
10,187
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "cloudio", ".", "layout", ";", "import", "java", ".", "util", ".", "Random", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "Assert", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Point", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Rectangle", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "cloudio", ".", "Word", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "cloudio", ".", "util", ".", "CloudMatrix", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "cloudio", ".", "util", ".", "RectTree", ";", "public", "class", "DefaultLayouter", "implements", "ILayouter", "{", "public", "static", "final", "String", "X_AXIS_VARIATION", "=", "\"xaxis\"", ";", "public", "static", "final", "String", "Y_AXIS_VARIATION", "=", "\"yaxis\"", ";", "private", "Random", "random", "=", "new", "Random", "(", ")", ";", "private", "int", "xAxisVariation", ";", "private", "int", "yAxisVariation", ";", "public", "DefaultLayouter", "(", "int", "i", ",", "int", "j", ")", "{", "this", ".", "xAxisVariation", "=", "i", ";", "this", ".", "yAxisVariation", "=", "j", ";", "}", "public", "Point", "getInitialOffset", "(", "Word", "word", ",", "Rectangle", "cloudArea", ")", "{", "int", "xOff", "=", "0", ";", "if", "(", "xAxisVariation", ">", "0", ")", "{", "int", "range", "=", "(", "cloudArea", ".", "width", "-", "word", ".", "width", ")", "/", "200", "*", "xAxisVariation", ";", "if", "(", "range", ">", "0", ")", "{", "xOff", "=", "random", ".", "nextInt", "(", "range", ")", ";", "if", "(", "random", ".", "nextBoolean", "(", ")", ")", "{", "xOff", "=", "-", "xOff", ";", "}", "}", "}", "int", "yOff", "=", "0", ";", "if", "(", "yAxisVariation", ">", "0", ")", "{", "int", "range", "=", "cloudArea", ".", "height", "/", "200", "*", "yAxisVariation", ";", "if", "(", "range", ">", "0", ")", "{", "yOff", "=", "random", ".", "nextInt", "(", "range", ")", ";", "if", "(", "random", ".", "nextBoolean", "(", ")", ")", "yOff", "=", "-", "yOff", ";", "}", "}", "return", "new", "Point", "(", "xOff", ",", "yOff", ")", ";", "}", "public", "boolean", "layout", "(", "Point", "offset", ",", "final", "Word", "word", ",", "final", "Rectangle", "cloudArea", ",", "CloudMatrix", "mainTree", ")", "{", "Assert", ".", "isLegal", "(", "word", "!=", "null", ",", "\"\"", ")", ";", "Point", "next", "=", "new", "Point", "(", "-", "word", ".", "width", "/", "2", ",", "-", "word", ".", "height", "/", "2", ")", ";", "next", ".", "x", "+=", "random", ".", "nextInt", "(", "25", ")", ";", "next", ".", "y", "+=", "random", ".", "nextInt", "(", "25", ")", ";", "double", "growFactor", "=", "1.6", ";", "offset", ".", "x", "+=", "cloudArea", ".", "width", "/", "2", ";", "offset", ".", "y", "+=", "cloudArea", ".", "height", "/", "2", ";", "final", "int", "accuracy", "=", "mainTree", ".", "getMinResolution", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "5000", ";", "i", "++", ")", "{", "final", "double", "radius", "=", "Math", ".", "sqrt", "(", "(", "double", ")", "(", "next", ".", "x", "*", "next", ".", "x", "+", "next", ".", "y", "*", "next", ".", "y", ")", ")", "+", "growFactor", ";", "double", "atan", "=", "Math", ".", "atan2", "(", "next", ".", "y", ",", "next", ".", "x", ")", ";", "if", "(", "growFactor", ">", "1.1", ")", "{", "growFactor", "-=", "0.0007", ";", "}", "if", "(", "radius", "<", "80", ")", "{", "atan", "+=", "0.7", ";", "}", "else", "{", "atan", "+=", "20", "/", "radius", ";", "}", "if", "(", "growFactor", "<", "0.0005", ")", "{", "growFactor", "=", "0.0005", ";", "}", "next", ".", "x", "=", "(", "int", ")", "(", "radius", "*", "Math", ".", "cos", "(", "atan", ")", ")", ";", "next", ".", "y", "=", "(", "int", ")", "(", "radius", "*", "Math", ".", "sin", "(", "atan", ")", ")", ";", "word", ".", "x", "=", "(", "(", "next", ".", "x", "+", "offset", ".", "x", ")", "/", "accuracy", ")", "*", "accuracy", ";", "word", ".", "y", "=", "(", "(", "next", ".", "y", "+", "offset", ".", "y", ")", "/", "accuracy", ")", "*", "accuracy", ";", "RectTree", "rt", "=", "word", ".", "tree", ";", "if", "(", "rt", "==", "null", ")", "break", ";", "rt", ".", "move", "(", "word", ".", "x", ",", "word", ".", "y", ")", ";", "if", "(", "cloudArea", ".", "x", "<=", "word", ".", "x", "&&", "cloudArea", ".", "y", "<=", "word", ".", "y", "&&", "cloudArea", ".", "x", "+", "cloudArea", ".", "width", ">=", "word", ".", "x", "+", "word", ".", "width", "&&", "cloudArea", ".", "y", "+", "cloudArea", ".", "height", ">=", "word", ".", "y", "+", "word", ".", "height", ")", "{", "if", "(", "rt", ".", "fits", "(", "mainTree", ")", ")", "{", "rt", ".", "place", "(", "mainTree", ",", "word", ".", "id", ")", ";", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}", "public", "void", "setOption", "(", "String", "optionName", ",", "Object", "object", ")", "{", "if", "(", "X_AXIS_VARIATION", ".", "equals", "(", "optionName", ")", ")", "{", "Integer", "value", "=", "(", "Integer", ")", "object", ";", "Assert", ".", "isLegal", "(", "value", ">=", "0", ",", "\"\"", "+", "value", ")", ";", "Assert", ".", "isLegal", "(", "value", "<=", "100", ",", "\"\"", "+", "value", ")", ";", "this", ".", "xAxisVariation", "=", "value", ";", "return", ";", "}", "if", "(", "Y_AXIS_VARIATION", ".", "equals", "(", "optionName", ")", ")", "{", "Integer", "value", "=", "(", "Integer", ")", "object", ";", "Assert", ".", "isLegal", "(", "value", ">=", "0", ",", "\"\"", "+", "value", ")", ";", "Assert", ".", "isLegal", "(", "value", "<=", "100", ",", "\"\"", "+", "value", ")", ";", "this", ".", "yAxisVariation", "=", "value", ";", "return", ";", "}", "System", ".", "err", ".", "println", "(", "\"\"", "+", "optionName", ")", ";", "}", "}", "</s>" ]
10,188
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "cloudio", ".", "layout", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Point", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Rectangle", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "cloudio", ".", "Word", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "cloudio", ".", "util", ".", "CloudMatrix", ";", "public", "interface", "ILayouter", "{", "public", "boolean", "layout", "(", "Point", "initial", ",", "final", "Word", "word", ",", "final", "Rectangle", "cloudArea", ",", "CloudMatrix", "cloudMatrix", ")", ";", "public", "Point", "getInitialOffset", "(", "Word", "word", ",", "Rectangle", "cloudArea", ")", ";", "public", "void", "setOption", "(", "String", "optionName", ",", "Object", "object", ")", ";", "}", "</s>" ]
10,189
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "cloudio", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "IBaseLabelProvider", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Color", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "FontData", ";", "public", "interface", "ICloudLabelProvider", "extends", "IBaseLabelProvider", "{", "public", "String", "getLabel", "(", "Object", "element", ")", ";", "public", "double", "getWeight", "(", "Object", "element", ")", ";", "public", "Color", "getColor", "(", "Object", "element", ")", ";", "public", "FontData", "[", "]", "getFontData", "(", "Object", "element", ")", ";", "public", "float", "getAngle", "(", "Object", "element", ")", ";", "public", "String", "getToolTip", "(", "Object", "element", ")", ";", "}", "</s>" ]
10,190
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "cloudio", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "FontData", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "RGB", ";", "public", "interface", "IEditableCloudLabelProvider", "extends", "ICloudLabelProvider", "{", "public", "void", "setColors", "(", "List", "<", "RGB", ">", "colors", ")", ";", "public", "void", "setFonts", "(", "List", "<", "FontData", ">", "fonts", ")", ";", "public", "void", "setAngles", "(", "List", "<", "Float", ">", "list", ")", ";", "}", "</s>" ]
10,191
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "cloudio", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "Assert", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "IProgressMonitor", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "ContentViewer", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "IBaseLabelProvider", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "IContentProvider", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "ISelection", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "IStructuredContentProvider", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "IStructuredSelection", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "SelectionChangedEvent", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "StructuredSelection", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "MouseEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "MouseListener", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "MouseTrackListener", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "MouseWheelListener", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionListener", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Control", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "cloudio", ".", "layout", ".", "ILayouter", ";", "public", "class", "TagCloudViewer", "extends", "ContentViewer", "{", "private", "TagCloud", "cloud", ";", "private", "Set", "<", "Word", ">", "selection", "=", "new", "HashSet", "<", "Word", ">", "(", ")", ";", "private", "Map", "<", "Object", ",", "Word", ">", "objectMap", "=", "new", "HashMap", "<", "Object", ",", "Word", ">", "(", ")", ";", "private", "int", "maxWords", "=", "300", ";", "private", "IProgressMonitor", "monitor", ";", "public", "TagCloudViewer", "(", "TagCloud", "cloud", ")", "{", "Assert", ".", "isLegal", "(", "cloud", "!=", "null", ",", "\"\"", ")", ";", "Assert", ".", "isLegal", "(", "!", "cloud", ".", "isDisposed", "(", ")", ",", "\"\"", ")", ";", "this", ".", "cloud", "=", "cloud", ";", "initListeners", "(", ")", ";", "}", "protected", "void", "initListeners", "(", ")", "{", "initSelectionListener", "(", ")", ";", "initMouseWheelListener", "(", ")", ";", "initToolTipSupport", "(", ")", ";", "}", "protected", "void", "initToolTipSupport", "(", ")", "{", "cloud", ".", "addMouseTrackListener", "(", "new", "MouseTrackListener", "(", ")", "{", "@", "Override", "public", "void", "mouseHover", "(", "MouseEvent", "e", ")", "{", "}", "@", "Override", "public", "void", "mouseExit", "(", "MouseEvent", "e", ")", "{", "cloud", ".", "setToolTipText", "(", "null", ")", ";", "}", "@", "Override", "public", "void", "mouseEnter", "(", "MouseEvent", "e", ")", "{", "Word", "word", "=", "(", "Word", ")", "e", ".", "data", ";", "ICloudLabelProvider", "labelProvider", "=", "(", "ICloudLabelProvider", ")", "getLabelProvider", "(", ")", ";", "cloud", ".", "setToolTipText", "(", "labelProvider", ".", "getToolTip", "(", "word", ".", "data", ")", ")", ";", "}", "}", ")", ";", "}", "protected", "void", "initMouseWheelListener", "(", ")", "{", "cloud", ".", "addMouseWheelListener", "(", "new", "MouseWheelListener", "(", ")", "{", "@", "Override", "public", "void", "mouseScrolled", "(", "MouseEvent", "e", ")", "{", "if", "(", "e", ".", "count", ">", "0", ")", "{", "cloud", ".", "zoomIn", "(", ")", ";", "}", "else", "{", "cloud", ".", "zoomOut", "(", ")", ";", "}", "}", "}", ")", ";", "}", "protected", "void", "initSelectionListener", "(", ")", "{", "cloud", ".", "addMouseListener", "(", "new", "MouseListener", "(", ")", "{", "@", "Override", "public", "void", "mouseUp", "(", "MouseEvent", "e", ")", "{", "Word", "word", "=", "(", "Word", ")", "e", ".", "data", ";", "if", "(", "word", "==", "null", ")", "return", ";", "boolean", "remove", "=", "selection", ".", "remove", "(", "word", ")", ";", "if", "(", "!", "remove", ")", "selection", ".", "add", "(", "word", ")", ";", "cloud", ".", "setSelection", "(", "selection", ")", ";", "}", "@", "Override", "public", "void", "mouseDown", "(", "MouseEvent", "e", ")", "{", "}", "@", "Override", "public", "void", "mouseDoubleClick", "(", "MouseEvent", "e", ")", "{", "}", "}", ")", ";", "cloud", ".", "addSelectionListener", "(", "new", "SelectionListener", "(", ")", "{", "@", "Override", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "List", "<", "Object", ">", "data", "=", "new", "ArrayList", "<", "Object", ">", "(", ")", ";", "Set", "<", "Word", ">", "selected", "=", "(", "Set", "<", "Word", ">", ")", "e", ".", "data", ";", "for", "(", "Word", "word", ":", "selected", ")", "{", "if", "(", "word", ".", "data", "!=", "null", ")", "{", "data", ".", "add", "(", "word", ".", "data", ")", ";", "}", "}", "StructuredSelection", "selection", "=", "new", "StructuredSelection", "(", "data", ")", ";", "fireSelectionChanged", "(", "new", "SelectionChangedEvent", "(", "TagCloudViewer", ".", "this", ",", "selection", ")", ")", ";", "}", "@", "Override", "public", "void", "widgetDefaultSelected", "(", "SelectionEvent", "e", ")", "{", "}", "}", ")", ";", "}", "@", "Override", "public", "Control", "getControl", "(", ")", "{", "return", "getCloud", "(", ")", ";", "}", "@", "Override", "public", "ISelection", "getSelection", "(", ")", "{", "List", "<", "Object", ">", "elements", "=", "new", "ArrayList", "<", "Object", ">", "(", ")", ";", "for", "(", "Word", "word", ":", "selection", ")", "{", "elements", ".", "add", "(", "word", ".", "data", ")", ";", "}", "return", "new", "StructuredSelection", "(", "elements", ")", ";", "}", "@", "Override", "public", "void", "refresh", "(", ")", "{", "}", "@", "Override", "public", "void", "setSelection", "(", "ISelection", "selection", ",", "boolean", "reveal", ")", "{", "this", ".", "selection", ".", "clear", "(", ")", ";", "IStructuredSelection", "sel", "=", "(", "IStructuredSelection", ")", "selection", ";", "Iterator", "<", "?", ">", "iterator", "=", "sel", ".", "iterator", "(", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "Object", "next", "=", "iterator", ".", "next", "(", ")", ";", "Word", "word", "=", "objectMap", ".", "get", "(", "next", ")", ";", "if", "(", "word", "!=", "null", ")", "{", "this", ".", "selection", ".", "add", "(", "word", ")", ";", "}", "}", "cloud", ".", "setSelection", "(", "this", ".", "selection", ")", ";", "}", "public", "void", "reset", "(", "IProgressMonitor", "monitor", ",", "boolean", "recalc", ")", "{", "cloud", ".", "layoutCloud", "(", "monitor", ",", "recalc", ")", ";", "}", "public", "TagCloud", "getCloud", "(", ")", "{", "return", "cloud", ";", "}", "@", "Override", "public", "void", "setLabelProvider", "(", "IBaseLabelProvider", "labelProvider", ")", "{", "super", ".", "setLabelProvider", "(", "labelProvider", ")", ";", "Assert", ".", "isLegal", "(", "labelProvider", "instanceof", "ICloudLabelProvider", ")", ";", "}", "@", "Override", "public", "void", "setContentProvider", "(", "IContentProvider", "contentProvider", ")", "{", "Assert", ".", "isLegal", "(", "contentProvider", "instanceof", "IStructuredContentProvider", ")", ";", "super", ".", "setContentProvider", "(", "contentProvider", ")", ";", "}", "@", "Override", "protected", "void", "inputChanged", "(", "Object", "input", ",", "Object", "oldInput", ")", "{", "selection", ".", "clear", "(", ")", ";", "objectMap", ".", "clear", "(", ")", ";", "IStructuredContentProvider", "contentProvider", "=", "(", "IStructuredContentProvider", ")", "getContentProvider", "(", ")", ";", "Object", "[", "]", "elements", "=", "contentProvider", ".", "getElements", "(", "input", ")", ";", "List", "<", "Word", ">", "words", "=", "new", "ArrayList", "<", "Word", ">", "(", ")", ";", "ICloudLabelProvider", "labelProvider", "=", "(", "ICloudLabelProvider", ")", "getLabelProvider", "(", ")", ";", "short", "i", "=", "0", ";", "for", "(", "Object", "element", ":", "elements", ")", "{", "Word", "word", "=", "new", "Word", "(", "labelProvider", ".", "getLabel", "(", "element", ")", ")", ";", "word", ".", "setColor", "(", "labelProvider", ".", "getColor", "(", "element", ")", ")", ";", "word", ".", "weight", "=", "labelProvider", ".", "getWeight", "(", "element", ")", ";", "word", ".", "setFontData", "(", "labelProvider", ".", "getFontData", "(", "element", ")", ")", ";", "word", ".", "angle", "=", "labelProvider", ".", "getAngle", "(", "element", ")", ";", "word", ".", "data", "=", "element", ";", "Assert", ".", "isLegal", "(", "word", ".", "string", "!=", "null", ",", "\"\"", ")", ";", "Assert", ".", "isLegal", "(", "word", ".", "getColor", "(", ")", "!=", "null", ",", "\"\"", ")", ";", "Assert", ".", "isLegal", "(", "word", ".", "getFontData", "(", ")", "!=", "null", ",", "\"\"", ")", ";", "Assert", ".", "isLegal", "(", "word", ".", "weight", ">=", "0", ",", "\"\"", "+", "word", ".", "weight", ")", ";", "Assert", ".", "isLegal", "(", "word", ".", "weight", "<=", "1", ",", "\"\"", "+", "word", ".", "weight", ")", ";", "Assert", ".", "isLegal", "(", "word", ".", "angle", ">=", "-", "90", ",", "\"\"", "+", "word", ".", "angle", ")", ";", "Assert", ".", "isLegal", "(", "word", ".", "angle", "<=", "90", ",", "\"\"", "+", "word", ".", "angle", ")", ";", "words", ".", "add", "(", "word", ")", ";", "i", "++", ";", "word", ".", "id", "=", "i", ";", "objectMap", ".", "put", "(", "element", ",", "word", ")", ";", "if", "(", "i", "==", "maxWords", ")", "break", ";", "}", "selection", ".", "clear", "(", ")", ";", "if", "(", "monitor", "!=", "null", ")", "{", "monitor", ".", "subTask", "(", "\"Layouting...\"", ")", ";", "}", "cloud", ".", "setWords", "(", "words", ",", "monitor", ")", ";", "}", "public", "void", "setMaxWords", "(", "int", "words", ")", "{", "this", ".", "maxWords", "=", "words", ";", "}", "public", "void", "zoomFit", "(", ")", "{", "cloud", ".", "zoomFit", "(", ")", ";", "}", "public", "void", "zoomIn", "(", ")", "{", "cloud", ".", "zoomIn", "(", ")", ";", "}", "public", "void", "zoomOut", "(", ")", "{", "cloud", ".", "zoomOut", "(", ")", ";", "}", "public", "void", "zoomReset", "(", ")", "{", "cloud", ".", "zoomReset", "(", ")", ";", "}", "public", "void", "setBoost", "(", "int", "boost", ")", "{", "cloud", ".", "setBoost", "(", "boost", ")", ";", "}", "public", "int", "getMaxWords", "(", ")", "{", "return", "maxWords", ";", "}", "public", "void", "setInput", "(", "Object", "input", ",", "IProgressMonitor", "progressMonitor", ")", "{", "this", ".", "monitor", "=", "progressMonitor", ";", "super", ".", "setInput", "(", "input", ")", ";", "this", ".", "monitor", "=", "null", ";", "}", "public", "void", "setBoostFactor", "(", "float", "boostFactor", ")", "{", "cloud", ".", "setBoostFactor", "(", "boostFactor", ")", ";", "}", "public", "void", "setLayouter", "(", "ILayouter", "layouter", ")", "{", "cloud", ".", "setLayouter", "(", "layouter", ")", ";", "}", "public", "ILayouter", "getLayouter", "(", ")", "{", "return", "cloud", ".", "getLayouter", "(", ")", ";", "}", "}", "</s>" ]
10,192
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "cloudio", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "Assert", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Color", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "FontData", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Point", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "cloudio", ".", "util", ".", "RectTree", ";", "public", "class", "Word", "{", "public", "Word", "(", "String", "string", ")", "{", "this", ".", "string", "=", "string", ";", "}", "public", "final", "String", "string", ";", "public", "double", "weight", ";", "public", "int", "x", ";", "public", "int", "y", ";", "private", "Color", "color", ";", "public", "RectTree", "tree", ";", "public", "float", "angle", ";", "private", "FontData", "[", "]", "fontData", ";", "public", "FontData", "[", "]", "getFontData", "(", ")", "{", "return", "fontData", ";", "}", "public", "void", "setFontData", "(", "FontData", "[", "]", "fontData", ")", "{", "Assert", ".", "isLegal", "(", "fontData", "!=", "null", ",", "\"\"", ")", ";", "this", ".", "fontData", "=", "fontData", ".", "clone", "(", ")", ";", "}", "public", "short", "id", ";", "public", "int", "height", ";", "public", "int", "width", ";", "public", "Object", "data", ";", "public", "Point", "stringExtent", ";", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "string", ";", "}", "public", "void", "setColor", "(", "Color", "color", ")", "{", "Assert", ".", "isLegal", "(", "color", "!=", "null", ",", "\"\"", ")", ";", "Assert", ".", "isLegal", "(", "!", "color", ".", "isDisposed", "(", ")", ",", "\"\"", ")", ";", "this", ".", "color", "=", "color", ";", "}", "public", "Color", "getColor", "(", ")", "{", "Assert", ".", "isLegal", "(", "color", "!=", "null", ",", "\"\"", ")", ";", "Assert", ".", "isLegal", "(", "!", "color", ".", "isDisposed", "(", ")", ",", "\"\"", ")", ";", "return", "color", ";", "}", "}", "</s>" ]
10,193
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "cloudio", ".", "util", ";", "import", "java", ".", "util", ".", "Collection", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "LinkedList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Point", ";", "public", "class", "RectTree", "{", "private", "final", "int", "minResolution", ";", "private", "short", "xOffset", ",", "yOffset", ";", "private", "RectNode", "root", ";", "private", "LinkedList", "<", "RectNode", ">", "leaves", ";", "public", "static", "short", "EMPTY", "=", "-", "3", ",", "MISC", "=", "-", "2", ",", "BACKGROUND", "=", "-", "1", ";", "class", "RectNode", "{", "final", "SmallRect", "rect", ";", "private", "RectNode", "[", "]", "children", ";", "private", "final", "SmallRect", "[", "]", "childAreas", ";", "short", "filled", "=", "EMPTY", ";", "public", "RectNode", "(", "SmallRect", "rect", ")", "{", "this", ".", "rect", "=", "rect", ";", "final", "int", "width", "=", "rect", ".", "width", "/", "2", ";", "final", "int", "height", "=", "rect", ".", "height", "/", "2", ";", "if", "(", "rect", ".", "width", ">", "minResolution", ")", "{", "this", ".", "childAreas", "=", "new", "SmallRect", "[", "4", "]", ";", "childAreas", "[", "0", "]", "=", "new", "SmallRect", "(", "rect", ".", "x", ",", "rect", ".", "y", ",", "width", ",", "height", ")", ";", "childAreas", "[", "1", "]", "=", "new", "SmallRect", "(", "rect", ".", "x", "+", "width", ",", "rect", ".", "y", ",", "width", ",", "height", ")", ";", "childAreas", "[", "2", "]", "=", "new", "SmallRect", "(", "rect", ".", "x", ",", "rect", ".", "y", "+", "height", ",", "width", ",", "height", ")", ";", "childAreas", "[", "3", "]", "=", "new", "SmallRect", "(", "rect", ".", "x", "+", "width", ",", "rect", ".", "y", "+", "height", ",", "width", ",", "height", ")", ";", "}", "else", "{", "this", ".", "childAreas", "=", "null", ";", "}", "}", "private", "int", "getChildIndex", "(", "SmallRect", "r", ")", "{", "int", "index", "=", "0", ";", "if", "(", "r", ".", "y", ">=", "childAreas", "[", "3", "]", ".", "y", ")", "{", "if", "(", "r", ".", "x", ">=", "childAreas", "[", "3", "]", ".", "x", ")", "{", "index", "=", "3", ";", "}", "else", "{", "index", "=", "2", ";", "}", "}", "else", "{", "if", "(", "r", ".", "x", ">=", "childAreas", "[", "1", "]", ".", "x", ")", "{", "index", "=", "1", ";", "}", "}", "return", "index", ";", "}", "public", "boolean", "insert", "(", "SmallRect", "r", ",", "short", "id", ")", "{", "if", "(", "rect", ".", "width", "==", "minResolution", ")", "{", "filled", "=", "id", ";", "return", "true", ";", "}", "int", "i", "=", "getChildIndex", "(", "r", ")", ";", "if", "(", "children", "==", "null", ")", "{", "children", "=", "new", "RectNode", "[", "4", "]", ";", "}", "if", "(", "children", "[", "i", "]", "==", "null", ")", "{", "children", "[", "i", "]", "=", "new", "RectNode", "(", "childAreas", "[", "i", "]", ")", ";", "}", "boolean", "filledChild", "=", "children", "[", "i", "]", ".", "insert", "(", "r", ",", "id", ")", ";", "if", "(", "filledChild", ")", "{", "Set", "<", "Short", ">", "ids", "=", "new", "HashSet", "<", "Short", ">", "(", ")", ";", "boolean", "filled", "=", "true", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "children", ".", "length", ";", "j", "++", ")", "{", "if", "(", "i", "==", "j", ")", "continue", ";", "if", "(", "children", "[", "j", "]", "==", "null", "||", "children", "[", "j", "]", ".", "filled", "==", "EMPTY", ")", "{", "filled", "=", "false", ";", "break", ";", "}", "ids", ".", "add", "(", "children", "[", "j", "]", ".", "filled", ")", ";", "}", "if", "(", "filled", ")", "{", "if", "(", "ids", ".", "size", "(", ")", "==", "1", ")", "{", "this", ".", "filled", "=", "ids", ".", "iterator", "(", ")", ".", "next", "(", ")", ";", "if", "(", "this", ".", "filled", "==", "BACKGROUND", ")", "{", "children", "=", "null", ";", "}", "}", "else", "{", "this", ".", "filled", "=", "MISC", ";", "}", "}", "return", "filled", ";", "}", "return", "false", ";", "}", "public", "boolean", "isAvailable", "(", "final", "SmallRect", "oRect", ")", "{", "if", "(", "filled", ">=", "MISC", ")", "return", "false", ";", "if", "(", "children", "==", "null", ")", "{", "return", "filled", "==", "EMPTY", ";", "}", "final", "int", "i", "=", "getChildIndex", "(", "oRect", ")", ";", "if", "(", "children", "[", "i", "]", "==", "null", ")", "return", "true", ";", "return", "children", "[", "i", "]", ".", "isAvailable", "(", "oRect", ")", ";", "}", "public", "short", "getWordId", "(", "int", "x", ",", "int", "y", ")", "{", "if", "(", "filled", ">", "BACKGROUND", ")", "return", "filled", ";", "if", "(", "children", "==", "null", ")", "{", "return", "filled", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "childAreas", ".", "length", ";", "i", "++", ")", "{", "if", "(", "childAreas", "[", "i", "]", ".", "intersects", "(", "x", ",", "y", ",", "minResolution", ",", "minResolution", ")", "&&", "children", "[", "i", "]", "!=", "null", ")", "{", "return", "children", "[", "i", "]", ".", "getWordId", "(", "x", ",", "y", ")", ";", "}", "}", "return", "EMPTY", ";", "}", "public", "short", "getWordId", "(", "Point", "position", ")", "{", "return", "getWordId", "(", "position", ".", "x", ",", "position", ".", "y", ")", ";", "}", "}", "public", "RectTree", "(", "SmallRect", "root", ",", "int", "minResolution", ")", "{", "this", ".", "minResolution", "=", "minResolution", ";", "this", ".", "root", "=", "new", "RectNode", "(", "root", ")", ";", "}", "public", "void", "insert", "(", "SmallRect", "r", ",", "short", "id", ")", "{", "root", ".", "insert", "(", "r", ",", "id", ")", ";", "}", "public", "void", "move", "(", "int", "x", ",", "int", "y", ")", "{", "this", ".", "xOffset", "=", "(", "short", ")", "x", ";", "this", ".", "yOffset", "=", "(", "short", ")", "y", ";", "}", "public", "boolean", "fits", "(", "final", "CloudMatrix", "mainTree", ")", "{", "LinkedList", "<", "RectNode", ">", "leaves", "=", "getLeaves", "(", ")", ";", "Iterator", "<", "RectNode", ">", "nodes", "=", "leaves", ".", "iterator", "(", ")", ";", "while", "(", "nodes", ".", "hasNext", "(", ")", ")", "{", "RectNode", "node", "=", "nodes", ".", "next", "(", ")", ";", "if", "(", "!", "mainTree", ".", "isEmpty", "(", "(", "node", ".", "rect", ".", "x", "+", "xOffset", ")", "/", "minResolution", ",", "(", "node", ".", "rect", ".", "y", "+", "yOffset", ")", "/", "minResolution", ")", ")", "{", "nodes", ".", "remove", "(", ")", ";", "leaves", ".", "addFirst", "(", "node", ")", ";", "return", "false", ";", "}", "}", "return", "true", ";", "}", "LinkedList", "<", "RectNode", ">", "getLeaves", "(", ")", "{", "if", "(", "leaves", "==", "null", ")", "{", "leaves", "=", "new", "LinkedList", "<", "RectNode", ">", "(", ")", ";", "addLeaves", "(", "leaves", ",", "root", ")", ";", "}", "return", "leaves", ";", "}", "private", "void", "addLeaves", "(", "List", "<", "RectNode", ">", "leaves", ",", "RectNode", "current", ")", "{", "if", "(", "current", ".", "children", "==", "null", ")", "{", "if", "(", "current", ".", "filled", "!=", "EMPTY", ")", "{", "leaves", ".", "add", "(", "current", ")", ";", "}", "}", "else", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "4", ";", "i", "++", ")", "{", "if", "(", "current", ".", "children", "[", "i", "]", "==", "null", ")", "continue", ";", "addLeaves", "(", "leaves", ",", "current", ".", "children", "[", "i", "]", ")", ";", "}", "}", "}", "public", "void", "place", "(", "final", "CloudMatrix", "mainTree", ",", "short", "id", ")", "{", "Collection", "<", "RectNode", ">", "leaves", "=", "getLeaves", "(", ")", ";", "for", "(", "RectNode", "node", ":", "leaves", ")", "{", "mainTree", ".", "set", "(", "node", ",", "id", ",", "xOffset", ",", "yOffset", ",", "minResolution", ")", ";", "}", "}", "public", "void", "releaseRects", "(", ")", "{", "getLeaves", "(", ")", ";", "root", ".", "children", "=", "null", ";", "}", "public", "RectNode", "getRoot", "(", ")", "{", "return", "root", ";", "}", "public", "void", "reset", "(", ")", "{", "root", "=", "new", "RectNode", "(", "root", ".", "rect", ")", ";", "}", "}", "</s>" ]
10,194
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "cloudio", ".", "util", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Rectangle", ";", "public", "class", "SmallRect", "{", "final", "short", "x", ",", "y", ",", "width", ",", "height", ";", "@", "Override", "public", "int", "hashCode", "(", ")", "{", "final", "int", "prime", "=", "31", ";", "int", "result", "=", "1", ";", "result", "=", "prime", "*", "result", "+", "height", ";", "result", "=", "prime", "*", "result", "+", "width", ";", "result", "=", "prime", "*", "result", "+", "x", ";", "result", "=", "prime", "*", "result", "+", "y", ";", "return", "result", ";", "}", "@", "Override", "public", "boolean", "equals", "(", "Object", "obj", ")", "{", "if", "(", "this", "==", "obj", ")", "return", "true", ";", "if", "(", "obj", "==", "null", ")", "return", "false", ";", "if", "(", "getClass", "(", ")", "!=", "obj", ".", "getClass", "(", ")", ")", "return", "false", ";", "SmallRect", "other", "=", "(", "SmallRect", ")", "obj", ";", "if", "(", "height", "!=", "other", ".", "height", ")", "return", "false", ";", "if", "(", "width", "!=", "other", ".", "width", ")", "return", "false", ";", "if", "(", "x", "!=", "other", ".", "x", ")", "return", "false", ";", "if", "(", "y", "!=", "other", ".", "y", ")", "return", "false", ";", "return", "true", ";", "}", "public", "SmallRect", "(", "int", "x", ",", "int", "y", ",", "int", "width", ",", "int", "height", ")", "{", "this", ".", "x", "=", "(", "short", ")", "x", ";", "this", ".", "y", "=", "(", "short", ")", "y", ";", "this", ".", "width", "=", "(", "short", ")", "width", ";", "this", ".", "height", "=", "(", "short", ")", "height", ";", "}", "public", "boolean", "intersects", "(", "SmallRect", "rect", ")", "{", "if", "(", "rect", "==", "null", ")", "SWT", ".", "error", "(", "SWT", ".", "ERROR_NULL_ARGUMENT", ")", ";", "return", "rect", "==", "this", "||", "intersects", "(", "rect", ".", "x", ",", "rect", ".", "y", ",", "rect", ".", "width", ",", "rect", ".", "height", ")", ";", "}", "public", "boolean", "intersects", "(", "final", "int", "x", ",", "final", "int", "y", ",", "final", "int", "width", ",", "final", "int", "height", ")", "{", "return", "(", "x", "<", "this", ".", "x", "+", "this", ".", "width", ")", "&&", "(", "y", "<", "this", ".", "y", "+", "this", ".", "height", ")", "&&", "(", "x", "+", "width", ">", "this", ".", "x", ")", "&&", "(", "y", "+", "height", ">", "this", ".", "y", ")", ";", "}", "public", "String", "toString", "(", ")", "{", "return", "\"Rectangle", "{\"", "+", "x", "+", "\",", "\"", "+", "y", "+", "\",", "\"", "+", "width", "+", "\",", "\"", "+", "height", "+", "\"}\"", ";", "}", "}", "</s>" ]
10,195
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "cloudio", ".", "util", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "cloudio", ".", "util", ".", "RectTree", ".", "RectNode", ";", "public", "class", "CloudMatrix", "{", "private", "RectTree", "tree", ";", "private", "final", "int", "max", ";", "private", "final", "int", "minResolution", ";", "public", "int", "getMinResolution", "(", ")", "{", "return", "minResolution", ";", "}", "public", "CloudMatrix", "(", "int", "maxSize", ",", "int", "minResolution", ")", "{", "this", ".", "max", "=", "maxSize", ";", "this", ".", "minResolution", "=", "minResolution", ";", "reset", "(", ")", ";", "}", "public", "short", "get", "(", "int", "x", ",", "int", "y", ")", "{", "return", "tree", ".", "getRoot", "(", ")", ".", "getWordId", "(", "x", "*", "minResolution", ",", "y", "*", "minResolution", ")", ";", "}", "public", "boolean", "isEmpty", "(", "int", "x", ",", "int", "y", ")", "{", "short", "id", "=", "tree", ".", "getRoot", "(", ")", ".", "getWordId", "(", "x", "*", "minResolution", ",", "y", "*", "minResolution", ")", ";", "return", "id", "==", "RectTree", ".", "EMPTY", ";", "}", "public", "void", "reset", "(", ")", "{", "SmallRect", "root", "=", "new", "SmallRect", "(", "0", ",", "0", ",", "max", ",", "max", ")", ";", "tree", "=", "new", "RectTree", "(", "root", ",", "minResolution", ")", ";", "}", "public", "void", "set", "(", "RectNode", "node", ",", "short", "id", ",", "short", "xOffset", ",", "short", "yOffset", ",", "int", "minResolution", ")", "{", "int", "cleanX", "=", "(", "(", "xOffset", "+", "node", ".", "rect", ".", "x", ")", "/", "minResolution", ")", "*", "minResolution", ";", "int", "cleanY", "=", "(", "(", "yOffset", "+", "node", ".", "rect", ".", "y", ")", "/", "minResolution", ")", "*", "minResolution", ";", "SmallRect", "rect", "=", "new", "SmallRect", "(", "cleanX", ",", "cleanY", ",", "minResolution", ",", "minResolution", ")", ";", "tree", ".", "insert", "(", "rect", ",", "id", ")", ";", "}", "}", "</s>" ]
10,196
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "cloudio", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Image", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "ImageData", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "ImageLoader", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "import", "org", ".", "eclipse", ".", "ui", ".", "plugin", ".", "AbstractUIPlugin", ";", "import", "org", ".", "osgi", ".", "framework", ".", "BundleContext", ";", "public", "class", "Activator", "extends", "AbstractUIPlugin", "{", "public", "static", "final", "String", "PLUGIN_ID", "=", "\"\"", ";", "private", "static", "Activator", "plugin", ";", "public", "static", "final", "String", "ADD", "=", "\"add.gif\"", ";", "public", "static", "final", "String", "REMOVE", "=", "\"remove.gif\"", ";", "public", "static", "final", "String", "TOGGLE_COLORS", "=", "\"\"", ";", "public", "Activator", "(", ")", "{", "}", "public", "void", "start", "(", "BundleContext", "context", ")", "throws", "Exception", "{", "super", ".", "start", "(", "context", ")", ";", "plugin", "=", "this", ";", "ImageLoader", "il", "=", "new", "ImageLoader", "(", ")", ";", "loadImage", "(", "il", ",", "ADD", ")", ";", "loadImage", "(", "il", ",", "REMOVE", ")", ";", "loadImage", "(", "il", ",", "TOGGLE_COLORS", ")", ";", "}", "private", "void", "loadImage", "(", "ImageLoader", "il", ",", "String", "fileName", ")", "throws", "IOException", "{", "InputStream", "stream", "=", "getBundle", "(", ")", ".", "getResource", "(", "\"img/\"", "+", "fileName", ")", ".", "openStream", "(", ")", ";", "ImageData", "[", "]", "data", "=", "il", ".", "load", "(", "stream", ")", ";", "Image", "image", "=", "new", "Image", "(", "Display", ".", "getDefault", "(", ")", ",", "data", "[", "0", "]", ")", ";", "getImageRegistry", "(", ")", ".", "put", "(", "fileName", ",", "image", ")", ";", "}", "public", "void", "stop", "(", "BundleContext", "context", ")", "throws", "Exception", "{", "plugin", "=", "null", ";", "super", ".", "stop", "(", "context", ")", ";", "}", "public", "static", "Activator", "getDefault", "(", ")", "{", "return", "plugin", ";", "}", "}", "</s>" ]
10,197
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "cloudio", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Collection", ";", "import", "java", ".", "util", ".", "Collections", ";", "import", "java", ".", "util", ".", "Comparator", ";", "import", "java", ".", "util", ".", "EventListener", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "java", ".", "util", ".", "concurrent", ".", "ExecutorService", ";", "import", "java", ".", "util", ".", "concurrent", ".", "Executors", ";", "import", "java", ".", "util", ".", "concurrent", ".", "TimeUnit", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "Assert", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "IProgressMonitor", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "dialogs", ".", "MessageDialog", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "DisposeEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "DisposeListener", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "MouseEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "MouseListener", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "MouseMoveListener", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "MouseTrackListener", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "MouseWheelListener", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionListener", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Color", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Font", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "FontData", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "FontMetrics", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "GC", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Image", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "ImageData", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "PaletteData", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Path", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Point", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Rectangle", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Transform", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Canvas", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Composite", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Event", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Listener", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "ScrollBar", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "cloudio", ".", "layout", ".", "DefaultLayouter", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "cloudio", ".", "layout", ".", "ILayouter", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "cloudio", ".", "util", ".", "CloudMatrix", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "cloudio", ".", "util", ".", "RectTree", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "cloudio", ".", "util", ".", "SmallRect", ";", "public", "class", "TagCloud", "extends", "Canvas", "{", "private", "final", "int", "accuracy", ";", "private", "final", "int", "maxSize", ";", "private", "final", "Rectangle", "cloudArea", ";", "private", "int", "maxFontSize", "=", "100", ";", "private", "final", "GC", "gc", ";", "private", "Color", "highlightColor", ";", "private", "Word", "currentWord", ";", "private", "int", "opacity", "=", "255", ";", "private", "final", "Point", "origin", "=", "new", "Point", "(", "0", ",", "0", ")", ";", "private", "Image", "textLayerImage", ";", "private", "Image", "selectionLayerImage", ";", "private", "Image", "zoomLayerImage", ";", "private", "List", "<", "Word", ">", "wordsToUse", ";", "private", "boolean", "initialized", "=", "false", ";", "private", "double", "currentZoom", "=", "1", ";", "private", "int", "minFontSize", "=", "12", ";", "private", "Set", "<", "Word", ">", "selection", "=", "new", "HashSet", "<", "Word", ">", "(", ")", ";", "private", "CloudMatrix", "cloudMatrix", ";", "private", "ExecutorService", "executors", ";", "private", "ILayouter", "layouter", ";", "private", "int", "boost", ";", "private", "Point", "regionOffset", ";", "private", "int", "antialias", "=", "SWT", ".", "ON", ";", "private", "float", "boostFactor", ";", "private", "Listener", "hBarListener", ";", "private", "Listener", "resizeListener", ";", "private", "Listener", "paintListener", ";", "private", "Listener", "mouseTrackListener", ";", "private", "Listener", "mouseMoveListener", ";", "private", "Listener", "mouseUpListener", ";", "private", "Listener", "mouseDCListener", ";", "private", "Listener", "mouseDownListener", ";", "private", "Listener", "mouseWheelListener", ";", "private", "Listener", "vBarListener", ";", "private", "Set", "<", "EventListener", ">", "mouseWheelListeners", "=", "new", "HashSet", "<", "EventListener", ">", "(", ")", ";", "private", "Set", "<", "EventListener", ">", "mouseTrackListeners", "=", "new", "HashSet", "<", "EventListener", ">", "(", ")", ";", "private", "Set", "<", "EventListener", ">", "mouseMoveListeners", "=", "new", "HashSet", "<", "EventListener", ">", "(", ")", ";", "private", "Set", "<", "EventListener", ">", "mouseListeners", "=", "new", "HashSet", "<", "EventListener", ">", "(", ")", ";", "private", "Set", "<", "SelectionListener", ">", "selectionListeners", "=", "new", "HashSet", "<", "SelectionListener", ">", "(", ")", ";", "private", "ImageData", "mask", ";", "public", "TagCloud", "(", "Composite", "parent", ",", "int", "style", ",", "int", "accuracy", ",", "int", "maxSize", ")", "{", "super", "(", "parent", ",", "style", ")", ";", "Assert", ".", "isLegal", "(", "accuracy", ">", "0", ",", "\"\"", "+", "accuracy", ")", ";", "Assert", ".", "isLegal", "(", "maxSize", ">", "0", ",", "\"\"", "+", "maxSize", ")", ";", "int", "tmp", "=", "maxSize", ";", "while", "(", "tmp", ">", "accuracy", ")", "{", "tmp", "/=", "2", ";", "}", "Assert", ".", "isLegal", "(", "tmp", "==", "accuracy", ",", "\"\"", ")", ";", "this", ".", "accuracy", "=", "accuracy", ";", "this", ".", "maxSize", "=", "maxSize", ";", "cloudArea", "=", "new", "Rectangle", "(", "0", ",", "0", ",", "maxSize", ",", "maxSize", ")", ";", "highlightColor", "=", "new", "Color", "(", "getDisplay", "(", ")", ",", "Display", ".", "getDefault", "(", ")", ".", "getSystemColor", "(", "SWT", ".", "COLOR_RED", ")", ".", "getRGB", "(", ")", ")", ";", "gc", "=", "new", "GC", "(", "this", ")", ";", "layouter", "=", "new", "DefaultLayouter", "(", "accuracy", ",", "accuracy", ")", ";", "setBackground", "(", "new", "Color", "(", "getDisplay", "(", ")", ",", "Display", ".", "getDefault", "(", ")", ".", "getSystemColor", "(", "SWT", ".", "COLOR_BLACK", ")", ".", "getRGB", "(", ")", ")", ")", ";", "initListeners", "(", ")", ";", "textLayerImage", "=", "new", "Image", "(", "getDisplay", "(", ")", ",", "100", ",", "100", ")", ";", "zoomFit", "(", ")", ";", "addDisposeListener", "(", "new", "DisposeListener", "(", ")", "{", "@", "Override", "public", "void", "widgetDisposed", "(", "DisposeEvent", "e", ")", "{", "internalDispose", "(", ")", ";", "}", "}", ")", ";", "}", "public", "TagCloud", "(", "Composite", "parent", ",", "int", "style", ")", "{", "this", "(", "parent", ",", "style", ",", "5", ",", "5120", ")", ";", "}", "private", "void", "internalDispose", "(", ")", "{", "removeListeners", "(", ")", ";", "textLayerImage", ".", "dispose", "(", ")", ";", "if", "(", "selectionLayerImage", "!=", "null", ")", "{", "selectionLayerImage", ".", "dispose", "(", ")", ";", "}", "if", "(", "zoomLayerImage", "!=", "null", ")", "{", "zoomLayerImage", ".", "dispose", "(", ")", ";", "}", "if", "(", "!", "this", ".", "isDisposed", "(", ")", ")", "{", "gc", ".", "dispose", "(", ")", ";", "}", "super", ".", "dispose", "(", ")", ";", "}", "private", "void", "removeListeners", "(", ")", "{", "if", "(", "isDisposed", "(", ")", ")", "return", ";", "removeListener", "(", "SWT", ".", "Paint", ",", "paintListener", ")", ";", "if", "(", "hBarListener", "!=", "null", ")", "{", "removeListener", "(", "SWT", ".", "H_SCROLL", ",", "hBarListener", ")", ";", "}", "if", "(", "vBarListener", "!=", "null", ")", "{", "removeListener", "(", "SWT", ".", "V_SCROLL", ",", "vBarListener", ")", ";", "}", "removeListener", "(", "SWT", ".", "MouseDoubleClick", ",", "mouseDCListener", ")", ";", "removeListener", "(", "SWT", ".", "MouseDown", ",", "mouseDownListener", ")", ";", "removeListener", "(", "SWT", ".", "MouseMove", ",", "mouseTrackListener", ")", ";", "removeListener", "(", "SWT", ".", "MouseUp", ",", "mouseUpListener", ")", ";", "removeListener", "(", "SWT", ".", "Resize", ",", "resizeListener", ")", ";", "removeListener", "(", "SWT", ".", "MouseMove", ",", "mouseMoveListener", ")", ";", "removeListener", "(", "SWT", ".", "MouseWheel", ",", "mouseWheelListener", ")", ";", "}", "public", "void", "zoomReset", "(", ")", "{", "checkWidget", "(", ")", ";", "if", "(", "selectionLayerImage", "==", "null", ")", "return", ";", "zoomLayerImage", "=", "new", "Image", "(", "getDisplay", "(", ")", ",", "selectionLayerImage", ".", "getBounds", "(", ")", ".", "width", ",", "selectionLayerImage", ".", "getBounds", "(", ")", ".", "height", ")", ";", "GC", "gc", "=", "new", "GC", "(", "zoomLayerImage", ")", ";", "gc", ".", "drawImage", "(", "selectionLayerImage", ",", "0", ",", "0", ")", ";", "gc", ".", "dispose", "(", ")", ";", "currentZoom", "=", "1", ";", "updateScrollbars", "(", ")", ";", "redraw", "(", ")", ";", "}", "public", "double", "getZoom", "(", ")", "{", "checkWidget", "(", ")", ";", "return", "currentZoom", ";", "}", "public", "void", "zoomFit", "(", ")", "{", "checkWidget", "(", ")", ";", "if", "(", "selectionLayerImage", "==", "null", ")", "return", ";", "Rectangle", "imageBound", "=", "selectionLayerImage", ".", "getBounds", "(", ")", ";", "Rectangle", "destRect", "=", "getClientArea", "(", ")", ";", "double", "sx", "=", "(", "double", ")", "destRect", ".", "width", "/", "(", "double", ")", "imageBound", ".", "width", ";", "double", "sy", "=", "(", "double", ")", "destRect", ".", "height", "/", "(", "double", ")", "imageBound", ".", "height", ";", "currentZoom", "=", "Math", ".", "min", "(", "sx", ",", "sy", ")", ";", "zoom", "(", "currentZoom", ")", ";", "}", "private", "void", "zoom", "(", "double", "s", ")", "{", "checkWidget", "(", ")", ";", "if", "(", "selectionLayerImage", "==", "null", ")", "return", ";", "if", "(", "s", "<", "0.1", ")", "s", "=", "0.1", ";", "if", "(", "s", ">", "3", ")", "s", "=", "3", ";", "int", "width", "=", "(", "int", ")", "(", "selectionLayerImage", ".", "getBounds", "(", ")", ".", "width", "*", "s", ")", ";", "int", "height", "=", "(", "int", ")", "(", "selectionLayerImage", ".", "getBounds", "(", ")", ".", "height", "*", "s", ")", ";", "if", "(", "width", "==", "0", "||", "height", "==", "0", ")", "return", ";", "zoomLayerImage", "=", "new", "Image", "(", "getDisplay", "(", ")", ",", "width", ",", "height", ")", ";", "Transform", "tf", "=", "new", "Transform", "(", "getDisplay", "(", ")", ")", ";", "tf", ".", "scale", "(", "(", "float", ")", "s", ",", "(", "float", ")", "s", ")", ";", "GC", "gc", "=", "new", "GC", "(", "zoomLayerImage", ")", ";", "gc", ".", "setTransform", "(", "tf", ")", ";", "gc", ".", "drawImage", "(", "selectionLayerImage", ",", "0", ",", "0", ")", ";", "gc", ".", "dispose", "(", ")", ";", "tf", ".", "dispose", "(", ")", ";", "currentZoom", "=", "s", ";", "updateScrollbars", "(", ")", ";", "redraw", "(", ")", ";", "}", "public", "void", "zoomIn", "(", ")", "{", "checkWidget", "(", ")", ";", "zoom", "(", "currentZoom", "*", "1.1", ")", ";", "redraw", "(", ")", ";", "}", "public", "void", "zoomOut", "(", ")", "{", "checkWidget", "(", ")", ";", "zoom", "(", "currentZoom", "*", "0.9", ")", ";", "redraw", "(", ")", ";", "}", "protected", "Rectangle", "getCloudArea", "(", ")", "{", "return", "cloudArea", ";", "}", "private", "float", "getFontSize", "(", "Word", "word", ")", "{", "float", "size", "=", "(", "float", ")", "(", "word", ".", "weight", "*", "maxFontSize", ")", ";", "size", "+=", "minFontSize", ";", "return", "size", ";", "}", "private", "void", "drawWord", "(", "final", "GC", "gc", ",", "final", "Word", "word", ",", "final", "Color", "color", ")", "{", "gc", ".", "setForeground", "(", "color", ")", ";", "Font", "font", "=", "new", "Font", "(", "gc", ".", "getDevice", "(", ")", ",", "word", ".", "getFontData", "(", ")", ")", ";", "gc", ".", "setFont", "(", "font", ")", ";", "gc", ".", "setAntialias", "(", "antialias", ")", ";", "gc", ".", "setAlpha", "(", "opacity", ")", ";", "Point", "stringExtent", "=", "word", ".", "stringExtent", ";", "gc", ".", "setForeground", "(", "color", ")", ";", "int", "xOffset", "=", "word", ".", "x", "-", "regionOffset", ".", "x", ";", "int", "yOffset", "=", "word", ".", "y", "-", "regionOffset", ".", "y", ";", "double", "radian", "=", "Math", ".", "toRadians", "(", "word", ".", "angle", ")", ";", "final", "double", "sin", "=", "Math", ".", "abs", "(", "Math", ".", "sin", "(", "radian", ")", ")", ";", "final", "double", "cos", "=", "Math", ".", "abs", "(", "Math", ".", "cos", "(", "radian", ")", ")", ";", "int", "y", "=", "(", "int", ")", "(", "(", "cos", "*", "stringExtent", ".", "y", ")", "+", "(", "sin", "*", "stringExtent", ".", "x", ")", ")", ";", "Transform", "t", "=", "new", "Transform", "(", "gc", ".", "getDevice", "(", ")", ")", ";", "if", "(", "word", ".", "angle", "<", "0", ")", "{", "t", ".", "translate", "(", "xOffset", ",", "yOffset", "+", "y", "-", "(", "int", ")", "(", "cos", "*", "stringExtent", ".", "y", ")", ")", ";", "}", "else", "{", "t", ".", "translate", "(", "xOffset", "+", "(", "int", ")", "(", "sin", "*", "stringExtent", ".", "y", ")", ",", "yOffset", ")", ";", "}", "t", ".", "rotate", "(", "word", ".", "angle", ")", ";", "gc", ".", "setTransform", "(", "t", ")", ";", "gc", ".", "drawString", "(", "word", ".", "string", ",", "0", ",", "0", ",", "true", ")", ";", "gc", ".", "setTransform", "(", "null", ")", ";", "t", ".", "dispose", "(", ")", ";", "font", ".", "dispose", "(", ")", ";", "}", "protected", "void", "calcExtents", "(", "IProgressMonitor", "monitor", ")", "{", "checkWidget", "(", ")", ";", "if", "(", "monitor", "!=", "null", ")", "{", "monitor", ".", "subTask", "(", "\"\"", ")", ";", "}", "if", "(", "wordsToUse", "==", "null", ")", "return", ";", "double", "step", "=", "80D", "/", "wordsToUse", ".", "size", "(", ")", ";", "double", "current", "=", "0", ";", "int", "next", "=", "10", ";", "executors", "=", "Executors", ".", "newFixedThreadPool", "(", "getNumberOfThreads", "(", ")", ")", ";", "final", "Color", "color", "=", "gc", ".", "getDevice", "(", ")", ".", "getSystemColor", "(", "SWT", ".", "COLOR_BLACK", ")", ";", "for", "(", "final", "Word", "word", ":", "wordsToUse", ")", "{", "FontData", "[", "]", "fontData", "=", "word", ".", "getFontData", "(", ")", ";", "int", "fontSize", "=", "(", "int", ")", "getFontSize", "(", "word", ")", ";", "for", "(", "FontData", "data", ":", "fontData", ")", "{", "data", ".", "setHeight", "(", "(", "int", ")", "fontSize", ")", ";", "}", "final", "Font", "font", "=", "new", "Font", "(", "gc", ".", "getDevice", "(", ")", ",", "fontData", ")", ";", "gc", ".", "setFont", "(", "font", ")", ";", "final", "Point", "stringExtent", "=", "gc", ".", "stringExtent", "(", "word", ".", "string", ")", ";", "FontMetrics", "fm", "=", "gc", ".", "getFontMetrics", "(", ")", ";", "stringExtent", ".", "y", "=", "fm", ".", "getHeight", "(", ")", ";", "executors", ".", "execute", "(", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "double", "radian", "=", "Math", ".", "toRadians", "(", "word", ".", "angle", ")", ";", "final", "double", "sin", "=", "Math", ".", "abs", "(", "Math", ".", "sin", "(", "radian", ")", ")", ";", "final", "double", "cos", "=", "Math", ".", "abs", "(", "Math", ".", "cos", "(", "radian", ")", ")", ";", "final", "int", "x", "=", "(", "int", ")", "(", "(", "cos", "*", "stringExtent", ".", "x", ")", "+", "(", "sin", "*", "stringExtent", ".", "y", ")", ")", ";", "final", "int", "y", "=", "(", "int", ")", "(", "(", "cos", "*", "stringExtent", ".", "y", ")", "+", "(", "sin", "*", "stringExtent", ".", "x", ")", ")", ";", "ImageData", "id", "=", "createImageData", "(", "word", ",", "font", ",", "stringExtent", ",", "sin", ",", "cos", ",", "x", ",", "y", ",", "color", ")", ";", "calcWordExtents", "(", "word", ",", "id", ")", ";", "font", ".", "dispose", "(", ")", ";", "}", "}", ")", ";", "if", "(", "monitor", "!=", "null", ")", "{", "current", "+=", "step", ";", "if", "(", "current", ">", "next", ")", "{", "monitor", ".", "worked", "(", "5", ")", ";", "next", "+=", "5", ";", "}", "}", "}", "executors", ".", "shutdown", "(", ")", ";", "try", "{", "executors", ".", "awaitTermination", "(", "Integer", ".", "MAX_VALUE", ",", "TimeUnit", ".", "SECONDS", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "Collections", ".", "sort", "(", "wordsToUse", ",", "new", "Comparator", "<", "Word", ">", "(", ")", "{", "@", "Override", "public", "int", "compare", "(", "Word", "o1", ",", "Word", "o2", ")", "{", "return", "(", "o2", ".", "width", "*", "o2", ".", "height", ")", "-", "(", "o1", ".", "width", "*", "o1", ".", "height", ")", ";", "}", "}", ")", ";", "short", "i", "=", "1", ";", "for", "(", "Word", "word", ":", "wordsToUse", ")", "{", "word", ".", "id", "=", "i", "++", ";", "}", "}", "private", "ImageData", "createImageData", "(", "final", "Word", "word", ",", "Font", "font", ",", "Point", "stringExtent", ",", "final", "double", "sin", ",", "final", "double", "cos", ",", "int", "x", ",", "int", "y", ",", "Color", "color", ")", "{", "Image", "img", "=", "new", "Image", "(", "null", ",", "x", ",", "y", ")", ";", "word", ".", "width", "=", "x", ";", "word", ".", "height", "=", "y", ";", "word", ".", "stringExtent", "=", "stringExtent", ";", "GC", "g", "=", "new", "GC", "(", "img", ")", ";", "g", ".", "setAntialias", "(", "antialias", ")", ";", "g", ".", "setForeground", "(", "color", ")", ";", "Transform", "t", "=", "new", "Transform", "(", "img", ".", "getDevice", "(", ")", ")", ";", "if", "(", "word", ".", "angle", "<", "0", ")", "{", "t", ".", "translate", "(", "0", ",", "img", ".", "getBounds", "(", ")", ".", "height", "-", "(", "int", ")", "(", "cos", "*", "stringExtent", ".", "y", ")", ")", ";", "}", "else", "{", "t", ".", "translate", "(", "(", "int", ")", "(", "sin", "*", "stringExtent", ".", "y", ")", ",", "0", ")", ";", "}", "t", ".", "rotate", "(", "word", ".", "angle", ")", ";", "g", ".", "setTransform", "(", "t", ")", ";", "g", ".", "setFont", "(", "font", ")", ";", "g", ".", "drawString", "(", "word", ".", "string", ",", "0", ",", "0", ",", "false", ")", ";", "int", "max", "=", "Math", ".", "max", "(", "x", ",", "y", ")", ";", "int", "tmp", "=", "maxSize", ";", "while", "(", "max", "<", "tmp", ")", "{", "tmp", "=", "tmp", "/", "2", ";", "}", "tmp", "=", "tmp", "*", "2", ";", "SmallRect", "root", "=", "new", "SmallRect", "(", "0", ",", "0", ",", "tmp", ",", "tmp", ")", ";", "word", ".", "tree", "=", "new", "RectTree", "(", "root", ",", "accuracy", ")", ";", "final", "ImageData", "id", "=", "img", ".", "getImageData", "(", ")", ";", "g", ".", "dispose", "(", ")", ";", "img", ".", "dispose", "(", ")", ";", "return", "id", ";", "}", "private", "void", "calcWordExtents", "(", "final", "Word", "word", ",", "final", "ImageData", "id", ")", "{", "final", "int", "[", "]", "pixels", "=", "new", "int", "[", "id", ".", "width", "]", ";", "final", "PaletteData", "palette", "=", "id", ".", "palette", ";", "Set", "<", "SmallRect", ">", "inserted", "=", "new", "HashSet", "<", "SmallRect", ">", "(", ")", ";", "for", "(", "int", "y", "=", "0", ";", "y", "<", "id", ".", "height", ";", "y", "++", ")", "{", "id", ".", "getPixels", "(", "0", ",", "y", ",", "id", ".", "width", ",", "pixels", ",", "0", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "pixels", ".", "length", ";", "i", "++", ")", "{", "int", "pixel", "=", "pixels", "[", "i", "]", ";", "int", "r", "=", "pixel", "&", "palette", ".", "redMask", ";", "r", "=", "(", "palette", ".", "redShift", "<", "0", ")", "?", "r", ">>>", "-", "palette", ".", "redShift", ":", "r", "<<", "palette", ".", "redShift", ";", "int", "g", "=", "pixel", "&", "palette", ".", "greenMask", ";", "g", "=", "(", "palette", ".", "greenShift", "<", "0", ")", "?", "g", ">>>", "-", "palette", ".", "greenShift", ":", "g", "<<", "palette", ".", "greenShift", ";", "int", "b", "=", "pixel", "&", "palette", ".", "blueMask", ";", "b", "=", "(", "palette", ".", "blueShift", "<", "0", ")", "?", "b", ">>>", "-", "palette", ".", "blueShift", ":", "b", "<<", "palette", ".", "blueShift", ";", "if", "(", "r", "<", "250", "||", "g", "<", "250", "||", "b", "<", "250", ")", "{", "SmallRect", "rect", "=", "new", "SmallRect", "(", "(", "i", "/", "accuracy", ")", "*", "accuracy", ",", "(", "y", "/", "accuracy", ")", "*", "accuracy", ",", "accuracy", ",", "accuracy", ")", ";", "if", "(", "!", "inserted", ".", "contains", "(", "rect", ")", ")", "{", "word", ".", "tree", ".", "insert", "(", "rect", ",", "word", ".", "id", ")", ";", "inserted", ".", "add", "(", "rect", ")", ";", "}", "i", "+=", "accuracy", "-", "1", ";", "}", "}", "}", "word", ".", "tree", ".", "releaseRects", "(", ")", ";", "}", "protected", "int", "layoutWords", "(", "Collection", "<", "Word", ">", "wordsToUse", ",", "IProgressMonitor", "monitor", ")", "{", "checkWidget", "(", ")", ";", "if", "(", "monitor", "!=", "null", ")", "{", "monitor", ".", "subTask", "(", "\"\"", ")", ";", "}", "Rectangle", "r", "=", "new", "Rectangle", "(", "Integer", ".", "MAX_VALUE", ",", "Integer", ".", "MAX_VALUE", ",", "0", ",", "0", ")", ";", "final", "Rectangle", "cloudArea", "=", "getCloudArea", "(", ")", ";", "int", "w", "=", "cloudArea", ".", "width", ";", "int", "h", "=", "cloudArea", ".", "height", ";", "double", "current", "=", "0", ";", "int", "next", "=", "10", ";", "final", "Image", "tmpImage", "=", "new", "Image", "(", "getDisplay", "(", ")", ",", "w", ",", "h", ")", ";", "GC", "gc", "=", "new", "GC", "(", "tmpImage", ")", ";", "gc", ".", "setBackground", "(", "getBackground", "(", ")", ")", ";", "gc", ".", "setTextAntialias", "(", "SWT", ".", "ON", ")", ";", "gc", ".", "setBackground", "(", "getBackground", "(", ")", ")", ";", "gc", ".", "fillRectangle", "(", "tmpImage", ".", "getBounds", "(", ")", ")", ";", "executors", "=", "Executors", ".", "newFixedThreadPool", "(", "1", ")", ";", "int", "success", "=", "0", ";", "if", "(", "wordsToUse", "!=", "null", ")", "{", "double", "step", "=", "100D", "/", "wordsToUse", ".", "size", "(", ")", ";", "final", "GC", "g", "=", "gc", ";", "for", "(", "Word", "word", ":", "wordsToUse", ")", "{", "Point", "point", "=", "layouter", ".", "getInitialOffset", "(", "word", ",", "cloudArea", ")", ";", "boolean", "result", "=", "layouter", ".", "layout", "(", "point", ",", "word", ",", "cloudArea", ",", "cloudMatrix", ")", ";", "if", "(", "!", "result", ")", "{", "System", ".", "err", ".", "println", "(", "\"\"", "+", "word", ".", "string", ")", ";", "continue", ";", "}", "success", "++", ";", "if", "(", "word", ".", "x", "<", "r", ".", "x", ")", "{", "r", ".", "x", "=", "word", ".", "x", ";", "}", "if", "(", "word", ".", "y", "<", "r", ".", "y", ")", "{", "r", ".", "y", "=", "word", ".", "y", ";", "}", "if", "(", "word", ".", "x", "+", "word", ".", "width", ">", "r", ".", "width", ")", "{", "r", ".", "width", "=", "word", ".", "x", "+", "word", ".", "width", ";", "}", "if", "(", "word", ".", "y", "+", "word", ".", "height", ">", "r", ".", "height", ")", "{", "r", ".", "height", "=", "word", ".", "y", "+", "word", ".", "height", ";", "}", "final", "Word", "wrd", "=", "word", ";", "executors", ".", "execute", "(", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "drawWord", "(", "g", ",", "wrd", ",", "wrd", ".", "getColor", "(", ")", ")", ";", "}", "}", ")", ";", "current", "+=", "step", ";", "if", "(", "current", ">", "next", ")", "{", "next", "+=", "5", ";", "if", "(", "monitor", "!=", "null", ")", "{", "monitor", ".", "worked", "(", "5", ")", ";", "}", "}", "}", "executors", ".", "shutdown", "(", ")", ";", "try", "{", "executors", ".", "awaitTermination", "(", "Integer", ".", "MAX_VALUE", ",", "TimeUnit", ".", "SECONDS", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "gc", ".", "dispose", "(", ")", ";", "if", "(", "success", "==", "0", ")", "return", "success", ";", "if", "(", "textLayerImage", "!=", "null", ")", "{", "textLayerImage", ".", "dispose", "(", ")", ";", "}", "textLayerImage", "=", "new", "Image", "(", "getDisplay", "(", ")", ",", "r", ".", "width", "-", "r", ".", "x", ",", "r", ".", "height", "-", "r", ".", "y", ")", ";", "gc", "=", "new", "GC", "(", "textLayerImage", ")", ";", "gc", ".", "drawImage", "(", "tmpImage", ",", "r", ".", "x", ",", "r", ".", "y", ",", "r", ".", "width", "-", "r", ".", "x", ",", "r", ".", "height", "-", "r", ".", "y", ",", "0", ",", "0", ",", "textLayerImage", ".", "getBounds", "(", ")", ".", "width", ",", "textLayerImage", ".", "getBounds", "(", ")", ".", "height", ")", ";", "this", ".", "regionOffset", "=", "new", "Point", "(", "r", ".", "x", ",", "r", ".", "y", ")", ";", "tmpImage", ".", "dispose", "(", ")", ";", "gc", ".", "dispose", "(", ")", ";", "selectionLayerImage", "=", "new", "Image", "(", "getDisplay", "(", ")", ",", "textLayerImage", ".", "getBounds", "(", ")", ")", ";", "gc", "=", "new", "GC", "(", "selectionLayerImage", ")", ";", "gc", ".", "drawImage", "(", "textLayerImage", ",", "0", ",", "0", ")", ";", "gc", ".", "dispose", "(", ")", ";", "zoomFit", "(", ")", ";", "if", "(", "monitor", "!=", "null", ")", "{", "monitor", ".", "worked", "(", "10", ")", ";", "}", "return", "success", ";", "}", "private", "void", "drawRects", "(", "GC", "gc", ")", "{", "gc", ".", "setBackground", "(", "Display", ".", "getDefault", "(", ")", ".", "getSystemColor", "(", "SWT", ".", "COLOR_RED", ")", ")", ";", "gc", ".", "setAlpha", "(", "120", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "maxSize", ";", "i", "+=", "accuracy", ")", "{", "for", "(", "int", "j", "=", "0", ";", "j", "<", "maxSize", ";", "j", "+=", "accuracy", ")", "{", "if", "(", "!", "cloudMatrix", ".", "isEmpty", "(", "i", "/", "accuracy", ",", "j", "/", "accuracy", ")", ")", "{", "gc", ".", "fillRectangle", "(", "(", "i", ")", ",", "(", "j", ")", ",", "accuracy", ",", "accuracy", ")", ";", "}", "}", "}", "}", "public", "int", "setWords", "(", "List", "<", "Word", ">", "values", ",", "IProgressMonitor", "monitor", ")", "{", "checkWidget", "(", ")", ";", "Assert", ".", "isLegal", "(", "values", "!=", "null", ",", "\"\"", ")", ";", "for", "(", "Word", "word", ":", "values", ")", "{", "Assert", ".", "isLegal", "(", "word", "!=", "null", ",", "\"\"", ")", ";", "Assert", ".", "isLegal", "(", "word", ".", "string", "!=", "null", ",", "\"\"", ")", ";", "Assert", ".", "isLegal", "(", "word", ".", "getColor", "(", ")", "!=", "null", ",", "\"\"", ")", ";", "Assert", ".", "isLegal", "(", "word", ".", "getFontData", "(", ")", "!=", "null", ",", "\"\"", ")", ";", "Assert", ".", "isLegal", "(", "word", ".", "weight", ">=", "0", ",", "\"\"", "+", "word", ".", "weight", ")", ";", "Assert", ".", "isLegal", "(", "word", ".", "weight", "<=", "1", ",", "\"\"", "+", "word", ".", "weight", ")", ";", "Assert", ".", "isLegal", "(", "word", ".", "angle", ">=", "-", "90", ",", "\"\"", "+", "word", ".", "angle", ")", ";", "Assert", ".", "isLegal", "(", "word", ".", "angle", "<=", "90", ",", "\"\"", "+", "word", ".", "angle", ")", ";", "}", "this", ".", "wordsToUse", "=", "new", "ArrayList", "<", "Word", ">", "(", "values", ")", ";", "if", "(", "boost", ">", "0", ")", "{", "double", "factor", "=", "boostFactor", ";", "int", "i", "=", "boost", ";", "for", "(", "Word", "word", ":", "values", ")", "{", "if", "(", "factor", "<=", "1", ")", "{", "break", ";", "}", "word", ".", "weight", "*=", "factor", ";", "factor", "-=", "0.2", ";", "i", "--", ";", "if", "(", "i", "==", "0", ")", "break", ";", "}", "}", "return", "layoutCloud", "(", "monitor", ",", "true", ")", ";", "}", "private", "void", "resetLayout", "(", ")", "{", "if", "(", "cloudMatrix", "==", "null", ")", "{", "cloudMatrix", "=", "new", "CloudMatrix", "(", "maxSize", ",", "accuracy", ")", ";", "}", "else", "{", "cloudMatrix", ".", "reset", "(", ")", ";", "}", "if", "(", "mask", "!=", "null", ")", "{", "resetMask", "(", ")", ";", "}", "}", "public", "void", "setBackgroundMask", "(", "ImageData", "bgData", ")", "{", "if", "(", "mask", "!=", "null", ")", "{", "mask", "=", "null", ";", "}", "if", "(", "bgData", "!=", "null", ")", "{", "Image", "img", "=", "new", "Image", "(", "null", ",", "cloudArea", ".", "width", ",", "cloudArea", ".", "height", ")", ";", "GC", "gc", "=", "new", "GC", "(", "img", ")", ";", "Image", "tmp", "=", "new", "Image", "(", "null", ",", "bgData", ")", ";", "gc", ".", "drawImage", "(", "tmp", ",", "0", ",", "0", ",", "tmp", ".", "getBounds", "(", ")", ".", "width", ",", "tmp", ".", "getBounds", "(", ")", ".", "height", ",", "0", ",", "0", ",", "cloudArea", ".", "width", ",", "cloudArea", ".", "height", ")", ";", "ImageData", "id", "=", "img", ".", "getImageData", "(", ")", ";", "tmp", ".", "dispose", "(", ")", ";", "img", ".", "dispose", "(", ")", ";", "gc", ".", "dispose", "(", ")", ";", "mask", "=", "id", ";", "}", "}", "private", "void", "resetMask", "(", ")", "{", "Word", "word", "=", "new", "Word", "(", "\"mask\"", ")", ";", "word", ".", "tree", "=", "new", "RectTree", "(", "new", "SmallRect", "(", "0", ",", "0", ",", "cloudArea", ".", "width", ",", "cloudArea", ".", "height", ")", ",", "accuracy", ")", ";", "calcWordExtents", "(", "word", ",", "mask", ")", ";", "word", ".", "tree", ".", "place", "(", "cloudMatrix", ",", "RectTree", ".", "BACKGROUND", ")", ";", "}", "private", "int", "getNumberOfThreads", "(", ")", "{", "return", "Runtime", ".", "getRuntime", "(", ")", ".", "availableProcessors", "(", ")", ";", "}", "private", "void", "initListeners", "(", ")", "{", "if", "(", "initialized", ")", "return", ";", "initialized", "=", "true", ";", "final", "ScrollBar", "hBar", "=", "this", ".", "getHorizontalBar", "(", ")", ";", "if", "(", "hBar", "!=", "null", ")", "{", "hBarListener", "=", "new", "Listener", "(", ")", "{", "@", "Override", "public", "void", "handleEvent", "(", "Event", "e", ")", "{", "int", "hSelection", "=", "hBar", ".", "getSelection", "(", ")", ";", "int", "destX", "=", "-", "hSelection", "-", "origin", ".", "x", ";", "Rectangle", "rect", "=", "zoomLayerImage", ".", "getBounds", "(", ")", ";", "TagCloud", ".", "this", ".", "scroll", "(", "destX", ",", "0", ",", "0", ",", "0", ",", "rect", ".", "width", ",", "rect", ".", "height", ",", "false", ")", ";", "origin", ".", "x", "=", "-", "hSelection", ";", "}", "}", ";", "hBar", ".", "addListener", "(", "SWT", ".", "Selection", ",", "hBarListener", ")", ";", "}", "final", "ScrollBar", "vBar", "=", "this", ".", "getVerticalBar", "(", ")", ";", "if", "(", "vBar", "!=", "null", ")", "{", "vBarListener", "=", "new", "Listener", "(", ")", "{", "@", "Override", "public", "void", "handleEvent", "(", "Event", "e", ")", "{", "int", "vSelection", "=", "vBar", ".", "getSelection", "(", ")", ";", "int", "destY", "=", "-", "vSelection", "-", "origin", ".", "y", ";", "Rectangle", "rect", "=", "zoomLayerImage", ".", "getBounds", "(", ")", ";", "TagCloud", ".", "this", ".", "scroll", "(", "0", ",", "destY", ",", "0", ",", "0", ",", "rect", ".", "width", ",", "rect", ".", "height", ",", "false", ")", ";", "origin", ".", "y", "=", "-", "vSelection", ";", "}", "}", ";", "vBar", ".", "addListener", "(", "SWT", ".", "Selection", ",", "vBarListener", ")", ";", "}", "resizeListener", "=", "new", "Listener", "(", ")", "{", "@", "Override", "public", "void", "handleEvent", "(", "Event", "e", ")", "{", "updateScrollbars", "(", ")", ";", "TagCloud", ".", "this", ".", "redraw", "(", ")", ";", "}", "}", ";", "this", ".", "addListener", "(", "SWT", ".", "Resize", ",", "resizeListener", ")", ";", "paintListener", "=", "new", "Listener", "(", ")", "{", "@", "Override", "public", "void", "handleEvent", "(", "Event", "e", ")", "{", "GC", "gc", "=", "e", ".", "gc", ";", "if", "(", "zoomLayerImage", "==", "null", ")", "return", ";", "Rectangle", "rect", "=", "zoomLayerImage", ".", "getBounds", "(", ")", ";", "Rectangle", "client", "=", "TagCloud", ".", "this", ".", "getClientArea", "(", ")", ";", "int", "marginWidth", "=", "client", ".", "width", "-", "rect", ".", "width", ";", "gc", ".", "setBackground", "(", "getBackground", "(", ")", ")", ";", "if", "(", "marginWidth", ">", "0", ")", "{", "gc", ".", "fillRectangle", "(", "rect", ".", "width", ",", "0", ",", "marginWidth", ",", "client", ".", "height", ")", ";", "}", "int", "marginHeight", "=", "client", ".", "height", "-", "rect", ".", "height", ";", "if", "(", "marginHeight", ">", "0", ")", "{", "gc", ".", "fillRectangle", "(", "0", ",", "rect", ".", "height", ",", "client", ".", "width", ",", "marginHeight", ")", ";", "}", "gc", ".", "drawImage", "(", "zoomLayerImage", ",", "origin", ".", "x", ",", "origin", ".", "y", ")", ";", "}", "}", ";", "this", ".", "addListener", "(", "SWT", ".", "Paint", ",", "paintListener", ")", ";", "mouseTrackListener", "=", "new", "Listener", "(", ")", "{", "@", "Override", "public", "void", "handleEvent", "(", "Event", "event", ")", "{", "Word", "word", "=", "getWordAt", "(", "new", "Point", "(", "event", ".", "x", ",", "event", ".", "y", ")", ")", ";", "MouseEvent", "me", "=", "createMouseEvent", "(", "event", ",", "word", ")", ";", "if", "(", "currentWord", "!=", "null", ")", "{", "if", "(", "word", "==", "currentWord", ")", "{", "fireMouseEvent", "(", "me", ",", "SWT", ".", "MouseHover", ",", "mouseTrackListeners", ")", ";", "}", "else", "{", "currentWord", "=", "null", ";", "fireMouseEvent", "(", "me", ",", "SWT", ".", "MouseExit", ",", "mouseTrackListeners", ")", ";", "}", "}", "if", "(", "currentWord", "==", "null", "&&", "word", "!=", "null", ")", "{", "currentWord", "=", "word", ";", "fireMouseEvent", "(", "me", ",", "SWT", ".", "MouseEnter", ",", "mouseTrackListeners", ")", ";", "}", "}", "}", ";", "this", ".", "addListener", "(", "SWT", ".", "MouseMove", ",", "mouseTrackListener", ")", ";", "mouseMoveListener", "=", "new", "Listener", "(", ")", "{", "@", "Override", "public", "void", "handleEvent", "(", "Event", "event", ")", "{", "Word", "word", "=", "getWordAt", "(", "new", "Point", "(", "event", ".", "x", ",", "event", ".", "y", ")", ")", ";", "MouseEvent", "me", "=", "createMouseEvent", "(", "event", ",", "word", ")", ";", "fireMouseEvent", "(", "me", ",", "SWT", ".", "MouseMove", ",", "mouseMoveListeners", ")", ";", "}", "}", ";", "this", ".", "addListener", "(", "SWT", ".", "MouseMove", ",", "mouseMoveListener", ")", ";", "mouseUpListener", "=", "new", "Listener", "(", ")", "{", "@", "Override", "public", "void", "handleEvent", "(", "Event", "event", ")", "{", "Word", "word", "=", "getWordAt", "(", "new", "Point", "(", "event", ".", "x", ",", "event", ".", "y", ")", ")", ";", "MouseEvent", "me", "=", "createMouseEvent", "(", "event", ",", "word", ")", ";", "fireMouseEvent", "(", "me", ",", "SWT", ".", "MouseUp", ",", "mouseListeners", ")", ";", "}", "}", ";", "this", ".", "addListener", "(", "SWT", ".", "MouseUp", ",", "mouseUpListener", ")", ";", "mouseDCListener", "=", "new", "Listener", "(", ")", "{", "@", "Override", "public", "void", "handleEvent", "(", "Event", "event", ")", "{", "Word", "word", "=", "getWordAt", "(", "new", "Point", "(", "event", ".", "x", ",", "event", ".", "y", ")", ")", ";", "MouseEvent", "me", "=", "createMouseEvent", "(", "event", ",", "word", ")", ";", "fireMouseEvent", "(", "me", ",", "SWT", ".", "MouseDoubleClick", ",", "mouseListeners", ")", ";", "}", "}", ";", "this", ".", "addListener", "(", "SWT", ".", "MouseDoubleClick", ",", "mouseDCListener", ")", ";", "mouseDownListener", "=", "new", "Listener", "(", ")", "{", "@", "Override", "public", "void", "handleEvent", "(", "Event", "event", ")", "{", "Word", "word", "=", "getWordAt", "(", "new", "Point", "(", "event", ".", "x", ",", "event", ".", "y", ")", ")", ";", "MouseEvent", "me", "=", "createMouseEvent", "(", "event", ",", "word", ")", ";", "fireMouseEvent", "(", "me", ",", "SWT", ".", "MouseDown", ",", "mouseListeners", ")", ";", "}", "}", ";", "this", ".", "addListener", "(", "SWT", ".", "MouseDown", ",", "mouseDownListener", ")", ";", "mouseWheelListener", "=", "new", "Listener", "(", ")", "{", "@", "Override", "public", "void", "handleEvent", "(", "Event", "event", ")", "{", "Word", "word", "=", "getWordAt", "(", "new", "Point", "(", "event", ".", "x", ",", "event", ".", "y", ")", ")", ";", "MouseEvent", "me", "=", "createMouseEvent", "(", "event", ",", "word", ")", ";", "fireMouseEvent", "(", "me", ",", "SWT", ".", "MouseWheel", ",", "mouseWheelListeners", ")", ";", "}", "}", ";", "this", ".", "addListener", "(", "SWT", ".", "MouseWheel", ",", "mouseWheelListener", ")", ";", "}", "private", "Word", "getWordAt", "(", "Point", "point", ")", "{", "if", "(", "cloudMatrix", "==", "null", "||", "regionOffset", "==", "null", ")", "return", "null", ";", "Point", "translatedMousePos", "=", "translateMousePos", "(", "point", ".", "x", ",", "point", ".", "y", ")", ";", "translatedMousePos", ".", "x", "+=", "regionOffset", ".", "x", ";", "translatedMousePos", ".", "y", "+=", "regionOffset", ".", "y", ";", "int", "x", "=", "translatedMousePos", ".", "x", "/", "accuracy", ";", "int", "y", "=", "translatedMousePos", ".", "y", "/", "accuracy", ";", "if", "(", "x", ">=", "maxSize", "||", "y", ">=", "maxSize", ")", "{", "return", "null", ";", "}", "short", "wordId", "=", "cloudMatrix", ".", "get", "(", "x", ",", "y", ")", ";", "if", "(", "wordId", ">", "0", ")", "{", "Word", "clicked", "=", "wordsToUse", ".", "get", "(", "wordId", "-", "1", ")", ";", "return", "clicked", ";", "}", "return", "null", ";", "}", "private", "Point", "translateMousePos", "(", "final", "int", "x", ",", "final", "int", "y", ")", "{", "final", "Point", "point", "=", "new", "Point", "(", "x", "-", "origin", ".", "x", ",", "y", "-", "origin", ".", "y", ")", ";", "point", ".", "x", "/=", "currentZoom", ";", "point", ".", "y", "/=", "currentZoom", ";", "return", "point", ";", "}", "@", "Override", "public", "void", "addMouseListener", "(", "MouseListener", "listener", ")", "{", "checkWidget", "(", ")", ";", "Assert", ".", "isLegal", "(", "listener", "!=", "null", ")", ";", "mouseListeners", ".", "add", "(", "listener", ")", ";", "}", "@", "Override", "public", "void", "addMouseMoveListener", "(", "MouseMoveListener", "listener", ")", "{", "checkWidget", "(", ")", ";", "Assert", ".", "isLegal", "(", "listener", "!=", "null", ")", ";", "mouseMoveListeners", ".", "add", "(", "listener", ")", ";", "}", "@", "Override", "public", "void", "addMouseTrackListener", "(", "MouseTrackListener", "listener", ")", "{", "checkWidget", "(", ")", ";", "Assert", ".", "isLegal", "(", "listener", "!=", "null", ")", ";", "mouseTrackListeners", ".", "add", "(", "listener", ")", ";", "}", "@", "Override", "public", "void", "addMouseWheelListener", "(", "MouseWheelListener", "listener", ")", "{", "checkWidget", "(", ")", ";", "Assert", ".", "isLegal", "(", "listener", "!=", "null", ")", ";", "mouseWheelListeners", ".", "add", "(", "listener", ")", ";", "}", "public", "void", "addSelectionListener", "(", "SelectionListener", "listener", ")", "{", "checkWidget", "(", ")", ";", "Assert", ".", "isLegal", "(", "listener", "!=", "null", ")", ";", "selectionListeners", ".", "add", "(", "listener", ")", ";", "}", "@", "Override", "public", "void", "removeMouseListener", "(", "MouseListener", "listener", ")", "{", "checkWidget", "(", ")", ";", "mouseListeners", ".", "remove", "(", "listener", ")", ";", "}", "@", "Override", "public", "void", "removeMouseMoveListener", "(", "MouseMoveListener", "listener", ")", "{", "checkWidget", "(", ")", ";", "mouseMoveListeners", ".", "remove", "(", "listener", ")", ";", "}", "@", "Override", "public", "void", "removeMouseTrackListener", "(", "MouseTrackListener", "listener", ")", "{", "checkWidget", "(", ")", ";", "mouseTrackListeners", ".", "remove", "(", "listener", ")", ";", "}", "@", "Override", "public", "void", "removeMouseWheelListener", "(", "MouseWheelListener", "listener", ")", "{", "checkWidget", "(", ")", ";", "mouseWheelListeners", ".", "remove", "(", "listener", ")", ";", "}", "public", "void", "removeSelectionListener", "(", "SelectionListener", "listener", ")", "{", "checkWidget", "(", ")", ";", "selectionListeners", ".", "remove", "(", "listener", ")", ";", "}", "private", "MouseEvent", "createMouseEvent", "(", "Event", "event", ",", "Word", "word", ")", "{", "MouseEvent", "me", "=", "new", "MouseEvent", "(", "event", ")", ";", "me", ".", "x", "=", "event", ".", "x", "-", "origin", ".", "x", ";", "me", ".", "y", "=", "event", ".", "y", "-", "origin", ".", "y", ";", "me", ".", "data", "=", "word", ";", "me", ".", "widget", "=", "TagCloud", ".", "this", ";", "me", ".", "display", "=", "Display", ".", "getCurrent", "(", ")", ";", "return", "me", ";", "}", "private", "void", "fireMouseEvent", "(", "MouseEvent", "me", ",", "int", "type", ",", "Set", "<", "EventListener", ">", "listeners", ")", "{", "for", "(", "EventListener", "listener", ":", "listeners", ")", "{", "if", "(", "listener", "instanceof", "MouseListener", ")", "{", "MouseListener", "ml", "=", "(", "MouseListener", ")", "listener", ";", "switch", "(", "type", ")", "{", "case", "SWT", ".", "MouseUp", ":", "ml", ".", "mouseUp", "(", "me", ")", ";", "break", ";", "case", "SWT", ".", "MouseDoubleClick", ":", "ml", ".", "mouseDoubleClick", "(", "me", ")", ";", "break", ";", "case", "SWT", ".", "MouseDown", ":", "ml", ".", "mouseDown", "(", "me", ")", ";", "break", ";", "}", "}", "if", "(", "listener", "instanceof", "MouseTrackListener", ")", "{", "MouseTrackListener", "ml", "=", "(", "MouseTrackListener", ")", "listener", ";", "switch", "(", "type", ")", "{", "case", "SWT", ".", "MouseEnter", ":", "ml", ".", "mouseEnter", "(", "me", ")", ";", "break", ";", "case", "SWT", ".", "MouseExit", ":", "ml", ".", "mouseExit", "(", "me", ")", ";", "break", ";", "case", "SWT", ".", "MouseHover", ":", "ml", ".", "mouseHover", "(", "me", ")", ";", "break", ";", "}", "}", "if", "(", "listener", "instanceof", "MouseMoveListener", ")", "{", "MouseMoveListener", "ml", "=", "(", "MouseMoveListener", ")", "listener", ";", "switch", "(", "type", ")", "{", "case", "SWT", ".", "MouseMove", ":", "ml", ".", "mouseMove", "(", "me", ")", ";", "break", ";", "}", "}", "if", "(", "listener", "instanceof", "MouseWheelListener", ")", "{", "MouseWheelListener", "ml", "=", "(", "MouseWheelListener", ")", "listener", ";", "switch", "(", "type", ")", "{", "case", "SWT", ".", "MouseWheel", ":", "ml", ".", "mouseScrolled", "(", "me", ")", ";", "break", ";", "}", "}", "}", "}", "public", "void", "setSelection", "(", "Set", "<", "Word", ">", "words", ")", "{", "checkWidget", "(", ")", ";", "Assert", ".", "isNotNull", "(", "words", ",", "\"\"", ")", ";", "if", "(", "wordsToUse", "==", "null", ")", "return", ";", "Set", "<", "Word", ">", "selection", "=", "new", "HashSet", "<", "Word", ">", "(", "words", ")", ";", "selection", ".", "retainAll", "(", "wordsToUse", ")", ";", "int", "w", "=", "textLayerImage", ".", "getBounds", "(", ")", ".", "width", ";", "int", "h", "=", "textLayerImage", ".", "getBounds", "(", ")", ".", "height", ";", "if", "(", "selectionLayerImage", "!=", "null", ")", "{", "selectionLayerImage", ".", "dispose", "(", ")", ";", "}", "selectionLayerImage", "=", "new", "Image", "(", "getDisplay", "(", ")", ",", "w", ",", "h", ")", ";", "GC", "gc", "=", "new", "GC", "(", "selectionLayerImage", ")", ";", "gc", ".", "drawImage", "(", "textLayerImage", ",", "0", ",", "0", ")", ";", "for", "(", "Word", "word", ":", "selection", ")", "{", "drawWord", "(", "gc", ",", "word", ",", "highlightColor", ")", ";", "}", "if", "(", "!", "selection", ".", "equals", "(", "this", ".", "selection", ")", ")", "{", "this", ".", "selection", "=", "selection", ";", "fireSelectionChanged", "(", ")", ";", "}", "gc", ".", "dispose", "(", ")", ";", "zoom", "(", "currentZoom", ")", ";", "redraw", "(", ")", ";", "}", "private", "void", "fireSelectionChanged", "(", ")", "{", "Event", "e", "=", "new", "Event", "(", ")", ";", "e", ".", "widget", "=", "this", ";", "final", "SelectionEvent", "event", "=", "new", "SelectionEvent", "(", "e", ")", ";", "event", ".", "data", "=", "getSelection", "(", ")", ";", "event", ".", "widget", "=", "this", ";", "event", ".", "display", "=", "Display", ".", "getCurrent", "(", ")", ";", "for", "(", "SelectionListener", "listener", ":", "selectionListeners", ")", "{", "listener", ".", "widgetSelected", "(", "event", ")", ";", "}", "}", "public", "void", "redrawTextLayerImage", "(", ")", "{", "if", "(", "wordsToUse", "==", "null", ")", "return", ";", "GC", "gc", "=", "new", "GC", "(", "textLayerImage", ")", ";", "gc", ".", "setBackground", "(", "getBackground", "(", ")", ")", ";", "gc", ".", "fillRectangle", "(", "0", ",", "0", ",", "textLayerImage", ".", "getBounds", "(", ")", ".", "width", ",", "textLayerImage", ".", "getBounds", "(", ")", ".", "height", ")", ";", "for", "(", "Word", "word", ":", "wordsToUse", ")", "{", "drawWord", "(", "gc", ",", "word", ",", "word", ".", "getColor", "(", ")", ")", ";", "}", "gc", ".", "dispose", "(", ")", ";", "setSelection", "(", "getSelection", "(", ")", ")", ";", "}", "public", "Set", "<", "Word", ">", "getSelection", "(", ")", "{", "checkWidget", "(", ")", ";", "Set", "<", "Word", ">", "copy", "=", "new", "HashSet", "<", "Word", ">", "(", "selection", ")", ";", "return", "copy", ";", "}", "public", "void", "setSelectionColor", "(", "Color", "color", ")", "{", "checkWidget", "(", ")", ";", "Assert", ".", "isLegal", "(", "color", "!=", "null", ",", "\"\"", ")", ";", "this", ".", "highlightColor", "=", "color", ";", "}", "@", "Override", "public", "void", "setBackground", "(", "Color", "color", ")", "{", "checkWidget", "(", ")", ";", "Assert", ".", "isLegal", "(", "color", "!=", "null", ",", "\"\"", ")", ";", "super", ".", "setBackground", "(", "color", ")", ";", "}", "public", "int", "layoutCloud", "(", "IProgressMonitor", "monitor", ",", "boolean", "recalc", ")", "{", "checkWidget", "(", ")", ";", "resetLayout", "(", ")", ";", "if", "(", "selectionLayerImage", "!=", "null", ")", "{", "selectionLayerImage", ".", "dispose", "(", ")", ";", "selectionLayerImage", "=", "null", ";", "}", "regionOffset", "=", "new", "Point", "(", "0", ",", "0", ")", ";", "if", "(", "textLayerImage", "!=", "null", ")", "textLayerImage", ".", "dispose", "(", ")", ";", "int", "placedWords", "=", "0", ";", "try", "{", "if", "(", "recalc", ")", "{", "calcExtents", "(", "monitor", ")", ";", "}", "placedWords", "=", "layoutWords", "(", "wordsToUse", ",", "monitor", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "MessageDialog", ".", "openError", "(", "getShell", "(", ")", ",", "\"\"", ",", "\"\"", "+", "e", ".", "getMessage", "(", ")", ")", ";", "e", ".", "printStackTrace", "(", ")", ";", "}", "redraw", "(", ")", ";", "updateScrollbars", "(", ")", ";", "return", "placedWords", ";", "}", "private", "void", "updateScrollbars", "(", ")", "{", "if", "(", "zoomLayerImage", "==", "null", ")", "{", "return", ";", "}", "Rectangle", "rect", "=", "zoomLayerImage", ".", "getBounds", "(", ")", ";", "Rectangle", "client", "=", "getClientArea", "(", ")", ";", "ScrollBar", "hBar", "=", "getHorizontalBar", "(", ")", ";", "ScrollBar", "vBar", "=", "getVerticalBar", "(", ")", ";", "if", "(", "hBar", "!=", "null", ")", "{", "hBar", ".", "setMaximum", "(", "rect", ".", "width", ")", ";", "hBar", ".", "setThumb", "(", "Math", ".", "min", "(", "rect", ".", "width", ",", "client", ".", "width", ")", ")", ";", "int", "hPage", "=", "rect", ".", "width", "-", "client", ".", "width", ";", "int", "hSelection", "=", "hBar", ".", "getSelection", "(", ")", ";", "if", "(", "hSelection", ">=", "hPage", ")", "{", "if", "(", "hPage", "<=", "0", ")", "hSelection", "=", "0", ";", "origin", ".", "x", "=", "-", "hSelection", ";", "}", "}", "if", "(", "vBar", "!=", "null", ")", "{", "vBar", ".", "setMaximum", "(", "rect", ".", "height", ")", ";", "vBar", ".", "setThumb", "(", "Math", ".", "min", "(", "rect", ".", "height", ",", "client", ".", "height", ")", ")", ";", "int", "vPage", "=", "rect", ".", "height", "-", "client", ".", "height", ";", "int", "vSelection", "=", "vBar", ".", "getSelection", "(", ")", ";", "if", "(", "vSelection", ">=", "vPage", ")", "{", "if", "(", "vPage", "<=", "0", ")", "vSelection", "=", "0", ";", "origin", ".", "y", "=", "-", "vSelection", ";", "}", "}", "}", "public", "void", "setMaxFontSize", "(", "int", "maxSize", ")", "{", "checkWidget", "(", ")", ";", "Assert", ".", "isLegal", "(", "maxSize", ">", "0", ",", "\"\"", "+", "maxSize", "+", "\"!\"", ")", ";", "maxFontSize", "=", "maxSize", ";", "}", "public", "void", "setOpacity", "(", "int", "opacity", ")", "{", "checkWidget", "(", ")", ";", "Assert", ".", "isLegal", "(", "opacity", ">", "0", ",", "\"\"", "+", "opacity", ")", ";", "Assert", ".", "isLegal", "(", "opacity", "<", "256", ",", "\"\"", "+", "opacity", ")", ";", "this", ".", "opacity", "=", "opacity", ";", "}", "public", "void", "setMinFontSize", "(", "int", "size", ")", "{", "checkWidget", "(", ")", ";", "Assert", ".", "isLegal", "(", "size", ">", "0", ",", "\"\"", "+", "size", ")", ";", "this", ".", "minFontSize", "=", "size", ";", "}", "public", "ImageData", "getImageData", "(", ")", "{", "checkWidget", "(", ")", ";", "if", "(", "textLayerImage", "==", "null", ")", "return", "null", ";", "return", "textLayerImage", ".", "getImageData", "(", ")", ";", "}", "public", "void", "setBoost", "(", "int", "boost", ")", "{", "checkWidget", "(", ")", ";", "Assert", ".", "isLegal", "(", "boost", ">=", "0", ",", "\"\"", ")", ";", "this", ".", "boost", "=", "boost", ";", "}", "public", "void", "setAntiAlias", "(", "boolean", "enabled", ")", "{", "checkWidget", "(", ")", ";", "if", "(", "enabled", ")", "{", "antialias", "=", "SWT", ".", "ON", ";", "}", "else", "{", "antialias", "=", "SWT", ".", "OFF", ";", "}", "}", "public", "void", "setBoostFactor", "(", "float", "boostFactor", ")", "{", "Assert", ".", "isLegal", "(", "boostFactor", "!=", "0", ")", ";", "this", ".", "boostFactor", "=", "boostFactor", ";", "}", "public", "Color", "getSelectionColor", "(", ")", "{", "return", "highlightColor", ";", "}", "public", "void", "setLayouter", "(", "ILayouter", "layouter", ")", "{", "checkWidget", "(", ")", ";", "Assert", ".", "isLegal", "(", "layouter", "!=", "null", ",", "\"\"", ")", ";", "this", ".", "layouter", "=", "layouter", ";", "}", "public", "int", "getMaxFontSize", "(", ")", "{", "checkWidget", "(", ")", ";", "return", "maxFontSize", ";", "}", "public", "int", "getMinFontSize", "(", ")", "{", "checkWidget", "(", ")", ";", "return", "minFontSize", ";", "}", "public", "int", "getBoost", "(", ")", "{", "checkWidget", "(", ")", ";", "return", "boost", ";", "}", "public", "float", "getBoostFactor", "(", ")", "{", "checkWidget", "(", ")", ";", "return", "boostFactor", ";", "}", "public", "List", "<", "Word", ">", "getWords", "(", ")", "{", "return", "wordsToUse", ";", "}", "public", "ILayouter", "getLayouter", "(", ")", "{", "return", "layouter", ";", "}", "}", "</s>" ]
10,198
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "jface", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "ISelectionChangedListener", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "LabelProvider", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "SelectionChangedEvent", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "StructuredSelection", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "Viewer", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Image", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "layout", ".", "FillLayout", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Shell", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "GraphViewer", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "IGraphContentProvider", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "SpringLayoutAlgorithm", ";", "public", "class", "GraphJFaceSnippet4", "{", "static", "class", "MyContentProvider", "implements", "IGraphContentProvider", "{", "public", "Object", "getDestination", "(", "Object", "rel", ")", "{", "if", "(", "\"Rock2Paper\"", ".", "equals", "(", "rel", ")", ")", "{", "return", "\"Rock\"", ";", "}", "else", "if", "(", "\"\"", ".", "equals", "(", "rel", ")", ")", "{", "return", "\"Paper\"", ";", "}", "else", "if", "(", "\"\"", ".", "equals", "(", "rel", ")", ")", "{", "return", "\"Scissors\"", ";", "}", "return", "null", ";", "}", "public", "Object", "[", "]", "getElements", "(", "Object", "input", ")", "{", "return", "new", "Object", "[", "]", "{", "\"Rock2Paper\"", ",", "\"\"", ",", "\"\"", "}", ";", "}", "public", "Object", "getSource", "(", "Object", "rel", ")", "{", "if", "(", "\"Rock2Paper\"", ".", "equals", "(", "rel", ")", ")", "{", "return", "\"Paper\"", ";", "}", "else", "if", "(", "\"\"", ".", "equals", "(", "rel", ")", ")", "{", "return", "\"Scissors\"", ";", "}", "else", "if", "(", "\"\"", ".", "equals", "(", "rel", ")", ")", "{", "return", "\"Rock\"", ";", "}", "return", "null", ";", "}", "public", "double", "getWeight", "(", "Object", "connection", ")", "{", "return", "0", ";", "}", "public", "void", "dispose", "(", ")", "{", "}", "public", "void", "inputChanged", "(", "Viewer", "viewer", ",", "Object", "oldInput", ",", "Object", "newInput", ")", "{", "}", "}", "static", "class", "MyLabelProvider", "extends", "LabelProvider", "{", "final", "Image", "image", "=", "Display", ".", "getDefault", "(", ")", ".", "getSystemImage", "(", "SWT", ".", "ICON_WARNING", ")", ";", "public", "Image", "getImage", "(", "Object", "element", ")", "{", "if", "(", "element", ".", "equals", "(", "\"Rock\"", ")", "||", "element", ".", "equals", "(", "\"Paper\"", ")", "||", "element", ".", "equals", "(", "\"Scissors\"", ")", ")", "{", "return", "image", ";", "}", "return", "null", ";", "}", "public", "String", "getText", "(", "Object", "element", ")", "{", "return", "element", ".", "toString", "(", ")", ";", "}", "}", "static", "GraphViewer", "viewer", "=", "null", ";", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "Display", "d", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setText", "(", "\"\"", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", "SWT", ".", "VERTICAL", ")", ")", ";", "shell", ".", "setSize", "(", "400", ",", "400", ")", ";", "viewer", "=", "new", "GraphViewer", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "viewer", ".", "setContentProvider", "(", "new", "MyContentProvider", "(", ")", ")", ";", "viewer", ".", "setLabelProvider", "(", "new", "MyLabelProvider", "(", ")", ")", ";", "viewer", ".", "setLayoutAlgorithm", "(", "new", "SpringLayoutAlgorithm", "(", ")", ")", ";", "viewer", ".", "setInput", "(", "new", "Object", "(", ")", ")", ";", "viewer", ".", "addSelectionChangedListener", "(", "new", "ISelectionChangedListener", "(", ")", "{", "public", "void", "selectionChanged", "(", "SelectionChangedEvent", "event", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", "+", "selectionToString", "(", "(", "StructuredSelection", ")", "event", ".", "getSelection", "(", ")", ")", ")", ";", "}", "private", "String", "selectionToString", "(", "StructuredSelection", "selection", ")", "{", "StringBuffer", "stringBuffer", "=", "new", "StringBuffer", "(", ")", ";", "Iterator", "iterator", "=", "selection", ".", "iterator", "(", ")", ";", "boolean", "first", "=", "true", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "if", "(", "first", ")", "{", "first", "=", "false", ";", "}", "else", "{", "stringBuffer", ".", "append", "(", "\"", ":", "\"", ")", ";", "}", "stringBuffer", ".", "append", "(", "iterator", ".", "next", "(", ")", ")", ";", "}", "return", "stringBuffer", ".", "toString", "(", ")", ";", "}", "}", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "}", "}", "</s>" ]
10,199
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "jface", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "LabelProvider", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "Viewer", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Image", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "layout", ".", "FillLayout", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Shell", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "GraphViewer", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "IGraphContentProvider", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "SpringLayoutAlgorithm", ";", "public", "class", "GraphJFaceSnippet2", "{", "static", "class", "MyContentProvider", "implements", "IGraphContentProvider", "{", "public", "Object", "getDestination", "(", "Object", "rel", ")", "{", "if", "(", "\"Rock2Paper\"", ".", "equals", "(", "rel", ")", ")", "{", "return", "\"Rock\"", ";", "}", "else", "if", "(", "\"\"", ".", "equals", "(", "rel", ")", ")", "{", "return", "\"Paper\"", ";", "}", "else", "if", "(", "\"\"", ".", "equals", "(", "rel", ")", ")", "{", "return", "\"Scissors\"", ";", "}", "return", "null", ";", "}", "public", "Object", "[", "]", "getElements", "(", "Object", "input", ")", "{", "return", "new", "Object", "[", "]", "{", "\"Rock2Paper\"", ",", "\"\"", ",", "\"\"", "}", ";", "}", "public", "Object", "getSource", "(", "Object", "rel", ")", "{", "if", "(", "\"Rock2Paper\"", ".", "equals", "(", "rel", ")", ")", "{", "return", "\"Paper\"", ";", "}", "else", "if", "(", "\"\"", ".", "equals", "(", "rel", ")", ")", "{", "return", "\"Scissors\"", ";", "}", "else", "if", "(", "\"\"", ".", "equals", "(", "rel", ")", ")", "{", "return", "\"Rock\"", ";", "}", "return", "null", ";", "}", "public", "double", "getWeight", "(", "Object", "connection", ")", "{", "return", "0", ";", "}", "public", "void", "dispose", "(", ")", "{", "}", "public", "void", "inputChanged", "(", "Viewer", "viewer", ",", "Object", "oldInput", ",", "Object", "newInput", ")", "{", "}", "}", "static", "class", "MyLabelProvider", "extends", "LabelProvider", "{", "final", "Image", "image", "=", "Display", ".", "getDefault", "(", ")", ".", "getSystemImage", "(", "SWT", ".", "ICON_WARNING", ")", ";", "public", "Image", "getImage", "(", "Object", "element", ")", "{", "if", "(", "element", ".", "equals", "(", "\"Rock\"", ")", "||", "element", ".", "equals", "(", "\"Paper\"", ")", "||", "element", ".", "equals", "(", "\"Scissors\"", ")", ")", "{", "return", "image", ";", "}", "return", "null", ";", "}", "public", "String", "getText", "(", "Object", "element", ")", "{", "return", "element", ".", "toString", "(", ")", ";", "}", "}", "static", "GraphViewer", "viewer", "=", "null", ";", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "Display", "d", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setText", "(", "\"\"", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", "SWT", ".", "VERTICAL", ")", ")", ";", "shell", ".", "setSize", "(", "400", ",", "400", ")", ";", "viewer", "=", "new", "GraphViewer", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "viewer", ".", "setContentProvider", "(", "new", "MyContentProvider", "(", ")", ")", ";", "viewer", ".", "setLabelProvider", "(", "new", "MyLabelProvider", "(", ")", ")", ";", "viewer", ".", "setLayoutAlgorithm", "(", "new", "SpringLayoutAlgorithm", "(", ")", ")", ";", "viewer", ".", "setInput", "(", "new", "Object", "(", ")", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "}", "}", "</s>" ]