protected void addQuadraticSpline(Point2d cp1, Point2d cp2, Point2d offset, int numSegs) { if (points.isEmpty()) { return; } normals.setSize(normals.size() + 2 * numSegs); Point2d cp0 = new Point2d( -((Point2d) points.lastElement()).x + offset.x, -((Point2d) points.lastElement()).y + offset.y); Point3d[] newPositions = new Point3d[numSegs + 1]; Vector3d[] newNormals = new Vector3d[numSegs + 1]; edu.cmu.cs.stage3.alice.core.util.Polynomial.evaluateBezierQuadratic( cp0, cp1, cp2, 0, newPositions, newNormals); normals.setElementAt(new Vector3f(newNormals[0]), (points.size() - 1) * 2); for (int i = 1; i <= numSegs; i++) { points.add(new Point2d(offset.x - newPositions[i].x, offset.y - newPositions[i].y)); normals.setElementAt(new Vector3f(newNormals[i]), (points.size() - 1) * 2); normals.setElementAt(new Vector3f(newNormals[i]), (points.size() - 1) * 2 + 1); } }
protected void close() { if (points.isEmpty()) { return; } if (points.size() > 1 && ((Point2d) points.lastElement()).equals((Point2d) points.firstElement())) { points.setSize(points.size() - 1); normals.setSize(normals.size() - 2); } if (points.size() >= 3) { double dx = ((Point2d) points.firstElement()).x - ((Point2d) points.lastElement()).x; double dy = ((Point2d) points.firstElement()).y - ((Point2d) points.lastElement()).y; double len = Math.sqrt(dx * dx + dy * dy); Vector3d a = new Vector3d(dx / len, 0, dy / len); Vector3d b = new Vector3d(0, 1, 0); Vector3d c = MathUtilities.crossProduct(a, b); normals.setElementAt(new Vector3f(-(float) c.x, -(float) c.z, 0), 1); normals.setElementAt(new Vector3f(-(float) c.x, -(float) c.z, 0), (points.size() - 1) * 2); } else { points.clear(); normals.clear(); } }
public Object cross(Vector lhs, Vector rhs) throws ParseException { int len = lhs.size(); if ((len != 2 && len != 3) || len != rhs.size()) throw new ParseException("Cross: both sides must be of length 3"); if (len == 3) { Vector res = new Vector(3); res.setSize(3); res.setElementAt( sub.sub( mul.mul(lhs.elementAt(1), rhs.elementAt(2)), mul.mul(lhs.elementAt(2), rhs.elementAt(1))), 0); res.setElementAt( sub.sub( mul.mul(lhs.elementAt(2), rhs.elementAt(0)), mul.mul(lhs.elementAt(0), rhs.elementAt(2))), 1); res.setElementAt( sub.sub( mul.mul(lhs.elementAt(0), rhs.elementAt(1)), mul.mul(lhs.elementAt(1), rhs.elementAt(0))), 2); return res; } else { return sub.sub( mul.mul(lhs.elementAt(0), rhs.elementAt(1)), mul.mul(lhs.elementAt(1), rhs.elementAt(0))); } }
public static boolean writeHighScore(int key, long value) { if (key >= MAX_RECORD) { System.out.println("%%%%%%%%%%%%%%%%%%%%% CANT KEY >= MAX_RECORD"); return false; } try { Vector existingData = loadData(RECORD_STORE_NAME); if (existingData.size() <= 0) { System.out.println("Existing Data belom ada ^&^*%%&^$^#%$#^$%#%"); for (int i = 0; i < MAX_RECORD; ++i) existingData.addElement(("" + 0).getBytes()); } else if (existingData.size() < MAX_RECORD) { Vector temp = new Vector(MAX_RECORD); for (int i = 0; i < MAX_RECORD; ++i) temp.addElement(("" + 0).getBytes()); for (int i = 0; i < existingData.size(); ++i) { System.out.println("i : " + i + " dari " + existingData.size()); temp.setElementAt(existingData.elementAt(i), i); } existingData = temp; } System.out.println("value: " + value + " di key:" + key); existingData.setElementAt(("" + value).getBytes(), key); saveData(RECORD_STORE_NAME, existingData); return true; } catch (Exception e) { e.printStackTrace(); return false; } }
private void calculate() { // 计算表达式 String res = ""; String res1 = ""; String res2 = ""; int index = 0; // 要运算的操作符所在的位置 int size = expVector.size(); String temp = ""; // 保存运算符 while (index < size) { temp = (String) expVector.elementAt(index); if (isSingleSign(temp) || isDoubleSign(temp)) { // 如果检测到运算符则要进行运算 if (temp.equals("!")) { res1 = (String) expVector.elementAt(index - 1); res = operation.operate(temp, res1, ""); expVector.setElementAt(res, index - 1); expVector.removeElementAt(index); } else { res1 = (String) expVector.elementAt(index - 2); res2 = (String) expVector.elementAt(index - 1); res = operation.operate(temp, res1, res2); expVector.setElementAt(res, index - 2); expVector.removeElementAt(index - 1); expVector.removeElementAt(index - 1); } calculate(); break; } else { index++; } } }
protected void sort() { if (set.size() > 1) { boolean swapped = true; int lastSwap = set.size() - 1; while (swapped) { int index = 0; int swapIndex = 0; byte[] a = getEncoded((DEREncodable) set.elementAt(0)); swapped = false; while (index != lastSwap) { byte[] b = getEncoded((DEREncodable) set.elementAt(index + 1)); if (lessThanOrEqual(a, b)) { a = b; } else { Object o = set.elementAt(index); set.setElementAt(set.elementAt(index + 1), index); set.setElementAt(o, index + 1); swapped = true; swapIndex = index; } index++; } lastSwap = swapIndex; } } }
protected Vector loadRecipes() { String filename = parametersFile(); Vector recipes = (Vector) Resources.getResource("PARSED: " + filename); if (recipes == null) { StringBuffer str = new CMFile(Resources.buildResourcePath("skills") + filename, null, true).text(); recipes = loadList(str); if (recipes.size() == 0) Log.errOut("LeatherWorking", "Recipes not found!"); else { Vector pleaseAdd1 = new Vector(); Vector pleaseAdd2 = new Vector(); for (int r = 0; r < recipes.size(); r++) { Vector V = (Vector) recipes.elementAt(r); if (V.size() > 0) { Vector V1 = (Vector) V.clone(); Vector V2 = (Vector) V.clone(); String name = (String) V.elementAt(RCP_FINALNAME); V1.setElementAt("Hard " + name, RCP_FINALNAME); V1.setElementAt("" + (CMath.s_int((String) V.elementAt(RCP_LEVEL)) + 5), RCP_LEVEL); V2.setElementAt("Studded " + name, RCP_FINALNAME); V2.setElementAt("" + (CMath.s_int((String) V.elementAt(RCP_LEVEL)) + 11), RCP_LEVEL); pleaseAdd1.addElement(V1); pleaseAdd2.addElement(V2); } } for (int i = 0; i < pleaseAdd1.size(); i++) recipes.addElement(pleaseAdd1.elementAt(i)); for (int i = 0; i < pleaseAdd2.size(); i++) recipes.addElement(pleaseAdd2.elementAt(i)); } Resources.submitResource("PARSED: " + filename, recipes); } return recipes; }
void sort() { for (int i = 0; i < len(); ++i) { for (int j = 0; j < len(); ++j) { if (get(i).isBigger(get(j))) { AccountData temp = get(i); list.setElementAt(get(j), i); list.setElementAt(temp, j); } } } }
public static void sort(Vector subnodes) { for (int i = 1; i < subnodes.size(); ++i) { Sortable currNode = (Sortable) subnodes.elementAt(i); int j = i - 1; for (; j >= 0; --j) { Sortable itemJ = (Sortable) subnodes.elementAt(j); if (compareNodes(itemJ, currNode) <= 0) { break; } subnodes.setElementAt(itemJ, j + 1); } if (j + 1 != i) { subnodes.setElementAt(currNode, j + 1); } } }
public void setColumnName(int col, String name) { if (columnNames.size() == 0 || col >= columnNames.size()) { columnNames.addElement(name); } else { columnNames.setElementAt(name, col); } }
/* * Sets the value of the indicated cell to value */ @Override public void setValueAt(Object value, int row, int col) { if ((row < getRowCount()) & (col < 2)) { Vector myRow = new Vector(2); myRow = (Vector) data.elementAt(row); myRow.setElementAt(value, col); data.setElementAt(myRow, row); // Create a TableModelEvent TableModelEvent evento; evento = new TableModelEvent(this, row, row, 0, TableModelEvent.UPDATE); // and tell the listeners tellListeners(evento); } }
public static void main(String[] args) { // TODO Auto-generated method stub Vector<String> vec = new Vector<String>(); vec.add("홍길동"); // 0 vec.add("이순신"); // 3 vec.add("을지문덕"); // 4 vec.add(1, "심청이"); // 2 vec.add(1, "춘향이"); // 1 vec.addElement("이산"); // 5 for (String name : vec) { System.out.println(name); } System.out.println("삭제후...."); vec.removeElementAt(0); for (String name : vec) { System.out.println(name); } vec.set(1, "박문수"); for (String name : vec) { System.out.println(name); } vec.setElementAt("강감찬", 1); for (String name : vec) { System.out.println(name); } System.out.println("출력..."); for (int i = 0; i < vec.size(); i++) { String name = vec.get(i); // elementAt(i) System.out.println(name); } // 전체 삭제 vec.removeAllElements(); // clear() System.out.println("전체 인원:" + vec.size()); }
public void updateLast(Object morphedMessage, Object lastMessage) { final int last = references.size() - 1; if (lastMessage != null && lastMessage == references.elementAt(last)) { // update the reference references.setElementAt(morphedMessage, last); } }
/** * Called to create a map the parent of each bookmark. * * @param parent top level bookmark. * @param parentMap map to add children to. * @param pagenoVector vector of page numbers. * @param depth object indicating bookmark depth. */ protected void mapChildren( final Bookmark parent, final Hashtable parentMap, final Vector pagenoVector, final Number depth) { getDepthMap().put(parent, depth); final int pageno = parent.getPageno(); if (pageno >= 0) { while (pageno >= pagenoVector.size()) { pagenoVector.addElement(null); } pagenoVector.setElementAt(parent, pageno); } final Enumeration e = parent.elements(); if (e.hasMoreElements()) { final Number childDepth = new Integer(depth.intValue() + 1); do { final Bookmark child = (Bookmark) e.nextElement(); parentMap.put(child, parent); mapChildren(child, parentMap, pagenoVector, childDepth); } while (e.hasMoreElements()); } }
/** * Adds a new row of objects to the 2D vector * * <p>The new row of the table after adding the given column is determined by choosing the * greatest value between <code>newRow.size()</code> and <code>width</code> * * @param newRow the vector of objects to append to the 2D vector */ public void appendRow(Vector newRow) { autosize(Math.max(newRow.size(), width), height + 1); for (int i = 0; i < width; i++) { Vector col = (Vector) items.elementAt(i); if (i < newRow.size()) col.setElementAt(newRow.elementAt(i), col.size() - 1); } }
/** * @param vParam * @param index */ public void setParam(Param vParam, int index) throws java.lang.IndexOutOfBoundsException { // -- check bounds for index if ((index < 0) || (index > _paramList.size())) { throw new IndexOutOfBoundsException(); } _paramList.setElementAt(vParam, index); } // -- void setParam(Param, int)
protected void removePrefixFromDatabaseObjectNames(Vector names) { for (int i = 0; i < names.size(); i++) { String qualifiedName = (String) names.elementAt(i); String name = qualifiedName.substring(qualifiedName.lastIndexOf('.') + 1); names.setElementAt(name, i); } }
public void setValueAt(Object value, int aRow, int aColumn) { logger.debug("setValueAt(" + aRow + "," + aColumn + ")"); Vector row = (Vector) rows.elementAt(aRow); try { Boolean n; Vector params = new Vector(); if (aColumn == 1) { // id, name, id_obj params.add((Integer) row.elementAt(4)); params.add((String) value); params.add(id_obj); n = (Boolean) xmlClient.execute("DateiHandler.updateName", params); } else if (aColumn == 2) { // id, beschreibung, id_obj params.add((Integer) row.elementAt(4)); params.add((String) value); params.add(id_obj); n = (Boolean) xmlClient.execute("DateiHandler.updateBeschreibung", params); } else { return; } } catch (XmlRpcException e) { MsgBox.error(e.getMessage()); return; } row.setElementAt(value, aColumn); }
@Override public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException { final StringBuilder msg = new StringBuilder(""); final Vector V = new Vector(); V.add(Integer.valueOf(Ability.ACODE_THIEF_SKILL)); V.add(Integer.valueOf(Ability.ACODE_SKILL)); V.add(Integer.valueOf(Ability.ACODE_COMMON_SKILL)); final String qual = CMParms.combine(commands, 1).toUpperCase(); if (parsedOutIndividualSkill(mob, qual, V)) return true; final int[] level = new int[1]; final int[] domain = new int[1]; final String[] domainName = new String[1]; domainName[0] = ""; level[0] = -1; parseDomainInfo(mob, commands, V, level, domain, domainName); int mask = Ability.ALL_ACODES; if (domain[0] >= 0) { mask = mask | Ability.ALL_DOMAINS; for (int v = 0; v < V.size(); v++) V.setElementAt(Integer.valueOf(((Integer) V.get(v)).intValue() + domain[0]), v); } if ((domain[0] >= 0) || (qual.length() == 0)) msg.append( L( "\n\r^HYour @x1skills:^? @x2", domainName[0].replace('_', ' '), getAbilities(mob, mob, V, mask, true, level[0]).toString())); if (!mob.isMonster()) mob.session().wraplessPrintln(msg.toString()); return false; }
public void updateRow(Object[] rowData, int row) throws ArrayIndexOutOfBoundsException { if (row < 0 || row >= datas.size()) { throw new ArrayIndexOutOfBoundsException("Index: " + row); } datas.setElementAt(rowData, row); this.fireTableRowsUpdated(row, row); }
/** * Type check a call to a standard function. Insert CastExprs when needed. If as a result of the * insertion of a CastExpr a type check error is thrown, then catch it and re-throw it with a new * "this". */ public Type typeCheckStandard(SymbolTable stable) throws TypeCheckError { _fname.clearNamespace(); // HACK!!! final int n = _arguments.size(); final Vector argsType = typeCheckArgs(stable); final MethodType args = new MethodType(Type.Void, argsType); final MethodType ptype = lookupPrimop(stable, _fname.getLocalPart(), args); if (ptype != null) { for (int i = 0; i < n; i++) { final Type argType = (Type) ptype.argsType().elementAt(i); final Expression exp = (Expression) _arguments.elementAt(i); if (!argType.identicalTo(exp.getType())) { try { _arguments.setElementAt(new CastExpr(exp, argType), i); } catch (TypeCheckError e) { throw new TypeCheckError(this); // invalid conversion } } } _chosenMethodType = ptype; return _type = ptype.resultType(); } throw new TypeCheckError(this); }
/** * Set an attribute. This replaces an attribute of the same name. To set the zeroth attribute (the * tag name), use setTagName(). * * @param attribute The attribute to set. */ public void setAttribute(Attribute attribute) { boolean replaced; Vector attributes; int length; String name; Attribute test; String test_name; replaced = false; attributes = getAttributesEx(); length = attributes.size(); if (0 < length) { name = attribute.getName(); for (int i = 1; i < attributes.size(); i++) { test = (Attribute) attributes.elementAt(i); test_name = test.getName(); if (null != test_name) if (test_name.equalsIgnoreCase(name)) { attributes.setElementAt(attribute, i); replaced = true; } } } if (!replaced) { // add whitespace between attributes if ((0 != length) && !((Attribute) attributes.elementAt(length - 1)).isWhitespace()) attributes.addElement(new Attribute(" ")); attributes.addElement(attribute); } }
/** * Clone object. Handles all service property types and does this recursively. * * @param bundle Object to clone. * @return Cloned object. */ Object cloneObject(Object val) { if (val instanceof Object[]) { val = ((Object[]) val).clone(); final int len = Array.getLength(val); if (len > 0 && Array.get(val, 0).getClass().isArray()) { for (int i = 0; i < len; i++) { Array.set(val, i, cloneObject(Array.get(val, i))); } } } else if (val instanceof boolean[]) { val = ((boolean[]) val).clone(); } else if (val instanceof byte[]) { val = ((byte[]) val).clone(); } else if (val instanceof char[]) { val = ((char[]) val).clone(); } else if (val instanceof double[]) { val = ((double[]) val).clone(); } else if (val instanceof float[]) { val = ((float[]) val).clone(); } else if (val instanceof int[]) { val = ((int[]) val).clone(); } else if (val instanceof long[]) { val = ((long[]) val).clone(); } else if (val instanceof short[]) { val = ((short[]) val).clone(); } else if (val instanceof Vector) { @SuppressWarnings({"rawtypes", "unchecked"}) final Vector<Object> c = (Vector) ((Vector) val).clone(); for (int i = 0; i < c.size(); i++) { c.setElementAt(cloneObject(c.elementAt(i)), i); } val = c; } return val; }
/** Compare the attributes. Return true if they are alike. Ignore the order of the elements. */ private boolean compareAttributeValuesWithoutOrder( Object collection1, Object collection2, AbstractSession session) { ContainerPolicy cp = this.getContainerPolicy(); Vector vector2 = cp.vectorFor(collection2, session); // "clone" it so we can clear out the slots for (Object iter1 = cp.iteratorFor(collection1); cp.hasNext(iter1); ) { Object element1 = cp.next(iter1, session); boolean found = false; for (int i = 0; i < vector2.size(); i++) { if (this.compareElements(element1, vector2.elementAt(i), session)) { found = true; vector2.setElementAt(XXX, i); // clear out the matching element break; // matching element found - skip the rest of them } } if (!found) { return false; } } // look for elements that were not in collection1 for (Enumeration stream = vector2.elements(); stream.hasMoreElements(); ) { if (stream.nextElement() != XXX) { return false; } } return true; }
/** * @param index * @param vValue */ public void setValue(int index, java.lang.String vValue) throws java.lang.IndexOutOfBoundsException { // -- check bounds for index if ((index < 0) || (index > _valueList.size())) { throw new IndexOutOfBoundsException(); } _valueList.setElementAt(vValue, index); } // -- void setValue(int, java.lang.String)
/** * Method setValueAt. * * @param value Object * @param row int * @param column int * @see javax.swing.table.TableModel#setValueAt(Object, int, int) */ public void setValueAt(Object value, int row, int column) { if (null != value && !value.equals(super.getValueAt(row, column))) { this.populateDAO(value, row, column); Vector<Object> dataRow = rows.get(row); dataRow.setElementAt(value, column); fireTableCellUpdated(row, column); } }
protected void addPoint(Point2d point) { points.add(point); normals.setSize(normals.size() + 2); if (points.size() > 1) { double dx = ((Point2d) points.lastElement()).x - ((Point2d) points.elementAt(points.size() - 2)).x; double dy = ((Point2d) points.lastElement()).y - ((Point2d) points.elementAt(points.size() - 2)).y; double len = Math.sqrt(dx * dx + dy * dy); Vector3d a = new Vector3d(dx / len, 0, dy / len); Vector3d b = new Vector3d(0, 1, 0); Vector3d c = MathUtilities.crossProduct(a, b); normals.setElementAt(new Vector3f(-(float) c.x, -(float) c.z, 0), (points.size() - 2) * 2); normals.setElementAt( new Vector3f(-(float) c.x, -(float) c.z, 0), (points.size() - 1) * 2 + 1); } }
public void keyPressed(int keyCode) { // super.keyPressed(keyCode); if (this.isPass()) { return; } if (!ui.selector.checkBox) { ui.selector.checkBox = true; } else { if (keyCode == Key.UPKEY(keyCode)) { if (onShowSelectedItemNum == -1) { ui.selector.checkBox = false; } else if (onShowSelectedItemNum > -1) { onShowSelectedItemNum--; /*if(y+ui.offsetY<60){ ui.offsetY+=20; }*/ } } else if (keyCode == Key.DOWNKEY(keyCode)) { if (onShowSelectedItemNum == (itemSum - 2)) { ui.selector.checkBox = false; } else if (onShowSelectedItemNum < (itemSum - 2)) { onShowSelectedItemNum++; /*if(height+y+ui.offsetY>ui.xWForm.frm_Height-40){ ui.offsetY-=20; ui.xWForm.repaint(); }*/ } } else if ((keyCode == Key.RIGHTKEY(keyCode)) || (keyCode == Key.LEFTKEY(keyCode))) { if (!inBox) ui.selector.checkBox = false; else ui.selector.button = false; } else if (keyCode == Key.FIREKEY(keyCode)) { if (!selector.elementAt(onShowSelectedItemNum + 1).equals(new Integer(1))) { selector.setElementAt(new Integer(1), onShowSelectedItemNum + 1); } else { selector.setElementAt(new Integer(0), onShowSelectedItemNum + 1); } } else if (keyCode == Key.LEFT_SOFT_KEY(keyCode)) { if (inBox) { actionPerformed(keyCode); ui.selector.checkBox = false; } } } }
/** Replaces a figure in the drawing without removing it from the drawing. */ public synchronized void replace(Figure figure, Figure replacement) { int index = fFigures.indexOf(figure); if (index != -1) { replacement.addToContainer(this); // will invalidate figure figure.changed(); fFigures.setElementAt(replacement, index); } }
public void setParameter(int index, Parameter vParameter) throws java.lang.IndexOutOfBoundsException { // -- check bounds for index if ((index < 0) || (index > parameters.size())) { throw new IndexOutOfBoundsException(); } parameters.setElementAt(vParameter, index); } // -- void setParameter(int, Parameter)