<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>pekalicious</title>
	
	<link>http://pekalicious.com/blog</link>
	<description />
	<lastBuildDate>Sun, 02 Sep 2012 19:29:02 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/pekalicious" /><feedburner:info uri="pekalicious" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Introducing ‘The History of Light’ v1.3 Release</title>
		<link>http://feedproxy.google.com/~r/pekalicious/~3/dUvxIuDC-pg/</link>
		<comments>http://pekalicious.com/blog/introducing-the-history-of-light-v1-3-release/#comments</comments>
		<pubDate>Sat, 01 Sep 2012 02:49:28 +0000</pubDate>
		<dc:creator>Panagiotis Peikidis</dc:creator>
				<category><![CDATA[Work]]></category>
		<category><![CDATA[brandon morris]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[nokia]]></category>
		<category><![CDATA[ovi]]></category>
		<category><![CDATA[the history of light]]></category>

		<guid isPermaLink="false">http://pekalicious.com/blog/?p=764</guid>
		<description><![CDATA[The latest version, 1.3, of The History of Light has been released at the Ovi Store. In this new update, two new worlds were added, with two entirely new and unique mechanics. In addition, each world now has 30 levels, as opposed to 20 in the previous release. That means that the game now has [...]]]></description>
				<content:encoded><![CDATA[<div id="attachment_770" class="wp-caption alignright" style="width: 178px"><a href="http://pekalicious.com/blog/wp-content/uploads/2012/09/screenshot-1.png" rel="lightbox[764]"><img class="size-medium wp-image-770" title="The History of Light" src="http://pekalicious.com/blog/wp-content/uploads/2012/09/screenshot-1-168x300.png" alt="" width="168" height="300" /></a><p class="wp-caption-text">The History of Light</p></div>
<p>The latest version, 1.3, of The History of Light has been released at the <a title="The History of Light - Ovi Store" href="http://bit.ly/TheHistoryOfLight">Ovi Store</a>. In this new update, two new worlds were added, with two entirely new and unique mechanics. In addition, each world now has 30 levels, as opposed to 20 in the previous release. That means that the game now has a whooping 210 levels. Given that the last ten levels of each world are particularly challenging, we expect players to spend a lot of time smashing their pho&#8230;. I mean, enjoying the puzzles that we created. To make it a little more bearable though, the more stars you gain in a level, the more levels are unlocked. Finally, in this release, we are delighted to feature composer Brandon Morris. Each world now has its own music, and most of the tracks come from Brandon&#8217;s collection.</p>
<h1>Introduction</h1>
<p>The History of Light is a fun and challenging puzzle game inspired by the electronic game Lights Out. Given a grid of lights that are either on or off, the goal of the game is to turn all of them off. Lights toggle on or off by clicking on them. However, depending on the world, clicking on a light will also toggle adjacent lights.</p>
<span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='640' height='390' src='http://www.youtube.com/embed/assgEt2LybE?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p style="text-align: center;"><a title="The History of Light - Ovi Store" href="http://bit.ly/TheHistoryOfLight"><img src="http://snac.nokia.com/hosted/50/41/nokia-n9-29-b599.png" alt="The History of Light - Ovi Store" border="0" /></a></p>
<h2 id=''></h2>
<p>&nbsp;</p>
<h1>Worlds</h1>
<p>There are 7 worlds in The History of Light, all based on milestones of light: Sun, Fire, Candle, Kerosene, Incandescent, Fluorescent and L.E.D.</p>
<p>Each world has 30 levels and each level awards you up to 3 stars depending on how few moves (light toggles) you made to solve the puzzle. The stars are required in order to unlock the next worlds.</p>
<h1>Mechanics</h1>
<div id="attachment_768" class="wp-caption alignleft" style="width: 178px"><a href="http://pekalicious.com/blog/wp-content/uploads/2012/09/screenshot-2.jpg" rel="lightbox[764]"><img class="size-medium wp-image-768" title="The History of Light - Worlds" src="http://pekalicious.com/blog/wp-content/uploads/2012/09/screenshot-2-168x300.jpg" alt="" width="168" height="300" /></a><p class="wp-caption-text">The History of Light &#8211; Worlds</p></div>
<p>Each world has it own unique mechanic. The first 20 levels gently introduces the new mechanic to the player, while the last 10 levels includes all the mechanics of the previous worlds! That means that, in the last world, at levels 21 through 30, the player has to solve a puzzle keeping in mind how all 6 mechanics work together!</p>
<p>The very first mechanic of the game is also the original way you play Lights Out: clicking on one light on the grid will toggle it on or off, but will also toggle the top, left, right and bottom lights as well. The First world introduces bombs: some lights have bombs with a countdown. The more times you toggle that specific light, the closer you get to exploding the bomb and ending the game. The Kerosene world toggle the diagonal lights, so all lights surrounding the clicked one are toggled with it. Try the game to discover all the mechanics. The L.E.D. world has a surprise mechanic that will make the player re-think the way the game was working all along!</p>
<h1>Music</h1>
<p>In addition to having different mechanics, in the latest release, each world has its own soundtrack. We found a number of great tracks at OpenGameArt and asked for the artists&#8217; permission to include them. Most of the music though, were from composer Brandon Morris. Brandon was kind enough to give us his music and link us in his own website (still under construction). In return, and as a thank you for his great work, we decided to feature him. We invite you to listen to his tracks on his YouTube channel, <a title="Brandon Morris - YouTube Channel" href="https://www.youtube.com/user/Brandon75689">Brandon75689</a>.</p>
<h1>BossCastle</h1>
<p><a href="http://pekalicious.com/blog/wp-content/uploads/2012/09/BossCastle.png" rel="lightbox[764]"><img class="alignleft size-full wp-image-798" title="BossCastle" src="http://pekalicious.com/blog/wp-content/uploads/2012/09/BossCastle.png" alt="" width="256" height="256" /></a>The History of Light was developed by <a title="BossCastle Studios" href="http://bosscastlestudios.com">BossCastle Studios</a>. A small, independent group of programmers and designers consisting of Panagiotis Peikidis (me), Harris Peikidis (my brother) and Dimitris Xanthopoulos. This game is the first under our belt, but we have plans for new titles in the near future. We have a very diverse knowledge on technologies and platforms and are constantly learning more. Expect to see games anywhere from Android phones, to Windows Phone or even tablets.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/pekalicious?a=dUvxIuDC-pg:aZDpvp1Q1R0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=dUvxIuDC-pg:aZDpvp1Q1R0:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=dUvxIuDC-pg:aZDpvp1Q1R0:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=dUvxIuDC-pg:aZDpvp1Q1R0:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=dUvxIuDC-pg:aZDpvp1Q1R0:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/pekalicious?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/pekalicious/~4/dUvxIuDC-pg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://pekalicious.com/blog/introducing-the-history-of-light-v1-3-release/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://pekalicious.com/blog/introducing-the-history-of-light-v1-3-release/</feedburner:origLink></item>
		<item>
		<title>Introducing: ‘Starcraft Planning Poker Cards’</title>
		<link>http://feedproxy.google.com/~r/pekalicious/~3/XCr9JLUBG4w/</link>
		<comments>http://pekalicious.com/blog/introducing-starcraft-planning-poker-cards/#comments</comments>
		<pubDate>Sat, 04 Aug 2012 23:51:02 +0000</pubDate>
		<dc:creator>Panagiotis Peikidis</dc:creator>
				<category><![CDATA[Work]]></category>
		<category><![CDATA[planning poker]]></category>
		<category><![CDATA[scrum]]></category>
		<category><![CDATA[starcraft]]></category>

		<guid isPermaLink="false">http://pekalicious.com/blog/?p=704</guid>
		<description><![CDATA[When one of our team members left and took his planning poker cards with him, as a fan of Starcraft (albeit, not that good of a player), naturally, I decided to design a deck inspired by Starcraft II: Wings of Liberty. We&#8217;ve been using this deck for over 4 months and today I decided to [...]]]></description>
				<content:encoded><![CDATA[<p>When one of our team members left and took his <a title="Planning Poker - Wikipedia" href="http://en.wikipedia.org/wiki/Planning_poker">planning poker</a> cards with him, as a fan of Starcraft (albeit, <a title="pek on Battle.net" href="http://us.battle.net/sc2/en/profile/3258725/1/pek/">not that good of a player</a>), naturally, I decided to design a deck inspired by <a title="Starcraft II: Wings of Liberty" href="http://us.battle.net/sc2/en/">Starcraft II: Wings of Liberty</a>. We&#8217;ve been using this deck for over 4 months and today I decided to share it with you.</p>
<p><span id="more-704"></span></p>
<h2 id='General-Information'>General Information</h2>
<div id="attachment_729" class="wp-caption alignright" style="width: 229px"><a href="http://pekalicious.com/blog/wp-content/uploads/2012/08/terran_05_hellion.jpg" rel="lightbox[704]"><img class="size-medium wp-image-729" title="Hellion by Yanni Davros" src="http://pekalicious.com/blog/wp-content/uploads/2012/08/terran_05_hellion-219x300.jpg" alt="" width="219" height="300" /></a><p class="wp-caption-text">Hellion by Yanni Davros</p></div>
<p>The entire deck is a standard poker deck with 13 cards for each suit and 2 joker cards. The suits in this case are Protoss, Terran, Zerg and Random. The 2 joker cards are the tech trees and a Starcraft II: Wings of Liberty logo. The backs are the promotional <a title="Starcraft Valentines Day - Kotaku" href="http://kotaku.com/5152941/starcraft-ii-valentines-cards">Starcraft II Valentines Day</a> wallpapers of each race (the random race is all the logos fused together) from Blizzard. The numbering used for the planning poker was the one we use in our team: 0, 1/2, 1, 2, 3, 5, 8, 13, 20, 30, 50, Epic and Question Mark. All the numbers are units from each race (the random race are heroes from the game) while the Epic is their respected logo and the Question Mark is a fun little comic.</p>
<p>All the artists are credited in the Readme.txt file that is included in the zip. The file also includes other information about the reasoning behind the numbers, and other trivia.</p>
<p>To print these cards I used <a title="ArtsCow.com" href="http://www.artscow.com/">ArtsCow.com</a>. I like their editor, which allows you to customize every aspect of the cards (other than the box they come into :/), but I&#8217;m not really impressed by the quality. However, the price was fine and they seem to hold OK after a couple of months of use. If you have any suggestions on where I can print quality plastic cards with a reasonable price for a couple of decks, feel free to add it in the comments.</p>
<p>Fun little trivia: a few months after my team started using these cards, I met <a title="Yianni Davros" href="http://yannidavrosart.com/">Yanni Davros</a>, who happened to have designed the Hellion artwork I used. He is a Starcraft fan as well and has made some <a title="Starcraft Posters - Yanni Davros" href="http://yannidavrosart.mybigcommerce.com/">posters you might want to look</a>.</p>
<p style="text-align: center; font-size: 24; border: 4px solid #27ae27; background-color: #bcffbc; padding-top: 12px; padding-bottom: 12px; vertical-align: middle;"><strong>DOWNLOAD URL<br />
</strong><a title="Starcraft: Wings of Liberty Planning Poker Cards" href="http://bit.ly/StarcraftIIPlanningPoker"><img style="vertical-align: middle; margin-right: 8px;" src="http://pekalicious.com/blog/wp-content/uploads/2012/08/dropbox.png" alt="" width="64" />http://bit.ly/StarcraftIIPlanningPoker</a></p>
<div id="attachment_725" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2012/08/IMG_6191.jpg" rel="lightbox[704]"><img class="size-medium wp-image-725 " title="All cards" src="http://pekalicious.com/blog/wp-content/uploads/2012/08/IMG_6191-300x199.jpg" alt="" width="300" height="199" /></a><p class="wp-caption-text">All cards</p></div>
<h2 id='Process'>Process</h2>
<p>The interface for each race was taken from high resolution (or, at least as high as I could find) screen shots from Google Images. I cut them into pieces and tried to fit them in a poker card format. I included some padding so as to make sure none of the art will be cut off when I order the prints. I used the <a title="Starcraft font - DaFont" href="http://www.dafont.com/starcraft.font">Starcraft font</a> I found in dafont.com for the numbers and names.</p>
<p>For every unit, I search for its portrait, an artwork and its cost in minerals, gas and supply. A lot of that came from the <a title="Starcraft - Wikia" href="http://starcraft.wikia.com">Starcraft Wikia</a> site (which is an amazing source of information for the Starcraft universe).</p>
<div id="attachment_726" class="wp-caption alignleft" style="width: 209px"><a href="http://pekalicious.com/blog/wp-content/uploads/2012/08/IMG_6194.jpg" rel="lightbox[704]"><img class="size-medium wp-image-726 " title="Close up" src="http://pekalicious.com/blog/wp-content/uploads/2012/08/IMG_6194-199x300.jpg" alt="" width="199" height="300" /></a><p class="wp-caption-text">Close up</p></div>
<h2 id='My-selfcriticism'>My self-criticism</h2>
<p>Yes, I know that the Colosus is a 5. The reason for that is simple: I couldn&#8217;t find a good artwork for the Sentry. I also know that the Warp Prism art is actually the Phase Prism concept art by Blizzard. I&#8217;m not a big fan of units with no backgrounds either. Unfortunately, there were not many choices for a lot of units (seriously, no Siege Tank artwork??) while others it&#8217;s hard to decide. I also colored the Broodlord myself, since the one I found was a black &amp; white sketch. I was desperately looking for a good artwork for Aldaris so I could have used the Adjutant, the Overmind and Aldaris as either the Question Mark or the Epic.</p>
<p>Finally, the positions of the numbers follow the traditional trading card games format (such as the mana cost on the top right in Magic: The Gathering) rather than the poker format (which would be a better fit, now that I think of it).</p>
<p>I hope you like it.</p>
<p>En Taro Adun!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/pekalicious?a=XCr9JLUBG4w:98DxEA9OEf0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=XCr9JLUBG4w:98DxEA9OEf0:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=XCr9JLUBG4w:98DxEA9OEf0:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=XCr9JLUBG4w:98DxEA9OEf0:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=XCr9JLUBG4w:98DxEA9OEf0:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/pekalicious?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/pekalicious/~4/XCr9JLUBG4w" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://pekalicious.com/blog/introducing-starcraft-planning-poker-cards/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://pekalicious.com/blog/introducing-starcraft-planning-poker-cards/</feedburner:origLink></item>
		<item>
		<title>Introducing ‘The History of Light’</title>
		<link>http://feedproxy.google.com/~r/pekalicious/~3/NI9NSlnTjWg/</link>
		<comments>http://pekalicious.com/blog/introducing-the-history-of-light/#comments</comments>
		<pubDate>Thu, 12 Jan 2012 00:53:57 +0000</pubDate>
		<dc:creator>Panagiotis Peikidis</dc:creator>
				<category><![CDATA[Work]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[ovi]]></category>
		<category><![CDATA[the history of light]]></category>

		<guid isPermaLink="false">http://pekalicious.com/blog/?p=688</guid>
		<description><![CDATA[The History of Light is a Lights Out-type of puzzle game: There is a grid of lights that are either on or off and your goal is to switch them all off. Clicking on a single tile will toggle it, and its adjacent tiles, on or off. There are five worlds in The History of [...]]]></description>
				<content:encoded><![CDATA[<div id="attachment_689" class="wp-caption alignright" style="width: 226px"><a href="http://pekalicious.com/blog/wp-content/uploads/2012/01/main.png" rel="lightbox[688]"><img class="size-full wp-image-689 " title="The History of Light" src="http://pekalicious.com/blog/wp-content/uploads/2012/01/main.png" alt="The History of Light" width="216" height="384" /></a><p class="wp-caption-text">The History of Light &#8211; Main Menu</p></div>
<p><a title="The History of Light" href="http://pekalicious.com/thehistoryoflight/">The History of Light</a> is a <a title="Light's Out (game)" href="https://en.wikipedia.org/wiki/Lights_Out_%28game%29">Lights Out</a>-type of puzzle game: There is a grid of lights that are either on or off and your goal is to switch them all off. Clicking on a single tile will toggle it, and its adjacent tiles, on or off.</p>
<p>There are five worlds in The History of Light, each with 20 levels and a new unique mechanic. On the second world for example, the player is introduced to the concept of bombs. In addition, the last 8 levels of each world has a bigger grid.</p>
<p>The game was developed by me and Dimitris Xanthopoulos. Audio was provided (with permission) by Brandon Morris, Louis Hostos and various other artists found at <a title="Open Game Art" href="http://opengameart.org/">OpenGameArt.org</a>.</p>
<p>The game is currently available at the <a title="The History of Light (Ovi store)" href="http://store.ovi.com/content/234366">Ovi store</a> and its official website is <a title="The History of Light" href="http://pekalicious.com/thehistoryoflight">http://pekalicious.com/thehistoryoflight</a>.</p>
<p><span id="more-688"></span></p>
<h1>Post Mortem</h1>
<p>While the development of the game took us less than a week (what with Dimitris learning QML and me learning C++) I kept tweaking and refining it until I felt comfortable enough to release it. However, I spent most of the time on the interface rather than the level design which, I believe, will cost me a lot of downloads. I have already got some feedback from some friends and I plan on working on them in the next couple of weeks.</p>
<p>One of the biggest things that didn&#8217;t get to the release was music. The game has one track for the menu and one when playing a level. My initial design was one track for each world from the very talented people at OpenGameArt. Unfortunately, the size of the game leaped from 5MB to more than 15MB. I believe that 15MB is not an acceptable size for a mobile game, so I had to cut it down. I&#8217;m thinking of making a &#8220;Director&#8217;s cut&#8221; edition of the game with full audio. At least that way the player will have a choice of the size of download.</p>
<p>Finally, let&#8217;s talk about the elephant in the room: The Ovi Store. I know that, in this day and age, with iOS and Android being the center of everything, many will wonder why we chose the Ovi Store. iOS was an easy decision; the cost was simply too high: buying a Mac, an iPhone, creating an iOS account etc, etc. Android vs Ovi Store needed a little more thinking. I have a good background in Java but nothing in C++ while Dimitris has a good background in C++ but no Java. Both of us didn&#8217;t have any experience in Android Development or Symbian, so, as far as development time went, they where both the same. It all came down to competition: Android has A LOT of competition compared to Ovi. A friend of Dimitris had previously released a couple of Symbian apps and he provided some good insights on how his apps went. So we went for Ovi after that.</p>
<p>Developing for Symbian had many hiccups. Especially in the audio department. It took me about two weeks to figure out how to fade in/fade out the background music and play sound effects. I finally came with a work around, but I didn&#8217;t like it at all.</p>
<p>There is another platform out there that I would really like to work on: Windows Phone 7. Especially because I am already working on <a title="Xanor" href="http://pekalicious.com/blog/introducing-xanor/">an XNA game</a> which is supported (with some limitations) on the platform. We&#8217;ll see. For the mean time, have a look at the other project Dimitris has released on the Ovi Store: <a title="Galaxy Jump" href="http://store.ovi.com/content/223619">Galaxy Jump</a>.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/pekalicious?a=NI9NSlnTjWg:gnPo90UY678:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=NI9NSlnTjWg:gnPo90UY678:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=NI9NSlnTjWg:gnPo90UY678:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=NI9NSlnTjWg:gnPo90UY678:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=NI9NSlnTjWg:gnPo90UY678:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/pekalicious?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/pekalicious/~4/NI9NSlnTjWg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://pekalicious.com/blog/introducing-the-history-of-light/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://pekalicious.com/blog/introducing-the-history-of-light/</feedburner:origLink></item>
		<item>
		<title>Working on Xanor: The Dialogue System</title>
		<link>http://feedproxy.google.com/~r/pekalicious/~3/s_PFRtzylLA/</link>
		<comments>http://pekalicious.com/blog/working-on-xanor-the-dialogue-system/#comments</comments>
		<pubDate>Mon, 08 Aug 2011 11:43:25 +0000</pubDate>
		<dc:creator>Panagiotis Peikidis</dc:creator>
				<category><![CDATA[Work]]></category>
		<category><![CDATA[dialogue]]></category>
		<category><![CDATA[mass effect]]></category>
		<category><![CDATA[open diagram]]></category>
		<category><![CDATA[xanor]]></category>
		<category><![CDATA[xna]]></category>

		<guid isPermaLink="false">http://pekalicious.com/blog/?p=645</guid>
		<description><![CDATA[As promised, I will be making a series of posts regarding my upcoming video game, Xanor. In this post I will be demonstrating the dialogue system. Before I began designing a whole new dialogue system, I thought I&#8217;d first google what other people have created. The very first hit was this Mass Effect dialogue system. [...]]]></description>
				<content:encoded><![CDATA[<p><a title="Introducing Xanor - pekalicious" href="http://pekalicious.com/blog/introducing-xanor/">As promised</a>, I will be making a series of posts regarding my upcoming video game, Xanor. In this post I will be demonstrating the dialogue system.</p>
<p><span id="more-645"></span>Before I began designing a whole new dialogue system, I thought I&#8217;d first google what other people have created. The very first hit was this <a title="Mass Effect Dialogue Sample" href="http://www.catalinzima.com/2009/04/mass-effect-dialogue-sample/">Mass Effect dialogue system</a>. Not bad I saids to myself. So I<del> copied it</del> investigated it and ended up using a similar system.</p>
<p>At its very core, the dialogue system consists of Branches and Hubs. A branch is a series of speech lines; the sentences a character says as well as his pose (remember, this is a 2D game, so no animations). A branch either terminates the dialogue, or reaches a hub. A hub has a list of branches which basically are the player&#8217;s options.</p>
<p>A hub can be of three types:</p>
<ul>
<li>a Normal Hub<br />
which contains a list of branches,</li>
<li>an End Hub<br />
which terminates the dialogue,</li>
<li>or an Info Hub<br />
which returns to the original hub once the branch ends</li>
</ul>
<p>Pretty straightforward, don&#8217;t you think? Here is a diagram to clear any confusion:</p>
<div id="attachment_674" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2011/08/dialogue-diagram1.png" rel="lightbox[645]"><img class="size-medium wp-image-674" title="dialogue-diagram" src="http://pekalicious.com/blog/wp-content/uploads/2011/08/dialogue-diagram1-300x241.png" alt="Dialogue Diagram" width="300" height="241" /></a><p class="wp-caption-text">Dialogue Diagram</p></div>
<p>While the Mass Effect sample was great, it was way more complicated than what I needed. First of all, Mass Effect has a morality system, so the branches where either good, bad or neutral and they were placed <a title="Mass Effect Dialogue Wheel" href="http://masseffect.wikia.com/wiki/Dialogue">around a wheel</a>. For Info branches, you had to select a special &#8220;Investigate&#8221; option to view them.</p>
<p>I have no morality system, and I don&#8217;t want my info branches to seem any different than any normal branch. So I simplified it by making info branches nothing more than a branch that has its NextHubID set to the same Hub as the one it was choosen from. I also eliminated the limitation of having 3 branches (good, bad and neutral) to unlimited. Finally, I removed the sound property since I won&#8217;t be having any voice overs (sigh).</p>
<p>On the designing side, the sample comes with an editor. Which doesn&#8217;t really look easy to understand:</p>
<div id="attachment_676" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2011/08/masseffect-editor.png" rel="lightbox[645]"><img class="size-medium wp-image-676" title="masseffect-editor" src="http://pekalicious.com/blog/wp-content/uploads/2011/08/masseffect-editor-300x215.png" alt="Mass Effect Dialogue Editor" width="300" height="215" /></a><p class="wp-caption-text">Editor for the Mass Effect-style Dialogue System</p></div>
<p>So I made a more designer-friendly tool:</p>
<div id="attachment_678" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2011/08/xanor-dialogue-editor.png" rel="lightbox[645]"><img class="size-medium wp-image-678" title="xanor-dialogue-editor" src="http://pekalicious.com/blog/wp-content/uploads/2011/08/xanor-dialogue-editor-300x225.png" alt="Xanor Dialogue Editor" width="300" height="225" /></a><p class="wp-caption-text">Xanor Dialogue Editor</p></div>
<p>Reminds you of something?</p>
<p>To do this, I had to test a LOT of diagramming libraries: <a title="Netron" href="http://sourceforge.net/projects/netron/">Netron</a>, <a title="Piccolo2D" href="http://www.piccolo2d.org/">Piccolo2D</a>, <a title="QuickGraph" href="http://quickgraph.codeplex.com/">QuickGraph </a>etc, etc. I ended up with <a title="Open Diagram" href="http://opendiagram.codeplex.com/">Open Diagram</a> mainly for its simplicity.</p>
<p>Here is a boring video that demonstrates how the whole system works (the interesting part is at 1:53):</p>
<!--YouTube Error: bad URL entered-->
<p>Now that I am able to create the dialogues and basically write the entire story of the game, I have to focus on a much more important system: the battle system.</p>
<p>So, stay tuned!</p>
<div id="_mcePaste" class="mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;">QuickGraph</div>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/pekalicious?a=s_PFRtzylLA:8c22DIX1Gk4:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=s_PFRtzylLA:8c22DIX1Gk4:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=s_PFRtzylLA:8c22DIX1Gk4:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=s_PFRtzylLA:8c22DIX1Gk4:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=s_PFRtzylLA:8c22DIX1Gk4:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/pekalicious?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/pekalicious/~4/s_PFRtzylLA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://pekalicious.com/blog/working-on-xanor-the-dialogue-system/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://pekalicious.com/blog/working-on-xanor-the-dialogue-system/</feedburner:origLink></item>
		<item>
		<title>Introducing ‘Xanor’ (WIP)</title>
		<link>http://feedproxy.google.com/~r/pekalicious/~3/eiV17ZjXhxc/</link>
		<comments>http://pekalicious.com/blog/introducing-xanor/#comments</comments>
		<pubDate>Sun, 17 Jul 2011 21:16:35 +0000</pubDate>
		<dc:creator>Panagiotis Peikidis</dc:creator>
				<category><![CDATA[Work]]></category>
		<category><![CDATA[ai game dev]]></category>
		<category><![CDATA[game ai conference]]></category>
		<category><![CDATA[starplanner]]></category>
		<category><![CDATA[xanor]]></category>

		<guid isPermaLink="false">http://pekalicious.com/blog/?p=575</guid>
		<description><![CDATA[Last month I attended the Paris Game AI Conference. Now I&#8217;m back and things look awesome! Time to get back to work! &#160; First of all, I would like to thank Alex Champandard for giving me the opportunity of having a poster of my BSc dissertation, StarPlanner, at this year&#8217;s Paris Game AI Conference. In [...]]]></description>
				<content:encoded><![CDATA[<p>Last month I attended the Paris Game AI Conference. Now I&#8217;m back and things look awesome! Time to get back to work!</p>
<p><span id="more-575"></span></p>
<p>&nbsp;</p>
<p>First of all, I would like to thank Alex Champandard for giving me the opportunity of having a poster of my BSc dissertation, <a title="StarPlanner" href="http://pekalicious.com/starplanner">StarPlanner</a>, at this year&#8217;s <a title="Paris Game AI Conference" href="http://gameaiconf.com">Paris Game AI Conference</a>. In fact, I am thankful to a number of people that helped me during and after the development of the project. Jeff Orkin who linked StarPlanner&#8217;s website on the <a title="Goal-Oriented Action Planning" href="http://web.media.mit.edu/~jorkin/goap.html">official GOAP website</a>, Eric Jacopin who used the source code as learning material for an internship and provided plenty of feedback, <a title="Edmund Long" href="http://www.edmundlong.com">Edmund Long</a> for his implementation of GOAP in C++ and William van der Sterren for his help in the <a title="AIGameDev forums" href="http://aigamedev.com/forums/">AiGameDev</a> forums.</p>
<div id="attachment_652" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2011/07/starplanner_gameaiconf_poster1.jpg" rel="lightbox[575]"><img class="size-medium wp-image-652 " title="starplanner_gameaiconf_poster" src="http://pekalicious.com/blog/wp-content/uploads/2011/07/starplanner_gameaiconf_poster1-300x212.jpg" alt="" width="300" height="212" /></a><p class="wp-caption-text">Wallpaper for the Paris Game AI Conference 2011</p></div>
<p>Planning was a big thing this year, having a short tutorial talk from  Luke Dicken and an entire panel about its pros, cons and future, which  meant that my project was an awesome conversation starter ;) So I met a lot of great people in person. Can&#8217;t wait for next  year&#8217;s conference.</p>
<p>Anyway, on with the main subject.</p>
<p>About ten months ago, I began working on a vertical shooter using the XNA framework. However, I had to stop for a while due to Greek&#8217;s obligatory military training. That is (finally) over and it&#8217;s time to get back to business.</p>
<h1>The Pitch</h1>
<p>Xanor (Working Title) is a vertical shooter (like Aero Fighters) with many JRPG elements such as Leveling up, Mana Power, Talent Trees and Side Quests.</p>
<h1>Game Overview</h1>
<p>Xanor is a top-down space shooter where the player assumes the role of Reik, a pilot who became an outcast as a result of a failed mission that caused his hometown to vanish. With the help of his trusted but, somewhat, clumsy engineer, Mishi, and an advanced alien technology, his mission is now to regain his identity back by reestablishing his hometown as the dominant empire it once was.</p>
<p>Thanks to Mishi&#8217;s talent, the player is able to upgrade his spaceship with powerful weaponry and defenses. Four types of spaceships are available to choose from:</p>
<ul>
<li>The Spartan<br />
This is the most dexterous ship of all. It is able to equip a vast amount of weapons that are easily upgraded.</li>
<li>The M109<br />
This ship is able to receive an extensive amount of damage and still be able to attack.</li>
<li>The Ulonar<br />
The Ulonar becomes more powerful the more damage it receives.</li>
<li>The Summoner<br />
The agile drones that orbit around the Summoner is a great way to get the job done.</li>
</ul>
<p>To make a living and be able to pay the upgrades he needs, Reik hunts down bounties. He has gained a reputation for being fierce and, as a consequence, he is hired by many to do their dirty work (such as escorting ships or flying spacecrafts). Among the scumbags and lowlifes that usually hire him, there is this young woman who awards him with something more valuable than money: information on how to destroy the federation and complete his mission.</p>
<p>However, the destruction of the federation has catastrophic consequences.</p>
<h1>Technical</h1>
<p>Xanor is written in C# using Microsoft&#8217;s XNA Game Studio 4.0 framework. The goal is to release it as an XBOX Live Indie Game. Here is a short video I did a while back (the art is currently placeholder sprites made &#8211; with permission &#8211; by <a title="Squirrel Squid @DeviantArt" href="http://squirrelsquid.deviantart.com/">SquirrelSquid</a>):</p>
<p style="text-align: center;"><!--YouTube Error: bad URL entered--></p>
<p>Under the hood Xanor is going over massive structural changes. I fell into the classic deep hierarchy problem and, after some research, I began working on a <a title="Evolve Your Hierarchy" href="http://cowboyprogramming.com/2007/01/05/evolve-your-heirachy/">component-based entity system</a>.</p>
<p>The good news is that last week I was fortunate enough to meet <a title="SiGra" href="http://sigra1989.deviantart.com/">SiGra</a>, who will be creating Xanor&#8217;s characters. Thus, currently I am focusing on developing a dialogue system.</p>
<p style="text-align: center;">&nbsp;</p>
<div id="attachment_661" class="wp-caption aligncenter" style="width: 240px"><a href="http://pekalicious.com/blog/wp-content/uploads/2011/07/mechanic_resized.jpg" rel="lightbox[575]"><img class="size-medium wp-image-661 " title="The young female mechanic side-kick." src="http://pekalicious.com/blog/wp-content/uploads/2011/07/mechanic_resized-230x300.jpg" alt="" width="230" height="300" /></a><p class="wp-caption-text">Mishi</p></div>
<p>&nbsp;</p>
<p>I will be posting updates of Xanor&#8217;s development as each component of the engine is stable enough for a demonstration. So stay tuned!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/pekalicious?a=eiV17ZjXhxc:g2hG7m-ZJwc:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=eiV17ZjXhxc:g2hG7m-ZJwc:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=eiV17ZjXhxc:g2hG7m-ZJwc:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=eiV17ZjXhxc:g2hG7m-ZJwc:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=eiV17ZjXhxc:g2hG7m-ZJwc:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/pekalicious?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/pekalicious/~4/eiV17ZjXhxc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://pekalicious.com/blog/introducing-xanor/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://pekalicious.com/blog/introducing-xanor/</feedburner:origLink></item>
		<item>
		<title>Training!</title>
		<link>http://feedproxy.google.com/~r/pekalicious/~3/HZl9tJwhvpc/</link>
		<comments>http://pekalicious.com/blog/training/#comments</comments>
		<pubDate>Tue, 19 Apr 2011 18:53:02 +0000</pubDate>
		<dc:creator>Panagiotis Peikidis</dc:creator>
				<category><![CDATA[Work]]></category>
		<category><![CDATA[comic]]></category>
		<category><![CDATA[gameai]]></category>
		<category><![CDATA[xkcd]]></category>

		<guid isPermaLink="false">http://pekalicious.com/blog/?p=632</guid>
		<description><![CDATA[I&#8217;ve been into Game AI a lot lately, and in one of the interviews I watched, the developer had to wait 2-3 days while the AI of the game trained its Neural Network. I then ran into xkcd&#8217;s classic Compiling comic and&#8230; Training &#160;]]></description>
				<content:encoded><![CDATA[<p><a title="StarPlanner" href="http://pekalicious.com/blog/introducing-my-dissertation-starplanner/">I&#8217;ve been into Game AI a lot lately</a>, and in one of the interviews I watched, the developer had to wait 2-3 days while the AI of the game trained its Neural Network. I then ran into <a title="Compiling - XKCD" href="http://xkcd.com/303/">xkcd&#8217;s classic Compiling comic</a> and&#8230;</p>
<p><span id="more-632"></span></p>
<div class="mceTemp mceIEcenter" style="text-align: center;">
<dl id="attachment_633" class="wp-caption aligncenter" style="width: 310px;">
<dt class="wp-caption-dt"><a href="http://pekalicious.com/blog/wp-content/uploads/2011/04/training.png" rel="lightbox[632]"><img class="size-medium wp-image-633   " title="'Are you playing?' 'No, I'm training the AI!'" src="http://pekalicious.com/blog/wp-content/uploads/2011/04/training-300x261.png" alt="Training" width="300" height="261" /></a></dt>
<dd class="wp-caption-dd">Training</dd>
</dl>
</div>
<p style="text-align: center;">&nbsp;</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/pekalicious?a=HZl9tJwhvpc:MEwWTES1VMs:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=HZl9tJwhvpc:MEwWTES1VMs:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=HZl9tJwhvpc:MEwWTES1VMs:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=HZl9tJwhvpc:MEwWTES1VMs:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=HZl9tJwhvpc:MEwWTES1VMs:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/pekalicious?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/pekalicious/~4/HZl9tJwhvpc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://pekalicious.com/blog/training/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://pekalicious.com/blog/training/</feedburner:origLink></item>
		<item>
		<title>Introducing my dissertation: StarPlanner</title>
		<link>http://feedproxy.google.com/~r/pekalicious/~3/v5jJ-Jf-uj8/</link>
		<comments>http://pekalicious.com/blog/introducing-my-dissertation-starplanner/#comments</comments>
		<pubDate>Wed, 30 Mar 2011 21:46:53 +0000</pubDate>
		<dc:creator>Panagiotis Peikidis</dc:creator>
				<category><![CDATA[Work]]></category>
		<category><![CDATA[ai]]></category>
		<category><![CDATA[bwapi]]></category>
		<category><![CDATA[city college]]></category>
		<category><![CDATA[dissertation]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[game programming]]></category>
		<category><![CDATA[gameai]]></category>
		<category><![CDATA[goap]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jbridge]]></category>
		<category><![CDATA[starcraft]]></category>
		<category><![CDATA[starplanner]]></category>
		<category><![CDATA[thesis]]></category>

		<guid isPermaLink="false">http://pekalicious.com/blog/?p=576</guid>
		<description><![CDATA[It&#8217;s about time I shared my final year project with the world. Due to my country&#8217;s military obligations I joined the army right after I got my bachelor, which meant that I didn&#8217;t have time to polish some stuff. However, I had some time off, so here it is! My dissertation: StarPlanner &#8211; Demonstrating the [...]]]></description>
				<content:encoded><![CDATA[<p>It&#8217;s about time I shared my final year project with the world. Due to my country&#8217;s military obligations I joined the army right after I got my bachelor, which meant that I didn&#8217;t have time to polish some stuff. However, I had some time off, so here it is! My dissertation: StarPlanner &#8211; Demonstrating the Use of AI Planning in a Video Game.</p>
<p><span id="more-576"></span></p>
<p style="text-align: center;"><!--YouTube Error: bad URL entered--></p>
<p>StarPlanner is a StarCraft bot that implements a <a title="Goal-Oriented Action Planning (GOAP)" href="http://web.media.mit.edu/~jorkin/goap.html">Goal-Oriented Action Planning (GOAP)</a> agent architecture. The architecture includes a Blackboard for subsystem communications, a working memory and an regressive planner for decision making. There are two levels of planning in StarPlanner: a high level strategic planner that creates a plan depending on the current state of the game and a low level build planner that creates a plan to build or train the required units in order to carry out the high level plan.</p>
<p style="text-align: center;"><!--YouTube Error: bad URL entered--></p>
<p>StarPlanner is written in Java and uses <a title="BWAPI" href="http://code.google.com/p/bwapi/">BWAPI</a> (specifically, <a title="JBridge" href="http://code.google.com/p/bwapi-jbridge/">JBridge</a>) to communicate with StarCraft. The project architecture is layered: at the lowest level there is an A* search engine. On top of that there is a generic GOAP architecture that uses the A* engine for its searching. And, finally, StarPlanner is a concrete implementation for StarCraft of the generic GOAP architecture.</p>
<div id="attachment_579" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2011/03/layers.png" rel="lightbox[576]"><img class="size-medium wp-image-579 " title="StarPlanner Layers" src="http://pekalicious.com/blog/wp-content/uploads/2011/03/layers-300x118.png" alt="StarPlanner Layers" width="300" height="118" /></a><p class="wp-caption-text">StarPlanner Layers</p></div>
<p>Full source code and documentation along with the full report and videos as delivered to City College can be found at <a title="StarPlanner" href="http://pekalicious.com/starplanner/ppeikidis.html ">http://pekalicious.com/starplanner/ppeikidis.html </a></p>
<h2 id='Post-Mortem'>Post Mortem</h2>
<p>I wish I had more time for the project and added a lot more actions from which the bot could choose. The biggest time-waster was trying to create an XNA 2D game from scratch. That was way before I discovered BWAPI in the middle of the semester. Of course, even after I used BWAPI, a lot of the functionality had to be created: controlling units, training units, etc. Although there is an extension of BWAPI called <a title="BWSAL" href="http://code.google.com/p/bwsal/">BWSAL</a> that handles a lot of this for you, this wasn&#8217;t ported in Java.</p>
<p>The GOAP architecture was done thanks to <a title="Edmund Long" href="http://www.edmundlong.com/">Edmund Long</a>&#8216;s MSc thesis &#8220;Enhanced NPC Behavior using Goal Oriented Action Planning&#8221;. Edmund implemented it in C++ in a 2D simulation he developed from scratch. I ported the code in Java and split it into the layers described earlier. This was this easy part.</p>
<p>The hardest part was modeling an RTS game in order to make decisions. Planning is a searching algorithm that uses a world state, a goal state and a set of actions to produce a plan (a sequence of actions that, when executed, will change the world state to the goal state). The actions contain preconditions and effects. Preconditions of an action are essentially a list of properties that must be true in the world state, otherwise the action cannot be performed. If all preconditions are true, the action can be selected. A heuristic is used to decide which of the valid actions should be chosen. Finally, the effects of the chosen action alter the world state and the cycle continues until the world state is the desired one.</p>
<p>So, initially the idea was to use any data type as a precondition and an effect. The world state then would have a set of integers, booleans or anything really. So, for example, when I wanted to create a plan that trained 3 Marines, the goal state would have an integer &#8220;marines = 3&#8243; as a precondition. The plan then would be &#8220;Build Barrack&#8221; -&gt; &#8220;Train Marine&#8221; -&gt; &#8220;Train Marine&#8221; -&gt; &#8220;Train Marine&#8221;. Unfortunately this was harder than I thought so I went with a boolean-based approach. However, this solution has other limitations. For example, a precondition can be &#8220;haveMarines = true&#8221;. But how many marines? 10? 12? 100? So finally, I decoupled the units from the buildings and now training is the responsibility of a TrainManager who constantly trains units  (as long as there are resources) until a new plan is created.</p>
<p>The bot is not, by any stretch of the imagination, a good AI player. It only does a limited number of actions and hardly can win a game (except when you are demonstrating it *cough*custom*cough*maps*cough). There where two reasons for this: first, I had to create managers that could successfully move units, battle against enemies, use unit abilities, upgrade, etc, etc, etc. And second, at the time, I wasn&#8217;t that much of a good player in StarCraft. I&#8217;m no pro, mind you, but I have been following the StarCraft II community (which, incidentally, launched right in the middle of my project) and realized how bad a player I was. A big thanks to Sean Plott and his <a title="Day[9] Daily" href="http://day9tv.blip.tv/">Day[9] Daily</a> videos who made it clear what is actually a strategy and what is a tactic in an RTS game.</p>
<p>All these delays also made it impossible to enter the first <a title="StarCraft AI Competition" href="http://eis.ucsc.edu/StarCraftAICompetition">StarCraft AI Competition</a> that was announced a while before I began the project. Another lost opportunity.</p>
<h2 id='Final-Thoughts'>Final Thoughts</h2>
<p>Even though a lot of things could have gone better, I am really satisfied with the results. When I started my dissertation 2 years ago, planning was a big deal in the world of Game AI, so I was kind of proud. I still am. In fact, I loved so much working on the project, that my professional goal is to work in the Game AI industry!</p>
<p>After attending the first <a title="Hellenic Artificial Intelligence Summer School" href="http://www.icsd.aegean.gr/haiss09/">Hellenic Artificial Intelligence Summer School</a>, I&#8217;m on my way to this year&#8217;s <a title="Paris Game AI Conference" href="http://gameaiconf.com/">Paris Game AI Conference</a>. All the while creating my first XNA video game for XBOX Live (coming up in a future post).</p>
<p>So yeah, once I&#8217;m done with my country&#8217;s military obligations this August, I&#8217;m flying to USA <a title="Panagiotis Peikidis CV" href="http://pekalicious.com/cv">looking for a job</a>. Wish me good luck!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/pekalicious?a=v5jJ-Jf-uj8:oLYSZsA05Eo:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=v5jJ-Jf-uj8:oLYSZsA05Eo:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=v5jJ-Jf-uj8:oLYSZsA05Eo:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=v5jJ-Jf-uj8:oLYSZsA05Eo:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=v5jJ-Jf-uj8:oLYSZsA05Eo:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/pekalicious?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/pekalicious/~4/v5jJ-Jf-uj8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://pekalicious.com/blog/introducing-my-dissertation-starplanner/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://pekalicious.com/blog/introducing-my-dissertation-starplanner/</feedburner:origLink></item>
		<item>
		<title>CodeSOD: How to avoid the expensive “If-then-else” statement</title>
		<link>http://feedproxy.google.com/~r/pekalicious/~3/jxvxsBg0yR0/</link>
		<comments>http://pekalicious.com/blog/codesod-how-to-avoid-the-expensive-if-statement/#comments</comments>
		<pubDate>Fri, 03 Sep 2010 19:25:58 +0000</pubDate>
		<dc:creator>Panagiotis Peikidis</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[fun]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://pekalicious.com/blog/?p=518</guid>
		<description><![CDATA[About two years ago, in Data Structures and Algorithms, our lecturer briefly talked about the &#8220;If-then-else&#8221; statement and how much expensive it is as an operation. Leaving us with many questions, I extensively researched the topic and found out that the word &#8220;expensive&#8221; is, well, really relative. Nevertheless, a particular student found a way to [...]]]></description>
				<content:encoded><![CDATA[<p>About two years ago, in Data Structures and Algorithms, our lecturer briefly talked about the &#8220;If-then-else&#8221; statement and how much expensive it is as an operation. Leaving us with many questions, <a title="StackOverflow: Is &quot;If&quot; expensive?" href="http://stackoverflow.com/questions/315306/is-if-expensive">I extensively researched the topic</a> and found out that the word &#8220;expensive&#8221; is, well, really relative. Nevertheless, a particular student found a way to avoid the cost&#8230;</p>
<p><span id="more-518"></span></p>
<p>First of all, here is how much you need to worry about the cost of the &#8220;If-then-else&#8221; statement: not at all*. You see, an &#8220;If-then-else&#8221; statement in your code creates a branch in the instruction list. If the statement is true, the processor will execute a particular instruction list, if not, it will execute another. The processor, always striving for optimizations, tries to predict which way the branch will go and pre-load the instructions. A wrong prediction is known as a &#8220;<a title="Google: Branch Misprediction" href="http://www.google.com/search?q=branch misprediction">Branch Miprediction</a>&#8220;. The penalty? In modern microprocessors, 10-20 cycles<a href="#wikipedia-branch-misprediction">[1]</a>. Your average 2.4GHz CPU can perform 2.400.000.000 cycles/second. That is 2.4 billion cycles per seconds, in case you haven&#8217;t noticed. Billions&#8230; Per second&#8230; So I think it&#8217;s pretty safe to say that this has absolutely no affect in your average pet-project.</p>
<p>One particular student, however, took this at face value and came up with the following gem:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java5" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">void</span> doSomething<span style="color: #009900;">&#40;</span><span style="color: #006600; font-weight: bold;">int</span> code<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000000;  font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span> code == <span style="color: #cc66cc;">101</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    doThis<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #000000;  font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span> code == <span style="color: #cc66cc;">102</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    doThat<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #000000;  font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span> code == <span style="color: #cc66cc;">103</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    justDoIt<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  ...
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>After I got over the initial shock I turned to him and asked &#8220;So why didn&#8217;t you use a for loop?&#8221; to which he replied &#8220;I would have, but the while loop came into my mind first.&#8221;</p>
<p>* Except if you are writing an extremely performance-critical application.</p>
<h3 id='References'>References</h3>
<p><a name="wikipedia-branch-misprediction">[1]</a>: <a title="Wikipedia: Branch Predictor" href="http://en.wikipedia.org/wiki/Branch_predictor">Branch Predictor &#8211; Wikipedia</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/pekalicious?a=jxvxsBg0yR0:nwcd2FGjJ58:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=jxvxsBg0yR0:nwcd2FGjJ58:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=jxvxsBg0yR0:nwcd2FGjJ58:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=jxvxsBg0yR0:nwcd2FGjJ58:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=jxvxsBg0yR0:nwcd2FGjJ58:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/pekalicious?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/pekalicious/~4/jxvxsBg0yR0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://pekalicious.com/blog/codesod-how-to-avoid-the-expensive-if-statement/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://pekalicious.com/blog/codesod-how-to-avoid-the-expensive-if-statement/</feedburner:origLink></item>
		<item>
		<title>Custom JPanel cell with JButtons in JTable</title>
		<link>http://feedproxy.google.com/~r/pekalicious/~3/ogkVgRBjgCA/</link>
		<comments>http://pekalicious.com/blog/custom-jpanel-cell-with-jbuttons-in-jtable/#comments</comments>
		<pubDate>Tue, 31 Aug 2010 15:24:16 +0000</pubDate>
		<dc:creator>Panagiotis Peikidis</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[JPanel]]></category>
		<category><![CDATA[JTable]]></category>
		<category><![CDATA[TableCellEditor]]></category>
		<category><![CDATA[TableCellRenderer]]></category>
		<category><![CDATA[TableModel]]></category>

		<guid isPermaLink="false">http://pekalicious.com/blog/?p=502</guid>
		<description><![CDATA[If you ever wanted to add a JPanel with various interactive components (e.g. JButtons, JCheckBoxes etc.) in a JTable cell and could not figure out how to make them work, then this post is for you. Otherwise, continue googling ;) The Intro It&#8217;s really difficult to find something in the Internet when you are not [...]]]></description>
				<content:encoded><![CDATA[<p>If you ever wanted to add a JPanel with various interactive components (e.g. JButtons, JCheckBoxes etc.) in a JTable cell and could not figure out how to make them work, then this post is for you. Otherwise, continue googling ;)</p>
<p><span id="more-502"></span> </p>
<h1>The Intro</h1>
<p>It&#8217;s really difficult to find something in the Internet when you are not really sure how to phrase it. That&#8217;s why you need to practice your google-fu as much as possible. See, I was looking for a way to have a JPanel with buttons in a JTable cell, but had no idea how to look for it. <a title="Google search: JPanel in JTable" href="http://www.google.com/search?q=JPanel%20in%20JTable">JPanel in JTable</a>? <a title="Google search: JPanel with buttons in JTable" href="http://www.google.com/search?q=JPanel+with+buttons+in+JTable">JPanel with buttons in JTable</a>? <a title="Google search: JTable JPanel JButton" href="http://www.google.com/search?q=JTable+JPanel+JButton">JTable JPanel JButton</a>?</p>
<p>OK, to be fair, I&#8217;m pretty sure my answer is in there somewhere deep (as in, after the first 3 results). But, as any impatient person that respects himself, I went the easy way: StackOverflow: <a title="StackOverflow: JTable: Buttons in Custom Panel in Cell" href="http://stackoverflow.com/questions/3606864/jtable-buttons-in-custom-panel-in-cell">JTable: Buttons in Custom Panel in Cell</a>.</p>
<p>You see, most examples I found with Google talked about Cell Editors, but for simple column components, such as using a JTextField to edit an integer, or a JComboBox to edit a String etc. I wanted a custom JPanel that did not change, but simply had interactive controls.</p>
<p>In retrospect, I could have simply used a panel with MigLayout, but NO! I wanted the challenge. I wanted to learn how to do it. Plus, now I can sort my table (which is absolutely useless in my context).</p>
<p>Anyway, on with the code!</p>
<h1>The Code</h1>
<p>First thing&#8217;s first, we need to have a basic ADT that will contain some data. This is what we ultimately want to display in our table rows. Let&#8217;s say we want to have some RSS Feeds.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java5" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> RssFeed <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">String</span> name<span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">String</span> url<span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">public</span> Article<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> articles<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> RssFeed<span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">String</span> name, <span style="color: #003399; font-weight: bold;">String</span> url, Article<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> articles<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">name</span> = name<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">url</span> = url<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">articles</span> = articles<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Article <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">String</span> title<span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">String</span> url<span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">String</span> content<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> Article<span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">String</span> title, <span style="color: #003399; font-weight: bold;">String</span> url, <span style="color: #003399; font-weight: bold;">String</span> content<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">title</span> = title<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">url</span> = url<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">content</span> = content<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>
Yeah yeah, make the fields private, add getters/setters blah blah blah. Here is a simple JFrame that displays a JTable with some example data:
</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java5" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> JInteractiveTableExample <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399; font-weight: bold;">JFrame</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">public</span> JInteractiveTableExample<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Interactive Table Cell Example&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    setDefaultCloseOperation<span style="color: #009900;">&#40;</span>EXIT_ON_CLOSE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    setSize<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">500</span>, <span style="color: #cc66cc;">300</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003399; font-weight: bold;">List</span><span style="color: #339933;">&lt;</span>RssFeed<span style="color: #339933;">&gt;</span> feeds = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">ArrayList</span><span style="color: #339933;">&lt;</span>RssFeed<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    feeds.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> RssFeed<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;pekalicious&quot;</span>, <span style="color: #0000ff;">&quot;http://feeds2.feedburner.com/pekalicious&quot;</span>,
      <span style="color: #000000; font-weight: bold;">new</span> Article<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">new</span> Article<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Title1&quot;</span>, <span style="color: #0000ff;">&quot;http://title1.com&quot;</span>, <span style="color: #0000ff;">&quot;Content 1&quot;</span><span style="color: #009900;">&#41;</span>,
        <span style="color: #000000; font-weight: bold;">new</span> Article<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Title2&quot;</span>, <span style="color: #0000ff;">&quot;http://title2.com&quot;</span>, <span style="color: #0000ff;">&quot;Content 2&quot;</span><span style="color: #009900;">&#41;</span>,
        <span style="color: #000000; font-weight: bold;">new</span> Article<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Title3&quot;</span>, <span style="color: #0000ff;">&quot;http://title3.com&quot;</span>, <span style="color: #0000ff;">&quot;Content 3&quot;</span><span style="color: #009900;">&#41;</span>,
        <span style="color: #000000; font-weight: bold;">new</span> Article<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Title4&quot;</span>, <span style="color: #0000ff;">&quot;http://title4.com&quot;</span>, <span style="color: #0000ff;">&quot;Content 4&quot;</span><span style="color: #009900;">&#41;</span>,
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    feeds.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> RssFeed<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Various Thoughts on Photography&quot;</span>, <span style="color: #0000ff;">&quot;http://various-photography-thoughts.blogspot.com/feeds/posts/default&quot;</span>,
      <span style="color: #000000; font-weight: bold;">new</span> Article<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">new</span> Article<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Title1&quot;</span>, <span style="color: #0000ff;">&quot;http://title1.com&quot;</span>, <span style="color: #0000ff;">&quot;Content 1&quot;</span><span style="color: #009900;">&#41;</span>,
        <span style="color: #000000; font-weight: bold;">new</span> Article<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Title2&quot;</span>, <span style="color: #0000ff;">&quot;http://title2.com&quot;</span>, <span style="color: #0000ff;">&quot;Content 2&quot;</span><span style="color: #009900;">&#41;</span>,
        <span style="color: #000000; font-weight: bold;">new</span> Article<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Title3&quot;</span>, <span style="color: #0000ff;">&quot;http://title3.com&quot;</span>, <span style="color: #0000ff;">&quot;Content 3&quot;</span><span style="color: #009900;">&#41;</span>,
        <span style="color: #000000; font-weight: bold;">new</span> Article<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Title4&quot;</span>, <span style="color: #0000ff;">&quot;http://title4.com&quot;</span>, <span style="color: #0000ff;">&quot;Content 4&quot;</span><span style="color: #009900;">&#41;</span>,
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003399; font-weight: bold;">JTable</span> table = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">JTable</span><span style="color: #009900;">&#40;</span>
      <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">Object</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">new</span> RssFeed<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#123;</span> feeds.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#125;</span>,
        <span style="color: #000000; font-weight: bold;">new</span> RssFeed<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#123;</span> feeds.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span>,
      <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">&quot;Feeds&quot;</span> <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    add<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">JScrollPane</span><span style="color: #009900;">&#40;</span>table<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Here we create two RssFeeds with articles on the fly and add them to a JTable. If we run this example, we will see that each row displays the toString() value of our RssFeed object.</p>
<div id="attachment_504" class="wp-caption alignnone" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/08/jtable_without_renderer.png" rel="lightbox[502]"><img class="size-medium wp-image-504 " title="jtable_without_renderer" src="http://pekalicious.com/blog/wp-content/uploads/2010/08/jtable_without_renderer-300x225.png" alt="JTable without a Cell Renderer" width="300" height="225" /></a><p class="wp-caption-text">JTable without a Cell Renderer</p></div>
<p>This is the default behavior of JTable when the data is not a known class (Strings, ints, etc.) We can change this behavior by creating a custom TableModel. Here is a basic table model for our example:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java5" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> RssFeedTableModel <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399; font-weight: bold;">AbstractTableModel</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003399; font-weight: bold;">List</span> feeds<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> RssFeedTableModel<span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">List</span> feeds<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">feeds</span> = feeds<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">Class</span> getColumnClass<span style="color: #009900;">&#40;</span><span style="color: #006600; font-weight: bold;">int</span> columnIndex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">return</span> RssFeed.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">int</span> getColumnCount<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">String</span> getColumnName<span style="color: #009900;">&#40;</span><span style="color: #006600; font-weight: bold;">int</span> columnIndex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #0000ff;">&quot;Feed&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">int</span> getRowCount<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span>feeds == <span style="color: #006600; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> <span style="color: #cc66cc;">0</span> : feeds.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">Object</span> getValueAt<span style="color: #009900;">&#40;</span><span style="color: #006600; font-weight: bold;">int</span> rowIndex, <span style="color: #006600; font-weight: bold;">int</span> columnIndex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span>feeds == <span style="color: #006600; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> <span style="color: #006600; font-weight: bold;">null</span> : feeds.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>rowIndex<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">boolean</span> isCellEditable<span style="color: #009900;">&#40;</span><span style="color: #006600; font-weight: bold;">int</span> columnIndex, <span style="color: #006600; font-weight: bold;">int</span> rowIndex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #006600; font-weight: bold;">true</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>
We then simply change our table declaration to:
</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java5" style="font-family:monospace;"><span style="color: #003399; font-weight: bold;">JTable</span> table = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">JTable</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> RssFeedTableModel<span style="color: #009900;">&#40;</span>feeds<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Voila! We now see the exact same thing in our table!</p>
<div id="attachment_504" class="wp-caption alignnone" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/08/jtable_without_renderer.png" rel="lightbox[502]"><img class="size-medium wp-image-504" title="jtable_without_renderer" src="http://pekalicious.com/blog/wp-content/uploads/2010/08/jtable_without_renderer-300x225.png" alt="JTable with Table Model (but still no Cell Renderer)" width="300" height="225" /></a><p class="wp-caption-text">JTable with Table Model (but still no Cell Renderer)</p></div>
<p>Errr.. OK, so it turns out that it&#8217;s not the Model that converts our objects into Strings, but the Renderer. Each JTable has a TableCellRenderer that, given an object, it returns a Swing component that can be used to display the underlying data.</p>
<p>So now we need to tell the JTable how to convert an RssFeed into a Component. We can do this by implementing the TableCellRenderer like so:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java5" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> RssFeedCellRenderer <span style="color: #000000; font-weight: bold;">implements</span> <span style="color: #003399; font-weight: bold;">TableCellRenderer</span><span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">Component</span> getTableCellRendererComponent<span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">JTable</span> table, <span style="color: #003399; font-weight: bold;">Object</span> value,
        <span style="color: #006600; font-weight: bold;">boolean</span> isSelected, <span style="color: #006600; font-weight: bold;">boolean</span> hasFocus, <span style="color: #006600; font-weight: bold;">int</span> row, <span style="color: #006600; font-weight: bold;">int</span> column<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    RssFeed feed = <span style="color: #009900;">&#40;</span>RssFeed<span style="color: #009900;">&#41;</span>value<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003399; font-weight: bold;">JButton</span> showButton = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">JButton</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;View Articles&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    showButton.<span style="color: #006633;">addActionListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">ActionListener</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">void</span> actionPerformed<span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">ActionEvent</span> arg0<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">&#40;</span><span style="color: #006600; font-weight: bold;">null</span>, <span style="color: #0000ff;">&quot;HA-HA!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003399; font-weight: bold;">JPanel</span> panel = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">JPanel</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">FlowLayout</span><span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">FlowLayout</span>.<span style="color: #006633;">LEFT</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    panel.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">JLabel</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;strong&gt;&quot;</span> + feed.<span style="color: #006633;">name</span> + <span style="color: #0000ff;">&quot;&lt;/strong&gt;&quot;</span>
            + feed.<span style="color: #006633;">url</span> + <span style="color: #0000ff;">&quot;Articles &quot;</span> + feed.<span style="color: #006633;">articles</span>.<span style="color: #006633;">length</span> + <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    panel.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>showButton<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000;  font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>isSelected<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      panel.<span style="color: #006633;">setBackground</span><span style="color: #009900;">&#40;</span>table.<span style="color: #006633;">getSelectionBackground</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #000000;  font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
      panel.<span style="color: #006633;">setBackground</span><span style="color: #009900;">&#40;</span>table.<span style="color: #006633;">getSelectionForeground</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">return</span> panel<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>
We also need to register this renderer in our table:
</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java5" style="font-family:monospace;"><span style="color: #003399; font-weight: bold;">JTable</span> table = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">JTable</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> RssFeedTableModel<span style="color: #009900;">&#40;</span>feeds<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
table.<span style="color: #006633;">setDefaultRenderer</span><span style="color: #009900;">&#40;</span>RssFeed.<span style="color: #000000; font-weight: bold;">class</span>, <span style="color: #000000; font-weight: bold;">new</span> RssFeedCellRenderer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
table.<span style="color: #006633;">setRowHeight</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">60</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>
In the above lines, we effectively say &#8220;Whenever a column is an RssFeed class, use this renderer&#8221;. We already said that our one and only column is of type RssFeed in our table model:
</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java5" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">Class</span> getColumnClass<span style="color: #009900;">&#40;</span><span style="color: #006600; font-weight: bold;">int</span> columnIndex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">return</span> RssFeed.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Now if we run our application, we can finally see something useful (although, I still prefer reading &#8220;com.pekalicious.interactiveJPanelTableCell.data.RssFeed@106caf16&#8243;. Yes, I&#8217;m THAT good):</p>
<div id="attachment_512" class="wp-caption alignnone" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/08/jtable_with_renderer_without_editor1.png" rel="lightbox[502]"><img class="size-medium wp-image-512" title="jtable_with_renderer_without_editor" src="http://pekalicious.com/blog/wp-content/uploads/2010/08/jtable_with_renderer_without_editor1-300x180.png" alt="JTable with Renderer" width="300" height="180" /></a><p class="wp-caption-text">JTable with Renderer</p></div>
<p>There are two things that are wrong here: first, every time the JTable needs to render a cell, it will instantiate a new JPanel. This can harm the performance if there are many rows. Second, the button does not work! Cell renderers are used only for what they say, to render cells. They do not provide any mechanism for the underlying components. However, JTable also has Cell Editors. Cell Editors work pretty much the same way as Renderers, they take an Object and return a Component, but the component returned can be interactive.</p>
<p>As you have probably guessed already, you can have different components returned by renderers and editors. An int, for example, can be rendered using a JLabel and edited using a JTextField (which is the default behavior of JTable). However, in our example, we want the same panel both for editing and rendering. This is why we will create a common Component that will be used by both:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java5" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> RssFeedCellComponent <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399; font-weight: bold;">JPanel</span> <span style="color: #009900;">&#123;</span>
  RssFeed feed<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #003399; font-weight: bold;">JButton</span> showButton<span style="color: #339933;">;</span>
  <span style="color: #003399; font-weight: bold;">JLabel</span> text<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> RssFeedCellComponent<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    showButton = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">JButton</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;View Articles&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    showButton.<span style="color: #006633;">addActionListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">ActionListener</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">void</span> actionPerformed<span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">ActionEvent</span> arg0<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">&#40;</span><span style="color: #006600; font-weight: bold;">null</span>, <span style="color: #0000ff;">&quot;Reading &quot;</span> + feed.<span style="color: #006633;">name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    text = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">JLabel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    add<span style="color: #009900;">&#40;</span>text<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    add<span style="color: #009900;">&#40;</span>showButton<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: #006600; font-weight: bold;">void</span> updateData<span style="color: #009900;">&#40;</span>RssFeed feed, <span style="color: #006600; font-weight: bold;">boolean</span> isSelected, <span style="color: #003399; font-weight: bold;">JTable</span> table<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">feed</span> = feed<span style="color: #339933;">;</span>
&nbsp;
    text.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;strong&gt;&quot;</span> + feed.<span style="color: #006633;">name</span> + <span style="color: #0000ff;">&quot;&lt;/strong&gt;&quot;</span> + feed.<span style="color: #006633;">url</span> + <span style="color: #0000ff;">&quot;Articles &quot;</span> + feed.<span style="color: #006633;">articles</span>.<span style="color: #006633;">length</span> + <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000;  font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>isSelected<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      setBackground<span style="color: #009900;">&#40;</span>table.<span style="color: #006633;">getSelectionBackground</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #000000;  font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
      setBackground<span style="color: #009900;">&#40;</span>table.<span style="color: #006633;">getSelectionForeground</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>
Now, our cell renderer becomes:
</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java5" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> RssFeedCellRenderer <span style="color: #000000; font-weight: bold;">implements</span> <span style="color: #003399; font-weight: bold;">TableCellRenderer</span><span style="color: #009900;">&#123;</span>
  RssFeedCellComponent feedComponent<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> RssFeedCellRenderer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    feedComponent = <span style="color: #000000; font-weight: bold;">new</span> RssFeedCellComponent<span style="color: #009900;">&#40;</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: #003399; font-weight: bold;">Component</span> getTableCellRendererComponent<span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">JTable</span> table, <span style="color: #003399; font-weight: bold;">Object</span> value,
      <span style="color: #006600; font-weight: bold;">boolean</span> isSelected, <span style="color: #006600; font-weight: bold;">boolean</span> hasFocus, <span style="color: #006600; font-weight: bold;">int</span> row, <span style="color: #006600; font-weight: bold;">int</span> column<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    RssFeed feed = <span style="color: #009900;">&#40;</span>RssFeed<span style="color: #009900;">&#41;</span>value<span style="color: #339933;">;</span>
&nbsp;
    feedComponent.<span style="color: #006633;">updateData</span><span style="color: #009900;">&#40;</span>feed, isSelected, table<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">return</span> feedComponent<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>
And once again, nothing changed! But we did optimize (and that&#8217;s always good, right?). Now, there is only one instance of  RssFeedCellComponent which changes it&#8217;s components depending on the RssFeed passed. In addition, creating a Cell Editor that returns the same component is now pretty simple:
</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java5" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> RssFeedCellEditor <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399; font-weight: bold;">AbstractCellEditor</span> <span style="color: #000000; font-weight: bold;">implements</span> <span style="color: #003399; font-weight: bold;">TableCellEditor</span> <span style="color: #009900;">&#123;</span>
  RssFeedCellComponent feedComponent<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> RssFeedCellEditor<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    feedComponent = <span style="color: #000000; font-weight: bold;">new</span> RssFeedCellComponent<span style="color: #009900;">&#40;</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: #003399; font-weight: bold;">Component</span> getTableCellEditorComponent<span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">JTable</span> table, <span style="color: #003399; font-weight: bold;">Object</span> value,
      <span style="color: #006600; font-weight: bold;">boolean</span> isSelected, <span style="color: #006600; font-weight: bold;">int</span> row, <span style="color: #006600; font-weight: bold;">int</span> column<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    RssFeed feed = <span style="color: #009900;">&#40;</span>RssFeed<span style="color: #009900;">&#41;</span>value<span style="color: #339933;">;</span>
    feedComponent.<span style="color: #006633;">updateData</span><span style="color: #009900;">&#40;</span>feed, <span style="color: #006600; font-weight: bold;">true</span>, table<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">return</span> feedComponent<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">Object</span> getCellEditorValue<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #006600; font-weight: bold;">null</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>
And now we register our editor:
</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java5" style="font-family:monospace;"><span style="color: #003399; font-weight: bold;">JTable</span> table = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">JTable</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> RssFeedTableModel<span style="color: #009900;">&#40;</span>feeds<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
table.<span style="color: #006633;">setDefaultRenderer</span><span style="color: #009900;">&#40;</span>RssFeed.<span style="color: #000000; font-weight: bold;">class</span>, <span style="color: #000000; font-weight: bold;">new</span> RssFeedCellRenderer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
table.<span style="color: #006633;">setDefaultEditor</span><span style="color: #009900;">&#40;</span>RssFeed.<span style="color: #000000; font-weight: bold;">class</span>, <span style="color: #000000; font-weight: bold;">new</span> RssFeedCellEditor<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
table.<span style="color: #006633;">setRowHeight</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">60</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>We can do even better. We can combine all three classes, RssFeedCellComponent, RssFeedCellRenderer and RssFeedCellEditor into a single RssFeedCell:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java5" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> RssFeedCell <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399; font-weight: bold;">AbstractCellEditor</span> <span style="color: #000000; font-weight: bold;">implements</span> <span style="color: #003399; font-weight: bold;">TableCellEditor</span>, <span style="color: #003399; font-weight: bold;">TableCellRenderer</span><span style="color: #009900;">&#123;</span>
  <span style="color: #003399; font-weight: bold;">JPanel</span> panel<span style="color: #339933;">;</span>
  <span style="color: #003399; font-weight: bold;">JLabel</span> text<span style="color: #339933;">;</span>
  <span style="color: #003399; font-weight: bold;">JButton</span> showButton<span style="color: #339933;">;</span>
&nbsp;
  RssFeed feed<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> RssFeedCell<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    text = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">JLabel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    showButton = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">JButton</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;View Articles&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    showButton.<span style="color: #006633;">addActionListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">ActionListener</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">void</span> actionPerformed<span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">ActionEvent</span> arg0<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">&#40;</span><span style="color: #006600; font-weight: bold;">null</span>, <span style="color: #0000ff;">&quot;Reading &quot;</span> + feed.<span style="color: #006633;">name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    panel = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">JPanel</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">FlowLayout</span><span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">FlowLayout</span>.<span style="color: #006633;">LEFT</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    panel.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>text<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    panel.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>showButton<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;">private</span> <span style="color: #006600; font-weight: bold;">void</span> updateData<span style="color: #009900;">&#40;</span>RssFeed feed, <span style="color: #006600; font-weight: bold;">boolean</span> isSelected, <span style="color: #003399; font-weight: bold;">JTable</span> table<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">feed</span> = feed<span style="color: #339933;">;</span>
&nbsp;
    text.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;strong&gt;&quot;</span> + feed.<span style="color: #006633;">name</span> + <span style="color: #0000ff;">&quot;&lt;/strong&gt;&quot;</span> + feed.<span style="color: #006633;">url</span> + <span style="color: #0000ff;">&quot;Articles &quot;</span> + feed.<span style="color: #006633;">articles</span>.<span style="color: #006633;">length</span> + <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000;  font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>isSelected<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      panel.<span style="color: #006633;">setBackground</span><span style="color: #009900;">&#40;</span>table.<span style="color: #006633;">getSelectionBackground</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #000000;  font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
      panel.<span style="color: #006633;">setBackground</span><span style="color: #009900;">&#40;</span>table.<span style="color: #006633;">getSelectionForeground</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">Component</span> getTableCellEditorComponent<span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">JTable</span> table, <span style="color: #003399; font-weight: bold;">Object</span> value,
      <span style="color: #006600; font-weight: bold;">boolean</span> isSelected, <span style="color: #006600; font-weight: bold;">int</span> row, <span style="color: #006600; font-weight: bold;">int</span> column<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    RssFeed feed = <span style="color: #009900;">&#40;</span>RssFeed<span style="color: #009900;">&#41;</span>value<span style="color: #339933;">;</span>
    updateData<span style="color: #009900;">&#40;</span>feed, <span style="color: #006600; font-weight: bold;">true</span>, table<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">return</span> panel<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">Object</span> getCellEditorValue<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #006600; font-weight: bold;">null</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: #003399; font-weight: bold;">Component</span> getTableCellRendererComponent<span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">JTable</span> table, <span style="color: #003399; font-weight: bold;">Object</span> value,
      <span style="color: #006600; font-weight: bold;">boolean</span> isSelected, <span style="color: #006600; font-weight: bold;">boolean</span> hasFocus, <span style="color: #006600; font-weight: bold;">int</span> row, <span style="color: #006600; font-weight: bold;">int</span> column<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    RssFeed feed = <span style="color: #009900;">&#40;</span>RssFeed<span style="color: #009900;">&#41;</span>value<span style="color: #339933;">;</span>
    updateData<span style="color: #009900;">&#40;</span>feed, isSelected, table<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">return</span> panel<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Now we use only one Panel for all rendering and editing!</p>
<div id="attachment_511" class="wp-caption alignnone" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/08/jtable_with_renderer_and_editor1.png" rel="lightbox[502]"><img class="size-medium wp-image-511" title="jtable_with_renderer_and_editor" src="http://pekalicious.com/blog/wp-content/uploads/2010/08/jtable_with_renderer_and_editor1-300x179.png" alt="JTable with Renderer and Editor" width="300" height="179" /></a><p class="wp-caption-text">JTable with Renderer and Editor</p></div>
<h1>The Conclusion</h1>
<p>Every time I try to use a JTable I discover how difficult it is to just create a f*cking simple table, but I also see how powerful it is for more complex things. I&#8217;m pretty sure there is a way to display the button only on mouse over. You know, web2.0-y.</p>
<p>Anyway, that&#8217;s that. As usual, you can find the source and the executable in my <a href="http://pekalicious.com/javacorner/">Java Corner</a>.</p>
<p>Now excuse me, but I got some Void Rays to counter attack. En Taro Adun!
</pre></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/pekalicious?a=ogkVgRBjgCA:6ikmw8RGvvk:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=ogkVgRBjgCA:6ikmw8RGvvk:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=ogkVgRBjgCA:6ikmw8RGvvk:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=ogkVgRBjgCA:6ikmw8RGvvk:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=ogkVgRBjgCA:6ikmw8RGvvk:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/pekalicious?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/pekalicious/~4/ogkVgRBjgCA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://pekalicious.com/blog/custom-jpanel-cell-with-jbuttons-in-jtable/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		<feedburner:origLink>http://pekalicious.com/blog/custom-jpanel-cell-with-jbuttons-in-jtable/</feedburner:origLink></item>
		<item>
		<title>Microsoft Word 2007: Numbered Headings Done Right</title>
		<link>http://feedproxy.google.com/~r/pekalicious/~3/RT27-tXUxYk/</link>
		<comments>http://pekalicious.com/blog/microsoft-word-2007-numbered-headings-done-right/#comments</comments>
		<pubDate>Thu, 29 Apr 2010 13:12:38 +0000</pubDate>
		<dc:creator>Panagiotis Peikidis</dc:creator>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[headings]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[numbered headings]]></category>
		<category><![CDATA[office 2007]]></category>
		<category><![CDATA[word]]></category>
		<category><![CDATA[word 2007]]></category>

		<guid isPermaLink="false">http://pekalicious.com/blog/?p=431</guid>
		<description><![CDATA[In my previous post I only briefly talked about numbering your headings. Well, today I discovered how to do them the right way. Interested? Continue reading after the jump. I was going to start with an introduction to Lists, but this needs a lot of research (about 5 minutes) so I will just reference Wikipedia [...]]]></description>
				<content:encoded><![CDATA[<p>In my <a title="Microsoft Word 2007 Made Simple" href="http://pekalicious.com/blog/microsoft-word-made-simple/">previous</a> post I only briefly talked about numbering your headings. Well, today I discovered how to do them the right way. Interested? Continue reading after the jump.</p>
<p><span id="more-431"></span>I was going to start with an introduction to Lists, but this needs a lot of research (about 5 minutes) so I will just reference Wikipedia (which took 2 seconds):</p>
<blockquote><p>&#8220;The Bullets and Numbering system has been significantly overhauled for Office 2007, which is intended to reduce the severity of these problems.&#8221; -<a title="Microsoft Word - Wikipedia" href="http://en.wikipedia.org/wiki/Microsoft_Word#Bullets_and_numbering">Microsoft Word, Wikipedia</a></p></blockquote>
<p>I&#8217;m not pretty sure if you can modify multi level lists prior to 2007 because this is the first time I&#8217;m doing this. But anyway, in Word 2007 you have the ability to define new multi level lists styles which is VERY useful for numbering your headings.</p>
<p>Let us begin by writing some chapter and section titles. As I told you yesterday, we will first write our document and then style it. So add some old fashion Lorem Ipsum text after each title. If you are lazy like me, you will probably find this tool handy: <a title="Lorem Ipsum Generator" href="http://www.lipsum.com/">Lorem Ipsum Generator</a>. Or, use Word&#8217;s built-in command &#8220;=lorem(X)&#8221; where X is the number of paragraphs; i.e. <strong>=lorem(2)</strong>. Thank you Geri for this tip.</p>
<div id="attachment_433" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/before-heading-style.png" rel="lightbox[431]"><img class="size-medium wp-image-433" title="before-heading-style" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/before-heading-style-300x115.png" alt="Example without styles" width="300" height="115" /></a><p class="wp-caption-text">Example without styles</p></div>
<p>Once you are done with your titles, style them with the appropriate heading style. Forget about setting the numbering in the heading style. We will number them in a better way.</p>
<div id="attachment_434" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/after-headings.png" rel="lightbox[431]"><img class="size-medium wp-image-434" title="after-headings" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/after-headings-300x238.png" alt="Example with Heading styles" width="300" height="238" /></a><p class="wp-caption-text">Example with Heading styles</p></div>
<p>Now, select your first heading and click on the &#8220;Multilevel List&#8221; in the &#8220;Home&#8221; tab and choose &#8220;Define New Multilevel List&#8230;.&#8221;.</p>
<div id="attachment_435" class="wp-caption aligncenter" style="width: 205px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/define-new-multilevel.png" rel="lightbox[431]"><img class="size-medium wp-image-435" title="define-new-multilevel" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/define-new-multilevel-195x300.png" alt="Define New Multilevel List" width="195" height="300" /></a><p class="wp-caption-text">Define New Multilevel List</p></div>
<p>On the bottom left of the &#8220;Define new Multilevel list&#8221; window click on the &#8220;More &gt;&gt;&#8221; button. This is what you will see:</p>
<div id="attachment_436" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/multilevel-dialog.png" rel="lightbox[431]"><img class="size-medium wp-image-436" title="multilevel-dialog" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/multilevel-dialog-300x270.png" alt="Multilevel List Dialog" width="300" height="270" /></a><p class="wp-caption-text">Multilevel List Dialog</p></div>
<p>Here we can select a level of the list (in the top left) and change its style.</p>
<p>Let&#8217;s say you want each Heading 1 to include &#8220;Chapter&#8221;. Simply enter &#8220;Chapter&#8221; before the number in the &#8220;Enter formatting for number:&#8221; text field. I personally don&#8217;t like spacing, so I set both &#8220;Aligned at:&#8221; and &#8220;Text indent at:&#8221; to 0 cm. Finally, I prefer a single space instead of a tab before my title, so I set &#8220;Follow number with:&#8221; to Space.</p>
<p>But aside from styling your list, the important step is to link this style to your header. You do this by selecting &#8220;Heading 1&#8243; to the &#8220;Link level to style:&#8221; drop down list.</p>
<div id="attachment_437" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/link-heading-to-style.png" rel="lightbox[431]"><img class="size-medium wp-image-437" title="link-heading-to-style" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/link-heading-to-style-300x270.png" alt="Link level to style" width="300" height="270" /></a><p class="wp-caption-text">Link level to style</p></div>
<p>For levels other than 1, you can include the number of its parent level. This is very useful when you want sub sections to look like &#8220;1.2.1 Title&#8221;. Simply edit those levels and select the level you want in the &#8220;Include level number from:&#8221;. Don&#8217;t forget to link each level to the appropriate headings style.</p>
<div id="attachment_438" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/include-level-number.png" rel="lightbox[431]"><img class="size-medium wp-image-438" title="include-level-number" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/include-level-number-300x259.png" alt="Include Level Number" width="300" height="259" /></a><p class="wp-caption-text">Include Level Number</p></div>
<p>You should now have each heading numbered correctly!</p>
<div id="attachment_440" class="wp-caption aligncenter" style="width: 267px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/after-numbering.png" rel="lightbox[431]"><img class="size-medium wp-image-440" title="after-numbering" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/after-numbering-257x300.png" alt="After Numbering" width="257" height="300" /></a><p class="wp-caption-text">After Numbering</p></div>
<p>But what about appendices? What if you want Appendix A, Appendix B etc? Well, we know that appendices appear in the Table of Contents as the same level as Heading 1, so clearly they have to be in the first level of the list.</p>
<p>So, one way of setting this is by applying the Heading 1 style to each. Then, select your first appendix title and define a new style. The settings of the current active list style are already set, so you don&#8217;t need to set everything again. This time you have the option to select how to apply these changes. Choose &#8220;This point forward&#8221; in the &#8220;Apply changes to:&#8221; drop down list and then make your changes. Set, for instance, the &#8220;Enter formatting for number:&#8221; to Appendix and the &#8220;Number style for this level:&#8221; to &#8220;A,B,C,&#8230;&#8221; and then the &#8220;Start at:&#8221; to &#8220;A&#8221;.</p>
<div id="attachment_441" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/appendix-first-way.png" rel="lightbox[431]"><img class="size-medium wp-image-441" title="appendix-first-way" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/appendix-first-way-300x258.png" alt="Appendix Multilevel List Style" width="300" height="258" /></a><p class="wp-caption-text">Appendix Multilevel List Style</p></div>
<p>While this will do the trick, you have to manually set the new style. I hate manuals! So let&#8217;s make them autos.</p>
<p>Create a new style by opening the &#8220;Styles&#8221; windows and clicking &#8220;New Style&#8221;. Name it &#8220;Appendix&#8221;, set the &#8220;Style type:&#8221; to &#8220;Linked (paragraph and character)&#8221; and &#8220;Style for following paragraph:&#8221; to &#8220;Normal&#8221;.</p>
<p>Now, this is where the magic happens: set the &#8220;Style based on:&#8221; to &#8220;Heading 1&#8243; and click &#8220;OK&#8221;. This will link this style with Heading 1, which means two things: a) any changes in Heading 1 will be set to Appendix as well and b) the title of this heading will be set to the same level of Heading 1 in Table of Contents.</p>
<div id="attachment_442" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/appendix-style.png" rel="lightbox[431]"><img class="size-medium wp-image-442" title="appendix-style" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/appendix-style-300x224.png" alt="Appendix Style" width="300" height="224" /></a><p class="wp-caption-text">Appendix Style</p></div>
<p>If you now apply the Appendix style to your titles, you will see that &#8220;Chapter&#8221; appears before them. To set this to &#8220;Appendix&#8221;, select your title and define a new multi level list. Next, select the fourth level and set the &#8220;Link level to style:&#8221; to &#8220;Appendix&#8221;. Make any changes to the style you want (like setting &#8220;Appendix&#8221;) and your done!</p>
<div id="attachment_443" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/appendix-text.png" rel="lightbox[431]"><img class="size-medium wp-image-443" title="appendix-text" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/appendix-text-300x167.png" alt="Appendix" width="300" height="167" /></a><p class="wp-caption-text">Appendix</p></div>
<p>When you will generate your Table of Contents, you&#8217;ll see that Appendices are at the same level as Heading 1. If you change the Appendix style to be based on Heading 2, this will be visible to the Table of Contents as well.</p>
<div id="attachment_444" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/table-of-contents1.png" rel="lightbox[431]"><img class="size-medium wp-image-444" title="table-of-contents" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/table-of-contents1-300x164.png" alt="Table of Contents" width="300" height="164" /></a><p class="wp-caption-text">Table of Contents</p></div>
<p>Easy!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/pekalicious?a=RT27-tXUxYk:oMdxK2aI-7c:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=RT27-tXUxYk:oMdxK2aI-7c:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=RT27-tXUxYk:oMdxK2aI-7c:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=RT27-tXUxYk:oMdxK2aI-7c:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=RT27-tXUxYk:oMdxK2aI-7c:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/pekalicious?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/pekalicious/~4/RT27-tXUxYk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://pekalicious.com/blog/microsoft-word-2007-numbered-headings-done-right/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		<feedburner:origLink>http://pekalicious.com/blog/microsoft-word-2007-numbered-headings-done-right/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 3.340 seconds. --><!-- Cached page generated by WP-Super-Cache on 2013-03-16 09:09:23 --><!-- Compression = gzip -->
