コード例 #1
1
  /** {@inheritDoc} */
  protected void getNewMonitors(Map<String, Monitor> map) throws MonitorException {
    assert Thread.holdsLock(this);

    int used = prologue.getUsed();
    long modificationTime = prologue.getModificationTimeStamp();

    if ((used > lastUsed) || (lastModificationTime > modificationTime)) {

      lastUsed = used;
      lastModificationTime = modificationTime;

      Monitor monitor = getNextMonitorEntry();
      while (monitor != null) {
        String name = monitor.getName();

        // guard against duplicate entries
        if (!map.containsKey(name)) {
          map.put(name, monitor);

          /*
           * insertedMonitors is null when called from pollFor()
           * via buildMonitorMap(). Since we update insertedMonitors
           * at the end of buildMonitorMap(), it's ok to skip the
           * add here.
           */
          if (insertedMonitors != null) {
            insertedMonitors.add(monitor);
          }
        }
        monitor = getNextMonitorEntry();
      }
    }
  }
コード例 #2
0
ファイル: SourceFile.java プロジェクト: movinghorse/YCombo
  /**
   * Get dependencies of a source file.
   *
   * @param path The canonical path of source file.
   * @return Path of dependencies.
   */
  private ArrayList<String> getDependencies(String path) {
    if (!dependenceMap.containsKey(path)) {
      ArrayList<String> dependencies = new ArrayList<String>();
      Matcher m = PATTERN_REQUIRE.matcher(read(path, charset));

      while (m.find()) {
        // Decide which root path to use.
        // Path wrapped in <> is related to root path.
        // Path wrapped in "" is related to parent folder of the source file.
        String root = null;

        if (m.group(1).equals("<")) {
          root = this.root;
        } else {
          root = new File(path).getParent();
        }

        // Get path of required file.
        String required = m.group(2);

        File f = new File(root, required);

        if (f.exists()) {
          dependencies.add(canonize(f));
        } else {
          App.exit("Cannot find required file " + required + " in " + path);
        }
      }

      dependenceMap.put(path, dependencies);
    }

    return dependenceMap.get(path);
  }
コード例 #3
0
  void isConnectable(SelectionKey k) {
    EventableSocketChannel ec = (EventableSocketChannel) k.attachment();
    long b = ec.getBinding();

    try {
      if (ec.finishConnecting()) eventCallback(b, EM_CONNECTION_COMPLETED, null);
      else UnboundConnections.add(b);
    } catch (IOException e) {
      UnboundConnections.add(b);
    }
  }
コード例 #4
0
ファイル: SourceFile.java プロジェクト: movinghorse/YCombo
  /**
   * Combine seed file with its' dependencies.
   *
   * @param seed The seed file.
   * @return Output queue with correct dependencies order.
   */
  public ArrayList<String> combo(File seed) {
    Stack<ArrayList<String>> tree = new Stack<ArrayList<String>>();
    ArrayList<String> root = new ArrayList<String>();
    ArrayList<String> output = new ArrayList<String>();

    // Construct the initial tree.
    root.add(canonize(seed));
    tree.add(root);

    // Travel the dependencies tree from the seed file.
    travel(tree, new Stack<String>(), output);

    return output;
  }
コード例 #5
0
  void isWritable(SelectionKey k) {
    EventableChannel ec = (EventableChannel) k.attachment();
    long b = ec.getBinding();

    if (ec.isWatchOnly()) {
      if (ec.isNotifyWritable()) eventCallback(b, EM_CONNECTION_NOTIFY_WRITABLE, null);
    } else {
      try {
        if (!ec.writeOutboundData()) UnboundConnections.add(b);
      } catch (IOException e) {
        UnboundConnections.add(b);
      }
    }
  }
コード例 #6
0
  public long installOneshotTimer(int milliseconds) {
    long s = createBinding();
    long deadline = new Date().getTime() + milliseconds;

    if (Timers.containsKey(deadline)) {
      Timers.get(deadline).add(s);
    } else {
      ArrayList<Long> callbacks = new ArrayList<Long>();
      callbacks.add(s);
      Timers.put(deadline, callbacks);
    }

    return s;
  }
コード例 #7
0
ファイル: TCPSock.java プロジェクト: sherwinyu/class
  /**
   * Accept a connection on a socket
   *
   * <p>Needs to trigger sending an ACK
   *
   * @return TCPSock The first established connection on the request queue remove from welcomeQueue
   *     adds recvSocket to socketSpace sends Ack
   */
  public TCPSock accept() {
    aa(this, this.sockType == SocketType.WELCOME, "accept() called by non-welcome socket");
    aa(this, this.state == State.LISTEN, "accept() called when not listening");

    if (welcomeQueue.isEmpty()) return null;

    p(this, 3, "accept()");
    TCPSock recvSock = welcomeQueue.remove(0);
    recvSock.state = State.ESTABLISHED;
    p(recvSock, 4, "established");
    tcpMan.add(recvSock.tsid, recvSock);
    tcpMan.sendACK(recvSock.tsid);

    return recvSock;
  }
コード例 #8
0
  void removeUnboundConnections() {
    ListIterator<Long> iter = UnboundConnections.listIterator(0);
    while (iter.hasNext()) {
      long b = iter.next();

      EventableChannel ec = Connections.remove(b);
      if (ec != null) {
        eventCallback(b, EM_CONNECTION_UNBOUND, null);
        ec.close();

        EventableSocketChannel sc = (EventableSocketChannel) ec;
        if (sc != null && sc.isAttached()) DetachedConnections.add(sc);
      }
    }
    UnboundConnections.clear();
  }
コード例 #9
0
  void runTimers() {
    long now = new Date().getTime();
    while (!Timers.isEmpty()) {
      long k = Timers.firstKey();
      if (k > now) break;

      ArrayList<Long> callbacks = Timers.get(k);
      Timers.remove(k);

      // Fire all timers at this timestamp
      ListIterator<Long> iter = callbacks.listIterator(0);
      while (iter.hasNext()) {
        eventCallback(0, EM_TIMER_FIRED, null, iter.next().longValue());
      }
    }
  }
コード例 #10
0
ファイル: ZCM.java プロジェクト: ZeroCM/zcm
  /**
   * Remove this particular regex/subscriber pair (UNTESTED AND API MAY CHANGE). If regex is null,
   * all subscriptions for 'sub' are cancelled. If subscriber is null, any previous subscriptions
   * matching the regular expression will be cancelled. If both 'sub' and 'regex' are null, all
   * subscriptions will be cancelled.
   */
  public void unsubscribe(String regex, ZCMSubscriber sub) {
    if (this.closed) throw new IllegalStateException();

    synchronized (this) {
      for (Provider p : providers) p.unsubscribe(regex);
    }

    // TODO: providers don't seem to use anything beyond first channel

    synchronized (subscriptions) {

      // Find and remove subscriber from list
      for (Iterator<SubscriptionRecord> it = subscriptions.iterator(); it.hasNext(); ) {
        SubscriptionRecord sr = it.next();

        if ((sub == null || sr.lcsub == sub) && (regex == null || sr.regex.equals(regex))) {
          it.remove();
        }
      }

      // Find and remove subscriber from map
      for (String channel : subscriptionsMap.keySet()) {
        for (Iterator<SubscriptionRecord> it = subscriptionsMap.get(channel).iterator();
            it.hasNext(); ) {
          SubscriptionRecord sr = it.next();

          if ((sub == null || sr.lcsub == sub) && (regex == null || sr.regex.equals(regex))) {
            it.remove();
          }
        }
      }
    }
  }
コード例 #11
0
  void isReadable(SelectionKey k) {
    EventableChannel ec = (EventableChannel) k.attachment();
    long b = ec.getBinding();

    if (ec.isWatchOnly()) {
      if (ec.isNotifyReadable()) eventCallback(b, EM_CONNECTION_NOTIFY_READABLE, null);
    } else {
      myReadBuffer.clear();

      try {
        ec.readInboundData(myReadBuffer);
        myReadBuffer.flip();
        if (myReadBuffer.limit() > 0) {
          if (ProxyConnections != null) {
            EventableChannel target = ProxyConnections.get(b);
            if (target != null) {
              ByteBuffer myWriteBuffer = ByteBuffer.allocate(myReadBuffer.limit());
              myWriteBuffer.put(myReadBuffer);
              myWriteBuffer.flip();
              target.scheduleOutboundData(myWriteBuffer);
            } else {
              eventCallback(b, EM_CONNECTION_READ, myReadBuffer);
            }
          } else {
            eventCallback(b, EM_CONNECTION_READ, myReadBuffer);
          }
        }
      } catch (IOException e) {
        UnboundConnections.add(b);
      }
    }
  }
コード例 #12
0
 private Iterable<GeographicText> makeIterable(DrawContext dc) {
   // get dispay dist for this service for use in label annealing
   double maxDisplayDistance = this.getPlaceNameService().getMaxDisplayDistance();
   ArrayList<GeographicText> list = new ArrayList<GeographicText>();
   for (int i = 0; i < this.numEntries; i++) {
     CharSequence str = getText(i);
     Position pos = getPosition(i);
     GeographicText text = new UserFacingText(str, pos);
     text.setFont(this.placeNameService.getFont());
     text.setColor(this.placeNameService.getColor());
     text.setBackgroundColor(this.placeNameService.getBackgroundColor());
     text.setVisible(isNameVisible(dc, this.placeNameService, pos));
     text.setPriority(maxDisplayDistance);
     list.add(text);
   }
   return list;
 }
コード例 #13
0
 public SocketChannel detachChannel(long sig) {
   EventableSocketChannel ec = (EventableSocketChannel) Connections.get(sig);
   if (ec != null) {
     UnboundConnections.add(sig);
     return ec.getChannel();
   } else {
     return null;
   }
 }
コード例 #14
0
    public List<NavigationTile> navTilesVisible(
        DrawContext dc, double minDistSquared, double maxDistSquared) {
      ArrayList<NavigationTile> navList = new ArrayList<NavigationTile>();
      if (this.isNavSectorVisible(dc, minDistSquared, maxDistSquared)) {
        if (this.level > 0 && !this.hasSubTiles()) this.buildSubNavTiles();

        if (this.hasSubTiles()) {
          for (NavigationTile nav : subNavTiles) {
            navList.addAll(nav.navTilesVisible(dc, minDistSquared, maxDistSquared));
          }
        } else // at bottom level navigation tile
        {
          navList.add(this);
        }
      }

      return navList;
    }
コード例 #15
0
ファイル: ZCM.java プロジェクト: ZeroCM/zcm
  /**
   * Not for use by end users. Provider back ends call this method when they receive a message. The
   * subscribers that match the channel name are synchronously notified.
   */
  public void receiveMessage(String channel, byte data[], int offset, int length) {
    if (this.closed) throw new IllegalStateException();
    synchronized (subscriptions) {
      ArrayList<SubscriptionRecord> srecs = subscriptionsMap.get(channel);

      if (srecs == null) {
        // must build this list!
        srecs = new ArrayList<SubscriptionRecord>();
        subscriptionsMap.put(channel, srecs);

        for (SubscriptionRecord srec : subscriptions) {
          if (srec.pat.matcher(channel).matches()) srecs.add(srec);
        }
      }

      for (SubscriptionRecord srec : srecs) {
        srec.lcsub.messageReceived(this, channel, new ZCMDataInputStream(data, offset, length));
      }
    }
  }
コード例 #16
0
  /**
   * 描画用オブジェクト情報を作成する
   *
   * @param mqoMats MQOファイルから読み込んだマテリアル情報配列
   * @param mqoObjs MQOファイルのオブジェクト情報
   * @return 描画用オブジェクト情報
   */
  private GLObject makeObjs(GL10 gl, material mqoMats[], objects mqoObjs) {
    GLObject ret = null;
    ArrayList<GLMaterial> mats = new ArrayList<GLMaterial>();
    GLMaterial mr;
    KGLPoint[] vn = null;
    vn = vNormal(mqoObjs);
    for (int m = 0; m < mqoMats.length; m++) {
      mr = makeMats(gl, mqoMats[m], m, mqoObjs, vn);
      if (mr != null) {
        mats.add(mr);
      }
    }
    if (mats.size() == 0) return null;
    ret = new GLObject();
    ret.name = mqoObjs.name;
    ret.mat = mats.toArray(new GLMaterial[0]);
    ret.isVisible = (mqoObjs.data.visible != 0);

    return ret;
  }
コード例 #17
0
  @Override
  protected void doRender(DrawContext dc) {
    this.referencePoint = this.computeReferencePoint(dc);

    int serviceCount = this.placeNameServiceSet.getServiceCount();
    for (int i = 0; i < serviceCount; i++) {
      PlaceNameService placeNameService = this.placeNameServiceSet.getService(i);
      if (!isServiceVisible(dc, placeNameService)) continue;

      double minDistSquared =
          placeNameService.getMinDisplayDistance() * placeNameService.getMinDisplayDistance();
      double maxDistSquared =
          placeNameService.getMaxDisplayDistance() * placeNameService.getMaxDisplayDistance();

      if (isSectorVisible(
          dc, placeNameService.getMaskingSector(), minDistSquared, maxDistSquared)) {
        ArrayList<Tile> baseTiles = new ArrayList<Tile>();
        NavigationTile navTile = this.navTiles.get(i);
        // drill down into tiles to find bottom level navTiles visible
        List<NavigationTile> list = navTile.navTilesVisible(dc, minDistSquared, maxDistSquared);
        for (NavigationTile nt : list) {
          baseTiles.addAll(nt.getTiles());
        }

        for (Tile tile : baseTiles) {
          try {
            drawOrRequestTile(dc, tile, minDistSquared, maxDistSquared);
          } catch (Exception e) {
            Logging.logger()
                .log(
                    Level.FINE,
                    Logging.getMessage("layers.PlaceNameLayer.ExceptionRenderingTile"),
                    e);
          }
        }
      }
    }

    this.sendRequests();
    this.requestQ.clear();
  }
コード例 #18
0
 protected synchronized Message receiveMessage() throws IOException {
   if (messageBuffer.size() > 0) {
     Message m = (Message) messageBuffer.get(0);
     messageBuffer.remove(0);
     return m;
   }
   try {
     InetSocketAddress remoteAddress = (InetSocketAddress) channel.receive(receiveBuffer);
     if (remoteAddress != null) {
       int len = receiveBuffer.position();
       receiveBuffer.rewind();
       receiveBuffer.get(buf, 0, len);
       try {
         IP address = IP.fromInetAddress(remoteAddress.getAddress());
         int port = remoteAddress.getPort();
         extractor.appendData(buf, 0, len, new SocketDescriptor(address, port));
         receiveBuffer.clear();
         extractor.updateAvailableMessages();
         return extractor.nextMessage();
       } catch (EOFException exc) {
         exc.printStackTrace();
         System.err.println(buf.length + ", " + len);
       } catch (InvocationTargetException exc) {
         exc.printStackTrace();
       } catch (IllegalAccessException exc) {
         exc.printStackTrace();
       } catch (InstantiationException exc) {
         exc.printStackTrace();
       } catch (IllegalArgumentException e) {
         e.printStackTrace();
       } catch (InvalidCompressionMethodException e) {
         e.printStackTrace();
       }
     }
   } catch (ClosedChannelException exc) {
     if (isKeepAlive()) {
       throw exc;
     }
   }
   return null;
 }
コード例 #19
0
ファイル: VBO.java プロジェクト: mrdev023/MyFirstVoxel
 /**
  * @param id
  * @param data @Info Stocke le FloatBuffer dans le GPU
  */
 public void bufferData() {
   buffer = BufferUtils.createFloatBuffer(floatlist.size());
   for (Float f : floatlist) {
     buffer.put(f);
   }
   buffer.flip();
   glBindBuffer(GL_ARRAY_BUFFER, vboID);
   glBufferData(GL_ARRAY_BUFFER, buffer, GL_STATIC_DRAW);
   //		glBufferSubData(vboID, 0, buffer);
   glBindBuffer(GL_ARRAY_BUFFER, 0);
   bufferSize = buffer.limit() / 7; // 7 = 3 vertex(x,y,z) + 4 color (r,g,b,a)
 }
コード例 #20
0
  void removeUnboundConnections() {
    if (UnboundConnections.size() == 0) {
      return;
    }
    ArrayList<Long> currentUnboundConnections = UnboundConnections;
    // fix concurrent modification exception
    UnboundConnections = new ArrayList<Long>();
    for (long b : currentUnboundConnections) {
      EventableChannel ec = Connections.remove(b);
      if (ec != null) {
        if (ProxyConnections != null) {
          ProxyConnections.remove(b);
        }
        eventCallback(b, EM_CONNECTION_UNBOUND, null);
        ec.close();

        EventableSocketChannel sc = (EventableSocketChannel) ec;
        if (sc != null && sc.isAttached()) DetachedConnections.add(sc);
      }
    }
  }
コード例 #21
0
  public long attachChannel(SocketChannel sc, boolean watch_mode) {
    long b = createBinding();

    EventableSocketChannel ec = new EventableSocketChannel(sc, b, mySelector);

    ec.setAttached();
    if (watch_mode) ec.setWatchOnly();

    Connections.put(b, ec);
    NewConnections.add(b);

    return b;
  }
コード例 #22
0
ファイル: ZCM.java プロジェクト: ZeroCM/zcm
  /**
   * Subscribe to all channels whose name matches the regular expression. Note that to subscribe to
   * all channels, you must specify ".*", not "*".
   */
  public void subscribe(String regex, ZCMSubscriber sub) {
    if (this.closed) throw new IllegalStateException();
    SubscriptionRecord srec = new SubscriptionRecord();
    srec.regex = regex;
    srec.pat = Pattern.compile(regex);
    srec.lcsub = sub;

    synchronized (this) {
      zcmjni.subscribe(regex, this);
    }

    synchronized (subscriptions) {
      subscriptions.add(srec);

      for (String channel : subscriptionsMap.keySet()) {
        if (srec.pat.matcher(channel).matches()) {
          ArrayList<SubscriptionRecord> subs = subscriptionsMap.get(channel);
          subs.add(srec);
        }
      }
    }
  }
コード例 #23
0
  void addNewConnections() {
    ListIterator<EventableSocketChannel> iter = DetachedConnections.listIterator(0);
    while (iter.hasNext()) {
      EventableSocketChannel ec = iter.next();
      ec.cleanup();
    }
    DetachedConnections.clear();

    ListIterator<Long> iter2 = NewConnections.listIterator(0);
    while (iter2.hasNext()) {
      long b = iter2.next();

      EventableChannel ec = Connections.get(b);
      if (ec != null) {
        try {
          ec.register();
        } catch (ClosedChannelException e) {
          UnboundConnections.add(ec.getBinding());
        }
      }
    }
    NewConnections.clear();
  }
コード例 #24
0
ファイル: ClientGame.java プロジェクト: Hikari9/SpaceShooter
  void turnOnFadeLog() throws IOException {
    Global.log("Connecting to fade log...");
    while (true) {
      if (isDisposed()) throw new IOException("Client game disposed");
      Global.log("Connecting to port " + Global.fadeLogPort() + "...");
      try {
        fadeLog = new ClientByteStream(ip, Global.fadeLogPort(), 12);
        break;
      } catch (IOException ex) {
      }
    }
    Global.log("Connected!");
    timers.add(
        new FixedTimer(
            new FixedTask() {
              public boolean fixedRate() {
                return false;
              }

              public float FPS() {
                return Global.ReceiveFPS;
              }

              public void run() {
                String s = null;
                byte[] data = null;
                try {
                  data = fadeLog.read();
                  if (data == null) return;
                  s = fadeLog.readLine();
                } catch (IOException ex) {
                  System.err.println("Error reading from fade log: " + ex);
                  Global.onException();
                  stop();
                  return;
                }
                if (s == null) return;
                ByteBuffer bb = ByteBuffer.wrap(data);
                float x = bb.getFloat();
                float y = bb.getFloat();
                Color color = Global.IntToColor(bb.getInt());

                // if fade color is same as ship color, play power-up sound

                if (color.equals(getPlayerShip().fill)) Sounds.powerUp.play();

                fadeLog(s, x, y, color);
              }
            }));
  }
コード例 #25
0
ファイル: SourceFile.java プロジェクト: movinghorse/YCombo
  /**
   * Travel dependencies tree by DFS and Post-Order algorithm.
   *
   * @param tree The initial tree which contains root node only.
   * @param footprint The footprint of the traversal.
   * @param output Output queue of combined files.
   */
  private void travel(
      Stack<ArrayList<String>> tree, Stack<String> footprint, ArrayList<String> output) {
    for (String node : tree.peek()) {
      // Detect circular dependences by looking back footprint.
      if (footprint.contains(node)) {
        String msg = "Circular dependences was found\n";
        for (String path : footprint) {
          msg += "    " + path + " ->\n";
        }
        msg += "    " + node;
        App.exit(msg);
      }

      // Skip visited node.
      if (output.contains(node)) {
        continue;
      }

      // Move forward.
      footprint.push(node);

      // Add sub nodes.
      tree.push(getDependencies(node));

      // Travel sub nodes.
      travel(tree, footprint, output);

      // Clean visited nodes.
      tree.pop();

      // Move backward.
      footprint.pop();

      // Add first visited node to output queue.
      output.add(node);
    }
  }
コード例 #26
0
ファイル: ClientGame.java プロジェクト: Hikari9/SpaceShooter
  void turnOnBulletReceiver() throws IOException {
    Global.log("Turning on bullet receiver...");
    while (true) {
      if (isDisposed()) throw new IOException("Client game disposed");
      Global.log("Connecting to port " + (Global.bulletPort()) + "...");
      try {
        bulletStream = new ClientByteStream(ip, Global.bulletPort(), Bullet.bufferSize());
        break;
      } catch (IOException ex) {
      }
    }
    Global.log("Connected!");
    timers.add(
        new FixedTimer(
            new FixedTask() {
              public boolean fixedRate() {
                return true;
              }

              public float FPS() {
                return Global.ReceiveFPS * 20;
              }

              public void run() {
                byte[] data = null;
                try {
                  data = bulletStream.read();
                } catch (IOException ex) {
                  System.err.println("Bullet receiver error: " + ex);
                  Global.onException();
                  stop();
                  return;
                }
                if (data == null) return;
                Bullet toSpawn = Bullet.fromBytes(data);
                Ship find = cShip.get(toSpawn.getFill());
                if (find == null) {
                  for (Ship s : turrets) {
                    if (s.fill.equals(toSpawn.getFill())) {
                      find = s;
                      break;
                    }
                  }
                }
                if (find == null) return;
                find.getBulletSet().add(toSpawn);
              }
            }));
  }
コード例 #27
0
  void isReadable(SelectionKey k) {
    EventableChannel ec = (EventableChannel) k.attachment();
    long b = ec.getBinding();

    if (ec.isWatchOnly()) {
      if (ec.isNotifyReadable()) eventCallback(b, EM_CONNECTION_NOTIFY_READABLE, null);
    } else {
      myReadBuffer.clear();

      try {
        ec.readInboundData(myReadBuffer);
        myReadBuffer.flip();
        if (myReadBuffer.limit() > 0) eventCallback(b, EM_CONNECTION_READ, myReadBuffer);
      } catch (IOException e) {
        UnboundConnections.add(b);
      }
    }
  }
コード例 #28
0
ファイル: ClientGame.java プロジェクト: Hikari9/SpaceShooter
  void turnOnTurretReceiver() throws IOException {
    Global.log("Turning on turret receiver...");
    while (true) {
      if (isDisposed()) throw new IOException("Client game disposed");
      Global.log("Connecting to port " + Global.turretPort() + "...");
      try {
        turretStream = new ClientByteStream(ip, Global.turretPort(), Ship.bufferSize());
        break;
      } catch (IOException ex) {
      }
    }
    Global.log("Connected!");
    timers.add(
        new FixedTimer(
            new FixedTask() {
              public boolean fixedRate() {
                return false;
              }

              public float FPS() {
                return Global.ReceiveFPS;
              }

              public void run() {
                byte[] data = null;
                String name = null;
                try {
                  data = turretStream.read();
                  name = turretStream.readLine();
                } catch (IOException ex) {
                  System.err.println("Cannot read info from turret stream");
                  Global.onException();
                  stop();
                  return;
                }
                if (data == null) return;
                Ship s = new Ship(name, Global.transparent);
                s.setDesign(new Design.Turret(s));
                s.fromBytes(data, false);
                addShip(s);
              }
            }));
  }
コード例 #29
0
  private boolean showDialog() {
    String[] types = {"RAW", "JPEG", "ZLIB"};
    GenericDialog gd = new GenericDialog("Generate Bricks");
    gd.addChoice("FileType", types, filetype);
    gd.addNumericField("JPEG quality", jpeg_quality, 0);
    gd.addNumericField("Max file size (MB)", bdsizelimit, 0);

    int[] wlist = WindowManager.getIDList();
    if (wlist == null) return false;

    String[] titles = new String[wlist.length];
    for (int i = 0; i < wlist.length; i++) titles[i] = "";

    int tnum = 0;
    for (int i = 0; i < wlist.length; i++) {
      ImagePlus imp = WindowManager.getImage(wlist[i]);
      if (imp != null) {
        titles[tnum] = imp.getTitle();
        tnum++;
      }
    }
    gd.addChoice("Source image: ", titles, titles[0]);

    gd.showDialog();
    if (gd.wasCanceled()) return false;

    filetype = types[gd.getNextChoiceIndex()];
    jpeg_quality = (int) gd.getNextNumber();
    if (jpeg_quality > 100) jpeg_quality = 100;
    if (jpeg_quality < 0) jpeg_quality = 0;
    bdsizelimit = (int) gd.getNextNumber();

    int id = gd.getNextChoiceIndex();
    lvImgTitle = new ArrayList<String>();
    lvImgTitle.add(titles[id]);

    Prefs.set("filetype.string", filetype);
    Prefs.set("jpeg_quality.int", jpeg_quality);
    Prefs.set("bdsizelimit.int", bdsizelimit);

    return true;
  }
コード例 #30
0
  void close() {
    try {
      if (mySelector != null) mySelector.close();
    } catch (IOException e) {
    }
    mySelector = null;

    // run down open connections and sockets.
    Iterator<ServerSocketChannel> i = Acceptors.values().iterator();
    while (i.hasNext()) {
      try {
        i.next().close();
      } catch (IOException e) {
      }
    }

    // 29Sep09: We create an ArrayList of the existing connections, then iterate over
    // that to call unbind on them. This is because an unbind can trigger a reconnect,
    // which will add to the Connections HashMap, causing a ConcurrentModificationException.
    // XXX: The correct behavior here would be to latch the various reactor methods to return
    // immediately if the reactor is shutting down.
    ArrayList<EventableChannel> conns = new ArrayList<EventableChannel>();
    Iterator<EventableChannel> i2 = Connections.values().iterator();
    while (i2.hasNext()) {
      EventableChannel ec = i2.next();
      if (ec != null) {
        conns.add(ec);
      }
    }
    Connections.clear();

    ListIterator<EventableChannel> i3 = conns.listIterator(0);
    while (i3.hasNext()) {
      EventableChannel ec = i3.next();
      eventCallback(ec.getBinding(), EM_CONNECTION_UNBOUND, null);
      ec.close();

      EventableSocketChannel sc = (EventableSocketChannel) ec;
      if (sc != null && sc.isAttached()) DetachedConnections.add(sc);
    }

    ListIterator<EventableSocketChannel> i4 = DetachedConnections.listIterator(0);
    while (i4.hasNext()) {
      EventableSocketChannel ec = i4.next();
      ec.cleanup();
    }
    DetachedConnections.clear();
  }