/** Listener to handle button actions */ public void actionPerformed(ActionEvent e) { // Check if the user changed the service filter option if (e.getSource() == service_box) { service_list.setEnabled(service_box.isSelected()); service_list.clearSelection(); remove_service_button.setEnabled(false); add_service_field.setEnabled(service_box.isSelected()); add_service_field.setText(""); add_service_button.setEnabled(false); } // Check if the user pressed the add service button if ((e.getSource() == add_service_button) || (e.getSource() == add_service_field)) { String text = add_service_field.getText(); if ((text != null) && (text.length() > 0)) { service_data.addElement(text); service_list.setListData(service_data); } add_service_field.setText(""); add_service_field.requestFocus(); } // Check if the user pressed the remove service button if (e.getSource() == remove_service_button) { Object[] sels = service_list.getSelectedValues(); for (int i = 0; i < sels.length; i++) { service_data.removeElement(sels[i]); } service_list.setListData(service_data); service_list.clearSelection(); } }
public void fireEvent(NCCPConnection.ConnectionEvent e) { ConnectionListener l; int max = listeners.size(); for (int i = 0; i < max; ++i) { ExpCoordinator.print( new String( "NCCPConnection.fireEvent (" + toString() + ") event: " + e.getType() + " max:" + max + " i:" + i), 2); l = (ConnectionListener) (listeners.elementAt(i)); switch (e.getType()) { case ConnectionEvent.CONNECTION_FAILED: l.connectionFailed(e); break; case ConnectionEvent.CONNECTION_CLOSED: l.connectionClosed(e); break; case ConnectionEvent.CONNECTION_OPENED: ExpCoordinator.printer.print( new String("Opened control connection (" + toString() + ")")); l.connectionOpened(e); } } }
@Override public void run() { // TODO Auto-generated method stub while (true) { try { Thread.sleep(100); } catch (Exception e) { // TODO: handle exception } // 判断每一粒子弹和每一辆敌人的坦克都是否有重合(击中) for (int i = 0; i < hero.bombs.size(); i++) { // 取出每个子弹 Bomb myBomb = hero.bombs.get(i); // 子弹必须得存活才有判断的意义 if (myBomb.isLive) { for (int j = 0; j < ets.size(); j++) { // 取出每辆坦克 EnemyTank et = ets.get(j); if (et.isLive) { this.isHit(myBomb, et); } } } } this.repaint(); } }
/** * Compute a logical, reasonably efficient join on the specified tables. See project description * for hints on how this should be implemented. * * @param stats Statistics for each table involved in the join, referenced by base table names, * not alias * @param filterSelectivities Selectivities of the filter predicates on each table in the join, * referenced by table alias (if no alias, the base table name) * @param explain Indicates whether your code should explain its query plan or simply execute it * @return A Vector<LogicalJoinNode> that stores joins in the left-deep order in which they should * be executed. * @throws ParsingException when stats or filter selectivities is missing a table in the join, or * or when another internal error occurs */ public Vector<LogicalJoinNode> orderJoins( HashMap<String, TableStats> stats, HashMap<String, Double> filterSelectivities, boolean explain) throws ParsingException { // See the project writeup for some hints as to how this function // should work. // some code goes here PlanCache pc = new PlanCache(); for (int i = 1; i <= joins.size(); i++) { Set<Set<LogicalJoinNode>> subsets = enumerateSubsets(joins, i); for (Set<LogicalJoinNode> subset : subsets) { CostCard best = new CostCard(); best.cost = Double.MAX_VALUE; for (LogicalJoinNode node : subset) { CostCard subCard = computeCostAndCardOfSubplan(stats, filterSelectivities, node, subset, best.cost, pc); if (subCard != null) { if (subCard.cost < best.cost) best = subCard; pc.addPlan(subset, best.cost, best.card, best.plan); } } } } if (explain) printJoins(joins, pc, stats, filterSelectivities); HashSet<LogicalJoinNode> joinSet = new HashSet<LogicalJoinNode>(); for (int i = 0; i < joins.size(); i++) { joinSet.add(joins.get(i)); } Vector<LogicalJoinNode> order = pc.getOrder(joinSet); if (order != null) return order; return joins; }
public void viewChange(View new_view) { Vector mbrship; if (new_view != null && (mbrship = new_view.getMembers()) != null) { tree._put(SEP, "members", mbrship); tree._put(SEP, "coordinator", mbrship.firstElement()); } }
public void redrawTree(boolean doRepaint) { displayText = false; if (argument == null) return; if (argument.isMultiRoots()) { argument.deleteDummyRoot(); argument.setMultiRoots(false); } TreeVertex root = null; Vector roots = argument.getTree().getRoots(); if (roots.size() > 1) { if (argument.getDummyRoot() == null) { argument.addDummyRoot(roots); } root = argument.getDummyRoot(); } else if (roots.size() == 1) { root = (TreeVertex) roots.firstElement(); } // if root == null, the entire tree has been erased, // so call emptyTree() to clean things up and // clear the display if (root == null) { argument.emptyTree(false); } else { calcTreeShape(root); } if (doRepaint) { repaint(); } /* if (displayFrame.getMainDiagramPanel() == this) { searchFrame.updateDisplays(false); } */ }
public void addConnectionListener(NCCPConnection.ConnectionListener l) { if (!listeners.contains(l)) { ExpCoordinator.printer.print( new String("NCCPConnection.addConnectionListener to " + toString()), 6); listeners.add(l); } }
public void actionPerformed(java.awt.event.ActionEvent arg0) { if (JTable1.getSelectedRowCount() != 1) { Utilities.errorMessage(resourceBundle.getString("Please select a view to delete")); return; } if (JOptionPane.showConfirmDialog( null, resourceBundle.getString("Are you sure you want to delete the selected view "), resourceBundle.getString("Warning!"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null) == JOptionPane.NO_OPTION) return; Vector viewvec = model.getAllViews(); for (int i = 0; i < viewvec.size(); i++) { String viewname = ((AuthViewWithOperations) viewvec.elementAt(i)).getAuthorizedViewName(); if (JTable1.getValueAt(JTable1.getSelectedRow(), 0).toString().equals(viewname)) { AuthViewWithOperations avop = (AuthViewWithOperations) viewvec.elementAt(i); model.delViewOp( avop.getAuthorizedViewName(), avop.getViewProperties(), avop.getOperations()); } } disableButtons(); }
protected void addPage(String _typeOfPage, String _name, String _code, boolean _enabled) { cardLayout.show(finalPanel, "TabbedPanel"); _name = getUniqueName(_name); Editor page = createPage(_typeOfPage, _name, _code); page.setFont(myFont); page.setColor(myColor); int index = tabbedPanel.getSelectedIndex(); if (index == -1) { pageList.addElement(page); if (tabbedPanel.getTabCount() == 0) { tabbedPanel.addTab( page.getName(), null, page.getComponent(), tooltip); // This causes an exception sometimes } else { tabbedPanel.insertTab( page.getName(), null, page.getComponent(), tooltip, tabbedPanel.getTabCount()); } index = 0; } else { index++; pageList.insertElementAt(page, index); tabbedPanel.insertTab(page.getName(), null, page.getComponent(), tooltip, index); } tabbedPanel.setSelectedComponent(page.getComponent()); page.setActive(_enabled); if (!_enabled) tabbedPanel.setTitleAt(index, page.getName() + " (D)"); updatePageCounterField(pageList.size()); // tabbedPanel.validate(); This hangs the computer when reading a file at start-up !!!??? tabbedPanel.repaint(); changed = true; }
/** * Method that surrounds whole Arena with 4 rectangles, one for each side of Arena, that blocks * objects in Arena from falling out of it. The walls are placed outside the Arena so that they * won't reduce the space in Arena with their bodies. * * @param thickness Width of the walls. */ private void encloseWithWalls(int thickness) { Fixed northWall = (Fixed) ArenaPartsGenerator.createPart( new Rectangle(0, -thickness, screenWidth, thickness), "FixedObstacle", 1, this); Fixed southWall = (Fixed) ArenaPartsGenerator.createPart( new Rectangle(0, screenHeight, screenWidth, thickness), "FixedObstacle", 1, this); Fixed eastWall = (Fixed) ArenaPartsGenerator.createPart( new Rectangle(screenWidth, 0, thickness, screenHeight), "FixedObstacle", 1, this); Fixed westWall = (Fixed) ArenaPartsGenerator.createPart( new Rectangle(-thickness, 0, thickness, screenHeight), "FixedObstacle", 1, this); walls.add(northWall); walls.add(southWall); walls.add(eastWall); walls.add(westWall); world.add(northWall.getBody()); world.add(southWall.getBody()); world.add(eastWall.getBody()); world.add(westWall.getBody()); isEnclosedWithWalls = true; }
public Vector getAssociatedLevelLists() { Vector levelLists = new Vector(); Vector endPts = CollectionHelper.makeVector("Keyword"); Hashtable keywordParents = oncotcap.Oncotcap.getDataSource() .getParentTree( "Keyword", endPts, CollectionHelper.makeVector(this), TreeDisplayModePanel.ROOT); // Take each of the parents and get the associated level lists if (keywordParents.size() <= 0) return levelLists; Hashtable levelListsHashtable = oncotcap.Oncotcap.getDataSource() .getInstanceTree( "EnumLevelList", new Vector(), makeLevelListFilter(keywordParents), TreeDisplayModePanel.ROOT); for (Enumeration e = keywordParents.keys(); e.hasMoreElements(); ) { System.out.println("Keyword.getAssociatedLevelLists: " + e.nextElement()); } // Collect all the level lists from the hashtable Vector selectedItems = CollectionHelper.makeVector(keyword); for (Enumeration e = levelListsHashtable.keys(); e.hasMoreElements(); ) { Object obj = e.nextElement(); if (obj instanceof EnumLevelList) { levelLists.addElement(obj); } } return levelLists; }
/** * Return the graph items for this graph. * * @return the graph items for this graph. */ public GraphItem[] getGraphItems() { GraphItem gia[] = new GraphItem[graphItems.size()]; for (int i = 0; i < graphItems.size(); i++) { gia[i] = (GraphItem) graphItems.elementAt(i); } return gia; }
public void setValueAt(Object value, int row, int col) { if (rowData.size() > row && row >= 0) { Object[] data = (Object[]) rowData.get(row); data[col] = value; } fireTableCellUpdated(row, col); }
/** Get row count (part of table model interface) */ public int getRowCount() { int count = data.size(); if (filter_data != null) { count = filter_data.size(); } return count; }
/** Constructor */ public SOAPMonitorFilter() { // By default, exclude NotificationService and // EventViewerService messages filter_exclude_list = new Vector(); filter_exclude_list.addElement("NotificationService"); filter_exclude_list.addElement("EventViewerService"); }
public String toString() { StringBuffer st = new StringBuffer(); st.append(" Cut Panels: "); for (int i = 0; i < visibleViewIds.size(); i++) { st.append(" " + Constants.cpNames[((Integer) visibleViewIds.elementAt(i)).intValue()]); } st.append(" \nCutPanelSize: "); st.append(cutPanelSize); st.append(" \nlonReference: "); st.append(lonReference); st.append(" \ngeoDisplayFormat: "); st.append(geoDisplayFormat); st.append(" \nuseCenterWidthOrMinMax: "); st.append(useCenterWidthOrMinMax); st.append(" \ntimeDisplayFormat: "); st.append(timeDisplayFormat); st.append(" \ntimeAxisMode: "); st.append(timeAxisMode); st.append(" \ntimeAxisReference: "); st.append(timeAxisReference); st.append(" \ntimeSinceUnits: "); st.append(timeSinceUnits); st.append(" \ndisplayPanelAxes: "); st.append(displayPanelAxes); st.append(" \nindependentHandles: "); st.append(independentHandles); return st.toString(); }
private GroovyTreeNode(GroovyTreeNode parent, GroovyNode node) { this.parent = parent; this.node = node; for (Map.Entry<String, String> entry : node.attributes().entrySet()) { children.add(new GroovyTreeNode(this, entry.getKey(), entry.getValue())); } if (node.getNodeValue() instanceof List) { string = node.getNodeName(); toolTip = String.format("Size: %d", ((List) node.getNodeValue()).size()); } else { String truncated = node.text(); if (truncated.contains("\n") || truncated.length() >= MAX_LENGTH) { int index = truncated.indexOf('\n'); if (index > 0) truncated = truncated.substring(0, index); if (truncated.length() >= MAX_LENGTH) truncated = truncated.substring(0, MAX_LENGTH); string = String.format("<html><b>%s</b> = %s ...</html>", node.getNodeName(), truncated); toolTip = tameTooltipText(node.text()); } else { string = String.format("<html><b>%s</b> = %s</html>", node.getNodeName(), truncated); toolTip = truncated; } } if (this.node.getNodeValue() instanceof List) { for (Object sub : ((List) this.node.getNodeValue())) { GroovyNode subnode = (GroovyNode) sub; children.add(new GroovyTreeNode(this, subnode)); } Collections.sort(children); } }
public void actionPerformed(ActionEvent evt) { // 删除原来的JTable(JTable使用scrollPane来包装) if (scrollPane != null) { jf.remove(scrollPane); } try ( // 根据用户输入的SQL执行查询 ResultSet rs = stmt.executeQuery(sqlField.getText())) { // 取出ResultSet的MetaData ResultSetMetaData rsmd = rs.getMetaData(); Vector<String> columnNames = new Vector<>(); Vector<Vector<String>> data = new Vector<>(); // 把ResultSet的所有列名添加到Vector里 for (int i = 0; i < rsmd.getColumnCount(); i++) { columnNames.add(rsmd.getColumnName(i + 1)); } // 把ResultSet的所有记录添加到Vector里 while (rs.next()) { Vector<String> v = new Vector<>(); for (int i = 0; i < rsmd.getColumnCount(); i++) { v.add(rs.getString(i + 1)); } data.add(v); } // 创建新的JTable JTable table = new JTable(data, columnNames); scrollPane = new JScrollPane(table); // 添加新的Table jf.add(scrollPane); // 更新主窗口 jf.validate(); } catch (Exception e) { e.printStackTrace(); } }
public void actionPerformed(java.awt.event.ActionEvent arg0) { if (JTable1.getSelectedRowCount() != 1) { Utilities.errorMessage(resourceBundle.getString("Please select a view to edit")); return; } views = new ViewsWizard(ViewConfig.this, applet); views.setSecurityModel(model); Point p = JLabel1.getLocationOnScreen(); views.setLocation(p); views.init(); views.setState(false); Vector viewvec = model.getAllViews(); for (int i = 0; i < viewvec.size(); i++) { String viewname = ((AuthViewWithOperations) viewvec.elementAt(i)).getAuthorizedViewName(); if (JTable1.getValueAt(JTable1.getSelectedRow(), 0).toString().equals(viewname)) { views.setValues((AuthViewWithOperations) viewvec.elementAt(i)); } } disableButtons(); views.setVisible(true); }
public int submit() { String newName = produktgruppeFormular.nameField.getText(); if (isProdGrAlreadyKnown(newName)) { // not allowed: changing name to one that is already registered in DB JOptionPane.showMessageDialog( this, "Fehler: Produktgruppe '" + newName + "' bereits vorhanden!", "Info", JOptionPane.INFORMATION_MESSAGE); produktgruppeFormular.nameField.setText(""); return 0; } Integer parentProdGrID = produktgruppeFormular.parentProdGrIDs.get( produktgruppeFormular.parentProdGrBox.getSelectedIndex()); Vector<Integer> idsNew = produktgruppeFormular.idsOfNewProdGr(parentProdGrID); Integer topID = idsNew.get(0); Integer subID = idsNew.get(1); Integer subsubID = idsNew.get(2); Integer mwstID = produktgruppeFormular.mwstIDs.get(produktgruppeFormular.mwstBox.getSelectedIndex()); Integer pfandID = produktgruppeFormular.pfandIDs.get(produktgruppeFormular.pfandBox.getSelectedIndex()); return insertNewProdGr(topID, subID, subsubID, newName, mwstID, pfandID); }
public Object clone() { FigForkState figClone = (FigForkState) super.clone(); Vector v = figClone.getFigs(); figClone._bigPort = (FigRect) v.elementAt(0); figClone._head = (FigRect) v.elementAt(1); return figClone; }
public void removeUser(String strChannel) { Vector vtData = tblUser.getFilteredData(); for (int iIndex = 0; iIndex < vtData.size(); iIndex++) { Vector vtRow = (Vector) vtData.elementAt(iIndex); if (vtRow.elementAt(0).equals(strChannel)) tblUser.deleteRow(iIndex); } }
public void setConnected(boolean b, boolean process_pending) { if (b && state != ConnectionEvent.CONNECTION_OPENED) { if (host.length() > 0) ExpCoordinator.print( "NCCPConnection open connection to ipaddress " + host + " port " + port); state = ConnectionEvent.CONNECTION_OPENED; // connected = true; fireEvent(new ConnectionEvent(this, state)); ExpCoordinator.printer.print("NCCPConnection.setConnected " + b + " event fired", 8); if (process_pending) { int max = pendingMessages.size(); ExpCoordinator.printer.print(new String(" pendingMessages " + max + " elements"), 8); for (int i = 0; i < max; ++i) { sendMessage((NCCP.Message) pendingMessages.elementAt(i)); } pendingMessages.removeAllElements(); } } else { if (!b && (state != ConnectionEvent.CONNECTION_CLOSED || state != ConnectionEvent.CONNECTION_FAILED)) { if (host.length() > 0) ExpCoordinator.print( new String( "NCCPConnection.setConnected -- Closed control socket for " + host + "." + port)); state = ConnectionEvent.CONNECTION_CLOSED; fireEvent(new ConnectionEvent(this, state)); } } }
public void changeDictionary(String strLanguage) { // Change dictionary MonitorDictionary.setCurrentLanguage(strLanguage); DefaultDictionary.setCurrentLanguage(strLanguage); ErrorDictionary.setCurrentLanguage(strLanguage); // Update UI updateLanguage(); WindowManager.updateLanguage(); int iIndex = mvtLanguage.indexOf(strLanguage); if (iIndex >= 0) { JRadioButtonMenuItem mnu = (JRadioButtonMenuItem) mvtLanguageItem.elementAt(iIndex); mnu.setSelected(true); } // Store config Hashtable prt = null; try { prt = Global.loadHashtable(Global.FILE_CONFIG); } catch (Exception e) { prt = new Hashtable(); } prt.put("Language", strLanguage); try { Global.storeHashtable(prt, Global.FILE_CONFIG); } catch (Exception e) { } }
public void removeConnectionListener(NCCPConnection.ConnectionListener l) { if (listeners.contains(l)) { // ExpCoordinator.printer.print(new String("NCCPConnection.removeConnectionListener to " + // toString()), 2); listeners.remove(l); } }
public void paintComponent(Graphics g) { g.setColor(new Color(96, 96, 96)); image.paintIcon(this, g, 1, 1); FontMetrics fm = g.getFontMetrics(); String[] args = {jEdit.getVersion()}; String version = jEdit.getProperty("about.version", args); g.drawString(version, (getWidth() - fm.stringWidth(version)) / 2, getHeight() - 5); g = g.create((getWidth() - maxWidth) / 2, TOP, maxWidth, getHeight() - TOP - BOTTOM); int height = fm.getHeight(); int firstLine = scrollPosition / height; int firstLineOffset = height - scrollPosition % height; int lines = (getHeight() - TOP - BOTTOM) / height; int y = firstLineOffset; for (int i = 0; i <= lines; i++) { if (i + firstLine >= 0 && i + firstLine < text.size()) { String line = (String) text.get(i + firstLine); g.drawString(line, (maxWidth - fm.stringWidth(line)) / 2, y); } y += fm.getHeight(); } }
// 判断坦克是否被击中 public void isHit(Bomb bomb, EnemyTank et) { // 敌人的坦克有四个方向,每个方向的坐标不同 switch (et.getDirection()) { // 朝上和朝下效果一样 case 0: case 2: // 子弹的坐标和坦克的坐标重合即为击中 if (bomb.x > et.getX() && bomb.x < et.getX() + 25 && bomb.y < et.getY() + 30 && bomb.y > et.getY()) { // 子弹死亡,敌人坦克死亡 bomb.isLive = false; et.isLive = false; BaoZha bz = new BaoZha(et.getX(), et.getY()); baozhas.add(bz); } // 敌人坦克朝左右两边 case 1: case 3: if (bomb.x > et.getX() && bomb.x < et.getX() + 30 && bomb.y > et.getY() && bomb.y < et.getY() + 25) { // 子弹死亡,敌人坦克死亡 bomb.isLive = false; et.isLive = false; BaoZha bz = new BaoZha(et.getX(), et.getY()); baozhas.add(bz); } } }
public Properties internalToProperties() { Properties props = new Properties(); StringBuffer st = new StringBuffer(); st.append(" "); for (int i = 0; i < visibleViewIds.size(); i++) { st.append(" " + Constants.cpNames[((Integer) visibleViewIds.elementAt(i)).intValue()]); } // System.out.println(" visibleViewIds: " + st.toString()); props.setProperty("ndedit.visibleViewIds", st.toString()); props.setProperty("ndedit.cutPanelSizeW", (new Integer(cutPanelSize.width).toString())); props.setProperty("ndedit.cutPanelSizeH", (new Integer(cutPanelSize.height).toString())); props.setProperty("ndedit.cutPanelWMin", (new Integer(cutPanelMinSize.width).toString())); props.setProperty("ndedit.cutPanelHMin", (new Integer(cutPanelMinSize.height).toString())); props.setProperty("ndedit.cutPanelWMax", (new Integer(cutPanelMaxSize.width).toString())); props.setProperty("ndedit.cutPanelHMax", (new Integer(cutPanelMaxSize.height).toString())); props.setProperty("ndedit.lonReference", (new Double(lonReference).toString())); props.setProperty("ndedit.geoDisplayFormat", (new Integer(geoDisplayFormat).toString())); props.setProperty("ndedit.timeDisplayFormat", (new Integer(timeDisplayFormat).toString())); props.setProperty("ndedit.timeAxisMode", (new Integer(timeAxisMode).toString())); props.setProperty("ndedit.timeAxisReference", (new Double(timeAxisReference).toString())); String dpa = new Boolean(displayPanelAxes).toString(); props.setProperty("ndedit.displayPanelAxes", dpa); dpa = new Boolean(independentHandles).toString(); props.setProperty("ndedit.independentHandles", dpa); return props; }
@Override public void valueChanged(TreeSelectionEvent e) { if (e.getSource() == colors && !locked) { TreeSelectionModel tsm = colors.getSelectionModel(); TreePath tp[] = tsm.getSelectionPaths(); if (tp == null) return; Vector<ClassedItem> tmp = new Vector<ClassedItem>(); for (TreePath element : tp) { try { Object[] path = element.getPath(); ClassedItem ci = new ClassedItem(path[1].toString(), path[2].toString()); tmp.add(ci); } catch (Exception exp) { // User did not select a leafnode } } if (sceneElement instanceof NenyaImageSceneElement) { ((NenyaImageSceneElement) sceneElement).setColorList(tmp.toArray(new ClassedItem[0])); } if (sceneElement instanceof NenyaTileSceneElement) { ((NenyaTileSceneElement) sceneElement).setColorList(tmp.toArray(new ClassedItem[0])); } if (sceneElement instanceof NenyaComponentSceneElement) { ((NenyaComponentSceneElement) sceneElement) .getComponents()[itemList.getSelectedIndex()].setColorList( tmp.toArray(new ClassedItem[0])); } submitElement(sceneElement, null); } else { super.valueChanged(e); } }
/** * Spawn a character on the map * * @param MiX Minimum X value * @param MiY Minimum Y value * @param MaX Maximum X value * @param MaY Maximum Y value */ public void Spawn(int MiX, int MiY, int MaX, int MaY) { double Nx = 0, Ny = 0; // Random coordinate Nx = Math.random() * MaX + MiX; Ny = Math.random() * MaY + MiY; // Store block number int BNum = MAP.elementAt(0).getBlockNum(Nx + W / 2, Ny + H / 2); // if invalid block number if (BNum == -1) { Spawn(MiX, MiY, MaX, MaY); } // if invalid surface else if (!isValidSurface(MAP.elementAt(0).Fill[BNum])) { Spawn(MiX, MiY, MaX, MaY); } // if colliding with something else if (this.Collision(Nx + W / 2, Ny + H / 2)) { Spawn(MiX, MiY, MaX, MaY); } else { X = Nx; Y = Ny; } }