Open Source JavaFX Now!

Steve On Java

Hacking Java, JavaFX, and Flash with Agility
  • rss
  • Home
  • About
  • Contact
    • E-mail Steve
    • SC2 Challenge
  • SvJugFX
  • JavaFX Petition
  • JFXtras
    • JFXtras Individual CLA
    • JFXtras Corporate CLA
  • Freedom From XML

Improving Java 1 Bytecode at a Time

steveonjava | July 25, 2011

This past weekend we held the very first OSCON JVM Languages Symposium.

This was truly a meeting of minds with a huge brain trust of language authors, JVM hackers, and professional developers tackling some of the biggest issues for the Java community at large.

I think we had a pretty good recipe for success that went something like this:

  • We ate some yummy Voodoo Donuts
    • (while discussing the impact of Java 7++ on JVM languages)
  • Washed down our donut remains with some of Portland’s finest Stumptown coffee
    • (while discussing JVM language interoperability)
  • Had some tasty pizza and drinks on a private patio
    • (while pontificating on JVM community dynamics)
  • And then back for some more Voodoo Donuts…

As you can see, we took our work (and play) very seriously.

Thanks to our sponsors, Typesafe and OSCON, this event was entirely free to the participants.

The full proceedings of our event can be found below… given the success, I am looking forward to making this a long standing OSCON Java tradition!

OSCON JVM Language Proceedings

 
Comments
No Comments »
Categories
Events, JavaFX, OSCON Java
Tags
jvm languages, oscon, stumptown coffee, voodoo donuts
Comments rss Comments rss
Trackback Trackback

The Frugal Geek’s Guide to Conference Crashing

steveonjava | July 24, 2011

Conferences are expensive…  they assume you work for a stacked megacorporation that believes the fastest path to increasing their shareholder value is investing in your individual career training.  If your employer is not having a great year or has had a surge of resignations from last year’s crew of esteemed conference goers, chances are that you won’t be getting reimbursed to attend your local geek-fest.

Fortunately for you, I happen to know the inside secrets to enjoying all the conference perks at OSCON without handing over a single Benjamin.

Secret 1:  Conference pre-events are free and easily crashable!

Today I dropped in completely unexpectedly on the Community Leadership Summit today, and even after boldly announcing myself as a party crasher was awarded with a super-secret badge (a.k.a. index card w/sharpie etchings).  This gave full access to their sessions and let me attend the after-party for free drinks!

Tomorrow I am planning on crashing the free OSCON JVM Languages Symposium…  I hear they have some of Portland’s scariest pastries being brought in and might even be doing a free lunch outing thanks to their sponsor, Typesafe.

It helps that both of these events have an unbelievably high Rockstar to attendee ratio…  more on why this matters a little later.

Secret 2:  The best type of conference pass is the free type

There are 9! different OSCON passes available for you to choose from on the registration site.  While this is a bewildering array of options, but if you pay attention to the price it is quite an easy decision.  Click the “Register Now” button below and you are good to go:

Register
Register now for a FREE Expo Hall Pass (use code EXPOPASS)

So what are you missing out on with an Expo Pass?  Well…  you can’t sit with the rest of the attendees and listen to a canned lecture, but you can hang out with your new Rockstar friends in the hallways.  Which takes us to Secret 3…

Secret 3:  Conference value = # of Rockstars / # of Attendess

This makes sense if you think about it…  if you were the only attendee, surrounded by a cluster of speakers and geniuses waiting to impart their knowledge on you, it would be infinitely valuable.  Most conferences you are one speck of sand in a huge pool of attendees vying for a little bit of wisdom to be imparted on your section of the audience.  The smaller the audience, the more chance you might actually get something of value out of the experience.

So what does this mean for the value you get from difference conference events?

  • Keynote = 1 speaker to 1000 attendees:  Avoid this at all costs…  you can always get the highlights off twitter, so who cares.  [as you can see, my days as a conference chair are clearly numbered.  :) ]
  • Technical Session = 1 speaker to 100 attendees:  This is slightly better, but still the odds are clearly against you!  [yes, and now my days as a speaker are coming to an end as well...  see if anyone invites me to give a technical talk again]
  • Birds of a Feather Sessions = 1 speaker to 30 attendees:  A slightly better ratio, more focused, and absolutely free!
  • Ignite = 30 speakers to 300 attendees:  Ignite talks are for the speaker grazer in all of us…  yeah, talk your heart out…  for 5 minutes.  If you haven’t impressed us in that amount of time, at 40 minute session will not change our opinion.  It also helps that this event is absolutely free!
  • Unconference = 20 speakers to 100 attendees:  Now we are talking.  With this many technical gurus walking around you are virtually bound to learn something…  without even without trying!  This includes the JVM Languages Symposium and Community Leadership Summit, both of which are free!
  • OSCON Hallways = 1 speaker to 1 attendee:  When you bump into Martin Odersky in the hallways after having had some good times over beer and pizza at the JVM Languages Symposium you are at a ratio where the real value comes in!  (and didn’t pay a dime to start the conversation)

If you were paying attention, you probably noticed an interesting relationship…  the most valuable parts of the conference were the parts that cost absolutely nothing to get into.  (don’t let your megacorp friends know about this, or all the wonderful corporate sponsorships that pay for all these extras might dry up!)

Secret 4:  Free stuff is the open source way

Open source is all about giving software out for free, right?  Well, maybe there is more to it than that, but there is still plenty of free conference stuff flying around that you can take advantage of with over 60 exhibitors waiting to hand you prizes just for the privilege of scanning your free badge!

Secret 5:  And parties galore!

While all those folks who paid for the high priced admission tickets may think they are special, the reality is that from a sponsor’s point of view, their eyeball is worth exactly the same as yours.  This means that you have an equal opportunity to take advantage of the most important part of any conference experience…  the parties!

Here are some of the free events that you won’t want to miss out on:

  • Opening Reception – Grab a drink and mingling with exhibitors and fellow attendees
  • OSCON Carnival – Join us for food, drinks, entertainment, and lots of good old fashioned fun
  • Puppet Labs Party at their headquarters in Portland’s Pearl District.
  • OpenStack Party – Join OpenStack for cocktails and hors d’oeuvres at the Spirit of 77
  • Surprise Attendee Event on Wednesday evening (sorry, we can’t tell you anything else about this event because it’s a secret)
  • Booth Crawl where you can quench your thirst with vendor-hosted libations and snacks while you check out all the cool stuff in the expo hall.
  • Media Temple Party at the Jupiter Hotel with open bar, music, and all you can eat tacos!

Final Secret:  Everyone can be a Rockstar

What makes the difference between a Rockstar speaker and an attendee?  Just the drive to do something with technology and be proud of it.  You can be an open-source contributor, user group leader, and technical speaker if you simply apply the skills you already have to the benefit of the community.  Don’t expect to get paid much, but at least it is a really easy way to get invited to conferences around the world.

—-

While this article is all meant in good humor, on a serious note I want to thank the O’Reilly folks for putting on OSCON, offering discounted expo tickets, and compiling this great list of free events.

 
Comments
1 Comment »
Categories
Events, Flash, JavaFX, OSCON Java
Tags
conferences, crashing, free, oscon
Comments rss Comments rss
Trackback Trackback

Turbocharging Performance with Caching

steveonjava | July 21, 2011

This is the third installation of my Flex Mobile series.  In my first post I talked about multitouch, and my second post I dug in on how to control the soft keyboard.  This post goes into detail on performance, specifically caching.

Flash applications tend to use a lot more vector graphics than other UI platforms. This is a great thing for designers who can directly use all their path art and graphics.  However, on mobile devices it increases the challenge to build high performing applications.

Fortunately, there is a feature of the Flash platform called cacheAsBitmap (and its newer sibling, cacheAsBitmapMatrix) that lets you speed up rendering performance at the expense of memory.

Cache as Bitmap

CacheAsBitmap is a boolean property of DisplayObject, and by extension all the visual elements you use in Flash and Flex includings Sprites and UIComponents, have access to this variable. When set to true, each time the DisplayObject or one of its children changes it will take a snapshot of the current state and save it to an offscreen buffer. Then for future rendering operations it will redraw off the saved offscreen buffer, which can be orders of magnitude faster for a complicated portion of the scene.

To enable cacheAsBitmap on a DisplayObject you would do the following:

cacheAsBitmap = true;

Flex UIComponents have a cache policy that will automatically enable cacheAsBitmap based on a heuristic. You can override this behavior and force cacheAsBitmap to be enabled by doing the following:

cachePolicy = UIComponentCachePolicy.ON;

While cacheAsBitmap is a very powerful tool for optimizing the redraw of your application, it is a double-edged sword if not used properly. A full size screen buffer is kept and refreshed for each DisplayObject with cacheAsBitmap set to true, which can consume a lot of device memory or exhaust the limited GPU memory if you are running in graphics accelerated mode.

Also, if you have an object that updates frequently or has a transform applied, then cacheAsBitmap will simply slow down your application with unnecessary buffering operations.

Cache as Bitmap Matrix

CacheAsBitmapMatrix is also a property on DisplayObject, and works together with cacheAsBitmap. For cacheAsBitmapMatrix to have any effect cacheAsBitmap must also be turned on.

CacheAsBitmap does not work when a transformation, such as a rotation or a skew, is applied to the object. The reason for this is that applying such a transformation to a saved bitmap produces scaling artifacts that would degrade the appearance of the final image. Therefore, if you would like to have caching applied to objects with a transform applied, Flash requires that you also specify a transformation matrix for the bitmap that is stored in the cacheAsBitmapMatrix property.

For most purposes, setting cacheAsBitmapMatrix to the identify matrix will do what you expect. The offscreen bitmap will be saved in the untransformed position and any subsequent transforms on the DisplayObject will be applied to that bitmap. The following code shows how to set cacheAsBitmapMatrix to the identify transform:

cacheAsBitmap = true;
cacheAsBitmapMatrix = new Matrix();

Tip: If you plan on setting cacheAsBitmapMatrix on multiple objects, you can reuse the same matrix to get rid of the cost of the matrix creation.

The downside to this is that the final image may show some slight aliasing, especially if the image is enlarged or straight lines are rotated. To account for this, you can specify a transform matrix that scales the image up prior to buffering it. Similarly, if you know that the final graphic will always be rendered at a reduced size you can specify a transform matrix that scales down the buffered image to save on memory usage.

If you are using cacheAsBitmapMatrix to scale the image size down you need to be careful that you never show the DisplayObject at the original size. The following figure shows an example of what happens if you set a cache matrix that reduces and rotates the image first, and then try to render the object at its original size:

Notice that the final image has quite a bit of aliasing from being scaled up. Even though you are displaying it with a one-to-one transform from the original, Flash will upscale the cached version resulting in a low fidelity image.

The optimal use of cacheAsBitmapMatrix is to set it slightly larger than the expected transform so you have enough pixel information to produce high quality transformed images.

Flash Mobile Bench

The Flash Mobile Bench is a simple application that lets you test the affect of different settings on the performance of your deployed mobile application.

The functionality that it lets you test includes the following:

  • Addition of a large number of shapes to the display list
  • Animation speed of a simple x/y translation
  • Animation speed of a simple clockwise rotation
  • Impact of cacheAsBitmap on performance
  • Impact of cacheAsBitmapMatrix on performance
  • Impact of the automatic Flex cache heuristic on performance

The code that updates the cache behavior of the shape group is shown below:

private var identityMatrix:Matrix = new Matrix();

private function cacheOff():void {
  shapeGroup.cachePolicy = UIComponentCachePolicy.OFF;
}

private function cacheAuto():void {
  shapeGroup.cachePolicy = UIComponentCachePolicy.AUTO;
}

private function cacheAsBitmapX():void {
  shapeGroup.cachePolicy = UIComponentCachePolicy.ON;
  shapeGroup.cacheAsBitmapMatrix = null;
}

private function cacheAsBitmapMatrixX():void {
  shapeGroup.cachePolicy = UIComponentCachePolicy.ON;
  shapeGroup.cacheAsBitmapMatrix = identityMatrix;
}

Even though we have only one instance of an object to apply the cacheAsBitmapMatrix on, we follow the best practice of reusing a common identity matrix to avoid extra memory and garbage collection overhead.

Upon running the Flash Mobile Bench, you will immediately see the FPS counter max out on your given device. Click on the buttons to add some shapes to the scene, set the cache to your desired setting, and see how your device performs. The following figure shows the Flash Mobile Bench application running on a Motorola Droid 2 with 300 circles rendered using cacheAsBitmapMatrix:

How does the performance of your device compare?

 
Comments
5 Comments »
Categories
AIR, Flash, Flex, Mobile
Tags
Android, caching, Flex, Mobile, performance
Comments rss Comments rss
Trackback Trackback

Taking Control of the Flex Soft Keyboard

steveonjava | July 14, 2011

This is part 2 of my Flex Mobile series.  Please see my first post for information on getting started.

When using the text components, the Android soft keyboard will automatically trigger upon focus as you would expect. However, sometimes you need finer grained control over when the soft keyboard gets triggered and what happens when it gets activated.

The soft keyboard in Flex is controlled by the application focus. When a component that has the needsSoftKeyboard property set to true is given the focus, the soft keyboard will come to the front and the stage will scroll so that the selected component is visible. When that component loses focus, the soft keyboard will disappear and the stage will return to its normal position.

With the understanding of the focus, you can control the soft keyboard by doing the following:

  • To show the soft keyboard declaratively – Set needsSoftKeyboard to true for your component
  • To show the soft keyboard programmatically – Call requestSoftKeyboard() on a component that already has needsSoftKeyboard set.
  • To hide the soft keyboard – Call setFocus() on a component that does not have needsSoftKeyboard set.

This works fine for components that do not normally trigger the soft keyboard; however, for components that automatically raise the keyboard, setting needsSoftKeyboard to false has no effect. A workaround to prevent the keyboard from popping up on these components is to listen for the activating event and suppressing it with code like the following:

<fx:Script>
  <![CDATA[
    private function preventActivate(event:SoftKeyboardEvent):void {
      event.preventDefault();
    }
  ]]>
</fx:Script>
<s:TextArea text="I am a text component, but have no keyboard?"
  softKeyboardActivating="preventActivate(event)"/>

This code catches the softKeyboardActivating event on the TextArea component and suppresses the default action of raising the soft keyboard.

In addition to getting events on activation, you can also catch softKeyboardActivate and softKeyboardDeactivate events in order to perform actions based on the soft keyboard status.

The following is the full code listing for a soft keyboard sample application that demonstrates all these techniques used together to take complete control over the soft keyboard.

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
         xmlns:s="library://ns.adobe.com/flex/spark"
         splashScreenImage="@Embed('ProAndroidFlash400.png')">
  <fx:Script>
    <![CDATA[
      [Bindable]
      private var state:String;

      [Bindable]
      private var type:String;

      private function handleActivating(event:SoftKeyboardEvent):void {
        state = "Activating...";
        type = event.triggerType;
      }

      private function handleActivate(event:SoftKeyboardEvent):void {
        state = "Active";
        type = event.triggerType;
      }

      private function handleDeactivate(event:SoftKeyboardEvent):void {
        state = "Deactive";
        type = event.triggerType;
      }

      private function preventActivate(event:SoftKeyboardEvent):void {
        event.preventDefault();
      }
    ]]>
  </fx:Script>
  <s:VGroup left="20" top="20" right="20" gap="15"
        softKeyboardActivating="handleActivating(event)"
        softKeyboardActivate="handleActivate(event)"
        softKeyboardDeactivate="handleDeactivate(event)">
    <s:HGroup>
      <s:Label text="Keyboard State: " fontWeight="bold"/>
      <s:Label text="{state}"/>
    </s:HGroup>
    <s:HGroup>
      <s:Label text="Trigger Type: " fontWeight="bold"/>
      <s:Label text="{type}"/>
    </s:HGroup>
    <s:Button id="needy" label="I Need the Keyboard" needsSoftKeyboard="true" emphasized="true"/>
    <s:TextArea text="I am a text component, but have no keyboard?"
          softKeyboardActivating="preventActivate(event)"/>
    <s:HGroup width="100%" gap="15">
      <s:Button label="Hide Keyboard" click="{setFocus()}" width="50%"/>
      <s:Button label="Show Keyboard" click="{needy.requestSoftKeyboard()}" width="50%"/>
    </s:HGroup>
  </s:VGroup>
</s:Application>

This code creates several controls and attaches actions to them so that you can hide and show the soft keyboard at will, as well as see the current soft keyboard state as reported by the events that trickle up. When you run the application it should look like this:

Notice that the TextArea control, which normally triggers the soft keyboard no longer brings it up, while the highlighted button immediately raises the soft keyboard whenever it gets focus. The two buttons at the bottom to show and hide the keyboard merely play focus tricks to get Flash to show and hide the keyboard at will.

You can use the same techniques in your own application to take full control over the soft keyboard.

 
Comments
5 Comments »
Categories
AIR, Flash, Flex, Mobile
Tags
Android, Flex, keyboard, Mobile
Comments rss Comments rss
Trackback Trackback

Celebrating Java 7 with 7 Reasons to Attend OSCON Java

steveonjava | July 7, 2011

OSCON Java is a new conference that I am helping to kick off as co-chair this July.  While there are plenty of conferences out there that you could attend, I am confident that this is the one you won’t want to miss.

To celebrate the Java 7 release, I put together 7 reasons why you should attend OSCON Java.  Also, make sure to use the 20% discount code of “OS11COM” when you register:

Register now

1. Come Celebrate the First New Java Release in Half a Decade!

The last major release of Java was Java 6, which came out 5 years ago on December 11, 2006. After only a year of the Sun acquisition, Oracle has already made a major Java release happen with another scheduled in a year’s time.

We have broad coverage of the Java 7 release with a keynote and technical session by Joe Darcy, and technical sessions on OpenJDK and Coin by Dalibor Topic and Stuart Marks. I have been pretty impressed with Stuart’s coverage of topics from a developer’s perspective and am looking forward to his talk myself. :)

2. Because Google Matters

Regardless of what you think about the Android lawsuit, I think the biggest detriment has been the lack of good content on Google technologies at Java conferences. We are an independent conference, so it allows us to bring content that you would otherwise not find, such as an exclusive keynote from Joshua Bloch and several mobile Android sessions to help you leverage your Java skills on modern devices.

3. You Think JVM Languages are Cool

It has been said that the crown jewel of the Java platform is the JVM, not the language. Java 7 has further solidified this with better support for dynamic languages. Come find out what is the latest and greatest on the alternative language front with a keynote and some meaty sessions from Martin Odersky, deep technical sessions on Groovy, Clojure, Scala, and other languages, and some bytecode hacking with Charles Nutter.

4. And You Wouldn’t Mind Hanging out with JVM language Authors for a Day…

On the Sunday before OSCON we are organizing a free JVM Languages Symposium that many of the speakers will be attending.  This is a great opportunity to hang out with JVM language authors and the movers and shakers in the industry in an informal unconference atmosphere.  Events like this are what I believe sets apart community-driven conferences from large corporate events, and provide a lot more value to the attendees than simply one-way content.  If you happen to be in the Portland area, you can drop by for this free event with no obligation to stay for OSCON.

5. Your Boss Won’t Let You Fly to Belgium

I travel to speak at different conferences around the world and I would have to say that the golden standard for Java conferences is Devoxx. They have an amazing venue — it is great to see your slides on a huge movie screen, and relaxing for attendees to take it in from nice, plush seats. They attract an international audience… not only Belgium, but Italy, France, Germany, and citizens of many of the other surrounding countries consider Devoxx their home conference. Even though Devoxx is a wildly successful conference, they still have a small-conference feel, run by a very tight knit conference committee that acts more like a user group than an organization. This makes the entire conference experience much more personalized.

OSCON Java has a lot of similarities with Devoxx. It has a small, enthusiastic program committee with folks who really care about Java technologies. We are also following the Devoxx model of recording and posting talks online afterwards, so even if you miss a great talk because you are in the room next door, you can always watch it online later. Finally, since we are an independent conference, you get the full experience of Java, Android, and other technologies that you would otherwise have to go to multiple conferences to see.

6. OSCON is a Pretty Sweet Conference as Well…


OSCON 2011

The O’Reilly OSCON conference has been underrepresented in the Java community, but is a pretty huge event in its own right.  They have some amazing content around emerging languages and mobile platforms.  Plus, you can get OSCON, OSCON Java, and OSCON Data all wrapped up in one neat package with the OSCON Superpass.

7. There is Only One Inaugural Year!


OSCON Java 2011

This is our first year putting on OSCON Java, so we are pulling out all the stops with the best speakers, tutorials, content, and events.  You will have a unique opportunity to participate in the creation of a new Java tradition, and a decade from now can brag to your friends about being a founding attendee of the biggest open-source Java conference in the world.

 
Comments
No Comments »
Categories
Android, Announcements, Events, JavaFX, Mobile, OSCON Java
Tags
Android, java 7, jvm languages, oscon, OSCON Java
Comments rss Comments rss
Trackback Trackback

Publications

   

Upcoming Talks

JavaOne 2011

Android Open
Use code "WIDGETFX"
for 20% off!

JavaOne 2011

Steve On…

  • Everything
  • Agile
  • Flash
  • JavaFX

Archives

Affiliations

Awards

2009 JavaOne Rock Star!

rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox