コード例 #1
0
ファイル: krypton_api.java プロジェクト: 0ldMaid/Krypton
  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;
  } // *************************************
コード例 #2
0
 public void run() {
   while (true) {
     LinkedList<PacketCallbackStruct> list = null;
     try {
       queuedPacketCallbacksLock.lock();
       try {
         queuedPacketCallbacksNotEmpty.await();
       } catch (Exception e) {
         Log.error(
             "RDPServer.PacketCallbackThread: queuedPacketCallbacksNotEmpty.await() caught exception "
                 + e.getMessage());
       }
       list = queuedPacketCallbacks;
       queuedPacketCallbacks = new LinkedList<PacketCallbackStruct>();
     } finally {
       queuedPacketCallbacksLock.unlock();
     }
     if (Log.loggingNet)
       Log.net("RDPServer.PacketCallbackThread: Got " + list.size() + " queued packets");
     for (PacketCallbackStruct pcs : list) {
       try {
         callbackProcessPacket(pcs.cb, pcs.con, pcs.packet);
       } catch (Exception e) {
         Log.exception("RDPServer.PacketCallbackThread: ", e);
       }
     }
   }
 }
コード例 #3
0
 public void addFinishedTarget(Target target) {
   // 向finishedTargets队列中加入一个任务
   synchronized (finishedTargets) {
     finishedTargets.notify();
     finishedTargets.add(target);
   }
 }
コード例 #4
0
 // Test method
 public LinkedList<Integer> getLiveAuctionsIds() throws RemoteException {
   LinkedList<Integer> ll = new LinkedList<Integer>();
   for (AuctionItem t : liveAuctionItems.values()) {
     ll.add(t.getAuctionId());
   }
   return ll;
 }
コード例 #5
0
 @Override
 public LinkedList<String> getExpiredAuctions() throws RemoteException {
   LinkedList<String> ll = new LinkedList<String>();
   for (ExpiredAuctionItem item : expiredAuctions.values()) {
     ll.add(item.toString());
   }
   return ll;
 }
コード例 #6
0
 @Override
 public LinkedList<String> getExistingAuctions() throws RemoteException {
   LinkedList<String> ll = new LinkedList<String>();
   for (AuctionItem i : liveAuctionItems.values()) {
     ll.add(i.toString());
   }
   return ll;
 }
コード例 #7
0
ファイル: ShowComp.java プロジェクト: vishalshar/NetMon
  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);
  }
コード例 #8
0
ファイル: StdTickGroup.java プロジェクト: renokun/CoffeeMud
 @Override
 public Iterator<TickClient> getTickSet(final Tickable T, final int tickID) {
   final LinkedList<TickClient> subSet = new LinkedList<TickClient>();
   if (tickID < 0)
     subSet.addAll(
         tickers.subSet(
             new StdTickClient(T, 0, 0), true, new StdTickClient(T, 0, Integer.MAX_VALUE), true));
   else
     subSet.addAll(
         tickers.subSet(
             new StdTickClient(T, 0, tickID), true, new StdTickClient(T, 0, tickID), true));
   return subSet.iterator();
 }
コード例 #9
0
ファイル: JMegaHal.java プロジェクト: javawizard/jzbot
  /** Generate a sentence that includes (if possible) the specified word. */
  public String getSentence(String word) {
    LinkedList parts = new LinkedList();

    Quad[] quads;
    if (words.containsKey(word)) {
      quads = (Quad[]) ((HashSet) words.get(word)).toArray(new Quad[0]);
    } else {
      quads = (Quad[]) this.quads.keySet().toArray(new Quad[0]);
    }

    if (quads.length == 0) {
      return "";
    }

    Quad middleQuad = quads[rand.nextInt(quads.length)];
    Quad quad = middleQuad;

    for (int i = 0; i < 4; i++) {
      parts.add(quad.getToken(i));
    }

    while (quad.canEnd() == false) {
      String[] nextTokens = (String[]) ((HashSet) next.get(quad)).toArray(new String[0]);
      String nextToken = nextTokens[rand.nextInt(nextTokens.length)];
      quad =
          (Quad)
              this.quads.get(
                  new Quad(quad.getToken(1), quad.getToken(2), quad.getToken(3), nextToken));
      parts.add(nextToken);
    }

    quad = middleQuad;
    while (quad.canStart() == false) {
      String[] previousTokens = (String[]) ((HashSet) previous.get(quad)).toArray(new String[0]);
      String previousToken = previousTokens[rand.nextInt(previousTokens.length)];
      quad =
          (Quad)
              this.quads.get(
                  new Quad(previousToken, quad.getToken(0), quad.getToken(1), quad.getToken(2)));
      parts.addFirst(previousToken);
    }

    StringBuffer sentence = new StringBuffer();
    Iterator it = parts.iterator();
    while (it.hasNext()) {
      String token = (String) it.next();
      sentence.append(token);
    }

    return sentence.toString();
  }
コード例 #10
0
ファイル: ShowComp.java プロジェクト: vishalshar/NetMon
 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;
   }
 }
コード例 #11
0
 public void printFinishedTargets() {
   // 打印finisedTargets队列中的任务
   try {
     for (; ; ) {
       Target target = null;
       synchronized (finishedTargets) {
         while (finishedTargets.size() == 0) finishedTargets.wait();
         target = (Target) finishedTargets.removeFirst();
       }
       target.show();
     }
   } catch (InterruptedException x) {
     return;
   }
 }
コード例 #12
0
ファイル: ShowComp.java プロジェクト: vishalshar/NetMon
    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);
      }
    }
コード例 #13
0
ファイル: MonitorFilter.java プロジェクト: Rikatouka/net.jxta
  /** {@inheritDoc} */
  public void initializeFrom(Element element) throws DocumentSerializationException {
    for (Enumeration e = element.getChildren(); e.hasMoreElements(); ) {
      Element serviceElement = (TextElement) e.nextElement();
      String tagName = (String) serviceElement.getKey();

      if (tagName.equals("service")) {
        try {
          ModuleClassID moduleClassID =
              (ModuleClassID)
                  IDFactory.fromURI(
                      new URI(
                          DocumentSerializableUtilities.getString(
                              serviceElement, "moduleClassID", "ERROR")));

          try {
            ServiceMonitorFilter serviceMonitorFilter =
                MonitorResources.createServiceMonitorFilter(moduleClassID);
            serviceMonitorFilter.init(moduleClassID);
            Element serviceMonitorFilterElement =
                DocumentSerializableUtilities.getChildElement(serviceElement, "serviceFilter");
            serviceMonitorFilter.initializeFrom(serviceMonitorFilterElement);
            serviceMonitorFilters.put(moduleClassID, serviceMonitorFilter);
          } catch (Exception ex) {
            if (unknownModuleClassIDs == null) unknownModuleClassIDs = new LinkedList();

            unknownModuleClassIDs.add(moduleClassID);
          }
        } catch (URISyntaxException jex) {
          throw new DocumentSerializationException("Can't get ModuleClassID", jex);
        }
      }
    }
  }
コード例 #14
0
  public void addTarget(Target target) {
    // 向targets队列中加入一个任务
    SocketChannel socketChannel = null;
    try {
      socketChannel = SocketChannel.open();
      socketChannel.configureBlocking(false);
      socketChannel.connect(target.address);

      target.channel = socketChannel;
      target.connectStart = System.currentTimeMillis();

      synchronized (targets) {
        targets.add(target);
      }
      selector.wakeup();
    } catch (Exception x) {
      if (socketChannel != null) {
        try {
          socketChannel.close();
        } catch (IOException xx) {
        }
      }
      target.failure = x;
      addFinishedTarget(target);
    }
  }
コード例 #15
0
ファイル: UserData.java プロジェクト: parthiban-manick/OpenDJ
  /** Creates a user data object with default values. */
  public UserData() {
    interactive = true;
    startServer = true;
    enableWindowsService = false;
    forceOnError = true;
    verbose = false;

    LinkedList<String> baseDn = new LinkedList<>();
    baseDn.add("dc=example,dc=com");
    NewSuffixOptions defaultNewSuffixOptions = NewSuffixOptions.createEmpty(baseDn);
    setNewSuffixOptions(defaultNewSuffixOptions);

    // See what we can propose as port
    int defaultLdapPort = getDefaultPort();
    if (defaultLdapPort != -1) {
      setServerPort(defaultLdapPort);
    }

    //  See what we can propose as port
    int defaultAdminPort = getDefaultAdminConnectorPort();
    if (defaultAdminPort != -1) {
      setAdminConnectorPort(defaultAdminPort);
    }

    setHostName(getDefaultHostName());

    setDirectoryManagerDn(Constants.DIRECTORY_MANAGER_DN);

    setNewSuffixOptions(defaultNewSuffixOptions);
    DataReplicationOptions repl = DataReplicationOptions.createStandalone();
    setReplicationOptions(repl);
    setGlobalAdministratorUID(Constants.GLOBAL_ADMIN_UID);

    SuffixesToReplicateOptions suffixes =
        new SuffixesToReplicateOptions(
            SuffixesToReplicateOptions.Type.REPLICATE_WITH_EXISTING_SUFFIXES,
            new HashSet<SuffixDescriptor>(),
            new HashSet<SuffixDescriptor>());
    setSuffixesToReplicateOptions(suffixes);
    SecurityOptions sec = SecurityOptions.createNoCertificateOptions();
    sec.setSslPort(getDefaultSslPort(defaultLdapPort));
    setSecurityOptions(sec);

    remoteWithNoReplicationPort = new HashMap<>();

    createDefaultJavaArguments();
  }
コード例 #16
0
ファイル: ShowComp.java プロジェクト: vishalshar/NetMon
    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);
          }
        }
      }
    }
コード例 #17
0
ファイル: draw.java プロジェクト: bossiernesto/jvmbytecodes
  // 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)
コード例 #18
0
  /**
   * Helper function: update the "old" RM group with the "next" group provided.
   *
   * @param old
   * @param next
   */
  private void updateRMGroup(LinkedList<MemberInfo> old, LinkedList<MemberInfo> next) {
    if (next == null || next.isEmpty()) {
      System.out.println("empty or null next MemberInfo sent in updated.");
      return;
    }

    // Add to our old list the memberInfo objects that were not previously there.
    for (MemberInfo m : next) {
      if (old == null) {
        System.out.println("OLD NULL");
      }

      if (m == null) {
        System.out.println("M NULL");
      }

      if (!old.contains(m)) {
        old.add(m);
      }
    }

    // Remove from our old list the memberInfo objects that are absent in next.
    LinkedList<MemberInfo> toRemove = new LinkedList<MemberInfo>();
    for (MemberInfo m : old) {
      if (!next.contains(m)) {
        toRemove.add(m);
      }
    }
    for (MemberInfo m : toRemove) {
      old.remove(m);
    }
  }
コード例 #19
0
    public void sendMessage(Address address, byte[] message) throws java.io.IOException {
      Socket s = null;
      SocketEntry entry = (SocketEntry) sockets.get(address);
      if (logger.isDebugEnabled()) {
        logger.debug("Looking up connection for destination '" + address + "' returned: " + entry);
        logger.debug(sockets.toString());
      }
      if (entry != null) {
        s = entry.getSocket();
      }
      if ((s == null) || (s.isClosed())) {
        if (logger.isDebugEnabled()) {
          logger.debug("Socket for address '" + address + "' is closed, opening it...");
        }
        SocketChannel sc = null;
        try {
          // Open the channel, set it to non-blocking, initiate connect
          sc = SocketChannel.open();
          sc.configureBlocking(false);
          sc.connect(
              new InetSocketAddress(
                  ((TcpAddress) address).getInetAddress(), ((TcpAddress) address).getPort()));
          s = sc.socket();
          entry = new SocketEntry((TcpAddress) address, s);
          entry.addMessage(message);
          sockets.put(address, entry);

          synchronized (pending) {
            pending.add(entry);
          }

          selector.wakeup();
          logger.debug("Trying to connect to " + address);
        } catch (IOException iox) {
          logger.error(iox);
          throw iox;
        }
      } else {
        entry.addMessage(message);
        synchronized (pending) {
          pending.add(entry);
        }
        selector.wakeup();
      }
    }
コード例 #20
0
  /** Get the Transport Metric for a specific Transport Type */
  public TransportMetric getTransportMetric(String protocol, EndpointAddress endpointAddress) {
    for (Iterator i = transportMetrics.iterator(); i.hasNext(); ) {
      TransportMetric transportMetric = (TransportMetric) i.next();
      if (protocol.equals(transportMetric.getProtocol())
          && endpointAddress.equals(transportMetric.getEndpointAddress())) return transportMetric;
    }

    return null;
  }
コード例 #21
0
  public void registerTargets() {
    // 取出targets队列中的任务,向Selector注册连接就绪事件
    synchronized (targets) {
      while (targets.size() > 0) {
        Target target = (Target) targets.removeFirst();

        try {
          target.channel.register(selector, SelectionKey.OP_CONNECT, target);
        } catch (IOException x) {
          try {
            target.channel.close();
          } catch (IOException e) {
            e.printStackTrace();
          }
          target.failure = x;
          addFinishedTarget(target);
        }
      }
    }
  }
コード例 #22
0
  /** {@inheritDoc} */
  public void serializeTo(Element element) throws DocumentSerializationException {
    for (Iterator i = transportMetrics.iterator(); i.hasNext(); ) {
      TransportMetric transportMetric = (TransportMetric) i.next();

      DocumentSerializableUtilities.addDocumentSerializable(
          element, "transportMetric", transportMetric);
    }
    if (moduleClassID != null) {
      DocumentSerializableUtilities.addString(element, "moduleClassID", moduleClassID.toString());
    }
  }
コード例 #23
0
ファイル: SVGApplet.java プロジェクト: shahidminhas/abc
 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;
 }
コード例 #24
0
    private void processPending() {
      synchronized (pending) {
        while (pending.size() > 0) {
          SocketEntry entry = (SocketEntry) pending.removeFirst();
          try {
            // Register the channel with the selector, indicating
            // interest in connection completion and attaching the
            // target object so that we can get the target back
            // after the key is added to the selector's
            // selected-key set
            if (entry.getSocket().isConnected()) {
              entry.getSocket().getChannel().register(selector, SelectionKey.OP_WRITE, entry);
            } else {
              entry.getSocket().getChannel().register(selector, SelectionKey.OP_CONNECT, entry);
            }

          } catch (IOException iox) {
            logger.error(iox);
            // Something went wrong, so close the channel and
            // record the failure
            try {
              entry.getSocket().getChannel().close();
              TransportStateEvent e =
                  new TransportStateEvent(
                      DefaultTcpTransportMapping.this,
                      entry.getPeerAddress(),
                      TransportStateEvent.STATE_CLOSED,
                      iox);
              fireConnectionStateChanged(e);
            } catch (IOException ex) {
              logger.error(ex);
            }
            lastError = iox;
          }
        }
      }
    }
コード例 #25
0
ファイル: draw.java プロジェクト: bossiernesto/jvmbytecodes
  public int createericlist(Element snap) {
    int numsnaps = 0;

    StructureCollection structs = new StructureCollection();
    LinkedList tempList = new LinkedList();

    try {
      load_snap_from_xml(snap, structs, tempList);

      structs.calcDimsAndStartPts(tempList, this);
      structs.drawTitle(tempList, this);
      structs.drawStructure(tempList, this);

    } catch (VisualizerLoadException e) {
      System.out.println(e.toString());
    }

    list_of_snapshots.append(tempList);
    Snaps++;

    return numsnaps; // this.. isnt used, and isnt what it says it is.
  } // createericlist(element)
コード例 #26
0
  /** {@inheritDoc} */
  public void initializeFrom(Element element) throws DocumentSerializationException {
    for (Enumeration e = element.getChildren(); e.hasMoreElements(); ) {
      Element childElement = (TextElement) e.nextElement();
      String tagName = (String) childElement.getKey();

      if (tagName.equals("transportMetric")) {
        TransportMetric transportMetric =
            (TransportMetric)
                DocumentSerializableUtilities.getDocumentSerializable(
                    childElement, TransportMetric.class);
        transportMetrics.add(transportMetric);
      }
      if (tagName.equals("moduleClassID")) {
        try {
          moduleClassID =
              (ModuleClassID)
                  IDFactory.fromURI(new URI(DocumentSerializableUtilities.getString(childElement)));
        } catch (URISyntaxException jex) {
          throw new DocumentSerializationException("Can't read moduleClassID", jex);
        }
      }
    }
  }
コード例 #27
0
ファイル: StdTickGroup.java プロジェクト: renokun/CoffeeMud
 @Override
 public Iterator<TickClient> getLocalItems(int itemTypes, Room R) {
   LinkedList<TickClient> localItems = null;
   for (TickClient C : tickers) {
     switch (itemTypes) {
       case 0:
         if (C.getClientObject() instanceof MOB) {
           if (((MOB) C.getClientObject()).getStartRoom() == R) {
             if (localItems == null) localItems = new LinkedList<TickClient>();
             localItems.add(C);
           }
         } else if ((C.getClientObject() instanceof ItemTicker)
             && ((((ItemTicker) C.getClientObject()).properLocation() == R))) {
           if (localItems == null) localItems = new LinkedList<TickClient>();
           localItems.add(C);
         }
         break;
       case 1:
         if ((C.getClientObject() instanceof ItemTicker)
             && ((((ItemTicker) C.getClientObject()).properLocation() == R))) {
           if (localItems == null) localItems = new LinkedList<TickClient>();
           localItems.add(C);
         }
         break;
       case 2:
         if ((C.getClientObject() instanceof MOB)
             && (((MOB) C.getClientObject()).getStartRoom() == R)) {
           if (localItems == null) localItems = new LinkedList<TickClient>();
           localItems.add(C);
         }
         break;
     }
   }
   if (localItems == null) return null;
   return localItems.iterator();
 }
コード例 #28
0
ファイル: MonitorFilter.java プロジェクト: Rikatouka/net.jxta
 /**
  * Get a list of ModuleClassIDs for subfilters that could not be deserialized because they weren't
  * registered
  *
  * @see MonitorResources
  * @return Iterator
  */
 public Iterator getUnknownModuleClassIDs() {
   if (unknownModuleClassIDs != null) return unknownModuleClassIDs.iterator();
   else return new LinkedList().iterator();
 }
コード例 #29
0
ファイル: draw.java プロジェクト: bossiernesto/jvmbytecodes
  // Although it presently returns a boolean, that was only needed
  // during my aborted attempted at animated graphics primitives.
  // Until those become a reality the boolean value returned by this
  // routine is unnecessary
  public boolean animate(int sAt, boolean forward) {

    int x;
    LinkedList lt = null;
    animation_done =
        true; // May be re-set in paintComponent via indirect paintImmediately call at end

    // Was used in aborted attempted to
    // introduce animated primitives.  Now
    // it's probably excess baggage that
    // remains because I still have hopes
    // of eventually having animated
    // primitives

    if (getSize().width != 0 && getSize().height != 0) {
      my_width = getSize().width; // set dimensions
      my_height = getSize().height;
    } else {
      my_width = GaigsAV.preferred_width; // set dimensions
      my_height = GaigsAV.preferred_height;
    }

    // First capture the new image in a buffer called image2
    SnapAt = sAt;
    BufferedImage image2 = new BufferedImage(my_width, my_height, BufferedImage.TYPE_INT_RGB);
    Graphics2D g2 = (Graphics2D) image2.getGraphics(); // need a separate object each time?
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setColor(Color.WHITE);
    g2.fillRect(0, 0, my_width, my_height);
    // Set horizoff and vertoff to properly center the visualization in the
    // viewing window. This is not quite perfect because visualizations
    // that are not properly centered within their [0,1] localized
    // coordinates will not be perfectly centered, but it is much better
    // than it was previously.

    if (no_mouse_drag) {
      horizoff = (my_width - GaigsAV.preferred_width) / 2;
      vertoff = (my_height - GaigsAV.preferred_height) / 2;
    }

    list_of_snapshots.reset();
    x = 0;
    lt = new LinkedList();
    while (x < SnapAt && list_of_snapshots.hasMoreElements()) {
      lt = (LinkedList) list_of_snapshots.nextElement();
      x++;
    }
    lt.reset();
    animation_done = true;
    //        System.out.println("before loop " + horizoff);
    while (lt.hasMoreElements()) {
      obj tempObj = (obj) lt.nextElement();
      animation_done =
          animation_done && (tempObj.execute(g2 /*offscreen*/, zoom, vertoff, horizoff));
      //  System.out.println("in loop");
    }

    // Next capture the image we are coming from in a buffer called image1
    SnapAt = (forward ? sAt - 1 : sAt + 1);
    BufferedImage image1 = new BufferedImage(my_width, my_height, BufferedImage.TYPE_INT_RGB);
    Graphics2D g1 = (Graphics2D) image1.getGraphics(); // need a separate object each time?
    g1.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g1.setColor(Color.WHITE);
    g1.fillRect(0, 0, my_width, my_height);
    // Set horizoff and vertoff to properly center the visualization in the
    // viewing window. This is not quite perfect because visualizations
    // that are not properly centered within their [0,1] localized
    // coordinates will not be perfectly centered, but it is much better
    // than it was previously.

    if (no_mouse_drag) {
      horizoff = (my_width - GaigsAV.preferred_width) / 2;
      vertoff = (my_height - GaigsAV.preferred_height) / 2;
    }

    list_of_snapshots.reset();
    x = 0;
    lt = new LinkedList();
    while (x < SnapAt && list_of_snapshots.hasMoreElements()) {
      lt = (LinkedList) list_of_snapshots.nextElement();
      x++;
    }
    lt.reset();
    animation_done = true;
    //        System.out.println("before loop " + horizoff);
    while (lt.hasMoreElements()) {
      obj tempObj = (obj) lt.nextElement();
      animation_done =
          animation_done && (tempObj.execute(g1 /*offscreen*/, zoom, vertoff, horizoff));
      //  System.out.println("in loop");
    }

    // Now slide from image1 to image2

    // From the gaff Visualizer by Chris Gaffney
    //        double step = 4;	// Adjust this for more/less granularity between images
    double step = 40; // Adjust this for more/less granularity between images

    Image buffer = getGraphicsConfiguration().createCompatibleVolatileImage(my_width, my_height);
    Graphics2D g2d = (Graphics2D) buffer.getGraphics();

    AffineTransform trans = AffineTransform.getTranslateInstance(step * (forward ? -1 : 1), 0);
    //        AffineTransform orig = g2d.getTransform();

    Shape mask = createMask(my_width, my_height);

    for (double i = 0; i < my_width; i += step) {
      if (i + step > my_width) // last time through loop, so adjust transform
      trans =
            AffineTransform.getTranslateInstance(((double) (my_width - i)) * (forward ? -1 : 1), 0);
      g2d.transform(trans);
      g2d.drawImage(image1, 0, 0, this);
      g2d.setColor(Color.BLACK);
      g2d.fill(mask);

      AffineTransform last = g2d.getTransform();
      g2d.transform(AffineTransform.getTranslateInstance(my_width * (-1 * (forward ? -1 : 1)), 0));
      g2d.drawImage(image2, 0, 0, this);
      g2d.setColor(Color.BLACK);
      g2d.fill(mask);

      g2d.setTransform(last);

      this.my_image = buffer;
      repaint();

      try {
        Thread.sleep(10);
      } catch (InterruptedException e) {

      }
    }
    Image b = getGraphicsConfiguration().createCompatibleImage(my_width, my_height);
    b.getGraphics().drawImage(buffer, 0, 0, null);
    this.my_image = b;

    return animation_done;
  }
コード例 #30
0
ファイル: draw.java プロジェクト: bossiernesto/jvmbytecodes
  // Although it presently returns a boolean, that was only needed
  // during my aborted attempted at animated graphics primitives.
  // Until those become a reality the boolean value returned by this
  // routine is unnecessary
  public /*synchronized*/ boolean execute(int sAt) {

    // The commented-out variables below are remnants from legacy
    // code -- they appear to be no longer needed.

    //         String urlTemp="";
    //         int z=0;
    //         int idx;
    //         int urlid;
    //         boolean showURL=false;
    animation_done =
        true; // May be re-set in paintComponent via indirect paintImmediately call at end

    // Was used in abored attempted to
    // introduce animated primitives.  Now
    // it's probably excess baggage that
    // remains because I still have hopes
    // of eventually having animated
    // primitives
    SnapAt = sAt;

    if (getSize().width != 0 && getSize().height != 0) {
      my_width = getSize().width; // set dimensions
      my_height = getSize().height;
    } else {
      my_width = GaigsAV.preferred_width; // set dimensions
      my_height = GaigsAV.preferred_height;
    }
    BufferedImage buff = new BufferedImage(my_width, my_height, BufferedImage.TYPE_INT_RGB);
    Graphics2D g2 = (Graphics2D) buff.getGraphics(); // need a separate object each time?
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setColor(Color.WHITE);
    g2.fillRect(0, 0, my_width, my_height);
    // Set horizoff and vertoff to properly center the visualization in the
    // viewing window. This is not quite perfect because visualizations
    // that are not properly centered within their [0,1] localized
    // coordinates will not be perfectly centered, but it is much better
    // than it was previously.

    // 	if(no_mouse_drag){
    // 	    if(first_paint_call){
    // // 		horizoff = (my_width - (int)(0.25 * my_width) -
    // // 			    GaigsAV.preferred_width) / 2;
    // 		horizoff = (my_width - GaigsAV.preferred_width) / 2;
    // 		first_paint_call = false;
    // 	    }else{
    // 		horizoff = (my_width - GaigsAV.preferred_width) / 2;
    // 		no_mouse_drag = false;
    // 	    }
    // 	}

    if (no_mouse_drag) {
      horizoff = (my_width - GaigsAV.preferred_width) / 2;
      vertoff = (my_height - GaigsAV.preferred_height) / 2;
    }

    int x;

    list_of_snapshots.reset();
    x = 0;
    LinkedList lt = new LinkedList();
    while (x < SnapAt && list_of_snapshots.hasMoreElements()) {
      lt = (LinkedList) list_of_snapshots.nextElement();
      x++;
    }
    lt.reset();
    animation_done = true;
    //        System.out.println("before loop " + horizoff);
    while (lt.hasMoreElements()) {
      obj tempObj = (obj) lt.nextElement();
      animation_done =
          animation_done && (tempObj.execute(g2 /*offscreen*/, zoom, vertoff, horizoff));
      //  System.out.println("in loop");
    }

    Shape mask = createMask(buff.getWidth(), buff.getHeight());

    g2.setColor(Color.BLACK);
    g2.fill(mask);

    my_image = buff;
    repaint();

    return animation_done;
  }