recovery of identical dataset sequence object on undo (rather than creation of a...
[jalview.git] / src / jalview / appletgui / FeatureRenderer.java
1 /*\r
2  * Jalview - A Sequence Alignment Editor and Viewer\r
3  * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
4  *\r
5  * This program is free software; you can redistribute it and/or\r
6  * modify it under the terms of the GNU General Public License\r
7  * as published by the Free Software Foundation; either version 2\r
8  * of the License, or (at your option) any later version.\r
9  *\r
10  * This program is distributed in the hope that it will be useful,\r
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13  * GNU General Public License for more details.\r
14  *\r
15  * You should have received a copy of the GNU General Public License\r
16  * along with this program; if not, write to the Free Software\r
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
18  */\r
19 package jalview.appletgui;\r
20 \r
21 import java.util.*;\r
22 \r
23 import java.awt.*;\r
24 \r
25 import java.awt.event.*;\r
26 \r
27 \r
28 import jalview.datamodel.*;\r
29 \r
30 /**\r
31  * DOCUMENT ME!\r
32  *\r
33  * @author $author$\r
34  * @version $Revision$\r
35  */\r
36 public class FeatureRenderer\r
37 {\r
38   AlignViewport av;\r
39 \r
40   Hashtable featureColours = new Hashtable();\r
41 \r
42   // A higher level for grouping features of a\r
43   // particular type\r
44   Hashtable featureGroups = null;\r
45 \r
46   // Holds web links for feature groups and feature types\r
47   // in the form label|link\r
48   Hashtable featureLinks = null;\r
49 \r
50   // This is actually an Integer held in the hashtable,\r
51   // Retrieved using the key feature type\r
52   Object currentColour;\r
53 \r
54   String[] renderOrder;\r
55 \r
56   FontMetrics fm;\r
57   int charOffset;\r
58 \r
59   float transparency = 1f;\r
60 \r
61   TransparencySetter transparencySetter = null;\r
62 \r
63   /**\r
64    * Creates a new FeatureRenderer object.\r
65    *\r
66    * @param av DOCUMENT ME!\r
67    */\r
68   public FeatureRenderer(AlignViewport av)\r
69   {\r
70     this.av = av;\r
71 \r
72     if (!System.getProperty("java.version").startsWith("1.1"))\r
73     {\r
74       transparencySetter = new TransparencySetter();\r
75     }\r
76   }\r
77 \r
78   public void transferSettings(FeatureRenderer fr)\r
79   {\r
80     renderOrder = fr.renderOrder;\r
81     featureGroups = fr.featureGroups;\r
82     featureColours = fr.featureColours;\r
83     transparency = fr.transparency;\r
84   }\r
85 \r
86 \r
87   static String lastFeatureAdded;\r
88   static String lastFeatureGroupAdded;\r
89   static String lastDescriptionAdded;\r
90 \r
91   int featureIndex = 0;\r
92   boolean deleteFeature = false;\r
93   Panel colourPanel;\r
94   boolean amendFeatures(final SequenceI[] sequences,\r
95                         final SequenceFeature[] features,\r
96                         boolean newFeatures,\r
97                         final AlignmentPanel ap)\r
98   {\r
99     Panel bigPanel = new Panel(new BorderLayout());\r
100     final TextField name = new TextField(16);\r
101     final TextField source = new TextField(16);\r
102     final TextArea description = new TextArea(3, 35);\r
103     final TextField start = new TextField(8);\r
104     final TextField end = new TextField(8);\r
105     final Choice overlaps;\r
106     Button deleteButton = new Button("Delete");\r
107     deleteFeature = false;\r
108 \r
109     colourPanel = new Panel(null);\r
110     colourPanel.setSize(110,15);\r
111     final FeatureRenderer fr = this;\r
112 \r
113     Panel panel = new Panel(new GridLayout(3, 1));\r
114 \r
115     Panel tmp;\r
116 \r
117     ///////////////////////////////////////\r
118     ///MULTIPLE FEATURES AT SELECTED RESIDUE\r
119     if(!newFeatures && features.length>1)\r
120     {\r
121      panel = new Panel(new GridLayout(4, 1));\r
122      tmp = new Panel();\r
123      tmp.add(new Label("Select Feature: "));\r
124      overlaps = new Choice();\r
125      for(int i=0; i<features.length; i++)\r
126      {\r
127        String item = features[i].getType()\r
128         +"/"+features[i].getBegin()+"-"+features[i].getEnd();\r
129 \r
130        if(features[i].getFeatureGroup()!=null)\r
131          item += " ("+features[i].getFeatureGroup()+")";\r
132 \r
133        overlaps.addItem(item);\r
134      }\r
135 \r
136      tmp.add(overlaps);\r
137 \r
138      overlaps.addItemListener(new java.awt.event.ItemListener()\r
139      {\r
140        public void itemStateChanged(java.awt.event.ItemEvent e)\r
141        {\r
142          int index = overlaps.getSelectedIndex();\r
143          if (index != -1)\r
144          {\r
145            featureIndex = index;\r
146            name.setText(features[index].getType());\r
147            description.setText(features[index].getDescription());\r
148            source.setText(features[index].getFeatureGroup());\r
149            start.setText(features[index].getBegin()+"");\r
150            end.setText(features[index].getEnd()+"");\r
151 \r
152            SearchResults highlight = new SearchResults();\r
153            highlight.addResult(sequences[0],\r
154                                features[index].getBegin(),\r
155                                features[index].getEnd());\r
156 \r
157            ap.seqPanel.seqCanvas.highlightSearchResults(highlight);\r
158 \r
159          }\r
160          Color col = getColour(name.getText());\r
161          if (col == null)\r
162          {\r
163            col = new\r
164                jalview.schemes.UserColourScheme()\r
165                .createColourFromName(name.getText());\r
166          }\r
167 \r
168          colourPanel.setBackground(col);\r
169        }\r
170      });\r
171 \r
172 \r
173      panel.add(tmp);\r
174     }\r
175     //////////\r
176     //////////////////////////////////////\r
177 \r
178 \r
179     tmp = new Panel();\r
180     panel.add(tmp);\r
181     tmp.add(new Label("Name: ", Label.RIGHT));\r
182     tmp.add(name);\r
183 \r
184     tmp = new Panel();\r
185     panel.add(tmp);\r
186     tmp.add(new Label("Group: ",Label.RIGHT));\r
187     tmp.add(source);\r
188 \r
189     tmp = new Panel();\r
190     panel.add(tmp);\r
191     tmp.add(new Label("Colour: ", Label.RIGHT));\r
192     tmp.add(colourPanel);\r
193 \r
194     bigPanel.add(panel, BorderLayout.NORTH);\r
195 \r
196     panel = new Panel();\r
197     panel.add(new Label("Description: ", Label.RIGHT));\r
198     panel.add(new ScrollPane().add(description));\r
199 \r
200     if (!newFeatures)\r
201     {\r
202       bigPanel.add(panel, BorderLayout.SOUTH);\r
203 \r
204       panel = new Panel();\r
205       panel.add(new Label(" Start:", Label.RIGHT));\r
206       panel.add(start);\r
207       panel.add(new Label("  End:", Label.RIGHT));\r
208       panel.add(end);\r
209       bigPanel.add(panel, BorderLayout.CENTER);\r
210     }\r
211     else\r
212     {\r
213       bigPanel.add(panel, BorderLayout.CENTER);\r
214     }\r
215 \r
216     if (lastFeatureAdded == null)\r
217     {\r
218       if (features[0].type != null)\r
219       {\r
220         lastFeatureAdded = features[0].type;\r
221       }\r
222       else\r
223       {\r
224         lastFeatureAdded = "feature_1";\r
225       }\r
226     }\r
227 \r
228     if (lastFeatureGroupAdded == null)\r
229     {\r
230       if (features[0].featureGroup != null)\r
231       {\r
232         lastFeatureGroupAdded = features[0].featureGroup;\r
233       }\r
234       else\r
235       {\r
236         lastFeatureAdded = "Jalview";\r
237       }\r
238     }\r
239 \r
240 \r
241     String title = newFeatures ? "Create New Sequence Feature(s)" :\r
242         "Amend/Delete Features for "\r
243         + sequences[0].getName();\r
244 \r
245     final JVDialog dialog = new JVDialog(ap.alignFrame,\r
246                                title,\r
247                                true,\r
248                                385,240);\r
249 \r
250     dialog.setMainPanel(bigPanel);\r
251 \r
252     if(newFeatures)\r
253     {\r
254       name.setText(lastFeatureAdded);\r
255       source.setText(lastFeatureGroupAdded);\r
256     }\r
257     else\r
258     {\r
259       dialog.ok.setLabel("Amend");\r
260       dialog.buttonPanel.add(deleteButton, 1);\r
261       deleteButton.addActionListener(new ActionListener()\r
262           {\r
263             public void actionPerformed(ActionEvent evt)\r
264             {\r
265               deleteFeature = true;\r
266               dialog.setVisible(false);\r
267             }\r
268           });\r
269       name.setText(features[0].getType());\r
270       source.setText(features[0].getFeatureGroup());\r
271     }\r
272 \r
273     start.setText(features[0].getBegin()+"");\r
274     end.setText(features[0].getEnd()+"");\r
275     description.setText(features[0].getDescription());\r
276 \r
277     Color col = getColour(name.getText());\r
278     if (col == null)\r
279     {\r
280       col = new\r
281           jalview.schemes.UserColourScheme()\r
282           .createColourFromName(name.getText());\r
283     }\r
284 \r
285     colourPanel.setBackground(col);\r
286 \r
287     dialog.setResizable(true);\r
288 \r
289 \r
290     colourPanel.addMouseListener(new java.awt.event.MouseAdapter()\r
291     {\r
292       public void mousePressed(java.awt.event.MouseEvent evt)\r
293       {\r
294         new UserDefinedColours(fr, ap.alignFrame);\r
295       }\r
296     });\r
297 \r
298     dialog.setVisible(true);\r
299 \r
300     jalview.io.FeaturesFile ffile = new jalview.io.FeaturesFile();\r
301 \r
302     if (dialog.accept)\r
303     {\r
304       //This ensures that the last sequence\r
305       //is refreshed and new features are rendered\r
306       lastSeq = null;\r
307       lastFeatureAdded = name.getText().trim();\r
308       lastFeatureGroupAdded = source.getText().trim();\r
309       lastDescriptionAdded = description.getText().replace('\n', ' ');\r
310     }\r
311 \r
312     if(lastFeatureGroupAdded !=null && lastFeatureGroupAdded.length()<1)\r
313       lastFeatureGroupAdded = null;\r
314 \r
315 \r
316     if (!newFeatures)\r
317     {\r
318       SequenceFeature sf = features[featureIndex];\r
319 \r
320       if (dialog.accept)\r
321       {\r
322         sf.type = lastFeatureAdded;\r
323         sf.featureGroup = lastFeatureGroupAdded;\r
324         sf.description = lastDescriptionAdded;\r
325         setColour(sf.type, colourPanel.getBackground());\r
326         try\r
327         {\r
328           sf.begin = Integer.parseInt(start.getText());\r
329           sf.end =  Integer.parseInt(end.getText());\r
330         }\r
331         catch (NumberFormatException ex)\r
332         {}\r
333 \r
334         ffile.parseDescriptionHTML(sf, false);\r
335       }\r
336       if (deleteFeature)\r
337       {\r
338         sequences[0].deleteFeature(sf);\r
339       }\r
340 \r
341     }\r
342     else\r
343     {\r
344       if (dialog.accept && name.getText().length()>0)\r
345       {\r
346         for (int i = 0; i < sequences.length; i++)\r
347         {\r
348           features[i].type = lastFeatureAdded;\r
349           features[i].featureGroup = lastFeatureGroupAdded;\r
350           features[i].description = lastDescriptionAdded;\r
351           sequences[i].addSequenceFeature(features[i]);\r
352           ffile.parseDescriptionHTML(features[i], false);\r
353         }\r
354 \r
355         if (av.featuresDisplayed == null)\r
356         {\r
357           av.featuresDisplayed = new Hashtable();\r
358         }\r
359 \r
360         if (featureGroups == null)\r
361         {\r
362           featureGroups = new Hashtable();\r
363         }\r
364 \r
365         col = colourPanel.getBackground();\r
366         setColour(lastFeatureAdded, col);\r
367 \r
368         if(lastFeatureGroupAdded!=null)\r
369         {\r
370           featureGroups.put(lastFeatureGroupAdded, new Boolean(true));\r
371           av.featuresDisplayed.put(lastFeatureGroupAdded,\r
372                                    new Integer(col.getRGB()));\r
373         }\r
374         findAllFeatures();\r
375 \r
376         String [] tro = new String[renderOrder.length];\r
377         tro[0] = renderOrder[renderOrder.length-1];\r
378         System.arraycopy(renderOrder,0,tro,1,renderOrder.length-1);\r
379         renderOrder = tro;\r
380 \r
381         ap.paintAlignment(true);\r
382 \r
383         return true;\r
384       }\r
385       else\r
386       {\r
387         return false;\r
388       }\r
389     }\r
390 \r
391     findAllFeatures();\r
392 \r
393     ap.paintAlignment(true);\r
394 \r
395     return true;\r
396   }\r
397 \r
398 \r
399   public Color findFeatureColour(Color initialCol, SequenceI seq, int i)\r
400   {\r
401     overview = true;\r
402     if (!av.showSequenceFeatures)\r
403     {\r
404       return initialCol;\r
405     }\r
406 \r
407     lastSeq = seq;\r
408     sequenceFeatures = lastSeq.getSequenceFeatures();\r
409     if (sequenceFeatures == null)\r
410     {\r
411       return initialCol;\r
412     }\r
413 \r
414     sfSize = sequenceFeatures.length;\r
415 \r
416     if (jalview.util.Comparison.isGap(lastSeq.getCharAt(i)))\r
417     {\r
418       return Color.white;\r
419     }\r
420 \r
421     currentColour = null;\r
422 \r
423     drawSequence(null, lastSeq, lastSeq.findPosition(i), -1, -1);\r
424 \r
425     if (currentColour == null)\r
426     {\r
427       return initialCol;\r
428     }\r
429 \r
430     return new Color( ( (Integer) currentColour).intValue());\r
431   }\r
432 \r
433   /**\r
434    * This is used by the Molecule Viewer to get the accurate colour\r
435    * of the rendered sequence\r
436    */\r
437   boolean overview = false;\r
438 \r
439 \r
440   /**\r
441    * DOCUMENT ME!\r
442    *\r
443    * @param g DOCUMENT ME!\r
444    * @param seq DOCUMENT ME!\r
445    * @param sg DOCUMENT ME!\r
446    * @param start DOCUMENT ME!\r
447    * @param end DOCUMENT ME!\r
448    * @param x1 DOCUMENT ME!\r
449    * @param y1 DOCUMENT ME!\r
450    * @param width DOCUMENT ME!\r
451    * @param height DOCUMENT ME!\r
452    */\r
453   // String type;\r
454   // SequenceFeature sf;\r
455 \r
456   SequenceI lastSeq;\r
457   SequenceFeature[] sequenceFeatures;\r
458   int sfSize, sfindex, spos, epos;\r
459 \r
460   synchronized public void drawSequence(Graphics g, SequenceI seq,\r
461                            int start, int end, int y1)\r
462   {\r
463     if (seq.getSequenceFeatures() == null\r
464         || seq.getSequenceFeatures().length == 0)\r
465     {\r
466       return;\r
467     }\r
468 \r
469     if (transparencySetter != null && g != null)\r
470     {\r
471       transparencySetter.setTransparency(g, transparency);\r
472     }\r
473 \r
474     if (lastSeq == null || seq != lastSeq || sequenceFeatures!=seq.getSequenceFeatures())\r
475     {\r
476       lastSeq = seq;\r
477       sequenceFeatures = seq.getSequenceFeatures();\r
478       sfSize = sequenceFeatures.length;\r
479     }\r
480 \r
481     if (av.featuresDisplayed == null || renderOrder == null)\r
482     {\r
483       findAllFeatures();\r
484       if (av.featuresDisplayed.size() < 1)\r
485       {\r
486         return;\r
487       }\r
488 \r
489       sequenceFeatures = seq.getSequenceFeatures();\r
490       sfSize = sequenceFeatures.length;\r
491     }\r
492     if (!overview)\r
493     {\r
494       spos = lastSeq.findPosition(start);\r
495       epos = lastSeq.findPosition(end);\r
496       if (g != null)\r
497       {\r
498         fm = g.getFontMetrics();\r
499       }\r
500     }\r
501     String type;\r
502     for (int renderIndex = 0; renderIndex < renderOrder.length; renderIndex++)\r
503     {\r
504       type = renderOrder[renderIndex];\r
505       if (!av.featuresDisplayed.containsKey(type))\r
506       {\r
507         continue;\r
508       }\r
509 \r
510       // loop through all features in sequence to find\r
511       // current feature to render\r
512       for (sfindex = 0; sfindex < sfSize; sfindex++)\r
513       {\r
514         if (!sequenceFeatures[sfindex].type.equals(type))\r
515         {\r
516           continue;\r
517         }\r
518 \r
519         if (featureGroups != null\r
520             && sequenceFeatures[sfindex].featureGroup != null\r
521             &&\r
522             featureGroups.containsKey(sequenceFeatures[sfindex].featureGroup)\r
523             &&\r
524             ! ( (Boolean) featureGroups.get(sequenceFeatures[sfindex].\r
525                                             featureGroup)).\r
526             booleanValue())\r
527         {\r
528           continue;\r
529         }\r
530 \r
531         if (!overview && (sequenceFeatures[sfindex].getBegin() > epos\r
532                           || sequenceFeatures[sfindex].getEnd() < spos))\r
533         {\r
534           continue;\r
535         }\r
536 \r
537         if (overview)\r
538         {\r
539           if (sequenceFeatures[sfindex].begin <= start &&\r
540               sequenceFeatures[sfindex].end >= start)\r
541           {\r
542             currentColour = av.featuresDisplayed.get(sequenceFeatures[sfindex].\r
543                 type);\r
544           }\r
545 \r
546         }\r
547         else if (sequenceFeatures[sfindex].type.equals("disulfide bond"))\r
548         {\r
549 \r
550           renderFeature(g, seq,\r
551                         seq.findIndex(sequenceFeatures[sfindex].begin) - 1,\r
552                         seq.findIndex(sequenceFeatures[sfindex].begin) - 1,\r
553                         new Color( ( (Integer) av.featuresDisplayed.get(\r
554                             sequenceFeatures[sfindex].type)).intValue()),\r
555                         start, end, y1);\r
556           renderFeature(g, seq,\r
557                         seq.findIndex(sequenceFeatures[sfindex].end) - 1,\r
558                         seq.findIndex(sequenceFeatures[sfindex].end) - 1,\r
559                         new Color( ( (Integer) av.featuresDisplayed.get(\r
560                             sequenceFeatures[sfindex].type)).intValue()),\r
561                         start, end, y1);\r
562 \r
563         }\r
564         else\r
565         {\r
566           renderFeature(g, seq,\r
567                         seq.findIndex(sequenceFeatures[sfindex].begin) - 1,\r
568                         seq.findIndex(sequenceFeatures[sfindex].end) - 1,\r
569                         getColour(sequenceFeatures[sfindex].type),\r
570                         start, end, y1);\r
571         }\r
572 \r
573       }\r
574     }\r
575 \r
576     if (transparencySetter != null && g != null)\r
577     {\r
578       transparencySetter.setTransparency(g, 1.0f);\r
579     }\r
580   }\r
581 \r
582   char s;\r
583   int i;\r
584   void renderFeature(Graphics g, SequenceI seq,\r
585                      int fstart, int fend, Color featureColour, int start,\r
586                      int end, int y1)\r
587   {\r
588 \r
589     if ( ( (fstart <= end) && (fend >= start)))\r
590     {\r
591       if (fstart < start)\r
592       { // fix for if the feature we have starts before the sequence start,\r
593         fstart = start; // but the feature end is still valid!!\r
594       }\r
595 \r
596       if (fend >= end)\r
597       {\r
598         fend = end;\r
599       }\r
600 \r
601       for (i = fstart; i <= fend; i++)\r
602       {\r
603         s = seq.getCharAt(i);\r
604 \r
605         if (jalview.util.Comparison.isGap(s))\r
606         {\r
607           continue;\r
608         }\r
609 \r
610         g.setColor(featureColour);\r
611 \r
612         g.fillRect( (i - start) * av.charWidth, y1, av.charWidth, av.charHeight);\r
613 \r
614         if (!av.validCharWidth)\r
615         {\r
616           continue;\r
617         }\r
618 \r
619         g.setColor(Color.white);\r
620         charOffset = (av.charWidth - fm.charWidth(s)) / 2;\r
621         g.drawString(String.valueOf(s),\r
622                      charOffset + (av.charWidth * (i - start)),\r
623                      (y1 + av.charHeight) - av.charHeight / 5); //pady = height / 5;\r
624 \r
625       }\r
626     }\r
627   }\r
628 \r
629   void findAllFeatures()\r
630   {\r
631     jalview.schemes.UserColourScheme ucs = new\r
632         jalview.schemes.UserColourScheme();\r
633 \r
634     av.featuresDisplayed = new Hashtable();\r
635     Vector allfeatures = new Vector();\r
636     for (int i = 0; i < av.alignment.getHeight(); i++)\r
637     {\r
638       SequenceFeature[] features = av.alignment.getSequenceAt(i).\r
639           getSequenceFeatures();\r
640 \r
641       if (features == null)\r
642       {\r
643         continue;\r
644       }\r
645 \r
646       int index = 0;\r
647       while (index < features.length)\r
648       {\r
649         if (!av.featuresDisplayed.containsKey(features[index].getType()))\r
650         {\r
651           if (getColour(features[index].getType()) == null)\r
652           {\r
653             featureColours.put(features[index].getType(),\r
654                                ucs.createColourFromName(features[index].\r
655                 getType()));\r
656           }\r
657 \r
658           av.featuresDisplayed.put(features[index].getType(),\r
659                                    new Integer(getColour(features[index].\r
660               getType()).getRGB()));\r
661           allfeatures.addElement(features[index].getType());\r
662         }\r
663         index++;\r
664       }\r
665     }\r
666 \r
667     renderOrder = new String[allfeatures.size()];\r
668     Enumeration en = allfeatures.elements();\r
669     int i = allfeatures.size() - 1;\r
670     while (en.hasMoreElements())\r
671     {\r
672       renderOrder[i] = en.nextElement().toString();\r
673       i--;\r
674     }\r
675   }\r
676 \r
677   public Color getColour(String featureType)\r
678   {\r
679     if (!featureColours.containsKey(featureType))\r
680     {\r
681       jalview.schemes.UserColourScheme ucs = new\r
682           jalview.schemes.UserColourScheme();\r
683       Color col = ucs.createColourFromName(featureType);\r
684       featureColours.put(featureType, col);\r
685       return col;\r
686     }\r
687     else\r
688       return (Color) featureColours.get(featureType);\r
689   }\r
690 \r
691 \r
692   public void setColour(String featureType, Color col)\r
693   {\r
694     featureColours.put(featureType, col);\r
695   }\r
696 \r
697   public void setFeaturePriority(Object[][] data)\r
698   {\r
699     // The feature table will display high priority\r
700     // features at the top, but theses are the ones\r
701     // we need to render last, so invert the data\r
702     if (av.featuresDisplayed != null)\r
703     {\r
704       av.featuresDisplayed.clear();\r
705     }\r
706 \r
707    /* if (visibleNew)\r
708     {\r
709       if (av.featuresDisplayed != null)\r
710       {\r
711         av.featuresDisplayed.clear();\r
712       }\r
713       else\r
714       {\r
715         av.featuresDisplayed = new Hashtable();\r
716       }\r
717     }\r
718     if (data == null)\r
719     {\r
720       return;\r
721     }*/\r
722 \r
723 \r
724     renderOrder = new String[data.length];\r
725 \r
726     if (data.length > 0)\r
727     {\r
728       for (int i = 0; i < data.length; i++)\r
729       {\r
730         String type = data[i][0].toString();\r
731         setColour(type, (Color) data[i][1]);\r
732         if ( ( (Boolean) data[i][2]).booleanValue())\r
733         {\r
734           av.featuresDisplayed.put(type, new Integer(getColour(type).getRGB()));\r
735         }\r
736 \r
737         renderOrder[data.length - i - 1] = type;\r
738       }\r
739     }\r
740   }\r
741 }\r
742 \r
743 class TransparencySetter\r
744 {\r
745   void setTransparency(Graphics g, float value)\r
746   {\r
747      Graphics2D g2 = (Graphics2D) g;\r
748      g2.setComposite(\r
749         AlphaComposite.getInstance(\r
750              AlphaComposite.SRC_OVER, value));\r
751   }\r
752 }\r