Changeset 1a69c4d0b531cf8397a603d2805ec0a14c7cb7f5
- Timestamp:
- 02/25/07 10:14:50
(2 years ago)
- Author:
- Christopher Jung <bktheg@web.de>
- git-committer:
- Christopher Jung <bktheg@web.de> 1172394890 +0100
- git-parent:
[e200d790d77a9428b9fda7da206d78266d3d237f]
- git-author:
- Christopher Jung <bktheg@web.de> 1172394890 +0100
- Message:
Einige Warnungen gefixt sowie Kommentare hinzugefuegt
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r296f325 |
r1a69c4d |
|
| 41 | 41 | import java.awt.image.BufferStrategy; |
|---|
| 42 | 42 | import java.awt.image.BufferedImage; |
|---|
| 43 | | import java.util.ArrayList; |
|---|
| 44 | 43 | import java.util.HashMap; |
|---|
| 45 | 44 | import java.util.Iterator; |
|---|
| … | … | |
| 95 | 94 | private static final int EVENT_RECREATE_BACKBUFFER = 2; |
|---|
| 96 | 95 | |
|---|
| | 96 | /** |
|---|
| | 97 | * Konstruktor |
|---|
| | 98 | * @param datapath Pfad zum Datenverzeichnis |
|---|
| | 99 | */ |
|---|
| 97 | 100 | public CanvasWindowManager(String datapath) { |
|---|
| 98 | 101 | super(); |
|---|
| … | … | |
| 113 | 116 | } |
|---|
| 114 | 117 | |
|---|
| | 118 | /** |
|---|
| | 119 | * Initalisiert den Fenstermanager |
|---|
| | 120 | * |
|---|
| | 121 | */ |
|---|
| 115 | 122 | public void init() { |
|---|
| 116 | 123 | |
|---|
| … | … | |
| 148 | 155 | } |
|---|
| 149 | 156 | |
|---|
| | 157 | /** |
|---|
| | 158 | * Fuellt die Zeichenflaeche mit Schwarz |
|---|
| | 159 | * @param g Die Zeichenflaeche |
|---|
| | 160 | */ |
|---|
| 150 | 161 | public void update(Graphics2D g) { |
|---|
| 151 | 162 | g.setColor(Color.BLACK); |
|---|
| … | … | |
| 153 | 164 | } |
|---|
| 154 | 165 | |
|---|
| | 166 | /** |
|---|
| | 167 | * Startet den Hauptthread |
|---|
| | 168 | * |
|---|
| | 169 | */ |
|---|
| 155 | 170 | public void start() { |
|---|
| 156 | 171 | if( mainThread == null ) { |
|---|
| … | … | |
| 172 | 187 | } |
|---|
| 173 | 188 | |
|---|
| 174 | | ArrayList offScreenBufferList = new ArrayList(); |
|---|
| 175 | | final int MAX_OFFSCREEN_BUFFERS = 100; |
|---|
| | 189 | //ArrayList offScreenBufferList = new ArrayList(); |
|---|
| | 190 | //final int MAX_OFFSCREEN_BUFFERS = 100; |
|---|
| 176 | 191 | |
|---|
| 177 | 192 | while( running ) { |
|---|
| … | … | |
| 366 | 381 | } |
|---|
| 367 | 382 | |
|---|
| | 383 | /** |
|---|
| | 384 | * Stoppt den Hauptthread |
|---|
| | 385 | * |
|---|
| | 386 | */ |
|---|
| 368 | 387 | public void stop () { |
|---|
| 369 | 388 | if( mainThread != null ) { |
|---|
| … | … | |
| 372 | 391 | } |
|---|
| 373 | 392 | |
|---|
| | 393 | @Override |
|---|
| 374 | 394 | public void update( Graphics g ) { |
|---|
| 375 | 395 | redraw = true; |
|---|
| 376 | 396 | } |
|---|
| 377 | 397 | |
|---|
| | 398 | @Override |
|---|
| 378 | 399 | public void paint( Graphics g ) { |
|---|
| 379 | 400 | redraw = true; |
|---|
| 380 | 401 | } |
|---|
| 381 | 402 | |
|---|
| | 403 | /** |
|---|
| | 404 | * Beendet den Fenstermanager |
|---|
| | 405 | * |
|---|
| | 406 | */ |
|---|
| 382 | 407 | public void destroy() { |
|---|
| 383 | 408 | stop(); |
|---|
| … | … | |
| 1701 | 1726 | (awnd.getOffscreenBuffer().getHeight() != awnd.getWindowRect().height) ) { |
|---|
| 1702 | 1727 | |
|---|
| 1703 | | Vector event = new Vector(); |
|---|
| | 1728 | Vector<Object> event = new Vector<Object>(); |
|---|
| 1704 | 1729 | event.add(0, new Integer(EVENT_RECREATE_BACKBUFFER)); |
|---|
| 1705 | 1730 | event.add(1, awnd.getWindow()); |
|---|
| re5910b8 |
r1a69c4d |
|
| 40 | 40 | */ |
|---|
| 41 | 41 | class aComboBoxWindow extends JDialog { |
|---|
| 42 | | private Vector items; |
|---|
| 43 | | private Vector data; |
|---|
| | 42 | private Vector<String> items; |
|---|
| | 43 | private Vector<Object> data; |
|---|
| 44 | 44 | private JComboBox comboBox; |
|---|
| 45 | 45 | private int lineHeight; |
|---|
| 46 | 46 | private Object selectedItem; |
|---|
| 47 | 47 | |
|---|
| | 48 | /** |
|---|
| | 49 | * Konstruktor |
|---|
| | 50 | * @param parent Das Elternfenster |
|---|
| | 51 | * @param windowmanager Der Fenstermanager |
|---|
| | 52 | * @param masterbox Die Kombobox zu der dieses Fenster gehoert |
|---|
| | 53 | */ |
|---|
| 48 | 54 | public aComboBoxWindow( JWindow parent, IWindowManager windowmanager, JComboBox masterbox ) { |
|---|
| 49 | 55 | super( parent, windowmanager ); |
|---|
| … | … | |
| 52 | 58 | selectedItem = null; |
|---|
| 53 | 59 | |
|---|
| 54 | | items = new Vector(); |
|---|
| 55 | | data = new Vector(); |
|---|
| | 60 | items = new Vector<String>(); |
|---|
| | 61 | data = new Vector<Object>(); |
|---|
| 56 | 62 | |
|---|
| 57 | 63 | Graphics2D localg = getImageCache().createImg(1, 1, Transparency.OPAQUE ).createGraphics(); |
|---|
| … | … | |
| 65 | 71 | } |
|---|
| 66 | 72 | |
|---|
| | 73 | @Override |
|---|
| 67 | 74 | public void onResize() { |
|---|
| 68 | 75 | super.onResize(); |
|---|
| … | … | |
| 76 | 83 | } |
|---|
| 77 | 84 | |
|---|
| | 85 | /** |
|---|
| | 86 | * Fuegt ein Item zum Komboboxfenster hinzu |
|---|
| | 87 | * @param itemname Der Name des Items |
|---|
| | 88 | * @param itemdata Das Objekt, welches mit dem Eintrag assoziiert ist |
|---|
| | 89 | */ |
|---|
| 78 | 90 | public void addItem( String itemname, Object itemdata ) { |
|---|
| 79 | 91 | items.add( itemname ); |
|---|
| … | … | |
| 88 | 100 | } |
|---|
| 89 | 101 | |
|---|
| | 102 | /** |
|---|
| | 103 | * Entfernt alle Eintraege aus der Liste |
|---|
| | 104 | * |
|---|
| | 105 | */ |
|---|
| 90 | 106 | public void clear() { |
|---|
| 91 | | items = new Vector(); |
|---|
| 92 | | data = new Vector(); |
|---|
| | 107 | items.clear(); |
|---|
| | 108 | data.clear(); |
|---|
| 93 | 109 | |
|---|
| 94 | 110 | getWindowManager().setWindowVClientMinSize( this, 0 ); |
|---|
| 95 | 111 | } |
|---|
| 96 | 112 | |
|---|
| | 113 | /** |
|---|
| | 114 | * Gibt das mit dem aktuell ausgewaehlten Eintrag assoziierte Objekt zurueck |
|---|
| | 115 | * @return Das Objekt des ausgewaehlten Eintrags oder <code>null</code> |
|---|
| | 116 | */ |
|---|
| 97 | 117 | public Object getSelectedData() { |
|---|
| 98 | 118 | return selectedItem; |
|---|
| 99 | 119 | } |
|---|
| 100 | 120 | |
|---|
| | 121 | @Override |
|---|
| 101 | 122 | public boolean mousePressed( int x, int y, int button ) { |
|---|
| 102 | 123 | boolean result = super.mousePressed( x, y, button ); |
|---|
| … | … | |
| 127 | 148 | } |
|---|
| 128 | 149 | |
|---|
| | 150 | @Override |
|---|
| 129 | 151 | public void paint( Graphics2D g ) { |
|---|
| 130 | 152 | super.paint(g); |
|---|
| … | … | |
| 144 | 166 | |
|---|
| 145 | 167 | for( int i=0; i < items.size(); i++ ) { |
|---|
| 146 | | g.drawString( (String)items.get(i), x, yPosition ); |
|---|
| | 168 | g.drawString( items.get(i), x, yPosition ); |
|---|
| 147 | 169 | |
|---|
| 148 | 170 | yPosition += g.getFontMetrics().getHeight() + 2; |
|---|
| … | … | |
| 161 | 183 | |
|---|
| 162 | 184 | public class JComboBox extends JWindow { |
|---|
| 163 | | private LinkedHashMap names; |
|---|
| 164 | | private LinkedHashMap data; |
|---|
| | 185 | private LinkedHashMap<Integer,String> names; |
|---|
| | 186 | private LinkedHashMap<Integer,Object> data; |
|---|
| 165 | 187 | private int index; |
|---|
| 166 | 188 | private int selected; |
|---|
| … | … | |
| 187 | 209 | cBoxWindow = null; |
|---|
| 188 | 210 | |
|---|
| 189 | | names = new LinkedHashMap(); |
|---|
| 190 | | data = new LinkedHashMap(); |
|---|
| | 211 | names = new LinkedHashMap<Integer,String>(); |
|---|
| | 212 | data = new LinkedHashMap<Integer,Object>(); |
|---|
| 191 | 213 | |
|---|
| 192 | 214 | getImageCache().getImage("interface/jstarmap/icon_dropdown.png", true); |
|---|
| … | … | |
| 194 | 216 | } |
|---|
| 195 | 217 | |
|---|
| | 218 | @Override |
|---|
| 196 | 219 | public void onResize() { |
|---|
| 197 | 220 | super.onResize(); |
|---|
| … | … | |
| 206 | 229 | } |
|---|
| 207 | 230 | |
|---|
| | 231 | @Override |
|---|
| 208 | 232 | public void onChangeVisibility( boolean vis ) { |
|---|
| 209 | 233 | super.onChangeVisibility(vis); |
|---|
| … | … | |
| 226 | 250 | */ |
|---|
| 227 | 251 | public int addElement( String name, Object data ) { |
|---|
| 228 | | this.names.put( new Integer(index), name ); |
|---|
| 229 | | this.data.put( new Integer(index), data ); |
|---|
| | 252 | this.names.put( index, name ); |
|---|
| | 253 | this.data.put( index, data ); |
|---|
| 230 | 254 | |
|---|
| 231 | 255 | if( selected < 0 ) { |
|---|
| … | … | |
| 242 | 266 | */ |
|---|
| 243 | 267 | public void removeElement( int index ) { |
|---|
| 244 | | names.remove( new Integer(index) ); |
|---|
| 245 | | data.remove( new Integer(index) ); |
|---|
| | 268 | names.remove( index ); |
|---|
| | 269 | data.remove( index ); |
|---|
| 246 | 270 | |
|---|
| 247 | 271 | if( index == selected ) { |
|---|
| … | … | |
| 257 | 281 | */ |
|---|
| 258 | 282 | public void setSelectedElement( int index ) { |
|---|
| 259 | | if( names.get(new Integer(index)) != null ) { |
|---|
| | 283 | if( names.get(index) != null ) { |
|---|
| 260 | 284 | selected = index; |
|---|
| 261 | 285 | } |
|---|
| … | … | |
| 281 | 305 | */ |
|---|
| 282 | 306 | public Object getElementData( int index ) { |
|---|
| 283 | | return data.get(new Integer(index)); |
|---|
| | 307 | return data.get(index); |
|---|
| 284 | 308 | } |
|---|
| 285 | 309 | |
|---|
| … | … | |
| 294 | 318 | */ |
|---|
| 295 | 319 | public String getElementString( int index ) { |
|---|
| 296 | | return (String)names.get(new Integer(index)); |
|---|
| 297 | | } |
|---|
| 298 | | |
|---|
| | 320 | return names.get(index); |
|---|
| | 321 | } |
|---|
| | 322 | |
|---|
| | 323 | @Override |
|---|
| 299 | 324 | public boolean mousePressed( int x, int y, int button ) { |
|---|
| 300 | 325 | boolean result = super.mousePressed( x, y, button ); |
|---|
| … | … | |
| 313 | 338 | Integer key = (Integer)iter.next(); |
|---|
| 314 | 339 | |
|---|
| 315 | | cBoxWindow.addItem((String)names.get(key), key); |
|---|
| | 340 | cBoxWindow.addItem(names.get(key), key); |
|---|
| 316 | 341 | } |
|---|
| 317 | 342 | getWindowManager().setVisibility(cBoxWindow,true); |
|---|
| … | … | |
| 333 | 358 | } |
|---|
| 334 | 359 | |
|---|
| | 360 | @Override |
|---|
| 335 | 361 | public boolean handleEvent( int handle, String event ) { |
|---|
| 336 | 362 | boolean result = super.handleEvent( handle, event ); |
|---|
| … | … | |
| 358 | 384 | } |
|---|
| 359 | 385 | |
|---|
| | 386 | @Override |
|---|
| 360 | 387 | public void paint(Graphics2D g) { |
|---|
| 361 | 388 | super.paint(g); |
|---|
| … | … | |
| 374 | 401 | String text = "[leer]"; |
|---|
| 375 | 402 | if( selected > -1 ) { |
|---|
| 376 | | text = (String)names.get(new Integer(selected)); |
|---|
| | 403 | text = names.get(selected); |
|---|
| 377 | 404 | if( text == null ) { |
|---|
| 378 | 405 | text = "[leer]"; |
|---|