1) Extract the javafx4linux.tar.bz2 file. In this example I’m placing it on my Desktop. After the installing process you can remove it.
2) Open your NetBeans 6.5 and go at Tools → Plugins and go to Downloaded tab. In a plain and new NetBeans installation there will be no plugin in this tab yet.
3) Click on the Add Plugins button and head to the directory you extracted the file and select all .nbm files.
4) You will see a list of 22 plugins selected. Click on the Install button.
5) Just keep clicking on the Next button.
6) Check the license agreement accept box.
7) You’ll see a warning because the Linux pluggin is not signed. Don’t worry, just click Continue.
8) Click on Finish to restart NetBeans.
9) Now we can test it. Go at File → New Project, select the JavaFX on Categories and JavaFX Script Application on Projects.
10) Put some code and run it. There is. JavaFX on Linux.
Considerations
This is not a official of JavaFX for Linux! This solution was tested on Ubuntu 9.04 “Jaunty Jackalope” with Java 6 update 13 and NetBeans 6.5.1, but should also work with others Linux distributions and Java versions greater than 5.
Known bugs
As a non official workaround for JavaFX for Linux you may notice some drawbacks. Some parts of the JavaFX runtime rely on native implementations on the specific operational system. You may not use some multimedia capabilities as video playback, JavaFX Mobile emulator and some performance issues in some effects. Despite that, is perfectly possible to develop applications using JavaFX on NetBeans.
Arduino is a free popular platform for embedded programming based on a simple I/O board easily programmable. Interfacing it with Java allow us to create sophisticated interfaces and take advantages from the several API available in the Java ecosystem.
This is not a completely mandatory step but it will easy a lot our work. Our program will borrow some Arduino IDE libraries and configurations like which serial port it is using and at which boud rate. At the moment I wrote this tutorial the version of Arduino IDE was 0013.
Step 2) Prepare your Arduino
Connect your Arduino to the serial port in your computer. Here I’m connecting my Arduino with my laptop throught a USB.
Make sure your Arduino IDE is configured and communicating well if your Arduino. Let put on it a little program that sends to us a mensage:
void setup(){
Serial.begin(9600);}void loop(){
Serial.println("Is there anybody out there?");
delay(1000);}
void setup(){
Serial.begin(9600);
}
void loop(){
Serial.println("Is there anybody out there?");
delay(1000);
}
Step 3) Install RXTX Library
We will use some libraries to acess the serial port, some of them relies on binary implementations on our system. Our first step is to install the RXTX library (Java CommAPI) in your system. In a Debian like Linux you can do that by:
Again, this is not a mandatory step but will easy a lot our work. NetBeans is a free and open source Java IDE that will help us to develop our little application. Create a new project at File → New Project and choose at Java at Categories and Java Application at Projects.
Chose a name for your project. I called mine SerialTalker.
At the moment I wrote this tutorial I was using Netbeans version 6.5 and Java 6 update 10 but should work as well on newer and some older versions
Step 5) Adding Libraries and a Working Directory
On NetBeans the Projects tab, right-click your project and choose Properties.
On the Project Properties window select the Libraries on the Categories panel.
Click the Add JAR/Folder button.
Find where you placed your Arduino IDE installation. Inside this directory there’s a lib directory will some JAR files. Select all them and click Ok.
As we want to borrow the Arduino IDE configuration the program needs to know where is they configuration files. There’s a simple way to do that.
Still in the Project Properties window select Run at Categories panel. At Working Directory click in the Browse button and select the directory of your Arduino IDE. Mine is at /home/silveira/arduino-0013.
You can close now the Project Properties window. At this moment in autocomplete for these libraries are enable in your code.
Step 6) Codding and running
Here is the code you can replace at Main.java in your project:
Já fazem algumas semanas que chegou o resultado, mas eu não tive tempo de postar. Eu passei na prova da certificação SCSNI (Sun Certified Specialist for NetBeans IDE) durante a fase beta do exame. A notÃcia foi uma surpresa porque depois da prova eu realmente tinha achado que tinha levado bomba. Mas como a prova era beta, ainda não estava definido qual ia ser a nota de corte, percentual mÃnimo que devia ser alcançado para você saber se passou ou não.
Tile sets are a very simple way to draw scenarios with repeated elements. From simple to complex ones using a very low footprint.
First step, load the png file that stores the tileset into a Image. The file tiles.png shoud be in the same directory of the source code. I adjusted some tiles from those tile set I’ve blogged here before into a grid of 10×10 tiles.
var tileset =Image{
url:"{__DIR__}tiles.png"}
var tileset = Image {
url: "{__DIR__}tiles.png"
}
Notice that each tile have 32 of height and 32 of width. We will assume this and use theses numbers when performing calculations to find a single tile in our tile set.
def w =32;
def h =32;
def w = 32;
def h = 32;
To display a Image in the screen we use a ImageView node. A ImageView can have a viewport property to create crop or zoom effect. A viewport is just a Rectangle2D, a object with position (minX and minY), height and width. If we want to display the first tile in the tileset we do
Notice that the minX determines the column and minY the row in the tileset. The first row is 0*32, the second row is 1*32 and so on. If we want to display the tile at the second line and third column of the tileset we do
Those properties in a Rectangle2D are for init and read only. So I created a list with all Rectangles I can need for use as a viewport.
def viewports =for(row in [0..9]){for(col in [0..9]){Rectangle2D{
minX: col * w, minY: row * h, height: w, width: h
}}}
def viewports = for (row in [0..9]) {
for (col in [0..9]) {
Rectangle2D{
minX: col * w, minY: row * h, height: w, width: h
}
}
}
The scenario map is stored in another list. The first element of the list is 7, that is, the first tile in the scenario is the 7th tile from the tile set.
Finally to create a scenario with 100 tiles, 10 per row and with 10 rows, in a list called tiles. Each iteration of this loop creates a ImageView. Each ImageView will store a single tile. We get the tile number in the map list and so use it to index the viewports list.
var tiles =for(row in [0..9]){for(col in [0..9]){
ImageView {
x: col * w, y: row * h,
viewport: bind viewports[map[row *10+ col]]
image: tileset
}}}
var tiles = for (row in [0..9]) {
for (col in [0..9]) {
ImageView {
x: col * w, y: row * h,
viewport: bind viewports[map[row * 10 + col]]
image: tileset
}
}
}
Additionally I added two things to transform this program also in a (extremely)Â simple map editor. At each ImageView I added a callback for onMouseClicked event. When you click on a tile, it changes its map position, ie, the tile. The next tile for the left button and the last tile for any other button.
onMouseClicked: function( e:MouseEvent):Void{
var amount =if(e.button== MouseButton.PRIMARY){1}else{-1};
map[row *10+ col]=(map[row *10+ col]+ amount) mod 100;}
We are using just a image that can handle 100 tiles, tiles.png with less than 30Kb. The map is also composed with 100 tiles. Each tile we can choose between 100 different tiles, so we can compose 10100 different maps (one googol10 ). Most of them are useless and without any sense, but some are cool. :)
Following Weiqi Gao’s steps it’s possible to already have a complete JavaFX development environment on Linux.
It’s all there for JavaFX development. Code complementation, live preview, the pallet with code snipets, templates, etc. Easier a lot my work. Those features already availiable on Windows and Mac OS X trought the regular JavaFX Kit.
Eu vou ministrar o primeiro em português amanhã, aqui está o relese:
Nós estamos introduzindo para os membros do OSUM seminários web ao vivo para prover treinamento em tempo real nas últimas tecnologias de Software Livre.
Este seminário web vai introduzir as novas funcionalidades do NetBeans 6.5 como:
→ Suporte robusto a PHP e JavaScript
→ Depuração para Groovy a Grails
→ Novas melhorarias para Java, Ruby e Rails, e desenvolvimento em C/C++
→ Suporte nativo para Hibernate, importação de projetos Eclipse, e a compilação ao salvar.
Este seminário será conduzido por Silveira Neto, Embaixador de Campus da Sun em Fortaleza, Ceará, membro do CEJUG (Ceará Java User Group), desenvolver e entusiasta de tecnologias de Software Livres.
Este seminário web será conduzido em Português. Por favor, consulte o Calendário de Eventos do OSUM para informações da mesma seção em outras lÃnguas.
Este seminário web está marcado para o dia 25 de Novembro de 2008 as 20:00 no horário de Fortaleza, Ceará (UTC -3:00).
Isso corresponde a:
→ 21:00 em São Paulo, Rio e demais estados de mesmo fuso horário do Ceará mas com horário de verão em vigência.
→ 23:00 em UTC (Greenwich).