/** * Redistributes the net reactions based on the current core and edge reaction models. Especially * useful when one or more species has been moved from the edge to the core since the last * pressure-dependent calculation. * * @param cerm The current core/edge reaction model */ public void updateReactionLists(CoreEdgeReactionModel cerm) throws PDepException { // Merge the net reaction and nonincluded reactinon lists together // We will recalculate how to distribute them LinkedList<PDepReaction> reactionList = new LinkedList<PDepReaction>(); for (int i = 0; i < netReactionList.size(); i++) { PDepReaction rxn = netReactionList.get(i); reactionList.add(rxn); } for (int i = 0; i < nonincludedReactionList.size(); i++) { PDepReaction rxn = nonincludedReactionList.get(i); reactionList.add(rxn); } netReactionList.clear(); nonincludedReactionList.clear(); for (int i = 0; i < reactionList.size(); i++) { PDepReaction forward = reactionList.get(i); PDepReaction reverse = (PDepReaction) forward.getReverseReaction(); if (forward == null) throw new PDepException( "Encountered null forward reaction while updating PDepNetwork reaction lists."); else if (reverse == null) throw new PDepException( "Encountered null reverse reaction while updating PDepNetwork reaction lists."); if (forward.isCoreReaction(cerm) || reverse.isCoreReaction(cerm)) netReactionList.add(forward); else if (forward.getReactant().getIncluded() && forward.getProduct().getIncluded()) netReactionList.add(forward); else nonincludedReactionList.add(forward); } }
public static void readOneLineFromFile() throws RuntimeException { // TODO: read 1 line of the file LinkedList<String> stringsOfFile = FileManager.readFromFile(); // Each line contains, type, question, answer if (stringsOfFile == null) { System.out.println("Line read from file is null"); throw new RuntimeException("File doesn't exist"); } System.out.println("This list has " + stringsOfFile.size() + " strings"); for (int i = 0; i < stringsOfFile.size() - 1; ) { Wrapper current = new Wrapper(); // Put the linked list to the wrapper class consecutively current.questionType = stringsOfFile.get(i++); current.question = stringsOfFile.get(i++); current.answer = stringsOfFile.get(i++); // Add this question to the question collection questionCollection.add(current); } // Load the first question currentQuestion = questionCollection.get(currentQuestionIndex); // Update the question count questionCount = questionCollection.size(); // Parse the line System.out.println("Finished parsing file"); }
public JLocalVariable getLocalVariable(int index) { for (int i = 0; i < localVariables.size(); i++) { if (((JLocalVariable)localVariables.get(i)).index == index) return (JLocalVariable)localVariables.get(i); } return null; }
/** * this method removes the last element of the formula, and returns whether the element removed is * an operator or an input: * * @return true if it is an operator, false otherwise * @exception SyntaxErrorException TO COMMENT FURTHER */ public boolean removeFromFormula() throws SyntaxErrorException { boolean isOperator = true; TreeCell currentCell; if (nextEntry == 0) // only one value { currentCell = opList.get(0); } else if ((nextEntry < opList.size()) && (opList.get(nextEntry).getstatusCell() != TreeCell.NOT_COMPLETED)) { currentCell = opList.get(nextEntry); } else { currentCell = opList.get(nextEntry - 1); // get the current cell that we will be using } try { isOperator = currentCell.removeInCell(); if (!isOperator) this.removeLeaveTotal(); if (currentCell.getstatusCell() == TreeCell.NOT_COMPLETED) { if (nextEntry > 0) nextEntry--; if (nextEntry < opList.size()) opList.remove(currentCell); } else if ((currentCell.getstatusCell() == TreeCell.LEFT_COMPLETED)) nextEntry = this.opList.size(); else if (nextEntry < opList.size()) { nextEntry++; } return isOperator; } catch (SyntaxErrorException e) { throw e; } }
public void actionPerformed(ActionEvent event) { int i; JButton aux = (JButton) event.getSource(); if (aux == closeCompra) { try { String[] information = { JOptionPane.showInputDialog(null, "nombre"), JOptionPane.showInputDialog(null, "numero de targeta") }; ObjectOutputStream oos = new ObjectOutputStream(client.getOutputStream()); oos.writeObject(information); oos.flush(); oos.writeObject(products); oos.flush(); oos.writeObject(comprados); oos.flush(); cleanTable(); comprados.clear(); } catch (Exception e) { System.out.print("\nerror al cerrar la compra " + e.getMessage()); } return; } for (i = 0; aux != mostrador.addCar[i]; i++) {; } if (products.get(i).getPiesas() > 0) { products.get(i).popParts(); addCompra(products.get(i)); total.setText("total: " + comprados.getLast().getTotal()); } else { JOptionPane.showMessageDialog(null, "no seas menso ya no hay mas piesas! :@"); } }
public LinkedList<Trigger> listaTrigger(String nombreT, Connection con) throws SQLException { Statement s = con.createStatement(); LinkedList<Trigger> lT = new LinkedList(); LinkedList<String> nombTrigger = nombreTrigger(nombreT, s); ResultSet rs; String disparador = null; for (int i = 0; i < nombTrigger.size(); i++) { LinkedList<String> condTrigger = new LinkedList(); rs = s.executeQuery( "SELECT event_manipulation,action_timing FROM information_schema.triggers where trigger_name ='" + nombTrigger.get(i) + "' order by event_manipulation"); int u = 0; while (rs.next()) { u++; } rs = s.executeQuery( "SELECT event_manipulation,action_timing FROM information_schema.triggers where trigger_name ='" + nombTrigger.get(i) + "' order by event_manipulation"); while (rs.next()) { disparador = rs.getObject("action_timing").toString(); condTrigger.add(rs.getObject("event_manipulation").toString()); // System.out.println("COND "+nombTrigger.get(i)+" - // "+rs.getObject("event_manipulation").toString()); } lT.add(new Trigger(nombTrigger.get(i), condTrigger, disparador)); } s.close(); return lT; }
static void run(String[] args) throws IOException { Instruction.genSSA(); Parser p = new Parser(args[0]); p.startParse(); ControlFlowGraph cfg = p.getCFG(); VariableSet varSet = p.getVarSet(); VCGCreator normVcg = new VCGCreator(args[0], cfg); normVcg.run(); if (cp) { CopyPropagation g = new CopyPropagation(p); g.runCP(); p.getCFG().print(); VCGCreator cpVcg = new VCGCreator(args[0], cfg, "CP"); cpVcg.run(); } if (cse) { CSE cse = new CSE(p.getCFG()); cse.runCSE(); p.getCFG().print(); String addName = "CSE"; if (cp) addName = "CP" + addName; VCGCreator cseVcg = new VCGCreator(args[0], cfg, addName); cseVcg.run(); } LiveTime lt = new LiveTime(cfg); lt.analysisLiveTime(); int maxReg = 8; if (dlxreg) maxReg = 27; LinearScan allocator = new LinearScan(lt.getLr(), maxReg); allocator.allocate(); StaticSingleAssignment.setShowType(StaticSingleAssignment.showREG); allocator.regAllocate(cfg); VCGCreator regVCG = new VCGCreator(args[0], cfg, true, "REG"); regVCG.run(); DLXCodeGeneration codeGen = new DLXCodeGeneration(varSet, cfg); LinkedList<Location> lsp = allocator.getSp1Sp2(); codeGen.setSpillRegister(lsp.get(0), lsp.get(1)); codeGen.assembleDLX(); StaticSingleAssignment.setShowType(StaticSingleAssignment.showAsm); varSet.printLayout(); VCGCreator asmVCG = new VCGCreator(args[0], cfg, true, "ASM"); asmVCG.run(); if (simulator) { DLXCode exe = new DLXCode(codeGen); exe.asmToBinary(); int[] program = exe.getProgram(); if (debug) { DLXdebuger.load(program); DLXdebuger.debugExecute(); } else { DLX.load(program); DLX.execute(); } } }
// Skapar de grafiska komponenterna för menyn public void createLabels() { // Skapar textfält för nick och intellegens och lägger till dem i en lista for (int i = 0; i < 4; i++) { textfields.add(new JTextField(20)); intfields.add(new JTextField(20)); } // Skapar checkboxes för att bestämma om spelaren är ett AI och lägger till den i en lista for (int i = 0; i < 4; i++) { boxes.add(new JCheckBox()); boxes.get(i).addActionListener(this); } // Lägger till labels med förbestämd text i panelen for (int i = 0; i < 4; i++) { panel.add(new JLabel(labeltext[i])); } // Lägger till textfields och checkboxes i panelen for (int i = 4; i < 8; i++) { panel.add(new JLabel(labeltext[i])); panel.add(textfields.get(i - 4)); panel.add(boxes.get(i - 4)); panel.add(intfields.get(i - 4)); intfields.get(i - 4).setVisible(false); } // Lägger till några tomma labels i panelen för att skapa mellanrum och symetri for (int i = 0; i < 5; i++) { panel.add(new JLabel(" ")); } // Lägger till knapparna och lägger actionlisteners på dem panel.add(go); go.addActionListener(this); panel.add(help); help.addActionListener(this); }
/** * Notification that its safe to update the node now with any operations that could potentially * effect the node's bounds. * * @param src The node or Node Component that is to be updated. */ public void updateNodeBoundsChanges(Object src) { Node kid; int size = (removedChildren == null) ? 0 : removedChildren.size(); for (int i = 0; i < size; i++) { kid = (Node) removedChildren.get(i); implGroup.removeChild(kid); } size = (addedChildren == null) ? 0 : addedChildren.size(); for (int i = 0; i < size; i++) { kid = (Node) addedChildren.get(i); implGroup.addChild(kid); } addedChildren.clear(); removedChildren.clear(); if (maskChanged) { implGroup.setMask(vfVisible); maskChanged = false; } }
protected void listMouseClicked(EventObject e) { for (ListLevel listLevelTuple : depthLists) { listLevelTuple.list.setCellRenderer(new SceneDepthListCellRender()); } JList list = (JList) e.getSource(); selectedScene = (Scene) list.getSelectedValue(); jumpToBt.setEnabled(true); jumpToBt.setText("Jump to [" + selectedScene.getName() + "]"); int idx = depthLists.indexOf(new ListLevel(-1, list)); assert idx != -1 : "Should have found a scenesList"; if (idx == 0) { JList startList = depthLists.get(1).list; startList.setCellRenderer(new ToCellRenderer(selectedScene)); Util.showComponent(startList); } else if (idx > 0) { JList fromList = depthLists.get(idx - 1).list; logger.debug("Before: " + fromList.getSelectedValue()); fromList.setCellRenderer(new FromCellRenderer(selectedScene)); Util.showComponent(fromList); if (idx + 1 < depthLists.size()) { JList afterList = depthLists.get(idx + 1).list; logger.debug("After: " + afterList.getSelectedValue()); afterList.setCellRenderer(new ToCellRenderer(selectedScene)); Util.showComponent(afterList); } } Util.showComponent(panel); }
/** * Détermine si la forme engendrée par les 3 cases représente un bateau correct ou non * * @param lc * @return */ private boolean isBoatCorrect(LinkedList<Case> lc) { if (lc.size() != 3) return false; // Order the list LinkedList<Case> nlc = new LinkedList<Case>(); for (Entry<String, Integer> en : this.matchKeys.entrySet()) for (Case c : lc) if (c.getName().equals(en.getKey())) nlc.add(c); String firstCase = nlc.get(0).getName(); String secondCase = nlc.get(1).getName(); String thirdCase = nlc.get(2).getName(); List<String[]> rows = new ArrayList<String[]>(); rows.add(this.numbersRowTitles); rows.add(this.firstRowTitles); rows.add(this.secondRowTitles); rows.add(this.thirdRowTitles); for (int i = 0; i < rows.size(); i++) { if (getIndexOf(rows.get(i), firstCase) != -1) return this.checkRow(rows, i, firstCase, secondCase, thirdCase); } return false; }
private static LinkedList<Coords> polarSort(LinkedList<Coords> list) { // find point with lowest x-coord int i = 0; double lowest = 9999999999.0; int lowIndex = 0; Coords tmp; while (i < list.size()) { tmp = list.get(i); if (tmp.getX() < lowest) { lowest = tmp.getX(); lowIndex = i; } else if (tmp.getX() == lowest) { if (tmp.getY() < list.get(lowIndex).getY()) { lowIndex = i; } } i++; } Coords lowestCoord = list.remove(lowIndex); LinkedList<Coords> sorted = new LinkedList<Coords>(); sorted.add(list.poll()); while (list.size() > 0) { tmp = list.poll(); i = sorted.size(); while (i > 0 && compVect(lowestCoord, sorted.get(i - 1), tmp) < 0.0) { i--; } sorted.add(i, tmp); } sorted.add(0, lowestCoord); return sorted; }
/** * Removes the specified module from the registry AND the simulation bus. * * @param index Index of the module to be removed. * @param sim Simulation core that is being run. */ public int removeModule(int index) { if (index >= modules.size() || index < 0) { return Msg.E("removeModule: invalid index:" + index, Constants.PLP_GENERIC_ERROR, null); } plp.sim.bus.remove(positionInBus.get(index)); positionInBus.remove(index); if (modules.get(index).threaded && modules.get(index).isAlive()) { modules.get(index).stop = true; } modules.get(index).remove(); modules.remove(index); regSize.remove(index); type.remove(index); if (moduleFrames.get(index) != null && moduleFrames.get(index) instanceof JFrame) ((JFrame) moduleFrames.get(index)).dispose(); moduleFrames.remove(index); // we have to update bus positions for (int i = index; i < positionInBus.size(); i++) { Integer val = positionInBus.get(i); positionInBus.set(i, val - 1); } return Constants.PLP_OK; }
public static String obfuscate(String email) { LinkedList<String> emailList = new LinkedList<>(); // Attack the dots String[] chunks = email.split(Pattern.quote(".")); String[] atChunks = null; int dotCounter = chunks.length - 1; for (int i = 0; i < chunks.length; i++) { emailList.addLast(chunks[i]); if (dotCounter != 0) { emailList.addLast("[.]"); dotCounter--; } } // Attack the @ for (int j = 0; j < emailList.size(); j++) { if (emailList.get(j).contains("@")) { atChunks = emailList.get(j).split(Pattern.quote("@")); emailList.remove(j); emailList.add(j, atChunks[0]); emailList.add(j + 1, "[at]"); emailList.add(j + 2, atChunks[1]); } } System.out.println(toString(emailList)); return toString(emailList); }
public static void main(String[] args) throws IOException { BufferedReader inp = new BufferedReader(new InputStreamReader(System.in)); ArrayList<ArrayList<Pair>> G; int T = Integer.parseInt(inp.readLine()); int startVertex = 0; int graphSize = 50; for (int test = 0; test < T; ++test) { int numberOfEdges = Integer.parseInt(inp.readLine()); G = new ArrayList<ArrayList<Pair>>(); for (int index = 0; index < graphSize; ++index) G.add(new ArrayList<Pair>()); for (int edge = 0; edge < numberOfEdges; ++edge) { String[] tokens = inp.readLine().split("\\s"); int u = Integer.parseInt(tokens[0]); --u; int v = Integer.parseInt(tokens[1]); --v; startVertex = u; G.get(u).add(new Pair(v, 1)); G.get(v).add(new Pair(u, 1)); } System.out.println("Case #" + (test + 1)); if (isEulerian(G)) { LinkedList<Integer> path = new LinkedList<Integer>(); eulerPath(G, path.listIterator(), startVertex); for (int index = 0; index < path.size() - 1; ++index) System.out.println((path.get(index) + 1) + " " + (path.get(index + 1) + 1)); if (path.size() > 0) System.out.println((path.get(path.size() - 1) + 1) + " " + (path.get(0) + 1)); } else System.out.println("some beads may be lost"); if (test != T - 1) System.out.println(); } }
public String createTable(String command) { String db = currentDB(); LinkedList<String> ret = new LinkedList<String>(); String table = command.substring(12, command.length()); table = table.substring(0, table.indexOf(" ")); ret = executeCommand("/tapi /relation_exists " + table); executeCommand("/tapi /use_db " + db); if (ret.get(0).contains("true")) { return "exists"; } else { ret = executeCommand(command); if (ret.get(0).contains("error")) return "error"; return "success"; } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); setContentView(R.layout.detalles_if36); inten = new Intent(this, BBVAfechaj3Activity.class); TextView encabezado = (TextView) findViewById(R.id.resti36); TextView g = (TextView) findViewById(R.id.dgi36); TextView ta = (TextView) findViewById(R.id.dai36); TextView tr = (TextView) findViewById(R.id.dri36); TextView l = (TextView) findViewById(R.id.dlsi36); LinkedList<BBVAfechaj7Activity> list = Bundfechaj9Activity.getInstancia().getListDTODti(getApplicationContext()); if (list.size() != 0) { String result = list.get(35).getDetalle(); String[] r = result.split("/"); if (r.length != 0 && !list.get(35).getDetalle().equalsIgnoreCase(" ")) { encabezado.setText(r[0]); g.setText(r[1]); ta.setText(r[2]); tr.setText(r[3]); l.setText(r[4]); } else if (r.length == 0) { encabezado.setText(" "); g.setText(" "); ta.setText(" "); tr.setText(" "); l.setText(" "); } } else if (list.size() == 0) { Log.d("Error", "No se ha cargado la Base de Dtos"); } }
/** * Creates a new restriction * * @param String restriction * @return String */ public String createRestriction(String restriction) { String db = currentDB(); String command = "/tapi " + restriction; LinkedList<String> res = executeCommand(command); boolean success = true; String result = ""; if (!res.isEmpty()) if (res.get(0).contains("$error")) { success = false; for (int i = 2; i < res.size(); i++) { String aux = res.get(i).trim(); result = result + aux + "\n"; } } executeCommand("/tapi /use_db " + db); if (success) return "$success"; else return result; }
public KMeansResult cluster(double[][] centroids, double[][] instances, double threshold) { int itr = -1; // initialize the result KMeansResult result = new KMeansResult(); LinkedList<Double> distortionList = new LinkedList<Double>(); result.clusterAssignment = new int[instances.length]; boolean completed = false; // loop until finally done while (!completed) { // increment iteration itr++; // call the assignInstance method to assign the instances to centroids assignInstance(centroids, instances, result); // check orphaned centroid boolean noOrphaned = false; while (!noOrphaned) { int orphanNum = -1; orphanNum = checkOrphan(centroids, result); // if the centroid is orphaned, then assign it as scenario requores if (orphanNum >= 0) { assignOrphan(orphanNum, centroids, instances, result); } else { noOrphaned = true; } } // update centroids updateCentroids(centroids, instances, result); // compute new distortion double distortion = calculateDistortion(centroids, instances, result); // track the distortion distortionList.add(distortion); // check whether the algorithm should terminate if (itr > 0 && Math.abs( (distortionList.get(itr) - distortionList.get(itr - 1)) / distortionList.get(itr - 1)) < threshold) { completed = true; } } // set centroids to KMeansResult final centroids array result.centroids = centroids; // initialize result's distortion array result.distortionIterations = new double[distortionList.size()]; // record distortionList into result of distortion array for (int i = 0; i < distortionList.size(); i++) { result.distortionIterations[i] = distortionList.get(i); } return result; }
public boolean pk(String db, String table, LinkedList<String> pk) { String currentDB = currentDB(); LinkedList<String> res = executeCommand("/tapi /use_db " + db); res = executeCommand("/dbschema"); String sPk = ""; for (int i = 0; i < pk.size(); i++) sPk += pk.get(i) + ", "; sPk = sPk.substring(0, sPk.length() - 2); String command = "/tapi :-pk(" + table + ", [" + sPk + "])"; res = executeCommand(command); executeCommand("/tapi /use_db " + currentDB); if (res.size() == 0) return true; if (res.get(0).contains("$error")) return false; return true; }
public void testPainters() throws Exception { LinkedList<Painter> painters = panel.getPainters(); assertEquals(2, painters.size()); assertEquals(BackgroundPainter.class, painters.get(0).getClass()); assertEquals(BorderPainter.class, painters.get(1).getClass()); }
/** * Returns the full name of the view * * @param String database, String view * @return String */ public String getView(String database, String oldView) { String view = ""; String childClear = ""; boolean found = false; int i = 0; LinkedList<String> views = getViews(database); while ((i < views.size()) && (!found)) { String aux = views.get(i); aux = aux.substring(0, aux.indexOf("(")); if (aux.equals(oldView)) { view = views.get(i); found = true; } i++; } if (found) { String[] cleanViews = view.split(","); for (int j = 0; j < cleanViews.length; j++) { if (j == (cleanViews.length - 1)) childClear = childClear + cleanViews[j].substring(0, cleanViews[j].indexOf(":")) + ")"; else childClear = childClear + cleanViews[j].substring(0, cleanViews[j].indexOf(":")) + ","; } } return childClear; }
public void instantiateSpacePoints() { int spaceWidth = this.getWidth() / ((spaceList.size() + 4) / 4); int spaceHeight = this.getHeight() / ((spaceList.size() + 4) / 4); int xpos = 0; int ypos = 0; int pos = 0; for (int i = 0; i <= (spaceList.size() - 1) / 4; i++) { spaceList.get(pos).setPoint(new Point(xpos, ypos)); xpos += spaceWidth; pos++; } for (int i = (spaceList.size() - 1) / 4 + 1; i <= (spaceList.size() - 1) / 2; i++) { spaceList.get(pos).setPoint(new Point(xpos, ypos)); ypos += spaceHeight; pos++; } for (int i = (spaceList.size() - 1) / 2 + 1; i <= (spaceList.size() - 1) * 3 / 4; i++) { spaceList.get(pos).setPoint(new Point(xpos, ypos)); xpos -= spaceWidth; pos++; } for (int i = (spaceList.size() - 1) * 3 / 4 + 1; i <= (spaceList.size() - 1); i++) { spaceList.get(pos).setPoint(new Point(xpos, ypos)); ypos -= spaceHeight; pos++; } }
/** * Returns the type of the view: SQL or RA * * @return String */ public String getViewType(String database, String view) { LinkedList<String> ret = new LinkedList<String>(); ret = executeCommand("/tapi /use_db " + database); ret = executeCommand("/tapi /dbschema " + view); String result = ""; boolean typeFound = false; int i = 0; while (!typeFound && i < ret.size()) { if (ret.get(i).contains("$sql")) { result = "SQL"; typeFound = true; } else if (ret.get(i).contains("$ra")) { result = "RA"; typeFound = true; } i++; } return result; }
// 一个经常使用的函数,当MathSignQueue的一部分由于得出值被化简,则这一部分将被一个具体的实数值替代 public void simplify(int start, int end, MathSign result) { result.setIndex(mMathSigns.get(start).start(), mMathSigns.get(end - 1).end()); while (end-- > start) { mMathSigns.remove(start); } mMathSigns.add(start, result); }
/** * Simplification of the line specified by "points" field. Remainin points are included to "used" * set. * * @param start - starting index * @param end - ending index * @param epsilon - min point-to line distance in pixels (tolerance) * @param depth - recursion level */ private void douglasPeucker(int start, int end, double epsilon, int depth) { if (depth > 500) return; if (end - start < 1) return; // incorrect invocation LatLon first = points.get(start); LatLon last = points.get(end); Point firstp = getPoint(first); Point lastp = getPoint(last); used.add(first); used.add(last); if (end - start < 2) return; int farthest_node = -1; double farthest_dist = 0; double d = 0; for (int i = start + 1; i < end; i++) { d = pointLineDistance(getPoint(points.get(i)), firstp, lastp); if (d > farthest_dist) { farthest_dist = d; farthest_node = i; } } if (farthest_dist > epsilon) { douglasPeucker(start, farthest_node, epsilon, depth + 1); douglasPeucker(farthest_node, end, epsilon, depth + 1); } }
public TraversePointInfo startTraverse(Point hitPoint, float maxDistance) { float distance = 9999, smallestDistance = 9999; nodes = renderNodes; PathNode t = null; for (int i = 0; i < nodes.size(); i++) { distance = nodes.get(i).getLocation().distancePoint2Point(hitPoint); // Helper.printKeyVal("PathNode: ", nodes.get(i).getLocation().toString()); // Helper.printKeyVal("Distance", distance); if (distance < smallestDistance) { // Helper.printKeyVal("New smallest point: ", nodes.get(i).getLocation().toString()); // Helper.printKeyVal("New smallest Distance", distance); smallestDistance = distance; t = nodes.get(i); } } if (smallestDistance > maxDistance) return null; TraversePointInfo info = new TraversePointInfo(); info.setPathNode(t); info.setTraverseLocation(t.getLocation()); info.setDistance(0); distance = 0; for (int i = 0; i < nodes.size(); i++) { if (nodes.get(i).equals(t)) break; distance += nodes.get(i).getRightDistance(); } info.setTotalDistanceInPath(distance); // Helper.printKeyVal("Total Distance Set: ", info.getTotalDistanceInPath()); info.setPath(this); return info; }
public void Draw(Canvas canvas) { canvas.drawBitmap(ret, pos.x, canvas.getHeight() - (pos.y + scale.y), null); // testing line------------------------------------------------// if (state == STATE.DRAGGING) { paint.setColor(Color.RED); paint.setStrokeWidth(10); // From startPos to current dragging pos canvas.drawLine( startPos.x, canvas.getHeight() - startPos.y, fingerPos.x, canvas.getHeight() - fingerPos.y, paint); } // draw the rubbish------------------------------------------// for (int i = 0; i < totalDragged; ++i) { if (rubbishPile.get(i).GetActive()) rubbishPile.get(i).Draw(canvas); } paint.setARGB(255, 255, 0, 0); paint.setStrokeWidth(120); // how thick you want the text to be in terms of pixel paint.setTextSize(60); canvas.drawText("Active: " + totalDragged, 130, 80, paint); bound.DrawDebug(canvas); }
public RC3500_A_IP44_DE( Context context, Long id, String name, LinkedList<Boolean> dips, Long roomId) { super(context, id, name, BRAND, MODEL, TYPE_DIPS, roomId); dipList = new LinkedList<>(); if (dips != null && dips.size() == 10) { dipList.add(new DipSwitch("1", dips.get(0))); dipList.add(new DipSwitch("2", dips.get(1))); dipList.add(new DipSwitch("3", dips.get(2))); dipList.add(new DipSwitch("4", dips.get(3))); dipList.add(new DipSwitch("5", dips.get(4))); dipList.add(new DipSwitch("A", dips.get(5))); dipList.add(new DipSwitch("B", dips.get(6))); dipList.add(new DipSwitch("C", dips.get(7))); dipList.add(new DipSwitch("D", dips.get(8))); dipList.add(new DipSwitch("E", dips.get(9))); } else { dipList.add(new DipSwitch("1", false)); dipList.add(new DipSwitch("2", false)); dipList.add(new DipSwitch("3", false)); dipList.add(new DipSwitch("4", false)); dipList.add(new DipSwitch("5", false)); dipList.add(new DipSwitch("A", false)); dipList.add(new DipSwitch("B", false)); dipList.add(new DipSwitch("C", false)); dipList.add(new DipSwitch("D", false)); dipList.add(new DipSwitch("E", false)); } buttons.add(new Button(Button.BUTTON_ON_ID, context.getString(R.string.on), id)); buttons.add(new Button(Button.BUTTON_OFF_ID, context.getString(R.string.off), id)); }
public void tick() { To4ka nOVApoZiciqTo4ka = new To4ka( (zmiiskoTqlo.get(0).daiXiksa() + velocityX), (zmiiskoTqlo.get(0).daiIgreka() + velocityY)); if (nOVApoZiciqTo4ka.daiXiksa() > Igr1t1.WIDTH - 20) { Igr1t1.gameRunning = false; } else if (nOVApoZiciqTo4ka.daiXiksa() < 0) { Igr1t1.gameRunning = false; } else if (nOVApoZiciqTo4ka.daiIgreka() < 0) { Igr1t1.gameRunning = false; } else if (nOVApoZiciqTo4ka.daiIgreka() > Igr1t1.height - 20) { Igr1t1.gameRunning = false; } else if (Igr1t1.apalkata.daiTo4ka().equals(nOVApoZiciqTo4ka)) { zmiiskoTqlo.add(Igr1t1.apalkata.daiTo4ka()); Igr1t1.apalkata = new Qbalkata(this); Igr1t1.to4ki += 50; } else if (zmiiskoTqlo.contains(nOVApoZiciqTo4ka)) { Igr1t1.gameRunning = false; System.out.println("You ate yourself"); } for (int i = zmiiskoTqlo.size() - 1; i > 0; i--) { zmiiskoTqlo.set(i, new To4ka(zmiiskoTqlo.get(i - 1))); } zmiiskoTqlo.set(0, nOVApoZiciqTo4ka); }