Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-13-2010, 02:56 AM   PM User | #1
Nutscase
New to the CF scene

 
Join Date: Dec 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Nutscase is an unknown quantity at this point
Help needed to change both set of images in programe when up/down button is pressed.

Hi guys, would appreciate some help here.

The below is part of the codes of my image matching programme. The programme loads 2 different series of images in the area and the up/down button is supposed to change each set of the series of images. Currently, the codes only allow one set of the images to be changed. Any idea what can be done so that both set get changes when the up/down key is pressed?

Thanks!

Codes:

public void keyReleased(KeyEvent e) {
zoom = false;
repaint();
}

public void keyPressed(KeyEvent e) {
System.out.println("" + e.getKeyCode());
switch (e.getKeyCode()) {
case 16:
zoom = true;
zoomPt = getMousePosition();
repaint();
break;
case 39:
loadImage(true, true);
break;
case 40:
loadImage(false, true);
break;
case 38:
loadImage(false, false);
break;
case 37:
loadImage(true, false);
break;
}

}
public void changeDir(File dir) {
this.dir = dir;
}
public void loadImage(boolean isFileA, boolean increase) {
File[] fileList = dir.listFiles(new FilenameFilter() {

public boolean accept(File dir, String name) {
if (name.toLowerCase().endsWith(".dcm")
|| name.toLowerCase().endsWith(".dc3")
|| name.toLowerCase().endsWith(".dic")) {
return true;
} else {
return false;
}
}
});
if (fileList.length < 2) {
return;
}
try {
if (isFileA) {
a_os = increase? (a_os + 1) % fileList.length : (a_os - 1 + fileList.length) % fileList.length;
} else {
b_os = increase? (b_os + 1) % fileList.length: (b_os - 1 + fileList.length) % fileList.length;
}
String ext = fileList[a_os].getName().substring(fileList[a_os].getName().lastIndexOf(".") + 1);
Iterator readers = ImageIO.getImageReadersByFormatName(ext);
ImageReader reader = (ImageReader) readers.next();
reader.setInput(new FileImageInputStream(fileList[a_os]), true);
imgA = ((DICOMImageReader) reader).read(0, null);

ext = fileList[b_os].getName().substring(fileList[b_os].getName().lastIndexOf(".") + 1);
readers = ImageIO.getImageReadersByFormatName(ext);
reader = (ImageReader) readers.next();
reader.setInput(new FileImageInputStream(fileList[b_os]), true);
imgB = ((DICOMImageReader) reader).read(0, null);

w = Math.max(imgA.getWidth(), imgB.getWidth());
h = Math.max(imgA.getHeight(), imgB.getHeight());
} catch (Exception e) {
String fileName;
fileName = isFileA ? fileList[a_os].getPath() : fileList[b_os].getPath();
promptError(fileName + " could not be read");
e.printStackTrace();
System.exit(1);
}
dx = w / 2;
dy = h / 2;
}

public void promptError(String msg) {
JOptionPane.showMessageDialog(null, msg, "Error", JOptionPane.ERROR_MESSAGE);
}

public void keyTyped(KeyEvent e) {
}
Nutscase is offline   Reply With Quote
Old 12-13-2010, 03:27 AM   PM User | #2
jmrker
Senior Coder

 
jmrker's Avatar
 
Join Date: Aug 2006
Location: FL
Posts: 2,764
Thanks: 29
Thanked 453 Times in 447 Posts
jmrker will become famous soon enough
You might want to begin by understanding the difference between java and javascript code.
You will probably get more responses on the correct forum.
jmrker is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:41 AM.


Advertisement
Log in to turn off these ads.