/** * Lanza un único disparo básico * * @param shooter - El shooter que realizó el disparo */ public static Basic shootOneBasicWeapon(GameObject shooter) { Basic basic = new Basic(shooter, 0, 0); int x = (int) (shooter.getX() - basic.getWidth()); int y = (int) (shooter.getY() + shooter.getHeight() / 2); if (shooter instanceof CampaignShip) { x += shooter.getWidth() + basic.getWidth(); y -= (shooter.getHeight() / 2 - basic.getHeight() / 2); } addToShoots(basic, x, y); return basic; }
public String SqlExcute(String xmlStr) { String outstr = "false"; Document doc; Element rootNode; String intStr = Basic.decode(xmlStr); try { Reader reader = new StringReader(intStr); SAXBuilder ss = new SAXBuilder(); doc = ss.build(reader); rootNode = doc.getRootElement(); List list = rootNode.getChildren(); DBTable datatable = new DBTable(); for (int i = 0; i < list.size(); i++) { Element childRoot = (Element) list.get(i); // System.out.print(childRoot.getText()); outstr = String.valueOf(datatable.SaveDateStr(childRoot.getText())); } } catch (JDOMException ex) { System.out.print(ex.getMessage()); } return outstr; }
@Override public void click(Int2D clickPos) { if (bottomArrowBarHit(clickPos)) { bottomArrowBar(); } super.click(clickPos); }
@Override public void drag(Int2D clickPos, Int2D delta, Frame f) { if (bottomArrowBarHit(clickPos)) { // bottomArrowBar(); } super.drag(clickPos, delta, f); }
@Override public void delete() { super.delete(); if (parentWorld != null) { parentWorld.removeListener(listener); } }
public void mouseReleased(MouseEvent e) { super.mouseReleased(e); // code to respond to mouse button released: // ------------------------------------------------------------------ // ------------------------------------------------------------------ }
public void mousePressed(MouseEvent e) { super.mousePressed(e); // code to respond to mouse button pressed: // ------------------------------------------------------------------ // ------------------------------------------------------------------ }
public void mouseDragged(MouseEvent e) { super.mouseDragged(e); // code to respond to mouse motion with a button pressed: // ------------------------------------------------------------------ // ------------------------------------------------------------------ }
public void mouseMoved(MouseEvent e) { super.mouseMoved(e); // code to respond to mouse motion: // ------------------------------------------------------------------ // ------------------------------------------------------------------ }
public void mouseExited(MouseEvent e) { super.mouseExited(e); // code to respond to mouse exiting window: // ------------------------------------------------------------------ // ------------------------------------------------------------------ }
public void mouseClicked(MouseEvent e) { super.mouseClicked(e); // code to respond to mouse click: // ------------------------------------------------------------------ // ------------------------------------------------------------------ }
@Override public void resolveRenaming(String oldId, String newId) { super.resolveRenaming(oldId, newId); targetString.set(Function.repairTarget(oldId, newId, targetString.get())); if (targetString.get() != null) { resetTargets(); } }
public String QuerySQL(String xmlStr) { String outstr = ""; Document doc; Element rootNode; String intStr = Basic.decode(xmlStr); try { Reader reader = new StringReader(intStr); SAXBuilder ss = new SAXBuilder(); doc = ss.build(reader); rootNode = doc.getRootElement(); String SqlStr = "select " + rootNode.getAttributeValue("fieldStr"); SqlStr = SqlStr + " from " + rootNode.getAttributeValue("tableStr"); SqlStr = SqlStr + " where (1=1) " + rootNode.getAttributeValue("whereStr"); DBTable datatable = new DBTable(); RecordSet rs = datatable.queryData(SqlStr); String[] fieldArr = rootNode.getAttributeValue("fieldStr").split(","); outstr = "<queryDataS success=\"true\">"; while (rs.next()) { outstr = outstr + "<queryData"; for (int i = 0; i < fieldArr.length; i++) { outstr = outstr + " " + fieldArr[i].trim() + "=\"" + rs.getString(fieldArr[i].trim()) + "\""; } outstr = outstr + "/>"; } outstr = outstr + "</queryDataS>"; } catch (JDOMException ex) { outstr = "<queryDataS success=false>"; outstr = outstr + ex.getMessage() + "</queryDataS>"; } return Basic.encode(outstr); }
@Override public void resolveCopying() { super.resolveCopying(); if (isCopied()) { String newTargetString = Global.idChangeDB().repairTargetString(targetString.get()); targetString.set(newTargetString); if (targetString.get() != null) { resetTargets(); } } }
/** * constructor * * @param fileName * @throws java.io.FileNotFoundException */ public FileInputIterator(String fileName, boolean reportProgress) throws IOException { this.fileName = fileName; if (fileName.startsWith(PREFIX_TO_INDICATE_TO_PARSE_FILENAME_STRING)) { reader = new BufferedReader(new StringReader(fileName.substring(3))); endOfLineBytes = 1; maxProgress = fileName.length() - PREFIX_TO_INDICATE_TO_PARSE_FILENAME_STRING.length(); } else { final File file = new File(fileName); if (Basic.isZIPorGZIPFile(file.getPath())) { reader = new BufferedReader( new InputStreamReader(Basic.getInputStreamPossiblyZIPorGZIP(file.getPath()))); endOfLineBytes = 1; maxProgress = 5 * file.length(); // assuming compression factor of 5-to-1 } else { reader = new BufferedReader(new FileReader(file), bufferSize); endOfLineBytes = Basic.getNumberOfNonSpaceCharacters(fileName); maxProgress = file.length(); } } done = (maxProgress <= 0); setReportProgress(reportProgress); }
public TreeViewer(String title, int ulx, int uly, int pw, int ph) { super(title, ulx, uly, pw, ph); // code to initialize instance variables before animation begins: // ------------------------------------------------------------------ state = "regular"; spread = 1; levelHeight = 10; // 10 levels for the camera region height tree = new SackBST(); String fileName = FileBrowser.chooseFile(true); try { Scanner input = new Scanner(new File(fileName)); String s; while (input.hasNext()) { s = input.nextLine(); if (s != null) { tree.add(s); } } input.close(); } catch (Exception e) { System.out.println("File load failed"); System.exit(1); } // code to finish setting up entire window: // ------------------------------------------------------------------ setBackgroundColor(new Color(128, 128, 200)); // code to set up camera(s) // ------------------------------------------------------------------ cameras.add(new Camera(10, 50, camw, camh, 0, 100, 0, new Color(255, 200, 255))); cameras.add(new Camera(10, 50 + camh + 10, camw, 20, 0, 100, 0, new Color(255, 255, 255))); // ------------------------------------------------------------------ // start up the animation: super.start(); }
@Override @SuppressWarnings("unchecked") public void setAttribute(String attribute, Object value) throws IOException { if (attribute.equals(PERMISSIONS_NAME)) { setPermissions((Set<PosixFilePermission>) value); return; } if (attribute.equals(OWNER_NAME)) { setOwner((UserPrincipal) value); return; } if (attribute.equals(GROUP_NAME)) { setGroup((GroupPrincipal) value); return; } super.setAttribute(attribute, value); }
/** * constructor * * @param r * @throws java.io.FileNotFoundException */ public FileInputIterator(Reader r, String fileName, boolean reportProgress) throws IOException { this.fileName = fileName; if (fileName.startsWith(PREFIX_TO_INDICATE_TO_PARSE_FILENAME_STRING)) { reader = new BufferedReader(new StringReader(fileName.substring(3))); endOfLineBytes = 1; maxProgress = fileName.length() - PREFIX_TO_INDICATE_TO_PARSE_FILENAME_STRING.length(); } else { reader = new BufferedReader(r, bufferSize); endOfLineBytes = Basic.getNumberOfNonSpaceCharacters(fileName); File file = new File(fileName); if (file.exists()) maxProgress = file.length(); else maxProgress = 10000000; // unknown } setReportProgress(reportProgress); }
private void readField(DeployBeanProperty prop) { // all Enums will have a ScalarType assigned... boolean isEnum = prop.getPropertyType().isEnum(); Enumerated enumerated = get(prop, Enumerated.class); if (isEnum || enumerated != null) { util.setEnumScalarType(enumerated, prop); } // its persistent and assumed to be on the base table // rather than on a secondary table prop.setDbRead(true); prop.setDbInsertable(true); prop.setDbUpdateable(true); Column column = get(prop, Column.class); if (column != null) { readColumn(column, prop); } Expose expose = get(prop, Expose.class); if (expose != null) { prop.setExposeSerialize(expose.serialize()); prop.setExposeDeserialize(expose.deserialize()); } if (prop.getDbColumn() == null) { // No @Column annotation or @Column.name() not set // Use the NamingConvention to set the DB column name String dbColumn = namingConvention.getColumnFromProperty(beanType, prop.getName()); prop.setDbColumn(dbColumn); } GeneratedValue gen = get(prop, GeneratedValue.class); if (gen != null) { readGenValue(gen, prop); } Id id = (Id) get(prop, Id.class); if (id != null) { readId(id, prop); } // determine the JDBC type using Lob/Temporal // otherwise based on the property Class Lob lob = get(prop, Lob.class); Temporal temporal = get(prop, Temporal.class); if (temporal != null) { readTemporal(temporal, prop); } else if (lob != null) { util.setLobType(prop); } Formula formula = get(prop, Formula.class); if (formula != null) { prop.setSqlFormula(formula.select(), formula.join()); } Version version = get(prop, Version.class); if (version != null) { // explicitly specify a version column prop.setVersionColumn(true); generatedPropFactory.setVersion(prop); } Basic basic = get(prop, Basic.class); if (basic != null) { prop.setFetchType(basic.fetch()); if (!basic.optional()) { prop.setNullable(false); } } else if (prop.isLob()) { // use the default Lob fetchType prop.setFetchType(defaultLobFetchType); } CreatedTimestamp ct = get(prop, CreatedTimestamp.class); if (ct != null) { generatedPropFactory.setInsertTimestamp(prop); } UpdatedTimestamp ut = get(prop, UpdatedTimestamp.class); if (ut != null) { generatedPropFactory.setUpdateTimestamp(prop); } if (validationAnnotations) { NotNull notNull = get(prop, NotNull.class); if (notNull != null && isNotNullOnAllValidationGroups(notNull.groups())) { // Not null on all validation groups so enable // DDL generation of Not Null Constraint prop.setNullable(false); } Size size = get(prop, Size.class); if (size != null) { if (size.max() < Integer.MAX_VALUE) { // explicitly specify a version column prop.setDbLength(size.max()); } } } EmbeddedColumns columns = get(prop, EmbeddedColumns.class); if (columns != null) { if (prop instanceof DeployBeanPropertyCompound) { DeployBeanPropertyCompound p = (DeployBeanPropertyCompound) prop; // convert into a Map String propColumns = columns.columns(); Map<String, String> propMap = StringHelper.delimitedToMap(propColumns, ",", "="); p.getDeployEmbedded().putAll(propMap); CtCompoundType<?> compoundType = p.getCompoundType(); if (compoundType == null) { throw new RuntimeException("No registered CtCompoundType for " + p.getPropertyType()); } } else { throw new RuntimeException( "Can't use EmbeddedColumns on ScalarType " + prop.getFullBeanName()); } } // Want to process last so we can use with @Formula Transient t = get(prop, Transient.class); if (t != null) { // it is not a persistent property. prop.setDbRead(false); prop.setDbInsertable(false); prop.setDbUpdateable(false); prop.setTransient(true); } if (!prop.isTransient()) { EncryptDeploy encryptDeploy = util.getEncryptDeploy(info.getDescriptor().getBaseTableFull(), prop.getDbColumn()); if (encryptDeploy == null || encryptDeploy.getMode().equals(Mode.MODE_ANNOTATION)) { Encrypted encrypted = get(prop, Encrypted.class); if (encrypted != null) { setEncryption(prop, encrypted.dbEncryption(), encrypted.dbLength()); } } else if (Mode.MODE_ENCRYPT.equals(encryptDeploy.getMode())) { setEncryption(prop, encryptDeploy.isDbEncrypt(), encryptDeploy.getDbLength()); } } Index index = get(prop, Index.class); if (index != null) { if (hasRelationshipItem(prop)) { throw new RuntimeException("Can't use Index on foreign key relationships."); } prop.setIndexed(true); prop.setIndexName(index.value()); } }
public Type navigateQualified(String name, Type[] qualifiers) throws OclTypeException { Type theQualifier = null; if (qualifiers != null) { if (qualifiers.length == 1) theQualifier = qualifiers[0]; else throw new OclTypeException("ReflectionFacade can handle one qualifier only"); } // System.out.println("ClassAny.navigateQualified:"+this+" "+name); Type ret = Basic.navigateAnyQualified(name, this, qualifiers); if (ret != null) return ret; String[] javaNames = rf.nameAdapter.getNames(name); Field f = null; for (int i = 0; i < javaNames.length && f == null; i++) { Class nextClass = c; while (nextClass != null && f == null) { try { f = nextClass.getDeclaredField(javaNames[i]); } catch (NoSuchFieldException nsf) { // try next class } nextClass = nextClass.getSuperclass(); } } if (f == null) { throw new OclTypeException(c.getName() + " has no field " + name); } Class type = f.getType(); Type modeltype = getTypeForClass(type); if (modeltype instanceof Collection) { Class elementtype = rf.getElementType(f); if (rf.reflAdapter.isMap(type)) { if (theQualifier == null) { if (elementtype != null) return new Collection( ((Collection) modeltype).getCollectionKind(), getTypeForClass(elementtype)); else return modeltype; } else { Class keytype_class = rf.getKeyType(f); Type keytype = null; if (keytype_class != null) keytype = getTypeForClass(keytype_class); if (keytype != null) { if (!theQualifier.equals(keytype)) throw new OclTypeException( "feature " + name + " in classifier " + c + ": expected qualifier type " + keytype + " found " + theQualifier + "."); if (elementtype != null) return getTypeForClass(elementtype); else throw new OclTypeException( "feature " + name + "[" + keytype + "] in classifier " + c + " has no @element-type tag."); } else throw new OclTypeException( "feature " + name + " in classifier " + c + ": qualified with type " + theQualifier + ", but feature has no @keytype tag."); } } else { if (theQualifier != null) throw new OclTypeException( "feature " + name + " in classifier " + c + " cannot be qualified."); if (elementtype != null) return new Collection( ((Collection) modeltype).getCollectionKind(), getTypeForClass(elementtype)); else return modeltype; } } else { if (theQualifier != null) throw new OclTypeException( "feature " + name + " in classifier " + c + " cannot be qualified."); return modeltype; } }
public Type navigateParameterized(String name, Type[] params) throws OclTypeException { Type ret = Basic.navigateAnyParameterized(name, params); if (ret != null) return ret; Method foundmethod = null; // this is very similar to tudresden.ocl.lib.OclAnyImpl.findMethod // if you find a bug here, its probably there as well. // suprisingly one has not to go after interfaces since methods // inherited from interfaces are automatically included into the // implementing class. This does not happen for methods inherited // from the superclass, so we have to ascend to all superclasses. // unfortunately the above is only true for classes, getSuperclass invoked // on an interface returns null, regardless of the interfaces extended by the // interface. Therefore, we need to check out getInterfaces() if iclass is // an interface HashSet hsVisited = new HashSet(); LinkedList llToVisit = new LinkedList(); if (c.isInterface()) { // as we're dealing with actual instances, it can be assumed that Object is // a superclass llToVisit.add(java.lang.Object.class); } classloop: for (Class iclass = c; iclass != null; ) // iclass=iclass.getSuperclass()) { Method[] methods = iclass.getDeclaredMethods(); methodloop: for (int i = 0; i < methods.length; i++) { if (!name.equals(methods[i].getName())) continue methodloop; Class[] methodparams = methods[i].getParameterTypes(); if (params.length != methodparams.length) continue methodloop; System.err.print("Checking method " + name + " ("); for (int j = 0; j < methodparams.length; j++) { if (j != 0) { System.err.print(", "); } System.err.print(methodparams[j]); } System.err.println(")"); for (int j = 0; j < params.length; j++) if (!params[j].conformsTo(getTypeForClass(methodparams[j]))) { System.err.println("No conformance for paramter # " + j); continue methodloop; } if (foundmethod == null) foundmethod = methods[i]; else throw new OclTypeException("ambigious method " + name + " of " + c + ") queried."); break classloop; } // determine classes to be visited if (iclass.isInterface()) { Class[] ca = iclass.getInterfaces(); for (int i = 0; i < ca.length; i++) { if (!hsVisited.contains(ca[i])) { llToVisit.add(ca[i]); } } } else { if (!hsVisited.contains(iclass.getSuperclass())) { llToVisit.add(iclass.getSuperclass()); } } // mark current class visited hsVisited.add(iclass); // go to next class if (!llToVisit.isEmpty()) { iclass = (Class) llToVisit.remove(0); } else { iclass = null; } } if (foundmethod == null) { StringBuffer sb = new StringBuffer(); sb.append(c.toString() + " has no method " + name + " with parameters ("); for (int i = 0; i < params.length; i++) { if (i != 0) sb.append(", "); sb.append(params[i] + "/" + params[i]); } sb.append(")"); throw new OclTypeException(sb.toString()); } return getTypeForClass(foundmethod.getReturnType()); }
@Override public void init() { super.init(); resetCollisionListener(); resetTargets(); }
public String getDataTableXML(String xmlStr) { String outstr = ""; Document doc; Element rootNode, child; ConnectionManager cm = ConnectionManager.getInstance(); try { cm.get(); Reader reader = new StringReader(xmlStr); SAXBuilder ss = new SAXBuilder(); doc = ss.build(reader); rootNode = doc.getRootElement(); List list = rootNode.getChildren(); Element childRoot = (Element) list.get(0); DBGrid dbGrid = new DBGrid(); dbGrid.setGridID(childRoot.getAttributeValue("id")); dbGrid.setGridType(childRoot.getAttributeValue("gridType")); dbGrid.setfieldSQL(childRoot.getAttributeValue("SQLStr")); dbGrid.setfieldcn(childRoot.getAttributeValue("fieldCN")); dbGrid.setenumType(childRoot.getAttributeValue("enumType")); dbGrid.setvisible(childRoot.getAttributeValue("visible")); dbGrid.setfieldName(childRoot.getAttributeValue("fieldname")); dbGrid.setfieldWidth(childRoot.getAttributeValue("fieldwidth")); dbGrid.setfieldType(childRoot.getAttributeValue("fieldtype")); dbGrid.setfieldCheck(childRoot.getAttributeValue("fieldCheck")); dbGrid.setcountSQL(childRoot.getAttributeValue("countSQL")); dbGrid.setpagesize(Integer.parseInt(childRoot.getAttributeValue("pageSize"))); dbGrid.setAbsolutePage(Integer.parseInt(childRoot.getAttributeValue("AbsolutePage"))); dbGrid.setRecordCount(Integer.parseInt(childRoot.getAttributeValue("RecordCount"))); dbGrid.setCheck(childRoot.getAttributeValue("checkbl").toLowerCase().trim().equals("true")); dbGrid.setAlign(childRoot.getAttributeValue("tralign")); /* if (childRoot.getAttributeValue("bottomVisible").toLowerCase().equals("true")) dbGrid.setGridBottomVisible(true); else dbGrid.setGridBottomVisible(false); */ // zr if (childRoot.getAttributeValue("bottomVisible").toLowerCase().equals("true")) { dbGrid.setGridBottomVisible(true); // dbGrid.setSumfield(childRoot.getAttributeValue("sumfield")); } else dbGrid.setGridBottomVisible(false); dbGrid.setWhereStr(Basic.decode(childRoot.getAttributeValue("whereStr"))); outstr = dbGrid.getEditDataTable(); // System.out.println(outstr); } catch (JDOMException ex) { System.out.print(ex.getMessage()); } finally { cm.release(); } return outstr; }
public String doExcelHou(String xmlStr, WritableWorkbook wwb) { String outstr = ""; Document doc; Element rootNode, child; // System.out.println(xmlStr); try { Reader reader = new StringReader(xmlStr); SAXBuilder ss = new SAXBuilder(); doc = ss.build(reader); rootNode = doc.getRootElement(); if (rootNode.getAttributeValue("type").equals("lp")) { return getloadspell(rootNode.getText()); } if (rootNode.getAttributeValue("type").equals("lm")) { return getLoadName(rootNode.getText()); } List list = rootNode.getChildren(); Element childRoot = (Element) list.get(0); String fieldTitle = childRoot.getAttributeValue("fieldTitle"); if (rootNode.getAttributeValue("type").equals("enum")) { String enumType = childRoot.getAttributeValue("enumType"); return getEnumType(enumType, fieldTitle); } if (rootNode.getAttributeValue("type").equals("sql")) { String SqlStr = childRoot.getAttributeValue("SqlStr"); DBTable datatable = new DBTable(); return datatable.getDropDownStr(SqlStr, fieldTitle); } if (rootNode.getAttributeValue("type").equals("excel")) { String SqlStr = childRoot.getAttributeValue("SQLStr"); // System.out.println(SqlStr); String whereStr = Basic.decode(childRoot.getAttributeValue("whereStr")); // System.out.println(whereStr); DBTable datatable = new DBTable(); return datatable.getExcel(SqlStr, whereStr); } // ! if (rootNode.getAttributeValue("type").equals("excelhou")) { String SqlStr = childRoot.getAttributeValue("SQLStr"); String fieldCN = childRoot.getAttributeValue("fieldCN"); String fieldType = childRoot.getAttributeValue("fieldType"); String fieldWidth = childRoot.getAttributeValue("fieldWidth"); String visible = childRoot.getAttributeValue("visible"); String enumType = childRoot.getAttributeValue("enumType"); String whereStr = Basic.decode(childRoot.getAttributeValue("whereStr")); DBTable datatable = new DBTable(); return datatable.writeExcel_new( wwb, SqlStr, whereStr, fieldCN, fieldType, fieldWidth, visible, enumType); } if (rootNode.getAttributeValue("type").equals("comboBox")) { String comboBoxID = childRoot.getAttributeValue("comboBoxID"); JOption jOption = new JOption(comboBoxID); String enumType = childRoot.getAttributeValue("enumType"); String titleStr = childRoot.getAttributeValue("titleStr"); String sqlStr = childRoot.getAttributeValue("sqlStr"); String defaultoption = childRoot.getAttributeValue("defaultOption"); String titleVisible = childRoot.getAttributeValue("titleVisible"); String keyVisible = childRoot.getAttributeValue("keyVisible"); if (defaultoption != null) { String[] options = defaultoption.split(",", -2); if (options.length == 2) { jOption.addOption(options[0], options[1]); } } if (titleVisible.toLowerCase().trim().equals("false")) jOption.setTitleVisible(false); if (keyVisible.toLowerCase().trim().equals("false")) jOption.setKeyVisible(false); jOption.setEnumType(enumType); jOption.setSQlStr(sqlStr); jOption.setTitleStr(titleStr); return jOption.getDropHtml(); } } catch (JDOMException ex) { System.out.print(ex.getMessage()); } return outstr; }
@Override public void setParent(KObject newParent) { super.setParent(newParent); resetCollisionListener(); }
public static void main(String[] args) { Basic print_basic = new Basic(); print_basic.erase(); print_basic.show(); }