source: trunk/src/org/expeditee/gui/FrameGraphics.java@ 19

Last change on this file since 19 was 19, checked in by ra33, 16 years ago
File size: 20.6 KB
Line 
1package org.expeditee.gui;
2
3import java.awt.Color;
4import java.awt.Component;
5import java.awt.Container;
6import java.awt.Dimension;
7import java.awt.Font;
8import java.awt.Graphics;
9import java.awt.Graphics2D;
10import java.awt.GraphicsEnvironment;
11import java.awt.Point;
12import java.awt.RenderingHints;
13import java.awt.image.VolatileImage;
14import java.util.LinkedList;
15import java.util.List;
16
17import javax.swing.JPopupMenu;
18import javax.swing.SwingUtilities;
19
20import org.expeditee.actions.Misc;
21import org.expeditee.items.Dot;
22import org.expeditee.items.InteractiveWidget;
23import org.expeditee.items.Item;
24import org.expeditee.items.Line;
25import org.expeditee.items.Picture;
26import org.expeditee.items.Text;
27import org.expeditee.items.WidgetEdge;
28
29public class FrameGraphics {
30 public static final int MESSAGE_BUFFER_HEIGHT = 100;
31
32 private static final int MESSAGE_LINK_Y_OFFSET = 100;
33
34 private static final int MESSAGE_LINK_X = 50;
35
36 // the graphics used to paint with
37 private static Graphics2D _DisplayGraphics;
38
39 // the maximum size that can be used to paint on
40 private static Dimension _MaxSize;
41
42 // messages shown in the message window
43 public static Text[] Messages = new Text[4];
44
45 // buffer of the message window
46 private static VolatileImage _MessageBuffer = null;
47
48 // font used for the messages
49 private static Font _MessageFont = Font.decode("Serif-Plain-16");
50
51 // the number of messages currently shown (used for scrolling up)
52 private static int _MessageCount = 1;
53
54 // modes
55 public static final int MODE_NORMAL = 0;
56
57 public static final int MODE_AUDIENCE = 1;
58
59 public static final int MODE_XRAY = 2;
60
61 private static int _Mode = MODE_NORMAL;
62
63 // if true, error messages are not shown to the user
64 private static boolean _SupressErrors = false;
65
66 // The link to the message frameset
67 public static Text MessageLink = new Text(-2, "Messages");
68
69 // Date\time formatter for timestamping the messages
70 /*
71 * private static SimpleDateFormat _formatter = new SimpleDateFormat( "
72 * [ddMMMyyyy:HHmm]");
73 */
74
75 // creator for creating the message frames
76 private static FrameCreator _creator;
77
78 /**
79 * Returns the Graphics2D object currently being used to draw with, this may
80 * be null if no Graphics2D has been assigned yet.
81 *
82 * @return the Graphics2D object being used to draw, or null.
83 */
84 public static Graphics2D getGraphics() {
85 return _DisplayGraphics;
86 }
87
88 /**
89 * If Audience Mode is on this method will toggle it to be off, or
90 * vice-versa. This results in the Frame being re-parsed and repainted.
91 */
92 public static void ToggleAudienceMode() {
93 if (_Mode == MODE_AUDIENCE)
94 _Mode = MODE_NORMAL;
95 else
96 _Mode = MODE_AUDIENCE;
97
98 FrameUtils.Parse(DisplayIO.getCurrentFrame());
99 DisplayIO.UpdateTitle();
100 Repaint();
101 }
102
103 /**
104 * If X-Ray Mode is on this method will toggle it to be off, or vice-versa.
105 * This results in the Frame being re-parsed and repainted.
106 */
107 public static void ToggleXRayMode() {
108 if (_Mode == MODE_XRAY)
109 _Mode = MODE_NORMAL;
110 else
111 _Mode = MODE_XRAY;
112
113 FrameUtils.Parse(DisplayIO.getCurrentFrame());
114 Repaint();
115 }
116
117 /**
118 * @return True if Audience Mode is currently on, False otherwise.
119 */
120 public static boolean isAudienceMode() {
121 return _Mode == MODE_AUDIENCE;
122 }
123
124 /**
125 * @return True if X-Ray Mode is currently on, False otherwise.
126 */
127 public static boolean isXRayMode() {
128 return _Mode == MODE_XRAY;
129 }
130
131 public static void setMaxSize(Dimension max) {
132 if (_MaxSize == null)
133 _MaxSize = max;
134
135 // Mike assumes this is the height of the Message window?
136 _MaxSize.setSize(max.width, max.height - MESSAGE_BUFFER_HEIGHT);
137 if (DisplayIO.getCurrentFrame() != null) {
138 DisplayIO.getCurrentFrame().setBuffer(null);
139 DisplayIO.getCurrentFrame().setMaxSize(max);
140 }
141
142 _MessageBuffer = null;
143
144 for (int i = 0; i < Messages.length; i++) {
145 if (Messages[i] != null) {
146 Messages[i].setOffset(0, -_MaxSize.height);
147 Messages[i].setMaxSize(_MaxSize);
148 }
149 }
150
151 MessageLink.setOffset(0, -_MaxSize.height);
152 MessageLink.setMaxSize(_MaxSize);
153 MessageLink.setPosition(_MaxSize.width - MESSAGE_LINK_Y_OFFSET,
154 MESSAGE_LINK_X);
155
156 Repaint();
157 }
158
159 public static Dimension getMaxSize() {
160 return _MaxSize;
161 }
162
163 public static Dimension getMaxFrameSize() {
164 if (DisplayIO.isTwinFramesOn()) {
165 return new Dimension((_MaxSize.width / 2), _MaxSize.height);
166 } else
167 return _MaxSize;
168 }
169
170 /**
171 * Sets the Graphics2D object that should be used for all painting tasks.
172 * Note: Actual painting is done by using g.create() to create temporary
173 * instances that are then disposed of using g.dispose().
174 *
175 * @param g
176 * The Graphics2D object to use for all painting
177 */
178 public static void setDisplayGraphics(Graphics2D g) {
179 _DisplayGraphics = g;
180 }
181
182 /*
183 * Displays the given Item on the screen
184 */
185 private static void PaintItem(Graphics2D g, Item i) {
186 if (i == null || g == null)
187 return;
188
189 // do not paint annotation items in audience mode
190 if (g != null
191 && (!isAudienceMode()
192 || (isAudienceMode() && !i.isAnnotation()) || i == FrameUtils.LastEdited)) {
193 /*
194 * // do not paint the name of overlay frames if (i.getParent() ==
195 * null || i.getParent() == DisplayIO.getCurrentFrame() ||
196 * i.getParent() == DisplayIO.getOppositeFrame() || i !=
197 * i.getParent().getFrameNameItem()) {
198 */
199 Graphics2D tg = (Graphics2D) g.create();
200 i.paint(tg);
201 tg.dispose();
202 }
203 }
204
205 private static void AddAllOverlayItems(List<Item> items, Frame overlay,
206 List<Frame> seenOverlays) {
207 if (seenOverlays.contains(overlay))
208 return;
209
210 seenOverlays.add(overlay);
211
212 for (Overlay o : overlay.getOverlays())
213 AddAllOverlayItems(items, o.Frame, seenOverlays);
214
215 items.addAll(overlay.getItems());
216 }
217
218 private static VolatileImage Paint(Frame toPaint) {
219 return Paint(toPaint, true);
220 }
221
222 private static VolatileImage Paint(Frame toPaint, boolean paintOverlay) {
223 if (toPaint == null)
224 return null;
225
226 // the buffer is not valid, so it must be recreated
227 if (!toPaint.isBufferValid()) {
228 VolatileImage buffer = toPaint.getBuffer();
229 if (buffer == null) {
230 GraphicsEnvironment ge = GraphicsEnvironment
231 .getLocalGraphicsEnvironment();
232 buffer = ge.getDefaultScreenDevice().getDefaultConfiguration()
233 .createCompatibleVolatileImage(_MaxSize.width,
234 _MaxSize.height);
235 toPaint.setBuffer(buffer);
236 }
237
238 Graphics2D bg = (Graphics2D) buffer.getGraphics();
239
240 // Nicer looking lines, but may be too jerky while
241 // rubber-banding on older machines
242 if (UserSettings.AntiAlias)
243 ((Graphics2D) bg).setRenderingHint(
244 RenderingHints.KEY_ANTIALIASING,
245 RenderingHints.VALUE_ANTIALIAS_ON);
246
247 bg.setColor(toPaint.getPaintBackgroundColor());
248 bg.fillRect(0, 0, _MaxSize.width, _MaxSize.height);
249
250 List<Item> paintItems = new LinkedList<Item>();
251 List<Frame> seenOverlays = new LinkedList<Frame>();
252 if (paintOverlay)
253 AddAllOverlayItems(paintItems, toPaint, seenOverlays);
254 else {
255 paintItems.addAll(toPaint.getItems());
256 }
257 // FIRST: Paint widgets swing gui (not expeditee gui) .
258 // Note that these are the ancored widgets
259 for (InteractiveWidget iw : toPaint.getInteractiveWidgets()) {
260 iw.paint(bg);
261 }
262
263 PaintPictures(bg, paintItems);
264
265 if (toPaint == DisplayIO.getCurrentFrame())
266 PaintPictures(bg, Frame.FreeItems);
267
268 PaintNonLinesNonPicture(bg, paintItems);
269 PaintLines(bg, paintItems);
270
271 if (toPaint == DisplayIO.getCurrentFrame())
272 PaintNonLinesNonPicture(bg, Frame.FreeItems);
273
274 // toPaint.setBufferValid(true);
275
276 if (DisplayIO.isTwinFramesOn()) {
277 List<Item> lines = new LinkedList<Item>();
278 for (Item i : Frame.FreeItems) {
279 if (i instanceof Line) {
280 Line line = (Line) i;
281
282 if (toPaint != DisplayIO.getCurrentFrame()) {
283 if (line.getEndItem().isFloating()
284 ^ line.getStartItem().isFloating()) {
285 lines.add(TransposeLine(line,
286 line.getEndItem(), toPaint, DisplayIO
287 .getRealMouseX(), -DisplayIO
288 .getMiddle()));
289 lines.add(TransposeLine(line, line
290 .getStartItem(), toPaint, DisplayIO
291 .getRealMouseX(), -DisplayIO
292 .getMiddle()));
293 }
294 } else {
295 if (line.getEndItem().isFloating()
296 ^ line.getStartItem().isFloating()) {
297 Line l = TransposeLine(line, line.getEndItem(),
298 toPaint, 0, 0);
299 if (l == null)
300 l = TransposeLine(line,
301 line.getStartItem(), toPaint, 0, 0);
302 if (l == null)
303 l = line;
304 lines.add(l);
305 } else
306 lines.add(line);
307 }
308 }
309 }
310 PaintLines(bg, lines);
311 } else {
312 // PaintPictures(bg, Frame.FreeItems);
313 // PaintNonLinesNonPicture(bg, Frame.FreeItems);
314 PaintLines(bg, Frame.FreeItems);
315 }
316
317 if (paintOverlay) {
318 PaintItem(bg, toPaint.getFrameNameItem());
319 }
320
321 // BROOK: Ensure popups are repainted
322 if (Browser._theBrowser != null)
323 repaintPopups(Browser._theBrowser.getLayeredPane(), bg);
324
325 bg.dispose();
326 }
327
328 return toPaint.getBuffer();
329 }
330
331 // creates a new line so that lines are shown correctly when spanning
332 // across frames in TwinFrames mode
333 private static Line TransposeLine(Line line, Item d, Frame toPaint,
334 int base, int adj) {
335 Line nl = null;
336
337 if (toPaint != DisplayIO.getCurrentFrame() && d.getParent() == null
338 && line.getOppositeEnd(d).getParent() == toPaint) {
339 nl = line.copy();
340 if (d == line.getStartItem())
341 d = nl.getStartItem();
342 else
343 d = nl.getEndItem();
344
345 if (DisplayIO.FrameOnSide(toPaint) == 0)
346 d.setX(base);
347 else
348 d.setX(base + adj);
349
350 } else if (toPaint == DisplayIO.getCurrentFrame()
351 && d.getParent() == null
352 && line.getOppositeEnd(d).getParent() != toPaint) {
353 nl = line.copy();
354
355 if (d == line.getStartItem())
356 d = nl.getEndItem();
357 else
358 d = nl.getStartItem();
359
360 if (DisplayIO.FrameOnSide(toPaint) == 1)
361 d.setX(d.getX() - DisplayIO.getMiddle());
362 else
363 d.setX(d.getX() + DisplayIO.getMiddle());
364 }
365
366 return nl;
367 }
368
369 private static void Paint(VolatileImage left, VolatileImage right,
370 Color background) {
371 if (_MessageBuffer == null) {
372 GraphicsEnvironment ge = GraphicsEnvironment
373 .getLocalGraphicsEnvironment();
374 _MessageBuffer = ge.getDefaultScreenDevice()
375 .getDefaultConfiguration().createCompatibleVolatileImage(
376 _MaxSize.width, MESSAGE_BUFFER_HEIGHT);
377 }
378
379 paintMessage(_MessageBuffer.createGraphics(), background);
380 Graphics g = _DisplayGraphics.create();
381
382 // if TwinFrames mode is on, then clipping etc has to be set
383 if (DisplayIO.isTwinFramesOn()) {
384 // draw the two lines down the middle of the window
385 if (left != null)
386 left.getGraphics().drawLine(DisplayIO.getMiddle() - 2, 0,
387 DisplayIO.getMiddle() - 2, _MaxSize.height);
388
389 if (right != null)
390 right.getGraphics().drawLine(0, 0, 0, _MaxSize.height);
391
392 // set the clipping area
393 ((Graphics2D) g).setClip(0, 0, DisplayIO.getMiddle() - 1,
394 _MaxSize.height);
395 g.drawImage(left, 0, 0, DisplayIO.DEFAULT_BACKGROUND, null);
396 ((Graphics2D) g).setClip(null);
397 g.drawImage(right, DisplayIO.getMiddle() + 1, 0,
398 DisplayIO.DEFAULT_BACKGROUND, null);
399
400 // otherwise, just draw whichever side is active
401 } else {
402 if (DisplayIO.getCurrentSide() == 0)
403 g.drawImage(left, 0, 0, DisplayIO.DEFAULT_BACKGROUND, null);
404 else
405 g.drawImage(right, 0, 0, DisplayIO.DEFAULT_BACKGROUND, null);
406 }
407 // draw the message area
408 g.drawImage(_MessageBuffer, 0, _MaxSize.height, null);
409 g.dispose();
410
411 }
412
413
414
415 private static void paintMessage(Graphics2D g, Color background) {
416 ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
417 RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
418 g.setColor(background);
419 g.fillRect(0, 0, _MaxSize.width, MESSAGE_BUFFER_HEIGHT);
420 g.setFont(_MessageFont);
421 g.setColor(Color.BLACK);
422 g.drawLine(0, 0, _MaxSize.width, 0);
423 for (Text t : Messages)
424 PaintItem(g, t);
425 if (MessageLink.getLink() != null)
426 PaintItem(g, MessageLink);
427 g.dispose();
428 }
429
430 public static void Clear() {
431 Graphics g = _DisplayGraphics.create();
432 g.setColor(Color.WHITE);
433 g.fillRect(0, 0, _MaxSize.width, _MaxSize.height);
434 g.dispose();
435 }
436
437 /**
438 * Called to refresh the display screen.
439 *
440 */
441 public static void Repaint() {
442 if (_DisplayGraphics == null)
443 return;
444
445 if (UserSettings.Threading) {
446 if (painter == null) {
447 painter = new FrameGraphics().new Repainter();
448
449 painter.setDaemon(true);
450 painter.setPriority(Thread.MIN_PRIORITY);
451
452 painter.start();
453 } else
454 painter.run();
455 } else {
456 Frame[] toPaint = DisplayIO.getFrames();
457
458 if (toPaint != null) {
459 VolatileImage left = Paint(toPaint[0]);
460 VolatileImage right = Paint(toPaint[1]);
461 Paint(left, right, DisplayIO.DEFAULT_BACKGROUND);
462 }
463 }
464 }
465
466 private static Repainter painter = null;
467
468 private static void PaintNonLinesNonPicture(Graphics2D g, List<Item> toPaint) {
469 for (Item i : toPaint)
470 if (!(i instanceof Line) && !(i instanceof Picture))
471 PaintItem(g, i);
472 }
473
474 private static void PaintLines(Graphics2D g, List<Item> toPaint) {
475 for (Item i : toPaint)
476 if (i instanceof Line)
477 PaintItem(g, i);
478 }
479
480 private static void PaintPictures(Graphics2D g, List<Item> toPaint) {
481 for (Item i : toPaint) {
482 if (i instanceof Picture)
483 PaintItem(g, i);
484 else if (i instanceof Dot)
485 ((Dot) i).paintFill(g);
486 }
487 }
488
489 /**
490 * Highlights an item on the screen Note: All graphics are handled by the
491 * Item itself.
492 *
493 * @param i
494 * The Item to highlight.
495 * @param val
496 * True if the highlighting is being shown, false if it is being
497 * erased.
498 */
499 public static void Highlight(Item i, boolean val, boolean changeMouse) {
500 if ((i instanceof Line)) {
501 // Check if within 20% of the end of the line
502 Line l = (Line) i;
503 Item toDisconnect = l.getEndPointToDisconnect(
504 FrameMouseActions.MouseX, FrameMouseActions.MouseY);
505
506 // Brook: Widget Edges do not have such a context
507 if (toDisconnect != null && !(i instanceof WidgetEdge)) {
508 if(Frame.itemAttachedToCursor())
509 return;
510
511 //unhighlight all the other dots
512 for (Item conn : toDisconnect.getAllConnected()) {
513 conn.showHighlight(false);
514 }
515 //highlight the dot that will be in disconnect mode
516 toDisconnect.showDisconnectHighlight(val);
517 toDisconnect.setFilledHighlight(true);
518 } else {
519 List<Item> connected = i.getAllConnected();
520 for (Item conn : connected) {
521 conn.showHighlight(val);
522 conn.setFilledHighlight(false);
523 }
524 }
525 } else {
526 i.showHighlight(val);
527 i.setFilledHighlight(true);
528 }
529
530 Repaint();
531 }
532
533 public static void OverwriteMessage(String message) {
534 for (int ind = Messages.length - 1; ind >= 0; ind--) {
535 if (Messages[ind] != null) {
536 Messages[ind].setText(message);
537 Repaint();
538 return;
539 }
540 }
541
542 // if we have not returned, then there are no messages yet
543 DisplayMessage(message);
544 }
545
546 /**
547 * Displays the given message in the message area of the Frame, any previous
548 * message is cleared from the screen.
549 *
550 * @param message
551 * The message to display to the user in the message area
552 */
553 public static void DisplayMessage(String message) {
554 DisplayMessageAlways(message);
555 }
556
557 public static void DisplayMessage(String message, Color textColor) {
558 displayMessage(message, null, textColor);
559 Misc.Beep();
560 }
561
562 public static void DisplayMessage(Text message) {
563 displayMessage(message.getFirstLine(), message.getLink(), message
564 .getColor());
565 // Misc.Beep();
566 }
567
568 public static void DisplayMessageAlways(String message) {
569 //_lastMessage = null;
570 displayMessage(message, null, Color.BLACK);
571 Misc.Beep();
572 }
573
574 public static void WarningMessage(String message) {
575 displayMessage(message, null, Color.MAGENTA);
576 Misc.Beep();
577 }
578
579 //private static String _lastMessage = null;
580
581 private static void displayMessage(String message, String link, Color color) {
582 // add timestamp to message
583 //if (message.equals(_lastMessage))
584 // return;
585 //_lastMessage = message;
586
587 // message += _formatter.format(Calendar.getInstance().getTime());
588
589 // if the creator needs to be initialised (happens on first message)
590 if (_creator == null) {
591 _creator = new FrameCreator("Messages", true);
592
593 // set up 'Messages' link on the right hand side
594 MessageLink.setPosition(_MaxSize.width - MESSAGE_LINK_Y_OFFSET,
595 MESSAGE_LINK_X);
596 MessageLink.setOffset(0, -_MaxSize.height);
597 }
598
599 // if the message slots have not all been used yet
600 if (_MessageCount <= Messages.length) {
601 int pos = 15;
602 // find the next empty slot, and create the new message
603 for (int i = 0; i < Messages.length; i++) {
604 if (Messages[i] == null) {
605 Messages[i] = new Text(-1, "@" + _MessageCount++ + ": " + message);
606 Messages[i].setPosition(20, pos);
607 Messages[i].setOffset(0, -_MaxSize.height);
608 Messages[i].setMaxSize(_MaxSize);
609 Messages[i].setColor(color);
610 Messages[i].setLink(link);
611
612 _creator.addItem(Messages[i].copy());
613 MessageLink.setLink(_creator.getCurrent());
614 Repaint();
615 return;
616 }
617
618 pos += 25;
619 }
620 }
621
622 // if we have not returned then all message slots are used
623 for (int i = 0; i < Messages.length - 1; i++) {
624 Messages[i].setText(Messages[i + 1].getFirstLine());
625 Messages[i].setColor(Messages[i + 1].getColor());
626 Messages[i].setLink(Messages[i + 1].getLink());
627 }
628
629 // show the new message
630 Text last = Messages[Messages.length - 1];
631 last.setColor(color);
632 last.setText("@" + _MessageCount++ + ": " + message);
633 last.setLink(link);
634
635 _creator.addItem(last.copy());
636 // update the link to the latest message frame
637 MessageLink.setLink(_creator.getCurrent());
638 Repaint();
639 }
640
641 /**
642 * Checks if the error message ends with a frame name after the
643 * frameNameSeparator symbol
644 *
645 * @param message
646 * the message to be displayed
647 */
648 public static void LinkedErrorMessage(String message) {
649 if (_SupressErrors)
650 return;
651 Misc.Beep();
652 String[] tokens = message.split(Text.FRAME_NAME_SEPARATOR);
653 String link = null;
654 if (tokens.length > 1)
655 link = tokens[tokens.length - 1];
656 displayMessage(message, link, Color.RED);
657 }
658
659 public static void ErrorMessage(String message) {
660 if (_SupressErrors)
661 return;
662 Misc.Beep();
663 displayMessage(message, null, Color.RED);
664
665 // Michael is confused about why this code is gettting into infinite
666 // loop
667
668 /*
669 * Exception e = new Exception();
670 *
671 * try{ throw e; }catch(Exception ex){ StackTraceElement[] trace =
672 * ex.getStackTrace(); message += " (" + trace[1].getFileName() + ":" +
673 * trace[1].getLineNumber() + ")";
674 *
675 * String source = trace[1].getClassName(); source = "src.java." +
676 * source; source = source.replace(".", File.separator); source +=
677 * ".java";
678 *
679 * try{ BufferedReader reader = new BufferedReader(new
680 * FileReader(source)); FrameCreator creator = new
681 * FrameCreator("Messages", false);
682 *
683 * int min = trace[1].getLineNumber() - 10; int max =
684 * trace[1].getLineNumber() + 3;
685 *
686 * int line = 0; while(reader.ready()){ if(line > min && line < max)
687 * if(line == trace[1].getLineNumber() - 1)
688 * creator.addText(reader.readLine(), Color.RED); else
689 * creator.addText(reader.readLine()); else if(line > max) break; else
690 * reader.readLine();
691 *
692 * line++; }
693 *
694 * reader.close();
695 *
696 * displayMessage(message, creator.getCurrent(), Color.RED);
697 * }catch(Exception ioe){ ioe.printStackTrace(); } }
698 */
699 }
700
701 private class Repainter extends Thread {
702 public boolean isPainting = false;
703
704 public void run() {
705 isPainting = true;
706
707 Frame[] toPaint = DisplayIO.getFrames();
708
709 if (toPaint != null) {
710 VolatileImage left = Paint(toPaint[0]);
711 VolatileImage right = Paint(toPaint[1]);
712 Paint(left, right, DisplayIO.DEFAULT_BACKGROUND);
713 }
714
715 isPainting = false;
716 }
717 }
718
719 /**
720 * Invalidates the buffered image of the current Frame and forces it to be
721 * repainted on to the screen.
722 */
723 public static void ForceRepaint() {
724 Frame current = DisplayIO.getCurrentFrame();
725
726 if (current == null)
727 return;
728
729 Repaint();
730 }
731
732 /**
733 * Repaints the buffer of the given Frame.
734 *
735 * @param toUpdate
736 * The Frame whose buffer is to be repainted.
737 */
738
739 public static void UpdateBuffer(Frame toUpdate, boolean paintOverlays) {
740 if (toUpdate == null)
741 return;
742
743 VolatileImage vi = Paint(toUpdate, paintOverlays);
744 toUpdate.setBuffer(vi);
745 }
746
747 public static void SupressErrors(boolean val) {
748 _SupressErrors = val;
749 }
750
751
752 private static void repaintPopups(Container parent, Graphics g) {
753 for (Component c : parent.getComponents()) {
754 if (c instanceof JPopupMenu && ((JPopupMenu)c).isVisible()) {
755
756 Point p = SwingUtilities.convertPoint(c, c.getLocation(), Browser._theBrowser.getContentPane());
757
758 g.translate(p.x, p.y);
759 c.paint(g);
760 g.translate(-p.x, -p.y);
761 } else if (c instanceof Container &&
762 c != Browser._theBrowser.getContentPane()) {
763 repaintPopups((Container)c, g);
764 }
765 }
766 }
767}
Note: See TracBrowser for help on using the repository browser.