-
Notifications
You must be signed in to change notification settings - Fork 1
/
AminoAcid.java
63 lines (51 loc) · 1.76 KB
/
AminoAcid.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import java.awt.*;
import javax.swing.*;
public class AminoAcid extends Label{
//Creation of fields
public boolean mobile;
public String name_1letter;
public String name_3;
public String full_name;
public boolean Polarity;
public double HydropathyIndex;
public String SideChainCharge;
int r;
int g;
int b;
int x;
JPanel panel;
AminoAcid (String full_name, Boolean Polarity, double HydropathyIndex, String SideChainCharge, String name_3, String name_1letter) {
//This constructor sets the fields of the object according to the parameters
this.name_1letter = name_1letter;
this.name_3 = name_3;
this.full_name = full_name;
this.Polarity = Polarity;
this.HydropathyIndex = HydropathyIndex;
this.SideChainCharge = SideChainCharge;
}
public void setup (int r, int g, int b, int x, JPanel panel) {
//Setting the value of the fields of AminoAcid equal to the parameters passed in
this.r = r;
this.g = g;
this.b = b;
this.x = x;
this.panel = panel;
//Setting the bounds and color of the object according to the parameters
setBounds(x*2/3, 50*2/3, 50*2/3, 50*2/3);
setBackground(new Color(r, g, b));
panel.add(this);
//Adding mouse listener and mouse motion listener to AminoAcid
addMouseMotionListener(new GUI.box_mouselistener());
addMouseListener(new GUI.box_mouselistener());
//Labeling the AminoAcid with its abbreviation
this.setAlignment(Label.CENTER);
this.setFont(new Font("Arial", Font.CENTER_BASELINE, 14));
this.setText(name_3);
}
public AminoAcid clone () {
//This method creates and returns a new AminoAcid with most of the same fields
AminoAcid clone = new AminoAcid(full_name, Polarity, HydropathyIndex, SideChainCharge, name_3, name_1letter);
clone.setup(r, g, b, x, panel);
return clone;
}
}