mercredi 28 octobre 2009

Acquisition de Sun par Oracle – des news !

Oracle publie, sur son site, un nouveau document concernant l’acquisition de Sun.
Ce document parle entre autre :
• Du futur des produits (incluant NetBeans, GlassFish, OpenOffice, VirtualBox , MySQL, …)
• De l’offre Hardware et Software
• Et de l’open source.
Vous pouvez lire ce document ici
Tant que j’y suis, d’autres news de produits Sun (En Early Access ou Beta)
Java ME SDK 3.0 pour Mac OS est disponible ici . On peut enfin tester nos applications JavaFX mobile sur le mac ;)
Et NetBeans 6.8 Beta est disponible ici. Il supporte entre autre GlassFish V3 / Java EE 6 et JavaFX
Je vais enfin pouvoir faire des tests sur Java EE 6 (et GlassFish V3) sans avoir a bidouiller mon NetBeans 6.7.1 ;)

mercredi 14 octobre 2009

JavaFX Custom Component

This is just an example to show how you can create your own component from an existing component (here a TextBox).

For that, I wrote a new UI component which is a search text box like you can have it on Mac OS X. This search text box is just a TextBox enhanced with one method which is called each time you enter or delete a character and a small button to reset the criteria in the search text box.

The only problem is this line

override var style = "padding-right: 25 ";

which is not compatible with common profile, but I don’t know how to do that differently.

You can try this JavaFX custom component in the applet below

SearchTextBox.fx
/*
 * StatusField.fx
 *
 * Created on 3 oct. 2009, 00:44:26
 */

package customcomponent;

import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.control.TextBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;

import javafx.scene.shape.Rectangle;

import javafx.scene.input.MouseEvent;

import javafx.scene.input.KeyEvent;

/**
 * @author Patrick
 */

public class SearchTextBox extends TextBox {

    public var onResetSearch:function() : Void;
    public var onSearch:function(s: String) : Void;
    override var style = "padding-right: 25 ";

    override var styleClass = "searchTextBox";

    override var onKeyTyped = function(event:KeyEvent){
        if (this.rawText!=""){
            onSearch(this.rawText);
        }
    }
   
    public override function create():Node {
        var t = super.create();
        var resetButton:Group;

        var g = Group {
            content: [
                t,
                resetButton = Group {

                  var crossWidth = bind this.layoutBounds.height * 0.45;
                  var crossHeight = bind this.layoutBounds.height * 0.05;

                  visible : bind this.rawText.length() > 0
                  layoutX: bind this.layoutBounds.width - (this.layoutBounds.height / 2.0)
                  layoutY: bind this.layoutBounds.height / 2.0

                  content: 
                  [
                    Circle {
                        fill: Color.GRAY
                        radius:  bind this.layoutBounds.height * 0.325 // 65% of the texbox height and div 2 for the radius
                    }
                    Rectangle {
                        width: bind crossWidth
                        height:bind crossHeight

                        translateX: bind 0 - crossWidth / 2.0
                        translateY: bind 0 - crossHeight / 2.0

                        fill : Color.WHITE
                        rotate: 45
                    }
                    Rectangle {
                        width: bind crossWidth
                        height:bind crossHeight

                        translateX: bind 0 - crossWidth / 2.0
                        translateY: bind 0 - crossHeight / 2.0

                        fill : Color.WHITE
                        rotate: -45
                    }
                 ]

                 onMouseClicked: function (event:MouseEvent ){
                     commit();
                     this.text="";
                     onResetSearch();
                 }

             }
           ]
       }
       
       return g;
   }
}


Main.fx
/*
 * Main.fx
 *
 * Created on 3 oct. 2009, 00:44:05
 */

package customcomponent;

import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.text.Text;
import javafx.scene.text.Font;
import javafx.scene.control.Button;

/**
 * @author Patrick
 */

Stage {
    title: "Application title"
    width: 250
    height: 200
    
    scene: Scene {
        content: [
            Text {
                font : Font {
                    size : 16
                }
                x: 10
                y: 30
                content: "Search "
            }
            SearchTextBox {
                    translateX :10
                    translateY :40
                    

                    onResetSearch:function(){
                        println("reset !");
                    }
                    onSearch:function(s: String){
                        println("Search of : {s}");
                    }
            }
            Button {
                    text: "just a button to change focus"
                    translateX :10
                    translateY :80
                    action: function() {
                        println("Hello !")
                   }
            }
        ]
    }
}

jeudi 24 septembre 2009

Duke Anim JavaFX


import java.util.Random;
import javafx.animation.Interpolator;
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
//import javafx.scene.effect.Reflection;
//import javafx.scene.effect.SepiaTone;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.Scene;
import javafx.scene.transform.Translate;
import javafx.stage.Stage;

/**
 * @author paddy
 */

class DukeAnimModel {
  
    public var imageURL = "{__DIR__}images/duke.png";
  
    public var x = 0;
    public var y = 0;

    var xTarget = 0;
    var yTarget = 0;

    var xTemp = 0;
    var yTemp = 0;

    public var anim =
    Timeline {
        autoReverse: false
        keyFrames: [
            KeyFrame {
                time: 0s
                values: [x => xTemp, y => yTemp]

            },
            KeyFrame {
                time: 1s
                //values: [x => 300 tween Interpolator.LINEAR,y => yTarget tween Interpolator.LINEAR]
                values: [x => xTarget tween
                    Interpolator.SPLINE(0,.5,.5,1),y => yTarget tween
                    Interpolator.SPLINE(0,.5,.5,1)]

                action: function(): Void{
                    println("at 1 second ...");

                    var generator = new Random();
                
                    //xTarget = (generator.nextFloat() * 400 + 1) as Integer;
                    xTarget = (
                    generator.nextFloat() * 240 + 1) as Integer;
                    println("xNext {xTarget} ");
                    //yTarget = (generator.nextFloat() * 300 + 1) as Integer;
                    yTarget = (
                    generator.nextFloat() * 320 + 1) as Integer;
                    println("yNext {yTarget} ");
                    xTemp=x;
                    yTemp=y;

                }
            },
        ]
        repeatCount: Timeline.INDEFINITE
    };
}

var dukeAnimModel = DukeAnimModel {}

dukeAnimModel.anim.play();


Stage {
    title: "Application title"
    width: 240  //400
    height: 320 //300
    scene: Scene {
        content: ImageView {
            transforms: Translate {
                x: bind dukeAnimModel.x
                y: bind dukeAnimModel.y
            }
            image: Image {
                url: dukeAnimModel.imageURL

            }
          /*  effect:Reflection{
                input: SepiaTone{
                }
            }
           */

        }
    }
    onClose: function(){
        println("exit");
    }
}

samedi 16 février 2008

Mac Os X 10.5, une nouvelle preview(9) de java SE 6 !

Une nouvelle Java SE 6 Developer Preview (9) est disponible sur ADC et elle inclus java SE 6 version 1.6.0_04 pour voir ce qu’il ya de nouveau, la realese note ! Et sinon, vous pouvez aussi allez lire ce que j’écris de temps en temps sur le blog de la boite ou je bosse actuellement :)

mercredi 19 décembre 2007

Java 6 on Mac Os X Leopard !!!!

Ca y est, on a une version de Java 6 pour Leopard (Mac OS X 10.5) … Bon ok c’est qu’une version Developper (Preview 8) de Java 1.6.0_01 et c’est pas la release … Mais ca marche nickel chrome ;) Les exemples de Scene Graph, qui nécessitent Java 6, tournent super bien… ainsi que les prog JavaFX Script qui avaient quelques petits problèmes d’affichage en Java 5. Par contre je comprend pas pourquoi Java Web Start ne fonctionne pas avec Safari alors qu’il marche super bien avec Firefox !!! (en Java 6 bien sur ;) ) Un problème de configuration du Type MIME JNLP je pense …

lundi 5 novembre 2007

13949712720901ForOSX

13949712720901ForOSX I want Java 6 on Leopard

mercredi 5 septembre 2007

Apprendre JavaFX Script part III

Et la troisième partie qui explique comment accéder à un Web Service JAX-WS 2.1 à partir de JavaFX Script