ApplicationSource

Lately I’ve been super busy, I’ve been getting some good hours for side work, and have been working on this really awesome charting application it’s not customizable to the extent of StockFetcher, but it’s cool in it’s own right.

Everything is driven and built dynamically based off of an xml file. The cool part of the app, is that in the xml I can specify the timeline I want to show, and customize all of these things called studies. Studies are calculations like On Balance Volume, Moving Average, and Double Smooth Stochastics. I have no clue what any of those things mean to a financial stock person, but looking at these graphs means something… pretty much whether or not to buy or sell stocks is what i presume.

Java, Coldfusion, and Flex marriage

We are using a customized java library for the calculations, and that helped out a lot. So we are leveraging three technologies here, Java, Coldfusion, Flex. It’s a great combonation, we’re not accessing any java directly with flex, but through coldfusion we are instantiating java objects in order to complete the calculations.

The Slider issue

FlexLib has a great slider class that I believe Doug Mccune is responsible for. It’s great because it adds the thumbskin and allows you to drage the area in between the thumbs.

The issues I needed to solve with the slider

  • The slider had to be able to be dragged when clicked on
    • accomplished with the flexlib slider
  • Things that weren’t possible yet
    • When clicking in the track the whole slider had to move
      • IT ALSO HAD TO MOVE BY WHATEVER AMOUNT IT WAS SHOWING!
      • so that means if the slider’s two thumbs were 60 datapoints apart, it would have to move 60 points to the left when the track was clicked on, or 60 points to the right when the track was clicked on
    • MY BIG BEEF
      • my beef with this was that, there really arent any events dispatched when you click on the track… it’s a private method that handles the animation and tweening of the slider to go to where ever it is on the track that you clicked…
      • I didn’t like that at all, but I didn’t have time to fix it either.
    • When you click and drag the slider (not the thumb, but the in between the thumbs) and you drag to the end of the track, the region that is locked shrinks or expands when you go out of it’s bounds…
      • that we couldn’t

My Solution

  • I added the following attributes to the SliderBase
    • lockRegionsOnTrackClick=”true”
      • this solved the first issue stated above…. how the sliders had to move as a whole
        • this was a little complicated simply because if there were multiple sliders you have to loop through them and change all of them by the proper amount.
    • lockRegionsWhileDragging=”true”
      • this solved the last issue where the slider was changing sizes if your mouse was either too far to the left of the track, or to the right of the track.
    • moveByCurrentSpan=”true”
      • this solved my issue of needing the sliders to move by whatever the current difference of the first and last thumbs were.
        • again the challenge with this one, is you had to move the inner thumbs by the correct amount either to the right or left.

so now you have the new slider
<flexlib:hslider snapinterval="1" maximum="9000" minimum="-9000" values="[-2000, 4000]" width="200" thumbcount="2" showtrackhighlight="true" datatipoffset="3" datatipplacement="bottom" showdatatip="true" livedragging="true" movebycurrentspan="true" lockregionswhiledragging="true" lockregionsontrackclick="true" allowthumboverlap="true" allowtrackclick="true" trackhighlightskin="flexlib.skins.SliderThumbHighlightSkin"> </flexlib:hslider>

Please check out the source and feel free to comment.

Please note these are just the same links as the ones that were at the top, they were just put here for convenience.

ApplicationSource