<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2494644693458689810</id><updated>2011-07-07T19:42:21.186-07:00</updated><title type='text'>Java Geek</title><subtitle type='html'>Confessions of a teenage java addict. I've been programming in Java for 4 years now and I love it.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://illuvis.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2494644693458689810/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://illuvis.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Illuvis</name><uri>http://www.blogger.com/profile/09595406151236135201</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2494644693458689810.post-1719067282558935256</id><published>2009-07-03T21:17:00.001-07:00</published><updated>2009-07-03T23:04:40.870-07:00</updated><title type='text'>JavaFX 1.2: Charts</title><content type='html'>&lt;a href="http://dilbert.com/strips/comic/2009-03-07/" title="Dilbert.com"&gt;&lt;img src="http://dilbert.com/dyn/str_strip/000000000/00000000/0000000/000000/40000/3000/500/43544/43544.strip.gif" alt="Dilbert.com" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Courtesy Scott Adams&lt;br /&gt;&lt;br /&gt;JavaFX 1.2 was released quite recently as of this blog post. One of the latest new features to the JavaFX scene-graph are charts!&lt;br /&gt;&lt;br /&gt;Despite the humorous commentary in the cartoon, charts really are useful to businesses because they make it easier to visualize and therefore analyse trends in data.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Memory Monitor Program&lt;/span&gt;&lt;br /&gt;Here is a demonstration of a program designed to track memory usage:&lt;br /&gt;&lt;a href="http://download62.mediafire.com/yrsxjieczx4g/immytnttojl/MemoryMonitorSRC.zip"&gt;Here is the source code for the program.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;This program calculates memory usage from the java.lang.Runtime class's getMaxMemory(), getTotalMemory(), and getFreeMemory() methods, converting them to Megabytes due to the sheer number of bytes. It then outputs it to the graph:&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;               &lt;span style="font-style: italic;"&gt; //Load total memory into the chart.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-style: italic;"&gt;                insert LineChart.Data {&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-style: italic;"&gt;                    xValue: time&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-style: italic;"&gt;                    yValue: runtime.totalMemory() / 1000000&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-style: italic;"&gt;                } into memoryChartSeries[0].data;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-style: italic;"&gt;                //Load the used memory into the chart.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-style: italic;"&gt;                insert LineChart.Data {&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-style: italic;"&gt;                    xValue: time&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-style: italic;"&gt;                    yValue: (runtime.totalMemory() - runtime.freeMemory()) / 1000000&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-style: italic;"&gt;                } into memoryChartSeries[1].data;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;and puts the proportions to the Pie Chart once every ten seconds:&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;                   &lt;span style="font-style: italic;"&gt; pieChart.data[0].value = (runtime.totalMemory() - runtime.freeMemory()) / 1000000;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-style: italic;"&gt;                    pieChart.data[1].value = runtime.freeMemory() / 1000000;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-style: italic;"&gt;                    pieChart.data[2].value = (runtime.maxMemory() - runtime.totalMemory()) / 1000000;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;span style="font-style: italic;"&gt;&lt;/span&gt;&lt;br /&gt;Additionally, you can add ImageView objects to see how much memory use increases.&lt;br /&gt;&lt;br /&gt;Though the program's layout isn't very pretty, you could theoretically use this program to check for memory leaks. For instance, it's obvious that each time this program updates the pie chart, more and more memory is consumed, which is why I wrote it to refresh only every 10 seconds (it still uses up all memory available to it if you run it long enough). Ah, the irony!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;JavaFX 1.2&lt;/span&gt;&lt;br /&gt;Overall, JavaFX 1.2 is a great improvement over the previous versions. There are still a few features I would like to see in the future.&lt;br /&gt;&lt;br /&gt;For instance, it would be helpful to be able to access media and video through streams. At the present time, they can only be loaded into JavaFX by means of a URL, which decreases flexibility quite a bit. It would be very convenient to be able to store media and images with the Storage class, as these files tend to be too large to efficiently save inside the program's jar file, and the file structure of different operating systems can vary. But alas, the Storage class can only be correctly accessed by streams (a "hack" to work around this limitation would make it system-specific).&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_pf9t6R9u_8Y/SjrsVoDdURI/AAAAAAAAAAU/ItM4GvsuDNI/s1600-h/CircleCollision.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 200px; height: 200px;" src="http://4.bp.blogspot.com/_pf9t6R9u_8Y/SjrsVoDdURI/AAAAAAAAAAU/ItM4GvsuDNI/s320/CircleCollision.png" alt="" id="BLOGGER_PHOTO_ID_5348847363729215762" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;It would also be nice if a more advanced collision detection and response system could be added. At the moment, one can detect collisions through a node's bounds. However, these bounds are based upon rectangles, thereby decreasing accuracy as one can infer from the figure to the left.&lt;br /&gt;&lt;br /&gt;It is also a bit difficult to replicate the appearance of an old fashioned swing GUI, though that is mainly due to the lack of a visual designer, which thankfully is due to arrive in the near future.&lt;br /&gt;&lt;br /&gt;The good news is that this version now includes Linux support, and other features I am eagerly awaiting are due to arrive in the near future.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2494644693458689810-1719067282558935256?l=illuvis.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://illuvis.blogspot.com/feeds/1719067282558935256/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illuvis.blogspot.com/2009/07/javafx-12-charts.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2494644693458689810/posts/default/1719067282558935256'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2494644693458689810/posts/default/1719067282558935256'/><link rel='alternate' type='text/html' href='http://illuvis.blogspot.com/2009/07/javafx-12-charts.html' title='JavaFX 1.2: Charts'/><author><name>Illuvis</name><uri>http://www.blogger.com/profile/09595406151236135201</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_pf9t6R9u_8Y/SjrsVoDdURI/AAAAAAAAAAU/ItM4GvsuDNI/s72-c/CircleCollision.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2494644693458689810.post-630455299084064818</id><published>2009-04-18T00:05:00.000-07:00</published><updated>2009-04-18T00:56:00.511-07:00</updated><title type='text'>Starfighter: Part 1</title><content type='html'>&lt;span style="font-size:180%;"&gt;&lt;span style="font-weight: bold;"&gt;Introduction&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I am eventually hoping to start up a commercial website dedicated to entertainment. I have decided to use &lt;a href="http://java.sun.com/"&gt;Java&lt;/a&gt; due to its relative platform independence and  the fact that I have spent a lot of time on it as a hobby.&lt;br /&gt;&lt;br /&gt;Towards this effort, I have been working on a number of games. I am currently focusing on a game I have titled: Starfighter.&lt;br /&gt;&lt;br /&gt;When I first tried to write games, I spent plenty of spare time trying to develop a Java based scene graph, or else find an effective open source solution. However, I found both options to be difficult and time consuming.&lt;br /&gt;&lt;br /&gt;Which is why I became excited when I first learned about &lt;a href="http://javafx.com/"&gt;JavaFX&lt;/a&gt;, a scripting language dedicated to graphics.&lt;br /&gt;&lt;span style="font-weight: bold;font-size:180%;" &gt;&lt;br /&gt;Handicaps&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;One of the largest handicaps I have had, is JavaFX's current incompatibility with Linux. After finally getting tired of viruses getting past my firewall and ruining my computer, I ended up switching to Linux. My computer has not demonstrated any virus problems since, but this is problematic when programming in JavaFX, because it is officially unavailable for Linux and Solaris. According to &lt;a href="http://blogs.sun.com/javafx/entry/a_word_on_linux_and"&gt;this article&lt;/a&gt;, it is because of difficulty in implementing graphics acceleration and video.&lt;br /&gt;&lt;br /&gt;I have managed to get around this using a &lt;a href="http://www.weiqigao.com/blog/2008/12/04/using_javafx_1_0_on_linux.html"&gt;popular hack&lt;/a&gt;, but I have thus far been unable to get video to work and I have had to develop a large number of typing habits to compensate for the buggy code editor.&lt;br /&gt;&lt;br /&gt;Curiously, all of the samples on the &lt;a href="http://javafx.com/"&gt;JavaFX website&lt;/a&gt; seem to work on my computer, even video. The only setback is that they are slower on Linux than they are on a Windows computer (and in one case unmanageably so).&lt;br /&gt;&lt;br /&gt;It is rather nice not having to write my own scene graph, but JavaFX still seems to lack a major component for graphics design: Collision Detection.&lt;br /&gt;&lt;span style="font-size:180%;"&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Collision Detection&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Collision detection refers to when a program checks to see if any of the sprites overlap. Then of course, it presumably calls a function to respond to the stimuli appropriately.&lt;br /&gt;&lt;br /&gt;I received major headaches when trying to implement this in Java. Fortunately, I have a better idea of what I am doing this time.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_pf9t6R9u_8Y/SemEAczW_dI/AAAAAAAAAAM/Z3qXpX4WnWM/s1600-h/RectangleCollision.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 320px; height: 192px;" src="http://3.bp.blogspot.com/_pf9t6R9u_8Y/SemEAczW_dI/AAAAAAAAAAM/Z3qXpX4WnWM/s320/RectangleCollision.png" alt="" id="BLOGGER_PHOTO_ID_5325933177608797650" border="0" /&gt;&lt;/a&gt;The simplest form of collision detection would be rectangle based and use the brute force method. Basically, a rectangle would bound each sprite, with its minimum and maximum x and y points corresponding to those of the sprite. Then, the program would mathematically calculate one sprite against every other sprite to see if any of their rectangles overlap.&lt;br /&gt;&lt;br /&gt;The problem with the rectangular bounds method is that the rectangles cannot accurately indicate whether or not various shapes, such as a circle or a line intersects with another object. I will be unable to work around this problem for now.&lt;br /&gt;&lt;br /&gt;The problem with the brute force detection method is that for every sprite I add to the scene graph, the amount of collision checks increases exponentially, as every sprite must be checked against every other sprite.&lt;br /&gt;&lt;br /&gt;There are two methods I am aware of that can take care of this problem: Quadtrees and Cells.&lt;br /&gt;&lt;br /&gt;Both are ways of dividing the space the sprites exist in into sections. That way, each sprite is only matched against sprites in the same section.&lt;br /&gt;&lt;br /&gt;Since I do not know very much about Quadtrees, and I am hoping that the JavaFX team will eventually resolve this, I am implementing a variation of the Cell method.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2494644693458689810-630455299084064818?l=illuvis.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://illuvis.blogspot.com/feeds/630455299084064818/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illuvis.blogspot.com/2009/04/starfighter-collision-detection.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2494644693458689810/posts/default/630455299084064818'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2494644693458689810/posts/default/630455299084064818'/><link rel='alternate' type='text/html' href='http://illuvis.blogspot.com/2009/04/starfighter-collision-detection.html' title='Starfighter: Part 1'/><author><name>Illuvis</name><uri>http://www.blogger.com/profile/09595406151236135201</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_pf9t6R9u_8Y/SemEAczW_dI/AAAAAAAAAAM/Z3qXpX4WnWM/s72-c/RectangleCollision.png' height='72' width='72'/><thr:total>0</thr:total></entry></feed>
