/[svn]/jsampler/trunk/src/org/jsampler/view/fantasia/basic/FantasiaPainter.java
ViewVC logotype

Diff of /jsampler/trunk/src/org/jsampler/view/fantasia/basic/FantasiaPainter.java

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

revision 2145 by iliev, Wed Dec 24 17:29:47 2008 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-2008 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 26  import java.awt.AlphaComposite; Line 26  import java.awt.AlphaComposite;
26  import java.awt.Color;  import java.awt.Color;
27  import java.awt.Composite;  import java.awt.Composite;
28  import java.awt.GradientPaint;  import java.awt.GradientPaint;
29    import java.awt.Graphics;
30  import java.awt.Graphics2D;  import java.awt.Graphics2D;
31    import java.awt.Insets;
32  import java.awt.Paint;  import java.awt.Paint;
33    import java.awt.RenderingHints;
34    
35  import java.awt.geom.Area;  import java.awt.geom.Area;
36  import java.awt.geom.Line2D;  import java.awt.geom.Line2D;
37  import java.awt.geom.Rectangle2D;  import java.awt.geom.Rectangle2D;
38    
39    import javax.swing.JComponent;
40    
41  /**  /**
42   *   *
43   * @author Grigor Iliev   * @author Grigor Iliev
# Line 747  public class FantasiaPainter { Line 752  public class FantasiaPainter {
752                  g2.setPaint(oldPaint);                  g2.setPaint(oldPaint);
753                  g2.setComposite(oldComposite);                  g2.setComposite(oldComposite);
754          }          }
755    
756            private static Color surface1Color1 = new Color(0x7a7a7a);
757            private static Color surface1Color2 = new Color(0x5e5e5e);
758            private static Color surface1Color3 = new Color(0x2e2e2e);
759    
760            /**
761             * Used to paint the MIDI keyboard
762             */
763            public static void
764            paintSurface1(JComponent c, Graphics g) {
765                    Graphics2D g2 = (Graphics2D)g;
766    
767                    Paint oldPaint = g2.getPaint();
768                    Composite oldComposite = g2.getComposite();
769                    Object aa = g2.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
770    
771                    Insets insets = c.getInsets();
772                    double x1 = insets.left;
773                    double y1 = insets.top;
774    
775                    double w = c.getSize().getWidth();
776                    double x2 = w - insets.right - 1;
777                    double h = c.getSize().getHeight();
778                    double y2 = h - insets.bottom - 1;
779    
780                    g2.setRenderingHint (
781                            RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF
782                    );
783    
784                    FantasiaPainter.paintGradient(g2, x1, y1, x2, y2 - 10, surface1Color1, surface1Color2);
785    
786                    double y3 = y2 - 10;
787                    if(y3 < 0) y3 = 0;
788    
789                    Rectangle2D.Double rect = new Rectangle2D.Double(x1, y3, x2 - x1 + 1, 11);
790    
791                    GradientPaint gr = new GradientPaint (
792                            0.0f, (float)y3, surface1Color2,
793                            0.0f, (float)h, surface1Color3
794                    );
795    
796                    g2.setPaint(gr);
797                    g2.fill(rect);
798    
799                    drawSurface1OutBorder(g2, x1, y1, x2, y2);
800    
801                    g2.setPaint(oldPaint);
802                    g2.setComposite(oldComposite);
803                    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, aa);
804            }
805    
806            private static void
807            drawSurface1OutBorder(Graphics2D g2, double x1, double y1, double x2, double y2) {
808                    AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.40f);
809                    g2.setComposite(ac);
810    
811                    g2.setPaint(Color.WHITE);
812                    Line2D.Double l = new Line2D.Double(x1, y1, x2, y1);
813                    g2.draw(l);
814    
815                    g2.setComposite(ac.derive(0.20f));
816                    l = new Line2D.Double(x1, y1 + 1, x2, y1 + 1);
817                    g2.draw(l);
818    
819                    g2.setComposite(ac.derive(0.255f));
820    
821                    l = new Line2D.Double(x1, y1, x1, y2);
822                    g2.draw(l);
823    
824                    g2.setComposite(ac.derive(0.40f));
825                    g2.setPaint(Color.BLACK);
826    
827                    //l = new Line2D.Double(x1, y2, x2, y2);
828                    //g2.draw(l);
829    
830                    g2.setComposite(ac.derive(0.20f));
831    
832                    l = new Line2D.Double(x2, y1, x2, y2);
833                    g2.draw(l);
834            }
835  }  }

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

  ViewVC Help
Powered by ViewVC