<?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>martinklinke.com &#187; charts</title>
	<atom:link href="http://www.martinklinke.com/tag/charts/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.martinklinke.com</link>
	<description>IT&#039;s my business</description>
	<lastBuildDate>Tue, 29 Jun 2010 19:33:58 +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>Speedometer with JFreeChart in Eclipse</title>
		<link>http://www.martinklinke.com/2009/02/18/speedometer-with-jfreechart-in-eclipse/</link>
		<comments>http://www.martinklinke.com/2009/02/18/speedometer-with-jfreechart-in-eclipse/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 22:25:18 +0000</pubDate>
		<dc:creator>mklinke</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[charts]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[visualization]]></category>

		<guid isPermaLink="false">http://www.martinklinke.com/?p=51</guid>
		<description><![CDATA[There is a great tutorial on vogella.de describing how to add a pie chart with JFreeChart to an Eclipse RCP application or plug-in. The ChartFactory that is used to create the pie chart does not include a method to create a speedometer (or dial) as shown in the sample section of JFreeChart. The following code [...]]]></description>
			<content:encoded><![CDATA[<p>There is a great tutorial on <a href="http://www.vogella.de">vogella.de</a> describing how to <a title="JFreeChart in Eclipse RCP" href="http://www.vogella.de/articles/EclipseJFreeChart/article.html">add a pie chart with JFreeChart to an Eclipse RCP application or plug-in</a>. The ChartFactory that is used to create the pie chart does not include a method to create a speedometer (or dial) as shown in the <a title="JFreeChart Samples" href="http://www.jfree.org/jfreechart/samples.html">sample section of JFreeChart</a>. The following code fragment creates a view that displays a very basic speedometer using the <strong>org.jfree.chart.plot.MeterPlot</strong> class:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.martinklinke.eclipse.jfreechart.demo.views</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.eclipse.swt.SWT</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.eclipse.swt.widgets.Composite</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.eclipse.ui.part.ViewPart</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jfree.chart.JFreeChart</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jfree.chart.plot.MeterPlot</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jfree.data.general.DefaultValueDataset</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jfree.experimental.chart.swt.ChartComposite</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
* @author martin
*
*/</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MeterChartView <span style="color: #000000; font-weight: bold;">extends</span> ViewPart <span style="color: #009900;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> ID <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;com.martinklinke.eclipse.jfreechart.demo.views.MeterChartView&quot;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> createPartControl<span style="color: #009900;">&#40;</span><span style="color: #003399;">Composite</span> parent<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      JFreeChart chart <span style="color: #339933;">=</span> createChart<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000000; font-weight: bold;">final</span> ChartComposite frame <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ChartComposite<span style="color: #009900;">&#40;</span>parent, SWT.<span style="color: #006633;">NONE</span>, chart, <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setFocus<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #008000; font-style: italic; font-weight: bold;">/**
    * Creates the Chart based on a dataset
    */</span>
   <span style="color: #000000; font-weight: bold;">private</span> JFreeChart createChart<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      DefaultValueDataset data <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DefaultValueDataset<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">20.0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      MeterPlot plot <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> MeterPlot<span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      JFreeChart chart <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JFreeChart<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Meter Chart&quot;</span>,
      JFreeChart.<span style="color: #006633;">DEFAULT_TITLE_FONT</span>, plot, <span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      plot.<span style="color: #006633;">setNoDataMessage</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;No data available&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000000; font-weight: bold;">return</span> chart<span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The result should look like the following screenshot:</p>
<div id="attachment_59" class="wp-caption alignnone" style="width: 579px"><a href="http://www.martinklinke.com/wp-content/uploads/2009/02/speedometer.jpg"><img class="size-full wp-image-59" title="speedometer" src="http://www.martinklinke.com/wp-content/uploads/2009/02/speedometer.jpg" alt="JFreeChart Speedometer in Eclipse View" width="569" height="329" /></a><p class="wp-caption-text">JFreeChart Speedometer in Eclipse View</p></div>
<p>Of course, the MeterPlot can be further customized by calling the plot.setXXX(&#8230;) methods. However, this exercise is left to the willing reader ;)</p>
<div style="text-align:center;width:100%;"><div style="margin:0 0 0 0;"><script type="text/javascript"><!--
google_ad_client = "pub-8213395052465060";
/* 300x250, Erstellt 03.06.10 */
google_ad_slot = "6327321139";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.martinklinke.com/2009/02/18/speedometer-with-jfreechart-in-eclipse/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.371 seconds -->
