Exemple #1
0
  public static void main(String[] args) throws IOException {
    InputHandler ih = new InputHandler(args[0]);
    Solution sol = new Solution();

    ArrayList<int[]> inIntList = ih.getDataAsIntList();
    for (int i = 0; i < inIntList.size(); i++) {
      int n = inIntList.get(i)[0];
      System.out.println(sol.isPalindrome(n));
    }
  }
  public void registerWithInputHandler(InputHandler inputHandler) {

    if (registeredInputHandler != null) {
      registeredInputHandler.removeAction(updateAction);
    }
    registeredInputHandler = inputHandler;
    if (inputHandler != null) {
      inputHandler.addAction(
          updateAction, InputHandler.DEVICE_MOUSE, InputHandler.BUTTON_NONE, 0, true);
    }
  }
Exemple #3
0
 public void update() {
   Display.setGuiProjection();
   TextureStorage.EMPTY.bind();
   if (InputHandler.isMouseButtonPress(InputHandler.MouseButton.MIDDLE)
       || InputHandler.isMouseButtonPress(InputHandler.MouseButton.RIGHT)) {
     drawCenter();
   }
   size = Display.getFrameBufferSize().copy();
   center = Display.getFrameBufferSize().copy().division(2);
   gui.render();
 }
Exemple #4
0
  private void connect() throws UnknownHostException, IOException {
    IrcServer = new Socket(serverName, 6667);

    BufferedReader br =
        new BufferedReader(
            new InputStreamReader(IrcServer.getInputStream(), BotStats.getInstance().getCharset()));
    PrintWriter pw =
        new PrintWriter(
            new OutputStreamWriter(
                IrcServer.getOutputStream(), BotStats.getInstance().getCharset()),
            true);
    ih = new InputHandler(br);
    oh = new OutputHandler(pw);

    ih.start();
    oh.start();

    new Message("", "NICK", BotStats.getInstance().getBotname(), "").send();
    new Message(
            "", "USER", "goat" + " nowhere.com " + serverName, BotStats.getInstance().getVersion())
        .send();
    // we sleep until we are connected, don't want to send these next messages too soon
    while (!connected) {
      try {
        sleep(100);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }

    joinChannels();
  }
Exemple #5
0
 public void init() {
   gui = new Gui();
   TopBar topBar;
   gui.addComponent(topBar = new TopBar());
   topBar.init(gui);
   InputHandler.registerKeyboardCallback(this);
   gui.addComponent(topBar.getCubeEditor());
   //        gui.addComponent(topBar.getModelTree());
   gui.addComponent(topBar.getTextureEditor());
   //        gui.addComponent(topBar.getGroupEditor());
 }
  private void tick() {
    tickCount++;

    if (input.exit.down) stop();

    if (!hasFocus()) {
      input.releaseAll();
    } else {
      level.tick(input);
    }
  }
 void done(String message) {
   if (!EventQueue.isDispatchThread()) {
     throw new AssertionError("#done must be called from EDT");
   }
   if (isShowing()) { // otherwise skip udpate, dialog is closed
     messageLabel.setText(message);
     progressBar.setIndeterminate(false);
     progressBar.getModel().setValue(progressBar.getModel().getMaximum());
     outputArea.setEditable(false);
   }
   inputHandler.detach();
 }
Exemple #8
0
 protected void setCharset(Charset cs) {
   try {
     BufferedReader br = new BufferedReader(new InputStreamReader(IrcServer.getInputStream(), cs));
     PrintWriter pw =
         new PrintWriter(new OutputStreamWriter(IrcServer.getOutputStream(), cs), true);
     ih.setBR(br);
     oh.setOSW(pw);
   } catch (IOException e) {
     e.printStackTrace();
   } catch (Exception e) {
     System.err.println("Unexpected exception in setCharset :");
     e.printStackTrace();
   }
 }
 public void outputComplete() throws IOException {
   if (location != null) {
     if (writeTrainingData) {
       try {
         inputHandler.writeTrainingData(location, labeled);
       } catch (Exception ex) {
         log.warn("Unable to write training data", ex);
       }
     }
     writeGTF(labeled, location + ".gtf");
     System.out.print(this);
     writeResults(location + ".dat");
   }
 }
 @Override
 public synchronized void close(Process process) throws IOException {
   try {
     super.close(process);
   } catch (IOException e) {
     // check if we got an exception because
     // the process actually completed and we were
     // trying to flush and close it's stdin
     if (process == null || process.exitValue() != 0) {
       // the process had not terminated normally
       // throw the exception we got
       throw e;
     }
   }
 }
Exemple #11
0
  private void tick() {

    // Update input
    input.update();
    if (input.escape) running = false;
  }
Exemple #12
0
 public void update() {
   handleInput();
   inputHandler.refreshMouseClicks();
 }
 /**
  * Constructs and adds this grabber to all agents belonging to the input handler.
  *
  * @see remixlab.bias.core.InputHandler#agents()
  */
 public GrabberObject(InputHandler inputHandler) {
   for (Agent agent : inputHandler.agents()) agent.addInPool(this);
 }
Exemple #14
0
 private void tick() {
   input.tick();
   player.tick();
 }
 GemProgressPanel(String message) {
   initComponents();
   messageLabel.setText(message);
   inputHandler = new InputHandler();
   inputHandler.attach(outputArea);
 }
Exemple #16
0
 public void tick() {
   InputHandler.update();
   Handler.tick();
 }