Progress Indicator - JavaFX !

Probably I missed something. But this is the way we can add indefinite progress indicator with any unpredictable events. Here I am just calling a Web service to show yahoo maps for NY city.

Here how progress indicator looks like :

Progress Indicator is very small :

var pi = ProgressIndicator {
    scaleX: 2
    scaleY: 2
    translateX: 90
    translateY: 110
    progress: -1
    visible: bind vLoad
    };

Make visibility false when Map is loaded. So, vLoad: false in:

onDone: function() {
                  Main.status = "Done ...";
                  Main.vLoad = false;
                }

Somehow, I am not getting such a good result. I guess, progress thread stuck when Data loading start. May be because one single thread is doing both work.

Here is the code :



package progressbarshow;

import java.lang.Math;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.Cursor;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseEvent;
import javafx.scene.Scene;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import progressbarshow.MapLocate;

var pi = ProgressIndicator {
    scaleX: 2
    scaleY: 2
    translateX: 90
    translateY: 110
    progress: -1
    visible: bind vLoad
    };

public var status: String = "Start Loading Data...";
var ml: MapLocate = MapLocate{zip:"10001"}; // 10001 - Newyork, i guess
var x1: Number = 0;
var y1: Number = 0;
var im: Image = bind Image {
    url: ml.location
}
public var vLoad = true;
var loadingText = Text {
    visible: bind vLoad
    font: Font {
        size: 12
    }
    x: 30,
    y: 70
    content: bind status
}

/\* Image of the map from Yahoo WS \*/
var imview = ImageView {
    cache: true
    translateX: bind x1
    translateY: bind y1
    image: bind im
    cursor: Cursor.MOVE
    /\* Navigation from Mouse event\*/
    onMouseDragged: function( e: MouseEvent ):Void {
        if(e.dragX < 0 and x1 < 0) {
            x1 = x1 + 5;
        }
        if(e.dragX > 0 and Math.abs(x1  -  240) < im.width) {
            x1 = x1 - 5;
        }
        if(e.dragY < 0 and y1 < 0 ) {
            y1 = y1 + 5;
        }
        if(e.dragY > 0 and Math.abs(y1  -  320) < im.height) {
            y1 = y1 - 5;
        }
    }
    /\* Navigation from key event \*/
    onKeyPressed: function( e: KeyEvent ):Void {
        if(e.code == KeyCode.VK_LEFT)
        {
            if(x1 < 0) {
                x1+=10;
            }
        }
        if(
                    e.code == KeyCode.VK_RIGHT)
        {
            if(Math.abs(x1  -  240) < im.width) {
                x1-=10;
            }
        }
        if(
                    e.code == KeyCode.VK_DOWN)
        {
            if(Math.abs(y1  -  320) < im.height) {
                y1-=10;
            }
        }
        if(e.code == KeyCode.VK_UP)
        {
            if(y1 < 0) {
                y1+=10;
            }
        }
    }
};
    function run() {
      Stage {
        title: "Yahoo Map Navigation"
        width: 240
        height: 320
        scene: Scene {
            content: [
            loadingText, imview,  pi
            ]
        }
    }
   }

Navigation Code:

package progressbarshow;

import java.lang.Exception;
import javafx.data.pull.PullParser;
import javafx.io.http.HttpRequest;

/\* Class to show Map from Yahoo Web service, input zip code \*/
public class MapLocate {
    public var location: String;
    public var zip: String;
    public var isguid: Boolean = false;
    var url = bind "http://local.yahooapis.com/MapsService/V1/mapImage?appid=P6pToNnV34GfP9zgTALgVW3CUTL5qHTnKjz5bLXPikqNjcMZTkF6h1xsnhm.P1WIs3U-&zip={zip}";
    var p: PullParser;
    var h: HttpRequest;
    init {
        if (url.length() > 0) {
            Main.status = "Reading HTTP request....";
            h = HttpRequest {
                location: url
                onException: function(exception: Exception) {
                    print("Please check the internet connectivity/Data Input");
                }
                onConnecting: function() {
                    Main.status = "Connection Established ... "
                }
                onInput: function(input) {
                    Main.status = "Parsing Input request....";
                    p = PullParser {
                        input: input
                        onEvent: function(event) {

                            if ((event.type == PullParser.END_ELEMENT)) {
                                if (event.qname.name == "Result") {
                                    isguid = true;
                                    location = event.text;
                                }
                            }
                        }
                    };
                    p.parse();
                    p.input.close();
                }
                onDone: function() {
                  Main.status = "Done ...";
                  Main.vLoad = false;
                }
            };
            h.start();
        }
    }
}


Comments:

It was a very nice idea! Just wanna say thank you for the information you have shared. Just continue writing this kind of post. I will be your loyal reader. Thanks again.

Posted by Christian Louboutin Boots on October 29, 2009 at 03:49 AM IST #

aa
[urltp://www.kissnfl.com/nfl-jerseys-c-631.html][b]authentic football jerseys[/b][/url]
[url=http://www.kissnfl.com][b]authentic jerseys[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]authentic nfl jerseys[/b][/url]
[url=http://www.kissnfl.com/nhl-jerseys-c-659.html][b]authentic nhl jerseys[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]buy nfl jerseys[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]cheap football jerseys[/b][/url]
[url=http://www.kissnfl.com][b]cheap jerseys[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]cheap nfl jerseys[/b][/url]
[url=http://www.kissnfl.com/nhl-jerseys-c-659.html][b]cheap nhl jerseys[/b][/url]
[url=http://www.kissnfl.com/nhl-jerseys-c-659.html][b]chicago blackhawks nhl[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]custom football jerseys[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]custom nfl jerseys[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]customized nfl jerseys[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]discount nfl jerseys[/b][/url]
[url=http://www.kissnfl.com/nhl-jerseys-c-659.html][b]discount nhl jerseys[/b][/url]
[url=http://www.kissnfl.com][b]hockey jerseys[/b][/url]
[url=http://www.kissnfl.com][b]jerseys[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]nfl authentic[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]nfl football jerseys[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]nfl jersey[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]nfl jerseys[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]nfl memorabilia[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]nfl replica jerseys[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]nfl store[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]nfl stores[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]nfl youth[/b][/url]
[url=http://www.kissnfl.com/nhl-jerseys-c-659.html][b]nhl apparel[/b][/url]
[url=http://www.kissnfl.com/nhl-jerseys-c-659.html][b]nhl hockey[/b][/url]
[url=http://www.kissnfl.com/nhl-jerseys-c-659.html][b]nhl hockey apparel[/b][/url]
[url=http://www.kissnfl.com/nhl-jerseys-c-659.html][b]nhl hockey jerseys[/b][/url]
[url=http://www.kissnfl.com/nhl-jerseys-c-659.html][b]nhl jersey[/b][/url]
[url=http://www.kissnfl.com/nhl-jerseys-c-659.html][b]nhl jerseys[/b][/url]
[url=http://www.kissnfl.com/nhl-jerseys-c-659.html][b]nhl new jersey devils[/b][/url]
[url=http://www.kissnfl.com/nhl-jerseys-c-659.html][b]nhl player[/b][/url]
[url=http://www.kissnfl.com/nhl-jerseys-c-659.html][b]nhl shop[/b][/url]
[url=http://www.kissnfl.com/nhl-jerseys-c-659.html][b]nhl store[/b][/url]
[url=http://www.kissnfl.com/nhl-jerseys-c-659.html][b]nhl team[/b][/url]
[url=http://www.kissnfl.com/nhl-jerseys-c-659.html][b]nhl teams[/b][/url]
[url=http://www.kissnfl.com/nhl-jerseys-c-659.html][b]nhl vintage[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]penguins jerseys[/b][/url]
[url=http://www.kissnfl.com/nhl-jerseys-c-659.html][b]red wings nhl[/b][/url]
[url=http://www.kissnlf.com][b]replica jerseys[/b][/url]
[url=http://www.kissnfl.com/][b]saints jerseys[/b][/url]
[url=http://www.kissnfl.com/][b]sports apparel[/b][/url]
[url=http://www.kissnfl.com/][b]sports jerseys[/b][/url]
[url=http://www.kissnfl.com/][b]steeler jerseys[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]stitched nfl jerseys[/b][/url]
[url=http://www.kissnfl.com/][b]team jerseys[/b][/url]
[url=http://www.kissnfl.com/nhl-jerseys-c-659.html][b]vintage nhl jerseys[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]wholesale nfl[/b][/url]
[url=http://www.kissnfl.com][b]youth jerseys[/b][/url]
[url=http://www.kissnfl.com/nfl-jerseys-c-631.html][b]youth nfl jerseys[/b][/url]

Posted by kissnfl on January 14, 2010 at 02:01 AM IST #

http://www.christianlouboutinmarts.com

Christian Louboutin http://www.christianlouboutinmarts.com
Christian Louboutin Shoes http://www.christianlouboutinmarts.com
christian louboutin sale http://www.christianlouboutinmarts.com
Christian Louboutin Boots http://www.christianlouboutinmarts.com
Christian Louboutin Pumps http://www.christianlouboutinmarts.com
Christian Louboutin Sandals http://www.christianlouboutinmarts.com

http://www.toptiffanylinks.com

tiffany wholesale http://www.toptiffanylinks.com
tiffany stores http://www.toptiffanylinks.com
replica tiffany http://www.toptiffanylinks.com
cheap jewelry http://www.toptiffanylinks.com
replica tiffany retail http://www.toptiffanylinks.com
pandora jewelry http://www.toptiffanylinks.com
replica pandora jewelry http://www.toptiffanylinks.com

http://www.ed-onlineshop.com

ed hardy http://www.ed-onlineshop.com
ed hardy clothing http://www.ed-onlineshop.com
ed hardy t shirt http://www.ed-onlineshop.com
ed hardy jeans http://www.ed-onlineshop.com
wholesale ed hardy http://www.ed-onlineshop.com
ed hardy shirt http://www.ed-onlineshop.com
ed hardy boots http://www.ed-onlineshop.com

http://www.edhardydream.com

ed hardy swimwear http://www.edhardydream.com
ed hardy clothing http://www.edhardydream.com
ed hardy clothes http://www.edhardydream.com
ed hardy t shirts http://www.edhardydream.com
ed hardy jeans http://www.edhardydream.com
ed hardy sunglasses http://www.edhardydream.com
ed hardy sunglass http://www.edhardydream.com

Posted by china wholesale on March 07, 2010 at 01:42 AM IST #

I would like to introduce a very good company, electronic products dealer.
I have bought some products from company,the price was very cheap,and the products are very good quality!They accept paypal, credit card transactions,bank transfers,and more.Just have a look at this web page : http://www.nike-airyeezy.com
I am sure you will could save a lot of money!
Best regards!
web: http://www.victoriawear.com
http://www.homybuy.com

Posted by wwwnice on March 09, 2010 at 06:05 AM IST #

Post a Comment:
Comments are closed for this entry.
About

Hi, I am Vaibhav Choudhary working in Sun. This blog is all about simple concept of Java and JavaFX.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today