Esempio n. 1
0
 // Metoden createLabels - Skapar de grafiska komponenterna för scorelistan
 public void createLabels() {
   // Om det är fler än en spelare, sortera listan efter score
   if (players.size() > 1) {
     players = sortPlayers(players);
   }
   // Lägg till labels med förbestämd text
   for (int i = 0; i < 3; i++) {
     panel.add(new JLabel(labeltext[i]));
   }
   // Lägg till labels med placering, nick och poäng för spelarna
   for (int i = 3; i < 7; i++) {
     if (players.size() > i - 3) {
       panel.add(new JLabel(labeltext[i]));
       panel.add(new JLabel(players.get(i - 3).nick));
       panel.add(new JLabel(players.get(i - 3).score + ""));
     }
   }
   // Lägger till några tomma labels i panelen för att skapa mellanrum och symetri
   for (int i = 0; i < 4; i++) {
     panel.add(new JLabel(" "));
   }
   // Lägger till avslutaknappen
   panel.add(exit);
   exit.addActionListener(this);
 }
Esempio n. 2
0
  public String get_item_ids() {

    String jsonarry;

    try {

      krypton_database_get_my_tokens getxt = new krypton_database_get_my_tokens();

      String token_array[] = new String[network.listing_size];
      token_array = getxt.get_tokens(network.base58_id);

      LinkedList<String> list = new LinkedList<String>();
      for (int loop = 0; loop < token_array.length; loop++) { // ************

        if (!token_array[loop].contains("-")) {
          list.add(token_array[loop]);
        }
      } // *****************************************************************

      jsonarry = JSONValue.toJSONString(list);

    } catch (Exception e) {

      statex = "0";
      jsonarry = "Error";
    } // *****************

    return jsonarry;
  } // *************************************
Esempio n. 3
0
 // This method was created to collect all nodes in a sub tree if unbalnced was detected
 private Point[] collectSatanSpawn(TreeNode t) {
   LinkedList<Point> points = new LinkedList<Point>();
   getPointsForRebuilding(t, points);
   Point[] a = new Point[points.size()];
   points.toArray(a);
   return a;
 }
 protected void updateHoverHandles(@Nullable DrawingView view, @Nullable Figure f) {
   if (f != hoverFigure) {
     Rectangle r = null;
     if (hoverFigure != null && hoverFigure.isSelectable()) {
       for (Handle h : hoverHandles) {
         if (r == null) {
           r = h.getDrawingArea();
         } else {
           r.add(h.getDrawingArea());
         }
         h.setView(null);
         h.dispose();
       }
       hoverHandles.clear();
     }
     hoverFigure = f;
     if (hoverFigure != null) {
       hoverHandles.addAll(hoverFigure.createHandles(-1));
       for (Handle h : hoverHandles) {
         h.setView(view);
         if (r == null) {
           r = h.getDrawingArea();
         } else {
           r.add(h.getDrawingArea());
         }
       }
     }
     if (r != null) {
       r.grow(1, 1);
       fireAreaInvalidated(r);
     }
   }
 }
Esempio n. 5
0
  /** @return the list of the data flavors */
  public Collection<DataFlavor> getColorDataFlavors() {

    LinkedList<DataFlavor> dataFlavors = new LinkedList<DataFlavor>();

    dataFlavors.add(colorFlavor);
    dataFlavors.add(w3cSVGColorFlavor);

    return dataFlavors;
  }
Esempio n. 6
0
 // Metoden turnCards - Plockar bort alla kort som är tagna och vänder tillbaka alla kort som inte
 // är tagna
 public void turnCards() {
   for (int i = 0; i < cards.size(); i++) {
     cards.get(i).setIcon(bk);
     cards.get(i).setBorder(new LineBorder(Color.WHITE, 1));
     if (cards.get(i).taken == true) {
       cards.get(i).setVisible(false);
     }
   }
 }
Esempio n. 7
0
  void createBend(int bendx, int bendy) {
    Bend bn = null;
    int index = 0;
    if (bends == null) {
      if (driver.nearpln(bendx, bendy, fromX, fromY, toX, toY)) {
        bends = new LinkedList<Bend>();
        bn = new Bend(bendx, bendy);
        if (fromX == toX) // if line vertical
        bn.x = fromX;
        if (fromY == toY) // if line horizontal
        bn.y = fromY;
        bends.add(bn);
        bn.marked = true;
        driver.bendForDragging = bn;
        return;
      }
    } else {
      int x = fromX;
      int y = fromY;
      Object[] oa = bends.toArray();
      for (Object o : oa) {
        Bend b = (Bend) o;
        if (sameBend(bendx, bendy, b)) {
          bn = b;
          bn.marked = true;
          driver.bendForDragging = bn;
          return;
        }
        if (driver.nearpln(bendx, bendy, x, y, b.x, b.y)) {
          bn = new Bend(bendx, bendy);
          if (x == b.x) // if line vertical
          bn.x = x;
          if (y == b.y) // if line horizontal
          bn.y = y;
          bends.add(index, bn);
          bn.marked = true;
          driver.bendForDragging = bn;
          return;
        }
        x = b.x;
        y = b.y;
        index++;
      }

      if (driver.nearpln(bendx, bendy, x, y, toX, toY)) {
        bn = new Bend(bendx, bendy);
        if (x == toX) // if line vertical
        bn.x = x;
        if (y == toY) // if line horizontal
        bn.y = y;
        bends.add(bn);
        bn.marked = true;
        driver.bendForDragging = bn;
      }
    }
  }
Esempio n. 8
0
 public Scorelist(LinkedList<Player> players) {
   super("Scores");
   this.players = players;
   panel = new JPanel(new GridLayout((3 + players.size()), 3));
   createLabels();
   this.add(panel);
   this.setVisible(true);
   this.setSize(300, 30 * (3 + players.size()));
   this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 }
Esempio n. 9
0
  public ShowComp() throws InterruptedException, IOException {
    super("CONNECTED COMPUTERS");
    int x = 0, d = 20;
    mb = new JMenuBar();
    File = new JMenu("File");
    mb.add(File);
    exit = new JMenuItem("Exit");
    exit.addActionListener(this);
    File.add(exit);
    ta = new JTextArea();
    ta.setBounds(20, 30, 315, 470);
    ta.setEditable(false);
    add(ta);

    setJMenuBar(mb);

    sel = new JLabel("The connected computers are..");
    sel.setBounds(15, 5, 300, 30);
    add(sel);
    b1 = new JButton("<< BACK");
    b1.setBounds(140, 510, 100, 30);
    b1.setToolTipText("Back to main page");
    b1.addActionListener(this);
    add(b1);
    setLayout(null);
    while (x < 360) {
      x = x + d;
      setBounds(675, 50, x, 600);
      this.show();
    }
    // setVisible(true);
    String s = "192.168.0.", temp = null;
    Printer printer = new Printer();
    printer.start();
    Connector connector = new Connector(printer);
    connector.start();

    LinkedList targets = new LinkedList();
    for (int i = 1; i <= 255; i++) {
      temp = s + Integer.toString(i);
      Target t = new Target(temp);
      targets.add(t);
      connector.add(t);
    }
    Thread.sleep(2000);
    connector.shutdown();
    connector.join();

    for (Iterator i = targets.iterator(); i.hasNext(); ) {
      Target t = (Target) i.next();
      if (!t.shown) t.show();
    }

    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
  }
Esempio n. 10
0
 // Metoden isCards - Kollar om det finns kort kvar, genom att kolla spelarnas sammanlagda poäng
 public boolean isCards() {
   int sum = 0;
   for (int i = 0; i < players.size(); i++) {
     sum += players.get(i).score;
   }
   // Om den sammanlagda summan av poäng spelarna har är mindre än 32, finns det kort kvar
   if (sum < 32) {
     return true;
   } else {
     return false;
   }
 }
Esempio n. 11
0
 // 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);
 }
Esempio n. 12
0
 public void run() {
   try {
     for (; ; ) {
       Target t = null;
       synchronized (pending) {
         while (pending.size() == 0) pending.wait();
         t = (Target) pending.removeFirst();
       }
       t.show();
     }
   } catch (InterruptedException x) {
     return;
   }
 }
Esempio n. 13
0
  public void run() {
    Map read;
    boolean shouldRead = go_read;
    String command = null;
    long last = 0;

    try {
      /* swallow the banner if requested to do so */
      if (swallow) {
        readResponse();
      }

      while (shouldRead) {
        synchronized (listeners) {
          if (commands.size() > 0) {
            command = (String) commands.removeFirst();
          }
        }

        if (command != null) {
          _sendString(command);
          command = null;
          lastRead = System.currentTimeMillis();
        }

        long now = System.currentTimeMillis();
        if (this.window != null && !this.window.isShowing() && (now - last) < 1500) {
          /* check if our window is not showing... if not, then we're going to switch to a very reduced
          read schedule. */
        } else {
          read = readResponse();
          if (read == null || "failure".equals(read.get("result") + "")) {
            break;
          }

          processRead(read);
          last = System.currentTimeMillis();
        }

        Thread.sleep(100);

        synchronized (listeners) {
          shouldRead = go_read;
        }
      }
    } catch (Exception javaSucksBecauseItMakesMeCatchEverythingFuckingThing) {
      javaSucksBecauseItMakesMeCatchEverythingFuckingThing.printStackTrace();
    }
  }
Esempio n. 14
0
 public void secureExport(int i) {
   File expf = getExportTempFile(store.plainName(i));
   // check if its already been exported
   if (expf.exists()) secureUse(expf);
   else { // otherwise add to work queue
     File cipf = store.locate(i);
     if (cipf != null) {
       synchronized (jobs) {
         if (priorityExport) jobs.addFirst(expJob(cipf, expf));
         else jobs.addLast(expJob(cipf, expf));
       }
     } else System.err.println("Cannot export, missing encrypted file");
   }
   updateStatus();
 }
Esempio n. 15
0
 public ButtonBar addButtonBar(JInternalFrame iaf) {
   ButtonBar bb = new ButtonBar(this, iaf, iaf.getTitle());
   bar.add(bb);
   bBar.add(bb);
   activeButton(bb);
   return bb;
 }
Esempio n. 16
0
 public void totalExport() {
   File expf = new File("export");
   if (expf.exists()) rmrf(expf);
   expf.mkdirs();
   for (int sto = 0; sto < storeLocs.size(); sto++) {
     try {
       String sl =
           storeLocs.get(sto).getAbsolutePath().replaceAll("/", "-").replaceAll("\\\\", "-");
       File estore = new File(expf, sl);
       estore.mkdir();
       File log = new File(estore, LIBRARY_NAME);
       PrintWriter pw = new PrintWriter(log);
       for (int i = 0; i < store.getRowCount(); i++)
         if (store.curStore(i) == sto) {
           File enc = store.locate(i);
           File dec = sec.prepareMainFile(enc, estore, false);
           pw.println(dec.getName());
           pw.println(store.getValueAt(i, Storage.COL_DATE));
           pw.println(store.getValueAt(i, Storage.COL_TAGS));
           synchronized (jobs) {
             jobs.addLast(expJob(enc, dec));
           }
         }
       pw.close();
     } catch (IOException exc) {
       exc.printStackTrace();
       JOptionPane.showMessageDialog(frm, "Exporting Failed");
       return;
     }
   }
   JOptionPane.showMessageDialog(frm, "Exporting to:\n   " + expf.getAbsolutePath());
 }
 public Collection<Handle> createHandles(SVGPathFigure pathFigure, int detailLevel) {
   LinkedList<Handle> handles = new LinkedList<Handle>();
   switch (detailLevel % 2) {
     case 0:
       for (int i = 0, n = path.size(); i < n; i++) {
         handles.add(new BezierNodeHandle(this, i, pathFigure));
       }
       break;
     case 1:
       TransformHandleKit.addTransformHandles(this, handles);
       break;
     default:
       break;
   }
   return handles;
 }
Esempio n. 18
0
 public void updateStatus() {
   txaStatus.setText("");
   txaStatus.append("size\t" + store.getRowCount() + "\n");
   txaStatus.append("total\t" + store.sumLengths() + "KB\n");
   txaStatus.append("\nThreads:\n");
   for (int i = 0; i < numThreads; i++) {
     txaStatus.append(" " + i + "- ");
     String jb = encryptDecryptThreads[i].getCur();
     if (jb == null) txaStatus.append("idle\n");
     else {
       txaStatus.append(jobString(jb) + "\n");
     }
   }
   txaStatus.append("\nJobs:\n");
   int c = 6 + numThreads;
   int i = 0;
   synchronized (jobs) {
     for (String s : jobs) {
       if (c + i < TXA_HEIGHT - 1) txaStatus.append(" - " + jobString(s) + "\n");
       else if (c + i == TXA_HEIGHT - 1) {
         txaStatus.append(" - [" + (jobs.size() - i) + "more ]");
       }
       i++;
     }
   }
 }
Esempio n. 19
0
  // Method that aids collectSatanSpawn(), recursively walks through tree and populates a linked
  // list
  private void getPointsForRebuilding(TreeNode t, LinkedList<Point> points) {
    if (t == null) return;

    points.add(t.p);
    getPointsForRebuilding(t.left, points);
    getPointsForRebuilding(t.right, points);
  }
Esempio n. 20
0
    void add(Target t) {
      SocketChannel sc = null;
      try {

        sc = SocketChannel.open();
        sc.configureBlocking(false);

        boolean connected = sc.connect(t.address);

        t.channel = sc;
        t.connectStart = System.currentTimeMillis();

        if (connected) {
          t.connectFinish = t.connectStart;
          sc.close();
          printer.add(t);
        } else {
          synchronized (pending) {
            pending.add(t);
          }

          sel.wakeup();
        }
      } catch (IOException x) {
        if (sc != null) {
          try {
            sc.close();
          } catch (IOException xx) {
          }
        }
        t.failure = x;
        printer.add(t);
      }
    }
Esempio n. 21
0
    void processPendingTargets() throws IOException {
      synchronized (pending) {
        while (pending.size() > 0) {
          Target t = (Target) pending.removeFirst();
          try {

            t.channel.register(sel, SelectionKey.OP_CONNECT, t);

          } catch (IOException x) {

            t.channel.close();
            t.failure = x;
            printer.add(t);
          }
        }
      }
    }
 @Override
 public void draw(Graphics2D g) {
   if (hoverHandles.size() > 0 && !getView().isFigureSelected(hoverFigure)) {
     for (Handle h : hoverHandles) {
       h.draw(g);
     }
   }
 }
Esempio n. 23
0
  // createericlist with a String signature is used to process a String
  // containing a sequence of GAIGS structures
  // createericlist creates the list of graphics primitives for these snapshot(s).
  // After creating these lists, that are then appended to l, the list of snapshots,
  // Also must return the number of snapshots loaded from the string
  public /*synchronized*/ int createericlist(String structString) {
    int numsnaps = 0;
    if (debug) System.out.println("In create eric " + structString);
    StringTokenizer st = new StringTokenizer(structString, "\r\n");
    while (st.hasMoreTokens()) {
      numsnaps++; // ??
      String tempString;
      LinkedList tempList = new LinkedList();
      StructureType strct;
      tempString = st.nextToken();
      try {
        boolean headers = true;
        while (headers) {
          headers = false;
          if (tempString.toUpperCase().startsWith("VIEW")) {
            tempString = HandleViewParams(tempString, tempList, st);
            headers = true;
          }
          if (tempString.toUpperCase().startsWith("FIBQUESTION ")
              || tempString.toUpperCase().startsWith("MCQUESTION ")
              || tempString.toUpperCase().startsWith("MSQUESTION ")
              || tempString.toUpperCase().startsWith("TFQUESTION ")) {
            tempString = add_a_question(tempString, st);
            headers = true;
          }
        }

        if (tempString.toUpperCase().equals("STARTQUESTIONS")) {
          numsnaps--; // questions don't count as snapshots
          readQuestions(st);
          break;
        }
        // After returning from HandleViewParams, tempString should now contain
        // the line with the structure type and possible additional text height info
        StringTokenizer structLine = new StringTokenizer(tempString, " \t");
        String structType = structLine.nextToken();
        if (debug) System.out.println("About to assign structure" + structType);
        strct = assignStructureType(structType);
        strct.loadTextHeights(structLine, tempList, this);
        strct.loadLinesPerNodeInfo(st, tempList, this);

        strct.loadTitle(st, tempList, this);
        strct.loadStructure(st, tempList, this);
        strct.calcDimsAndStartPts(tempList, this);
        strct.drawTitle(tempList, this);
        strct.drawStructure(tempList, this);
      } catch (VisualizerLoadException e) {
        System.out.println(e.toString());
      }
      //             // You've just created a snapshot.  Need to insure that "**" is appended
      //             // to the URLList for this snapshot IF no VIEW ALGO line was parsed in the
      //             // string for the snapshot.  This could probably best be done in the
      //             // HandleViewParams method
      list_of_snapshots.append(tempList);
      Snaps++;
    }
    return (numsnaps);
  } // createericlist(string)
Esempio n. 24
0
  @Override
  public Collection<Action> getActions(Point2D.Double p) {
    LinkedList<Action> actions = new LinkedList<Action>();
    if (get(TRANSFORM) != null) {
      ResourceBundleUtil labels = ResourceBundleUtil.getBundle("org.jhotdraw.samples.odg.Labels");
      actions.add(
          new AbstractAction(labels.getString("edit.removeTransform.text")) {
            private static final long serialVersionUID = 1L;

            public void actionPerformed(ActionEvent evt) {
              willChange();
              fireUndoableEditHappened(TRANSFORM.setUndoable(ODGAttributedFigure.this, null));
              changed();
            }
          });
    }
    return actions;
  }
 /** highlight a route (maybe to show it's in use...) */
 public void highlightRoute(String src, String dst) {
   Iterator i = rows.iterator();
   while (i.hasNext()) {
     Map temp = (Map) i.next();
     if (temp.get("Address").equals(dst) && temp.get("Pivot").equals(src)) {
       temp.put("Active", Boolean.TRUE);
     }
   }
 }
 /** show the meterpreter routes . :) */
 public void setRoutes(Route[] routes) {
   Iterator i = rows.iterator();
   while (i.hasNext()) {
     Map temp = (Map) i.next();
     for (int x = 0; x < routes.length; x++) {
       Route r = routes[x];
       if (r.shouldRoute(temp.get("Address") + "")) temp.put("Pivot", r.getGateway());
     }
   }
 }
Esempio n. 27
0
    @Override
    public void run() {
      // System.out.println("update map now");
      LinkedList<EdgeOp> backlist = new LinkedList<>();
      PublicData pd = PublicData.getData();
      int i;
      PosOp tmpPosOp;
      EdgeOp tmpEdgeOp;
      Pos tmpPos;
      for (i = 0; i < pd.posTask.size(); i++) {
        tmpPosOp = pd.posTask.get(i);
        if (tmpPosOp.op == 0) { // op==0 add a pos
          MapViewer.this.g.addVertex(new Integer(tmpPosOp.pos));
          tmpPos = pd.agentsPos.get(tmpPosOp.pos);
          MapViewer.this.layout.setLocation(tmpPosOp.pos, tmpPos.getX(), tmpPos.getY());
        } else {
          MapViewer.this.g.removeVertex(tmpPosOp.pos);
        }
      }
      for (i = 0; i < pd.edgeTask.size(); i++) {
        tmpEdgeOp = pd.edgeTask.get(i);
        if (tmpEdgeOp.op == 0) { // add a edge
          // int edgeNum=g.getEdgeCount();
          MapViewer.this.g.addEdge(edgeCnt, tmpEdgeOp.start, tmpEdgeOp.end);
          backlist.add(new EdgeOp(1, edgeCnt, 0, pd.displayCnt));
          edgeCnt++;
        } else { // remove

          if (tmpEdgeOp.delay <= 0) {
            g.removeEdge(tmpEdgeOp.start);
          } else {
            tmpEdgeOp.delay--;
            backlist.add(tmpEdgeOp);
          }
        }
      }
      pd.resetTask();
      pd.edgeTask = backlist;
      vv.repaint();
      // throw new UnsupportedOperationException("Not supported yet."); //To change body of
      // generated methods, choose Tools | Templates.
    }
Esempio n. 28
0
 public Memory(LinkedList<Player> players) {
   super("Memory -");
   this.players = players;
   makeBoard();
   this.add(panel);
   this.setVisible(true);
   this.setSize(640, 720);
   this.setResizable(false);
   this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   // Ger den första spelaren turen
   players.get(0).myTurn = true;
   playerlabels.get(0).setForeground(Color.GREEN);
   // Startar endast tråden för AI-hantering om det finns något AI med i spelet
   for (int i = 0; i < players.size(); i++) {
     if (players.get(i).getClass() == ai.getClass()) {
       AIh.start();
       break;
     }
   }
 }
Esempio n. 29
0
 @Override
 public Collection<Handle> createHandles(int detailLevel) {
   LinkedList<Handle> handles = new LinkedList<Handle>();
   switch (detailLevel % 2) {
     case -1: // Mouse hover handles
       handles.add(new BezierOutlineHandle(this, true));
       break;
     case 0:
       handles.add(new BezierOutlineHandle(this));
       for (int i = 0, n = path.size(); i < n; i++) {
         handles.add(new BezierNodeHandle(this, i));
       }
       break;
     case 1:
       TransformHandleKit.addTransformHandles(this, handles);
       handles.add(new BezierScaleHandle(this));
       break;
   }
   return handles;
 }
Esempio n. 30
0
 private Drawing createDrawing() {
   DefaultDrawing drawing = new DefaultDrawing();
   LinkedList<InputFormat> inputFormats = new LinkedList<InputFormat>();
   inputFormats.add(new SVGInputFormat());
   inputFormats.add(new SVGZInputFormat());
   inputFormats.add(new ImageInputFormat(new SVGImageFigure()));
   inputFormats.add(new TextInputFormat(new SVGTextFigure()));
   LinkedList<OutputFormat> outputFormats = new LinkedList<OutputFormat>();
   outputFormats.add(new SVGOutputFormat());
   outputFormats.add(new ImageOutputFormat());
   drawing.setInputFormats(inputFormats);
   drawing.setOutputFormats(outputFormats);
   return drawing;
 }