<?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; Contributed</title>
	<atom:link href="http://www.jug-muenster.de/category/contributed/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>Sat, 04 Feb 2012 16:42:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com" />
	<atom:link rel="hub" href="http://superfeedr.com/hubbub" />
			<item>
		<title>Java Testing best practice: Projekt Organisation</title>
		<link>http://www.jug-muenster.de/java-testing-best-practice-projekt-organisation-941/</link>
		<comments>http://www.jug-muenster.de/java-testing-best-practice-projekt-organisation-941/#comments</comments>
		<pubDate>Fri, 21 Jan 2011 15:43:20 +0000</pubDate>
		<dc:creator>Thomas</dc:creator>
				<category><![CDATA[Contributed]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[junit]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[netbeans]]></category>

		<guid isPermaLink="false">http://www.jug-muenster.de/?p=941</guid>
		<description><![CDATA[Im folgenden wird beschrieben, wie man sein Projekt so strukturieren kann, dass auf der einen Seite das Testen erleichtert wird, auf der anderen Seite die Tests vom produktiven Java Quellcode separiert werden. Das erleichtert zum Beispiel die Paketierung zur Auslieferung an Kunden, die lediglich den produktiven Quellcode erhalten sollen. Bei einigen Entwicklungsumgebungen, wie z.B. Netbeans, [...]
Weitere Artikel:<ol>
<li><a href='http://www.jug-muenster.de/swingdemo-projekt-175/' rel='bookmark' title='SwingDemo Projekt'>SwingDemo Projekt</a></li>
<li><a href='http://www.jug-muenster.de/modular-java-238/' rel='bookmark' title='Modular Java (Buch)'>Modular Java (Buch)</a></li>
<li><a href='http://www.jug-muenster.de/java-ee-summit-berlin-1176/' rel='bookmark' title='Java EE Summit Berlin'>Java EE Summit Berlin</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><!--S-ButtonZ 1.1.5 End--><p>Im folgenden wird beschrieben, wie man sein Projekt so strukturieren kann, dass auf der einen Seite das Testen erleichtert wird, auf der anderen Seite die Tests vom produktiven Java Quellcode separiert werden. Das erleichtert zum Beispiel die Paketierung zur Auslieferung an Kunden, die lediglich den produktiven Quellcode erhalten sollen.</p>
<p>Bei einigen Entwicklungsumgebungen, wie z.B. Netbeans, ist bereits bei einem leeren Java Projekt eine Separierung von Test Quellcode und Java Quellcode vorgesehen: Es gibt einen Ordner für &#8220;Test Packages&#8221; und einen für &#8220;Source Packages&#8221;. Im Dateisystem werden diese auf die Ordner &#8220;src&#8221; und &#8220;test&#8221; entsprechend abgebildet. Bei der Tastenausführung werden aus beiden Verzeichnissen die Quellen übersetzt und die Ergebnisse zusammen geführt. Bei dem von Netbeans standardmäßig erstellten Buildfile kann man auch von der Kommandozeile mittels &#8220;ant test&#8221; die Tests ausführen, bei &#8220;ant jar&#8221; wird eine JAR Datei (im &#8220;dist&#8221; Verzeichnis) erstellt, die lediglich den produktiven Code enthält.<span id="more-941"></span><a href="http://www.jug-muenster.de/wp-content/uploads/2011/01/netbeans-struktur.png" rel="lightbox[941]"><img class="alignnone size-medium wp-image-942" title="netbeans-struktur" src="http://www.jug-muenster.de/wp-content/uploads/2011/01/netbeans-struktur-300x185.png" alt="" width="300" height="185" /></a></p>
<p>Durch das ant Buildfile und die Projektstruktur ist damit ein Netbeans Projekt von Haus aus direkt für eine Continuos Integration Umgebung optimal vorbereitet.</p>
<p>Eclipse ist noch nicht ganz soweit, jedoch sollte man seine Projektstruktur auch hier so aufbauen: Der Code ist klar getrennt, verwendet man eine parallele Paket Struktur, können auch Methoden die &#8220;protected&#8221; oder &#8220;default&#8221; Sichtbarkeit haben, einfach getestet werden. So vermeidet man zu grob geschnittene Tests (nur &#8220;public&#8221; Methoden testen) bzw. unnötige Erweiterung der Sichtbarkeit, in dem man Methoden &#8220;public&#8221; macht, nur um sie testen zu können.</p>
<p>Das ganze ist sehr einfach: Startet man ein neues Projekt, so kann man bei der Einrichtung direkt ueber &#8220;create new source folder&#8221; neben &#8220;src&#8221; einen &#8220;test&#8221; Source-Folder anlegen.</p>
<p><a href="http://www.jug-muenster.de/wp-content/uploads/2011/01/eclipse-test-source-folder.png" rel="lightbox[941]"><img class="alignnone size-medium wp-image-943" title="eclipse-test-source-folder" src="http://www.jug-muenster.de/wp-content/uploads/2011/01/eclipse-test-source-folder-217x300.png" alt="" width="217" height="300" /></a></p>
<p>Eclipse fügt dann entsprechend alle übersetzten Class Dateien, in diesem Fall &#8220;Sample&#8221; aus den produktiven Sourcen und &#8220;SampleTest&#8221; aus den Test Quellen im &#8220;bin&#8221; Verzeichnis zusammen:</p>
<p><a href="http://www.jug-muenster.de/wp-content/uploads/2011/01/kompilierte-klassen.png" rel="lightbox[941]"><img class="alignnone size-full wp-image-944" title="kompilierte-klassen" src="http://www.jug-muenster.de/wp-content/uploads/2011/01/kompilierte-klassen.png" alt="" width="289" height="165" /></a></p>
<p>Bei Eclipse muss man sich noch selber um ein Build-System kümmern, wenn man von der IDE unabhängig bauen möchte &#8211; und das möchte man. Immer.</p>
<p>Hier bietet sich z.B. &#8220;Maven&#8221; an, welches für einfache Projekte auch schnell einzurichten ist. Alternativ kann man auch ant oder das neue Gradle benutzen. Übrigens: Möchte man von Anfang an seine Projektstruktur bereits entlang der Maven Konventionen aufbauen, sollte man seine produktiven Sourcen unter &#8220;src/main/java&#8221; und seine Test Klassen unter &#8220;src/test/java&#8221; anlegen. Setzt man kein Maven ein, macht das keinen großen Unterschied, da die IDE-Ansicht sich nicht unterscheidet. Moechte man jedoch auf Maven später umstellen, spart man sich etwas Arbeit und hat sich bereits an die Konventionen gewöhnt.</p>
<div style="clear:both;">&nbsp;</div><p>Weitere Artikel:<ol>
<li><a href='http://www.jug-muenster.de/swingdemo-projekt-175/' rel='bookmark' title='SwingDemo Projekt'>SwingDemo Projekt</a></li>
<li><a href='http://www.jug-muenster.de/modular-java-238/' rel='bookmark' title='Modular Java (Buch)'>Modular Java (Buch)</a></li>
<li><a href='http://www.jug-muenster.de/java-ee-summit-berlin-1176/' rel='bookmark' title='Java EE Summit Berlin'>Java EE Summit Berlin</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jug-muenster.de/java-testing-best-practice-projekt-organisation-941/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JPA Einführung: Entity Klassen</title>
		<link>http://www.jug-muenster.de/jpa-einfuhrung-entity-klassen-833/</link>
		<comments>http://www.jug-muenster.de/jpa-einfuhrung-entity-klassen-833/#comments</comments>
		<pubDate>Thu, 04 Nov 2010 14:27:07 +0000</pubDate>
		<dc:creator>Thomas</dc:creator>
				<category><![CDATA[Contributed]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[jpa]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.jug-muenster.de/?p=833</guid>
		<description><![CDATA[Nachdem im ersten Teil der JPA Einführung die Infrastruktur für die Arbeit mit JPA fertig gestellt wurde, kommen wir nun zu den Entitätsklassen. Bei den Entities handelt es sich um ganz normale Java Klassen (POJOs), die kein spezielles Interface implementieren oder von einer vorgegebenen Oberklasse erben müssen. Lediglich ein default Konstruktor muss vorhanden sein. Dank [...]
Weitere Artikel:<ol>
<li><a href='http://www.jug-muenster.de/jpa-tutorial-jpa-einrichtung-829/' rel='bookmark' title='JPA Tutorial: JPA Einrichtung'>JPA Tutorial: JPA Einrichtung</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><!--S-ButtonZ 1.1.5 End--><p>Nachdem <a href="http://www.jug-muenster.de/jpa-tutorial-jpa-einrichtung-829/" target="_blank">im ersten Teil</a> der JPA Einführung die Infrastruktur für die Arbeit mit JPA fertig gestellt wurde, kommen wir nun zu den Entitätsklassen. Bei den Entities handelt es sich um ganz normale Java Klassen (POJOs), die kein spezielles Interface implementieren oder von einer vorgegebenen Oberklasse erben müssen. Lediglich ein default Konstruktor muss vorhanden sein.<br />
Dank JPA Annotationen kann man erkennen, dass die Objekte persistiert werden.<br />
Möchte man EJB3 konform arbeiten, so sollten die Annotationen dort angebracht werden, wo auf die Properties zugegriffen wird: An den Attributen für field-access, an den Getter-Methoden bei property-access. Dies sollte konsistent gemacht werden, und die beiden Formen sollten nicht gemischt werden. (Zwischen den beiden Formen wird über die Position der @Id Annotation unterschieden.)<br />
Die Annotation der Attribute hat dabei den Vorteil, dass schnell erkennbar ist, was wie persistiert wird &#8211; kann jedoch bei einigen JPA Providern zu Performance Problemen führen. Auf der anderen Seite führen Getter-Methoden, die nicht zu persistierende Werte liefern und nicht explizit von der Persistierung ausgenommen werden zu möglicherweise schwer zu findenden Programmfehlern.<span id="more-833"></span></p>
<h2>Ein Beispiel für eine einfache Entitätsklasse</h2>
<p><code> @Entity<br />
public class Person {<br />
@Id<br />
@GeneratedValue<br />
private Long id;<br />
private String vorname;<br />
private String nachname;<br />
// default constructor<br />
public Person () {<br />
}<br />
// getter + setter<br />
}</code></p>
<p>Die <em>@Entity</em> Annotation macht kenntlich, dass diese Klasse von JPA persistiert werden soll, @Id kennzeichnet den Primärschluessel und @GeneratedValue bedeutet, dass dieser automatisch generiert werden soll (also ein synthetischer Primärschlüssel).<br />
Mit diesen wenigen Angaben ist bereits erreicht, dass Objekte der Person Klasse persistiert werden können &#8211; lediglich die Konfiguration der Datenbank für JPA fehlt noch. Die genaue Steuerung in welche Tabellen/Spalten die Speicherung in der Datenbank erfolgt ist optional, und wird ohne zusätzliche Konfiguration mit Default-Werten realisiert.</p>
<h2>JPA <em>persistence.xml</em> Konfiguration</h2>
<p>In der Datei &#8220;persistence.xml&#8221; (normalerweise im META-INF Verzeichnis) befindet sich die Datenbankkonfiguration fuer den JPA Provider.<br />
Ein verkürztes Beispiel passende zu der Beispiel-Entität von oben:<br />
<code>&lt;persistence xmln="http://java.sun.com/xml/ns/persistence" ... &gt;<br />
&lt;persistence-unit name="addressbook"&gt;<br />
&lt;class&gt;com.example.domain.Person&lt;/class&gt;<br />
&lt;properties&gt;<br />
&lt;property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver" /&gt;<br />
...<br />
&lt;/properties&gt;<br />
&lt;/persistence-unit&gt;<br />
&lt;/persistence&gt;</code><br />
Zuerst erfolgt die Angabe des symbolischen Namens unter welchem diese Konfiguration verfügbar gemacht wird, dann folgt welche Klasse(n) zu persistieren sind (falls diese nicht per @Entity bereits deklariert sind, je nach JPA Provider reicht die @Entity Annotation nicht aus) und schließlich die Konfiguration der Datenbankverbindung ueber den JPA Provider Hibernate.<br />
Theoretisch sind verschiedene Persistence-Units möglich, ebenso kann über <em>&lt;provider&gt;</em> explizit der JPA Provider konfiguriert werden. In der Praxis findet sich jedoch für eine Anwendung in der Regel eine Persistence Unit und lediglich eine JPA Implementierung, die dann auch standardmäßig verwendet wird.<br />
Die Properties des JPA Providers sind dabei spezifisch für den jeweiligen Provider &#8211; in diesem Fall Hibernate.</p>
<h2>Objekt mittels JPA speichern</h2>
<p>Nun fehlt nur noch, dass ein Entity Object mittels JPA auch gespeichert wird. Nachdem die Vorarbeiten erledigt sind, zeigt sich schnell wie einfach die Arbeit Objekte zu speichern und zu laden dank JPA wird:<br />
<code>EntityManagerFactory emf =<br />
Persistence.createEntityManagerFactory("addressbook" ); //der symbolische Name<br />
EntityManager em = emf .createEntityManager();<br />
EntityTransaction tx = em.getTransaction();<br />
tx.begin ()<br />
Person p = new Person ();<br />
...<br />
em.persist(p);<br />
tx.commit();<br />
em.close();</code><br />
Im nächsten Teil folgt dann wie Objekte aus der Datenbank geladen, geändert und auch gelöscht werden können.</p>
<div style="clear:both;">&nbsp;</div><p>Weitere Artikel:<ol>
<li><a href='http://www.jug-muenster.de/jpa-tutorial-jpa-einrichtung-829/' rel='bookmark' title='JPA Tutorial: JPA Einrichtung'>JPA Tutorial: JPA Einrichtung</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jug-muenster.de/jpa-einfuhrung-entity-klassen-833/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spring Integration 2:RC1</title>
		<link>http://www.jug-muenster.de/spring-integration-2rc1-843/</link>
		<comments>http://www.jug-muenster.de/spring-integration-2rc1-843/#comments</comments>
		<pubDate>Wed, 03 Nov 2010 15:02:59 +0000</pubDate>
		<dc:creator>Thomas</dc:creator>
				<category><![CDATA[Contributed]]></category>
		<category><![CDATA[eai]]></category>
		<category><![CDATA[jms]]></category>
		<category><![CDATA[messaging]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[spring integration]]></category>

		<guid isPermaLink="false">http://www.jug-muenster.de/?p=843</guid>
		<description><![CDATA[Von der Firma SpringSource wurde jetzt &#8220;Spring Integration 2&#8243; als Release Candidate 1 veröffentlicht. Spring Integration ist eine auf dem Spring Framework aufbauendes Framework das Enterprise Application Integration und die EAI Patterns von Hohpe und Woolf umsetzt. Dabei unterstützt Spring Integration Messaging innerhalb von Spring Anwendungen und ermöglicht so einen modularen und lose gekoppelten Aufbau [...]
Weitere Artikel:<ol>
<li><a href='http://www.jug-muenster.de/kritische-sicherheitslucke-im-spring-framework-616/' rel='bookmark' title='Kritische Sicherheitslücke im Spring Framework'>Kritische Sicherheitslücke im Spring Framework</a></li>
<li><a href='http://www.jug-muenster.de/modular-java-238/' rel='bookmark' title='Modular Java (Buch)'>Modular Java (Buch)</a></li>
<li><a href='http://www.jug-muenster.de/java-testing-best-practice-projekt-organisation-941/' rel='bookmark' title='Java Testing best practice: Projekt Organisation'>Java Testing best practice: Projekt Organisation</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><!--S-ButtonZ 1.1.5 End--><p>Von der Firma SpringSource wurde jetzt &#8220;Spring Integration 2&#8243; als Release Candidate 1 veröffentlicht. Spring Integration ist eine auf dem Spring Framework aufbauendes Framework das Enterprise Application Integration und die EAI Patterns von Hohpe und Woolf umsetzt. Dabei unterstützt Spring Integration Messaging innerhalb von Spring Anwendungen und ermöglicht so einen modularen und lose gekoppelten Aufbau der Anwendung, externe Systeme können jedoch deklarativ zusätzlich angebunden werden.</p>
<p>Spring Integration 2 bringt bereits Adapter für die Anbindung von verschiedenen Systemen wie Messaging (JMS, XMPP), FTP, Mail, Webservices und auch spezielle Dienste wie Twitter mit. Neu ist in der Version 2 von Spring Integration dass die Spring Expression Language verwendet werden kann, und in der Eclipse basierten Spring Source Toolsuite (STS) ein grafischer Editor für die Modellierung der  Spring Integration Realisierung vorhanden ist.<span id="more-843"></span><br />
<a href="http://www.jug-muenster.de/wp-content/uploads/2010/11/si-sts-editor.png" rel="lightbox[843]"><img class="alignnone size-medium wp-image-844" title="si-sts-editor" src="http://www.jug-muenster.de/wp-content/uploads/2010/11/si-sts-editor-300x212.png" alt="" width="300" height="212" /></a></p>
<p>Spring Integration steht unter  der Apache 2 Lizenz und eignet sich somit für die Entwicklung kommerzieller Programme. Alle Neuigkeiten von Spring Integration 2 finden sich auch in dem <a href="http://blog.springsource.com/2010/10/29/spring-integration-2-0-release-candidate-1/" target="_blank">Blogpost</a> von SpringSource.</p>
<p>Hier gibt es ein paar Slides zu dem Vortrag zu Spring Integration auf dem SoftwareFreedomDay 2010 der JUG Muenster: <a href="http://www.jug-muenster.de/wp-content/uploads/2010/09/100911-spring-integration.pdf" target="_blank">Spring Integration Vortrag</a>.</p>
<div style="clear:both;">&nbsp;</div><p>Weitere Artikel:<ol>
<li><a href='http://www.jug-muenster.de/kritische-sicherheitslucke-im-spring-framework-616/' rel='bookmark' title='Kritische Sicherheitslücke im Spring Framework'>Kritische Sicherheitslücke im Spring Framework</a></li>
<li><a href='http://www.jug-muenster.de/modular-java-238/' rel='bookmark' title='Modular Java (Buch)'>Modular Java (Buch)</a></li>
<li><a href='http://www.jug-muenster.de/java-testing-best-practice-projekt-organisation-941/' rel='bookmark' title='Java Testing best practice: Projekt Organisation'>Java Testing best practice: Projekt Organisation</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jug-muenster.de/spring-integration-2rc1-843/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JPA Tutorial: JPA Einrichtung</title>
		<link>http://www.jug-muenster.de/jpa-tutorial-jpa-einrichtung-829/</link>
		<comments>http://www.jug-muenster.de/jpa-tutorial-jpa-einrichtung-829/#comments</comments>
		<pubDate>Sun, 31 Oct 2010 18:40:27 +0000</pubDate>
		<dc:creator>Thomas</dc:creator>
				<category><![CDATA[Contributed]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[jpa]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.jug-muenster.de/?p=829</guid>
		<description><![CDATA[JPA, die Java Persistence API bietet im Vergleich zu JDBC ein erhöhtes Abstraktionsniveau und ermöglicht damit in kurzer Zeit Anwendungen zu entwickeln, in denen Daten dauerhaft gespeichert werden müssen. Zum Hintergrund von JPA: Bei dem Umgang mit Datenbanken gibt es schon sehr lange JDBC (Java Database connectivity) als einheitliche API um die Verbindung zu Datenbanken [...]
Weitere Artikel:<ol>
<li><a href='http://www.jug-muenster.de/jpa-einfuhrung-entity-klassen-833/' rel='bookmark' title='JPA Einführung: Entity Klassen'>JPA Einführung: Entity Klassen</a></li>
<li><a href='http://www.jug-muenster.de/java-testing-best-practice-projekt-organisation-941/' rel='bookmark' title='Java Testing best practice: Projekt Organisation'>Java Testing best practice: Projekt Organisation</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><!--S-ButtonZ 1.1.5 End--><p>JPA, die Java Persistence API bietet im Vergleich zu JDBC ein erhöhtes Abstraktionsniveau und ermöglicht damit in kurzer Zeit Anwendungen zu entwickeln, in denen Daten dauerhaft gespeichert werden müssen.<br />
Zum Hintergrund von JPA: Bei dem Umgang mit Datenbanken gibt es schon sehr lange JDBC (Java Database connectivity) als einheitliche API um die Verbindung zu Datenbanken herzustellen. Auch hier handelt es sich bereits um eine einheitliche Schnittstelle, jedoch wird darüber lediglich festgelegt, wie Verbindungen aufgebaut werden, wie eine Abfrage eingeleitet wird und wie Transaktionen manuell gesteuert werden können.<br />
Damit bleiben zwei Probleme: Der SQL Code muss von Hand erstellt werden, was gerade bei CRUD (Create, Update, Delete) Anwendungen viel Produktivität kostet, und zudem ist der SQL Code in der Regel herstellerabhängig. Ein Wechsel von Oracle zu Postgres bedeutet damit das Programm an vielen Stellen ändern zu müssen. Auch sind händisch erstellte Abfragen nicht immer optimal: Lazy loading von Entitäten, Caching Strategien und Transaktionssteuerung können sehr aufwendig werden. Dazu gesellen sich der relativ hohe Wartungsaufwand und die Gefahr von Fehlern die erst zur Laufzeit entdeckt werden.<span id="more-829"></span>Das Beispielprojekt wird ein einfaches Adressbuch, dabei werden Personen und ihre zugehörigen Adressen gespeichert. Im ersten Teil beschäftigen wir uns damit die Projektstruktur einzurichten, und die nötigen Bibliotheken zu installieren.</p>
<h2>Dependencies</h2>
<p>JPA selber ist lediglich eine API &#8211; diese wird durch einen sogenannten JPA Provider implementiert. Hibernate, OpenJPA und EclipseLink (bzw. Oracle Toplink) sind Beispiele fuer JPA Provider, die als OpenSource zur Verfuegung stehen und auch kommerziell verwendet werden koennen.<br />
Am einfachsten lassen sich diese Abhaengigkeiten durch Maven erfuellen, Maven kuemmert sich dabei um Download der direkten und indirekten (transistiven) Dependencies. Fuer diejenigen, die bereits Maven Erfahrung haben und Maven mit JPA nutzen moechten, hier ein Beispiel (weiter unten findet sich ein fertiges Eclipse Projekt ohne Maven zum Download) fuer Hibernate als JPA Provider (und SLF4J zum Loggen):<br />
<code>&lt;dependencies&gt;<br />
&lt;dependency&gt;<br />
&lt;groupId&gt;org.hibernate&lt;/groupId&gt;<br />
&lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;<br />
&lt;version&gt;3.3.2.GA&lt;/version&gt;<br />
&lt;/dependency&gt;<br />
&lt;dependency&gt;<br />
&lt;groupId&gt;org.hibernate&lt;/groupId&gt;<br />
&lt;artifactId&gt;hibernate-annotations&lt;/artifactId&gt;<br />
&lt;version&gt;3.4.0.GA&lt;/version&gt;<br />
&lt;/dependency&gt;<br />
&lt;dependency&gt;<br />
&lt;groupId&gt;org.hibernate&lt;/groupId&gt;<br />
&lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;<br />
&lt;version&gt;3.4.0.GA&lt;/version&gt;<br />
&lt;/dependency&gt;<br />
&lt;dependency&gt;<br />
&lt;groupId&gt;org.hibernate&lt;/groupId&gt;<br />
&lt;artifactId&gt;hibernate-c3p0&lt;/artifactId&gt;<br />
&lt;version&gt;3.3.2.GA&lt;/version&gt;<br />
&lt;/dependency&gt;<br />
&lt;dependency&gt;<br />
&lt;groupId&gt;org.hibernate&lt;/groupId&gt;<br />
&lt;artifactId&gt;hibernate-ehcache&lt;/artifactId&gt;<br />
&lt;version&gt;3.3.2.GA&lt;/version&gt;<br />
&lt;/dependency&gt;<br />
&lt;dependency&gt;<br />
&lt;groupId&gt;org.slf4j&lt;/groupId&gt;<br />
&lt;artifactId&gt;slf4j-simple&lt;/artifactId&gt;<br />
&lt;version&gt;1.5.8&lt;/version&gt;<br />
&lt;/dependency&gt;<br />
&lt;dependency&gt;<br />
&lt;groupId&gt;org.hsqldb&lt;/groupId&gt;<br />
&lt;artifactId&gt;hsqldb&lt;/artifactId&gt;<br />
&lt;version&gt;1.8.0.10&lt;/version&gt;<br />
&lt;/dependency&gt;<br />
&lt;/dependencies&gt;</code></p>
<h2>Manuelle Einrichtung</h2>
<p>Hier eine Liste der nötigen Bibliotheken, für diejenigen, die von Hand (beinhaltet alle transitiven Abhängigkeiten) das Projekt konfigurieren möchten:</p>
<ul>
<li>antlr-2.7.6.jar</li>
<li>c3p0-0.9.1.jar</li>
<li>commons-collections-3.1.jar</li>
<li>commons-logging-1.0.4.jar</li>
<li>dom4j-1.6.1.jar</li>
<li>ehcache-1.2.3.jar</li>
<li>ejb3-persistence-1.0.2.GA.jar</li>
<li>hibernate-annotations-3.4.0.GA.jar</li>
<li>hibernate-c3p0-3.3.2.GA.jar</li>
<li>hibernate-commons-annotations-3.1.0.GA.jar</li>
<li>hibernate-core-3.3.2.GA.jar</li>
<li>hibernate-ehcache-3.3.2.GA.jar</li>
<li>hibernate-entitymanager-3.4.0.GA.jar</li>
<li>hsqldb-1.8.0.10.jar</li>
<li>javassist-3.4.GA.jar</li>
<li>jta-1.1.jar</li>
<li>slf4j-api-1.5.8.jar</li>
<li>slf4j-simple-1.5.8.jar</li>
<li>xml-apis-1.0.b2.jar</li>
</ul>
<p>Diese JAR Dateien werden in den Classpath gelegt, normalerweise in einen &#8220;lib&#8221; Ordner, und anschließend wird der Classpath entsprechend konfiguriert. (In Eclipse über Rechtsklick auf das Projekt &#8220;Properties&#8221; im Menü auswählen, dann &#8220;Java Build Path&#8221; und dort mittels &#8220;Add JARs&#8221; die entsprechenden Dateien hinzufügen.)</p>
<h2>JPA Projekt Download</h2>
<p>Der Download als fertiges Eclipse Projekt (hier: <a href="http://www.jug-muenster.de/wp-content/uploads/2010/10/jpa-tutorial.zip">Eclipse JPA Project</a>) beinhaltet die nötigen JAR Dateien im &#8220;lib&#8221; Ordner, ist bereits entsprechend konfiguriert und benötigt kein Maven oder andere externe Tools.  (Die Ordnerstruktur verwendet jedoch die Maven Verzeichnisstruktur, was jedoch keine große Umstellung bedeuten sollte.)</p>
<p>Für dies Beispiel wird hsql als Datenbank verwendet, und dabei separat gestartet. Je nach Anwendung (Desktop oder Server) würde man in der Regel eine eingebettete Datenbank (Swing/Desktop Anwendung) oder eine externe Datenbank (Java Enterprise Application) verwenden. Hsql bietet den Betrieb als Embedded- und Standalone-Datenkbank an, dabei ist die JAR Datei mit rund 700kb relativ schlank und kann somit sehr gut für dieses Tutorial eingesetzt werden.</p>
<p>Um HSQL zu konfigurieren gibt es die Datei &#8220;server.properties&#8221;, die eine Datenbank konfiguriert, die in dem Ordner &#8220;db&#8221; abgelegt wird, &#8220;addressbook&#8221; heisst und auch als &#8220;addressbook&#8221; angesprochen wird.<br />
Server properties:<code><br />
server.database.0=db/addressbook<br />
server.dbname.0=addressbook</code></p>
<p>Von der Kommandozeile startet man den HSQL Server dann aus dem Projekt Verzeichnis in dem sich der &#8220;db&#8221; Ordner, der &#8220;lib&#8221; Ordner mit der hsqldb JAR Datei  und die &#8220;server.properties&#8221; Datei befindet:<br />
<code>java -cp lib/hsqldb-1.8.0.10.jar org.hsqldb.Server</code></p>
<p>Damit ist die Vorbereitung der serverseitigen JPA Infrastruktur abgeschlossen, die nächsten Schritte beinhalten die Einrichtung von JPA Provider, Verbindung zur Datenbank und welche Java Klassen wie auf die Datenbank abgebildet werden sollen.<br />
(Zum besseren Vergleich zwischen Hibernate und JPA beinhaltet das Beispielprojekt auch die entsprechende native Hibernate Konfiguration und die Hibernate API Aufrufe in separaten Klassen. Mehr dazu in den folgenden Artikeln.)</p>
<div style="clear:both;">&nbsp;</div><p>Weitere Artikel:<ol>
<li><a href='http://www.jug-muenster.de/jpa-einfuhrung-entity-klassen-833/' rel='bookmark' title='JPA Einführung: Entity Klassen'>JPA Einführung: Entity Klassen</a></li>
<li><a href='http://www.jug-muenster.de/java-testing-best-practice-projekt-organisation-941/' rel='bookmark' title='Java Testing best practice: Projekt Organisation'>Java Testing best practice: Projekt Organisation</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jug-muenster.de/jpa-tutorial-jpa-einrichtung-829/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Versioning and signing jar files in Netbeans</title>
		<link>http://www.jug-muenster.de/versioning-and-signing-jar-files-in-netbeans-775/</link>
		<comments>http://www.jug-muenster.de/versioning-and-signing-jar-files-in-netbeans-775/#comments</comments>
		<pubDate>Fri, 01 Oct 2010 06:54:43 +0000</pubDate>
		<dc:creator>Gerrit</dc:creator>
				<category><![CDATA[Contributed]]></category>

		<guid isPermaLink="false">http://www.jug-muenster.de/?p=775</guid>
		<description><![CDATA[﻿Hi again, these days i&#8217;ve got the problem that i need to add a version number to the SteelSeries java component library and to be honest i had no idea how to realize it. So after a short internet research i figured out that there is the ability to add version information to the manifest [...]
Weitere Artikel:<ol>
<li><a href='http://www.jug-muenster.de/using-smack-xmpp-lib-on-android-with-netbeans-573/' rel='bookmark' title='Using Smack xmpp lib on Android with Netbeans'>Using Smack xmpp lib on Android with Netbeans</a></li>
<li><a href='http://www.jug-muenster.de/netbeans-platform-certified-training-1138/' rel='bookmark' title='Netbeans Platform certified Training'>Netbeans Platform certified Training</a></li>
<li><a href='http://www.jug-muenster.de/swing-weather-worldclock-490/' rel='bookmark' title='Swing Weather Worldclock'>Swing Weather Worldclock</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><!--S-ButtonZ 1.1.5 End--><p>﻿Hi again,</p>
<p>these days i&#8217;ve got the problem that i need to add a version number to the <a href="http://www.harmonic-code.org">SteelSeries</a> java component library and to be honest i had no idea how to realize it.</p>
<p>So after a short internet research i figured out that there is the ability to add version information to the manifest file that&#8217;s included in a jar file.</p>
<p>If you do not know what a manifest is or how it is embedded in the jar file you will find a detailled description <a href="http://download.oracle.com/javase/tutorial/deployment/jar/index.html">here</a>.</p>
<p>Now that i knew where to put the version information the question was how to get <a href="http://www.netbeans.org">Netbeans</a> adding this information automaticaly to the manifest file during the build process. Well Netbeans is using <a href="http://ant.apache.org">Ant</a> under the hood to build your projects and because i knew ant build scripts from using the <a href="http://hudson-ci.org/">Hudson Continues Integration server</a> it was easy to achieve this.</p>
<p>First of all you have to locate the build.xml file in your Netbeans projects folder. Simply open it in Netbeans itself and you will see something like this&#8230;<span id="more-775"></span></p>
<blockquote>
<pre>﻿<span style="font-family: 'Courier New';"><span style="color: #1738f5;">&lt;?xml</span> version="1.0" encoding="UTF-8"?&gt;</span>
<span style="font-family: 'Courier New';"><span style="color: #295534;">&lt;!-- You may freely edit this file. See commented blocks below for --&gt;</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">&lt;!-- some examples of how to customize the build. --&gt;</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">&lt;!-- (If you delete it and reopen the project it will be recreated.) --&gt;</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">&lt;!-- By default, only the Clean and Build commands use this build script. --&gt;</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">&lt;!-- Commands such as Run, Debug, and Test only use this build script if --&gt;</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">&lt;!-- the Compile on Save feature is turned off for the project. --&gt;</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">&lt;!-- You can turn off the Compile on Save (or Deploy on Save) setting --&gt;</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">&lt;!-- in the project's Project Properties dialog box.--&gt;</span></span>
<span style="font-family: 'Courier New';"><span style="color: #1738f5;">&lt;project</span> name=<span style="color: #ff42f6;">"SteelTest"</span> default=<span style="color: #ff42f6;">"default"</span> basedir=<span style="color: #ff42f6;">"."</span><span style="color: #1738f5;">&gt;</span></span>
<span style="font-family: 'Courier New';">    <span style="color: #1738f5;">&lt;description&gt;</span>Builds, tests, and runs the project SteelTest.<span style="color: #1738f5;">&lt;/description&gt;</span></span>
<span style="font-family: 'Courier New';">    <span style="color: #1738f5;">&lt;import</span> file=<span style="color: #ff42f6;">"nbproject/build-impl.xml"</span><span style="color: #1738f5;">/&gt;</span></span>
<span style="font-family: 'Courier New';">    <span style="color: #295534;">&lt;!--</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">    There exist several targets which are by default empty and which can be </span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">    used for execution of your tasks. These targets are usually executed </span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">    before and after some main targets. They are: </span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">      -pre-init:                 called before initialization of project properties</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">      -post-init:                called after initialization of project properties</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">      -pre-compile:              called before javac compilation</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">      -post-compile:             called after javac compilation</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">      -pre-compile-single:       called before javac compilation of single file</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">      -post-compile-single:      called after javac compilation of single file</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">      -pre-compile-test:         called before javac compilation of JUnit tests</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">      -post-compile-test:        called after javac compilation of JUnit tests</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">      -pre-compile-test-single:  called before javac compilation of single JUnit test</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">      -post-compile-test-single: called after javac compilation of single JUunit test</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">      -pre-jar:                  called before JAR building</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">      -post-jar:                 called after JAR building</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">      -post-clean:               called after cleaning build products</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">    (Targets beginning with '-' are not intended to be called on their own.)</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">    Example of inserting an obfuscator after compilation could look like this:</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">        &lt;target name="-post-compile"&gt;</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">            &lt;obfuscate&gt;</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">                &lt;fileset dir="${build.classes.dir}"/&gt;</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">            &lt;/obfuscate&gt;</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">        &lt;/target&gt;</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">    For list of available properties check the imported </span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">    nbproject/build-impl.xml file. </span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">    Another way to customize the build is by overriding existing main targets.</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">    The targets of interest are: </span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">      -init-macrodef-javac:     defines macro for javac compilation</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">      -init-macrodef-junit:     defines macro for junit execution</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">      -init-macrodef-debug:     defines macro for class debugging</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">      -init-macrodef-java:      defines macro for class execution</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">      -do-jar-with-manifest:    JAR building (if you are using a manifest)</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">      -do-jar-without-manifest: JAR building (if you are not using a manifest)</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">      run:                      execution of project </span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">      -javadoc-build:           Javadoc generation</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">      test-report:              JUnit report generation</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">    An example of overriding the target for project execution could look like this:</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">        &lt;target name="run" depends="SteelTest-impl.jar"&gt;</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">            &lt;exec dir="bin" executable="launcher.exe"&gt;</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">                &lt;arg file="${dist.jar}"/&gt;</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">            &lt;/exec&gt;</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">        &lt;/target&gt;</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">    Notice that the overridden target depends on the jar target and not only on </span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">    the compile target as the regular run target does. Again, for a list of available </span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">    properties which you can use, check the target you are overriding in the</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">    nbproject/build-impl.xml file. </span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">    --&gt;</span></span></pre>
<p><span style="color: #ff201a;"><strong>P L A C E   T H E   F O L L O W I N G   T A R G E T S   H E R E   !   !   !</strong></span></p>
<pre><span style="font-family: 'Courier New';"><span style="color: #1738f5;">&lt;/project&gt;</span></span></pre>
</blockquote>
<p>Like it&#8217;s described in the text above there are different hooks where you could add your own stuff into the ant build script. Thinking about what kind of information to add to the manifest file i decided to not only add a version number but also a build number and in addition to this the subversion revision. This could be useful if someone would like to check out the sources for a specific version of the jar.</p>
<p>Means i need three things:</p>
<ul>
<li>version number</li>
<li>build number</li>
<li>subversion revision</li>
</ul>
<p>To achieve this information i will use two hooks in the build script</p>
<ul>
<li>-post init</li>
<li>-post jar</li>
</ul>
<p>Getting the subversion revision is easy and i found a ant target for this that looks like this&#8230;</p>
<blockquote>
<pre><span style="font-family: 'Courier New';"><span style="font-family: Helvetica; white-space: normal;">
<pre style="margin: 8px;"><span style="font-family: 'Courier New'; color: #295534;">   </span><span style="font-family: 'Courier New';"><span style="color: #295534;">&lt;!-- Extract the svn revision from subversion --&gt;</span></span></pre>
<p></span></span></p>
<pre style="margin: 8px;"><span style="font-family: 'Courier New';"><span style="color: #295534;">   </span><span style="color: #1738f5;">&lt;target</span><span style="color: #295534;"> </span>name=<span style="color: #ff42f6;">"-post-init"</span><span style="color: #295534;"> </span>description=<span style="color: #ff42f6;">"Get the svn revision of the current build"</span><span style="color: #1738f5;">&gt;</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">       </span><span style="color: #1738f5;">&lt;exec</span> outputproperty=<span style="color: #ff42f6;">"svna.version"</span> executable=<span style="color: #ff42f6;">"svnversion"</span><span style="color: #1738f5;">&gt;</span></span>
<span style="font-family: 'Courier New';">           <span style="color: #1738f5;">&lt;arg</span> value=<span style="color: #ff42f6;">"-c"</span> <span style="color: #1738f5;">/&gt;</span></span>
<span style="font-family: 'Courier New';">           <span style="color: #1738f5;">&lt;redirector&gt;</span></span>
<span style="font-family: 'Courier New';">               <span style="color: #1738f5;">&lt;outputfilterchain&gt;</span></span>
<span style="font-family: 'Courier New';">                   <span style="color: #1738f5;">&lt;tokenfilter&gt;</span></span>
<span style="font-family: 'Courier New';">                       <span style="color: #1738f5;">&lt;replaceregex</span> pattern=<span style="color: #ff42f6;">"^[0-9]*:?"</span> replace=<span style="color: #ff42f6;">""</span> flags=<span style="color: #ff42f6;">"g"</span><span style="color: #1738f5;">/&gt;</span></span>
<span style="font-family: 'Courier New';">                       <span style="color: #1738f5;">&lt;replaceregex</span> pattern=<span style="color: #ff42f6;">"M"</span> replace=<span style="color: #ff42f6;">""</span> flags=<span style="color: #ff42f6;">"g"</span><span style="color: #1738f5;">/&gt;</span></span>
<span style="font-family: 'Courier New';">                   <span style="color: #1738f5;">&lt;/tokenfilter&gt;</span></span>
<span style="font-family: 'Courier New';">               <span style="color: #1738f5;">&lt;/outputfilterchain&gt;</span></span>
<span style="font-family: 'Courier New';">           <span style="color: #1738f5;">&lt;/redirector&gt;</span></span>
<span style="font-family: 'Courier New';">       <span style="color: #1738f5;">&lt;/exec&gt;</span></span>
<span style="font-family: 'Courier New';">   <span style="color: #1738f5;">&lt;/target&gt;</span></span><span style="color: #295534;">
</span></pre>
</pre>
</blockquote>
<p>Next thing we need is the version and the build number. Ant is able to create a automatic increasing buildnumber everytime you run the build script so this is also no big deal. The version number could either be read from a text file or hardcoded in the build script.</p>
<p>In this example i hardcoded the version number directly into the build file because this number won&#8217;t change very often.</p>
<p>In addition to the version and build numbering you might also want to sign your jar automaticaly after it&#8217;s creation, well that&#8217;s again easy to achieve in ant but lets have a look at the ant target&#8230;</p>
<blockquote>
<pre style="margin: 8px;"><span style="font-family: 'Courier New';"><span style="color: #295534;">&lt;!-- Add the version information to the jar, sign the jar and create</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">     create a copy of the jar containing the version number in the filename --&gt;</span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;"><span style="color: #1738f5;">&lt;target</span></span><span style="color: #295534;"> </span><span style="color: #295534;">name=<span style="color: #ff42f6;">"-post-jar"</span></span><span style="color: #295534;"><span style="color: #1738f5;">&gt;</span></span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">    </span><span style="color: #295534;"><span style="color: #1738f5;">&lt;property</span></span><span style="color: #295534;"> </span><span style="color: #295534;">name=<span style="color: #ff42f6;">"version.num"</span> value=<span style="color: #ff42f6;">"</span><span style="color: #ff201a;"><strong>1.0</strong></span><span style="color: #ff42f6;">"</span> <span style="color: #1738f5;">/&gt;</span></span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">    </span><span style="color: #295534;"><span style="color: #1738f5;">&lt;buildnumber</span></span><span style="color: #295534;"> </span><span style="color: #295534;">file="build.num" <span style="color: #1738f5;">/&gt;</span></span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">    </span><span style="color: #295534;"><span style="color: #1738f5;">&lt;tstamp&gt;</span></span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">        </span><span style="color: #295534;"><span style="color: #1738f5;">&lt;format</span></span><span style="color: #295534;"> </span><span style="color: #295534;">property=<span style="color: #ff42f6;">"NOW"</span> pattern=<span style="color: #ff42f6;">"yyyy-MM-dd HH:mm:ss z"</span> <span style="color: #1738f5;">/&gt;</span></span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">    </span><span style="color: #295534;"><span style="color: #1738f5;">&lt;/tstamp&gt;</span></span></span>
<span style="font-family: 'Courier New';"><span style="color: #1738f5;">    </span></span>
<span style="font-family: 'Courier New';">    <span style="color: #1738f5;"><span style="color: #295534;">&lt;!-- Add the version information to the manifest file --</span></span><span style="color: #1738f5;"><span style="color: #295534;">&gt;</span></span></span>
<span style="font-family: 'Courier New';">    <span style="color: #1738f5;">&lt;jar&gt;</span></span>
<span style="font-family: 'Courier New';">        </span><span style="font-family: 'Courier New'; color: #1738f5;">&lt;manifest&gt;</span><span style="font-family: Helvetica; white-space: normal;">
<pre style="margin: 8px;"><span style="font-family: 'Courier New';">           <span style="color: #295534;"><span style="color: #1738f5;">&lt;attribute</span></span><span style="color: #295534;"> </span><span style="color: #295534;">name=<span style="color: #ff42f6;">"</span><span style="color: #ff201a;"><strong>PROJECT_NAME</strong></span><span style="color: #ff42f6;">-Version"</span> value=<span style="color: #ff42f6;">"${version.num}.${build.number}"</span> <span style="color: #1738f5;">/&gt;</span></span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">           </span><span style="color: #295534;"><span style="color: #1738f5;">&lt;attribute</span></span><span style="color: #295534;"> </span><span style="color: #295534;">name=<span style="color: #ff42f6;">"</span><span style="color: #ff201a;"><strong>PROJECT_NAME</strong></span><span style="color: #ff42f6;">-SVN-Revision"</span> value=<span style="color: #ff42f6;">"${svna.version}"</span> <span style="color: #1738f5;">/&gt;</span></span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">           </span><span style="color: #295534;"><span style="color: #1738f5;">&lt;attribute</span></span><span style="color: #295534;"> </span><span style="color: #295534;">name=<span style="color: #ff42f6;">"</span><span style="color: #ff201a;"><strong>PROJECT_NAME</strong></span><span style="color: #ff42f6;">-BuildStamp"</span> value=<span style="color: #ff42f6;">"${NOW}"</span> <span style="color: #1738f5;">/&gt;</span></span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">       </span><span style="color: #295534;"><span style="color: #1738f5;">&lt;/manifest&gt;</span></span></span></pre>
<p></span><span style="font-family: 'Courier New';"><span style="color: #295534;"> </span><span style="color: #295534;"><span style="color: #1738f5;"> &lt;/jar&gt;</span></span></span></pre>
<pre style="margin: 8px;"><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">    </span><span style="color: #295534;"><span style="color: #295534;">&lt;!--Sign the jar file with you credentials --&gt;</span></span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">    </span><span style="color: #295534;"><span style="color: #295534;">&lt;!--&lt;signjar jar="${dist.jar}" alias="..." keystore="..." storepass="..." /&gt;--&gt;</span></span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">    </span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">    </span><span style="color: #295534;"><span style="color: #295534;">&lt;!-- Make a copy of the jar file and add the version number to the filename --&gt;</span></span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;">    </span><span style="color: #295534;"><span style="color: #1738f5;">&lt;copy</span> file=<span style="color: #ff42f6;">"${dist.jar}"</span> tofile=<span style="color: #ff42f6;">"${dist.dir}/<strong><span style="color: #ff201a;">PROJECT_NAME</span></strong>-${version.num}.jar"</span> <span style="color: #1738f5;">/&gt;</span></span></span><span style="color: #295534;">
</span><span style="font-family: 'Courier New';"><span style="color: #295534;"><span style="color: #1738f5;">&lt;/target&gt;</span></span></span></pre>
</blockquote>
<p>So as you can see in the file above the buildnumber will be generated by the tag &lt;buildnumber&gt; and will be stored in a file called &#8220;build.num&#8221;. If this file isn&#8217;t present it will be created automaticaly (might make sense to delete it for every new major version).</p>
<p>If you copy and paste this targets in the build.xml file of your project you only have to replace the <strong><span style="color: #ff201a;">PROJECT_NAME</span></strong> in the above examples with your project name and modify the version number and you are ready to go.</p>
<p>These modifications to the build.xml file will give you the following result in the manifest file of your jar.</p>
<blockquote><p>﻿Manifest-Version: 1.0</p>
<p>Ant-Version: Apache Ant 1.8.1</p>
<p>Created-By: 1.6.0_20-b02-279-10M3065 (Apple Inc.)</p>
<p><strong><span style="color: #ff201a;">PROJECT_NAME</span></strong>-Version: 1.0.1</p>
<p><strong><span style="color: #ff201a;">PROJECT_NAME</span></strong>-SVN-Revision: 1</p>
<p><span style="color: #ff201a;"><strong>PROJECT_NAME</strong></span>-BuildStamp: 2010-09-30 09:58:38 MESZ</p></blockquote>
<p>For me this was the solution i was looking for but if someone has a trick how to improve it&#8230;PLEASE LET ME KNOW !!!</p>
<p>Follow me on <a href="http://twitter.com/hansolo_">twitter</a> if you like&#8230;</p>
<div style="clear:both;">&nbsp;</div><p>Weitere Artikel:<ol>
<li><a href='http://www.jug-muenster.de/using-smack-xmpp-lib-on-android-with-netbeans-573/' rel='bookmark' title='Using Smack xmpp lib on Android with Netbeans'>Using Smack xmpp lib on Android with Netbeans</a></li>
<li><a href='http://www.jug-muenster.de/netbeans-platform-certified-training-1138/' rel='bookmark' title='Netbeans Platform certified Training'>Netbeans Platform certified Training</a></li>
<li><a href='http://www.jug-muenster.de/swing-weather-worldclock-490/' rel='bookmark' title='Swing Weather Worldclock'>Swing Weather Worldclock</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jug-muenster.de/versioning-and-signing-jar-files-in-netbeans-775/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SteelSeries update</title>
		<link>http://www.jug-muenster.de/steelseries-update-768/</link>
		<comments>http://www.jug-muenster.de/steelseries-update-768/#comments</comments>
		<pubDate>Fri, 17 Sep 2010 16:41:05 +0000</pubDate>
		<dc:creator>Gerrit</dc:creator>
				<category><![CDATA[Contributed]]></category>

		<guid isPermaLink="false">http://www.jug-muenster.de/?p=768</guid>
		<description><![CDATA[Hi there, this is just to inform you that there is a updated version of the Java Swing component library &#8220;SteelSeries&#8221; available. I added 10 more components&#8230; There are radial bargraphs which you could see below   In addition to these i added another version of the Radial2 component which is called Radial2Top The last [...]
Weitere Artikel:<ol>
<li><a href='http://www.jug-muenster.de/steelseries-java-swing-component-library-715/' rel='bookmark' title='SteelSeries Java Swing component library'>SteelSeries Java Swing component library</a></li>
<li><a href='http://www.jug-muenster.de/devoxx-update-185/' rel='bookmark' title='Devoxx update'>Devoxx update</a></li>
<li><a href='http://www.jug-muenster.de/devoxx-update-2-187/' rel='bookmark' title='Devoxx update #2'>Devoxx update #2</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><!--S-ButtonZ 1.1.5 End--><p>Hi there,</p>
<p>this is just to inform you that there is a updated version of the Java Swing component library &#8220;SteelSeries&#8221; available.</p>
<p>I added 10 more components&#8230;</p>
<p>There are radial bargraphs which you could see below</p>
<p><img src="http://www.jug-muenster.de/wp-content/uploads/2010/09/ishot-4.png" border="0" alt="ishot-4.png" width="600" height="307" /></p>
<p> </p>
<p>In addition to these i added another version of the Radial2 component which is called Radial2Top</p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="http://www.jug-muenster.de/wp-content/uploads/2010/09/ishot-6.png" border="0" alt="ishot-6.png" width="240" height="240" />The last component i added is called RadialCounter. I saw this kind of component during a visit of a german u-boat</p>
<p>where it was used to visualize the depth of the boat.</p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="http://www.jug-muenster.de/wp-content/uploads/2010/09/ishot-7.png" border="0" alt="ishot-7.png" width="240" height="240" /></p>
<p> </p>
<p>In addition to the new components there a some more modifications like colored tickmarks etc.</p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="http://www.jug-muenster.de/wp-content/uploads/2010/09/ishot-5.png" border="0" alt="ishot-5.png" width="458" height="240" /></p>
<p> </p>
<p>For more info please go to <a href="http://www.harmonic-code.org">http://www.harmonic-code.org</a></p>
<p> </p>
<p>Follow me on <a href="http://twitter.com/hansolo_">twitter</a> if you like&#8230;</p>
<div style="clear:both;">&nbsp;</div><p>Weitere Artikel:<ol>
<li><a href='http://www.jug-muenster.de/steelseries-java-swing-component-library-715/' rel='bookmark' title='SteelSeries Java Swing component library'>SteelSeries Java Swing component library</a></li>
<li><a href='http://www.jug-muenster.de/devoxx-update-185/' rel='bookmark' title='Devoxx update'>Devoxx update</a></li>
<li><a href='http://www.jug-muenster.de/devoxx-update-2-187/' rel='bookmark' title='Devoxx update #2'>Devoxx update #2</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jug-muenster.de/steelseries-update-768/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SteelSeries Java Swing component library</title>
		<link>http://www.jug-muenster.de/steelseries-java-swing-component-library-715/</link>
		<comments>http://www.jug-muenster.de/steelseries-java-swing-component-library-715/#comments</comments>
		<pubDate>Thu, 12 Aug 2010 22:41:01 +0000</pubDate>
		<dc:creator>Gerrit</dc:creator>
				<category><![CDATA[Contributed]]></category>
		<category><![CDATA[custom component]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[swing]]></category>

		<guid isPermaLink="false">http://www.jug-muenster.de/?p=715</guid>
		<description><![CDATA[Here we go again&#8230; A few months ago i started a new project where i again focussed on gauges (i love that stuff). It took me some time because i only work on the project on my spare time (which is rare) but now i finished a first version of a little library that contains [...]
Weitere Artikel:<ol>
<li><a href='http://www.jug-muenster.de/custom-swing-component-227/' rel='bookmark' title='Custom swing component'>Custom swing component</a></li>
<li><a href='http://www.jug-muenster.de/steelseries-update-768/' rel='bookmark' title='SteelSeries update'>SteelSeries update</a></li>
<li><a href='http://www.jug-muenster.de/java-autoconversion-textfield-component-638/' rel='bookmark' title='Java AutoConversion textfield component'>Java AutoConversion textfield component</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><!--S-ButtonZ 1.1.5 End--><p>Here we go again&#8230;</p>
<p>A few months ago i started a new project where i again focussed on gauges (i love that stuff). It took me some time because i only work on the project on my spare time (which is rare) but now i finished a first version of a little library that contains a lot of gauges for Java applications&#8230;</p>
<p>First of all i have to mention that this library was not meant to be a professional components library and should not be used on mission critical software. Means if you use the library it&#8217;s on your own risk !</p>
<p>I&#8217;ve never before created a component library and for me it was and is a great challenge to dive deeper into the Java universe&#8230;</p>
<p>But now let&#8217;s have some fun&#8230;</p>
<p>The library contains two general types of gauges, radial and linear ones and some little candy in the form of additional components like a Radar component etc.</p>
<p>I add some properties to the gauges that hopefuly will be useful for some of you.</p>
<p>Here is a short list of the most interesting features:</p>
<ul>
<li>frameDesign (metal, shiny metal, blackmetal)</li>
<li>backgroundColor (dark gray, light gray, white, black, beige, red, green blue)</li>
<li>pointer/bar color (red, green, blue, yellow, orange)</li>
<li>a three colored track to visualize areas of special interest (e.g. a critical temperature range)</li>
<li>thresholdIndicator</li>
<li>blinking threshold led (red, green, blue, orange, yellow)</li>
<li>adjustable tickmarks</li>
<li>indicators for min. and max. measured values</li>
<li>auto reset to zero feature</li>
</ul>
<p>It should be possible for you to create your own components out of these library and  if you&#8217;ll take a look at the <a href="http://kenai.com/projects/steelseries/pages/Home">source</a> you will find components like Radial1Lcd, Radial2Lcd and Radial3Lcd where i used <a href="http://www.netbeans.org">Netbeans</a> matisse gui builder to create the component from the FrameCircular and DisplaySingle components.</p>
<p>So you should be able to check read the sourcecode of these components and see how i did it (the easiest way would be to use <a href="http://www.netbeans.org">Netbeans</a> to check the source).</p>
<p style="font-size: 14px;">But to give you a impression, let pictures speak&#8230;<span id="more-715"></span><strong>Radial gauges&#8230;</strong></p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/08/ishot-1.png" border="0" alt="ishot-1.png" width="240" height="240" /></p>
<p><strong>Radial4 component</strong></p>
<p>backgroundColor: beige</p>
<p>frameDesign: blackMetal</p>
<p>pointerColor: orange</p>
<p>ledColor: orange</p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/08/ishot-31.png" border="0" alt="ishot-3.png" width="240" height="240" /></p>
<p><strong>Radial2Lcd component</strong></p>
<p>backgroundColor: white</p>
<p>frameDesign: metal</p>
<p>pointerColor: red</p>
<p>ledColor: red</p>
<p>lcdColor: beige</p>
<p>digitalFont</p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/08/ishot-21.png" border="0" alt="ishot-2.png" width="240" height="240" /></p>
<p><strong>Radial4 component</strong></p>
<p>backgroundColor: black</p>
<p>frameDesign: shinyMetal</p>
<p>pointerColor: green</p>
<p>track: 70, 90, 100</p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/08/ishot-51.png" border="0" alt="ishot-5.png" width="240" height="240" /></p>
<p><strong>Radial1Square component</strong></p>
<p>backgroundColor: green</p>
<p>frameDesign: metal</p>
<p>pointerColor: red</p>
<p>ledColor: yellow</p>
<p>track: 0, 50, 100</p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/08/ishot-41.png" border="0" alt="ishot-4.png" width="240" height="240" /></p>
<p><strong>Radial3Lcd component</strong></p>
<p>backgroundColor: lightGray</p>
<p>frameDesign: blackMetal</p>
<p>pointerColor: blue</p>
<p>ledColor: blue</p>
<p>lcdColor: blueBlue</p>
<p>track: 40, 55, 70</p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/08/ishot-101.png" border="0" alt="ishot-10.png" width="240" height="240" /></p>
<p><strong>Radial1Vertical component</strong></p>
<p>backgroundColor: beige</p>
<p>frameDesign: metal</p>
<p>pointerColor: red</p>
<p>ledColor: red</p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/08/ishot-111.png" border="0" alt="ishot-11.png" width="240" height="240" /></p>
<p><strong>Radial1Vertical component</strong></p>
<p>backgroundColor: white</p>
<p>frameDesign: blackMetal</p>
<p>pointerColor: yellow</p>
<p>ledColor: orange</p>
<p>track: 0, 75, 100</p>
<p>threshold: 75</p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/08/ishot-8.png" border="0" alt="ishot-8.png" width="240" height="240" /></p>
<p><strong>DigitalRadialLcd component</strong></p>
<p>backgroundColor: black</p>
<p>frameDesign: blackMetal</p>
<p>lcdColor: green</p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/08/ishot-9.png" border="0" alt="ishot-9.png" width="240" height="240" /></p>
<p><strong>DisplayCircular component</strong></p>
<p>backgroundColor: blue</p>
<p>frameDesign: shinyMetal</p>
<p>digitalFont</p>
<hr />
<p style="font-size: 14px;"><strong>Linear gauges&#8230;</strong></p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/08/ishot-61.png" border="0" alt="ishot-6.png" width="180" height="440" /></p>
<p><strong>Linear component</strong></p>
<p>backgroundColor: darkGray</p>
<p>frameDesign: metal</p>
<p>ledColor: orange</p>
<p>valueColor: orange</p>
<p>track: 70, 85, 100</p>
<p>threshold: 50</p>
<p>vertical orientation</p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/08/ishot-71.png" border="0" alt="ishot-7.png" width="180" height="440" /></p>
<p><strong>Linear component</strong></p>
<p>backgroundColor: beige</p>
<p>frameDesign: blackMetal</p>
<p>ledColor: red</p>
<p>valueColor: red</p>
<p>lcdColor: green</p>
<p>digitalFont</p>
<p>minMeasuredValue: 0</p>
<p>maxMeasuredValue: 70</p>
<p>vertical orientation</p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/08/ishot-12.png" border="0" alt="ishot-12.png" width="473" height="180" /></p>
<p><strong>Linear component</strong></p>
<p>backgroundColor: white</p>
<p>frameDesign: shinyMetal</p>
<p>valueColor: green</p>
<p>ledColor: green</p>
<p>track 80, 90, 100</p>
<p>threshold: 80</p>
<p>orientation: horizontal</p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/08/ishot-13.png" border="0" alt="ishot-13.png" width="473" height="180" /></p>
<p><strong>Linear component</strong></p>
<p>backgroundColor: lightGray</p>
<p>frameDesign: blackMetal</p>
<p>valueColor: yellow</p>
<p>ledColor: yellow</p>
<p>lcdColor: standard</p>
<p>track: 0, 70, 100</p>
<hr /><strong>The Candy stuff comes here&#8230;</strong></p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/08/Altimeter.png" border="0" alt="Altimeter.png" width="240" height="240" /><span style="text-decoration: underline;"><strong>Altimeter component</strong></span></p>
<p>A component that behave like a altimeter that you might know from airplanes. It has three pointers</p>
<p>10 ft        :  the big fast pointer</p>
<p>100 ft      : the smaller slower pointer</p>
<p>1000 ft    : the pointer with the triangle at the end, moving very slow</p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/08/Clock.png" border="0" alt="Clock.png" width="240" height="240" /></p>
<p><strong>Clock component</strong></p>
<p>Just a simple analog clock component in the same look as the other gauges.</p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/08/Compass.png" border="0" alt="Compass.png" width="240" height="240" /><strong> </strong></p>
<p><strong>Compass component</strong></p>
<p>A compass component that takes values in the range from -360&#8230;360 degrees.</p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/08/Level.png" border="0" alt="Level.png" width="240" height="240" /><strong> </strong></p>
<p><strong>Level component</strong></p>
<p>A clinometer component that takes values in the range from -360&#8230;360 degrees.</p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/08/Radar.png" border="0" alt="Radar.png" width="240" height="240" /><strong> </strong></p>
<p><strong>Radar component</strong></p>
<p>This is a little bit special component that like a lot. You could define a home position in the component which will then represent the center of the component.</p>
<p>Now you could add poi objects that represent locations defined by their latitude and longitude and the component will show these poi&#8217;s on the screen if they are in the range of the radar which could be defined.</p>
<p>This means if you read out data from a gps device and set the home position to the current position of the gps from time to time you could add some poi&#8217;s and they will appear and disappear on the radar screen when you move&#8230;</p>
<p>Download the library <a href="http://idisk.mac.com/han.solo-Public/SteelSeries.jar">here</a>&#8230;</p>
<p>I also create a project on <a href="http://kenai.com/projects/steelseries/pages/Home">Kenai</a> where you could download the sourcecode or might want to participate&#8230;</p>
<p>There is a special blog that i created to present my <a href="http://www.java.com">Java</a> Swing related stuff in more detail, please find it <a href="http://www.harmonic-code.org">here</a>. In that blog i will try to give you a more detailed view at the creation of these components.</p>
<p>Follow me on <a href="http://twitter.com/hansolo_">twitter</a> if you like&#8230;</p>
<div style="clear:both;">&nbsp;</div><p>Weitere Artikel:<ol>
<li><a href='http://www.jug-muenster.de/custom-swing-component-227/' rel='bookmark' title='Custom swing component'>Custom swing component</a></li>
<li><a href='http://www.jug-muenster.de/steelseries-update-768/' rel='bookmark' title='SteelSeries update'>SteelSeries update</a></li>
<li><a href='http://www.jug-muenster.de/java-autoconversion-textfield-component-638/' rel='bookmark' title='Java AutoConversion textfield component'>Java AutoConversion textfield component</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jug-muenster.de/steelseries-java-swing-component-library-715/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java2D Conical Gradient Paint</title>
		<link>http://www.jug-muenster.de/java2d-conical-gradient-paint-674/</link>
		<comments>http://www.jug-muenster.de/java2d-conical-gradient-paint-674/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 13:28:10 +0000</pubDate>
		<dc:creator>Gerrit</dc:creator>
				<category><![CDATA[Contributed]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[java2d]]></category>
		<category><![CDATA[swing]]></category>

		<guid isPermaLink="false">http://www.jug-muenster.de/?p=674</guid>
		<description><![CDATA[Just a short blogpost about a little tool that i would like to share with you&#8230; A few months ago i was creating a worldclock with a night and day display where i needed a conical gradient. So what is a conical gradient ? Here we go&#8230; You might think &#8220;ok, it looks nice but [...]
Weitere Artikel:<ol>
<li><a href='http://www.jug-muenster.de/fxg-to-java2d-converter-555/' rel='bookmark' title='FXG to Java2D converter'>FXG to Java2D converter</a></li>
<li><a href='http://www.jug-muenster.de/swing-worldclock-427/' rel='bookmark' title='Swing Worldclock'>Swing Worldclock</a></li>
<li><a href='http://www.jug-muenster.de/drawing-in-code-part-2-2-384/' rel='bookmark' title='Drawing in code (Part 2)'>Drawing in code (Part 2)</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><!--S-ButtonZ 1.1.5 End--><p>Just a short blogpost about a little tool that i would like to share with you&#8230;<br />
A few months ago i was creating a worldclock with a night and day display where i needed a conical gradient.<br />
So what is a conical gradient ? Here we go&#8230;<span id="more-674"></span></p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/07/ishot-22.png" border="0" alt="ishot-2.png" width="186" height="203" /></p>
<p>You might think &#8220;ok, it looks nice but where is it useful ?&#8221;&#8230;well here are three little examples&#8230;</p>
<blockquote><p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/07/ishot-41.png" border="0" alt="ishot-4.png" width="138" height="160" /></p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="http://www.jug-muenster.de/wp-content/uploads/2010/07/ishot-5.png" border="0" alt="ishot-5.png" width="278" height="276" /></p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="http://www.jug-muenster.de/wp-content/uploads/2010/07/ishot-6.png" border="0" alt="ishot-6.png" width="451" height="205" /></p></blockquote>
<p>So if you would like to achieve these results without the conical gradient paint you have to rotate a line a change the color at every angle. This works out but if it comes to large angles you have to decrease the stepsize which leads to artifacts around the rotation center.</p>
<p>So the conical gradient paint is especialy useful when you work with rotationally symetrical stuff. With this kind of gradient you could get more realistic results of circular structures like the two buttons in the image above. On the left side i used a conical gradient and on the right side i used a linear gradient.</p>
<p>For most of the stuff the linear approach will work but the conical gradient gives you a more realistic shading. Things like the stainless steel button is hard to be generated without a gradient like this.</p>
<p>So let me show you some code to give you an idea of how to work with the ConicalGradientPaint:</p>
<p>The syntax is similar to the LinearGradientPaint and RadialGradientPaint where you define a float array that holds all the fractions of the gradient, a color array that holds all the colors for each fraction and a point that defines the rotation center of the gradient.</p>
<p>Additional to that standard parameters i added a indicator for the usage of degrees and a rotation offset.</p>
<p><strong>Usage:</strong></p>
<p>ConicalGradientPaint cgp = new ConicalGradientPaint(USE_DEGREES, CENTER, OFFSET, FRACTIONS, COLORS);</p>
<p>USE_DEGREES = true/false</p>
<p>CENTER = java.awt.geom.Point2D</p>
<p>OFFSET = float (either 0.0f &#8211; 1.0f or 0.0f &#8211; 360.0f)</p>
<p>FRACTIONS = float[] (either values from 0.0f..1.0f or from 0.0f..360.0f)</p>
<p>COLORS = java.awt.Color[]</p>
<pre class="brush:java;">// Code for a simple cone like from black over white to black
final Ellipse2D CONE = new Ellipse2D.Double(0, 0, 150, 150);

final Point2D CONE_CENTER = new Point2D.Double(CONE.getCenterX(), CONE.getCenterY());

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

final java.awt.Color[] CONE_COLORS =
{
    java.awt.Color.BLACK,
    java.awt.Color.WHITE,
    java.awt.Color.BLACK
};

final ConicalGradientPaint CONE_GRADIENT = new ConicalGradientPaint(
	CONE_CENTER,
	CONE_FRACTIONS,
	CONE_COLORS);

G2.setPaint(CONE_GRADIENT);

G2.fill(CONE);</pre>
<p>As you can see it&#8217;s not magic but simple stupid java code and with a little variation in colors and fractions you could achieve effects like the stainless steel button.</p>
<p>In my free time i&#8217;m working on a new component library (mostly gauges) where i also could use the conical gradient paint.</p>
<blockquote><p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/07/ishot-7.png" border="0" alt="ishot-7.png" width="209" height="215" /></p></blockquote>
<p>In the screenshot you could see that the gauge has a area from 10 to 60 where it has a gradient in the background. This gradient is also filled by the ConicalGradientPaint.</p>
<p>So you see it could be useful to have this kind of gradient available and for that reason i would like to share it with you&#8230;</p>
<p>Here is the source as zipped <a href="http://www.netbeans.org">Netbeans</a> <a title="ConicalGradientPaint.zip" href="http://www.jug-muenster.de/wp-content/uploads/2010/07/ConicalGradientPaint.zip">project</a>. It contains the ConicalGradient class and a little demo that will give you an idea of how to use the paint.</p>
<p>In this project you&#8217;ll also find a compiled jar that you could start and it will show you this</p>
<blockquote><p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/07/ishot-8.png" border="0" alt="ishot-8.png" width="471" height="450" /></p></blockquote>
<p>So enjoy Swing and follow me on <a href="http://twitter.com/hansolo_">twitter</a> if you like&#8230;</p>
<div style="clear:both;">&nbsp;</div><p>Weitere Artikel:<ol>
<li><a href='http://www.jug-muenster.de/fxg-to-java2d-converter-555/' rel='bookmark' title='FXG to Java2D converter'>FXG to Java2D converter</a></li>
<li><a href='http://www.jug-muenster.de/swing-worldclock-427/' rel='bookmark' title='Swing Worldclock'>Swing Worldclock</a></li>
<li><a href='http://www.jug-muenster.de/drawing-in-code-part-2-2-384/' rel='bookmark' title='Drawing in code (Part 2)'>Drawing in code (Part 2)</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jug-muenster.de/java2d-conical-gradient-paint-674/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android AutoConversion EditText component</title>
		<link>http://www.jug-muenster.de/android-autoconversion-edittext-component-653/</link>
		<comments>http://www.jug-muenster.de/android-autoconversion-edittext-component-653/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 07:39:36 +0000</pubDate>
		<dc:creator>Gerrit</dc:creator>
				<category><![CDATA[Contributed]]></category>

		<guid isPermaLink="false">http://www.jug-muenster.de/?p=653</guid>
		<description><![CDATA[AutoConversion EditText component: Yesterday i created a Java Swing textfield component that autoconverts a given value into a selectable unit which could be useful. In the evening i got the idea to port this component to Android and see if it will work there. Just as a short note&#8230;if you are a Java developer you [...]
Weitere Artikel:<ol>
<li><a href='http://www.jug-muenster.de/java-autoconversion-textfield-component-638/' rel='bookmark' title='Java AutoConversion textfield component'>Java AutoConversion textfield component</a></li>
<li><a href='http://www.jug-muenster.de/using-smack-xmpp-lib-on-android-with-netbeans-573/' rel='bookmark' title='Using Smack xmpp lib on Android with Netbeans'>Using Smack xmpp lib on Android with Netbeans</a></li>
<li><a href='http://www.jug-muenster.de/steelseries-java-swing-component-library-715/' rel='bookmark' title='SteelSeries Java Swing component library'>SteelSeries Java Swing component library</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><!--S-ButtonZ 1.1.5 End--><p><strong>AutoConversion EditText component:</strong></p>
<p>Yesterday i created a Java Swing textfield component that autoconverts a given value into a selectable unit which could be useful.</p>
<p>In the evening i got the idea to port this component to Android and see if it will work there.</p>
<p>Just as a short note&#8230;if you are a Java developer you should take a look into Android&#8230;it&#8217;s sooooo nice, porting the component tooks me not more than 2 hours (and i&#8217;m not really into Android development).</p>
<p>Here is the result:</p>
<p><img style="font-size: 11px; float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/07/ishot-21.png" border="0" alt="ishot-2.png" width="170" height="250" /><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/07/ishot-31.png" border="0" alt="ishot-3.png" width="170" height="250" /><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/07/ishot-4.png" border="0" alt="ishot-4.png" width="170" height="250" /></p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p>So you could type in a value with the unit of your choice and after leaving the field the value will be converted into the EditText &#8220;base unit&#8221;.</p>
<p>I changed the units with special characters like µ, Å, ² and ³ to u, A, 2 and 3 which leads to units like:</p>
<p>um  &lt;=&gt;  µm</p>
<p>A &lt;=&gt;  Å﻿</p>
<p>m2  &lt;=&gt;  m²﻿</p>
<p>m3  &lt;=&gt;  m³﻿</p>
<p>and so on&#8230;﻿</p>
<p>The upper spinner will select the type of unit you would like to use.</p>
<p>The middle spinner will select the current base unit for the textfield.</p>
<p>The lower spinner will adjust the number of decimals for the textfield.</p>
<p>Because it displays the unit directly in the textfield there&#8217;s no need for a additional label for the unit.</p>
<p>You also might check this little <a href="http://www.youtube.com/watch?v=Gnved6KjoC0">video</a></p>
<p>Well again this is nothing very fancy or gui related but it was a nice challange for me so i decided to share it with you&#8230; <a title="AutoConversionField.zip" href="http://www.jug-muenster.de/wp-content/uploads/2010/07/AutoConversionField.zip">AutoConversionField.zip</a></p>
<p> </p>
<p>follow me on <a href="http://twitter.com/hansolo_">twitter</a> if you like&#8230;﻿</p>
<p> </p>
<div style="clear:both;">&nbsp;</div><p>Weitere Artikel:<ol>
<li><a href='http://www.jug-muenster.de/java-autoconversion-textfield-component-638/' rel='bookmark' title='Java AutoConversion textfield component'>Java AutoConversion textfield component</a></li>
<li><a href='http://www.jug-muenster.de/using-smack-xmpp-lib-on-android-with-netbeans-573/' rel='bookmark' title='Using Smack xmpp lib on Android with Netbeans'>Using Smack xmpp lib on Android with Netbeans</a></li>
<li><a href='http://www.jug-muenster.de/steelseries-java-swing-component-library-715/' rel='bookmark' title='SteelSeries Java Swing component library'>SteelSeries Java Swing component library</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jug-muenster.de/android-autoconversion-edittext-component-653/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java AutoConversion textfield component</title>
		<link>http://www.jug-muenster.de/java-autoconversion-textfield-component-638/</link>
		<comments>http://www.jug-muenster.de/java-autoconversion-textfield-component-638/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 11:22:17 +0000</pubDate>
		<dc:creator>Gerrit</dc:creator>
				<category><![CDATA[Contributed]]></category>

		<guid isPermaLink="false">http://www.jug-muenster.de/?p=638</guid>
		<description><![CDATA[AutoConversion textfield component: If you drive a motorized stage of a microscope you often have to handle coordinates in a unit like millimeter [mm]. But it might happen that the sample in your microscope is only in the range of microns [µm]. So would it not be nice to directly type in the coordinates in [...]
Weitere Artikel:<ol>
<li><a href='http://www.jug-muenster.de/android-autoconversion-edittext-component-653/' rel='bookmark' title='Android AutoConversion EditText component'>Android AutoConversion EditText component</a></li>
<li><a href='http://www.jug-muenster.de/steelseries-java-swing-component-library-715/' rel='bookmark' title='SteelSeries Java Swing component library'>SteelSeries Java Swing component library</a></li>
<li><a href='http://www.jug-muenster.de/custom-swing-component-227/' rel='bookmark' title='Custom swing component'>Custom swing component</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><!--S-ButtonZ 1.1.5 End--><p><strong>AutoConversion textfield component:</strong></p>
<p>If you drive a motorized stage of a microscope you often have to handle coordinates in a unit like millimeter [mm]. But it might happen that the sample in your microscope is only in the range of microns [µm].</p>
<p>So would it not be nice to directly type in the coordinates in µm and the textfield would automaticaly convert the unit into [mm] ?</p>
<p>This would increase the workflow a lot because you do not have to think about conversion of units. There seems to be countries that are using inches and people living there might like to type in coordinates in inches instead of millimeters..etc&#8230;</p>
<p>For this reason i created a little component that extends a standard javax.swing.JTextField and is now able to do the conversion. You could also use the conversion alone without the textfield to create some kind of unit converter&#8230;it&#8217;s up to you.</p>
<p>Here are a few screenshots of a demo app that uses the component:</p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/07/ishot-1.png" border="0" alt="#1 Step" width="166" height="239" /></p>
<p><img style="float: right;" src="http://www.jug-muenster.de/wp-content/uploads/2010/07/ishot-3.png" border="0" alt="#3 Step" width="166" height="239" /><img style="display: block; margin-left: auto; margin-right: auto;" src="http://www.jug-muenster.de/wp-content/uploads/2010/07/ishot-2.png" border="0" alt="#2 Step" width="166" height="239" /></p>
<p>So you could type in a value with the unit of your choice and after leaving the field or pressing enter the value will be converted into the textfields &#8220;base unit&#8221;.</p>
<p>The upper combobox will select the type of unit you would like to use (it supports angle, area, length, mass, temperature, time at the moment but one could easily add more units to it).</p>
<p>The middle combobox will select the current base unit for the textfield.</p>
<p>The lower combobox will adjust the number of decimals for the textfield.</p>
<p>Because it displays the unit directly in the textfield there&#8217;s no need for a additional label for the unit.</p>
<p>You also might check this little <a href="http://www.youtube.com/watch?v=1GkrDIh5ZsQ">video</a></p>
<p>Well this is nothing very fancy or gui related but it was very useful for me so i decided to share it with you&#8230; <a title="ConversionField.zip" href="http://www.jug-muenster.de/wp-content/uploads/2010/07/ConversionField3.zip">ConversionField.zip</a></p>
<p> </p>
<p>follow me on <a href="http://twitter.com/hansolo_">twitter</a> if you like&#8230;</p>
<div style="clear:both;">&nbsp;</div><p>Weitere Artikel:<ol>
<li><a href='http://www.jug-muenster.de/android-autoconversion-edittext-component-653/' rel='bookmark' title='Android AutoConversion EditText component'>Android AutoConversion EditText component</a></li>
<li><a href='http://www.jug-muenster.de/steelseries-java-swing-component-library-715/' rel='bookmark' title='SteelSeries Java Swing component library'>SteelSeries Java Swing component library</a></li>
<li><a href='http://www.jug-muenster.de/custom-swing-component-227/' rel='bookmark' title='Custom swing component'>Custom swing component</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jug-muenster.de/java-autoconversion-textfield-component-638/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

