The Artima Developer Community
Sponsored Link

Java Answers Forum
creating motif logo

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
promiti chakraborty

Posts: 2
Nickname: p01
Registered: May, 2014

creating motif logo Posted: May 14, 2014 10:00 PM
Reply to this message Reply
Advertisement
I am trying to create a motif logo taking input from file and the output will show the result in the textarea. Here, input can be taken but output is not shown. I have done the code as follows:

public class Loogo extends JFrame {

Container c = getContentPane();
int lng1, lng2, i, j;
JLabel l1, l2, l3, l4;
JTextField t1, t2, t3, t4;
JTextArea t5;
//int match=5,gap=-4,mismatch=-3;
JButton b1, b2, b3, b4;
String s1, s2, s3, s4;
String output;

public Loogo() {
l3 = new JLabel("NiddlemanWunch Algorithm.");
c.add(l3);
l1 = new JLabel("1st sequence");
l2 = new JLabel("2nd sequence");
l3 = new JLabel("3rd sequence");
l4 = new JLabel("4th sequence");
t1 = new JTextField(20);
t2 = new JTextField(20);
t3 = new JTextField(20);
t4 = new JTextField(20);
t5 = new JTextArea(20, 20);
b1 = new JButton("upload 1st sequence file");
b2 = new JButton("upload 2nd sequence file");
final JButton b5 = new JButton("Motif");
b3 = new JButton("upload 3rd sequence file");
b4 = new JButton("upload 4th sequence file");
FlowLayout f = new FlowLayout();
c.setLayout(f);
c.add(l1);
c.add(t1);
c.add(l2);
c.add(t2);
c.add(l3);
c.add(t3);
c.add(l4);
c.add(t4);
c.add(b1);
c.add(b2);
c.add(b3);
c.add(b4);
c.add(b5);
c.add(t5);
Font font = new Font("Courier", Font.PLAIN, 20);
t3.setFont(font);
b1.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent ae) {
JFileChooser fj = new JFileChooser();
fj.showOpenDialog(null);
fj.setFileSelectionMode(JFileChooser.FILES_ONLY);
File fe = fj.getSelectedFile();
try {
FileReader reader = new FileReader(fe);
BufferedReader br = new BufferedReader(reader);
t1.read(br, null);
br.close();
} catch (Exception e2) {
System.out.println(e2);
}
}
});


b2.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent ae) {
JFileChooser fj = new JFileChooser();
fj.showOpenDialog(null);
fj.setFileSelectionMode(JFileChooser.FILES_ONLY);
File fw = fj.getSelectedFile();
try {
FileReader reader = new FileReader(fw);
BufferedReader br = new BufferedReader(reader);
t2.read(br, null);
br.close();
} catch (Exception e2) {
System.out.println(e2);
}
}
});
b3.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent ae) {
JFileChooser fj = new JFileChooser();
fj.showOpenDialog(null);
fj.setFileSelectionMode(JFileChooser.FILES_ONLY);
File fe = fj.getSelectedFile();
try {
FileReader reader = new FileReader(fe);
BufferedReader br = new BufferedReader(reader);
t3.read(br, null);
br.close();
} catch (Exception e2) {
System.out.println(e2);
}
}
});


b4.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent ae) {
JFileChooser fj = new JFileChooser();
fj.showOpenDialog(null);
fj.setFileSelectionMode(JFileChooser.FILES_ONLY);
File fw = fj.getSelectedFile();
try {
FileReader reader = new FileReader(fw);
BufferedReader br = new BufferedReader(reader);
t4.read(br, null);
br.close();
} catch (Exception e2) {
System.out.println(e2);
}
}
});

b5.addActionListener(new ActionListener() {

private int colorIndex;

public void paint(Graphics g) {
char c1 = ' ';
char c2 = ' ';
char c3 = ' ';
char c4 = ' ';

s1 = t1.getText();
s2 = t2.getText();
s3 = t3.getText();
s4 = t4.getText();
int l1 = s1.length();
colorIndex = 0;
c1 = s1.charAt(i);
c2 = s2.charAt(i);
c3 = s3.charAt(i);
c4 = s4.charAt(i);
Point loc = new Point(10, 10);
for (int i = 0; i < l1; i++) {
if (c1 == c2 && c1 == c3 && c1 == c4) {

if (c1 == 'A') {
g.setColor(Color.black);
} else if (c1 == 'T') {
g.setColor(Color.red);
} else if (c1 == 'G') {
g.setColor(Color.blue);
} else if (c1 == 'C') {
g.setColor(Color.green);
}
Font f = new Font("TimesRoman", Font.PLAIN, 72);
int width = g.getFontMetrics().charWidth(c1);
g.drawString("" + c, loc.x, loc.y);
loc.x += width;

}
}
}

public void actionPerformed(ActionEvent ae) {
t5.setEditable(true);


if (ae.getSource() == b5) {
repaint();
}


}
});
setVisible(true);
setSize(500, 600);
}

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Loogo l = new Loogo();
// TODO code application logic here`enter code here`
}
}

Topic: implementing position specific scoring matrix Previous Topic   Next Topic Topic: Problem in runnig java code

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use