Example #1
2
  // Takes and image_id, pulls in the image from cache, and goes about
  // encoding it to put it into the database in a transaction.  The last
  // query in the transaction records the image having been stored.
  protected void storeImage(int image_id) throws Exception {
    PhotoImage p = new PhotoImage(image_id);
    SpyDB pdb = getDB();
    Connection db = null;
    Statement st = null;
    Vector v = p.getImage();
    System.err.println(
        "Storer: Got image for " + image_id + " " + v.size() + " lines of data to store.");
    try {
      int i = 0, n = 0;
      db = pdb.getConn();
      db.setAutoCommit(false);
      st = db.createStatement();
      BASE64Encoder base64 = new BASE64Encoder();
      String data = "";

      for (; i < v.size(); i++) {
        String tmp = base64.encodeBuffer((byte[]) v.elementAt(i));
        tmp = tmp.trim();

        if (data.length() < 2048) {
          data += tmp + "\n";
        } else {
          storeQuery(image_id, n, st, data);
          data = tmp;
          n++;
        }
      }
      // OK, this is sick, but another one right now for the spare.
      if (data.length() > 0) {
        System.err.println("Storer:  Storing spare.");
        storeQuery(image_id, n, st, data);
        n++;
      }
      System.err.println("Storer:  Stored " + n + " lines of data for " + image_id + ".");
      st.executeUpdate(
          "update upload_log set stored=datetime(now())\n" + "\twhere photo_id = " + image_id);
      db.commit();
      // Go ahead and generate a thumbnail.
      p.getThumbnail();
    } catch (Exception e) {
      // If anything happens, roll it back.
      if (st != null) {
        try {
          db.rollback();
        } catch (Exception e3) {
          // Nothing
        }
      }
    } finally {
      if (db != null) {
        try {
          db.setAutoCommit(true);
        } catch (Exception e) {
          System.err.println("Error:  " + e);
        }
      }
      pdb.freeDBConn();
    }
  }
Example #2
1
 public void fireEvent(NCCPConnection.ConnectionEvent e) {
   ConnectionListener l;
   int max = listeners.size();
   for (int i = 0; i < max; ++i) {
     ExpCoordinator.print(
         new String(
             "NCCPConnection.fireEvent ("
                 + toString()
                 + ") event: "
                 + e.getType()
                 + " max:"
                 + max
                 + " i:"
                 + i),
         2);
     l = (ConnectionListener) (listeners.elementAt(i));
     switch (e.getType()) {
       case ConnectionEvent.CONNECTION_FAILED:
         l.connectionFailed(e);
         break;
       case ConnectionEvent.CONNECTION_CLOSED:
         l.connectionClosed(e);
         break;
       case ConnectionEvent.CONNECTION_OPENED:
         ExpCoordinator.printer.print(
             new String("Opened control connection (" + toString() + ")"));
         l.connectionOpened(e);
     }
   }
 }
Example #3
1
    public void updatePosition(float dt) {
      if (fixed) {
        netForce.reset(); // Shouldn't accumulate forces if fixed
        return;
      }

      updateAcceleration(dt);
      updateVelocity(dt);

      Point prev = new Point(pos.x, pos.y);
      pos.add(vel.copy().scale(dt, dt));

      ensureInBounds();
    }
Example #4
1
    public void applyForce() {
      // force is proportional to the diff between restLen and current idst

      // a vector from A --> B
      Vector diff = new Vector(endA.pos, endB.pos);

      // compute the current distance
      float dist = diff.getMagnitude();
      // compute dx, which is what the force depends on
      float dx = Math.abs(dist - restLen);

      // a vector containing just the direction component of A --> B
      Vector dir = diff.copy().normalize();

      Vector force = dir.copy().scale(-K * dx, -K * dx);

      if (restLen < getDistance()) {
        // forces go INWARDS

        endB.addForce(force);
        endA.addForce(force.reverse());
      } else {
        // forces go OUTWARDS

        endA.addForce(force);
        endB.addForce(force.reverse());
      }
    }
Example #5
0
 /**
  * Re-scans the bus for devices. <i>ScanForDevices()</i> is called automatically by <i>{@link
  * #open() open()}</i>. <i>You must terminate use of all USB devices before calling
  * scanForDevices()!</i> After calling <i>scanForDevices()</i> you can reestablish connections to
  * USB devices.
  *
  * @return This device manager, useful for chaining together multiple operations.
  * @throws OperationFailedException
  */
 public USBDeviceManager scanForDevices() {
   if (isOpen()) {
     deviceList.clear();
     final int MAX_DEVICES = 100;
     int devices[] = new int[1 + MAX_DEVICES * 2]; // device index-product ID pairs
     final int result =
         getDeviceByProductID(MIN_PRODUCT_ID, MAX_PRODUCT_ID, devices); // get all devices
     if (result != SUCCESS) throw new OperationFailedException(result);
     final int numDevices = devices[0];
     for (int index = 0; index < numDevices; index++) {
       USBDevice device = null;
       final int deviceIndex = devices[1 + index * 2];
       final int productID = devices[1 + index * 2 + 1];
       if (USB_AI16_Family.isSupportedProductID(productID)) {
         device = new USB_AI16_Family(productID, deviceIndex);
       } else if (USB_AO16_Family.isSupportedProductID(productID)) {
         device = new USB_AO16_Family(productID, deviceIndex);
       } else if (USB_CTR_15_Family.isSupportedProductID(productID)) {
         device = new USB_CTR_15_Family(productID, deviceIndex);
       } else if (USB_DA12_8A_Family.isSupportedProductID(productID)) {
         device = new USB_DA12_8A_Family(productID, deviceIndex);
       } else if (USB_DA12_8E_Family.isSupportedProductID(productID)) {
         device = new USB_DA12_8E_Family(productID, deviceIndex);
       } else if (USB_DIO_16_Family.isSupportedProductID(productID)) {
         device = new USB_DIO_16_Family(productID, deviceIndex);
       } else if (USB_DIO_32_Family.isSupportedProductID(productID)) {
         device = new USB_DIO_32_Family(productID, deviceIndex);
       } else if (USB_DIO_Family.isSupportedProductID(productID)) {
         device = new USB_DIO_Family(productID, deviceIndex);
       } // else if( USB_DIO_Family.isSupportedProductID( ...
       if (device != null) deviceList.add(device);
     } // for( int index ...
   } else throw new OperationFailedException(MESSAGE_NOT_OPEN);
   return this;
 } // scanForDevices()
Example #6
0
  // Get a list of images that have been added, but not yet added into
  // the database.
  protected void doFlush() {
    SpyDB pdb = getDB();
    Vector v = null;
    try {
      Connection db = pdb.getConn();
      Statement st = db.createStatement();
      String query = "select * from upload_log where stored is null";
      ResultSet rs = st.executeQuery(query);
      v = new Vector();
      while (rs.next()) {
        v.addElement(rs.getString("photo_id"));
      }
    } catch (Exception e) {
      // Do nothing, we'll try again later.
    } finally {
      pdb.freeDBConn();
    }

    // Got the vector, now store the actual images.  This is done so
    // that we don't hold the database connection open whlie we're
    // making the list *and* getting another database connection to act
    // on it.
    if (v != null) {
      try {
        for (int i = 0; i < v.size(); i++) {
          String stmp = (String) v.elementAt(i);
          storeImage(Integer.valueOf(stmp).intValue());
        }
      } catch (Exception e) {
        // Don't care, we'll try again soon.
      }
    }
  }
Example #7
0
  /** Calculate the rectangle occupied by the data */
  protected Rectangle getDataRectangle(Graphics g, Rectangle r) {
    Axis a;
    int waxis;
    int x = r.x;
    int y = r.y;
    int width = r.width;
    int height = r.height;

    for (int i = 0; i < axis.size(); i++) {
      a = ((Axis) axis.elementAt(i));

      waxis = a.getAxisWidth(g);

      switch (a.getAxisPos()) {
        case Axis.LEFT:
          x += waxis;
          width -= waxis;
          break;
        case Axis.RIGHT:
          width -= waxis;
          break;
        case Axis.TOP:
          y += waxis;
          height -= waxis;
          break;
        case Axis.BOTTOM:
          height -= waxis;
          break;
      }
    }

    return new Rectangle(x, y, width, height);
  }
  /**
   * Gets a list of courses that belongs to an instructor. Throws InvalidDBRequestException if any
   * error occured to the database connection.
   *
   * @param name the instructor's user name
   * @return a vector containing the list of courses
   * @throws InvalidDBRequestException
   */
  public Vector getCourseList(String name) throws InvalidDBRequestException {
    Vector courseList = new Vector();

    try {
      Connection db;

      Class.forName(GaigsServer.DBDRIVER);
      db =
          DriverManager.getConnection(GaigsServer.DBURL, GaigsServer.DBLOGIN, GaigsServer.DBPASSWD);

      Statement stmt = db.createStatement();
      ResultSet rs;

      // get the course list
      rs =
          stmt.executeQuery(
              "select course_num, course_name from course where instructor = '"
                  + name
                  + "' order by course_num");
      while (rs.next()) courseList.add(rs.getString(1) + " - " + rs.getString(2));

      rs.close();
      stmt.close();
      db.close();
    } catch (SQLException e) {
      System.err.println("Invalid SQL in getCourseList: " + e.getMessage());
      throw new InvalidDBRequestException("???");
    } catch (ClassNotFoundException e) {
      System.err.println("Driver Not Loaded");
      throw new InvalidDBRequestException("Server Error");
    }

    return courseList;
  }
Example #9
0
 public void setConnected(boolean b, boolean process_pending) {
   if (b && state != ConnectionEvent.CONNECTION_OPENED) {
     if (host.length() > 0)
       ExpCoordinator.print(
           "NCCPConnection open connection to ipaddress " + host + " port " + port);
     state = ConnectionEvent.CONNECTION_OPENED;
     // connected = true;
     fireEvent(new ConnectionEvent(this, state));
     ExpCoordinator.printer.print("NCCPConnection.setConnected " + b + " event fired", 8);
     if (process_pending) {
       int max = pendingMessages.size();
       ExpCoordinator.printer.print(new String("   pendingMessages " + max + " elements"), 8);
       for (int i = 0; i < max; ++i) {
         sendMessage((NCCP.Message) pendingMessages.elementAt(i));
       }
       pendingMessages.removeAllElements();
     }
   } else {
     if (!b
         && (state != ConnectionEvent.CONNECTION_CLOSED
             || state != ConnectionEvent.CONNECTION_FAILED)) {
       if (host.length() > 0)
         ExpCoordinator.print(
             new String(
                 "NCCPConnection.setConnected -- Closed control socket for " + host + "." + port));
       state = ConnectionEvent.CONNECTION_CLOSED;
       fireEvent(new ConnectionEvent(this, state));
     }
   }
 }
Example #10
0
  /**
   * This method queries the database to get the details related to the bp_id passed.
   *
   * @exception SQLException, if query fails
   * @author
   */
  public Vector getBpdet(String bpid) {
    String query;
    Vector bpdet = new Vector();
    PreparedStatement pstmt = null;
    ResultSet rs = null;

    query = "select rtrim(bs_id_fk||bp_rgn),bp_month from blg_prd where bp_id = ?";

    try {
      pstmt = conn.prepareStatement(query);
      pstmt.setString(1, bpid);

      rs = pstmt.executeQuery();
      while (rs.next()) {
        bpdet.addElement(rs.getString(1));
        bpdet.addElement(rs.getString(2));
      }
      if (rs != null) rs.close();
      if (pstmt != null) pstmt.close();
    } catch (SQLException ex) {
      USFEnv.getLog().writeCrit("Dinvjrnl: BP_ID details not Retreived ", this, ex);
      try {
        if (rs != null) rs.close();
        if (pstmt != null) pstmt.close();
      } catch (SQLException e) {
        USFEnv.getLog().writeCrit("Unable to close the resultset/prepared statement", this, e);
      }
    }

    return bpdet;
  }
Example #11
0
 public void addConnectionListener(NCCPConnection.ConnectionListener l) {
   if (!listeners.contains(l)) {
     ExpCoordinator.printer.print(
         new String("NCCPConnection.addConnectionListener to " + toString()), 6);
     listeners.add(l);
   }
 }
Example #12
0
  /**
   * This method queries the database to get the list of the Billing Systems.
   *
   * @exception SQLException, if query fails
   * @author
   */
  public Vector getYears(String year) {
    String query;
    Vector years = new Vector();
    PreparedStatement pstmt = null;
    ResultSet rs = null;

    query = "select yr||'-'||(yr+1),yr from fung_yr where yr > ?";

    try {
      pstmt = conn.prepareStatement(query);
      pstmt.setString(1, year);

      rs = pstmt.executeQuery();
      while (rs.next()) {
        years.addElement(rs.getString(1));
        years.addElement(rs.getString(2));
      }
      if (rs != null) rs.close();
      if (pstmt != null) pstmt.close();
    } catch (SQLException ex) {
      USFEnv.getLog().writeCrit("Dinvjrnl: Years List not Retreived ", this, ex);
      try {
        if (rs != null) rs.close();
        if (pstmt != null) pstmt.close();
      } catch (SQLException e) {
        USFEnv.getLog().writeCrit("Unable to close the resultset/prepared statement", this, e);
      }
    }

    return years;
  }
Example #13
0
 public void removeConnectionListener(NCCPConnection.ConnectionListener l) {
   if (listeners.contains(l)) {
     // ExpCoordinator.printer.print(new String("NCCPConnection.removeConnectionListener to " +
     // toString()), 2);
     listeners.remove(l);
   }
 }
  /**
   * Query a quiz list from the database. If there is no student user name specified, the list will
   * contain all quizzes that are used in the instructor's courses. Otherwise, the list will contain
   * all quizzes that the student has taken and from the instructor's courses which the student is
   * registered. Throws InvalidDBRequestException if any error occured to the database connection.
   *
   * @param instructor instructor's user name
   * @param student student's user name. Can be empty to get a list of all quizzes in the
   *     instructor's courses.
   * @return a vector containing the list of quizzes
   * @throws InvalidDBRequestException
   */
  public Vector getQuizList(String instructor, String student) throws InvalidDBRequestException {
    Vector list = new Vector();

    try {
      Connection db;

      Class.forName(GaigsServer.DBDRIVER);
      db =
          DriverManager.getConnection(GaigsServer.DBURL, GaigsServer.DBLOGIN, GaigsServer.DBPASSWD);

      Statement stmt = db.createStatement();
      ResultSet rs;

      if (!student.equals("")) {
        // get the list that contains all quizzes that the student has taken and from the
        // instructor's courses which the student is registered
        rs =
            stmt.executeQuery(
                "select courseTest.test_name, scores.start_time from scores, courseTest, course "
                    + "where courseTest.test_name = scores.test_name "
                    + "and courseTest.course_id = course.course_id "
                    + "and instructor = '"
                    + instructor
                    + "' and user_login = '******' "
                    + "order by scores.start_time");

        while (rs.next()) {
          list.add(rs.getString(1) + " <" + rs.getString(2) + ">");
        }
      } else {
        // get the list that contains all quizzes that are used in the instructor's courses
        rs =
            stmt.executeQuery(
                "select test_name from courseTest, course "
                    + "where courseTest.course_id = course.course_id "
                    + "and instructor = '"
                    + instructor
                    + "' ");

        while (rs.next()) {
          list.add(rs.getString(1));
        }
      }

      rs.close();
      stmt.close();
      db.close();
    } catch (SQLException e) {
      System.err.println("Invalid SQL in getQuizList: " + e.getMessage());
      throw new InvalidDBRequestException("???");
    } catch (ClassNotFoundException e) {
      System.err.println("Driver Not Loaded");
      throw new InvalidDBRequestException("Internal Server Error");
    }

    return list;
  }
Example #15
0
  /* is the given variable a neighbor of this variable?*/
  public boolean isNeighbor(Variable v) {

    for (int i = 0; i < neighbors.size(); i++) {
      Variable vv = (Variable) neighbors.elementAt(i);
      if (v.equalVar(vv)) return true;
    }
    return false;
  }
Example #16
0
  /**
   * This method queries the database to get the Journal Dates for the passed in Funding Year
   *
   * @exception SQLException, if query fails
   * @author
   */
  public Vector getJrnldts(String year) {
    String query;
    Vector jrnllst = new Vector();
    PreparedStatement pstmt = null;
    ResultSet rs = null;

    query =
        "select bp_id,decode(bs_nm,'CRIS','1','IABS','2','BART','3','SOFI','4','INFRANET','5','6') ord, ";
    query = query + "rtrim(bs_nm||' '||bp_rgn) nm, bp_month,decode(bp_month,1,'January',";
    query =
        query
            + "2,'February',3,'March',4,'April',5,'May',6,'June',7,'July',8,'August',9,'September',";
    query =
        query
            + "10,'October',11,'November',12,'December'), to_char(bp_strt_dat,'MM/DD/YYYY'),to_char(bp_end_dat,'MM/DD/YYYY') ";
    query = query + "from blg_prd,blg_sys ";
    query = query + "where bs_id=bs_id_fk and ( bp_strt_dat >= ";
    query = query + "(select strt_dat from fung_yr where yr = ?) and ";
    query = query + "bp_end_dat <= (select end_dat from fung_yr where yr = ?) ";
    query = query + "or ( bp_year =to_number(?) and bp_month=7) ) ";
    query = query + "order by ord,nm,bp_strt_dat ";

    USFEnv.getLog().writeDebug("Dinvjrnl: JRNL Dates Query :" + query, this, null);
    try {
      pstmt = conn.prepareStatement(query);
      pstmt.setString(1, year);
      pstmt.setString(2, year);
      pstmt.setString(3, year);

      rs = pstmt.executeQuery();
      while (rs.next()) {
        Dinvjrnl jrnldts = new Dinvjrnl(null);

        jrnldts.strBpid = rs.getString(1);
        jrnldts.strBlgsys = rs.getString(3);
        jrnldts.strBlgmnth = rs.getString(5);
        jrnldts.strBlgstrtdt = rs.getString(6);
        jrnldts.strBlgenddt = rs.getString(7);

        jrnllst.addElement(jrnldts);
        jrnldts = null;
      }
      if (rs != null) rs.close();
      if (pstmt != null) pstmt.close();
    } catch (SQLException ex) {
      USFEnv.getLog().writeCrit("Dinvjrnl: JRNL Dates not retreived for the Year ", this, ex);
      try {
        if (rs != null) rs.close();
        if (pstmt != null) pstmt.close();
      } catch (SQLException e) {
        USFEnv.getLog().writeCrit("Unable to close the resultset/prepared statement", this, e);
      }
    }

    USFEnv.getLog()
        .writeDebug("Dinvjrnl: Journal Dates Vector size :" + jrnllst.size(), this, null);
    return jrnllst;
  }
Example #17
0
 protected Vector /* of Object */ queryAssertionLines1(String query) throws IOException {
   write(query);
   Vector v = readlines();
   Vector r = new Vector();
   for (Enumeration e = v.elements(); e.hasMoreElements(); ) {
     r.addElement(TT.stringToObject((String) e.nextElement()));
   }
   return r;
 }
 public XmlUIElement getXmlElement(UserInput uiArg) {
   String type = "textfield";
   Qualifier qual = uiArg.getQualifier();
   String enumNames[] = null;
   String enumValues[] = null;
   if (qual != null) {
     type = qual.getType();
     Vector enumVec = qual.getEnums();
     if (enumVec.size() > 0) {
       enumNames = new String[enumVec.size()];
       enumValues = new String[enumVec.size()];
       for (int i = 0; i < enumNames.length; i++) {
         com.adventnet.management.config.xml.Enum e =
             (com.adventnet.management.config.xml.Enum) enumVec.elementAt(i);
         enumNames[i] = e.getName();
         enumValues[i] = e.getValue();
         if (enumNames[i] == null) {
           enumNames[i] = enumValues[i];
         }
       }
     }
   }
   XmlUIElement el = getXmlUIElementFor(type);
   if (el == null) {
     return null;
   }
   el.setDescription(uiArg.getDescription());
   if (enumNames != null) {
     el.setEnumeratedValues(enumNames, enumValues);
   }
   if ((qual != null) && (qual.getRange() != null) && (!(qual.getRange().equals("")))) {
     el.setRange(qual.getRange());
   }
   if (uiArg.getDefaultValue() != null) {
     el.setValue(uiArg.getDefaultValue());
   }
   String isEditable = uiArg.getAttribute("editable");
   if (isEditable != null) {
     if (isEditable.trim().equals("false")) {
       el.setEditable(false);
     } else {
       el.setEditable(true);
     }
   }
   String required = uiArg.getAttribute("required");
   {
     if (required.trim().equals("true")) {
       el.setRequired(true);
       numberOfRequiredFields++;
     } else {
       el.setRequired(false);
     }
   }
   el.setLabelName(uiArg.getLabel());
   return el;
 }
Example #19
0
 protected Vector /* of String */ readlines() throws IOException {
   Vector r = new Vector();
   while (true) {
     String s = in.readLine();
     if (DEBUG) dbg("FROM TT: <" + s + ">");
     if (s.equals(".")) break;
     if (s.startsWith("error:")) break;
     r.addElement(s);
   }
   return r;
 }
Example #20
0
  /**
   * This paints the entire plot. It calls the draw methods of all the attached axis and data sets.
   * The order of drawing is - Axis first, data legends next, data last.
   *
   * @params g Graphics state.
   */
  public void paint(Graphics g) {
    int i;
    Graphics lg = g.create();
    Rectangle r = bounds();

    /* The r.x and r.y returned from bounds is relative to the
     ** parents space so set them equal to zero.
     */
    r.x = 0;
    r.y = 0;

    if (DefaultBackground == null) DefaultBackground = this.getBackground();
    if (DataBackground == null) DataBackground = this.getBackground();

    //        System.out.println("Graph2D paint method called!");

    if (!paintAll) return;

    r.x += borderLeft;
    r.y += borderTop;
    r.width -= borderLeft + borderRight;
    r.height -= borderBottom + borderTop;

    paintFirst(lg, r);

    if (!axis.isEmpty()) r = drawAxis(lg, r);
    else {
      if (clearAll) {
        Color c = g.getColor();
        g.setColor(DataBackground);
        g.fillRect(r.x, r.y, r.width, r.height);
        g.setColor(c);
      }
      drawFrame(lg, r.x, r.y, r.width, r.height);
    }

    paintBeforeData(lg, r);

    if (!dataset.isEmpty()) {

      datarect.x = r.x;
      datarect.y = r.y;
      datarect.width = r.width;
      datarect.height = r.height;

      for (i = 0; i < dataset.size(); i++) {
        ((DataSet) dataset.elementAt(i)).draw_data(lg, r);
      }
    }

    paintLast(lg, r);

    lg.dispose();
  }
Example #21
0
  public DataSet loadDataSet(Vector<Integer> data) {
    int i;
    int j;
    double tempdata[] = new double[2 * data.size()];

    for (i = j = 0; i < data.size(); i++, j += 2) {
      tempdata[j] = i;
      tempdata[j + 1] = data.get(i);
    }

    return loadDataSet(tempdata, data.size());
  }
Example #22
0
  /** Detach All attached Axes. */
  public void detachAxes() {
    int i;

    if (axis == null | axis.isEmpty()) return;

    for (i = 0; i < axis.size(); i++) {
      ((Axis) axis.elementAt(i)).detachAll();
      ((Axis) axis.elementAt(i)).g2d = null;
    }

    axis.removeAllElements();
  }
 public JPanel getPanelFor(Form f) throws InvalidTemplateException {
   // clear();by jai
   // uiList = new ArrayList();
   // uiElementsList = new ArrayList();
   ArrayList list = getXmlUIElements(f);
   Vector tables = f.getTables();
   if (tables.size() == 0) {
     return getPanelFor(list);
   } else {
     Table table = (Table) tables.elementAt(0);
     return getPanelWithTable(list, table);
   }
 }
Example #24
0
  /**
   * Get the Minimum Y value of all attached DataSets.
   *
   * @return The minimum value
   */
  public double getYmin() {
    DataSet d;
    double min = 0.0;

    if (dataset == null | dataset.isEmpty()) return min;
    for (int i = 0; i < dataset.size(); i++) {
      d = ((DataSet) dataset.elementAt(i));
      if (i == 0) min = d.getYmin();
      else min = Math.min(min, d.getYmin());
    }

    return min;
  }
Example #25
0
  /**
   * Get the Maximum Y value of all attached DataSets.
   *
   * @return The maximum value
   */
  public double getYmax() {
    DataSet d;
    double max = 0.0;

    if (dataset == null | dataset.isEmpty()) return max;
    for (int i = 0; i < dataset.size(); i++) {
      d = ((DataSet) dataset.elementAt(i));
      if (i == 0) max = d.getYmax();
      else max = Math.max(max, d.getYmax());
    }

    return max;
  }
Example #26
0
  /** Constructs a Level with no label */
  public Level() {
    draw = new LevelDraw();
    label = new JLabel("interface", JLabel.CENTER);

    TableLayout table = new TableLayout();
    this.setLayout(table);
    this.add("0 0 ", draw);
    this.add("0 1 hH", label);

    Vector v = new Vector(2);
    v.addElement(draw);
    v.addElement(label);
    table.sameWidth(v);
  }
Example #27
0
  /** Detach All the DataSets from the class. */
  public void detachDataSets() {
    DataSet d;
    int i;

    if (dataset == null | dataset.isEmpty()) return;

    for (i = 0; i < dataset.size(); i++) {
      d = ((DataSet) dataset.elementAt(i));
      if (d.xaxis != null) d.xaxis.detachDataSet(d);
      if (d.yaxis != null) d.yaxis.detachDataSet(d);
    }

    dataset.removeAllElements();
  }
Example #28
0
  // ------------------------------------------------------------------------
  // *****---Packet Recieved event handler---******//
  // this function will be called by the thread running the packetReciever
  // everytime a new packet is recieved
  // make sure it is synchronized if it modifies any of your data
  public synchronized void PacketReceived(PacketEvent e) {
    // this function defines what you do when a new packet is heard by the system (recall that the
    // parent class (PacketAnalyzer) already registered you to listen for new packets automatically)
    // if this is a long function, you should call it in a seperate thread to allow the
    // PacketReciever thread to continue recieving packets

    Packet packet = e.GetPacket();
    Vector node_list = packet.CreateRoutePathArray();
    for (int i = 0; i < node_list.size() - 1; i++) {
      Integer currentNodeNumber = (Integer) node_list.elementAt(i);
      NodeInfo currentNodeInfo;
      if ((currentNodeInfo = (NodeInfo) proprietaryNodeInfo.get(currentNodeNumber)) != null) {
        currentNodeInfo.SetValue(packet.getValue());
      }
    }
  }
Example #29
0
  /**
   * Attach a DataSet to the graph. By attaching the data set the class can draw the data through
   * its paint method.
   */
  public void attachDataSet(DataSet d) {

    if (d != null) {
      dataset.addElement(d);
      d.g2d = this;
    }
  }
Example #30
0
 /**
  * Detach the DataSet from the class. Data associated with the DataSet will nolonger be plotted.
  *
  * @param d The DataSet to detach.
  */
 public void detachDataSet(DataSet d) {
   if (d != null) {
     if (d.xaxis != null) d.xaxis.detachDataSet(d);
     if (d.yaxis != null) d.yaxis.detachDataSet(d);
     dataset.removeElement(d);
   }
 }