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

Last change on this file since 21 was 21, checked in by ra33, 16 years ago
File size: 20.7 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 Graphics2D tg = (Graphics2D) g.create();
195 i.paint(tg);
196 tg.dispose();
197 }
198 }
199
200 private static void AddAllOverlayItems(List<Item> items, Frame overlay,
201 List<Frame> seenOverlays) {
202 if (seenOverlays.contains(overlay))
203 return;
204
205 seenOverlays.add(overlay);
206
207 for (Overlay o : overlay.getOverlays())
208 AddAllOverlayItems(items, o.Frame, seenOverlays);
209
210 items.addAll(overlay.getItems());
211 }
212
213 private static VolatileImage Paint(Frame toPaint) {
214 return Paint(toPaint, true);
215 }
216
217 private static VolatileImage Paint(Frame toPaint, boolean paintOverlay) {
218 if (toPaint == null)
219 return null;
220
221 // the buffer is not valid, so it must be recreated
222 if (!toPaint.isBufferValid()) {
223 VolatileImage buffer = toPaint.getBuffer();
224 if (buffer == null) {
225 GraphicsEnvironment ge = GraphicsEnvironment
226 .getLocalGraphicsEnvironment();
227 buffer = ge.getDefaultScreenDevice().getDefaultConfiguration()
228 .createCompatibleVolatileImage(_MaxSize.width,
229 _MaxSize.height);
230 toPaint.setBuffer(buffer);
231 }
232
233 Graphics2D bg = (Graphics2D) buffer.getGraphics();
234
235 // Nicer looking lines, but may be too jerky while
236 // rubber-banding on older machines
237 if (UserSettings.AntiAlias)
238 ((Graphics2D) bg).setRenderingHint(
239 RenderingHints.KEY_ANTIALIASING,
240 RenderingHints.VALUE_ANTIALIAS_ON);
241
242 bg.setColor(toPaint.getPaintBackgroundColor());
243 bg.fillRect(0, 0, _MaxSize.width, _MaxSize.height);
244
245 List<Item> paintItems = new LinkedList<Item>();
246 List<Frame> seenOverlays = new LinkedList<Frame>();
247 if (paintOverlay)
248 AddAllOverlayItems(paintItems, toPaint, seenOverlays);
249 else {
250 paintItems.addAll(toPaint.getItems());
251 }
252 // FIRST: Paint widgets swing gui (not expeditee gui) .
253 // Note that these are the ancored widgets
254 for (InteractiveWidget iw : toPaint.getInteractiveWidgets()) {
255 iw.paint(bg);
256 }
257
258 PaintPictures(bg, paintItems);
259
260 if (toPaint == DisplayIO.getCurrentFrame())
261 PaintPictures(bg, Frame.FreeItems);
262
263 PaintNonLinesNonPicture(bg, paintItems);
264 PaintLines(bg, paintItems);
265
266 if (toPaint == DisplayIO.getCurrentFrame())
267 PaintNonLinesNonPicture(bg, Frame.FreeItems);
268
269 // toPaint.setBufferValid(true);
270
271 if (DisplayIO.isTwinFramesOn()) {
272 List<Item> lines = new LinkedList<Item>();
273 for (Item i : Frame.FreeItems) {
274 if (i instanceof Line) {
275 Line line = (Line) i;
276
277 if (toPaint != DisplayIO.getCurrentFrame()) {
278 if (line.getEndItem().isFloating()
279 ^ line.getStartItem().isFloating()) {
280 lines.add(TransposeLine(line,
281 line.getEndItem(), toPaint, DisplayIO
282 .getRealMouseX(), -DisplayIO
283 .getMiddle()));
284 lines.add(TransposeLine(line, line
285 .getStartItem(), toPaint, DisplayIO
286 .getRealMouseX(), -DisplayIO
287 .getMiddle()));
288 }
289 } else {
290 if (line.getEndItem().isFloating()
291 ^ line.getStartItem().isFloating()) {
292 Line l = TransposeLine(line, line.getEndItem(),
293 toPaint, 0, 0);
294 if (l == null)
295 l = TransposeLine(line,
296 line.getStartItem(), toPaint, 0, 0);
297 if (l == null)
298 l = line;
299 lines.add(l);
300 } else
301 lines.add(line);
302 }
303 }
304 }
305 PaintLines(bg, lines);
306 } else {
307 // PaintPictures(bg, Frame.FreeItems);
308 // PaintNonLinesNonPicture(bg, Frame.FreeItems);
309 PaintLines(bg, Frame.FreeItems);
310 }
311
312 if (paintOverlay) {
313 PaintItem(bg, toPaint.getFrameNameItem());
314 }
315
316 // BROOK: Ensure popups are repainted
317 if (Browser._theBrowser != null)
318 repaintPopups(Browser._theBrowser.getLayeredPane(), bg);
319
320 bg.dispose();
321 }
322
323 return toPaint.getBuffer();
324 }
325
326 // creates a new line so that lines are shown correctly when spanning
327 // across frames in TwinFrames mode
328 private static Line TransposeLine(Line line, Item d, Frame toPaint,
329 int base, int adj) {
330 Line nl = null;
331
332 if (toPaint != DisplayIO.getCurrentFrame() && d.getParent() == null
333 && line.getOppositeEnd(d).getParent() == toPaint) {
334 nl = line.copy();
335 if (d == line.getStartItem())
336 d = nl.getStartItem();
337 else
338 d = nl.getEndItem();
339
340 if (DisplayIO.FrameOnSide(toPaint) == 0)
341 d.setX(base);
342 else
343 d.setX(base + adj);
344
345 } else if (toPaint == DisplayIO.getCurrentFrame()
346 && d.getParent() == null
347 && line.getOppositeEnd(d).getParent() != toPaint) {
348 nl = line.copy();
349
350 if (d == line.getStartItem())
351 d = nl.getEndItem();
352 else
353 d = nl.getStartItem();
354
355 if (DisplayIO.FrameOnSide(toPaint) == 1)
356 d.setX(d.getX() - DisplayIO.getMiddle());
357 else
358 d.setX(d.getX() + DisplayIO.getMiddle());
359 }
360
361 return nl;
362 }
363
364 private static void Paint(VolatileImage left, VolatileImage right,
365 Color background) {
366 if (_MessageBuffer == null) {
367 GraphicsEnvironment ge = GraphicsEnvironment
368 .getLocalGraphicsEnvironment();
369 _MessageBuffer = ge.getDefaultScreenDevice()
370 .getDefaultConfiguration().createCompatibleVolatileImage(
371 _MaxSize.width, MESSAGE_BUFFER_HEIGHT);
372 }
373
374 paintMessage(_MessageBuffer.createGraphics(), background);
375 Graphics g = _DisplayGraphics.create();
376
377 // if TwinFrames mode is on, then clipping etc has to be set
378 if (DisplayIO.isTwinFramesOn()) {
379 // draw the two lines down the middle of the window
380 if (left != null)
381 left.getGraphics().drawLine(DisplayIO.getMiddle() - 2, 0,
382 DisplayIO.getMiddle() - 2, _MaxSize.height);
383
384 if (right != null)
385 right.getGraphics().drawLine(0, 0, 0, _MaxSize.height);
386
387 // set the clipping area
388 ((Graphics2D) g).setClip(0, 0, DisplayIO.getMiddle() - 1,
389 _MaxSize.height);
390 g.drawImage(left, 0, 0, DisplayIO.DEFAULT_BACKGROUND, null);
391 ((Graphics2D) g).setClip(null);
392 g.drawImage(right, DisplayIO.getMiddle() + 1, 0,
393 DisplayIO.DEFAULT_BACKGROUND, null);
394
395 // otherwise, just draw whichever side is active
396 } else {
397 if (DisplayIO.getCurrentSide() == 0)
398 g.drawImage(left, 0, 0, DisplayIO.DEFAULT_BACKGROUND, null);
399 else
400 g.drawImage(right, 0, 0, DisplayIO.DEFAULT_BACKGROUND, null);
401 }
402 // draw the message area
403 g.drawImage(_MessageBuffer, 0, _MaxSize.height, null);
404 g.dispose();
405
406 }
407
408 /**
409 * Paints the message area
410 * @param g
411 * @param background
412 */
413 private static void paintMessage(Graphics2D g, Color background) {
414 ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
415 RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
416 g.setColor(background);
417 g.fillRect(0, 0, _MaxSize.width, MESSAGE_BUFFER_HEIGHT);
418 g.setFont(_MessageFont);
419 g.setColor(Color.BLACK);
420 g.drawLine(0, 0, _MaxSize.width, 0);
421 for (Text t : Messages)
422 PaintItem(g, t);
423 if (MessageLink.getLink() != null)
424 PaintItem(g, MessageLink);
425 g.dispose();
426 }
427
428 public static void Clear() {
429 Graphics g = _DisplayGraphics.create();
430 g.setColor(Color.WHITE);
431 g.fillRect(0, 0, _MaxSize.width, _MaxSize.height);
432 g.dispose();
433 }
434
435 /**
436 * Called to refresh the display screen.
437 *
438 */
439 public static void Repaint() {
440 if (_DisplayGraphics == null)
441 return;
442
443 if (UserSettings.Threading) {
444 if (painter == null) {
445 painter = new FrameGraphics().new Repainter();
446
447 painter.setDaemon(true);
448 painter.setPriority(Thread.MIN_PRIORITY);
449
450 painter.start();
451 } else
452 painter.run();
453 } else {
454 Frame[] toPaint = DisplayIO.getFrames();
455
456 if (toPaint != null) {
457 VolatileImage left = Paint(toPaint[0]);
458 VolatileImage right = Paint(toPaint[1]);
459 Paint(left, right, DisplayIO.DEFAULT_BACKGROUND);
460 }
461 }
462 }
463
464 private static Repainter painter = null;
465
466 private static void PaintNonLinesNonPicture(Graphics2D g, List<Item> toPaint) {
467 for (Item i : toPaint)
468 if (!(i instanceof Line) && !(i instanceof Picture))
469 PaintItem(g, i);
470 }
471
472 private static void PaintLines(Graphics2D g, List<Item> toPaint) {
473 for (Item i : toPaint)
474 if (i instanceof Line)
475 PaintItem(g, i);
476 }
477
478 private static void PaintPictures(Graphics2D g, List<Item> toPaint) {
479 for (Item i : toPaint) {
480 if (i instanceof Picture)
481 PaintItem(g, i);
482 else if (i instanceof Dot)
483 ((Dot) i).paintFill(g);
484 }
485 }
486
487 /**
488 * Highlights an item on the screen Note: All graphics are handled by the
489 * Item itself.
490 *
491 * @param i
492 * The Item to highlight.
493 * @param val
494 * True if the highlighting is being shown, false if it is being
495 * erased.
496 */
497 public static void Highlight(Item i) {
498 if ((i instanceof Line)) {
499 // Check if within 20% of the end of the line
500 Line l = (Line) i;
501 Item toDisconnect = l.getEndPointToDisconnect(
502 FrameMouseActions.MouseX, FrameMouseActions.MouseY);
503
504 // Brook: Widget Edges do not have such a context
505 if (toDisconnect != null && !(i instanceof WidgetEdge)) {
506 Item.SelectedMode newMode = toDisconnect.getSelectedMode();
507 if (Frame.itemAttachedToCursor())
508 newMode = Item.SelectedMode.Normal;
509 // unhighlight all the other dots
510 for (Item conn : toDisconnect.getAllConnected()) {
511 conn.setSelectedMode(Item.SelectedMode.None);
512 }
513 l.setSelectedMode(newMode);
514 // highlight the dot that will be in disconnect mode
515 toDisconnect.setSelectedMode(newMode);
516 } else {
517 List<Item> connected = i.getAllConnected();
518 for (Item conn : connected) {
519 conn.setSelectedMode(Item.SelectedMode.Connected);
520 }
521 }
522 } else {
523 i.setSelectedMode(Item.SelectedMode.Normal);
524 }
525
526 Repaint();
527 }
528
529 public static void ChangeSelectionMode(Item item, Item.SelectedMode newMode) {
530 if (item == null)
531 return;
532
533 for(Item i: item.getAllConnected())
534 i.setSelectedMode(newMode);
535 Repaint();
536 }
537
538 public static void OverwriteMessage(String message) {
539 for (int ind = Messages.length - 1; ind >= 0; ind--) {
540 if (Messages[ind] != null) {
541 Messages[ind].setText(message);
542 Repaint();
543 return;
544 }
545 }
546
547 // if we have not returned, then there are no messages yet
548 DisplayMessage(message);
549 }
550
551 /**
552 * Displays the given message in the message area of the Frame, any previous
553 * message is cleared from the screen.
554 *
555 * @param message
556 * The message to display to the user in the message area
557 */
558 public static void DisplayMessage(String message) {
559 DisplayMessageAlways(message);
560 }
561
562 public static void DisplayMessage(String message, Color textColor) {
563 displayMessage(message, null, textColor);
564 Misc.Beep();
565 }
566
567 public static void DisplayMessage(Text message) {
568 displayMessage(message.getFirstLine(), message.getLink(), message
569 .getColor());
570 // Misc.Beep();
571 }
572
573 public static void DisplayMessageAlways(String message) {
574 // _lastMessage = null;
575 displayMessage(message, null, Color.BLACK);
576 Misc.Beep();
577 }
578
579 public static void WarningMessage(String message) {
580 displayMessage(message, null, Color.MAGENTA);
581 Misc.Beep();
582 }
583
584 // private static String _lastMessage = null;
585
586 private static void displayMessage(String message, String link, Color color) {
587 // add timestamp to message
588 // if (message.equals(_lastMessage))
589 // return;
590 // _lastMessage = message;
591
592 // message += _formatter.format(Calendar.getInstance().getTime());
593
594 // if the creator needs to be initialised (happens on first message)
595 if (_creator == null) {
596 _creator = new FrameCreator("Messages", true);
597
598 // set up 'Messages' link on the right hand side
599 MessageLink.setPosition(_MaxSize.width - MESSAGE_LINK_Y_OFFSET,
600 MESSAGE_LINK_X);
601 MessageLink.setOffset(0, -_MaxSize.height);
602 }
603
604 // if the message slots have not all been used yet
605 if (_MessageCount <= Messages.length) {
606 int pos = 15;
607 // find the next empty slot, and create the new message
608 for (int i = 0; i < Messages.length; i++) {
609 if (Messages[i] == null) {
610 Messages[i] = new Text(-1, "@" + _MessageCount++ + ": "
611 + message);
612 Messages[i].setPosition(20, pos);
613 Messages[i].setOffset(0, -_MaxSize.height);
614 Messages[i].setMaxSize(_MaxSize);
615 Messages[i].setColor(color);
616 Messages[i].setLink(link);
617
618 _creator.addItem(Messages[i].copy());
619 MessageLink.setLink(_creator.getCurrent());
620 Repaint();
621 return;
622 }
623
624 pos += 25;
625 }
626 }
627
628 // if we have not returned then all message slots are used
629 for (int i = 0; i < Messages.length - 1; i++) {
630 Messages[i].setText(Messages[i + 1].getFirstLine());
631 Messages[i].setColor(Messages[i + 1].getColor());
632 Messages[i].setLink(Messages[i + 1].getLink());
633 }
634
635 // show the new message
636 Text last = Messages[Messages.length - 1];
637 last.setColor(color);
638 last.setText("@" + _MessageCount++ + ": " + message);
639 last.setLink(link);
640
641 _creator.addItem(last.copy());
642 // update the link to the latest message frame
643 MessageLink.setLink(_creator.getCurrent());
644 Repaint();
645 }
646
647 /**
648 * Checks if the error message ends with a frame name after the
649 * frameNameSeparator symbol
650 *
651 * @param message
652 * the message to be displayed
653 */
654 public static void LinkedErrorMessage(String message) {
655 if (_SupressErrors)
656 return;
657 Misc.Beep();
658 String[] tokens = message.split(Text.FRAME_NAME_SEPARATOR);
659 String link = null;
660 if (tokens.length > 1)
661 link = tokens[tokens.length - 1];
662 displayMessage(message, link, Color.RED);
663 }
664
665 public static void ErrorMessage(String message) {
666 if (_SupressErrors)
667 return;
668 Misc.Beep();
669 displayMessage(message, null, Color.RED);
670
671 // Michael is confused about why this code is gettting into infinite
672 // loop
673
674 /*
675 * Exception e = new Exception();
676 *
677 * try{ throw e; }catch(Exception ex){ StackTraceElement[] trace =
678 * ex.getStackTrace(); message += " (" + trace[1].getFileName() + ":" +
679 * trace[1].getLineNumber() + ")";
680 *
681 * String source = trace[1].getClassName(); source = "src.java." +
682 * source; source = source.replace(".", File.separator); source +=
683 * ".java";
684 *
685 * try{ BufferedReader reader = new BufferedReader(new
686 * FileReader(source)); FrameCreator creator = new
687 * FrameCreator("Messages", false);
688 *
689 * int min = trace[1].getLineNumber() - 10; int max =
690 * trace[1].getLineNumber() + 3;
691 *
692 * int line = 0; while(reader.ready()){ if(line > min && line < max)
693 * if(line == trace[1].getLineNumber() - 1)
694 * creator.addText(reader.readLine(), Color.RED); else
695 * creator.addText(reader.readLine()); else if(line > max) break; else
696 * reader.readLine();
697 *
698 * line++; }
699 *
700 * reader.close();
701 *
702 * displayMessage(message, creator.getCurrent(), Color.RED);
703 * }catch(Exception ioe){ ioe.printStackTrace(); } }
704 */
705 }
706
707 private class Repainter extends Thread {
708 public boolean isPainting = false;
709
710 public void run() {
711 isPainting = true;
712
713 Frame[] toPaint = DisplayIO.getFrames();
714
715 if (toPaint != null) {
716 VolatileImage left = Paint(toPaint[0]);
717 VolatileImage right = Paint(toPaint[1]);
718 Paint(left, right, DisplayIO.DEFAULT_BACKGROUND);
719 }
720
721 isPainting = false;
722 }
723 }
724
725 /**
726 * Invalidates the buffered image of the current Frame and forces it to be
727 * repainted on to the screen.
728 */
729 public static void ForceRepaint() {
730 Frame current = DisplayIO.getCurrentFrame();
731
732 if (current == null)
733 return;
734
735 Repaint();
736 }
737
738 /**
739 * Repaints the buffer of the given Frame.
740 *
741 * @param toUpdate
742 * The Frame whose buffer is to be repainted.
743 */
744
745 public static void UpdateBuffer(Frame toUpdate, boolean paintOverlays) {
746 if (toUpdate == null)
747 return;
748
749 VolatileImage vi = Paint(toUpdate, paintOverlays);
750 toUpdate.setBuffer(vi);
751 }
752
753 public static void SupressErrors(boolean val) {
754 _SupressErrors = val;
755 }
756
757 private static void repaintPopups(Container parent, Graphics g) {
758 for (Component c : parent.getComponents()) {
759 if (c instanceof JPopupMenu && ((JPopupMenu) c).isVisible()) {
760
761 Point p = SwingUtilities.convertPoint(c, c.getLocation(),
762 Browser._theBrowser.getContentPane());
763
764 g.translate(p.x, p.y);
765 c.paint(g);
766 g.translate(-p.x, -p.y);
767 } else if (c instanceof Container
768 && c != Browser._theBrowser.getContentPane()) {
769 repaintPopups((Container) c, g);
770 }
771 }
772 }
773}
Note: See TracBrowser for help on using the repository browser.