// Return a collection of common actions. // Each action in the collection is a compound // action. There is one compound action in the collection // for each action which is common to all viewlets in the selection. public Collection getCommonActions() { Collection commonActions = new LinkedList(); Collection firstViewletsActions; ViewletAction currentAction; Iterator viewletsIterator; Iterator firstViewletsActionsIterator; Viewlet firstViewlet, currentViewlet; List currentViewletActions; boolean allContainAction; if (isEmpty()) { return (Collections.EMPTY_SET); } firstViewlet = (Viewlet) (iterator().next()); firstViewletsActions = firstViewlet.getActions(); firstViewletsActionsIterator = firstViewletsActions.iterator(); // for each currentAction in the first viewlet's actions while (firstViewletsActionsIterator.hasNext()) { currentAction = (ViewletAction) firstViewletsActionsIterator.next(); viewletsIterator = iterator(); allContainAction = true; // test whether each viewlet has an action equals() to currentAction while (viewletsIterator.hasNext() && allContainAction) { currentViewlet = (Viewlet) viewletsIterator.next(); if (!currentViewlet.getActions().contains(currentAction)) { allContainAction = false; } } if (allContainAction) { commonActions.add(currentAction.createCompoundAction(this)); } } return (commonActions); }
public void startServer() throws Exception { while (true) { Socket s = server.accept(); cClient.add(new ClientConn(s)); ta.append("NEW-CLIENT " + s.getInetAddress() + ":" + s.getPort()); ta.append("\n" + "CLIENTS-COUNT: " + cClient.size() + "\n\n"); } }
// Works the exact same way as rangeSize(). Simply checks if sub-tree possibly contains points in // query private void rangeQuery(Point sw, Point ne, Collection<Point> result, TreeNode t) { if (t == null) return; if (subTreeInRange(sw, new Point(ne.x(), sw.y()), new Point(sw.x(), ne.y()), ne, t.minX.p) || subTreeInRange(sw, new Point(ne.x(), sw.y()), new Point(sw.x(), ne.y()), ne, t.maxX.p) || subTreeInRange(sw, new Point(ne.x(), sw.y()), new Point(sw.x(), ne.y()), ne, t.minY.p) || subTreeInRange(sw, new Point(ne.x(), sw.y()), new Point(sw.x(), ne.y()), ne, t.maxY.p)) { rangeQuery(sw, ne, result, t.left); rangeQuery(sw, ne, result, t.right); } else return; if (inRange(sw, ne, t.p)) result.add(t.p); }
private void captureUsagesExpandState(TreePath pathFrom, final Collection<UsageState> states) { if (!myTree.isExpanded(pathFrom)) { return; } final DefaultMutableTreeNode node = (DefaultMutableTreeNode) pathFrom.getLastPathComponent(); final int childCount = node.getChildCount(); for (int idx = 0; idx < childCount; idx++) { final TreeNode child = node.getChildAt(idx); if (child instanceof UsageNode) { final Usage usage = ((UsageNode) child).getUsage(); states.add( new UsageState( usage, myTree.getSelectionModel().isPathSelected(pathFrom.pathByAddingChild(child)))); } else { captureUsagesExpandState(pathFrom.pathByAddingChild(child), states); } } }
protected void loadAirspacesFromPath(String path, Collection<Airspace> airspaces) { File file = ExampleUtil.saveResourceToTempFile(path, ".zip"); if (file == null) return; try { ZipFile zipFile = new ZipFile(file); ZipEntry entry = null; for (Enumeration<? extends ZipEntry> e = zipFile.entries(); e.hasMoreElements(); entry = e.nextElement()) { if (entry == null) continue; String name = WWIO.getFilename(entry.getName()); if (!(name.startsWith("gov.nasa.worldwind.render.airspaces") && name.endsWith(".xml"))) continue; String[] tokens = name.split("-"); try { Class c = Class.forName(tokens[0]); Airspace airspace = (Airspace) c.newInstance(); BufferedReader input = new BufferedReader(new InputStreamReader(zipFile.getInputStream(entry))); String s = input.readLine(); airspace.restoreState(s); airspaces.add(airspace); if (tokens.length >= 2) { airspace.setValue(AVKey.DISPLAY_NAME, tokens[1]); } } catch (Exception ex) { ex.printStackTrace(); } } } catch (IOException e) { e.printStackTrace(); } }
/** * Adds the given <tt>TextFieldChangeListener</tt> to the list of listeners notified on changes of * the text contained in this field. * * @param l the <tt>TextFieldChangeListener</tt> to add */ public void addTextChangeListener(TextFieldChangeListener l) { synchronized (changeListeners) { changeListeners.add(l); } }