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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
| public class SkillView extends JPanel {
public static final long serialVersionUID=0;
private skill.ClassList professions=new skill.ClassList();
private JScrollPane list=new JScrollPane();
public SkillView() {
this.setLayout(new BorderLayout());
this.add(classView(), BorderLayout.NORTH);
list.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
list.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
list.setViewportView(attributeView(professions.getClassByCode("W")));
this.add(list, BorderLayout.CENTER);
System.out.println(professions.toString());
}
private JPanel lineView(skill.Skill s) {
JPanel g=new JPanel(new GridLayout(1, 6));
if(s.elite) g.setBackground(Color.GREEN);
//g.setDropTarget(dt);
JLabel[] line={null, null, new JLabel(), new JLabel(), new JLabel(), new JLabel()};
line[0]=new JLabel(new ImageIcon("ressources/images/skills_small/"+s.code+".jpg"), SwingConstants.LEFT);
line[0].setSize(50, 32);
g.add(line[0]);
line[1]=new JLabel(s.code, SwingConstants.LEFT);
//line[1].setSize(200, 32);
g.add(line[1]);
if(s.adrenaline>0) {
line[2]=new JLabel(Integer.toString(s.adrenaline), new ImageIcon("ressources/images/icons/adrenaline.gif"), SwingConstants.LEFT);
}
if(s.energyCost>0) {
line[2]=new JLabel(Integer.toString(s.energyCost), new ImageIcon("ressources/images/icons/energy.gif"), SwingConstants.LEFT);
}
line[2].setSize(50, 32);
g.add(line[2]);
if(s.castTime>0) {
line[3]=new JLabel(Double.toString(s.castTime), new ImageIcon("ressources/images/icons/cast.gif"), SwingConstants.LEFT);
}
line[3].setSize(50, 32);
g.add(line[3]);
if(s.rechargeTime>0) {
line[4]=new JLabel(Double.toString(s.rechargeTime), new ImageIcon("ressources/images/icons/recharge.gif"), SwingConstants.LEFT);
}
line[4].setSize(50, 32);
g.add(line[4]);
if(s.energyArrow==1) {
line[5]=new JLabel(Integer.toString(s.energyArrow), new ImageIcon("ressources/images/icons/energyHolding.gif"), SwingConstants.LEFT);
}
line[5].setSize(50, 32);
g.add(line[5]);
return g;
}
private JScrollPane attributeView(skill.Class c) {
JPanel jp=new JPanel(new GridLayout(c.attributes.size() * 2, 1)), jp1=null;
JLabel cat=null;
for(int i=0; i<c.attributes.size(); i++) {
cat=new JLabel(c.attributes.get(i).code);
cat.setHorizontalAlignment(SwingConstants.CENTER);
cat.setSize(200, 50);
jp.add(cat);
jp1=new JPanel(new GridLayout(c.attributes.get(i).skills.size(), 1));
for(int j=0; j<c.attributes.get(i).skills.size(); j++) {
jp1.add(lineView(c.attributes.get(i).skills.get(j)));
}
jp.add(jp1);
}
return new JScrollPane(jp);
}
private JPanel classView() {
String[] tags=professions.getClassTags();
JPanel icons=new JPanel(new GridLayout(1, tags.length));
ClassButton[] bprof=new ClassButton[tags.length];
for(int i=0; i<tags.length; i++) {
bprof[i]=new ClassButton(new ImageIcon("ressources/images/class/"+tags[i]+".gif"));
bprof[i].setSize(90, 90);
bprof[i].classCode=tags[i];
bprof[i].setFocusPainted(false);
bprof[i].setBorderPainted(false);
bprof[i].setContentAreaFilled(false);
icons.add(bprof[i]);
}
return icons;
}
private class ClassButton extends JButton {
public static final long serialVersionUID=0;
public String classCode;
public ClassButton(ImageIcon i) {
super(i);
this.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
list.setViewportView(attributeView(professions.getClassByCode(classCode)));
}
});
}
}
} |
Partager