/** * Event.detail line start offset (input) Event.text line text (input) LineStyleEvent.styles * Enumeration of StyleRanges, need to be in order. (output) LineStyleEvent.background line * background color (output) */ public void lineGetStyle(LineStyleEvent event) { Vector styles = new Vector(); int token; StyleRange lastStyle; // If the line is part of a block comment, create one style for the entire line. if (inBlockComment(event.lineOffset, event.lineOffset + event.lineText.length())) { styles.addElement( new StyleRange(event.lineOffset, event.lineText.length(), getColor(COMMENT), null)); event.styles = new StyleRange[styles.size()]; styles.copyInto(event.styles); return; } Color defaultFgColor = ((Control) event.widget).getForeground(); scanner.setRange(event.lineText); token = scanner.nextToken(); while (token != EOF) { if (token == OTHER) { // do nothing for non-colored tokens } else if (token != WHITE) { Color color = getColor(token); // Only create a style if the token color is different than the // widget's default foreground color and the token's style is not // bold. Keywords are bolded. if ((!color.equals(defaultFgColor)) || (token == KEY)) { StyleRange style = new StyleRange( scanner.getStartOffset() + event.lineOffset, scanner.getLength(), color, null); if (token == KEY) { style.fontStyle = SWT.BOLD; } if (styles.isEmpty()) { styles.addElement(style); } else { // Merge similar styles. Doing so will improve performance. lastStyle = (StyleRange) styles.lastElement(); if (lastStyle.similarTo(style) && (lastStyle.start + lastStyle.length == style.start)) { lastStyle.length += style.length; } else { styles.addElement(style); } } } } else if ((!styles.isEmpty()) && ((lastStyle = (StyleRange) styles.lastElement()).fontStyle == SWT.BOLD)) { int start = scanner.getStartOffset() + event.lineOffset; lastStyle = (StyleRange) styles.lastElement(); // A font style of SWT.BOLD implies that the last style // represents a java keyword. if (lastStyle.start + lastStyle.length == start) { // Have the white space take on the style before it to // minimize the number of style ranges created and the // number of font style changes during rendering. lastStyle.length += scanner.getLength(); } } token = scanner.nextToken(); } event.styles = new StyleRange[styles.size()]; styles.copyInto(event.styles); }
public void parseBlockComments(String text) { blockComments = new Vector(); StringReader buffer = new StringReader(text); int ch; boolean blkComment = false; int cnt = 0; int[] offsets = new int[2]; boolean done = false; try { while (!done) { switch (ch = buffer.read()) { case -1: { if (blkComment) { offsets[1] = cnt; blockComments.addElement(offsets); } done = true; break; } case '/': { ch = buffer.read(); if ((ch == '*') && (!blkComment)) { offsets = new int[2]; offsets[0] = cnt; blkComment = true; cnt++; } else { cnt++; } cnt++; break; } case '*': { if (blkComment) { ch = buffer.read(); cnt++; if (ch == '/') { blkComment = false; offsets[1] = cnt; blockComments.addElement(offsets); } } cnt++; break; } default: { cnt++; break; } } } } catch (IOException e) { // ignore errors } }
/** * Returns an enumeration describing the available options. * * @return an enumeration of all the available options. */ public Enumeration listOptions() { Vector newVector = new Vector(4); newVector.addElement(new Option("\tTurn on debugging output.", "D", 0, "-D")); newVector.addElement( new Option( "\tFull class name of classifier to include, followed\n" + "\tby scheme options. May be specified multiple times,\n" + "\trequired at least twice.\n" + "\teg: \"weka.classifiers.bayes.NaiveBayes -D\"", "B", 1, "-B <classifier specification>")); newVector.addElement( new Option( "\tSets the random number seed (default 1).", "S", 1, "-S <random number seed>")); newVector.addElement( new Option( "\tUse cross validation for model selection using the\n" + "\tgiven number of folds. (default 0, is to\n" + "\tuse training error)", "X", 1, "-X <number of folds>")); return newVector.elements(); }
/* Check: getLoggerNames() must return correct names * for registered loggers and their parents. * Returns boolean values: PASSED or FAILED */ public static boolean checkLoggers() { String failMsg = "# checkLoggers: getLoggerNames() returned unexpected loggers"; Vector<String> expectedLoggerNames = new Vector<String>(getDefaultLoggerNames()); // Create the logger LOGGER_NAME_1 Logger.getLogger(LOGGER_NAME_1); expectedLoggerNames.addElement(PARENT_NAME_1); expectedLoggerNames.addElement(LOGGER_NAME_1); // Create the logger LOGGER_NAME_2 Logger.getLogger(LOGGER_NAME_2); expectedLoggerNames.addElement(PARENT_NAME_2); expectedLoggerNames.addElement(LOGGER_NAME_2); Enumeration<String> returnedLoggersEnum = logMgr.getLoggerNames(); Vector<String> returnedLoggerNames = new Vector<String>(0); while (returnedLoggersEnum.hasMoreElements()) { String logger = returnedLoggersEnum.nextElement(); if (!initialLoggerNames.contains(logger)) { // filter out the loggers that have been added before this test runs returnedLoggerNames.addElement(logger); } } ; return checkNames(expectedLoggerNames, returnedLoggerNames, failMsg); }
/** * Read a list of space-separated "flag_extension" sequences and return the list as a array of * Strings. An empty list is returned as null. This is an IMAP-ism, and perhaps this method should * moved into the IMAP layer. */ public String[] readSimpleList() { skipSpaces(); if (buffer[index] != '(') // not what we expected return null; index++; // skip '(' Vector v = new Vector(); int start; for (start = index; buffer[index] != ')'; index++) { if (buffer[index] == ' ') { // got one item v.addElement(ASCIIUtility.toString(buffer, start, index)); start = index + 1; // index gets incremented at the top } } if (index > start) // get the last item v.addElement(ASCIIUtility.toString(buffer, start, index)); index++; // skip ')' int size = v.size(); if (size > 0) { String[] s = new String[size]; v.copyInto(s); return s; } else // empty list return null; }
/** 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"); }
/** * Check the headers of the Phenotype matrix file * * @param titles * @param errorMessages * @param suid * @return */ private boolean checkMatrixTitles(String[] titles, Vector errorMessages) { boolean errorFound = false; String errorStr = null; try { if (titles.length < 2) errorFound = true; else if (!(titles[0].equals("IDENTITY") || titles[0].equals("ALIAS"))) { errorFound = true; } if (errorFound) { errorStr = " Illegal headers.\n" + "# Required file headers: IDENTITY/ALIAS VARIABLE1 VARIABLE2 ...\n" + "# Headers found in file: "; for (int j = 0; j < titles.length; j++) { errorStr = errorStr + " " + titles[j]; } errorMessages.addElement(errorStr); } // now we check that the variables in header exists for (int i = 1; i < titles.length; i++) { if (db.isVariableUnique(titles[i])) { errorFound = true; errorStr = "Variable " + titles[i] + " does not exist."; errorMessages.addElement(errorStr); } } } catch (Exception e) { e.printStackTrace(System.err); } return errorFound; }
/** Creates a new instance of AccountPicker */ public AccountSelect(Display display, boolean enableQuit) { super(); // this.display=display; setTitleItem(new Title(SR.MS_ACCOUNTS)); accountList = new Vector(); Account a; int index = 0; activeAccount = Config.getInstance().accountIndex; do { a = Account.createFromStorage(index); if (a != null) { accountList.addElement(a); a.active = (activeAccount == index); index++; } } while (a != null); if (accountList.isEmpty()) { a = Account.createFromJad(); if (a != null) { // a.updateJidCache(); accountList.addElement(a); rmsUpdate(); } } attachDisplay(display); addCommand(cmdAdd); if (enableQuit) addCommand(cmdQuit); commandState(); setCommandListener(this); }
public void mousePressed(MouseEvent e) { System.out.println("mousePressed"); Point1 p2; switch (toolFlag) { case 3: // 直线 x = (int) e.getX(); y = (int) e.getY(); p2 = new Point1(x, y, c, toolFlag, con); paintInfo.addElement(p2); break; case 4: // 圆 x = (int) e.getX(); y = (int) e.getY(); p2 = new Point1(x, y, c, toolFlag, con); paintInfo.addElement(p2); break; case 5: // 矩形 x = (int) e.getX(); y = (int) e.getY(); p2 = new Point1(x, y, c, toolFlag, con); paintInfo.addElement(p2); break; default: } }
/* * In text: a string seperate by comma (,) Out a collection of elements * without (between) comma */ static Collection parseIPaddresses(String text) { Vector prefixes = new Vector(); if (text == null || "".equals(text)) { return prefixes; } String tempStr = text.toUpperCase(); String currentLabel = null; int index = tempStr.indexOf(","); while (index != -1) { currentLabel = tempStr.substring(0, index).trim(); if (!"".equals(currentLabel)) { prefixes.addElement(currentLabel); } tempStr = tempStr.substring(index + 1); index = tempStr.indexOf(","); } // Last label currentLabel = tempStr.trim(); if (!"".equals(currentLabel)) { prefixes.addElement(currentLabel); } return prefixes; }
public static String[] parseString(String text, String seperator) { Vector vResult = new Vector(); if (text == null || "".equals(text)) { return null; } String tempStr = text.trim(); String currentLabel = null; int index = tempStr.indexOf(seperator); while (index != -1) { currentLabel = tempStr.substring(0, index).trim(); if (!"".equals(currentLabel)) { vResult.addElement(currentLabel); } tempStr = tempStr.substring(index + 1); index = tempStr.indexOf(seperator); } // Last label currentLabel = tempStr.trim(); if (!"".equals(currentLabel)) { vResult.addElement(currentLabel); } String[] re = new String[vResult.size()]; Iterator it = vResult.iterator(); index = 0; while (it.hasNext()) { re[index] = (String) it.next(); index++; } return re; }
public void startElement(String uri, String localName, String qName, Attributes atts) { logger.log( LogService.LOG_DEBUG, "Here is AttributeDefinitionHandler:startElement():" //$NON-NLS-1$ + qName); if (!_isParsedDataValid) return; String name = getName(localName, qName); if (name.equalsIgnoreCase(OPTION)) { OptionHandler optionHandler = new OptionHandler(this); optionHandler.init(name, atts); if (optionHandler._isParsedDataValid) { // Only add valid Option _optionLabel_vector.addElement(optionHandler._label_val); _optionValue_vector.addElement(optionHandler._value_val); } } else { logger.log( LogService.LOG_WARNING, NLS.bind( MetaTypeMsg.UNEXPECTED_ELEMENT, new Object[] { name, atts.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName() })); } }
/** Load all of the named resource. */ private void loadAllResources(Vector v, String name) { boolean anyLoaded = false; try { URL[] urls; ClassLoader cld = null; // First try the "application's" class loader. cld = SecuritySupport.getContextClassLoader(); if (cld == null) cld = this.getClass().getClassLoader(); if (cld != null) urls = SecuritySupport.getResources(cld, name); else urls = SecuritySupport.getSystemResources(name); if (urls != null) { if (LogSupport.isLoggable()) LogSupport.log("MimetypesFileTypeMap: getResources"); for (int i = 0; i < urls.length; i++) { URL url = urls[i]; InputStream clis = null; if (LogSupport.isLoggable()) LogSupport.log("MimetypesFileTypeMap: URL " + url); try { clis = SecuritySupport.openStream(url); if (clis != null) { v.addElement(new MimeTypeFile(clis)); anyLoaded = true; if (LogSupport.isLoggable()) LogSupport.log( "MimetypesFileTypeMap: " + "successfully loaded " + "mime types from URL: " + url); } else { if (LogSupport.isLoggable()) LogSupport.log( "MimetypesFileTypeMap: " + "not loading " + "mime types from URL: " + url); } } catch (IOException ioex) { if (LogSupport.isLoggable()) LogSupport.log("MimetypesFileTypeMap: can't load " + url, ioex); } catch (SecurityException sex) { if (LogSupport.isLoggable()) LogSupport.log("MimetypesFileTypeMap: can't load " + url, sex); } finally { try { if (clis != null) clis.close(); } catch (IOException cex) { } } } } } catch (Exception ex) { if (LogSupport.isLoggable()) LogSupport.log("MimetypesFileTypeMap: can't load " + name, ex); } // if failed to load anything, fall back to old technique, just in case if (!anyLoaded) { LogSupport.log("MimetypesFileTypeMap: !anyLoaded"); MimeTypeFile mf = loadResource("/" + name); if (mf != null) v.addElement(mf); } }
/** * Gets the handles of the figure. It returns the normal PolyLineHandles but adds * ChangeConnectionHandles at the start and end. */ public Vector handles() { Vector handles = new Vector(fPoints.size()); handles.addElement(new ChangeConnectionStartHandle(this)); for (int i = 1; i < fPoints.size() - 1; i++) { handles.addElement(new PolyLineHandle(this, locator(i), i)); } handles.addElement(new ChangeConnectionEndHandle(this)); return handles; }
public void addMenuItem(String text, String loc) { locations.put(text, loc); if (filenames.contains("Test Text")) { filenames.remove("Test Text"); filenames.addElement(text); } else { filenames.addElement(text); } createPopupMenu(); }
/** * This Method returns the 2D Array which is the list of the Items for the selected WorkOrder of * the Customer. * * @param workorderId - WorkOrder Id Foreign Key of WRK_ORDR_DETS table * @return Object[][] - 2D Array which is List of the Items for the WorkOrder */ public Object[][] getWorkOrderItems(long workorderId) throws RemoteException { WrkOrdrDets wrkordrdts_obj = new WrkOrdrDets(conn); RHCCBlgKeys blgkeys_obj = new RHCCBlgKeys(conn); Vector workorderdetList = wrkordrdts_obj.getProductList(workorderId); // Hashtable BSysList = (Hashtable) USFEnv.getBillSystems(); BlgSys blgsys = new BlgSys(); Hashtable BSysList = (Hashtable) blgsys.searchBlgSys(); Enumeration BSys = BSysList.keys(); // The 2-Dimensional array to hold the Items Billing System wise. Object[][] prodList = new Object[BSysList.size()][workorderdetList.size() + 1]; // The Number of Billing Systems are assumed to be equal to the // Static Load Billing Systems Hashtable size. The Billing Systems will // be in order starting from 1 and incrementing by one. for (int i = 0; i < BSysList.size(); i++) { // Set the 2D array to store the Billing System as the first element // of each row. prodList[i][0] = String.valueOf(i + 1); } // Loop throught the WorkOrder Items List and place them in the appropriate // positions in the 2D array. for (int j = 0; j < workorderdetList.size(); j++) { // Determine the Billing System of the Product Vector tmpVector = new Vector(); WrkOrdrDets workorderObj = (WrkOrdrDets) workorderdetList.elementAt(j); RHCCBlgKeys bkObj = blgkeys_obj.searchRHCCBlgKeys(((WrkOrdrDets) workorderdetList.elementAt(j)).getRBKID()); int bsid = (new Long(bkObj.getBsId())).intValue(); tmpVector.addElement(bkObj); tmpVector.addElement(workorderObj); // Based on the Billing System Id retreived place the Product Object // in the 2D array. int k = 1; while (prodList[bsid - 1][k] != null) { k = k + 1; } prodList[bsid - 1][k] = tmpVector; } // Return the 2D array return prodList; }
/** Add data to the table as a new row */ public void addData(SOAPMonitorData soap) { int row = data.size(); data.addElement(soap); if (filter_data != null) { if (filterMatch(soap)) { row = filter_data.size(); filter_data.addElement(soap); fireTableRowsInserted(row, row); } } else { fireTableRowsInserted(row, row); } }
/** Remove all messages from the table (but leave "most recent") */ public void clearAll() { int last_row = data.size() - 1; if (last_row > 0) { data.removeAllElements(); SOAPMonitorData soap = new SOAPMonitorData(null, null, null); data.addElement(soap); if (filter_data != null) { filter_data.removeAllElements(); filter_data.addElement(soap); } fireTableDataChanged(); } }
/** * Gets the list of the hierarchical folders. * * @return the list of the hierarchical folders. */ public Vector getHierarchicalFolders() { Vector folder_list = new Vector(); folder_list.addElement(CatalogManager.getCatalogCategoryFolder(getCatalogCategoryNumber())); folder_list.addElement(getCatalogFolderCode()); int number = Integer.parseInt(name) / 100; number *= 100; folder_list.addElement(String.valueOf(number)); return folder_list; }
/** * INTERNAL: Return the value for in memory comparison. This is only valid for valueable * expressions. */ public Object valueFromObject( Object object, AbstractSession session, AbstractRecord translationRow, int valueHolderPolicy, boolean isObjectUnregistered) { // The expression may be across a relationship, in which case it must be traversed. if ((!getBaseExpression().isExpressionBuilder()) && getBaseExpression().isQueryKeyExpression()) { object = getBaseExpression() .valueFromObject( object, session, translationRow, valueHolderPolicy, isObjectUnregistered); // toDo: Null means the join filters out the row, returning null is not correct if an inner // join, // outer/inner joins need to be fixed to filter correctly. if (object == null) { return null; } // If from an anyof the object will be a collection of values, // A new vector must union the object values and the values extracted from it. if (object instanceof Vector) { Vector comparisonVector = new Vector(((Vector) object).size() + 2); for (Enumeration valuesToIterate = ((Vector) object).elements(); valuesToIterate.hasMoreElements(); ) { Object vectorObject = valuesToIterate.nextElement(); if (vectorObject == null) { comparisonVector.addElement(vectorObject); } else { Object valueOrValues = valuesFromCollection( vectorObject, session, valueHolderPolicy, isObjectUnregistered); // If a collection of values were extracted union them. if (valueOrValues instanceof Vector) { for (Enumeration nestedValuesToIterate = ((Vector) valueOrValues).elements(); nestedValuesToIterate.hasMoreElements(); ) { comparisonVector.addElement(nestedValuesToIterate.nextElement()); } } else { comparisonVector.addElement(valueOrValues); } } } return comparisonVector; } } return valuesFromCollection(object, session, valueHolderPolicy, isObjectUnregistered); }
/** * This method returns an array of all the tables referenced in the datastore. * * @param updateable True if the table list should only include updateable tables and false if it * should include all. */ public String[] getTableList(boolean updateable) { DSColumnDescriptor col = null; Vector tables = new Vector(); Vector pkey = new Vector(); for (int i = 0; i < _desc.getColumnCount(); i++) { col = _desc.getColumn(i); String tableName = col.getTable(); if (tableName == null) tableName = _desc.getDefaultTable(); if ((!updateable) || col.isUpdateable()) { boolean found = false; for (int j = 0; j < tables.size(); j++) { if ((tables.elementAt(j)).equals(tableName)) { if (col.isPrimaryKey()) pkey.setElementAt(new Boolean(true), j); found = true; break; } } if (!found && tableName != null) { tables.addElement(tableName); pkey.addElement(new Boolean(col.isPrimaryKey())); } } } if (updateable) { for (int i = pkey.size() - 1; i > -1; i--) { if (!((Boolean) pkey.elementAt(i)).booleanValue()) tables.removeElementAt(i); } } else { for (int i = 0; i < getAliasCount(); i++) { try { String table = getTable(i); boolean found = false; for (int j = 0; j < tables.size(); j++) { if ((tables.elementAt(j)).equals(table)) found = true; } if (!found && table != null) tables.addElement(table); } catch (Exception e) { } } } String retVal[] = new String[tables.size()]; tables.copyInto(retVal); return retVal; }
/** * Gets the list of the hierarchical folders. * * @return the list of the hierarchical folders. */ public Vector getHierarchicalFolders() { Vector folder_list = new Vector(); folder_list.addElement(CatalogManager.getCatalogCategoryFolder(getCatalogCategoryNumber())); folder_list.addElement(getCatalogFolderCode()); folder_list.addElement(name.substring(0, 1)); int number = Format.intValueOf(name.substring(2)) / 100; number *= 100; folder_list.addElement(String.valueOf(number)); return folder_list; }
private void assembleAction() { String line; messages = new Vector(); mainFrame.resetExecWindow(); save(); assembleFailed = false; haveAssemblyErrors = false; if (Assembler.version()) { while ((line = Assembler.output()) != null) { messages.addElement(line); } Assembler.setPaths(baseName, sourcePath); if (Assembler.assemble()) { while ((line = Assembler.output()) != null) { System.out.println(line); messages.addElement(line); if (line.startsWith(" [ERROR:")) { haveAssemblyErrors = true; } } messageList.setListData(messages); messageList.ensureIndexIsVisible(0); mainFrame.showExecWindow(baseName); } else { assembleFailed = true; } } else { assembleFailed = true; } if (assembleFailed) { String message = String.format( "Autocoder failed!\nVerify the correctness of autocoder path\n%s", AssemblerOptions.assemblerPath); System.out.println(message); JOptionPane.showMessageDialog(this, message, "ROPE", JOptionPane.ERROR_MESSAGE); } }
/** * Gets the list of the hierarchical folders. * * @return the list of the hierarchical folders. */ public Vector getHierarchicalFolders() { Vector folder_list = new Vector(); folder_list.addElement(CatalogManager.getCatalogCategoryFolder(getCatalogCategoryNumber())); folder_list.addElement(getCatalogFolderCode()); int p = name.indexOf('+'); if (p < 0) p = name.indexOf('-'); folder_list.addElement(name.substring(0, 2)); folder_list.addElement(name.substring(p, p + 2) + "0"); return folder_list; }
public static int rules( String top, Vector<String> first, Vector<String> second, Vector<String> afia) { while (!first.isEmpty() && !second.isEmpty()) { if (count % 2 == 0) { boolean check = false; for (int i = 0; i < first.size(); i++) { check = matcher( top, first.elementAt( i)); // performs a linear search on player1's whot to see if any matches the // top card if (check == true) { place.addElement(first.elementAt(i)); first.removeElementAt(i); break; } } if (check == false) { Random rd = new Random(); int pick = Math.abs(rd.nextInt(afia.size() - 1)) % (afia.size() - 1); first.addElement(afia.elementAt(pick)); afia.removeElementAt(pick); } } else { boolean check = false; for (int i = 0; i < second.size(); i++) { check = matcher( top, second.elementAt( i)); // performs a linear search on player1's whot to see if any matches the // top card if (check == true) { place.addElement(second.elementAt(i)); second.removeElementAt(i); break; } } if (check == false) { Random rd = new Random(); int pick = Math.abs(rd.nextInt(afia.size() - 1)) % (afia.size() - 1); second.addElement(afia.elementAt(pick)); afia.removeElementAt(pick); } } } return 1; }
// ---------------------------------------------------------------------- // for "SrvTypeRqst" // get the list of service types for specified scope & naming authority // ---------------------------------------------------------------------- public synchronized String getServiceTypeList(String na, String scope) { Vector typelist = new Vector(5); Iterator values = table.values().iterator(); while (values.hasNext()) { Entry e = (Entry) values.next(); if (!e.getDeleted() && // nor deleted scope.equalsIgnoreCase(e.getScope()) && // match scope (na.equals("*") || // NA wildcard na.equalsIgnoreCase(e.getNA())) && // match NA !typelist.contains(e.getType())) { typelist.addElement(e.getType()); } } StringBuffer tl = new StringBuffer(); for (int i = 0; i < typelist.size(); i++) { String s = (String) typelist.elementAt(i); if (tl.length() > 0) tl.append(","); tl.append(s); } return tl.toString(); }
// TODO: check for multiple modifiers (several Ifs, several Prefix, ect.) Rule(String name, Modifier[] someModifiers) { this(name); for (int i = 0; i < someModifiers.length; i++) { Modifier modifier = someModifiers[i]; if (modifier instanceof PrefixModifier) { prefixModifier = (PrefixModifier) modifier; } else if (modifier instanceof SuffixModifier) { suffixModifier = (SuffixModifier) modifier; } else if (modifier instanceof SeparatorModifier) { separatorModifier = (SeparatorModifier) modifier; } else if (modifier instanceof NullModifier) { nullModifier = (NullModifier) modifier; } else if (modifier instanceof DomainModifier) { domainModifier = (DomainModifier) modifier; } else if (modifier instanceof FileModifier) { fileModifier = (FileModifier) modifier; } else if (modifier instanceof ExternModifier) { externModifier = (ExternModifier) modifier; } else if (modifier instanceof BooleanModifier) { m_booleanModifier = (BooleanModifier) modifier; } else if (modifier instanceof CaseModifier) { m_caseModifier = (CaseModifier) modifier; } else if (modifier instanceof VariableModifier) { if (variableVector == null) { variableVector = new Vector(); } variableVector.addElement(modifier); } } }
/** 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(); } }
private void server() { new CountDown(60).start(); while (true) { try { Socket socket = serverSock.accept(); System.out.println("New Client:" + socket); if (readyState[6] == 1) { System.out.println("正在游戏中,无法加入"); continue; } for (i = 0; i <= 5; i++) { if (players[i].equals("虚位以待")) break; } if (i > 5) { System.out.println("房间已满,无法加入"); continue; } i++; ObjectOutputStream remoteOut = new ObjectOutputStream(socket.getOutputStream()); clients.addElement(remoteOut); ObjectInputStream remoteIn = new ObjectInputStream(socket.getInputStream()); new ServerHelder(remoteIn, remoteOut, socket.getPort(), i).start(); } catch (IOException e) { System.out.println(e.getMessage() + ": Failed to connect to client."); try { serverSock.close(); } catch (IOException x) { System.out.println(e.getMessage() + ": Failed to close server socket."); } } } }