id
int32
0
12.9k
code
sequencelengths
2
264k
10,200
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "jface", ";", "import", "java", ".", "io", ".", "BufferedReader", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileReader", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "StringTokenizer", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "LabelProvider", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "Viewer", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "layout", ".", "FillLayout", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "FileDialog", ";", "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", ".", "RadialLayoutAlgorithm", ";", "public", "class", "GraphJFaceSnippet3", "{", "public", "static", "final", "String", "graph", "=", "\"a", "calls", "bn\"", "+", "\"a", "calls", "cn\"", "+", "\"b", "calld", "dn\"", "+", "\"b", "calls", "en\"", "+", "\"c", "calls", "fn\"", "+", "\"c", "calls", "gn\"", "+", "\"d", "calls", "hn\"", "+", "\"d", "calls", "in\"", "+", "\"e", "calls", "jn\"", "+", "\"e", "calls", "kn\"", "+", "\"f", "calls", "ln\"", "+", "\"f", "calls", "mn\"", ";", "static", "class", "SimpleGraphContentProvider", "implements", "IGraphContentProvider", "{", "private", "StringTokenizer", "graph", ";", "public", "Object", "getDestination", "(", "Object", "rel", ")", "{", "String", "string", "=", "(", "String", ")", "rel", ";", "String", "[", "]", "parts", "=", "string", ".", "split", "(", "\"", "\"", ")", ";", "return", "parts", "[", "2", "]", ";", "}", "public", "Object", "[", "]", "getElements", "(", "Object", "input", ")", "{", "ArrayList", "listOfEdges", "=", "new", "ArrayList", "(", ")", ";", "while", "(", "graph", ".", "hasMoreTokens", "(", ")", ")", "{", "listOfEdges", ".", "add", "(", "graph", ".", "nextToken", "(", ")", ")", ";", "}", "return", "listOfEdges", ".", "toArray", "(", ")", ";", "}", "public", "Object", "getSource", "(", "Object", "rel", ")", "{", "String", "string", "=", "(", "String", ")", "rel", ";", "String", "[", "]", "parts", "=", "string", ".", "split", "(", "\"", "\"", ")", ";", "return", "parts", "[", "0", "]", ";", "}", "public", "double", "getWeight", "(", "Object", "connection", ")", "{", "return", "0", ";", "}", "public", "void", "dispose", "(", ")", "{", "}", "public", "void", "inputChanged", "(", "Viewer", "viewer", ",", "Object", "oldInput", ",", "Object", "newInput", ")", "{", "if", "(", "newInput", "!=", "null", ")", "{", "graph", "=", "new", "StringTokenizer", "(", "(", "String", ")", "newInput", ",", "\"n\"", ")", ";", "}", "}", "}", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "throws", "IOException", "{", "Display", "display", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "display", ")", ";", "shell", ".", "setText", "(", "\"\"", ")", ";", "FileDialog", "dialog", "=", "new", "FileDialog", "(", "shell", ",", "SWT", ".", "OPEN", ")", ";", "dialog", ".", "setFilterNames", "(", "new", "String", "[", "]", "{", "\"\"", ",", "\"\"", "}", ")", ";", "dialog", ".", "setFilterExtensions", "(", "new", "String", "[", "]", "{", "\"*.sgf\"", ",", "\"*.*\"", "}", ")", ";", "String", "directory", "=", "System", ".", "getProperty", "(", "\"user.dir\"", ")", "+", "\"\"", ";", "System", ".", "out", ".", "println", "(", "directory", ")", ";", "dialog", ".", "setFilterPath", "(", "directory", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", "SWT", ".", "VERTICAL", ")", ")", ";", "shell", ".", "setSize", "(", "400", ",", "400", ")", ";", "GraphViewer", "viewer", "=", "null", ";", "viewer", "=", "new", "GraphViewer", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "viewer", ".", "setContentProvider", "(", "new", "SimpleGraphContentProvider", "(", ")", ")", ";", "viewer", ".", "setLabelProvider", "(", "new", "LabelProvider", "(", ")", ")", ";", "viewer", ".", "setLayoutAlgorithm", "(", "new", "RadialLayoutAlgorithm", "(", ")", ")", ";", "shell", ".", "open", "(", ")", ";", "String", "fileName", "=", "dialog", ".", "open", "(", ")", ";", "if", "(", "fileName", "==", "null", ")", "{", "viewer", ".", "setInput", "(", "graph", ")", ";", "}", "else", "{", "FileReader", "fileReader", "=", "new", "FileReader", "(", "new", "File", "(", "fileName", ")", ")", ";", "BufferedReader", "bufferedReader", "=", "new", "BufferedReader", "(", "fileReader", ")", ";", "StringBuffer", "stringBuffer", "=", "new", "StringBuffer", "(", ")", ";", "while", "(", "bufferedReader", ".", "ready", "(", ")", ")", "{", "stringBuffer", ".", "append", "(", "bufferedReader", ".", "readLine", "(", ")", "+", "\"n\"", ")", ";", "}", "viewer", ".", "setInput", "(", "stringBuffer", ".", "toString", "(", ")", ")", ";", "}", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "if", "(", "!", "display", ".", "readAndDispatch", "(", ")", ")", "{", "display", ".", "sleep", "(", ")", ";", "}", "}", "display", ".", "dispose", "(", ")", ";", "}", "}", "</s>" ]
10,201
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "jface", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Graphics", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "GridData", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "GridLayout", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "IFigure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Label", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "RectangleFigure", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "LabelProvider", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "Viewer", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Color", ";", "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", ".", "EntityConnectionData", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "GraphViewer", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "IFigureProvider", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "IGraphEntityContentProvider", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "ILabeledFigure", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "IStyleableFigure", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "SpringLayoutAlgorithm", ";", "public", "class", "CustomFigureJFaceSnippet", "{", "public", "static", "class", "RectLabelFigure", "extends", "RectangleFigure", "implements", "ILabeledFigure", ",", "IStyleableFigure", "{", "private", "Label", "label", ";", "private", "Color", "borderColor", ";", "public", "RectLabelFigure", "(", ")", "{", "super", "(", ")", ";", "setLayoutManager", "(", "new", "GridLayout", "(", "1", ",", "true", ")", ")", ";", "label", "=", "new", "Label", "(", ")", ";", "add", "(", "label", ")", ";", "GridData", "gd", "=", "new", "GridData", "(", "GridData", ".", "FILL", ",", "GridData", ".", "FILL", ",", "true", ",", "true", ")", ";", "setConstraint", "(", "label", ",", "gd", ")", ";", "}", "protected", "void", "outlineShape", "(", "Graphics", "graphics", ")", "{", "graphics", ".", "setForegroundColor", "(", "borderColor", ")", ";", "super", ".", "outlineShape", "(", "graphics", ")", ";", "}", "public", "void", "setBorderColor", "(", "Color", "borderColor", ")", "{", "this", ".", "borderColor", "=", "borderColor", ";", "}", "public", "void", "setBorderWidth", "(", "int", "borderWidth", ")", "{", "setLineWidth", "(", "borderWidth", ")", ";", "}", "public", "void", "setText", "(", "String", "text", ")", "{", "label", ".", "setText", "(", "text", ")", ";", "adjustSize", "(", ")", ";", "}", "public", "String", "getText", "(", ")", "{", "return", "label", ".", "getText", "(", ")", ";", "}", "public", "void", "setIcon", "(", "Image", "icon", ")", "{", "label", ".", "setIcon", "(", "icon", ")", ";", "adjustSize", "(", ")", ";", "}", "public", "Image", "getIcon", "(", ")", "{", "return", "label", ".", "getIcon", "(", ")", ";", "}", "protected", "void", "adjustSize", "(", ")", "{", "setSize", "(", "getPreferredSize", "(", ")", ")", ";", "}", "}", "static", "class", "MyContentProvider", "implements", "IGraphEntityContentProvider", "{", "public", "Object", "[", "]", "getConnectedTo", "(", "Object", "entity", ")", "{", "if", "(", "entity", ".", "equals", "(", "\"One\"", ")", ")", "{", "return", "new", "Object", "[", "]", "{", "\"Two\"", "}", ";", "}", "if", "(", "entity", ".", "equals", "(", "\"Two\"", ")", ")", "{", "return", "new", "Object", "[", "]", "{", "\"Three\"", "}", ";", "}", "if", "(", "entity", ".", "equals", "(", "\"Three\"", ")", ")", "{", "return", "new", "Object", "[", "]", "{", "\"One\"", "}", ";", "}", "return", "null", ";", "}", "public", "Object", "[", "]", "getElements", "(", "Object", "inputElement", ")", "{", "return", "new", "String", "[", "]", "{", "\"One\"", ",", "\"Two\"", ",", "\"Three\"", "}", ";", "}", "public", "void", "dispose", "(", ")", "{", "}", "public", "void", "inputChanged", "(", "Viewer", "viewer", ",", "Object", "oldInput", ",", "Object", "newInput", ")", "{", "}", "}", "static", "class", "MyLabelProvider", "extends", "LabelProvider", "implements", "IFigureProvider", "{", "final", "Image", "image", "=", "Display", ".", "getDefault", "(", ")", ".", "getSystemImage", "(", "SWT", ".", "ICON_INFORMATION", ")", ";", "public", "Image", "getImage", "(", "Object", "element", ")", "{", "if", "(", "element", "instanceof", "EntityConnectionData", ")", "{", "return", "null", ";", "}", "return", "image", ";", "}", "public", "String", "getText", "(", "Object", "element", ")", "{", "if", "(", "element", "instanceof", "EntityConnectionData", ")", "{", "return", "null", ";", "}", "return", "element", ".", "toString", "(", ")", ";", "}", "public", "IFigure", "getFigure", "(", "Object", "element", ")", "{", "return", "new", "RectLabelFigure", "(", ")", ";", "}", "}", "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>" ]
10,202
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "jface", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "ISelectionChangedListener", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "LabelProvider", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "SelectionChangedEvent", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "Viewer", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionAdapter", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Image", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "layout", ".", "FillLayout", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Button", ";", "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", ".", "IGraphEntityContentProvider", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "SpringLayoutAlgorithm", ";", "public", "class", "GraphJFaceSnippet1", "{", "static", "class", "MyContentProvider", "implements", "IGraphEntityContentProvider", "{", "public", "Object", "[", "]", "getConnectedTo", "(", "Object", "entity", ")", "{", "if", "(", "entity", ".", "equals", "(", "\"First\"", ")", ")", "{", "return", "new", "Object", "[", "]", "{", "\"Second\"", "}", ";", "}", "if", "(", "entity", ".", "equals", "(", "\"Second\"", ")", ")", "{", "return", "new", "Object", "[", "]", "{", "\"Third\"", "}", ";", "}", "if", "(", "entity", ".", "equals", "(", "\"Third\"", ")", ")", "{", "return", "new", "Object", "[", "]", "{", "\"First\"", "}", ";", "}", "return", "null", ";", "}", "public", "Object", "[", "]", "getElements", "(", "Object", "inputElement", ")", "{", "return", "new", "String", "[", "]", "{", "\"First\"", ",", "\"Second\"", ",", "\"Third\"", "}", ";", "}", "public", "double", "getWeight", "(", "Object", "entity1", ",", "Object", "entity2", ")", "{", "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", "instanceof", "String", ")", "{", "return", "image", ";", "}", "return", "null", ";", "}", "public", "String", "getText", "(", "Object", "element", ")", "{", "if", "(", "element", "instanceof", "String", ")", "{", "return", "element", ".", "toString", "(", ")", ";", "}", "return", "null", ";", "}", "}", "static", "GraphViewer", "viewer", "=", "null", ";", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "Display", "d", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", "SWT", ".", "VERTICAL", ")", ")", ";", "shell", ".", "setSize", "(", "400", ",", "400", ")", ";", "Button", "button", "=", "new", "Button", "(", "shell", ",", "SWT", ".", "PUSH", ")", ";", "button", ".", "setText", "(", "\"Reload\"", ")", ";", "button", ".", "addSelectionListener", "(", "new", "SelectionAdapter", "(", ")", "{", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "viewer", ".", "setInput", "(", "new", "Object", "(", ")", ")", ";", "}", "}", ")", ";", "viewer", "=", "new", "GraphViewer", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "viewer", ".", "setContentProvider", "(", "new", "MyContentProvider", "(", ")", ")", ";", "viewer", ".", "setLabelProvider", "(", "new", "MyLabelProvider", "(", ")", ")", ";", "viewer", ".", "setLayoutAlgorithm", "(", "new", "SpringLayoutAlgorithm", "(", ")", ")", ";", "viewer", ".", "addSelectionChangedListener", "(", "new", "ISelectionChangedListener", "(", ")", "{", "public", "void", "selectionChanged", "(", "SelectionChangedEvent", "event", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", "+", "(", "event", ".", "getSelection", "(", ")", ")", ")", ";", "}", "}", ")", ";", "viewer", ".", "setInput", "(", "new", "Object", "(", ")", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "}", "}", "</s>" ]
10,203
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "jface", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "LabelProvider", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "Viewer", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "SpringLayoutAlgorithm", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "GraphViewer", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "IGraphContentProvider", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionAdapter", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Image", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "layout", ".", "FillLayout", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "layout", ".", "GridData", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "layout", ".", "GridLayout", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Button", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Composite", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Shell", ";", "public", "class", "GraphJFaceSnippet5", "{", "static", "class", "MyContentProvider", "implements", "IGraphContentProvider", "{", "Object", "[", "]", "elements", "=", "new", "Object", "[", "]", "{", "\"Rock2Paper\"", ",", "\"\"", ",", "\"\"", "}", ";", "public", "Object", "getDestination", "(", "Object", "rel", ")", "{", "if", "(", "\"Rock2Paper\"", ".", "equals", "(", "rel", ")", ")", "{", "return", "\"Rock\"", ";", "}", "else", "if", "(", "\"\"", ".", "equals", "(", "rel", ")", "||", "\"\"", ".", "equals", "(", "rel", ")", ")", "{", "return", "\"Paper\"", ";", "}", "else", "if", "(", "\"\"", ".", "equals", "(", "rel", ")", ")", "{", "return", "\"Scissors\"", ";", "}", "return", "null", ";", "}", "public", "Object", "[", "]", "getElements", "(", "Object", "input", ")", "{", "return", "elements", ";", "}", "public", "Object", "getSource", "(", "Object", "rel", ")", "{", "if", "(", "\"Rock2Paper\"", ".", "equals", "(", "rel", ")", ")", "{", "return", "\"Paper\"", ";", "}", "else", "if", "(", "\"\"", ".", "equals", "(", "rel", ")", "||", "\"\"", ".", "equals", "(", "rel", ")", ")", "{", "return", "\"Scissors\"", ";", "}", "else", "if", "(", "\"\"", ".", "equals", "(", "rel", ")", ")", "{", "return", "\"Rock\"", ";", "}", "return", "null", ";", "}", "public", "void", "setElements", "(", "Object", "[", "]", "elements", ")", "{", "this", ".", "elements", "=", "elements", ";", "}", "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", "MyLabelProvider", "(", ")", "{", "}", "public", "String", "getText", "(", "Object", "element", ")", "{", "return", "element", ".", "toString", "(", ")", ";", "}", "public", "Image", "getImage", "(", "Object", "element", ")", "{", "return", "image", ";", "}", "}", "static", "GraphViewer", "viewer", "=", "null", ";", "private", "static", "MyContentProvider", "contentProvider", ";", "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", ")", ";", "Composite", "parent", "=", "new", "Composite", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "parent", ".", "setLayout", "(", "new", "GridLayout", "(", "2", ",", "false", ")", ")", ";", "buildViewer", "(", "parent", ")", ";", "buildButton", "(", "parent", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "}", "private", "static", "void", "buildButton", "(", "Composite", "parent", ")", "{", "Button", "button", "=", "new", "Button", "(", "parent", ",", "SWT", ".", "PUSH", ")", ";", "button", ".", "setText", "(", "\"Refresh\"", ")", ";", "button", ".", "addSelectionListener", "(", "new", "SelectionAdapter", "(", ")", "{", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "contentProvider", ".", "setElements", "(", "new", "Object", "[", "]", "{", "\"Rock2Paper\"", ",", "\"\"", ",", "\"\"", "}", ")", ";", "viewer", ".", "refresh", "(", ")", ";", "}", "}", ")", ";", "}", "private", "static", "void", "buildViewer", "(", "Composite", "parent", ")", "{", "viewer", "=", "new", "GraphViewer", "(", "parent", ",", "SWT", ".", "NONE", ")", ";", "viewer", ".", "getGraphControl", "(", ")", ".", "setLayoutData", "(", "new", "GridData", "(", "SWT", ".", "FILL", ",", "SWT", ".", "FILL", ",", "true", ",", "true", ")", ")", ";", "contentProvider", "=", "new", "MyContentProvider", "(", ")", ";", "viewer", ".", "setContentProvider", "(", "contentProvider", ")", ";", "viewer", ".", "setLabelProvider", "(", "new", "MyLabelProvider", "(", ")", ")", ";", "viewer", ".", "setLayoutAlgorithm", "(", "new", "SpringLayoutAlgorithm", "(", ")", ")", ";", "viewer", ".", "setInput", "(", "new", "Object", "(", ")", ")", ";", "}", "}", "</s>" ]
10,204
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "jface", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ConnectionRouter", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "IFigure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ManhattanConnectionRouter", ";", "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", ".", "Color", ";", "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", ".", "IConnectionStyleProvider", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "IEntityConnectionStyleProvider", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "IGraphContentProvider", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "SpringLayoutAlgorithm", ";", "public", "class", "ManhattanLayoutJFaceSnippet", "{", "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", "MyConnectionRelationLabelProvider", "extends", "LabelProvider", "implements", "IConnectionStyleProvider", "{", "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", "(", ")", ";", "}", "public", "ConnectionRouter", "getRouter", "(", "Object", "rel", ")", "{", "if", "(", "!", "rel", ".", "equals", "(", "\"\"", ")", ")", "return", "new", "ManhattanConnectionRouter", "(", ")", ";", "else", "return", "null", ";", "}", "public", "int", "getConnectionStyle", "(", "Object", "rel", ")", "{", "return", "SWT", ".", "NONE", ";", "}", "public", "Color", "getColor", "(", "Object", "rel", ")", "{", "return", "null", ";", "}", "public", "Color", "getHighlightColor", "(", "Object", "rel", ")", "{", "return", "null", ";", "}", "public", "int", "getLineWidth", "(", "Object", "rel", ")", "{", "return", "-", "1", ";", "}", "public", "IFigure", "getTooltip", "(", "Object", "entity", ")", "{", "return", "null", ";", "}", "}", "static", "class", "MyEndpointEntityLabelProvider", "extends", "LabelProvider", "implements", "IEntityConnectionStyleProvider", "{", "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", "(", ")", ";", "}", "public", "ConnectionRouter", "getRouter", "(", "Object", "src", ",", "Object", "dest", ")", "{", "System", ".", "out", ".", "println", "(", "src", "+", "\"", "->", "\"", "+", "dest", ")", ";", "if", "(", "!", "(", "src", ".", "equals", "(", "\"Paper\"", ")", "&&", "dest", ".", "equals", "(", "\"Rock\"", ")", ")", ")", "return", "new", "ManhattanConnectionRouter", "(", ")", ";", "else", "return", "null", ";", "}", "public", "int", "getConnectionStyle", "(", "Object", "src", ",", "Object", "dest", ")", "{", "return", "SWT", ".", "NONE", ";", "}", "public", "Color", "getColor", "(", "Object", "src", ",", "Object", "dest", ")", "{", "return", "null", ";", "}", "public", "Color", "getHighlightColor", "(", "Object", "src", ",", "Object", "dest", ")", "{", "return", "null", ";", "}", "public", "int", "getLineWidth", "(", "Object", "src", ",", "Object", "dest", ")", "{", "return", "-", "1", ";", "}", "public", "IFigure", "getTooltip", "(", "Object", "src", ",", "Object", "dest", ")", "{", "return", "null", ";", "}", "}", "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", "MyConnectionRelationLabelProvider", "(", ")", ")", ";", "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,205
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "jface", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "IFigure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Label", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "LabelProvider", ";", "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", ".", "Font", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Image", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "layout", ".", "FillLayout", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Button", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Shell", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "EntityConnectionData", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "GraphViewer", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "IFigureProvider", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "IGraphEntityContentProvider", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "INestedContentProvider", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "uml", ".", "UMLClassFigure", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "SpringLayoutAlgorithm", ";", "public", "class", "GraphJFaceSnippet7", "{", "public", "static", "IFigure", "createClassFigure1", "(", "Font", "classFont", ",", "Image", "classImage", ",", "Image", "publicField", ",", "Image", "privateField", ")", "{", "Label", "classLabel1", "=", "new", "Label", "(", "\"Table\"", ",", "classImage", ")", ";", "classLabel1", ".", "setFont", "(", "classFont", ")", ";", "UMLClassFigure", "classFigure", "=", "new", "UMLClassFigure", "(", "classLabel1", ")", ";", "Label", "attribute1", "=", "new", "Label", "(", "\"\"", ",", "privateField", ")", ";", "Label", "attribute2", "=", "new", "Label", "(", "\"rows:", "Row[]\"", ",", "privateField", ")", ";", "Label", "method1", "=", "new", "Label", "(", "\"\"", ",", "publicField", ")", ";", "Label", "method2", "=", "new", "Label", "(", "\"\"", ",", "publicField", ")", ";", "classFigure", ".", "getAttributesCompartment", "(", ")", ".", "add", "(", "attribute1", ")", ";", "classFigure", ".", "getAttributesCompartment", "(", ")", ".", "add", "(", "attribute2", ")", ";", "classFigure", ".", "getMethodsCompartment", "(", ")", ".", "add", "(", "method1", ")", ";", "classFigure", ".", "getMethodsCompartment", "(", ")", ".", "add", "(", "method2", ")", ";", "classFigure", ".", "setSize", "(", "-", "1", ",", "-", "1", ")", ";", "return", "classFigure", ";", "}", "static", "class", "MyContentProvider", "implements", "IGraphEntityContentProvider", ",", "INestedContentProvider", "{", "public", "Object", "[", "]", "getConnectedTo", "(", "Object", "entity", ")", "{", "if", "(", "entity", ".", "equals", "(", "\"First\"", ")", ")", "{", "return", "new", "Object", "[", "]", "{", "\"Second\"", "}", ";", "}", "if", "(", "entity", ".", "equals", "(", "\"Second\"", ")", ")", "{", "return", "new", "Object", "[", "]", "{", "\"Third\"", ",", "\"rock\"", "}", ";", "}", "if", "(", "entity", ".", "equals", "(", "\"Third\"", ")", ")", "{", "return", "new", "Object", "[", "]", "{", "\"First\"", "}", ";", "}", "if", "(", "entity", ".", "equals", "(", "\"rock\"", ")", ")", "{", "return", "new", "Object", "[", "]", "{", "\"paper\"", "}", ";", "}", "return", "null", ";", "}", "public", "Object", "[", "]", "getElements", "(", "Object", "inputElement", ")", "{", "return", "new", "String", "[", "]", "{", "\"First\"", ",", "\"Second\"", ",", "\"Third\"", "}", ";", "}", "public", "double", "getWeight", "(", "Object", "entity1", ",", "Object", "entity2", ")", "{", "return", "0", ";", "}", "public", "void", "dispose", "(", ")", "{", "}", "public", "void", "inputChanged", "(", "Viewer", "viewer", ",", "Object", "oldInput", ",", "Object", "newInput", ")", "{", "}", "public", "Object", "[", "]", "getChildren", "(", "Object", "element", ")", "{", "return", "new", "Object", "[", "]", "{", "\"rock\"", ",", "\"paper\"", ",", "\"scissors\"", "}", ";", "}", "public", "boolean", "hasChildren", "(", "Object", "element", ")", "{", "if", "(", "element", ".", "equals", "(", "\"First\"", ")", ")", "return", "true", ";", "return", "false", ";", "}", "}", "static", "class", "MyLabelProvider", "extends", "LabelProvider", "implements", "IFigureProvider", "{", "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", ")", "{", "if", "(", "element", "instanceof", "EntityConnectionData", ")", "return", "\"\"", ";", "return", "element", ".", "toString", "(", ")", ";", "}", "public", "IFigure", "getFigure", "(", "Object", "element", ")", "{", "Font", "classFont", "=", "new", "Font", "(", "null", ",", "\"Arial\"", ",", "12", ",", "SWT", ".", "BOLD", ")", ";", "Image", "classImage", "=", "new", "Image", "(", "Display", ".", "getDefault", "(", ")", ",", "UMLClassFigure", ".", "class", ".", "getResourceAsStream", "(", "\"\"", ")", ")", ";", "Image", "privateField", "=", "new", "Image", "(", "Display", ".", "getDefault", "(", ")", ",", "UMLClassFigure", ".", "class", ".", "getResourceAsStream", "(", "\"\"", ")", ")", ";", "Image", "publicField", "=", "new", "Image", "(", "Display", ".", "getDefault", "(", ")", ",", "UMLClassFigure", ".", "class", ".", "getResourceAsStream", "(", "\"\"", ")", ")", ";", "return", "createClassFigure1", "(", "classFont", ",", "classImage", ",", "publicField", ",", "privateField", ")", ";", "}", "}", "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", "(", ")", ")", ";", "Button", "button", "=", "new", "Button", "(", "shell", ",", "SWT", ".", "PUSH", ")", ";", "button", ".", "setText", "(", "\"push\"", ")", ";", "button", ".", "addSelectionListener", "(", "new", "SelectionListener", "(", ")", "{", "public", "void", "widgetDefaultSelected", "(", "SelectionEvent", "e", ")", "{", "}", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "viewer", ".", "setInput", "(", "new", "Object", "(", ")", ")", ";", "}", "}", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "}", "}", "</s>" ]
10,206
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "jface", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "ISelectionChangedListener", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "ITreeContentProvider", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "LabelProvider", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "SelectionChangedEvent", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "Viewer", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionAdapter", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Image", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "layout", ".", "FillLayout", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Button", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Shell", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "GraphViewer", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "TreeLayoutAlgorithm", ";", "public", "class", "GraphJFaceSnippet9", "{", "static", "class", "MyContentProvider", "implements", "ITreeContentProvider", "{", "private", "static", "final", "String", "n1", "=", "\"First\"", ",", "n2", "=", "\"Second\"", ",", "n3", "=", "\"Third\"", ",", "n4", "=", "\"Fourth\"", ";", "public", "Object", "[", "]", "getElements", "(", "Object", "inputElement", ")", "{", "return", "new", "String", "[", "]", "{", "n1", "}", ";", "}", "public", "void", "dispose", "(", ")", "{", "}", "public", "void", "inputChanged", "(", "Viewer", "viewer", ",", "Object", "oldInput", ",", "Object", "newInput", ")", "{", "}", "public", "Object", "[", "]", "getChildren", "(", "Object", "parentElement", ")", "{", "if", "(", "parentElement", ".", "equals", "(", "n1", ")", ")", "{", "return", "new", "Object", "[", "]", "{", "n2", ",", "n3", "}", ";", "}", "if", "(", "parentElement", ".", "equals", "(", "n2", ")", ")", "{", "return", "new", "Object", "[", "]", "{", "n4", "}", ";", "}", "return", "null", ";", "}", "public", "Object", "getParent", "(", "Object", "element", ")", "{", "if", "(", "element", ".", "equals", "(", "n2", ")", ")", "{", "return", "n1", ";", "}", "else", "if", "(", "element", ".", "equals", "(", "n3", ")", ")", "{", "return", "n1", ";", "}", "else", "if", "(", "element", ".", "equals", "(", "n4", ")", ")", "{", "return", "new", "Object", "[", "]", "{", "n2", "}", ";", "}", "return", "null", ";", "}", "public", "boolean", "hasChildren", "(", "Object", "element", ")", "{", "return", "element", ".", "equals", "(", "\"First\"", ")", "||", "element", ".", "equals", "(", "\"Second\"", ")", ";", "}", "}", "static", "class", "MyLabelProvider", "extends", "LabelProvider", "{", "final", "Image", "image", "=", "Display", ".", "getDefault", "(", ")", ".", "getSystemImage", "(", "SWT", ".", "ICON_WARNING", ")", ";", "public", "Image", "getImage", "(", "Object", "element", ")", "{", "if", "(", "element", "instanceof", "String", ")", "{", "return", "image", ";", "}", "return", "null", ";", "}", "public", "String", "getText", "(", "Object", "element", ")", "{", "if", "(", "element", "instanceof", "String", ")", "{", "return", "element", ".", "toString", "(", ")", ";", "}", "return", "null", ";", "}", "}", "static", "GraphViewer", "viewer", "=", "null", ";", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "Display", "d", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", "SWT", ".", "VERTICAL", ")", ")", ";", "shell", ".", "setSize", "(", "400", ",", "400", ")", ";", "Button", "button", "=", "new", "Button", "(", "shell", ",", "SWT", ".", "PUSH", ")", ";", "button", ".", "setText", "(", "\"Reload\"", ")", ";", "button", ".", "addSelectionListener", "(", "new", "SelectionAdapter", "(", ")", "{", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "viewer", ".", "setInput", "(", "new", "Object", "(", ")", ")", ";", "}", "}", ")", ";", "viewer", "=", "new", "GraphViewer", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "viewer", ".", "setContentProvider", "(", "new", "MyContentProvider", "(", ")", ")", ";", "viewer", ".", "setLabelProvider", "(", "new", "MyLabelProvider", "(", ")", ")", ";", "viewer", ".", "setLayoutAlgorithm", "(", "new", "TreeLayoutAlgorithm", "(", ")", ")", ";", "viewer", ".", "addSelectionChangedListener", "(", "new", "ISelectionChangedListener", "(", ")", "{", "public", "void", "selectionChanged", "(", "SelectionChangedEvent", "event", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", "+", "(", "event", ".", "getSelection", "(", ")", ")", ")", ";", "}", "}", ")", ";", "viewer", ".", "setInput", "(", "new", "Object", "(", ")", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "}", "}", "</s>" ]
10,207
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "jface", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ColorConstants", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Graphics", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "PolygonDecoration", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "PolylineConnection", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "LabelProvider", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "viewers", ".", "Viewer", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Color", ";", "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", ".", "IGraphEntityContentProvider", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "ISelfStyleProvider", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphConnection", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphNode", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "SpringLayoutAlgorithm", ";", "public", "class", "GraphJFaceSnippet8", "{", "static", "class", "MyContentProvider", "implements", "IGraphEntityContentProvider", "{", "public", "Object", "[", "]", "getConnectedTo", "(", "Object", "entity", ")", "{", "if", "(", "entity", ".", "equals", "(", "\"First\"", ")", ")", "{", "return", "new", "Object", "[", "]", "{", "\"First\"", ",", "\"Second\"", "}", ";", "}", "if", "(", "entity", ".", "equals", "(", "\"Second\"", ")", ")", "{", "return", "new", "Object", "[", "]", "{", "\"Third\"", "}", ";", "}", "if", "(", "entity", ".", "equals", "(", "\"Third\"", ")", ")", "{", "return", "new", "Object", "[", "]", "{", "\"Second\"", "}", ";", "}", "return", "null", ";", "}", "public", "Object", "[", "]", "getElements", "(", "Object", "inputElement", ")", "{", "return", "new", "String", "[", "]", "{", "\"First\"", ",", "\"Second\"", ",", "\"Third\"", "}", ";", "}", "public", "double", "getWeight", "(", "Object", "entity1", ",", "Object", "entity2", ")", "{", "return", "0", ";", "}", "public", "void", "dispose", "(", ")", "{", "}", "public", "void", "inputChanged", "(", "Viewer", "viewer", ",", "Object", "oldInput", ",", "Object", "newInput", ")", "{", "}", "}", "static", "class", "MyLabelProvider", "extends", "LabelProvider", "implements", "ISelfStyleProvider", "{", "public", "Image", "getImage", "(", "Object", "element", ")", "{", "return", "null", ";", "}", "public", "String", "getText", "(", "Object", "element", ")", "{", "return", "element", ".", "toString", "(", ")", ";", "}", "public", "void", "selfStyleConnection", "(", "Object", "element", ",", "GraphConnection", "connection", ")", "{", "connection", ".", "setLineStyle", "(", "SWT", ".", "LINE_CUSTOM", ")", ";", "PolylineConnection", "pc", "=", "(", "PolylineConnection", ")", "connection", ".", "getConnectionFigure", "(", ")", ";", "pc", ".", "setLineDash", "(", "new", "float", "[", "]", "{", "4", "}", ")", ";", "pc", ".", "setTargetDecoration", "(", "createDecoration", "(", "ColorConstants", ".", "white", ")", ")", ";", "pc", ".", "setSourceDecoration", "(", "createDecoration", "(", "ColorConstants", ".", "green", ")", ")", ";", "}", "private", "PolygonDecoration", "createDecoration", "(", "final", "Color", "color", ")", "{", "PolygonDecoration", "decoration", "=", "new", "PolygonDecoration", "(", ")", "{", "protected", "void", "fillShape", "(", "Graphics", "g", ")", "{", "g", ".", "setBackgroundColor", "(", "color", ")", ";", "super", ".", "fillShape", "(", "g", ")", ";", "}", "}", ";", "decoration", ".", "setScale", "(", "10", ",", "5", ")", ";", "decoration", ".", "setBackgroundColor", "(", "color", ")", ";", "return", "decoration", ";", "}", "public", "void", "selfStyleNode", "(", "Object", "element", ",", "GraphNode", "node", ")", "{", "}", "}", "static", "GraphViewer", "viewer", "=", "null", ";", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "Display", "d", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "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>" ]
10,208
[ "<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", ".", "events", ".", "SelectionEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionListener", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Image", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "layout", ".", "FillLayout", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Button", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Shell", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "EntityConnectionData", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "GraphViewer", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "IGraphEntityContentProvider", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "viewers", ".", "INestedContentProvider", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "SpringLayoutAlgorithm", ";", "public", "class", "GraphJFaceSnippet6", "{", "static", "class", "MyContentProvider", "implements", "IGraphEntityContentProvider", ",", "INestedContentProvider", "{", "public", "Object", "[", "]", "getConnectedTo", "(", "Object", "entity", ")", "{", "if", "(", "entity", ".", "equals", "(", "\"First\"", ")", ")", "{", "return", "new", "Object", "[", "]", "{", "\"Second\"", "}", ";", "}", "if", "(", "entity", ".", "equals", "(", "\"Second\"", ")", ")", "{", "return", "new", "Object", "[", "]", "{", "\"Third\"", ",", "\"rock\"", "}", ";", "}", "if", "(", "entity", ".", "equals", "(", "\"Third\"", ")", ")", "{", "return", "new", "Object", "[", "]", "{", "\"First\"", "}", ";", "}", "if", "(", "entity", ".", "equals", "(", "\"rock\"", ")", ")", "{", "return", "new", "Object", "[", "]", "{", "\"paper\"", "}", ";", "}", "return", "null", ";", "}", "public", "Object", "[", "]", "getElements", "(", "Object", "inputElement", ")", "{", "return", "new", "String", "[", "]", "{", "\"First\"", ",", "\"Second\"", ",", "\"Third\"", "}", ";", "}", "public", "double", "getWeight", "(", "Object", "entity1", ",", "Object", "entity2", ")", "{", "return", "0", ";", "}", "public", "void", "dispose", "(", ")", "{", "}", "public", "void", "inputChanged", "(", "Viewer", "viewer", ",", "Object", "oldInput", ",", "Object", "newInput", ")", "{", "}", "public", "Object", "[", "]", "getChildren", "(", "Object", "element", ")", "{", "return", "new", "Object", "[", "]", "{", "\"rock\"", ",", "\"paper\"", ",", "\"scissors\"", "}", ";", "}", "public", "boolean", "hasChildren", "(", "Object", "element", ")", "{", "if", "(", "element", ".", "equals", "(", "\"First\"", ")", ")", "return", "true", ";", "return", "false", ";", "}", "}", "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", ")", "{", "if", "(", "element", "instanceof", "EntityConnectionData", ")", "return", "\"\"", ";", "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", "(", ")", ")", ";", "Button", "button", "=", "new", "Button", "(", "shell", ",", "SWT", ".", "PUSH", ")", ";", "button", ".", "setText", "(", "\"push\"", ")", ";", "button", ".", "addSelectionListener", "(", "new", "SelectionListener", "(", ")", "{", "public", "void", "widgetDefaultSelected", "(", "SelectionEvent", "e", ")", "{", "}", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "viewer", ".", "setInput", "(", "new", "Object", "(", ")", ")", ";", "}", "}", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "}", "}", "</s>" ]
10,209
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "uml", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ColorConstants", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Figure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Label", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "LineBorder", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ToolbarLayout", ";", "public", "class", "UMLClassFigure", "extends", "Figure", "{", "private", "CompartmentFigure", "attributeFigure", "=", "new", "CompartmentFigure", "(", ")", ";", "private", "CompartmentFigure", "methodFigure", "=", "new", "CompartmentFigure", "(", ")", ";", "public", "UMLClassFigure", "(", "Label", "name", ")", "{", "ToolbarLayout", "layout", "=", "new", "ToolbarLayout", "(", ")", ";", "setLayoutManager", "(", "layout", ")", ";", "setBorder", "(", "new", "LineBorder", "(", "ColorConstants", ".", "black", ",", "1", ")", ")", ";", "setBackgroundColor", "(", "UMLExample", ".", "classColor", ")", ";", "setOpaque", "(", "true", ")", ";", "add", "(", "name", ")", ";", "add", "(", "attributeFigure", ")", ";", "add", "(", "methodFigure", ")", ";", "}", "public", "CompartmentFigure", "getAttributesCompartment", "(", ")", "{", "return", "attributeFigure", ";", "}", "public", "CompartmentFigure", "getMethodsCompartment", "(", ")", "{", "return", "methodFigure", ";", "}", "}", "</s>" ]
10,210
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "uml", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "IFigure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Label", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Color", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Font", ";", "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", ".", "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", ".", "IContainer", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "ZestStyles", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "SpringLayoutAlgorithm", ";", "public", "class", "UMLExample", "{", "public", "static", "Color", "classColor", "=", "null", ";", "public", "static", "IFigure", "createClassFigure1", "(", "Font", "classFont", ",", "Image", "classImage", ",", "Image", "publicField", ",", "Image", "privateField", ")", "{", "Label", "classLabel1", "=", "new", "Label", "(", "\"Table\"", ",", "classImage", ")", ";", "classLabel1", ".", "setFont", "(", "classFont", ")", ";", "UMLClassFigure", "classFigure", "=", "new", "UMLClassFigure", "(", "classLabel1", ")", ";", "Label", "attribute1", "=", "new", "Label", "(", "\"\"", ",", "privateField", ")", ";", "Label", "attribute2", "=", "new", "Label", "(", "\"rows:", "Row[]\"", ",", "privateField", ")", ";", "Label", "method1", "=", "new", "Label", "(", "\"\"", ",", "publicField", ")", ";", "Label", "method2", "=", "new", "Label", "(", "\"\"", ",", "publicField", ")", ";", "classFigure", ".", "getAttributesCompartment", "(", ")", ".", "add", "(", "attribute1", ")", ";", "classFigure", ".", "getAttributesCompartment", "(", ")", ".", "add", "(", "attribute2", ")", ";", "classFigure", ".", "getMethodsCompartment", "(", ")", ".", "add", "(", "method1", ")", ";", "classFigure", ".", "getMethodsCompartment", "(", ")", ".", "add", "(", "method2", ")", ";", "classFigure", ".", "setSize", "(", "-", "1", ",", "-", "1", ")", ";", "return", "classFigure", ";", "}", "public", "static", "IFigure", "createClassFigure2", "(", "Font", "classFont", ",", "Image", "classImage", ",", "Image", "publicField", ",", "Image", "privateField", ")", "{", "Label", "classLabel2", "=", "new", "Label", "(", "\"Column\"", ",", "classImage", ")", ";", "classLabel2", ".", "setFont", "(", "classFont", ")", ";", "UMLClassFigure", "classFigure", "=", "new", "UMLClassFigure", "(", "classLabel2", ")", ";", "Label", "attribute3", "=", "new", "Label", "(", "\"\"", ",", "privateField", ")", ";", "Label", "attribute4", "=", "new", "Label", "(", "\"items:", "List\"", ",", "privateField", ")", ";", "Label", "method3", "=", "new", "Label", "(", "\"\"", ",", "publicField", ")", ";", "Label", "method4", "=", "new", "Label", "(", "\"\"", ",", "publicField", ")", ";", "classFigure", ".", "getAttributesCompartment", "(", ")", ".", "add", "(", "attribute3", ")", ";", "classFigure", ".", "getAttributesCompartment", "(", ")", ".", "add", "(", "attribute4", ")", ";", "classFigure", ".", "getMethodsCompartment", "(", ")", ".", "add", "(", "method3", ")", ";", "classFigure", ".", "getMethodsCompartment", "(", ")", ".", "add", "(", "method4", ")", ";", "classFigure", ".", "setSize", "(", "-", "1", ",", "-", "1", ")", ";", "return", "classFigure", ";", "}", "static", "class", "UMLNode", "extends", "GraphNode", "{", "IFigure", "customFigure", "=", "null", ";", "public", "UMLNode", "(", "IContainer", "graphModel", ",", "int", "style", ",", "IFigure", "figure", ")", "{", "super", "(", "graphModel", ",", "style", ",", "figure", ")", ";", "}", "protected", "IFigure", "createFigureForModel", "(", ")", "{", "return", "(", "IFigure", ")", "this", ".", "getData", "(", ")", ";", "}", "}", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "Display", "d", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "400", ",", "400", ")", ";", "classColor", "=", "new", "Color", "(", "null", ",", "255", ",", "255", ",", "206", ")", ";", "Font", "classFont", "=", "new", "Font", "(", "null", ",", "\"Arial\"", ",", "12", ",", "SWT", ".", "BOLD", ")", ";", "Image", "classImage", "=", "new", "Image", "(", "Display", ".", "getDefault", "(", ")", ",", "UMLClassFigure", ".", "class", ".", "getResourceAsStream", "(", "\"\"", ")", ")", ";", "Image", "privateField", "=", "new", "Image", "(", "Display", ".", "getDefault", "(", ")", ",", "UMLClassFigure", ".", "class", ".", "getResourceAsStream", "(", "\"\"", ")", ")", ";", "Image", "publicField", "=", "new", "Image", "(", "Display", ".", "getDefault", "(", ")", ",", "UMLClassFigure", ".", "class", ".", "getResourceAsStream", "(", "\"\"", ")", ")", ";", "Graph", "g", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "g", ".", "setConnectionStyle", "(", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ")", ";", "GraphContainer", "c", "=", "new", "GraphContainer", "(", "g", ",", "SWT", ".", "NONE", ")", ";", "c", ".", "setText", "(", "\"\"", ")", ";", "UMLNode", "n", "=", "new", "UMLNode", "(", "c", ",", "SWT", ".", "NONE", ",", "createClassFigure1", "(", "classFont", ",", "classImage", ",", "publicField", ",", "privateField", ")", ")", ";", "GraphNode", "n1", "=", "new", "UMLNode", "(", "g", ",", "SWT", ".", "NONE", ",", "createClassFigure1", "(", "classFont", ",", "classImage", ",", "publicField", ",", "privateField", ")", ")", ";", "GraphNode", "n2", "=", "new", "UMLNode", "(", "g", ",", "SWT", ".", "NONE", ",", "createClassFigure2", "(", "classFont", ",", "classImage", ",", "publicField", ",", "privateField", ")", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n1", ",", "n2", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n", ",", "n1", ")", ";", "c", ".", "setLayoutAlgorithm", "(", "new", "SpringLayoutAlgorithm", "(", ")", ",", "true", ")", ";", "g", ".", "setLayoutAlgorithm", "(", "new", "SpringLayoutAlgorithm", "(", ")", ",", "true", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "classColor", ".", "dispose", "(", ")", ";", "classFont", ".", "dispose", "(", ")", ";", "classImage", ".", "dispose", "(", ")", ";", "publicField", ".", "dispose", "(", ")", ";", "privateField", ".", "dispose", "(", ")", ";", "}", "}", "</s>" ]
10,211
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "uml", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "AbstractBorder", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Figure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Graphics", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "IFigure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ToolbarLayout", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Insets", ";", "public", "class", "CompartmentFigure", "extends", "Figure", "{", "public", "CompartmentFigure", "(", ")", "{", "ToolbarLayout", "layout", "=", "new", "ToolbarLayout", "(", ")", ";", "layout", ".", "setMinorAlignment", "(", "ToolbarLayout", ".", "ALIGN_TOPLEFT", ")", ";", "layout", ".", "setStretchMinorAxis", "(", "false", ")", ";", "layout", ".", "setSpacing", "(", "2", ")", ";", "setLayoutManager", "(", "layout", ")", ";", "setBorder", "(", "new", "CompartmentFigureBorder", "(", ")", ")", ";", "}", "class", "CompartmentFigureBorder", "extends", "AbstractBorder", "{", "public", "Insets", "getInsets", "(", "IFigure", "figure", ")", "{", "return", "new", "Insets", "(", "1", ",", "0", ",", "0", ",", "0", ")", ";", "}", "public", "void", "paint", "(", "IFigure", "figure", ",", "Graphics", "graphics", ",", "Insets", "insets", ")", "{", "graphics", ".", "drawLine", "(", "getPaintRectangle", "(", "figure", ",", "insets", ")", ".", "getTopLeft", "(", ")", ",", "tempRect", ".", "getTopRight", "(", ")", ")", ";", "}", "}", "}", "</s>" ]
10,212
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "layouts", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "action", ".", "Action", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "action", ".", "MenuManager", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionAdapter", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "layout", ".", "GridData", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "layout", ".", "GridLayout", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Button", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "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", ".", "ZestStyles", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "LayoutAlgorithm", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "DirectedGraphLayoutAlgorithm", ";", "public", "class", "DAGExample", "{", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "Display", "d", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setText", "(", "\"\"", ")", ";", "GridLayout", "gridLayout", "=", "new", "GridLayout", "(", ")", ";", "gridLayout", ".", "numColumns", "=", "10", ";", "shell", ".", "setLayout", "(", "gridLayout", ")", ";", "shell", ".", "setSize", "(", "500", ",", "500", ")", ";", "final", "Graph", "g", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "LayoutAlgorithm", "algorithm", "=", "new", "DirectedGraphLayoutAlgorithm", "(", ")", ";", "g", ".", "setLayoutData", "(", "new", "GridData", "(", "SWT", ".", "FILL", ",", "SWT", ".", "FILL", ",", "true", ",", "true", ",", "10", ",", "10", ")", ")", ";", "g", ".", "setSize", "(", "500", ",", "500", ")", ";", "g", ".", "setSubgraphFactory", "(", "new", "DefaultSubgraph", ".", "PrunedSuccessorsSubgraphFactory", "(", ")", ")", ";", "g", ".", "setLayoutAlgorithm", "(", "algorithm", ",", "false", ")", ";", "g", ".", "setExpandCollapseManager", "(", "new", "DAGExpandCollapseManager", "(", ")", ")", ";", "GraphNode", "root", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Root\"", ")", ";", "GraphNode", "a", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"A\"", ")", ";", "GraphNode", "b", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"B\"", ")", ";", "GraphNode", "c", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"C\"", ")", ";", "GraphNode", "e", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"D\"", ")", ";", "GraphNode", "f", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"E\"", ")", ";", "GraphNode", "h", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"F\"", ")", ";", "new", "GraphConnection", "(", "g", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "root", ",", "a", ")", ";", "new", "GraphConnection", "(", "g", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "root", ",", "b", ")", ";", "new", "GraphConnection", "(", "g", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "root", ",", "c", ")", ";", "new", "GraphConnection", "(", "g", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "a", ",", "c", ")", ";", "new", "GraphConnection", "(", "g", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "c", ",", "e", ")", ";", "new", "GraphConnection", "(", "g", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "e", ",", "f", ")", ";", "new", "GraphConnection", "(", "g", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "e", ",", "h", ")", ";", "new", "GraphConnection", "(", "g", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "root", ",", "h", ")", ";", "hookMenu", "(", "g", ")", ";", "final", "Button", "buttonTopDown", "=", "new", "Button", "(", "shell", ",", "SWT", ".", "FLAT", ")", ";", "buttonTopDown", ".", "setText", "(", "\"TOP_DOWN\"", ")", ";", "final", "Button", "buttonBottomUp", "=", "new", "Button", "(", "shell", ",", "SWT", ".", "FLAT", ")", ";", "buttonBottomUp", ".", "setText", "(", "\"BOTTOM_UP\"", ")", ";", "buttonBottomUp", ".", "setLayoutData", "(", "new", "GridData", "(", ")", ")", ";", "final", "Button", "buttonLeftRight", "=", "new", "Button", "(", "shell", ",", "SWT", ".", "FLAT", ")", ";", "buttonLeftRight", ".", "setText", "(", "\"LEFT_RIGHT\"", ")", ";", "final", "Button", "buttonRightLeft", "=", "new", "Button", "(", "shell", ",", "SWT", ".", "FLAT", ")", ";", "buttonRightLeft", ".", "setText", "(", "\"RIGHT_LEFT\"", ")", ";", "SelectionAdapter", "buttonListener", "=", "new", "SelectionAdapter", "(", ")", "{", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "g", ".", "applyLayout", "(", ")", ";", "}", "}", ";", "buttonTopDown", ".", "addSelectionListener", "(", "buttonListener", ")", ";", "buttonBottomUp", ".", "addSelectionListener", "(", "buttonListener", ")", ";", "buttonLeftRight", ".", "addSelectionListener", "(", "buttonListener", ")", ";", "buttonRightLeft", ".", "addSelectionListener", "(", "buttonListener", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "}", "private", "static", "void", "hookMenu", "(", "final", "Graph", "g", ")", "{", "MenuManager", "menuMgr", "=", "new", "MenuManager", "(", "\"#PopupMenu\"", ")", ";", "Action", "expandAction", "=", "new", "Action", "(", ")", "{", "public", "void", "run", "(", ")", "{", "List", "selection", "=", "g", ".", "getSelection", "(", ")", ";", "if", "(", "!", "selection", ".", "isEmpty", "(", ")", ")", "{", "GraphNode", "selected", "=", "(", "GraphNode", ")", "selection", ".", "get", "(", "0", ")", ";", "g", ".", "setExpanded", "(", "(", "GraphNode", ")", "selected", ",", "true", ")", ";", "}", "}", "}", ";", "expandAction", ".", "setText", "(", "\"expand\"", ")", ";", "menuMgr", ".", "add", "(", "expandAction", ")", ";", "Action", "collapseAction", "=", "new", "Action", "(", ")", "{", "public", "void", "run", "(", ")", "{", "List", "selection", "=", "g", ".", "getSelection", "(", ")", ";", "if", "(", "!", "selection", ".", "isEmpty", "(", ")", ")", "{", "GraphItem", "selected", "=", "(", "GraphItem", ")", "selection", ".", "get", "(", "0", ")", ";", "g", ".", "setExpanded", "(", "(", "GraphNode", ")", "selected", ",", "false", ")", ";", "}", "}", "}", ";", "collapseAction", ".", "setText", "(", "\"collapse\"", ")", ";", "menuMgr", ".", "add", "(", "collapseAction", ")", ";", "g", ".", "setMenu", "(", "menuMgr", ".", "createContextMenu", "(", "g", ")", ")", ";", "}", "}", "</s>" ]
10,213
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "layouts", ";", "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", ".", "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", ".", "GridLayoutAlgorithm", ";", "public", "class", "FisheyeGraphSnippet", "{", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "Display", "d", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setText", "(", "\"\"", ")", ";", "Image", "image1", "=", "Display", ".", "getDefault", "(", ")", ".", "getSystemImage", "(", "SWT", ".", "ICON_INFORMATION", ")", ";", "Image", "image2", "=", "Display", ".", "getDefault", "(", ")", ".", "getSystemImage", "(", "SWT", ".", "ICON_WARNING", ")", ";", "Image", "image3", "=", "Display", ".", "getDefault", "(", ")", ".", "getSystemImage", "(", "SWT", ".", "ICON_ERROR", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "800", ",", "800", ")", ";", "Graph", "g", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "g", ".", "setConnectionStyle", "(", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "80", ";", "i", "++", ")", "{", "GraphNode", "n1", "=", "new", "GraphNode", "(", "g", ",", "ZestStyles", ".", "NODES_HIDE_TEXT", "|", "ZestStyles", ".", "NODES_FISHEYE", ",", "\"Information\"", ")", ";", "n1", ".", "setImage", "(", "image1", ")", ";", "GraphNode", "n2", "=", "new", "GraphNode", "(", "g", ",", "ZestStyles", ".", "NODES_HIDE_TEXT", "|", "ZestStyles", ".", "NODES_FISHEYE", ",", "\"Warning\"", ")", ";", "n2", ".", "setImage", "(", "image2", ")", ";", "GraphNode", "n3", "=", "new", "GraphNode", "(", "g", ",", "ZestStyles", ".", "NODES_HIDE_TEXT", "|", "ZestStyles", ".", "NODES_FISHEYE", ",", "\"Error\"", ")", ";", "n3", ".", "setImage", "(", "image3", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n1", ",", "n2", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n2", ",", "n3", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n3", ",", "n3", ")", ";", "}", "g", ".", "setLayoutAlgorithm", "(", "new", "GridLayoutAlgorithm", "(", ")", ",", "true", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "image1", ".", "dispose", "(", ")", ";", "image2", ".", "dispose", "(", ")", ";", "image3", ".", "dispose", "(", ")", ";", "}", "}", "</s>" ]
10,214
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "layouts", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "action", ".", "Action", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "action", ".", "MenuManager", ";", "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", ".", "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", ".", "layouts", ".", "algorithms", ".", "SpaceTreeLayoutAlgorithm", ";", "public", "class", "SpaceTreeBuilding", "{", "private", "static", "GraphNode", "parentNode", "=", "null", ";", "private", "static", "GraphNode", "childNode", "=", "null", ";", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "Display", "d", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setText", "(", "\"\"", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "400", ",", "400", ")", ";", "final", "Graph", "g", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "hookMenu", "(", "g", ")", ";", "SpaceTreeLayoutAlgorithm", "spaceTreeLayoutAlgorithm", "=", "new", "SpaceTreeLayoutAlgorithm", "(", ")", ";", "g", ".", "setLayoutAlgorithm", "(", "spaceTreeLayoutAlgorithm", ",", "false", ")", ";", "g", ".", "setExpandCollapseManager", "(", "spaceTreeLayoutAlgorithm", ".", "getExpandCollapseManager", "(", ")", ")", ";", "g", ".", "setSubgraphFactory", "(", "new", "DefaultSubgraph", ".", "LabelSubgraphFactory", "(", ")", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "20", ";", "i", "++", ")", "{", "GraphNode", "graphNode", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ")", ";", "graphNode", ".", "setText", "(", "\"\"", "+", "i", ")", ";", "}", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "}", "private", "static", "void", "tryToAddConnection", "(", "Graph", "g", ")", "{", "if", "(", "parentNode", "!=", "null", "&&", "childNode", "!=", "null", ")", "{", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "parentNode", ",", "childNode", ")", ";", "parentNode", "=", "childNode", "=", "null", ";", "}", "}", "private", "static", "void", "hookMenu", "(", "final", "Graph", "g", ")", "{", "MenuManager", "menuMgr", "=", "new", "MenuManager", "(", "\"#PopupMenu\"", ")", ";", "Action", "parentAction", "=", "new", "Action", "(", ")", "{", "public", "void", "run", "(", ")", "{", "List", "selection", "=", "g", ".", "getSelection", "(", ")", ";", "if", "(", "!", "selection", ".", "isEmpty", "(", ")", ")", "{", "GraphNode", "selected", "=", "(", "GraphNode", ")", "selection", ".", "get", "(", "0", ")", ";", "parentNode", "=", "selected", ";", "tryToAddConnection", "(", "g", ")", ";", "}", "}", "}", ";", "parentAction", ".", "setText", "(", "\"\"", ")", ";", "menuMgr", ".", "add", "(", "parentAction", ")", ";", "Action", "childAction", "=", "new", "Action", "(", ")", "{", "public", "void", "run", "(", ")", "{", "List", "selection", "=", "g", ".", "getSelection", "(", ")", ";", "if", "(", "!", "selection", ".", "isEmpty", "(", ")", ")", "{", "GraphNode", "selected", "=", "(", "GraphNode", ")", "selection", ".", "get", "(", "0", ")", ";", "childNode", "=", "selected", ";", "tryToAddConnection", "(", "g", ")", ";", "}", "}", "}", ";", "childAction", ".", "setText", "(", "\"use", "as", "child\"", ")", ";", "menuMgr", ".", "add", "(", "childAction", ")", ";", "Action", "expandAction", "=", "new", "Action", "(", ")", "{", "public", "void", "run", "(", ")", "{", "List", "selection", "=", "g", ".", "getSelection", "(", ")", ";", "if", "(", "!", "selection", ".", "isEmpty", "(", ")", ")", "{", "GraphNode", "selected", "=", "(", "GraphNode", ")", "selection", ".", "get", "(", "0", ")", ";", "g", ".", "setExpanded", "(", "(", "GraphNode", ")", "selected", ",", "true", ")", ";", "}", "}", "}", ";", "expandAction", ".", "setText", "(", "\"expand\"", ")", ";", "menuMgr", ".", "add", "(", "expandAction", ")", ";", "Action", "collapseAction", "=", "new", "Action", "(", ")", "{", "public", "void", "run", "(", ")", "{", "List", "selection", "=", "g", ".", "getSelection", "(", ")", ";", "if", "(", "!", "selection", ".", "isEmpty", "(", ")", ")", "{", "GraphItem", "selected", "=", "(", "GraphItem", ")", "selection", ".", "get", "(", "0", ")", ";", "g", ".", "setExpanded", "(", "(", "GraphNode", ")", "selected", ",", "false", ")", ";", "}", "}", "}", ";", "collapseAction", ".", "setText", "(", "\"collapse\"", ")", ";", "menuMgr", ".", "add", "(", "collapseAction", ")", ";", "g", ".", "setMenu", "(", "menuMgr", ".", "createContextMenu", "(", "g", ")", ")", ";", "}", "}", "</s>" ]
10,215
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "layouts", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Dimension", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "action", ".", "Action", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "action", ".", "MenuManager", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionAdapter", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "layout", ".", "GridData", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "layout", ".", "GridLayout", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Button", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "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", ".", "layouts", ".", "algorithms", ".", "TreeLayoutAlgorithm", ";", "public", "class", "TreeLayoutExample", "{", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "Display", "d", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setText", "(", "\"\"", ")", ";", "GridLayout", "gridLayout", "=", "new", "GridLayout", "(", ")", ";", "gridLayout", ".", "numColumns", "=", "10", ";", "shell", ".", "setLayout", "(", "gridLayout", ")", ";", "shell", ".", "setSize", "(", "600", ",", "500", ")", ";", "final", "Graph", "g", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "final", "TreeLayoutAlgorithm", "algorithm", "=", "new", "TreeLayoutAlgorithm", "(", ")", ";", "g", ".", "setSubgraphFactory", "(", "new", "DefaultSubgraph", ".", "PrunedSuccessorsSubgraphFactory", "(", ")", ")", ";", "g", ".", "setLayoutAlgorithm", "(", "algorithm", ",", "false", ")", ";", "g", ".", "setExpandCollapseManager", "(", "new", "DAGExpandCollapseManager", "(", ")", ")", ";", "g", ".", "setLayoutData", "(", "new", "GridData", "(", "SWT", ".", "FILL", ",", "SWT", ".", "FILL", ",", "true", ",", "true", ",", "10", ",", "10", ")", ")", ";", "g", ".", "setSize", "(", "500", ",", "500", ")", ";", "GraphNode", "root", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Root\"", ")", ";", "GraphNode", "lastNode", "=", "null", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "3", ";", "i", "++", ")", "{", "GraphNode", "n", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"1", "-", "\"", "+", "i", ")", ";", "if", "(", "lastNode", "!=", "null", ")", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n", ",", "lastNode", ")", ".", "setDirected", "(", "true", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "1", ";", "j", "++", ")", "{", "GraphNode", "n2", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"2", "-", "\"", "+", "j", ")", ";", "GraphConnection", "c", "=", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n", ",", "n2", ")", ";", "c", ".", "setWeight", "(", "-", "1", ")", ";", "c", ".", "setDirected", "(", "true", ")", ";", "lastNode", "=", "n2", ";", "}", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "root", ",", "n", ")", ".", "setDirected", "(", "true", ")", ";", "}", "hookMenu", "(", "g", ")", ";", "final", "Button", "buttonTopDown", "=", "new", "Button", "(", "shell", ",", "SWT", ".", "FLAT", ")", ";", "buttonTopDown", ".", "setText", "(", "\"TOP_DOWN\"", ")", ";", "final", "Button", "buttonBottomUp", "=", "new", "Button", "(", "shell", ",", "SWT", ".", "FLAT", ")", ";", "buttonBottomUp", ".", "setText", "(", "\"BOTTOM_UP\"", ")", ";", "buttonBottomUp", ".", "setLayoutData", "(", "new", "GridData", "(", ")", ")", ";", "final", "Button", "buttonLeftRight", "=", "new", "Button", "(", "shell", ",", "SWT", ".", "FLAT", ")", ";", "buttonLeftRight", ".", "setText", "(", "\"LEFT_RIGHT\"", ")", ";", "final", "Button", "buttonRightLeft", "=", "new", "Button", "(", "shell", ",", "SWT", ".", "FLAT", ")", ";", "buttonRightLeft", ".", "setText", "(", "\"RIGHT_LEFT\"", ")", ";", "SelectionAdapter", "buttonListener", "=", "new", "SelectionAdapter", "(", ")", "{", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "if", "(", "e", ".", "widget", "==", "buttonTopDown", ")", "algorithm", ".", "setDirection", "(", "TreeLayoutAlgorithm", ".", "TOP_DOWN", ")", ";", "if", "(", "e", ".", "widget", "==", "buttonBottomUp", ")", "algorithm", ".", "setDirection", "(", "TreeLayoutAlgorithm", ".", "BOTTOM_UP", ")", ";", "if", "(", "e", ".", "widget", "==", "buttonLeftRight", ")", "algorithm", ".", "setDirection", "(", "TreeLayoutAlgorithm", ".", "LEFT_RIGHT", ")", ";", "if", "(", "e", ".", "widget", "==", "buttonRightLeft", ")", "algorithm", ".", "setDirection", "(", "TreeLayoutAlgorithm", ".", "RIGHT_LEFT", ")", ";", "g", ".", "applyLayout", "(", ")", ";", "}", "}", ";", "buttonTopDown", ".", "addSelectionListener", "(", "buttonListener", ")", ";", "buttonBottomUp", ".", "addSelectionListener", "(", "buttonListener", ")", ";", "buttonLeftRight", ".", "addSelectionListener", "(", "buttonListener", ")", ";", "buttonRightLeft", ".", "addSelectionListener", "(", "buttonListener", ")", ";", "final", "Button", "resizeButton", "=", "new", "Button", "(", "shell", ",", "SWT", ".", "CHECK", ")", ";", "resizeButton", ".", "setText", "(", "\"Resize\"", ")", ";", "resizeButton", ".", "addSelectionListener", "(", "new", "SelectionAdapter", "(", ")", "{", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "algorithm", ".", "setResizing", "(", "resizeButton", ".", "getSelection", "(", ")", ")", ";", "}", "}", ")", ";", "final", "Button", "nodeSpaceButton", "=", "new", "Button", "(", "shell", ",", "SWT", ".", "CHECK", ")", ";", "nodeSpaceButton", ".", "setText", "(", "\"\"", ")", ";", "nodeSpaceButton", ".", "addSelectionListener", "(", "new", "SelectionAdapter", "(", ")", "{", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "algorithm", ".", "setNodeSpace", "(", "nodeSpaceButton", ".", "getSelection", "(", ")", "?", "new", "Dimension", "(", "100", ",", "100", ")", ":", "null", ")", ";", "}", "}", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "}", "private", "static", "void", "hookMenu", "(", "final", "Graph", "g", ")", "{", "MenuManager", "menuMgr", "=", "new", "MenuManager", "(", "\"#PopupMenu\"", ")", ";", "Action", "expandAction", "=", "new", "Action", "(", ")", "{", "public", "void", "run", "(", ")", "{", "List", "selection", "=", "g", ".", "getSelection", "(", ")", ";", "if", "(", "!", "selection", ".", "isEmpty", "(", ")", ")", "{", "GraphNode", "selected", "=", "(", "GraphNode", ")", "selection", ".", "get", "(", "0", ")", ";", "g", ".", "setExpanded", "(", "(", "GraphNode", ")", "selected", ",", "true", ")", ";", "}", "}", "}", ";", "expandAction", ".", "setText", "(", "\"expand\"", ")", ";", "menuMgr", ".", "add", "(", "expandAction", ")", ";", "Action", "collapseAction", "=", "new", "Action", "(", ")", "{", "public", "void", "run", "(", ")", "{", "List", "selection", "=", "g", ".", "getSelection", "(", ")", ";", "if", "(", "!", "selection", ".", "isEmpty", "(", ")", ")", "{", "GraphItem", "selected", "=", "(", "GraphItem", ")", "selection", ".", "get", "(", "0", ")", ";", "g", ".", "setExpanded", "(", "(", "GraphNode", ")", "selected", ",", "false", ")", ";", "}", "}", "}", ";", "collapseAction", ".", "setText", "(", "\"collapse\"", ")", ";", "menuMgr", ".", "add", "(", "collapseAction", ")", ";", "g", ".", "setMenu", "(", "menuMgr", ".", "createContextMenu", "(", "g", ")", ")", ";", "}", "}", "</s>" ]
10,216
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "layouts", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ColorConstants", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "action", ".", "Action", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "action", ".", "IMenuListener", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "action", ".", "IMenuManager", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "action", ".", "MenuManager", ";", "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", ".", "DefaultSubgraph", ";", "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", ".", "core", ".", "widgets", ".", "DefaultSubgraph", ".", "TriangleSubgraphFactory", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "SpaceTreeLayoutAlgorithm", ";", "public", "class", "SpaceTreeExample", "{", "static", "Graph", "g", ";", "static", "GraphNode", "source", ";", "static", "GraphNode", "target", ";", "static", "boolean", "changesSeries", "=", "false", ";", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "Display", "d", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setText", "(", "\"\"", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "400", ",", "400", ")", ";", "g", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "g", ".", "setConnectionStyle", "(", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ")", ";", "g", ".", "setNodeStyle", "(", "ZestStyles", ".", "NODES_FISHEYE", ")", ";", "TriangleSubgraphFactory", "factory", "=", "new", "DefaultSubgraph", ".", "TriangleSubgraphFactory", "(", ")", ";", "factory", ".", "setColor", "(", "ColorConstants", ".", "green", ")", ";", "g", ".", "setSubgraphFactory", "(", "factory", ")", ";", "SpaceTreeLayoutAlgorithm", "spaceTreeLayoutAlgorithm", "=", "new", "SpaceTreeLayoutAlgorithm", "(", ")", ";", "g", ".", "setExpandCollapseManager", "(", "spaceTreeLayoutAlgorithm", ".", "getExpandCollapseManager", "(", ")", ")", ";", "g", ".", "setLayoutAlgorithm", "(", "spaceTreeLayoutAlgorithm", ",", "false", ")", ";", "createTree", "(", "g", ",", "\"!\"", ",", "5", ",", "5", ")", ";", "hookMenu", "(", "g", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "}", "private", "static", "GraphNode", "createTree", "(", "Graph", "g", ",", "String", "rootTitle", ",", "int", "depth", ",", "int", "breadth", ")", "{", "GraphNode", "root", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "rootTitle", ")", ";", "if", "(", "depth", ">", "0", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "breadth", ";", "i", "++", ")", "{", "GraphNode", "child", "=", "createTree", "(", "g", ",", "rootTitle", "+", "i", ",", "depth", "-", "1", "-", "i", ",", "breadth", "-", "i", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "root", ",", "child", ")", ";", "}", "}", "return", "root", ";", "}", "private", "static", "void", "hookMenu", "(", "final", "Graph", "g", ")", "{", "MenuManager", "menuMgr", "=", "new", "MenuManager", "(", "\"#PopupMenu\"", ")", ";", "menuMgr", ".", "setRemoveAllWhenShown", "(", "true", ")", ";", "menuMgr", ".", "addMenuListener", "(", "new", "IMenuListener", "(", ")", "{", "public", "void", "menuAboutToShow", "(", "IMenuManager", "manager", ")", "{", "fillContextMenu", "(", "manager", ")", ";", "}", "}", ")", ";", "g", ".", "setMenu", "(", "menuMgr", ".", "createContextMenu", "(", "g", ")", ")", ";", "}", "private", "static", "void", "fillContextMenu", "(", "IMenuManager", "menuMgr", ")", "{", "List", "selection", "=", "g", ".", "getSelection", "(", ")", ";", "if", "(", "selection", ".", "size", "(", ")", "==", "1", ")", "{", "if", "(", "selection", ".", "get", "(", "0", ")", "instanceof", "GraphNode", ")", "{", "final", "GraphNode", "node", "=", "(", "GraphNode", ")", "selection", ".", "get", "(", "0", ")", ";", "if", "(", "g", ".", "canExpand", "(", "node", ")", ")", "{", "Action", "expandAction", "=", "new", "Action", "(", ")", "{", "public", "void", "run", "(", ")", "{", "g", ".", "setExpanded", "(", "node", ",", "true", ")", ";", "}", "}", ";", "expandAction", ".", "setText", "(", "\"expand\"", ")", ";", "menuMgr", ".", "add", "(", "expandAction", ")", ";", "}", "if", "(", "g", ".", "canCollapse", "(", "node", ")", ")", "{", "Action", "collapseAction", "=", "new", "Action", "(", ")", "{", "public", "void", "run", "(", ")", "{", "g", ".", "setExpanded", "(", "node", ",", "false", ")", ";", "}", "}", ";", "collapseAction", ".", "setText", "(", "\"collapse\"", ")", ";", "menuMgr", ".", "add", "(", "collapseAction", ")", ";", "}", "Action", "disposeAction", "=", "new", "Action", "(", ")", "{", "public", "void", "run", "(", ")", "{", "node", ".", "dispose", "(", ")", ";", "}", "}", ";", "disposeAction", ".", "setText", "(", "\"dispose\"", ")", ";", "menuMgr", ".", "add", "(", "disposeAction", ")", ";", "Action", "asSourceAction", "=", "new", "Action", "(", ")", "{", "public", "void", "run", "(", ")", "{", "source", "=", "node", ";", "addConnection", "(", ")", ";", "}", "}", ";", "asSourceAction", ".", "setText", "(", "\"\"", ")", ";", "menuMgr", ".", "add", "(", "asSourceAction", ")", ";", "Action", "asTargetAction", "=", "new", "Action", "(", ")", "{", "public", "void", "run", "(", ")", "{", "target", "=", "node", ";", "addConnection", "(", ")", ";", "}", "}", ";", "asTargetAction", ".", "setText", "(", "\"\"", ")", ";", "menuMgr", ".", "add", "(", "asTargetAction", ")", ";", "}", "if", "(", "selection", ".", "get", "(", "0", ")", "instanceof", "GraphConnection", ")", "{", "final", "GraphConnection", "connection", "=", "(", "GraphConnection", ")", "selection", ".", "get", "(", "0", ")", ";", "Action", "removeAction", "=", "new", "Action", "(", ")", "{", "public", "void", "run", "(", ")", "{", "connection", ".", "dispose", "(", ")", ";", "}", "}", ";", "removeAction", ".", "setText", "(", "\"remove\"", ")", ";", "menuMgr", ".", "add", "(", "removeAction", ")", ";", "}", "}", "if", "(", "selection", ".", "size", "(", ")", "==", "0", ")", "{", "Action", "addNode", "=", "new", "Action", "(", ")", "{", "public", "void", "run", "(", ")", "{", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"new!\"", ")", ";", "}", "}", ";", "addNode", ".", "setText", "(", "\"add", "node\"", ")", ";", "menuMgr", ".", "add", "(", "addNode", ")", ";", "if", "(", "!", "changesSeries", ")", "{", "Action", "startChangesSeries", "=", "new", "Action", "(", ")", "{", "public", "void", "run", "(", ")", "{", "g", ".", "setDynamicLayout", "(", "false", ")", ";", "changesSeries", "=", "true", ";", "}", "}", ";", "startChangesSeries", ".", "setText", "(", "\"\"", ")", ";", "menuMgr", ".", "add", "(", "startChangesSeries", ")", ";", "}", "else", "{", "Action", "endChangesSeries", "=", "new", "Action", "(", ")", "{", "public", "void", "run", "(", ")", "{", "g", ".", "setDynamicLayout", "(", "true", ")", ";", "changesSeries", "=", "false", ";", "}", "}", ";", "endChangesSeries", ".", "setText", "(", "\"end", "changes\"", ")", ";", "menuMgr", ".", "add", "(", "endChangesSeries", ")", ";", "}", "}", "}", "private", "static", "void", "addConnection", "(", ")", "{", "if", "(", "source", "!=", "null", "&&", "target", "!=", "null", ")", "{", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "source", ",", "target", ")", ";", "source", "=", "target", "=", "null", ";", "}", "}", ";", "}", "</s>" ]
10,217
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "layouts", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Figure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "FlowLayout", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "IFigure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ImageFigure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Label", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "MarginBorder", ";", "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", ".", "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", ".", "layouts", ".", "algorithms", ".", "SpringLayoutAlgorithm", ";", "public", "class", "ContainersGraphSnippet", "{", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "final", "Display", "d", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setText", "(", "\"\"", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "400", ",", "400", ")", ";", "final", "Graph", "g", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "Image", "zx", "=", "new", "Image", "(", "d", ",", "\"zxsnow.png\"", ")", ";", "IFigure", "tooltip", "=", "new", "Figure", "(", ")", ";", "tooltip", ".", "setBorder", "(", "new", "MarginBorder", "(", "5", ",", "5", ",", "5", ",", "5", ")", ")", ";", "FlowLayout", "layout", "=", "new", "FlowLayout", "(", "false", ")", ";", "layout", ".", "setMajorSpacing", "(", "3", ")", ";", "layout", ".", "setMinorAlignment", "(", "3", ")", ";", "tooltip", ".", "setLayoutManager", "(", "new", "FlowLayout", "(", "false", ")", ")", ";", "tooltip", ".", "add", "(", "new", "ImageFigure", "(", "zx", ")", ")", ";", "tooltip", ".", "add", "(", "new", "Label", "(", "\"\"", ")", ")", ";", "tooltip", ".", "add", "(", "new", "Label", "(", "\"\"", ")", ")", ";", "GraphContainer", "c1", "=", "new", "GraphContainer", "(", "g", ",", "SWT", ".", "NONE", ")", ";", "c1", ".", "setText", "(", "\"Canada\"", ")", ";", "GraphContainer", "c2", "=", "new", "GraphContainer", "(", "g", ",", "SWT", ".", "NONE", ")", ";", "c2", ".", "setText", "(", "\"USA\"", ")", ";", "GraphNode", "n1", "=", "new", "GraphNode", "(", "c1", ",", "SWT", ".", "NONE", ",", "\"Ian", "B.\"", ")", ";", "n1", ".", "setSize", "(", "200", ",", "100", ")", ";", "GraphNode", "n2", "=", "new", "GraphNode", "(", "c2", ",", "SWT", ".", "NONE", ",", "\"Chris", "A.\"", ")", ";", "n2", ".", "setTooltip", "(", "tooltip", ")", ";", "GraphConnection", "connection", "=", "new", "GraphConnection", "(", "g", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "n1", ",", "n2", ")", ";", "connection", ".", "setCurveDepth", "(", "-", "30", ")", ";", "GraphConnection", "connection2", "=", "new", "GraphConnection", "(", "g", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "n2", ",", "n1", ")", ";", "connection2", ".", "setCurveDepth", "(", "-", "30", ")", ";", "g", ".", "setLayoutAlgorithm", "(", "new", "SpringLayoutAlgorithm", "(", ")", ",", "true", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "zx", ".", "dispose", "(", ")", ";", "}", "}", "</s>" ]
10,218
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "layouts", ";", "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", ".", "layouts", ".", "algorithms", ".", "SpringLayoutAlgorithm", ";", "public", "class", "SimpleGraphSnippet", "{", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "Display", "d", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setText", "(", "\"\"", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "400", ",", "400", ")", ";", "Graph", "g", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "GraphNode", "n", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Paper\"", ")", ";", "GraphNode", "n2", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Rock\"", ")", ";", "GraphNode", "n3", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Scissors\"", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n", ",", "n2", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n2", ",", "n3", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n3", ",", "n", ")", ";", "g", ".", "setLayoutAlgorithm", "(", "new", "SpringLayoutAlgorithm", "(", ")", ",", "true", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "}", "}", "</s>" ]
10,219
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "layouts", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "KeyEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "KeyListener", ";", "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", ".", "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", ".", "layouts", ".", "LayoutAlgorithm", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "CompositeLayoutAlgorithm", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "GridLayoutAlgorithm", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "HorizontalShiftAlgorithm", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "RadialLayoutAlgorithm", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "TreeLayoutAlgorithm", ";", "public", "class", "ContainerResizeGraphSnippet", "{", "private", "static", "Image", "image1", ";", "private", "static", "Image", "classImage", ";", "public", "static", "void", "createContainer", "(", "Graph", "g", ")", "{", "GraphContainer", "a", "=", "new", "GraphContainer", "(", "g", ",", "SWT", ".", "NONE", ")", ";", "a", ".", "setText", "(", "\"\"", ")", ";", "a", ".", "setImage", "(", "classImage", ")", ";", "int", "r", "=", "(", "int", ")", "(", "(", "Math", ".", "random", "(", ")", "*", "3", ")", "+", "1", ")", ";", "r", "=", "2", ";", "populateContainer", "(", "a", ",", "g", ",", "r", ",", "true", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "4", ";", "i", "++", ")", "{", "GraphContainer", "b", "=", "new", "GraphContainer", "(", "g", ",", "SWT", ".", "NONE", ")", ";", "b", ".", "setText", "(", "\"\"", ")", ";", "b", ".", "setImage", "(", "classImage", ")", ";", "r", "=", "(", "int", ")", "(", "(", "Math", ".", "random", "(", ")", "*", "3", ")", "+", "1", ")", ";", "r", "=", "2", ";", "populateContainer", "(", "b", ",", "g", ",", "r", ",", "false", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "a", ",", "b", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "4", ";", "j", "++", ")", "{", "GraphContainer", "c", "=", "new", "GraphContainer", "(", "g", ",", "SWT", ".", "NONE", ")", ";", "c", ".", "setText", "(", "\"\"", ")", ";", "c", ".", "setImage", "(", "classImage", ")", ";", "r", "=", "(", "int", ")", "(", "(", "Math", ".", "random", "(", ")", "*", "3", ")", "+", "1", ")", ";", "r", "=", "2", ";", "populateContainer", "(", "c", ",", "g", ",", "r", ",", "true", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "b", ",", "c", ")", ";", "}", "}", "}", "public", "static", "void", "populateContainer", "(", "GraphContainer", "c", ",", "Graph", "g", ",", "int", "number", ",", "boolean", "radial", ")", "{", "GraphNode", "a", "=", "new", "GraphNode", "(", "c", ",", "ZestStyles", ".", "NODES_FISHEYE", "|", "ZestStyles", ".", "NODES_HIDE_TEXT", ")", ";", "a", ".", "setText", "(", "\"\"", ")", ";", "a", ".", "setImage", "(", "classImage", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "4", ";", "i", "++", ")", "{", "GraphNode", "b", "=", "new", "GraphNode", "(", "c", ",", "ZestStyles", ".", "NODES_FISHEYE", "|", "ZestStyles", ".", "NODES_HIDE_TEXT", ")", ";", "b", ".", "setText", "(", "\"\"", ")", ";", "b", ".", "setImage", "(", "classImage", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "a", ",", "b", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "4", ";", "j", "++", ")", "{", "GraphNode", "d", "=", "new", "GraphNode", "(", "c", ",", "ZestStyles", ".", "NODES_FISHEYE", "|", "ZestStyles", ".", "NODES_HIDE_TEXT", ")", ";", "d", ".", "setText", "(", "\"\"", ")", ";", "d", ".", "setImage", "(", "classImage", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "b", ",", "d", ")", ";", "if", "(", "number", ">", "2", ")", "{", "for", "(", "int", "k", "=", "0", ";", "k", "<", "4", ";", "k", "++", ")", "{", "GraphNode", "e", "=", "new", "GraphNode", "(", "c", ",", "ZestStyles", ".", "NODES_FISHEYE", "|", "ZestStyles", ".", "NODES_HIDE_TEXT", ")", ";", "e", ".", "setText", "(", "\"\"", ")", ";", "e", ".", "setImage", "(", "classImage", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "d", ",", "e", ")", ";", "if", "(", "number", ">", "3", ")", "{", "for", "(", "int", "l", "=", "0", ";", "l", "<", "4", ";", "l", "++", ")", "{", "GraphNode", "f", "=", "new", "GraphNode", "(", "c", ",", "ZestStyles", ".", "NODES_FISHEYE", "|", "ZestStyles", ".", "NODES_HIDE_TEXT", ")", ";", "f", ".", "setText", "(", "\"\"", ")", ";", "f", ".", "setImage", "(", "classImage", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "e", ",", "f", ")", ";", "}", "}", "}", "}", "}", "}", "if", "(", "number", "==", "1", ")", "{", "c", ".", "setScale", "(", "0.75", ")", ";", "}", "else", "if", "(", "number", "==", "2", ")", "{", "c", ".", "setScale", "(", "0.50", ")", ";", "}", "else", "{", "c", ".", "setScale", "(", "0.25", ")", ";", "}", "if", "(", "radial", ")", "{", "c", ".", "setLayoutAlgorithm", "(", "new", "RadialLayoutAlgorithm", "(", ")", ",", "true", ")", ";", "}", "else", "{", "c", ".", "setLayoutAlgorithm", "(", "new", "TreeLayoutAlgorithm", "(", ")", ",", "true", ")", ";", "}", "}", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "Display", "d", "=", "new", "Display", "(", ")", ";", "image1", "=", "new", "Image", "(", "Display", ".", "getDefault", "(", ")", ",", "ContainerResizeGraphSnippet", ".", "class", ".", "getResourceAsStream", "(", "\"\"", ")", ")", ";", "classImage", "=", "new", "Image", "(", "Display", ".", "getDefault", "(", ")", ",", "ContainerResizeGraphSnippet", ".", "class", ".", "getResourceAsStream", "(", "\"\"", ")", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setText", "(", "\"\"", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "500", ",", "800", ")", ";", "final", "Graph", "g", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "createContainer", "(", "g", ")", ";", "CompositeLayoutAlgorithm", "compositeLayoutAlgorithm", "=", "new", "CompositeLayoutAlgorithm", "(", "new", "LayoutAlgorithm", "[", "]", "{", "new", "GridLayoutAlgorithm", "(", ")", ",", "new", "HorizontalShiftAlgorithm", "(", ")", "}", ")", ";", "g", ".", "setLayoutAlgorithm", "(", "compositeLayoutAlgorithm", ",", "true", ")", ";", "g", ".", "addKeyListener", "(", "new", "KeyListener", "(", ")", "{", "boolean", "flip", "=", "true", ";", "public", "void", "keyPressed", "(", "KeyEvent", "e", ")", "{", "if", "(", "g", ".", "getSelection", "(", ")", ".", "size", "(", ")", "==", "1", ")", "{", "GraphNode", "item", "=", "(", "GraphNode", ")", "g", ".", "getSelection", "(", ")", ".", "get", "(", "0", ")", ";", "if", "(", "item", ".", "getItemType", "(", ")", "==", "GraphItem", ".", "CONTAINER", ")", "{", "if", "(", "flip", ")", "{", "(", "item", ")", ".", "setSize", "(", "500", ",", "100", ")", ";", "}", "else", "{", "(", "item", ")", ".", "setSize", "(", "0", ",", "0", ")", ";", "}", "flip", "=", "!", "flip", ";", "}", "}", "}", "public", "void", "keyReleased", "(", "KeyEvent", "e", ")", "{", "}", "}", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "image1", ".", "dispose", "(", ")", ";", "}", "}", "</s>" ]
10,220
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "layouts", ";", "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", ".", "layouts", ".", "LayoutAlgorithm", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "EntityLayout", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "LayoutContext", ";", "public", "class", "CustomLayout", "{", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "Display", "d", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setText", "(", "\"\"", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "400", ",", "400", ")", ";", "Graph", "g", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "GraphNode", "n", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Paper\"", ")", ";", "GraphNode", "n2", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Rock\"", ")", ";", "GraphNode", "n3", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Scissors\"", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n", ",", "n2", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n2", ",", "n3", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n3", ",", "n", ")", ";", "LayoutAlgorithm", "layoutAlgorithm", "=", "new", "LayoutAlgorithm", "(", ")", "{", "private", "LayoutContext", "context", ";", "public", "void", "setLayoutContext", "(", "LayoutContext", "context", ")", "{", "this", ".", "context", "=", "context", ";", "}", "public", "void", "applyLayout", "(", "boolean", "clean", ")", "{", "EntityLayout", "[", "]", "entitiesToLayout", "=", "context", ".", "getEntities", "(", ")", ";", "int", "totalSteps", "=", "entitiesToLayout", ".", "length", ";", "double", "distance", "=", "context", ".", "getBounds", "(", ")", ".", "width", "/", "totalSteps", ";", "int", "xLocation", "=", "0", ";", "for", "(", "int", "currentStep", "=", "0", ";", "currentStep", "<", "entitiesToLayout", ".", "length", ";", "currentStep", "++", ")", "{", "EntityLayout", "layoutEntity", "=", "entitiesToLayout", "[", "currentStep", "]", ";", "layoutEntity", ".", "setLocation", "(", "xLocation", ",", "layoutEntity", ".", "getLocation", "(", ")", ".", "y", ")", ";", "xLocation", "+=", "distance", ";", "}", "}", "}", ";", "g", ".", "setLayoutAlgorithm", "(", "layoutAlgorithm", ",", "true", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "}", "}", "</s>" ]
10,221
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "layouts", ";", "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", ".", "layouts", ".", "LayoutAlgorithm", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "RadialLayoutAlgorithm", ";", "public", "class", "RadialLayoutExample", "{", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "Display", "d", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setText", "(", "\"\"", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "500", ",", "500", ")", ";", "final", "Graph", "g", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "g", ".", "setSize", "(", "500", ",", "500", ")", ";", "GraphNode", "root", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Root\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "3", ";", "i", "++", ")", "{", "GraphNode", "n", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"1", "-", "\"", "+", "i", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "3", ";", "j", "++", ")", "{", "GraphNode", "n2", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"2", "-", "\"", "+", "j", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n", ",", "n2", ")", ".", "setWeight", "(", "-", "1", ")", ";", "}", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "root", ",", "n", ")", ";", "}", "final", "LayoutAlgorithm", "layoutAlgorithm", "=", "new", "RadialLayoutAlgorithm", "(", ")", ";", "g", ".", "setLayoutAlgorithm", "(", "layoutAlgorithm", ",", "true", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "}", "}", "</s>" ]
10,222
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "layouts", ";", "import", "org", ".", "eclipse", ".", "jface", ".", "layout", ".", "GridDataFactory", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "layout", ".", "GridLayout", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Button", ";", "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", ".", "LayoutAlgorithm", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "SpringLayoutAlgorithm", ";", "public", "class", "SpringLayoutExample", "{", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "Display", "d", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setText", "(", "\"\"", ")", ";", "shell", ".", "setLayout", "(", "new", "GridLayout", "(", "2", ",", "false", ")", ")", ";", "shell", ".", "setSize", "(", "500", ",", "500", ")", ";", "final", "Graph", "g", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "BORDER", ")", ";", "g", ".", "setSize", "(", "500", ",", "500", ")", ";", "GraphNode", "root", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Root\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "3", ";", "i", "++", ")", "{", "GraphNode", "n", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"1", "-", "\"", "+", "i", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "3", ";", "j", "++", ")", "{", "GraphNode", "n2", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"2", "-", "\"", "+", "j", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n", ",", "n2", ")", ".", "setWeight", "(", "-", "1", ")", ";", "}", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "root", ",", "n", ")", ";", "}", "GridDataFactory", ".", "fillDefaults", "(", ")", ".", "grab", "(", "true", ",", "true", ")", ".", "applyTo", "(", "g", ")", ";", "new", "Button", "(", "shell", ",", "SWT", ".", "PUSH", ")", ".", "setText", "(", "\"Push", "Me\"", ")", ";", "final", "LayoutAlgorithm", "layoutAlgorithm", "=", "new", "SpringLayoutAlgorithm", "(", ")", ";", "g", ".", "setLayoutAlgorithm", "(", "layoutAlgorithm", ",", "true", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "}", "}", "</s>" ]
10,223
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "layouts", ";", "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", ".", "layouts", ".", "algorithms", ".", "SugiyamaLayoutAlgorithm", ";", "public", "class", "SugiyamaLayoutExample", "{", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "Display", "d", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "400", ",", "400", ")", ";", "Graph", "g", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "g", ".", "setConnectionStyle", "(", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ")", ";", "GraphNode", "coal", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Coal\"", ")", ";", "GraphNode", "ore", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Ore\"", ")", ";", "GraphNode", "stone", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Stone\"", ")", ";", "GraphNode", "metal", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Metal\"", ")", ";", "GraphNode", "concrete", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Concrete\"", ")", ";", "GraphNode", "machine", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Machine\"", ")", ";", "GraphNode", "building", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Building\"", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "coal", ",", "metal", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "coal", ",", "concrete", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "metal", ",", "machine", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "metal", ",", "building", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "concrete", ",", "building", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "ore", ",", "metal", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "stone", ",", "concrete", ")", ";", "g", ".", "setLayoutAlgorithm", "(", "new", "SugiyamaLayoutAlgorithm", "(", ")", ",", "true", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "}", "}", "</s>" ]
10,224
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "layouts", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ColorConstants", ";", "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", ".", "GraphItem", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphNode", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "LayoutFilter", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "ZestStyles", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "TreeLayoutAlgorithm", ";", "public", "class", "FilterGraphSnippet", "{", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "Display", "display", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "display", ")", ";", "shell", ".", "setText", "(", "\"\"", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "400", ",", "400", ")", ";", "final", "Graph", "graph", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "GraphNode", "a", "=", "new", "GraphNode", "(", "graph", ",", "SWT", ".", "NONE", ",", "\"Root\"", ")", ";", "GraphNode", "b", "=", "new", "GraphNode", "(", "graph", ",", "SWT", ".", "NONE", ",", "\"B\"", ")", ";", "GraphNode", "c", "=", "new", "GraphNode", "(", "graph", ",", "SWT", ".", "NONE", ",", "\"C\"", ")", ";", "GraphNode", "d", "=", "new", "GraphNode", "(", "graph", ",", "SWT", ".", "NONE", ",", "\"D\"", ")", ";", "GraphNode", "e", "=", "new", "GraphNode", "(", "graph", ",", "SWT", ".", "NONE", ",", "\"E\"", ")", ";", "GraphNode", "f", "=", "new", "GraphNode", "(", "graph", ",", "SWT", ".", "NONE", ",", "\"F\"", ")", ";", "GraphNode", "g", "=", "new", "GraphNode", "(", "graph", ",", "SWT", ".", "NONE", ",", "\"G\"", ")", ";", "GraphNode", "h", "=", "new", "GraphNode", "(", "graph", ",", "SWT", ".", "NONE", ",", "\"H\"", ")", ";", "GraphConnection", "connection", "=", "new", "GraphConnection", "(", "graph", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "a", ",", "b", ")", ";", "connection", ".", "setData", "(", "Boolean", ".", "TRUE", ")", ";", "connection", "=", "new", "GraphConnection", "(", "graph", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "a", ",", "c", ")", ";", "connection", ".", "setData", "(", "Boolean", ".", "TRUE", ")", ";", "connection", "=", "new", "GraphConnection", "(", "graph", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "a", ",", "c", ")", ";", "connection", ".", "setData", "(", "Boolean", ".", "TRUE", ")", ";", "connection", "=", "new", "GraphConnection", "(", "graph", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "a", ",", "d", ")", ";", "connection", ".", "setData", "(", "Boolean", ".", "TRUE", ")", ";", "connection", "=", "new", "GraphConnection", "(", "graph", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "b", ",", "e", ")", ";", "connection", ".", "setData", "(", "Boolean", ".", "FALSE", ")", ";", "connection", "=", "new", "GraphConnection", "(", "graph", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "b", ",", "f", ")", ";", "connection", ".", "setData", "(", "Boolean", ".", "FALSE", ")", ";", "connection", "=", "new", "GraphConnection", "(", "graph", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "c", ",", "g", ")", ";", "connection", ".", "setData", "(", "Boolean", ".", "FALSE", ")", ";", "connection", "=", "new", "GraphConnection", "(", "graph", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "d", ",", "h", ")", ";", "connection", ".", "setData", "(", "Boolean", ".", "FALSE", ")", ";", "connection", "=", "new", "GraphConnection", "(", "graph", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "b", ",", "c", ")", ";", "connection", ".", "setLineColor", "(", "ColorConstants", ".", "red", ")", ";", "connection", ".", "setLineWidth", "(", "3", ")", ";", "connection", "=", "new", "GraphConnection", "(", "graph", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "c", ",", "d", ")", ";", "connection", ".", "setLineColor", "(", "ColorConstants", ".", "red", ")", ";", "connection", ".", "setLineWidth", "(", "3", ")", ";", "connection", "=", "new", "GraphConnection", "(", "graph", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "e", ",", "f", ")", ";", "connection", ".", "setLineColor", "(", "ColorConstants", ".", "red", ")", ";", "connection", ".", "setLineWidth", "(", "3", ")", ";", "connection", "=", "new", "GraphConnection", "(", "graph", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "f", ",", "g", ")", ";", "connection", ".", "setLineColor", "(", "ColorConstants", ".", "red", ")", ";", "connection", ".", "setLineWidth", "(", "3", ")", ";", "connection", "=", "new", "GraphConnection", "(", "graph", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "h", ",", "e", ")", ";", "connection", ".", "setLineColor", "(", "ColorConstants", ".", "red", ")", ";", "connection", ".", "setLineWidth", "(", "3", ")", ";", "TreeLayoutAlgorithm", "treeLayoutAlgorithm", "=", "new", "TreeLayoutAlgorithm", "(", ")", ";", "LayoutFilter", "filter", "=", "new", "LayoutFilter", "(", ")", "{", "public", "boolean", "isObjectFiltered", "(", "GraphItem", "item", ")", "{", "if", "(", "item", "instanceof", "GraphConnection", ")", "{", "GraphConnection", "connection", "=", "(", "GraphConnection", ")", "item", ";", "Object", "data", "=", "connection", ".", "getData", "(", ")", ";", "if", "(", "data", "!=", "null", "&&", "data", "instanceof", "Boolean", ")", "{", "return", "(", "(", "Boolean", ")", "data", ")", ".", "booleanValue", "(", ")", ";", "}", "return", "true", ";", "}", "return", "false", ";", "}", "}", ";", "graph", ".", "addLayoutFilter", "(", "filter", ")", ";", "graph", ".", "setLayoutAlgorithm", "(", "treeLayoutAlgorithm", ",", "true", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "display", ".", "readAndDispatch", "(", ")", ")", "{", "display", ".", "sleep", "(", ")", ";", "}", "}", "}", "}", "</s>" ]
10,225
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "layouts", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "List", ";", "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", ".", "events", ".", "SelectionListener", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "layout", ".", "GridData", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "layout", ".", "GridLayout", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Button", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Label", ";", "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", ".", "LayoutFilter", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "SpringLayoutAlgorithm", ";", "public", "class", "SpringLayoutProgress", "{", "static", "Runnable", "r", "=", "null", ";", "static", "boolean", "MouseDown", "=", "false", ";", "static", "boolean", "first", "=", "true", ";", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "Display", "d", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setText", "(", "\"\"", ")", ";", "GridLayout", "gridLayout", "=", "new", "GridLayout", "(", ")", ";", "gridLayout", ".", "numColumns", "=", "5", ";", "shell", ".", "setLayout", "(", "gridLayout", ")", ";", "shell", ".", "setSize", "(", "500", ",", "500", ")", ";", "final", "Graph", "g", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "g", ".", "setLayoutData", "(", "new", "GridData", "(", "SWT", ".", "FILL", ",", "SWT", ".", "FILL", ",", "true", ",", "true", ",", "5", ",", "5", ")", ")", ";", "g", ".", "setSize", "(", "500", ",", "500", ")", ";", "GraphNode", "aa", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"A\"", ")", ";", "GraphNode", "bb", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"B\"", ")", ";", "GraphNode", "cc", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"C\"", ")", ";", "GraphNode", "dd", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"D\"", ")", ";", "GraphNode", "ee", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"E\"", ")", ";", "GraphNode", "ff", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"F\"", ")", ";", "GraphNode", "root", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Root\"", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "root", ",", "aa", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "root", ",", "bb", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "root", ",", "cc", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "aa", ",", "bb", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "bb", ",", "cc", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "cc", ",", "aa", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "aa", ",", "dd", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "bb", ",", "ee", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "cc", ",", "ff", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "cc", ",", "dd", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "dd", ",", "ee", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "ee", ",", "ff", ")", ";", "GraphNode", "nodes", "[", "]", "=", "new", "GraphNode", "[", "3", "]", ";", "nodes", "[", "0", "]", "=", "aa", ";", "nodes", "[", "1", "]", "=", "bb", ";", "nodes", "[", "2", "]", "=", "cc", ";", "for", "(", "int", "k", "=", "0", ";", "k", "<", "1", ";", "k", "++", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "8", ";", "i", "++", ")", "{", "GraphNode", "n", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"1", "-", "\"", "+", "i", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "5", ";", "j", "++", ")", "{", "GraphNode", "n2", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"2", "-", "\"", "+", "j", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n", ",", "n2", ")", ".", "setWeight", "(", "-", "1", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "nodes", "[", "j", "%", "3", "]", ",", "n2", ")", ";", "}", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "root", ",", "n", ")", ";", "}", "}", "List", "nodes2", "=", "g", ".", "getNodes", "(", ")", ";", "for", "(", "Iterator", "iterator", "=", "nodes2", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "GraphNode", "node", "=", "(", "GraphNode", ")", "iterator", ".", "next", "(", ")", ";", "node", ".", "setLocation", "(", "200", ",", "200", ")", ";", "}", "g", ".", "addMouseListener", "(", "new", "MouseListener", "(", ")", "{", "public", "void", "mouseUp", "(", "MouseEvent", "e", ")", "{", "MouseDown", "=", "false", ";", "}", "public", "void", "mouseDown", "(", "MouseEvent", "e", ")", "{", "MouseDown", "=", "true", ";", "}", "public", "void", "mouseDoubleClick", "(", "MouseEvent", "e", ")", "{", "}", "}", ")", ";", "g", ".", "addSelectionListener", "(", "new", "SelectionListener", "(", ")", "{", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "List", "selection", "=", "g", ".", "getSelection", "(", ")", ";", "List", "graphNodes", "=", "g", ".", "getNodes", "(", ")", ";", "for", "(", "Iterator", "iterator", "=", "graphNodes", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "GraphNode", "node", "=", "(", "GraphNode", ")", "iterator", ".", "next", "(", ")", ";", "if", "(", "!", "g", ".", "getSelection", "(", ")", ".", "contains", "(", "node", ")", ")", "node", ".", "unhighlight", "(", ")", ";", "}", "List", "connctions", "=", "g", ".", "getConnections", "(", ")", ";", "for", "(", "Iterator", "iterator", "=", "connctions", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "GraphConnection", "connection", "=", "(", "GraphConnection", ")", "iterator", ".", "next", "(", ")", ";", "connection", ".", "unhighlight", "(", ")", ";", "connection", ".", "setWeight", "(", "-", "1", ")", ";", "}", "for", "(", "Iterator", "iterator", "=", "selection", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "Object", "object", "=", "iterator", ".", "next", "(", ")", ";", "if", "(", "object", "instanceof", "GraphNode", ")", "{", "GraphNode", "node", "=", "(", "GraphNode", ")", "object", ";", "List", "sourceConnections", "=", "node", ".", "getSourceConnections", "(", ")", ";", "for", "(", "Iterator", "iterator2", "=", "sourceConnections", ".", "iterator", "(", ")", ";", "iterator2", ".", "hasNext", "(", ")", ";", ")", "{", "GraphConnection", "connection", "=", "(", "GraphConnection", ")", "iterator2", ".", "next", "(", ")", ";", "connection", ".", "getDestination", "(", ")", ".", "highlight", "(", ")", ";", "connection", ".", "highlight", "(", ")", ";", "connection", ".", "setWeight", "(", "10", ")", ";", "}", "List", "target", "=", "node", ".", "getTargetConnections", "(", ")", ";", "for", "(", "Iterator", "iterator2", "=", "target", ".", "iterator", "(", ")", ";", "iterator2", ".", "hasNext", "(", ")", ";", ")", "{", "GraphConnection", "connection", "=", "(", "GraphConnection", ")", "iterator2", ".", "next", "(", ")", ";", "connection", ".", "getSource", "(", ")", ".", "highlight", "(", ")", ";", "connection", ".", "highlight", "(", ")", ";", "connection", ".", "setWeight", "(", "10", ")", ";", "}", "}", "}", "}", "public", "void", "widgetDefaultSelected", "(", "SelectionEvent", "e", ")", "{", "}", "}", ")", ";", "final", "SpringLayoutAlgorithm", "springLayoutAlgorithm", "=", "new", "SpringLayoutAlgorithm", "(", ")", ";", "g", ".", "addLayoutFilter", "(", "new", "LayoutFilter", "(", ")", "{", "public", "boolean", "isObjectFiltered", "(", "GraphItem", "item", ")", "{", "if", "(", "item", "instanceof", "GraphNode", ")", "{", "return", "item", ".", "getGraphModel", "(", ")", ".", "getSelection", "(", ")", ".", "contains", "(", "item", ")", "&&", "MouseDown", ";", "}", "return", "false", ";", "}", "}", ")", ";", "g", ".", "setLayoutAlgorithm", "(", "springLayoutAlgorithm", ",", "false", ")", ";", "g", ".", "applyLayoutNow", "(", ")", ";", "Button", "b", "=", "new", "Button", "(", "shell", ",", "SWT", ".", "FLAT", ")", ";", "b", ".", "setText", "(", "\"step\"", ")", ";", "final", "Label", "label", "=", "new", "Label", "(", "shell", ",", "SWT", ".", "LEFT", ")", ";", "label", ".", "setText", "(", "\"<--click\"", ")", ";", "label", ".", "setLayoutData", "(", "new", "GridData", "(", "SWT", ".", "FILL", ",", "SWT", ".", "CENTER", ",", "true", ",", "false", ")", ")", ";", "b", ".", "addSelectionListener", "(", "new", "SelectionAdapter", "(", ")", "{", "int", "steps", "=", "0", ";", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "r", "=", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "springLayoutAlgorithm", ".", "performNIteration", "(", "1", ")", ";", "g", ".", "redraw", "(", ")", ";", "label", ".", "setText", "(", "\"steps:", "\"", "+", "++", "steps", ")", ";", "try", "{", "Thread", ".", "sleep", "(", "10", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "Display", ".", "getCurrent", "(", ")", ".", "asyncExec", "(", "r", ")", ";", "}", "}", ";", "Display", ".", "getCurrent", "(", ")", ".", "asyncExec", "(", "r", ")", ";", "}", "}", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "}", "}", "</s>" ]
10,226
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "layouts", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ColorConstants", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Ellipse", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Figure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "FreeformLayout", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "IFigure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ImageFigure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "PolylineShape", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Point", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Rectangle", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionListener", ";", "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", ".", "widgets", ".", "Graph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphConnection", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphNode", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "custom", ".", "CGraphNode", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "SpringLayoutAlgorithm", ";", "public", "class", "CustomFigureGraphSnippet", "{", "public", "static", "IFigure", "createPersonFigure", "(", "Image", "headImage", ")", "{", "Figure", "person", "=", "new", "Figure", "(", ")", ";", "person", ".", "setLayoutManager", "(", "new", "FreeformLayout", "(", ")", ")", ";", "IFigure", "head", "=", "null", ";", "if", "(", "headImage", "!=", "null", ")", "{", "headImage", "=", "new", "Image", "(", "headImage", ".", "getDevice", "(", ")", ",", "headImage", ".", "getImageData", "(", ")", ".", "scaledTo", "(", "40", ",", "50", ")", ")", ";", "head", "=", "new", "ImageFigure", "(", "headImage", ")", ";", "}", "else", "head", "=", "new", "Ellipse", "(", ")", ";", "head", ".", "setSize", "(", "40", ",", "50", ")", ";", "PolylineShape", "body", "=", "new", "PolylineShape", "(", ")", ";", "body", ".", "setLineWidth", "(", "1", ")", ";", "body", ".", "setStart", "(", "new", "Point", "(", "20", ",", "40", ")", ")", ";", "body", ".", "setEnd", "(", "new", "Point", "(", "20", ",", "100", ")", ")", ";", "body", ".", "setBounds", "(", "new", "Rectangle", "(", "0", ",", "0", ",", "40", ",", "100", ")", ")", ";", "PolylineShape", "leftLeg", "=", "new", "PolylineShape", "(", ")", ";", "leftLeg", ".", "setLineWidth", "(", "1", ")", ";", "leftLeg", ".", "setStart", "(", "new", "Point", "(", "20", ",", "100", ")", ")", ";", "leftLeg", ".", "setEnd", "(", "new", "Point", "(", "0", ",", "130", ")", ")", ";", "leftLeg", ".", "setBounds", "(", "new", "Rectangle", "(", "0", ",", "0", ",", "40", ",", "130", ")", ")", ";", "PolylineShape", "rightLeg", "=", "new", "PolylineShape", "(", ")", ";", "rightLeg", ".", "setLineWidth", "(", "1", ")", ";", "rightLeg", ".", "setStart", "(", "new", "Point", "(", "20", ",", "100", ")", ")", ";", "rightLeg", ".", "setEnd", "(", "new", "Point", "(", "40", ",", "130", ")", ")", ";", "rightLeg", ".", "setBounds", "(", "new", "Rectangle", "(", "0", ",", "0", ",", "40", ",", "130", ")", ")", ";", "PolylineShape", "leftArm", "=", "new", "PolylineShape", "(", ")", ";", "leftArm", ".", "setLineWidth", "(", "1", ")", ";", "leftArm", ".", "setStart", "(", "new", "Point", "(", "20", ",", "60", ")", ")", ";", "leftArm", ".", "setEnd", "(", "new", "Point", "(", "0", ",", "50", ")", ")", ";", "leftArm", ".", "setBounds", "(", "new", "Rectangle", "(", "0", ",", "0", ",", "40", ",", "130", ")", ")", ";", "PolylineShape", "rightArm", "=", "new", "PolylineShape", "(", ")", ";", "rightArm", ".", "setLineWidth", "(", "1", ")", ";", "rightArm", ".", "setStart", "(", "new", "Point", "(", "20", ",", "60", ")", ")", ";", "rightArm", ".", "setEnd", "(", "new", "Point", "(", "40", ",", "50", ")", ")", ";", "rightArm", ".", "setBounds", "(", "new", "Rectangle", "(", "0", ",", "0", ",", "40", ",", "130", ")", ")", ";", "person", ".", "add", "(", "head", ")", ";", "person", ".", "add", "(", "body", ")", ";", "person", ".", "add", "(", "leftLeg", ")", ";", "person", ".", "add", "(", "rightLeg", ")", ";", "person", ".", "add", "(", "leftArm", ")", ";", "person", ".", "add", "(", "rightArm", ")", ";", "person", ".", "setSize", "(", "40", ",", "130", ")", ";", "return", "person", ";", "}", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "final", "Display", "d", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setText", "(", "\"\"", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "400", ",", "400", ")", ";", "final", "Graph", "g", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "g", ".", "addSelectionListener", "(", "new", "SelectionListener", "(", ")", "{", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "Iterator", "iter", "=", "g", ".", "getSelection", "(", ")", ".", "iterator", "(", ")", ";", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "Object", "o", "=", "iter", ".", "next", "(", ")", ";", "if", "(", "o", "instanceof", "CGraphNode", ")", "{", "IFigure", "figure", "=", "(", "(", "CGraphNode", ")", "o", ")", ".", "getFigure", "(", ")", ";", "figure", ".", "setBackgroundColor", "(", "ColorConstants", ".", "blue", ")", ";", "figure", ".", "setForegroundColor", "(", "ColorConstants", ".", "blue", ")", ";", "}", "}", "iter", "=", "g", ".", "getNodes", "(", ")", ".", "iterator", "(", ")", ";", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "Object", "o", "=", "iter", ".", "next", "(", ")", ";", "if", "(", "o", "instanceof", "CGraphNode", ")", "{", "if", "(", "!", "g", ".", "getSelection", "(", ")", ".", "contains", "(", "o", ")", ")", "{", "(", "(", "CGraphNode", ")", "o", ")", ".", "getFigure", "(", ")", ".", "setBackgroundColor", "(", "ColorConstants", ".", "black", ")", ";", "(", "(", "CGraphNode", ")", "o", ")", ".", "getFigure", "(", ")", ".", "setForegroundColor", "(", "ColorConstants", ".", "black", ")", ";", "}", "}", "}", "}", "public", "void", "widgetDefaultSelected", "(", "SelectionEvent", "e", ")", "{", "}", "}", ")", ";", "Image", "zx", "=", "new", "Image", "(", "d", ",", "\"zx.png\"", ")", ";", "Image", "ibull", "=", "new", "Image", "(", "d", ",", "\"ibull.jpg\"", ")", ";", "CGraphNode", "n", "=", "new", "CGraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "createPersonFigure", "(", "zx", ")", ")", ";", "CGraphNode", "n2", "=", "new", "CGraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "createPersonFigure", "(", "ibull", ")", ")", ";", "GraphNode", "n3", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"PDE\"", ")", ";", "GraphNode", "n4", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Zest\"", ")", ";", "GraphNode", "n5", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"PDE", "Viz", "tool\"", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n", ",", "n2", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n", ",", "n3", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n2", ",", "n4", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n", ",", "n5", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n2", ",", "n5", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n3", ",", "n5", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n4", ",", "n5", ")", ";", "g", ".", "setLayoutAlgorithm", "(", "new", "SpringLayoutAlgorithm", "(", ")", ",", "true", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "zx", ".", "dispose", "(", ")", ";", "ibull", ".", "dispose", "(", ")", ";", "}", "}", "</s>" ]
10,227
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "swt", ";", "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", ".", "layouts", ".", "algorithms", ".", "SpringLayoutAlgorithm", ";", "public", "class", "HelloWorld", "{", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "Display", "d", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setText", "(", "\"Hello,", "World\"", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "400", ",", "400", ")", ";", "Graph", "g", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "GraphNode", "hello", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Hello\"", ")", ";", "GraphNode", "world", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"World\"", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "hello", ",", "world", ")", ";", "g", ".", "setLayoutAlgorithm", "(", "new", "SpringLayoutAlgorithm", "(", ")", ",", "true", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "}", "}", "</s>" ]
10,228
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "swt", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ConnectionRouter", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ManhattanConnectionRouter", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionAdapter", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "layout", ".", "FillLayout", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Button", ";", "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", ".", "SpringLayoutAlgorithm", ";", "public", "class", "ManhattanLayoutGraphSnippet", "{", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "final", "Display", "d", "=", "new", "Display", "(", ")", ";", "final", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setText", "(", "\"\"", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "400", ",", "400", ")", ";", "Button", "b", "=", "new", "Button", "(", "shell", ",", "SWT", ".", "PUSH", ")", ";", "b", ".", "setText", "(", "\"\"", ")", ";", "final", "Graph", "g", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "GraphNode", "n", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Paper\"", ")", ";", "GraphNode", "n2", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Rock\"", ")", ";", "GraphNode", "n3", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Scissors\"", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n", ",", "n2", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n2", ",", "n3", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n3", ",", "n", ")", ";", "g", ".", "setLayoutAlgorithm", "(", "new", "SpringLayoutAlgorithm", "(", ")", ",", "true", ")", ";", "b", ".", "addSelectionListener", "(", "new", "SelectionAdapter", "(", ")", "{", "ConnectionRouter", "router", "=", "null", ";", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "if", "(", "router", "==", "null", ")", "{", "router", "=", "new", "ManhattanConnectionRouter", "(", ")", ";", "}", "else", "{", "router", "=", "null", ";", "}", "g", ".", "setRouter", "(", "router", ")", ";", "}", "}", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "}", "}", "</s>" ]
10,229
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "swt", ";", "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", ".", "layouts", ".", "algorithms", ".", "SpringLayoutAlgorithm", ";", "public", "class", "GraphSnippet1", "{", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "Display", "d", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setText", "(", "\"\"", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "400", ",", "400", ")", ";", "Graph", "g", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "GraphNode", "n", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Paper\"", ")", ";", "GraphNode", "n2", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Rock\"", ")", ";", "GraphNode", "n3", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Scissors\"", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n", ",", "n2", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n2", ",", "n3", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n3", ",", "n", ")", ";", "g", ".", "setLayoutAlgorithm", "(", "new", "SpringLayoutAlgorithm", "(", ")", ",", "true", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "}", "}", "</s>" ]
10,230
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "swt", ";", "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", ";", "public", "class", "GraphSnippet9", "{", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "Display", "display", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "display", ")", ";", "shell", ".", "setText", "(", "\"\"", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "400", ",", "400", ")", ";", "final", "Graph", "graph", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "GraphNode", "a", "=", "new", "GraphNode", "(", "graph", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "\"Root\"", ")", ";", "GraphConnection", "connection", "=", "new", "GraphConnection", "(", "graph", ",", "SWT", ".", "NONE", ",", "a", ",", "a", ")", ";", "connection", ".", "setText", "(", "\"A", "to", "A\"", ")", ";", "a", ".", "setLocation", "(", "100", ",", "100", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "display", ".", "readAndDispatch", "(", ")", ")", "{", "display", ".", "sleep", "(", ")", ";", "}", "}", "}", "}", "</s>" ]
10,231
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "swt", ";", "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", ".", "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", ".", "SpringLayoutAlgorithm", ";", "public", "class", "GraphSnippet2", "{", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "Display", "d", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "Image", "image1", "=", "Display", ".", "getDefault", "(", ")", ".", "getSystemImage", "(", "SWT", ".", "ICON_INFORMATION", ")", ";", "Image", "image2", "=", "Display", ".", "getDefault", "(", ")", ".", "getSystemImage", "(", "SWT", ".", "ICON_WARNING", ")", ";", "Image", "image3", "=", "Display", ".", "getDefault", "(", ")", ".", "getSystemImage", "(", "SWT", ".", "ICON_ERROR", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "400", ",", "400", ")", ";", "Graph", "g", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "g", ".", "setConnectionStyle", "(", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ")", ";", "GraphNode", "n1", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ")", ";", "n1", ".", "setText", "(", "\"Information\"", ")", ";", "n1", ".", "setImage", "(", "image1", ")", ";", "GraphNode", "n2", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ")", ";", "n2", ".", "setText", "(", "\"Warning\"", ")", ";", "n2", ".", "setImage", "(", "image2", ")", ";", "GraphNode", "n3", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ")", ";", "n3", ".", "setText", "(", "\"Error\"", ")", ";", "n3", ".", "setImage", "(", "image3", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n1", ",", "n2", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n2", ",", "n3", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n3", ",", "n3", ")", ";", "g", ".", "setLayoutAlgorithm", "(", "new", "SpringLayoutAlgorithm", "(", ")", ",", "true", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "image1", ".", "dispose", "(", ")", ";", "image2", ".", "dispose", "(", ")", ";", "image3", ".", "dispose", "(", ")", ";", "}", "}", "</s>" ]
10,232
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "swt", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Animation", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionListener", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "layout", ".", "FillLayout", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Button", ";", "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", ";", "public", "class", "AnimationSnippet", "{", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "Display", "d", "=", "new", "Display", "(", ")", ";", "final", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setText", "(", "\"\"", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", "SWT", ".", "VERTICAL", ")", ")", ";", "shell", ".", "setSize", "(", "400", ",", "400", ")", ";", "Button", "b", "=", "new", "Button", "(", "shell", ",", "SWT", ".", "PUSH", ")", ";", "b", ".", "setText", "(", "\"Animate\"", ")", ";", "final", "Graph", "g", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "final", "GraphNode", "n", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Paper\"", ")", ";", "final", "GraphNode", "n2", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Rock\"", ")", ";", "b", ".", "addSelectionListener", "(", "new", "SelectionListener", "(", ")", "{", "public", "void", "widgetDefaultSelected", "(", "SelectionEvent", "e", ")", "{", "}", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "Animation", ".", "markBegin", "(", ")", ";", "n2", ".", "setLocation", "(", "0", ",", "0", ")", ";", "n", ".", "setLocation", "(", "g", ".", "getSize", "(", ")", ".", "x", "-", "n2", ".", "getSize", "(", ")", ".", "width", "-", "5", ",", "0", ")", ";", "Animation", ".", "run", "(", "1000", ")", ";", "}", "}", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n", ",", "n2", ")", ";", "int", "centerX", "=", "shell", ".", "getSize", "(", ")", ".", "x", "/", "2", ";", "int", "centerY", "=", "shell", ".", "getSize", "(", ")", ".", "y", "/", "4", ";", "n", ".", "setLocation", "(", "centerX", ",", "centerY", ")", ";", "n2", ".", "setLocation", "(", "centerX", ",", "centerY", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "}", "}", "</s>" ]
10,233
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "swt", ";", "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", ".", "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", ".", "GridLayoutAlgorithm", ";", "public", "class", "GraphSnippet6", "{", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "Display", "d", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setText", "(", "\"\"", ")", ";", "Image", "image1", "=", "Display", ".", "getDefault", "(", ")", ".", "getSystemImage", "(", "SWT", ".", "ICON_INFORMATION", ")", ";", "Image", "image2", "=", "Display", ".", "getDefault", "(", ")", ".", "getSystemImage", "(", "SWT", ".", "ICON_WARNING", ")", ";", "Image", "image3", "=", "Display", ".", "getDefault", "(", ")", ".", "getSystemImage", "(", "SWT", ".", "ICON_ERROR", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "800", ",", "800", ")", ";", "Graph", "g", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "g", ".", "setConnectionStyle", "(", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "80", ";", "i", "++", ")", "{", "GraphNode", "n1", "=", "new", "GraphNode", "(", "g", ",", "ZestStyles", ".", "NODES_HIDE_TEXT", "|", "ZestStyles", ".", "NODES_FISHEYE", ")", ";", "n1", ".", "setText", "(", "\"Information\"", ")", ";", "n1", ".", "setImage", "(", "image1", ")", ";", "GraphNode", "n2", "=", "new", "GraphNode", "(", "g", ",", "ZestStyles", ".", "NODES_HIDE_TEXT", "|", "ZestStyles", ".", "NODES_FISHEYE", ")", ";", "n2", ".", "setText", "(", "\"Warning\"", ")", ";", "n2", ".", "setImage", "(", "image2", ")", ";", "GraphNode", "n3", "=", "new", "GraphNode", "(", "g", ",", "ZestStyles", ".", "NODES_HIDE_TEXT", "|", "ZestStyles", ".", "NODES_FISHEYE", ")", ";", "n3", ".", "setText", "(", "\"Error\"", ")", ";", "n3", ".", "setImage", "(", "image3", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n1", ",", "n2", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n2", ",", "n3", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n3", ",", "n3", ")", ";", "}", "g", ".", "setLayoutAlgorithm", "(", "new", "GridLayoutAlgorithm", "(", ")", ",", "true", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "image1", ".", "dispose", "(", ")", ";", "image2", ".", "dispose", "(", ")", ";", "image3", ".", "dispose", "(", ")", ";", "}", "}", "</s>" ]
10,234
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "swt", ";", "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", ".", "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", ".", "layouts", ".", "LayoutAlgorithm", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "CompositeLayoutAlgorithm", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "GridLayoutAlgorithm", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "HorizontalShiftAlgorithm", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "RadialLayoutAlgorithm", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "TreeLayoutAlgorithm", ";", "public", "class", "NestedGraphSnippet", "{", "private", "static", "Image", "image1", ";", "private", "static", "Image", "classImage", ";", "public", "static", "void", "createContainer", "(", "Graph", "g", ")", "{", "GraphContainer", "a", "=", "new", "GraphContainer", "(", "g", ",", "SWT", ".", "NONE", ")", ";", "a", ".", "setText", "(", "\"\"", ")", ";", "a", ".", "setImage", "(", "classImage", ")", ";", "int", "r", "=", "(", "int", ")", "(", "(", "Math", ".", "random", "(", ")", "*", "3", ")", "+", "1", ")", ";", "r", "=", "2", ";", "populateContainer", "(", "a", ",", "g", ",", "r", ",", "true", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "4", ";", "i", "++", ")", "{", "GraphContainer", "b", "=", "new", "GraphContainer", "(", "g", ",", "SWT", ".", "NONE", ")", ";", "b", ".", "setText", "(", "\"\"", ")", ";", "b", ".", "setImage", "(", "classImage", ")", ";", "r", "=", "(", "int", ")", "(", "(", "Math", ".", "random", "(", ")", "*", "3", ")", "+", "1", ")", ";", "r", "=", "2", ";", "populateContainer", "(", "b", ",", "g", ",", "r", ",", "false", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "a", ",", "b", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "4", ";", "j", "++", ")", "{", "GraphContainer", "c", "=", "new", "GraphContainer", "(", "g", ",", "SWT", ".", "NONE", ")", ";", "c", ".", "setText", "(", "\"\"", ")", ";", "c", ".", "setImage", "(", "classImage", ")", ";", "r", "=", "(", "int", ")", "(", "(", "Math", ".", "random", "(", ")", "*", "3", ")", "+", "1", ")", ";", "r", "=", "2", ";", "populateContainer", "(", "c", ",", "g", ",", "r", ",", "true", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "b", ",", "c", ")", ";", "}", "}", "}", "public", "static", "void", "populateContainer", "(", "GraphContainer", "c", ",", "Graph", "g", ",", "int", "number", ",", "boolean", "radial", ")", "{", "GraphNode", "a", "=", "new", "GraphNode", "(", "c", ",", "ZestStyles", ".", "NODES_FISHEYE", "|", "ZestStyles", ".", "NODES_HIDE_TEXT", ")", ";", "a", ".", "setText", "(", "\"\"", ")", ";", "a", ".", "setImage", "(", "classImage", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "4", ";", "i", "++", ")", "{", "GraphNode", "b", "=", "new", "GraphNode", "(", "c", ",", "ZestStyles", ".", "NODES_FISHEYE", "|", "ZestStyles", ".", "NODES_HIDE_TEXT", ")", ";", "b", ".", "setText", "(", "\"\"", ")", ";", "b", ".", "setImage", "(", "classImage", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "a", ",", "b", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "4", ";", "j", "++", ")", "{", "GraphNode", "d", "=", "new", "GraphNode", "(", "c", ",", "ZestStyles", ".", "NODES_FISHEYE", "|", "ZestStyles", ".", "NODES_HIDE_TEXT", ")", ";", "d", ".", "setText", "(", "\"\"", ")", ";", "d", ".", "setImage", "(", "classImage", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "b", ",", "d", ")", ";", "if", "(", "number", ">", "2", ")", "{", "for", "(", "int", "k", "=", "0", ";", "k", "<", "4", ";", "k", "++", ")", "{", "GraphNode", "e", "=", "new", "GraphNode", "(", "c", ",", "ZestStyles", ".", "NODES_FISHEYE", "|", "ZestStyles", ".", "NODES_HIDE_TEXT", ")", ";", "e", ".", "setText", "(", "\"\"", ")", ";", "e", ".", "setImage", "(", "classImage", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "d", ",", "e", ")", ";", "if", "(", "number", ">", "3", ")", "{", "for", "(", "int", "l", "=", "0", ";", "l", "<", "4", ";", "l", "++", ")", "{", "GraphNode", "f", "=", "new", "GraphNode", "(", "c", ",", "ZestStyles", ".", "NODES_FISHEYE", "|", "ZestStyles", ".", "NODES_HIDE_TEXT", ")", ";", "f", ".", "setText", "(", "\"\"", ")", ";", "f", ".", "setImage", "(", "classImage", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "e", ",", "f", ")", ";", "}", "}", "}", "}", "}", "}", "if", "(", "number", "==", "1", ")", "{", "c", ".", "setScale", "(", "0.75", ")", ";", "}", "else", "if", "(", "number", "==", "2", ")", "{", "c", ".", "setScale", "(", "0.50", ")", ";", "}", "else", "{", "c", ".", "setScale", "(", "0.25", ")", ";", "}", "if", "(", "radial", ")", "{", "c", ".", "setLayoutAlgorithm", "(", "new", "RadialLayoutAlgorithm", "(", ")", ",", "true", ")", ";", "}", "else", "{", "c", ".", "setLayoutAlgorithm", "(", "new", "TreeLayoutAlgorithm", "(", ")", ",", "true", ")", ";", "}", "}", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "Display", "d", "=", "new", "Display", "(", ")", ";", "image1", "=", "new", "Image", "(", "Display", ".", "getDefault", "(", ")", ",", "NestedGraphSnippet", ".", "class", ".", "getResourceAsStream", "(", "\"\"", ")", ")", ";", "classImage", "=", "new", "Image", "(", "Display", ".", "getDefault", "(", ")", ",", "NestedGraphSnippet", ".", "class", ".", "getResourceAsStream", "(", "\"\"", ")", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setText", "(", "\"\"", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "500", ",", "800", ")", ";", "Graph", "g", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "createContainer", "(", "g", ")", ";", "CompositeLayoutAlgorithm", "compositeLayoutAlgorithm", "=", "new", "CompositeLayoutAlgorithm", "(", "new", "LayoutAlgorithm", "[", "]", "{", "new", "GridLayoutAlgorithm", "(", ")", ",", "new", "HorizontalShiftAlgorithm", "(", ")", "}", ")", ";", "g", ".", "setLayoutAlgorithm", "(", "compositeLayoutAlgorithm", ",", "true", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "image1", ".", "dispose", "(", ")", ";", "}", "}", "</s>" ]
10,235
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "swt", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "KeyEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "KeyListener", ";", "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", ".", "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", ".", "layouts", ".", "LayoutAlgorithm", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "CompositeLayoutAlgorithm", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "GridLayoutAlgorithm", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "HorizontalShiftAlgorithm", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "RadialLayoutAlgorithm", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "TreeLayoutAlgorithm", ";", "public", "class", "ZoomSnippet", "{", "private", "static", "Image", "image1", ";", "private", "static", "Image", "classImage", ";", "public", "static", "void", "createContainer", "(", "Graph", "g", ")", "{", "GraphContainer", "a", "=", "new", "GraphContainer", "(", "g", ",", "SWT", ".", "NONE", ")", ";", "a", ".", "setText", "(", "\"\"", ")", ";", "a", ".", "setImage", "(", "classImage", ")", ";", "int", "r", "=", "(", "int", ")", "(", "(", "Math", ".", "random", "(", ")", "*", "3", ")", "+", "1", ")", ";", "r", "=", "2", ";", "populateContainer", "(", "a", ",", "g", ",", "r", ",", "true", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "4", ";", "i", "++", ")", "{", "GraphContainer", "b", "=", "new", "GraphContainer", "(", "g", ",", "SWT", ".", "NONE", ")", ";", "b", ".", "setText", "(", "\"\"", ")", ";", "b", ".", "setImage", "(", "classImage", ")", ";", "r", "=", "(", "int", ")", "(", "(", "Math", ".", "random", "(", ")", "*", "3", ")", "+", "1", ")", ";", "r", "=", "2", ";", "populateContainer", "(", "b", ",", "g", ",", "r", ",", "false", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "a", ",", "b", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "4", ";", "j", "++", ")", "{", "GraphContainer", "c", "=", "new", "GraphContainer", "(", "g", ",", "SWT", ".", "NONE", ")", ";", "c", ".", "setText", "(", "\"\"", ")", ";", "c", ".", "setImage", "(", "classImage", ")", ";", "r", "=", "(", "int", ")", "(", "(", "Math", ".", "random", "(", ")", "*", "3", ")", "+", "1", ")", ";", "r", "=", "2", ";", "populateContainer", "(", "c", ",", "g", ",", "r", ",", "true", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "b", ",", "c", ")", ";", "}", "}", "}", "public", "static", "void", "populateContainer", "(", "GraphContainer", "c", ",", "Graph", "g", ",", "int", "number", ",", "boolean", "radial", ")", "{", "GraphNode", "a", "=", "new", "GraphNode", "(", "c", ",", "ZestStyles", ".", "NODES_FISHEYE", "|", "ZestStyles", ".", "NODES_HIDE_TEXT", ")", ";", "a", ".", "setText", "(", "\"\"", ")", ";", "a", ".", "setImage", "(", "classImage", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "4", ";", "i", "++", ")", "{", "GraphNode", "b", "=", "new", "GraphNode", "(", "c", ",", "ZestStyles", ".", "NODES_FISHEYE", "|", "ZestStyles", ".", "NODES_HIDE_TEXT", ")", ";", "b", ".", "setText", "(", "\"\"", ")", ";", "b", ".", "setImage", "(", "classImage", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "a", ",", "b", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "4", ";", "j", "++", ")", "{", "GraphNode", "d", "=", "new", "GraphNode", "(", "c", ",", "ZestStyles", ".", "NODES_FISHEYE", "|", "ZestStyles", ".", "NODES_HIDE_TEXT", ")", ";", "d", ".", "setText", "(", "\"\"", ")", ";", "d", ".", "setImage", "(", "classImage", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "b", ",", "d", ")", ";", "if", "(", "number", ">", "2", ")", "{", "for", "(", "int", "k", "=", "0", ";", "k", "<", "4", ";", "k", "++", ")", "{", "GraphNode", "e", "=", "new", "GraphNode", "(", "c", ",", "ZestStyles", ".", "NODES_FISHEYE", "|", "ZestStyles", ".", "NODES_HIDE_TEXT", ")", ";", "e", ".", "setText", "(", "\"\"", ")", ";", "e", ".", "setImage", "(", "classImage", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "d", ",", "e", ")", ";", "if", "(", "number", ">", "3", ")", "{", "for", "(", "int", "l", "=", "0", ";", "l", "<", "4", ";", "l", "++", ")", "{", "GraphNode", "f", "=", "new", "GraphNode", "(", "c", ",", "ZestStyles", ".", "NODES_FISHEYE", "|", "ZestStyles", ".", "NODES_HIDE_TEXT", ")", ";", "f", ".", "setText", "(", "\"\"", ")", ";", "f", ".", "setImage", "(", "classImage", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "e", ",", "f", ")", ";", "}", "}", "}", "}", "}", "}", "if", "(", "number", "==", "1", ")", "{", "c", ".", "setScale", "(", "0.75", ")", ";", "}", "else", "if", "(", "number", "==", "2", ")", "{", "c", ".", "setScale", "(", "0.50", ")", ";", "}", "else", "{", "c", ".", "setScale", "(", "0.25", ")", ";", "}", "if", "(", "radial", ")", "{", "c", ".", "setLayoutAlgorithm", "(", "new", "RadialLayoutAlgorithm", "(", ")", ",", "true", ")", ";", "}", "else", "{", "c", ".", "setLayoutAlgorithm", "(", "new", "TreeLayoutAlgorithm", "(", ")", ",", "true", ")", ";", "}", "}", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "Display", "d", "=", "new", "Display", "(", ")", ";", "image1", "=", "new", "Image", "(", "Display", ".", "getDefault", "(", ")", ",", "ZoomSnippet", ".", "class", ".", "getResourceAsStream", "(", "\"\"", ")", ")", ";", "classImage", "=", "new", "Image", "(", "Display", ".", "getDefault", "(", ")", ",", "ZoomSnippet", ".", "class", ".", "getResourceAsStream", "(", "\"\"", ")", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setText", "(", "\"\"", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "500", ",", "800", ")", ";", "final", "Graph", "g", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "createContainer", "(", "g", ")", ";", "CompositeLayoutAlgorithm", "compositeLayoutAlgorithm", "=", "new", "CompositeLayoutAlgorithm", "(", "new", "LayoutAlgorithm", "[", "]", "{", "new", "GridLayoutAlgorithm", "(", ")", ",", "new", "HorizontalShiftAlgorithm", "(", ")", "}", ")", ";", "g", ".", "setLayoutAlgorithm", "(", "compositeLayoutAlgorithm", ",", "true", ")", ";", "g", ".", "addKeyListener", "(", "new", "KeyListener", "(", ")", "{", "boolean", "flip", "=", "true", ";", "public", "void", "keyPressed", "(", "KeyEvent", "e", ")", "{", "if", "(", "g", ".", "getSelection", "(", ")", ".", "size", "(", ")", "==", "1", ")", "{", "GraphNode", "item", "=", "(", "GraphNode", ")", "g", ".", "getSelection", "(", ")", ".", "get", "(", "0", ")", ";", "if", "(", "item", ".", "getItemType", "(", ")", "==", "GraphItem", ".", "CONTAINER", ")", "{", "if", "(", "flip", ")", "{", "(", "item", ")", ".", "setSize", "(", "500", ",", "100", ")", ";", "}", "else", "{", "(", "item", ")", ".", "setSize", "(", "0", ",", "0", ")", ";", "}", "flip", "=", "!", "flip", ";", "}", "}", "}", "public", "void", "keyReleased", "(", "KeyEvent", "e", ")", "{", "}", "}", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "image1", ".", "dispose", "(", ")", ";", "}", "}", "</s>" ]
10,236
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "swt", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionAdapter", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionEvent", ";", "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", ".", "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", ".", "SpringLayoutAlgorithm", ";", "public", "class", "GraphSnippet3", "{", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "Display", "d", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "Image", "image1", "=", "Display", ".", "getDefault", "(", ")", ".", "getSystemImage", "(", "SWT", ".", "ICON_INFORMATION", ")", ";", "Image", "image2", "=", "Display", ".", "getDefault", "(", ")", ".", "getSystemImage", "(", "SWT", ".", "ICON_WARNING", ")", ";", "Image", "image3", "=", "Display", ".", "getDefault", "(", ")", ".", "getSystemImage", "(", "SWT", ".", "ICON_ERROR", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "400", ",", "400", ")", ";", "Graph", "g", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "g", ".", "addSelectionListener", "(", "new", "SelectionAdapter", "(", ")", "{", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "System", ".", "out", ".", "println", "(", "(", "(", "Graph", ")", "e", ".", "widget", ")", ".", "getSelection", "(", ")", ")", ";", "}", "}", ")", ";", "g", ".", "setConnectionStyle", "(", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ")", ";", "GraphNode", "n1", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ")", ";", "n1", ".", "setText", "(", "\"Information\"", ")", ";", "n1", ".", "setImage", "(", "image1", ")", ";", "GraphNode", "n2", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ")", ";", "n2", ".", "setText", "(", "\"Warning\"", ")", ";", "n2", ".", "setImage", "(", "image2", ")", ";", "GraphNode", "n3", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ")", ";", "n3", ".", "setText", "(", "\"Error\"", ")", ";", "n3", ".", "setImage", "(", "image3", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n1", ",", "n2", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n2", ",", "n3", ")", ";", "g", ".", "setLayoutAlgorithm", "(", "new", "SpringLayoutAlgorithm", "(", ")", ",", "true", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "image1", ".", "dispose", "(", ")", ";", "image2", ".", "dispose", "(", ")", ";", "image3", ".", "dispose", "(", ")", ";", "}", "}", "</s>" ]
10,237
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "swt", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ColorConstants", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "KeyAdapter", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "KeyEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "PaintEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "PaintListener", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Font", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "FontData", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Image", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Region", ";", "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", ".", "GraphItem", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphNode", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "ZestStyles", ";", "public", "class", "GraphSnippet5", "{", "public", "static", "final", "int", "BACKSPACE", "=", "8", ";", "public", "static", "final", "int", "ENTER", "=", "13", ";", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "final", "Map", "figureListing", "=", "new", "HashMap", "(", ")", ";", "final", "StringBuffer", "stringBuffer", "=", "new", "StringBuffer", "(", ")", ";", "final", "Display", "d", "=", "new", "Display", "(", ")", ";", "FontData", "fontData", "=", "d", ".", "getSystemFont", "(", ")", ".", "getFontData", "(", ")", "[", "0", "]", ";", "fontData", ".", "height", "=", "42", ";", "final", "Font", "font", "=", "new", "Font", "(", "d", ",", "fontData", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setText", "(", "\"\"", ")", ";", "Image", "image1", "=", "Display", ".", "getDefault", "(", ")", ".", "getSystemImage", "(", "SWT", ".", "ICON_INFORMATION", ")", ";", "Image", "image2", "=", "Display", ".", "getDefault", "(", ")", ".", "getSystemImage", "(", "SWT", ".", "ICON_WARNING", ")", ";", "Image", "image3", "=", "Display", ".", "getDefault", "(", ")", ".", "getSystemImage", "(", "SWT", ".", "ICON_ERROR", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "400", ",", "400", ")", ";", "final", "Graph", "g", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "g", ".", "setConnectionStyle", "(", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ")", ";", "GraphNode", "n1", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ")", ";", "n1", ".", "setText", "(", "\"Information\"", ")", ";", "n1", ".", "setImage", "(", "image1", ")", ";", "GraphNode", "n2", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ")", ";", "n2", ".", "setText", "(", "\"Warning\"", ")", ";", "n2", ".", "setImage", "(", "image2", ")", ";", "GraphNode", "n3", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ")", ";", "n3", ".", "setText", "(", "\"Error\"", ")", ";", "n3", ".", "setImage", "(", "image3", ")", ";", "figureListing", ".", "put", "(", "n1", ".", "getText", "(", ")", ".", "toLowerCase", "(", ")", ",", "n1", ")", ";", "figureListing", ".", "put", "(", "n2", ".", "getText", "(", ")", ".", "toLowerCase", "(", ")", ",", "n2", ")", ";", "figureListing", ".", "put", "(", "n3", ".", "getText", "(", ")", ".", "toLowerCase", "(", ")", ",", "n3", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n1", ",", "n2", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n2", ",", "n3", ")", ";", "n1", ".", "setLocation", "(", "10", ",", "10", ")", ";", "n2", ".", "setLocation", "(", "200", ",", "10", ")", ";", "n3", ".", "setLocation", "(", "200", ",", "200", ")", ";", "g", ".", "addKeyListener", "(", "new", "KeyAdapter", "(", ")", "{", "public", "void", "keyPressed", "(", "KeyEvent", "e", ")", "{", "boolean", "complete", "=", "false", ";", "if", "(", "e", ".", "keyCode", "==", "BACKSPACE", ")", "{", "if", "(", "stringBuffer", ".", "length", "(", ")", ">", "0", ")", "{", "stringBuffer", ".", "deleteCharAt", "(", "stringBuffer", ".", "length", "(", ")", "-", "1", ")", ";", "}", "}", "else", "if", "(", "e", ".", "keyCode", "==", "ENTER", ")", "{", "complete", "=", "true", ";", "}", "else", "if", "(", "(", "e", ".", "character", ">=", "'a'", "&&", "e", ".", "character", "<=", "'z'", ")", "||", "(", "e", ".", "character", ">=", "'A'", "&&", "e", ".", "character", "<=", "'Z'", ")", "||", "(", "e", ".", "character", "==", "'.'", ")", "||", "(", "e", ".", "character", ">=", "'0'", "&&", "e", ".", "character", "<=", "'9'", ")", ")", "{", "stringBuffer", ".", "append", "(", "e", ".", "character", ")", ";", "}", "Iterator", "iterator", "=", "figureListing", ".", "keySet", "(", ")", ".", "iterator", "(", ")", ";", "List", "list", "=", "new", "ArrayList", "(", ")", ";", "if", "(", "stringBuffer", ".", "length", "(", ")", ">", "0", ")", "{", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "String", "string", "=", "(", "String", ")", "iterator", ".", "next", "(", ")", ";", "if", "(", "string", ".", "indexOf", "(", "stringBuffer", ".", "toString", "(", ")", ".", "toLowerCase", "(", ")", ")", ">=", "0", ")", "{", "list", ".", "add", "(", "figureListing", ".", "get", "(", "string", ")", ")", ";", "}", "}", "}", "g", ".", "setSelection", "(", "(", "GraphItem", "[", "]", ")", "list", ".", "toArray", "(", "new", "GraphItem", "[", "list", ".", "size", "(", ")", "]", ")", ")", ";", "if", "(", "complete", "&&", "stringBuffer", ".", "length", "(", ")", ">", "0", ")", "{", "stringBuffer", ".", "delete", "(", "0", ",", "stringBuffer", ".", "length", "(", ")", ")", ";", "}", "g", ".", "redraw", "(", ")", ";", "}", "}", ")", ";", "g", ".", "addPaintListener", "(", "new", "PaintListener", "(", ")", "{", "public", "void", "paintControl", "(", "PaintEvent", "e", ")", "{", "e", ".", "gc", ".", "setFont", "(", "font", ")", ";", "e", ".", "gc", ".", "setClipping", "(", "(", "Region", ")", "null", ")", ";", "e", ".", "gc", ".", "setForeground", "(", "ColorConstants", ".", "black", ")", ";", "e", ".", "gc", ".", "drawText", "(", "stringBuffer", ".", "toString", "(", ")", ",", "50", ",", "50", ",", "true", ")", ";", "}", "}", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "image1", ".", "dispose", "(", ")", ";", "image2", ".", "dispose", "(", ")", ";", "image3", ".", "dispose", "(", ")", ";", "font", ".", "dispose", "(", ")", ";", "}", "}", "</s>" ]
10,238
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "swt", ";", "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", ".", "layouts", ".", "LayoutAlgorithm", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "EntityLayout", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "LayoutContext", ";", "public", "class", "CustomLayout", "{", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "Display", "d", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setText", "(", "\"\"", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "400", ",", "400", ")", ";", "Graph", "g", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "GraphNode", "n", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Paper\"", ")", ";", "GraphNode", "n2", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Rock\"", ")", ";", "GraphNode", "n3", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Scissors\"", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n", ",", "n2", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n2", ",", "n3", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n3", ",", "n", ")", ";", "LayoutAlgorithm", "layoutAlgorithm", "=", "new", "LayoutAlgorithm", "(", ")", "{", "private", "LayoutContext", "context", ";", "public", "void", "setLayoutContext", "(", "LayoutContext", "context", ")", "{", "this", ".", "context", "=", "context", ";", "}", "public", "void", "applyLayout", "(", "boolean", "clean", ")", "{", "EntityLayout", "[", "]", "entitiesToLayout", "=", "context", ".", "getEntities", "(", ")", ";", "int", "totalSteps", "=", "entitiesToLayout", ".", "length", ";", "double", "distance", "=", "context", ".", "getBounds", "(", ")", ".", "width", "/", "totalSteps", ";", "int", "xLocation", "=", "0", ";", "for", "(", "int", "currentStep", "=", "0", ";", "currentStep", "<", "entitiesToLayout", ".", "length", ";", "currentStep", "++", ")", "{", "EntityLayout", "layoutEntity", "=", "entitiesToLayout", "[", "currentStep", "]", ";", "layoutEntity", ".", "setLocation", "(", "xLocation", ",", "layoutEntity", ".", "getLocation", "(", ")", ".", "y", ")", ";", "xLocation", "+=", "distance", ";", "}", "}", "}", ";", "g", ".", "setLayoutAlgorithm", "(", "layoutAlgorithm", ",", "true", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "}", "}", "</s>" ]
10,239
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "swt", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "SWTGraphics", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "PaintEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "PaintListener", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionListener", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "GC", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Image", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Point", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "layout", ".", "FillLayout", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Button", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Canvas", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Event", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Listener", ";", "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", ".", "SpringLayoutAlgorithm", ";", "public", "class", "PaintSnippet", "{", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "final", "Display", "d", "=", "new", "Display", "(", ")", ";", "final", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setText", "(", "\"\"", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "400", ",", "400", ")", ";", "Button", "b", "=", "new", "Button", "(", "shell", ",", "SWT", ".", "PUSH", ")", ";", "b", ".", "setText", "(", "\"\"", ")", ";", "final", "Graph", "g", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "GraphNode", "n", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Paper\"", ")", ";", "GraphNode", "n2", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Rock\"", ")", ";", "GraphNode", "n3", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Scissors\"", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n", ",", "n2", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n2", ",", "n3", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n3", ",", "n", ")", ";", "g", ".", "setLayoutAlgorithm", "(", "new", "SpringLayoutAlgorithm", "(", ")", ",", "true", ")", ";", "b", ".", "addSelectionListener", "(", "new", "SelectionListener", "(", ")", "{", "public", "void", "widgetDefaultSelected", "(", "SelectionEvent", "e", ")", "{", "}", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "Point", "size", "=", "new", "Point", "(", "g", ".", "getContents", "(", ")", ".", "getSize", "(", ")", ".", "width", ",", "g", ".", "getContents", "(", ")", ".", "getSize", "(", ")", ".", "height", ")", ";", "final", "Image", "image", "=", "new", "Image", "(", "null", ",", "size", ".", "x", ",", "size", ".", "y", ")", ";", "GC", "gc", "=", "new", "GC", "(", "image", ")", ";", "SWTGraphics", "swtGraphics", "=", "new", "SWTGraphics", "(", "gc", ")", ";", "g", ".", "getContents", "(", ")", ".", "paint", "(", "swtGraphics", ")", ";", "gc", ".", "copyArea", "(", "image", ",", "0", ",", "0", ")", ";", "gc", ".", "dispose", "(", ")", ";", "Shell", "popup", "=", "new", "Shell", "(", "shell", ")", ";", "popup", ".", "setText", "(", "\"Image\"", ")", ";", "popup", ".", "addListener", "(", "SWT", ".", "Close", ",", "new", "Listener", "(", ")", "{", "public", "void", "handleEvent", "(", "Event", "e", ")", "{", "image", ".", "dispose", "(", ")", ";", "}", "}", ")", ";", "Canvas", "canvas", "=", "new", "Canvas", "(", "popup", ",", "SWT", ".", "NONE", ")", ";", "canvas", ".", "setBounds", "(", "10", ",", "10", ",", "size", ".", "x", "+", "10", ",", "size", ".", "y", "+", "10", ")", ";", "canvas", ".", "addPaintListener", "(", "new", "PaintListener", "(", ")", "{", "public", "void", "paintControl", "(", "PaintEvent", "e", ")", "{", "e", ".", "gc", ".", "drawImage", "(", "image", ",", "0", ",", "0", ")", ";", "}", "}", ")", ";", "popup", ".", "pack", "(", ")", ";", "popup", ".", "open", "(", ")", ";", "}", "}", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "}", "}", "</s>" ]
10,240
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "swt", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ColorConstants", ";", "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", ".", "GraphItem", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphNode", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "LayoutFilter", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "ZestStyles", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "TreeLayoutAlgorithm", ";", "public", "class", "GraphSnippet8", "{", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "Display", "display", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "display", ")", ";", "shell", ".", "setText", "(", "\"\"", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "400", ",", "400", ")", ";", "final", "Graph", "graph", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "GraphNode", "a", "=", "new", "GraphNode", "(", "graph", ",", "SWT", ".", "NONE", ",", "\"Root\"", ")", ";", "GraphNode", "b", "=", "new", "GraphNode", "(", "graph", ",", "SWT", ".", "NONE", ",", "\"B\"", ")", ";", "GraphNode", "c", "=", "new", "GraphNode", "(", "graph", ",", "SWT", ".", "NONE", ",", "\"C\"", ")", ";", "GraphNode", "d", "=", "new", "GraphNode", "(", "graph", ",", "SWT", ".", "NONE", ",", "\"D\"", ")", ";", "GraphNode", "e", "=", "new", "GraphNode", "(", "graph", ",", "SWT", ".", "NONE", ",", "\"E\"", ")", ";", "GraphNode", "f", "=", "new", "GraphNode", "(", "graph", ",", "SWT", ".", "NONE", ",", "\"F\"", ")", ";", "GraphNode", "g", "=", "new", "GraphNode", "(", "graph", ",", "SWT", ".", "NONE", ",", "\"G\"", ")", ";", "GraphNode", "h", "=", "new", "GraphNode", "(", "graph", ",", "SWT", ".", "NONE", ",", "\"H\"", ")", ";", "GraphConnection", "connection", "=", "new", "GraphConnection", "(", "graph", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "a", ",", "b", ")", ";", "connection", ".", "setData", "(", "Boolean", ".", "TRUE", ")", ";", "connection", "=", "new", "GraphConnection", "(", "graph", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "a", ",", "c", ")", ";", "connection", ".", "setData", "(", "Boolean", ".", "TRUE", ")", ";", "connection", "=", "new", "GraphConnection", "(", "graph", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "a", ",", "c", ")", ";", "connection", ".", "setData", "(", "Boolean", ".", "TRUE", ")", ";", "connection", "=", "new", "GraphConnection", "(", "graph", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "a", ",", "d", ")", ";", "connection", ".", "setData", "(", "Boolean", ".", "TRUE", ")", ";", "connection", "=", "new", "GraphConnection", "(", "graph", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "b", ",", "e", ")", ";", "connection", ".", "setData", "(", "Boolean", ".", "FALSE", ")", ";", "connection", "=", "new", "GraphConnection", "(", "graph", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "b", ",", "f", ")", ";", "connection", ".", "setData", "(", "Boolean", ".", "FALSE", ")", ";", "connection", "=", "new", "GraphConnection", "(", "graph", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "c", ",", "g", ")", ";", "connection", ".", "setData", "(", "Boolean", ".", "FALSE", ")", ";", "connection", "=", "new", "GraphConnection", "(", "graph", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "d", ",", "h", ")", ";", "connection", ".", "setData", "(", "Boolean", ".", "FALSE", ")", ";", "connection", "=", "new", "GraphConnection", "(", "graph", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "b", ",", "c", ")", ";", "connection", ".", "setLineColor", "(", "ColorConstants", ".", "red", ")", ";", "connection", ".", "setLineWidth", "(", "3", ")", ";", "connection", "=", "new", "GraphConnection", "(", "graph", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "c", ",", "d", ")", ";", "connection", ".", "setLineColor", "(", "ColorConstants", ".", "red", ")", ";", "connection", ".", "setLineWidth", "(", "3", ")", ";", "connection", "=", "new", "GraphConnection", "(", "graph", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "e", ",", "f", ")", ";", "connection", ".", "setLineColor", "(", "ColorConstants", ".", "red", ")", ";", "connection", ".", "setLineWidth", "(", "3", ")", ";", "connection", "=", "new", "GraphConnection", "(", "graph", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "f", ",", "g", ")", ";", "connection", ".", "setLineColor", "(", "ColorConstants", ".", "red", ")", ";", "connection", ".", "setLineWidth", "(", "3", ")", ";", "connection", "=", "new", "GraphConnection", "(", "graph", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "h", ",", "e", ")", ";", "connection", ".", "setLineColor", "(", "ColorConstants", ".", "red", ")", ";", "connection", ".", "setLineWidth", "(", "3", ")", ";", "TreeLayoutAlgorithm", "treeLayoutAlgorithm", "=", "new", "TreeLayoutAlgorithm", "(", ")", ";", "LayoutFilter", "filter", "=", "new", "LayoutFilter", "(", ")", "{", "public", "boolean", "isObjectFiltered", "(", "GraphItem", "item", ")", "{", "if", "(", "item", "instanceof", "GraphConnection", ")", "{", "GraphConnection", "connection", "=", "(", "GraphConnection", ")", "item", ";", "Object", "data", "=", "connection", ".", "getData", "(", ")", ";", "if", "(", "data", "!=", "null", "&&", "data", "instanceof", "Boolean", ")", "{", "return", "(", "(", "Boolean", ")", "data", ")", ".", "booleanValue", "(", ")", ";", "}", "return", "true", ";", "}", "return", "false", ";", "}", "}", ";", "graph", ".", "addLayoutFilter", "(", "filter", ")", ";", "graph", ".", "setLayoutAlgorithm", "(", "treeLayoutAlgorithm", ",", "true", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "display", ".", "readAndDispatch", "(", ")", ")", "{", "display", ".", "sleep", "(", ")", ";", "}", "}", "}", "}", "</s>" ]
10,241
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "swt", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "IFigure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Label", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "GC", ";", "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", ".", "widgets", ".", "Graph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphConnection", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphNode", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "ZestStyles", ";", "public", "class", "GraphSnippet4", "{", "public", "static", "Image", "mergeImages", "(", "Image", "image1", ",", "Image", "image2", ")", "{", "Image", "mergedImage", "=", "new", "Image", "(", "Display", ".", "getDefault", "(", ")", ",", "image1", ".", "getBounds", "(", ")", ".", "width", "+", "image2", ".", "getBounds", "(", ")", ".", "width", ",", "image1", ".", "getBounds", "(", ")", ".", "height", ")", ";", "GC", "gc", "=", "new", "GC", "(", "mergedImage", ")", ";", "gc", ".", "drawImage", "(", "image1", ",", "0", ",", "0", ")", ";", "gc", ".", "drawImage", "(", "image2", ",", "image1", ".", "getBounds", "(", ")", ".", "width", ",", "0", ")", ";", "gc", ".", "dispose", "(", ")", ";", "return", "mergedImage", ";", "}", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "Display", "d", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setText", "(", "\"\"", ")", ";", "Image", "image1", "=", "Display", ".", "getDefault", "(", ")", ".", "getSystemImage", "(", "SWT", ".", "ICON_INFORMATION", ")", ";", "Image", "image2", "=", "Display", ".", "getDefault", "(", ")", ".", "getSystemImage", "(", "SWT", ".", "ICON_WARNING", ")", ";", "Image", "image3", "=", "Display", ".", "getDefault", "(", ")", ".", "getSystemImage", "(", "SWT", ".", "ICON_ERROR", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "400", ",", "400", ")", ";", "Graph", "g", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "g", ".", "setConnectionStyle", "(", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ")", ";", "GraphNode", "n1", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ")", ";", "n1", ".", "setText", "(", "\"Information\"", ")", ";", "n1", ".", "setImage", "(", "image1", ")", ";", "GraphNode", "n2", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ")", ";", "n2", ".", "setText", "(", "\"Warning\"", ")", ";", "n2", ".", "setImage", "(", "image2", ")", ";", "GraphNode", "n3", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ")", ";", "n3", ".", "setText", "(", "\"Error\"", ")", ";", "n3", ".", "setImage", "(", "image3", ")", ";", "GraphConnection", "connection1", "=", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n1", ",", "n2", ")", ";", "GraphConnection", "connection2", "=", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n2", ",", "n3", ")", ";", "Image", "information2warningImage", "=", "mergeImages", "(", "image1", ",", "image2", ")", ";", "Image", "warning2error", "=", "mergeImages", "(", "image2", ",", "image3", ")", ";", "IFigure", "tooltip1", "=", "new", "Label", "(", "\"\"", ",", "information2warningImage", ")", ";", "IFigure", "tooltip2", "=", "new", "Label", "(", "\"\"", ",", "warning2error", ")", ";", "connection1", ".", "setTooltip", "(", "tooltip1", ")", ";", "connection2", ".", "setTooltip", "(", "tooltip2", ")", ";", "n1", ".", "setLocation", "(", "10", ",", "10", ")", ";", "n2", ".", "setLocation", "(", "200", ",", "10", ")", ";", "n3", ".", "setLocation", "(", "200", ",", "200", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "image1", ".", "dispose", "(", ")", ";", "image2", ".", "dispose", "(", ")", ";", "image3", ".", "dispose", "(", ")", ";", "information2warningImage", ".", "dispose", "(", ")", ";", "warning2error", ".", "dispose", "(", ")", ";", "}", "}", "</s>" ]
10,242
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "swt", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "MouseEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "MouseMoveListener", ";", "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", ".", "layouts", ".", "algorithms", ".", "SpringLayoutAlgorithm", ";", "public", "class", "GraphSnippet7", "{", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "Display", "d", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setText", "(", "\"\"", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "400", ",", "400", ")", ";", "final", "Graph", "g", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "GraphNode", "n", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Paper\"", ")", ";", "GraphNode", "n2", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Rock\"", ")", ";", "GraphNode", "n3", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Scissors\"", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n", ",", "n2", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n2", ",", "n3", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n3", ",", "n", ")", ";", "g", ".", "setLayoutAlgorithm", "(", "new", "SpringLayoutAlgorithm", "(", ")", ",", "true", ")", ";", "g", ".", "addMouseMoveListener", "(", "new", "MouseMoveListener", "(", ")", "{", "public", "void", "mouseMove", "(", "MouseEvent", "e", ")", "{", "Object", "o", "=", "g", ".", "getFigureAt", "(", "e", ".", "x", ",", "e", ".", "y", ")", ";", "if", "(", "o", "!=", "null", ")", "{", "System", ".", "out", ".", "println", "(", "o", "+", "\"", "is", "at:", "(\"", "+", "e", ".", "x", "+", "\",\"", "+", "e", ".", "y", "+", "\")\"", ")", ";", "}", "}", "}", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "}", "}", "</s>" ]
10,243
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "swt", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ColorConstants", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Ellipse", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Figure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "FlowLayout", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "FreeformLayout", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "IFigure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ImageFigure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Label", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "MarginBorder", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "PolylineShape", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Point", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Rectangle", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionListener", ";", "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", ".", "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", ".", "core", ".", "widgets", ".", "custom", ".", "CGraphNode", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "SpringLayoutAlgorithm", ";", "public", "class", "GraphSnippet13", "{", "public", "static", "IFigure", "createPersonFigure", "(", "Image", "headImage", ")", "{", "Figure", "person", "=", "new", "Figure", "(", ")", ";", "person", ".", "setLayoutManager", "(", "new", "FreeformLayout", "(", ")", ")", ";", "IFigure", "head", "=", "null", ";", "if", "(", "headImage", "!=", "null", ")", "{", "headImage", "=", "new", "Image", "(", "headImage", ".", "getDevice", "(", ")", ",", "headImage", ".", "getImageData", "(", ")", ".", "scaledTo", "(", "40", ",", "50", ")", ")", ";", "head", "=", "new", "ImageFigure", "(", "headImage", ")", ";", "}", "else", "head", "=", "new", "Ellipse", "(", ")", ";", "head", ".", "setSize", "(", "40", ",", "50", ")", ";", "PolylineShape", "body", "=", "new", "PolylineShape", "(", ")", ";", "body", ".", "setLineWidth", "(", "1", ")", ";", "body", ".", "setStart", "(", "new", "Point", "(", "20", ",", "40", ")", ")", ";", "body", ".", "setEnd", "(", "new", "Point", "(", "20", ",", "100", ")", ")", ";", "body", ".", "setBounds", "(", "new", "Rectangle", "(", "0", ",", "0", ",", "40", ",", "100", ")", ")", ";", "PolylineShape", "leftLeg", "=", "new", "PolylineShape", "(", ")", ";", "leftLeg", ".", "setLineWidth", "(", "1", ")", ";", "leftLeg", ".", "setStart", "(", "new", "Point", "(", "20", ",", "100", ")", ")", ";", "leftLeg", ".", "setEnd", "(", "new", "Point", "(", "0", ",", "130", ")", ")", ";", "leftLeg", ".", "setBounds", "(", "new", "Rectangle", "(", "0", ",", "0", ",", "40", ",", "130", ")", ")", ";", "PolylineShape", "rightLeg", "=", "new", "PolylineShape", "(", ")", ";", "rightLeg", ".", "setLineWidth", "(", "1", ")", ";", "rightLeg", ".", "setStart", "(", "new", "Point", "(", "20", ",", "100", ")", ")", ";", "rightLeg", ".", "setEnd", "(", "new", "Point", "(", "40", ",", "130", ")", ")", ";", "rightLeg", ".", "setBounds", "(", "new", "Rectangle", "(", "0", ",", "0", ",", "40", ",", "130", ")", ")", ";", "PolylineShape", "leftArm", "=", "new", "PolylineShape", "(", ")", ";", "leftArm", ".", "setLineWidth", "(", "1", ")", ";", "leftArm", ".", "setStart", "(", "new", "Point", "(", "20", ",", "60", ")", ")", ";", "leftArm", ".", "setEnd", "(", "new", "Point", "(", "0", ",", "50", ")", ")", ";", "leftArm", ".", "setBounds", "(", "new", "Rectangle", "(", "0", ",", "0", ",", "40", ",", "130", ")", ")", ";", "PolylineShape", "rightArm", "=", "new", "PolylineShape", "(", ")", ";", "rightArm", ".", "setLineWidth", "(", "1", ")", ";", "rightArm", ".", "setStart", "(", "new", "Point", "(", "20", ",", "60", ")", ")", ";", "rightArm", ".", "setEnd", "(", "new", "Point", "(", "40", ",", "50", ")", ")", ";", "rightArm", ".", "setBounds", "(", "new", "Rectangle", "(", "0", ",", "0", ",", "40", ",", "130", ")", ")", ";", "person", ".", "add", "(", "head", ")", ";", "person", ".", "add", "(", "body", ")", ";", "person", ".", "add", "(", "leftLeg", ")", ";", "person", ".", "add", "(", "rightLeg", ")", ";", "person", ".", "add", "(", "leftArm", ")", ";", "person", ".", "add", "(", "rightArm", ")", ";", "person", ".", "setSize", "(", "40", ",", "130", ")", ";", "return", "person", ";", "}", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "final", "Display", "d", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setText", "(", "\"\"", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "400", ",", "400", ")", ";", "final", "Graph", "g", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "g", ".", "addSelectionListener", "(", "new", "SelectionListener", "(", ")", "{", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "Iterator", "iter", "=", "g", ".", "getSelection", "(", ")", ".", "iterator", "(", ")", ";", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "Object", "o", "=", "iter", ".", "next", "(", ")", ";", "if", "(", "o", "instanceof", "CGraphNode", ")", "{", "IFigure", "figure", "=", "(", "(", "CGraphNode", ")", "o", ")", ".", "getFigure", "(", ")", ";", "figure", ".", "setBackgroundColor", "(", "ColorConstants", ".", "blue", ")", ";", "figure", ".", "setForegroundColor", "(", "ColorConstants", ".", "blue", ")", ";", "}", "}", "iter", "=", "g", ".", "getNodes", "(", ")", ".", "iterator", "(", ")", ";", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "Object", "o", "=", "iter", ".", "next", "(", ")", ";", "if", "(", "o", "instanceof", "CGraphNode", ")", "{", "if", "(", "!", "g", ".", "getSelection", "(", ")", ".", "contains", "(", "o", ")", ")", "{", "(", "(", "CGraphNode", ")", "o", ")", ".", "getFigure", "(", ")", ".", "setBackgroundColor", "(", "ColorConstants", ".", "black", ")", ";", "(", "(", "CGraphNode", ")", "o", ")", ".", "getFigure", "(", ")", ".", "setForegroundColor", "(", "ColorConstants", ".", "black", ")", ";", "}", "}", "}", "}", "public", "void", "widgetDefaultSelected", "(", "SelectionEvent", "e", ")", "{", "}", "}", ")", ";", "Image", "zx", "=", "new", "Image", "(", "d", ",", "\"zxsnow.png\"", ")", ";", "IFigure", "tooltip", "=", "new", "Figure", "(", ")", ";", "tooltip", ".", "setBorder", "(", "new", "MarginBorder", "(", "5", ",", "5", ",", "5", ",", "5", ")", ")", ";", "FlowLayout", "layout", "=", "new", "FlowLayout", "(", "false", ")", ";", "layout", ".", "setMajorSpacing", "(", "3", ")", ";", "layout", ".", "setMinorAlignment", "(", "3", ")", ";", "tooltip", ".", "setLayoutManager", "(", "new", "FlowLayout", "(", "false", ")", ")", ";", "tooltip", ".", "add", "(", "new", "ImageFigure", "(", "zx", ")", ")", ";", "tooltip", ".", "add", "(", "new", "Label", "(", "\"Name:", "\"", "+", "\"\"", ")", ")", ";", "tooltip", ".", "add", "(", "new", "Label", "(", "\"Location:", "\"", "+", "\"\"", ")", ")", ";", "Image", "ibull", "=", "new", "Image", "(", "d", ",", "\"ibull.jpg\"", ")", ";", "GraphContainer", "c1", "=", "new", "GraphContainer", "(", "g", ",", "SWT", ".", "NONE", ")", ";", "c1", ".", "setText", "(", "\"Canada\"", ")", ";", "GraphContainer", "c2", "=", "new", "GraphContainer", "(", "g", ",", "SWT", ".", "NONE", ")", ";", "c2", ".", "setText", "(", "\"USA\"", ")", ";", "GraphNode", "n1", "=", "new", "GraphNode", "(", "c1", ",", "SWT", ".", "NONE", ",", "\"Ian", "B.\"", ")", ";", "n1", ".", "setSize", "(", "200", ",", "100", ")", ";", "GraphNode", "n2", "=", "new", "GraphNode", "(", "c2", ",", "SWT", ".", "NONE", ",", "\"Chris", "A.\"", ")", ";", "n2", ".", "setTooltip", "(", "tooltip", ")", ";", "GraphConnection", "connection", "=", "new", "GraphConnection", "(", "g", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "n1", ",", "n2", ")", ";", "connection", ".", "setCurveDepth", "(", "-", "30", ")", ";", "GraphConnection", "connection2", "=", "new", "GraphConnection", "(", "g", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ",", "n2", ",", "n1", ")", ";", "connection2", ".", "setCurveDepth", "(", "-", "30", ")", ";", "g", ".", "setLayoutAlgorithm", "(", "new", "SpringLayoutAlgorithm", "(", ")", ",", "true", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "zx", ".", "dispose", "(", ")", ";", "ibull", ".", "dispose", "(", ")", ";", "}", "}", "</s>" ]
10,244
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "swt", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionAdapter", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "layout", ".", "FillLayout", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Button", ";", "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", ".", "SpringLayoutAlgorithm", ";", "public", "class", "GraphSnippet10", "{", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "Display", "d", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setText", "(", "\"\"", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "400", ",", "400", ")", ";", "final", "Graph", "g", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "GraphNode", "n", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Paper\"", ")", ";", "n", ".", "setBorderColor", "(", "org", ".", "eclipse", ".", "draw2d", ".", "ColorConstants", ".", "yellow", ")", ";", "n", ".", "setBorderWidth", "(", "3", ")", ";", "GraphNode", "n2", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Rock\"", ")", ";", "GraphNode", "n3", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Scissors\"", ")", ";", "final", "GraphConnection", "connection", "=", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n", ",", "n2", ")", ";", "connection", ".", "setLineWidth", "(", "3", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n2", ",", "n3", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n3", ",", "n", ")", ";", "g", ".", "setLayoutAlgorithm", "(", "new", "SpringLayoutAlgorithm", "(", ")", ",", "true", ")", ";", "Button", "button", "=", "new", "Button", "(", "shell", ",", "SWT", ".", "PUSH", ")", ";", "button", ".", "setText", "(", "\"Change", "Curve\"", ")", ";", "button", ".", "addSelectionListener", "(", "new", "SelectionAdapter", "(", ")", "{", "int", "count", "=", "0", ";", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "count", "=", "++", "count", "%", "16", ";", "if", "(", "count", ">", "8", ")", "{", "connection", ".", "setCurveDepth", "(", "(", "-", "16", "+", "count", ")", "*", "10", ")", ";", "}", "else", "{", "connection", ".", "setCurveDepth", "(", "count", "*", "10", ")", ";", "}", "}", "}", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "}", "}", "</s>" ]
10,245
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "swt", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ColorConstants", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Ellipse", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Figure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "FreeformLayout", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "IFigure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ImageFigure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "PolylineShape", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Point", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Rectangle", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionListener", ";", "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", ".", "widgets", ".", "Graph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphConnection", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphNode", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "custom", ".", "CGraphNode", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "SpringLayoutAlgorithm", ";", "public", "class", "GraphSnippet12", "{", "public", "static", "IFigure", "createPersonFigure", "(", "Image", "headImage", ")", "{", "Figure", "person", "=", "new", "Figure", "(", ")", ";", "person", ".", "setLayoutManager", "(", "new", "FreeformLayout", "(", ")", ")", ";", "IFigure", "head", "=", "null", ";", "if", "(", "headImage", "!=", "null", ")", "{", "headImage", "=", "new", "Image", "(", "headImage", ".", "getDevice", "(", ")", ",", "headImage", ".", "getImageData", "(", ")", ".", "scaledTo", "(", "40", ",", "50", ")", ")", ";", "head", "=", "new", "ImageFigure", "(", "headImage", ")", ";", "}", "else", "head", "=", "new", "Ellipse", "(", ")", ";", "head", ".", "setSize", "(", "40", ",", "50", ")", ";", "PolylineShape", "body", "=", "new", "PolylineShape", "(", ")", ";", "body", ".", "setLineWidth", "(", "1", ")", ";", "body", ".", "setStart", "(", "new", "Point", "(", "20", ",", "40", ")", ")", ";", "body", ".", "setEnd", "(", "new", "Point", "(", "20", ",", "100", ")", ")", ";", "body", ".", "setBounds", "(", "new", "Rectangle", "(", "0", ",", "0", ",", "40", ",", "100", ")", ")", ";", "PolylineShape", "leftLeg", "=", "new", "PolylineShape", "(", ")", ";", "leftLeg", ".", "setLineWidth", "(", "1", ")", ";", "leftLeg", ".", "setStart", "(", "new", "Point", "(", "20", ",", "100", ")", ")", ";", "leftLeg", ".", "setEnd", "(", "new", "Point", "(", "0", ",", "130", ")", ")", ";", "leftLeg", ".", "setBounds", "(", "new", "Rectangle", "(", "0", ",", "0", ",", "40", ",", "130", ")", ")", ";", "PolylineShape", "rightLeg", "=", "new", "PolylineShape", "(", ")", ";", "rightLeg", ".", "setLineWidth", "(", "1", ")", ";", "rightLeg", ".", "setStart", "(", "new", "Point", "(", "20", ",", "100", ")", ")", ";", "rightLeg", ".", "setEnd", "(", "new", "Point", "(", "40", ",", "130", ")", ")", ";", "rightLeg", ".", "setBounds", "(", "new", "Rectangle", "(", "0", ",", "0", ",", "40", ",", "130", ")", ")", ";", "PolylineShape", "leftArm", "=", "new", "PolylineShape", "(", ")", ";", "leftArm", ".", "setLineWidth", "(", "1", ")", ";", "leftArm", ".", "setStart", "(", "new", "Point", "(", "20", ",", "60", ")", ")", ";", "leftArm", ".", "setEnd", "(", "new", "Point", "(", "0", ",", "50", ")", ")", ";", "leftArm", ".", "setBounds", "(", "new", "Rectangle", "(", "0", ",", "0", ",", "40", ",", "130", ")", ")", ";", "PolylineShape", "rightArm", "=", "new", "PolylineShape", "(", ")", ";", "rightArm", ".", "setLineWidth", "(", "1", ")", ";", "rightArm", ".", "setStart", "(", "new", "Point", "(", "20", ",", "60", ")", ")", ";", "rightArm", ".", "setEnd", "(", "new", "Point", "(", "40", ",", "50", ")", ")", ";", "rightArm", ".", "setBounds", "(", "new", "Rectangle", "(", "0", ",", "0", ",", "40", ",", "130", ")", ")", ";", "person", ".", "add", "(", "head", ")", ";", "person", ".", "add", "(", "body", ")", ";", "person", ".", "add", "(", "leftLeg", ")", ";", "person", ".", "add", "(", "rightLeg", ")", ";", "person", ".", "add", "(", "leftArm", ")", ";", "person", ".", "add", "(", "rightArm", ")", ";", "person", ".", "setSize", "(", "40", ",", "130", ")", ";", "return", "person", ";", "}", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "final", "Display", "d", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setText", "(", "\"\"", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "400", ",", "400", ")", ";", "final", "Graph", "g", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "g", ".", "addSelectionListener", "(", "new", "SelectionListener", "(", ")", "{", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "Iterator", "iter", "=", "g", ".", "getSelection", "(", ")", ".", "iterator", "(", ")", ";", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "Object", "o", "=", "iter", ".", "next", "(", ")", ";", "if", "(", "o", "instanceof", "CGraphNode", ")", "{", "IFigure", "figure", "=", "(", "(", "CGraphNode", ")", "o", ")", ".", "getFigure", "(", ")", ";", "figure", ".", "setBackgroundColor", "(", "ColorConstants", ".", "blue", ")", ";", "figure", ".", "setForegroundColor", "(", "ColorConstants", ".", "blue", ")", ";", "}", "}", "iter", "=", "g", ".", "getNodes", "(", ")", ".", "iterator", "(", ")", ";", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "Object", "o", "=", "iter", ".", "next", "(", ")", ";", "if", "(", "o", "instanceof", "CGraphNode", ")", "{", "if", "(", "!", "g", ".", "getSelection", "(", ")", ".", "contains", "(", "o", ")", ")", "{", "(", "(", "CGraphNode", ")", "o", ")", ".", "getFigure", "(", ")", ".", "setBackgroundColor", "(", "ColorConstants", ".", "black", ")", ";", "(", "(", "CGraphNode", ")", "o", ")", ".", "getFigure", "(", ")", ".", "setForegroundColor", "(", "ColorConstants", ".", "black", ")", ";", "}", "}", "}", "}", "public", "void", "widgetDefaultSelected", "(", "SelectionEvent", "e", ")", "{", "}", "}", ")", ";", "Image", "zx", "=", "new", "Image", "(", "d", ",", "\"zx.png\"", ")", ";", "Image", "ibull", "=", "new", "Image", "(", "d", ",", "\"ibull.jpg\"", ")", ";", "CGraphNode", "n", "=", "new", "CGraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "createPersonFigure", "(", "zx", ")", ")", ";", "CGraphNode", "n2", "=", "new", "CGraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "createPersonFigure", "(", "ibull", ")", ")", ";", "GraphNode", "n3", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"PDE\"", ")", ";", "GraphNode", "n4", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Zest\"", ")", ";", "GraphNode", "n5", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"PDE", "Viz", "tool\"", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n", ",", "n2", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n", ",", "n3", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n2", ",", "n4", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n", ",", "n5", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n2", ",", "n5", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n3", ",", "n5", ")", ";", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n4", ",", "n5", ")", ";", "g", ".", "setLayoutAlgorithm", "(", "new", "SpringLayoutAlgorithm", "(", ")", ",", "true", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "zx", ".", "dispose", "(", ")", ";", "ibull", ".", "dispose", "(", ")", ";", "}", "}", "</s>" ]
10,246
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "examples", ".", "swt", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ColorConstants", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Color", ";", "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", ".", "layouts", ".", "algorithms", ".", "SpringLayoutAlgorithm", ";", "public", "class", "GraphSnippet11", "{", "public", "static", "void", "createConnection", "(", "Graph", "g", ",", "GraphNode", "n1", ",", "GraphNode", "n2", ",", "Color", "color", ",", "int", "curve", ")", "{", "GraphConnection", "connection", "=", "new", "GraphConnection", "(", "g", ",", "SWT", ".", "NONE", ",", "n1", ",", "n2", ")", ";", "connection", ".", "setLineColor", "(", "color", ")", ";", "connection", ".", "setCurveDepth", "(", "curve", ")", ";", "connection", ".", "setLineWidth", "(", "1", ")", ";", "}", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "Display", "d", "=", "new", "Display", "(", ")", ";", "Shell", "shell", "=", "new", "Shell", "(", "d", ")", ";", "shell", ".", "setText", "(", "\"\"", ")", ";", "shell", ".", "setLayout", "(", "new", "FillLayout", "(", ")", ")", ";", "shell", ".", "setSize", "(", "400", ",", "400", ")", ";", "final", "Graph", "g", "=", "new", "Graph", "(", "shell", ",", "SWT", ".", "NONE", ")", ";", "GraphNode", "n", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Node", "1\"", ")", ";", "GraphNode", "n2", "=", "new", "GraphNode", "(", "g", ",", "SWT", ".", "NONE", ",", "\"Node", "2\"", ")", ";", "createConnection", "(", "g", ",", "n", ",", "n2", ",", "ColorConstants", ".", "darkGreen", ",", "20", ")", ";", "createConnection", "(", "g", ",", "n", ",", "n2", ",", "ColorConstants", ".", "darkGreen", ",", "-", "20", ")", ";", "createConnection", "(", "g", ",", "n", ",", "n2", ",", "ColorConstants", ".", "darkBlue", ",", "40", ")", ";", "createConnection", "(", "g", ",", "n", ",", "n2", ",", "ColorConstants", ".", "darkBlue", ",", "-", "40", ")", ";", "createConnection", "(", "g", ",", "n", ",", "n2", ",", "ColorConstants", ".", "darkGray", ",", "60", ")", ";", "createConnection", "(", "g", ",", "n", ",", "n2", ",", "ColorConstants", ".", "darkGray", ",", "-", "60", ")", ";", "createConnection", "(", "g", ",", "n", ",", "n2", ",", "ColorConstants", ".", "black", ",", "0", ")", ";", "g", ".", "setLayoutAlgorithm", "(", "new", "SpringLayoutAlgorithm", "(", ")", ",", "true", ")", ";", "shell", ".", "open", "(", ")", ";", "while", "(", "!", "shell", ".", "isDisposed", "(", ")", ")", "{", "while", "(", "!", "d", ".", "readAndDispatch", "(", ")", ")", "{", "d", ".", "sleep", "(", ")", ";", "}", "}", "}", "}", "</s>" ]
10,247
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "internal", ".", "dot", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "*", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "*", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "*", ";", "public", "class", "DotTemplate", "{", "protected", "static", "String", "nl", ";", "public", "static", "synchronized", "DotTemplate", "create", "(", "String", "lineSeparator", ")", "{", "nl", "=", "lineSeparator", ";", "DotTemplate", "result", "=", "new", "DotTemplate", "(", ")", ";", "nl", "=", "null", ";", "return", "result", ";", "}", "public", "final", "String", "NL", "=", "nl", "==", "null", "?", "(", "System", ".", "getProperties", "(", ")", ".", "getProperty", "(", "\"\"", ")", ")", ":", "nl", ";", "protected", "final", "String", "TEXT_1", "=", "\"\"", ";", "protected", "final", "String", "TEXT_2", "=", "NL", ";", "protected", "final", "String", "TEXT_3", "=", "\"", "\"", ";", "protected", "final", "String", "TEXT_4", "=", "\"{\"", "+", "NL", "+", "\"\"", "+", "NL", "+", "\"\"", "+", "NL", "+", "\"\"", ";", "protected", "final", "String", "TEXT_5", "=", "\"]\"", "+", "NL", "+", "\"\"", "+", "NL", "+", "\"trankdir=\"", ";", "protected", "final", "String", "TEXT_6", "=", "NL", "+", "\"t\"", "+", "NL", "+", "\"t/*", "Nodes", "*/\"", "+", "NL", "+", "\"t\"", ";", "protected", "final", "String", "TEXT_7", "=", "\"", "\"", "+", "NL", "+", "\"t\"", ";", "protected", "final", "String", "TEXT_8", "=", "\"[label=\\\"\"", ";", "protected", "final", "String", "TEXT_9", "=", "\"\\\"];\"", ";", "protected", "final", "String", "TEXT_10", "=", "NL", "+", "\"t\"", ";", "protected", "final", "String", "TEXT_11", "=", "\"", "\"", "+", "NL", "+", "\"t", "\"", ";", "protected", "final", "String", "TEXT_12", "=", "\"", "\"", ";", "protected", "final", "String", "TEXT_13", "=", "NL", "+", "\"", "\"", ";", "protected", "final", "String", "TEXT_14", "=", "\"[label=\\\"\"", ";", "protected", "final", "String", "TEXT_15", "=", "\"\\\"];\"", ";", "protected", "final", "String", "TEXT_16", "=", "NL", "+", "\"t\"", ";", "protected", "final", "String", "TEXT_17", "=", "NL", "+", "\"t\"", ";", "protected", "final", "String", "TEXT_18", "=", "NL", "+", "\"t\"", "+", "NL", "+", "\"t/*", "Edges", "*/\"", "+", "NL", "+", "\"t\"", ";", "protected", "final", "String", "TEXT_19", "=", "\"", "\"", "+", "NL", "+", "\"t\"", ";", "protected", "final", "String", "TEXT_20", "=", "\"", "\"", "+", "NL", "+", "\"t\"", ";", "protected", "final", "String", "TEXT_21", "=", "\"", "\"", ";", "protected", "final", "String", "TEXT_22", "=", "\"", "\"", ";", "protected", "final", "String", "TEXT_23", "=", "\"[style=\"", ";", "protected", "final", "String", "TEXT_24", "=", "\"", "label=\\\"\"", ";", "protected", "final", "String", "TEXT_25", "=", "\"\\\"];\"", "+", "NL", "+", "\"t\"", ";", "protected", "final", "String", "TEXT_26", "=", "NL", "+", "\"}\"", ";", "public", "String", "generate", "(", "Object", "argument", ")", "{", "final", "StringBuffer", "stringBuffer", "=", "new", "StringBuffer", "(", ")", ";", "Graph", "graph", "=", "(", "Graph", ")", "argument", ";", "boolean", "small", "=", "graph", ".", "getNodes", "(", ")", ".", "size", "(", ")", "<", "100", ";", "LayoutAlgorithm", "algo", "=", "graph", ".", "getLayoutAlgorithm", "(", ")", "!=", "null", "?", "graph", ".", "getLayoutAlgorithm", "(", ")", ":", "new", "TreeLayoutAlgorithm", "(", ")", ";", "boolean", "digraph", "=", "graph", ".", "getConnectionStyle", "(", ")", "==", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ";", "String", "simpleClassName", "=", "graph", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", ";", "simpleClassName", "=", "simpleClassName", ".", "equals", "(", "\"Graph\"", ")", "?", "\"Zest\"", "+", "simpleClassName", ":", "simpleClassName", ";", "stringBuffer", ".", "append", "(", "TEXT_1", ")", ";", "stringBuffer", ".", "append", "(", "TEXT_2", ")", ";", "stringBuffer", ".", "append", "(", "digraph", "?", "\"digraph\"", ":", "\"graph\"", ")", ";", "stringBuffer", ".", "append", "(", "TEXT_3", ")", ";", "stringBuffer", ".", "append", "(", "simpleClassName", ")", ";", "stringBuffer", ".", "append", "(", "TEXT_4", ")", ";", "stringBuffer", ".", "append", "(", "(", "algo", ".", "getClass", "(", ")", "==", "RadialLayoutAlgorithm", ".", "class", ")", "?", "\"twopi\"", ":", "(", "algo", ".", "getClass", "(", ")", "==", "GridLayoutAlgorithm", ".", "class", ")", "?", "\"osage\"", ":", "(", "algo", ".", "getClass", "(", ")", "==", "SpringLayoutAlgorithm", ".", "class", ")", "?", "(", "small", "?", "\"fdp\"", ":", "\"sfdp\"", ")", ":", "\"dot\"", ")", ";", "stringBuffer", ".", "append", "(", "TEXT_5", ")", ";", "stringBuffer", ".", "append", "(", "(", "graph", ".", "getLayoutAlgorithm", "(", ")", "!=", "null", "&&", "graph", ".", "getLayoutAlgorithm", "(", ")", ".", "getClass", "(", ")", "==", "TreeLayoutAlgorithm", ".", "class", "&&", "(", "(", "TreeLayoutAlgorithm", ")", "graph", ".", "getLayoutAlgorithm", "(", ")", ")", ".", "getDirection", "(", ")", "==", "TreeLayoutAlgorithm", ".", "LEFT_RIGHT", ")", "?", "\"LR\"", ":", "\"TD\"", ")", ";", "stringBuffer", ".", "append", "(", "TEXT_6", ")", ";", "for", "(", "Object", "nodeObject", ":", "graph", ".", "getNodes", "(", ")", ")", "{", "GraphNode", "node", "=", "(", "GraphNode", ")", "nodeObject", ";", "stringBuffer", ".", "append", "(", "TEXT_7", ")", ";", "if", "(", "!", "(", "node", "instanceof", "GraphContainer", ")", ")", "{", "stringBuffer", ".", "append", "(", "node", ".", "hashCode", "(", ")", ")", ";", "stringBuffer", ".", "append", "(", "TEXT_8", ")", ";", "stringBuffer", ".", "append", "(", "node", ".", "getText", "(", ")", ")", ";", "stringBuffer", ".", "append", "(", "TEXT_9", ")", ";", "}", "stringBuffer", ".", "append", "(", "TEXT_10", ")", ";", "if", "(", "node", "instanceof", "GraphContainer", ")", "{", "stringBuffer", ".", "append", "(", "TEXT_11", ")", ";", "for", "(", "Object", "o", ":", "(", "(", "GraphContainer", ")", "node", ")", ".", "getNodes", "(", ")", ")", "{", "GraphNode", "n", "=", "(", "GraphNode", ")", "o", ";", "stringBuffer", ".", "append", "(", "TEXT_12", ")", ";", "stringBuffer", ".", "append", "(", "TEXT_13", ")", ";", "stringBuffer", ".", "append", "(", "n", ".", "hashCode", "(", ")", ")", ";", "stringBuffer", ".", "append", "(", "TEXT_14", ")", ";", "stringBuffer", ".", "append", "(", "n", ".", "getText", "(", ")", ")", ";", "stringBuffer", ".", "append", "(", "TEXT_15", ")", ";", "}", "stringBuffer", ".", "append", "(", "TEXT_16", ")", ";", "}", "stringBuffer", ".", "append", "(", "TEXT_17", ")", ";", "}", "stringBuffer", ".", "append", "(", "TEXT_18", ")", ";", "for", "(", "Object", "edgeObject", ":", "graph", ".", "getConnections", "(", ")", ")", "{", "GraphConnection", "edge", "=", "(", "GraphConnection", ")", "edgeObject", ";", "stringBuffer", ".", "append", "(", "TEXT_19", ")", ";", "boolean", "dashed", "=", "edge", ".", "getLineStyle", "(", ")", "==", "SWT", ".", "LINE_DASH", ";", "boolean", "dotted", "=", "edge", ".", "getLineStyle", "(", ")", "==", "SWT", ".", "LINE_DOT", ";", "stringBuffer", ".", "append", "(", "TEXT_20", ")", ";", "stringBuffer", ".", "append", "(", "edge", ".", "getSource", "(", ")", ".", "hashCode", "(", ")", ")", ";", "stringBuffer", ".", "append", "(", "TEXT_21", ")", ";", "stringBuffer", ".", "append", "(", "digraph", "?", "\"->\"", ":", "\"--\"", ")", ";", "stringBuffer", ".", "append", "(", "TEXT_22", ")", ";", "stringBuffer", ".", "append", "(", "edge", ".", "getDestination", "(", ")", ".", "hashCode", "(", ")", ")", ";", "stringBuffer", ".", "append", "(", "TEXT_23", ")", ";", "stringBuffer", ".", "append", "(", "dashed", "?", "\"dashed\"", ":", "dotted", "?", "\"dotted\"", ":", "\"solid\"", ")", ";", "stringBuffer", ".", "append", "(", "TEXT_24", ")", ";", "stringBuffer", ".", "append", "(", "edge", ".", "getText", "(", ")", ")", ";", "stringBuffer", ".", "append", "(", "TEXT_25", ")", ";", "}", "stringBuffer", ".", "append", "(", "TEXT_26", ")", ";", "return", "stringBuffer", ".", "toString", "(", ")", ";", "}", "}", "</s>" ]
10,248
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "internal", ".", "dot", ";", "import", "java", ".", "io", ".", "Closeable", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileNotFoundException", ";", "import", "java", ".", "io", ".", "FileOutputStream", ";", "import", "java", ".", "io", ".", "FileWriter", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "net", ".", "MalformedURLException", ";", "import", "java", ".", "net", ".", "URISyntaxException", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "java", ".", "util", ".", "Scanner", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "FileLocator", ";", "public", "final", "class", "DotFileUtils", "{", "private", "DotFileUtils", "(", ")", "{", "}", "public", "static", "File", "resolve", "(", "final", "URL", "url", ")", "{", "File", "resultFile", "=", "null", ";", "URL", "resolved", "=", "url", ";", "if", "(", "!", "url", ".", "getProtocol", "(", ")", ".", "equals", "(", "\"file\"", ")", ")", "{", "try", "{", "resolved", "=", "FileLocator", ".", "resolve", "(", "resolved", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "try", "{", "resultFile", "=", "new", "File", "(", "resolved", ".", "toURI", "(", ")", ")", ";", "}", "catch", "(", "URISyntaxException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "return", "resultFile", ";", "}", "public", "static", "File", "write", "(", "final", "String", "text", ")", "{", "try", "{", "return", "write", "(", "text", ",", "File", ".", "createTempFile", "(", "\"zest\"", ",", "\".dot\"", ")", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "return", "null", ";", "}", "public", "static", "File", "write", "(", "final", "String", "text", ",", "final", "File", "destination", ")", "{", "try", "{", "FileWriter", "writer", "=", "new", "FileWriter", "(", "destination", ")", ";", "writer", ".", "write", "(", "text", ")", ";", "writer", ".", "flush", "(", ")", ";", "writer", ".", "close", "(", ")", ";", "return", "destination", ";", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "return", "null", ";", "}", "public", "static", "String", "read", "(", "final", "File", "file", ")", "{", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", ")", ";", "try", "{", "Scanner", "s", "=", "new", "Scanner", "(", "file", ")", ";", "while", "(", "s", ".", "hasNextLine", "(", ")", ")", "{", "builder", ".", "append", "(", "s", ".", "nextLine", "(", ")", ")", ".", "append", "(", "\"n\"", ")", ";", "}", "}", "catch", "(", "FileNotFoundException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "return", "builder", ".", "toString", "(", ")", ";", "}", "public", "static", "void", "close", "(", "final", "Closeable", "closeable", ")", "{", "if", "(", "closeable", "!=", "null", ")", "{", "try", "{", "closeable", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "}", "public", "static", "void", "copyAllFiles", "(", "final", "File", "sourceRootFolder", ",", "final", "File", "destinationRootFolder", ")", "{", "for", "(", "String", "name", ":", "sourceRootFolder", ".", "list", "(", ")", ")", "{", "File", "source", "=", "new", "File", "(", "sourceRootFolder", ",", "name", ")", ";", "if", "(", "source", ".", "getName", "(", ")", ".", "equals", "(", "\"CVS\"", ")", ")", "{", "continue", ";", "}", "if", "(", "source", ".", "isDirectory", "(", ")", ")", "{", "File", "destinationFolder", "=", "new", "File", "(", "destinationRootFolder", ",", "source", ".", "getName", "(", ")", ")", ";", "if", "(", "!", "destinationFolder", ".", "mkdirs", "(", ")", "&&", "!", "destinationFolder", ".", "exists", "(", ")", ")", "{", "throw", "new", "IllegalStateException", "(", "DotMessages", ".", "DotFileUtils_0", "+", "\":", "\"", "+", "destinationFolder", ")", ";", "}", "copyAllFiles", "(", "source", ",", "destinationFolder", ")", ";", "}", "else", "{", "copySingleFile", "(", "destinationRootFolder", ",", "name", ",", "source", ")", ";", "}", "}", "}", "public", "static", "File", "copySingleFile", "(", "final", "File", "destinationFolder", ",", "final", "String", "newFileName", ",", "final", "File", "sourceFile", ")", "{", "File", "destinationFile", "=", "new", "File", "(", "destinationFolder", ",", "newFileName", ")", ";", "InputStream", "sourceStream", "=", "null", ";", "FileOutputStream", "destinationStream", "=", "null", ";", "try", "{", "sourceStream", "=", "sourceFile", ".", "toURI", "(", ")", ".", "toURL", "(", ")", ".", "openStream", "(", ")", ";", "destinationStream", "=", "new", "FileOutputStream", "(", "destinationFile", ")", ";", "byte", "[", "]", "buffer", "=", "new", "byte", "[", "4096", "]", ";", "int", "bytesRead", ";", "while", "(", "(", "bytesRead", "=", "sourceStream", ".", "read", "(", "buffer", ")", ")", "!=", "-", "1", ")", "{", "destinationStream", ".", "write", "(", "buffer", ",", "0", ",", "bytesRead", ")", ";", "}", "}", "catch", "(", "MalformedURLException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "finally", "{", "close", "(", "sourceStream", ")", ";", "close", "(", "destinationStream", ")", ";", "}", "return", "destinationFile", ";", "}", "}", "</s>" ]
10,249
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "internal", ".", "dot", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "util", ".", "Arrays", ";", "final", "class", "DotDrawer", "{", "private", "DotDrawer", "(", ")", "{", "}", "static", "File", "renderImage", "(", "final", "File", "dotExecutableDir", ",", "final", "File", "dotInputFile", ",", "final", "String", "format", ",", "final", "String", "imageResultFile", ")", "{", "String", "outputFormat", "=", "\"-T\"", "+", "format", ";", "String", "resultFile", "=", "imageResultFile", "==", "null", "?", "dotInputFile", ".", "getName", "(", ")", "+", "\".\"", "+", "format", ":", "imageResultFile", ";", "String", "dotFile", "=", "dotInputFile", ".", "getName", "(", ")", ";", "String", "inputFolder", "=", "new", "File", "(", "dotInputFile", ".", "getParent", "(", ")", ")", ".", "getAbsolutePath", "(", ")", "+", "File", ".", "separator", ";", "String", "outputFolder", "=", "imageResultFile", "==", "null", "?", "inputFolder", ":", "new", "File", "(", "new", "File", "(", "imageResultFile", ")", ".", "getAbsolutePath", "(", ")", ")", ".", "getParentFile", "(", ")", ".", "getAbsolutePath", "(", ")", "+", "File", ".", "separator", ";", "String", "dotExecutable", "=", "\"dot\"", "+", "(", "runningOnWindows", "(", ")", "?", "\".exe\"", ":", "\"\"", ")", ";", "String", "[", "]", "commands", "=", "new", "String", "[", "]", "{", "dotExecutableDir", ".", "getAbsolutePath", "(", ")", "+", "File", ".", "separator", "+", "dotExecutable", ",", "outputFormat", ",", "\"-o\"", ",", "outputFolder", "+", "resultFile", ",", "inputFolder", "+", "dotFile", "}", ";", "call", "(", "commands", ")", ";", "return", "new", "File", "(", "outputFolder", ",", "resultFile", ")", ";", "}", "private", "static", "void", "call", "(", "final", "String", "[", "]", "commands", ")", "{", "System", ".", "out", ".", "print", "(", "\"Calling:", "\"", "+", "Arrays", ".", "asList", "(", "commands", ")", ")", ";", "Runtime", "runtime", "=", "Runtime", ".", "getRuntime", "(", ")", ";", "Process", "p", "=", "null", ";", "try", "{", "p", "=", "runtime", ".", "exec", "(", "commands", ")", ";", "p", ".", "waitFor", "(", ")", ";", "}", "catch", "(", "Exception", "x", ")", "{", "x", ".", "printStackTrace", "(", ")", ";", "}", "System", ".", "out", ".", "println", "(", "\",", "\"", "+", "\"\"", "+", "\":", "\"", "+", "p", ".", "exitValue", "(", ")", ")", ";", "String", "errors", "=", "read", "(", "p", ".", "getErrorStream", "(", ")", ")", ";", "String", "output", "=", "read", "(", "p", ".", "getInputStream", "(", ")", ")", ";", "if", "(", "errors", ".", "trim", "(", ")", ".", "length", "(", ")", ">", "0", ")", "{", "System", ".", "err", ".", "println", "(", "\"\"", "+", "errors", ")", ";", "}", "if", "(", "output", ".", "trim", "(", ")", ".", "length", "(", ")", ">", "0", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", "+", "output", ")", ";", "}", "}", "private", "static", "String", "read", "(", "InputStream", "s", ")", "{", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", ")", ";", "try", "{", "int", "current", "=", "-", "1", ";", "while", "(", "(", "current", "=", "s", ".", "read", "(", ")", ")", "!=", "-", "1", ")", "{", "builder", ".", "append", "(", "(", "char", ")", "current", ")", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "return", "builder", ".", "toString", "(", ")", ";", "}", "private", "static", "boolean", "runningOnWindows", "(", ")", "{", "return", "System", ".", "getProperty", "(", "\"os.name\"", ")", ".", "toLowerCase", "(", ")", ".", "contains", "(", "\"win\"", ")", ";", "}", "}", "</s>" ]
10,250
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "internal", ".", "dot", ";", "import", "org", ".", "eclipse", ".", "osgi", ".", "util", ".", "NLS", ";", "public", "class", "DotMessages", "extends", "NLS", "{", "private", "static", "final", "String", "BUNDLE_NAME", "=", "\"\"", ";", "public", "static", "String", "GraphCreatorInterpreter_0", ";", "public", "static", "String", "DotFileUtils_0", ";", "public", "static", "String", "DotImport_0", ";", "public", "static", "String", "DotImport_1", ";", "public", "static", "String", "DotImport_2", ";", "public", "static", "String", "DotImport_3", ";", "public", "static", "String", "DotAst_0", ";", "static", "{", "NLS", ".", "initializeMessages", "(", "BUNDLE_NAME", ",", "DotMessages", ".", "class", ")", ";", "}", "private", "DotMessages", "(", ")", "{", "}", "}", "</s>" ]
10,251
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "internal", ".", "dot", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "util", ".", "Scanner", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "SWTGraphics", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Rectangle", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "GC", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Image", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "ImageData", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "ImageLoader", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Point", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "Graph", ";", "public", "final", "class", "DotExport", "{", "public", "static", "final", "String", "DOT_BIN_DIR_KEY", "=", "\"\"", ";", "private", "static", "final", "String", "DEFAULT_OUTPUT_FORMAT", "=", "\"pdf\"", ";", "private", "String", "dotString", ";", "private", "String", "graphName", "=", "\"Unnamed\"", "+", "System", ".", "currentTimeMillis", "(", ")", ";", "private", "Graph", "graph", ";", "public", "DotExport", "(", "final", "Graph", "graph", ")", "{", "this", ".", "dotString", "=", "graphToDot", "(", "graph", ")", ";", "this", ".", "graphName", "=", "graph", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", ";", "this", ".", "graph", "=", "graph", ";", "}", "public", "DotExport", "(", "String", "dotString", ")", "{", "this", ".", "dotString", "=", "dotString", ";", "}", "public", "String", "toDotString", "(", ")", "{", "return", "dotString", ";", "}", "public", "File", "toDotFile", "(", "final", "File", "destination", ")", "{", "DotFileUtils", ".", "write", "(", "dotString", ",", "destination", ")", ";", "return", "destination", ";", "}", "public", "File", "toImage", "(", "String", "dotBinDir", ",", "String", "resultFile", ")", "{", "return", "toImage", "(", "dotBinDir", ",", "resultFile", "==", "null", "?", "DEFAULT_OUTPUT_FORMAT", ":", "resultFile", ".", "substring", "(", "resultFile", ".", "lastIndexOf", "(", "'.'", ")", "+", "1", ")", ",", "resultFile", ")", ";", "}", "public", "File", "toImage", "(", "String", "resultFile", ")", "{", "Rectangle", "bounds", "=", "graph", ".", "getContents", "(", ")", ".", "getBounds", "(", ")", ";", "Point", "size", "=", "new", "Point", "(", "graph", ".", "getContents", "(", ")", ".", "getSize", "(", ")", ".", "width", ",", "graph", ".", "getContents", "(", ")", ".", "getSize", "(", ")", ".", "height", ")", ";", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Point", "viewLocation", "=", "graph", ".", "getViewport", "(", ")", ".", "getViewLocation", "(", ")", ";", "final", "Image", "image", "=", "new", "Image", "(", "null", ",", "size", ".", "x", ",", "size", ".", "y", ")", ";", "GC", "gc", "=", "new", "GC", "(", "image", ")", ";", "SWTGraphics", "swtGraphics", "=", "new", "SWTGraphics", "(", "gc", ")", ";", "swtGraphics", ".", "translate", "(", "-", "1", "*", "bounds", ".", "x", "+", "viewLocation", ".", "x", ",", "-", "1", "*", "bounds", ".", "y", "+", "viewLocation", ".", "y", ")", ";", "graph", ".", "getViewport", "(", ")", ".", "paint", "(", "swtGraphics", ")", ";", "gc", ".", "copyArea", "(", "image", ",", "0", ",", "0", ")", ";", "gc", ".", "dispose", "(", ")", ";", "ImageLoader", "loader", "=", "new", "ImageLoader", "(", ")", ";", "loader", ".", "data", "=", "new", "ImageData", "[", "]", "{", "image", ".", "getImageData", "(", ")", "}", ";", "loader", ".", "save", "(", "resultFile", ",", "SWT", ".", "IMAGE_PNG", ")", ";", "return", "new", "File", "(", "resultFile", ")", ";", "}", "public", "File", "toImage", "(", "final", "String", "dotDir", ",", "final", "String", "format", ",", "final", "String", "resultFile", ")", "{", "File", "dotFile", "=", "DotFileUtils", ".", "write", "(", "dotString", ")", ";", "File", "image", "=", "DotDrawer", ".", "renderImage", "(", "new", "File", "(", "dotDir", ")", ",", "dotFile", ",", "format", ",", "resultFile", ")", ";", "return", "image", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "graphName", ".", "equals", "(", "\"Graph\"", ")", "?", "\"Zest\"", "+", "graphName", ":", "graphName", ";", "}", "private", "static", "String", "graphToDot", "(", "final", "Graph", "graph", ")", "{", "String", "raw", "=", "new", "DotTemplate", "(", ")", ".", "generate", "(", "graph", ")", ";", "raw", "=", "removeBlankLines", "(", "raw", ")", ";", "return", "raw", ";", "}", "private", "static", "String", "removeBlankLines", "(", "final", "String", "raw", ")", "{", "Scanner", "scanner", "=", "new", "Scanner", "(", "raw", ")", ";", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", ")", ";", "while", "(", "scanner", ".", "hasNextLine", "(", ")", ")", "{", "String", "line", "=", "scanner", ".", "nextLine", "(", ")", ";", "if", "(", "!", "line", ".", "trim", "(", ")", ".", "equals", "(", "\"\"", ")", ")", "{", "builder", ".", "append", "(", "line", "+", "\"n\"", ")", ";", "}", "}", "return", "builder", ".", "toString", "(", ")", ";", "}", "}", "</s>" ]
10,252
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "internal", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ColorConstants", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "FigureUtilities", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Graphics", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "MarginBorder", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ScaledGraphics", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "StackLayout", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Dimension", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Rectangle", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Color", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Font", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Image", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "RGB", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "IStyleableFigure", ";", "public", "class", "GraphLabel", "extends", "CachedLabel", "implements", "IStyleableFigure", "{", "private", "Color", "borderColor", ";", "private", "int", "borderWidth", ";", "private", "int", "arcWidth", ";", "private", "boolean", "painting", "=", "false", ";", "public", "GraphLabel", "(", "boolean", "cacheLabel", ")", "{", "this", "(", "\"\"", ",", "cacheLabel", ")", ";", "}", "public", "GraphLabel", "(", "String", "text", ",", "boolean", "cacheLabel", ")", "{", "this", "(", "text", ",", "null", ",", "cacheLabel", ")", ";", "}", "public", "GraphLabel", "(", "Image", "i", ",", "boolean", "cacheLabel", ")", "{", "this", "(", "\"\"", ",", "i", ",", "cacheLabel", ")", ";", "}", "public", "GraphLabel", "(", "String", "text", ",", "Image", "i", ",", "boolean", "cacheLabel", ")", "{", "super", "(", "cacheLabel", ")", ";", "initLabel", "(", ")", ";", "setText", "(", "text", ")", ";", "setIcon", "(", "i", ")", ";", "adjustBoundsToFit", "(", ")", ";", "}", "protected", "void", "initLabel", "(", ")", "{", "super", ".", "setFont", "(", "Display", ".", "getDefault", "(", ")", ".", "getSystemFont", "(", ")", ")", ";", "this", ".", "borderColor", "=", "ColorConstants", ".", "black", ";", "this", ".", "borderWidth", "=", "0", ";", "this", ".", "arcWidth", "=", "8", ";", "this", ".", "setLayoutManager", "(", "new", "StackLayout", "(", ")", ")", ";", "this", ".", "setBorder", "(", "new", "MarginBorder", "(", "1", ")", ")", ";", "}", "public", "void", "setFont", "(", "Font", "f", ")", "{", "super", ".", "setFont", "(", "f", ")", ";", "adjustBoundsToFit", "(", ")", ";", "}", "protected", "void", "adjustBoundsToFit", "(", ")", "{", "String", "text", "=", "getText", "(", ")", ";", "int", "safeBorderWidth", "=", "borderWidth", ">", "0", "?", "borderWidth", ":", "1", ";", "if", "(", "(", "text", "!=", "null", ")", ")", "{", "Font", "font", "=", "getFont", "(", ")", ";", "if", "(", "font", "!=", "null", ")", "{", "Dimension", "minSize", "=", "FigureUtilities", ".", "getTextExtents", "(", "text", ",", "font", ")", ";", "if", "(", "getIcon", "(", ")", "!=", "null", ")", "{", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Rectangle", "imageRect", "=", "getIcon", "(", ")", ".", "getBounds", "(", ")", ";", "int", "expandHeight", "=", "Math", ".", "max", "(", "imageRect", ".", "height", "-", "minSize", ".", "height", ",", "0", ")", ";", "minSize", ".", "expand", "(", "imageRect", ".", "width", "+", "4", ",", "expandHeight", ")", ";", "}", "minSize", ".", "expand", "(", "10", "+", "(", "2", "*", "safeBorderWidth", ")", ",", "4", "+", "(", "2", "*", "safeBorderWidth", ")", ")", ";", "setBounds", "(", "new", "Rectangle", "(", "getLocation", "(", ")", ",", "minSize", ")", ")", ";", "}", "}", "}", "public", "void", "paint", "(", "Graphics", "graphics", ")", "{", "int", "blue", "=", "getBackgroundColor", "(", ")", ".", "getBlue", "(", ")", ";", "blue", "=", "(", "int", ")", "(", "blue", "-", "(", "blue", "*", "0.20", ")", ")", ";", "blue", "=", "blue", ">", "0", "?", "blue", ":", "0", ";", "int", "red", "=", "getBackgroundColor", "(", ")", ".", "getRed", "(", ")", ";", "red", "=", "(", "int", ")", "(", "red", "-", "(", "red", "*", "0.20", ")", ")", ";", "red", "=", "red", ">", "0", "?", "red", ":", "0", ";", "int", "green", "=", "getBackgroundColor", "(", ")", ".", "getGreen", "(", ")", ";", "green", "=", "(", "int", ")", "(", "green", "-", "(", "green", "*", "0.20", ")", ")", ";", "green", "=", "green", ">", "0", "?", "green", ":", "0", ";", "Color", "lightenColor", "=", "new", "Color", "(", "Display", ".", "getCurrent", "(", ")", ",", "new", "RGB", "(", "red", ",", "green", ",", "blue", ")", ")", ";", "graphics", ".", "setForegroundColor", "(", "lightenColor", ")", ";", "graphics", ".", "setBackgroundColor", "(", "getBackgroundColor", "(", ")", ")", ";", "int", "safeBorderWidth", "=", "borderWidth", ">", "0", "?", "borderWidth", ":", "1", ";", "graphics", ".", "pushState", "(", ")", ";", "double", "scale", "=", "1", ";", "if", "(", "graphics", "instanceof", "ScaledGraphics", ")", "{", "scale", "=", "(", "(", "ScaledGraphics", ")", "graphics", ")", ".", "getAbsoluteScale", "(", ")", ";", "}", "Rectangle", "rect", "=", "getBounds", "(", ")", ".", "getCopy", "(", ")", ";", "rect", ".", "height", "/=", "2", ";", "graphics", ".", "setForegroundColor", "(", "getBackgroundColor", "(", ")", ")", ";", "graphics", ".", "setBackgroundColor", "(", "getBackgroundColor", "(", ")", ")", ";", "graphics", ".", "fillRoundRectangle", "(", "rect", ",", "arcWidth", "*", "safeBorderWidth", ",", "arcWidth", "*", "2", "*", "safeBorderWidth", ")", ";", "rect", ".", "y", "=", "rect", ".", "y", "+", "rect", ".", "height", ";", "rect", ".", "height", "+=", "1", ";", "graphics", ".", "setForegroundColor", "(", "lightenColor", ")", ";", "graphics", ".", "setBackgroundColor", "(", "lightenColor", ")", ";", "graphics", ".", "fillRoundRectangle", "(", "rect", ",", "arcWidth", "*", "safeBorderWidth", ",", "arcWidth", "*", "2", "*", "safeBorderWidth", ")", ";", "rect", "=", "bounds", ".", "getCopy", "(", ")", ";", "rect", ".", "height", "-=", "2", ";", "rect", ".", "y", "+=", "(", "safeBorderWidth", ")", "/", "2", ";", "rect", ".", "y", "+=", "(", "arcWidth", "/", "2", ")", ";", "rect", ".", "height", "-=", "arcWidth", "/", "2", ";", "rect", ".", "height", "-=", "safeBorderWidth", ";", "graphics", ".", "setBackgroundColor", "(", "lightenColor", ")", ";", "graphics", ".", "setForegroundColor", "(", "getBackgroundColor", "(", ")", ")", ";", "graphics", ".", "fillGradient", "(", "rect", ",", "true", ")", ";", "if", "(", "borderWidth", ">", "0", ")", "{", "rect", "=", "getBounds", "(", ")", ".", "getCopy", "(", ")", ";", "rect", ".", "x", "+=", "safeBorderWidth", "/", "2", ";", "rect", ".", "y", "+=", "safeBorderWidth", "/", "2", ";", "rect", ".", "width", "-=", "safeBorderWidth", ";", "rect", ".", "height", "-=", "safeBorderWidth", ";", "graphics", ".", "setForegroundColor", "(", "borderColor", ")", ";", "graphics", ".", "setBackgroundColor", "(", "borderColor", ")", ";", "graphics", ".", "setLineWidth", "(", "(", "int", ")", "(", "safeBorderWidth", "*", "scale", ")", ")", ";", "graphics", ".", "drawRoundRectangle", "(", "rect", ",", "arcWidth", ",", "arcWidth", ")", ";", "}", "super", ".", "paint", "(", "graphics", ")", ";", "graphics", ".", "popState", "(", ")", ";", "lightenColor", ".", "dispose", "(", ")", ";", "}", "protected", "Color", "getBackgroundTextColor", "(", ")", "{", "return", "getBackgroundColor", "(", ")", ";", "}", "public", "void", "invalidate", "(", ")", "{", "if", "(", "!", "painting", ")", "{", "super", ".", "invalidate", "(", ")", ";", "}", "}", "public", "void", "setText", "(", "String", "s", ")", "{", "super", ".", "setText", "(", "s", ")", ";", "adjustBoundsToFit", "(", ")", ";", "}", "public", "void", "setIcon", "(", "Image", "image", ")", "{", "super", ".", "setIcon", "(", "image", ")", ";", "adjustBoundsToFit", "(", ")", ";", "}", "public", "Color", "getBorderColor", "(", ")", "{", "return", "borderColor", ";", "}", "public", "void", "setBorderColor", "(", "Color", "c", ")", "{", "this", ".", "borderColor", "=", "c", ";", "}", "public", "int", "getBorderWidth", "(", ")", "{", "return", "borderWidth", ";", "}", "public", "void", "setBorderWidth", "(", "int", "width", ")", "{", "this", ".", "borderWidth", "=", "width", ";", "}", "public", "int", "getArcWidth", "(", ")", "{", "return", "arcWidth", ";", "}", "public", "void", "setArcWidth", "(", "int", "arcWidth", ")", "{", "this", ".", "arcWidth", "=", "arcWidth", ";", "}", "}", "</s>" ]
10,253
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "internal", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ActionEvent", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ActionListener", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Clickable", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ColorConstants", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Figure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "FigureUtilities", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "FreeformLayout", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Graphics", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Label", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ToolbarLayout", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Triangle", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Dimension", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Point", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Rectangle", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Color", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Font", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Image", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "RGB", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphContainer", ";", "public", "class", "ExpandGraphLabel", "extends", "Figure", "implements", "ActionListener", "{", "public", "static", "final", "int", "OPEN", "=", "1", ";", "public", "static", "final", "int", "CLOSED", "=", "2", ";", "private", "int", "state", "=", "CLOSED", ";", "private", "Expander", "expander", "=", "null", ";", "class", "Expander", "extends", "Clickable", "{", "private", "Triangle", "triangle", ";", "public", "Expander", "(", ")", "{", "setStyle", "(", "Clickable", ".", "STYLE_TOGGLE", ")", ";", "triangle", "=", "new", "Triangle", "(", ")", ";", "triangle", ".", "setSize", "(", "10", ",", "10", ")", ";", "triangle", ".", "setBackgroundColor", "(", "ColorConstants", ".", "black", ")", ";", "triangle", ".", "setForegroundColor", "(", "ColorConstants", ".", "black", ")", ";", "triangle", ".", "setFill", "(", "true", ")", ";", "triangle", ".", "setDirection", "(", "Triangle", ".", "EAST", ")", ";", "triangle", ".", "setLocation", "(", "new", "Point", "(", "5", ",", "3", ")", ")", ";", "this", ".", "setLayoutManager", "(", "new", "FreeformLayout", "(", ")", ")", ";", "this", ".", "add", "(", "triangle", ")", ";", "this", ".", "setPreferredSize", "(", "15", ",", "15", ")", ";", "this", ".", "addActionListener", "(", "ExpandGraphLabel", ".", "this", ")", ";", "}", "public", "void", "open", "(", ")", "{", "triangle", ".", "setDirection", "(", "Triangle", ".", "SOUTH", ")", ";", "}", "public", "void", "close", "(", ")", "{", "triangle", ".", "setDirection", "(", "Triangle", ".", "EAST", ")", ";", "}", "}", "public", "void", "setExpandedState", "(", "int", "state", ")", "{", "if", "(", "state", "==", "OPEN", ")", "{", "expander", ".", "open", "(", ")", ";", "}", "else", "{", "expander", ".", "close", "(", ")", ";", "}", "this", ".", "state", "=", "state", ";", "}", "public", "void", "actionPerformed", "(", "ActionEvent", "event", ")", "{", "if", "(", "state", "==", "OPEN", ")", "{", "container", ".", "close", "(", "true", ")", ";", "}", "else", "{", "container", ".", "open", "(", "true", ")", ";", "}", "}", "private", "int", "arcWidth", ";", "private", "Label", "label", "=", "null", ";", "private", "final", "GraphContainer", "container", ";", "private", "ToolbarLayout", "layout", ";", "public", "ExpandGraphLabel", "(", "GraphContainer", "container", ",", "boolean", "cacheLabel", ")", "{", "this", "(", "container", ",", "\"\"", ",", "null", ",", "cacheLabel", ")", ";", "}", "public", "ExpandGraphLabel", "(", "GraphContainer", "container", ",", "Image", "i", ",", "boolean", "cacheLabel", ")", "{", "this", "(", "container", ",", "\"\"", ",", "i", ",", "cacheLabel", ")", ";", "}", "public", "ExpandGraphLabel", "(", "GraphContainer", "container", ",", "String", "text", ",", "boolean", "cacheLabel", ")", "{", "this", "(", "container", ",", "text", ",", "null", ",", "cacheLabel", ")", ";", "}", "public", "ExpandGraphLabel", "(", "GraphContainer", "container", ",", "String", "text", ",", "Image", "image", ",", "boolean", "cacheLabel", ")", "{", "this", ".", "label", "=", "new", "Label", "(", "text", ")", "{", "protected", "void", "paintFigure", "(", "Graphics", "graphics", ")", "{", "if", "(", "isOpaque", "(", ")", ")", "{", "super", ".", "paintFigure", "(", "graphics", ")", ";", "}", "Rectangle", "bounds", "=", "getBounds", "(", ")", ";", "graphics", ".", "translate", "(", "bounds", ".", "x", ",", "bounds", ".", "y", ")", ";", "if", "(", "getIcon", "(", ")", "!=", "null", ")", "{", "graphics", ".", "drawImage", "(", "getIcon", "(", ")", ",", "getIconLocation", "(", ")", ")", ";", "}", "if", "(", "!", "isEnabled", "(", ")", ")", "{", "graphics", ".", "translate", "(", "1", ",", "1", ")", ";", "graphics", ".", "setForegroundColor", "(", "ColorConstants", ".", "buttonLightest", ")", ";", "graphics", ".", "drawText", "(", "getSubStringText", "(", ")", ",", "getTextLocation", "(", ")", ")", ";", "graphics", ".", "translate", "(", "-", "1", ",", "-", "1", ")", ";", "graphics", ".", "setForegroundColor", "(", "ColorConstants", ".", "buttonDarker", ")", ";", "}", "graphics", ".", "drawText", "(", "getText", "(", ")", ",", "getTextLocation", "(", ")", ")", ";", "graphics", ".", "translate", "(", "-", "bounds", ".", "x", ",", "-", "bounds", ".", "y", ")", ";", "}", "}", ";", "this", ".", "setText", "(", "text", ")", ";", "this", ".", "setImage", "(", "image", ")", ";", "this", ".", "container", "=", "container", ";", "this", ".", "expander", "=", "new", "Expander", "(", ")", ";", "this", ".", "arcWidth", "=", "8", ";", "this", ".", "setFont", "(", "Display", ".", "getDefault", "(", ")", ".", "getSystemFont", "(", ")", ")", ";", "layout", "=", "new", "ToolbarLayout", "(", "true", ")", ";", "layout", ".", "setSpacing", "(", "5", ")", ";", "layout", ".", "setMinorAlignment", "(", "ToolbarLayout", ".", "ALIGN_CENTER", ")", ";", "this", ".", "setLayoutManager", "(", "layout", ")", ";", "this", ".", "add", "(", "this", ".", "expander", ")", ";", "this", ".", "add", "(", "this", ".", "label", ")", ";", "}", "protected", "void", "adjustBoundsToFit", "(", ")", "{", "String", "text", "=", "getText", "(", ")", ";", "if", "(", "(", "text", "!=", "null", ")", "&&", "(", "text", ".", "length", "(", ")", ">", "0", ")", ")", "{", "Font", "font", "=", "getFont", "(", ")", ";", "if", "(", "font", "!=", "null", ")", "{", "Dimension", "minSize", "=", "FigureUtilities", ".", "getTextExtents", "(", "text", ",", "font", ")", ";", "if", "(", "getIcon", "(", ")", "!=", "null", ")", "{", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Rectangle", "imageRect", "=", "getIcon", "(", ")", ".", "getBounds", "(", ")", ";", "int", "expandHeight", "=", "Math", ".", "max", "(", "imageRect", ".", "height", "-", "minSize", ".", "height", ",", "0", ")", ";", "minSize", ".", "expand", "(", "imageRect", ".", "width", "+", "4", ",", "expandHeight", ")", ";", "}", "minSize", ".", "expand", "(", "10", "+", "(", "2", "*", "1", ")", "+", "100", ",", "4", "+", "(", "2", "*", "1", ")", ")", ";", "label", ".", "setBounds", "(", "new", "Rectangle", "(", "getLocation", "(", ")", ",", "minSize", ")", ")", ";", "}", "}", "}", "private", "Image", "getIcon", "(", ")", "{", "return", "this", ".", "label", ".", "getIcon", "(", ")", ";", "}", "private", "String", "getText", "(", ")", "{", "return", "this", ".", "label", ".", "getText", "(", ")", ";", "}", "public", "void", "paint", "(", "Graphics", "graphics", ")", "{", "int", "blue", "=", "getBackgroundColor", "(", ")", ".", "getBlue", "(", ")", ";", "blue", "=", "(", "int", ")", "(", "blue", "-", "(", "blue", "*", "0.20", ")", ")", ";", "blue", "=", "blue", ">", "0", "?", "blue", ":", "0", ";", "int", "red", "=", "getBackgroundColor", "(", ")", ".", "getRed", "(", ")", ";", "red", "=", "(", "int", ")", "(", "red", "-", "(", "red", "*", "0.20", ")", ")", ";", "red", "=", "red", ">", "0", "?", "red", ":", "0", ";", "int", "green", "=", "getBackgroundColor", "(", ")", ".", "getGreen", "(", ")", ";", "green", "=", "(", "int", ")", "(", "green", "-", "(", "green", "*", "0.20", ")", ")", ";", "green", "=", "green", ">", "0", "?", "green", ":", "0", ";", "Color", "lightenColor", "=", "new", "Color", "(", "Display", ".", "getCurrent", "(", ")", ",", "new", "RGB", "(", "red", ",", "green", ",", "blue", ")", ")", ";", "graphics", ".", "setForegroundColor", "(", "lightenColor", ")", ";", "graphics", ".", "setBackgroundColor", "(", "getBackgroundColor", "(", ")", ")", ";", "graphics", ".", "pushState", "(", ")", ";", "Rectangle", "bounds", "=", "getBounds", "(", ")", ".", "getCopy", "(", ")", ";", "Rectangle", "r", "=", "bounds", ".", "getCopy", "(", ")", ";", "r", ".", "y", "+=", "arcWidth", "/", "2", ";", "r", ".", "height", "-=", "arcWidth", ";", "Rectangle", "top", "=", "bounds", ".", "getCopy", "(", ")", ";", "top", ".", "height", "/=", "2", ";", "graphics", ".", "setForegroundColor", "(", "getBackgroundColor", "(", ")", ")", ";", "graphics", ".", "setBackgroundColor", "(", "getBackgroundColor", "(", ")", ")", ";", "graphics", ".", "fillRoundRectangle", "(", "top", ",", "arcWidth", ",", "arcWidth", ")", ";", "top", ".", "y", "=", "top", ".", "y", "+", "top", ".", "height", ";", "graphics", ".", "setForegroundColor", "(", "lightenColor", ")", ";", "graphics", ".", "setBackgroundColor", "(", "lightenColor", ")", ";", "graphics", ".", "fillRoundRectangle", "(", "top", ",", "arcWidth", ",", "arcWidth", ")", ";", "graphics", ".", "setBackgroundColor", "(", "lightenColor", ")", ";", "graphics", ".", "setForegroundColor", "(", "getBackgroundColor", "(", ")", ")", ";", "graphics", ".", "fillGradient", "(", "r", ",", "true", ")", ";", "super", ".", "paint", "(", "graphics", ")", ";", "graphics", ".", "popState", "(", ")", ";", "graphics", ".", "setForegroundColor", "(", "lightenColor", ")", ";", "graphics", ".", "setBackgroundColor", "(", "lightenColor", ")", ";", "bounds", ".", "setSize", "(", "bounds", ".", "width", "-", "1", ",", "bounds", ".", "height", "-", "1", ")", ";", "graphics", ".", "drawRoundRectangle", "(", "bounds", ",", "arcWidth", ",", "arcWidth", ")", ";", "lightenColor", ".", "dispose", "(", ")", ";", "}", "public", "void", "setTextT", "(", "String", "string", ")", "{", "this", ".", "setPreferredSize", "(", "null", ")", ";", "this", ".", "label", ".", "setText", "(", "string", ")", ";", "this", ".", "add", "(", "label", ")", ";", "this", ".", "layout", ".", "layout", "(", "this", ")", ";", "this", ".", "invalidate", "(", ")", ";", "this", ".", "revalidate", "(", ")", ";", "this", ".", "validate", "(", ")", ";", "}", "public", "void", "setText", "(", "String", "string", ")", "{", "this", ".", "label", ".", "setText", "(", "string", ")", ";", "}", "public", "void", "setImage", "(", "Image", "image", ")", "{", "this", ".", "label", ".", "setIcon", "(", "image", ")", ";", "}", "public", "void", "setLocation", "(", "Point", "p", ")", "{", "super", ".", "setLocation", "(", "p", ")", ";", "}", "public", "void", "setBounds", "(", "Rectangle", "rect", ")", "{", "super", ".", "setBounds", "(", "rect", ")", ";", "}", "}", "</s>" ]
10,254
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "internal", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "FreeformFigure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "FreeformLayer", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "FreeformLayout", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Graphics", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "MarginBorder", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ScalableFigure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Dimension", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Point", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "PointList", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "PrecisionDimension", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "PrecisionPoint", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "PrecisionRectangle", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Rectangle", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Translatable", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "text", ".", "CaretInfo", ";", "public", "class", "AspectRatioFreeformLayer", "extends", "FreeformLayer", "implements", "ScalableFigure", ",", "FreeformFigure", "{", "private", "double", "widthScale", "=", "1.0", ";", "private", "double", "heigthScale", "=", "1.0", ";", "public", "AspectRatioFreeformLayer", "(", "String", "debugLabel", ")", "{", "widthScale", "=", "1D", ";", "heigthScale", "=", "1D", ";", "setLayoutManager", "(", "new", "FreeformLayout", "(", ")", ")", ";", "setBorder", "(", "new", "MarginBorder", "(", "5", ")", ")", ";", "}", "protected", "boolean", "isValidationRoot", "(", ")", "{", "return", "true", ";", "}", "public", "void", "setScale", "(", "double", "wScale", ",", "double", "hScale", ")", "{", "this", ".", "widthScale", "=", "wScale", ";", "this", ".", "heigthScale", "=", "hScale", ";", "}", "public", "double", "getWidthScale", "(", ")", "{", "return", "this", ".", "widthScale", ";", "}", "public", "double", "getHeightScale", "(", ")", "{", "return", "this", ".", "heigthScale", ";", "}", "public", "double", "getScale", "(", ")", "{", "throw", "new", "RuntimeException", "(", "\"\"", ")", ";", "}", "public", "void", "setScale", "(", "double", "scale", ")", "{", "this", ".", "widthScale", "=", "scale", ";", "this", ".", "heigthScale", "=", "scale", ";", "revalidate", "(", ")", ";", "repaint", "(", ")", ";", "}", "public", "Rectangle", "getClientArea", "(", "Rectangle", "rect", ")", "{", "rect", ".", "width", "/=", "widthScale", ";", "rect", ".", "height", "/=", "heigthScale", ";", "rect", ".", "x", "/=", "widthScale", ";", "rect", ".", "y", "/=", "heigthScale", ";", "return", "rect", ";", "}", "public", "Dimension", "getPreferredSize", "(", "int", "wHint", ",", "int", "hHint", ")", "{", "Dimension", "d", "=", "super", ".", "getPreferredSize", "(", "wHint", ",", "hHint", ")", ";", "int", "w", "=", "getInsets", "(", ")", ".", "getWidth", "(", ")", ";", "int", "h", "=", "getInsets", "(", ")", ".", "getHeight", "(", ")", ";", "return", "d", ".", "getExpanded", "(", "-", "w", ",", "-", "h", ")", ".", "scale", "(", "widthScale", ",", "heigthScale", ")", ".", "expand", "(", "w", ",", "h", ")", ";", "}", "public", "void", "translateFromParent", "(", "Translatable", "t", ")", "{", "super", ".", "translateFromParent", "(", "t", ")", ";", "if", "(", "t", "instanceof", "PrecisionRectangle", ")", "{", "PrecisionRectangle", "r", "=", "(", "PrecisionRectangle", ")", "t", ";", "r", ".", "setPreciseX", "(", "r", ".", "preciseX", "(", ")", "*", "(", "1", "/", "widthScale", ")", ")", ";", "r", ".", "setPreciseY", "(", "r", ".", "preciseY", "(", ")", "*", "(", "1", "/", "heigthScale", ")", ")", ";", "r", ".", "setPreciseWidth", "(", "r", ".", "preciseWidth", "(", ")", "*", "(", "1", "/", "widthScale", ")", ")", ";", "r", ".", "setPreciseHeight", "(", "r", ".", "preciseHeight", "(", ")", "*", "(", "1", "/", "heigthScale", ")", ")", ";", "}", "else", "if", "(", "t", "instanceof", "Rectangle", ")", "{", "Rectangle", "r", "=", "(", "Rectangle", ")", "t", ";", "r", ".", "scale", "(", "1", "/", "widthScale", ",", "1", "/", "heigthScale", ")", ";", "}", "else", "if", "(", "t", "instanceof", "CaretInfo", ")", "{", "CaretInfo", "c", "=", "(", "CaretInfo", ")", "t", ";", "c", ".", "performScale", "(", "1", "/", "heigthScale", ")", ";", "}", "else", "if", "(", "t", "instanceof", "PrecisionDimension", ")", "{", "PrecisionDimension", "d", "=", "(", "PrecisionDimension", ")", "t", ";", "d", ".", "setPreciseWidth", "(", "d", ".", "preciseWidth", "(", ")", "*", "(", "1", "/", "widthScale", ")", ")", ";", "d", ".", "setPreciseHeight", "(", "d", ".", "preciseHeight", "(", ")", "*", "(", "1", "/", "heigthScale", ")", ")", ";", "}", "else", "if", "(", "t", "instanceof", "Dimension", ")", "{", "Dimension", "d", "=", "(", "Dimension", ")", "t", ";", "d", ".", "scale", "(", "1", "/", "widthScale", ",", "1", "/", "heigthScale", ")", ";", "}", "else", "if", "(", "t", "instanceof", "PrecisionPoint", ")", "{", "PrecisionPoint", "p", "=", "(", "PrecisionPoint", ")", "t", ";", "p", ".", "setPreciseX", "(", "p", ".", "preciseX", "(", ")", "*", "(", "1", "/", "widthScale", ")", ")", ";", "p", ".", "setPreciseY", "(", "p", ".", "preciseY", "(", ")", "*", "(", "1", "/", "heigthScale", ")", ")", ";", "}", "else", "if", "(", "t", "instanceof", "Point", ")", "{", "Point", "p", "=", "(", "Point", ")", "t", ";", "p", ".", "scale", "(", "1", "/", "widthScale", ",", "1", "/", "heigthScale", ")", ";", "}", "else", "if", "(", "t", "instanceof", "PointList", ")", "{", "throw", "new", "RuntimeException", "(", "\"\"", ")", ";", "}", "else", "{", "throw", "new", "RuntimeException", "(", "t", ".", "toString", "(", ")", "+", "\"\"", ")", ";", "}", "}", "public", "void", "translateToParent", "(", "Translatable", "t", ")", "{", "if", "(", "t", "instanceof", "PrecisionRectangle", ")", "{", "PrecisionRectangle", "r", "=", "(", "PrecisionRectangle", ")", "t", ";", "r", ".", "setPreciseX", "(", "r", ".", "preciseX", "(", ")", "*", "widthScale", ")", ";", "r", ".", "setPreciseY", "(", "r", ".", "preciseY", "(", ")", "*", "heigthScale", ")", ";", "r", ".", "setPreciseWidth", "(", "r", ".", "preciseWidth", "(", ")", "*", "widthScale", ")", ";", "r", ".", "setPreciseHeight", "(", "r", ".", "preciseHeight", "(", ")", "*", "heigthScale", ")", ";", "}", "else", "if", "(", "t", "instanceof", "Rectangle", ")", "{", "Rectangle", "r", "=", "(", "Rectangle", ")", "t", ";", "r", ".", "scale", "(", "widthScale", ",", "heigthScale", ")", ";", "}", "else", "if", "(", "t", "instanceof", "CaretInfo", ")", "{", "CaretInfo", "c", "=", "(", "CaretInfo", ")", "t", ";", "c", ".", "performScale", "(", "heigthScale", ")", ";", "}", "else", "if", "(", "t", "instanceof", "PrecisionDimension", ")", "{", "PrecisionDimension", "d", "=", "(", "PrecisionDimension", ")", "t", ";", "d", ".", "setPreciseWidth", "(", "d", ".", "preciseWidth", "(", ")", "*", "widthScale", ")", ";", "d", ".", "setPreciseHeight", "(", "d", ".", "preciseHeight", "(", ")", "*", "heigthScale", ")", ";", "}", "else", "if", "(", "t", "instanceof", "Dimension", ")", "{", "Dimension", "d", "=", "(", "Dimension", ")", "t", ";", "d", ".", "scale", "(", "widthScale", ",", "heigthScale", ")", ";", "}", "else", "if", "(", "t", "instanceof", "PrecisionPoint", ")", "{", "PrecisionPoint", "p", "=", "(", "PrecisionPoint", ")", "t", ";", "p", ".", "setPreciseX", "(", "p", ".", "preciseX", "(", ")", "*", "widthScale", ")", ";", "p", ".", "setPreciseY", "(", "p", ".", "preciseY", "(", ")", "*", "heigthScale", ")", ";", "}", "else", "if", "(", "t", "instanceof", "Point", ")", "{", "Point", "p", "=", "(", "Point", ")", "t", ";", "p", ".", "scale", "(", "widthScale", ",", "heigthScale", ")", ";", "}", "else", "if", "(", "t", "instanceof", "PointList", ")", "{", "throw", "new", "RuntimeException", "(", "\"\"", ")", ";", "}", "else", "{", "throw", "new", "RuntimeException", "(", "t", ".", "toString", "(", ")", "+", "\"\"", ")", ";", "}", "super", ".", "translateToParent", "(", "t", ")", ";", "}", "protected", "void", "paintClientArea", "(", "Graphics", "graphics", ")", "{", "if", "(", "getChildren", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "return", ";", "}", "XYScaledGraphics", "g", "=", "null", ";", "boolean", "disposeGraphics", "=", "false", ";", "if", "(", "graphics", "instanceof", "XYScaledGraphics", ")", "{", "g", "=", "(", "XYScaledGraphics", ")", "graphics", ";", "}", "else", "{", "g", "=", "new", "XYScaledGraphics", "(", "graphics", ")", ";", "disposeGraphics", "=", "true", ";", "}", "boolean", "optimizeClip", "=", "getBorder", "(", ")", "==", "null", "||", "getBorder", "(", ")", ".", "isOpaque", "(", ")", ";", "if", "(", "!", "optimizeClip", ")", "{", "g", ".", "clipRect", "(", "getBounds", "(", ")", ".", "getShrinked", "(", "getInsets", "(", ")", ")", ")", ";", "}", "g", ".", "scale", "(", "widthScale", ",", "heigthScale", ")", ";", "g", ".", "pushState", "(", ")", ";", "paintChildren", "(", "g", ")", ";", "g", ".", "popState", "(", ")", ";", "if", "(", "disposeGraphics", ")", "{", "g", ".", "dispose", "(", ")", ";", "graphics", ".", "restoreState", "(", ")", ";", "}", "}", "}", "</s>" ]
10,255
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "internal", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "AbstractLocator", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Connection", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "IFigure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "PositionConstants", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Dimension", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Point", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "PointList", ";", "public", "class", "AligningBendpointLocator", "extends", "AbstractLocator", "{", "public", "static", "final", "int", "MIDDLE", "=", "0", ";", "public", "static", "final", "int", "ABOVE", "=", "1", ";", "public", "static", "final", "int", "BELOW", "=", "2", ";", "public", "static", "final", "int", "CENTER", "=", "0", ";", "public", "static", "final", "int", "BEGINNING", "=", "1", ";", "public", "static", "final", "int", "END", "=", "2", ";", "public", "static", "final", "int", "CENTER_BEGINNING", "=", "3", ";", "public", "static", "final", "int", "CENTER_END", "=", "4", ";", "private", "int", "horizontal", ";", "private", "int", "vertical", ";", "private", "Connection", "connection", ";", "public", "AligningBendpointLocator", "(", "Connection", "connection", ")", "{", "this", "(", "connection", ",", "CENTER", ",", "MIDDLE", ")", ";", "}", "public", "AligningBendpointLocator", "(", "Connection", "connection", ",", "int", "horizontal", ",", "int", "vertical", ")", "{", "this", ".", "connection", "=", "connection", ";", "this", ".", "horizontal", "=", "horizontal", ";", "this", ".", "vertical", "=", "vertical", ";", "}", "protected", "Point", "getReferencePoint", "(", ")", "{", "PointList", "points", "=", "getConnection", "(", ")", ".", "getPoints", "(", ")", ";", "Point", "p", "=", "points", ".", "getMidpoint", "(", ")", ".", "getCopy", "(", ")", ";", "PointList", "tempPoints", "=", "new", "PointList", "(", ")", ";", "switch", "(", "horizontal", ")", "{", "case", "BEGINNING", ":", "p", "=", "points", ".", "getFirstPoint", "(", ")", ".", "getCopy", "(", ")", ";", "break", ";", "case", "END", ":", "p", "=", "points", ".", "getLastPoint", "(", ")", ".", "getCopy", "(", ")", ";", "break", ";", "case", "CENTER_BEGINNING", ":", "tempPoints", ".", "addPoint", "(", "points", ".", "getFirstPoint", "(", ")", ".", "getCopy", "(", ")", ")", ";", "tempPoints", ".", "addPoint", "(", "points", ".", "getPoint", "(", "1", ")", ".", "getCopy", "(", ")", ")", ";", "p", "=", "tempPoints", ".", "getMidpoint", "(", ")", ".", "getCopy", "(", ")", ";", "break", ";", "case", "CENTER_END", ":", "tempPoints", "=", "new", "PointList", "(", ")", ";", "int", "s", "=", "points", ".", "size", "(", ")", ";", "tempPoints", ".", "addPoint", "(", "points", ".", "getLastPoint", "(", ")", ".", "getCopy", "(", ")", ")", ";", "tempPoints", ".", "addPoint", "(", "points", ".", "getPoint", "(", "s", "-", "2", ")", ".", "getCopy", "(", ")", ")", ";", "p", "=", "tempPoints", ".", "getMidpoint", "(", ")", ".", "getCopy", "(", ")", ";", "case", "CENTER", ":", "default", ":", "p", "=", "points", ".", "getMidpoint", "(", ")", ".", "getCopy", "(", ")", ";", "}", "return", "p", ";", "}", "public", "void", "relocate", "(", "IFigure", "target", ")", "{", "Dimension", "prefSize", "=", "target", ".", "getPreferredSize", "(", ")", ";", "Point", "center", "=", "getReferencePoint", "(", ")", ";", "calculatePosition", "(", ")", ";", "target", ".", "setBounds", "(", "getNewBounds", "(", "prefSize", ",", "center", ")", ")", ";", "}", "private", "void", "calculatePosition", "(", ")", "{", "PointList", "points", "=", "getConnection", "(", ")", ".", "getPoints", "(", ")", ";", "int", "position", "=", "0", ";", "switch", "(", "horizontal", ")", "{", "case", "BEGINNING", ":", "Point", "first", "=", "points", ".", "getFirstPoint", "(", ")", ";", "Point", "next", "=", "points", ".", "getPoint", "(", "1", ")", ";", "if", "(", "first", ".", "x", "<=", "next", ".", "x", ")", "{", "position", "|=", "PositionConstants", ".", "EAST", ";", "}", "else", "{", "position", "|=", "PositionConstants", ".", "WEST", ";", "}", "break", ";", "case", "END", ":", "Point", "last", "=", "points", ".", "getLastPoint", "(", ")", ";", "int", "s", "=", "points", ".", "size", "(", ")", ";", "Point", "before", "=", "points", ".", "getPoint", "(", "s", "-", "1", ")", ";", "if", "(", "last", ".", "x", "<=", "before", ".", "x", ")", "{", "position", "|=", "PositionConstants", ".", "EAST", ";", "}", "else", "{", "position", "|=", "PositionConstants", ".", "WEST", ";", "}", "break", ";", "}", "if", "(", "position", "==", "0", ")", "{", "position", "=", "PositionConstants", ".", "CENTER", ";", "}", "switch", "(", "vertical", ")", "{", "case", "ABOVE", ":", "position", "|=", "PositionConstants", ".", "NORTH", ";", "break", ";", "case", "BELOW", ":", "position", "|=", "PositionConstants", ".", "SOUTH", ";", "break", ";", "case", "MIDDLE", ":", "position", "|=", "PositionConstants", ".", "MIDDLE", ";", "}", "setRelativePosition", "(", "position", ")", ";", "}", "public", "int", "getHorizontalAlignment", "(", ")", "{", "return", "horizontal", ";", "}", "public", "void", "setHorizontalAlignment", "(", "int", "horizontal", ")", "{", "this", ".", "horizontal", "=", "horizontal", ";", "}", "public", "void", "setVerticalAlginment", "(", "int", "vertical", ")", "{", "this", ".", "vertical", "=", "vertical", ";", "}", "public", "int", "getVerticalAlignment", "(", ")", "{", "return", "vertical", ";", "}", "public", "Connection", "getConnection", "(", ")", "{", "return", "connection", ";", "}", "}", "</s>" ]
10,256
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "internal", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "FreeformLayer", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "IFigure", ";", "public", "class", "ZestRootLayer", "extends", "FreeformLayer", "{", "public", "static", "final", "int", "CONNECTIONS_LAYER", "=", "0", ";", "public", "static", "final", "int", "SUBGRAPHS_LAYER", "=", "1", ";", "public", "static", "final", "int", "NODES_LAYER", "=", "2", ";", "public", "static", "final", "int", "CONNECTIONS_HIGHLIGHTED_LAYER", "=", "3", ";", "public", "static", "final", "int", "NODES_HIGHLIGHTED_LAYER", "=", "4", ";", "public", "static", "final", "int", "TOP_LAYER", "=", "5", ";", "public", "static", "final", "int", "NUMBER_OF_LAYERS", "=", "6", ";", "private", "final", "int", "[", "]", "itemsInLayer", "=", "new", "int", "[", "NUMBER_OF_LAYERS", "]", ";", "private", "HashSet", "decoratingFigures", "=", "new", "HashSet", "(", ")", ";", "private", "boolean", "isLayerKnown", "=", "false", ";", "public", "void", "addNode", "(", "IFigure", "nodeFigure", ")", "{", "addFigure", "(", "nodeFigure", ",", "NODES_LAYER", ")", ";", "}", "public", "void", "addConnection", "(", "IFigure", "connectionFigure", ")", "{", "addFigure", "(", "connectionFigure", ",", "CONNECTIONS_LAYER", ")", ";", "}", "public", "void", "addSubgraph", "(", "IFigure", "subgraphFigrue", ")", "{", "addFigure", "(", "subgraphFigrue", ",", "SUBGRAPHS_LAYER", ")", ";", "}", "public", "void", "highlightNode", "(", "IFigure", "nodeFigure", ")", "{", "changeFigureLayer", "(", "nodeFigure", ",", "NODES_HIGHLIGHTED_LAYER", ")", ";", "}", "public", "void", "highlightConnection", "(", "IFigure", "connectionFigure", ")", "{", "changeFigureLayer", "(", "connectionFigure", ",", "CONNECTIONS_HIGHLIGHTED_LAYER", ")", ";", "}", "public", "void", "unHighlightNode", "(", "IFigure", "nodeFigure", ")", "{", "changeFigureLayer", "(", "nodeFigure", ",", "NODES_LAYER", ")", ";", "}", "public", "void", "unHighlightConnection", "(", "IFigure", "connectionFigure", ")", "{", "changeFigureLayer", "(", "connectionFigure", ",", "CONNECTIONS_LAYER", ")", ";", "}", "private", "void", "changeFigureLayer", "(", "IFigure", "figure", ",", "int", "newLayer", ")", "{", "ArrayList", "decorations", "=", "getDecorations", "(", "figure", ")", ";", "remove", "(", "figure", ")", ";", "addFigure", "(", "figure", ",", "newLayer", ")", ";", "for", "(", "Iterator", "iterator", "=", "decorations", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "addDecoration", "(", "figure", ",", "(", "IFigure", ")", "iterator", ".", "next", "(", ")", ")", ";", "}", "this", ".", "invalidate", "(", ")", ";", "this", ".", "repaint", "(", ")", ";", "}", "private", "ArrayList", "getDecorations", "(", "IFigure", "figure", ")", "{", "ArrayList", "result", "=", "new", "ArrayList", "(", ")", ";", "int", "index", "=", "getChildren", "(", ")", ".", "indexOf", "(", "figure", ")", ";", "if", "(", "index", "==", "-", "1", ")", "{", "return", "result", ";", "}", "for", "(", "index", "++", ";", "index", "<", "getChildren", "(", ")", ".", "size", "(", ")", ";", "index", "++", ")", "{", "Object", "nextFigure", "=", "getChildren", "(", ")", ".", "get", "(", "index", ")", ";", "if", "(", "decoratingFigures", ".", "contains", "(", "nextFigure", ")", ")", "{", "result", ".", "add", "(", "nextFigure", ")", ";", "}", "else", "{", "break", ";", "}", "}", "return", "result", ";", "}", "private", "int", "getPosition", "(", "int", "layer", ")", "{", "int", "result", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<=", "layer", ";", "i", "++", ")", "{", "result", "+=", "itemsInLayer", "[", "i", "]", ";", "}", "return", "result", ";", "}", "private", "int", "getLayer", "(", "int", "position", ")", "{", "int", "layer", "=", "0", ";", "int", "positionInLayer", "=", "itemsInLayer", "[", "0", "]", ";", "while", "(", "layer", "<", "NUMBER_OF_LAYERS", "-", "1", "&&", "positionInLayer", "<=", "position", ")", "{", "layer", "++", ";", "positionInLayer", "+=", "itemsInLayer", "[", "layer", "]", ";", "}", "return", "layer", ";", "}", "public", "void", "addFigure", "(", "IFigure", "figure", ",", "int", "layer", ")", "{", "int", "position", "=", "getPosition", "(", "layer", ")", ";", "itemsInLayer", "[", "layer", "]", "++", ";", "isLayerKnown", "=", "true", ";", "add", "(", "figure", ",", "position", ")", ";", "}", "public", "void", "add", "(", "IFigure", "child", ",", "Object", "constraint", ",", "int", "index", ")", "{", "super", ".", "add", "(", "child", ",", "constraint", ",", "index", ")", ";", "if", "(", "!", "isLayerKnown", ")", "{", "int", "layer", "=", "0", ",", "positionInLayer", "=", "itemsInLayer", "[", "0", "]", ";", "while", "(", "positionInLayer", "<", "index", ")", "{", "layer", "++", ";", "positionInLayer", "+=", "itemsInLayer", "[", "layer", "]", ";", "}", "if", "(", "index", "==", "-", "1", ")", "{", "layer", "=", "NUMBER_OF_LAYERS", "-", "1", ";", "}", "itemsInLayer", "[", "layer", "]", "++", ";", "}", "isLayerKnown", "=", "false", ";", "}", "public", "void", "remove", "(", "IFigure", "child", ")", "{", "int", "position", "=", "this", ".", "getChildren", "(", ")", ".", "indexOf", "(", "child", ")", ";", "if", "(", "position", "==", "-", "1", ")", "{", "return", ";", "}", "itemsInLayer", "[", "getLayer", "(", "position", ")", "]", "--", ";", "if", "(", "decoratingFigures", ".", "contains", "(", "child", ")", ")", "{", "decoratingFigures", ".", "remove", "(", "child", ")", ";", "super", ".", "remove", "(", "child", ")", ";", "}", "else", "{", "ArrayList", "decorations", "=", "getDecorations", "(", "child", ")", ";", "super", ".", "remove", "(", "child", ")", ";", "for", "(", "Iterator", "iterator", "=", "decorations", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "remove", "(", "(", "IFigure", ")", "iterator", ".", "next", "(", ")", ")", ";", "}", "}", "}", "public", "void", "addDecoration", "(", "IFigure", "decorated", ",", "IFigure", "decorating", ")", "{", "int", "position", "=", "this", ".", "getChildren", "(", ")", ".", "indexOf", "(", "decorated", ")", ";", "if", "(", "position", "==", "-", "1", ")", "{", "throw", "new", "RuntimeException", "(", "\"\"", ")", ";", "}", "itemsInLayer", "[", "getLayer", "(", "position", ")", "]", "++", ";", "isLayerKnown", "=", "true", ";", "do", "{", "position", "++", ";", "}", "while", "(", "position", "<", "getChildren", "(", ")", ".", "size", "(", ")", "&&", "decoratingFigures", ".", "contains", "(", "getChildren", "(", ")", ".", "get", "(", "position", ")", ")", ")", ";", "decoratingFigures", ".", "add", "(", "decorating", ")", ";", "add", "(", "decorating", ",", "position", ")", ";", "}", "}", "</s>" ]
10,257
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "internal", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ChopboxAnchor", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "IFigure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Point", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Rectangle", ";", "public", "class", "RoundedChopboxAnchor", "extends", "ChopboxAnchor", "{", "private", "int", "arcRadius", "=", "10", ";", "private", "int", "shift", "=", "7", ";", "public", "RoundedChopboxAnchor", "(", "int", "arcRadius", ")", "{", "super", "(", ")", ";", "this", ".", "arcRadius", "=", "arcRadius", ";", "this", ".", "shift", "=", "arcRadius", "-", "(", "int", ")", "(", "0.707", "*", "arcRadius", ")", ";", "}", "public", "RoundedChopboxAnchor", "(", "IFigure", "owner", ",", "int", "arcRadius", ")", "{", "super", "(", "owner", ")", ";", "this", ".", "arcRadius", "=", "arcRadius", ";", "this", ".", "shift", "=", "arcRadius", "-", "(", "int", ")", "(", "0.707", "*", "arcRadius", ")", ";", "}", "public", "Point", "getLocation", "(", "Point", "reference", ")", "{", "Point", "p", "=", "super", ".", "getLocation", "(", "reference", ")", ";", "Rectangle", "bounds", "=", "getBox", "(", ")", ";", "boolean", "done", "=", "getTranslatedPoint", "(", "bounds", ".", "getTopLeft", "(", ")", ",", "p", ",", "shift", ",", "shift", ")", ";", "if", "(", "!", "done", ")", "{", "done", "=", "getTranslatedPoint", "(", "bounds", ".", "getTopRight", "(", ")", ",", "p", ",", "-", "shift", ",", "shift", ")", ";", "}", "if", "(", "!", "done", ")", "{", "done", "=", "getTranslatedPoint", "(", "bounds", ".", "getBottomLeft", "(", ")", ",", "p", ",", "shift", ",", "-", "shift", ")", ";", "}", "if", "(", "!", "done", ")", "{", "done", "=", "getTranslatedPoint", "(", "bounds", ".", "getBottomRight", "(", ")", ",", "p", ",", "-", "shift", ",", "-", "shift", ")", ";", "}", "return", "p", ";", "}", "private", "boolean", "getTranslatedPoint", "(", "Point", "corner", ",", "Point", "p", ",", "int", "dx", ",", "int", "dy", ")", "{", "int", "diff", "=", "(", "int", ")", "corner", ".", "getDistance", "(", "p", ")", ";", "if", "(", "diff", "<", "arcRadius", ")", "{", "Point", "t", "=", "corner", ".", "getTranslated", "(", "dx", ",", "dy", ")", ";", "p", ".", "setLocation", "(", "t", ".", "x", ",", "t", ".", "y", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}", "}", "</s>" ]
10,258
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "internal", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "PolylineConnection", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "RectangleFigure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Point", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "PointList", ";", "public", "class", "PolylineArcConnection", "extends", "PolylineConnection", "{", "private", "int", "depth", ";", "private", "boolean", "inverse", "=", "false", ";", "private", "static", "final", "float", "PI", "=", "(", "float", ")", "3.14159", ";", "private", "RectangleFigure", "center", ";", "{", "this", ".", "depth", "=", "0", ";", "center", "=", "new", "RectangleFigure", "(", ")", ";", "}", "public", "void", "setPoints", "(", "PointList", "points", ")", "{", "updateArc", "(", "points", ")", ";", "}", "public", "void", "addPoint", "(", "Point", "pt", ")", "{", "}", "public", "void", "setDepth", "(", "int", "depth", ")", "{", "this", ".", "inverse", "=", "depth", "<", "0", "?", "true", ":", "false", ";", "this", ".", "depth", "=", "depth", ";", "updateArc", "(", "getPoints", "(", ")", ")", ";", "}", "protected", "void", "updateArc", "(", "PointList", "pointList", ")", "{", "if", "(", "pointList", ".", "size", "(", ")", "<", "2", ")", "{", "return", ";", "}", "if", "(", "center", ".", "getParent", "(", ")", "==", "this", ")", "{", "remove", "(", "center", ")", ";", "}", "Point", "start", "=", "pointList", ".", "getFirstPoint", "(", ")", ";", "Point", "end", "=", "pointList", ".", "getLastPoint", "(", ")", ";", "if", "(", "depth", "==", "0", ")", "{", "super", ".", "setPoints", "(", "pointList", ")", ";", "return", ";", "}", "PointList", "points", "=", "new", "PointList", "(", ")", ";", "float", "arcStart", "=", "0", ";", "float", "arcEnd", "=", "0", ";", "float", "arcLength", "=", "0", ";", "float", "cartCenterX", "=", "0", ";", "float", "cartCenterY", "=", "0", ";", "float", "r", "=", "0", ";", "float", "x1", "=", "start", ".", "x", ";", "float", "y1", "=", "-", "start", ".", "y", ";", "float", "x2", "=", "end", ".", "x", ";", "float", "y2", "=", "-", "end", ".", "y", ";", "float", "depth", "=", "this", ".", "depth", ";", "if", "(", "start", ".", "equals", "(", "end", ")", ")", "{", "arcStart", "=", "-", "PI", "/", "2", ";", "arcLength", "=", "PI", "*", "2", ";", "cartCenterX", "=", "x1", ";", "cartCenterY", "=", "y1", "+", "depth", "/", "2", ";", "r", "=", "depth", "/", "2", ";", "}", "else", "{", "if", "(", "x1", ">=", "x2", ")", "{", "depth", "=", "-", "depth", ";", "}", "float", "cartChordX", "=", "(", "x2", "+", "x1", ")", "/", "2", ";", "float", "cartChordY", "=", "(", "y2", "+", "y1", ")", "/", "2", ";", "float", "chordLength", "=", "(", "float", ")", "Math", ".", "sqrt", "(", "(", "x1", "-", "x2", ")", "*", "(", "x1", "-", "x2", ")", "+", "(", "y1", "-", "y2", ")", "*", "(", "y1", "-", "y2", ")", ")", ";", "if", "(", "Math", ".", "abs", "(", "depth", ")", ">=", "chordLength", "/", "2", ")", "{", "depth", "=", "(", "chordLength", "/", "3", ")", "*", "(", "depth", "/", "Math", ".", "abs", "(", "depth", ")", ")", ";", "}", "r", "=", "(", "(", "(", "(", "chordLength", "/", "2", ")", "*", "(", "chordLength", "/", "2", ")", ")", "+", "(", "depth", "*", "depth", ")", ")", "/", "(", "2", "*", "depth", ")", ")", ";", "float", "chordNormal", "=", "0", ";", "if", "(", "Math", ".", "abs", "(", "x1", "-", "x2", ")", "<=", ".000001", ")", "{", "chordNormal", "=", "Float", ".", "NaN", ";", "}", "else", "if", "(", "Math", ".", "abs", "(", "y1", "-", "y2", ")", "<=", "0.000001", ")", "{", "chordNormal", "=", "Float", ".", "POSITIVE_INFINITY", ";", "}", "else", "{", "chordNormal", "=", "-", "1", "*", "(", "y2", "-", "y1", ")", "/", "(", "x2", "-", "x1", ")", ";", "}", "float", "th1", ";", "if", "(", "Float", ".", "isNaN", "(", "chordNormal", ")", ")", "{", "cartCenterX", "=", "(", "y1", ">", "y2", ")", "?", "(", "cartChordX", "-", "r", "+", "(", "depth", ")", ")", ":", "(", "cartChordX", "+", "r", "-", "(", "depth", ")", ")", ";", "cartCenterY", "=", "cartChordY", ";", "th1", "=", "PI", "/", "2", ";", "}", "else", "if", "(", "Float", ".", "isInfinite", "(", "chordNormal", ")", ")", "{", "cartCenterX", "=", "cartChordX", ";", "cartCenterY", "=", "cartChordY", "+", "r", "-", "(", "depth", ")", ";", "th1", "=", "0", ";", "}", "else", "{", "th1", "=", "(", "float", ")", "Math", ".", "atan", "(", "chordNormal", ")", ";", "cartCenterX", "=", "(", "r", "-", "(", "depth", ")", ")", "*", "(", "float", ")", "Math", ".", "sin", "(", "th1", ")", "+", "cartChordX", ";", "cartCenterY", "=", "(", "r", "-", "(", "depth", ")", ")", "*", "(", "float", ")", "Math", ".", "cos", "(", "th1", ")", "+", "cartChordY", ";", "}", "float", "cartArcX1", "=", "x1", "-", "cartCenterX", ";", "float", "cartArcY1", "=", "y1", "-", "cartCenterY", ";", "float", "cartArcX2", "=", "x2", "-", "cartCenterX", ";", "float", "cartArcY2", "=", "y2", "-", "cartCenterY", ";", "arcStart", "=", "angleRadians", "(", "cartArcX1", ",", "cartArcY1", ")", ";", "arcEnd", "=", "angleRadians", "(", "cartArcX2", ",", "cartArcY2", ")", ";", "if", "(", "arcEnd", "<", "arcStart", ")", "{", "arcEnd", "=", "arcEnd", "+", "PI", "+", "PI", ";", "}", "arcLength", "=", "arcEnd", "-", "arcStart", ";", "float", "pad", "=", "PI", "/", "Math", ".", "abs", "(", "r", ")", ";", "arcStart", "+=", "pad", ";", "arcEnd", "-=", "pad", ";", "arcLength", "=", "(", "arcEnd", ")", "-", "(", "arcStart", ")", ";", "if", "(", "inverse", ")", "{", "arcLength", "=", "(", "2", "*", "PI", "-", "arcLength", ")", ";", "}", "}", "r", "=", "Math", ".", "abs", "(", "r", ")", ";", "float", "x", "=", "0", ",", "y", "=", "0", ";", "Point", "p", "=", "null", ";", "points", ".", "addPoint", "(", "start", ")", ";", "float", "length", "=", "arcLength", "*", "r", ";", "int", "steps", "=", "(", "int", ")", "length", "/", "16", ";", "if", "(", "steps", "<", "10", "&&", "length", ">", "10", ")", "{", "steps", "=", "10", ";", "}", "if", "(", "arcLength", "<", "PI", "/", "4", "&&", "steps", ">", "6", ")", "{", "steps", "=", "6", ";", "}", "if", "(", "steps", "<", "4", "&&", "length", ">", "4", ")", "{", "steps", "=", "4", ";", "}", "float", "stepSize", "=", "arcLength", "/", "steps", ";", "if", "(", "inverse", ")", "{", "float", "step", "=", "arcStart", "-", "stepSize", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "steps", ";", "i", "++", ",", "step", "-=", "stepSize", ")", "{", "x", "=", "(", "r", ")", "*", "(", "float", ")", "Math", ".", "cos", "(", "step", ")", "+", "cartCenterX", ";", "y", "=", "(", "r", ")", "*", "(", "float", ")", "Math", ".", "sin", "(", "step", ")", "+", "cartCenterY", ";", "p", "=", "new", "Point", "(", "Math", ".", "round", "(", "x", ")", ",", "Math", ".", "round", "(", "-", "y", ")", ")", ";", "points", ".", "addPoint", "(", "p", ")", ";", "}", "}", "else", "{", "float", "step", "=", "stepSize", "+", "arcStart", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "steps", ";", "i", "++", ",", "step", "+=", "stepSize", ")", "{", "x", "=", "(", "r", ")", "*", "(", "float", ")", "Math", ".", "cos", "(", "step", ")", "+", "cartCenterX", ";", "y", "=", "(", "r", ")", "*", "(", "float", ")", "Math", ".", "sin", "(", "step", ")", "+", "cartCenterY", ";", "p", "=", "new", "Point", "(", "Math", ".", "round", "(", "x", ")", ",", "Math", ".", "round", "(", "-", "y", ")", ")", ";", "points", ".", "addPoint", "(", "p", ")", ";", "}", "}", "points", ".", "addPoint", "(", "end", ")", ";", "super", ".", "setPoints", "(", "points", ")", ";", "}", "float", "angleRadians", "(", "float", "x", ",", "float", "y", ")", "{", "float", "theta", "=", "(", "float", ")", "Math", ".", "atan", "(", "y", "/", "x", ")", ";", "switch", "(", "findQuadrant", "(", "x", ",", "y", ")", ")", "{", "case", "1", ":", "return", "theta", ";", "case", "2", ":", "return", "(", "theta", "+", "PI", ")", ";", "case", "4", ":", "theta", "=", "(", "theta", "+", "PI", ")", ";", "case", "3", ":", "return", "(", "theta", "+", "PI", ")", ";", "default", ":", "return", "theta", ";", "}", "}", "protected", "int", "findQuadrant", "(", "float", "x", ",", "float", "y", ")", "{", "if", "(", "y", ">", "0", ")", "{", "if", "(", "x", ">", "0", ")", "{", "return", "1", ";", "}", "else", "{", "return", "2", ";", "}", "}", "else", "{", "if", "(", "x", ">", "0", ")", "{", "return", "4", ";", "}", "else", "{", "return", "3", ";", "}", "}", "}", "}", "</s>" ]
10,259
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "internal", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Control", ";", "public", "interface", "RevealListener", "{", "public", "void", "revealed", "(", "Control", "c", ")", ";", "}", "</s>" ]
10,260
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "internal", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Animation", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ColorConstants", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Graphics", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Label", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "SWTGraphics", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ScaledGraphics", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Point", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Rectangle", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Color", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Font", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "GC", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Image", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "ILabeledFigure", ";", "public", "abstract", "class", "CachedLabel", "extends", "Label", "implements", "ILabeledFigure", "{", "Image", "cachedImage", "=", "null", ";", "boolean", "cacheLabel", "=", "false", ";", "boolean", "invalidationRequired", "=", "false", ";", "public", "CachedLabel", "(", "boolean", "cacheLabel", ")", "{", "this", ".", "cacheLabel", "=", "cacheLabel", ";", "}", "public", "void", "setIcon", "(", "Image", "image", ")", "{", "updateInvalidation", "(", ")", ";", "super", ".", "setIcon", "(", "image", ")", ";", "}", "public", "void", "setForegroundColor", "(", "Color", "fg", ")", "{", "updateInvalidation", "(", ")", ";", "super", ".", "setForegroundColor", "(", "fg", ")", ";", "}", "public", "void", "setBackgroundColor", "(", "Color", "bg", ")", "{", "updateInvalidation", "(", ")", ";", "super", ".", "setBackgroundColor", "(", "bg", ")", ";", "}", "public", "void", "setFont", "(", "Font", "f", ")", "{", "updateInvalidation", "(", ")", ";", "super", ".", "setFont", "(", "f", ")", ";", "}", "public", "void", "setText", "(", "String", "s", ")", "{", "updateInvalidation", "(", ")", ";", "super", ".", "setText", "(", "s", ")", ";", "}", "public", "void", "setSize", "(", "int", "w", ",", "int", "h", ")", "{", "updateInvalidation", "(", ")", ";", "if", "(", "cachedImage", "!=", "null", "&&", "shouldInvalidateCache", "(", ")", ")", "{", "cleanImage", "(", ")", ";", "}", "super", ".", "setSize", "(", "w", ",", "h", ")", ";", "}", "public", "void", "setBounds", "(", "Rectangle", "rect", ")", "{", "boolean", "resize", "=", "(", "rect", ".", "width", "!=", "bounds", ".", "width", ")", "||", "(", "rect", ".", "height", "!=", "bounds", ".", "height", ")", ";", "if", "(", "resize", "&&", "Animation", ".", "isAnimating", "(", ")", ")", "{", "updateInvalidation", "(", ")", ";", "}", "if", "(", "resize", "&&", "shouldInvalidateCache", "(", ")", "&&", "cachedImage", "!=", "null", ")", "{", "cleanImage", "(", ")", ";", "}", "super", ".", "setBounds", "(", "rect", ")", ";", "}", "protected", "abstract", "Color", "getBackgroundTextColor", "(", ")", ";", "static", "Rectangle", "tempRect", "=", "new", "Rectangle", "(", ")", ";", "protected", "void", "paintFigure", "(", "Graphics", "graphics", ")", "{", "if", "(", "graphics", ".", "getClass", "(", ")", "==", "ScaledGraphics", ".", "class", ")", "{", "if", "(", "(", "(", "ScaledGraphics", ")", "graphics", ")", ".", "getAbsoluteScale", "(", ")", "<", "0.30", ")", "{", "return", ";", "}", "}", "if", "(", "!", "cacheLabel", ")", "{", "if", "(", "isOpaque", "(", ")", ")", "{", "super", ".", "paintFigure", "(", "graphics", ")", ";", "}", "Rectangle", "bounds", "=", "getBounds", "(", ")", ";", "graphics", ".", "translate", "(", "bounds", ".", "x", ",", "bounds", ".", "y", ")", ";", "if", "(", "getIcon", "(", ")", "!=", "null", ")", "{", "graphics", ".", "drawImage", "(", "getIcon", "(", ")", ",", "getIconLocation", "(", ")", ")", ";", "}", "if", "(", "!", "isEnabled", "(", ")", ")", "{", "graphics", ".", "translate", "(", "1", ",", "1", ")", ";", "graphics", ".", "setForegroundColor", "(", "ColorConstants", ".", "buttonLightest", ")", ";", "graphics", ".", "drawText", "(", "getSubStringText", "(", ")", ",", "getTextLocation", "(", ")", ")", ";", "graphics", ".", "translate", "(", "-", "1", ",", "-", "1", ")", ";", "graphics", ".", "setForegroundColor", "(", "ColorConstants", ".", "buttonDarker", ")", ";", "}", "graphics", ".", "drawText", "(", "getText", "(", ")", ",", "getTextLocation", "(", ")", ")", ";", "graphics", ".", "translate", "(", "-", "bounds", ".", "x", ",", "-", "bounds", ".", "y", ")", ";", "return", ";", "}", "if", "(", "isOpaque", "(", ")", ")", "{", "graphics", ".", "fillRectangle", "(", "getBounds", "(", ")", ")", ";", "}", "Rectangle", "bounds", "=", "getBounds", "(", ")", ";", "graphics", ".", "translate", "(", "bounds", ".", "x", ",", "bounds", ".", "y", ")", ";", "Image", "icon", "=", "getIcon", "(", ")", ";", "if", "(", "icon", "!=", "null", ")", "{", "graphics", ".", "drawImage", "(", "icon", ",", "getIconLocation", "(", ")", ")", ";", "}", "int", "width", "=", "getSubStringTextSize", "(", ")", ".", "width", ";", "int", "height", "=", "getSubStringTextSize", "(", ")", ".", "height", ";", "if", "(", "cachedImage", "==", "null", "||", "shouldInvalidateCache", "(", ")", ")", "{", "invalidationRequired", "=", "false", ";", "cleanImage", "(", ")", ";", "cachedImage", "=", "new", "Image", "(", "Display", ".", "getCurrent", "(", ")", ",", "width", ",", "height", ")", ";", "GC", "gc", "=", "new", "GC", "(", "cachedImage", ")", ";", "Graphics", "graphics2", "=", "new", "SWTGraphics", "(", "gc", ")", ";", "graphics2", ".", "setBackgroundColor", "(", "getBackgroundTextColor", "(", ")", ")", ";", "graphics2", ".", "fillRectangle", "(", "0", ",", "0", ",", "width", ",", "height", ")", ";", "graphics2", ".", "setForegroundColor", "(", "getForegroundColor", "(", ")", ")", ";", "graphics2", ".", "drawText", "(", "getText", "(", ")", ",", "new", "Point", "(", "0", ",", "0", ")", ")", ";", "gc", ".", "dispose", "(", ")", ";", "}", "graphics", ".", "drawImage", "(", "cachedImage", ",", "getTextLocation", "(", ")", ")", ";", "graphics", ".", "translate", "(", "-", "bounds", ".", "x", ",", "-", "bounds", ".", "y", ")", ";", "this", ".", "paintBorder", "(", "graphics", ")", ";", "}", "private", "boolean", "shouldInvalidateCache", "(", ")", "{", "if", "(", "invalidationRequired", "&&", "!", "Animation", ".", "isAnimating", "(", ")", ")", "{", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}", "private", "void", "updateInvalidation", "(", ")", "{", "invalidationRequired", "=", "true", ";", "}", "protected", "void", "cleanImage", "(", ")", "{", "if", "(", "cachedImage", "!=", "null", ")", "{", "cachedImage", ".", "dispose", "(", ")", ";", "cachedImage", "=", "null", ";", "}", "}", "}", "</s>" ]
10,261
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "internal", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Figure", ";", "public", "class", "ContainerFigure", "extends", "Figure", "{", "}", "</s>" ]
10,262
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "internal", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "FigureUtilities", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Graphics", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ScaledGraphics", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Point", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "PointList", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Rectangle", ";", "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", ".", "Image", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "TextLayout", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "TextStyle", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "public", "class", "XYScaledGraphics", "extends", "ScaledGraphics", "{", "public", "static", "final", "double", "MAX_TEXT_SIZE", "=", "0.45", ";", "private", "static", "class", "FontHeightCache", "{", "Font", "font", ";", "int", "height", ";", "}", "static", "class", "FontKey", "{", "Font", "font", ";", "int", "height", ";", "protected", "FontKey", "(", ")", "{", "}", "protected", "FontKey", "(", "Font", "font", ",", "int", "height", ")", "{", "this", ".", "font", "=", "font", ";", "this", ".", "height", "=", "height", ";", "}", "public", "boolean", "equals", "(", "Object", "obj", ")", "{", "return", "(", "(", "(", "FontKey", ")", "obj", ")", ".", "font", ".", "equals", "(", "font", ")", "&&", "(", "(", "FontKey", ")", "obj", ")", ".", "height", "==", "height", ")", ";", "}", "public", "int", "hashCode", "(", ")", "{", "return", "font", ".", "hashCode", "(", ")", "^", "height", ";", "}", "protected", "void", "setValues", "(", "Font", "font", ",", "int", "height", ")", "{", "this", ".", "font", "=", "font", ";", "this", ".", "height", "=", "height", ";", "}", "}", "protected", "static", "class", "State", "{", "private", "double", "appliedX", ";", "private", "double", "appliedY", ";", "private", "Font", "font", ";", "private", "int", "lineWidth", ";", "private", "double", "xZoom", ";", "private", "double", "yZoom", ";", "protected", "State", "(", ")", "{", "}", "protected", "State", "(", "double", "xZoom", ",", "double", "yZoom", ",", "double", "x", ",", "double", "y", ",", "Font", "font", ",", "int", "lineWidth", ")", "{", "this", ".", "xZoom", "=", "xZoom", ";", "this", ".", "yZoom", "=", "yZoom", ";", "this", ".", "appliedX", "=", "x", ";", "this", ".", "appliedY", "=", "y", ";", "this", ".", "font", "=", "font", ";", "this", ".", "lineWidth", "=", "lineWidth", ";", "}", "protected", "void", "setValues", "(", "double", "xZoom", ",", "double", "yZoom", ",", "double", "x", ",", "double", "y", ",", "Font", "font", ",", "int", "lineWidth", ")", "{", "this", ".", "xZoom", "=", "xZoom", ";", "this", ".", "yZoom", "=", "yZoom", ";", "this", ".", "appliedX", "=", "x", ";", "this", ".", "appliedY", "=", "y", ";", "this", ".", "font", "=", "font", ";", "this", ".", "lineWidth", "=", "lineWidth", ";", "}", "}", "private", "static", "int", "[", "]", "[", "]", "intArrayCache", "=", "new", "int", "[", "8", "]", "[", "]", ";", "private", "final", "Rectangle", "tempRECT", "=", "new", "Rectangle", "(", ")", ";", "static", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "intArrayCache", ".", "length", ";", "i", "++", ")", "{", "intArrayCache", "[", "i", "]", "=", "new", "int", "[", "i", "+", "1", "]", ";", "}", "}", "private", "boolean", "allowText", "=", "true", ";", "private", "Map", "fontCache", "=", "new", "HashMap", "(", ")", ";", "private", "Map", "fontDataCache", "=", "new", "HashMap", "(", ")", ";", "private", "FontKey", "fontKey", "=", "new", "FontKey", "(", ")", ";", "private", "double", "fractionalX", ";", "private", "double", "fractionalY", ";", "private", "Graphics", "graphics", ";", "private", "FontHeightCache", "localCache", "=", "new", "FontHeightCache", "(", ")", ";", "private", "Font", "localFont", ";", "private", "int", "localLineWidth", ";", "private", "List", "stack", "=", "new", "ArrayList", "(", ")", ";", "private", "int", "stackPointer", "=", "0", ";", "private", "FontHeightCache", "targetCache", "=", "new", "FontHeightCache", "(", ")", ";", "double", "xZoom", "=", "1.0", ";", "double", "yZoom", "=", "1.0", ";", "public", "XYScaledGraphics", "(", "Graphics", "g", ")", "{", "super", "(", "g", ")", ";", "graphics", "=", "g", ";", "localFont", "=", "g", ".", "getFont", "(", ")", ";", "localLineWidth", "=", "g", ".", "getLineWidth", "(", ")", ";", "}", "public", "void", "clipRect", "(", "Rectangle", "r", ")", "{", "graphics", ".", "clipRect", "(", "zoomClipRect", "(", "r", ")", ")", ";", "}", "Font", "createFont", "(", "FontData", "data", ")", "{", "return", "new", "Font", "(", "Display", ".", "getCurrent", "(", ")", ",", "data", ")", ";", "}", "public", "void", "dispose", "(", ")", "{", "while", "(", "stackPointer", ">", "0", ")", "{", "popState", "(", ")", ";", "}", "Iterator", "iter", "=", "fontCache", ".", "values", "(", ")", ".", "iterator", "(", ")", ";", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "Font", "font", "=", "(", "(", "Font", ")", "iter", ".", "next", "(", ")", ")", ";", "font", ".", "dispose", "(", ")", ";", "}", "}", "public", "void", "drawArc", "(", "int", "x", ",", "int", "y", ",", "int", "w", ",", "int", "h", ",", "int", "offset", ",", "int", "sweep", ")", "{", "Rectangle", "z", "=", "zoomRect", "(", "x", ",", "y", ",", "w", ",", "h", ")", ";", "if", "(", "z", ".", "isEmpty", "(", ")", "||", "sweep", "==", "0", ")", "{", "return", ";", "}", "graphics", ".", "drawArc", "(", "z", ",", "offset", ",", "sweep", ")", ";", "}", "public", "void", "drawFocus", "(", "int", "x", ",", "int", "y", ",", "int", "w", ",", "int", "h", ")", "{", "graphics", ".", "drawFocus", "(", "zoomRect", "(", "x", ",", "y", ",", "w", ",", "h", ")", ")", ";", "}", "public", "void", "drawImage", "(", "Image", "srcImage", ",", "int", "x", ",", "int", "y", ")", "{", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Rectangle", "size", "=", "srcImage", ".", "getBounds", "(", ")", ";", "double", "imageZoom", "=", "Math", ".", "min", "(", "xZoom", ",", "yZoom", ")", ";", "graphics", ".", "drawImage", "(", "srcImage", ",", "0", ",", "0", ",", "size", ".", "width", ",", "size", ".", "height", ",", "(", "int", ")", "(", "Math", ".", "floor", "(", "(", "x", "*", "xZoom", "+", "fractionalX", ")", ")", ")", ",", "(", "int", ")", "(", "Math", ".", "floor", "(", "(", "y", "*", "yZoom", "+", "fractionalY", ")", ")", ")", ",", "(", "int", ")", "(", "Math", ".", "floor", "(", "(", "size", ".", "width", "*", "imageZoom", "+", "fractionalX", ")", ")", ")", ",", "(", "int", ")", "(", "Math", ".", "floor", "(", "(", "size", ".", "height", "*", "imageZoom", "+", "fractionalY", ")", ")", ")", ")", ";", "}", "public", "void", "drawImage", "(", "Image", "srcImage", ",", "int", "sx", ",", "int", "sy", ",", "int", "sw", ",", "int", "sh", ",", "int", "tx", ",", "int", "ty", ",", "int", "tw", ",", "int", "th", ")", "{", "Rectangle", "t", "=", "zoomRect", "(", "tx", ",", "ty", ",", "tw", ",", "th", ")", ";", "if", "(", "!", "t", ".", "isEmpty", "(", ")", ")", "{", "graphics", ".", "drawImage", "(", "srcImage", ",", "sx", ",", "sy", ",", "sw", ",", "sh", ",", "t", ".", "x", ",", "t", ".", "y", ",", "t", ".", "width", ",", "t", ".", "height", ")", ";", "}", "}", "public", "void", "drawLine", "(", "int", "x1", ",", "int", "y1", ",", "int", "x2", ",", "int", "y2", ")", "{", "graphics", ".", "drawLine", "(", "(", "int", ")", "(", "Math", ".", "floor", "(", "(", "x1", "*", "xZoom", "+", "fractionalX", ")", ")", ")", ",", "(", "int", ")", "(", "Math", ".", "floor", "(", "(", "y1", "*", "yZoom", "+", "fractionalY", ")", ")", ")", ",", "(", "int", ")", "(", "Math", ".", "floor", "(", "(", "x2", "*", "xZoom", "+", "fractionalX", ")", ")", ")", ",", "(", "int", ")", "(", "Math", ".", "floor", "(", "(", "y2", "*", "yZoom", "+", "fractionalY", ")", ")", ")", ")", ";", "}", "public", "void", "drawOval", "(", "int", "x", ",", "int", "y", ",", "int", "w", ",", "int", "h", ")", "{", "graphics", ".", "drawOval", "(", "zoomRect", "(", "x", ",", "y", ",", "w", ",", "h", ")", ")", ";", "}", "public", "void", "drawPoint", "(", "int", "x", ",", "int", "y", ")", "{", "graphics", ".", "drawPoint", "(", "(", "int", ")", "Math", ".", "floor", "(", "x", "*", "xZoom", "+", "fractionalX", ")", ",", "(", "int", ")", "Math", ".", "floor", "(", "y", "*", "yZoom", "+", "fractionalY", ")", ")", ";", "}", "public", "void", "drawPolygon", "(", "int", "[", "]", "points", ")", "{", "graphics", ".", "drawPolygon", "(", "zoomPointList", "(", "points", ")", ")", ";", "}", "public", "void", "drawPolygon", "(", "PointList", "points", ")", "{", "graphics", ".", "drawPolygon", "(", "zoomPointList", "(", "points", ".", "toIntArray", "(", ")", ")", ")", ";", "}", "public", "void", "drawPolyline", "(", "int", "[", "]", "points", ")", "{", "graphics", ".", "drawPolyline", "(", "zoomPointList", "(", "points", ")", ")", ";", "}", "public", "void", "drawPolyline", "(", "PointList", "points", ")", "{", "graphics", ".", "drawPolyline", "(", "zoomPointList", "(", "points", ".", "toIntArray", "(", ")", ")", ")", ";", "}", "public", "void", "drawRectangle", "(", "int", "x", ",", "int", "y", ",", "int", "w", ",", "int", "h", ")", "{", "graphics", ".", "drawRectangle", "(", "zoomRect", "(", "x", ",", "y", ",", "w", ",", "h", ")", ")", ";", "}", "public", "void", "drawRoundRectangle", "(", "Rectangle", "r", ",", "int", "arcWidth", ",", "int", "arcHeight", ")", "{", "graphics", ".", "drawRoundRectangle", "(", "zoomRect", "(", "r", ".", "x", ",", "r", ".", "y", ",", "r", ".", "width", ",", "r", ".", "height", ")", ",", "(", "int", ")", "(", "arcWidth", "*", "xZoom", ")", ",", "(", "int", ")", "(", "arcHeight", "*", "yZoom", ")", ")", ";", "}", "public", "void", "drawString", "(", "String", "s", ",", "int", "x", ",", "int", "y", ")", "{", "if", "(", "allowText", ")", "{", "graphics", ".", "drawString", "(", "s", ",", "zoomTextPoint", "(", "x", ",", "y", ")", ")", ";", "}", "}", "public", "void", "drawText", "(", "String", "s", ",", "int", "x", ",", "int", "y", ")", "{", "if", "(", "allowText", ")", "{", "graphics", ".", "drawText", "(", "s", ",", "zoomTextPoint", "(", "x", ",", "y", ")", ")", ";", "}", "}", "public", "void", "drawText", "(", "String", "s", ",", "int", "x", ",", "int", "y", ",", "int", "style", ")", "{", "if", "(", "allowText", ")", "{", "graphics", ".", "drawText", "(", "s", ",", "zoomTextPoint", "(", "x", ",", "y", ")", ",", "style", ")", ";", "}", "}", "public", "void", "drawTextLayout", "(", "TextLayout", "layout", ",", "int", "x", ",", "int", "y", ",", "int", "selectionStart", ",", "int", "selectionEnd", ",", "Color", "selectionForeground", ",", "Color", "selectionBackground", ")", "{", "TextLayout", "scaled", "=", "zoomTextLayout", "(", "layout", ")", ";", "graphics", ".", "drawTextLayout", "(", "scaled", ",", "(", "int", ")", "Math", ".", "floor", "(", "x", "*", "xZoom", "+", "fractionalX", ")", ",", "(", "int", ")", "Math", ".", "floor", "(", "y", "*", "yZoom", "+", "fractionalY", ")", ",", "selectionStart", ",", "selectionEnd", ",", "selectionBackground", ",", "selectionForeground", ")", ";", "scaled", ".", "dispose", "(", ")", ";", "}", "public", "void", "fillArc", "(", "int", "x", ",", "int", "y", ",", "int", "w", ",", "int", "h", ",", "int", "offset", ",", "int", "sweep", ")", "{", "Rectangle", "z", "=", "zoomFillRect", "(", "x", ",", "y", ",", "w", ",", "h", ")", ";", "if", "(", "z", ".", "isEmpty", "(", ")", "||", "sweep", "==", "0", ")", "{", "return", ";", "}", "graphics", ".", "fillArc", "(", "z", ",", "offset", ",", "sweep", ")", ";", "}", "public", "void", "fillGradient", "(", "int", "x", ",", "int", "y", ",", "int", "w", ",", "int", "h", ",", "boolean", "vertical", ")", "{", "graphics", ".", "fillGradient", "(", "zoomFillRect", "(", "x", ",", "y", ",", "w", ",", "h", ")", ",", "vertical", ")", ";", "}", "public", "void", "fillOval", "(", "int", "x", ",", "int", "y", ",", "int", "w", ",", "int", "h", ")", "{", "graphics", ".", "fillOval", "(", "zoomFillRect", "(", "x", ",", "y", ",", "w", ",", "h", ")", ")", ";", "}", "public", "void", "fillPolygon", "(", "int", "[", "]", "points", ")", "{", "graphics", ".", "fillPolygon", "(", "zoomPointList", "(", "points", ")", ")", ";", "}", "public", "void", "fillPolygon", "(", "PointList", "points", ")", "{", "graphics", ".", "fillPolygon", "(", "zoomPointList", "(", "points", ".", "toIntArray", "(", ")", ")", ")", ";", "}", "public", "void", "fillRectangle", "(", "int", "x", ",", "int", "y", ",", "int", "w", ",", "int", "h", ")", "{", "graphics", ".", "fillRectangle", "(", "zoomFillRect", "(", "x", ",", "y", ",", "w", ",", "h", ")", ")", ";", "}", "public", "void", "fillRoundRectangle", "(", "Rectangle", "r", ",", "int", "arcWidth", ",", "int", "arcHeight", ")", "{", "graphics", ".", "fillRoundRectangle", "(", "zoomFillRect", "(", "r", ".", "x", ",", "r", ".", "y", ",", "r", ".", "width", ",", "r", ".", "height", ")", ",", "(", "int", ")", "(", "arcWidth", "*", "xZoom", ")", ",", "(", "int", ")", "(", "arcHeight", "*", "yZoom", ")", ")", ";", "}", "public", "void", "fillString", "(", "String", "s", ",", "int", "x", ",", "int", "y", ")", "{", "if", "(", "allowText", ")", "{", "graphics", ".", "fillString", "(", "s", ",", "zoomTextPoint", "(", "x", ",", "y", ")", ")", ";", "}", "}", "public", "void", "fillText", "(", "String", "s", ",", "int", "x", ",", "int", "y", ")", "{", "if", "(", "allowText", ")", "{", "graphics", ".", "fillText", "(", "s", ",", "zoomTextPoint", "(", "x", ",", "y", ")", ")", ";", "}", "}", "public", "double", "getAbsoluteScale", "(", ")", "{", "return", "xZoom", "*", "graphics", ".", "getAbsoluteScale", "(", ")", ";", "}", "public", "int", "getAlpha", "(", ")", "{", "return", "graphics", ".", "getAlpha", "(", ")", ";", "}", "public", "int", "getAntialias", "(", ")", "{", "return", "graphics", ".", "getAntialias", "(", ")", ";", "}", "public", "Color", "getBackgroundColor", "(", ")", "{", "return", "graphics", ".", "getBackgroundColor", "(", ")", ";", "}", "Font", "getCachedFont", "(", "FontKey", "key", ")", "{", "Font", "font", "=", "(", "Font", ")", "fontCache", ".", "get", "(", "key", ")", ";", "if", "(", "font", "!=", "null", ")", "{", "return", "font", ";", "}", "key", "=", "new", "FontKey", "(", "key", ".", "font", ",", "key", ".", "height", ")", ";", "FontData", "data", "=", "key", ".", "font", ".", "getFontData", "(", ")", "[", "0", "]", ";", "data", ".", "setHeight", "(", "key", ".", "height", ")", ";", "Font", "zoomedFont", "=", "createFont", "(", "data", ")", ";", "fontCache", ".", "put", "(", "key", ",", "zoomedFont", ")", ";", "return", "zoomedFont", ";", "}", "FontData", "getCachedFontData", "(", "Font", "f", ")", "{", "FontData", "data", "=", "(", "FontData", ")", "fontDataCache", ".", "get", "(", "f", ")", ";", "if", "(", "data", "!=", "null", ")", "{", "return", "data", ";", "}", "data", "=", "getLocalFont", "(", ")", ".", "getFontData", "(", ")", "[", "0", "]", ";", "fontDataCache", ".", "put", "(", "f", ",", "data", ")", ";", "return", "data", ";", "}", "public", "Rectangle", "getClip", "(", "Rectangle", "rect", ")", "{", "graphics", ".", "getClip", "(", "rect", ")", ";", "int", "x", "=", "(", "int", ")", "(", "rect", ".", "x", "/", "xZoom", ")", ";", "int", "y", "=", "(", "int", ")", "(", "rect", ".", "y", "/", "yZoom", ")", ";", "rect", ".", "width", "=", "(", "int", ")", "Math", ".", "ceil", "(", "rect", ".", "right", "(", ")", "/", "xZoom", ")", "-", "x", ";", "rect", ".", "height", "=", "(", "int", ")", "Math", ".", "ceil", "(", "rect", ".", "bottom", "(", ")", "/", "yZoom", ")", "-", "y", ";", "rect", ".", "x", "=", "x", ";", "rect", ".", "y", "=", "y", ";", "return", "rect", ";", "}", "public", "int", "getFillRule", "(", ")", "{", "return", "graphics", ".", "getFillRule", "(", ")", ";", "}", "public", "Font", "getFont", "(", ")", "{", "return", "getLocalFont", "(", ")", ";", "}", "public", "FontMetrics", "getFontMetrics", "(", ")", "{", "return", "FigureUtilities", ".", "getFontMetrics", "(", "localFont", ")", ";", "}", "public", "Color", "getForegroundColor", "(", ")", "{", "return", "graphics", ".", "getForegroundColor", "(", ")", ";", "}", "public", "int", "getInterpolation", "(", ")", "{", "return", "graphics", ".", "getInterpolation", "(", ")", ";", "}", "public", "int", "getLineCap", "(", ")", "{", "return", "graphics", ".", "getLineCap", "(", ")", ";", "}", "public", "int", "getLineJoin", "(", ")", "{", "return", "graphics", ".", "getLineJoin", "(", ")", ";", "}", "public", "int", "getLineStyle", "(", ")", "{", "return", "graphics", ".", "getLineStyle", "(", ")", ";", "}", "public", "int", "getLineWidth", "(", ")", "{", "return", "getLocalLineWidth", "(", ")", ";", "}", "private", "Font", "getLocalFont", "(", ")", "{", "return", "localFont", ";", "}", "private", "int", "getLocalLineWidth", "(", ")", "{", "return", "localLineWidth", ";", "}", "public", "int", "getTextAntialias", "(", ")", "{", "return", "graphics", ".", "getTextAntialias", "(", ")", ";", "}", "public", "boolean", "getXORMode", "(", ")", "{", "return", "graphics", ".", "getXORMode", "(", ")", ";", "}", "public", "void", "popState", "(", ")", "{", "graphics", ".", "popState", "(", ")", ";", "stackPointer", "--", ";", "restoreLocalState", "(", "(", "State", ")", "stack", ".", "get", "(", "stackPointer", ")", ")", ";", "}", "public", "void", "pushState", "(", ")", "{", "State", "s", ";", "if", "(", "stack", ".", "size", "(", ")", ">", "stackPointer", ")", "{", "s", "=", "(", "State", ")", "stack", ".", "get", "(", "stackPointer", ")", ";", "s", ".", "setValues", "(", "xZoom", ",", "yZoom", ",", "fractionalX", ",", "fractionalY", ",", "getLocalFont", "(", ")", ",", "localLineWidth", ")", ";", "}", "else", "{", "stack", ".", "add", "(", "new", "State", "(", "xZoom", ",", "yZoom", ",", "fractionalX", ",", "fractionalY", ",", "getLocalFont", "(", ")", ",", "localLineWidth", ")", ")", ";", "}", "stackPointer", "++", ";", "graphics", ".", "pushState", "(", ")", ";", "}", "private", "void", "restoreLocalState", "(", "State", "state", ")", "{", "this", ".", "fractionalX", "=", "state", ".", "appliedX", ";", "this", ".", "fractionalY", "=", "state", ".", "appliedY", ";", "setScale", "(", "state", ".", "xZoom", ",", "state", ".", "yZoom", ")", ";", "setLocalFont", "(", "state", ".", "font", ")", ";", "setLocalLineWidth", "(", "state", ".", "lineWidth", ")", ";", "}", "public", "void", "restoreState", "(", ")", "{", "graphics", ".", "restoreState", "(", ")", ";", "restoreLocalState", "(", "(", "State", ")", "stack", ".", "get", "(", "stackPointer", "-", "1", ")", ")", ";", "}", "public", "void", "scale", "(", "double", "xAmount", ",", "double", "yAmount", ")", "{", "setScale", "(", "xZoom", "*", "xAmount", ",", "yZoom", "*", "yAmount", ")", ";", "}", "public", "void", "scale", "(", "double", "amount", ")", "{", "throw", "new", "RuntimeException", "(", "\"\"", ")", ";", "}", "public", "void", "setAlpha", "(", "int", "alpha", ")", "{", "graphics", ".", "setAlpha", "(", "alpha", ")", ";", "}", "public", "void", "setAntialias", "(", "int", "value", ")", "{", "graphics", ".", "setAntialias", "(", "value", ")", ";", "}", "public", "void", "setBackgroundColor", "(", "Color", "rgb", ")", "{", "graphics", ".", "setBackgroundColor", "(", "rgb", ")", ";", "}", "public", "void", "setClip", "(", "Rectangle", "r", ")", "{", "graphics", ".", "setClip", "(", "zoomClipRect", "(", "r", ")", ")", ";", "}", "public", "void", "setFillRule", "(", "int", "rule", ")", "{", "graphics", ".", "setFillRule", "(", "rule", ")", ";", "}", "public", "void", "setFont", "(", "Font", "f", ")", "{", "setLocalFont", "(", "f", ")", ";", "}", "public", "void", "setForegroundColor", "(", "Color", "rgb", ")", "{", "graphics", ".", "setForegroundColor", "(", "rgb", ")", ";", "}", "public", "void", "setInterpolation", "(", "int", "interpolation", ")", "{", "graphics", ".", "setInterpolation", "(", "interpolation", ")", ";", "}", "public", "void", "setLineCap", "(", "int", "cap", ")", "{", "graphics", ".", "setLineCap", "(", "cap", ")", ";", "}", "public", "void", "setLineDash", "(", "int", "[", "]", "dash", ")", "{", "graphics", ".", "setLineDash", "(", "dash", ")", ";", "}", "public", "void", "setLineJoin", "(", "int", "join", ")", "{", "graphics", ".", "setLineJoin", "(", "join", ")", ";", "}", "public", "void", "setLineStyle", "(", "int", "style", ")", "{", "graphics", ".", "setLineStyle", "(", "style", ")", ";", "}", "public", "void", "setLineWidth", "(", "int", "width", ")", "{", "setLocalLineWidth", "(", "width", ")", ";", "}", "private", "void", "setLocalFont", "(", "Font", "f", ")", "{", "localFont", "=", "f", ";", "graphics", ".", "setFont", "(", "zoomFont", "(", "f", ")", ")", ";", "}", "private", "void", "setLocalLineWidth", "(", "int", "width", ")", "{", "localLineWidth", "=", "width", ";", "graphics", ".", "setLineWidth", "(", "zoomLineWidth", "(", "width", ")", ")", ";", "}", "public", "void", "setScale", "(", "double", "xValue", ",", "double", "yValue", ")", "{", "if", "(", "xValue", "==", "xZoom", "&&", "yValue", "==", "yZoom", ")", "{", "return", ";", "}", "this", ".", "xZoom", "=", "xValue", ";", "this", ".", "yZoom", "=", "yValue", ";", "graphics", ".", "setFont", "(", "zoomFont", "(", "getLocalFont", "(", ")", ")", ")", ";", "graphics", ".", "setLineWidth", "(", "zoomLineWidth", "(", "localLineWidth", ")", ")", ";", "}", "void", "setScale", "(", "double", "value", ")", "{", "throw", "new", "RuntimeException", "(", "\"\"", ")", ";", "}", "public", "void", "setTextAntialias", "(", "int", "value", ")", "{", "graphics", ".", "setTextAntialias", "(", "value", ")", ";", "}", "public", "void", "setXORMode", "(", "boolean", "b", ")", "{", "graphics", ".", "setXORMode", "(", "b", ")", ";", "}", "public", "void", "translate", "(", "int", "dx", ",", "int", "dy", ")", "{", "double", "dxFloat", "=", "dx", "*", "xZoom", "+", "fractionalX", ";", "double", "dyFloat", "=", "dy", "*", "yZoom", "+", "fractionalY", ";", "fractionalX", "=", "dxFloat", "-", "Math", ".", "floor", "(", "dxFloat", ")", ";", "fractionalY", "=", "dyFloat", "-", "Math", ".", "floor", "(", "dyFloat", ")", ";", "graphics", ".", "translate", "(", "(", "int", ")", "Math", ".", "floor", "(", "dxFloat", ")", ",", "(", "int", ")", "Math", ".", "floor", "(", "dyFloat", ")", ")", ";", "}", "private", "Rectangle", "zoomClipRect", "(", "Rectangle", "r", ")", "{", "tempRECT", ".", "x", "=", "(", "int", ")", "(", "Math", ".", "floor", "(", "r", ".", "x", "*", "xZoom", "+", "fractionalX", ")", ")", ";", "tempRECT", ".", "y", "=", "(", "int", ")", "(", "Math", ".", "floor", "(", "r", ".", "y", "*", "yZoom", "+", "fractionalY", ")", ")", ";", "tempRECT", ".", "width", "=", "(", "int", ")", "(", "Math", ".", "ceil", "(", "(", "(", "r", ".", "x", "+", "r", ".", "width", ")", "*", "xZoom", "+", "fractionalX", ")", ")", ")", "-", "tempRECT", ".", "x", ";", "tempRECT", ".", "height", "=", "(", "int", ")", "(", "Math", ".", "ceil", "(", "(", "(", "r", ".", "y", "+", "r", ".", "height", ")", "*", "yZoom", "+", "fractionalY", ")", ")", ")", "-", "tempRECT", ".", "y", ";", "return", "tempRECT", ";", "}", "private", "Rectangle", "zoomFillRect", "(", "int", "x", ",", "int", "y", ",", "int", "w", ",", "int", "h", ")", "{", "tempRECT", ".", "x", "=", "(", "int", ")", "(", "Math", ".", "floor", "(", "(", "x", "*", "xZoom", "+", "fractionalX", ")", ")", ")", ";", "tempRECT", ".", "y", "=", "(", "int", ")", "(", "Math", ".", "floor", "(", "(", "y", "*", "yZoom", "+", "fractionalY", ")", ")", ")", ";", "tempRECT", ".", "width", "=", "(", "int", ")", "(", "Math", ".", "floor", "(", "(", "(", "x", "+", "w", "-", "1", ")", "*", "xZoom", "+", "fractionalX", ")", ")", ")", "-", "tempRECT", ".", "x", "+", "1", ";", "tempRECT", ".", "height", "=", "(", "int", ")", "(", "Math", ".", "floor", "(", "(", "(", "y", "+", "h", "-", "1", ")", "*", "yZoom", "+", "fractionalY", ")", ")", ")", "-", "tempRECT", ".", "y", "+", "1", ";", "return", "tempRECT", ";", "}", "Font", "zoomFont", "(", "Font", "f", ")", "{", "if", "(", "f", "==", "null", ")", "{", "f", "=", "Display", ".", "getCurrent", "(", ")", ".", "getSystemFont", "(", ")", ";", "}", "FontData", "data", "=", "getCachedFontData", "(", "f", ")", ";", "int", "zoomedFontHeight", "=", "zoomFontHeight", "(", "data", ".", "getHeight", "(", ")", ")", ";", "allowText", "=", "zoomedFontHeight", ">", "0", ";", "fontKey", ".", "setValues", "(", "f", ",", "zoomedFontHeight", ")", ";", "return", "getCachedFont", "(", "fontKey", ")", ";", "}", "int", "zoomFontHeight", "(", "int", "height", ")", "{", "double", "tmp", "=", "Math", ".", "min", "(", "yZoom", ",", "xZoom", ")", ";", "if", "(", "tmp", "<", "MAX_TEXT_SIZE", ")", "{", "return", "(", "int", ")", "(", "tmp", "*", "height", ")", ";", "}", "else", "{", "return", "(", "int", ")", "(", "height", "*", "tmp", ")", ";", "}", "}", "int", "zoomLineWidth", "(", "int", "w", ")", "{", "return", "w", ";", "}", "private", "int", "[", "]", "zoomPointList", "(", "int", "[", "]", "points", ")", "{", "int", "[", "]", "scaled", "=", "null", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "intArrayCache", ".", "length", ";", "i", "++", ")", "{", "if", "(", "intArrayCache", "[", "i", "]", ".", "length", "==", "points", ".", "length", ")", "{", "scaled", "=", "intArrayCache", "[", "i", "]", ";", "if", "(", "i", "!=", "0", ")", "{", "int", "[", "]", "temp", "=", "intArrayCache", "[", "i", "-", "1", "]", ";", "intArrayCache", "[", "i", "-", "1", "]", "=", "scaled", ";", "intArrayCache", "[", "i", "]", "=", "temp", ";", "}", "}", "}", "if", "(", "scaled", "==", "null", ")", "{", "intArrayCache", "[", "intArrayCache", ".", "length", "-", "1", "]", "=", "new", "int", "[", "points", ".", "length", "]", ";", "scaled", "=", "intArrayCache", "[", "intArrayCache", ".", "length", "-", "1", "]", ";", "}", "for", "(", "int", "i", "=", "0", ";", "(", "i", "+", "1", ")", "<", "points", ".", "length", ";", "i", "+=", "2", ")", "{", "scaled", "[", "i", "]", "=", "(", "int", ")", "(", "Math", ".", "floor", "(", "(", "points", "[", "i", "]", "*", "xZoom", "+", "fractionalX", ")", ")", ")", ";", "scaled", "[", "i", "+", "1", "]", "=", "(", "int", ")", "(", "Math", ".", "floor", "(", "(", "points", "[", "i", "+", "1", "]", "*", "yZoom", "+", "fractionalY", ")", ")", ")", ";", "}", "return", "scaled", ";", "}", "private", "Rectangle", "zoomRect", "(", "int", "x", ",", "int", "y", ",", "int", "w", ",", "int", "h", ")", "{", "tempRECT", ".", "x", "=", "(", "int", ")", "(", "Math", ".", "floor", "(", "x", "*", "xZoom", "+", "fractionalX", ")", ")", ";", "tempRECT", ".", "y", "=", "(", "int", ")", "(", "Math", ".", "floor", "(", "y", "*", "yZoom", "+", "fractionalY", ")", ")", ";", "tempRECT", ".", "width", "=", "(", "int", ")", "(", "Math", ".", "floor", "(", "(", "(", "x", "+", "w", ")", "*", "xZoom", "+", "fractionalX", ")", ")", ")", "-", "tempRECT", ".", "x", ";", "tempRECT", ".", "height", "=", "(", "int", ")", "(", "Math", ".", "floor", "(", "(", "(", "y", "+", "h", ")", "*", "yZoom", "+", "fractionalY", ")", ")", ")", "-", "tempRECT", ".", "y", ";", "return", "tempRECT", ";", "}", "private", "TextLayout", "zoomTextLayout", "(", "TextLayout", "layout", ")", "{", "TextLayout", "zoomed", "=", "new", "TextLayout", "(", "Display", ".", "getCurrent", "(", ")", ")", ";", "zoomed", ".", "setText", "(", "layout", ".", "getText", "(", ")", ")", ";", "int", "zoomWidth", "=", "-", "1", ";", "if", "(", "layout", ".", "getWidth", "(", ")", "!=", "-", "1", ")", "{", "zoomWidth", "=", "(", "(", "int", ")", "(", "layout", ".", "getWidth", "(", ")", "*", "xZoom", ")", ")", ";", "}", "if", "(", "zoomWidth", "<", "-", "1", "||", "zoomWidth", "==", "0", ")", "{", "return", "null", ";", "}", "zoomed", ".", "setFont", "(", "zoomFont", "(", "layout", ".", "getFont", "(", ")", ")", ")", ";", "zoomed", ".", "setAlignment", "(", "layout", ".", "getAlignment", "(", ")", ")", ";", "zoomed", ".", "setAscent", "(", "layout", ".", "getAscent", "(", ")", ")", ";", "zoomed", ".", "setDescent", "(", "layout", ".", "getDescent", "(", ")", ")", ";", "zoomed", ".", "setOrientation", "(", "layout", ".", "getOrientation", "(", ")", ")", ";", "zoomed", ".", "setSegments", "(", "layout", ".", "getSegments", "(", ")", ")", ";", "zoomed", ".", "setSpacing", "(", "layout", ".", "getSpacing", "(", ")", ")", ";", "zoomed", ".", "setTabs", "(", "layout", ".", "getTabs", "(", ")", ")", ";", "zoomed", ".", "setWidth", "(", "zoomWidth", ")", ";", "int", "length", "=", "layout", ".", "getText", "(", ")", ".", "length", "(", ")", ";", "if", "(", "length", ">", "0", ")", "{", "int", "start", "=", "0", ",", "offset", "=", "1", ";", "TextStyle", "style", "=", "null", ",", "lastStyle", "=", "layout", ".", "getStyle", "(", "0", ")", ";", "for", "(", ";", "offset", "<=", "length", ";", "offset", "++", ")", "{", "if", "(", "offset", "!=", "length", "&&", "(", "style", "=", "layout", ".", "getStyle", "(", "offset", ")", ")", "==", "lastStyle", ")", "{", "continue", ";", "}", "int", "end", "=", "offset", "-", "1", ";", "if", "(", "lastStyle", "!=", "null", ")", "{", "TextStyle", "zoomedStyle", "=", "new", "TextStyle", "(", "zoomFont", "(", "lastStyle", ".", "font", ")", ",", "lastStyle", ".", "foreground", ",", "lastStyle", ".", "background", ")", ";", "zoomed", ".", "setStyle", "(", "zoomedStyle", ",", "start", ",", "end", ")", ";", "}", "lastStyle", "=", "style", ";", "start", "=", "offset", ";", "}", "}", "return", "zoomed", ";", "}", "private", "Point", "zoomTextPoint", "(", "int", "x", ",", "int", "y", ")", "{", "if", "(", "localCache", ".", "font", "!=", "localFont", ")", "{", "FontMetrics", "metric", "=", "FigureUtilities", ".", "getFontMetrics", "(", "localFont", ")", ";", "localCache", ".", "height", "=", "metric", ".", "getHeight", "(", ")", "-", "metric", ".", "getDescent", "(", ")", ";", "localCache", ".", "font", "=", "localFont", ";", "}", "if", "(", "targetCache", ".", "font", "!=", "graphics", ".", "getFont", "(", ")", ")", "{", "FontMetrics", "metric", "=", "graphics", ".", "getFontMetrics", "(", ")", ";", "targetCache", ".", "font", "=", "graphics", ".", "getFont", "(", ")", ";", "targetCache", ".", "height", "=", "metric", ".", "getHeight", "(", ")", "-", "metric", ".", "getDescent", "(", ")", ";", "}", "return", "new", "Point", "(", "(", "(", "int", ")", "(", "Math", ".", "floor", "(", "(", "x", "*", "xZoom", ")", "+", "fractionalX", ")", ")", ")", ",", "(", "int", ")", "(", "Math", ".", "floor", "(", "(", "y", "+", "localCache", ".", "height", "-", "1", ")", "*", "yZoom", "-", "targetCache", ".", "height", "+", "1", "+", "fractionalY", ")", ")", ")", ";", "}", "}", "</s>" ]
10,263
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "internal", ";", "public", "class", "SharedMessages", "{", "public", "static", "String", "FitAllAction_Label", "=", "\"Page\"", ";", "public", "static", "String", "FitWidthAction_Label", "=", "\"Width\"", ";", "public", "static", "String", "FitHeightAction_Label", "=", "\"Height\"", ";", "}", "</s>" ]
10,264
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "internal", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ChopboxAnchor", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "IFigure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Point", ";", "public", "class", "LoopAnchor", "extends", "ChopboxAnchor", "{", "public", "LoopAnchor", "(", "IFigure", "owner", ")", "{", "super", "(", "owner", ")", ";", "}", "public", "Point", "getReferencePoint", "(", ")", "{", "if", "(", "getOwner", "(", ")", "==", "null", ")", "{", "return", "null", ";", "}", "else", "{", "Point", "ref", "=", "getOwner", "(", ")", ".", "getBounds", "(", ")", ".", "getCenter", "(", ")", ";", "ref", ".", "y", "=", "getOwner", "(", ")", ".", "getBounds", "(", ")", ".", "y", ";", "getOwner", "(", ")", ".", "translateToAbsolute", "(", "ref", ")", ";", "return", "ref", ";", "}", "}", "}", "</s>" ]
10,265
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "gestures", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Point", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Transform", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "GestureEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "GestureListener", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "Graph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphNode", ";", "public", "class", "RotateGestureListener", "implements", "GestureListener", "{", "Graph", "graph", ";", "double", "rotate", ";", "List", "nodes", ";", "List", "originalLocations", ";", "double", "xCenter", ",", "yCenter", ";", "void", "storePosition", "(", "List", "nodes", ")", "{", "originalLocations", "=", "new", "ArrayList", "(", ")", ";", "Iterator", "it", "=", "nodes", ".", "iterator", "(", ")", ";", "Transform", "t", "=", "new", "Transform", "(", ")", ";", "t", ".", "setTranslation", "(", "-", "xCenter", ",", "-", "yCenter", ")", ";", "while", "(", "it", ".", "hasNext", "(", ")", ")", "{", "GraphNode", "node", "=", "(", "GraphNode", ")", "it", ".", "next", "(", ")", ";", "originalLocations", ".", "add", "(", "t", ".", "getTransformed", "(", "node", ".", "getLocation", "(", ")", ")", ")", ";", "}", "}", "void", "updatePositions", "(", "double", "rotation", ")", "{", "Transform", "t", "=", "new", "Transform", "(", ")", ";", "t", ".", "setRotation", "(", "rotation", ")", ";", "t", ".", "setTranslation", "(", "xCenter", ",", "yCenter", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "nodes", ".", "size", "(", ")", ";", "i", "++", ")", "{", "GraphNode", "node", "=", "(", "GraphNode", ")", "nodes", ".", "get", "(", "i", ")", ";", "Point", "p", "=", "(", "Point", ")", "originalLocations", ".", "get", "(", "i", ")", ";", "Point", "rot", "=", "t", ".", "getTransformed", "(", "p", ")", ";", "node", ".", "setLocation", "(", "rot", ".", "preciseX", "(", ")", ",", "rot", ".", "preciseY", "(", ")", ")", ";", "}", "}", "public", "void", "gesture", "(", "GestureEvent", "e", ")", "{", "if", "(", "!", "(", "e", ".", "widget", "instanceof", "Graph", ")", ")", "{", "return", ";", "}", "switch", "(", "e", ".", "detail", ")", "{", "case", "SWT", ".", "GESTURE_BEGIN", ":", "graph", "=", "(", "Graph", ")", "e", ".", "widget", ";", "rotate", "=", "0.0", ";", "nodes", "=", "graph", ".", "getSelection", "(", ")", ";", "if", "(", "nodes", ".", "isEmpty", "(", ")", ")", "{", "nodes", "=", "graph", ".", "getNodes", "(", ")", ";", "}", "xCenter", "=", "0", ";", "yCenter", "=", "0", ";", "Iterator", "it", "=", "nodes", ".", "iterator", "(", ")", ";", "while", "(", "it", ".", "hasNext", "(", ")", ")", "{", "GraphNode", "node", "=", "(", "GraphNode", ")", "it", ".", "next", "(", ")", ";", "Point", "location", "=", "node", ".", "getLocation", "(", ")", ";", "xCenter", "+=", "location", ".", "preciseX", "(", ")", ";", "yCenter", "+=", "location", ".", "preciseY", "(", ")", ";", "}", "xCenter", "=", "xCenter", "/", "nodes", ".", "size", "(", ")", ";", "yCenter", "=", "yCenter", "/", "nodes", ".", "size", "(", ")", ";", "storePosition", "(", "nodes", ")", ";", "break", ";", "case", "SWT", ".", "GESTURE_END", ":", "break", ";", "case", "SWT", ".", "GESTURE_ROTATE", ":", "updatePositions", "(", "e", ".", "rotation", "/", "2", "/", "Math", ".", "PI", ")", ";", "break", ";", "default", ":", "}", "}", "}", "</s>" ]
10,266
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "gestures", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "GestureEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "GestureListener", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "Graph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "zooming", ".", "ZoomManager", ";", "public", "class", "ZoomGestureListener", "implements", "GestureListener", "{", "ZoomManager", "manager", ";", "double", "zoom", "=", "1.0", ";", "public", "void", "gesture", "(", "GestureEvent", "e", ")", "{", "if", "(", "!", "(", "e", ".", "widget", "instanceof", "Graph", ")", ")", "{", "return", ";", "}", "switch", "(", "e", ".", "detail", ")", "{", "case", "SWT", ".", "GESTURE_BEGIN", ":", "manager", "=", "(", "(", "Graph", ")", "e", ".", "widget", ")", ".", "getZoomManager", "(", ")", ";", "zoom", "=", "manager", ".", "getZoom", "(", ")", ";", "break", ";", "case", "SWT", ".", "GESTURE_END", ":", "break", ";", "case", "SWT", ".", "GESTURE_MAGNIFY", ":", "double", "newValue", "=", "zoom", "*", "e", ".", "magnification", ";", "manager", ".", "setZoom", "(", "newValue", ")", ";", "break", ";", "default", ":", "}", "}", "}", "</s>" ]
10,267
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "IFigure", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Item", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Widget", ";", "public", "abstract", "class", "GraphItem", "extends", "Item", "{", "public", "static", "final", "int", "GRAPH", "=", "0", ";", "public", "static", "final", "int", "NODE", "=", "1", ";", "public", "static", "final", "int", "CONNECTION", "=", "2", ";", "public", "static", "final", "int", "CONTAINER", "=", "3", ";", "public", "GraphItem", "(", "Widget", "parent", ",", "int", "style", ")", "{", "super", "(", "parent", ",", "style", "|", "SWT", ".", "NO_BACKGROUND", ")", ";", "}", "public", "GraphItem", "(", "Widget", "parent", ",", "int", "style", ",", "Object", "data", ")", "{", "this", "(", "parent", ",", "style", "|", "SWT", ".", "NO_BACKGROUND", ")", ";", "setDataChecked", "(", "data", ")", ";", "}", "protected", "GraphItem", "(", "IContainer", "parent", ",", "int", "style", ",", "Object", "data", ")", "{", "this", "(", "parent", ".", "getGraph", "(", ")", ",", "style", "|", "SWT", ".", "NO_BACKGROUND", ")", ";", "setDataChecked", "(", "data", ")", ";", "}", "private", "void", "setDataChecked", "(", "Object", "data", ")", "{", "if", "(", "data", "!=", "null", ")", "{", "this", ".", "setData", "(", "data", ")", ";", "}", "}", "public", "void", "dispose", "(", ")", "{", "super", ".", "dispose", "(", ")", ";", "}", "public", "abstract", "int", "getItemType", "(", ")", ";", "public", "abstract", "void", "setVisible", "(", "boolean", "visible", ")", ";", "public", "abstract", "boolean", "isVisible", "(", ")", ";", "public", "abstract", "Graph", "getGraphModel", "(", ")", ";", "public", "abstract", "void", "highlight", "(", ")", ";", "public", "abstract", "void", "unhighlight", "(", ")", ";", "abstract", "IFigure", "getFigure", "(", ")", ";", "protected", "boolean", "checkStyle", "(", "int", "styleToCheck", ")", "{", "return", "(", "(", "getStyle", "(", ")", "&", "styleToCheck", ")", ">", "0", ")", ";", "}", "}", "</s>" ]
10,268
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ChopboxAnchor", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ColorConstants", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Connection", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ConnectionRouter", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Graphics", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "IFigure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Label", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Locator", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "MidpointLocator", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "PolygonDecoration", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "PolylineConnection", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Shape", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Point", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Color", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Font", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "internal", ".", "LoopAnchor", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "internal", ".", "PolylineArcConnection", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "internal", ".", "RoundedChopboxAnchor", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "internal", ".", "ZestRootLayer", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "ConnectionLayout", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "NodeLayout", ";", "public", "class", "GraphConnection", "extends", "GraphItem", "{", "private", "Font", "font", ";", "private", "GraphNode", "sourceNode", ";", "private", "GraphNode", "destinationNode", ";", "private", "double", "weight", ";", "private", "Color", "color", ";", "private", "Color", "highlightColor", ";", "private", "Color", "foreground", ";", "private", "int", "lineWidth", ";", "private", "int", "lineStyle", ";", "private", "final", "Graph", "graph", ";", "private", "int", "connectionStyle", ";", "private", "int", "curveDepth", ";", "private", "boolean", "isDisposed", "=", "false", ";", "private", "Label", "connectionLabel", "=", "null", ";", "private", "PolylineArcConnection", "connectionFigure", "=", "null", ";", "private", "PolylineArcConnection", "cachedConnectionFigure", "=", "null", ";", "private", "Connection", "sourceContainerConnectionFigure", "=", "null", ";", "private", "Connection", "targetContainerConnectionFigure", "=", "null", ";", "private", "boolean", "visible", ";", "private", "IFigure", "tooltip", ";", "private", "boolean", "highlighted", ";", "private", "boolean", "hasCustomTooltip", ";", "private", "ConnectionRouter", "router", "=", "null", ";", "public", "GraphConnection", "(", "Graph", "graphModel", ",", "int", "style", ",", "GraphNode", "source", ",", "GraphNode", "destination", ")", "{", "super", "(", "graphModel", ",", "style", ")", ";", "this", ".", "connectionStyle", "|=", "graphModel", ".", "getConnectionStyle", "(", ")", ";", "this", ".", "connectionStyle", "|=", "style", ";", "this", ".", "sourceNode", "=", "source", ";", "this", ".", "destinationNode", "=", "destination", ";", "this", ".", "visible", "=", "true", ";", "this", ".", "color", "=", "ColorConstants", ".", "lightGray", ";", "this", ".", "foreground", "=", "ColorConstants", ".", "lightGray", ";", "this", ".", "highlightColor", "=", "graphModel", ".", "DARK_BLUE", ";", "this", ".", "lineWidth", "=", "1", ";", "this", ".", "lineStyle", "=", "Graphics", ".", "LINE_SOLID", ";", "setWeight", "(", "1.0", ")", ";", "this", ".", "graph", "=", "graphModel", ";", "this", ".", "curveDepth", "=", "0", ";", "this", ".", "font", "=", "Display", ".", "getDefault", "(", ")", ".", "getSystemFont", "(", ")", ";", "registerConnection", "(", "source", ",", "destination", ")", ";", "}", "private", "void", "registerConnection", "(", "GraphNode", "source", ",", "GraphNode", "destination", ")", "{", "if", "(", "source", ".", "getSourceConnections", "(", ")", ".", "contains", "(", "this", ")", ")", "{", "source", ".", "removeSourceConnection", "(", "this", ")", ";", "}", "if", "(", "destination", ".", "getTargetConnections", "(", ")", ".", "contains", "(", "this", ")", ")", "{", "destination", ".", "removeTargetConnection", "(", "this", ")", ";", "}", "(", "source", ")", ".", "addSourceConnection", "(", "this", ")", ";", "(", "destination", ")", ".", "addTargetConnection", "(", "this", ")", ";", "if", "(", "source", ".", "getParent", "(", ")", ".", "getItemType", "(", ")", "==", "GraphItem", ".", "CONTAINER", "&&", "destination", ".", "getParent", "(", ")", ".", "getItemType", "(", ")", "==", "GraphItem", ".", "CONTAINER", "&&", "(", "source", ".", "getParent", "(", ")", "==", "destination", ".", "getParent", "(", ")", ")", ")", "{", "graph", ".", "addConnection", "(", "this", ",", "false", ")", ";", "}", "else", "{", "graph", ".", "addConnection", "(", "this", ",", "true", ")", ";", "}", "if", "(", "(", "source", ".", "getParent", "(", ")", ")", ".", "getItemType", "(", ")", "==", "GraphItem", ".", "CONTAINER", ")", "{", "sourceContainerConnectionFigure", "=", "doCreateFigure", "(", ")", ";", "(", "(", "GraphContainer", ")", "source", ".", "getParent", "(", ")", ")", ".", "addConnectionFigure", "(", "sourceContainerConnectionFigure", ")", ";", "this", ".", "setVisible", "(", "false", ")", ";", "}", "if", "(", "(", "destination", ".", "getParent", "(", ")", ")", ".", "getItemType", "(", ")", "==", "GraphItem", ".", "CONTAINER", ")", "{", "targetContainerConnectionFigure", "=", "doCreateFigure", "(", ")", ";", "(", "(", "GraphContainer", ")", "destination", ".", "getParent", "(", ")", ")", ".", "addConnectionFigure", "(", "targetContainerConnectionFigure", ")", ";", "this", ".", "setVisible", "(", "false", ")", ";", "}", "graph", ".", "registerItem", "(", "this", ")", ";", "}", "void", "removeFigure", "(", ")", "{", "if", "(", "connectionFigure", ".", "getParent", "(", ")", "!=", "null", ")", "{", "connectionFigure", ".", "getParent", "(", ")", ".", "remove", "(", "connectionFigure", ")", ";", "}", "connectionFigure", "=", "null", ";", "if", "(", "sourceContainerConnectionFigure", "!=", "null", ")", "{", "sourceContainerConnectionFigure", ".", "getParent", "(", ")", ".", "remove", "(", "sourceContainerConnectionFigure", ")", ";", "sourceContainerConnectionFigure", "=", "null", ";", "}", "if", "(", "targetContainerConnectionFigure", "!=", "null", ")", "{", "targetContainerConnectionFigure", ".", "getParent", "(", ")", ".", "remove", "(", "targetContainerConnectionFigure", ")", ";", "targetContainerConnectionFigure", "=", "null", ";", "}", "}", "public", "void", "dispose", "(", ")", "{", "super", ".", "dispose", "(", ")", ";", "this", ".", "isDisposed", "=", "true", ";", "(", "getSource", "(", ")", ")", ".", "removeSourceConnection", "(", "this", ")", ";", "(", "getDestination", "(", ")", ")", ".", "removeTargetConnection", "(", "this", ")", ";", "graph", ".", "removeConnection", "(", "this", ")", ";", "if", "(", "sourceContainerConnectionFigure", "!=", "null", ")", "{", "sourceContainerConnectionFigure", ".", "getParent", "(", ")", ".", "remove", "(", "sourceContainerConnectionFigure", ")", ";", "}", "if", "(", "targetContainerConnectionFigure", "!=", "null", ")", "{", "targetContainerConnectionFigure", ".", "getParent", "(", ")", ".", "remove", "(", "targetContainerConnectionFigure", ")", ";", "}", "}", "public", "boolean", "isDisposed", "(", ")", "{", "return", "isDisposed", ";", "}", "public", "Connection", "getConnectionFigure", "(", ")", "{", "if", "(", "connectionFigure", "==", "null", ")", "{", "connectionFigure", "=", "doCreateFigure", "(", ")", ";", "}", "return", "connectionFigure", ";", "}", "public", "Object", "getExternalConnection", "(", ")", "{", "return", "this", ".", "getData", "(", ")", ";", "}", "public", "String", "toString", "(", ")", "{", "StringBuffer", "buffer", "=", "new", "StringBuffer", "(", "\"\"", ")", ";", "buffer", ".", "append", "(", "sourceNode", "!=", "null", "?", "sourceNode", ".", "getText", "(", ")", ":", "\"null\"", ")", ";", "buffer", ".", "append", "(", "isDirected", "(", ")", "?", "\"", "-->", "\"", ":", "\"", "---", "\"", ")", ";", "buffer", ".", "append", "(", "destinationNode", "!=", "null", "?", "destinationNode", ".", "getText", "(", ")", ":", "\"null\"", ")", ";", "buffer", ".", "append", "(", "\"", "(weight=\"", ")", ".", "append", "(", "getWeightInLayout", "(", ")", ")", ".", "append", "(", "\")\"", ")", ";", "return", "buffer", ".", "toString", "(", ")", ";", "}", "public", "int", "getConnectionStyle", "(", ")", "{", "return", "connectionStyle", ";", "}", "public", "void", "setConnectionStyle", "(", "int", "style", ")", "{", "this", ".", "connectionStyle", "=", "style", ";", "updateFigure", "(", "this", ".", "connectionFigure", ")", ";", "}", "public", "double", "getWeightInLayout", "(", ")", "{", "return", "weight", ";", "}", "public", "Font", "getFont", "(", ")", "{", "return", "this", ".", "font", ";", "}", "public", "void", "setFont", "(", "Font", "f", ")", "{", "this", ".", "font", "=", "f", ";", "}", "public", "void", "setWeight", "(", "double", "weight", ")", "{", "if", "(", "weight", "<", "0", ")", "{", "this", ".", "weight", "=", "-", "1", ";", "}", "else", "if", "(", "weight", ">", "1", ")", "{", "this", ".", "weight", "=", "1", ";", "}", "else", "{", "this", ".", "weight", "=", "weight", ";", "}", "}", "public", "Color", "getLineColor", "(", ")", "{", "return", "color", ";", "}", "public", "void", "setHighlightColor", "(", "Color", "color", ")", "{", "this", ".", "highlightColor", "=", "color", ";", "}", "public", "Color", "getHighlightColor", "(", ")", "{", "return", "highlightColor", ";", "}", "public", "void", "setLineColor", "(", "Color", "color", ")", "{", "this", ".", "foreground", "=", "color", ";", "changeLineColor", "(", "foreground", ")", ";", "}", "public", "void", "changeLineColor", "(", "Color", "color", ")", "{", "this", ".", "color", "=", "color", ";", "updateFigure", "(", "connectionFigure", ")", ";", "}", "public", "void", "setTooltip", "(", "IFigure", "tooltip", ")", "{", "hasCustomTooltip", "=", "true", ";", "this", ".", "tooltip", "=", "tooltip", ";", "updateFigure", "(", "connectionFigure", ")", ";", "}", "public", "IFigure", "getTooltip", "(", ")", "{", "return", "this", ".", "tooltip", ";", "}", "public", "int", "getLineWidth", "(", ")", "{", "return", "lineWidth", ";", "}", "public", "void", "setLineWidth", "(", "int", "lineWidth", ")", "{", "this", ".", "lineWidth", "=", "lineWidth", ";", "updateFigure", "(", "connectionFigure", ")", ";", "}", "public", "int", "getLineStyle", "(", ")", "{", "return", "lineStyle", ";", "}", "public", "void", "setLineStyle", "(", "int", "lineStyle", ")", "{", "this", ".", "lineStyle", "=", "lineStyle", ";", "updateFigure", "(", "connectionFigure", ")", ";", "}", "public", "GraphNode", "getSource", "(", ")", "{", "return", "this", ".", "sourceNode", ";", "}", "public", "GraphNode", "getDestination", "(", ")", "{", "return", "this", ".", "destinationNode", ";", "}", "public", "void", "highlight", "(", ")", "{", "if", "(", "highlighted", ")", "{", "return", ";", "}", "IFigure", "parentFigure", "=", "connectionFigure", ".", "getParent", "(", ")", ";", "if", "(", "parentFigure", "instanceof", "ZestRootLayer", ")", "{", "(", "(", "ZestRootLayer", ")", "parentFigure", ")", ".", "highlightConnection", "(", "connectionFigure", ")", ";", "}", "highlighted", "=", "true", ";", "updateFigure", "(", "connectionFigure", ")", ";", "}", "public", "void", "unhighlight", "(", ")", "{", "if", "(", "!", "highlighted", ")", "{", "return", ";", "}", "IFigure", "parentFigure", "=", "connectionFigure", ".", "getParent", "(", ")", ";", "if", "(", "parentFigure", "instanceof", "ZestRootLayer", ")", "{", "(", "(", "ZestRootLayer", ")", "parentFigure", ")", ".", "unHighlightConnection", "(", "connectionFigure", ")", ";", "}", "highlighted", "=", "false", ";", "updateFigure", "(", "connectionFigure", ")", ";", "}", "public", "boolean", "isHighlighted", "(", ")", "{", "return", "highlighted", ";", "}", "public", "Graph", "getGraphModel", "(", ")", "{", "return", "this", ".", "graph", ";", "}", "public", "void", "setCurveDepth", "(", "int", "depth", ")", "{", "if", "(", "this", ".", "curveDepth", "==", "0", "&&", "depth", "!=", "0", "||", "this", ".", "curveDepth", "!=", "0", "&&", "depth", "==", "0", ")", "{", "this", ".", "cachedConnectionFigure", "=", "connectionFigure", ";", "graph", ".", "removeConnection", "(", "this", ")", ";", "this", ".", "curveDepth", "=", "depth", ";", "this", ".", "connectionFigure", "=", "doCreateFigure", "(", ")", ";", "registerConnection", "(", "sourceNode", ",", "destinationNode", ")", ";", "updateFigure", "(", "this", ".", "connectionFigure", ")", ";", "}", "else", "{", "this", ".", "curveDepth", "=", "depth", ";", "updateFigure", "(", "this", ".", "connectionFigure", ")", ";", "}", "}", "public", "int", "getItemType", "(", ")", "{", "return", "CONNECTION", ";", "}", "public", "void", "setVisible", "(", "boolean", "visible", ")", "{", "if", "(", "getSource", "(", ")", ".", "isVisible", "(", ")", "&&", "getDestination", "(", ")", ".", "isVisible", "(", ")", "&&", "visible", ")", "{", "this", ".", "getFigure", "(", ")", ".", "setVisible", "(", "visible", ")", ";", "if", "(", "sourceContainerConnectionFigure", "!=", "null", ")", "{", "sourceContainerConnectionFigure", ".", "setVisible", "(", "visible", ")", ";", "}", "if", "(", "targetContainerConnectionFigure", "!=", "null", ")", "{", "targetContainerConnectionFigure", ".", "setVisible", "(", "visible", ")", ";", "}", "this", ".", "visible", "=", "visible", ";", "}", "else", "{", "this", ".", "getFigure", "(", ")", ".", "setVisible", "(", "false", ")", ";", "if", "(", "sourceContainerConnectionFigure", "!=", "null", ")", "{", "sourceContainerConnectionFigure", ".", "setVisible", "(", "false", ")", ";", "}", "if", "(", "targetContainerConnectionFigure", "!=", "null", ")", "{", "targetContainerConnectionFigure", ".", "setVisible", "(", "false", ")", ";", "}", "this", ".", "visible", "=", "false", ";", "}", "}", "public", "boolean", "isVisible", "(", ")", "{", "return", "visible", ";", "}", "public", "void", "setText", "(", "String", "string", ")", "{", "super", ".", "setText", "(", "string", ")", ";", "if", "(", "this", ".", "connectionFigure", "!=", "null", ")", "{", "updateFigure", "(", "this", ".", "connectionFigure", ")", ";", "}", "}", "public", "boolean", "isDirected", "(", ")", "{", "return", "ZestStyles", ".", "checkStyle", "(", "connectionStyle", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ")", ";", "}", "public", "void", "setDirected", "(", "boolean", "directed", ")", "{", "if", "(", "directed", ")", "{", "setConnectionStyle", "(", "connectionStyle", "|", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ")", ";", "}", "else", "{", "setConnectionStyle", "(", "connectionStyle", "&", "(", "-", "1", "-", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ")", ")", ";", "}", "}", "PolylineConnection", "getSourceContainerConnectionFigure", "(", ")", "{", "return", "(", "PolylineConnection", ")", "sourceContainerConnectionFigure", ";", "}", "PolylineConnection", "getTargetContainerConnectionFigure", "(", ")", "{", "return", "(", "PolylineConnection", ")", "targetContainerConnectionFigure", ";", "}", "private", "void", "updateFigure", "(", "PolylineArcConnection", "connection", ")", "{", "if", "(", "sourceContainerConnectionFigure", "!=", "null", ")", "{", "doUpdateFigure", "(", "sourceContainerConnectionFigure", ")", ";", "}", "if", "(", "targetContainerConnectionFigure", "!=", "null", ")", "{", "doUpdateFigure", "(", "targetContainerConnectionFigure", ")", ";", "}", "doUpdateFigure", "(", "connection", ")", ";", "}", "private", "void", "doUpdateFigure", "(", "Connection", "connection", ")", "{", "if", "(", "connection", "==", "null", "||", "this", ".", "isDisposed", "(", ")", ")", "{", "return", ";", "}", "Shape", "connectionShape", "=", "(", "Shape", ")", "connection", ";", "connectionShape", ".", "setLineStyle", "(", "getLineStyle", "(", ")", ")", ";", "if", "(", "this", ".", "getText", "(", ")", "!=", "null", "||", "this", ".", "getImage", "(", ")", "!=", "null", ")", "{", "if", "(", "this", ".", "getImage", "(", ")", "!=", "null", ")", "{", "this", ".", "connectionLabel", ".", "setIcon", "(", "this", ".", "getImage", "(", ")", ")", ";", "}", "if", "(", "this", ".", "getText", "(", ")", "!=", "null", ")", "{", "this", ".", "connectionLabel", ".", "setText", "(", "this", ".", "getText", "(", ")", ")", ";", "}", "this", ".", "connectionLabel", ".", "setFont", "(", "this", ".", "getFont", "(", ")", ")", ";", "}", "if", "(", "highlighted", ")", "{", "connectionShape", ".", "setForegroundColor", "(", "getHighlightColor", "(", ")", ")", ";", "connectionShape", ".", "setLineWidth", "(", "getLineWidth", "(", ")", "*", "2", ")", ";", "}", "else", "{", "connectionShape", ".", "setForegroundColor", "(", "getLineColor", "(", ")", ")", ";", "connectionShape", ".", "setLineWidth", "(", "getLineWidth", "(", ")", ")", ";", "}", "if", "(", "connection", "instanceof", "PolylineArcConnection", ")", "{", "PolylineArcConnection", "arcConnection", "=", "(", "PolylineArcConnection", ")", "connection", ";", "arcConnection", ".", "setDepth", "(", "curveDepth", ")", ";", "}", "if", "(", "connectionFigure", "!=", "null", ")", "{", "applyConnectionRouter", "(", "connectionFigure", ")", ";", "}", "if", "(", "(", "connectionStyle", "&", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ")", ">", "0", ")", "{", "PolygonDecoration", "decoration", "=", "new", "PolygonDecoration", "(", ")", ";", "if", "(", "getLineWidth", "(", ")", "<", "3", ")", "{", "decoration", ".", "setScale", "(", "9", ",", "3", ")", ";", "}", "else", "{", "double", "logLineWith", "=", "getLineWidth", "(", ")", "/", "2.0", ";", "decoration", ".", "setScale", "(", "7", "*", "logLineWith", ",", "3", "*", "logLineWith", ")", ";", "}", "if", "(", "connection", "instanceof", "PolylineConnection", ")", "{", "(", "(", "PolylineArcConnection", ")", "connection", ")", ".", "setTargetDecoration", "(", "decoration", ")", ";", "}", "}", "IFigure", "toolTip", ";", "if", "(", "this", ".", "getTooltip", "(", ")", "==", "null", "&&", "getText", "(", ")", "!=", "null", "&&", "getText", "(", ")", ".", "length", "(", ")", ">", "0", "&&", "hasCustomTooltip", "==", "false", ")", "{", "toolTip", "=", "new", "Label", "(", ")", ";", "(", "(", "Label", ")", "toolTip", ")", ".", "setText", "(", "getText", "(", ")", ")", ";", "}", "else", "{", "toolTip", "=", "this", ".", "getTooltip", "(", ")", ";", "}", "connection", ".", "setToolTip", "(", "toolTip", ")", ";", "}", "private", "PolylineArcConnection", "doCreateFigure", "(", ")", "{", "PolylineArcConnection", "connectionFigure", "=", "cachedOrNewConnectionFigure", "(", ")", ";", "ChopboxAnchor", "sourceAnchor", "=", "null", ";", "ChopboxAnchor", "targetAnchor", "=", "null", ";", "this", ".", "connectionLabel", "=", "new", "Label", "(", ")", ";", "Locator", "labelLocator", "=", "null", ";", "if", "(", "getSource", "(", ")", "==", "getDestination", "(", ")", ")", "{", "sourceAnchor", "=", "new", "LoopAnchor", "(", "getSource", "(", ")", ".", "getNodeFigure", "(", ")", ")", ";", "targetAnchor", "=", "new", "LoopAnchor", "(", "getDestination", "(", ")", ".", "getNodeFigure", "(", ")", ")", ";", "labelLocator", "=", "new", "MidpointLocator", "(", "connectionFigure", ",", "0", ")", "{", "protected", "Point", "getReferencePoint", "(", ")", "{", "Point", "p", "=", "Point", ".", "SINGLETON", ";", "p", ".", "x", "=", "getConnection", "(", ")", ".", "getPoints", "(", ")", ".", "getPoint", "(", "getIndex", "(", ")", ")", ".", "x", ";", "p", ".", "y", "=", "(", "int", ")", "(", "getConnection", "(", ")", ".", "getPoints", "(", ")", ".", "getPoint", "(", "getIndex", "(", ")", ")", ".", "y", "-", "(", "curveDepth", "*", "1.5", ")", ")", ";", "getConnection", "(", ")", ".", "translateToAbsolute", "(", "p", ")", ";", "return", "p", ";", "}", "}", ";", "}", "else", "{", "if", "(", "curveDepth", "!=", "0", ")", "{", "connectionFigure", ".", "setDepth", "(", "this", ".", "curveDepth", ")", ";", "}", "applyConnectionRouter", "(", "connectionFigure", ")", ";", "sourceAnchor", "=", "new", "RoundedChopboxAnchor", "(", "getSource", "(", ")", ".", "getNodeFigure", "(", ")", ",", "8", ")", ";", "targetAnchor", "=", "new", "RoundedChopboxAnchor", "(", "getDestination", "(", ")", ".", "getNodeFigure", "(", ")", ",", "8", ")", ";", "labelLocator", "=", "new", "MidpointLocator", "(", "connectionFigure", ",", "0", ")", ";", "}", "connectionFigure", ".", "setSourceAnchor", "(", "sourceAnchor", ")", ";", "connectionFigure", ".", "setTargetAnchor", "(", "targetAnchor", ")", ";", "connectionFigure", ".", "add", "(", "this", ".", "connectionLabel", ",", "labelLocator", ")", ";", "doUpdateFigure", "(", "connectionFigure", ")", ";", "return", "connectionFigure", ";", "}", "private", "PolylineArcConnection", "cachedOrNewConnectionFigure", "(", ")", "{", "return", "cachedConnectionFigure", "==", "null", "?", "new", "PolylineArcConnection", "(", ")", ":", "cachedConnectionFigure", ";", "}", "IFigure", "getFigure", "(", ")", "{", "return", "this", ".", "getConnectionFigure", "(", ")", ";", "}", "private", "InternalConnectionLayout", "layout", ";", "InternalConnectionLayout", "getLayout", "(", ")", "{", "if", "(", "layout", "==", "null", ")", "{", "layout", "=", "new", "InternalConnectionLayout", "(", ")", ";", "}", "return", "layout", ";", "}", "class", "InternalConnectionLayout", "implements", "ConnectionLayout", "{", "private", "boolean", "visible", "=", "GraphConnection", ".", "this", ".", "isVisible", "(", ")", ";", "public", "NodeLayout", "getSource", "(", ")", "{", "return", "sourceNode", ".", "getLayout", "(", ")", ";", "}", "public", "NodeLayout", "getTarget", "(", ")", "{", "return", "destinationNode", ".", "getLayout", "(", ")", ";", "}", "public", "double", "getWeight", "(", ")", "{", "return", "GraphConnection", ".", "this", ".", "getWeightInLayout", "(", ")", ";", "}", "public", "boolean", "isDirected", "(", ")", "{", "return", "!", "ZestStyles", ".", "checkStyle", "(", "getConnectionStyle", "(", ")", ",", "ZestStyles", ".", "CONNECTIONS_DIRECTED", ")", ";", "}", "public", "boolean", "isVisible", "(", ")", "{", "return", "visible", ";", "}", "public", "void", "setVisible", "(", "boolean", "visible", ")", "{", "graph", ".", "getLayoutContext", "(", ")", ".", "checkChangesAllowed", "(", ")", ";", "this", ".", "visible", "=", "visible", ";", "}", "void", "applyLayout", "(", ")", "{", "if", "(", "GraphConnection", ".", "this", ".", "isVisible", "(", ")", "!=", "this", ".", "visible", ")", "{", "GraphConnection", ".", "this", ".", "setVisible", "(", "this", ".", "visible", ")", ";", "}", "}", "}", "void", "applyLayoutChanges", "(", ")", "{", "if", "(", "layout", "!=", "null", ")", "{", "layout", ".", "applyLayout", "(", ")", ";", "}", "}", "void", "applyConnectionRouter", "(", "Connection", "conn", ")", "{", "if", "(", "router", "!=", "null", ")", "{", "conn", ".", "setConnectionRouter", "(", "router", ")", ";", "}", "else", "if", "(", "graph", ".", "getDefaultConnectionRouter", "(", ")", "!=", "null", ")", "{", "conn", ".", "setConnectionRouter", "(", "graph", ".", "getDefaultConnectionRouter", "(", ")", ")", ";", "}", "}", "public", "void", "setRouter", "(", "ConnectionRouter", "router", ")", "{", "this", ".", "router", "=", "router", ";", "}", "}", "</s>" ]
10,269
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "zooming", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Collections", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "FreeformFigure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "IFigure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ScalableFigure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ScalableFreeformLayeredPane", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Viewport", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Dimension", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Point", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Rectangle", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "internal", ".", "SharedMessages", ";", "public", "class", "ZoomManager", "{", "public", "static", "final", "int", "ANIMATE_NEVER", "=", "0", ";", "public", "static", "final", "int", "ANIMATE_ZOOM_IN_OUT", "=", "1", ";", "private", "List", "listeners", "=", "new", "ArrayList", "(", ")", ";", "private", "double", "multiplier", "=", "1.0", ";", "private", "ScalableFigure", "pane", ";", "private", "Viewport", "viewport", ";", "private", "double", "zoom", "=", "1.0", ";", "private", "String", "currentZoomContant", "=", "null", ";", "private", "double", "[", "]", "zoomLevels", "=", "{", ".5", ",", ".75", ",", "1.0", ",", "1.5", ",", "2.0", ",", "2.5", ",", "3", ",", "4", "}", ";", "public", "static", "final", "String", "FIT_HEIGHT", "=", "SharedMessages", ".", "FitHeightAction_Label", ";", "public", "static", "final", "String", "FIT_WIDTH", "=", "SharedMessages", ".", "FitWidthAction_Label", ";", "public", "static", "final", "String", "FIT_ALL", "=", "SharedMessages", ".", "FitAllAction_Label", ";", "private", "List", "zoomLevelContributions", "=", "Collections", ".", "emptyList", "(", ")", ";", "public", "ZoomManager", "(", "ScalableFigure", "pane", ",", "Viewport", "viewport", ")", "{", "this", ".", "pane", "=", "pane", ";", "this", ".", "viewport", "=", "viewport", ";", "zoomLevelContributions", "=", "new", "ArrayList", "(", ")", ";", "zoomLevelContributions", ".", "add", "(", "FIT_ALL", ")", ";", "}", "public", "ZoomManager", "(", "ScalableFreeformLayeredPane", "pane", ",", "Viewport", "viewport", ")", "{", "this", ".", "pane", "=", "pane", ";", "this", ".", "viewport", "=", "viewport", ";", "}", "public", "void", "addZoomListener", "(", "ZoomListener", "listener", ")", "{", "listeners", ".", "add", "(", "listener", ")", ";", "}", "public", "boolean", "canZoomIn", "(", ")", "{", "return", "getZoom", "(", ")", "<", "getMaxZoom", "(", ")", ";", "}", "public", "boolean", "canZoomOut", "(", ")", "{", "return", "getZoom", "(", ")", ">", "getMinZoom", "(", ")", ";", "}", "protected", "void", "fireZoomChanged", "(", ")", "{", "Iterator", "iter", "=", "listeners", ".", "iterator", "(", ")", ";", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "(", "(", "ZoomListener", ")", "iter", ".", "next", "(", ")", ")", ".", "zoomChanged", "(", "zoom", ")", ";", "}", "}", "private", "double", "getFitXZoomLevel", "(", "int", "which", ")", "{", "IFigure", "fig", "=", "getScalableFigure", "(", ")", ";", "Dimension", "available", "=", "getViewport", "(", ")", ".", "getClientArea", "(", ")", ".", "getSize", "(", ")", ";", "Dimension", "desired", ";", "if", "(", "fig", "instanceof", "FreeformFigure", ")", "{", "desired", "=", "(", "(", "FreeformFigure", ")", "fig", ")", ".", "getFreeformExtent", "(", ")", ".", "getCopy", "(", ")", ".", "union", "(", "0", ",", "0", ")", ".", "getSize", "(", ")", ";", "}", "else", "{", "desired", "=", "fig", ".", "getPreferredSize", "(", ")", ".", "getCopy", "(", ")", ";", "}", "desired", ".", "width", "-=", "fig", ".", "getInsets", "(", ")", ".", "getWidth", "(", ")", ";", "desired", ".", "height", "-=", "fig", ".", "getInsets", "(", ")", ".", "getHeight", "(", ")", ";", "while", "(", "fig", "!=", "getViewport", "(", ")", ")", "{", "available", ".", "width", "-=", "fig", ".", "getInsets", "(", ")", ".", "getWidth", "(", ")", ";", "available", ".", "height", "-=", "fig", ".", "getInsets", "(", ")", ".", "getHeight", "(", ")", ";", "fig", "=", "fig", ".", "getParent", "(", ")", ";", "}", "double", "scaleX", "=", "Math", ".", "min", "(", "available", ".", "width", "*", "zoom", "/", "desired", ".", "width", ",", "getMaxZoom", "(", ")", ")", ";", "double", "scaleY", "=", "Math", ".", "min", "(", "available", ".", "height", "*", "zoom", "/", "desired", ".", "height", ",", "getMaxZoom", "(", ")", ")", ";", "if", "(", "which", "==", "0", ")", "{", "return", "scaleX", ";", "}", "if", "(", "which", "==", "1", ")", "{", "return", "scaleY", ";", "}", "return", "Math", ".", "min", "(", "scaleX", ",", "scaleY", ")", ";", "}", "protected", "double", "getFitHeightZoomLevel", "(", ")", "{", "return", "getFitXZoomLevel", "(", "1", ")", ";", "}", "protected", "double", "getFitPageZoomLevel", "(", ")", "{", "return", "getFitXZoomLevel", "(", "2", ")", ";", "}", "protected", "double", "getFitWidthZoomLevel", "(", ")", "{", "return", "getFitXZoomLevel", "(", "0", ")", ";", "}", "public", "double", "getMaxZoom", "(", ")", "{", "return", "getZoomLevels", "(", ")", "[", "getZoomLevels", "(", ")", ".", "length", "-", "1", "]", ";", "}", "public", "double", "getMinZoom", "(", ")", "{", "return", "getZoomLevels", "(", ")", "[", "0", "]", ";", "}", "public", "double", "getUIMultiplier", "(", ")", "{", "return", "multiplier", ";", "}", "public", "double", "getNextZoomLevel", "(", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "zoomLevels", ".", "length", ";", "i", "++", ")", "{", "if", "(", "zoomLevels", "[", "i", "]", ">", "zoom", ")", "{", "return", "zoomLevels", "[", "i", "]", ";", "}", "}", "return", "getMaxZoom", "(", ")", ";", "}", "public", "double", "getPreviousZoomLevel", "(", ")", "{", "for", "(", "int", "i", "=", "1", ";", "i", "<", "zoomLevels", ".", "length", ";", "i", "++", ")", "{", "if", "(", "zoomLevels", "[", "i", "]", ">=", "zoom", ")", "{", "return", "zoomLevels", "[", "i", "-", "1", "]", ";", "}", "}", "return", "getMinZoom", "(", ")", ";", "}", "public", "ScalableFigure", "getScalableFigure", "(", ")", "{", "return", "pane", ";", "}", "public", "Viewport", "getViewport", "(", ")", "{", "return", "viewport", ";", "}", "public", "double", "getZoom", "(", ")", "{", "return", "zoom", ";", "}", "private", "String", "format", "(", "double", "d", ")", "{", "return", "\"\"", "+", "(", "(", "int", ")", "(", "d", "*", "100", ")", ")", "+", "\"%\"", ";", "}", "public", "String", "getZoomAsText", "(", ")", "{", "if", "(", "currentZoomContant", "!=", "null", ")", "{", "return", "currentZoomContant", ";", "}", "String", "newItem", "=", "format", "(", "zoom", "*", "multiplier", ")", ";", "return", "newItem", ";", "}", "public", "List", "getZoomLevelContributions", "(", ")", "{", "return", "zoomLevelContributions", ";", "}", "public", "double", "[", "]", "getZoomLevels", "(", ")", "{", "return", "zoomLevels", ";", "}", "public", "String", "[", "]", "getZoomLevelsAsText", "(", ")", "{", "String", "[", "]", "zoomLevelStrings", "=", "new", "String", "[", "zoomLevels", ".", "length", "+", "zoomLevelContributions", ".", "size", "(", ")", "]", ";", "if", "(", "zoomLevelContributions", "!=", "null", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "zoomLevelContributions", ".", "size", "(", ")", ";", "i", "++", ")", "{", "zoomLevelStrings", "[", "i", "]", "=", "(", "String", ")", "zoomLevelContributions", ".", "get", "(", "i", ")", ";", "}", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "zoomLevels", ".", "length", ";", "i", "++", ")", "{", "zoomLevelStrings", "[", "i", "+", "zoomLevelContributions", ".", "size", "(", ")", "]", "=", "format", "(", "zoomLevels", "[", "i", "]", "*", "multiplier", ")", ";", "}", "return", "zoomLevelStrings", ";", "}", "protected", "void", "primSetZoom", "(", "double", "zoom", ")", "{", "Point", "p1", "=", "getViewport", "(", ")", ".", "getClientArea", "(", ")", ".", "getCenter", "(", ")", ";", "Point", "p2", "=", "p1", ".", "getCopy", "(", ")", ";", "Point", "p", "=", "getViewport", "(", ")", ".", "getViewLocation", "(", ")", ";", "double", "prevZoom", "=", "this", ".", "zoom", ";", "this", ".", "zoom", "=", "zoom", ";", "pane", ".", "setScale", "(", "zoom", ")", ";", "fireZoomChanged", "(", ")", ";", "getViewport", "(", ")", ".", "validate", "(", ")", ";", "p2", ".", "scale", "(", "zoom", "/", "prevZoom", ")", ";", "Dimension", "dif", "=", "p2", ".", "getDifference", "(", "p1", ")", ";", "p", ".", "x", "+=", "dif", ".", "width", ";", "p", ".", "y", "+=", "dif", ".", "height", ";", "setViewLocation", "(", "p", ")", ";", "}", "public", "void", "removeZoomListener", "(", "ZoomListener", "listener", ")", "{", "listeners", ".", "remove", "(", "listener", ")", ";", "}", "public", "void", "setUIMultiplier", "(", "double", "multiplier", ")", "{", "this", ".", "multiplier", "=", "multiplier", ";", "}", "public", "void", "setViewLocation", "(", "Point", "p", ")", "{", "viewport", ".", "setViewLocation", "(", "p", ".", "x", ",", "p", ".", "y", ")", ";", "}", "public", "void", "setZoom", "(", "double", "zoom", ")", "{", "currentZoomContant", "=", "null", ";", "zoom", "=", "Math", ".", "min", "(", "getMaxZoom", "(", ")", ",", "zoom", ")", ";", "zoom", "=", "Math", ".", "max", "(", "getMinZoom", "(", ")", ",", "zoom", ")", ";", "if", "(", "this", ".", "zoom", "!=", "zoom", ")", "{", "primSetZoom", "(", "zoom", ")", ";", "}", "}", "public", "void", "setZoomAnimationStyle", "(", "int", "style", ")", "{", "}", "public", "void", "setZoomAsText", "(", "String", "zoomString", ")", "{", "currentZoomContant", "=", "null", ";", "if", "(", "zoomString", ".", "equalsIgnoreCase", "(", "FIT_HEIGHT", ")", ")", "{", "currentZoomContant", "=", "FIT_HEIGHT", ";", "primSetZoom", "(", "getFitHeightZoomLevel", "(", ")", ")", ";", "viewport", ".", "getUpdateManager", "(", ")", ".", "performUpdate", "(", ")", ";", "viewport", ".", "setViewLocation", "(", "viewport", ".", "getHorizontalRangeModel", "(", ")", ".", "getValue", "(", ")", ",", "viewport", ".", "getVerticalRangeModel", "(", ")", ".", "getMinimum", "(", ")", ")", ";", "}", "else", "if", "(", "zoomString", ".", "equalsIgnoreCase", "(", "FIT_ALL", ")", ")", "{", "currentZoomContant", "=", "FIT_ALL", ";", "primSetZoom", "(", "getFitPageZoomLevel", "(", ")", ")", ";", "viewport", ".", "getUpdateManager", "(", ")", ".", "performUpdate", "(", ")", ";", "viewport", ".", "setViewLocation", "(", "viewport", ".", "getHorizontalRangeModel", "(", ")", ".", "getMinimum", "(", ")", ",", "viewport", ".", "getVerticalRangeModel", "(", ")", ".", "getMinimum", "(", ")", ")", ";", "}", "else", "if", "(", "zoomString", ".", "equalsIgnoreCase", "(", "FIT_WIDTH", ")", ")", "{", "currentZoomContant", "=", "FIT_WIDTH", ";", "primSetZoom", "(", "getFitWidthZoomLevel", "(", ")", ")", ";", "viewport", ".", "getUpdateManager", "(", ")", ".", "performUpdate", "(", ")", ";", "viewport", ".", "setViewLocation", "(", "viewport", ".", "getHorizontalRangeModel", "(", ")", ".", "getMinimum", "(", ")", ",", "viewport", ".", "getVerticalRangeModel", "(", ")", ".", "getValue", "(", ")", ")", ";", "}", "else", "{", "try", "{", "if", "(", "zoomString", ".", "charAt", "(", "zoomString", ".", "length", "(", ")", "-", "1", ")", "==", "'%'", ")", "{", "zoomString", "=", "zoomString", ".", "substring", "(", "0", ",", "zoomString", ".", "length", "(", ")", "-", "1", ")", ";", "}", "double", "newZoom", "=", "Double", ".", "parseDouble", "(", "zoomString", ")", "/", "100", ";", "setZoom", "(", "newZoom", "/", "multiplier", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "Display", ".", "getCurrent", "(", ")", ".", "beep", "(", ")", ";", "}", "}", "}", "public", "void", "setZoomLevelContributions", "(", "List", "contributions", ")", "{", "zoomLevelContributions", "=", "contributions", ";", "}", "public", "void", "setZoomLevels", "(", "double", "[", "]", "zoomLevels", ")", "{", "this", ".", "zoomLevels", "=", "zoomLevels", ";", "}", "public", "void", "zoomIn", "(", ")", "{", "setZoom", "(", "getNextZoomLevel", "(", ")", ")", ";", "}", "public", "void", "zoomTo", "(", "Rectangle", "rect", ")", "{", "}", "public", "void", "zoomOut", "(", ")", "{", "setZoom", "(", "getPreviousZoomLevel", "(", ")", ")", ";", "}", "}", "</s>" ]
10,270
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "zooming", ";", "public", "interface", "ZoomListener", "{", "void", "zoomChanged", "(", "double", "zoom", ")", ";", "}", "</s>" ]
10,271
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "LayoutContext", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "NodeLayout", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "SubgraphLayout", ";", "public", "interface", "SubgraphFactory", "{", "SubgraphLayout", "createSubgraph", "(", "NodeLayout", "[", "]", "nodes", ",", "LayoutContext", "context", ")", ";", "}", "</s>" ]
10,272
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ";", "public", "final", "class", "ZestStyles", "{", "public", "static", "final", "int", "NONE", "=", "0", ";", "public", "static", "final", "int", "IGNORE_INVISIBLE_LAYOUT", "=", "1", "<<", "1", ";", "public", "static", "final", "int", "NODES_CACHE_LABEL", "=", "1", "<<", "1", ";", "public", "static", "final", "int", "NODES_FISHEYE", "=", "1", "<<", "2", ";", "public", "static", "final", "int", "NODES_HIDE_TEXT", "=", "1", "<<", "3", ";", "public", "static", "final", "int", "NODES_NO_LAYOUT_RESIZE", "=", "1", "<<", "4", ";", "public", "static", "final", "int", "CONNECTIONS_DIRECTED", "=", "1", "<<", "1", ";", "public", "static", "final", "int", "CONNECTIONS_SOLID", "=", "1", "<<", "2", ";", "public", "static", "final", "int", "CONNECTIONS_DASH", "=", "1", "<<", "3", ";", "public", "static", "final", "int", "CONNECTIONS_DOT", "=", "1", "<<", "4", ";", "public", "static", "final", "int", "CONNECTIONS_DASH_DOT", "=", "1", "<<", "5", ";", "public", "static", "final", "int", "GESTURES_DISABLED", "=", "1", "<<", "6", ";", "public", "static", "boolean", "checkStyle", "(", "int", "style", ",", "int", "styleToCheck", ")", "{", "return", "(", "(", "style", "&", "styleToCheck", ")", "==", "styleToCheck", ")", ";", "}", "public", "static", "boolean", "validateConnectionStyle", "(", "int", "styleToValidate", ")", "{", "int", "style", "=", "styleToValidate", ";", "int", "illegal", "=", "CONNECTIONS_DASH_DOT", "|", "CONNECTIONS_DASH", "|", "CONNECTIONS_DOT", "|", "CONNECTIONS_SOLID", ";", "style", "=", "styleToValidate", ";", "style", "&=", "illegal", ";", "int", "rightBit", "=", "style", "&", "(", "-", "style", ")", ";", "boolean", "okay", "=", "(", "style", "==", "rightBit", ")", ";", "if", "(", "!", "okay", ")", "{", "return", "okay", ";", "}", "return", "true", ";", "}", "}", "</s>" ]
10,273
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "FigureListener", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "IFigure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Dimension", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Point", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Item", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "dataStructures", ".", "DisplayIndependentDimension", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "dataStructures", ".", "DisplayIndependentPoint", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "ConnectionLayout", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "EntityLayout", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "NodeLayout", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "SubgraphLayout", ";", "class", "InternalNodeLayout", "implements", "NodeLayout", "{", "private", "final", "static", "FigureListener", "figureListener", "=", "new", "FigureListener", "(", ")", "{", "public", "void", "figureMoved", "(", "IFigure", "source", ")", "{", "GraphNode", "node", "=", "(", "GraphNode", ")", "figureToNode", ".", "get", "(", "source", ")", ";", "if", "(", "node", ".", "getLayout", "(", ")", ".", "isMinimized", "(", ")", "&&", "source", ".", "getSize", "(", ")", ".", "equals", "(", "0", ",", "0", ")", ")", "{", "source", ".", "setVisible", "(", "false", ")", ";", "}", "else", "{", "source", ".", "setVisible", "(", "node", ".", "isVisible", "(", ")", ")", ";", "}", "}", "}", ";", "private", "final", "static", "HashMap", "figureToNode", "=", "new", "HashMap", "(", ")", ";", "private", "DisplayIndependentPoint", "location", ";", "private", "DisplayIndependentDimension", "size", ";", "private", "boolean", "minimized", "=", "false", ";", "private", "final", "GraphNode", "node", ";", "private", "final", "InternalLayoutContext", "ownerLayoutContext", ";", "private", "DefaultSubgraph", "subgraph", ";", "private", "boolean", "isDisposed", "=", "false", ";", "public", "InternalNodeLayout", "(", "GraphNode", "graphNode", ")", "{", "this", ".", "node", "=", "graphNode", ";", "this", ".", "ownerLayoutContext", "=", "node", ".", "parent", ".", "getLayoutContext", "(", ")", ";", "graphNode", ".", "nodeFigure", ".", "addFigureListener", "(", "figureListener", ")", ";", "figureToNode", ".", "put", "(", "graphNode", ".", "nodeFigure", ",", "graphNode", ")", ";", "}", "public", "DisplayIndependentPoint", "getLocation", "(", ")", "{", "if", "(", "location", "==", "null", ")", "{", "refreshLocation", "(", ")", ";", "}", "return", "new", "DisplayIndependentPoint", "(", "location", ")", ";", "}", "public", "DisplayIndependentDimension", "getSize", "(", ")", "{", "if", "(", "size", "==", "null", ")", "{", "refreshSize", "(", ")", ";", "}", "return", "new", "DisplayIndependentDimension", "(", "size", ")", ";", "}", "public", "SubgraphLayout", "getSubgraph", "(", ")", "{", "return", "subgraph", ";", "}", "public", "boolean", "isMovable", "(", ")", "{", "return", "true", ";", "}", "public", "boolean", "isPrunable", "(", ")", "{", "return", "ownerLayoutContext", ".", "isPruningEnabled", "(", ")", ";", "}", "public", "boolean", "isPruned", "(", ")", "{", "return", "subgraph", "!=", "null", ";", "}", "public", "boolean", "isResizable", "(", ")", "{", "return", "(", "node", ".", "parent", ".", "getItem", "(", ")", ".", "getStyle", "(", ")", "&", "ZestStyles", ".", "NODES_NO_LAYOUT_RESIZE", ")", "==", "0", ";", "}", "public", "void", "prune", "(", "SubgraphLayout", "subgraph", ")", "{", "if", "(", "subgraph", "!=", "null", "&&", "!", "(", "subgraph", "instanceof", "DefaultSubgraph", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"\"", ")", ";", "}", "ownerLayoutContext", ".", "checkChangesAllowed", "(", ")", ";", "if", "(", "subgraph", "==", "this", ".", "subgraph", ")", "{", "return", ";", "}", "if", "(", "this", ".", "subgraph", "!=", "null", ")", "{", "SubgraphLayout", "subgraph2", "=", "this", ".", "subgraph", ";", "this", ".", "subgraph", "=", "null", ";", "subgraph2", ".", "removeNodes", "(", "new", "NodeLayout", "[", "]", "{", "this", "}", ")", ";", "}", "if", "(", "subgraph", "!=", "null", ")", "{", "this", ".", "subgraph", "=", "(", "DefaultSubgraph", ")", "subgraph", ";", "subgraph", ".", "addNodes", "(", "new", "NodeLayout", "[", "]", "{", "this", "}", ")", ";", "}", "}", "public", "void", "setLocation", "(", "double", "x", ",", "double", "y", ")", "{", "if", "(", "!", "ownerLayoutContext", ".", "isLayoutItemFiltered", "(", "this", ".", "getNode", "(", ")", ")", ")", "{", "ownerLayoutContext", ".", "checkChangesAllowed", "(", ")", ";", "internalSetLocation", "(", "x", ",", "y", ")", ";", "}", "}", "private", "void", "internalSetLocation", "(", "double", "x", ",", "double", "y", ")", "{", "if", "(", "location", "!=", "null", ")", "{", "location", ".", "x", "=", "x", ";", "location", ".", "y", "=", "y", ";", "}", "else", "{", "location", "=", "new", "DisplayIndependentPoint", "(", "x", ",", "y", ")", ";", "}", "}", "public", "void", "setSize", "(", "double", "width", ",", "double", "height", ")", "{", "ownerLayoutContext", ".", "checkChangesAllowed", "(", ")", ";", "internalSetSize", "(", "width", ",", "height", ")", ";", "}", "private", "void", "internalSetSize", "(", "double", "width", ",", "double", "height", ")", "{", "if", "(", "size", "!=", "null", ")", "{", "size", ".", "width", "=", "width", ";", "size", ".", "height", "=", "height", ";", "}", "else", "{", "size", "=", "new", "DisplayIndependentDimension", "(", "width", ",", "height", ")", ";", "}", "}", "public", "void", "setMinimized", "(", "boolean", "minimized", ")", "{", "ownerLayoutContext", ".", "checkChangesAllowed", "(", ")", ";", "getSize", "(", ")", ";", "this", ".", "minimized", "=", "minimized", ";", "}", "public", "boolean", "isMinimized", "(", ")", "{", "return", "minimized", ";", "}", "public", "NodeLayout", "[", "]", "getPredecessingNodes", "(", ")", "{", "ConnectionLayout", "[", "]", "connections", "=", "getIncomingConnections", "(", ")", ";", "NodeLayout", "[", "]", "result", "=", "new", "NodeLayout", "[", "connections", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "connections", ".", "length", ";", "i", "++", ")", "{", "result", "[", "i", "]", "=", "connections", "[", "i", "]", ".", "getSource", "(", ")", ";", "if", "(", "result", "[", "i", "]", "==", "this", ")", "{", "result", "[", "i", "]", "=", "connections", "[", "i", "]", ".", "getTarget", "(", ")", ";", "}", "}", "return", "result", ";", "}", "public", "NodeLayout", "[", "]", "getSuccessingNodes", "(", ")", "{", "ConnectionLayout", "[", "]", "connections", "=", "getOutgoingConnections", "(", ")", ";", "NodeLayout", "[", "]", "result", "=", "new", "NodeLayout", "[", "connections", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "connections", ".", "length", ";", "i", "++", ")", "{", "result", "[", "i", "]", "=", "connections", "[", "i", "]", ".", "getTarget", "(", ")", ";", "if", "(", "result", "[", "i", "]", "==", "this", ")", "{", "result", "[", "i", "]", "=", "connections", "[", "i", "]", ".", "getSource", "(", ")", ";", "}", "}", "return", "result", ";", "}", "public", "EntityLayout", "[", "]", "getSuccessingEntities", "(", ")", "{", "if", "(", "isPruned", "(", ")", ")", "{", "return", "new", "NodeLayout", "[", "0", "]", ";", "}", "ArrayList", "result", "=", "new", "ArrayList", "(", ")", ";", "HashSet", "addedSubgraphs", "=", "new", "HashSet", "(", ")", ";", "NodeLayout", "[", "]", "successingNodes", "=", "getSuccessingNodes", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "successingNodes", ".", "length", ";", "i", "++", ")", "{", "if", "(", "!", "successingNodes", "[", "i", "]", ".", "isPruned", "(", ")", ")", "{", "result", ".", "add", "(", "successingNodes", "[", "i", "]", ")", ";", "}", "else", "{", "SubgraphLayout", "successingSubgraph", "=", "successingNodes", "[", "i", "]", ".", "getSubgraph", "(", ")", ";", "if", "(", "successingSubgraph", ".", "isGraphEntity", "(", ")", "&&", "!", "addedSubgraphs", ".", "contains", "(", "successingSubgraph", ")", ")", "{", "result", ".", "add", "(", "successingSubgraph", ")", ";", "addedSubgraphs", ".", "add", "(", "successingSubgraph", ")", ";", "}", "}", "}", "return", "(", "EntityLayout", "[", "]", ")", "result", ".", "toArray", "(", "new", "EntityLayout", "[", "result", ".", "size", "(", ")", "]", ")", ";", "}", "public", "EntityLayout", "[", "]", "getPredecessingEntities", "(", ")", "{", "if", "(", "isPruned", "(", ")", ")", "{", "return", "new", "NodeLayout", "[", "0", "]", ";", "}", "ArrayList", "result", "=", "new", "ArrayList", "(", ")", ";", "HashSet", "addedSubgraphs", "=", "new", "HashSet", "(", ")", ";", "NodeLayout", "[", "]", "predecessingNodes", "=", "getPredecessingNodes", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "predecessingNodes", ".", "length", ";", "i", "++", ")", "{", "if", "(", "!", "predecessingNodes", "[", "i", "]", ".", "isPruned", "(", ")", ")", "{", "result", ".", "add", "(", "predecessingNodes", "[", "i", "]", ")", ";", "}", "else", "{", "SubgraphLayout", "predecessingSubgraph", "=", "predecessingNodes", "[", "i", "]", ".", "getSubgraph", "(", ")", ";", "if", "(", "predecessingSubgraph", ".", "isGraphEntity", "(", ")", "&&", "!", "addedSubgraphs", ".", "contains", "(", "predecessingSubgraph", ")", ")", "{", "result", ".", "add", "(", "predecessingSubgraph", ")", ";", "addedSubgraphs", ".", "add", "(", "predecessingSubgraph", ")", ";", "}", "}", "}", "return", "(", "EntityLayout", "[", "]", ")", "result", ".", "toArray", "(", "new", "EntityLayout", "[", "result", ".", "size", "(", ")", "]", ")", ";", "}", "public", "ConnectionLayout", "[", "]", "getIncomingConnections", "(", ")", "{", "ArrayList", "result", "=", "new", "ArrayList", "(", ")", ";", "for", "(", "Iterator", "iterator", "=", "node", ".", "getTargetConnections", "(", ")", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "GraphConnection", "connection", "=", "(", "GraphConnection", ")", "iterator", ".", "next", "(", ")", ";", "if", "(", "!", "ownerLayoutContext", ".", "isLayoutItemFiltered", "(", "connection", ")", ")", "{", "result", ".", "add", "(", "connection", ".", "getLayout", "(", ")", ")", ";", "}", "}", "for", "(", "Iterator", "iterator", "=", "node", ".", "getSourceConnections", "(", ")", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "GraphConnection", "connection", "=", "(", "GraphConnection", ")", "iterator", ".", "next", "(", ")", ";", "if", "(", "!", "connection", ".", "isDirected", "(", ")", "&&", "!", "ownerLayoutContext", ".", "isLayoutItemFiltered", "(", "connection", ")", ")", "{", "result", ".", "add", "(", "connection", ".", "getLayout", "(", ")", ")", ";", "}", "}", "return", "(", "ConnectionLayout", "[", "]", ")", "result", ".", "toArray", "(", "new", "ConnectionLayout", "[", "result", ".", "size", "(", ")", "]", ")", ";", "}", "public", "ConnectionLayout", "[", "]", "getOutgoingConnections", "(", ")", "{", "ArrayList", "result", "=", "new", "ArrayList", "(", ")", ";", "for", "(", "Iterator", "iterator", "=", "node", ".", "getSourceConnections", "(", ")", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "GraphConnection", "connection", "=", "(", "GraphConnection", ")", "iterator", ".", "next", "(", ")", ";", "if", "(", "!", "ownerLayoutContext", ".", "isLayoutItemFiltered", "(", "connection", ")", ")", "{", "result", ".", "add", "(", "connection", ".", "getLayout", "(", ")", ")", ";", "}", "}", "for", "(", "Iterator", "iterator", "=", "node", ".", "getTargetConnections", "(", ")", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "GraphConnection", "connection", "=", "(", "GraphConnection", ")", "iterator", ".", "next", "(", ")", ";", "if", "(", "!", "connection", ".", "isDirected", "(", ")", "&&", "!", "ownerLayoutContext", ".", "isLayoutItemFiltered", "(", "connection", ")", ")", "{", "result", ".", "add", "(", "connection", ".", "getLayout", "(", ")", ")", ";", "}", "}", "return", "(", "ConnectionLayout", "[", "]", ")", "result", ".", "toArray", "(", "new", "ConnectionLayout", "[", "result", ".", "size", "(", ")", "]", ")", ";", "}", "public", "double", "getPreferredAspectRatio", "(", ")", "{", "return", "0", ";", "}", "GraphNode", "getNode", "(", ")", "{", "return", "node", ";", "}", "public", "Item", "[", "]", "getItems", "(", ")", "{", "return", "new", "GraphNode", "[", "]", "{", "node", "}", ";", "}", "void", "applyLayout", "(", ")", "{", "if", "(", "minimized", ")", "{", "node", ".", "setSize", "(", "0", ",", "0", ")", ";", "if", "(", "location", "!=", "null", ")", "{", "node", ".", "setLocation", "(", "location", ".", "x", ",", "location", ".", "y", ")", ";", "}", "}", "else", "{", "node", ".", "setSize", "(", "-", "1", ",", "-", "1", ")", ";", "if", "(", "location", "!=", "null", ")", "{", "node", ".", "setLocation", "(", "location", ".", "x", "-", "getSize", "(", ")", ".", "width", "/", "2", ",", "location", ".", "y", "-", "size", ".", "height", "/", "2", ")", ";", "}", "if", "(", "size", "!=", "null", ")", "{", "Dimension", "currentSize", "=", "node", ".", "getSize", "(", ")", ";", "if", "(", "size", ".", "width", "!=", "currentSize", ".", "width", "||", "size", ".", "height", "!=", "currentSize", ".", "height", ")", "{", "node", ".", "setSize", "(", "size", ".", "width", ",", "size", ".", "height", ")", ";", "}", "}", "}", "}", "InternalLayoutContext", "getOwnerLayoutContext", "(", ")", "{", "return", "ownerLayoutContext", ";", "}", "void", "refreshSize", "(", ")", "{", "Dimension", "size2", "=", "node", ".", "getSize", "(", ")", ";", "internalSetSize", "(", "size2", ".", "width", ",", "size2", ".", "height", ")", ";", "}", "void", "refreshLocation", "(", ")", "{", "Point", "location2", "=", "node", ".", "getLocation", "(", ")", ";", "internalSetLocation", "(", "location2", ".", "x", "+", "getSize", "(", ")", ".", "width", "/", "2", ",", "location2", ".", "y", "+", "size", ".", "height", "/", "2", ")", ";", "}", "public", "String", "toString", "(", ")", "{", "return", "node", ".", "toString", "(", ")", "+", "\"(layout)\"", ";", "}", "void", "dispose", "(", ")", "{", "isDisposed", "=", "true", ";", "if", "(", "subgraph", "!=", "null", ")", "{", "subgraph", ".", "removeDisposedNodes", "(", ")", ";", "}", "ownerLayoutContext", ".", "fireNodeRemovedEvent", "(", "node", ".", "getLayout", "(", ")", ")", ";", "figureToNode", ".", "remove", "(", "node", ".", "nodeFigure", ")", ";", "}", "boolean", "isDisposed", "(", ")", "{", "return", "isDisposed", ";", "}", "}", "</s>" ]
10,274
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "LinkedList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ActionEvent", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ActionListener", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Animation", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Clickable", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ColorConstants", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Figure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "FreeformLayout", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "FreeformViewport", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Graphics", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "IFigure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Label", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "LayoutAnimator", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "LineBorder", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ScrollPane", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ToolbarLayout", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Triangle", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Viewport", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Dimension", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Point", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Rectangle", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionListener", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Color", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Image", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "RGB", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Widget", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "internal", ".", "AspectRatioFreeformLayer", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "internal", ".", "ContainerFigure", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "internal", ".", "ZestRootLayer", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "LayoutAlgorithm", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "TreeLayoutAlgorithm", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "dataStructures", ".", "DisplayIndependentRectangle", ";", "public", "class", "GraphContainer", "extends", "GraphNode", "implements", "IContainer", "{", "static", "class", "ExpandGraphLabel", "extends", "Figure", "implements", "ActionListener", "{", "private", "boolean", "isExpanded", ";", "private", "Expander", "expander", "=", "new", "Expander", "(", ")", ";", "private", "Color", "darkerBackground", ";", "class", "Expander", "extends", "Clickable", "{", "private", "Triangle", "triangle", ";", "public", "Expander", "(", ")", "{", "setStyle", "(", "Clickable", ".", "STYLE_TOGGLE", ")", ";", "triangle", "=", "new", "Triangle", "(", ")", ";", "triangle", ".", "setSize", "(", "10", ",", "10", ")", ";", "triangle", ".", "setBackgroundColor", "(", "ColorConstants", ".", "black", ")", ";", "triangle", ".", "setForegroundColor", "(", "ColorConstants", ".", "black", ")", ";", "triangle", ".", "setFill", "(", "true", ")", ";", "triangle", ".", "setDirection", "(", "Triangle", ".", "EAST", ")", ";", "triangle", ".", "setLocation", "(", "new", "Point", "(", "5", ",", "3", ")", ")", ";", "this", ".", "setLayoutManager", "(", "new", "FreeformLayout", "(", ")", ")", ";", "this", ".", "add", "(", "triangle", ")", ";", "this", ".", "setPreferredSize", "(", "15", ",", "15", ")", ";", "this", ".", "addActionListener", "(", "ExpandGraphLabel", ".", "this", ")", ";", "}", "public", "void", "open", "(", ")", "{", "triangle", ".", "setDirection", "(", "Triangle", ".", "SOUTH", ")", ";", "}", "public", "void", "close", "(", ")", "{", "triangle", ".", "setDirection", "(", "Triangle", ".", "EAST", ")", ";", "}", "}", "public", "void", "setExpandedState", "(", "boolean", "expanded", ")", "{", "if", "(", "expanded", ")", "{", "expander", ".", "open", "(", ")", ";", "}", "else", "{", "expander", ".", "close", "(", ")", ";", "}", "this", ".", "isExpanded", "=", "expanded", ";", "}", "public", "void", "actionPerformed", "(", "ActionEvent", "event", ")", "{", "if", "(", "isExpanded", ")", "{", "container", ".", "close", "(", "true", ")", ";", "}", "else", "{", "container", ".", "open", "(", "true", ")", ";", "}", "}", "private", "final", "int", "arcWidth", "=", "8", ";", "private", "final", "Label", "label", ";", "private", "final", "GraphContainer", "container", ";", "private", "final", "ToolbarLayout", "layout", ";", "public", "ExpandGraphLabel", "(", "GraphContainer", "container", ",", "String", "text", ",", "Image", "image", ",", "boolean", "cacheLabel", ")", "{", "this", ".", "label", "=", "new", "Label", "(", "text", ")", "{", "protected", "void", "paintFigure", "(", "Graphics", "graphics", ")", "{", "if", "(", "isOpaque", "(", ")", ")", "{", "super", ".", "paintFigure", "(", "graphics", ")", ";", "}", "Rectangle", "bounds", "=", "getBounds", "(", ")", ";", "graphics", ".", "translate", "(", "bounds", ".", "x", ",", "bounds", ".", "y", ")", ";", "if", "(", "getIcon", "(", ")", "!=", "null", ")", "{", "graphics", ".", "drawImage", "(", "getIcon", "(", ")", ",", "getIconLocation", "(", ")", ")", ";", "}", "if", "(", "!", "isEnabled", "(", ")", ")", "{", "graphics", ".", "translate", "(", "1", ",", "1", ")", ";", "graphics", ".", "setForegroundColor", "(", "ColorConstants", ".", "buttonLightest", ")", ";", "graphics", ".", "drawText", "(", "getSubStringText", "(", ")", ",", "getTextLocation", "(", ")", ")", ";", "graphics", ".", "translate", "(", "-", "1", ",", "-", "1", ")", ";", "graphics", ".", "setForegroundColor", "(", "ColorConstants", ".", "buttonDarker", ")", ";", "}", "graphics", ".", "drawText", "(", "getText", "(", ")", ",", "getTextLocation", "(", ")", ")", ";", "graphics", ".", "translate", "(", "-", "bounds", ".", "x", ",", "-", "bounds", ".", "y", ")", ";", "}", "}", ";", "this", ".", "setText", "(", "text", ")", ";", "this", ".", "setImage", "(", "image", ")", ";", "this", ".", "container", "=", "container", ";", "this", ".", "setFont", "(", "Display", ".", "getDefault", "(", ")", ".", "getSystemFont", "(", ")", ")", ";", "layout", "=", "new", "ToolbarLayout", "(", "true", ")", ";", "layout", ".", "setSpacing", "(", "5", ")", ";", "layout", ".", "setMinorAlignment", "(", "ToolbarLayout", ".", "ALIGN_CENTER", ")", ";", "this", ".", "setLayoutManager", "(", "layout", ")", ";", "this", ".", "add", "(", "this", ".", "expander", ")", ";", "this", ".", "add", "(", "this", ".", "label", ")", ";", "}", "private", "Color", "getDarkerBackgroundColor", "(", ")", "{", "if", "(", "darkerBackground", "==", "null", ")", "{", "Color", "baseColor", "=", "getBackgroundColor", "(", ")", ";", "int", "blue", "=", "(", "int", ")", "(", "baseColor", ".", "getBlue", "(", ")", "*", "0.8", "+", "0.5", ")", ";", "int", "red", "=", "(", "int", ")", "(", "baseColor", ".", "getRed", "(", ")", "*", "0.8", "+", "0.5", ")", ";", "int", "green", "=", "(", "int", ")", "(", "baseColor", ".", "getGreen", "(", ")", "*", "0.8", "+", "0.5", ")", ";", "darkerBackground", "=", "new", "Color", "(", "Display", ".", "getCurrent", "(", ")", ",", "new", "RGB", "(", "red", ",", "green", ",", "blue", ")", ")", ";", "}", "return", "darkerBackground", ";", "}", "public", "void", "paint", "(", "Graphics", "graphics", ")", "{", "graphics", ".", "setForegroundColor", "(", "getDarkerBackgroundColor", "(", ")", ")", ";", "graphics", ".", "setBackgroundColor", "(", "getBackgroundColor", "(", ")", ")", ";", "graphics", ".", "pushState", "(", ")", ";", "Rectangle", "bounds", "=", "getBounds", "(", ")", ".", "getCopy", "(", ")", ";", "Rectangle", "r", "=", "bounds", ".", "getCopy", "(", ")", ";", "r", ".", "y", "+=", "arcWidth", "/", "2", ";", "r", ".", "height", "-=", "arcWidth", ";", "Rectangle", "top", "=", "bounds", ".", "getCopy", "(", ")", ";", "top", ".", "height", "/=", "2", ";", "graphics", ".", "setForegroundColor", "(", "getBackgroundColor", "(", ")", ")", ";", "graphics", ".", "setBackgroundColor", "(", "getBackgroundColor", "(", ")", ")", ";", "graphics", ".", "fillRoundRectangle", "(", "top", ",", "arcWidth", ",", "arcWidth", ")", ";", "top", ".", "y", "=", "top", ".", "y", "+", "top", ".", "height", ";", "graphics", ".", "setForegroundColor", "(", "darkerBackground", ")", ";", "graphics", ".", "setBackgroundColor", "(", "darkerBackground", ")", ";", "graphics", ".", "fillRoundRectangle", "(", "top", ",", "arcWidth", ",", "arcWidth", ")", ";", "graphics", ".", "setBackgroundColor", "(", "darkerBackground", ")", ";", "graphics", ".", "setForegroundColor", "(", "getBackgroundColor", "(", ")", ")", ";", "graphics", ".", "fillGradient", "(", "r", ",", "true", ")", ";", "super", ".", "paint", "(", "graphics", ")", ";", "graphics", ".", "popState", "(", ")", ";", "graphics", ".", "setForegroundColor", "(", "darkerBackground", ")", ";", "graphics", ".", "setBackgroundColor", "(", "darkerBackground", ")", ";", "bounds", ".", "setSize", "(", "bounds", ".", "width", "-", "1", ",", "bounds", ".", "height", "-", "1", ")", ";", "graphics", ".", "drawRoundRectangle", "(", "bounds", ",", "arcWidth", ",", "arcWidth", ")", ";", "}", "public", "void", "setBackgroundColor", "(", "Color", "bg", ")", "{", "super", ".", "setBackgroundColor", "(", "bg", ")", ";", "if", "(", "darkerBackground", "!=", "null", ")", "{", "darkerBackground", ".", "dispose", "(", ")", ";", "}", "darkerBackground", "=", "null", ";", "}", "public", "void", "setTextT", "(", "String", "string", ")", "{", "this", ".", "setPreferredSize", "(", "null", ")", ";", "this", ".", "label", ".", "setText", "(", "string", ")", ";", "this", ".", "add", "(", "label", ")", ";", "this", ".", "layout", ".", "layout", "(", "this", ")", ";", "this", ".", "invalidate", "(", ")", ";", "this", ".", "revalidate", "(", ")", ";", "this", ".", "validate", "(", ")", ";", "}", "public", "void", "setText", "(", "String", "string", ")", "{", "this", ".", "label", ".", "setText", "(", "string", ")", ";", "}", "public", "void", "setImage", "(", "Image", "image", ")", "{", "this", ".", "label", ".", "setIcon", "(", "image", ")", ";", "}", "public", "void", "setFocus", "(", ")", "{", "expander", ".", "requestFocus", "(", ")", ";", "}", "}", "static", "final", "double", "SCALED_WIDTH", "=", "300", ";", "static", "final", "double", "SCALED_HEIGHT", "=", "200", ";", "private", "static", "final", "int", "CONTAINER_HEIGHT", "=", "200", ";", "private", "static", "final", "int", "MIN_WIDTH", "=", "250", ";", "private", "static", "final", "int", "MIN_HEIGHT", "=", "30", ";", "private", "static", "final", "int", "ANIMATION_TIME", "=", "100", ";", "private", "static", "final", "int", "SUBLAYER_OFFSET", "=", "2", ";", "private", "static", "SelectionListener", "selectionListener", ";", "private", "ExpandGraphLabel", "expandGraphLabel", ";", "private", "List", "childNodes", "=", "null", ";", "private", "int", "childAreaHeight", "=", "CONTAINER_HEIGHT", ";", "private", "ZestRootLayer", "zestLayer", ";", "private", "ScrollPane", "scrollPane", ";", "private", "LayoutAlgorithm", "layoutAlgorithm", ";", "private", "boolean", "isExpanded", "=", "false", ";", "private", "AspectRatioFreeformLayer", "scalledLayer", ";", "private", "InternalLayoutContext", "layoutContext", ";", "public", "GraphContainer", "(", "Graph", "graph", ",", "int", "style", ")", "{", "super", "(", "graph", ",", "style", ")", ";", "initModel", "(", "graph", ",", "\"\"", ",", "null", ")", ";", "close", "(", "false", ")", ";", "childNodes", "=", "new", "ArrayList", "(", ")", ";", "registerToParent", "(", "graph", ")", ";", "}", "public", "GraphContainer", "(", "Graph", "graph", ",", "int", "style", ",", "String", "text", ",", "Image", "image", ")", "{", "this", "(", "graph", ",", "style", ")", ";", "setText", "(", "text", ")", ";", "setImage", "(", "image", ")", ";", "}", "public", "GraphContainer", "(", "GraphContainer", "container", ",", "int", "style", ")", "{", "this", "(", "container", ".", "getGraph", "(", ")", ",", "style", ")", ";", "}", "public", "void", "setCustomFigure", "(", "IFigure", "nodeFigure", ")", "{", "throw", "new", "RuntimeException", "(", "\"\"", ")", ";", "}", "public", "void", "close", "(", "boolean", "animate", ")", "{", "if", "(", "animate", ")", "{", "Animation", ".", "markBegin", "(", ")", ";", "}", "isExpanded", "=", "false", ";", "expandGraphLabel", ".", "setExpandedState", "(", "false", ")", ";", "Rectangle", "newBounds", "=", "scrollPane", ".", "getBounds", "(", ")", ".", "getCopy", "(", ")", ";", "newBounds", ".", "height", "=", "0", ";", "scrollPane", ".", "setSize", "(", "scrollPane", ".", "getSize", "(", ")", ".", "width", ",", "0", ")", ";", "updateFigureForModel", "(", "this", ".", "zestLayer", ")", ";", "scrollPane", ".", "setVisible", "(", "false", ")", ";", "List", "children", "=", "this", ".", "zestLayer", ".", "getChildren", "(", ")", ";", "for", "(", "Iterator", "iterator", "=", "children", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "IFigure", "child", "=", "(", "IFigure", ")", "iterator", ".", "next", "(", ")", ";", "GraphItem", "item", "=", "getGraph", "(", ")", ".", "getGraphItem", "(", "child", ")", ";", "item", ".", "setVisible", "(", "false", ")", ";", "}", "Rectangle", "containerBounds", "=", "new", "Rectangle", "(", "this", ".", "getLocation", "(", ")", ",", "new", "Dimension", "(", "this", ".", "getSize", "(", ")", ".", "width", ",", "CONTAINER_HEIGHT", "+", "this", ".", "expandGraphLabel", ".", "getSize", "(", ")", ".", "height", ")", ")", ";", "moveNodesUp", "(", "containerBounds", ",", "this", ")", ";", "if", "(", "animate", ")", "{", "Animation", ".", "run", "(", "ANIMATION_TIME", ")", ";", "}", "updateFigureForModel", "(", "nodeFigure", ")", ";", "}", "private", "static", "void", "addNodeToOrderedList", "(", "List", "orderedNodeList", ",", "GraphNode", "node", ")", "{", "Iterator", "orderedNodeIterator", "=", "orderedNodeList", ".", "iterator", "(", ")", ";", "int", "counter", "=", "0", ";", "while", "(", "orderedNodeIterator", ".", "hasNext", "(", ")", ")", "{", "GraphNode", "nextOrderedNode", "=", "(", "GraphNode", ")", "orderedNodeIterator", ".", "next", "(", ")", ";", "if", "(", "nextOrderedNode", ".", "getLocation", "(", ")", ".", "y", "+", "nextOrderedNode", ".", "getBounds", "(", ")", ".", "height", ">", "node", ".", "getLocation", "(", ")", ".", "y", "+", "node", ".", "getBounds", "(", ")", ".", "height", ")", "{", "break", ";", "}", "counter", "++", ";", "}", "orderedNodeList", ".", "add", "(", "counter", ",", "node", ")", ";", "}", "private", "static", "List", "getOrderedNodesBelowY", "(", "List", "nodes", ",", "int", "yValue", ",", "GraphNode", "yValueNode", ")", "{", "Iterator", "iterator", "=", "nodes", ".", "iterator", "(", ")", ";", "LinkedList", "orderedNode", "=", "new", "LinkedList", "(", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "GraphNode", "node", "=", "(", "GraphNode", ")", "iterator", ".", "next", "(", ")", ";", "if", "(", "node", "==", "yValueNode", ")", "{", "continue", ";", "}", "if", "(", "node", ".", "getLocation", "(", ")", ".", "y", "+", "node", ".", "getBounds", "(", ")", ".", "height", ">", "yValue", ")", "{", "addNodeToOrderedList", "(", "orderedNode", ",", "node", ")", ";", "}", "}", "List", "arrayList", "=", "new", "ArrayList", "(", ")", ";", "iterator", "=", "orderedNode", ".", "iterator", "(", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "arrayList", ".", "add", "(", "iterator", ".", "next", "(", ")", ")", ";", "}", "return", "arrayList", ";", "}", "private", "static", "boolean", "nodeInStripe", "(", "int", "left", ",", "int", "right", ",", "GraphNode", "node", ")", "{", "return", "(", "node", ".", "getBounds", "(", ")", ".", "x", "<", "right", "&&", "node", ".", "getBounds", "(", ")", ".", "x", "+", "node", ".", "getBounds", "(", ")", ".", "width", ">", "left", ")", ";", "}", "void", "pack", "(", "Graph", "g", ")", "{", "GraphNode", "highestNode", "=", "getHighestNode", "(", "g", ")", ";", "moveNodesUp", "(", "highestNode", ".", "getBounds", "(", ")", ",", "highestNode", ")", ";", "}", "static", "GraphNode", "getHighestNode", "(", "Graph", "g", ")", "{", "Iterator", "iterator", "=", "g", ".", "getNodes", "(", ")", ".", "iterator", "(", ")", ";", "GraphNode", "lowest", "=", "null", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "GraphNode", "node", "=", "(", "GraphNode", ")", "iterator", ".", "next", "(", ")", ";", "if", "(", "lowest", "==", "null", "||", "lowest", ".", "getBounds", "(", ")", ".", "y", ">", "node", ".", "getBounds", "(", ")", ".", "y", ")", "{", "lowest", "=", "node", ";", "}", "}", "return", "lowest", ";", "}", "private", "void", "moveNodesUp", "(", "Rectangle", "containerBounds", ",", "GraphNode", "graphContainer", ")", "{", "List", "orderedNodesBelowY", "=", "getOrderedNodesBelowY", "(", "parent", ".", "getGraph", "(", ")", ".", "getNodes", "(", ")", ",", "containerBounds", ".", "y", ",", "graphContainer", ")", ";", "int", "leftSide", "=", "containerBounds", ".", "x", ";", "int", "rightSide", "=", "containerBounds", ".", "x", "+", "containerBounds", ".", "width", ";", "List", "nodesToConsider", "=", "new", "LinkedList", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "orderedNodesBelowY", ".", "size", "(", ")", ";", "i", "++", ")", "{", "nodesToConsider", ".", "add", "(", "orderedNodesBelowY", ".", "get", "(", "i", ")", ")", ";", "}", "addNodeToOrderedList", "(", "orderedNodesBelowY", ",", "graphContainer", ")", ";", "while", "(", "nodesToConsider", ".", "size", "(", ")", ">", "0", ")", "{", "GraphNode", "node", "=", "(", "GraphNode", ")", "nodesToConsider", ".", "get", "(", "0", ")", ";", "if", "(", "nodeInStripe", "(", "leftSide", ",", "rightSide", ",", "node", ")", ")", "{", "leftSide", "=", "Math", ".", "min", "(", "leftSide", ",", "node", ".", "getBounds", "(", ")", ".", "x", ")", ";", "rightSide", "=", "Math", ".", "max", "(", "rightSide", ",", "node", ".", "getBounds", "(", ")", ".", "x", "+", "node", ".", "getBounds", "(", ")", ".", "width", ")", ";", "GraphNode", "previousNode", "=", "null", ";", "int", "i", "=", "0", ";", "for", "(", ";", "i", "<", "orderedNodesBelowY", ".", "size", "(", ")", ";", "i", "++", ")", "{", "if", "(", "orderedNodesBelowY", ".", "get", "(", "i", ")", "==", "node", ")", "{", "break", ";", "}", "}", "int", "j", "=", "i", "-", "1", ";", "while", "(", "j", ">=", "0", ")", "{", "GraphNode", "pastNode", "=", "(", "GraphNode", ")", "orderedNodesBelowY", ".", "get", "(", "j", ")", ";", "if", "(", "nodeInStripe", "(", "node", ".", "getBounds", "(", ")", ".", "x", ",", "node", ".", "getBounds", "(", ")", ".", "x", "+", "node", ".", "getBounds", "(", ")", ".", "width", ",", "pastNode", ")", ")", "{", "previousNode", "=", "pastNode", ";", "break", ";", "}", "j", "--", ";", "}", "if", "(", "previousNode", "==", "null", ")", "{", "previousNode", "=", "graphContainer", ";", "}", "int", "previousLocation", "=", "previousNode", ".", "getBounds", "(", ")", ".", "y", "+", "previousNode", ".", "getBounds", "(", ")", ".", "height", "+", "2", ";", "orderedNodesBelowY", ".", "remove", "(", "i", ")", ";", "node", ".", "setLocation", "(", "node", ".", "getLocation", "(", ")", ".", "x", ",", "previousLocation", ")", ";", "addNodeToOrderedList", "(", "orderedNodesBelowY", ",", "node", ")", ";", "}", "nodesToConsider", ".", "remove", "(", "node", ")", ";", "}", "}", "public", "void", "open", "(", "boolean", "animate", ")", "{", "if", "(", "animate", ")", "{", "Animation", ".", "markBegin", "(", ")", ";", "}", "isExpanded", "=", "true", ";", "expandGraphLabel", ".", "setExpandedState", "(", "true", ")", ";", "scrollPane", ".", "setSize", "(", "computeChildArea", "(", ")", ")", ";", "scrollPane", ".", "setVisible", "(", "true", ")", ";", "List", "children", "=", "this", ".", "zestLayer", ".", "getChildren", "(", ")", ";", "for", "(", "Iterator", "iterator", "=", "children", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "IFigure", "child", "=", "(", "IFigure", ")", "iterator", ".", "next", "(", ")", ";", "GraphItem", "item", "=", "getGraph", "(", ")", ".", "getGraphItem", "(", "child", ")", ";", "item", ".", "setVisible", "(", "true", ")", ";", "}", "updateFigureForModel", "(", "nodeFigure", ")", ";", "Rectangle", "containerBounds", "=", "new", "Rectangle", "(", "this", ".", "getLocation", "(", ")", ",", "new", "Dimension", "(", "this", ".", "getSize", "(", ")", ".", "width", ",", "CONTAINER_HEIGHT", "+", "this", ".", "expandGraphLabel", ".", "getSize", "(", ")", ".", "height", ")", ")", ";", "moveNodesDown", "(", "containerBounds", ",", "this", ")", ";", "moveNodesUp", "(", "containerBounds", ",", "this", ")", ";", "if", "(", "animate", ")", "{", "Animation", ".", "run", "(", "ANIMATION_TIME", ")", ";", "}", "this", ".", "getFigure", "(", ")", ".", "getUpdateManager", "(", ")", ".", "performValidation", "(", ")", ";", "}", "private", "void", "moveNodesDown", "(", "Rectangle", "containerBounds", ",", "GraphContainer", "graphContainer", ")", "{", "List", "nodesBelowHere", "=", "getOrderedNodesBelowY", "(", "parent", ".", "getGraph", "(", ")", ".", "getNodes", "(", ")", ",", "containerBounds", ".", "y", ",", "graphContainer", ")", ";", "Iterator", "nodesBelowHereIterator", "=", "nodesBelowHere", ".", "iterator", "(", ")", ";", "List", "nodesToMove", "=", "new", "LinkedList", "(", ")", ";", "int", "left", "=", "containerBounds", ".", "x", ";", "int", "right", "=", "containerBounds", ".", "x", "+", "containerBounds", ".", "width", ";", "while", "(", "nodesBelowHereIterator", ".", "hasNext", "(", ")", ")", "{", "GraphNode", "node", "=", "(", "GraphNode", ")", "nodesBelowHereIterator", ".", "next", "(", ")", ";", "if", "(", "nodeInStripe", "(", "left", ",", "right", ",", "node", ")", ")", "{", "nodesToMove", ".", "add", "(", "node", ")", ";", "left", "=", "Math", ".", "min", "(", "left", ",", "node", ".", "getBounds", "(", ")", ".", "x", ")", ";", "right", "=", "Math", ".", "max", "(", "right", ",", "node", ".", "getBounds", "(", ")", ".", "x", "+", "node", ".", "getBounds", "(", ")", ".", "width", ")", ";", "}", "}", "List", "intersectingNodes", "=", "intersectingNodes", "(", "containerBounds", ",", "nodesToMove", ",", "graphContainer", ")", ";", "int", "delta", "=", "getMaxMovement", "(", "containerBounds", ",", "intersectingNodes", ")", ";", "if", "(", "delta", ">", "0", ")", "{", "shiftNodesDown", "(", "nodesToMove", ",", "delta", ")", ";", "}", "}", "private", "List", "intersectingNodes", "(", "Rectangle", "bounds", ",", "List", "nodesToCheck", ",", "GraphNode", "node", ")", "{", "List", "result", "=", "new", "LinkedList", "(", ")", ";", "Iterator", "nodes", "=", "nodesToCheck", ".", "iterator", "(", ")", ";", "while", "(", "nodes", ".", "hasNext", "(", ")", ")", "{", "GraphNode", "nodeToCheck", "=", "(", "GraphNode", ")", "nodes", ".", "next", "(", ")", ";", "if", "(", "node", "==", "nodeToCheck", ")", "{", "continue", ";", "}", "if", "(", "bounds", ".", "intersects", "(", "nodeToCheck", ".", "getBounds", "(", ")", ")", ")", "{", "result", ".", "add", "(", "nodeToCheck", ")", ";", "}", "}", "return", "result", ";", "}", "private", "int", "getMaxMovement", "(", "Rectangle", "bounds", ",", "List", "nodesToMove", ")", "{", "Iterator", "iterator", "=", "nodesToMove", ".", "iterator", "(", ")", ";", "int", "maxMovement", "=", "0", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "GraphNode", "node", "=", "(", "GraphNode", ")", "iterator", ".", "next", "(", ")", ";", "int", "yValue", "=", "node", ".", "getLocation", "(", ")", ".", "y", ";", "int", "distanceFromBottom", "=", "(", "bounds", ".", "y", "+", "bounds", ".", "height", ")", "-", "yValue", ";", "maxMovement", "=", "Math", ".", "max", "(", "maxMovement", ",", "distanceFromBottom", ")", ";", "}", "return", "maxMovement", "+", "3", ";", "}", "private", "void", "shiftNodesDown", "(", "List", "nodesToShift", ",", "int", "amount", ")", "{", "Iterator", "iterator", "=", "nodesToShift", ".", "iterator", "(", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "GraphNode", "node", "=", "(", "GraphNode", ")", "iterator", ".", "next", "(", ")", ";", "node", ".", "setLocation", "(", "node", ".", "getLocation", "(", ")", ".", "x", ",", "node", ".", "getLocation", "(", ")", ".", "y", "+", "amount", ")", ";", "}", "}", "public", "Graph", "getGraph", "(", ")", "{", "return", "this", ".", "graph", ";", "}", "public", "Widget", "getItem", "(", ")", "{", "return", "this", ";", "}", "public", "int", "getItemType", "(", ")", "{", "return", "CONTAINER", ";", "}", "public", "void", "setLayoutAlgorithm", "(", "LayoutAlgorithm", "algorithm", ",", "boolean", "applyLayout", ")", "{", "this", ".", "layoutAlgorithm", "=", "algorithm", ";", "this", ".", "layoutAlgorithm", ".", "setLayoutContext", "(", "getLayoutContext", "(", ")", ")", ";", "if", "(", "applyLayout", ")", "{", "applyLayout", "(", ")", ";", "}", "}", "public", "InternalLayoutContext", "getLayoutContext", "(", ")", "{", "if", "(", "layoutContext", "==", "null", ")", "{", "layoutContext", "=", "new", "InternalLayoutContext", "(", "this", ")", ";", "}", "return", "layoutContext", ";", "}", "public", "DisplayIndependentRectangle", "getLayoutBounds", "(", ")", "{", "double", "width", "=", "GraphContainer", ".", "SCALED_WIDTH", "-", "10", ";", "double", "height", "=", "GraphContainer", ".", "SCALED_HEIGHT", "-", "10", ";", "return", "new", "DisplayIndependentRectangle", "(", "25", ",", "25", ",", "width", "-", "50", ",", "height", "-", "50", ")", ";", "}", "public", "void", "applyLayout", "(", ")", "{", "if", "(", "layoutAlgorithm", "==", "null", ")", "{", "setLayoutAlgorithm", "(", "new", "TreeLayoutAlgorithm", "(", ")", ",", "false", ")", ";", "}", "Animation", ".", "markBegin", "(", ")", ";", "layoutAlgorithm", ".", "applyLayout", "(", "true", ")", ";", "layoutContext", ".", "flushChanges", "(", "false", ")", ";", "Animation", ".", "run", "(", "ANIMATION_TIME", ")", ";", "getFigure", "(", ")", ".", "getUpdateManager", "(", ")", ".", "performUpdate", "(", ")", ";", "}", "public", "double", "getScale", "(", ")", "{", "return", "this", ".", "scalledLayer", ".", "getScale", "(", ")", ";", "}", "public", "void", "setScale", "(", "double", "scale", ")", "{", "this", ".", "scalledLayer", ".", "setScale", "(", "scale", ")", ";", "}", "protected", "void", "initFigure", "(", ")", "{", "nodeFigure", "=", "createContainerFigure", "(", ")", ";", "}", "class", "ContainerDimension", "{", "int", "width", ";", "int", "labelHeight", ";", "int", "expandedHeight", ";", "}", "private", "Dimension", "computeChildArea", "(", ")", "{", "ContainerDimension", "containerDimension", "=", "computeContainerSize", "(", ")", ";", "Dimension", "dimension", "=", "new", "Dimension", "(", ")", ";", "dimension", ".", "width", "=", "containerDimension", ".", "width", ";", "dimension", ".", "height", "=", "containerDimension", ".", "expandedHeight", "-", "containerDimension", ".", "labelHeight", "+", "SUBLAYER_OFFSET", ";", "return", "dimension", ";", "}", "private", "ContainerDimension", "computeContainerSize", "(", ")", "{", "ContainerDimension", "dimension", "=", "new", "ContainerDimension", "(", ")", ";", "int", "labelHeight", "=", "expandGraphLabel", ".", "getPreferredSize", "(", ")", ".", "height", ";", "int", "labelWidth", "=", "expandGraphLabel", ".", "getPreferredSize", "(", ")", ".", "width", ";", "if", "(", "labelWidth", "<", "MIN_WIDTH", ")", "{", "labelWidth", "=", "MIN_WIDTH", ";", "expandGraphLabel", ".", "setPreferredSize", "(", "labelWidth", ",", "labelHeight", ")", ";", "}", "dimension", ".", "labelHeight", "=", "Math", ".", "max", "(", "labelHeight", ",", "MIN_HEIGHT", ")", ";", "dimension", ".", "width", "=", "Math", ".", "max", "(", "labelWidth", ",", "this", ".", "size", ".", "width", ")", ";", "dimension", ".", "expandedHeight", "=", "Math", ".", "max", "(", "dimension", ".", "labelHeight", "+", "childAreaHeight", "-", "SUBLAYER_OFFSET", ",", "this", ".", "size", ".", "height", ")", ";", "return", "dimension", ";", "}", "private", "double", "computeHeightScale", "(", ")", "{", "Dimension", "childArea", "=", "computeChildArea", "(", ")", ";", "double", "heightScale", "=", "childArea", ".", "height", "/", "SCALED_HEIGHT", ";", "return", "heightScale", ";", "}", "private", "double", "computeWidthScale", "(", ")", "{", "Dimension", "childArea", "=", "computeChildArea", "(", ")", ";", "double", "widthScale", "=", "childArea", ".", "width", "/", "SCALED_WIDTH", ";", "return", "widthScale", ";", "}", "private", "IFigure", "createContainerFigure", "(", ")", "{", "GraphContainer", "node", "=", "this", ";", "IFigure", "containerFigure", "=", "new", "ContainerFigure", "(", ")", ";", "containerFigure", ".", "setOpaque", "(", "true", ")", ";", "containerFigure", ".", "addLayoutListener", "(", "LayoutAnimator", ".", "getDefault", "(", ")", ")", ";", "containerFigure", ".", "setLayoutManager", "(", "new", "FreeformLayout", "(", ")", ")", ";", "expandGraphLabel", "=", "new", "ExpandGraphLabel", "(", "this", ",", "node", ".", "getText", "(", ")", ",", "node", ".", "getImage", "(", ")", ",", "false", ")", ";", "expandGraphLabel", ".", "setText", "(", "getText", "(", ")", ")", ";", "expandGraphLabel", ".", "setImage", "(", "getImage", "(", ")", ")", ";", "ContainerDimension", "containerDimension", "=", "computeContainerSize", "(", ")", ";", "scrollPane", "=", "new", "ScrollPane", "(", ")", ";", "scrollPane", ".", "addLayoutListener", "(", "LayoutAnimator", ".", "getDefault", "(", ")", ")", ";", "Viewport", "viewport", "=", "new", "FreeformViewport", "(", ")", ";", "scrollPane", ".", "setViewport", "(", "viewport", ")", ";", "viewport", ".", "addLayoutListener", "(", "LayoutAnimator", ".", "getDefault", "(", ")", ")", ";", "scrollPane", ".", "setScrollBarVisibility", "(", "ScrollPane", ".", "AUTOMATIC", ")", ";", "scalledLayer", "=", "new", "AspectRatioFreeformLayer", "(", "\"debug", "label\"", ")", ";", "scalledLayer", ".", "addLayoutListener", "(", "LayoutAnimator", ".", "getDefault", "(", ")", ")", ";", "scalledLayer", ".", "setScale", "(", "computeWidthScale", "(", ")", ",", "computeHeightScale", "(", ")", ")", ";", "zestLayer", "=", "new", "ZestRootLayer", "(", ")", ";", "zestLayer", ".", "addLayoutListener", "(", "LayoutAnimator", ".", "getDefault", "(", ")", ")", ";", "scalledLayer", ".", "add", "(", "zestLayer", ")", ";", "zestLayer", ".", "setLayoutManager", "(", "new", "FreeformLayout", "(", ")", ")", ";", "scrollPane", ".", "setSize", "(", "computeChildArea", "(", ")", ")", ";", "scrollPane", ".", "setLocation", "(", "new", "Point", "(", "0", ",", "containerDimension", ".", "labelHeight", "-", "SUBLAYER_OFFSET", ")", ")", ";", "scrollPane", ".", "setForegroundColor", "(", "ColorConstants", ".", "gray", ")", ";", "expandGraphLabel", ".", "setBackgroundColor", "(", "getBackgroundColor", "(", ")", ")", ";", "expandGraphLabel", ".", "setForegroundColor", "(", "getForegroundColor", "(", ")", ")", ";", "expandGraphLabel", ".", "setLocation", "(", "new", "Point", "(", "0", ",", "0", ")", ")", ";", "containerFigure", ".", "add", "(", "scrollPane", ")", ";", "containerFigure", ".", "add", "(", "expandGraphLabel", ")", ";", "scrollPane", ".", "getViewport", "(", ")", ".", "setContents", "(", "scalledLayer", ")", ";", "scrollPane", ".", "setBorder", "(", "new", "LineBorder", "(", ")", ")", ";", "return", "containerFigure", ";", "}", "private", "void", "registerToParent", "(", "IContainer", "parent", ")", "{", "if", "(", "parent", ".", "getItemType", "(", ")", "==", "GRAPH", ")", "{", "createSelectionListener", "(", ")", ";", "parent", ".", "getGraph", "(", ")", ".", "addSelectionListener", "(", "selectionListener", ")", ";", "}", "}", "private", "void", "createSelectionListener", "(", ")", "{", "if", "(", "selectionListener", "==", "null", ")", "{", "selectionListener", "=", "new", "SelectionListener", "(", ")", "{", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "if", "(", "e", ".", "item", "instanceof", "GraphContainer", ")", "{", "(", "(", "GraphContainer", ")", "e", ".", "item", ")", ".", "expandGraphLabel", ".", "setFocus", "(", ")", ";", "}", "}", "public", "void", "widgetDefaultSelected", "(", "SelectionEvent", "e", ")", "{", "}", "}", ";", "}", "}", "protected", "void", "updateFigureForModel", "(", "IFigure", "currentFigure", ")", "{", "if", "(", "expandGraphLabel", "==", "null", ")", "{", "initFigure", "(", ")", ";", "}", "expandGraphLabel", ".", "setTextT", "(", "getText", "(", ")", ")", ";", "expandGraphLabel", ".", "setImage", "(", "getImage", "(", ")", ")", ";", "expandGraphLabel", ".", "setFont", "(", "getFont", "(", ")", ")", ";", "if", "(", "highlighted", "==", "HIGHLIGHT_ON", ")", "{", "expandGraphLabel", ".", "setForegroundColor", "(", "getForegroundColor", "(", ")", ")", ";", "expandGraphLabel", ".", "setBackgroundColor", "(", "getHighlightColor", "(", ")", ")", ";", "}", "else", "{", "expandGraphLabel", ".", "setForegroundColor", "(", "getForegroundColor", "(", ")", ")", ";", "expandGraphLabel", ".", "setBackgroundColor", "(", "getBackgroundColor", "(", ")", ")", ";", "}", "ContainerDimension", "containerDimension", "=", "computeContainerSize", "(", ")", ";", "expandGraphLabel", ".", "setSize", "(", "containerDimension", ".", "width", ",", "containerDimension", ".", "labelHeight", ")", ";", "if", "(", "isExpanded", ")", "{", "setSize", "(", "containerDimension", ".", "width", ",", "containerDimension", ".", "expandedHeight", ")", ";", "}", "else", "{", "setSize", "(", "containerDimension", ".", "width", ",", "containerDimension", ".", "labelHeight", ")", ";", "}", "scrollPane", ".", "setLocation", "(", "new", "Point", "(", "expandGraphLabel", ".", "getLocation", "(", ")", ".", "x", ",", "expandGraphLabel", ".", "getLocation", "(", ")", ".", "y", "+", "containerDimension", ".", "labelHeight", "-", "SUBLAYER_OFFSET", ")", ")", ";", "}", "void", "refreshBounds", "(", ")", "{", "if", "(", "nodeFigure", "==", "null", "||", "nodeFigure", ".", "getParent", "(", ")", "==", "null", ")", "{", "return", ";", "}", "GraphNode", "node", "=", "this", ";", "Point", "loc", "=", "node", ".", "getLocation", "(", ")", ";", "ContainerDimension", "containerDimension", "=", "computeContainerSize", "(", ")", ";", "Dimension", "size", "=", "new", "Dimension", "(", ")", ";", "expandGraphLabel", ".", "setSize", "(", "containerDimension", ".", "width", ",", "containerDimension", ".", "labelHeight", ")", ";", "this", ".", "childAreaHeight", "=", "computeChildArea", "(", ")", ".", "height", ";", "if", "(", "isExpanded", ")", "{", "size", ".", "width", "=", "containerDimension", ".", "width", ";", "size", ".", "height", "=", "containerDimension", ".", "expandedHeight", ";", "}", "else", "{", "size", ".", "width", "=", "containerDimension", ".", "width", ";", "size", ".", "height", "=", "containerDimension", ".", "labelHeight", ";", "}", "Rectangle", "bounds", "=", "new", "Rectangle", "(", "loc", ",", "size", ")", ";", "nodeFigure", ".", "getParent", "(", ")", ".", "setConstraint", "(", "nodeFigure", ",", "bounds", ")", ";", "scrollPane", ".", "setLocation", "(", "new", "Point", "(", "expandGraphLabel", ".", "getLocation", "(", ")", ".", "x", ",", "expandGraphLabel", ".", "getLocation", "(", ")", ".", "y", "+", "containerDimension", ".", "labelHeight", "-", "SUBLAYER_OFFSET", ")", ")", ";", "scrollPane", ".", "setSize", "(", "computeChildArea", "(", ")", ")", ";", "scalledLayer", ".", "setScale", "(", "computeWidthScale", "(", ")", ",", "computeHeightScale", "(", ")", ")", ";", "}", "public", "void", "addSubgraphFigure", "(", "IFigure", "figure", ")", "{", "zestLayer", ".", "addSubgraph", "(", "figure", ")", ";", "graph", ".", "subgraphFigures", ".", "add", "(", "figure", ")", ";", "}", "void", "addConnectionFigure", "(", "IFigure", "figure", ")", "{", "nodeFigure", ".", "add", "(", "figure", ")", ";", "}", "public", "void", "addNode", "(", "GraphNode", "node", ")", "{", "zestLayer", ".", "addNode", "(", "node", ".", "getNodeFigure", "(", ")", ")", ";", "this", ".", "childNodes", ".", "add", "(", "node", ")", ";", "node", ".", "setVisible", "(", "isExpanded", ")", ";", "}", "public", "List", "getNodes", "(", ")", "{", "return", "this", ".", "childNodes", ";", "}", "public", "List", "getConnections", "(", ")", "{", "return", "filterConnections", "(", "getGraph", "(", ")", ".", "getConnections", "(", ")", ")", ";", "}", "private", "List", "filterConnections", "(", "List", "connections", ")", "{", "List", "result", "=", "new", "ArrayList", "(", ")", ";", "for", "(", "Iterator", "iterator", "=", "connections", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "GraphConnection", "connection", "=", "(", "GraphConnection", ")", "iterator", ".", "next", "(", ")", ";", "if", "(", "connection", ".", "getSource", "(", ")", ".", "getParent", "(", ")", "==", "this", "&&", "connection", ".", "getDestination", "(", ")", ".", "getParent", "(", ")", "==", "this", ")", "{", "result", ".", "add", "(", "connection", ")", ";", "}", "}", "return", "result", ";", "}", "public", "LayoutAlgorithm", "getLayoutAlgorithm", "(", ")", "{", "return", "layoutAlgorithm", ";", "}", "}", "</s>" ]
10,275
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Animation", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ColorConstants", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "FigureListener", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "IFigure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Label", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Dimension", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Insets", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Point", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "PrecisionPoint", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Rectangle", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Color", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Font", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Image", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "internal", ".", "GraphLabel", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "internal", ".", "ZestRootLayer", ";", "public", "class", "GraphNode", "extends", "GraphItem", "{", "public", "static", "final", "int", "HIGHLIGHT_NONE", "=", "0", ";", "public", "static", "final", "int", "HIGHLIGHT_ON", "=", "1", ";", "private", "int", "nodeStyle", ";", "private", "List", "sourceConnections", ";", "private", "List", "targetConnections", ";", "private", "Color", "foreColor", ";", "private", "Color", "backColor", ";", "private", "Color", "highlightColor", ";", "private", "Color", "borderColor", ";", "private", "Color", "borderHighlightColor", ";", "private", "int", "borderWidth", ";", "private", "PrecisionPoint", "currentLocation", ";", "protected", "Dimension", "size", ";", "private", "Font", "font", ";", "private", "boolean", "cacheLabel", ";", "private", "boolean", "visible", "=", "true", ";", "protected", "Graph", "graph", ";", "protected", "IContainer", "parent", ";", "protected", "Object", "internalNode", ";", "private", "boolean", "selected", ";", "protected", "int", "highlighted", "=", "HIGHLIGHT_NONE", ";", "private", "IFigure", "tooltip", ";", "protected", "IFigure", "nodeFigure", ";", "private", "boolean", "isDisposed", "=", "false", ";", "private", "boolean", "hasCustomTooltip", ";", "public", "GraphNode", "(", "IContainer", "graphModel", ",", "int", "style", ")", "{", "this", "(", "graphModel", ",", "style", ",", "(", "IFigure", ")", "null", ")", ";", "}", "public", "GraphNode", "(", "IContainer", "graphModel", ",", "int", "style", ",", "String", "text", ")", "{", "this", "(", "graphModel", ",", "style", ",", "text", ",", "null", ",", "null", ")", ";", "}", "public", "GraphNode", "(", "IContainer", "graphModel", ",", "int", "style", ",", "Object", "data", ")", "{", "this", "(", "graphModel", ",", "style", ",", "\"\"", ",", "null", ",", "data", ")", ";", "}", "public", "GraphNode", "(", "IContainer", "graphModel", ",", "int", "style", ",", "String", "text", ",", "Image", "image", ")", "{", "this", "(", "graphModel", ",", "style", ",", "text", ",", "image", ",", "null", ")", ";", "}", "protected", "GraphNode", "(", "IContainer", "graphModel", ",", "int", "style", ",", "IFigure", "figure", ")", "{", "this", "(", "graphModel", ",", "style", ",", "\"\"", ",", "null", ",", "figure", ")", ";", "}", "private", "GraphNode", "(", "IContainer", "graphModel", ",", "int", "style", ",", "String", "text", ",", "Image", "image", ",", "Object", "data", ")", "{", "super", "(", "graphModel", ",", "style", ",", "data", ")", ";", "initModel", "(", "graphModel", ",", "text", ",", "image", ")", ";", "if", "(", "nodeFigure", "==", "null", ")", "{", "initFigure", "(", ")", ";", "}", "this", ".", "parent", ".", "addNode", "(", "this", ")", ";", "this", ".", "parent", ".", "getGraph", "(", ")", ".", "registerItem", "(", "this", ")", ";", "}", "protected", "void", "initFigure", "(", ")", "{", "nodeFigure", "=", "createFigureForModel", "(", ")", ";", "}", "static", "int", "count", "=", "0", ";", "protected", "void", "initModel", "(", "IContainer", "graphModel", ",", "String", "text", ",", "Image", "image", ")", "{", "this", ".", "nodeStyle", "|=", "graphModel", ".", "getGraph", "(", ")", ".", "getNodeStyle", "(", ")", ";", "this", ".", "parent", "=", "graphModel", ";", "this", ".", "sourceConnections", "=", "new", "ArrayList", "(", ")", ";", "this", ".", "targetConnections", "=", "new", "ArrayList", "(", ")", ";", "this", ".", "foreColor", "=", "graphModel", ".", "getGraph", "(", ")", ".", "DARK_BLUE", ";", "this", ".", "backColor", "=", "graphModel", ".", "getGraph", "(", ")", ".", "LIGHT_BLUE", ";", "this", ".", "highlightColor", "=", "graphModel", ".", "getGraph", "(", ")", ".", "HIGHLIGHT_COLOR", ";", "this", ".", "borderColor", "=", "ColorConstants", ".", "lightGray", ";", "this", ".", "borderHighlightColor", "=", "ColorConstants", ".", "blue", ";", "this", ".", "borderWidth", "=", "1", ";", "this", ".", "currentLocation", "=", "new", "PrecisionPoint", "(", "0", ",", "0", ")", ";", "this", ".", "size", "=", "new", "Dimension", "(", "-", "1", ",", "-", "1", ")", ";", "this", ".", "font", "=", "Display", ".", "getDefault", "(", ")", ".", "getSystemFont", "(", ")", ";", "this", ".", "graph", "=", "graphModel", ".", "getGraph", "(", ")", ";", "this", ".", "cacheLabel", "=", "false", ";", "this", ".", "setText", "(", "text", ")", ";", "if", "(", "image", "!=", "null", ")", "{", "this", ".", "setImage", "(", "image", ")", ";", "}", "if", "(", "font", "==", "null", ")", "{", "font", "=", "Display", ".", "getDefault", "(", ")", ".", "getSystemFont", "(", ")", ";", "}", "}", "public", "String", "toString", "(", ")", "{", "return", "\"\"", "+", "getText", "(", ")", ";", "}", "public", "void", "dispose", "(", ")", "{", "if", "(", "isFisheyeEnabled", ")", "{", "this", ".", "fishEye", "(", "false", ",", "false", ")", ";", "}", "super", ".", "dispose", "(", ")", ";", "this", ".", "isDisposed", "=", "true", ";", "while", "(", "getSourceConnections", "(", ")", ".", "size", "(", ")", ">", "0", ")", "{", "GraphConnection", "connection", "=", "(", "GraphConnection", ")", "getSourceConnections", "(", ")", ".", "get", "(", "0", ")", ";", "if", "(", "!", "connection", ".", "isDisposed", "(", ")", ")", "{", "connection", ".", "dispose", "(", ")", ";", "}", "else", "{", "removeSourceConnection", "(", "connection", ")", ";", "}", "}", "while", "(", "getTargetConnections", "(", ")", ".", "size", "(", ")", ">", "0", ")", "{", "GraphConnection", "connection", "=", "(", "GraphConnection", ")", "getTargetConnections", "(", ")", ".", "get", "(", "0", ")", ";", "if", "(", "!", "connection", ".", "isDisposed", "(", ")", ")", "{", "connection", ".", "dispose", "(", ")", ";", "}", "else", "{", "removeTargetConnection", "(", "connection", ")", ";", "}", "}", "graph", ".", "removeNode", "(", "this", ")", ";", "}", "public", "boolean", "isDisposed", "(", ")", "{", "return", "isDisposed", ";", "}", "public", "boolean", "isSizeFixed", "(", ")", "{", "return", "!", "(", "this", ".", "size", ".", "width", "<", "0", "&&", "this", ".", "size", ".", "height", "<", "0", ")", ";", "}", "public", "List", "getSourceConnections", "(", ")", "{", "return", "new", "ArrayList", "(", "sourceConnections", ")", ";", "}", "public", "List", "getTargetConnections", "(", ")", "{", "return", "new", "ArrayList", "(", "targetConnections", ")", ";", "}", "Rectangle", "getBounds", "(", ")", "{", "return", "new", "Rectangle", "(", "getLocation", "(", ")", ",", "getSize", "(", ")", ")", ";", "}", "public", "Point", "getLocation", "(", ")", "{", "return", "currentLocation", ";", "}", "public", "boolean", "isSelected", "(", ")", "{", "return", "selected", ";", "}", "public", "void", "setLocation", "(", "double", "x", ",", "double", "y", ")", "{", "if", "(", "currentLocation", ".", "preciseX", "(", ")", "!=", "x", "||", "currentLocation", ".", "preciseY", "(", ")", "!=", "y", ")", "{", "currentLocation", ".", "setPreciseX", "(", "x", ")", ";", "currentLocation", ".", "setPreciseY", "(", "y", ")", ";", "refreshBounds", "(", ")", ";", "if", "(", "getGraphModel", "(", ")", ".", "isDynamicLayoutEnabled", "(", ")", ")", "{", "parent", ".", "getLayoutContext", "(", ")", ".", "fireNodeMovedEvent", "(", "this", ".", "getLayout", "(", ")", ")", ";", "}", "}", "}", "public", "Dimension", "getSize", "(", ")", "{", "if", "(", "size", ".", "height", "<", "0", "&&", "size", ".", "width", "<", "0", "&&", "nodeFigure", "!=", "null", ")", "{", "return", "nodeFigure", ".", "getSize", "(", ")", ".", "getCopy", "(", ")", ";", "}", "return", "size", ".", "getCopy", "(", ")", ";", "}", "public", "Color", "getForegroundColor", "(", ")", "{", "return", "foreColor", ";", "}", "public", "void", "setForegroundColor", "(", "Color", "c", ")", "{", "this", ".", "foreColor", "=", "c", ";", "updateFigureForModel", "(", "nodeFigure", ")", ";", "}", "public", "Color", "getBackgroundColor", "(", ")", "{", "return", "backColor", ";", "}", "public", "void", "setBackgroundColor", "(", "Color", "c", ")", "{", "backColor", "=", "c", ";", "updateFigureForModel", "(", "nodeFigure", ")", ";", "}", "public", "void", "setTooltip", "(", "IFigure", "tooltip", ")", "{", "hasCustomTooltip", "=", "true", ";", "this", ".", "tooltip", "=", "tooltip", ";", "updateFigureForModel", "(", "nodeFigure", ")", ";", "}", "public", "IFigure", "getTooltip", "(", ")", "{", "return", "this", ".", "tooltip", ";", "}", "public", "void", "setBorderColor", "(", "Color", "c", ")", "{", "borderColor", "=", "c", ";", "updateFigureForModel", "(", "nodeFigure", ")", ";", "}", "public", "void", "setBorderHighlightColor", "(", "Color", "c", ")", "{", "this", ".", "borderHighlightColor", "=", "c", ";", "updateFigureForModel", "(", "nodeFigure", ")", ";", "}", "public", "Color", "getHighlightColor", "(", ")", "{", "return", "highlightColor", ";", "}", "public", "void", "setHighlightColor", "(", "Color", "c", ")", "{", "this", ".", "highlightColor", "=", "c", ";", "}", "public", "void", "highlight", "(", ")", "{", "if", "(", "highlighted", "==", "HIGHLIGHT_ON", ")", "{", "return", ";", "}", "IFigure", "parentFigure", "=", "nodeFigure", ".", "getParent", "(", ")", ";", "if", "(", "parentFigure", "instanceof", "ZestRootLayer", ")", "{", "(", "(", "ZestRootLayer", ")", "parentFigure", ")", ".", "highlightNode", "(", "nodeFigure", ")", ";", "}", "highlighted", "=", "HIGHLIGHT_ON", ";", "updateFigureForModel", "(", "getNodeFigure", "(", ")", ")", ";", "}", "public", "void", "unhighlight", "(", ")", "{", "if", "(", "highlighted", "==", "HIGHLIGHT_NONE", ")", "{", "return", ";", "}", "IFigure", "parentFigure", "=", "nodeFigure", ".", "getParent", "(", ")", ";", "if", "(", "parentFigure", "instanceof", "ZestRootLayer", ")", "{", "(", "(", "ZestRootLayer", ")", "parentFigure", ")", ".", "unHighlightNode", "(", "nodeFigure", ")", ";", "}", "highlighted", "=", "HIGHLIGHT_NONE", ";", "updateFigureForModel", "(", "nodeFigure", ")", ";", "}", "void", "refreshBounds", "(", ")", "{", "Point", "loc", "=", "this", ".", "getLocation", "(", ")", ";", "Dimension", "size", "=", "this", ".", "getSize", "(", ")", ";", "Rectangle", "bounds", "=", "new", "Rectangle", "(", "loc", ",", "size", ")", ";", "if", "(", "nodeFigure", "==", "null", "||", "nodeFigure", ".", "getParent", "(", ")", "==", "null", ")", "{", "return", ";", "}", "nodeFigure", ".", "getParent", "(", ")", ".", "setConstraint", "(", "nodeFigure", ",", "bounds", ")", ";", "if", "(", "isFisheyeEnabled", ")", "{", "Rectangle", "fishEyeBounds", "=", "calculateFishEyeBounds", "(", ")", ";", "if", "(", "fishEyeBounds", "!=", "null", ")", "{", "fishEyeFigure", ".", "getParent", "(", ")", ".", "translateToRelative", "(", "fishEyeBounds", ")", ";", "fishEyeFigure", ".", "getParent", "(", ")", ".", "translateFromParent", "(", "fishEyeBounds", ")", ";", "fishEyeFigure", ".", "getParent", "(", ")", ".", "setConstraint", "(", "fishEyeFigure", ",", "fishEyeBounds", ")", ";", "}", "}", "}", "public", "Color", "getBorderColor", "(", ")", "{", "return", "borderColor", ";", "}", "public", "int", "getBorderWidth", "(", ")", "{", "return", "borderWidth", ";", "}", "public", "void", "setBorderWidth", "(", "int", "width", ")", "{", "this", ".", "borderWidth", "=", "width", ";", "updateFigureForModel", "(", "nodeFigure", ")", ";", "}", "public", "Font", "getFont", "(", ")", "{", "return", "font", ";", "}", "public", "void", "setFont", "(", "Font", "font", ")", "{", "this", ".", "font", "=", "font", ";", "updateFigureForModel", "(", "nodeFigure", ")", ";", "}", "public", "void", "setText", "(", "String", "string", ")", "{", "if", "(", "string", "==", "null", ")", "{", "string", "=", "\"\"", ";", "}", "super", ".", "setText", "(", "string", ")", ";", "updateFigureForModel", "(", "this", ".", "nodeFigure", ")", ";", "}", "public", "void", "setImage", "(", "Image", "image", ")", "{", "super", ".", "setImage", "(", "image", ")", ";", "updateFigureForModel", "(", "nodeFigure", ")", ";", "}", "public", "Graph", "getGraphModel", "(", ")", "{", "return", "this", ".", "graph", ";", "}", "public", "int", "getNodeStyle", "(", ")", "{", "return", "nodeStyle", ";", "}", "public", "void", "setNodeStyle", "(", "int", "nodeStyle", ")", "{", "this", ".", "nodeStyle", "=", "nodeStyle", ";", "this", ".", "cacheLabel", "=", "(", "(", "this", ".", "nodeStyle", "&", "ZestStyles", ".", "NODES_CACHE_LABEL", ")", ">", "0", ")", "?", "true", ":", "false", ";", "}", "public", "void", "setSize", "(", "double", "width", ",", "double", "height", ")", "{", "if", "(", "(", "width", "!=", "size", ".", "width", ")", "||", "(", "height", "!=", "size", ".", "height", ")", ")", "{", "size", ".", "width", "=", "(", "int", ")", "width", ";", "size", ".", "height", "=", "(", "int", ")", "height", ";", "refreshBounds", "(", ")", ";", "}", "}", "public", "Color", "getBorderHighlightColor", "(", ")", "{", "return", "borderHighlightColor", ";", "}", "public", "boolean", "cacheLabel", "(", ")", "{", "return", "this", ".", "cacheLabel", ";", "}", "public", "void", "setCacheLabel", "(", "boolean", "cacheLabel", ")", "{", "this", ".", "cacheLabel", "=", "cacheLabel", ";", "}", "IFigure", "getNodeFigure", "(", ")", "{", "return", "this", ".", "nodeFigure", ";", "}", "public", "void", "setVisible", "(", "boolean", "visible", ")", "{", "this", ".", "visible", "=", "visible", ";", "this", ".", "getFigure", "(", ")", ".", "setVisible", "(", "visible", ")", ";", "for", "(", "Iterator", "iterator2", "=", "sourceConnections", ".", "iterator", "(", ")", ";", "iterator2", ".", "hasNext", "(", ")", ";", ")", "{", "GraphConnection", "connection", "=", "(", "GraphConnection", ")", "iterator2", ".", "next", "(", ")", ";", "connection", ".", "setVisible", "(", "visible", ")", ";", "}", "for", "(", "Iterator", "iterator2", "=", "targetConnections", ".", "iterator", "(", ")", ";", "iterator2", ".", "hasNext", "(", ")", ";", ")", "{", "GraphConnection", "connection", "=", "(", "GraphConnection", ")", "iterator2", ".", "next", "(", ")", ";", "connection", ".", "setVisible", "(", "visible", ")", ";", "}", "}", "public", "boolean", "isVisible", "(", ")", "{", "return", "visible", ";", "}", "public", "int", "getStyle", "(", ")", "{", "return", "super", ".", "getStyle", "(", ")", "|", "this", ".", "getNodeStyle", "(", ")", ";", "}", "private", "IFigure", "fishEyeFigure", "=", "null", ";", "private", "boolean", "isFisheyeEnabled", ";", "protected", "IFigure", "fishEye", "(", "boolean", "enable", ",", "boolean", "animate", ")", "{", "if", "(", "isDisposed", ")", "{", "return", "null", ";", "}", "if", "(", "!", "checkStyle", "(", "ZestStyles", ".", "NODES_FISHEYE", ")", ")", "{", "return", "null", ";", "}", "if", "(", "enable", ")", "{", "fishEyeFigure", "=", "createFishEyeFigure", "(", ")", ";", "Rectangle", "rectangle", "=", "calculateFishEyeBounds", "(", ")", ";", "if", "(", "rectangle", "==", "null", ")", "{", "return", "null", ";", "}", "this", ".", "getGraphModel", "(", ")", ".", "fishEye", "(", "nodeFigure", ",", "fishEyeFigure", ",", "rectangle", ",", "true", ")", ";", "if", "(", "fishEyeFigure", "!=", "null", ")", "{", "isFisheyeEnabled", "=", "true", ";", "}", "return", "fishEyeFigure", ";", "}", "else", "{", "isFisheyeEnabled", "=", "false", ";", "this", ".", "getGraphModel", "(", ")", ".", "removeFishEye", "(", "fishEyeFigure", ",", "nodeFigure", ",", "animate", ")", ";", "return", "null", ";", "}", "}", "IContainer", "getParent", "(", ")", "{", "return", "parent", ";", "}", "boolean", "isHighlighted", "(", ")", "{", "return", "highlighted", ">", "0", ";", "}", "protected", "void", "updateFigureForModel", "(", "IFigure", "currentFigure", ")", "{", "if", "(", "currentFigure", "==", "null", ")", "{", "return", ";", "}", "IFigure", "figure", "=", "currentFigure", ";", "IFigure", "toolTip", ";", "if", "(", "figure", "instanceof", "ILabeledFigure", ")", "{", "ILabeledFigure", "labeledFigure", "=", "(", "ILabeledFigure", ")", "figure", ";", "if", "(", "!", "checkStyle", "(", "ZestStyles", ".", "NODES_HIDE_TEXT", ")", "&&", "!", "labeledFigure", ".", "getText", "(", ")", ".", "equals", "(", "this", ".", "getText", "(", ")", ")", ")", "{", "labeledFigure", ".", "setText", "(", "this", ".", "getText", "(", ")", ")", ";", "}", "if", "(", "labeledFigure", ".", "getIcon", "(", ")", "!=", "getImage", "(", ")", ")", "{", "labeledFigure", ".", "setIcon", "(", "getImage", "(", ")", ")", ";", "}", "}", "if", "(", "figure", "instanceof", "IStyleableFigure", ")", "{", "IStyleableFigure", "styleableFigure", "=", "(", "IStyleableFigure", ")", "figure", ";", "if", "(", "highlighted", "==", "HIGHLIGHT_ON", ")", "{", "styleableFigure", ".", "setForegroundColor", "(", "getForegroundColor", "(", ")", ")", ";", "styleableFigure", ".", "setBackgroundColor", "(", "getHighlightColor", "(", ")", ")", ";", "styleableFigure", ".", "setBorderColor", "(", "getBorderHighlightColor", "(", ")", ")", ";", "}", "else", "{", "styleableFigure", ".", "setForegroundColor", "(", "getForegroundColor", "(", ")", ")", ";", "styleableFigure", ".", "setBackgroundColor", "(", "getBackgroundColor", "(", ")", ")", ";", "styleableFigure", ".", "setBorderColor", "(", "getBorderColor", "(", ")", ")", ";", "}", "styleableFigure", ".", "setBorderWidth", "(", "getBorderWidth", "(", ")", ")", ";", "if", "(", "figure", ".", "getFont", "(", ")", "!=", "getFont", "(", ")", ")", "{", "figure", ".", "setFont", "(", "getFont", "(", ")", ")", ";", "}", "}", "if", "(", "this", ".", "getTooltip", "(", ")", "==", "null", "&&", "hasCustomTooltip", "==", "false", ")", "{", "toolTip", "=", "new", "Label", "(", ")", ";", "(", "(", "Label", ")", "toolTip", ")", ".", "setText", "(", "getText", "(", ")", ")", ";", "}", "else", "{", "toolTip", "=", "this", ".", "getTooltip", "(", ")", ";", "}", "figure", ".", "setToolTip", "(", "toolTip", ")", ";", "if", "(", "isFisheyeEnabled", ")", "{", "IFigure", "newFisheyeFigure", "=", "createFishEyeFigure", "(", ")", ";", "if", "(", "graph", ".", "replaceFishFigure", "(", "this", ".", "fishEyeFigure", ",", "newFisheyeFigure", ")", ")", "{", "this", ".", "fishEyeFigure", "=", "newFisheyeFigure", ";", "}", "}", "refreshBounds", "(", ")", ";", "}", "protected", "IFigure", "createFigureForModel", "(", ")", "{", "GraphNode", "node", "=", "this", ";", "boolean", "cacheLabel", "=", "(", "this", ")", ".", "cacheLabel", "(", ")", ";", "final", "GraphLabel", "label", "=", "new", "GraphLabel", "(", "node", ".", "getText", "(", ")", ",", "node", ".", "getImage", "(", ")", ",", "cacheLabel", ")", ";", "label", ".", "setFont", "(", "this", ".", "font", ")", ";", "if", "(", "checkStyle", "(", "ZestStyles", ".", "NODES_HIDE_TEXT", ")", ")", "{", "label", ".", "setText", "(", "\"\"", ")", ";", "}", "updateFigureForModel", "(", "label", ")", ";", "label", ".", "addFigureListener", "(", "new", "FigureListener", "(", ")", "{", "private", "Dimension", "previousSize", "=", "label", ".", "getBounds", "(", ")", ".", "getSize", "(", ")", ";", "public", "void", "figureMoved", "(", "IFigure", "source", ")", "{", "if", "(", "Animation", ".", "isAnimating", "(", ")", "||", "getLayout", "(", ")", ".", "isMinimized", "(", ")", ")", "{", "return", ";", "}", "Rectangle", "newBounds", "=", "nodeFigure", ".", "getBounds", "(", ")", ";", "if", "(", "!", "newBounds", ".", "getSize", "(", ")", ".", "equals", "(", "previousSize", ")", ")", "{", "previousSize", "=", "newBounds", ".", "getSize", "(", ")", ";", "if", "(", "size", ".", "width", ">=", "0", "&&", "size", ".", "height", ">=", "0", ")", "{", "size", "=", "newBounds", ".", "getSize", "(", ")", ";", "}", "currentLocation", "=", "new", "PrecisionPoint", "(", "nodeFigure", ".", "getBounds", "(", ")", ".", "getTopLeft", "(", ")", ")", ";", "parent", ".", "getLayoutContext", "(", ")", ".", "fireNodeResizedEvent", "(", "getLayout", "(", ")", ")", ";", "}", "else", "if", "(", "currentLocation", ".", "x", "!=", "newBounds", ".", "x", "||", "currentLocation", ".", "y", "!=", "newBounds", ".", "y", ")", "{", "currentLocation", "=", "new", "PrecisionPoint", "(", "nodeFigure", ".", "getBounds", "(", ")", ".", "getTopLeft", "(", ")", ")", ";", "parent", ".", "getLayoutContext", "(", ")", ".", "fireNodeMovedEvent", "(", "getLayout", "(", ")", ")", ";", "}", "}", "}", ")", ";", "return", "label", ";", "}", "private", "IFigure", "createFishEyeFigure", "(", ")", "{", "GraphNode", "node", "=", "this", ";", "boolean", "cacheLabel", "=", "this", ".", "cacheLabel", "(", ")", ";", "GraphLabel", "label", "=", "new", "GraphLabel", "(", "node", ".", "getText", "(", ")", ",", "node", ".", "getImage", "(", ")", ",", "cacheLabel", ")", ";", "if", "(", "highlighted", "==", "HIGHLIGHT_ON", ")", "{", "label", ".", "setForegroundColor", "(", "getForegroundColor", "(", ")", ")", ";", "label", ".", "setBackgroundColor", "(", "getHighlightColor", "(", ")", ")", ";", "label", ".", "setBorderColor", "(", "getBorderHighlightColor", "(", ")", ")", ";", "}", "else", "{", "label", ".", "setForegroundColor", "(", "getForegroundColor", "(", ")", ")", ";", "label", ".", "setBackgroundColor", "(", "getBackgroundColor", "(", ")", ")", ";", "label", ".", "setBorderColor", "(", "getBorderColor", "(", ")", ")", ";", "}", "label", ".", "setBorderWidth", "(", "getBorderWidth", "(", ")", ")", ";", "label", ".", "setFont", "(", "getFont", "(", ")", ")", ";", "return", "label", ";", "}", "private", "Rectangle", "calculateFishEyeBounds", "(", ")", "{", "Rectangle", "rectangle", "=", "nodeFigure", ".", "getBounds", "(", ")", ".", "getCopy", "(", ")", ";", "Dimension", "newSize", "=", "fishEyeFigure", ".", "getPreferredSize", "(", ")", ";", "Rectangle", "currentSize", "=", "rectangle", ".", "getCopy", "(", ")", ";", "nodeFigure", ".", "translateToAbsolute", "(", "currentSize", ")", ";", "int", "expandedH", "=", "Math", ".", "max", "(", "(", "newSize", ".", "height", "-", "currentSize", ".", "height", ")", "/", "2", "+", "1", ",", "0", ")", ";", "int", "expandedW", "=", "Math", ".", "max", "(", "(", "newSize", ".", "width", "-", "currentSize", ".", "width", ")", "/", "2", "+", "1", ",", "0", ")", ";", "Dimension", "expandAmount", "=", "new", "Dimension", "(", "expandedW", ",", "expandedH", ")", ";", "nodeFigure", ".", "translateToAbsolute", "(", "rectangle", ")", ";", "rectangle", ".", "expand", "(", "new", "Insets", "(", "expandAmount", ".", "height", ",", "expandAmount", ".", "width", ",", "expandAmount", ".", "height", ",", "expandAmount", ".", "width", ")", ")", ";", "if", "(", "expandedH", "<=", "0", "&&", "expandedW", "<=", "0", ")", "{", "return", "null", ";", "}", "return", "rectangle", ";", "}", "void", "addSourceConnection", "(", "GraphConnection", "connection", ")", "{", "this", ".", "sourceConnections", ".", "add", "(", "connection", ")", ";", "}", "void", "addTargetConnection", "(", "GraphConnection", "connection", ")", "{", "this", ".", "targetConnections", ".", "add", "(", "connection", ")", ";", "}", "void", "removeSourceConnection", "(", "GraphConnection", "connection", ")", "{", "this", ".", "sourceConnections", ".", "remove", "(", "connection", ")", ";", "}", "void", "removeTargetConnection", "(", "GraphConnection", "connection", ")", "{", "this", ".", "targetConnections", ".", "remove", "(", "connection", ")", ";", "}", "void", "setSelected", "(", "boolean", "selected", ")", "{", "if", "(", "selected", "==", "isSelected", "(", ")", ")", "{", "return", ";", "}", "if", "(", "selected", ")", "{", "highlight", "(", ")", ";", "}", "else", "{", "unhighlight", "(", ")", ";", "}", "this", ".", "selected", "=", "selected", ";", "}", "public", "int", "getItemType", "(", ")", "{", "return", "NODE", ";", "}", "public", "IFigure", "getFigure", "(", ")", "{", "if", "(", "this", ".", "nodeFigure", "==", "null", ")", "{", "initFigure", "(", ")", ";", "}", "return", "this", ".", "getNodeFigure", "(", ")", ";", "}", "private", "InternalNodeLayout", "layout", ";", "public", "InternalNodeLayout", "getLayout", "(", ")", "{", "if", "(", "layout", "==", "null", ")", "{", "layout", "=", "new", "InternalNodeLayout", "(", "this", ")", ";", "}", "return", "layout", ";", "}", "void", "applyLayoutChanges", "(", ")", "{", "if", "(", "layout", "!=", "null", ")", "{", "layout", ".", "applyLayout", "(", ")", ";", "}", "}", "}", "</s>" ]
10,276
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Animation", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "FigureListener", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "IFigure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Dimension", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Point", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "PrecisionPoint", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Rectangle", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "dataStructures", ".", "DisplayIndependentDimension", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "dataStructures", ".", "DisplayIndependentPoint", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "EntityLayout", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "LayoutContext", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "NodeLayout", ";", "public", "abstract", "class", "FigureSubgraph", "extends", "DefaultSubgraph", "{", "protected", "IFigure", "figure", ";", "private", "DisplayIndependentPoint", "location", ";", "private", "boolean", "isLayoutBeingApplied", "=", "false", ";", "protected", "class", "SubgraphFigrueListener", "implements", "FigureListener", "{", "private", "Rectangle", "previousBounds", "=", "figure", ".", "getBounds", "(", ")", ".", "getCopy", "(", ")", ";", "public", "void", "figureMoved", "(", "IFigure", "source", ")", "{", "if", "(", "Animation", ".", "isAnimating", "(", ")", "||", "isLayoutBeingApplied", ")", "{", "return", ";", "}", "Rectangle", "newBounds", "=", "figure", ".", "getBounds", "(", ")", ";", "if", "(", "!", "newBounds", ".", "getSize", "(", ")", ".", "equals", "(", "previousBounds", ".", "getSize", "(", ")", ")", ")", "{", "(", "context", ")", ".", "fireSubgraphResizedEvent", "(", "FigureSubgraph", ".", "this", ")", ";", "}", "else", "if", "(", "!", "newBounds", ".", "getLocation", "(", ")", ".", "equals", "(", "previousBounds", ".", "getLocation", "(", ")", ")", ")", "{", "(", "context", ")", ".", "fireSubgraphMovedEvent", "(", "FigureSubgraph", ".", "this", ")", ";", "}", "previousBounds", "=", "newBounds", ".", "getCopy", "(", ")", ";", "}", "}", ";", "protected", "abstract", "void", "createFigure", "(", ")", ";", "protected", "abstract", "void", "updateFigure", "(", ")", ";", "public", "IFigure", "getFigure", "(", ")", "{", "if", "(", "figure", "==", "null", ")", "{", "createFigure", "(", ")", ";", "updateFigure", "(", ")", ";", "figure", ".", "addFigureListener", "(", "new", "SubgraphFigrueListener", "(", ")", ")", ";", "(", "context", ")", ".", "container", ".", "addSubgraphFigure", "(", "figure", ")", ";", "}", "return", "figure", ";", "}", "protected", "FigureSubgraph", "(", "NodeLayout", "[", "]", "nodes", ",", "LayoutContext", "context", ")", "{", "super", "(", "context", ")", ";", "addNodes", "(", "nodes", ")", ";", "}", "public", "void", "addNodes", "(", "NodeLayout", "[", "]", "nodes", ")", "{", "int", "initialCount", "=", "this", ".", "nodes", ".", "size", "(", ")", ";", "super", ".", "addNodes", "(", "nodes", ")", ";", "if", "(", "this", ".", "nodes", ".", "size", "(", ")", ">", "initialCount", "&&", "figure", "!=", "null", ")", "{", "updateFigure", "(", ")", ";", "if", "(", "location", "!=", "null", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "nodes", ".", "length", ";", "i", "++", ")", "{", "nodes", "[", "i", "]", ".", "setLocation", "(", "location", ".", "x", ",", "location", ".", "y", ")", ";", "}", "}", "}", "}", "public", "void", "removeNodes", "(", "NodeLayout", "[", "]", "nodes", ")", "{", "int", "initialCount", "=", "this", ".", "nodes", ".", "size", "(", ")", ";", "super", ".", "removeNodes", "(", "nodes", ")", ";", "if", "(", "this", ".", "nodes", ".", "size", "(", ")", "<", "initialCount", "&&", "figure", "!=", "null", "&&", "!", "disposed", ")", "{", "updateFigure", "(", ")", ";", "}", "}", "public", "EntityLayout", "[", "]", "getSuccessingEntities", "(", ")", "{", "return", "super", ".", "getSuccessingEntities", "(", ")", ";", "}", "public", "EntityLayout", "[", "]", "getPredecessingEntities", "(", ")", "{", "return", "super", ".", "getPredecessingEntities", "(", ")", ";", "}", "public", "DisplayIndependentDimension", "getSize", "(", ")", "{", "Dimension", "size", "=", "getFigure", "(", ")", ".", "getSize", "(", ")", ";", "return", "new", "DisplayIndependentDimension", "(", "size", ".", "width", ",", "size", ".", "height", ")", ";", "}", "public", "DisplayIndependentPoint", "getLocation", "(", ")", "{", "if", "(", "location", "==", "null", ")", "{", "Point", "location2", "=", "getFigure", "(", ")", ".", "getBounds", "(", ")", ".", "getLocation", "(", ")", ";", "Dimension", "size", "=", "getFigure", "(", ")", ".", "getSize", "(", ")", ";", "return", "new", "DisplayIndependentPoint", "(", "location2", ".", "x", "+", "size", ".", "width", "/", "2", ",", "location2", ".", "y", "+", "size", ".", "height", "/", "2", ")", ";", "}", "return", "new", "DisplayIndependentPoint", "(", "location", ")", ";", "}", "public", "void", "setLocation", "(", "double", "x", ",", "double", "y", ")", "{", "super", ".", "setLocation", "(", "x", ",", "y", ")", ";", "for", "(", "Iterator", "iterator", "=", "nodes", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "NodeLayout", "node", "=", "(", "NodeLayout", ")", "iterator", ".", "next", "(", ")", ";", "node", ".", "setLocation", "(", "x", ",", "y", ")", ";", "}", "if", "(", "location", "!=", "null", ")", "{", "location", ".", "x", "=", "x", ";", "location", ".", "y", "=", "y", ";", "}", "else", "{", "location", "=", "new", "DisplayIndependentPoint", "(", "x", ",", "y", ")", ";", "applyLayoutChanges", "(", ")", ";", "}", "}", "protected", "void", "refreshLocation", "(", ")", "{", "Rectangle", "bounds", "=", "figure", ".", "getBounds", "(", ")", ";", "if", "(", "location", "==", "null", ")", "{", "location", "=", "new", "DisplayIndependentPoint", "(", "0", ",", "0", ")", ";", "}", "location", ".", "x", "=", "bounds", ".", "x", "+", "bounds", ".", "width", "/", "2", ";", "location", ".", "y", "=", "bounds", ".", "y", "+", "bounds", ".", "height", "/", "2", ";", "}", "public", "boolean", "isGraphEntity", "(", ")", "{", "return", "true", ";", "}", "public", "boolean", "isMovable", "(", ")", "{", "return", "true", ";", "}", "protected", "void", "dispose", "(", ")", "{", "if", "(", "!", "disposed", ")", "{", "super", ".", "dispose", "(", ")", ";", "if", "(", "figure", "!=", "null", ")", "{", "context", ".", "container", ".", "getGraph", "(", ")", ".", "removeSubgraphFigure", "(", "figure", ")", ";", "}", "}", "}", "protected", "void", "applyLayoutChanges", "(", ")", "{", "getFigure", "(", ")", ";", "if", "(", "location", "!=", "null", ")", "{", "isLayoutBeingApplied", "=", "true", ";", "Dimension", "size", "=", "figure", ".", "getSize", "(", ")", ";", "figure", ".", "setLocation", "(", "new", "PrecisionPoint", "(", "location", ".", "x", "-", "size", ".", "width", "/", "2", ",", "location", ".", "y", "-", "size", ".", "height", "/", "2", ")", ")", ";", "isLayoutBeingApplied", "=", "false", ";", "}", "}", "}", "</s>" ]
10,277
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ";", "public", "interface", "LayoutFilter", "{", "public", "boolean", "isObjectFiltered", "(", "GraphItem", "item", ")", ";", "}", "</s>" ]
10,278
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "custom", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "IFigure", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "Graph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphContainer", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "GraphNode", ";", "public", "class", "CGraphNode", "extends", "GraphNode", "{", "IFigure", "figure", "=", "null", ";", "public", "CGraphNode", "(", "Graph", "graphModel", ",", "int", "style", ",", "IFigure", "figure", ")", "{", "super", "(", "graphModel", ",", "style", ",", "figure", ")", ";", "}", "public", "CGraphNode", "(", "GraphContainer", "graphModel", ",", "int", "style", ",", "IFigure", "figure", ")", "{", "super", "(", "graphModel", ",", "style", ",", "figure", ")", ";", "}", "public", "IFigure", "getFigure", "(", ")", "{", "return", "super", ".", "getFigure", "(", ")", ";", "}", "protected", "IFigure", "createFigureForModel", "(", ")", "{", "this", ".", "figure", "=", "(", "IFigure", ")", "this", ".", "getData", "(", ")", ";", "return", "this", ".", "figure", ";", "}", "}", "</s>" ]
10,279
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "custom", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ColorConstants", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Graphics", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Shape", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "PointList", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Rectangle", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Color", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "FigureSubgraph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "TreeLayoutObserver", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "TreeLayoutObserver", ".", "TreeListener", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "TreeLayoutObserver", ".", "TreeNode", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "LayoutContext", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "NodeLayout", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "SubgraphLayout", ";", "public", "class", "TriangleSubgraph", "extends", "FigureSubgraph", "{", "public", "static", "class", "TriangleParameters", "implements", "Cloneable", "{", "public", "Color", "color", "=", "ColorConstants", ".", "black", ";", "public", "int", "direction", "=", "TOP_DOWN", ";", "public", "double", "referenceHeight", "=", "50", ";", "public", "double", "referenceBase", "=", "50", ";", "public", "Object", "clone", "(", ")", "{", "TriangleParameters", "result", "=", "new", "TriangleParameters", "(", ")", ";", "result", ".", "color", "=", "color", ";", "result", ".", "direction", "=", "direction", ";", "result", ".", "referenceHeight", "=", "referenceHeight", ";", "result", ".", "referenceBase", "=", "referenceBase", ";", "return", "result", ";", "}", "}", "private", "class", "IsoscelesTriangle", "extends", "Shape", "{", "private", "PointList", "points", "=", "new", "PointList", "(", "3", ")", ";", "protected", "void", "fillShape", "(", "Graphics", "graphics", ")", "{", "graphics", ".", "fillPolygon", "(", "points", ")", ";", "}", "protected", "void", "outlineShape", "(", "Graphics", "graphics", ")", "{", "graphics", ".", "drawPolygon", "(", "points", ")", ";", "}", "protected", "void", "primTranslate", "(", "int", "dx", ",", "int", "dy", ")", "{", "super", ".", "primTranslate", "(", "dx", ",", "dy", ")", ";", "points", ".", "translate", "(", "dx", ",", "dy", ")", ";", "}", "public", "void", "validate", "(", ")", "{", "super", ".", "validate", "(", ")", ";", "Rectangle", "r", "=", "new", "Rectangle", "(", ")", ";", "r", ".", "setBounds", "(", "getBounds", "(", ")", ")", ";", "r", ".", "shrink", "(", "getInsets", "(", ")", ")", ";", "points", ".", "removeAllPoints", "(", ")", ";", "switch", "(", "parameters", ".", "direction", ")", "{", "case", "TOP_DOWN", ":", "points", ".", "addPoint", "(", "r", ".", "x", "+", "r", ".", "width", "/", "2", ",", "r", ".", "y", ")", ";", "points", ".", "addPoint", "(", "r", ".", "x", ",", "r", ".", "y", "+", "r", ".", "height", ")", ";", "points", ".", "addPoint", "(", "r", ".", "x", "+", "r", ".", "width", ",", "r", ".", "y", "+", "r", ".", "height", ")", ";", "break", ";", "case", "BOTTOM_UP", ":", "points", ".", "addPoint", "(", "r", ".", "x", "+", "r", ".", "width", "/", "2", ",", "r", ".", "y", "+", "r", ".", "height", ")", ";", "points", ".", "addPoint", "(", "r", ".", "x", ",", "r", ".", "y", ")", ";", "points", ".", "addPoint", "(", "r", ".", "x", "+", "r", ".", "width", ",", "r", ".", "y", ")", ";", "break", ";", "case", "LEFT_RIGHT", ":", "points", ".", "addPoint", "(", "r", ".", "x", ",", "r", ".", "y", "+", "r", ".", "height", "/", "2", ")", ";", "points", ".", "addPoint", "(", "r", ".", "x", "+", "r", ".", "width", ",", "r", ".", "y", ")", ";", "points", ".", "addPoint", "(", "r", ".", "x", "+", "r", ".", "width", ",", "r", ".", "y", "+", "r", ".", "height", ")", ";", "break", ";", "case", "RIGHT_LEFT", ":", "points", ".", "addPoint", "(", "r", ".", "x", "+", "r", ".", "width", ",", "r", ".", "y", "+", "r", ".", "height", "/", "2", ")", ";", "points", ".", "addPoint", "(", "r", ".", "x", ",", "r", ".", "y", ")", ";", "points", ".", "addPoint", "(", "r", ".", "x", ",", "r", ".", "y", "+", "r", ".", "height", ")", ";", "break", ";", "}", "}", "}", "private", "static", "HashMap", "contextToTree", "=", "new", "HashMap", "(", ")", ";", "private", "TriangleParameters", "parameters", ";", "public", "TriangleSubgraph", "(", "NodeLayout", "[", "]", "nodes", ",", "LayoutContext", "context", ",", "TriangleParameters", "triangleParameters", ")", "{", "super", "(", "nodes", ",", "context", ")", ";", "this", ".", "parameters", "=", "triangleParameters", ";", "if", "(", "contextToTree", ".", "get", "(", "context", ")", "==", "null", ")", "{", "TreeLayoutObserver", "treeLayoutObserver", "=", "new", "TreeLayoutObserver", "(", "context", ",", "null", ")", ";", "treeLayoutObserver", ".", "addTreeListener", "(", "new", "TreeListener", "(", ")", "{", "protected", "void", "defaultHandle", "(", "TreeNode", "changedNode", ")", "{", "SubgraphLayout", "subgraph", "=", "changedNode", ".", "getNode", "(", ")", ".", "getSubgraph", "(", ")", ";", "if", "(", "subgraph", "instanceof", "TriangleSubgraph", ")", "{", "(", "(", "TriangleSubgraph", ")", "subgraph", ")", ".", "updateFigure", "(", ")", ";", "}", "}", "}", ")", ";", "contextToTree", ".", "put", "(", "context", ",", "treeLayoutObserver", ")", ";", "}", "}", "protected", "void", "createFigure", "(", ")", "{", "figure", "=", "new", "IsoscelesTriangle", "(", ")", ";", "figure", ".", "setBackgroundColor", "(", "parameters", ".", "color", ")", ";", "figure", ".", "setForegroundColor", "(", "parameters", ".", "color", ")", ";", "}", "private", "double", "log", "(", "double", "value", ",", "double", "base", ")", "{", "return", "Math", ".", "log", "(", "value", ")", "/", "Math", ".", "log", "(", "base", ")", ";", "}", "protected", "void", "updateFigure", "(", ")", "{", "TreeLayoutObserver", "tree", "=", "(", "TreeLayoutObserver", ")", "contextToTree", ".", "get", "(", "context", ")", ";", "TreeNode", "subgraphRoot", "=", "tree", ".", "getTreeNode", "(", "(", "NodeLayout", ")", "nodes", ".", "iterator", "(", ")", ".", "next", "(", ")", ")", ";", "if", "(", "subgraphRoot", "==", "null", ")", "{", "return", ";", "}", "while", "(", "nodes", ".", "contains", "(", "subgraphRoot", ".", "getNode", "(", ")", ")", ")", "{", "subgraphRoot", "=", "subgraphRoot", ".", "getParent", "(", ")", ";", "}", "TreeNode", "superRoot", "=", "tree", ".", "getSuperRoot", "(", ")", ";", "double", "triangleHeight", "=", "parameters", ".", "referenceHeight", "*", "subgraphRoot", ".", "getHeight", "(", ")", "/", "superRoot", ".", "getHeight", "(", ")", ";", "int", "numOfNodes", "=", "superRoot", ".", "getNumOfDescendants", "(", ")", ";", "int", "numOfNodesWithChildren", "=", "numOfNodes", "-", "superRoot", ".", "getNumOfLeaves", "(", ")", "+", "1", ";", "double", "logBase", "=", "(", "numOfNodesWithChildren", ">", "0", ")", "?", "(", "double", ")", "numOfNodes", "/", "numOfNodesWithChildren", ":", "1", ";", "double", "triangleBaseModifier", "=", "(", "parameters", ".", "referenceBase", "-", "1", ")", "/", "log", "(", "superRoot", ".", "getNumOfLeaves", "(", ")", ",", "logBase", ")", ";", "double", "triangleBase", "=", "parameters", ".", "referenceBase", "+", "triangleBaseModifier", "*", "log", "(", "(", "double", ")", "subgraphRoot", ".", "getNumOfLeaves", "(", ")", "/", "superRoot", ".", "getNumOfLeaves", "(", ")", ",", "logBase", ")", ";", "if", "(", "parameters", ".", "direction", "==", "0", ")", "{", "parameters", ".", "direction", "=", "parameters", ".", "direction", ";", "}", "if", "(", "parameters", ".", "direction", "==", "TOP_DOWN", "||", "parameters", ".", "direction", "==", "BOTTOM_UP", ")", "{", "figure", ".", "setSize", "(", "(", "int", ")", "(", "triangleBase", "+", "0.5", ")", ",", "(", "int", ")", "(", "triangleHeight", "+", "0.5", ")", ")", ";", "}", "else", "{", "figure", ".", "setSize", "(", "(", "int", ")", "(", "triangleHeight", "+", "0.5", ")", ",", "(", "int", ")", "(", "triangleBase", "+", "0.5", ")", ")", ";", "}", "int", "numOfNodesWithChildrenInSubgraph", "=", "nodes", ".", "size", "(", ")", "-", "subgraphRoot", ".", "getNumOfLeaves", "(", ")", "+", "1", ";", "double", "avgNumOfChildrenInSugbraph", "=", "(", "numOfNodesWithChildrenInSubgraph", ">", "0", ")", "?", "(", "double", ")", "nodes", ".", "size", "(", ")", "/", "numOfNodesWithChildrenInSubgraph", ":", "1", ";", "int", "r", "=", "(", "int", ")", "(", "parameters", ".", "color", ".", "getRed", "(", ")", "+", "(", "(", "double", ")", "255", "-", "parameters", ".", "color", ".", "getRed", "(", ")", ")", "/", "avgNumOfChildrenInSugbraph", ")", ";", "int", "g", "=", "(", "int", ")", "(", "parameters", ".", "color", ".", "getGreen", "(", ")", "+", "(", "(", "double", ")", "255", "-", "parameters", ".", "color", ".", "getGreen", "(", ")", ")", "/", "avgNumOfChildrenInSugbraph", ")", ";", "int", "b", "=", "(", "int", ")", "(", "parameters", ".", "color", ".", "getBlue", "(", ")", "+", "(", "(", "double", ")", "255", "-", "parameters", ".", "color", ".", "getBlue", "(", ")", ")", "/", "avgNumOfChildrenInSugbraph", ")", ";", "figure", ".", "setBackgroundColor", "(", "new", "Color", "(", "parameters", ".", "color", ".", "getDevice", "(", ")", ",", "r", ",", "g", ",", "b", ")", ")", ";", "figure", ".", "setForegroundColor", "(", "parameters", ".", "color", ")", ";", "}", "public", "boolean", "isDirectionDependant", "(", ")", "{", "return", "true", ";", "}", "public", "void", "setDirection", "(", "int", "direction", ")", "{", "super", ".", "setDirection", "(", "direction", ")", ";", "if", "(", "parameters", ".", "direction", "==", "direction", ")", "{", "return", ";", "}", "if", "(", "direction", "==", "TOP_DOWN", "||", "direction", "==", "BOTTOM_UP", "||", "direction", "==", "LEFT_RIGHT", "||", "direction", "==", "RIGHT_LEFT", ")", "{", "parameters", ".", "direction", "=", "direction", ";", "updateFigure", "(", ")", ";", "}", "else", "{", "throw", "new", "IllegalArgumentException", "(", "\"\"", ")", ";", "}", "}", "public", "void", "setColor", "(", "Color", "color", ")", "{", "parameters", ".", "color", "=", "color", ";", "updateFigure", "(", ")", ";", "}", "}", "</s>" ]
10,280
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "custom", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Label", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Color", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "FigureSubgraph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "internal", ".", "GraphLabel", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "LayoutContext", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "NodeLayout", ";", "public", "class", "LabelSubgraph", "extends", "FigureSubgraph", "{", "private", "Color", "backgroundColor", ";", "private", "Color", "foregroundColor", ";", "public", "void", "setForegroundColor", "(", "Color", "color", ")", "{", "figure", ".", "setForegroundColor", "(", "color", ")", ";", "}", "public", "void", "setBackgroundColor", "(", "Color", "color", ")", "{", "figure", ".", "setBackgroundColor", "(", "color", ")", ";", "}", "protected", "void", "createFigure", "(", ")", "{", "figure", "=", "new", "GraphLabel", "(", "false", ")", ";", "figure", ".", "setForegroundColor", "(", "foregroundColor", ")", ";", "figure", ".", "setBackgroundColor", "(", "backgroundColor", ")", ";", "updateFigure", "(", ")", ";", "}", "protected", "void", "updateFigure", "(", ")", "{", "(", "(", "Label", ")", "figure", ")", ".", "setText", "(", "\"\"", "+", "nodes", ".", "size", "(", ")", ")", ";", "}", "public", "LabelSubgraph", "(", "NodeLayout", "[", "]", "nodes", ",", "LayoutContext", "context", ",", "Color", "foregroundColor", ",", "Color", "backgroundColor", ")", "{", "super", "(", "nodes", ",", "context", ")", ";", "this", ".", "foregroundColor", "=", "foregroundColor", ";", "this", ".", "backgroundColor", "=", "backgroundColor", ";", "}", "}", "</s>" ]
10,281
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ColorConstants", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Color", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Item", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "custom", ".", "LabelSubgraph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "custom", ".", "TriangleSubgraph", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "custom", ".", "TriangleSubgraph", ".", "TriangleParameters", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "dataStructures", ".", "DisplayIndependentDimension", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "dataStructures", ".", "DisplayIndependentPoint", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "dataStructures", ".", "DisplayIndependentRectangle", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "ConnectionLayout", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "EntityLayout", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "LayoutContext", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "NodeLayout", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "SubgraphLayout", ";", "public", "class", "DefaultSubgraph", "implements", "SubgraphLayout", "{", "public", "static", "class", "DefaultSubgraphFactory", "implements", "SubgraphFactory", "{", "private", "HashMap", "contextToSubgraph", "=", "new", "HashMap", "(", ")", ";", "public", "SubgraphLayout", "createSubgraph", "(", "NodeLayout", "[", "]", "nodes", ",", "LayoutContext", "context", ")", "{", "DefaultSubgraph", "subgraph", "=", "(", "DefaultSubgraph", ")", "contextToSubgraph", ".", "get", "(", "context", ")", ";", "if", "(", "subgraph", "==", "null", ")", "{", "subgraph", "=", "new", "DefaultSubgraph", "(", "context", ")", ";", "contextToSubgraph", ".", "put", "(", "context", ",", "subgraph", ")", ";", "}", "subgraph", ".", "addNodes", "(", "nodes", ")", ";", "return", "subgraph", ";", "}", "}", ";", "public", "static", "class", "LabelSubgraphFactory", "implements", "SubgraphFactory", "{", "private", "Color", "defaultForegroundColor", "=", "ColorConstants", ".", "black", ";", "private", "Color", "defaultBackgroundColor", "=", "ColorConstants", ".", "yellow", ";", "public", "void", "setDefualtForegroundColor", "(", "Color", "c", ")", "{", "defaultForegroundColor", "=", "c", ";", "}", "public", "void", "setDefaultBackgroundColor", "(", "Color", "c", ")", "{", "defaultBackgroundColor", "=", "c", ";", "}", "public", "SubgraphLayout", "createSubgraph", "(", "NodeLayout", "[", "]", "nodes", ",", "LayoutContext", "context", ")", "{", "return", "new", "LabelSubgraph", "(", "nodes", ",", "context", ",", "defaultForegroundColor", ",", "defaultBackgroundColor", ")", ";", "}", "}", ";", "public", "static", "class", "TriangleSubgraphFactory", "implements", "SubgraphFactory", "{", "private", "TriangleParameters", "parameters", "=", "new", "TriangleParameters", "(", ")", ";", "public", "SubgraphLayout", "createSubgraph", "(", "NodeLayout", "[", "]", "nodes", ",", "LayoutContext", "context", ")", "{", "return", "new", "TriangleSubgraph", "(", "nodes", ",", "context", ",", "(", "TriangleParameters", ")", "parameters", ".", "clone", "(", ")", ")", ";", "}", "public", "Color", "getColor", "(", ")", "{", "return", "parameters", ".", "color", ";", "}", "public", "void", "setColor", "(", "Color", "color", ")", "{", "parameters", ".", "color", "=", "color", ";", "}", "public", "int", "getDirection", "(", ")", "{", "return", "parameters", ".", "direction", ";", "}", "public", "void", "setDirection", "(", "int", "direction", ")", "{", "parameters", ".", "direction", "=", "direction", ";", "}", "public", "double", "getReferenceHeight", "(", ")", "{", "return", "parameters", ".", "referenceHeight", ";", "}", "public", "void", "setReferenceHeight", "(", "double", "referenceHeight", ")", "{", "parameters", ".", "referenceHeight", "=", "referenceHeight", ";", "}", "public", "double", "getReferenceBase", "(", ")", "{", "return", "parameters", ".", "referenceBase", ";", "}", "public", "void", "setReferenceBase", "(", "double", "referenceBase", ")", "{", "parameters", ".", "referenceBase", "=", "referenceBase", ";", "}", "}", ";", "public", "static", "class", "PrunedSuccessorsSubgraphFactory", "implements", "SubgraphFactory", "{", "private", "HashMap", "contextToSubgraph", "=", "new", "HashMap", "(", ")", ";", "public", "SubgraphLayout", "createSubgraph", "(", "NodeLayout", "[", "]", "nodes", ",", "LayoutContext", "context", ")", "{", "PrunedSuccessorsSubgraph", "subgraph", "=", "(", "PrunedSuccessorsSubgraph", ")", "contextToSubgraph", ".", "get", "(", "context", ")", ";", "if", "(", "subgraph", "==", "null", ")", "{", "subgraph", "=", "new", "PrunedSuccessorsSubgraph", "(", "context", ")", ";", "contextToSubgraph", ".", "put", "(", "context", ",", "subgraph", ")", ";", "}", "subgraph", ".", "addNodes", "(", "nodes", ")", ";", "return", "subgraph", ";", "}", "public", "void", "updateLabelForNode", "(", "InternalNodeLayout", "node", ")", "{", "InternalLayoutContext", "context", "=", "node", ".", "getOwnerLayoutContext", "(", ")", ";", "PrunedSuccessorsSubgraph", "subgraph", "=", "(", "PrunedSuccessorsSubgraph", ")", "contextToSubgraph", ".", "get", "(", "context", ")", ";", "if", "(", "subgraph", "==", "null", ")", "{", "subgraph", "=", "new", "PrunedSuccessorsSubgraph", "(", "context", ")", ";", "contextToSubgraph", ".", "put", "(", "context", ",", "subgraph", ")", ";", "}", "subgraph", ".", "updateNodeLabel", "(", "node", ")", ";", "}", "}", ";", "protected", "final", "InternalLayoutContext", "context", ";", "protected", "final", "Set", "nodes", "=", "new", "HashSet", "(", ")", ";", "protected", "boolean", "disposed", "=", "false", ";", "protected", "DefaultSubgraph", "(", "LayoutContext", "context2", ")", "{", "if", "(", "context2", "instanceof", "InternalLayoutContext", ")", "{", "this", ".", "context", "=", "(", "InternalLayoutContext", ")", "context2", ";", "}", "else", "{", "throw", "new", "RuntimeException", "(", "\"\"", ")", ";", "}", "}", "public", "boolean", "isGraphEntity", "(", ")", "{", "return", "false", ";", "}", "public", "void", "setSize", "(", "double", "width", ",", "double", "height", ")", "{", "context", ".", "checkChangesAllowed", "(", ")", ";", "}", "public", "void", "setLocation", "(", "double", "x", ",", "double", "y", ")", "{", "context", ".", "checkChangesAllowed", "(", ")", ";", "}", "public", "boolean", "isResizable", "(", ")", "{", "return", "false", ";", "}", "public", "boolean", "isMovable", "(", ")", "{", "return", "false", ";", "}", "public", "EntityLayout", "[", "]", "getSuccessingEntities", "(", ")", "{", "return", "new", "EntityLayout", "[", "0", "]", ";", "}", "public", "DisplayIndependentDimension", "getSize", "(", ")", "{", "DisplayIndependentRectangle", "bounds", "=", "context", ".", "getBounds", "(", ")", ";", "return", "new", "DisplayIndependentDimension", "(", "bounds", ".", "width", ",", "bounds", ".", "height", ")", ";", "}", "public", "double", "getPreferredAspectRatio", "(", ")", "{", "return", "0", ";", "}", "public", "EntityLayout", "[", "]", "getPredecessingEntities", "(", ")", "{", "return", "new", "EntityLayout", "[", "0", "]", ";", "}", "public", "DisplayIndependentPoint", "getLocation", "(", ")", "{", "DisplayIndependentRectangle", "bounds", "=", "context", ".", "getBounds", "(", ")", ";", "return", "new", "DisplayIndependentPoint", "(", "bounds", ".", "x", "+", "bounds", ".", "width", "/", "2", ",", "bounds", ".", "y", "+", "bounds", ".", "height", "/", "2", ")", ";", "}", "public", "boolean", "isDirectionDependant", "(", ")", "{", "return", "false", ";", "}", "public", "void", "setDirection", "(", "int", "direction", ")", "{", "context", ".", "checkChangesAllowed", "(", ")", ";", "}", "public", "void", "removeNodes", "(", "NodeLayout", "[", "]", "nodes", ")", "{", "context", ".", "checkChangesAllowed", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "nodes", ".", "length", ";", "i", "++", ")", "{", "if", "(", "this", ".", "nodes", ".", "remove", "(", "nodes", "[", "i", "]", ")", ")", "{", "nodes", "[", "i", "]", ".", "prune", "(", "null", ")", ";", "nodes", "[", "i", "]", ".", "setMinimized", "(", "false", ")", ";", "refreshConnectionsVisibility", "(", "nodes", "[", "i", "]", ".", "getIncomingConnections", "(", ")", ")", ";", "refreshConnectionsVisibility", "(", "nodes", "[", "i", "]", ".", "getOutgoingConnections", "(", ")", ")", ";", "}", "}", "if", "(", "this", ".", "nodes", ".", "isEmpty", "(", ")", ")", "{", "dispose", "(", ")", ";", "}", "}", "public", "void", "removeDisposedNodes", "(", ")", "{", "for", "(", "Iterator", "iterator", "=", "nodes", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "InternalNodeLayout", "node", "=", "(", "InternalNodeLayout", ")", "iterator", ".", "next", "(", ")", ";", "if", "(", "node", ".", "isDisposed", "(", ")", ")", "{", "iterator", ".", "remove", "(", ")", ";", "}", "}", "}", "public", "NodeLayout", "[", "]", "getNodes", "(", ")", "{", "InternalNodeLayout", "[", "]", "result", "=", "new", "InternalNodeLayout", "[", "nodes", ".", "size", "(", ")", "]", ";", "int", "i", "=", "0", ";", "for", "(", "Iterator", "iterator", "=", "nodes", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "result", "[", "i", "]", "=", "(", "InternalNodeLayout", ")", "iterator", ".", "next", "(", ")", ";", "if", "(", "!", "context", ".", "isLayoutItemFiltered", "(", "result", "[", "i", "]", ".", "getNode", "(", ")", ")", ")", "{", "i", "++", ";", "}", "}", "if", "(", "i", "==", "nodes", ".", "size", "(", ")", ")", "{", "return", "result", ";", "}", "NodeLayout", "[", "]", "result2", "=", "new", "NodeLayout", "[", "i", "]", ";", "System", ".", "arraycopy", "(", "result", ",", "0", ",", "result2", ",", "0", ",", "i", ")", ";", "return", "result2", ";", "}", "public", "Item", "[", "]", "getItems", "(", ")", "{", "GraphNode", "[", "]", "result", "=", "new", "GraphNode", "[", "nodes", ".", "size", "(", ")", "]", ";", "int", "i", "=", "0", ";", "for", "(", "Iterator", "iterator", "=", "nodes", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "InternalNodeLayout", "node", "=", "(", "InternalNodeLayout", ")", "iterator", ".", "next", "(", ")", ";", "result", "[", "i", "]", "=", "(", "GraphNode", ")", "node", ".", "getItems", "(", ")", "[", "0", "]", ";", "if", "(", "!", "context", ".", "isLayoutItemFiltered", "(", "node", ".", "getNode", "(", ")", ")", ")", "{", "i", "++", ";", "}", "}", "if", "(", "i", "==", "nodes", ".", "size", "(", ")", ")", "{", "return", "result", ";", "}", "GraphNode", "[", "]", "result2", "=", "new", "GraphNode", "[", "i", "]", ";", "System", ".", "arraycopy", "(", "result", ",", "0", ",", "result2", ",", "0", ",", "i", ")", ";", "return", "result2", ";", "}", "public", "int", "countNodes", "(", ")", "{", "return", "nodes", ".", "size", "(", ")", ";", "}", "public", "void", "addNodes", "(", "NodeLayout", "[", "]", "nodes", ")", "{", "context", ".", "checkChangesAllowed", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "nodes", ".", "length", ";", "i", "++", ")", "{", "if", "(", "this", ".", "nodes", ".", "add", "(", "nodes", "[", "i", "]", ")", ")", "{", "nodes", "[", "i", "]", ".", "prune", "(", "this", ")", ";", "nodes", "[", "i", "]", ".", "setMinimized", "(", "true", ")", ";", "refreshConnectionsVisibility", "(", "nodes", "[", "i", "]", ".", "getIncomingConnections", "(", ")", ")", ";", "refreshConnectionsVisibility", "(", "nodes", "[", "i", "]", ".", "getOutgoingConnections", "(", ")", ")", ";", "}", "}", "}", "protected", "void", "refreshConnectionsVisibility", "(", "ConnectionLayout", "[", "]", "connections", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "connections", ".", "length", ";", "i", "++", ")", "{", "connections", "[", "i", "]", ".", "setVisible", "(", "!", "connections", "[", "i", "]", ".", "getSource", "(", ")", ".", "isPruned", "(", ")", "&&", "!", "connections", "[", "i", "]", ".", "getTarget", "(", ")", ".", "isPruned", "(", ")", ")", ";", "}", "}", "protected", "void", "refreshLocation", "(", ")", "{", "}", "protected", "void", "refreshSize", "(", ")", "{", "}", "protected", "void", "applyLayoutChanges", "(", ")", "{", "}", "protected", "void", "dispose", "(", ")", "{", "if", "(", "!", "disposed", ")", "{", "context", ".", "removeSubgrah", "(", "this", ")", ";", "disposed", "=", "true", ";", "}", "}", "}", ";", "</s>" ]
10,282
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "IFigure", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Image", ";", "public", "interface", "ILabeledFigure", "extends", "IFigure", "{", "public", "void", "setText", "(", "String", "text", ")", ";", "public", "String", "getText", "(", ")", ";", "public", "void", "setIcon", "(", "Image", "icon", ")", ";", "public", "Image", "getIcon", "(", ")", ";", "}", "</s>" ]
10,283
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "IFigure", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Color", ";", "public", "interface", "IStyleableFigure", "extends", "IFigure", "{", "void", "setBorderColor", "(", "Color", "borderColor", ")", ";", "void", "setBorderWidth", "(", "int", "borderWidth", ")", ";", "}", "</s>" ]
10,284
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "IFigure", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Widget", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "LayoutAlgorithm", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "dataStructures", ".", "DisplayIndependentRectangle", ";", "public", "interface", "IContainer", "{", "public", "abstract", "Graph", "getGraph", "(", ")", ";", "public", "Widget", "getItem", "(", ")", ";", "public", "abstract", "List", "getNodes", "(", ")", ";", "public", "abstract", "List", "getConnections", "(", ")", ";", "public", "abstract", "void", "addNode", "(", "GraphNode", "graphNode", ")", ";", "public", "abstract", "void", "addSubgraphFigure", "(", "IFigure", "figure", ")", ";", "public", "abstract", "int", "getItemType", "(", ")", ";", "public", "abstract", "DisplayIndependentRectangle", "getLayoutBounds", "(", ")", ";", "public", "abstract", "InternalLayoutContext", "getLayoutContext", "(", ")", ";", "public", "void", "applyLayout", "(", ")", ";", "public", "void", "setLayoutAlgorithm", "(", "LayoutAlgorithm", "algorithm", ",", "boolean", "apply", ")", ";", "}", "</s>" ]
10,285
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Animation", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ColorConstants", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ConnectionRouter", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "CoordinateListener", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "FigureCanvas", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "FreeformLayer", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "FreeformLayout", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "FreeformViewport", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "IFigure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "LayoutAnimator", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "MouseMotionListener", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "PolylineConnection", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "SWTEventDispatcher", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ScalableFigure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ScalableFreeformLayeredPane", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ScrollPane", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "TreeSearch", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Dimension", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Point", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Rectangle", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "SWT", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "ControlEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "ControlListener", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "DisposeEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "DisposeListener", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "PaintEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "PaintListener", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionAdapter", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionEvent", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "SelectionListener", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Color", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Composite", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Event", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Item", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Widget", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "gestures", ".", "RotateGestureListener", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "gestures", ".", "ZoomGestureListener", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "internal", ".", "ContainerFigure", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "internal", ".", "ZestRootLayer", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "zooming", ".", "ZoomManager", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "LayoutAlgorithm", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "dataStructures", ".", "DisplayIndependentRectangle", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "ExpandCollapseManager", ";", "public", "class", "Graph", "extends", "FigureCanvas", "implements", "IContainer", "{", "public", "static", "final", "int", "ANIMATION_TIME", "=", "500", ";", "public", "static", "final", "int", "FISHEYE_ANIMATION_TIME", "=", "100", ";", "public", "Color", "LIGHT_BLUE", "=", "new", "Color", "(", "null", ",", "216", ",", "228", ",", "248", ")", ";", "public", "Color", "LIGHT_BLUE_CYAN", "=", "new", "Color", "(", "null", ",", "213", ",", "243", ",", "255", ")", ";", "public", "Color", "GREY_BLUE", "=", "new", "Color", "(", "null", ",", "139", ",", "150", ",", "171", ")", ";", "public", "Color", "DARK_BLUE", "=", "new", "Color", "(", "null", ",", "1", ",", "70", ",", "122", ")", ";", "public", "Color", "LIGHT_YELLOW", "=", "new", "Color", "(", "null", ",", "255", ",", "255", ",", "206", ")", ";", "public", "Color", "HIGHLIGHT_COLOR", "=", "ColorConstants", ".", "yellow", ";", "public", "Color", "HIGHLIGHT_ADJACENT_COLOR", "=", "ColorConstants", ".", "orange", ";", "public", "Color", "DEFAULT_NODE_COLOR", "=", "LIGHT_BLUE", ";", "private", "List", "nodes", ";", "protected", "List", "connections", ";", "HashSet", "subgraphFigures", ";", "private", "List", "selectedItems", "=", "null", ";", "private", "ArrayList", "fisheyeListeners", "=", "new", "ArrayList", "(", ")", ";", "private", "List", "selectionListeners", "=", "null", ";", "private", "HashMap", "figure2ItemMap", "=", "null", ";", "private", "int", "connectionStyle", ";", "private", "int", "nodeStyle", ";", "private", "ScalableFreeformLayeredPane", "fishEyeLayer", "=", "null", ";", "private", "InternalLayoutContext", "layoutContext", "=", "null", ";", "private", "volatile", "boolean", "shouldSheduleLayout", ";", "private", "volatile", "Runnable", "scheduledLayoutRunnable", "=", "null", ";", "private", "volatile", "boolean", "scheduledLayoutClean", "=", "false", ";", "private", "Dimension", "preferredSize", "=", "null", ";", "int", "style", "=", "0", ";", "private", "ScalableFreeformLayeredPane", "rootlayer", ";", "private", "ZestRootLayer", "zestRootLayer", ";", "private", "ConnectionRouter", "defaultConnectionRouter", ";", "private", "ZoomManager", "zoomManager", "=", "null", ";", "public", "Graph", "(", "Composite", "parent", ",", "int", "style", ")", "{", "super", "(", "parent", ",", "style", "|", "SWT", ".", "DOUBLE_BUFFERED", ")", ";", "this", ".", "style", "=", "style", ";", "this", ".", "setBackground", "(", "ColorConstants", ".", "white", ")", ";", "this", ".", "setViewport", "(", "new", "FreeformViewport", "(", ")", ")", ";", "this", ".", "getVerticalBar", "(", ")", ".", "addSelectionListener", "(", "new", "SelectionAdapter", "(", ")", "{", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "Graph", ".", "this", ".", "redraw", "(", ")", ";", "}", "}", ")", ";", "this", ".", "getHorizontalBar", "(", ")", ".", "addSelectionListener", "(", "new", "SelectionAdapter", "(", ")", "{", "public", "void", "widgetSelected", "(", "SelectionEvent", "e", ")", "{", "Graph", ".", "this", ".", "redraw", "(", ")", ";", "}", "}", ")", ";", "this", ".", "getLightweightSystem", "(", ")", ".", "setEventDispatcher", "(", "new", "SWTEventDispatcher", "(", ")", "{", "public", "void", "dispatchMouseMoved", "(", "org", ".", "eclipse", ".", "swt", ".", "events", ".", "MouseEvent", "me", ")", "{", "super", ".", "dispatchMouseMoved", "(", "me", ")", ";", "if", "(", "getCurrentEvent", "(", ")", "==", "null", ")", "{", "return", ";", "}", "if", "(", "getMouseTarget", "(", ")", "==", "null", ")", "{", "setMouseTarget", "(", "getRoot", "(", ")", ")", ";", "}", "if", "(", "(", "me", ".", "stateMask", "&", "SWT", ".", "BUTTON_MASK", ")", "!=", "0", ")", "{", "getMouseTarget", "(", ")", ".", "handleMouseDragged", "(", "getCurrentEvent", "(", ")", ")", ";", "}", "else", "{", "getMouseTarget", "(", ")", ".", "handleMouseMoved", "(", "getCurrentEvent", "(", ")", ")", ";", "}", "}", "}", ")", ";", "this", ".", "setContents", "(", "createLayers", "(", ")", ")", ";", "DragSupport", "dragSupport", "=", "new", "DragSupport", "(", ")", ";", "this", ".", "getLightweightSystem", "(", ")", ".", "getRootFigure", "(", ")", ".", "addMouseListener", "(", "dragSupport", ")", ";", "this", ".", "getLightweightSystem", "(", ")", ".", "getRootFigure", "(", ")", ".", "addMouseMotionListener", "(", "dragSupport", ")", ";", "this", ".", "nodes", "=", "new", "ArrayList", "(", ")", ";", "this", ".", "preferredSize", "=", "new", "Dimension", "(", "-", "1", ",", "-", "1", ")", ";", "this", ".", "connectionStyle", "=", "ZestStyles", ".", "NONE", ";", "this", ".", "nodeStyle", "=", "ZestStyles", ".", "NONE", ";", "this", ".", "connections", "=", "new", "ArrayList", "(", ")", ";", "this", ".", "subgraphFigures", "=", "new", "HashSet", "(", ")", ";", "this", ".", "selectedItems", "=", "new", "ArrayList", "(", ")", ";", "this", ".", "selectionListeners", "=", "new", "ArrayList", "(", ")", ";", "this", ".", "figure2ItemMap", "=", "new", "HashMap", "(", ")", ";", "this", ".", "addPaintListener", "(", "new", "PaintListener", "(", ")", "{", "public", "void", "paintControl", "(", "PaintEvent", "e", ")", "{", "if", "(", "shouldSheduleLayout", ")", "{", "applyLayoutInternal", "(", "true", ")", ";", "shouldSheduleLayout", "=", "false", ";", "}", "}", "}", ")", ";", "this", ".", "addControlListener", "(", "new", "ControlListener", "(", ")", "{", "public", "void", "controlResized", "(", "ControlEvent", "e", ")", "{", "if", "(", "preferredSize", ".", "width", "==", "-", "1", "||", "preferredSize", ".", "height", "==", "-", "1", ")", "{", "getLayoutContext", "(", ")", ".", "fireBoundsChangedEvent", "(", ")", ";", "}", "}", "public", "void", "controlMoved", "(", "ControlEvent", "e", ")", "{", "}", "}", ")", ";", "if", "(", "(", "style", "&", "(", "ZestStyles", ".", "GESTURES_DISABLED", ")", ")", "==", "0", ")", "{", "this", ".", "addGestureListener", "(", "new", "ZoomGestureListener", "(", ")", ")", ";", "this", ".", "addGestureListener", "(", "new", "RotateGestureListener", "(", ")", ")", ";", "}", "this", ".", "addDisposeListener", "(", "new", "DisposeListener", "(", ")", "{", "public", "void", "widgetDisposed", "(", "DisposeEvent", "e", ")", "{", "release", "(", ")", ";", "}", "}", ")", ";", "}", "public", "void", "addSelectionListener", "(", "SelectionListener", "selectionListener", ")", "{", "if", "(", "!", "selectionListeners", ".", "contains", "(", "selectionListener", ")", ")", "{", "selectionListeners", ".", "add", "(", "selectionListener", ")", ";", "}", "}", "public", "void", "removeSelectionListener", "(", "SelectionListener", "selectionListener", ")", "{", "if", "(", "selectionListeners", ".", "contains", "(", "selectionListener", ")", ")", "{", "selectionListeners", ".", "remove", "(", "selectionListener", ")", ";", "}", "}", "public", "List", "getNodes", "(", ")", "{", "return", "nodes", ";", "}", "public", "ScalableFigure", "getRootLayer", "(", ")", "{", "return", "rootlayer", ";", "}", "public", "void", "setConnectionStyle", "(", "int", "connectionStyle", ")", "{", "this", ".", "connectionStyle", "=", "connectionStyle", ";", "}", "public", "int", "getConnectionStyle", "(", ")", "{", "return", "connectionStyle", ";", "}", "public", "void", "setNodeStyle", "(", "int", "nodeStyle", ")", "{", "this", ".", "nodeStyle", "=", "nodeStyle", ";", "}", "public", "int", "getNodeStyle", "(", ")", "{", "return", "nodeStyle", ";", "}", "public", "List", "getConnections", "(", ")", "{", "return", "this", ".", "connections", ";", "}", "public", "void", "setSelection", "(", "GraphItem", "[", "]", "items", ")", "{", "clearSelection", "(", ")", ";", "if", "(", "items", "!=", "null", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "items", ".", "length", ";", "i", "++", ")", "{", "if", "(", "items", "[", "i", "]", "!=", "null", ")", "{", "select", "(", "items", "[", "i", "]", ")", ";", "}", "}", "}", "}", "public", "void", "selectAll", "(", ")", "{", "setSelection", "(", "(", "GraphItem", "[", "]", ")", "nodes", ".", "toArray", "(", "new", "GraphItem", "[", "]", "{", "}", ")", ")", ";", "}", "public", "List", "getSelection", "(", ")", "{", "return", "selectedItems", ";", "}", "public", "String", "toString", "(", ")", "{", "return", "\"GraphModel", "{\"", "+", "nodes", ".", "size", "(", ")", "+", "\"", "nodes,", "\"", "+", "connections", ".", "size", "(", ")", "+", "\"\"", ";", "}", "public", "void", "dispose", "(", ")", "{", "release", "(", ")", ";", "super", ".", "dispose", "(", ")", ";", "}", "public", "void", "applyLayout", "(", ")", "{", "scheduleLayoutOnReveal", "(", "true", ")", ";", "}", "public", "void", "applyLayoutNow", "(", ")", "{", "getLayoutContext", "(", ")", ".", "applyLayout", "(", "true", ")", ";", "layoutContext", ".", "flushChanges", "(", "false", ")", ";", "}", "public", "void", "setDynamicLayout", "(", "boolean", "enabled", ")", "{", "if", "(", "getLayoutContext", "(", ")", ".", "isBackgroundLayoutEnabled", "(", ")", "!=", "enabled", ")", "{", "layoutContext", ".", "setBackgroundLayoutEnabled", "(", "enabled", ")", ";", "if", "(", "enabled", ")", "{", "scheduleLayoutOnReveal", "(", "false", ")", ";", "}", "}", "}", "public", "boolean", "isDynamicLayoutEnabled", "(", ")", "{", "return", "getLayoutContext", "(", ")", ".", "isBackgroundLayoutEnabled", "(", ")", ";", "}", "private", "void", "release", "(", ")", "{", "while", "(", "nodes", ".", "size", "(", ")", ">", "0", ")", "{", "GraphNode", "node", "=", "(", "GraphNode", ")", "nodes", ".", "get", "(", "0", ")", ";", "if", "(", "node", "!=", "null", ")", "{", "node", ".", "dispose", "(", ")", ";", "}", "}", "while", "(", "connections", ".", "size", "(", ")", ">", "0", ")", "{", "GraphConnection", "connection", "=", "(", "GraphConnection", ")", "connections", ".", "get", "(", "0", ")", ";", "if", "(", "connection", "!=", "null", ")", "{", "connection", ".", "dispose", "(", ")", ";", "}", "}", "LIGHT_BLUE", ".", "dispose", "(", ")", ";", "LIGHT_BLUE_CYAN", ".", "dispose", "(", ")", ";", "GREY_BLUE", ".", "dispose", "(", ")", ";", "DARK_BLUE", ".", "dispose", "(", ")", ";", "LIGHT_YELLOW", ".", "dispose", "(", ")", ";", "}", "private", "void", "applyLayoutInternal", "(", "boolean", "clean", ")", "{", "if", "(", "getLayoutContext", "(", ")", ".", "getLayoutAlgorithm", "(", ")", "==", "null", ")", "{", "return", ";", "}", "scheduledLayoutClean", "=", "scheduledLayoutClean", "||", "clean", ";", "synchronized", "(", "this", ")", "{", "if", "(", "scheduledLayoutRunnable", "==", "null", ")", "{", "Display", ".", "getDefault", "(", ")", ".", "asyncExec", "(", "scheduledLayoutRunnable", "=", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "Animation", ".", "markBegin", "(", ")", ";", "getLayoutContext", "(", ")", ".", "applyLayout", "(", "scheduledLayoutClean", ")", ";", "layoutContext", ".", "flushChanges", "(", "false", ")", ";", "Animation", ".", "run", "(", "ANIMATION_TIME", ")", ";", "getLightweightSystem", "(", ")", ".", "getUpdateManager", "(", ")", ".", "performUpdate", "(", ")", ";", "synchronized", "(", "Graph", ".", "this", ")", "{", "scheduledLayoutRunnable", "=", "null", ";", "scheduledLayoutClean", "=", "false", ";", "}", "}", "}", ")", ";", "}", "}", "}", "public", "void", "setPreferredSize", "(", "int", "width", ",", "int", "height", ")", "{", "this", ".", "preferredSize", "=", "new", "Dimension", "(", "width", ",", "height", ")", ";", "getLayoutContext", "(", ")", ".", "fireBoundsChangedEvent", "(", ")", ";", "}", "public", "Dimension", "getPreferredSize", "(", ")", "{", "if", "(", "preferredSize", ".", "width", "<", "0", "||", "preferredSize", ".", "height", "<", "0", ")", "{", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Point", "size", "=", "getSize", "(", ")", ";", "double", "scale", "=", "getZoomManager", "(", ")", ".", "getZoom", "(", ")", ";", "return", "new", "Dimension", "(", "(", "int", ")", "(", "size", ".", "x", "/", "scale", "+", "0.5", ")", ",", "(", "int", ")", "(", "size", ".", "y", "/", "scale", "+", "0.5", ")", ")", ";", "}", "return", "preferredSize", ";", "}", "public", "InternalLayoutContext", "getLayoutContext", "(", ")", "{", "if", "(", "layoutContext", "==", "null", ")", "{", "layoutContext", "=", "new", "InternalLayoutContext", "(", "this", ")", ";", "}", "return", "layoutContext", ";", "}", "public", "void", "setLayoutAlgorithm", "(", "LayoutAlgorithm", "algorithm", ",", "boolean", "applyLayout", ")", "{", "getLayoutContext", "(", ")", ".", "setLayoutAlgorithm", "(", "algorithm", ")", ";", "if", "(", "applyLayout", ")", "{", "applyLayout", "(", ")", ";", "}", "}", "public", "LayoutAlgorithm", "getLayoutAlgorithm", "(", ")", "{", "return", "getLayoutContext", "(", ")", ".", "getLayoutAlgorithm", "(", ")", ";", "}", "public", "void", "setSubgraphFactory", "(", "SubgraphFactory", "factory", ")", "{", "getLayoutContext", "(", ")", ".", "setSubgraphFactory", "(", "factory", ")", ";", "}", "public", "SubgraphFactory", "getSubgraphFactory", "(", ")", "{", "return", "getLayoutContext", "(", ")", ".", "getSubgraphFactory", "(", ")", ";", "}", "public", "void", "setExpandCollapseManager", "(", "ExpandCollapseManager", "expandCollapseManager", ")", "{", "getLayoutContext", "(", ")", ".", "setExpandCollapseManager", "(", "expandCollapseManager", ")", ";", "}", "public", "ExpandCollapseManager", "getExpandCollapseManager", "(", ")", "{", "return", "getLayoutContext", "(", ")", ".", "getExpandCollapseManager", "(", ")", ";", "}", "public", "void", "addLayoutFilter", "(", "LayoutFilter", "filter", ")", "{", "getLayoutContext", "(", ")", ".", "addFilter", "(", "filter", ")", ";", "}", "public", "void", "removeLayoutFilter", "(", "LayoutFilter", "filter", ")", "{", "getLayoutContext", "(", ")", ".", "removeFilter", "(", "filter", ")", ";", "}", "public", "IFigure", "getFigureAt", "(", "int", "x", ",", "int", "y", ")", "{", "IFigure", "figureUnderMouse", "=", "this", ".", "getContents", "(", ")", ".", "findFigureAt", "(", "x", ",", "y", ",", "new", "TreeSearch", "(", ")", "{", "public", "boolean", "accept", "(", "IFigure", "figure", ")", "{", "return", "true", ";", "}", "public", "boolean", "prune", "(", "IFigure", "figure", ")", "{", "IFigure", "parent", "=", "figure", ".", "getParent", "(", ")", ";", "if", "(", "parent", "==", "fishEyeLayer", ")", "{", "return", "true", ";", "}", "if", "(", "parent", "instanceof", "ContainerFigure", "&&", "figure", "instanceof", "PolylineConnection", ")", "{", "return", "false", ";", "}", "if", "(", "parent", "==", "zestRootLayer", "||", "parent", "==", "zestRootLayer", ".", "getParent", "(", ")", "||", "parent", "==", "zestRootLayer", ".", "getParent", "(", ")", ".", "getParent", "(", ")", ")", "{", "return", "false", ";", "}", "GraphItem", "item", "=", "(", "GraphItem", ")", "figure2ItemMap", ".", "get", "(", "figure", ")", ";", "if", "(", "item", "!=", "null", "&&", "item", ".", "getItemType", "(", ")", "==", "GraphItem", ".", "CONTAINER", ")", "{", "return", "false", ";", "}", "else", "if", "(", "figure", "instanceof", "FreeformLayer", "||", "parent", "instanceof", "FreeformLayer", "||", "figure", "instanceof", "ScrollPane", "||", "parent", "instanceof", "ScrollPane", "||", "parent", "instanceof", "ScalableFreeformLayeredPane", "||", "figure", "instanceof", "ScalableFreeformLayeredPane", "||", "figure", "instanceof", "FreeformViewport", "||", "parent", "instanceof", "FreeformViewport", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}", "}", ")", ";", "return", "figureUnderMouse", ";", "}", "private", "class", "DragSupport", "implements", "MouseMotionListener", ",", "org", ".", "eclipse", ".", "draw2d", ".", "MouseListener", "{", "Point", "dragStartLocation", "=", "null", ";", "IFigure", "draggedSubgraphFigure", "=", "null", ";", "ArrayList", "relativeLocations", "=", "new", "ArrayList", "(", ")", ";", "GraphItem", "fisheyedItem", "=", "null", ";", "boolean", "isDragging", "=", "false", ";", "public", "void", "mouseDragged", "(", "org", ".", "eclipse", ".", "draw2d", ".", "MouseEvent", "me", ")", "{", "if", "(", "!", "isDragging", ")", "{", "return", ";", "}", "if", "(", "selectedItems", ".", "isEmpty", "(", ")", ")", "{", "IFigure", "figureUnderMouse", "=", "getFigureAt", "(", "dragStartLocation", ".", "x", ",", "dragStartLocation", ".", "y", ")", ";", "if", "(", "subgraphFigures", ".", "contains", "(", "figureUnderMouse", ")", ")", "{", "draggedSubgraphFigure", "=", "figureUnderMouse", ";", "}", "}", "Point", "mousePoint", "=", "new", "Point", "(", "me", ".", "x", ",", "me", ".", "y", ")", ";", "if", "(", "!", "selectedItems", ".", "isEmpty", "(", ")", "||", "draggedSubgraphFigure", "!=", "null", ")", "{", "if", "(", "relativeLocations", ".", "isEmpty", "(", ")", ")", "{", "for", "(", "Iterator", "iterator", "=", "selectedItems", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "GraphItem", "item", "=", "(", "GraphItem", ")", "iterator", ".", "next", "(", ")", ";", "if", "(", "(", "item", ".", "getItemType", "(", ")", "==", "GraphItem", ".", "NODE", ")", "||", "(", "item", ".", "getItemType", "(", ")", "==", "GraphItem", ".", "CONTAINER", ")", ")", "{", "relativeLocations", ".", "add", "(", "getRelativeLocation", "(", "item", ".", "getFigure", "(", ")", ")", ")", ";", "}", "}", "if", "(", "draggedSubgraphFigure", "!=", "null", ")", "{", "relativeLocations", ".", "add", "(", "getRelativeLocation", "(", "draggedSubgraphFigure", ")", ")", ";", "}", "}", "Iterator", "locationsIterator", "=", "relativeLocations", ".", "iterator", "(", ")", ";", "for", "(", "Iterator", "selectionIterator", "=", "selectedItems", ".", "iterator", "(", ")", ";", "selectionIterator", ".", "hasNext", "(", ")", ";", ")", "{", "GraphItem", "item", "=", "(", "GraphItem", ")", "selectionIterator", ".", "next", "(", ")", ";", "if", "(", "(", "item", ".", "getItemType", "(", ")", "==", "GraphItem", ".", "NODE", ")", "||", "(", "item", ".", "getItemType", "(", ")", "==", "GraphItem", ".", "CONTAINER", ")", ")", "{", "Point", "pointCopy", "=", "mousePoint", ".", "getCopy", "(", ")", ";", "Point", "relativeLocation", "=", "(", "Point", ")", "locationsIterator", ".", "next", "(", ")", ";", "item", ".", "getFigure", "(", ")", ".", "getParent", "(", ")", ".", "translateToRelative", "(", "pointCopy", ")", ";", "item", ".", "getFigure", "(", ")", ".", "getParent", "(", ")", ".", "translateFromParent", "(", "pointCopy", ")", ";", "(", "(", "GraphNode", ")", "item", ")", ".", "setLocation", "(", "relativeLocation", ".", "x", "+", "pointCopy", ".", "x", ",", "relativeLocation", ".", "y", "+", "pointCopy", ".", "y", ")", ";", "}", "else", "{", "}", "}", "if", "(", "draggedSubgraphFigure", "!=", "null", ")", "{", "Point", "pointCopy", "=", "mousePoint", ".", "getCopy", "(", ")", ";", "draggedSubgraphFigure", ".", "getParent", "(", ")", ".", "translateToRelative", "(", "pointCopy", ")", ";", "draggedSubgraphFigure", ".", "getParent", "(", ")", ".", "translateFromParent", "(", "pointCopy", ")", ";", "Point", "relativeLocation", "=", "(", "Point", ")", "locationsIterator", ".", "next", "(", ")", ";", "pointCopy", ".", "x", "+=", "relativeLocation", ".", "x", ";", "pointCopy", ".", "y", "+=", "relativeLocation", ".", "y", ";", "draggedSubgraphFigure", ".", "setLocation", "(", "pointCopy", ")", ";", "}", "}", "}", "private", "Point", "getRelativeLocation", "(", "IFigure", "figure", ")", "{", "Point", "location", "=", "figure", ".", "getBounds", "(", ")", ".", "getTopLeft", "(", ")", ";", "Point", "mousePointCopy", "=", "dragStartLocation", ".", "getCopy", "(", ")", ";", "figure", ".", "getParent", "(", ")", ".", "translateToRelative", "(", "mousePointCopy", ")", ";", "figure", ".", "getParent", "(", ")", ".", "translateFromParent", "(", "mousePointCopy", ")", ";", "location", ".", "x", "-=", "mousePointCopy", ".", "x", ";", "location", ".", "y", "-=", "mousePointCopy", ".", "y", ";", "return", "location", ";", "}", "public", "void", "mouseEntered", "(", "org", ".", "eclipse", ".", "draw2d", ".", "MouseEvent", "me", ")", "{", "}", "public", "void", "mouseExited", "(", "org", ".", "eclipse", ".", "draw2d", ".", "MouseEvent", "me", ")", "{", "}", "public", "void", "mouseHover", "(", "org", ".", "eclipse", ".", "draw2d", ".", "MouseEvent", "me", ")", "{", "}", "public", "void", "mouseMoved", "(", "org", ".", "eclipse", ".", "draw2d", ".", "MouseEvent", "me", ")", "{", "Point", "mousePoint", "=", "new", "Point", "(", "me", ".", "x", ",", "me", ".", "y", ")", ";", "getRootLayer", "(", ")", ".", "translateToRelative", "(", "mousePoint", ")", ";", "IFigure", "figureUnderMouse", "=", "getFigureAt", "(", "mousePoint", ".", "x", ",", "mousePoint", ".", "y", ")", ";", "if", "(", "figureUnderMouse", "!=", "null", ")", "{", "GraphItem", "itemUnderMouse", "=", "(", "GraphItem", ")", "figure2ItemMap", ".", "get", "(", "figureUnderMouse", ")", ";", "if", "(", "itemUnderMouse", "==", "fisheyedItem", ")", "{", "return", ";", "}", "if", "(", "fisheyedItem", "!=", "null", ")", "{", "(", "(", "GraphNode", ")", "fisheyedItem", ")", ".", "fishEye", "(", "false", ",", "true", ")", ";", "fisheyedItem", "=", "null", ";", "}", "if", "(", "itemUnderMouse", "!=", "null", "&&", "itemUnderMouse", ".", "getItemType", "(", ")", "==", "GraphItem", ".", "NODE", ")", "{", "fisheyedItem", "=", "itemUnderMouse", ";", "IFigure", "fisheyedFigure", "=", "(", "(", "GraphNode", ")", "itemUnderMouse", ")", ".", "fishEye", "(", "true", ",", "true", ")", ";", "if", "(", "fisheyedFigure", "==", "null", ")", "{", "fisheyedItem", "=", "null", ";", "}", "}", "}", "else", "{", "if", "(", "fisheyedItem", "!=", "null", ")", "{", "(", "(", "GraphNode", ")", "fisheyedItem", ")", ".", "fishEye", "(", "false", ",", "true", ")", ";", "fisheyedItem", "=", "null", ";", "}", "}", "}", "public", "void", "mouseDoubleClicked", "(", "org", ".", "eclipse", ".", "draw2d", ".", "MouseEvent", "me", ")", "{", "}", "public", "void", "mousePressed", "(", "org", ".", "eclipse", ".", "draw2d", ".", "MouseEvent", "me", ")", "{", "isDragging", "=", "true", ";", "Point", "mousePoint", "=", "new", "Point", "(", "me", ".", "x", ",", "me", ".", "y", ")", ";", "dragStartLocation", "=", "mousePoint", ".", "getCopy", "(", ")", ";", "getRootLayer", "(", ")", ".", "translateToRelative", "(", "mousePoint", ")", ";", "if", "(", "(", "me", ".", "getState", "(", ")", "&", "SWT", ".", "MOD3", ")", "!=", "0", ")", "{", "if", "(", "(", "me", ".", "getState", "(", ")", "&", "SWT", ".", "MOD2", ")", "==", "0", ")", "{", "double", "scale", "=", "getRootLayer", "(", ")", ".", "getScale", "(", ")", ";", "scale", "*=", "1.05", ";", "getRootLayer", "(", ")", ".", "setScale", "(", "scale", ")", ";", "Point", "newMousePoint", "=", "mousePoint", ".", "getCopy", "(", ")", ".", "scale", "(", "1.05", ")", ";", "Point", "delta", "=", "new", "Point", "(", "newMousePoint", ".", "x", "-", "mousePoint", ".", "x", ",", "newMousePoint", ".", "y", "-", "mousePoint", ".", "y", ")", ";", "Point", "newViewLocation", "=", "getViewport", "(", ")", ".", "getViewLocation", "(", ")", ".", "getCopy", "(", ")", ".", "translate", "(", "delta", ")", ";", "getViewport", "(", ")", ".", "setViewLocation", "(", "newViewLocation", ")", ";", "clearSelection", "(", ")", ";", "return", ";", "}", "else", "{", "double", "scale", "=", "getRootLayer", "(", ")", ".", "getScale", "(", ")", ";", "scale", "/=", "1.05", ";", "getRootLayer", "(", ")", ".", "setScale", "(", "scale", ")", ";", "Point", "newMousePoint", "=", "mousePoint", ".", "getCopy", "(", ")", ".", "scale", "(", "1", "/", "1.05", ")", ";", "Point", "delta", "=", "new", "Point", "(", "newMousePoint", ".", "x", "-", "mousePoint", ".", "x", ",", "newMousePoint", ".", "y", "-", "mousePoint", ".", "y", ")", ";", "Point", "newViewLocation", "=", "getViewport", "(", ")", ".", "getViewLocation", "(", ")", ".", "getCopy", "(", ")", ".", "translate", "(", "delta", ")", ";", "getViewport", "(", ")", ".", "setViewLocation", "(", "newViewLocation", ")", ";", "clearSelection", "(", ")", ";", "return", ";", "}", "}", "else", "{", "boolean", "hasSelection", "=", "selectedItems", ".", "size", "(", ")", ">", "0", ";", "IFigure", "figureUnderMouse", "=", "getFigureAt", "(", "mousePoint", ".", "x", ",", "mousePoint", ".", "y", ")", ";", "getRootLayer", "(", ")", ".", "translateFromParent", "(", "mousePoint", ")", ";", "if", "(", "figureUnderMouse", "!=", "null", ")", "{", "figureUnderMouse", ".", "getParent", "(", ")", ".", "translateFromParent", "(", "mousePoint", ")", ";", "}", "if", "(", "figureUnderMouse", "==", "null", "||", "figureUnderMouse", "==", "Graph", ".", "this", ")", "{", "if", "(", "(", "me", ".", "getState", "(", ")", "&", "SWT", ".", "MOD1", ")", "==", "0", ")", "{", "clearSelection", "(", ")", ";", "if", "(", "hasSelection", ")", "{", "fireWidgetSelectedEvent", "(", "null", ")", ";", "hasSelection", "=", "false", ";", "}", "}", "return", ";", "}", "GraphItem", "itemUnderMouse", "=", "(", "GraphItem", ")", "figure2ItemMap", ".", "get", "(", "figureUnderMouse", ")", ";", "if", "(", "itemUnderMouse", "==", "null", ")", "{", "if", "(", "(", "me", ".", "getState", "(", ")", "&", "SWT", ".", "MOD1", ")", "!=", "0", ")", "{", "clearSelection", "(", ")", ";", "if", "(", "hasSelection", ")", "{", "fireWidgetSelectedEvent", "(", "null", ")", ";", "hasSelection", "=", "false", ";", "}", "}", "return", ";", "}", "if", "(", "selectedItems", ".", "contains", "(", "itemUnderMouse", ")", ")", "{", "if", "(", "(", "me", ".", "getState", "(", ")", "&", "SWT", ".", "MOD1", ")", "!=", "0", ")", "{", "selectedItems", ".", "remove", "(", "itemUnderMouse", ")", ";", "(", "itemUnderMouse", ")", ".", "unhighlight", "(", ")", ";", "fireWidgetSelectedEvent", "(", "itemUnderMouse", ")", ";", "}", "return", ";", "}", "if", "(", "(", "me", ".", "getState", "(", ")", "&", "SWT", ".", "MOD1", ")", "==", "0", ")", "{", "clearSelection", "(", ")", ";", "}", "if", "(", "itemUnderMouse", ".", "getItemType", "(", ")", "==", "GraphItem", ".", "NODE", ")", "{", "selectedItems", ".", "add", "(", "itemUnderMouse", ")", ";", "(", "(", "GraphNode", ")", "itemUnderMouse", ")", ".", "highlight", "(", ")", ";", "fireWidgetSelectedEvent", "(", "itemUnderMouse", ")", ";", "}", "else", "if", "(", "itemUnderMouse", ".", "getItemType", "(", ")", "==", "GraphItem", ".", "CONNECTION", ")", "{", "selectedItems", ".", "add", "(", "itemUnderMouse", ")", ";", "(", "(", "GraphConnection", ")", "itemUnderMouse", ")", ".", "highlight", "(", ")", ";", "fireWidgetSelectedEvent", "(", "itemUnderMouse", ")", ";", "}", "else", "if", "(", "itemUnderMouse", ".", "getItemType", "(", ")", "==", "GraphItem", ".", "CONTAINER", ")", "{", "selectedItems", ".", "add", "(", "itemUnderMouse", ")", ";", "(", "(", "GraphContainer", ")", "itemUnderMouse", ")", ".", "highlight", "(", ")", ";", "fireWidgetSelectedEvent", "(", "itemUnderMouse", ")", ";", "}", "}", "}", "public", "void", "mouseReleased", "(", "org", ".", "eclipse", ".", "draw2d", ".", "MouseEvent", "me", ")", "{", "isDragging", "=", "false", ";", "relativeLocations", ".", "clear", "(", ")", ";", "draggedSubgraphFigure", "=", "null", ";", "}", "}", "public", "void", "notifyListeners", "(", "int", "eventType", ",", "Event", "event", ")", "{", "super", ".", "notifyListeners", "(", "eventType", ",", "event", ")", ";", "if", "(", "eventType", "==", "SWT", ".", "Selection", "&&", "event", "!=", "null", ")", "{", "notifySelectionListeners", "(", "new", "SelectionEvent", "(", "event", ")", ")", ";", "}", "}", "private", "void", "clearSelection", "(", ")", "{", "Iterator", "iterator", "=", "new", "ArrayList", "(", "selectedItems", ")", ".", "iterator", "(", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "deselect", "(", "(", "GraphItem", ")", "iterator", ".", "next", "(", ")", ")", ";", "}", "}", "private", "void", "fireWidgetSelectedEvent", "(", "Item", "item", ")", "{", "Event", "swtEvent", "=", "new", "Event", "(", ")", ";", "swtEvent", ".", "item", "=", "item", ";", "swtEvent", ".", "widget", "=", "this", ";", "notifySelectionListeners", "(", "new", "SelectionEvent", "(", "swtEvent", ")", ")", ";", "}", "private", "void", "notifySelectionListeners", "(", "SelectionEvent", "event", ")", "{", "Iterator", "iterator", "=", "selectionListeners", ".", "iterator", "(", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "(", "(", "SelectionListener", ")", "iterator", ".", "next", "(", ")", ")", ".", "widgetSelected", "(", "event", ")", ";", "}", "}", "private", "void", "deselect", "(", "GraphItem", "item", ")", "{", "selectedItems", ".", "remove", "(", "item", ")", ";", "item", ".", "unhighlight", "(", ")", ";", "setNodeSelected", "(", "item", ",", "false", ")", ";", "}", "private", "void", "select", "(", "GraphItem", "item", ")", "{", "selectedItems", ".", "add", "(", "item", ")", ";", "item", ".", "highlight", "(", ")", ";", "setNodeSelected", "(", "item", ",", "true", ")", ";", "}", "private", "void", "setNodeSelected", "(", "GraphItem", "item", ",", "boolean", "selected", ")", "{", "if", "(", "item", "instanceof", "GraphNode", ")", "{", "(", "(", "GraphNode", ")", "item", ")", ".", "setSelected", "(", "selected", ")", ";", "}", "}", "GraphConnection", "[", "]", "getConnectionsArray", "(", ")", "{", "GraphConnection", "[", "]", "connsArray", "=", "new", "GraphConnection", "[", "connections", ".", "size", "(", ")", "]", ";", "connsArray", "=", "(", "GraphConnection", "[", "]", ")", "connections", ".", "toArray", "(", "connsArray", ")", ";", "return", "connsArray", ";", "}", "public", "void", "clear", "(", ")", "{", "for", "(", "Iterator", "i", "=", "new", "ArrayList", "(", "connections", ")", ".", "iterator", "(", ")", ";", "i", ".", "hasNext", "(", ")", ";", ")", "{", "removeConnection", "(", "(", "GraphConnection", ")", "i", ".", "next", "(", ")", ")", ";", "}", "for", "(", "Iterator", "i", "=", "new", "HashSet", "(", "subgraphFigures", ")", ".", "iterator", "(", ")", ";", "i", ".", "hasNext", "(", ")", ";", ")", "{", "removeSubgraphFigure", "(", "(", "IFigure", ")", "i", ".", "next", "(", ")", ")", ";", "}", "for", "(", "Iterator", "i", "=", "new", "ArrayList", "(", "nodes", ")", ".", "iterator", "(", ")", ";", "i", ".", "hasNext", "(", ")", ";", ")", "{", "removeNode", "(", "(", "GraphNode", ")", "i", ".", "next", "(", ")", ")", ";", "}", "}", "void", "removeConnection", "(", "GraphConnection", "connection", ")", "{", "IFigure", "figure", "=", "connection", ".", "getConnectionFigure", "(", ")", ";", "PolylineConnection", "sourceContainerConnectionFigure", "=", "connection", ".", "getSourceContainerConnectionFigure", "(", ")", ";", "PolylineConnection", "targetContainerConnectionFigure", "=", "connection", ".", "getTargetContainerConnectionFigure", "(", ")", ";", "connection", ".", "removeFigure", "(", ")", ";", "this", ".", "getConnections", "(", ")", ".", "remove", "(", "connection", ")", ";", "this", ".", "selectedItems", ".", "remove", "(", "connection", ")", ";", "figure2ItemMap", ".", "remove", "(", "figure", ")", ";", "if", "(", "sourceContainerConnectionFigure", "!=", "null", ")", "{", "figure2ItemMap", ".", "remove", "(", "sourceContainerConnectionFigure", ")", ";", "}", "if", "(", "targetContainerConnectionFigure", "!=", "null", ")", "{", "figure2ItemMap", ".", "remove", "(", "targetContainerConnectionFigure", ")", ";", "}", "getLayoutContext", "(", ")", ".", "fireConnectionRemovedEvent", "(", "connection", ".", "getLayout", "(", ")", ")", ";", "}", "void", "removeNode", "(", "GraphNode", "node", ")", "{", "IFigure", "figure", "=", "node", ".", "getNodeFigure", "(", ")", ";", "if", "(", "figure", ".", "getParent", "(", ")", "!=", "null", ")", "{", "figure", ".", "getParent", "(", ")", ".", "remove", "(", "figure", ")", ";", "}", "this", ".", "getNodes", "(", ")", ".", "remove", "(", "node", ")", ";", "this", ".", "selectedItems", ".", "remove", "(", "node", ")", ";", "figure2ItemMap", ".", "remove", "(", "figure", ")", ";", "node", ".", "getLayout", "(", ")", ".", "dispose", "(", ")", ";", "}", "void", "addConnection", "(", "GraphConnection", "connection", ",", "boolean", "addToEdgeLayer", ")", "{", "this", ".", "getConnections", "(", ")", ".", "add", "(", "connection", ")", ";", "if", "(", "addToEdgeLayer", ")", "{", "zestRootLayer", ".", "addConnection", "(", "connection", ".", "getFigure", "(", ")", ")", ";", "}", "getLayoutContext", "(", ")", ".", "fireConnectionAddedEvent", "(", "connection", ".", "getLayout", "(", ")", ")", ";", "}", "public", "void", "addNode", "(", "GraphNode", "node", ")", "{", "this", ".", "getNodes", "(", ")", ".", "add", "(", "node", ")", ";", "zestRootLayer", ".", "addNode", "(", "node", ".", "getFigure", "(", ")", ")", ";", "getLayoutContext", "(", ")", ".", "fireNodeAddedEvent", "(", "node", ".", "getLayout", "(", ")", ")", ";", "}", "public", "void", "addSubgraphFigure", "(", "IFigure", "figure", ")", "{", "zestRootLayer", ".", "addSubgraph", "(", "figure", ")", ";", "subgraphFigures", ".", "add", "(", "figure", ")", ";", "}", "void", "removeSubgraphFigure", "(", "IFigure", "figure", ")", "{", "subgraphFigures", ".", "remove", "(", "figure", ")", ";", "figure", ".", "getParent", "(", ")", ".", "remove", "(", "figure", ")", ";", "}", "void", "registerItem", "(", "GraphItem", "item", ")", "{", "if", "(", "item", ".", "getItemType", "(", ")", "==", "GraphItem", ".", "NODE", ")", "{", "IFigure", "figure", "=", "item", ".", "getFigure", "(", ")", ";", "figure2ItemMap", ".", "put", "(", "figure", ",", "item", ")", ";", "}", "else", "if", "(", "item", ".", "getItemType", "(", ")", "==", "GraphItem", ".", "CONNECTION", ")", "{", "IFigure", "figure", "=", "item", ".", "getFigure", "(", ")", ";", "figure2ItemMap", ".", "put", "(", "figure", ",", "item", ")", ";", "if", "(", "(", "(", "GraphConnection", ")", "item", ")", ".", "getSourceContainerConnectionFigure", "(", ")", "!=", "null", ")", "{", "figure2ItemMap", ".", "put", "(", "(", "(", "GraphConnection", ")", "item", ")", ".", "getSourceContainerConnectionFigure", "(", ")", ",", "item", ")", ";", "}", "if", "(", "(", "(", "GraphConnection", ")", "item", ")", ".", "getTargetContainerConnectionFigure", "(", ")", "!=", "null", ")", "{", "figure2ItemMap", ".", "put", "(", "(", "(", "GraphConnection", ")", "item", ")", ".", "getTargetContainerConnectionFigure", "(", ")", ",", "item", ")", ";", "}", "}", "else", "if", "(", "item", ".", "getItemType", "(", ")", "==", "GraphItem", ".", "CONTAINER", ")", "{", "IFigure", "figure", "=", "item", ".", "getFigure", "(", ")", ";", "figure2ItemMap", ".", "put", "(", "figure", ",", "item", ")", ";", "}", "else", "{", "throw", "new", "RuntimeException", "(", "\"\"", "+", "item", ".", "getItemType", "(", ")", ")", ";", "}", "}", "private", "void", "scheduleLayoutOnReveal", "(", "final", "boolean", "clean", ")", "{", "final", "boolean", "[", "]", "isVisibleSync", "=", "new", "boolean", "[", "1", "]", ";", "Display", ".", "getDefault", "(", ")", ".", "syncExec", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "isVisibleSync", "[", "0", "]", "=", "isVisible", "(", ")", ";", "}", "}", ")", ";", "if", "(", "isVisibleSync", "[", "0", "]", ")", "{", "applyLayoutInternal", "(", "clean", ")", ";", "}", "else", "{", "shouldSheduleLayout", "=", "true", ";", "}", "}", "private", "ScalableFigure", "createLayers", "(", ")", "{", "rootlayer", "=", "new", "ScalableFreeformLayeredPane", "(", ")", ";", "rootlayer", ".", "setLayoutManager", "(", "new", "FreeformLayout", "(", ")", ")", ";", "zestRootLayer", "=", "new", "ZestRootLayer", "(", ")", ";", "zestRootLayer", ".", "setLayoutManager", "(", "new", "FreeformLayout", "(", ")", ")", ";", "fishEyeLayer", "=", "new", "ScalableFreeformLayeredPane", "(", ")", ";", "fishEyeLayer", ".", "setLayoutManager", "(", "new", "FreeformLayout", "(", ")", ")", ";", "rootlayer", ".", "add", "(", "zestRootLayer", ")", ";", "rootlayer", ".", "add", "(", "fishEyeLayer", ")", ";", "zestRootLayer", ".", "addLayoutListener", "(", "LayoutAnimator", ".", "getDefault", "(", ")", ")", ";", "fishEyeLayer", ".", "addLayoutListener", "(", "LayoutAnimator", ".", "getDefault", "(", ")", ")", ";", "rootlayer", ".", "addCoordinateListener", "(", "new", "CoordinateListener", "(", ")", "{", "public", "void", "coordinateSystemChanged", "(", "IFigure", "source", ")", "{", "if", "(", "preferredSize", ".", "width", "==", "-", "1", "&&", "preferredSize", ".", "height", "==", "-", "1", ")", "{", "getLayoutContext", "(", ")", ".", "fireBoundsChangedEvent", "(", ")", ";", "}", "}", "}", ")", ";", "return", "rootlayer", ";", "}", "void", "removeFishEye", "(", "final", "IFigure", "fishEyeFigure", ",", "final", "IFigure", "regularFigure", ",", "boolean", "animate", ")", "{", "if", "(", "!", "fishEyeLayer", ".", "getChildren", "(", ")", ".", "contains", "(", "fishEyeFigure", ")", ")", "{", "return", ";", "}", "if", "(", "animate", ")", "{", "Animation", ".", "markBegin", "(", ")", ";", "}", "Rectangle", "bounds", "=", "regularFigure", ".", "getBounds", "(", ")", ".", "getCopy", "(", ")", ";", "regularFigure", ".", "translateToAbsolute", "(", "bounds", ")", ";", "double", "scale", "=", "rootlayer", ".", "getScale", "(", ")", ";", "fishEyeLayer", ".", "setScale", "(", "1", "/", "scale", ")", ";", "fishEyeLayer", ".", "translateToRelative", "(", "bounds", ")", ";", "fishEyeLayer", ".", "translateFromParent", "(", "bounds", ")", ";", "fishEyeLayer", ".", "setConstraint", "(", "fishEyeFigure", ",", "bounds", ")", ";", "for", "(", "Iterator", "iterator", "=", "fisheyeListeners", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "FisheyeListener", "listener", "=", "(", "FisheyeListener", ")", "iterator", ".", "next", "(", ")", ";", "listener", ".", "fisheyeRemoved", "(", "this", ",", "regularFigure", ",", "fishEyeFigure", ")", ";", "}", "if", "(", "animate", ")", "{", "Animation", ".", "run", "(", "FISHEYE_ANIMATION_TIME", "*", "2", ")", ";", "}", "this", ".", "getRootLayer", "(", ")", ".", "getUpdateManager", "(", ")", ".", "performUpdate", "(", ")", ";", "fishEyeLayer", ".", "removeAll", "(", ")", ";", "}", "boolean", "replaceFishFigure", "(", "IFigure", "oldFigure", ",", "IFigure", "newFigure", ")", "{", "if", "(", "this", ".", "fishEyeLayer", ".", "getChildren", "(", ")", ".", "contains", "(", "oldFigure", ")", ")", "{", "Rectangle", "bounds", "=", "oldFigure", ".", "getBounds", "(", ")", ";", "newFigure", ".", "setBounds", "(", "bounds", ")", ";", "this", ".", "fishEyeLayer", ".", "remove", "(", "oldFigure", ")", ";", "this", ".", "fishEyeLayer", ".", "add", "(", "newFigure", ")", ";", "for", "(", "Iterator", "iterator", "=", "fisheyeListeners", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "FisheyeListener", "listener", "=", "(", "FisheyeListener", ")", "iterator", ".", "next", "(", ")", ";", "listener", ".", "fisheyeReplaced", "(", "this", ",", "oldFigure", ",", "newFigure", ")", ";", "}", "return", "true", ";", "}", "return", "false", ";", "}", "void", "fishEye", "(", "IFigure", "startFigure", ",", "IFigure", "endFigure", ",", "Rectangle", "newBounds", ",", "boolean", "animate", ")", "{", "fishEyeLayer", ".", "removeAll", "(", ")", ";", "if", "(", "animate", ")", "{", "Animation", ".", "markBegin", "(", ")", ";", "}", "double", "scale", "=", "rootlayer", ".", "getScale", "(", ")", ";", "fishEyeLayer", ".", "setScale", "(", "1", "/", "scale", ")", ";", "fishEyeLayer", ".", "translateToRelative", "(", "newBounds", ")", ";", "fishEyeLayer", ".", "translateFromParent", "(", "newBounds", ")", ";", "Rectangle", "bounds", "=", "startFigure", ".", "getBounds", "(", ")", ".", "getCopy", "(", ")", ";", "startFigure", ".", "translateToAbsolute", "(", "bounds", ")", ";", "fishEyeLayer", ".", "translateToRelative", "(", "bounds", ")", ";", "fishEyeLayer", ".", "translateFromParent", "(", "bounds", ")", ";", "endFigure", ".", "setLocation", "(", "bounds", ".", "getLocation", "(", ")", ")", ";", "endFigure", ".", "setSize", "(", "bounds", ".", "getSize", "(", ")", ")", ";", "fishEyeLayer", ".", "add", "(", "endFigure", ")", ";", "fishEyeLayer", ".", "setConstraint", "(", "endFigure", ",", "newBounds", ")", ";", "for", "(", "Iterator", "iterator", "=", "fisheyeListeners", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "FisheyeListener", "listener", "=", "(", "FisheyeListener", ")", "iterator", ".", "next", "(", ")", ";", "listener", ".", "fisheyeAdded", "(", "this", ",", "startFigure", ",", "endFigure", ")", ";", "}", "if", "(", "animate", ")", "{", "Animation", ".", "run", "(", "FISHEYE_ANIMATION_TIME", ")", ";", "}", "this", ".", "getRootLayer", "(", ")", ".", "getUpdateManager", "(", ")", ".", "performUpdate", "(", ")", ";", "}", "public", "void", "addFisheyeListener", "(", "FisheyeListener", "listener", ")", "{", "fisheyeListeners", ".", "add", "(", "listener", ")", ";", "}", "public", "void", "removeFisheyeListener", "(", "FisheyeListener", "listener", ")", "{", "fisheyeListeners", ".", "remove", "(", "listener", ")", ";", "}", "public", "int", "getItemType", "(", ")", "{", "return", "GraphItem", ".", "GRAPH", ";", "}", "GraphItem", "getGraphItem", "(", "IFigure", "figure", ")", "{", "return", "(", "GraphItem", ")", "figure2ItemMap", ".", "get", "(", "figure", ")", ";", "}", "public", "void", "setExpanded", "(", "GraphNode", "node", ",", "boolean", "expanded", ")", "{", "layoutContext", ".", "setExpanded", "(", "node", ".", "getLayout", "(", ")", ",", "expanded", ")", ";", "rootlayer", ".", "invalidate", "(", ")", ";", "}", "public", "boolean", "canExpand", "(", "GraphNode", "node", ")", "{", "return", "layoutContext", ".", "canExpand", "(", "node", ".", "getLayout", "(", ")", ")", ";", "}", "public", "boolean", "canCollapse", "(", "GraphNode", "node", ")", "{", "return", "layoutContext", ".", "canCollapse", "(", "node", ".", "getLayout", "(", ")", ")", ";", "}", "public", "Graph", "getGraph", "(", ")", "{", "return", "this", ";", "}", "public", "Widget", "getItem", "(", ")", "{", "return", "this", ";", "}", "public", "DisplayIndependentRectangle", "getLayoutBounds", "(", ")", "{", "Dimension", "preferredSize", "=", "this", ".", "getPreferredSize", "(", ")", ";", "return", "new", "DisplayIndependentRectangle", "(", "0", ",", "0", ",", "preferredSize", ".", "width", ",", "preferredSize", ".", "height", ")", ";", "}", "void", "setDefaultConnectionRouter", "(", "ConnectionRouter", "defaultConnectionRouter", ")", "{", "this", ".", "defaultConnectionRouter", "=", "defaultConnectionRouter", ";", "}", "ConnectionRouter", "getDefaultConnectionRouter", "(", ")", "{", "return", "defaultConnectionRouter", ";", "}", "void", "applyConnectionRouter", "(", ")", "{", "Iterator", "iterator", "=", "getConnections", "(", ")", ".", "iterator", "(", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "GraphConnection", "conn", "=", "(", "GraphConnection", ")", "iterator", ".", "next", "(", ")", ";", "conn", ".", "getConnectionFigure", "(", ")", ".", "setConnectionRouter", "(", "defaultConnectionRouter", ")", ";", "}", "this", ".", "getRootLayer", "(", ")", ".", "getUpdateManager", "(", ")", ".", "performUpdate", "(", ")", ";", "}", "public", "void", "setRouter", "(", "ConnectionRouter", "connectionRouter", ")", "{", "setDefaultConnectionRouter", "(", "connectionRouter", ")", ";", "applyConnectionRouter", "(", ")", ";", "}", "public", "ZoomManager", "getZoomManager", "(", ")", "{", "if", "(", "zoomManager", "==", "null", ")", "{", "zoomManager", "=", "new", "ZoomManager", "(", "getRootLayer", "(", ")", ",", "getViewport", "(", ")", ")", ";", "}", "return", "zoomManager", ";", "}", "}", "</s>" ]
10,286
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "Animation", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "LayoutAlgorithm", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "dataStructures", ".", "DisplayIndependentRectangle", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "ConnectionLayout", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "ContextListener", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "EntityLayout", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "ExpandCollapseManager", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "GraphStructureListener", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "LayoutContext", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "LayoutListener", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "NodeLayout", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "PruningListener", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "SubgraphLayout", ";", "class", "InternalLayoutContext", "implements", "LayoutContext", "{", "final", "IContainer", "container", ";", "private", "final", "List", "filters", "=", "new", "ArrayList", "(", ")", ";", "private", "final", "List", "contextListeners", "=", "new", "ArrayList", "(", ")", ";", "private", "final", "List", "graphStructureListeners", "=", "new", "ArrayList", "(", ")", ";", "private", "final", "List", "layoutListeners", "=", "new", "ArrayList", "(", ")", ";", "private", "final", "List", "pruningListeners", "=", "new", "ArrayList", "(", ")", ";", "private", "LayoutAlgorithm", "mainAlgorithm", ";", "private", "LayoutAlgorithm", "layoutAlgorithm", ";", "private", "ExpandCollapseManager", "expandCollapseManager", ";", "private", "SubgraphFactory", "subgraphFactory", "=", "new", "DefaultSubgraph", ".", "DefaultSubgraphFactory", "(", ")", ";", "private", "final", "HashSet", "subgraphs", "=", "new", "HashSet", "(", ")", ";", "private", "boolean", "eventsOn", "=", "true", ";", "private", "boolean", "backgorundLayoutEnabled", "=", "true", ";", "private", "boolean", "externalLayoutInvocation", "=", "false", ";", "InternalLayoutContext", "(", "Graph", "graph", ")", "{", "this", ".", "container", "=", "graph", ";", "}", "InternalLayoutContext", "(", "GraphContainer", "container", ")", "{", "this", ".", "container", "=", "container", ";", "}", "public", "void", "addContextListener", "(", "ContextListener", "listener", ")", "{", "contextListeners", ".", "add", "(", "listener", ")", ";", "}", "public", "void", "addGraphStructureListener", "(", "GraphStructureListener", "listener", ")", "{", "graphStructureListeners", ".", "add", "(", "listener", ")", ";", "}", "public", "void", "addLayoutListener", "(", "LayoutListener", "listener", ")", "{", "layoutListeners", ".", "add", "(", "listener", ")", ";", "}", "public", "void", "addPruningListener", "(", "PruningListener", "listener", ")", "{", "pruningListeners", ".", "add", "(", "listener", ")", ";", "}", "public", "SubgraphLayout", "createSubgraph", "(", "NodeLayout", "[", "]", "nodes", ")", "{", "checkChangesAllowed", "(", ")", ";", "InternalNodeLayout", "[", "]", "internalNodes", "=", "new", "InternalNodeLayout", "[", "nodes", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "nodes", ".", "length", ";", "i", "++", ")", "{", "internalNodes", "[", "i", "]", "=", "(", "InternalNodeLayout", ")", "nodes", "[", "i", "]", ";", "}", "SubgraphLayout", "subgraph", "=", "subgraphFactory", ".", "createSubgraph", "(", "internalNodes", ",", "this", ")", ";", "subgraphs", ".", "add", "(", "subgraph", ")", ";", "return", "subgraph", ";", "}", "void", "removeSubgrah", "(", "DefaultSubgraph", "subgraph", ")", "{", "subgraphs", ".", "remove", "(", "subgraph", ")", ";", "}", "public", "void", "flushChanges", "(", "boolean", "animationHint", ")", "{", "if", "(", "!", "container", ".", "getGraph", "(", ")", ".", "isVisible", "(", ")", "&&", "animationHint", ")", "{", "return", ";", "}", "eventsOn", "=", "false", ";", "if", "(", "animationHint", ")", "{", "Animation", ".", "markBegin", "(", ")", ";", "}", "for", "(", "Iterator", "iterator", "=", "container", ".", "getNodes", "(", ")", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "GraphNode", "node", "=", "(", "GraphNode", ")", "iterator", ".", "next", "(", ")", ";", "node", ".", "applyLayoutChanges", "(", ")", ";", "}", "for", "(", "Iterator", "iterator", "=", "container", ".", "getConnections", "(", ")", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "GraphConnection", "connection", "=", "(", "GraphConnection", ")", "iterator", ".", "next", "(", ")", ";", "connection", ".", "applyLayoutChanges", "(", ")", ";", "}", "for", "(", "Iterator", "iterator", "=", "subgraphs", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "DefaultSubgraph", "subgraph", "=", "(", "DefaultSubgraph", ")", "iterator", ".", "next", "(", ")", ";", "subgraph", ".", "applyLayoutChanges", "(", ")", ";", "}", "if", "(", "animationHint", ")", "{", "Animation", ".", "run", "(", "Graph", ".", "ANIMATION_TIME", ")", ";", "}", "eventsOn", "=", "true", ";", "}", "public", "DisplayIndependentRectangle", "getBounds", "(", ")", "{", "DisplayIndependentRectangle", "result", "=", "new", "DisplayIndependentRectangle", "(", "container", ".", "getLayoutBounds", "(", ")", ")", ";", "result", ".", "width", "-=", "20", ";", "result", ".", "height", "-=", "20", ";", "return", "result", ";", "}", "public", "LayoutAlgorithm", "getMainLayoutAlgorithm", "(", ")", "{", "return", "mainAlgorithm", ";", "}", "public", "ExpandCollapseManager", "getExpandCollapseManager", "(", ")", "{", "return", "expandCollapseManager", ";", "}", "public", "NodeLayout", "[", "]", "getNodes", "(", ")", "{", "ArrayList", "result", "=", "new", "ArrayList", "(", ")", ";", "for", "(", "Iterator", "iterator", "=", "this", ".", "container", ".", "getNodes", "(", ")", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "GraphNode", "node", "=", "(", "GraphNode", ")", "iterator", ".", "next", "(", ")", ";", "if", "(", "!", "isLayoutItemFiltered", "(", "node", ")", ")", "{", "result", ".", "add", "(", "node", ".", "getLayout", "(", ")", ")", ";", "}", "}", "return", "(", "NodeLayout", "[", "]", ")", "result", ".", "toArray", "(", "new", "NodeLayout", "[", "result", ".", "size", "(", ")", "]", ")", ";", "}", "public", "EntityLayout", "[", "]", "getEntities", "(", ")", "{", "HashSet", "addedSubgraphs", "=", "new", "HashSet", "(", ")", ";", "ArrayList", "result", "=", "new", "ArrayList", "(", ")", ";", "for", "(", "Iterator", "iterator", "=", "this", ".", "container", ".", "getNodes", "(", ")", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "GraphNode", "node", "=", "(", "GraphNode", ")", "iterator", ".", "next", "(", ")", ";", "if", "(", "!", "isLayoutItemFiltered", "(", "node", ")", ")", "{", "InternalNodeLayout", "nodeLayout", "=", "node", ".", "getLayout", "(", ")", ";", "if", "(", "!", "nodeLayout", ".", "isPruned", "(", ")", ")", "{", "result", ".", "add", "(", "nodeLayout", ")", ";", "}", "else", "{", "SubgraphLayout", "subgraph", "=", "nodeLayout", ".", "getSubgraph", "(", ")", ";", "if", "(", "subgraph", ".", "isGraphEntity", "(", ")", "&&", "!", "addedSubgraphs", ".", "contains", "(", "subgraph", ")", ")", "{", "result", ".", "add", "(", "subgraph", ")", ";", "addedSubgraphs", ".", "add", "(", "subgraph", ")", ";", "}", "}", "}", "}", "return", "(", "EntityLayout", "[", "]", ")", "result", ".", "toArray", "(", "new", "EntityLayout", "[", "result", ".", "size", "(", ")", "]", ")", ";", "}", "public", "SubgraphLayout", "[", "]", "getSubgraphs", "(", ")", "{", "SubgraphLayout", "[", "]", "result", "=", "new", "SubgraphLayout", "[", "subgraphs", ".", "size", "(", ")", "]", ";", "int", "subgraphCount", "=", "0", ";", "for", "(", "Iterator", "iterator", "=", "subgraphs", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "SubgraphLayout", "subgraph", "=", "(", "SubgraphLayout", ")", "iterator", ".", "next", "(", ")", ";", "NodeLayout", "[", "]", "nodes", "=", "subgraph", ".", "getNodes", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "nodes", ".", "length", ";", "i", "++", ")", "{", "if", "(", "!", "isLayoutItemFiltered", "(", "(", "(", "InternalNodeLayout", ")", "nodes", "[", "i", "]", ")", ".", "getNode", "(", ")", ")", ")", "{", "result", "[", "subgraphCount", "++", "]", "=", "subgraph", ";", "break", ";", "}", "}", "}", "if", "(", "subgraphCount", "==", "subgraphs", ".", "size", "(", ")", ")", "{", "return", "result", ";", "}", "else", "{", "SubgraphLayout", "[", "]", "result2", "=", "new", "SubgraphLayout", "[", "subgraphCount", "]", ";", "System", ".", "arraycopy", "(", "result", ",", "0", ",", "result2", ",", "0", ",", "subgraphCount", ")", ";", "return", "result2", ";", "}", "}", "public", "boolean", "isBoundsExpandable", "(", ")", "{", "return", "false", ";", "}", "public", "boolean", "isBackgroundLayoutEnabled", "(", ")", "{", "return", "backgorundLayoutEnabled", ";", "}", "void", "setBackgroundLayoutEnabled", "(", "boolean", "enabled", ")", "{", "if", "(", "this", ".", "backgorundLayoutEnabled", "!=", "enabled", ")", "{", "this", ".", "backgorundLayoutEnabled", "=", "enabled", ";", "fireBackgroundEnableChangedEvent", "(", ")", ";", "}", "}", "public", "boolean", "isPruningEnabled", "(", ")", "{", "return", "expandCollapseManager", "!=", "null", ";", "}", "public", "void", "removeContextListener", "(", "ContextListener", "listener", ")", "{", "contextListeners", ".", "remove", "(", "listener", ")", ";", "}", "public", "void", "removeGraphStructureListener", "(", "GraphStructureListener", "listener", ")", "{", "graphStructureListeners", ".", "remove", "(", "listener", ")", ";", "}", "public", "void", "removeLayoutListener", "(", "LayoutListener", "listener", ")", "{", "layoutListeners", ".", "remove", "(", "listener", ")", ";", "}", "public", "void", "removePruningListener", "(", "PruningListener", "listener", ")", "{", "pruningListeners", ".", "remove", "(", "listener", ")", ";", "}", "public", "void", "setMainLayoutAlgorithm", "(", "LayoutAlgorithm", "algorithm", ")", "{", "mainAlgorithm", "=", "algorithm", ";", "}", "public", "void", "setExpandCollapseManager", "(", "ExpandCollapseManager", "expandCollapseManager", ")", "{", "this", ".", "expandCollapseManager", "=", "expandCollapseManager", ";", "expandCollapseManager", ".", "initExpansion", "(", "this", ")", ";", "}", "public", "ConnectionLayout", "[", "]", "getConnections", "(", ")", "{", "List", "connections", "=", "container", ".", "getConnections", "(", ")", ";", "ConnectionLayout", "[", "]", "result", "=", "new", "ConnectionLayout", "[", "connections", ".", "size", "(", ")", "]", ";", "int", "i", "=", "0", ";", "for", "(", "Iterator", "iterator", "=", "connections", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "GraphConnection", "connection", "=", "(", "GraphConnection", ")", "iterator", ".", "next", "(", ")", ";", "if", "(", "!", "isLayoutItemFiltered", "(", "connection", ")", ")", "{", "result", "[", "i", "++", "]", "=", "connection", ".", "getLayout", "(", ")", ";", "}", "}", "if", "(", "i", "==", "result", ".", "length", ")", "{", "return", "result", ";", "}", "ConnectionLayout", "[", "]", "result2", "=", "new", "ConnectionLayout", "[", "i", "]", ";", "System", ".", "arraycopy", "(", "result", ",", "0", ",", "result2", ",", "0", ",", "i", ")", ";", "return", "result2", ";", "}", "public", "ConnectionLayout", "[", "]", "getConnections", "(", "EntityLayout", "source", ",", "EntityLayout", "target", ")", "{", "ArrayList", "result", "=", "new", "ArrayList", "(", ")", ";", "ArrayList", "sourcesList", "=", "new", "ArrayList", "(", ")", ";", "if", "(", "source", "instanceof", "NodeLayout", ")", "{", "sourcesList", ".", "add", "(", "source", ")", ";", "}", "if", "(", "source", "instanceof", "SubgraphLayout", ")", "{", "sourcesList", ".", "addAll", "(", "Arrays", ".", "asList", "(", "(", "(", "SubgraphLayout", ")", "source", ")", ".", "getNodes", "(", ")", ")", ")", ";", "}", "HashSet", "targets", "=", "new", "HashSet", "(", ")", ";", "if", "(", "target", "instanceof", "NodeLayout", ")", "{", "targets", ".", "add", "(", "target", ")", ";", "}", "if", "(", "target", "instanceof", "SubgraphLayout", ")", "{", "targets", ".", "addAll", "(", "Arrays", ".", "asList", "(", "(", "(", "SubgraphLayout", ")", "target", ")", ".", "getNodes", "(", ")", ")", ")", ";", "}", "for", "(", "Iterator", "iterator", "=", "sourcesList", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "NodeLayout", "source2", "=", "(", "NodeLayout", ")", "iterator", ".", "next", "(", ")", ";", "ConnectionLayout", "[", "]", "outgoingConnections", "=", "source2", ".", "getOutgoingConnections", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "outgoingConnections", ".", "length", ";", "i", "++", ")", "{", "ConnectionLayout", "connection", "=", "outgoingConnections", "[", "i", "]", ";", "if", "(", "(", "connection", ".", "getSource", "(", ")", "==", "source2", "&&", "targets", ".", "contains", "(", "connection", ".", "getTarget", "(", ")", ")", ")", "||", "(", "connection", ".", "getTarget", "(", ")", "==", "source2", "&&", "targets", ".", "contains", "(", "connection", ".", "getSource", "(", ")", ")", ")", ")", "{", "result", ".", "add", "(", "connection", ")", ";", "}", "}", "}", "return", "(", "ConnectionLayout", "[", "]", ")", "result", ".", "toArray", "(", "new", "ConnectionLayout", "[", "result", ".", "size", "(", ")", "]", ")", ";", "}", "void", "addFilter", "(", "LayoutFilter", "filter", ")", "{", "filters", ".", "add", "(", "filter", ")", ";", "}", "void", "removeFilter", "(", "LayoutFilter", "filter", ")", "{", "filters", ".", "remove", "(", "filter", ")", ";", "}", "boolean", "isLayoutItemFiltered", "(", "GraphItem", "item", ")", "{", "for", "(", "Iterator", "it", "=", "filters", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "LayoutFilter", "filter", "=", "(", "LayoutFilter", ")", "it", ".", "next", "(", ")", ";", "if", "(", "filter", ".", "isObjectFiltered", "(", "item", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}", "void", "setExpanded", "(", "NodeLayout", "node", ",", "boolean", "expanded", ")", "{", "externalLayoutInvocation", "=", "true", ";", "if", "(", "expandCollapseManager", "!=", "null", ")", "{", "expandCollapseManager", ".", "setExpanded", "(", "this", ",", "node", ",", "expanded", ")", ";", "}", "externalLayoutInvocation", "=", "false", ";", "}", "boolean", "canExpand", "(", "NodeLayout", "node", ")", "{", "return", "expandCollapseManager", "!=", "null", "&&", "expandCollapseManager", ".", "canExpand", "(", "this", ",", "node", ")", ";", "}", "boolean", "canCollapse", "(", "NodeLayout", "node", ")", "{", "return", "expandCollapseManager", "!=", "null", "&&", "expandCollapseManager", ".", "canCollapse", "(", "this", ",", "node", ")", ";", "}", "void", "setSubgraphFactory", "(", "SubgraphFactory", "factory", ")", "{", "subgraphFactory", "=", "factory", ";", "}", "SubgraphFactory", "getSubgraphFactory", "(", ")", "{", "return", "subgraphFactory", ";", "}", "void", "applyMainAlgorithm", "(", ")", "{", "if", "(", "backgorundLayoutEnabled", "&&", "mainAlgorithm", "!=", "null", ")", "{", "mainAlgorithm", ".", "applyLayout", "(", "true", ")", ";", "flushChanges", "(", "false", ")", ";", "}", "}", "void", "setLayoutAlgorithm", "(", "LayoutAlgorithm", "algorithm", ")", "{", "this", ".", "layoutAlgorithm", "=", "algorithm", ";", "this", ".", "layoutAlgorithm", ".", "setLayoutContext", "(", "this", ")", ";", "}", "LayoutAlgorithm", "getLayoutAlgorithm", "(", ")", "{", "return", "layoutAlgorithm", ";", "}", "void", "applyLayout", "(", "boolean", "clean", ")", "{", "if", "(", "layoutAlgorithm", "!=", "null", ")", "{", "externalLayoutInvocation", "=", "true", ";", "layoutAlgorithm", ".", "applyLayout", "(", "clean", ")", ";", "externalLayoutInvocation", "=", "false", ";", "}", "}", "void", "checkChangesAllowed", "(", ")", "{", "if", "(", "!", "backgorundLayoutEnabled", "&&", "!", "externalLayoutInvocation", ")", "{", "throw", "new", "RuntimeException", "(", "\"\"", ")", ";", "}", "}", "void", "fireNodeAddedEvent", "(", "NodeLayout", "node", ")", "{", "boolean", "intercepted", "=", "!", "eventsOn", ";", "GraphStructureListener", "[", "]", "listeners", "=", "(", "GraphStructureListener", "[", "]", ")", "graphStructureListeners", ".", "toArray", "(", "new", "GraphStructureListener", "[", "graphStructureListeners", ".", "size", "(", ")", "]", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "listeners", ".", "length", "&&", "!", "intercepted", ";", "i", "++", ")", "{", "intercepted", "=", "listeners", "[", "i", "]", ".", "nodeAdded", "(", "this", ",", "node", ")", ";", "}", "if", "(", "!", "intercepted", ")", "{", "applyMainAlgorithm", "(", ")", ";", "}", "}", "void", "fireNodeRemovedEvent", "(", "NodeLayout", "node", ")", "{", "boolean", "intercepted", "=", "!", "eventsOn", ";", "GraphStructureListener", "[", "]", "listeners", "=", "(", "GraphStructureListener", "[", "]", ")", "graphStructureListeners", ".", "toArray", "(", "new", "GraphStructureListener", "[", "graphStructureListeners", ".", "size", "(", ")", "]", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "listeners", ".", "length", "&&", "!", "intercepted", ";", "i", "++", ")", "{", "intercepted", "=", "listeners", "[", "i", "]", ".", "nodeRemoved", "(", "this", ",", "node", ")", ";", "}", "if", "(", "!", "intercepted", ")", "{", "applyMainAlgorithm", "(", ")", ";", "}", "}", "void", "fireConnectionAddedEvent", "(", "ConnectionLayout", "connection", ")", "{", "InternalLayoutContext", "sourceContext", "=", "(", "(", "InternalNodeLayout", ")", "connection", ".", "getSource", "(", ")", ")", ".", "getOwnerLayoutContext", "(", ")", ";", "InternalLayoutContext", "targetContext", "=", "(", "(", "InternalNodeLayout", ")", "connection", ".", "getTarget", "(", ")", ")", ".", "getOwnerLayoutContext", "(", ")", ";", "if", "(", "sourceContext", "!=", "targetContext", ")", "{", "return", ";", "}", "if", "(", "sourceContext", "==", "this", ")", "{", "boolean", "intercepted", "=", "!", "eventsOn", ";", "GraphStructureListener", "[", "]", "listeners", "=", "(", "GraphStructureListener", "[", "]", ")", "graphStructureListeners", ".", "toArray", "(", "new", "GraphStructureListener", "[", "graphStructureListeners", ".", "size", "(", ")", "]", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "listeners", ".", "length", "&&", "!", "intercepted", ";", "i", "++", ")", "{", "intercepted", "=", "listeners", "[", "i", "]", ".", "connectionAdded", "(", "this", ",", "connection", ")", ";", "}", "if", "(", "!", "intercepted", ")", "{", "applyMainAlgorithm", "(", ")", ";", "}", "}", "else", "{", "sourceContext", ".", "fireConnectionAddedEvent", "(", "connection", ")", ";", "}", "}", "void", "fireConnectionRemovedEvent", "(", "ConnectionLayout", "connection", ")", "{", "InternalLayoutContext", "sourceContext", "=", "(", "(", "InternalNodeLayout", ")", "connection", ".", "getSource", "(", ")", ")", ".", "getOwnerLayoutContext", "(", ")", ";", "InternalLayoutContext", "targetContext", "=", "(", "(", "InternalNodeLayout", ")", "connection", ".", "getTarget", "(", ")", ")", ".", "getOwnerLayoutContext", "(", ")", ";", "if", "(", "sourceContext", "!=", "targetContext", ")", "{", "return", ";", "}", "if", "(", "sourceContext", "==", "this", ")", "{", "boolean", "intercepted", "=", "!", "eventsOn", ";", "GraphStructureListener", "[", "]", "listeners", "=", "(", "GraphStructureListener", "[", "]", ")", "graphStructureListeners", ".", "toArray", "(", "new", "GraphStructureListener", "[", "graphStructureListeners", ".", "size", "(", ")", "]", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "listeners", ".", "length", "&&", "!", "intercepted", ";", "i", "++", ")", "{", "intercepted", "=", "listeners", "[", "i", "]", ".", "connectionRemoved", "(", "this", ",", "connection", ")", ";", "}", "if", "(", "!", "intercepted", ")", "{", "applyMainAlgorithm", "(", ")", ";", "}", "}", "else", "{", "sourceContext", ".", "fireConnectionAddedEvent", "(", "connection", ")", ";", "}", "}", "void", "fireBoundsChangedEvent", "(", ")", "{", "boolean", "intercepted", "=", "!", "eventsOn", ";", "ContextListener", "[", "]", "listeners", "=", "(", "ContextListener", "[", "]", ")", "contextListeners", ".", "toArray", "(", "new", "ContextListener", "[", "contextListeners", ".", "size", "(", ")", "]", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "listeners", ".", "length", "&&", "!", "intercepted", ";", "i", "++", ")", "{", "intercepted", "=", "listeners", "[", "i", "]", ".", "boundsChanged", "(", "this", ")", ";", "}", "if", "(", "!", "intercepted", ")", "{", "applyMainAlgorithm", "(", ")", ";", "}", "}", "void", "fireBackgroundEnableChangedEvent", "(", ")", "{", "ContextListener", "[", "]", "listeners", "=", "(", "ContextListener", "[", "]", ")", "contextListeners", ".", "toArray", "(", "new", "ContextListener", "[", "contextListeners", ".", "size", "(", ")", "]", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "listeners", ".", "length", ";", "i", "++", ")", "{", "listeners", "[", "i", "]", ".", "backgroundEnableChanged", "(", "this", ")", ";", "}", "}", "void", "fireNodeMovedEvent", "(", "InternalNodeLayout", "node", ")", "{", "if", "(", "eventsOn", ")", "{", "node", ".", "refreshLocation", "(", ")", ";", "}", "boolean", "intercepted", "=", "!", "eventsOn", ";", "LayoutListener", "[", "]", "listeners", "=", "(", "LayoutListener", "[", "]", ")", "layoutListeners", ".", "toArray", "(", "new", "LayoutListener", "[", "layoutListeners", ".", "size", "(", ")", "]", ")", ";", "node", ".", "setLocation", "(", "node", ".", "getNode", "(", ")", ".", "getLocation", "(", ")", ".", "x", ",", "node", ".", "getNode", "(", ")", ".", "getLocation", "(", ")", ".", "y", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "listeners", ".", "length", "&&", "!", "intercepted", ";", "i", "++", ")", "{", "intercepted", "=", "listeners", "[", "i", "]", ".", "nodeMoved", "(", "this", ",", "node", ")", ";", "}", "if", "(", "!", "intercepted", ")", "{", "applyMainAlgorithm", "(", ")", ";", "}", "}", "void", "fireNodeResizedEvent", "(", "InternalNodeLayout", "node", ")", "{", "if", "(", "eventsOn", ")", "{", "node", ".", "refreshSize", "(", ")", ";", "node", ".", "refreshLocation", "(", ")", ";", "}", "boolean", "intercepted", "=", "!", "eventsOn", ";", "LayoutListener", "[", "]", "listeners", "=", "(", "LayoutListener", "[", "]", ")", "layoutListeners", ".", "toArray", "(", "new", "LayoutListener", "[", "layoutListeners", ".", "size", "(", ")", "]", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "listeners", ".", "length", "&&", "!", "intercepted", ";", "i", "++", ")", "{", "intercepted", "=", "listeners", "[", "i", "]", ".", "nodeResized", "(", "this", ",", "node", ")", ";", "}", "if", "(", "!", "intercepted", ")", "{", "applyMainAlgorithm", "(", ")", ";", "}", "}", "void", "fireSubgraphMovedEvent", "(", "DefaultSubgraph", "subgraph", ")", "{", "if", "(", "eventsOn", ")", "{", "subgraph", ".", "refreshLocation", "(", ")", ";", "}", "boolean", "intercepted", "=", "!", "eventsOn", ";", "LayoutListener", "[", "]", "listeners", "=", "(", "LayoutListener", "[", "]", ")", "layoutListeners", ".", "toArray", "(", "new", "LayoutListener", "[", "layoutListeners", ".", "size", "(", ")", "]", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "listeners", ".", "length", "&&", "!", "intercepted", ";", "i", "++", ")", "{", "intercepted", "=", "listeners", "[", "i", "]", ".", "subgraphMoved", "(", "this", ",", "subgraph", ")", ";", "}", "if", "(", "!", "intercepted", ")", "{", "applyMainAlgorithm", "(", ")", ";", "}", "}", "void", "fireSubgraphResizedEvent", "(", "DefaultSubgraph", "subgraph", ")", "{", "if", "(", "eventsOn", ")", "{", "subgraph", ".", "refreshSize", "(", ")", ";", "subgraph", ".", "refreshLocation", "(", ")", ";", "}", "boolean", "intercepted", "=", "!", "eventsOn", ";", "LayoutListener", "[", "]", "listeners", "=", "(", "LayoutListener", "[", "]", ")", "layoutListeners", ".", "toArray", "(", "new", "LayoutListener", "[", "layoutListeners", ".", "size", "(", ")", "]", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "listeners", ".", "length", "&&", "!", "intercepted", ";", "i", "++", ")", "{", "intercepted", "=", "listeners", "[", "i", "]", ".", "subgraphResized", "(", "this", ",", "subgraph", ")", ";", "}", "if", "(", "!", "intercepted", ")", "{", "applyMainAlgorithm", "(", ")", ";", "}", "}", "}", "</s>" ]
10,287
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "AncestorListener", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "ColorConstants", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "FigureListener", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "IFigure", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Dimension", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Point", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "geometry", ".", "Rectangle", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "Font", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "graphics", ".", "FontData", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Display", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "internal", ".", "GraphLabel", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ".", "internal", ".", "ZestRootLayer", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "LayoutContext", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "NodeLayout", ";", "class", "PrunedSuccessorsSubgraph", "extends", "DefaultSubgraph", "{", "private", "class", "LabelAncestorListener", "extends", "AncestorListener", ".", "Stub", "{", "private", "final", "IFigure", "originalFigure", ";", "private", "IFigure", "fisheyeFigure", ";", "public", "LabelAncestorListener", "(", "IFigure", "originalFigure", ",", "IFigure", "fisheyeFigure", ")", "{", "this", ".", "originalFigure", "=", "originalFigure", ";", "this", ".", "fisheyeFigure", "=", "fisheyeFigure", ";", "}", "public", "void", "ancestorRemoved", "(", "IFigure", "ancestor", ")", "{", "if", "(", "fisheyeFigure", "!=", "null", ")", "{", "final", "GraphLabel", "label", "=", "(", "GraphLabel", ")", "nodeFigureToLabel", ".", "get", "(", "fisheyeFigure", ")", ";", "if", "(", "label", "==", "null", ")", "{", "return", ";", "}", "nodeFigureToLabel", ".", "remove", "(", "fisheyeFigure", ")", ";", "Display", ".", "getDefault", "(", ")", ".", "asyncExec", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "label", ".", "removeAncestorListener", "(", "LabelAncestorListener", ".", "this", ")", ";", "}", "}", ")", ";", "fisheyeFigure", ".", "removeFigureListener", "(", "nodeFigureListener", ")", ";", "originalFigure", ".", "addFigureListener", "(", "nodeFigureListener", ")", ";", "labelToAncestorListener", ".", "remove", "(", "label", ")", ";", "fisheyeFigure", "=", "null", ";", "addLabelForFigure", "(", "originalFigure", ",", "label", ")", ";", "refreshLabelBounds", "(", "originalFigure", ",", "label", ")", ";", "}", "}", "}", "private", "final", "FigureListener", "nodeFigureListener", "=", "new", "FigureListener", "(", ")", "{", "public", "void", "figureMoved", "(", "IFigure", "source", ")", "{", "GraphLabel", "label", "=", "(", "GraphLabel", ")", "nodeFigureToLabel", ".", "get", "(", "source", ")", ";", "if", "(", "label", "!=", "null", ")", "{", "refreshLabelBounds", "(", "source", ",", "label", ")", ";", "}", "}", "}", ";", "private", "final", "FisheyeListener", "fisheyeListener", "=", "new", "FisheyeListener", "(", ")", "{", "public", "void", "fisheyeReplaced", "(", "Graph", "graph", ",", "IFigure", "oldFisheyeFigure", ",", "IFigure", "newFisheyeFigure", ")", "{", "oldFisheyeFigure", ".", "removeFigureListener", "(", "nodeFigureListener", ")", ";", "newFisheyeFigure", ".", "addFigureListener", "(", "nodeFigureListener", ")", ";", "GraphLabel", "label", "=", "(", "GraphLabel", ")", "nodeFigureToLabel", ".", "remove", "(", "oldFisheyeFigure", ")", ";", "nodeFigureToLabel", ".", "put", "(", "newFisheyeFigure", ",", "label", ")", ";", "LabelAncestorListener", "ancestorListener", "=", "(", "LabelAncestorListener", ")", "labelToAncestorListener", ".", "get", "(", "label", ")", ";", "ancestorListener", ".", "fisheyeFigure", "=", "null", ";", "addLabelForFigure", "(", "newFisheyeFigure", ",", "label", ")", ";", "ancestorListener", ".", "fisheyeFigure", "=", "newFisheyeFigure", ";", "refreshLabelBounds", "(", "newFisheyeFigure", ",", "label", ")", ";", "}", "public", "void", "fisheyeRemoved", "(", "Graph", "graph", ",", "IFigure", "originalFigure", ",", "IFigure", "fisheyeFigure", ")", "{", "}", "public", "void", "fisheyeAdded", "(", "Graph", "graph", ",", "IFigure", "originalFigure", ",", "IFigure", "fisheyeFigure", ")", "{", "originalFigure", ".", "removeFigureListener", "(", "nodeFigureListener", ")", ";", "fisheyeFigure", ".", "addFigureListener", "(", "nodeFigureListener", ")", ";", "GraphLabel", "label", "=", "(", "GraphLabel", ")", "nodeFigureToLabel", ".", "get", "(", "originalFigure", ")", ";", "if", "(", "label", "==", "null", ")", "{", "return", ";", "}", "nodeFigureToLabel", ".", "put", "(", "fisheyeFigure", ",", "label", ")", ";", "refreshLabelBounds", "(", "fisheyeFigure", ",", "label", ")", ";", "addLabelForFigure", "(", "fisheyeFigure", ",", "label", ")", ";", "LabelAncestorListener", "labelAncestorListener", "=", "new", "LabelAncestorListener", "(", "originalFigure", ",", "fisheyeFigure", ")", ";", "label", ".", "addAncestorListener", "(", "labelAncestorListener", ")", ";", "labelToAncestorListener", ".", "put", "(", "label", ",", "labelAncestorListener", ")", ";", "}", "}", ";", "private", "HashMap", "nodeFigureToLabel", "=", "new", "HashMap", "(", ")", ";", "private", "HashMap", "labelToAncestorListener", "=", "new", "HashMap", "(", ")", ";", "protected", "PrunedSuccessorsSubgraph", "(", "LayoutContext", "context2", ")", "{", "super", "(", "context2", ")", ";", "context", ".", "container", ".", "getGraph", "(", ")", ".", "addFisheyeListener", "(", "fisheyeListener", ")", ";", "}", "public", "void", "addNodes", "(", "NodeLayout", "[", "]", "nodes", ")", "{", "super", ".", "addNodes", "(", "nodes", ")", ";", "HashSet", "nodesToUpdate", "=", "new", "HashSet", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "nodes", ".", "length", ";", "i", "++", ")", "{", "nodesToUpdate", ".", "addAll", "(", "Arrays", ".", "asList", "(", "nodes", "[", "i", "]", ".", "getPredecessingNodes", "(", ")", ")", ")", ";", "}", "for", "(", "Iterator", "iterator", "=", "nodesToUpdate", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "InternalNodeLayout", "nodeToUpdate", "=", "(", "InternalNodeLayout", ")", "iterator", ".", "next", "(", ")", ";", "updateNodeLabel", "(", "nodeToUpdate", ")", ";", "}", "}", "public", "void", "removeNodes", "(", "NodeLayout", "[", "]", "nodes", ")", "{", "super", ".", "removeNodes", "(", "nodes", ")", ";", "HashSet", "nodesToUpdate", "=", "new", "HashSet", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "nodes", ".", "length", ";", "i", "++", ")", "{", "nodesToUpdate", ".", "addAll", "(", "Arrays", ".", "asList", "(", "nodes", "[", "i", "]", ".", "getPredecessingNodes", "(", ")", ")", ")", ";", "if", "(", "(", "(", "InternalNodeLayout", ")", "nodes", "[", "i", "]", ")", ".", "isDisposed", "(", ")", ")", "{", "removeFigureForNode", "(", "(", "InternalNodeLayout", ")", "nodes", "[", "i", "]", ")", ";", "}", "else", "{", "nodesToUpdate", ".", "add", "(", "nodes", "[", "i", "]", ")", ";", "}", "}", "for", "(", "Iterator", "iterator", "=", "nodesToUpdate", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "InternalNodeLayout", "predecessor", "=", "(", "InternalNodeLayout", ")", "iterator", ".", "next", "(", ")", ";", "updateNodeLabel", "(", "predecessor", ")", ";", "}", "}", "private", "void", "addLabelForFigure", "(", "IFigure", "figure", ",", "GraphLabel", "label", ")", "{", "IFigure", "parent", "=", "figure", ".", "getParent", "(", ")", ";", "if", "(", "parent", "instanceof", "ZestRootLayer", ")", "{", "(", "(", "ZestRootLayer", ")", "parent", ")", ".", "addDecoration", "(", "figure", ",", "label", ")", ";", "}", "else", "{", "if", "(", "parent", ".", "getChildren", "(", ")", ".", "contains", "(", "label", ")", ")", "{", "parent", ".", "remove", "(", "label", ")", ";", "}", "int", "index", "=", "parent", ".", "getChildren", "(", ")", ".", "indexOf", "(", "figure", ")", ";", "parent", ".", "add", "(", "label", ",", "index", "+", "1", ")", ";", "}", "}", "private", "void", "refreshLabelBounds", "(", "IFigure", "figure", ",", "GraphLabel", "label", ")", "{", "Rectangle", "figureBounds", "=", "figure", ".", "getBounds", "(", ")", ";", "if", "(", "figureBounds", ".", "width", "*", "figureBounds", ".", "height", ">", "0", ")", "{", "label", ".", "setText", "(", "label", ".", "getText", "(", ")", ")", ";", "Dimension", "labelSize", "=", "label", ".", "getSize", "(", ")", ";", "labelSize", ".", "expand", "(", "-", "6", ",", "-", "4", ")", ";", "Point", "anchorPoint", "=", "figure", ".", "getBounds", "(", ")", ".", "getBottomRight", "(", ")", ";", "anchorPoint", ".", "x", "-=", "labelSize", ".", "width", "/", "2", ";", "anchorPoint", ".", "y", "-=", "labelSize", ".", "height", "/", "2", ";", "Rectangle", "bounds", "=", "new", "Rectangle", "(", "anchorPoint", ",", "labelSize", ")", ";", "label", ".", "setBounds", "(", "bounds", ")", ";", "label", ".", "getParent", "(", ")", ".", "setConstraint", "(", "label", ",", "bounds", ")", ";", "}", "else", "{", "label", ".", "getParent", "(", ")", ".", "setConstraint", "(", "label", ",", "new", "Rectangle", "(", "figureBounds", ".", "x", ",", "figureBounds", ".", "y", ",", "0", ",", "0", ")", ")", ";", "label", ".", "setBounds", "(", "new", "Rectangle", "(", "figureBounds", ".", "x", ",", "figureBounds", ".", "y", ",", "0", ",", "0", ")", ")", ";", "}", "}", "void", "updateNodeLabel", "(", "InternalNodeLayout", "internalNode", ")", "{", "if", "(", "internalNode", ".", "isDisposed", "(", ")", ")", "{", "return", ";", "}", "IFigure", "figure", "=", "internalNode", ".", "getNode", "(", ")", ".", "getFigure", "(", ")", ";", "GraphLabel", "label", "=", "(", "GraphLabel", ")", "nodeFigureToLabel", ".", "get", "(", "figure", ")", ";", "IFigure", "fisheye", "=", "getFisheyeFigure", "(", "figure", ")", ";", "if", "(", "fisheye", "!=", "null", ")", "{", "figure", "=", "fisheye", ";", "}", "if", "(", "label", "==", "null", ")", "{", "label", "=", "new", "GraphLabel", "(", "false", ")", ";", "label", ".", "setForegroundColor", "(", "ColorConstants", ".", "white", ")", ";", "label", ".", "setBackgroundColor", "(", "ColorConstants", ".", "red", ")", ";", "FontData", "fontData", "=", "Display", ".", "getDefault", "(", ")", ".", "getSystemFont", "(", ")", ".", "getFontData", "(", ")", "[", "0", "]", ";", "fontData", ".", "setHeight", "(", "6", ")", ";", "label", ".", "setFont", "(", "new", "Font", "(", "Display", ".", "getCurrent", "(", ")", ",", "fontData", ")", ")", ";", "figure", ".", "addFigureListener", "(", "nodeFigureListener", ")", ";", "addLabelForFigure", "(", "figure", ",", "label", ")", ";", "nodeFigureToLabel", ".", "put", "(", "figure", ",", "label", ")", ";", "}", "GraphNode", "graphNode", "=", "internalNode", ".", "getNode", "(", ")", ";", "if", "(", "!", "graphNode", ".", "getGraphModel", "(", ")", ".", "canExpand", "(", "graphNode", ")", "||", "graphNode", ".", "getGraphModel", "(", ")", ".", "canCollapse", "(", "graphNode", ")", "||", "internalNode", ".", "isPruned", "(", ")", ")", "{", "label", ".", "setVisible", "(", "false", ")", ";", "}", "else", "{", "NodeLayout", "[", "]", "successors", "=", "internalNode", ".", "getSuccessingNodes", "(", ")", ";", "int", "numberOfHiddenSuccessors", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "successors", ".", "length", ";", "i", "++", ")", "{", "if", "(", "successors", "[", "i", "]", ".", "isPruned", "(", ")", ")", "{", "numberOfHiddenSuccessors", "++", ";", "}", "}", "String", "labelText", "=", "numberOfHiddenSuccessors", ">", "0", "?", "\"\"", "+", "numberOfHiddenSuccessors", ":", "\"\"", ";", "if", "(", "!", "labelText", ".", "equals", "(", "label", ".", "getText", "(", ")", ")", ")", "{", "label", ".", "setText", "(", "labelText", ")", ";", "}", "label", ".", "setVisible", "(", "true", ")", ";", "}", "refreshLabelBounds", "(", "figure", ",", "label", ")", ";", "}", "private", "IFigure", "getFisheyeFigure", "(", "IFigure", "originalFigure", ")", "{", "GraphLabel", "label", "=", "(", "GraphLabel", ")", "nodeFigureToLabel", ".", "get", "(", "originalFigure", ")", ";", "LabelAncestorListener", "ancestorListener", "=", "(", "LabelAncestorListener", ")", "labelToAncestorListener", ".", "get", "(", "label", ")", ";", "if", "(", "ancestorListener", "!=", "null", ")", "{", "return", "ancestorListener", ".", "fisheyeFigure", ";", "}", "return", "null", ";", "}", "private", "void", "removeFigureForNode", "(", "InternalNodeLayout", "internalNode", ")", "{", "IFigure", "figure", "=", "internalNode", ".", "getNode", "(", ")", ".", "getFigure", "(", ")", ";", "GraphLabel", "label", "=", "(", "GraphLabel", ")", "nodeFigureToLabel", ".", "get", "(", "figure", ")", ";", "if", "(", "label", "!=", "null", "&&", "label", ".", "getParent", "(", ")", "!=", "null", ")", "{", "label", ".", "getParent", "(", ")", ".", "remove", "(", "label", ")", ";", "}", "nodeFigureToLabel", ".", "remove", "(", "figure", ")", ";", "}", "}", "</s>" ]
10,288
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "ConnectionLayout", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "ContextListener", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "ExpandCollapseManager", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "GraphStructureListener", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "LayoutContext", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ".", "NodeLayout", ";", "public", "class", "DAGExpandCollapseManager", "implements", "ExpandCollapseManager", "{", "private", "InternalLayoutContext", "context", ";", "private", "HashSet", "expandedNodes", "=", "new", "HashSet", "(", ")", ";", "private", "HashSet", "nodesToPrune", "=", "new", "HashSet", "(", ")", ";", "private", "HashSet", "nodesToUnprune", "=", "new", "HashSet", "(", ")", ";", "private", "HashSet", "nodesToUpdate", "=", "new", "HashSet", "(", ")", ";", "private", "boolean", "cleanLayoutScheduled", "=", "false", ";", "public", "void", "initExpansion", "(", "final", "LayoutContext", "context2", ")", "{", "if", "(", "!", "(", "context2", "instanceof", "InternalLayoutContext", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"\"", ")", ";", "}", "context", "=", "(", "InternalLayoutContext", ")", "context2", ";", "context", ".", "addGraphStructureListener", "(", "new", "GraphStructureListener", "(", ")", "{", "public", "boolean", "nodeRemoved", "(", "LayoutContext", "context", ",", "NodeLayout", "node", ")", "{", "if", "(", "isExpanded", "(", "node", ")", ")", "{", "collapse", "(", "node", ")", ";", "}", "flushChanges", "(", "false", ",", "true", ")", ";", "return", "false", ";", "}", "public", "boolean", "nodeAdded", "(", "LayoutContext", "context", ",", "NodeLayout", "node", ")", "{", "resetState", "(", "node", ")", ";", "flushChanges", "(", "false", ",", "true", ")", ";", "return", "false", ";", "}", "public", "boolean", "connectionRemoved", "(", "LayoutContext", "context", ",", "ConnectionLayout", "connection", ")", "{", "NodeLayout", "target", "=", "connection", ".", "getTarget", "(", ")", ";", "if", "(", "!", "isExpanded", "(", "target", ")", "&&", "target", ".", "getIncomingConnections", "(", ")", ".", "length", "==", "0", ")", "{", "expand", "(", "target", ")", ";", "}", "flushChanges", "(", "false", ",", "true", ")", ";", "return", "false", ";", "}", "public", "boolean", "connectionAdded", "(", "LayoutContext", "context", ",", "ConnectionLayout", "connection", ")", "{", "resetState", "(", "connection", ".", "getTarget", "(", ")", ")", ";", "updateNodeLabel", "(", "connection", ".", "getSource", "(", ")", ")", ";", "flushChanges", "(", "false", ",", "true", ")", ";", "return", "false", ";", "}", "}", ")", ";", "context", ".", "addContextListener", "(", "new", "ContextListener", ".", "Stub", "(", ")", "{", "public", "void", "backgroundEnableChanged", "(", "LayoutContext", "context", ")", "{", "flushChanges", "(", "false", ",", "false", ")", ";", "}", "}", ")", ";", "}", "public", "boolean", "canCollapse", "(", "LayoutContext", "context", ",", "NodeLayout", "node", ")", "{", "return", "isExpanded", "(", "node", ")", "&&", "!", "node", ".", "isPruned", "(", ")", "&&", "node", ".", "getOutgoingConnections", "(", ")", ".", "length", ">", "0", ";", "}", "public", "boolean", "canExpand", "(", "LayoutContext", "context", ",", "NodeLayout", "node", ")", "{", "return", "!", "isExpanded", "(", "node", ")", "&&", "!", "node", ".", "isPruned", "(", ")", "&&", "node", ".", "getOutgoingConnections", "(", ")", ".", "length", ">", "0", ";", "}", "private", "void", "collapseAllConnections", "(", "NodeLayout", "node", ")", "{", "ConnectionLayout", "[", "]", "outgoingConnections", "=", "node", ".", "getOutgoingConnections", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "outgoingConnections", ".", "length", ";", "i", "++", ")", "{", "outgoingConnections", "[", "i", "]", ".", "setVisible", "(", "false", ")", ";", "}", "flushChanges", "(", "true", ",", "true", ")", ";", "}", "private", "void", "expandAllConnections", "(", "NodeLayout", "node", ")", "{", "ConnectionLayout", "[", "]", "outgoingConnections", "=", "node", ".", "getOutgoingConnections", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "outgoingConnections", ".", "length", ";", "i", "++", ")", "{", "outgoingConnections", "[", "i", "]", ".", "setVisible", "(", "true", ")", ";", "}", "flushChanges", "(", "true", ",", "true", ")", ";", "}", "public", "void", "setExpanded", "(", "LayoutContext", "context", ",", "NodeLayout", "node", ",", "boolean", "expanded", ")", "{", "if", "(", "expanded", ")", "{", "if", "(", "canExpand", "(", "context", ",", "node", ")", ")", "{", "expand", "(", "node", ")", ";", "}", "expandAllConnections", "(", "node", ")", ";", "}", "else", "{", "if", "(", "canCollapse", "(", "context", ",", "node", ")", ")", "{", "collapse", "(", "node", ")", ";", "}", "collapseAllConnections", "(", "node", ")", ";", "}", "flushChanges", "(", "true", ",", "true", ")", ";", "}", "private", "void", "expand", "(", "NodeLayout", "node", ")", "{", "setExpanded", "(", "node", ",", "true", ")", ";", "NodeLayout", "[", "]", "successingNodes", "=", "node", ".", "getSuccessingNodes", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "successingNodes", ".", "length", ";", "i", "++", ")", "{", "unpruneNode", "(", "successingNodes", "[", "i", "]", ")", ";", "}", "updateNodeLabel", "(", "node", ")", ";", "}", "private", "void", "collapse", "(", "NodeLayout", "node", ")", "{", "if", "(", "isExpanded", "(", "node", ")", ")", "{", "setExpanded", "(", "node", ",", "false", ")", ";", "}", "else", "{", "return", ";", "}", "NodeLayout", "[", "]", "successors", "=", "node", ".", "getSuccessingNodes", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "successors", ".", "length", ";", "i", "++", ")", "{", "checkPruning", "(", "successors", "[", "i", "]", ")", ";", "if", "(", "isPruned", "(", "successors", "[", "i", "]", ")", ")", "{", "collapse", "(", "successors", "[", "i", "]", ")", ";", "}", "}", "updateNodeLabel", "(", "node", ")", ";", "}", "private", "void", "checkPruning", "(", "NodeLayout", "node", ")", "{", "boolean", "prune", "=", "true", ";", "NodeLayout", "[", "]", "predecessors", "=", "node", ".", "getPredecessingNodes", "(", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "predecessors", ".", "length", ";", "j", "++", ")", "{", "if", "(", "isExpanded", "(", "predecessors", "[", "j", "]", ")", ")", "{", "prune", "=", "false", ";", "break", ";", "}", "}", "if", "(", "prune", ")", "{", "pruneNode", "(", "node", ")", ";", "}", "else", "{", "unpruneNode", "(", "node", ")", ";", "}", "}", "private", "void", "resetState", "(", "NodeLayout", "node", ")", "{", "NodeLayout", "[", "]", "predecessors", "=", "node", ".", "getPredecessingNodes", "(", ")", ";", "if", "(", "predecessors", ".", "length", "==", "0", ")", "{", "expand", "(", "node", ")", ";", "}", "else", "{", "collapse", "(", "node", ")", ";", "checkPruning", "(", "node", ")", ";", "}", "}", "private", "void", "updateNodeLabel", "(", "NodeLayout", "node", ")", "{", "nodesToUpdate", ".", "add", "(", "node", ")", ";", "}", "private", "void", "updateNodeLabel2", "(", "InternalNodeLayout", "node", ")", "{", "SubgraphFactory", "subgraphFactory", "=", "node", ".", "getOwnerLayoutContext", "(", ")", ".", "getSubgraphFactory", "(", ")", ";", "if", "(", "subgraphFactory", "instanceof", "DefaultSubgraph", ".", "PrunedSuccessorsSubgraphFactory", ")", "{", "(", "(", "DefaultSubgraph", ".", "PrunedSuccessorsSubgraphFactory", ")", "subgraphFactory", ")", ".", "updateLabelForNode", "(", "node", ")", ";", "}", "}", "private", "void", "pruneNode", "(", "NodeLayout", "node", ")", "{", "if", "(", "isPruned", "(", "node", ")", ")", "{", "return", ";", "}", "nodesToUnprune", ".", "remove", "(", "node", ")", ";", "nodesToPrune", ".", "add", "(", "node", ")", ";", "}", "private", "void", "unpruneNode", "(", "NodeLayout", "node", ")", "{", "if", "(", "!", "isPruned", "(", "node", ")", ")", "{", "return", ";", "}", "nodesToPrune", ".", "remove", "(", "node", ")", ";", "nodesToUnprune", ".", "add", "(", "node", ")", ";", "}", "private", "boolean", "isPruned", "(", "NodeLayout", "node", ")", "{", "if", "(", "nodesToUnprune", ".", "contains", "(", "node", ")", ")", "{", "return", "false", ";", "}", "if", "(", "nodesToPrune", ".", "contains", "(", "node", ")", ")", "{", "return", "true", ";", "}", "return", "node", ".", "isPruned", "(", ")", ";", "}", "private", "void", "flushChanges", "(", "boolean", "force", ",", "boolean", "clean", ")", "{", "cleanLayoutScheduled", "=", "cleanLayoutScheduled", "||", "clean", ";", "if", "(", "!", "force", "&&", "!", "context", ".", "isBackgroundLayoutEnabled", "(", ")", ")", "{", "return", ";", "}", "for", "(", "Iterator", "iterator", "=", "nodesToUnprune", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "NodeLayout", "node", "=", "(", "NodeLayout", ")", "iterator", ".", "next", "(", ")", ";", "node", ".", "prune", "(", "null", ")", ";", "}", "nodesToUnprune", ".", "clear", "(", ")", ";", "if", "(", "!", "nodesToPrune", ".", "isEmpty", "(", ")", ")", "{", "context", ".", "createSubgraph", "(", "(", "NodeLayout", "[", "]", ")", "nodesToPrune", ".", "toArray", "(", "new", "NodeLayout", "[", "nodesToPrune", ".", "size", "(", ")", "]", ")", ")", ";", "nodesToPrune", ".", "clear", "(", ")", ";", "}", "for", "(", "Iterator", "iterator", "=", "nodesToUpdate", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "InternalNodeLayout", "node", "=", "(", "InternalNodeLayout", ")", "iterator", ".", "next", "(", ")", ";", "updateNodeLabel2", "(", "node", ")", ";", "}", "nodesToUpdate", ".", "clear", "(", ")", ";", "(", "context", ")", ".", "applyLayout", "(", "cleanLayoutScheduled", ")", ";", "cleanLayoutScheduled", "=", "false", ";", "context", ".", "flushChanges", "(", "true", ")", ";", "}", "private", "boolean", "isExpanded", "(", "NodeLayout", "node", ")", "{", "return", "expandedNodes", ".", "contains", "(", "node", ")", ";", "}", "private", "void", "setExpanded", "(", "NodeLayout", "node", ",", "boolean", "expanded", ")", "{", "if", "(", "expanded", ")", "{", "expandedNodes", ".", "add", "(", "node", ")", ";", "}", "else", "{", "expandedNodes", ".", "remove", "(", "node", ")", ";", "}", "}", "}", "</s>" ]
10,289
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "core", ".", "widgets", ";", "import", "org", ".", "eclipse", ".", "draw2d", ".", "IFigure", ";", "public", "interface", "FisheyeListener", "{", "public", "void", "fisheyeAdded", "(", "Graph", "graph", ",", "IFigure", "originalFigure", ",", "IFigure", "fisheyeFigure", ")", ";", "public", "void", "fisheyeRemoved", "(", "Graph", "graph", ",", "IFigure", "originalFigure", ",", "IFigure", "fisheyeFigure", ")", ";", "public", "void", "fisheyeReplaced", "(", "Graph", "graph", ",", "IFigure", "oldFisheyeFigure", ",", "IFigure", "newFisheyeFigure", ")", ";", "}", "</s>" ]
10,290
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "layouts", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "algorithms", ".", "TreeLayoutAlgorithm", ";", "public", "interface", "LayoutStyles", "{", "public", "final", "static", "int", "NONE", "=", "0x00", ";", "public", "final", "static", "int", "NO_LAYOUT_NODE_RESIZING", "=", "0x01", ";", "public", "static", "final", "int", "ENFORCE_BOUNDS", "=", "0X02", ";", "}", "</s>" ]
10,291
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "LayoutAlgorithm", ";", "public", "interface", "PruningListener", "{", "public", "boolean", "nodesPruned", "(", "LayoutContext", "context", ",", "SubgraphLayout", "[", "]", "subgraph", ")", ";", "public", "boolean", "nodesUnpruned", "(", "LayoutContext", "context", ",", "NodeLayout", "[", "]", "nodes", ")", ";", "}", "</s>" ]
10,292
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "LayoutAlgorithm", ";", "public", "interface", "ContextListener", "{", "public", "class", "Stub", "implements", "ContextListener", "{", "public", "boolean", "boundsChanged", "(", "LayoutContext", "context", ")", "{", "return", "false", ";", "}", "public", "void", "backgroundEnableChanged", "(", "LayoutContext", "context", ")", "{", "}", "public", "boolean", "pruningEnablementChanged", "(", "LayoutContext", "context", ")", "{", "return", "false", ";", "}", "}", "public", "boolean", "boundsChanged", "(", "LayoutContext", "context", ")", ";", "public", "boolean", "pruningEnablementChanged", "(", "LayoutContext", "context", ")", ";", "public", "void", "backgroundEnableChanged", "(", "LayoutContext", "context", ")", ";", "}", "</s>" ]
10,293
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ";", "public", "interface", "ExpandCollapseManager", "{", "public", "void", "initExpansion", "(", "LayoutContext", "context", ")", ";", "public", "void", "setExpanded", "(", "LayoutContext", "context", ",", "NodeLayout", "node", ",", "boolean", "expanded", ")", ";", "public", "boolean", "canExpand", "(", "LayoutContext", "context", ",", "NodeLayout", "node", ")", ";", "public", "boolean", "canCollapse", "(", "LayoutContext", "context", ",", "NodeLayout", "node", ")", ";", "}", "</s>" ]
10,294
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "LayoutAlgorithm", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "dataStructures", ".", "DisplayIndependentRectangle", ";", "public", "interface", "LayoutContext", "{", "public", "NodeLayout", "[", "]", "getNodes", "(", ")", ";", "public", "ConnectionLayout", "[", "]", "getConnections", "(", ")", ";", "public", "EntityLayout", "[", "]", "getEntities", "(", ")", ";", "public", "ConnectionLayout", "[", "]", "getConnections", "(", "EntityLayout", "layoutEntity1", ",", "EntityLayout", "layoutEntity2", ")", ";", "public", "DisplayIndependentRectangle", "getBounds", "(", ")", ";", "public", "boolean", "isBoundsExpandable", "(", ")", ";", "public", "SubgraphLayout", "[", "]", "getSubgraphs", "(", ")", ";", "public", "SubgraphLayout", "createSubgraph", "(", "NodeLayout", "[", "]", "nodes", ")", ";", "public", "boolean", "isPruningEnabled", "(", ")", ";", "public", "boolean", "isBackgroundLayoutEnabled", "(", ")", ";", "public", "void", "setMainLayoutAlgorithm", "(", "LayoutAlgorithm", "algorithm", ")", ";", "public", "LayoutAlgorithm", "getMainLayoutAlgorithm", "(", ")", ";", "public", "void", "setExpandCollapseManager", "(", "ExpandCollapseManager", "expandCollapseManager", ")", ";", "public", "ExpandCollapseManager", "getExpandCollapseManager", "(", ")", ";", "public", "void", "addLayoutListener", "(", "LayoutListener", "listener", ")", ";", "public", "void", "removeLayoutListener", "(", "LayoutListener", "listener", ")", ";", "public", "void", "addGraphStructureListener", "(", "GraphStructureListener", "listener", ")", ";", "public", "void", "removeGraphStructureListener", "(", "GraphStructureListener", "listener", ")", ";", "public", "void", "addContextListener", "(", "ContextListener", "listener", ")", ";", "public", "void", "removeContextListener", "(", "ContextListener", "listener", ")", ";", "public", "void", "addPruningListener", "(", "PruningListener", "listener", ")", ";", "public", "void", "removePruningListener", "(", "PruningListener", "listener", ")", ";", "public", "void", "flushChanges", "(", "boolean", "animationHint", ")", ";", "}", "</s>" ]
10,295
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ";", "public", "interface", "SubgraphLayout", "extends", "EntityLayout", "{", "public", "final", "int", "TOP_DOWN", "=", "1", ";", "public", "final", "int", "BOTTOM_UP", "=", "2", ";", "public", "final", "int", "LEFT_RIGHT", "=", "3", ";", "public", "final", "int", "RIGHT_LEFT", "=", "4", ";", "public", "NodeLayout", "[", "]", "getNodes", "(", ")", ";", "public", "int", "countNodes", "(", ")", ";", "public", "void", "addNodes", "(", "NodeLayout", "[", "]", "nodes", ")", ";", "public", "void", "removeNodes", "(", "NodeLayout", "[", "]", "nodes", ")", ";", "public", "boolean", "isGraphEntity", "(", ")", ";", "public", "boolean", "isDirectionDependant", "(", ")", ";", "public", "void", "setDirection", "(", "int", "direction", ")", ";", "}", "</s>" ]
10,296
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ";", "import", "org", ".", "eclipse", ".", "swt", ".", "widgets", ".", "Item", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "dataStructures", ".", "DisplayIndependentDimension", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "dataStructures", ".", "DisplayIndependentPoint", ";", "public", "interface", "EntityLayout", "{", "public", "DisplayIndependentPoint", "getLocation", "(", ")", ";", "public", "void", "setLocation", "(", "double", "x", ",", "double", "y", ")", ";", "public", "DisplayIndependentDimension", "getSize", "(", ")", ";", "public", "void", "setSize", "(", "double", "width", ",", "double", "height", ")", ";", "public", "double", "getPreferredAspectRatio", "(", ")", ";", "public", "boolean", "isResizable", "(", ")", ";", "public", "boolean", "isMovable", "(", ")", ";", "public", "EntityLayout", "[", "]", "getSuccessingEntities", "(", ")", ";", "public", "EntityLayout", "[", "]", "getPredecessingEntities", "(", ")", ";", "public", "Item", "[", "]", "getItems", "(", ")", ";", "}", "</s>" ]
10,297
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ";", "import", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "LayoutAlgorithm", ";", "public", "interface", "LayoutListener", "{", "public", "boolean", "nodeMoved", "(", "LayoutContext", "context", ",", "NodeLayout", "node", ")", ";", "public", "boolean", "nodeResized", "(", "LayoutContext", "context", ",", "NodeLayout", "node", ")", ";", "public", "boolean", "subgraphMoved", "(", "LayoutContext", "context", ",", "SubgraphLayout", "subgraph", ")", ";", "public", "boolean", "subgraphResized", "(", "LayoutContext", "context", ",", "SubgraphLayout", "subgraph", ")", ";", "}", "</s>" ]
10,298
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ";", "public", "interface", "ConnectionLayout", "{", "public", "NodeLayout", "getSource", "(", ")", ";", "public", "NodeLayout", "getTarget", "(", ")", ";", "public", "double", "getWeight", "(", ")", ";", "public", "boolean", "isDirected", "(", ")", ";", "public", "void", "setVisible", "(", "boolean", "visible", ")", ";", "public", "boolean", "isVisible", "(", ")", ";", "}", "</s>" ]
10,299
[ "<s>", "package", "org", ".", "eclipse", ".", "zest", ".", "layouts", ".", "interfaces", ";", "public", "interface", "NodeLayout", "extends", "EntityLayout", "{", "public", "boolean", "isPrunable", "(", ")", ";", "public", "boolean", "isPruned", "(", ")", ";", "public", "SubgraphLayout", "getSubgraph", "(", ")", ";", "public", "void", "prune", "(", "SubgraphLayout", "subgraph", ")", ";", "public", "NodeLayout", "[", "]", "getSuccessingNodes", "(", ")", ";", "public", "NodeLayout", "[", "]", "getPredecessingNodes", "(", ")", ";", "public", "ConnectionLayout", "[", "]", "getIncomingConnections", "(", ")", ";", "public", "ConnectionLayout", "[", "]", "getOutgoingConnections", "(", ")", ";", "public", "void", "setMinimized", "(", "boolean", "minimized", ")", ";", "public", "boolean", "isMinimized", "(", ")", ";", "}", "</s>" ]