6 // Seth Widoff (core functionality)
7 // Michael Kircher (mk1@cs.wustl.edu)
10 // This is a Visualization Component for displaying weapons.
12 // ============================================================================
20 public class WeaponsVisComp
extends Panel
implements VisComp
22 private final static String ONLINE
= "Online";
23 private final static String OFFLINE
= "Offline";
24 private final static Font FONT_BIG
= new Font ("Dialog", Font
.BOLD
, 14);
25 private final static Font FONT_SMALL
= new Font ("Dialog", Font
.BOLD
, 10);
26 private final static Color BLUE
= new Color (30, 144, 255);
28 private int count_
= 0;
29 private Hashtable weapons_table_
= new Hashtable ();
30 private GridBagLayout gbl_
= new GridBagLayout ();
31 private GridBagConstraints gbc_
= new GridBagConstraints ();
33 Label default_label_
= new Label ("No weapons available", Label
.CENTER
);
35 public WeaponsVisComp ()
37 default_label_
.setFont (FONT_BIG
);
38 default_label_
.setForeground (BLUE
);
45 gbc_
.anchor
= GridBagConstraints
.NORTH
;
46 gbc_
.fill
= GridBagConstraints
.NONE
;
47 setBackground (Color
.black
);
49 gbl_
.setConstraints (default_label_
, gbc_
);
53 public void setName (String title
) {
56 public int getProperty () {
57 return Properties
.WEAPONS
;
60 public Dimension
getPreferredSize () {
61 return new Dimension (250, 200);
64 public Dimension
getMinimumSize () {
65 return new Dimension (80, 80);
68 public void update (java
.util
.Observable observable
, java
.lang
.Object obj
) {
69 Weapons weapons_
= null;
71 weapons_
= (Weapons
) obj
;
73 catch (Exception excp
) {
74 System
.out
.println (excp
);
75 System
.out
.println ("Visualization Component received wrong data type!");
79 for (int i
= 0; i
< weapons_
.number_of_weapons
&& i
< 5; i
++)
87 case 0: weapon
= weapons_
.weapon1_identifier
;
88 status
= weapons_
.weapon1_status
;
90 case 1: weapon
= weapons_
.weapon2_identifier
;
91 status
= weapons_
.weapon2_status
;
93 case 2: weapon
= weapons_
.weapon3_identifier
;
94 status
= weapons_
.weapon3_status
;
96 case 3: weapon
= weapons_
.weapon4_identifier
;
97 status
= weapons_
.weapon4_status
;
99 case 4: weapon
= weapons_
.weapon5_identifier
;
100 status
= weapons_
.weapon5_status
;
105 Label status_label_
= (Label
)weapons_table_
.get (weapon
);
107 if (status_label_
!= null)
108 status_label_
.setText ((status
== 1) ? ONLINE
: OFFLINE
);
115 Label weapon_label_
= new Label (count_
+ ". " + weapon
, Label
.LEFT
);
116 status_label_
= new Label ((status
== 1) ? ONLINE
: OFFLINE
, Label
.RIGHT
);
118 status_label_
.setFont (FONT_SMALL
);
119 weapon_label_
.setFont (FONT_SMALL
);
120 weapon_label_
.setForeground (BLUE
);
123 gbc_
.anchor
= GridBagConstraints
.WEST
;
124 gbl_
.setConstraints (weapon_label_
, gbc_
);
127 gbc_
.anchor
= GridBagConstraints
.EAST
;
128 gbl_
.setConstraints (status_label_
, gbc_
);
132 weapons_table_
.put (weapon
, status_label_
);
135 status_label_
.setForeground ((status
== 1) ?