KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > common > ui > ViewerPane


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2002-2004 IBM Corporation and others.
5  * All rights reserved. This program and the accompanying materials
6  * are made available under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution, and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors:
11  * IBM - Initial API and implementation
12  *
13  * </copyright>
14  *
15  * $Id: ViewerPane.java,v 1.5 2005/06/12 13:24:22 emerks Exp $
16  */

17 package org.eclipse.emf.common.ui;
18
19
20 import java.net.MalformedURLException JavaDoc;
21 import java.net.URL JavaDoc;
22 import java.util.ArrayList JavaDoc;
23 import java.util.Collection JavaDoc;
24 import java.util.HashMap JavaDoc;
25 import java.util.Iterator JavaDoc;
26
27 import org.eclipse.jface.action.MenuManager;
28 import org.eclipse.jface.action.ToolBarManager;
29 import org.eclipse.jface.resource.ImageDescriptor;
30 import org.eclipse.jface.viewers.ContentViewer;
31 import org.eclipse.jface.viewers.IBaseLabelProvider;
32 import org.eclipse.jface.viewers.ILabelProvider;
33 import org.eclipse.jface.viewers.Viewer;
34 import org.eclipse.swt.SWT;
35 import org.eclipse.swt.custom.CLabel;
36 import org.eclipse.swt.custom.CTabFolder;
37 import org.eclipse.swt.custom.SashForm;
38 import org.eclipse.swt.custom.ViewForm;
39 import org.eclipse.swt.events.DisposeEvent;
40 import org.eclipse.swt.events.DisposeListener;
41 import org.eclipse.swt.events.MouseAdapter;
42 import org.eclipse.swt.events.MouseEvent;
43 import org.eclipse.swt.events.MouseListener;
44 import org.eclipse.swt.events.PaintEvent;
45 import org.eclipse.swt.events.PaintListener;
46 import org.eclipse.swt.events.SelectionAdapter;
47 import org.eclipse.swt.events.SelectionEvent;
48 import org.eclipse.swt.graphics.Color;
49 import org.eclipse.swt.graphics.GC;
50 import org.eclipse.swt.graphics.Image;
51 import org.eclipse.swt.graphics.Point;
52 import org.eclipse.swt.graphics.RGB;
53 import org.eclipse.swt.graphics.Rectangle;
54 import org.eclipse.swt.widgets.Composite;
55 import org.eclipse.swt.widgets.Control;
56 import org.eclipse.swt.widgets.Display;
57 import org.eclipse.swt.widgets.Event;
58 import org.eclipse.swt.widgets.Listener;
59 import org.eclipse.swt.widgets.Menu;
60 import org.eclipse.swt.widgets.MenuItem;
61 import org.eclipse.swt.widgets.ToolBar;
62 import org.eclipse.swt.widgets.ToolItem;
63 import org.eclipse.ui.IPartListener;
64 import org.eclipse.ui.IPropertyListener;
65 import org.eclipse.ui.IWorkbenchPage;
66 import org.eclipse.ui.IWorkbenchPart;
67
68
69 /**
70  * Please don't use this class until the design is complete.
71  */

72 public abstract class ViewerPane implements IPropertyListener, Listener
73 {
74   protected IWorkbenchPage page;
75   protected IWorkbenchPart part;
76   protected Collection JavaDoc buddies = new ArrayList JavaDoc();
77   protected Viewer viewer;
78   protected Composite container;
79   boolean isActive;
80   protected CLabel titleLabel;
81   protected ToolBar actionBar;
82   protected ToolBarManager toolBarManager;
83   protected MenuManager menuManager;
84   protected Image pullDownImage;
85   protected ToolBar systemBar;
86   protected ViewForm control;
87
88   protected MouseListener mouseListener =
89     new MouseAdapter()
90     {
91       public void mouseDown(MouseEvent e)
92       {
93         requestActivation();
94       }
95       public void mouseDoubleClick(MouseEvent e)
96       {
97         if (e.getSource() == titleLabel)
98         {
99           doMaximize();
100         }
101       }
102     };
103
104   protected IPartListener partListener =
105     new IPartListener()
106     {
107       public void partActivated(IWorkbenchPart p)
108       {
109       }
110       public void partBroughtToTop(IWorkbenchPart p)
111       {
112       }
113       public void partClosed(IWorkbenchPart p)
114       {
115       }
116       public void partDeactivated(IWorkbenchPart p)
117       {
118         if (p == ViewerPane.this.part)
119         {
120           showFocus(false);
121         }
122       }
123       public void partOpened(IWorkbenchPart p)
124       {
125       }
126     };
127
128
129   /**
130    * Constructs a view pane for a view part.
131    */

132   public ViewerPane(IWorkbenchPage page, IWorkbenchPart part)
133   {
134     WorkbenchColors.startup();
135     this.page = page;
136     this.part = part;
137
138     page.addPartListener(partListener);
139   }
140
141   abstract public Viewer createViewer(Composite parent);
142
143   public Collection JavaDoc getBudies()
144   {
145     return buddies;
146   }
147
148   public void createControl(Composite parent)
149   {
150     if (getControl() == null)
151     {
152       container = parent;
153
154       // Create view form.
155
//control = new ViewForm(parent, getStyle());
156
control = new ViewForm(parent, SWT.NONE);
157       control.addDisposeListener
158         (new DisposeListener()
159          {
160            public void widgetDisposed(DisposeEvent event)
161            {
162              dispose();
163            }
164          });
165       control.marginWidth = 0;
166       control.marginHeight = 0;
167
168       // Create a title bar.
169
createTitleBar();
170
171       viewer = createViewer(control);
172       control.setContent(viewer.getControl());
173
174       control.setTabList(new Control [] { viewer.getControl() });
175       
176       // When the pane or any child gains focus, notify the workbench.
177
control.addListener(SWT.Activate, this);
178       hookFocus(control);
179       hookFocus(viewer.getControl());
180     }
181   }
182
183   public Viewer getViewer()
184   {
185     return viewer;
186   }
187
188   /**
189    * Get the control.
190    */

191   public Control getControl()
192   {
193     return control;
194   }
195
196   /**
197    * Get the view form.
198    */

199   protected ViewForm getViewForm()
200   {
201     return control;
202   }
203
204   /**
205    * @see Listener
206    */

207   public void handleEvent(Event event)
208   {
209     if (event.type == SWT.Activate)
210     {
211       requestActivation();
212     }
213   }
214
215   /**
216    * Hook focus on a control.
217    */

218   public void hookFocus(Control ctrl)
219   {
220     ctrl.addMouseListener(mouseListener);
221   }
222
223   /**
224    * Notify the workbook page that the part pane has
225    * been activated by the user.
226    */

227   protected void requestActivation()
228   {
229     control.getContent().setFocus();
230     showFocus(true);
231   }
232
233   /**
234    * Sets focus to this part.
235    */

236   public void setFocus()
237   {
238     requestActivation();
239     control.getContent().setFocus();
240   }
241
242   /**
243    * Tool bar manager
244    */

245   class PaneToolBarManager extends ToolBarManager
246   {
247     public PaneToolBarManager(ToolBar paneToolBar)
248     {
249       super(paneToolBar);
250     }
251
252     /**
253      * EATM I have no idea how this is supposed to be called.
254      */

255     protected void relayout(ToolBar toolBar, int oldCount, int newCount)
256     {
257       // remove/add the action bar from the view so to avoid
258
// having an empty action bar participating in the view's
259
// layout calculation (and maybe causing an empty bar to appear)
260
if (newCount < 1)
261       {
262         if (control.getTopCenter() != null)
263         {
264           control.setTopCenter(null);
265         }
266       }
267       else
268       {
269         toolBar.layout();
270         if (control.getTopCenter() == null)
271         {
272           control.setTopCenter(toolBar);
273         }
274       }
275       Composite parent= toolBar.getParent();
276       parent.layout();
277       if (parent.getParent() != null)
278       {
279         parent.getParent().layout();
280       }
281     }
282   }
283
284   /**
285    * Create the menu manager.
286    */

287   private void createMenuManager()
288   {
289     menuManager = new MenuManager("Pane Menu");
290     if (systemBar != null)
291     {
292       createPulldownMenu();
293     }
294   }
295
296   /**
297    * Create a pulldown menu on the action bar.
298    */

299   private void createPulldownMenu()
300   {
301     if (systemBar != null)
302     {
303       ToolItem ti = new ToolItem(systemBar, SWT.PUSH, 0);
304       try
305       {
306         pullDownImage =
307           ImageDescriptor.createFromURL
308             (new URL JavaDoc(CommonUIPlugin.INSTANCE.getImage("full/ctool16/ViewPullDown").toString())).createImage();
309         ti.setImage(pullDownImage);
310         ti.addSelectionListener
311           (new SelectionAdapter()
312            {
313              public void widgetSelected(SelectionEvent e)
314              {
315               showViewMenu();
316              }
317            });
318       }
319       catch (MalformedURLException JavaDoc exception)
320       {
321       }
322     }
323   }
324
325   /**
326    * Create a title bar for the pane which includes
327    * the view icon and title to the far left, and
328    * the close X icon to the far right.
329    * The middle part is reserved for the view part to
330    * add a menu and tools.
331    */

332   protected void createTitleBar()
333   {
334     // Only do this once.
335
if (titleLabel == null)
336     {
337       // Title.
338
titleLabel = new CLabel(control, SWT.SHADOW_NONE);
339       hookFocus(titleLabel);
340       titleLabel.setAlignment(SWT.LEFT);
341       titleLabel.setBackground(null, null);
342       titleLabel.addMouseListener
343         (new MouseAdapter()
344          {
345            public void mouseDown(MouseEvent e)
346            {
347              if (e.button == 3)
348              {
349                showTitleLabelMenu(e);
350              }
351            }
352          });
353       titleLabel.addPaintListener
354         (new PaintListener()
355          {
356            public void paintControl(PaintEvent event)
357            {
358              if (isActive)
359              {
360                Rectangle clientRectangle = titleLabel.getClientArea();
361                event.gc.drawImage
362                  (WorkbenchColors.getGradient(),
363                   10, 0, 10, 10,
364                   0, 0, 24, clientRectangle.height);
365   
366                Image image = titleLabel.getImage();
367                if (image != null)
368                {
369                  Rectangle imageRectangle = image.getBounds();
370                  event.gc.drawImage
371                    (image,
372                     0, 0, imageRectangle.width, imageRectangle.height,
373                     3, (clientRectangle.height-imageRectangle.height) / 2, imageRectangle.width, imageRectangle.height);
374                }
375              }
376            }
377          });
378
379       updateTitles();
380       control.setTopLeft(titleLabel);
381
382       // Listen to title changes.
383
// getViewPart().addPropertyListener(this);
384

385       // Action bar.
386
actionBar = new ToolBar(control, SWT.FLAT | SWT.WRAP);
387       hookFocus(actionBar);
388       control.setTopCenter(actionBar);
389       
390       // System bar.
391
systemBar = new ToolBar(control, SWT.FLAT | SWT.WRAP);
392       hookFocus(systemBar);
393       if (menuManager != null && !menuManager.isEmpty())
394       {
395         createPulldownMenu();
396       }
397       control.setTopRight(systemBar);
398     }
399   }
400
401   protected void doMaximize()
402   {
403     Control child = control;
404     for (Control parent = control.getParent(); parent instanceof SashForm || parent instanceof CTabFolder; parent = parent.getParent())
405     {
406       if (parent instanceof CTabFolder)
407       {
408         CTabFolder cTabFolder = (CTabFolder)parent;
409         cTabFolder.setMaximized(!cTabFolder.getMaximized());
410       }
411       else if (parent instanceof SashForm)
412       {
413         SashForm sashForm = (SashForm)parent;
414         if (sashForm.getMaximizedControl() == null)
415         {
416           sashForm.setMaximizedControl(child);
417         }
418         else
419         {
420           sashForm.setMaximizedControl(null);
421         }
422       }
423       child = parent;
424     }
425   }
426
427   public void dispose()
428   {
429     if ((control != null) && (!control.isDisposed()))
430     {
431       control.removeListener(SWT.Activate, this);
432       control = null;
433       page.removePartListener(partListener);
434     }
435
436     if (pullDownImage != null)
437     {
438       pullDownImage.dispose();
439       pullDownImage = null;
440     }
441   }
442
443   public MenuManager getMenuManager()
444   {
445     if (menuManager == null)
446     {
447       createMenuManager();
448     }
449     return menuManager;
450   }
451
452   public ToolBarManager getToolBarManager()
453   {
454     if (toolBarManager == null)
455     {
456       toolBarManager = new PaneToolBarManager(actionBar);
457     }
458     return toolBarManager;
459   }
460
461   /**
462    * Indicates that a property has changed.
463    *
464    * @param source the object whose property has changed
465    * @param propId the id of the property which has changed; property ids
466    * are generally defined as constants on the source class
467    */

468   public void propertyChanged(Object JavaDoc source, int propId)
469   {
470     if (propId == IWorkbenchPart.PROP_TITLE)
471     {
472       updateTitles();
473     }
474   }
475
476   /**
477    * Indicate focus in part.
478    */

479   public void showFocus(boolean inFocus)
480   {
481     if (inFocus != isActive)
482     {
483       isActive = inFocus;
484
485       if (titleLabel != null)
486       {
487         if (inFocus)
488         {
489           //titleLabel.setBackground(WorkbenchColors.getActiveGradient(), WorkbenchColors.getActiveGradientPercents());
490
// titleLabel.setForeground(titleLabel.getDisplay().getSystemColor(SWT.COLOR_TITLE_FOREGROUND));
491
titleLabel.update();
492           titleLabel.redraw();
493           //actionBar.setBackground(WorkbenchColors.getActiveGradientEnd());
494
//systemBar.setBackground(WorkbenchColors.getActiveGradientEnd());
495
}
496         else
497         {
498           //titleLabel.setBackground(null, null);
499
// titleLabel.setForeground(null);
500
titleLabel.update();
501           titleLabel.redraw();
502           //actionBar.setBackground(WorkbenchColors.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
503
//systemBar.setBackground(WorkbenchColors.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
504
}
505       }
506     }
507   }
508
509   /**
510    * Show the context menu for this window.
511    */

512   private void showViewMenu()
513   {
514     Menu aMenu = menuManager.createContextMenu(getControl());
515     Point topLeft = new Point(0, 0);
516     topLeft.y += systemBar.getBounds().height;
517     topLeft = systemBar.toDisplay(topLeft);
518     aMenu.setLocation(topLeft.x, topLeft.y);
519     aMenu.setVisible(true);
520   }
521
522   public String JavaDoc toString()
523   {
524     String JavaDoc label = "disposed";
525     if((titleLabel != null) && (!titleLabel.isDisposed()))
526       label = titleLabel.getText();
527     
528     return getClass().getName() + "@" + Integer.toHexString(hashCode()) +
529     "(" + label + ")";
530   }
531
532   public void updateActionBars()
533   {
534     if (menuManager != null)
535     {
536       menuManager.updateAll(false);
537     }
538   
539     if (toolBarManager != null)
540     {
541       getToolBarManager().update(false);
542     }
543   }
544
545   /**
546    * Update the title attributes.
547    */

548   public void updateTitles()
549   {
550     // IViewPart view = getViewPart();
551
// titleLabel.setText(view.getTitle());
552
// titleLabel.setImage(view.getTitleImage());
553
titleLabel.update();
554   }
555
556   public void setTitle(Object JavaDoc object)
557   {
558     if (viewer != null)
559     {
560       if (viewer instanceof ContentViewer)
561       {
562         IBaseLabelProvider labelProvider = ((ContentViewer)viewer).getLabelProvider();
563         if (labelProvider instanceof ILabelProvider)
564         {
565           if (object == null)
566           {
567             titleLabel.setImage(null);
568             titleLabel.setText("");
569           }
570           else
571           {
572             titleLabel.setImage(((ILabelProvider)labelProvider).getImage(object));
573             titleLabel.setText(((ILabelProvider)labelProvider).getText(object));
574           }
575         }
576       }
577     }
578   }
579
580   public void setTitle(String JavaDoc title, Image image)
581   {
582     if (titleLabel != null)
583     {
584       titleLabel.setImage(image);
585       titleLabel.setText(title);
586     }
587   }
588
589   private void showTitleLabelMenu(MouseEvent e)
590   {
591     Menu menu = new Menu(titleLabel);
592
593     boolean isMaximized =
594         control.getParent() instanceof SashForm ?
595           ((SashForm)control.getParent()).getMaximizedControl() != null :
596           control.getParent() instanceof CTabFolder && ((CTabFolder)control.getParent()).getMaximized();
597
598     MenuItem restoreItem = new MenuItem(menu, SWT.NONE);
599     restoreItem.setText(CommonUIPlugin.INSTANCE.getString("_UI_Restore_menu_item"));
600     restoreItem.addSelectionListener
601       (new SelectionAdapter()
602        {
603          public void widgetSelected(SelectionEvent selectionEvent)
604          {
605            doMaximize();
606          }
607        });
608     restoreItem.setEnabled(isMaximized);
609
610     MenuItem maximizeItem = new MenuItem(menu, SWT.NONE);
611     maximizeItem.setText(CommonUIPlugin.INSTANCE.getString("_UI_Maximize_menu_item"));
612     maximizeItem.addSelectionListener
613       (new SelectionAdapter()
614        {
615          public void widgetSelected(SelectionEvent selectionEvent)
616          {
617            doMaximize();
618          }
619        });
620     maximizeItem.setEnabled(!isMaximized);
621
622     Point point = new Point(e.x, e.y);
623     point = titleLabel.toDisplay(point);
624     menu.setLocation(point.x, point.y);
625     menu.setVisible(true);
626   }
627 }
628
629
630 /**
631  * EATM I just ripped this off and it's still a big mess.
632  *
633  * This class manages the common workbench colors.
634  */

635 class WorkbenchColors
636 {
637   static private boolean init = false;
638   static private HashMap JavaDoc colorMap;
639   static private Color [] activeGradient;
640   static private int [] activePercentages;
641   final static private String JavaDoc CLR_GRAD_START = "clrGradStart";
642   final static private String JavaDoc CLR_GRAD_MID = "clrGradMid";
643   final static private String JavaDoc CLR_GRAD_END = "clrGradEnd";
644
645 /**
646  * Returns the active gradient.
647  */

648 static public Color [] getActiveGradient() {
649   return activeGradient;
650 }
651 /**
652  * Returns the active gradient start color.
653  */

654 static public Color getActiveGradientStart() {
655   Color clr = (Color)colorMap.get(CLR_GRAD_START);
656   return clr;
657 }
658 /**
659  * Returns the active gradient end color.
660  */

661 static public Color getActiveGradientEnd() {
662   Color clr = (Color)colorMap.get(CLR_GRAD_END);
663   return clr;
664 }
665 /**
666  * Returns the active gradient percents.
667  */

668 static public int [] getActiveGradientPercents() {
669   return activePercentages;
670 }
671 /**
672  * Returns a color identified by an RGB value.
673  */

674 static public Color getColor(RGB rgbValue) {
675   Color clr = (Color)colorMap.get(rgbValue);
676   if (clr == null) {
677     Display disp = Display.getDefault();
678     clr = new Color(disp, rgbValue);
679     colorMap.put(rgbValue, clr);
680   }
681   return clr;
682 }
683 /**
684  * Returns a system color identified by a SWT constant.
685  */

686 static public Color getSystemColor(int swtId) {
687   Integer JavaDoc bigInt = new Integer JavaDoc(swtId);
688   Color clr = (Color)colorMap.get(bigInt);
689   if (clr == null) {
690     Display disp = Display.getDefault();
691     clr = disp.getSystemColor(swtId);
692     colorMap.put(bigInt, clr);
693   }
694   return clr;
695 }
696 /**
697  * Disposes of the colors.
698  */

699 static public void shutdown() {
700   if (!init)
701     return;
702     
703   Iterator JavaDoc iter = colorMap.values().iterator();
704   while (iter.hasNext()) {
705     Color clr = (Color)iter.next();
706     clr.dispose();
707   }
708   colorMap.clear();
709   gradient.dispose();
710 }
711
712 /**
713  * Initializes the colors.
714  */

715 static public void startup() {
716   if (init)
717     return;
718     
719   init = true;
720   Display disp = Display.getDefault();
721   colorMap = new HashMap JavaDoc(10);
722
723 /*
724   // Define gradient (blue to widget background color)
725   //Color clr1 = new Color(disp, 57, 90, 189); //blue
726   Color clr1 = new Color(disp, 201, 211, 239); //lighter blue
727   colorMap.put(CLR_GRAD_START, clr1);
728   Color clr2 = disp.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
729   colorMap.put(CLR_GRAD_END, clr2);
730   colorMap.put(CLR_GRAD_MID, clr2);
731   activeGradient = new Color [] { clr1, clr2, clr2 };
732   activePercentages = new int[] {50, 100};
733 */

734
735   //define editor gradient (blue to white)
736
/*
737   colorMap.put(CLR_EDITOR_GRAD_START, clr1);
738   Color clr3 = disp.getSystemColor(SWT.COLOR_WHITE);
739   colorMap.put(CLR_EDITOR_GRAD_END, clr3);
740   colorMap.put(CLR_EDITOR_GRAD_MID, clr3);
741   activeEditorGradient = new Color [] { clr1, clr3, clr3 };
742 */

743
744   // Define gradient (blue to widget background color)
745
Color clr1 = disp.getSystemColor(SWT.COLOR_TITLE_BACKGROUND);
746   Color clr2 = disp.getSystemColor(SWT.COLOR_TITLE_BACKGROUND_GRADIENT);
747   Color clr3 = disp.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
748
749   int r = clr1.getRGB().red + 2 * (clr3.getRGB().red - clr1.getRGB().red) / 3;
750   r = (clr3.getRGB().red > clr1.getRGB().red) ? Math.min(r, clr3.getRGB().red) : Math.max(r, clr3.getRGB().red);
751   int g = clr1.getRGB().green + 2 * (clr3.getRGB().green - clr1.getRGB().green) / 3;
752   g = (clr3.getRGB().green > clr1.getRGB().green) ? Math.min(g, clr3.getRGB().green) : Math.max(g, clr3.getRGB().green);
753   int b = clr1.getRGB().blue + 2 * (clr3.getRGB().blue - clr1.getRGB().blue) / 3;
754   b = (clr3.getRGB().blue > clr1.getRGB().blue) ? Math.min(b, clr3.getRGB().blue) : Math.max(b, clr3.getRGB().blue);
755   Color clr4 = new Color(disp, r, g, b);
756   
757   // colorMap.put(CLR_GRAD_START, clr1);
758
colorMap.put(CLR_GRAD_START, clr4);
759   colorMap.put(CLR_GRAD_MID, clr2);
760   colorMap.put(CLR_GRAD_END, clr3);
761   
762   activeGradient = new Color [] { clr4, clr3, clr3 };
763   activePercentages = new int[] {25, 100};
764   
765   // Preload.
766
getSystemColor(SWT.COLOR_WIDGET_FOREGROUND);
767   getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
768 }
769
770   protected static Image gradient;
771   public static Image getGradient()
772   {
773     if (gradient == null)
774     {
775       int width = 20;
776       int height = 10;
777
778       Display display = Display.getDefault();
779
780       gradient = new Image(display, width, height);
781       GC gc = new GC(gradient);
782
783       Color startColor = display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
784       RGB rgb1 = startColor.getRGB();
785
786       Color endColor = display.getSystemColor(SWT.COLOR_TITLE_BACKGROUND);
787       RGB rgb2 = endColor.getRGB();
788
789       for (int k = 0; k < width; k++)
790       {
791         int r = rgb1.red + k * (rgb2.red - rgb1.red) / width;
792         r = (rgb2.red > rgb1.red) ? Math.min(r, rgb2.red) : Math.max(r, rgb2.red);
793         int g = rgb1.green + k * (rgb2.green - rgb1.green) / width;
794         g = (rgb2.green > rgb1.green) ? Math.min(g, rgb2.green) : Math.max(g, rgb2.green);
795         int b = rgb1.blue + k * (rgb2.blue - rgb1.blue) / width;
796         b = (rgb2.blue > rgb1.blue) ? Math.min(b, rgb2.blue) : Math.max(b, rgb2.blue);
797
798         Color color = new Color(display, r, g, b);
799
800         gc.setBackground(color);
801         gc.fillRectangle(width - k - 1, 0, 1, height);
802
803         color.dispose();
804       }
805
806       gc.dispose();
807     }
808
809     return gradient;
810   }
811 }
812
Popular Tags