Skip to content

Tag: vídeo

JavaFX SDK 1.0 on Linux

JavaFX 1.0 is out and is absolutely amazing. You guys did really a great work on it.

As I really need a working SDK on Linux to continue to study and I don’t have any Windows/Mac near me, I’m using the Weiqi Gao’s workaround. I tried to simplify a little bit more the process for those who need JavaFX SDK working on Linux right now.

Download javafxsdk_linux_unofficial.tar.bz2 (~18Mb).

And then

tar -xjvf javafxsdk_linux_unofficial.tar.bz2
sudo cp javafx /opt/javafx
echo “PATH=\$PATH:/opt/javafx/bin” >> ~/.profile
echo “JAVAFX_HOME=/opt/javafx” >> ~/.profile
source ~/.profile

Now you can call javafx, javafxc, javafxdoc and javafxpackager from your terminal. Don’t forget that you need Java 1.6 or greater installed.

Here’s a video showing the SDK working, I’m compiling and running two sample applications. Remeber that as a temporary unofficial port for Linux, there’s not native video support nor hardware acceleration.

Un P’tit Café

Par Odelaf e Monsier D.

Lyrique:

Pour bien commencer
Ma petite journée
Et me réveiller
Moi, j’ai pris un café
Un arabica
Noir et bien corsé
J’enfile ma parka
Ça y est je peux y aller

«Où est-ce que tu vas ?»
Me crie mon aimée
«Prenons un kawa
Je viens de me lever»
Étant en avance
Et un peu forcé
Je change de sens
Et reprends un café

A huit heures moins l’quart
Faut bien l’avouer
Les bureaux sont vides
On pourrait s’ennuyer
Mais je reste calme
Je sais m’adapter
Le temps qu’ils arrivent
J’ai l’temps pour un café

La journée s’emballe
Tout le monde peut bosser
Au moins jusqu’à l’heure
De la pause-café
Ma secrétaire entre :
«Fort comme vous l’aimez»
Ah mince, j’viens d’en prendre
Mais maintenant qu’il est fait…

Un repas d’affaire
Tout près du Sentier
Il fait un temps super
Mais je me sens stressé
Mes collègues se marrent :
«Détends-toi, René !
Prends un bon cigare
Et un p’tit café…»

Une fois fini
Mes collègues crevés
Appellent un taxi
Mais moi j’ai envie d’sauter
Je fais tout Paris
Puis je vois un troquet
J’commande un déca
Mais recaféiné

J’arrive au bureau
Ma secrétaire me fait :
«Vous êtes un peu en r’tard
Je me suis inquiétée»
Han ! – J’la jette par la f’nêtre
Elle l’avait bien cherché
T’façons faut qu’je rentre
Mais avant un café

Attendant l’métro
Je me fais agresser
Une p’tite vieille me dit :
«Vous avez l’heure s’il vous plaît ?»
Han РJe lui casse la t̻te
Et j’la pousse sur le quai
Je file à la maison
Et j’me sers un – devinez ?

«Papa, mon Papa,
En classe je suis premier»
Putain mais quoi ?
Tu vas arrêter de m’faire chier ?
Qu’il est con ce gosse !
En plus y s’met à chialer !
J’m’enferme dans la cuisine
Il reste un peu d’café

Ça fait quatorze jours
Que je suis enfermé
J’suis seul dans ma cuisine
Et je bois du café
Il faudrait bien qu’je dorme
Mais les flics vont m’choper
Alors je cloue les portes
Et j’reprends du café..

JavaFX Overview Slides

My slides about a overview on JavaFX at our last CEJUG event.

JavaFX Overview

View SlideShare presentation or Upload your own. (tags: javafx ria)

Downloads:

Café com Tapioca na Christus

Café com Tapioca na Christus

Here a little screncast showing the live preview feature on the NetBeans JavaFX Plugin.

You can also download the orignal screencast in higher resolution netbeans_javafx_preview.ogg (15 Mb). Photos of the presentation at my Flickr album.

JavaFX, Duke Potato

Do you know the toy Mr. Potato Head? Now meet the Java Potato.

Duke images here from previous dukes I posted and other images from Open Clipart Project.

Java Web Start:

The code:

package dukepotato;
 
import javafx.application.Frame;
import javafx.application.Stage;
import javafx.scene.CustomNode;
import javafx.scene.Node;
import javafx.scene.Group;
import javafx.input.MouseEvent;
import javafx.scene.geometry.Circle;
import javafx.scene.paint.Color;
import javafx.scene.image.ImageView;
import javafx.scene.image.Image;
 
public class Img extends ImageView{
    public  attribute content: Node[];
    public  attribute src: String;
 
    private attribute endX = 0.0;
    private attribute endY = 0.0;
    private attribute startX = 0.0;
    private attribute startY = 0.0;
 
    override attribute translateX = bind endX;
    override attribute translateY = bind endY;
    override attribute blocksMouse = true;
 
    init {
        image = Image {
            url: "{__DIR__}/{src}"
        }
    }
 
    override attribute onMousePressed = function(e:MouseEvent):Void {
        startX = e.getDragX()-endX;
        startY = e.getDragY()-endY;
    }
 
    override attribute onMouseDragged = function(e:MouseEvent):Void {
        endX = e.getDragX()-startX;
        endY = e.getDragY()-startY;
    }
}
 
var dukesimages = ["duke1.png", "duke2.png", "duke3.png", "duke4.png"];
var dukes = for (image in dukesimages){
    Image {
        url: "{__DIR__}/{image}"
    }
}
var index = 0;
var duke = ImageView {
    x: 200, y:170
    image: bind dukes[index];
    onMouseClicked: function( e: MouseEvent ):Void {
        index = (index + 1) mod sizeof dukesimages;
    }
}
 
var hat = Img { src: "hat.png", x: 370 }
var partyhat = Img { src: "party_hat.png", x: 160, y: 5 }
var cap = Img { src: "cap.png", x: 230, y: 10 }
var cake = Img { src: "cake.png", x: 526, y: 190 }
var glove = Img { src: "glove.png", x: 338, y: 363 }
var baseball = Img { src: "baseball.png", x: 548, y:373 }
var pencil = Img { src: "pencil.png", x: 451, y: 365 }
var camera = Img { src: "camera.png", x: 125, y: 380 }
var coffee = Img { src: "coffee.png", x: 541, y: 114 }
var burger = Img { src: "burger.png", x: 542, y: 282 }
var diamond = Img { src: "diamond.png", x: 243, y: 383 }
var pliers = Img { src: "pliers.png", x: 20, y: 368 }
var rubikcube = Img { src : "rubikcube.png", x: 37, y: 295 }
var syringe = Img { src: "syringe.png", x: 35, y: 245 }
var hourglass = Img { src: "hourglass.png", x: 35, y: 127 }
var adventurehat = Img { src: "adventurehat.png", x: 8, y:30 }
var tie = Img { src: "tie.png", x: 547, y:35 }
 
Frame {
    title: "Duke Potato"
    width: 640
    height: 480
    closeAction: function() {
        java.lang.System.exit( 0 );
    }
    visible: true
 
    stage: Stage {
        content: [duke, hat, partyhat, cake, adventurehat, cap, glove,
            baseball, pencil, camera, coffee, burger, diamond,
            pliers, rubikcube, syringe, hourglass, tie]
    }
}
  • Lines 14 to 42 is the same dragging approach I showed in the post Draggable Nodes, but this time creating a class that inherits the behavior of ImageView.
  • Lines 44 to 57 is the Duke that changes when you click on it. It cycles over the dukesimages list.
  • Lines 59 to 75 is just instantiations of all toys and objects we will use to dress the Duke. Look how easier was to create and place a image.
  • Lines 78 to the end is just creating a Frame and putting all elements on it.

Download a package with the NetBeans project, sources, libraries and images, DukePotato.tar.gz.

Robot Fish

[youtube:http://youtube.com/watch?v=eO9oseiCTdk]

Description from video:

A robotic fish developed by scientists from Essex University is put through its paces in a special tank at the London Aquarium. It works via sensors and has autonomous navigational control.

Should be hard creating robotics to work underwater…

JavaFX, comic balloon

A example of how flexible can be extending your own Custom Node. In this example I’m creating a comic ballon that can be simple created by:

Ballon {
   text: "I can has fx?"
}

That can also be incremented to work like this:

[youtube:http://br.youtube.com/watch?v=LexJbO1-ti4]

Here a simpler implementation of a balloon, without the dragging behavior but that can be used for creating comics.

import javafx.scene.CustomNode;
import javafx.scene.Group;
import javafx.scene.geometry.Ellipse;
import javafx.scene.geometry.Polygon;
import javafx.scene.geometry.ShapeSubtract;
import javafx.scene.paint.Color;
import javafx.scene.Font;
import javafx.scene.text.Text;
import javafx.scene.FontStyle;
import java.lang.Math;
 
public class Balloon extends CustomNode {  
 
    /* (cx,cy) center of the balloon */
    public attribute cx: Number = 100 on replace {
        distance = Math.sqrt(toX * toX + toY * toY);
    }
    public attribute cy: Number = 100 on replace {
        distance = Math.sqrt(toX * toX + toY * toY);
    }
 
    /* (toX, toY) point where balloon points at */
    public attribute toX: Number = cx on replace {
        distance = Math.sqrt(toX * toX + toY * toY);
    }
    public attribute toY: Number = cy on replace {
        distance = Math.sqrt(toX * toX + toY * toY);
    }
 
    /* what is writted in the balloon */
    public attribute text: String = "balloon";
 
    /* font for the text */
    public attribute font: Font = Font {
        size: 24
        style: FontStyle.PLAIN
    }
 
    /* Distance between (cx,cy) and (toX, toY) */
    private attribute distance: Number;
 
    /* Text inside the balloon */
    private attribute label = Text {
        font: bind font
        content: bind text
    }
 
    /* place the label correctly based on text */
    init {
        label.x = -label .getWidth() / 2;
        label.y = label.font.size / 2;
    }
 
    /* ballon body */
    private attribute body = ShapeSubtract{
        fill: Color.WHITE
        stroke: Color.BLACK
        blocksMouse: true
        a:  bind [
            Ellipse {
                radiusX: bind label.getWidth() / 2 + 20
                radiusY: bind font.size * 2
            },
            Polygon {
                points : [
                    10 * ( - toY / distance),
                    10 * (toX / distance),
                    10 * (toY / distance),
                    10 * ( - toX / distance),
                    toX,
                    toY
                ]
            }
        ]
    }
 
    public function create(): Node {
        return Group {
            cursor: Cursor.HAND
            content: [ body, label]
            translateX: bind cx
            translateY: bind cy
        }
    }
}