public String renderTool(HttpServletResponse response, Controller controller) { Hashtable jsImageProperties = new Hashtable(); StringBuffer propertyValue = new StringBuffer(); String fullEnabledImageLink = controller.getPathWithContext(enabledImageLink_); generateOnMouseValue(propertyValue, response, fullEnabledImageLink); int propertyValueLength = propertyValue.length(); jsImageProperties.put("class", "normal"); jsImageProperties.put("onMouseOut", propertyValue.append(";mouseout(this)").toString()); propertyValue.delete(propertyValueLength, propertyValue.length()); jsImageProperties.put("onMouseUp", propertyValue.append(";mouseup(this)").toString()); propertyValue.setLength(0); generateOnMouseValue( propertyValue, response, controller.getPathWithContext(highlightedImageLink_)); propertyValueLength = propertyValue.length(); jsImageProperties.put("onMouseOver", propertyValue.append(";mouseover(this)").toString()); propertyValue.delete(propertyValueLength, propertyValue.length()); jsImageProperties.put("onMouseDOwn", propertyValue.append(";mousedown(this)").toString()); String imageTag = HTMLUtils.getHTMLImageTag( response, fullEnabledImageLink, alt_, "16", "16", jsImageProperties); return HTMLUtils.getHTMLLinkTag( response, controller.getPathWithContext(getSelectToolActionHref(false)), getSelectToolActionTarget(), null, imageTag, null); }
public void init(Controller c) { super.init(c); // Make the Display2D. We'll have it display stuff later. display = new Display2D(500, 500, this, 1); // at 400x400, we've got 4x4 per array position displayFrame = display.createFrame(); c.registerFrame(displayFrame); // register the frame so it appears in the "Display" list displayFrame.setVisible(true); // attach the portrayals from bottom to top display.attach(foodPortrayal, "Food"); display.attach(agentPortrayal, "Agents"); displayFrame.setTitle("Agents"); // specify the backdrop color -- what gets painted behind the displays display.setBackdrop(Color.yellow); // Make the Display2D. We'll have it display stuff later. display2 = new Display2D(400, 400, this, 1); // at 400x400, we've got 4x4 per array position displayFrame2 = display2.createFrame(); displayFrame2.setTitle("Statistic"); c.registerFrame(displayFrame2); // register the frame so it appears in the "Display" list displayFrame2.setVisible(false); // specify the backdrop color -- what gets painted behind the displays display2.setBackdrop(Color.GRAY); // attach the portrayals from bottom to top display2.attach(summaryPortrayal, "Summary"); }
@Override protected Void doInBackground(Void... params) { int bufferSize = AudioRecord.getMinBufferSize(frequency, channelConfiguration, audioEncoding); AudioRecord audioRecord = new AudioRecord( controller.getAudioSource(), frequency, channelConfiguration, audioEncoding, bufferSize); try { short[] buffer = new short[blockSize]; audioRecord.startRecording(); while (controller.isStarted()) { int bufferReadSize = audioRecord.read(buffer, 0, blockSize); DataBlock dataBlock = new DataBlock(buffer, blockSize, bufferReadSize); blockingQueue.put(dataBlock); } } catch (Throwable t) { // Log.e("AudioRecord", "Recording Failed"); } audioRecord.stop(); return null; }
@Test public void testMultipleDisposal() { final Controller controller = new Controller(); controller.init(); controller.dispose(); controller.dispose(); }
@SuppressWarnings("unchecked") public static void inferResult(Object o) throws Result { // Return type inference if (o != null) { if (o instanceof NoResult) { return; } if (o instanceof Result) { // Of course throw (Result) o; } if (o instanceof InputStream) { Controller.renderBinary((InputStream) o); } if (o instanceof File) { Controller.renderBinary((File) o); } if (o instanceof Map) { Controller.renderTemplate((Map<String, Object>) o); } // if (o instanceof Object[]) { // Controller.render(o); // } // bran disable Groovy rendering Controller.renderHtml(o); } }
private void dispatchEvent(String state, Action action) { for (Controller c : controllers) { if (action == c.getActionType() || c.getActionType() == Action.All) { c.actionPerformed(state); } } }
private void getTrafficSpots() { controller.showProgressBar(); String uploadWebsite = "http://" + controller.selectedCity.URL + "/php/trafficstatus.cache?dummy=ert43"; String[] ArrayOfData = null; StreamConnection c = null; InputStream s = null; StringBuffer b = new StringBuffer(); String url = uploadWebsite; System.out.print(url); try { c = (StreamConnection) Connector.open(url); s = c.openDataInputStream(); int ch; int k = 0; while ((ch = s.read()) != -1) { System.out.print((char) ch); b.append((char) ch); } // System.out.println("b"+b); try { JSONObject ff1 = new JSONObject(b.toString()); String data1 = ff1.getString("locations"); JSONArray jsonArray1 = new JSONArray(data1); Vector TrafficStatus = new Vector(); for (int i = 0; i < jsonArray1.length(); i++) { System.out.println(jsonArray1.getJSONArray(i).getString(3)); double aDoubleLat = Double.parseDouble(jsonArray1.getJSONArray(i).getString(1)); double aDoubleLon = Double.parseDouble(jsonArray1.getJSONArray(i).getString(2)); System.out.println(aDoubleLat + " " + aDoubleLon); TrafficStatus.addElement( new LocationPointer( jsonArray1.getJSONArray(i).getString(3), (float) aDoubleLon, (float) aDoubleLat, 1, true)); } controller.setCurrentScreen(controller.TrafficSpots(TrafficStatus)); } catch (Exception E) { controller.setCurrentScreen(traf); new Thread() { public void run() { controller.showAlert("Error in network connection.", Alert.FOREVER, AlertType.INFO); } }.start(); } } catch (Exception e) { controller.setCurrentScreen(traf); new Thread() { public void run() { controller.showAlert("Error in network connection.", Alert.FOREVER, AlertType.INFO); } }.start(); } }
void process() { for (; ; ) { OWLProofNode next = toDo_.poll(); if (next == null) { break; } for (OWLProofStep inf : next.getInferences()) { // recursively unwind premise inferences for (OWLProofNode premise : inf.getPremises()) { // proof reader guarantees equality for structurally // equivalent expressions so we avoid infinite loops here toDo(premise); } // pass to the client if (controller_.inferenceVisited(inf)) { break; } } if (controller_.nodeVisited(next)) { break; } } }
/** @param args the command line arguments */ public static void main(String[] args) throws InterruptedException { // TODO code application logic here UpdateList updateList = new UpdateList(); Runnable serverThread = new SocketServer(updateList); Thread server = new Thread(serverThread); server.start(); // while(true) // { // Thread.sleep(500); // // Float[] asad = new Float[1]; // // asad[0] = 1.0f; // // updateList.add(asad); // // // } Controller contr = new Controller(updateList); contr.test(); }
public Node addNode(int homeId, byte nodeId) { if (!isNodeExist(nodeId)) { size++; logs.add(String.format("Adding node: %d", SafeCast.toInt(nodeId))); } Node node; if (nodesCount() == 1) { primaryController = new Controller(homeId, nodeId, queue, xml, logs); primaryController.setLibraryType(libraryType); primaryController.setLibraryTypeName(libraryTypeName); primaryController.setLibraryVersion(libraryVersion); primaryController.setNodeListener(listener); setNode(nodeId, primaryController); node = primaryController; } else { node = new Node(homeId, nodeId, primaryController, queue, xml, logs); setNode(nodeId, node); node.setNodeListener(listener); node.setQueryStage(QueryStage.ProtocolInfo); } if (listener != null) { listener.onNodeAddedToList(); } return node; }
private String[] GetBusPosition(String Str) { String uploadWebsite = "http://" + controller.URL_BASE + "/php/busposition?q="; String[] ArrayOfData = null; StreamConnection c = null; InputStream s = null; StringBuffer b = new StringBuffer(); String url = uploadWebsite + Str; System.out.print(url); try { /* c = (StreamConnection)Connector.open(url); s = c.openDataInputStream(); int ch; int k =0; while((ch = s.read()) != -1) { System.out.print((char) ch); b.append((char) ch); } */ String result; // = b.toString(); result = "365E~~RTONO~~09:30:23~~12.21212~~89.23324234"; // System.out.print("in thread---------"); // System.out.print(result); if (!result.equals("")) { ArrayOfData = StringUtil.split(result.toString().trim(), "~~"); } } catch (Exception e) { System.out.print(e); controller.ShowPointingCanvas(); controller.showAlert("Network Error", 3, AlertType.ERROR); } return ArrayOfData; }
/** * Get simple node number. This is defined as one plus the number of previous siblings of the same * node type and name. It is not accessible directly in XSL. * * @param node The node whose number is required * @param controller Used for remembering previous result, for performance * @exception XPathException if any error occurs * @return the node number, as defined above */ public static int getNumberSimple(NodeInfo node, Controller controller) throws XPathException { // checkNumberable(node); int fingerprint = node.getFingerprint(); NodeTest same; if (fingerprint == -1) { same = NodeKindTest.makeNodeKindTest(node.getNodeKind()); } else { same = new NameTest(node); } SequenceIterator preceding = node.iterateAxis(Axis.PRECEDING_SIBLING, same); int i = 1; while (true) { NodeInfo prev = (NodeInfo) preceding.next(); if (prev == null) { break; } int memo = controller.getRememberedNumber(prev); if (memo > 0) { memo += i; controller.setRememberedNumber(node, memo); return memo; } i++; } controller.setRememberedNumber(node, i); return i; }
public void updateModel(List<Integer> pressedKeys) { if (startFrame == -1) { controller.stepModel(0, pressedKeys); startFrame = System.nanoTime(); } controller.stepModel(System.nanoTime() - startFrame, pressedKeys); }
public static void main(String[] args) { Map<Integer, CalcularPolignos> poligono = new HashMap<>(); Scanner sc = new Scanner(System.in); System.out.println("Digite o número de lados do poligono: "); BigInteger lados = sc.nextBigInteger(); int opcao = 0; if (lados.intValue() < 3) { System.out.println("Valor negativo para número de lados do poligno, tente novamente!"); main(args); } else if (lados.intValue() == 3) { opcao = 1; } else if (lados.intValue() == 4) { opcao = 2; } else if (lados.intValue() > 4) { opcao = 3; } System.out.println("Digite o Tamanho do Lado do Poligono: "); BigDecimal tamanho = sc.nextBigDecimal(); poligono.put(1, new Triagulo(lados, tamanho)); poligono.put(2, new Quadrilatero(lados, tamanho)); poligono.put(3, new OutrosPoligonos(lados, tamanho)); Controller cont = new Controller(); cont.calcular(lados, poligono.get(opcao)); }
public void addCube(int x, int y, int z) { Cube tempCube = new Cube("stoneTop.png", -x, -y, -z); if (!collision(-x, -y, -z) && !collision( (int) controller.getX(), (int) controller.getY(), (int) controller.getZ(), tempCube)) { cubes.add(tempCube); } }
@Test public void testGetRoleInfoDefault() { RoleInfo info = controller.getRoleInfo(); assertEquals(HARole.ACTIVE, info.getRole()); assertNotNull(info.getRoleChangeDescription()); assertEquals(HARole.ACTIVE, controller.getRole()); // FIXME: RoleInfo's date. but the format is kinda broken }
public HexPanelListener() { /* * Set this object as the listener * for the hex panel for * *both* types of Mouse Listener */ Controller.getHexPanel().addMouseMotionListener(this); Controller.getHexPanel().addMouseListener(this); }
public static void main(String[] args) throws BluetoothStateException, InterruptedException, IOException, JSONException, URISyntaxException { // BTConnection con = new BTConnection(); Controller con = new Controller(); con.run(); }
public void notifyController() { if (mController != null) { if (mCrumbs.size() > 0) { mController.onTop(this, mCrumbs.size(), getTopCrumb().data); } else { mController.onTop(this, 0, null); } } }
/** * Public constructor * * @param displayManager the DisplayManager object to be used. * @param controller */ public DialogController(DisplayManager displayManager, Controller controller) { this.displayManager = displayManager; this.controller = controller; this.localization = controller.getLocalization(); this.appSyncSourceManager = controller.getAppSyncSourceManager(); this.lastFirstSyncDialogState = new FirstSyncDialogState(); this.lastWifiNotAvailableDialogState = new WifiNotAvailableDialogState(); this.lastSelectedDirection = -1; }
public Tooltip register(String theControllerName, String theText) { Controller<?> c = skatolo.getController(theControllerName); if (c == null) { return this; } map.put(c, theText); c.registerProperty("setTooltipEnabled", "isTooltipEnabled"); return this; }
/** * finds the user object in the array list and loads it to an object variable that is returned to * main * * @param input string name of the user */ public static void login(String input) { int val = finduser(input); if (val == -1) { System.out.println("User " + input + " does not exist"); return; } Controller controller = new Controller(users.get(val)); controller.runner(); }
@Test public void testAutomaticInitialization() { Controller controller = null; try { controller = new Controller(); controller.process(ImmutableMap.<String, Object>of(), ComponentWithInitParameter.class); } finally { controller.dispose(); } }
private void processAndDispose(final Object designator) { Controller controller = null; try { controller = new Controller(); controller.init(); controller.process(ImmutableMap.<String, Object>of(), designator); } finally { controller.dispose(); } }
/** * a Tooltip is activated when the mouse enters a controller. * * @param theController */ protected void activate(Controller<?> theController) { if (map.containsKey(theController)) { startTime = System.nanoTime(); _myController = theController; currentPosition.set( theController.getControlWindow().mouseX, theController.getControlWindow().mouseY, 0); updateText(map.get(_myController)); _myMode = ControlP5.WAIT; } }
public static void main(String[] args) { System.out.println("Main for AdMan"); controller = new Controller(); controller.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); controller.setSize(380, 200); controller.setLocationRelativeTo(null); controller.setVisible(true); }
@Test(expected = IllegalStateException.class) public void testMultipleInitialization() { Controller controller = null; try { controller = new Controller(); controller.init(); controller.init(); } finally { controller.dispose(); } }
public void onDisable() { Controller.getXMPPManager() .sendAll("Server is now shutting down. You will be disconnected from the chat."); try { Controller.getXMPPManager().close(); } catch (XMPPException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println("[" + Controller.getName() + "] is now disabled!"); }
@Override public void hierarchyChanged(HierarchyEvent e) { if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) { if (isShowing()) { controller.addControllerListener(this); update(); } else { controller.removeControllerListener(this); } } }
public TicTacEye() { TicTac model = new TicTac(3); Controller controller = new SequentialController(model); // GridView view = new GridView(model, controller, 640, 480, new ColorScheme()); TicTacView view = new TicTacView(model, controller); controller.bind(model.player0, new RandomAgent()); controller.bind(model.player1, new RandomAgent()); show(view); }