예제 #1
0
  /**
   * Spawn a character on the map
   *
   * @param MiX Minimum X value
   * @param MiY Minimum Y value
   * @param MaX Maximum X value
   * @param MaY Maximum Y value
   */
  public void Spawn(int MiX, int MiY, int MaX, int MaY) {
    double Nx = 0, Ny = 0;

    // Random coordinate
    Nx = Math.random() * MaX + MiX;
    Ny = Math.random() * MaY + MiY;

    // Store block number
    int BNum = MAP.elementAt(0).getBlockNum(Nx + W / 2, Ny + H / 2);

    // if invalid block number
    if (BNum == -1) {
      Spawn(MiX, MiY, MaX, MaY);
    }

    // if invalid surface
    else if (!isValidSurface(MAP.elementAt(0).Fill[BNum])) {
      Spawn(MiX, MiY, MaX, MaY);
    }

    // if colliding with something
    else if (this.Collision(Nx + W / 2, Ny + H / 2)) {
      Spawn(MiX, MiY, MaX, MaY);
    } else {
      X = Nx;
      Y = Ny;
    }
  }
예제 #2
0
 protected void fireChangeListeners() {
   if (changeListeners == null) return;
   for (int a = 0; a < changeListeners.size(); a++) {
     ChangeListener l = (ChangeListener) changeListeners.get(a);
     try {
       l.stateChanged(new ChangeEvent(this));
     } catch (RuntimeException e) {
       e.printStackTrace();
     }
   }
 }
예제 #3
0
  /**
   * Used for debugging get list of spells available to character
   *
   * @return List
   */
  public String[] getSpellList() {
    // Make Array
    String[] arg = new String[SPELL_LIST.size()];

    // Assign names
    for (int i = 0; i < arg.length; i++) {
      arg[i] = SPELL_LIST.elementAt(i)[0].NAME;
      System.out.println(arg[i]);
    }

    // Return list
    return arg;
  }
예제 #4
0
 /*
  * The Huffman class constructor
  */
 public Huffman(int Width, int Height) {
   bits = new Vector();
   bits.addElement(bitsDCluminance);
   bits.addElement(bitsACluminance);
   bits.addElement(bitsDCchrominance);
   bits.addElement(bitsACchrominance);
   val = new Vector();
   val.addElement(valDCluminance);
   val.addElement(valACluminance);
   val.addElement(valDCchrominance);
   val.addElement(valACchrominance);
   initHuf();
   code = code;
   ImageWidth = Width;
   ImageHeight = Height;
 }
예제 #5
0
파일: Clusters.java 프로젝트: arneboe/jplag
 public void writeMap(Cluster cluster, float yBar) {
   Set<Submission> subSet = new HashSet<Submission>(cluster.size());
   String documents = "";
   for (int i = 0; i < cluster.size(); i++) {
     Submission sub = submissions.elementAt(cluster.getSubmissionAt(i));
     documents += sub.name + " ";
     subSet.add(sub);
   }
   documents = documents.trim();
   String theme =
       ThemeGenerator.generateThemes(subSet, this.program.get_themewords(), false, this.program);
   mapString +=
       "<area shape=\"rect\" coords=\""
           + (cluster.x - 2)
           + ","
           + (yBar)
           + ","
           + (cluster.x + 2)
           + ","
           + (cluster.y + 2)
           + "\" onMouseover=\"set('"
           + cluster.size()
           + "','"
           + trimStringToLength(String.valueOf(cluster.getSimilarity()), 6)
           + "','"
           + trimStringToLength(documents, 50)
           + "','"
           + theme
           + "')\" ";
   //		if (cluster.size() == 1)
   //			mapString += "href=\"submission"+cluster.getSubmissionAt(0)+".html\">\n";
   //		else
   mapString += "nohref>\n";
 }
예제 #6
0
  /** Mthis method perform equals based on string rapresentation of objects */
  public static void updateStringComboBox(
      javax.swing.JComboBox comboBox, Vector newItems, boolean addNullEntry) {
    Object itemSelected = null;
    if (comboBox.getSelectedIndex() >= 0) {
      itemSelected = comboBox.getSelectedItem() + "";
    }

    comboBox.removeAllItems();
    boolean selected = false;
    boolean foundNullItem = false;
    Enumeration e = newItems.elements();
    while (e.hasMoreElements()) {
      String item = "" + e.nextElement();
      comboBox.addItem(item);
      if (item.equals(itemSelected)) {
        selected = true;
        comboBox.setSelectedItem(itemSelected);
      }
      if (item.equals("")) {
        foundNullItem = true;
      }
    }

    if (addNullEntry) {
      if (!foundNullItem) comboBox.insertItemAt("", 0);
      if (!selected) comboBox.setSelectedItem("");
    }
  }
예제 #7
0
 public void CompleteQuest(int Index) {
   Quest qstComp = QUEST_LIST.elementAt(Index);
   qstComp.STATUS = 3;
   qstComp.QUEST_GIVER.QUEST_LIST.elementAt(0).STATUS = 3;
   qstComp.QUEST_GIVER.QUEST_LIST.removeElementAt(0);
   STATS.IncreaseXP(qstComp.XP);
   GOLD += qstComp.GOLD;
 }
예제 #8
0
 public void giveQuest(GameCharacter Reciever) {
   if (QUEST_LIST.size() > 0) {
     if (QUEST_LIST.elementAt(0).STATUS == 0) {
       Reciever.QUEST_LIST.add(QUEST_LIST.elementAt(0));
       QUEST_LIST.elementAt(0).play_UpdateSound();
       if (QUEST_LIST.elementAt(0).QTYPE == Quest_Type.DELIVERY) {
         for (int i = 0; i < QUEST_LIST.elementAt(0).TARGET_LIST.ITEM_NAME.size(); i++) {
           Reciever.INVENTORY.addItem(
               QUEST_LIST.elementAt(0).TARGET_LIST.ITEM_NAME.elementAt(i),
               QUEST_LIST.elementAt(0).TARGET_LIST.ITEM_PRICE.elementAt(i),
               QUEST_LIST.elementAt(0).TARGET_LIST.ITEM_QUANTITY.elementAt(i),
               QUEST_LIST.elementAt(0).TARGET_LIST.ITEM_IMAGE.elementAt(i),
               QUEST_LIST.elementAt(0).TARGET_LIST.ITEM_TAG.elementAt(i),
               QUEST_LIST.elementAt(0).TARGET_LIST.STATS.elementAt(i));
         }
       }
       QUEST_LIST.elementAt(0).STATUS = 1;
     }
   }
 }
예제 #9
0
파일: Clusters.java 프로젝트: arneboe/jplag
  /** Min clustering... */
  public Cluster minMaxAvrClustering() {
    int nrOfSubmissions = submissions.size();
    boolean minClustering = (Options.MIN_CLUSTER == this.program.get_clusterType());
    boolean maxClustering = (Options.MAX_CLUSTER == this.program.get_clusterType());
    SimilarityMatrix simMatrix = this.program.get_similarity();

    ArrayList<Cluster> clusters = new ArrayList<Cluster>(submissions.size());
    for (int i = 0; i < nrOfSubmissions; i++) clusters.add(new Cluster(i, this));

    while (clusters.size() > 1) {
      int indexA = -1, indexB = -1;
      float maxSim = -1;
      int nrOfClusters = clusters.size();

      // find similarity
      for (int a = 0; a < (nrOfClusters - 1); a++) {
        Cluster cluster = clusters.get(a);
        for (int b = a + 1; b < nrOfClusters; b++) {
          float sim;
          if (minClustering) sim = cluster.maxSimilarity(clusters.get(b), simMatrix);
          else if (maxClustering) sim = cluster.minSimilarity(clusters.get(b), simMatrix);
          else sim = cluster.avrSimilarity(clusters.get(b), simMatrix);
          if (sim > maxSim) {
            maxSim = sim;
            indexA = a;
            indexB = b;
          }
        }
      }

      if (maxSim > maxMergeValue) maxMergeValue = maxSim;

      // now merge these clusters
      Cluster clusterA = clusters.get(indexA);
      Cluster clusterB = clusters.get(indexB);
      clusters.remove(clusterA);
      clusters.remove(clusterB);
      clusters.add(new Cluster(clusterA, clusterB, maxSim, this));
    }
    return clusters.get(0);
  }
예제 #10
0
  /**
   * Draw character in game window
   *
   * @param g Graphics
   * @param Dx X Displacement
   * @param Dy Y Displacement
   * @param G Growth factor
   */
  public void Draw(Graphics g, int Dx, int Dy, double G) {
    // Draw blood
    if (ISDEAD) {
      g.drawImage(
          imgBLOOD,
          (int) (X + Dx - 25),
          (int) (Y + Dy - 15),
          (int) (W * GROWTHFACTOR + 35),
          (int) (H * GROWTHFACTOR + 35),
          null);
    }

    // Quest Givers
    if (CLASS != "Player") {
      for (int i = 0; i < QUEST_LIST.size(); i++) {
        if (QUEST_LIST.elementAt(i).STATUS == 0) {
          g.drawImage(imgQStart, (int) (X + Dx + 5), (int) (Y + Dy - 30), (int) W, 35, null);
        } else if (QUEST_LIST.elementAt(i).STATUS == 2) {
          g.drawImage(imgQEnd, (int) (X + Dx), (int) (Y + Dy - 30), (int) W + 5, 35, null);
        }
      }
    }

    // Draw character
    g.drawImage(
        imgCHARAC,
        (int) (X + Dx),
        (int) (Y + Dy),
        (int) (X + Dx + W * G),
        (int) (Y + Dy + H * G),
        (int) (W * FX),
        (int) (H * FY),
        (int) (W * FX + W),
        (int) (H * FY + H),
        null);

    GROWTHFACTOR = G;
  }
예제 #11
0
  /**
   * Parse the text then draw it without any rotation.
   *
   * @param g Graphics context
   * @param x pixel position of the text
   * @param y pixel position of the text
   */
  public void draw(Graphics g, int x, int y) {
    TextState ts;
    int xoffset = x;
    int yoffset = y;

    if (g == null || text == null) return;

    Graphics lg = g.create();

    parseText(g);

    if (justification == CENTER) {
      xoffset = x - width / 2;
    } else if (justification == RIGHT) {
      xoffset = x - width;
    }

    if (background != null) {
      lg.setColor(background);
      lg.fillRect(xoffset, yoffset - ascent, width, height);
      lg.setColor(g.getColor());
    }

    if (font != null) lg.setFont(font);
    if (color != null) lg.setColor(color);

    for (int i = 0; i < list.size(); i++) {
      ts = ((TextState) (list.elementAt(i)));
      if (ts.f != null) lg.setFont(ts.f);
      if (ts.s != null) lg.drawString(ts.toString(), ts.x + xoffset, ts.y + yoffset);
    }

    lg.dispose();

    lg = null;
  }
예제 #12
0
  /**
   * Check character collision with all kinds of objects
   *
   * @param x X Coordinate
   * @param y Y Coordinate
   * @return if Character is about to collide with something
   */
  public boolean Collision(double x, double y) {
    boolean blnCol = false;
    // Wall Collision
    for (int i = 0; i < MAP.size(); i++) {
      blnCol = blnCol || WallCollision(x, y, MAP.elementAt(i));
    }
    // Game Object Collision
    for (int i = 0; i < OBJECTS.size(); i++) {
      blnCol = blnCol || ObjectCollision(x, y, OBJECTS.elementAt(i));
    }
    // Game Character collision
    for (int i = 0; i < CHARACTERS.size(); i++) {
      blnCol = blnCol || CharacterCollision(x, y, CHARACTERS.elementAt(i));
    }
    // Game Building Collision
    for (int i = 0; i < BUILD.size(); i++) {
      blnCol = blnCol || BuildingCollision(x, y, BUILD.elementAt(i));
    }

    return blnCol;
  }
예제 #13
0
 /**
  * Adds the specified class to a Vector to keep it from being garbage collected, causing static
  * fields to be reset.
  */
 public void register(Class c) {
   if (!classes.contains(c)) classes.addElement(c);
 }
예제 #14
0
  /**
   * parse the text. When the text is parsed the width, height, leading are all calculated. The text
   * will only be truly parsed if the graphics context has changed or the text has changed or the
   * font has changed. Otherwise nothing is done when this method is called.
   *
   * @param g Graphics context.
   */
  public void parseText(Graphics g) {
    FontMetrics fm;
    TextState current = new TextState();
    char ch;
    Stack state = new Stack();
    int w = 0;

    if (lg != g) parse = true;
    lg = g;

    if (!parse) return;

    parse = false;
    width = 0;
    leading = 0;
    ascent = 0;
    descent = 0;
    height = 0;
    maxAscent = 0;
    maxDescent = 0;

    if (text == null || g == null) return;

    list.removeAllElements();

    if (font == null) current.f = g.getFont();
    else current.f = font;

    state.push(current);
    list.addElement(current);

    fm = g.getFontMetrics(current.f);

    for (int i = 0; i < text.length(); i++) {
      ch = text.charAt(i);

      switch (ch) {
        case '$':
          i++;
          if (i < text.length()) current.s.append(text.charAt(i));
          break;
          /*
           **                    Push the current state onto the state stack
           **                    and start a new storage string
           */
        case '{':
          w = current.getWidth(g);
          if (!current.isEmpty()) {
            current = current.copyState();
            list.addElement(current);
          }

          state.push(current);
          current.x += w;
          break;
          /*
           **                    Pop the state off the state stack and set the current
           **                    state to the top of the state stack
           */
        case '}':
          w = current.x + current.getWidth(g);
          state.pop();
          current = ((TextState) state.peek()).copyState();
          list.addElement(current);
          current.x = w;
          break;
        case '^':
          w = current.getWidth(g);
          if (!current.isEmpty()) {
            current = current.copyState();
            list.addElement(current);
          }
          current.f = getScriptFont(current.f);
          current.x += w;
          current.y -= (int) ((double) (current.getAscent(g)) * sup_offset + 0.5);
          break;
        case '_':
          w = current.getWidth(g);
          if (!current.isEmpty()) {
            current = current.copyState();
            list.addElement(current);
          }
          current.f = getScriptFont(current.f);
          current.x += w;
          current.y += (int) ((double) (current.getDescent(g)) * sub_offset + 0.5);
          break;

        default:
          current.s.append(ch);
          break;
      }
    }

    for (int i = 0; i < list.size(); i++) {
      current = ((TextState) (list.elementAt(i)));

      if (!current.isEmpty()) {
        width += current.getWidth(g);
        ascent = Math.max(ascent, Math.abs(current.y) + current.getAscent(g));
        descent = Math.max(descent, Math.abs(current.y) + current.getDescent(g));
        leading = Math.max(leading, current.getLeading(g));

        maxDescent = Math.max(maxDescent, Math.abs(current.y) + current.getMaxDescent(g));
        maxAscent = Math.max(maxAscent, Math.abs(current.y) + current.getMaxAscent(g));
      }
    }

    height = ascent + descent + leading;

    return;
  }
예제 #15
0
 /**
  * add a Object collision object
  *
  * @param O Object
  */
 public void addColisionObject(GameObject O) {
   OBJECTS.add(O);
 }
예제 #16
0
 /**
  * add Character collision object
  *
  * @param C Character
  */
 public void addColisionObject(GameCharacter C) {
   CHARACTERS.add(C);
 }
예제 #17
0
파일: Clusters.java 프로젝트: arneboe/jplag
  /** This method returns the distribution HTML code as a string */
  private String outputClustering(HTMLFile f, Collection<Cluster> allClusters, int maxSize) {
    int[] distribution = new int[maxSize + 1];
    int max = 0;
    for (int i = 0; i <= maxSize; i++) distribution[i] = 0;

    // Now output the clustering:
    f.println("<TABLE CELLPADDING=2 CELLSPACING=2>");

    f.println(
        "<TR><TH ALIGN=center BGCOLOR=#8080ff>"
            + msg.getString("Clusters.Cluster_number")
            + "<TH ALIGN=center BGCOLOR=#8080ff>"
            + msg.getString("Clusters.Size")
            + "<TH ALIGN=center BGCOLOR=#8080ff>"
            + msg.getString("Clusters.Threshold")
            + "<TH ALIGN=center BGCOLOR=#8080ff>"
            + msg.getString("Clusters.Cluster_members")
            + "<TH ALIGN=center BGCOLOR=#8080ff>"
            + msg.getString("Clusters.Most_frequent_words")
            + "</TR>");
    Iterator<Cluster> clusterI = allClusters.iterator();
    for (int i = 1; clusterI.hasNext(); i++) {
      Cluster cluster = clusterI.next();
      if (max < ++distribution[cluster.size()]) max = distribution[cluster.size()];

      // no singleton clusters
      if (cluster.size() == 1) continue;

      f.print(
          "<TR><TD ALIGN=center BGCOLOR=#8080ff>"
              + i
              + "<TD ALIGN=center BGCOLOR=#c0c0ff>"
              + cluster.size()
              + "<TD ALIGN=center BGCOLOR=#c0c0ff>"
              + cluster.getSimilarity()
              + "<TD ALIGN=left BGCOLOR=#c0c0ff>");

      // sort names
      TreeSet<Submission> sortedSubmissions = new TreeSet<Submission>();
      for (int x = 0; x < cluster.size(); x++) {
        sortedSubmissions.add(submissions.elementAt(cluster.getSubmissionAt(x)));
      }

      for (Iterator<Submission> iter = sortedSubmissions.iterator(); iter.hasNext(); ) {
        Submission sub = iter.next();
        int index = submissions.indexOf(sub);
        f.print("<A HREF=\"submission" + index + ".html\">" + sub.name + "</A>");
        if (iter.hasNext()) f.print(", ");
        neededSubmissions.add(sub); // write files for these.
      }

      if (this.program.get_language() instanceof jplag.text.Language) {
        f.println(
            "<TD ALIGN=left BGCOLOR=#c0c0ff>"
                + ThemeGenerator.generateThemes(
                    sortedSubmissions, this.program.get_themewords(), true, this.program));
      } else {
        f.println("<TD ALIGN=left BGCOLOR=#c0c0ff>-");
      }

      f.println("</TR>");
    }
    f.println("</TABLE>\n<P>\n");

    f.println("<H5>" + msg.getString("Clusters.Distribution_of_cluster_size") + ":</H5>");

    String text;
    text = "<TABLE CELLPADDING=1 CELLSPACING=1>\n";
    text +=
        "<TR><TH ALIGN=center BGCOLOR=#8080ff>"
            + msg.getString("Clusters.Cluster_size")
            + "<TH ALIGN=center BGCOLOR=#8080ff>"
            + msg.getString("Clusters.Number_of_clusters")
            + "<TH ALIGN=center BGCOLOR=#8080ff>.</TR>\n";
    for (int i = 0; i <= maxSize; i++) {
      if (distribution[i] == 0) continue;
      text +=
          "<TR><TD ALIGN=center BGCOLOR=#c0c0ff>"
              + i
              + "<TD ALIGN=right BGCOLOR=#c0c0ff>"
              + distribution[i]
              + "<TD BGCOLOR=#c0c0ff>\n";
      for (int j = (distribution[i] * barLength / max); j > 0; j--) text += ("#");
      if (distribution[i] * barLength / max == 0) {
        if (distribution[i] == 0) text += (".");
        else text += ("#");
      }
      text += ("</TR>\n");
    }
    text += ("</TABLE>\n");

    f.print(text);
    return text;
  }
예제 #18
0
 public void removeCollisionObject(GameObject obj) {
   //	for(int i=0;i<obj.length;i++){
   OBJECTS.remove(obj);
   // OBJECTS.add(obj[i]);
   // }
 }
예제 #19
0
 /**
  * Remove a <code>ChangeListener</code> so it is no longer notified when the selected color
  * changes.
  */
 public void removeChangeListener(ChangeListener l) {
   if (changeListeners == null) return;
   changeListeners.remove(l);
 }
예제 #20
0
 /**
  * This listener will be notified when the current HSB or RGB values change, depending on what
  * mode the user is in.
  */
 public void addChangeListener(ChangeListener l) {
   if (changeListeners == null) changeListeners = new Vector();
   if (changeListeners.contains(l)) return;
   changeListeners.add(l);
 }
예제 #21
0
 /**
  * add an array of Building collision object
  *
  * @param M Array of GridMap
  */
 public void addColisionObject(Building[] B) {
   for (int i = 0; i < B.length; i++) {
     BUILD.add(B[i]);
   }
 }
예제 #22
0
 /**
  * add a Map collision object
  *
  * @param M Array of GridMap
  */
 public void addColisionObject(GridMap[] M) {
   for (int i = 0; i < M.length; i++) {
     MAP.add(M[i]);
   }
 }
  /** Method declaration */
  void showResultInText() {

    String col[] = gResult.getHead();
    int width = col.length;
    int size[] = new int[width];
    Vector data = gResult.getData();
    String row[];
    int height = data.size();

    for (int i = 0; i < width; i++) {
      size[i] = col[i].length();
    }

    for (int i = 0; i < height; i++) {
      row = (String[]) data.elementAt(i);

      for (int j = 0; j < width; j++) {
        int l = row[j].length();

        if (l > size[j]) {
          size[j] = l;
        }
      }
    }

    StringBuffer b = new StringBuffer();

    for (int i = 0; i < width; i++) {
      b.append(col[i]);

      for (int l = col[i].length(); l <= size[i]; l++) {
        b.append(' ');
      }
    }

    b.append(NL);

    for (int i = 0; i < width; i++) {
      for (int l = 0; l < size[i]; l++) {
        b.append('-');
      }

      b.append(' ');
    }

    b.append(NL);

    for (int i = 0; i < height; i++) {
      row = (String[]) data.elementAt(i);

      for (int j = 0; j < width; j++) {
        b.append(row[j]);

        for (int l = row[j].length(); l <= size[j]; l++) {
          b.append(' ');
        }
      }

      b.append(NL);
    }

    b.append(NL + height + " row(s) in " + lTime + " ms");
    txtResult.setText(b.toString());
  }
예제 #24
0
 /**
  * add Character collision object
  *
  * @param C Array of Characters
  */
 public void addColisionObject(GameCharacter[] C) {
   for (int i = 0; i < C.length; i++) {
     CHARACTERS.add(C[i]);
   }
 }
예제 #25
0
  void refresh() {

    JPanel4.showCard("router"); // No Internationalisation
    if (routerobject != null) {
      ((com.adventnet.nms.examples.routermap.RouterDetails) JPanel4.getCard("router"))
          .setValues((Properties) routerobject.elementAt(0)); // No Internationalisation
      Properties prop = (Properties) routerobject.elementAt(0);
      RouterBtn.setBackground(
          SeverityInfo.getInstance()
              .getColor(Integer.parseInt(prop.getProperty("status")))); // No Internationalisation
      RouterBtn.setToolTipText(prop.getProperty("ipAddress")); // No Internationalisation
      JLabel1.setText(
          NmsClientUtil.GetString("Router details  :  ")
              + prop.getProperty("name")); // No Internationalisation
    }
    if (routerobject.size() >= 2) {
      one.setVisible(true);
      Properties prop = (Properties) routerobject.elementAt(1);
      one.setValues(
          SeverityInfo.getInstance().getColor(Integer.parseInt(prop.getProperty("status"))),
          prop.getProperty("ipAddress")); // No Internationalisation
      one.setToolTipText(prop.getProperty("ipAddress")); // No Internationalisation
    }
    if (routerobject.size() >= 3) {
      two.setVisible(true);
      Properties prop = (Properties) routerobject.elementAt(2);
      two.setValues(
          SeverityInfo.getInstance().getColor(Integer.parseInt(prop.getProperty("status"))),
          prop.getProperty("ipAddress")); // No Internationalisation
      two.setToolTipText(prop.getProperty("ipAddress")); // No Internationalisation
    }
    if (routerobject.size() >= 4) {
      three.setVisible(true);
      Properties prop = (Properties) routerobject.elementAt(3);
      three.setValues(
          SeverityInfo.getInstance().getColor(Integer.parseInt(prop.getProperty("status"))),
          prop.getProperty("ipAddress")); // No Internationalisation
      three.setToolTipText(prop.getProperty("ipAddress")); // No Internationalisation
    }
    if (routerobject.size() >= 5) {
      four.setVisible(true);
      Properties prop = (Properties) routerobject.elementAt(4);
      four.setValues(
          SeverityInfo.getInstance().getColor(Integer.parseInt(prop.getProperty("status"))),
          prop.getProperty("ipAddress")); // No Internationalisation
      four.setToolTipText(prop.getProperty("ipAddress")); // No Internationalisation
    }
    if (routerobject.size() >= 6) {
      five.setVisible(true);
      Properties prop = (Properties) routerobject.elementAt(5);
      five.setValues(
          SeverityInfo.getInstance().getColor(Integer.parseInt(prop.getProperty("status"))),
          prop.getProperty("ipAddress")); // No Internationalisation
      five.setToolTipText(prop.getProperty("ipAddress")); // No Internationalisation
    }
    if (routerobject.size() >= 7) {
      six.setVisible(true);
      Properties prop = (Properties) routerobject.elementAt(6);
      six.setValues(
          SeverityInfo.getInstance().getColor(Integer.parseInt(prop.getProperty("status"))),
          prop.getProperty("ipAddress")); // No Internationalisation
      six.setToolTipText(prop.getProperty("ipAddress")); // No Internationalisation
    }
    if (routerobject.size() >= 8) {
      seven.setVisible(true);
      Properties prop = (Properties) routerobject.elementAt(7);
      seven.setValues(
          SeverityInfo.getInstance().getColor(Integer.parseInt(prop.getProperty("status"))),
          prop.getProperty("ipAddress")); // No Internationalisation
      seven.setToolTipText(prop.getProperty("ipAddress")); // No Internationalisation
    }
    if (routerobject.size() >= 9) {
      eight.setVisible(true);
      Properties prop = (Properties) routerobject.elementAt(8);
      eight.setValues(
          SeverityInfo.getInstance().getColor(Integer.parseInt(prop.getProperty("status"))),
          prop.getProperty("ipAddress")); // No Internationalisation
      eight.setToolTipText(prop.getProperty("ipAddress")); // No Internationalisation
    }
    if (routerobject.size() >= 10) {
      nine.setVisible(true);
      Properties prop = (Properties) routerobject.elementAt(9);
      nine.setValues(
          SeverityInfo.getInstance().getColor(Integer.parseInt(prop.getProperty("status"))),
          prop.getProperty("ipAddress")); // No Internationalisation
      nine.setToolTipText(prop.getProperty("ipAddress")); // No Internationalisation
    }
    if (routerobject.size() >= 11) {
      ten.setVisible(true);
      Properties prop = (Properties) routerobject.elementAt(10);
      ten.setValues(
          SeverityInfo.getInstance().getColor(Integer.parseInt(prop.getProperty("status"))),
          prop.getProperty("ipAddress")); // No Internationalisation
      ten.setToolTipText(prop.getProperty("ipAddress")); // No Internationalisation
    }
  }
예제 #26
0
 /**
  * add Building collision object
  *
  * @param B Building
  */
 public void addColisionObject(Building B) {
   BUILD.add(B);
 }
  /** Method declaration */
  private void refreshTree() {

    tTree.removeAll();

    try {
      int color_table = Color.yellow.getRGB();
      int color_column = Color.orange.getRGB();
      int color_index = Color.red.getRGB();

      tTree.addRow("", dMeta.getURL(), "-", 0);

      String usertables[] = {"TABLE"};
      ResultSet result = dMeta.getTables(null, null, null, usertables);
      Vector tables = new Vector();

      // sqlbob@users Added remarks.
      Vector remarks = new Vector();

      while (result.next()) {
        tables.addElement(result.getString(3));
        remarks.addElement(result.getString(5));
      }

      result.close();

      for (int i = 0; i < tables.size(); i++) {
        String name = (String) tables.elementAt(i);
        String key = "tab-" + name + "-";

        tTree.addRow(key, name, "+", color_table);

        // sqlbob@users Added remarks.
        String remark = (String) remarks.elementAt(i);

        if ((remark != null) && !remark.trim().equals("")) {
          tTree.addRow(key + "r", " " + remark);
        }

        ResultSet col = dMeta.getColumns(null, null, name, null);

        while (col.next()) {
          String c = col.getString(4);
          String k1 = key + "col-" + c + "-";

          tTree.addRow(k1, c, "+", color_column);

          String type = col.getString(6);

          tTree.addRow(k1 + "t", "Type: " + type);

          boolean nullable = col.getInt(11) != DatabaseMetaData.columnNoNulls;

          tTree.addRow(k1 + "n", "Nullable: " + nullable);
        }

        col.close();
        tTree.addRow(key + "ind", "Indices", "+", 0);

        ResultSet ind = dMeta.getIndexInfo(null, null, name, false, false);
        String oldiname = null;

        while (ind.next()) {
          boolean nonunique = ind.getBoolean(4);
          String iname = ind.getString(6);
          String k2 = key + "ind-" + iname + "-";

          if ((oldiname == null || !oldiname.equals(iname))) {
            tTree.addRow(k2, iname, "+", color_index);
            tTree.addRow(k2 + "u", "Unique: " + !nonunique);

            oldiname = iname;
          }

          String c = ind.getString(9);

          tTree.addRow(k2 + "c-" + c + "-", c);
        }

        ind.close();
      }

      tTree.addRow("p", "Properties", "+", 0);
      tTree.addRow("pu", "User: "******"pr", "ReadOnly: " + cConn.isReadOnly());
      tTree.addRow("pa", "AutoCommit: " + cConn.getAutoCommit());
      tTree.addRow("pd", "Driver: " + dMeta.getDriverName());
      tTree.addRow("pp", "Product: " + dMeta.getDatabaseProductName());
      tTree.addRow("pv", "Version: " + dMeta.getDatabaseProductVersion());
    } catch (SQLException e) {
      tTree.addRow("", "Error getting metadata:", "-", 0);
      tTree.addRow("-", e.getMessage());
      tTree.addRow("-", e.getSQLState());
    }

    tTree.update();
  }
예제 #28
0
 /**
  * add a Object collision object
  *
  * @param O Array of Objects
  */
 public void addColisionObject(GameObject[] O) {
   for (int i = 0; i < O.length; i++) {
     OBJECTS.add(O[i]);
   }
 }
 /*.................................................................................................................*/
 public TreeDisplayExtra createTreeDisplayExtra(TreeDisplay treeDisplay) {
   PAdjustToolExtra newPj = new PAdjustToolExtra(this, treeDisplay);
   extras.addElement(newPj);
   return newPj;
 }
  public WebcamCaptureAndFadePanel(String saveDir, String layout) {

    System.out.println("Using " + saveDir + " as directory for the images.");
    saveDirectory = saveDir;

    getImages();
    images_used = new ArrayList<Integer>();
    images_lastadded = new ArrayList<Integer>();
    images_nevershown = new ArrayList<Integer>();

    Vector devices = (Vector) CaptureDeviceManager.getDeviceList(null).clone();
    Enumeration enumeration = devices.elements();
    System.out.println("- Available cameras -");
    ArrayList<String> names = new ArrayList<String>();
    while (enumeration.hasMoreElements()) {
      CaptureDeviceInfo cdi = (CaptureDeviceInfo) enumeration.nextElement();
      String name = cdi.getName();
      if (name.startsWith("vfw:")) {
        names.add(name);
        System.out.println(name);
      }
    }

    // String str1 = "vfw:Logitech USB Video Camera:0";
    // String str2 = "vfw:Microsoft WDM Image Capture (Win32):0";
    if (names.size() == 0) {
      JOptionPane.showMessageDialog(
          null,
          "Ingen kamera funnet. " + "Du må koble til et kamera for å kjøre programmet.",
          "Feil",
          JOptionPane.ERROR_MESSAGE);
      System.exit(0);
    } else if (names.size() > 1) {

      JOptionPane.showMessageDialog(
          null,
          "Fant mer enn 1 kamera. " + "Velger da:\n" + names.get(0),
          "Advarsel",
          JOptionPane.WARNING_MESSAGE);
    }

    String str2 = names.get(0);
    di = CaptureDeviceManager.getDevice(str2);
    ml = di.getLocator();

    try {
      player = Manager.createRealizedPlayer(ml);
      formatControl = (FormatControl) player.getControl("javax.media.control.FormatControl");

      /*
      Format[] formats = formatControl.getSupportedFormats();
      for (int i=0; i<formats.length; i++)
      	System.out.println(formats[i].toString());
      */

      player.start();
    } catch (javax.media.NoPlayerException e) {
      JOptionPane.showMessageDialog(
          null,
          "Klarer ikke å starte" + " programmet pga. feil med kamera. Sjekk at det er koblet til.",
          "IOException",
          JOptionPane.ERROR_MESSAGE);
      System.exit(0);
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(0);
    }

    /*
     * Layout
     *
     * Add
     * - comp
     * - imagepanels
     */

    if (layout.equals("1024v2")) {
      layout1024v2();
    } else if (layout.equals("1280")) {
      layout1280();
    } else {
      layout1024();
    }

    // Capture Window
    if (captureWindow) {
      cw = new JFrame("Capture from webcam");
      cw.setAlwaysOnTop(true);
      cw.setSize(sizeCaptureWindow_x, sizeCaptureWindow_y);
      cw.addKeyListener(new captureWindowKeyListner());
      cw.setUndecorated(true);

      // Add webcam
      if ((comp = player.getVisualComponent()) != null) {
        cw.add(comp);
      }

      // Add panel to window and set location of window
      cw.setLocation(cwLocation_x, cwLocation_y);
    }

    // Text window
    cwText = new rotatedText("");

    /*
     * Timer for update
     */
    Timer thread = new Timer();
    thread.schedule(new frameUpdateTask(), 0, (1000 / fps));
  }