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); } */ }
@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(); } }
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()); } }
/** Adds a figure to the list of figures. Initializes the the figure's container. */ public Figure add(Figure figure) { if (!fFigures.contains(figure)) { fFigures.addElement(figure); figure.addToContainer(this); } return figure; }
/** Brings a figure to the front. */ public synchronized void bringToFront(Figure figure) { if (fFigures.contains(figure)) { fFigures.removeElement(figure); fFigures.addElement(figure); figure.changed(); } }
/** * Notify any DialogListeners of changes having occurred If a listener returns false, do not call * further listeners and disable the OK button and preview Checkbox (if it exists). For * PlugInFilters, this ensures that the PlugInFilterRunner, which listens as the last one, is not * called if the PlugInFilter has detected invalid parameters. Thus, unnecessary calling the * run(ip) method of the PlugInFilter for preview is avoided in that case. */ private void notifyListeners(AWTEvent e) { if (dialogListeners == null) return; boolean everythingOk = true; for (int i = 0; everythingOk && i < dialogListeners.size(); i++) try { resetCounters(); if (!((DialogListener) dialogListeners.elementAt(i)).dialogItemChanged(this, e)) everythingOk = false; } // disable further listeners if false (invalid parameters) returned catch (Exception err) { // for exceptions, don't cover the input by a window but IJ.beep(); // show them at in the "Log" IJ.log( "ERROR: " + err + "\nin DialogListener of " + dialogListeners.elementAt(i) + "\nat " + (err.getStackTrace()[0]) + "\nfrom " + (err.getStackTrace()[1])); // requires Java 1.4 } boolean workaroundOSXbug = IJ.isMacOSX() && okay != null && !okay.isEnabled() && everythingOk; if (previewCheckbox != null) previewCheckbox.setEnabled(everythingOk); if (okay != null) okay.setEnabled(everythingOk); if (workaroundOSXbug) repaint(); // OSX 10.4 bug delays update of enabled until the next input }
public Buffer getUV() { float v[] = new float[uv.size()]; for (int i = 0; i < uv.size(); i++) { v[i] = (uv.elementAt(i)).floatValue(); } return FloatBuffer.wrap(v); }
public Buffer getNormals() { float v[] = new float[normals.size()]; for (int i = 0; i < normals.size(); i++) { v[i] = (normals.elementAt(i)).floatValue(); } return FloatBuffer.wrap(v); }
/** Calculate the rectangle occupied by the data */ protected Rectangle getDataRectangle(Graphics g, Rectangle r) { Axis a; int waxis; int x = r.x; int y = r.y; int width = r.width; int height = r.height; for (int i = 0; i < axis.size(); i++) { a = ((Axis) axis.elementAt(i)); waxis = a.getAxisWidth(g); switch (a.getAxisPos()) { case Axis.LEFT: x += waxis; width -= waxis; break; case Axis.RIGHT: width -= waxis; break; case Axis.TOP: y += waxis; height -= waxis; break; case Axis.BOTTOM: height -= waxis; break; } } return new Rectangle(x, y, width, height); }
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 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 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 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 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(); } }
/** Returns the contents of the next text field. */ public String getNextString() { String theText; if (stringField == null) return ""; TextField tf = (TextField) (stringField.elementAt(sfIndex)); theText = tf.getText(); if (macro) { String label = (String) labels.get((Object) tf); theText = Macro.getValue(macroOptions, label, theText); if (theText != null && (theText.startsWith("&") || label.toLowerCase(Locale.US).startsWith(theText))) { // Is the value a macro variable? if (theText.startsWith("&")) theText = theText.substring(1); Interpreter interp = Interpreter.getInstance(); String s = interp != null ? interp.getVariableAsString(theText) : null; if (s != null) theText = s; } } if (recorderOn) { String s = theText; if (s != null && s.length() >= 3 && Character.isLetter(s.charAt(0)) && s.charAt(1) == ':' && s.charAt(2) == '\\') s = s.replaceAll("\\\\", "\\\\\\\\"); // replace "\" with "\\" in Windows file paths if (!smartRecording || !s.equals((String) defaultStrings.elementAt(sfIndex))) recordOption(tf, s); else if (Recorder.getCommandOptions() == null) Recorder.recordOption(" "); } sfIndex++; return theText; }
/** * Adds a popup menu. * * @param label the label * @param items the menu items * @param defaultItem the menu item initially selected */ public void addChoice(String label, String[] items, String defaultItem) { String label2 = label; if (label2.indexOf('_') != -1) label2 = label2.replace('_', ' '); Label theLabel = makeLabel(label2); c.gridx = 0; c.gridy = y; c.anchor = GridBagConstraints.EAST; c.gridwidth = 1; if (choice == null) { choice = new Vector(4); defaultChoiceIndexes = new Vector(4); c.insets = getInsets(5, 0, 5, 0); } else c.insets = getInsets(0, 0, 5, 0); grid.setConstraints(theLabel, c); add(theLabel); Choice thisChoice = new Choice(); thisChoice.addKeyListener(this); thisChoice.addItemListener(this); for (int i = 0; i < items.length; i++) thisChoice.addItem(items[i]); if (defaultItem != null) thisChoice.select(defaultItem); else thisChoice.select(0); c.gridx = 1; c.gridy = y; c.anchor = GridBagConstraints.WEST; grid.setConstraints(thisChoice, c); add(thisChoice); choice.addElement(thisChoice); int index = thisChoice.getSelectedIndex(); defaultChoiceIndexes.addElement(new Integer(index)); if (Recorder.record || macro) saveLabel(thisChoice, label); y++; }
/** * Adds a radio button group. * * @param label group label (or null) * @param items radio button labels * @param rows number of rows * @param columns number of columns * @param defaultItem button initially selected */ public void addRadioButtonGroup( String label, String[] items, int rows, int columns, String defaultItem) { Panel panel = new Panel(); int n = items.length; panel.setLayout(new GridLayout(rows, columns, 0, 0)); CheckboxGroup cg = new CheckboxGroup(); for (int i = 0; i < n; i++) { Checkbox cb = new Checkbox(items[i], cg, items[i].equals(defaultItem)); cb.addItemListener(this); panel.add(cb); } if (radioButtonGroups == null) radioButtonGroups = new Vector(); radioButtonGroups.addElement(cg); Insets insets = getInsets(5, 10, 0, 0); if (label == null || label.equals("")) { label = "rbg" + radioButtonGroups.size(); insets.top += 5; } else { setInsets(10, insets.left, 0); addMessage(label); insets.top = 2; insets.left += 10; } c.gridx = 0; c.gridy = y; c.gridwidth = 2; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(insets.top, insets.left, 0, 0); grid.setConstraints(panel, c); add(panel); if (Recorder.record || macro) saveLabel(cg, label); y++; }
/** * Removes a figure from the composite. * * @see #removeAll */ public Figure remove(Figure figure) { if (fFigures.contains(figure)) { figure.removeFromContainer(this); fFigures.removeElement(figure); } return figure; }
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 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; }
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(); }
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(); }
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 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 Buffer getVertices() { float v[] = new float[points.size()]; for (int i = 0; i < points.size(); i++) { v[i] = (points.elementAt(i)).floatValue(); } return FloatBuffer.wrap(v); }
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; }
// keyboard discovery code private void _mapKey(char charCode, int keyindex, boolean shift, boolean altgraph) { log("_mapKey: " + charCode); // if character is not in map, add it if (!charMap.containsKey(new Integer(charCode))) { log("Notified: " + (char) charCode); KeyEvent event = new KeyEvent( applet(), 0, 0, (shift ? KeyEvent.SHIFT_MASK : 0) + (altgraph ? KeyEvent.ALT_GRAPH_MASK : 0), ((Integer) vkKeys.get(keyindex)).intValue(), (char) charCode); charMap.put(new Integer(charCode), event); log("Mapped char " + (char) charCode + " to KeyEvent " + event); if (((char) charCode) >= 'a' && ((char) charCode) <= 'z') { // put shifted version of a-z in automatically int uppercharCode = (int) Character.toUpperCase((char) charCode); event = new KeyEvent( applet(), 0, 0, KeyEvent.SHIFT_MASK + (altgraph ? KeyEvent.ALT_GRAPH_MASK : 0), ((Integer) vkKeys.get(keyindex)).intValue(), (char) uppercharCode); charMap.put(new Integer(uppercharCode), event); log("Mapped char " + (char) uppercharCode + " to KeyEvent " + event); } } }
/** Returns the index of the selected item in the next popup menu. */ public int getNextChoiceIndex() { if (choice == null) return -1; Choice thisChoice = (Choice) (choice.elementAt(choiceIndex)); int index = thisChoice.getSelectedIndex(); if (macro) { String label = (String) labels.get((Object) thisChoice); String oldItem = thisChoice.getSelectedItem(); int oldIndex = thisChoice.getSelectedIndex(); String item = Macro.getValue(macroOptions, label, oldItem); if (item != null && item.startsWith("&")) // value is macro variable item = getChoiceVariable(item); thisChoice.select(item); index = thisChoice.getSelectedIndex(); if (index == oldIndex && !item.equals(oldItem)) { // is value a macro variable? Interpreter interp = Interpreter.getInstance(); String s = interp != null ? interp.getStringVariable(item) : null; if (s == null) IJ.error(getTitle(), "\"" + item + "\" is not a valid choice for \"" + label + "\""); else item = s; } } if (recorderOn) { int defaultIndex = ((Integer) (defaultChoiceIndexes.elementAt(choiceIndex))).intValue(); if (!(smartRecording && index == defaultIndex)) { String item = thisChoice.getSelectedItem(); if (!(item.equals("*None*") && getTitle().equals("Merge Channels"))) recordOption(thisChoice, thisChoice.getSelectedItem()); } } choiceIndex++; return index; }
/** Sends a figure to the back of the drawing. */ public synchronized void sendToBack(Figure figure) { if (fFigures.contains(figure)) { fFigures.removeElement(figure); fFigures.insertElementAt(figure, 0); figure.changed(); } }
/** * 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; }