<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: frame code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sat, 26 Jul 2008 11:32:16 GMT</pubDate>
    <description>DZone Snippets: frame code</description>
    <item>
      <title>TimeLine //JavaScript Class</title>
      <link>http://snippets.dzone.com/posts/show/5293</link>
      <description>&lt;br /&gt;&lt;br /&gt;&lt;a href="http://jsfromhell.com/classes/timeline"&gt;&lt;br /&gt;Simulates the Adobe Flash timeline. You define the amount of frames, the speed in fps (frames per second) and, at each frame passage an event is called, useful for animations.&lt;br /&gt;&lt;br /&gt;[UPDATED CODE AND HELP CAN BE FOUND HERE]&lt;br /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;//+ Jonas Raoni Soares Silva&lt;br /&gt;//@ http://jsfromhell.com/classes/timeline [v1.0]&lt;br /&gt;&lt;br /&gt;TimeLine = function(fps, f){&lt;br /&gt;	this.fps = fps, this.frames = f;&lt;br /&gt;};&lt;br /&gt;with({o: TimeLine, $: TimeLine.prototype}){&lt;br /&gt;	o.timers = [];&lt;br /&gt;	$.running = !!($.current = +(o.timer = $.time = null));&lt;br /&gt;	o.run = function(){&lt;br /&gt;		var o = this;&lt;br /&gt;		o.timer || (o.timer = setInterval(function(){&lt;br /&gt;			for(var h, d = +(new Date), t = o.timers, i = t.length; i--;){&lt;br /&gt;				(!t[i].running || ((d - t[i].time) / (1e3 / t[i].fps) &gt; t[i].current + 1 &amp;&amp;&lt;br /&gt;				t[i].onframe(++t[i].current), t[i].current &gt;= t[i].frames)) &amp;&amp;&lt;br /&gt;				(h = t.splice(i, 1)[0], h.stop(1));&lt;br /&gt;			}&lt;br /&gt;		}, 1));&lt;br /&gt;	};&lt;br /&gt;	$.start = function(c){&lt;br /&gt;		var o = this, t = TimeLine;&lt;br /&gt;		if(o.running) return;&lt;br /&gt;		o.running = true, o.current = c || 0;&lt;br /&gt;		o.time = new Date, o.onstart &amp;&amp; o.onstart();&lt;br /&gt;		if(!o.onframe || o.frames &lt;= 0 || o.fps &lt;= 0)&lt;br /&gt;			return o.stop(1);&lt;br /&gt;		t.timers.push(this), t.run();&lt;br /&gt;	};&lt;br /&gt;	$.stop = function(){&lt;br /&gt;		var o = this;&lt;br /&gt;		o.running = false;&lt;br /&gt;		if(!TimeLine.timers.length)&lt;br /&gt;			TimeLine.timer = clearInterval(TimeLine.timer), null;&lt;br /&gt;		arguments.length &amp;&amp; o.onstop &amp;&amp; o.onstop();&lt;br /&gt;	};&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Example&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;br /&gt;&lt;div id="box" style="position: absolute; top: 100px; background: #efe; width: 100px; height: 100px"&gt;25 fps&lt;/div&gt;&lt;br /&gt;&lt;div id="box2" style="position: absolute; top: 300px; background: #ff9; width: 100px; height: 100px"&gt;12 fps&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;TimeLine working together with the ease in quad function.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;Math.ease = function (t, b, c, d) {&lt;br /&gt;	if ((t /= d / 2) &lt; 1)&lt;br /&gt;		return c / 2 * t * t + b;&lt;br /&gt;	return -c / 2 * (--t * (t - 2) - 1) + b;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;var o = new TimeLine(25, 50), d = document, b = d.getElementById("box");&lt;br /&gt;o.onframe = function(){&lt;br /&gt;	b.style.left = Math.ease(this.current, 0, 400, 30) + "px";&lt;br /&gt;};&lt;br /&gt;o.onstart = function(){&lt;br /&gt;	d.body.appendChild(d.createTextNode("Started"));&lt;br /&gt;};&lt;br /&gt;o.onstop = function(){&lt;br /&gt;	d.body.appendChild(d.createTextNode(" - Finished (" + (((new Date) - this.time)) + " msec)"))&lt;br /&gt;	d.body.appendChild(d.createElement("br"));&lt;br /&gt;	this.start();&lt;br /&gt;};&lt;br /&gt;o.start();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;var o2 = new TimeLine(12, 50), b2 = d.getElementById("box2");&lt;br /&gt;o2.onframe = function(){&lt;br /&gt;	b2.style.left = Math.ease(this.current, 0, 400, 30) + "px";&lt;br /&gt;};&lt;br /&gt;o2.onstop = function(){&lt;br /&gt;	this.start();&lt;br /&gt;};&lt;br /&gt;o2.start();&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 30 Mar 2008 16:49:21 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5293</guid>
      <author>jonasraoni (Jonas Raoni Soares Silva)</author>
    </item>
    <item>
      <title>Java - JFreeChart Example</title>
      <link>http://snippets.dzone.com/posts/show/2945</link>
      <description>&lt;code&gt;&lt;br /&gt;import java.awt.Font;&lt;br /&gt;&lt;br /&gt;import javax.swing.JFrame;&lt;br /&gt;import javax.swing.JPanel;&lt;br /&gt;&lt;br /&gt;import org.jfree.chart.ChartFactory;&lt;br /&gt;import org.jfree.chart.ChartPanel;&lt;br /&gt;import org.jfree.chart.JFreeChart;&lt;br /&gt;import org.jfree.chart.plot.PiePlot;&lt;br /&gt;import org.jfree.data.general.DefaultPieDataset;&lt;br /&gt;&lt;br /&gt;public class jfcExample extends JFrame&lt;br /&gt;{&lt;br /&gt;	private static final long serialVersionUID = 1L;&lt;br /&gt;	&lt;br /&gt;	private DefaultPieDataset dataset;&lt;br /&gt;	private JFreeChart jfc;&lt;br /&gt;&lt;br /&gt;	public jfcExample()&lt;br /&gt;	{&lt;br /&gt;		dataset = new DefaultPieDataset();&lt;br /&gt;	}&lt;br /&gt;	&lt;br /&gt;	public void setValue(String title, Double numDouble)&lt;br /&gt;	{&lt;br /&gt;		dataset.setValue(title, numDouble);&lt;br /&gt;	}&lt;br /&gt;	&lt;br /&gt;	public void setChar(String title)&lt;br /&gt;	{&lt;br /&gt;		jfc = ChartFactory.createPieChart(title, dataset, true, true, false);&lt;br /&gt;		&lt;br /&gt;		PiePlot pp = (PiePlot) jfc.getPlot();&lt;br /&gt;		pp.setSectionOutlinesVisible(false);&lt;br /&gt;		pp.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));&lt;br /&gt;		pp.setNoDataMessage("Nessun Dato Inserito");&lt;br /&gt;		pp.setCircular(false);&lt;br /&gt;		pp.setLabelGap(0.02);&lt;br /&gt;	}&lt;br /&gt;	&lt;br /&gt;	private JPanel createPanel()&lt;br /&gt;	{&lt;br /&gt;		return new ChartPanel(jfc);&lt;br /&gt;	}&lt;br /&gt;	&lt;br /&gt;	public void Show()&lt;br /&gt;	{&lt;br /&gt;		setContentPane(createPanel());&lt;br /&gt;		setVisible(true);&lt;br /&gt;	}&lt;br /&gt;	&lt;br /&gt;	public static void main(String[] args)&lt;br /&gt;	{&lt;br /&gt;		jfcExample j = new jfcExample();&lt;br /&gt;		j.setTitle("Example Chart...");&lt;br /&gt;		j.setSize(640, 430);&lt;br /&gt;		&lt;br /&gt;		j.setValue("UNO", new Double(20.0));&lt;br /&gt;		j.setValue("DUE", new Double(10.0));&lt;br /&gt;		j.setValue("TRE", new Double(20.0));&lt;br /&gt;		j.setValue("QUATTRO", new Double(30.0));&lt;br /&gt;		j.setValue("CINQUE", new Double(20.0));&lt;br /&gt;		&lt;br /&gt;		j.setChar("Example Chart...");&lt;br /&gt;		&lt;br /&gt;		j.Show();&lt;br /&gt;	}&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 01 Nov 2006 19:03:27 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2945</guid>
      <author>whitetiger ()</author>
    </item>
    <item>
      <title>Java - UIManager all-windows</title>
      <link>http://snippets.dzone.com/posts/show/2017</link>
      <description>// Imposto il tema Metal non solo all'interno delle finestre di Java, ma anche al suo esterno...&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;    // Con queste definizioni dico che tutti i frame e i dialog prendono il tema Metal&lt;br /&gt;    JFrame.setDefaultLookAndFeelDecorated(true);&lt;br /&gt;    JDialog.setDefaultLookAndFeelDecorated(true);&lt;br /&gt;    //&lt;br /&gt;&lt;br /&gt;    try&lt;br /&gt;    {&lt;br /&gt;        // Con questa imposto il tema&lt;br /&gt;	UIManager.setLookAndFeel(new MetalLookAndFeel());&lt;br /&gt;    }&lt;br /&gt;    catch(UnsupportedLookAndFeelException e)&lt;br /&gt;    {&lt;br /&gt;	e.printStackTrace();&lt;br /&gt;    }&lt;br /&gt;    // In questo modo tutte le finestre avranno il tema Metal&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 15 May 2006 01:41:13 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2017</guid>
      <author>whitetiger ()</author>
    </item>
  </channel>
</rss>
