sventon subversion web client - http://www.sventon.org
[show recent changes]
 
  Go to revisionGo to path
HEAD Help
Rev: 657 - svn://greenwoodma.servehttp.com/open-source / SVGRoundTrip / trunk / src / englishcoffeedrinker / svg / in / templates / flamingo
Diff View - flamingo
Next diff       /SVGRoundTrip/trunk/src/englishcoffeedrinker/svg/in/templates/flamingo @ revision 656
        /SVGRoundTrip/trunk/src/englishcoffeedrinker/svg/in/templates/flamingo @ revision 657
1 1   TOKEN_PACKAGE
2 2    
3 3   import java.awt.*;
4 4   import java.awt.geom.*;
5 5   import java.awt.image.*;
6 6    
7 7   import java.awt.image.BufferedImage;
8 8   import java.io.IOException;
9 9   import javax.imageio.ImageIO;
10 10    
11 11   /**
12 12    * This class has been automatically generated using <a
13 13    * href="http://englishjavadrinker.blogspot.com/search/label/SVGRoundTrip">SVGRoundTrip</a>.
14 14    */
15 15   @SuppressWarnings("unused")
16 16   public class TOKEN_CLASSNAME implements
17 17     org.pushingpixels.flamingo.api.common.icon.ResizableIcon {
Next diff 18 +  
Next diff 19 +  private static Color getColor(int red, int green, int blue, int alpha, boolean disabled) {
Next diff 20 +   return new Color(red, green, blue, alpha);
Next diff 21 +  }
Next diff 22 +  
18 23    /**
19 24     * Paints the transcoded SVG image on the specified graphics context. You
20 25     * can install a custom transformation on the graphics context to scale the
21 26     * image.
22 27     *
23 28     * @param g
24 29     * Graphics context.
25 30     */
Next diff 26 -  public static void paint(Graphics2D g) {
Next diff 31 +  public static void paint(Graphics2D g, boolean disabled) {
27 32           Shape shape = null;
28 33           Paint paint = null;
29 34           Stroke stroke = null;
30 35           Area clip = null;
31 36    
32 37           float origAlpha = 1.0f;
33 38           Composite origComposite = g.getComposite();
34 39           if (origComposite instanceof AlphaComposite) {
35 40               AlphaComposite origAlphaComposite =
36 41                   (AlphaComposite)origComposite;
37 42               if (origAlphaComposite.getRule() == AlphaComposite.SRC_OVER) {
38 43                   origAlpha = origAlphaComposite.getAlpha();
39 44               }
40 45           }
41 46    
42 47        TOKEN_PAINTING_CODE
43 48    }
44 49    
45 50    public Image getImage() {
46 51     BufferedImage image =
47 52               new BufferedImage(getIconWidth(), getIconHeight(),
48 53                       BufferedImage.TYPE_INT_ARGB);
49 54        Graphics2D g = image.createGraphics();
50 55        paintIcon(null, g, 0, 0);
51 56        g.dispose();
52 57        return image;
53 58    }
54 59    
55 60       /**
56 61        * Returns the X of the bounding box of the original SVG image.
57 62        *
58 63        * @return The X of the bounding box of the original SVG image.
59 64        */
60 65       public static int getOrigX() {
61 66           return TOKEN_ORIG_X;
62 67       }
63 68    
64 69       /**
65 70        * Returns the Y of the bounding box of the original SVG image.
66 71        *
67 72        * @return The Y of the bounding box of the original SVG image.
68 73        */
69 74       public static int getOrigY() {
70 75           return TOKEN_ORIG_Y;
71 76       }
72 77    
73 78    /**
74 79     * Returns the width of the bounding box of the original SVG image.
75 80     *
76 81     * @return The width of the bounding box of the original SVG image.
77 82     */
78 83    public static int getOrigWidth() {
79 84     return TOKEN_ORIG_WIDTH;
80 85    }
81 86    
82 87    /**
83 88     * Returns the height of the bounding box of the original SVG image.
84 89     *
85 90     * @return The height of the bounding box of the original SVG image.
86 91     */
87 92    public static int getOrigHeight() {
88 93     return TOKEN_ORIG_HEIGHT;
89 94    }
90 95    
91 96    /**
92 97     * The current width of this resizable icon.
93 98     */
94 99    int width;
95 100    
96 101    /**
97 102     * The current height of this resizable icon.
98 103     */
99 104    int height;
100 105    
101 106    /**
102 107     * Creates a new transcoded SVG image.
103 108     */
104 109    public TOKEN_CLASSNAME() {
105 110           this.width = getOrigWidth();
106 111           this.height = getOrigHeight();
107 112    }
108 113    
109 114    /**
110 115     * Creates a new transcoded SVG image with the given dimensions.
111 116     *
112 117     * @param size the dimensions of the icon
113 118     */
114 119    public TOKEN_CLASSNAME(Dimension size) {
115 120     this.width = size.width;
116 121     this.height = size.width;
117 122    }
118 123    
119 124    public TOKEN_CLASSNAME(int width, int height) {
120 125     this.width = width;
121 126     this.height = height;
122 127    }
123 128    
124 129    /*
125 130     * (non-Javadoc)
126 131     *
127 132     * @see javax.swing.Icon#getIconHeight()
128 133     */
129 134       @Override
130 135    public int getIconHeight() {
131 136     return height;
132 137    }
133 138    
134 139    /*
135 140     * (non-Javadoc)
136 141     *
137 142     * @see javax.swing.Icon#getIconWidth()
138 143     */
139 144       @Override
140 145    public int getIconWidth() {
141 146     return width;
142 147    }
143 148    
144 149    /*
145 150     * (non-Javadoc)
146 151     *
147 152     * @see
148 153     * org.jvnet.flamingo.common.icon.ResizableIcon#setDimension(java.awt.Dimension
149 154     * )
150 155     */
151 156    @Override
152 157    public void setDimension(Dimension newDimension) {
153 158     this.width = newDimension.width;
154 159     this.height = newDimension.height;
155 160    }
156 161    
157 162    /*
158 163     * (non-Javadoc)
159 164     *
160 165     * @see javax.swing.Icon#paintIcon(java.awt.Component, java.awt.Graphics,
161 166     * int, int)
162 167     */
163 168       @Override
164 169    public void paintIcon(Component c, Graphics g, int x, int y) {
165 170     Graphics2D g2d = (Graphics2D) g.create();
166 171     g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
167 172       RenderingHints.VALUE_ANTIALIAS_ON);
168 173     g2d.translate(x, y);
169 174    
170 175     Area clip = new Area(new Rectangle(0, 0, this.width, this.height));
171 176     if (g2d.getClip() != null) clip.intersect(new Area(g2d.getClip()));
172 177     g2d.setClip(clip);
173 178    
174 179     double coef1 = (double) this.width / (double) getOrigWidth();
175 180     double coef2 = (double) this.height / (double) getOrigHeight();
176 181     double coef = Math.min(coef1, coef2);
177 182     g2d.scale(coef, coef);
Next diff 178 -   paint(g2d);
Next diff 183 +   paint(g2d, false);
179 184     g2d.dispose();
180 185    }
181 186   }

feed icon

sventon 2.1.4