<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Java User Group Münster &#187; tutorial</title>
	<atom:link href="http://www.jug-muenster.de/tag/tutorial/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jug-muenster.de</link>
	<description>Java User Group für Münster und das Münsterland</description>
	<lastBuildDate>Sun, 25 Jul 2010 12:26:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Drawing in code (Part 2)</title>
		<link>http://www.jug-muenster.de/drawing-in-code-part-2-2-384/</link>
		<comments>http://www.jug-muenster.de/drawing-in-code-part-2-2-384/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 20:39:55 +0000</pubDate>
		<dc:creator>Gerrit</dc:creator>
				<category><![CDATA[Contributed]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[swing]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.jug-muenster.de/?p=384</guid>
		<description><![CDATA[Drawing in code: Part 2 (Transfer the prototype into swing): So you will find out that this is not magic but only drawing the same elements that we used in the vector drawing programm but now in their Java2D representations. We just create a buffered image with the same size as the prototype. So we [...]


Weitere Artikel:<ol><li><a href='http://www.jug-muenster.de/drawing-in-code-part-1-379/' rel='bookmark' title='Permanent Link: Drawing in code (Part 1)'>Drawing in code (Part 1)</a></li>
<li><a href='http://www.jug-muenster.de/java2d-conical-gradient-paint-674/' rel='bookmark' title='Permanent Link: Java2D Conical Gradient Paint'>Java2D Conical Gradient Paint</a></li>
<li><a href='http://www.jug-muenster.de/swing-worldclock-427/' rel='bookmark' title='Permanent Link: Swing Worldclock'>Swing Worldclock</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><!--S-ButtonZ 1.1.5 End--><h1>Drawing in code:</h1>
<h2>Part 2 (Transfer the prototype into swing):</h2>
<p>So you will find out that this is not magic but only drawing the same elements that we used in the vector drawing programm but now in their Java2D representations. We just create a buffered image with the same size as the prototype. So we could use the same pixelcoordinates for the shapes and gradients in swing.<br />
<span id="more-384"></span></p>
<table>
<tbody>
<tr>
<td>In <a href="http://www.adobe.com/products/fireworks">Adobe Fireworks</a> you have the ability to move the mousecursor over a pixel and you could see the pixelcoordinate and it&#8217;s color values in a window, this is nothing special but it&#8217;s a needed functionality to grab the positions of all the shapes and the colors of the gradients from the prototype.</p>
<p><strong>Keep in mind that i won&#8217;t show how i pick all these coordinates and colors, but you have to do this</strong></td>
<td><img src="http://www.jug-muenster.de/wp-content/uploads/2010/01/ishot-31.png" border="0" alt="ishot-3.png" width="328" height="217" align="right" /></td>
</tr>
</tbody>
</table>
<p><strong>Step 1. &#8211; 5.</strong></p>
<p>First coding the vertical pill which is in principle just a rounded rectangle with a corner radius of it&#8217;s width.</p>
<p>After that we code the rounded rectangle that will represent the bottom if the tube.</p>
<p>Now follows the small ellipse on the top.<br />
After all we combine all of these shapes into one which is really easy in swing.</p>
<p>Just take a look at the code:</p>
<pre class="brush:java;">/**
* Tutorial Step 1. - 5.
* Create the glass tube form
*/
final java.awt.geom.Area TUBE = new java.awt.geom.Area(new java.awt.geom.RoundRectangle2D.Float(1, 8, 86, 136, 86, 86));
final java.awt.geom.Area TUBE_BOTTOM = new java.awt.geom.Area(new java.awt.geom.RoundRectangle2D.Float(1, 75, 86, 70, 30, 30));
final java.awt.geom.Area TUBE_TOP = new java.awt.geom.Area(new java.awt.geom.Ellipse2D.Float(38, 0, 12, 18));
TUBE.add(TUBE_TOP);
TUBE.add(TUBE_BOTTOM);</pre>
<p><strong>Step 6.</strong></p>
<p>Create and apply a horizontal gradient to the tube.</p>
<pre class="brush:java;">/**
* Tutorial Step 6.
* Create and apply the left to right gradient
*/
final java.awt.geom.Point2D START_LEFT = new java.awt.geom.Point2D.Float(0,0);
final java.awt.geom.Point2D STOP_RIGHT = new java.awt.geom.Point2D.Float(86,0);

final float[] FRACTIONS_LEFT_TO_RIGHT =
{
    0.0f,
    0.15f,
    0.4f,
    0.6f,
    0.75f,
    1.0f
};

final java.awt.Color[] COLORS_LEFT_TO_RIGHT =
{
    new java.awt.Color(0.0f, 0.0f, 0.0f, 0.5f),
    new java.awt.Color(0.0f, 0.0f, 0.0f, 0.3f),
    new java.awt.Color(0.0f, 0.0f, 0.0f, 0.1f),
    new java.awt.Color(0.0f, 0.0f, 0.0f, 0.1f),
    new java.awt.Color(0.0f, 0.0f, 0.0f, 0.3f),
    new java.awt.Color(0.0f, 0.0f, 0.0f, 0.5f)
};

final java.awt.LinearGradientPaint LEFT_TO_RIGHT_GRADIENT = new java.awt.LinearGradientPaint(START_LEFT, STOP_RIGHT, FRACTIONS_LEFT_TO_RIGHT, COLORS_LEFT_TO_RIGHT);

g2.setPaint(LEFT_TO_RIGHT_GRADIENT);
g2.fill(TUBE);</pre>
<p><strong>Step 7.</strong></p>
<p>Now create and apply a vertical gradient from top to bottom to the same tube shape.</p>
<pre class="brush:java;">/**
* Tutorial Step 7.
* Create and apply the top to bottom gradient
*/
final java.awt.geom.Point2D START_TOP = new java.awt.geom.Point2D.Float(0,0);
final java.awt.geom.Point2D STOP_BOTTOM = new java.awt.geom.Point2D.Float(0,146);

final float[] FRACTIONS_TOP_TO_BOTTOM =
{
    0.0f,
    0.9f,
    1.0f
};

final java.awt.Color[] COLORS_TOP_TO_BOTTOM =
{
    new java.awt.Color(0.0f, 0.0f, 0.0f, 0.0f),
    new java.awt.Color(0.0f, 0.0f, 0.0f, 0.0f),
    new java.awt.Color(0.0f, 0.0f, 0.0f, 0.6f)
};

final java.awt.LinearGradientPaint TOP_TO_BOTTOM_GRADIENT = new java.awt.LinearGradientPaint(START_TOP, STOP_BOTTOM, FRACTIONS_TOP_TO_BOTTOM, COLORS_TOP_TO_BOTTOM);

g2.setPaint(TOP_TO_BOTTOM_GRADIENT);
g2.fill(TUBE);</pre>
<p><strong>Step 8. &#8211; 9.</strong></p>
<p>So let&#8217;s add the side light effect. So we code two roundedrectangles and subtract one from another. Let&#8217;s take a look at the code:</p>
<pre class="brush:java;">/**
* Tutorial Step 8. - 9.
* Create the side light reflection shape
*/
final java.awt.geom.Area SIDE_LIGHT_EFFECT = new java.awt.geom.Area(new java.awt.geom.RoundRectangle2D.Float(3, 43, 36, 99, 18, 18));
final java.awt.geom.Area EFFECT_SUB = new java.awt.geom.Area(new java.awt.geom.RoundRectangle2D.Float(7, 37, 36, 105, 18, 18));
SIDE_LIGHT_EFFECT.subtract(EFFECT_SUB);</pre>
<p>et voila&#8230;that was easy</p>
<p><strong>Step 10.</strong></p>
<p>Now we have to create and apply a horizontal gradient for this side light effect.</p>
<pre class="brush:java;">/**
* Tutorial Step 10.
* Create and apply the side light gradient
*/
final java.awt.geom.Point2D SIDE_LIGHT_EFFECT_START = new java.awt.geom.Point2D.Float(3, 0);
final java.awt.geom.Point2D SIDE_LIGHT_EFFECT_STOP = new java.awt.geom.Point2D.Float(13, 0);

final float[] SIDE_LIGHT_EFFECT_FRACTIONS =
{
    0.0f,
    1.0f
};

final java.awt.Color[] SIDE_LIGHT_EFFECT_COLORS =
{
    new java.awt.Color(1.0f, 1.0f, 1.0f, 0.5f),
    new java.awt.Color(1.0f, 1.0f, 1.0f, 0.0f)
};

final java.awt.LinearGradientPaint SIDE_LIGHT_EFFECT_GRADIENT = new java.awt.LinearGradientPaint(SIDE_LIGHT_EFFECT_START, SIDE_LIGHT_EFFECT_STOP, SIDE_LIGHT_EFFECT_FRACTIONS, SIDE_LIGHT_EFFECT_COLORS);

g2.setPaint(SIDE_LIGHT_EFFECT_GRADIENT);
g2.fill(SIDE_LIGHT_EFFECT);</pre>
<p><strong>Step 11.</strong></p>
<p>Next thing to code is the ellipse on top of the tube which will be the top light reflection.</p>
<pre class="brush:java;">/**
* Tutorial Step 11.
* Create the top light effect ellipse
*/
final java.awt.geom.Ellipse2D TOP_LIGHT_EFFECT = new java.awt.geom.Ellipse2D.Float(17, 11, 52, 21);</pre>
<p><strong>Step 12.</strong></p>
<p>Now we have to create and apply the gradient for this top light reflection.</p>
<pre class="brush:java;">/**
* Tutorial Step 12.
* Create and apply the top light gradient
*/
final java.awt.geom.Point2D TOP_LIGHT_EFFECT_START = new java.awt.geom.Point2D.Float(0, 11);
final java.awt.geom.Point2D TOP_LIGHT_EFFECT_STOP = new java.awt.geom.Point2D.Float(0, 32);

final float[] TOP_LIGHT_EFFECT_FRACTIONS =
{
    0.0f,
    1.0f
};

final java.awt.Color[] TOP_LIGHT_EFFECT_COLORS =
{
    new java.awt.Color(1.0f, 1.0f, 1.0f, 0.5f),
    new java.awt.Color(1.0f, 1.0f, 1.0f, 0.0f)
};

final java.awt.LinearGradientPaint TOP_LIGHT_EFFECT_GRADIENT = new java.awt.LinearGradientPaint(TOP_LIGHT_EFFECT_START, TOP_LIGHT_EFFECT_STOP, TOP_LIGHT_EFFECT_FRACTIONS, TOP_LIGHT_EFFECT_COLORS);

g2.setPaint(TOP_LIGHT_EFFECT_GRADIENT);
g2.fill(TOP_LIGHT_EFFECT);</pre>
<p><strong>Step 13.</strong></p>
<p>This one is ease, just a small ellipse on top.</p>
<pre class="brush:java;">/**
* Tutorial Step 13.
* Create the small light effect ellipse
*/
final java.awt.geom.Ellipse2D SMALL_TOP_LIGHT_EFFECT = new java.awt.geom.Ellipse2D.Float(39, 3, 4, 6);</pre>
<p><strong>Step 14.</strong></p>
<p>And again create and apply the right gradient for the reflection effect.</p>
<pre class="brush:java;">/**
* Tutorial Step 14.
* Create and apply the small light effect gradient
*/
final java.awt.geom.Point2D SMALL_TOP_LIGHT_EFFECT_START = new java.awt.geom.Point2D.Float(0, 3);
final java.awt.geom.Point2D SMALL_TOP_LIGHT_EFFECT_STOP = new java.awt.geom.Point2D.Float(0, 9);

final float[] SMALL_TOP_LIGHT_EFFECT_FRACTIONS =
{
    0.0f,
    1.0f
};

final java.awt.Color[] SMALL_TOP_LIGHT_EFFECT_COLORS =
{
    new java.awt.Color(1.0f, 1.0f, 1.0f, 0.3f),
    new java.awt.Color(1.0f, 1.0f, 1.0f, 0.0f)
};

final java.awt.LinearGradientPaint SMALL_TOP_LIGHT_EFFECT_GRADIENT = new java.awt.LinearGradientPaint(SMALL_TOP_LIGHT_EFFECT_START, SMALL_TOP_LIGHT_EFFECT_STOP, SMALL_TOP_LIGHT_EFFECT_FRACTIONS, SMALL_TOP_LIGHT_EFFECT_COLORS);

g2.setPaint(SMALL_TOP_LIGHT_EFFECT_GRADIENT);
g2.fill(SMALL_TOP_LIGHT_EFFECT);</pre>
<p><strong>Step 15.</strong></p>
<p>We are coming slowly to the end, now creating the small rectangle for the stripe reflection.</p>
<pre class="brush:java;">/**
* Tutorial Step 15.
* Creating the rectangle for the stripe light effect
*/
final java.awt.geom.Rectangle2D STRIPE_LIGHT_EFFECT = new java.awt.geom.Rectangle2D.Float(13, 46, 62, 1);</pre>
<p><strong>Step 16.</strong></p>
<p>Finally create and apply the gradient for the stripe reflection.</p>
<pre class="brush:java;">/**
* Tutorial Step 16.
* Create and apply the stripe light effect gradient
*/
final java.awt.geom.Point2D STRIPE_LIGHT_EFFECT_START = new java.awt.geom.Point2D.Float(13, 0);
final java.awt.geom.Point2D STRIPE_LIGHT_EFFECT_STOP = new java.awt.geom.Point2D.Float(75, 0);

final float[] STRIPE_LIGHT_EFFECT_FRACTIONS =
{
    0.0f,
    0.5f,
    1.0f
};

final java.awt.Color[] STRIPE_LIGHT_EFFECT_COLORS =
{
    new java.awt.Color(1.0f, 1.0f, 1.0f, 0.0f),
    new java.awt.Color(1.0f, 1.0f, 1.0f, 0.5f),
    new java.awt.Color(1.0f, 1.0f, 1.0f, 0.0f)
};

final java.awt.LinearGradientPaint STRIPE_LIGHT_EFFECT_GRADIENT = new java.awt.LinearGradientPaint(STRIPE_LIGHT_EFFECT_START, STRIPE_LIGHT_EFFECT_STOP, STRIPE_LIGHT_EFFECT_FRACTIONS, STRIPE_LIGHT_EFFECT_COLORS);

g2.setPaint(STRIPE_LIGHT_EFFECT_GRADIENT);
g2.fill(STRIPE_LIGHT_EFFECT);</pre>
<table>
<tbody>
<tr>
<th>Prototype</th>
<th>Swing</th>
</tr>
<tr>
<td><img src="http://www.jug-muenster.de/wp-content/uploads/2010/01/ishot-23.png" border="0" alt="ishot-23.png" width="92" height="150" align="right" /></td>
<td><img src="http://www.jug-muenster.de/wp-content/uploads/2010/01/ishot-41.png" border="0" alt="ishot-4.png" width="148" height="231" align="right" /></td>
</tr>
</tbody>
</table>
<h3>Conclusion:</h3>
<p>As you can see transfering an image to swing is not rocket-science. To achieve this you have to get a feeling for drawing effects like light reflections, shadows etc. (and i&#8217;m really not a designer).</p>
<p>So my recommendation is follow design blogs, play with your drawing program or just walk around with open eyes and take pictures of intersting things&#8230;there are so many of them&#8230;</p>
<p>Please find the related Netbeans project here <a title="DrawInCode.zip" href="http://www.jug-muenster.de/wp-content/uploads/2010/01/DrawInCode.zip">DrawInCode.zip</a></p>
<p>Now enjoy swinging&#8230;</p>
<div style="clear:both;">&nbsp;</div>

<p>Weitere Artikel:<ol><li><a href='http://www.jug-muenster.de/drawing-in-code-part-1-379/' rel='bookmark' title='Permanent Link: Drawing in code (Part 1)'>Drawing in code (Part 1)</a></li>
<li><a href='http://www.jug-muenster.de/java2d-conical-gradient-paint-674/' rel='bookmark' title='Permanent Link: Java2D Conical Gradient Paint'>Java2D Conical Gradient Paint</a></li>
<li><a href='http://www.jug-muenster.de/swing-worldclock-427/' rel='bookmark' title='Permanent Link: Swing Worldclock'>Swing Worldclock</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jug-muenster.de/drawing-in-code-part-2-2-384/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Drawing in code (Part 1)</title>
		<link>http://www.jug-muenster.de/drawing-in-code-part-1-379/</link>
		<comments>http://www.jug-muenster.de/drawing-in-code-part-1-379/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 20:29:35 +0000</pubDate>
		<dc:creator>Gerrit</dc:creator>
				<category><![CDATA[Contributed]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[swing]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.jug-muenster.de/?p=379</guid>
		<description><![CDATA[Drawing in code: Part 1 (Drawing the prototype): After i published my little fun swing nixieclock i got a lot of requests on how i transferred the image into swing. Because i remember when i was starting swing development i asked myself the same questions when i saw the amazing work of swing/design guru&#8217;s like [...]


Weitere Artikel:<ol><li><a href='http://www.jug-muenster.de/drawing-in-code-part-2-2-384/' rel='bookmark' title='Permanent Link: Drawing in code (Part 2)'>Drawing in code (Part 2)</a></li>
<li><a href='http://www.jug-muenster.de/java2d-conical-gradient-paint-674/' rel='bookmark' title='Permanent Link: Java2D Conical Gradient Paint'>Java2D Conical Gradient Paint</a></li>
<li><a href='http://www.jug-muenster.de/swing-worldclock-427/' rel='bookmark' title='Permanent Link: Swing Worldclock'>Swing Worldclock</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><!--S-ButtonZ 1.1.5 End--><h1>Drawing in code:</h1>
<h2>Part 1 (Drawing the prototype):</h2>
<p>After i published my little fun swing nixieclock i got a lot of requests on how i transferred the image into swing.<br />
Because i remember when i was starting swing development i asked myself the same questions when i saw the amazing work of swing/design guru&#8217;s like <a href="http://www.pushing-pixels.org">Kirill Grouchnikov</a>, <a href="http://www.curious-creature.org/">Romain Guy</a>, <a href="http://www.joshondesign.com/">Joshua Marinacci</a>, <a href="http://graphics-geek.blogspot.com/">Chet Haase</a>, and others.<br />
Well in the meantime i figured out how  to do this and find a workflow that i would like to share here. By the way this is really nothing compared to the things these swing/design guru&#8217;s are able to do.</p>
<p>So here we go, first of all i have one good advice for you <strong>&#8220;Know your tools&#8221;</strong>,<br />
which means not only java and swing but also your graphics program.</p>
<p>So i&#8217;m using <a href="http://www.adobe.com/products/fireworks">Adobe Fireworks</a> for that but you could also use any other kind of graphics program like <a href="http://www.adobe.com/products/photoshop">Adobe Photoshop</a>, <a href="http://www.gimp.org">Gimp</a>, <a href="http://www.inkscape.org">Inkscape</a> etc.</p>
<p>I will start the tutorial with the drawing of the tube in <a href="http://www.adobe.com/products/fireworks">Adobe Fireworks</a> because it makes coding in swing so much easier if you know how to draw it in a graphics program. So the first part will be focussed on the drawing and the second part will explain how to draw all the different points in java2d/swing:<span id="more-379"></span></p>
<table>
<tbody>
<tr>
<td>So we would like to create a nixie glass tube in swing that should look similar to this but to keep it simple i will focus only on the glass tube itself without any numbers or logic etc.</p>
<p>Once you understand the way of doing this you could easily adopt these technique to everything you would like to do (if there is a equivalent in swing).</td>
<td><img src="http://www.jug-muenster.de/wp-content/uploads/2010/01/NixieTubeVorlage.jpg" border="0" alt="NixieTubeVorlage.jpg" width="112" height="250" align="right" /></td>
</tr>
</tbody>
</table>
<table>
<tbody>
<tr>
<td><strong>Step 1. </strong></p>
<p>Draw a vertical pill which will be the main body of the tube.</td>
<td><img src="http://www.jug-muenster.de/wp-content/uploads/2010/01/ishot-11.png" border="0" alt="ishot-1.png" width="140" height="225" align="right" /></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td><strong>Step 2. </strong></p>
<p>Draw a rounded rectangle that will represent the bottom if the tube.</td>
<td><img src="http://www.jug-muenster.de/wp-content/uploads/2010/01/ishot-21.png" border="0" alt="ishot-2.png" width="140" height="225" align="right" /></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td><strong>Step 3.</strong></p>
<p>Merge this two shapes into one shape.</td>
<td><img src="http://www.jug-muenster.de/wp-content/uploads/2010/01/ishot-3.png" border="0" alt="ishot-3.png" width="140" height="225" align="right" /></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td><strong>Step 4.</strong></p>
<p>Now draw a little ellipse on top of the tube.</td>
<td><img src="http://www.jug-muenster.de/wp-content/uploads/2010/01/ishot-4.png" border="0" alt="ishot-4.png" width="140" height="225" align="right" /></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td><strong>Step 5.</strong></p>
<p>Again merge the two shapes into one.</td>
<td><img src="http://www.jug-muenster.de/wp-content/uploads/2010/01/ishot-5.png" border="0" alt="ishot-5.png" width="140" height="225" align="right" /></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td><strong>Step 6.</strong></p>
<p>Fill the tube with a horizontal gradient from left to right where you use black with different values for transparency.</p>
<table>
<tbody>
<tr>
<th> Position</th>
<th> Transparency</th>
</tr>
<tr>
<td>0%</td>
<td>60%</td>
</tr>
<tr>
<td>15%</td>
<td>20%</td>
</tr>
<tr>
<td>75%</td>
<td>20%</td>
</tr>
<tr>
<td>100%</td>
<td>60%</td>
</tr>
</tbody>
</table>
</td>
<td><img src="http://www.jug-muenster.de/wp-content/uploads/2010/01/ishot-61.png" border="0" alt="ishot-6.png" width="140" height="225" align="right" /><br />
<img src="http://www.jug-muenster.de/wp-content/uploads/2010/01/ishot-7.png" border="0" alt="ishot-7.png" width="120" height="80" align="right" /></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td><strong>Step 7.</strong></p>
<p>Now fill the same tube shape again with a vertical gradient from top to bottom again using black with different values for transparency.</p>
<table>
<tbody>
<tr>
<th> Position</th>
<th> Transparency</th>
</tr>
<tr>
<td>0%</td>
<td>0%</td>
</tr>
<tr>
<td>90%</td>
<td>0%</td>
</tr>
<tr>
<td>100%</td>
<td>60%</td>
</tr>
</tbody>
</table>
</td>
<td><img src="http://www.jug-muenster.de/wp-content/uploads/2010/01/ishot-10.png" border="0" alt="ishot-10.png" width="140" height="225" align="right" /><br />
<img src="http://www.jug-muenster.de/wp-content/uploads/2010/01/ishot-9.png" border="0" alt="ishot-9.png" width="120" height="80" align="right" /></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td><strong>Step 8.</strong></p>
<p>Now we will add some reflection effects. First of all a side light reflection. Therefor create a vertical rounded rectangle. Than create a second rounded rectangle which is slightly higher than the first one and place it a little bit shifted to the right of the first one.</td>
<td><img src="http://www.jug-muenster.de/wp-content/uploads/2010/01/ishot-111.png" border="0" alt="ishot-11.png" width="140" height="225" align="right" /></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td><strong>Step 9.</strong></p>
<p>Subtract the second rectangle from the first one.</td>
<td><img src="http://www.jug-muenster.de/wp-content/uploads/2010/01/ishot-12.png" border="0" alt="ishot-12.png" width="140" height="225" align="right" /></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td><strong>Step 10.</strong></p>
<p>Now fill this shape with a horizontal gradient from left to right with white of with different values for transparency.</p>
<table>
<tbody>
<tr>
<th> Position</th>
<th> Transparency</th>
</tr>
<tr>
<td>0%</td>
<td>60%</td>
</tr>
<tr>
<td>100%</td>
<td>0%</td>
</tr>
</tbody>
</table>
</td>
<td><img src="http://www.jug-muenster.de/wp-content/uploads/2010/01/ishot-14.png" border="0" alt="ishot-14.png" width="140" height="225" align="right" /><br />
<img src="http://www.jug-muenster.de/wp-content/uploads/2010/01/ishot-13.png" border="0" alt="ishot-13.png" width="120" height="80" align="right" /></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td><strong>Step 11.</strong></p>
<p>Create a ellipse on top of the tube which will be the top light reflection.</td>
<td><img src="http://www.jug-muenster.de/wp-content/uploads/2010/01/ishot-15.png" border="0" alt="ishot-15.png" width="140" height="225" align="right" /></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td><strong>Step 12.</strong></p>
<p>Fill this ellipse with a vertical gradient from top to bottom with white with different values for transparency.</p>
<table>
<tbody>
<tr>
<th> Position</th>
<th> Transparency</th>
</tr>
<tr>
<td>0%</td>
<td>60%</td>
</tr>
<tr>
<td>100%</td>
<td>0%</td>
</tr>
</tbody>
</table>
</td>
<td><img src="http://www.jug-muenster.de/wp-content/uploads/2010/01/ishot-17.png" border="0" alt="ishot-17.png" width="140" height="225" align="right" /><br />
<img src="http://www.jug-muenster.de/wp-content/uploads/2010/01/ishot-16.png" border="0" alt="ishot-16.png" width="120" height="80" align="right" /></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td><strong>Step 13.</strong></p>
<p>Next add a small ellipse on the very top of the tube.</td>
<td><img src="http://www.jug-muenster.de/wp-content/uploads/2010/01/ishot-18.png" border="0" alt="ishot-18.png" width="140" height="225" align="right" /></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td><strong>Step 14.</strong></p>
<p>Fill this ellipse also with a vertical gradient from top to bottom with white with different values for transparency.</p>
<table>
<tbody>
<tr>
<th> Position</th>
<th> Transparency</th>
</tr>
<tr>
<td>0%</td>
<td>60%</td>
</tr>
<tr>
<td>100%</td>
<td>0%</td>
</tr>
</tbody>
</table>
</td>
<td><img src="http://www.jug-muenster.de/wp-content/uploads/2010/01/ishot-19.png" border="0" alt="ishot-19.png" width="140" height="225" align="right" /></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td><strong>Step 15.</strong></p>
<p>Finally create a small horizontal rectangle on the top of the tube.</td>
<td><img src="http://www.jug-muenster.de/wp-content/uploads/2010/01/ishot-20.png" border="0" alt="ishot-20.png" width="140" height="225" align="right" /></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td><strong>Step 16.</strong></p>
<p>Fill this rectangle with a horizontal gradient from left to right with different values for transparency</p>
<table>
<tbody>
<tr>
<th> Position</th>
<th> Transparency</th>
</tr>
<tr>
<td>0%</td>
<td>0%</td>
</tr>
<tr>
<td>50%</td>
<td>60%</td>
</tr>
<tr>
<td>100%</td>
<td>0%</td>
</tr>
</tbody>
</table>
</td>
<td><img src="http://www.jug-muenster.de/wp-content/uploads/2010/01/ishot-22.png" border="0" alt="ishot-22.png" width="140" height="225" align="right" /><br />
<img src="http://www.jug-muenster.de/wp-content/uploads/2010/01/ishot-211.png" border="0" alt="ishot-21.png" width="120" height="80" align="right" /></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td>That&#8217;s it&#8230; so we created a nice looking glass tube just with combination of some shapes and gradients.</p>
<p>In the second part of the tutorial i&#8217;ll explain the representation of all these shapes and gradients in code&#8230;so hang on&#8230;</td>
<td><img src="http://www.jug-muenster.de/wp-content/uploads/2010/01/ishot-23.png" border="0" alt="ishot-23.png" width="92" height="150" align="right" /></td>
</tr>
</tbody>
</table>
<p>Part two: <a href="http://www.jug-muenster.de/drawing-in-code-part-2-2-384/">http://www.jug-muenster.de/drawing-in-code-part-2-2-384/</a></p>
<div style="clear:both;">&nbsp;</div>

<p>Weitere Artikel:<ol><li><a href='http://www.jug-muenster.de/drawing-in-code-part-2-2-384/' rel='bookmark' title='Permanent Link: Drawing in code (Part 2)'>Drawing in code (Part 2)</a></li>
<li><a href='http://www.jug-muenster.de/java2d-conical-gradient-paint-674/' rel='bookmark' title='Permanent Link: Java2D Conical Gradient Paint'>Java2D Conical Gradient Paint</a></li>
<li><a href='http://www.jug-muenster.de/swing-worldclock-427/' rel='bookmark' title='Permanent Link: Swing Worldclock'>Swing Worldclock</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jug-muenster.de/drawing-in-code-part-1-379/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
