public static int getPartsHeight(Part[] parts) { int dimension = 0; for (Part part : parts) { dimension += part.height(); } return dimension; }
private LanguageNode handleOrFunction(FunctionCall fc) { ArrayList<Part> subparts = new ArrayList<Part>(); for (ExpressionNode en : fc.getParameters()) { Part p = state.get(en); if (p == null) { broadening(); return fc; } subparts.add(p); } // now to figure out what we have. we may have a a bunch of incomplete subexprs, // in which case we took a = 1 or a = 2 or a = 3 => a part collection of incompletes // or we may have (a = 1 and b = 2) or (a =3 and b =4) ... - likewise // or they maybe complete. regardless, just build a partcollection and move on. // sort subparts by table key; if there's more than one let's just set broadening for now TableKey tk = null; for (Part p : subparts) { if (tk == null) tk = p.getTableKey(); else if (!tk.equals(p.getTableKey())) { broadening(); return fc; } } OredParts op = parent.buildOredParts(fc, subparts); if (op.isComplete()) setComplete(op); state.put(fc, op); return fc; }
/** * Display the jMusic Phrase in a ShowScore window, at the specified x <br> * and y coordinates, measured in pixels. * * @param Phrase * @param xLoc the left-right location of the window * @param yLoc the up-down location of the window */ public static void sketch(Phrase phr, int xLoc, int yLoc) { Score s = new Score("Phrase: " + phr.getTitle()); Part p = new Part(); p.addPhrase(phr); s.addPart(p); new SketchScore(s, xLoc, yLoc); }
private LanguageNode handleInFunction(FunctionCall fc) { ExpressionNode lhs = fc.getParameters().get(0); if (EngineConstant.COLUMN.has(lhs) && parent.isQualifyingColumn((ColumnInstance) lhs)) { // only matches if all the rhs are constant for (ExpressionNode en : fc.getParameters(1)) { if (!EngineConstant.CONSTANT.has(en)) return fc; } ColumnInstance ci = (ColumnInstance) lhs; if (!parent.isQualifyingColumn(ci.getPEColumn())) return fc; ArrayList<ExpressionNode> subexprs = new ArrayList<ExpressionNode>(); ArrayList<Part> parts = new ArrayList<Part>(); for (ExpressionNode en : fc.getParameters(1)) { ColumnInstance tci = (ColumnInstance) ci.copy(null); ConstantExpression litex = (ConstantExpression) en; ExpressionNode subeq = new FunctionCall(FunctionName.makeEquals(), tci, litex); Part p = buildPart(subeq, tci, litex); parts.add(p); subexprs.add((ExpressionNode) p.getParent()); } if (subexprs.size() > 1) { FunctionCall orcall = new FunctionCall(FunctionName.makeOr(), subexprs); OredParts pc = parent.buildOredParts(orcall, parts); if (pc.isComplete()) setComplete(pc); orcall.setGrouped(); state.put(orcall, pc); return orcall; } else { Part p = parts.get(0); return p.getParent(); } } return fc; }
public static int getPartsWidth(Part[] parts) { int dimension = 0; for (Part part : parts) { dimension = (part.width() > dimension) ? part.width() : dimension; } return dimension; }
@Override public String toJpdl() throws InvalidModelException { StringWriter jpdl = new StringWriter(); jpdl.write(" <esb"); jpdl.write(JsonToJpdl.transformAttribute("name", name)); try { jpdl.write(JsonToJpdl.transformRequieredAttribute("category", category)); jpdl.write(JsonToJpdl.transformRequieredAttribute("service", service)); } catch (InvalidModelException e) { throw new InvalidModelException("Invalid Esb activity. " + e.getMessage()); } if (bounds != null) { jpdl.write(bounds.toJpdl()); } else { throw new InvalidModelException("Invalid ESB activity. Bounds is missing."); } jpdl.write(" >\n"); for (Part p : part) { jpdl.write(p.toJpdl()); } for (Transition t : outgoings) { jpdl.write(t.toJpdl()); } jpdl.write(" </esb>\n\n"); return jpdl.toString(); }
/** * Display the jMusic CPhrase in a piano roll window * * @param CPhrase * @param xLoc the left-right location of the window * @param yLoc the up-down location of the window */ public static void pianoRoll(CPhrase cphr, int xLoc, int yLoc) { Score s = new Score("Phrase: " + cphr.getTitle()); Part p = new Part(); p.addCPhrase(cphr); s.addPart(p); new ShowScore(s, xLoc, yLoc); }
public void update(long dtime) { super.update(dtime); if (this.health == 0 && this.dead == false) { if (this == Gamestate.getInstance().getPlayer()) { this.setController(new NoController()); } SOUNDS.TANK_EXPLODE.play(); Vector3f bpos = new Vector3f(this.getBase().getPos()); Gamestate.getInstance().addObject(new ExplosionCluster(bpos, new Vector3f(0, 1.2f, 0), 20)); this.setController(new NoController()); this.dead = true; this.base.unjoin(this.turret); this.parts.remove(this.turret); } else { lastFired++; Vector2f lookdir = turret.getPhys().getDir(); if (lookdir.y > 25.0f) lookdir.y = 25.0f; if (lookdir.y < -25.0f) lookdir.y = -25.0f; if (lookdir.x > 55.0f) lookdir.x = 55.0f; if (lookdir.x < -55.0f) lookdir.x = -55.0f; turret.getPhys().setDir(lookdir); } }
public static void main(String[] args) { Phrase phr = new Phrase(); // create a random walk int pitch = 60; for (int i = 0; i < 12; i++) { Note n = new Note(pitch += (int) (Math.random() * 8 - 4), SQ * (int) (Math.random() * 2 + 1)); phr.addNote(n); } // repeat the whole thing three times Mod.repeat(phr, 3); // see the result at this stage View.show(phr); // repeat beats 2 - 4 three times Mod.repeat(phr, 3, 2.0, 4.0); // see the result of this change View.show(phr, 50, 50); // hear the result Part p = new Part(); Score s = new Score(); p.addPhrase(phr); s.addPart(p); s.setTempo(140.0); Play.midi(s, false); // false so that it doesn't close everything, the view.show() window // in particular Write.midi(s, "Repeat.mid"); }
/** * Create the entity by combining the stored key and data. This "tricky" binding returns the * stored data as the entity, but first it sets the transient key fields from the stored key. */ public Object entryToObject(TupleInput keyInput, Object dataInput) { String number = keyInput.readString(); Part part = (Part) dataInput; part.setKey(number); return part; }
protected TableKey assertSingleTableKey(List<Part> comps) { TableKey tk = null; for (Part p : comps) { if (tk == null) tk = p.getTableKey(); else if (!tk.equals(p.getTableKey())) throw new SchemaException(Pass.PLANNER, "Mixed table keys for key collector"); } return tk; }
public void write(Path path, ByteArrayOutputStream os) throws IOException { boolean first = true; for (Part p : path.parts) { if (!first) { path_seperator.writeTo(os); } new AsciiBuffer(p.toString(this)).writeTo(os); first = false; } }
private void notifyFocusListeners() { Part f = project.getPartSelection().getFocus(); if (f == null) { return; } if (f.getLane() == this) { project.getPartSelection().setDirty(); project.getPartSelection().notifyListeners(); } }
public void displayPartMenu(String type) throws DataException { ArrayList<Part> list = partCtrl.retrieveAvailablePartsByType(type); System.out.println(); System.out.println("== BattleStations :: Le Part :: " + type + " =="); for (int i = 0; i < list.size(); i++) { Part p = list.get(i); System.out.println((i + 1) + ". " + p.getName() + " (min: L" + p.getLvlReq() + ")"); } System.out.print("[R]eturn to main | Enter number > "); }
public void transform() { // Bird for (int i = 0; i < bird_num; i++) { note = new Note( bird_jnote[i].pitch, (double) bird_jnote[i].duration / 120, bird_jnote[i].velocity); bird_phrase.addNote(note); } bird_phrase.setStartTime(start_time * 4.0); bird_part.empty(); bird_part.addPhrase(bird_phrase); }
public void startMultipart(BodyDescriptor bd) { expect(Part.class); Part e = (Part) stack.peek(); try { MimeMultipart multiPart = new MimeMultipart(e.getContentType()); e.setBody(multiPart); stack.push(multiPart); } catch (MessagingException me) { throw new Error(me); } }
/** * Converts the path back to the string representation. * * @return */ public String toString(Path path) { StringBuffer buffer = new StringBuffer(); boolean first = true; for (Part p : path.parts) { if (!first) { buffer.append(path_seperator); } buffer.append(p.toString(this)); first = false; } return buffer.toString(); }
private void combineParts( MultiMap<Part, ColumnKey> needed, MultiMap<ColumnKey, Part> classified, List<ExpressionNode> andexprs, List<Part> andparts) { Part p = needed.keySet().iterator().next(); Collection<ColumnKey> missing = needed.get(p); if (missing == null || missing.isEmpty()) { andexprs.add((ExpressionNode) p.getParent()); needed.remove(p); andparts.add(p); return; } ListSet<Part> containingMissing = new ListSet<Part>(); boolean first = true; for (ColumnKey ck : missing) { Collection<Part> matching = classified.get(ck); if (matching == null || matching.isEmpty()) continue; if (first) containingMissing.addAll(matching); else { containingMissing.retainAll(matching); } } if (containingMissing.isEmpty()) { andexprs.add((ExpressionNode) p.getParent()); andparts.add(p); needed.remove(p); } else { ListSet<Part> toCombine = new ListSet<Part>(); toCombine.add(p); toCombine.addAll(containingMissing); ListSet<Part> toRemove = new ListSet<Part>(); toRemove.addAll(toCombine); Part clhs = choosePartForAndCombo(toCombine); toCombine.remove(clhs); while (!toCombine.isEmpty()) { Part crhs = choosePartForAndCombo(toCombine); toCombine.remove(crhs); clhs = combineParts(clhs, crhs); } for (Part rp : toRemove) { needed.remove(rp); ArrayList<ColumnKey> classKeys = new ArrayList<ColumnKey>(classified.keySet()); for (ColumnKey ck : classKeys) { Collection<Part> sub = classified.get(ck); if (sub == null || sub.isEmpty()) continue; if (sub.contains(rp)) classified.remove(ck, rp); } } andexprs.add((ExpressionNode) clhs.getParent()); andparts.add(clhs); } }
public Map<String, Construct> evaluate(BindableEvent e) throws EventException { Map<String, Construct> retn = new HashMap<String, Construct>(); if (e instanceof Part) { Part msg = (Part) e; retn.put("id", new CString(msg.getBot().getID(), Target.UNKNOWN)); retn.put("who", new CString(msg.getWho(), Target.UNKNOWN)); retn.put("channel", new CString(msg.getChannel(), Target.UNKNOWN)); } return retn; }
@RequestMapping(method = RequestMethod.PUT) public void addPart( @RequestParam("partid") Long pId, @RequestParam("partdesc") String pDesc, @RequestParam("productiondate") Date pDate) { LOG.log(Level.INFO, "PUT request"); Part p = new Part(); p.partid = pId; p.partdesc = pDesc; p.productiondate = pDate; mParts.add(p); mMap.put(mParts.indexOf(p), p.partid); LOG.fine(new Date() + " POST Insert\t" + p.toString()); }
private Part buildNewMultiMultiPart(OredParts lp, OredParts rp) { ArrayList<Part> newParts = new ArrayList<Part>(); for (Part lpc : lp.getParts()) { for (Part rpc : rp.getParts()) { newParts.add(combineParts(lpc.copy(), rpc.copy())); } } FunctionCall orcall = new FunctionCall( FunctionName.makeOr(), Functional.apply(newParts, Part.castToExpression)); OredParts op = parent.buildOredParts(orcall, newParts); if (op.isComplete()) setComplete(op); return op; }
private Part combineParts(Part lp, Part rp) { if (!(lp instanceof OredParts) && !(rp instanceof OredParts)) { return buildNewComplexPart(lp, rp); } else if (lp instanceof OredParts && rp instanceof OredParts) { return buildNewMultiMultiPart((OredParts) lp, (OredParts) rp); } else if (lp instanceof OredParts && !(rp instanceof OredParts)) { return buildNewPartCollection((OredParts) lp, rp); } else if (!(lp instanceof OredParts) && rp instanceof OredParts) { return buildNewPartCollection((OredParts) rp, lp); } else { throw new SchemaException( Pass.PLANNER, "Can't combine parts: " + lp.getClass().getName() + " and " + rp.getClass().getName()); } }
@Autowired @Consumes(MediaType.APPLICATION_JSON) @RequestMapping(method = RequestMethod.DELETE) public void deletePart( @RequestParam("partid") Long pId, @RequestParam("partdesc") String pDesc, @RequestParam("productiondate") Date pDate) { Part p = new Part(); p.partid = pId; p.partdesc = pDesc; p.productiondate = pDate; mMap.remove(mParts.indexOf(p)); mParts.remove(p); LOG.fine("Delete "); }
protected ListSet<Part> getCompletedParts() { if (stopped) return null; ListSet<Part> cols = new ListSet<Part>(); for (Part p : completedParts) { if (p instanceof OredParts) cols.add(p); } completedParts.removeAll(cols); for (Part p : cols) { for (Part sp : p.getParts()) { completedParts.remove(sp); } } completedParts.addAll(cols); return completedParts; }
/** * Constructor for deepClone * * @param cloneMe */ private MidiLane(MidiLane cloneMe) { super("Copy of " + cloneMe.getName(), cloneMe.project); trackHeaderPart = (MidiPart) (cloneMe.trackHeaderPart.deepCopy(null)); trackHeaderPart.lane = this; midiDeviceIndex = cloneMe.midiDeviceIndex; midiChannel = cloneMe.midiChannel; keyNames = cloneMe.keyNames; for (Part part : cloneMe.getParts()) { part.deepCopy(this); } ftw = cloneMe.ftw.getSequence().createFrinikaTrack(); ftw.setMidiChannel(midiChannel); setUpKeys(); }
private MultiPartIterator(List<Part> parts) { this.parts = parts; if (parts.isEmpty()) { iterator = Stream.of(onlyBoundary.slice()).iterator(); } else { List<ByteBuffer> list = new ArrayList<>(); for (int i = 0; i < parts.size(); ++i) { Part part = parts.get(i); if (i == 0) list.add(firstBoundary.slice()); else list.add(middleBoundary.slice()); list.addAll(part.getByteBuffers()); } list.add(lastBoundary.slice()); iterator = list.iterator(); } }
@Override public void fix() { super.fix(); if (null != unit) { unit.repairSystem(CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_COCKPIT); } }
private LanguageNode handleEqualsFunction(FunctionCall fc) { ExpressionNode lhs = fc.getParameters().get(0); ExpressionNode rhs = fc.getParameters().get(1); if (EngineConstant.CONSTANT.has(rhs) && EngineConstant.COLUMN.has(lhs) && parent.isQualifyingColumn((ColumnInstance) lhs)) { ColumnInstance ci = (ColumnInstance) lhs; ConstantExpression litex = (ConstantExpression) rhs; PEColumn c = ci.getPEColumn(); if (parent.isQualifyingColumn(c)) { Part p = buildPart(fc, ci, litex); return p.getParent(); } } return fc; }
@Override public void handle(Request request, Response response) throws Exception { userSession.checkPermission(GlobalPermissions.SYSTEM_ADMIN); Part part = request.mandatoryParamAsPart(PARAM_FILE); String fileName = part.getFileName(); checkArgument(fileName.endsWith(".jar"), "Only jar file is allowed"); InputStream inputStream = part.getInputStream(); try { File destPlugin = new File(downloadDir, fileName); Files.copy(inputStream, destPlugin.toPath(), REPLACE_EXISTING); response.noContent(); } finally { closeQuietly(inputStream); } }
@RequestMapping(method = RequestMethod.POST) public void updatePart( @RequestParam("partid") Long pId, @RequestParam("partdesc") String pDesc, @RequestParam("productiondate") Date pDate, @RequestParam("param1") int recId) { LOG.log(Level.INFO, "POST request"); Part p = new Part(); p.partid = pId; p.partdesc = pDesc; p.productiondate = pDate; LOG.fine(new Date() + " PUT update\t" + p.toString() + "\trec=" + recId); if (recId > 0) { mParts.add(recId, p); } }