Wednesday, 27 February 2008

flex: a single object as a dataProvider for a chart

I'm still really enjoying Flex and 3.0 (and Air 1.0) has officially been released now. After working with Vince, my relatively new colleague, I can see that I'm still in the learning curve for Flex, though I'm confident I could hold my own and will catch up pretty quickly.

This evening I'm tinkering with my "webwar" game again. I decided to use a ColumnChart instead of a form and labels (ahem, very developerish!) to show the status of "resources". The problem I was having was that my resources are expressed as properties on a single object:

public class Resources
public var earth:int = 0;
public var fire:int = 0;
public var metal:int = 0;
public var water:int = 0;
public var wood:int = 0;

The dataProvider for a ChartBase subclass has to implement the IList or ICollectionView interface which obviously Object does not. I played around with various bindings, setting the dataProvider on the ColumnSeries instead of the chart, with little success. Eventually I came up with this, which seems to work, but I'm not sure if it's the most appropriate method or not (will check with Vince tomorrow!)

<mx:ArrayCollection id="chartData">

So rather than setting the object as the dataProvider, I set this array collection as the dataProvider and bind the elements of the Resource object to my custom collection.

So apart from that, we're still doing some cool stuff with Flex and OSGi at work and we will have an alpha release of our Solstice framework this week! Promise.

Wednesday, 13 February 2008

Arum's new website

Arum Systems' new website just went live. Expect to see some interesting stuff appearing here about our particular industry focus (business consulting to debt collection and recovery) and the work of Arum's relatively new RIA team, which of course I am a member of.

Tuesday, 12 February 2008

A New Dawn - OSGi and Flex

I can't say too much about the actual project I've been working on at Arum Systems just now, but what I can say was that we decided to adopt my proposed architecture as it fits the business model we're planning to employ for the product very well.

As a result, we have combined OSGi, Flex and BlazeDS in order to develop a Modular RIA/RS (Rich Internet Application/Rich Server) Framework that we've called Solstice. An official announcment will be made before the end of this month, but I wanted to give a quick overview of what's going on in my head ahead of that announcement.

I had previously tried to achieve the same thing with GWT, but I had two main problems with GWT:
  1. lack of modularity
  2. lack of visuality
Don't get me wrong, it's a pretty funky technology, but by modularity what I mean is, it is impossible to create dynamic modules for a UI that you create with GWT mainly because of the way you have to code it up in Java and then convert it to a JavaScript application at compile time. This leads on to the second problem, which I am sure there is a better word for than "visuality".

Although I'm not a Microsoft technology fan, I have to admit that I have always admired their approach to building UIs. That is, a developer literally builds the UI. Of course, they can add code on clicks and so on, but they know exactly what they are going to get as they are building it because they can see the graphical representation of it at build time, rather than runtime unlike GWT (and even Java) which is only recently starting to see fairly immature graphical builder tools being made available. However, throughout my career I have found Microsoft technology to be quite inaccessible and have never been lucky enough to be in a job where I can get my hands on the tools and have time to play with them at the same time.

All this changed when I joined Arum Systems' RIA team. My background is Java/J2EE of course, and they needed a strong developer with good Java experience and all the other "senior" stuff (aka "hardcore") to round off the team's skillset. Being "hardcore" I set about learning Flex, which was helped a lot by the fact that it is so easy to get your hands on, install and just get going with. I was very excited when I saw the visual nature of the Flex Builder tool, especially that it is part of the Eclipse IDE - I felt right at home from the outset.

I'm the first to admit, I'm no UI expert. Some of the Flash/Flex stuff out there is just amazing, but my focus really is software engineering and product development. I think this is why Eclipse RCP appealed to me - it removes the choices about the UI from the developer which is good and bad for many reasons. Ultimately, RCP and even plugin development appears to be a very niche/elite developer market because the learning curve is so steep and some of the architectural decisions made by the Eclipse team are questionable. Flex on the other hand is very easy to get in to whether you come from a web design background or a Java background. The learning curve is long, but shallow.

So, the business model for our new product calls for a lot of flexibility (no pun intended). We don't plan on mass selling a shrink wrapped product, instead we plan on targetting a selected group of new and existing customers with varying integration needs. One option was simply to "copy and paste" the product for each customer, but this seemed wasteful to me, so instead I drew on my experience of Eclipse plugin development, and more specifically my growing experience with OSGi, in order to propose an architecture that lets us build a product that is 80% complete for all customers, with only 20% left as integration consultancy.

Combining those concepts with Flex allows us to build modular ich internet applications and rich server applications. Combining these two key technologies in to the Solstice framework allows us to:
  • extend our product quickly and easily for multiple customers without having to maintain multiple codebases
  • maximsing profit by enabling re-use
  • reduce time to market and costs for our customers

Solstice will be available by the end of this month as a fully open source framework. Documentation, examples and tutorials will be available and I am hoping to talk about it at Flex360 Europe in April.

Wednesday, 6 February 2008

Flex UI Experiment

This is a Flex UI experiment that I knocked together in a few hours last night. I kind of had an Eclipse feeling at the time, which may explain why it looks the way it does. It's for a game that I'm writing in my "spare" time, which may or may not go somewhere...

The main thing I wanted to play with last night was the “graph” in the middle section, which is “SpringGraph” by Mark Shepherd (Flex Builder team). The graph uses a custom renderer in order to draw the pie charts and show a tool tip. I had started writing my own and realised this graph view had probably been in the past so did a quick Google and there was SpringGraph.

The pie charts are just drawn as “wedges” on a custom component created using a Drawing library from Ric Ewing updated for AS2 by Kevin Williams and now for Flex by me. You can get a copy of it using the link below.

My main change was to pass a graphics context in to each of the methods and a few other bits of tidying up. It's pretty cool and lets you easily draw polygons, stars, wedges and "gears". Very handy for weird shaped custom components. Just subclass Canvas and draw using this library. Flex is neat in that by default it only seems to detect mouse events over drawn areas making those weird shaped components feel as though they are really weirdly shaped rather than just a rectangle with a drawing in them.