9 package micropolisj.gui;
12 import java.awt.event.*;
16 import micropolisj.engine.*;
17 import static micropolisj.gui.ColorParser.parseColor;
22 JViewport mapViewport;
27 static final Dimension VIEWPORT_SIZE =
new Dimension(160,160);
28 static final Color QUERY_COLOR =
new Color(255,165,0);
29 static final ResourceBundle strings =
MainWindow.strings;
30 static final ResourceBundle mstrings = ResourceBundle.getBundle(
"micropolisj.CityMessages");
31 static final ResourceBundle s_strings = ResourceBundle.getBundle(
"micropolisj.StatusMessages");
35 super(
new BorderLayout());
38 headerLbl =
new JLabel();
39 headerLbl.setOpaque(
true);
40 headerLbl.setHorizontalAlignment(SwingConstants.CENTER);
41 headerLbl.setBorder(BorderFactory.createRaisedBevelBorder());
42 add(headerLbl, BorderLayout.NORTH);
44 JButton dismissBtn =
new JButton(strings.getString(
"notification.dismiss"));
45 dismissBtn.addActionListener(
new ActionListener() {
46 public void actionPerformed(ActionEvent evt) {
49 add(dismissBtn, BorderLayout.SOUTH);
51 mainPane =
new JPanel(
new BorderLayout());
52 add(mainPane, BorderLayout.CENTER);
54 JPanel viewportContainer =
new JPanel(
new BorderLayout());
55 viewportContainer.setBorder(
56 BorderFactory.createCompoundBorder(
57 BorderFactory.createEmptyBorder(8,4,8,4),
58 BorderFactory.createLineBorder(Color.BLACK)
60 mainPane.add(viewportContainer, BorderLayout.WEST);
62 mapViewport =
new JViewport();
63 mapViewport.setPreferredSize(VIEWPORT_SIZE);
64 mapViewport.setMaximumSize(VIEWPORT_SIZE);
65 mapViewport.setMinimumSize(VIEWPORT_SIZE);
66 viewportContainer.add(mapViewport, BorderLayout.CENTER);
69 mapViewport.setView(mapView);
77 void setPicture(
Micropolis engine,
int xpos,
int ypos)
79 Dimension sz = VIEWPORT_SIZE;
84 mapViewport.setViewPosition(
new Point(
85 r.x + r.width/2 - sz.width/2,
86 r.y + r.height/2 - sz.height/2
92 setPicture(engine, xpos, ypos);
94 if (infoPane != null) {
95 mainPane.remove(infoPane);
99 headerLbl.setText(mstrings.getString(msg.name()+
".title"));
100 headerLbl.setBackground(parseColor(mstrings.getString(msg.name()+
".color")));
102 JLabel myLabel =
new JLabel(
"<html><p>"+
103 mstrings.getString(msg.name()+
".detail") +
"</p></html>");
104 myLabel.setPreferredSize(
new Dimension(1,1));
107 mainPane.add(myLabel, BorderLayout.CENTER);
114 headerLbl.setText(strings.getString(
"notification.query_hdr"));
115 headerLbl.setBackground(QUERY_COLOR);
117 String buildingStr = zone.
building != -1 ? s_strings.getString(
"zone."+zone.
building) :
"";
118 String popDensityStr = s_strings.getString(
"status."+zone.
popDensity);
119 String landValueStr = s_strings.getString(
"status."+zone.
landValue);
120 String crimeLevelStr = s_strings.getString(
"status."+zone.
crimeLevel);
121 String pollutionStr = s_strings.getString(
"status."+zone.
pollution);
122 String growthRateStr = s_strings.getString(
"status."+zone.
growthRate);
124 setPicture(engine, xpos, ypos);
126 if (infoPane != null) {
127 mainPane.remove(infoPane);
131 JPanel p =
new JPanel(
new GridBagLayout());
132 mainPane.add(p, BorderLayout.CENTER);
135 GridBagConstraints c1 =
new GridBagConstraints();
136 GridBagConstraints c2 =
new GridBagConstraints();
140 c1.gridy = c2.gridy = 0;
141 c1.anchor = GridBagConstraints.WEST;
142 c2.anchor = GridBagConstraints.WEST;
143 c1.insets =
new Insets(0,0,0,8);
146 p.add(
new JLabel(strings.getString(
"notification.zone_lbl")), c1);
147 p.add(
new JLabel(buildingStr), c2);
149 c1.gridy = ++c2.gridy;
150 p.add(
new JLabel(strings.getString(
"notification.density_lbl")), c1);
151 p.add(
new JLabel(popDensityStr), c2);
153 c1.gridy = ++c2.gridy;
154 p.add(
new JLabel(strings.getString(
"notification.value_lbl")), c1);
155 p.add(
new JLabel(landValueStr), c2);
157 c1.gridy = ++c2.gridy;
158 p.add(
new JLabel(strings.getString(
"notification.crime_lbl")), c1);
159 p.add(
new JLabel(crimeLevelStr), c2);
161 c1.gridy = ++c2.gridy;
162 p.add(
new JLabel(strings.getString(
"notification.pollution_lbl")), c1);
163 p.add(
new JLabel(pollutionStr), c2);
165 c1.gridy = ++c2.gridy;
166 p.add(
new JLabel(strings.getString(
"notification.growth_lbl")), c1);
167 p.add(
new JLabel(growthRateStr), c2);
172 p.add(
new JLabel(), c1);