7fd59977 |
1 | |
2 | //Title: Open CASCADE Technology Samples |
3 | //Version: |
4 | //Copyright: Copyright (c) 2000 |
5 | //Author: User Interface Group (Nizhny Novgorod) |
6 | //Company: Matra Datavision |
7 | //Description: |
8 | |
9 | |
10 | import java.awt.*; |
11 | import java.awt.event.*; |
12 | import javax.swing.*; |
13 | import javax.swing.border.*; |
14 | import java.util.*; |
15 | |
16 | import util.*; |
17 | import CASCADESamplesJni.*; |
18 | |
19 | |
20 | public class ViewPanel extends JPanel implements ActionListener, |
21 | KeyListener |
22 | { |
23 | //-----------------------------------------------------------// |
24 | // Resources |
25 | //-----------------------------------------------------------// |
26 | static private ResourceBundle res1 = ResourceBundle.getBundle("properties.Viewer"); |
27 | static private ResourceBundle res = ResourceBundle.getBundle("properties.ViewerIcon"); |
28 | |
29 | // Zooming |
30 | static private ImageIcon imgFitAll = new ImageIcon(res.getString("IC_FIT_ALL")); |
31 | static private ImageIcon imgZoom = new ImageIcon(res.getString("IC_ZOOM")); |
32 | static private ImageIcon imgDynZoom = new ImageIcon(res.getString("IC_DYN_ZOOM")); |
33 | |
34 | // Panning |
35 | static private ImageIcon imgDynPan = new ImageIcon(res.getString("IC_DYN_PAN")); |
36 | static private ImageIcon imgGlobPan = new ImageIcon(res.getString("IC_GLOB_PAN")); |
37 | |
38 | // Projection |
39 | static private ImageIcon imgFront = new ImageIcon(res.getString("IC_FRONT")); |
40 | static private ImageIcon imgTop = new ImageIcon(res.getString("IC_TOP")); |
41 | static private ImageIcon imgLeft = new ImageIcon(res.getString("IC_LEFT")); |
42 | static private ImageIcon imgBack = new ImageIcon(res.getString("IC_BACK")); |
43 | static private ImageIcon imgRight = new ImageIcon(res.getString("IC_RIGHT")); |
44 | static private ImageIcon imgBottom = new ImageIcon(res.getString("IC_BOTTOM")); |
45 | static private ImageIcon imgAxo = new ImageIcon(res.getString("IC_AXO")); |
46 | |
47 | // Rotation |
48 | static private ImageIcon imgRotate = new ImageIcon(res.getString("IC_ROTATE")); |
49 | |
50 | // Reset view |
51 | static private ImageIcon imgReset = new ImageIcon(res.getString("IC_RESET")); |
52 | |
53 | // Degenerated mode |
54 | static private ImageIcon imgHiddenOff = new ImageIcon(res.getString("IC_HIDDEN_OFF")); |
55 | static private ImageIcon imgHiddenOn = new ImageIcon(res.getString("IC_HIDDEN_ON")); |
56 | |
57 | // Grid management |
58 | static private ImageIcon imgRectLine = new ImageIcon(res.getString("IC_RECT_LINE")); |
59 | static private ImageIcon imgRectPoint = new ImageIcon(res.getString("IC_RECT_POINT")); |
60 | static private ImageIcon imgCircLine = new ImageIcon(res.getString("IC_CIRC_LINE")); |
61 | static private ImageIcon imgCircPoint = new ImageIcon(res.getString("IC_CIRC_POINT")); |
62 | static private ImageIcon imgEditGrid = new ImageIcon(res.getString("IC_EDIT_GRID")); |
63 | static private ImageIcon imgEraseGrid = new ImageIcon(res.getString("IC_ERASE_GRID")); |
64 | |
65 | |
66 | //-----------------------------------------------------------// |
67 | // GUI components |
68 | //-----------------------------------------------------------// |
69 | private JToolBar buttonsBar = new JToolBar(JToolBar.HORIZONTAL); |
70 | private ViewCanvas VPort; |
71 | |
72 | static private Insets margin = new Insets(1,1,1,1); |
73 | |
74 | |
75 | //-----------------------------------------------------------// |
76 | // Listeners |
77 | //-----------------------------------------------------------// |
78 | private transient Vector mouseMotionListeners; |
79 | private transient Vector mouseListeners; |
80 | private transient Vector keyListeners; |
81 | |
82 | |
83 | //-----------------------------------------------------------// |
84 | // OS type |
85 | //-----------------------------------------------------------// |
86 | private static int OsType = ViewCanvas.getOSType(); |
87 | |
88 | |
89 | //-----------------------------------------------------------// |
90 | // View type |
91 | //-----------------------------------------------------------// |
92 | public static int VIEW_3D = 0; |
93 | public static int VIEW_2D = 1; |
94 | |
95 | |
96 | //=======================================================================// |
97 | // Constructor |
98 | //=======================================================================// |
99 | public ViewPanel() |
100 | { |
101 | this(VIEW_3D); |
102 | } |
103 | |
104 | public ViewPanel(int type) |
105 | { |
106 | try |
107 | { |
108 | jbInit(type); |
109 | } |
110 | catch (Exception e) |
111 | { |
112 | e.printStackTrace(); |
113 | } |
114 | } |
115 | |
116 | //=======================================================================// |
117 | // Component initialization |
118 | //=======================================================================// |
119 | private void jbInit(int type) throws Exception |
120 | { |
121 | this.setBackground(Color.gray); |
122 | this.setLayout(new BorderLayout()); |
123 | |
124 | // Create view port |
125 | JPanel port = new JPanel(new BorderLayout()); |
126 | port.setBorder(BorderFactory.createLoweredBevelBorder()); |
127 | VPort = createViewPort(); |
128 | VPort.setParent(this); |
129 | port.add(VPort, BorderLayout.CENTER); |
130 | add(port, BorderLayout.CENTER); |
131 | |
132 | // Create toolbar |
133 | buttonsBar = new JToolBar(); |
134 | buttonsBar.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); |
135 | buttonsBar.setFloatable(true); |
136 | if (type == VIEW_2D) |
137 | createMenu2d(); |
138 | else |
139 | createMenu3d(); |
140 | add(buttonsBar, BorderLayout.NORTH); |
141 | |
142 | addKeyListener(this); |
143 | } |
144 | |
145 | //-----------------------------------------------------------// |
146 | // Creation view port |
147 | //-----------------------------------------------------------// |
148 | public ViewCanvas createViewPort() |
149 | { |
150 | return new ViewCanvas(); |
151 | } |
152 | |
153 | public ViewCanvas getViewPort() |
154 | { |
155 | return VPort; |
156 | } |
157 | |
158 | |
159 | //-----------------------------------------------------------// |
160 | // Creation menu for view3d |
161 | //-----------------------------------------------------------// |
162 | private void createMenu3d() |
163 | { |
164 | JButton button; |
165 | JToggleButton toggle; |
166 | |
167 | // Zooming |
168 | button = new HeavyButton(imgFitAll); |
169 | button.setToolTipText(res1.getString("TT_FIT_ALL")); |
170 | button.setActionCommand("FitAll"); |
171 | button.addActionListener(VPort); |
172 | button.setMargin(margin); |
173 | buttonsBar.add(button); |
174 | |
175 | button = new HeavyButton(imgZoom); |
176 | button.setToolTipText(res1.getString("TT_ZOOM")); |
177 | button.setActionCommand("Zoom"); |
178 | button.addActionListener(VPort); |
179 | button.setMargin(margin); |
180 | buttonsBar.add(button); |
181 | |
182 | button = new HeavyButton(imgDynZoom); |
183 | button.setToolTipText(res1.getString("TT_DYN_ZOOM")); |
184 | button.setActionCommand("DynZoom"); |
185 | button.addActionListener(VPort); |
186 | button.setMargin(margin); |
187 | buttonsBar.add(button); |
188 | |
189 | buttonsBar.addSeparator(); |
190 | |
191 | // Panning |
192 | button = new HeavyButton(imgDynPan); |
193 | button.setToolTipText(res1.getString("TT_DYN_PAN")); |
194 | button.setActionCommand("DynPan"); |
195 | button.addActionListener(VPort); |
196 | button.setMargin(margin); |
197 | buttonsBar.add(button); |
198 | |
199 | button = new HeavyButton(imgGlobPan); |
200 | button.setToolTipText(res1.getString("TT_GLOB_PAN")); |
201 | button.setActionCommand("GlobPan"); |
202 | button.addActionListener(VPort); |
203 | button.setMargin(margin); |
204 | buttonsBar.add(button); |
205 | |
206 | buttonsBar.addSeparator(); |
207 | |
208 | // Projection |
209 | button = new HeavyButton(imgFront); |
210 | button.setToolTipText(res1.getString("TT_FRONT")); |
211 | button.setActionCommand("Front"); |
212 | button.addActionListener(VPort); |
213 | button.setMargin(margin); |
214 | buttonsBar.add(button); |
215 | |
216 | button = new HeavyButton(imgTop); |
217 | button.setToolTipText(res1.getString("TT_TOP")); |
218 | button.setActionCommand("Top"); |
219 | button.addActionListener(VPort); |
220 | button.setMargin(margin); |
221 | buttonsBar.add(button); |
222 | |
223 | button = new HeavyButton(imgLeft); |
224 | button.setToolTipText(res1.getString("TT_LEFT")); |
225 | button.setActionCommand("Left"); |
226 | button.addActionListener(VPort); |
227 | button.setMargin(margin); |
228 | buttonsBar.add(button); |
229 | |
230 | button = new HeavyButton(imgBack); |
231 | button.setToolTipText(res1.getString("TT_BACK")); |
232 | button.setActionCommand("Back"); |
233 | button.addActionListener(VPort); |
234 | button.setMargin(margin); |
235 | buttonsBar.add(button); |
236 | |
237 | button = new HeavyButton(imgRight); |
238 | button.setToolTipText(res1.getString("TT_RIGHT")); |
239 | button.setActionCommand("Right"); |
240 | button.addActionListener(VPort); |
241 | button.setMargin(margin); |
242 | buttonsBar.add(button); |
243 | |
244 | button = new HeavyButton(imgBottom); |
245 | button.setToolTipText(res1.getString("TT_BOTTOM")); |
246 | button.setActionCommand("Bottom"); |
247 | button.addActionListener(VPort); |
248 | button.setMargin(margin); |
249 | buttonsBar.add(button); |
250 | |
251 | button = new HeavyButton(imgAxo); |
252 | button.setToolTipText(res1.getString("TT_AXO")); |
253 | button.setActionCommand("Axo"); |
254 | button.addActionListener(VPort); |
255 | button.setMargin(margin); |
256 | buttonsBar.add(button); |
257 | |
258 | buttonsBar.addSeparator(); |
259 | |
260 | // Rotation |
261 | button = new HeavyButton(imgRotate); |
262 | button.setToolTipText(res1.getString("TT_ROTATE")); |
263 | button.setActionCommand("Rotate"); |
264 | button.addActionListener(VPort); |
265 | button.setMargin(margin); |
266 | buttonsBar.add(button); |
267 | |
268 | buttonsBar.addSeparator(); |
269 | |
270 | // Reset view |
271 | button = new HeavyButton(imgReset); |
272 | button.setToolTipText(res1.getString("TT_RESET")); |
273 | button.setActionCommand("Reset"); |
274 | button.addActionListener(VPort); |
275 | button.setMargin(margin); |
276 | buttonsBar.add(button); |
277 | |
278 | buttonsBar.addSeparator(); |
279 | |
280 | // Degeneration mode |
281 | ButtonGroup group = new ButtonGroup(); |
282 | toggle = new JToggleButton(imgHiddenOff, false); |
283 | toggle.setToolTipText(res1.getString("TT_HIDDEN_OFF")); |
284 | toggle.setActionCommand("HiddenOff"); |
285 | toggle.addActionListener(VPort); |
286 | toggle.setMargin(margin); |
287 | group.add(toggle); |
288 | buttonsBar.add(toggle); |
289 | |
290 | toggle = new JToggleButton(imgHiddenOn, true); |
291 | toggle.setToolTipText(res1.getString("TT_HIDDEN_ON")); |
292 | toggle.setActionCommand("HiddenOn"); |
293 | toggle.addActionListener(VPort); |
294 | toggle.setMargin(margin); |
295 | group.add(toggle); |
296 | buttonsBar.add(toggle); |
297 | |
298 | VPort.SetDegenerateMode(true); |
299 | } |
300 | |
301 | |
302 | //-----------------------------------------------------------// |
303 | // Creation menu for view2d |
304 | //-----------------------------------------------------------// |
305 | private void createMenu2d() |
306 | { |
307 | JButton button; |
308 | |
309 | // Zooming |
310 | button = new HeavyButton(imgFitAll); |
311 | button.setToolTipText(res1.getString("TT_FIT_ALL")); |
312 | button.setActionCommand("FitAll"); |
313 | button.addActionListener(VPort); |
314 | button.setMargin(margin); |
315 | buttonsBar.add(button); |
316 | |
317 | button = new HeavyButton(imgZoom); |
318 | button.setToolTipText(res1.getString("TT_ZOOM")); |
319 | button.setActionCommand("Zoom"); |
320 | button.addActionListener(VPort); |
321 | button.setMargin(margin); |
322 | buttonsBar.add(button); |
323 | |
324 | button = new HeavyButton(imgDynZoom); |
325 | button.setToolTipText(res1.getString("TT_DYN_ZOOM")); |
326 | button.setActionCommand("DynZoom"); |
327 | button.addActionListener(VPort); |
328 | button.setMargin(margin); |
329 | buttonsBar.add(button); |
330 | |
331 | buttonsBar.addSeparator(); |
332 | |
333 | // Panning |
334 | button = new HeavyButton(imgDynPan); |
335 | button.setToolTipText(res1.getString("TT_DYN_PAN")); |
336 | button.setActionCommand("DynPan"); |
337 | button.addActionListener(VPort); |
338 | button.setMargin(margin); |
339 | buttonsBar.add(button); |
340 | |
341 | button = new HeavyButton(imgGlobPan); |
342 | button.setToolTipText(res1.getString("TT_GLOB_PAN")); |
343 | button.setActionCommand("GlobPan"); |
344 | button.addActionListener(VPort); |
345 | button.setMargin(margin); |
346 | buttonsBar.add(button); |
347 | |
348 | buttonsBar.addSeparator(); |
349 | |
350 | // Grid management |
351 | button = new HeavyButton(imgRectLine); |
352 | button.setToolTipText(res1.getString("TT_RECT_LINE")); |
353 | button.setActionCommand("RectLine"); |
354 | button.addActionListener(VPort); |
355 | button.setMargin(margin); |
356 | buttonsBar.add(button); |
357 | |
358 | button = new HeavyButton(imgRectPoint); |
359 | button.setToolTipText(res1.getString("TT_RECT_POINT")); |
360 | button.setActionCommand("RectPoint"); |
361 | button.addActionListener(VPort); |
362 | button.setMargin(margin); |
363 | buttonsBar.add(button); |
364 | |
365 | button = new HeavyButton(imgCircLine); |
366 | button.setToolTipText(res1.getString("TT_CIRC_LINE")); |
367 | button.setActionCommand("CircLine"); |
368 | button.addActionListener(VPort); |
369 | button.setMargin(margin); |
370 | buttonsBar.add(button); |
371 | |
372 | button = new HeavyButton(imgCircPoint); |
373 | button.setToolTipText(res1.getString("TT_CIRC_POINT")); |
374 | button.setActionCommand("CircPoint"); |
375 | button.addActionListener(VPort); |
376 | button.setMargin(margin); |
377 | buttonsBar.add(button); |
378 | |
379 | button = new HeavyButton(imgEditGrid); |
380 | button.setToolTipText(res1.getString("TT_EDIT_GRID")); |
381 | button.setActionCommand("EditGrid"); |
382 | button.addActionListener(VPort); |
383 | button.setMargin(margin); |
384 | buttonsBar.add(button); |
385 | |
386 | button = new HeavyButton(imgEraseGrid); |
387 | button.setToolTipText(res1.getString("TT_ERASE_GRID")); |
388 | button.setActionCommand("EraseGrid"); |
389 | button.addActionListener(VPort); |
390 | button.setMargin(margin); |
391 | buttonsBar.add(button); |
392 | } |
393 | |
394 | |
395 | //-----------------------------------------------------------// |
396 | // Minimum size |
397 | //-----------------------------------------------------------// |
398 | public Dimension getMinimumSize() |
399 | { |
400 | return new Dimension(700, 100); |
401 | } |
402 | |
403 | |
404 | //-----------------------------------------------------------// |
405 | // Background color |
406 | //-----------------------------------------------------------// |
407 | public void ChangeBackgroundColor() |
408 | { |
409 | Color newColor = JColorChooser.showDialog(this, res1.getString("DLG_CHANGECOLOR"), |
410 | VPort.GetBackgroundColor()); |
411 | if (newColor != null) |
412 | VPort.SetBackgroundColor(newColor); |
413 | } |
414 | |
415 | |
416 | //-----------------------------------------------------------// |
417 | // Default popup |
418 | //-----------------------------------------------------------// |
419 | public PopupMenu getDefaultPopup() |
420 | { |
421 | PopupMenu popup = new PopupMenu(res1.getString("VIEW_POPUP")); |
422 | |
423 | MenuItem item = new MenuItem(res1.getString("MN_BACKGROUND")); |
424 | item.setActionCommand("ChangeColor"); |
425 | item.addActionListener(this); |
426 | popup.add(item); |
427 | |
428 | return popup; |
429 | } |
430 | |
431 | |
432 | //=======================================================================// |
433 | // ActionListener // |
434 | //=======================================================================// |
435 | public void actionPerformed(ActionEvent event) |
436 | { |
437 | String nameAction = event.getActionCommand(); |
438 | |
439 | VPort.ResetState(); |
440 | |
441 | // Backgroung color |
442 | if (nameAction.equals("ChangeColor")) |
443 | ChangeBackgroundColor(); |
444 | |
445 | } |
446 | |
447 | //=======================================================================// |
448 | // External Listeners // |
449 | //=======================================================================// |
450 | public synchronized void removeMouseMotionListener(MouseMotionListener l) |
451 | { |
452 | super.removeMouseMotionListener(l); |
453 | if (mouseMotionListeners != null && mouseMotionListeners.contains(l)) |
454 | { |
455 | Vector v = (Vector) mouseMotionListeners.clone(); |
456 | v.removeElement(l); |
457 | mouseMotionListeners = v; |
458 | } |
459 | } |
460 | |
461 | //=======================================================================// |
462 | public synchronized void addMouseMotionListener(MouseMotionListener l) |
463 | { |
464 | super.addMouseMotionListener(l); |
465 | Vector v = mouseMotionListeners == null ? new Vector(2) : (Vector) mouseMotionListeners.clone(); |
466 | if (!v.contains(l)) |
467 | { |
468 | v.addElement(l); |
469 | mouseMotionListeners = v; |
470 | } |
471 | } |
472 | |
473 | //=======================================================================// |
474 | public void MouseDragged(MouseEvent e) |
475 | { |
476 | MouseEvent event = new MouseEvent(this, e.getID(), e.getWhen(), |
477 | e.getModifiers(), e.getX(), e.getY(), |
478 | e.getClickCount(), e.isPopupTrigger()); |
479 | if (VPort.hasWindow()) fireMouseDragged(event); |
480 | } |
481 | protected void fireMouseDragged(MouseEvent e) |
482 | { |
483 | if (mouseMotionListeners != null) |
484 | { |
485 | Vector listeners = mouseMotionListeners; |
486 | int count = listeners.size(); |
487 | for (int i = 0; i < count; i++) |
488 | ((MouseMotionListener) listeners.elementAt(i)).mouseDragged(e); |
489 | } |
490 | } |
491 | |
492 | //=======================================================================// |
493 | public void MouseMoved(MouseEvent e) |
494 | { |
495 | MouseEvent event = new MouseEvent(this, e.getID(), e.getWhen(), |
496 | e.getModifiers(), e.getX(), e.getY(), |
497 | e.getClickCount(), e.isPopupTrigger()); |
498 | if (VPort.hasWindow()) fireMouseMoved(event); |
499 | } |
500 | protected void fireMouseMoved(MouseEvent e) |
501 | { |
502 | if (mouseMotionListeners != null) |
503 | { |
504 | Vector listeners = mouseMotionListeners; |
505 | int count = listeners.size(); |
506 | for (int i = 0; i < count; i++) |
507 | ((MouseMotionListener) listeners.elementAt(i)).mouseMoved(e); |
508 | } |
509 | } |
510 | |
511 | //=======================================================================// |
512 | public synchronized void removeMouseListener(MouseListener l) |
513 | { |
514 | super.removeMouseListener(l); |
515 | if (mouseListeners != null && mouseListeners.contains(l)) |
516 | { |
517 | Vector v = (Vector) mouseListeners.clone(); |
518 | v.removeElement(l); |
519 | mouseListeners = v; |
520 | } |
521 | } |
522 | |
523 | //=======================================================================// |
524 | public synchronized void addMouseListener(MouseListener l) |
525 | { |
526 | super.addMouseListener(l); |
527 | Vector v = mouseListeners == null ? new Vector(2) : (Vector) mouseListeners.clone(); |
528 | if (!v.contains(l)) |
529 | { |
530 | v.addElement(l); |
531 | mouseListeners = v; |
532 | } |
533 | } |
534 | |
535 | //=======================================================================// |
536 | public void MouseClicked(MouseEvent e) |
537 | { |
538 | MouseEvent event = new MouseEvent(this, e.getID(), e.getWhen(), |
539 | e.getModifiers(), e.getX(), e.getY(), |
540 | e.getClickCount(), e.isPopupTrigger()); |
541 | if (VPort.hasWindow()) fireMouseClicked(event); |
542 | } |
543 | protected void fireMouseClicked(MouseEvent e) |
544 | { |
545 | if (mouseListeners != null) |
546 | { |
547 | Vector listeners = mouseListeners; |
548 | int count = listeners.size(); |
549 | for (int i = 0; i < count; i++) |
550 | ((MouseListener) listeners.elementAt(i)).mouseClicked(e); |
551 | } |
552 | } |
553 | |
554 | //=======================================================================// |
555 | public void MouseEntered(MouseEvent e) |
556 | { |
557 | MouseEvent event = new MouseEvent(this, e.getID(), e.getWhen(), |
558 | e.getModifiers(), e.getX(), e.getY(), |
559 | e.getClickCount(), e.isPopupTrigger()); |
560 | if (VPort.hasWindow()) fireMouseEntered(event); |
561 | } |
562 | protected void fireMouseEntered(MouseEvent e) |
563 | { |
564 | if (mouseListeners != null) |
565 | { |
566 | Vector listeners = mouseListeners; |
567 | int count = listeners.size(); |
568 | for (int i = 0; i < count; i++) |
569 | ((MouseListener) listeners.elementAt(i)).mouseEntered(e); |
570 | } |
571 | } |
572 | |
573 | //=======================================================================// |
574 | public void MouseExited(MouseEvent e) |
575 | { |
576 | MouseEvent event = new MouseEvent(this, e.getID(), e.getWhen(), |
577 | e.getModifiers(), e.getX(), e.getY(), |
578 | e.getClickCount(), e.isPopupTrigger()); |
579 | if (VPort.hasWindow()) fireMouseExited(event); |
580 | } |
581 | protected void fireMouseExited(MouseEvent e) |
582 | { |
583 | if (mouseListeners != null) |
584 | { |
585 | Vector listeners = mouseListeners; |
586 | int count = listeners.size(); |
587 | for (int i = 0; i < count; i++) |
588 | ((MouseListener) listeners.elementAt(i)).mouseExited(e); |
589 | } |
590 | } |
591 | |
592 | //=======================================================================// |
593 | public void MousePressed(MouseEvent e) |
594 | { |
595 | MouseEvent event = new MouseEvent(this, e.getID(), e.getWhen(), |
596 | e.getModifiers(), e.getX(), e.getY(), |
597 | e.getClickCount(), e.isPopupTrigger()); |
598 | if (VPort.hasWindow()) fireMousePressed(event); |
599 | } |
600 | protected void fireMousePressed(MouseEvent e) |
601 | { |
602 | if (mouseListeners != null) |
603 | { |
604 | Vector listeners = mouseListeners; |
605 | int count = listeners.size(); |
606 | for (int i = 0; i < count; i++) |
607 | ((MouseListener) listeners.elementAt(i)).mousePressed(e); |
608 | } |
609 | } |
610 | |
611 | //=======================================================================// |
612 | public void MouseReleased(MouseEvent e) |
613 | { |
614 | MouseEvent event = new MouseEvent(this, e.getID(), e.getWhen(), |
615 | e.getModifiers(), e.getX(), e.getY(), |
616 | e.getClickCount(), e.isPopupTrigger()); |
617 | if (VPort.hasWindow()) fireMouseReleased(event); |
618 | } |
619 | protected void fireMouseReleased(MouseEvent e) |
620 | { |
621 | if (mouseListeners != null) |
622 | { |
623 | Vector listeners = mouseListeners; |
624 | int count = listeners.size(); |
625 | for (int i = 0; i < count; i++) |
626 | ((MouseListener) listeners.elementAt(i)).mouseReleased(e); |
627 | } |
628 | } |
629 | |
630 | //=======================================================================// |
631 | // KeyListener |
632 | //=======================================================================// |
633 | public void keyTyped(KeyEvent e) |
634 | { |
635 | } |
636 | |
637 | //=======================================================================// |
638 | public void keyPressed(KeyEvent e) |
639 | { |
640 | } |
641 | |
642 | //=======================================================================// |
643 | public void keyReleased(KeyEvent e) |
644 | { |
645 | if (e.getKeyCode() == e.VK_ESCAPE) VPort.ResetState(); |
646 | } |
647 | |
648 | //=======================================================================// |
649 | public synchronized void removeKeyListener(KeyListener l) |
650 | { |
651 | if(keyListeners != null && keyListeners.contains(l)) |
652 | { |
653 | Vector v = (Vector) keyListeners.clone(); |
654 | v.removeElement(l); |
655 | keyListeners = v; |
656 | super.removeKeyListener(l); |
657 | } |
658 | } |
659 | |
660 | //=======================================================================// |
661 | public synchronized void addKeyListener(KeyListener l) |
662 | { |
663 | Vector v = keyListeners == null ? new Vector(2) : (Vector) keyListeners.clone(); |
664 | if(!v.contains(l)) |
665 | { |
666 | v.addElement(l); |
667 | keyListeners = v; |
668 | super.addKeyListener(l); |
669 | } |
670 | } |
671 | } |
672 | |
673 | |