Monday Aug 11, 2008

Need more than Preview Mode - JavaFX

JavaFX Preview SDK came up somewhere in the middle of last month. It is no doubt one of the important thing required. But still the preview is not enough to remove the tiny complexity. I don't do lot of JavaFX coding, but whatever I do, most of the time I spend in putting the circle at right place, adjusting the rectangle corners, making the polygon of the correct shape, where to put the image and many more. Because the preview generates a code which need a lot of modification(why not builder makes it for me). 

Here how it works :

When I drag the line on my code part, it will write something like :

Line {
                startX: 10, startY: 10
                endX: 230, endY: 100
                strokeWidth: 1
                stroke: Color.BLACK
        }

Which is my partial requirement. I want my line to go in the position where it is required in the output window, not a default one. Would love to see Screen View or Output View or Image View where I can draw the objects like Circle, Line, Polygon, Image and drop at a point where it is required in the Output Window. I mean, simply how it happens in Flash or happens in Paint. When I drag say Circle, it comes into editable mode, I can do operation on it, I can increase its radius, I can change the center, I can fill the color and many more and finally settle down at the right position.

If I am not wrong, then we all invest(waste) 20-30 percent of the time still in putting stuff at right position. Talking about the complex drawing, say like making a face, it will take more than 40 percent of time. Why not we can have a View which do that for us. It is just my personal opinion, for rest JavaFX preview is simple and sober. I am damn sure, FX Engineers are working on this. Say if all this is done, poor developer like me can put more brain on writing logic code like Mouse Movement, Key Events, Binding calls(even binding should be done by Builder) and more.

Tuesday Jul 29, 2008

Boat in an ocean :-) JavaFX !

OK, nothing to laugh. I know my animation sense is little poor. But here I tried to move a ship, in the way they show in movies -D. Nothing like that, I have tried to give a sinusoidal movement of a ship. In the comment section, you can see there is a sea image as well. Animation was looking little ugly with sea, so I removed it :-). But point to note, you can give any animation to a image based on any mathematical methods. And if you have a complex equation, you can fit that in, in place of my simple sin curve. Here is the code:

package move;

import javafx.application.Frame;
import javafx.application.Stage;
import javafx.scene.paint.Color;
import java.lang.Math;
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.scene.image.ImageView;
import javafx.scene.image.Image;

var time : Number = 0.0;


var timeline : Timeline = Timeline {
    repeatCount: Timeline.INDEFINITE        
    keyFrames : 
        KeyFrame {
            time : 5ms
            action: function() {
                time += 0.02;
            }                
        }
};
Frame {
    title: "MyApplication"
    width: 1200
    height: 500
    closeAction: function() { 
        java.lang.System.exit( 0 ); 
    }
    visible: true

    stage: Stage {
        fill: Color.AQUA
        content: [
     /\*       ImageView {
                image: Image {
                url: "http://birdblog.merseyblogs.co.uk/sea21206.jpg"
                 }
            },
     \*/
            ImageView {
                x:bind(100 + time \* 10)
                y:bind(100 + Math.cos(time) \* 10)
                image: Image {
                    url: "http://lal.cas.psu.edu/Research/visualiz/images/boat.gif"
                }
            }
        ]

    }
}
timeline.start(); 

Just 3-4 drags from Netbeans 6.1 FX viewer :

1.  One Timeline and an action inside it.

2. One Frame.

3. One Image.

Thats it ! Set the code logic and rest leave all the work on binding :-). Quite simple, just that I am not able to make some good animation out of it !

Friday Jul 18, 2008

New JavaFX and Netbeans 6.1

Ah, in last 7 days I had written few examples of Java FX and it's nothing of use. I have installed the new plugin of JavaFX on Netbeans6.1. Quite a cool plugin, with FX builder, debugger and many more features. But all with these, the API of JavaFX also got changed. And none of the old code is running on new API base.

Anyway it takes sometime to get acquainted with it but whatever be the changes, new one looks cool. Have a look at the new builder of JavaFX :


How to learn Java FX with new API - Best is to go and check the Netbeans examples which are quite awesome. Knowing about the API's and Attributes. Check this path:

There are some issues I have seen with the ImageViewer feature in Netbeans. It crashes sometime, ok be honest, most of the time. So, the best way to handle it, run the ImageViewer only when you are done with the code. Close it, if you are changing the code. Open it again when you are done with changes. I guess, the subsequent patched will make it stable.

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