eggmatters 21 Junior Poster in Training

hey thanks for the reply..but i need to know whether u have done something regarding this project or no?...coz if u have..then i can actually elaborate my doubts that i am facing while implementing the laplacianfaces algorithm in matlab...the k nearest neighbors problem is specific to that only....actually i know what does k nearest neighbors means...but i need to clarify some observations in my result
reply soon...

Yeah that is a little out of my league. I certainly would love to help, am somewhat familiar with k-NN algorithm, but unsure how it's implemented in Matlab. We dealt with more basic pattern recognition, not specific face recognition techniques. If you need an extra set of eyes however, please feel free to reply. Sorry I can't be more help.

eggmatters 21 Junior Poster in Training

You basically already did. Object source = event.getSource() returns the Object that caused the event to be fired. So you could just use '==' to determine which Object it was at that point, if you need to.

Right, but by calling the toString method, it returned the caller as the ListSelectionModel. Which is fine, I guess. It isn't completely necessary, and I've kludged a harmonious solution to what I want, but if I can embed event handlers and objects in form data, then I should be able to expose those behaviors. Like being able to fire an event when a check box is selected on a form. The way my code is structured now, an event fires whenever a cell is selected. The fact that there is a checkbox there or not is completely arbitrary. The code block I posted is ran everytime a user clicks on a cell on the data table (As it is caused by a listSelection event) i just added logic to limit what happens based on where something was selected.

eggmatters 21 Junior Poster in Training

I guess that if I know specically which column my checkboxes occur in, I can just specify something to the effect of:

if (table.getSelectedColumn() == the_column_the_checkboxes_are_in)
{
     Object value =  table.getValueAt(table.getSelectedRow(), (table.getSelectedColumn() - 1));
. . .
}

But my curiosity lays more with determining greater detail about event data. Thanks!

eggmatters 21 Junior Poster in Training

Hello all,
I am writing a java application where I have a Jtable with checkboxes next to the data. If the user checks a box, I want to store a specific value from the data table. I can do this inelegantly by setting setCellSelectionEnabled(true) and adding the following to the event listener:

private class selectionListener implements ListSelectionListener {
        public void valueChanged(ListSelectionEvent event) {
            if (event.getValueIsAdjusting()) {
                return;
            }
            // This will return any value where the user clicks on a cell:
            Object value =  table.getValueAt(table.getSelectedRow(), (table.getSelectedColumn() - 1));
            //debug message for verification:
            System.out.println("Selected: " + value.toString());
            //Trying to determine who fired the event:
            Object source = event.getSource();
            System.out.println("From: " + source.toString());
            // An array list to store selected values:
            selection_array.add(value);
            
        }

Here is some sample output:

Selected: DONE C
From: javax.swing.DefaultListSelectionModel 27296482 ={7}

Is there a method I can invoke that will tell me who the caller was? The checkboxes are embedded in the table via an override to the Default Table model, they weren't explicitly defined by me. So, I think that the listener just knows that it is a cell selection event and is not concerned about the type.

eggmatters 21 Junior Poster in Training

Won't the statement:

c.SetBefore(before);

keep moving the cursor back one from where it is when rs.next() was called?

eggmatters 21 Junior Poster in Training

I made no assumption about the data, I was just exploring the logical consequences of the problem statement.
In the case you give, the boolean is false, no further processing is required. You will hit this condition (if it is the case) in a single pass - hence O(n).
It's only interesting if the boolean is true, hence you need to keep looking. In that case the recursive analysis I posted suggests you do not need the nested loop, a single loop is sufficient, hence it runs in O(n).

Actually I made a mistaken assumption that i ∀ 0 - n. (Or i represents a range of all indices of the array).
He didn't say anything to that effect. If i is one value, then the case is trivial. If i is meant to specify a range of values, then it is impossible to do in O(n).

eggmatters 21 Junior Poster in Training

hiii,
i am doing my final year project in Face recognition using laplacianfaces.
if any body has done this technique then please help me out..
i dont know how to find the k-nearest neighbors and thus the similarity matrix between images...
please reply me anybody who ha some IDEA OR CLUE for this...

thnxx

Look into Adaptive Resonance theory of Neural Networks. That's usually how it's done in the real world.

eggmatters 21 Junior Poster in Training

I am supposed to submit my final year project title within 3days. I think i am finished cause till now,i have totally no clue about it.
.

What class is it for? Is it a CS class? Are you an undergrad? Graduate? In Computer Science, there are 3 real suitable categories to explore, Concurrency, Synchronization, and Distributed processing. If it were me, I would explore distributed processing, but I already did a Senior project on Distributed Processing.

Salem commented: 3 years too late - so I'm guessing graduate, or burger flipper -3
eggmatters 21 Junior Poster in Training

Did anyone say it was?

Well, I think you may be making an assumption of the value of any given element of the array. array may point to a value 7 where array may point to a value of 77.

eggmatters 21 Junior Poster in Training

There are at least 2 ways to approach this. I can tell you from a desing perspective but my java specifics may lack. At any rate, method one requires that you need some server side code that can fire an event whenever a file is loaded. that event will trigger the frp process on your side.

Method 2 is more stable, eaiser to implement but not as efficient. If your client (the one your'e writing the code on - transferring the file to) is a Linux / Unix type, then you will have a crontab utility. There you can specify a time and frequency to fire a specific "job" in this case, some code that you've written to poll a server for a file and transfer. You mentioned that the file is dropped daily, that you have an approximate time window which to expect it so you should have all you need. Here is a good resource on crontab:

http://www.adminschoice.com/docs/crontab.htm

eggmatters 21 Junior Poster in Training

> data[k + 1] = new Boolean(false);

Better yet; data[i][k + 1] = Boolean.FALSE . Same result, no unnecessary object creation.

HA! I copied that code directly from the sun site. The JDBC / SQL stuff was mine (Although copied from another source initially). I'm not sure however, but the boolean value is meant to represent a checkbox in a Jtable that displays the sql data (I am adding a selection checkbox to the end.) The boolean value needs toreturn its type from a call to getColumnClass() I've overriden. Could that why the created it as an object? Traditinally, there is no such thing as a native "boolean" type.

eggmatters 21 Junior Poster in Training

I encapsulated the above code into a class method, surrounded by a try-catch block. That worked

eggmatters 21 Junior Poster in Training

Hello all,

I have used this code throughout this application with no troubles. I am creating a datatable, and the data is a result set returned from a sql query to an oracle 11g database. I'm creating a TableModel class that overrides the AbstractTableModel so I can add fetures to it. I get errors when I try to assign my ResultSet object however. Here is the code:

class MyTableModel extends AbstractTableModel {

       Statement stmt = conn.createStatement();
       ResultSet rs;
// the following throws compilation error: "cannot find symbol, symbol: class rs, location class <where it resides in my app> <identifier exepected>

       rs = stmt.executeQuery(query);
       
       //the following is fine:
       ResultSetMetaData rsmd = rs.getMetaData();
       int numcols = rsmd.getColumnCount();
       int numrows;

       int i = 0;
       int k = 0;
       
//rs.next throws the same error as above
       while (rs.next()) {
           for (k = 0; k <= numcols; k++) {
                data[i][k] = rs.getString(k);
           }
           if (checked) {
               data[i][k + 1] = new Boolean(false);
           }
           i++;
                
        }
//Default Table Model overrides follow.

I have no idea why this is not recognizing an object that was created in the line of code right above it, or why rs will auto complete with the expected methods and members but java can't find the package it belongs to.

rs hasn't been declared elsewhere. (It would throw a different error if it had). Any ideas?

eggmatters 21 Junior Poster in Training

Well if you think about it, all of the images share similarities in their filenames except for the numeric designation. You can determine that by using rand right? So you can loop 52 times, assigning that number to a predetermined string. Truebot showed us how to do it in PHP. You just need to transform that code into java. Your pseudo code would look something like:

string base = ".png";
for(int i = 0; i < 52;i++)
{
   int  number = randomly generated number between 1 - 52;
//ensure that all numbers returned are unique!
    string filename = (convert int number to string; add the string base to the end of it;)
  load / display filename;
}

That sounds like the purpose of this exercise. It sounds like your instructor wants you to be comfortable with creating strings on the fly. I'm assuming that you've been introduced to string functions like concat, etc. You should have enough course materials to be able to flesh out the psuedo code into full-fledged java.
One thing to note with the above code however, You will need to generate unique values. Typically random generators don't pay attention to the fact if they've already generated a value. You will need to play around with that.

eggmatters 21 Junior Poster in Training

If you really want to split hairs, scripting languages are interpreters, Perl for example actually compiles code to C which is where the actual work is done. This is not exactly the case but is close enough conceptually. Some folks feel strongly about this, while others believe "if it looks like a duck . . ." So scripting languages are interpreters (Perl, PHP, VB, JavaScript etc.) and languages are languages.
Is java an interpreter? you can pass any type of data as Object but you need to cast it before you implement it to the expected data type.
Anything that is not strongly typed can be argued as being an interpreter. But essentially interpreters are animals which take your code (a script) and turn it into compiled code using another language specification.
I think a perfect example would be Haskel which is an interpreter for prolog.

eggmatters 21 Junior Poster in Training

Try ending your string with your "token" - this from onlinepubs:
The strtok() function then searches from there for a byte that is contained in the current separator string. If no such byte is found, the current token extends to the end of the string pointed to by s1, and subsequent searches for a token shall return a null pointer

I think that means it wraps the string.

eggmatters 21 Junior Poster in Training

Hmm, for offline tasks, you would want to go to a more traditional operable language (C++, java, etc) . Even then, certain of those languages can be distilled into which tasks does one perform over another. So, a few examples, if you want to do operating system programming (Creating command line commands like grep, etc.) use good ol' fashioned C. Games, intensive programs that require a lot of memory, C++. Windows look and feel GUI programs, I would recommend C#. For a very happy medium, I recommend java. I find it to be the most predictable language I have worked with. You can easily add GUI desktop components with Swing, it enforces good programming habits, it runs much cleaner than a scripting language like PHP, Python or Perl. I however, miss C++ and have caught java not managing it's memory in the way I would expect it to.

eggmatters 21 Junior Poster in Training

Worked! Thank you. The good ol' Modal and non-modal dialogs. It's slowly creeping back. For any other readers out there having this problem, also, in the Form2 code, make sure you actually assign Form2.DialogResult = Dialog.OK That hung me up for a bit, I'm embarrassed to admit.

eggmatters 21 Junior Poster in Training

Hello,

I have an application where (and this is probably not how its done but something I'd like to do) the user clicks a button which brings up another form with 2 text boxes. The user enters text, and then clicks ok. The user entered text is then passed to a constructor to an object instantiated in form1. I noticed that control flow during form1's click event falls to the next line after form 2 is shown. Can I "suspend" control flow on form1, passing focus to form2 until the ok click event occurs on form2 so I can use its data to instantiate my constructor? In short, what I'm trying to do is this:

public class myClass
{
   public myClass(int a, int b);
//...constructor, and class methods, members, accessors etc.
}

public struct constructordata
{
   public int int_a;
   public int int_b;
}

public partial class form1 : Form
{
   public Form1()
   {
      InitializeComponent();
   }

   private void Its_Ok_button(object sender, EventArgs e)
   {
      constructordata c_data = new constructordata();
      //Passing in constructordata to form 2.
      Form2 form2 = new Form2(ref c_data);
      form2.Show();
      //Here I want to wait until the data has been assigned in form 2.
      myClass class = new myClass(c_data.int_a, c_data.int_b);
   }
   
   . . .

   public partial class Form2 : Form
   {
      public Form2(ref constructordata c_data)
      {
         InitializeComponent;
      }

   private void data_ok_Click(object sender, EventArgs e)
   {
      c_data.int_a = textBox1.Text.ToInt16();
      c_data.int_b = textBox2.Text.ToInt16();
// So here is where I want focus to return back to form1. 
     }

I tried writing …