예제 #1
0
  public Event_listener(AppLogic pLogic, Gui pGui) {

    pGui.getBtnCreateNewUser().setOnClickListener(this);
    pGui.getBtnGoToFileSelection().setOnClickListener(this);
    pGui.getBtnEditUser().setOnClickListener(this);
    mLogic = pLogic;
  }
예제 #2
0
 @Override
 protected void process(List<String> chunks) {
   Gui.updateStatusBar(chunks.get(chunks.size() - 3));
   long time = Long.parseLong(chunks.get(chunks.size() - 2));
   Gui.updateTimeLabel(parseNanoToNormal(time));
   long estTime = Long.parseLong(chunks.get(chunks.size() - 1));
   Gui.updateTotalTimeLabel(parseNanoToNormal(estTime));
 }
예제 #3
0
 public TowerCost(Gui gui, Rectangle rectangle) {
   super(gui, rectangle);
   this.shapeRenderer = gui.getShapeRenderer();
   this.spriteBatch = gui.getSpriteBatch();
   this.font = gui.getFont();
   this.showCost = true;
   this.setScale(0.75f);
 }
예제 #4
0
  Main init() {

    // Create a chart to monitor the infection progress rate
    final XYLineChart chart =
        new XYLineChart("Infection Rate", 5.0, "Infected Nodes (%)", "time(s)");
    chart.setYRange(false, 0, 100);
    chart.setSeriesLinesAndShapes("s0", true, true);

    Gui.setFrameRectangle("MainFrame", 0, 0, 480, 480);
    Gui.setFrameRectangle("Infection Rate", 484, 0, 480, 480);

    // Create the simulation nodes
    for (int i = 0; i < TOTAL_NODES; i++) new Node();

    // Initialize the simulation nodes
    for (Node i : NodeDB.nodes()) i.init();

    NodeDB.randomNode().infect();

    // Sets up a periodic task that, at one second intervals, computes and shows the percentage of
    // infected nodes in the system
    // Stops the simulation when it detects that every node is infected...
    new PeriodicTask(1.0) {
      public void run() {
        double T = 0, N = 0;
        for (Node n : NodeDB.nodes()) {
          if (n.infected) T++;
          N++;
        }
        chart.getSeries("s0").add(Simulation.currentTime(), 100.0 * T / N);
        if (N == T) stop();
      };
    };

    // From time to time, select a random node to go fail and go offline...
    new Task(0) {
      public void run() {
        NodeDB.randomNode().crash();
        reSchedule(0.5 + 0.5 * rg.nextDouble()); // schedules a new execution of this task...
      }
    };

    // From time to time, create a new node. If the rate of births and deaths is the same,
    // the size of the system should stay constant on average.
    new Task(0) {
      public void run() {
        new Node().init();
        reSchedule(0.5 + 0.5 * rg.nextDouble()); // schedules a new execution of this task...
      }
    };

    super.setSimulationMaxTimeWarp(2.0);

    return this;
  }
예제 #5
0
 /**
  * If user pushes a key in the Gui
  *
  * @param e
  */
 @Override
 public void keyPressed(KeyEvent e) {
   if (e.getKeyCode() == KeyEvent.VK_ENTER) { // Enter key pressed
     if (gui.isConnected()) { // Do a guess if connected
       String guess = gui.getGuess();
       if (guess != null && !guess.equals("")) {
         connector.sendMsg(guess);
       }
     }
   }
 }
예제 #6
0
파일: Main.java 프로젝트: damacode/MyTumblr
 public static void main(String[] args) {
   if (args.length == 0) {
     gui = new Gui();
     gui.setVisible(true);
   } else if (args.length == 3 || args.length == 4) {
     Main.setBlogName(args[0]);
     Main.load();
     if (args.length == 3) {
       int start, limit;
       try {
         start = Integer.parseInt(args[1]);
         limit = Integer.parseInt(args[2]);
       } catch (Exception e) {
         Main.status("usage: Main <blogname> <start_page> <end_page> -hires");
         Main.status("start_page and end_page must be integers >= 1");
         return;
       }
       Main.run(start, limit);
       Main.save();
     } else if (args.length == 4 && args[3].equals("-hires")) {
       Main.downloadHiRes();
       Main.save();
     } else {
       Main.status("usage: Main <blogname> <start_page> <end_page> -hires");
     }
   } else {
     Main.status("usage: Main <blogname> <start_page> <end_page> -hires");
   }
 }
예제 #7
0
파일: Main.java 프로젝트: damacode/MyTumblr
 private static void error(String error) {
   if (gui == null) {
     System.err.println(error);
   } else {
     gui.setStatus(error);
   }
 }
예제 #8
0
파일: Main.java 프로젝트: damacode/MyTumblr
 private static void status(String status) {
   if (gui == null) {
     System.out.println(status);
   } else {
     gui.setStatus(status);
   }
 }
예제 #9
0
 @Override
 public void update() {
   super.update();
   textMusic2.setText(sliderMusic.getText());
   textEffects2.setText(sliderEffects.getText());
   SoundCategory.MUSIC.setGain(sliderMusic.getPosition());
   SoundCategory.EFFECT.setGain(sliderEffects.getPosition());
 }
예제 #10
0
 @Override
 protected void done() {
   Gui.progressBar.setIndeterminate(false);
   NumberFormat formatter = new DecimalFormat("#0.00000");
   Gui.progressBar.setString(
       "Done! Total execution time is "
           + formatter.format(totalSleuthRunTime / 1000000000d)
           + " seconds.");
   Gui.updateTimeLabel("0");
   Main.outputTimers(this.getTotalTime(), this.totalImgPixels, this.getIterations());
 }
예제 #11
0
  public void onButtonAnswerInputClick() {

    if (mData.isAnswerRight(mGui.getEdAnswere().getText().toString())) {

      Navigation.startActivityResponseRight(mData.getActivity());

    } else {

      Navigation.startActivityResponseFalse(mData.getActivity());
    }
  }
  protected void processPage(Object mediaWiki, Object page_) throws Exception {
    PageType page = (PageType) page_;

    for (Object o : page.getRevisionOrUploadOrLogitem()) {
      if (o instanceof RevisionType) {
        RevisionJob job = new RevisionJob(page, (RevisionType) o);

        JobTrace trace = job.getTrace();
        trace.signOff(getClass(), null);

        jobTraces.add(trace);

        inTray.put(job);

        Gui gui = dumpCruncher.getGui();
        gui.setPageCount((int) getParsedCount());
        gui.setBytesRead(getCompressedBytesRead());
        gui.redrawLater();
      }
    }
  }
예제 #13
0
파일: Main.java 프로젝트: damacode/MyTumblr
 public static void downloadHiRes() {
   Main.status("Downloading hi res versions of photos in database.");
   if (gui != null) {
     gui.setProgress(0);
     gui.setMaxProgress(pic_pic_hash.keySet().size());
   }
   int progress = 0;
   for (Picture picture : pic_pic_hash.keySet()) {
     if (!picture.downloaded_hi) {
       tryResUrls(picture);
     }
     if (gui != null) {
       gui.setProgress(progress);
       progress++;
     }
   }
   if (gui != null) {
     gui.setProgress(progress);
     progress++;
   }
   Main.status("Done downloading hi res versions.");
 }
예제 #14
0
파일: Runner.java 프로젝트: rtayek/Cb7
 @Override
 public void buildGui(MessageReceiver.Model model) {
   pl("building gui.");
   final RelativeLayout relativeLayout = gui.builGui();
   gui.setStatusVisibility(
       gui.status[0].getVisibility() == View.VISIBLE ? View.INVISIBLE : View.VISIBLE);
   mainActivity.runOnUiThread(
       new Runnable() {
         @Override
         public void run() {
           mainActivity.setContentView(relativeLayout);
         }
       });
   hasATablet = gui;
   model.addObserver(gui);
   p("building gui adapter.");
   guiAdapterABC = gui.buildGuiAdapter();
   gui.guiAdapterABC = guiAdapterABC;
   hasATablet.setTablet(null);
   guiAdapterABC.setTablet(null);
   p("gui adapter: " + guiAdapterABC);
   p("gui built.");
 }
예제 #15
0
  public static void main(String[] args) {

    Luola luola = new Luola(5);
    Gui kayttoliittyma = new Gui(35, luola);
    kayttoliittyma.run();
    luola.setPaivitettava(kayttoliittyma.getPaivitettava());
    luola.start();

    while (kayttoliittyma.getPaivitettava() == null) {
      System.out.println("haha");
      try {
        Thread.sleep(100);
      } catch (InterruptedException ex) {
        System.out.println("Piirtoalustaa ei ole vielä luotu.");
      }
    }
    //        LuolaMenu menu = new LuolaMenu(kayttoliittyma);
    //        SwingUtilities.invokeLater(kayttoliittyma);
    //        menu.setPaivitettava(kayttoliittyma.getPaivitettava());

    //        Luola luola = new Luola(15, true,5);

  }
예제 #16
0
파일: Parser.java 프로젝트: jtribble/java
  /**
   * Run
   *
   * @param Vector<Token> t, Gui gui
   * @return DefaultMutableTreeNode
   */
  public static DefaultMutableTreeNode run(Vector<A2.Token> t, Gui gui) {
    Parser.gui = gui;
    tokens = t;
    currentToken = 0;

    SemanticAnalyzer.reset(); // reset the data structures

    root = new DefaultMutableTreeNode("program");
    rule_program(root);

    gui.writeSymbolTable(SemanticAnalyzer.getSymbolTable());

    return root;
  }
예제 #17
0
  public void draw(Graphics2D screen) {
    GraphicsDraw.initializeDraw(screen);
    if (first) {
      GraphicsDraw.initialize(screen.getFont());
      Gui.initialize();
      FileManager.initialize();
      first = false;
    }
    GraphicsDraw.setColor(_G.COLOR_BACKGROUND);
    GraphicsDraw.fillRectangle(_G.LEVELEDITOR_SCREENSIZE.div(2), _G.LEVELEDITOR_SCREENSIZE);

    ///// Update stuff
    update_mouse();
    Gui.update();

    ///// Draw stuff
    Gui.draw();

    ///// Final stuff (must be last)
    for (int i = 0; i < keypress.length; i++) keypress[i] = false;
    wheelRotation = 0;
    _G.cycle++;
  }
예제 #18
0
  public static void error(int err) {
    int n = 0;
    // if(currentToken<tokens.size())
    if (err != 4
        && currentToken != 0
        && (tokens.get(currentToken - 1).getLine() < tokens.get(currentToken).getLine())) {
      n = tokens.get(currentToken - 1).getLine();
    } else {
      n = tokens.get(currentToken).getLine();
    }

    switch (err) {
      case 1:
        gui.writeConsole("Line" + n + ":expected {");
        break;
      case 2:
        gui.writeConsole("Line" + n + ":expected }");
        break;
      case 3:
        gui.writeConsole("Line" + n + ":expected ;");
        break;
      case 4:
        gui.writeConsole("Line" + n + ":expected identifier or keyword");
        break;
      case 5:
        gui.writeConsole("Line" + n + ": expected =");
        break;
      case 6:
        gui.writeConsole("Line" + n + ": expected identifier");
        break;
      case 7:
        gui.writeConsole("Line" + n + ": expected )");
        break;
      case 8:
        gui.writeConsole("Line" + n + ": expected (");
        break;
      case 9:
        gui.writeConsole("Line" + n + ": expected value, identifier, (");
        break;
    }
  }
예제 #19
0
 public static DefaultMutableTreeNode run(Vector<Token> t, Gui gui) {
   Parser.gui = gui;
   tokens = t;
   currentToken = 0;
   root = new DefaultMutableTreeNode("program");
   CodeGenerator.clear(gui);
   //
   rule_program(root);
   CodeGenerator.addInstruction("OPR", "0", "0");
   codeLine++;
   gui.writeSymbolTable(SemanticAnalyzer.getSymbolTable());
   CodeGenerator.writeCode(gui);
   //
   return root;
 }
예제 #20
0
  public Notice(
      Gui gui, Rectangle target, Orientation orientation, String message, Placement placement) {
    super(gui);
    switch (orientation) {
      case TOP_LEFT:
        this.x = target.x + target.width;
        this.y = target.y;
        break;
      case TOP_RIGHT:
        this.x = target.x;
        this.y = target.y;
        break;
      case BOTTOM_LEFT:
        this.x = target.x + target.width;
        this.y = target.y + target.height;
        break;
      case BOTTOM_RIGHT:
        this.x = target.x;
        this.y = target.y + target.height;
        break;
    }
    this.target = target;
    this.orientation = orientation;
    this.message = message;
    this.placement = placement;
    this.maxWidth = Gdx.graphics.getWidth() / 4;
    this.text = new DisplayText(gui, new Rectangle(), gui.getFont(), BitmapFont.HAlignment.CENTER);
    this.backgroud = new GuiBox(gui, new Rectangle());
    arrow =
        new Icon(gui, new Rectangle()) {
          @Override
          public void process(float x, float y) {}
        };
    refresh();

    if (placement.equals(Placement.RELATIVE)) {
      setRenderer(this);
      setRenderer(backgroud);
      setRenderer(text);
      setRenderer(arrow);
    }
  }
예제 #21
0
파일: Main.java 프로젝트: damacode/MyTumblr
 public static void run(int start_page, int end_page) {
   if (start_page < 1 || end_page < 1) {
     Main.status("start_page and end_page must be integers >= 1");
     return;
   }
   int progress = 0;
   if (gui != null) {
     gui.setProgress(progress);
   }
   if (end_page >= start_page) {
     if (gui != null) {
       gui.setMaxProgress(end_page - start_page);
     }
     for (int i = start_page; i <= end_page; i++) {
       boolean exists =
           Main.handleURL(String.format("http://%s.tumblr.com/page/%s", Main.blogname, i));
       if (!exists) {
         Main.status(String.format("We ran out of posts to process at page %s.", i));
         break;
       }
       if (gui != null) {
         gui.setProgress(progress);
         progress++;
       }
     }
   } else {
     if (gui != null) {
       gui.setMaxProgress(start_page - end_page);
     }
     for (int i = start_page; i >= end_page; i--) {
       boolean exists =
           Main.handleURL(String.format("http://%s.tumblr.com/page/%s", Main.blogname, i));
       if (!exists) {
         Main.status(String.format("We ran out of posts to process at page %s.", i));
         break;
       }
       if (gui != null) {
         gui.setProgress(progress);
         progress++;
       }
     }
   }
   if (gui != null) {
     gui.setProgress(progress);
   }
   Main.writeDuplicates();
 }
예제 #22
0
  public static void main(String vmargs[]) {
    // start with parameters:
    // args[0]: spider
    // args[1]: distance
    ewe.sys.Vm.startEwe(vmargs);
    /*		Gui.screenIs(Gui.PDA_SCREEN);
    		Rect s = (Rect)Window.getGuiInfo(Window.INFO_SCREEN_RECT,null,new Rect(),0);
    		//Gui.screenIs(Gui.PDA_SCREEN)
    		if (Vm.isMobile() && s.height >= 400) {
    			Font defaultGuiFont = mApp.findFont("gui");
    			int sz = (int)(defaultGuiFont.getSize());
    			Font newGuiFont = new Font(defaultGuiFont.getName(), defaultGuiFont.getStyle(), sz);
    			mApp.addFont(newGuiFont, "gui");
    			mApp.fontsChanged();
    			mApp.mainApp.font = newGuiFont;
    		}
    */
    if (Gui.screenIs(Gui.PDA_SCREEN) && Vm.isMobile()) {
      Vm.setSIP(Vm.SIP_LEAVE_BUTTON);
    }

    // get program command line parameters and switches
    String[] args =
        vmargs; // Vm.getProgramArguments(); <-- only works in eclipse, but mixes the letters in the
                // ewe-vm (tested in ewe-1.49 on win xp)
    String configfile = null;
    boolean debug = false;
    if (args.length > 0) {
      if (args[0].equals("test")) {
        Test t = new Test();
        t.testAll();
      }
      for (int i = 0; i < args.length; i++) {
        Vm.debug("prog: " + args[i]);
        Vm.debug("vm: " + vmargs[i]);
        if (args[i] != null
            && args[i].length() > 1
            && (args[i].startsWith("-") || args[i].startsWith("/"))) {
          String c = args[i].substring(1, args[i].length());
          if (c.equalsIgnoreCase("c")) {
            if (i < args.length - 1) {
              configfile = args[i + 1];
              i++;
            } else {
              (new MessageBox(
                      "Error",
                      MyLocale.getMsg(7200, "Usage: CacheWolf [-c <path to pref.xml>] [-debug]"),
                      MessageBox.OKB))
                  .execute();
              // return usage info
              ewe.sys.Vm.exit(1);
            }
          }
          if (c.equalsIgnoreCase("debug")) {
            // Vm.debug("d");
            debug = true;
          }
        }
      }
    }

    if (debug) {
      Vm.debug("prg-args: " + args.length);
      Vm.debug("vm-args: " + vmargs.length);
    }

    Editor mainF = new MainForm(debug, configfile);
    Device.preventIdleState(true);
    mainF.execute();
    Device.preventIdleState(false);
    ewe.sys.Vm.exit(0);
  }
예제 #23
0
  public void checkInput(String input) {
    if (currentConvo != null) {
      if (input.equalsIgnoreCase("cancel")) {
        currentConvo = null;
        player.currentLoc.look();
      } else {
        currentConvo.talk(input);
      }
      return;
    }
    System.out.println(input);
    Pattern lookPattern = Pattern.compile("^look(\\s|$)");
    Pattern getPattern = Pattern.compile("^get(\\s|$)");
    Pattern dropPattern = Pattern.compile("^drop(\\s|$)");
    Pattern usePattern = Pattern.compile("^use(\\s|$)");
    Pattern movePattern = Pattern.compile("^move(\\s|$)");
    Pattern talkPattern = Pattern.compile("^talk(\\s|$)");
    Pattern argumentPattern = Pattern.compile("\\s\\w+($|\\s)");
    Pattern twoArgumentPattern =
        Pattern.compile(
            "\\s(\\w+|\\w+\\s\\w+)\\son\\s(\\w+|\\w+\\s\\w+)($|\\s)"); // makes UseOn work
    Pattern savePattern = Pattern.compile("^save(\\s|$)");
    Pattern loadPattern = Pattern.compile("^load(\\s|$)");
    Matcher argumentMatcher = argumentPattern.matcher(input);
    Matcher twoArgumentMatcher = twoArgumentPattern.matcher(input);

    // LOOK
    if (lookPattern.matcher(input).find()) {
      if (argumentMatcher.find()) {
        player.look(input.substring(argumentMatcher.start() + 1, input.length()));
      } else {
        player.look("");
      }
      return;
    }
    // END LOOK

    // TALK
    if (talkPattern.matcher(input).find()) {
      if (argumentMatcher.find()) {
        player.talk(input.substring(argumentMatcher.start() + 1, input.length()));
      } else {
        Gui.setOutputText("You talk to yourself for a while, it was a rivetting conversation");
      }
      return;
    }

    // GET/PICK UP
    if (getPattern.matcher(input).find()) {
      if (argumentMatcher.find()) {
        System.out.println("found argument");
        player.pickUp(input.substring(argumentMatcher.start() + 1, input.length()));
        return;
      } else {
        Gui.setOutputText("You can't pick up nothing, f****t.");
        return;
      }
    }
    // END GET

    // USE ON
    if (twoArgumentMatcher
        .find()) { // checks for two arguments so "use cat picture on joint" should call useOn?
      input = input.substring(twoArgumentMatcher.start() + 1, input.length());
      Pattern findOnPattern = Pattern.compile("\\son\\s");
      Matcher findOnMatcher = findOnPattern.matcher(input);
      findOnMatcher.find();
      String firstArg = input.substring(0, findOnMatcher.start()); // item 1
      String secondArg = input.substring(findOnMatcher.end(), input.length()); // item 2
      player.useOn(firstArg, secondArg);
      return;
    }
    // END USE ON

    // USE
    if (usePattern.matcher(input).find()) {
      if (argumentMatcher.find()) {
        player.use(input.substring(argumentMatcher.start() + 1, input.length()));
        return;
      } else {
        Gui.setOutputText("There's nothing like that to use.");
        return;
      }
    }
    // END USE

    // DROP
    if (dropPattern.matcher(input).find()) {
      if (argumentMatcher.find()) {
        player.drop(input.substring(argumentMatcher.start() + 1, input.length()));
        return;
      } else {
        Gui.setOutputText("You have dropped nothing.");
        return;
      }
    }
    // END DROP

    // MOVE
    if (movePattern.matcher(input).find()) {
      if (argumentMatcher.find()) {
        String destination = input.substring(argumentMatcher.start() + 1, input.length());
        for (Location l : player.currentLoc.getLinks()) {
          if (destination.equalsIgnoreCase(l.getName()) && l.isDiscovered()) {
            player.move(l);
            return;
          }
        }
        Gui.setOutputText("Invalid location");
        return;
      } else {
        Gui.setOutputText("You shuffled around a little bit");
        return;
      }
    }
    // END MOVE

    // SAVE
    if (savePattern.matcher(input).find()) {
      Gui.setOutputText(TextAdventure.saveWorld());
    }
    // END SAVE

    // LOAD
    if (loadPattern.matcher(input).find()) {
      Gui.setOutputText(TextAdventure.loadWorld());
    }
    // END LOAD

    // NONE OF THE ABOVE
    Gui.setOutputText(
        (String) TextAdventure.pick(TextAdventure.invalidVerb)); // prints out invalid verb
    return;
  }
  /** @param args */
  public static void main(String[] args) {
    int experimentNumber = 0;
    int producers = 0;
    int consumers = 0;
    int cycles = 0;
    int cycleLengthC = 0;
    int cycleLengthP = 0;
    int bufferSize = 0;

    // parses user input

    for (int i = 0; i < args.length; i++) {
      // parses experiment number if word found

      if (args[i].equals("-exp")) {
        try {
          experimentNumber = Integer.parseInt(args[i + 1]);
          if (experimentNumber < 1 || experimentNumber > 3) printUsage(experimentNumber);
        } catch (NumberFormatException e) {
          printUsage(experimentNumber);
        }
      }

      // parses cycles number if word found

      if (args[i].equals("-c")) {
        try {
          cycles = Integer.parseInt(args[i + 1]);
          if (cycles < 1) printUsage(experimentNumber);
        } catch (NumberFormatException e) {
          printUsage(experimentNumber);
        }
      }

      // parces the buffer size if word found

      if (args[i].equals("-b")) {
        try {
          bufferSize = Integer.parseInt(args[i + 1]);
          if (bufferSize < 1) printUsage(experimentNumber);
        } catch (NumberFormatException e) {
          printUsage(experimentNumber);
        }
      }

      // parses producers' cycle time if word found

      if (args[i].equals("-tp")) {
        try {
          cycleLengthP = Integer.parseInt(args[i + 1]);
          if (cycleLengthP < 0) printUsage(experimentNumber);
        } catch (NumberFormatException e) {
          printUsage(experimentNumber);
        }
      }

      // parses consumers' if word found

      if (args[i].equals("-tc")) {
        try {
          cycleLengthC = Integer.parseInt(args[i + 1]);
          if (cycleLengthC < 0) printUsage(experimentNumber);
        } catch (NumberFormatException e) {
          printUsage(experimentNumber);
        }
      }

      // prints help if word found

      if (args[i].equals("-h")) {
        printUsage(experimentNumber);
        failed = true;
      }
    }

    // if help wasn't printed the experiment is launched

    if (!failed) {
      Buffer buffer;
      switch (experimentNumber) {
        case 1:
          buffer = new Buffer(1, experimentNumber);
          Consumer c = new Consumer(buffer, 0);
          Producer p = new Producer(buffer, 0);
          buffer.registerThread(p, cycleLengthP, cycles);
          buffer.registerThread(c, cycleLengthC);
          break;
        case 2:
          buffer = new Buffer(bufferSize, experimentNumber);
          Consumer c2 = new Consumer(buffer, 0);
          Producer p2 = new Producer(buffer, 0);
          buffer.registerThread(p2, cycleLengthP, cycles);
          buffer.registerThread(c2, cycleLengthC);
          break;
        case 3:
          Gui g = new Gui();
          g.init();
          g.changeBSize();
          break;
      }
    }
  }
 public static void main(String[] args) {
   Gui m = new Gui();
   m.setVisible(true);
 }
예제 #26
0
파일: Parser.java 프로젝트: jtribble/java
  /**
   * Error
   *
   * @param int code
   */
  public static void error(int code) {
    int n = tokens.get(currentToken - 1).getLine();

    switch (code) {
      case 1:
        gui.writeConsole("Line " + n + ": expected {");
        break;

      case 2:
        gui.writeConsole("Line " + n + ": expected }");
        break;

      case 3:
        gui.writeConsole("Line " + n + ": expected ;");
        break;

      case 4:
        gui.writeConsole("Line " + n + ": expected identifier or keyword");
        break;

      case 5:
        gui.writeConsole("Line " + n + ": expected =");
        break;

      case 6:
        gui.writeConsole("Line " + n + ": expected identifier");
        break;

      case 7:
        gui.writeConsole("Line " + n + ": expected )");
        break;

      case 8:
        gui.writeConsole("Line " + n + ": expected (");
        break;

      case 9:
        gui.writeConsole("Line " + n + ": expected value, identifier, (");
        break;

      case 10:
        gui.writeConsole("Line " + n + ": expected keyword");
        break;

      case 11:
        gui.writeConsole("Line " + n + ": expected type");
        break;
    }
  }
예제 #27
0
  public void update() { // sorry for all the megafunctions here
    super.update();

    scale = desiredscale * SCALELERPAMOUNT + scale * (1 - SCALELERPAMOUNT);
    // drawOffset = viewOffset.add(scale);

    update_middleclickmapmovement();
    update_rightclickselection();

    if (this.checkMouseOver()) {
      if (Center.leftMouseDown()) {
        if (Center.leftMouseClicked()) {
          currentPoint =
              new EventLocation(
                  Center.mousePosition(), Gui.SpawnLocationCreator_getDesiredSpawnType());
          SpawnList.clearSelections();
        }
        if (currentPoint != null) {
          currentPoint.position = screenToMap(Center.mousePosition());
          if (!checkValidSpawnLocation()) {
            showMessage("Invalid location.");
            currentPoint.position = new Vector2(9999, 0);
          } else {
            switch (snapType) {
              case None:
                break;
              case Grid:
                currentPoint.useSnap_Cartesian(.2f);
                break;
              case Ring:
                currentPoint.useSnap_Polar(_G.PI / 12, .2f);
                break;
            }
            String mess = "Placing point.";
            for (int i = 0; i < (_G.cycle % 150) / 50; i++) mess += '.';
            showMessage(mess);
          }
        }
      } else if (currentPoint != null) {
        if (!checkValidSpawnLocation()) { // Out of bounds
          showMessage("Invalid location.");
          currentPoint = null;
        } else {
          /*if(currentPoint.type == EventType.PlotHole){
          	if(currentPoint.position.x > FIELDUNITSIZE.x*2 || currentPoint.position.x < -FIELDUNITSIZE.x*2 || currentPoint.position.y > FIELDUNITSIZE.y*2 || currentPoint.position.y < -FIELDUNITSIZE.y*2){
          		showMessage("WARNING: Plot Hole will be moved.");
          	}else{
          		showMessage("Plot Hole placed!");
          	}
          }else{*/
          if (currentPoint.position.magnitude() < 2) {
            showMessage("WARNING: Location is too close!");
          } else {
            showMessage("Point placed!");
          }
          // }
          addSpawnLocation(currentPoint);
          SpawnList.selectSpawn(currentPoint);
          currentPoint = null;
        }
      }
    } else if (currentPoint != null) {
      if (Center.leftMouseDown()) {
        showMessage("Invalid location.");
        currentPoint.position = new Vector2(9999, 0);
      } else {
        currentPoint = null;
        showMessage("Point placement cancelled.");
      }
    } else if (SpawnList.selectedSpawns.size() != 0) {
      int siz = SpawnList.selectedSpawns.size();
      // showMessage(""+siz+(siz == 1 ? " point selected." : " points selected."));
    }
  }
예제 #28
0
  /** Create the panel. */
  public MyPanel() {
    // setBackground(new Color(175, 238, 238));
    setBackground(Gui.getThemeColorLight());
    setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));

    btnDownload.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            Downloader d = new Downloader();
            d.setVisible(true);
            try {
              String source = location.substring(6);
              d.setData(location);
              //// String dest="z://"+lblFileNameHere.getText();
              // Gui.debug(source+"   "+dest);
              // copyFile("//172.16.144.135/Videos/Bhakti/SWASAN DI
              // MAALA/AVSEQ02.avi","z://xyz.avi");
              //// copyFile(source,dest);
            } catch (Exception e) {
              Gui.debug("MyPanel-Copy error:" + e.getLocalizedMessage());
            }
          }
        });

    lblFileNameHere = new JLabel("file name here");
    lblFileNameHere.setFont(new Font("Tahoma", Font.BOLD, 11));
    lblFileNameHere.setForeground(new Color(255, 255, 255));
    lblFileNameHere.setToolTipText("hi there");
    final Dimension size = lblFileNameHere.getPreferredSize();
    lblFileNameHere.setMinimumSize(size);
    lblFileNameHere.setPreferredSize(size);

    JButton btnOpenLocation = new JButton("Open Location..");
    btnOpenLocation.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            try {
              OpenLocationBox olc = new OpenLocationBox(location);
            } catch (Exception e) {
              LogWindow.addErrorLog(e.getLocalizedMessage());
            }
          }
        });

    txtFullAddress = new JTextField();
    txtFullAddress.setText("full address goes here");
    txtFullAddress.setColumns(10);

    JLabel lblFileSize = new JLabel("");

    GroupLayout groupLayout = new GroupLayout(this);
    groupLayout.setHorizontalGroup(
        groupLayout
            .createParallelGroup(Alignment.TRAILING)
            .addGroup(
                groupLayout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        groupLayout
                            .createParallelGroup(Alignment.TRAILING)
                            .addGroup(
                                groupLayout
                                    .createSequentialGroup()
                                    .addComponent(
                                        lblFileNameHere,
                                        GroupLayout.DEFAULT_SIZE,
                                        392,
                                        Short.MAX_VALUE)
                                    .addGap(16)
                                    .addComponent(
                                        btnOpen,
                                        GroupLayout.PREFERRED_SIZE,
                                        99,
                                        GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(ComponentPlacement.RELATED)
                                    .addComponent(btnDownload)
                                    .addContainerGap())
                            .addGroup(
                                groupLayout
                                    .createSequentialGroup()
                                    .addPreferredGap(
                                        ComponentPlacement.RELATED, 474, Short.MAX_VALUE)
                                    .addComponent(lblFileSize)
                                    .addGap(128))
                            .addGroup(
                                groupLayout
                                    .createSequentialGroup()
                                    .addComponent(
                                        txtFullAddress,
                                        GroupLayout.DEFAULT_SIZE,
                                        477,
                                        Short.MAX_VALUE)
                                    .addPreferredGap(ComponentPlacement.RELATED)
                                    .addComponent(btnOpenLocation)
                                    .addContainerGap()))));
    btnOpen.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            try {
              OpenFileBox olc = new OpenFileBox(location);
            } catch (Exception e) {
              LogWindow.addErrorLog(e.getLocalizedMessage());
            }
          }
        });
    groupLayout.setVerticalGroup(
        groupLayout
            .createParallelGroup(Alignment.LEADING)
            .addGroup(
                groupLayout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        groupLayout
                            .createParallelGroup(Alignment.BASELINE)
                            .addComponent(
                                lblFileNameHere,
                                GroupLayout.PREFERRED_SIZE,
                                25,
                                GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnDownload)
                            .addComponent(btnOpen))
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addGroup(
                        groupLayout
                            .createParallelGroup(Alignment.BASELINE)
                            .addComponent(
                                txtFullAddress,
                                GroupLayout.PREFERRED_SIZE,
                                22,
                                GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblFileSize)
                            .addComponent(btnOpenLocation))
                    .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    setLayout(groupLayout);
  }
예제 #29
0
  /**
   * If user pushes a button in the Gui
   *
   * @param e
   */
  @Override
  public void actionPerformed(ActionEvent e) {
    String actionCommand = e.getActionCommand();

    if (actionCommand.equals("button_connect")) { // Connect button

      if (gui.isConnected()) { // Disconnect pressed (ending connection)
        disconnectServer();
        gui.setTextOnConsole(Gui.DEFAULT_CONSOLE_MESSAGE); // puts default console message
        gui.setConnectionStatus(false);
      } else { // Connect pressed (connecting to server)

        try {
          String ip = gui.getGivenIP();
          int newport = Integer.parseInt(gui.getPort());
          createConnection(new Socket(ip, newport));
          gui.setConnectionStatus(true);

        } catch (IOException ex) {
          gui.showMessage("Connection failure", "Connection failed.. test a another ip or port");
          gui.setConnectionStatus(false);
          // ex.printStackTrace();

        } catch (
            NumberFormatException
                ex) { // user didn't enter a integer as portnumbertried to enter other value th to
          // enter
          gui.showMessage("Connection failure", "Connection failed.. test a another ip or port");
          gui.setConnectionStatus(false);
        }
      }
    }
    // User wants to guess
    if (actionCommand.equals("button_guess")) { // Button pressed

      if (gui.isConnected()) {
        String guess = gui.getGuess();
        if (guess != null && !guess.equals("")) {
          connector.sendMsg(guess);
        }
      }
      ;
    }

    if (actionCommand.equals("button_showMessage_ok")) {
      gui.exitShowMessage();
    }
  }
예제 #30
0
 public void toggleBackground() {
   this.setBackground(Gui.getThemeColorLight2());
 }