/[svn]/jsampler/trunk/src/org/jsampler/view/std/StdUtils.java
ViewVC logotype

Diff of /jsampler/trunk/src/org/jsampler/view/std/StdUtils.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2145 by iliev, Fri Jun 12 01:22:41 2009 UTC revision 2146 by iliev, Mon Oct 11 09:31:27 2010 UTC
# Line 1  Line 1 
1  /*  /*
2   *   JSampler - a java front-end for LinuxSampler   *   JSampler - a java front-end for LinuxSampler
3   *   *
4   *   Copyright (C) 2005-2009 Grigor Iliev <grigor@grigoriliev.com>   *   Copyright (C) 2005-2010 Grigor Iliev <grigor@grigoriliev.com>
5   *   *
6   *   This file is part of JSampler.   *   This file is part of JSampler.
7   *   *
# Line 21  Line 21 
21   */   */
22  package org.jsampler.view.std;  package org.jsampler.view.std;
23    
24    import java.awt.Graphics2D;
25    import java.awt.Image;
26    import java.awt.Color;
27  import java.awt.Desktop;  import java.awt.Desktop;
28  import java.awt.Dialog;  import java.awt.Dialog;
29  import java.awt.FileDialog;  import java.awt.FileDialog;
30  import java.awt.Frame;  import java.awt.Frame;
31  import java.awt.Rectangle;  import java.awt.Rectangle;
32    import java.awt.Toolkit;
33  import java.awt.Window;  import java.awt.Window;
34    
35  import java.awt.event.ActionEvent;  import java.awt.event.ActionEvent;
# Line 33  import java.awt.event.ActionListener; Line 37  import java.awt.event.ActionListener;
37  import java.awt.event.MouseAdapter;  import java.awt.event.MouseAdapter;
38  import java.awt.event.MouseEvent;  import java.awt.event.MouseEvent;
39    
40    import java.awt.image.BufferedImage;
41    
42  import java.beans.PropertyChangeEvent;  import java.beans.PropertyChangeEvent;
43  import java.beans.PropertyChangeListener;  import java.beans.PropertyChangeListener;
44    
# Line 44  import java.text.NumberFormat; Line 50  import java.text.NumberFormat;
50  import java.util.Vector;  import java.util.Vector;
51  import java.util.logging.Level;  import java.util.logging.Level;
52    
53    import javax.swing.ImageIcon;
54  import javax.swing.JComboBox;  import javax.swing.JComboBox;
55  import javax.swing.JFileChooser;  import javax.swing.JFileChooser;
56  import javax.swing.JSlider;  import javax.swing.JSlider;
# Line 431  public class StdUtils { Line 438  public class StdUtils {
438                          tip.repaint();                          tip.repaint();
439                  }                  }
440          }          }
441    
442            /**
443             * Applies the specified color as background to
444             * the specified image and returns the newly created image.
445             */
446            public static ImageIcon
447            createImageIcon(Image img, Color bgColor) {
448                    BufferedImage img2 = new BufferedImage (
449                            img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_RGB
450                    );
451    
452                    Graphics2D g = img2.createGraphics();
453                    g.drawImage(img, 0, 0, bgColor, null);
454                    g.dispose();
455    
456                    return new ImageIcon(Toolkit.getDefaultToolkit().createImage(img2.getSource()));
457            }
458  }  }

Legend:
Removed from v.2145  
changed lines
  Added in v.2146

  ViewVC Help
Powered by ViewVC