Tuesday, August 4, 2009

Cheaterskorean Movies

Java JavaFX GUI JavaFX declarative syntax

In the previous post we have seen an example on how to make a Hello World JavaFX but without going into much detail about a few lines of code, now continue with some examples and explain a bit about this Declarative Syntax, for example an object can be created with an object literal. That means a concise declarative syntax similar to JavaScript, instead of explaining "how" to do something (the algorithm in imperative languages), we describe "what" that something is. For example, in HTML, you declare the content page, but did not explain how this will be displayed on the screen. Now we will see some examples to clarify this.
examples
We will develop an almost line by line, to be feeling the simplicity of language and go see some effects, for this example we use an image that can be found at the following link , let us begin.

Step 1:
  import 
javafx.stage.Stage;


Stage {width: 400
height: 400}


with the few lines above we have already defined an instance of an object Stage, which is needed to render a window.

Step 2:
  
javafx.stage.Stage import, import
javafx.scene.Scene;
javafx.scene.image.ImageView import, import
javafx.scene.image.Image;

var image =
Image {url: "{} JavaFX.png __DIR__"
} {


Stage width: 400 height
: 400
scene: Scene {
content: [ImageView {

x: 75
and: 60
image:

image}]}
}


here we have complicated a little thing, but we will see more details first import Scene, Image and ImageView are needed for the following reasons.
Scene is the object which allows us to render the graphical elements within the ImageView is the container for a given image, and finally the Image is the image itself. If we notice the definition of Scene, we see that their property content (Here we draw the graphical elements), we have added an instance of ImageView already have assigned the image previously loaded into the image variable. As you can see all the syntax is very simple and we always worry about the statement of what we want and not how to generate all this.
The code so far we create a window with the image positioned in the center but our Scene by default has a white background color, if seen in previous posts will see that we assign colors as gradients, as well that we as the next step.

Step 3:
  
javafx.stage.Stage import, import
javafx.scene.Scene;
javafx.scene.image.ImageView import, import
javafx.scene.image.Image;
javafx import. scene.paint.LinearGradient;
javafx.scene.paint.Stop import, import
javafx.scene.paint.Color;

/ ** * @ author SoftDesign

* / var


image = Image {url: " JavaFX.png __DIR__} {"
} {


Stage width: 400
height: 400
scene: Scene {
content: [
ImageView {
x: 75
y: 60
image: image
}
]
fill: LinearGradient {
startX : 0.0
startY : 0.0
endX : 0.0
endY : 1.0
stops: [
Stop {
color : Color.WHITE
offset: 0.0
},
Stop {
color : Color.BLACK
offset: 1.0
}
]

}}}


If we fill the object property Scene, we realize that we are assigning a LinearGradient to this property as we can deduce that generate a linear gradient for average property startx StartY, EndX, Endy linear direction defined by the stops defined that use different Stop, Stop defines each property needs its color and offset property which indicated when the gradient stop.

Many times when we're retouching images or making some effect raises the need for a mirror effect on the water or material, JavaFX comes with many of these problems resolved as it gives various effects to be applied to our images, to see this effect we will use Reflection to be able to reflect our image.

Step 4:
  
import
javafx.stage.Stage;
javafx.scene.Scene import, import
javafx.scene.image.ImageView;
javafx.scene.image.Image import, import
javafx . scene.paint.LinearGradient;
javafx.scene.paint.Stop import;
javafx.scene.paint.Color import, import
javafx.scene.effect.Reflection;

/ ** * @ author SoftDesign

* / var


image = Image {url: "{} JavaFX.png __DIR__"
}

Stage {
width: 400
height: 600
scene: Scene {
content: [
ImageView {
x: 75
y: 60
image: image
effect: Reflection {
fraction: 0.75
topOffset: 0.0
topOpacity: 0.5
bottomOpacity: 0.0
}
}
]
fill: LinearGradient {
startX : 0.0
startY : 0.0
endX : 0.0
endY : 1.0
stops: [Stop {

color: Color.white
offset: 0.0
}, Stop {

color: Color.Black
offset: 1.0
}
]

}}}


Now we have our image a Reflection effect, it is assigned to the ImageView and that is the container of the image and now explain each property for this purpose.
fraction: fraction is shown reflected image based on the original (percentage value).
topOffset: is the distance between the image and the onset of reflex (free value).
topOpacity: opacity is the beginning of the reflex (percentage value).
bottomOpacity: is the final opacity of the reflection (percentage value).

example to be ending as the last detail, we show two effects simultaneously, which should be a DropShadow and Reflection effect.

Step 5:
  
javafx.stage.Stage import, import
javafx.scene.Scene;
javafx.scene.image.ImageView import, import
javafx.scene.image.Image;
javafx import. scene.paint.LinearGradient;
javafx.scene.paint.Stop import;
import javafx.scene.paint.Color;
import javafx.scene.effect.Reflection;
import javafx.scene.effect.DropShadow;

/**
* @author softdesigner
*/

var image = Image {
url: "{__DIR__}JavaFX.png"
}

Stage {
width: 400
height: 600
scene: Scene {
content: [
ImageView {
x: 75
y: 60
image: image
effect: Reflection {
fraction: 0.75
topOffset: 0.0
topOpacity: 0.5
bottomOpacity: 0.0
input: DropShadow {
offsetX: 10
offsetY: 10
color: Color.BLACK
radius: 10
}
}
}
]
fill: LinearGradient {
startX : 0.0
startY : 0.0
endX : 0.0
endY : 1.0
stops: [
Stop {
color : Color.WHITE
offset: 0.0
}, Stop

{color: Color.Black
offset: 1.0
}
]

}}}


If we read about the effect of ImageView property will discover that only accepts an object effect, and here we enter the doubt how to do more to add two effects simultaneously, for most purposes it has a property input which receives an effect, so if we wanted to go chaining purposes should do so through this property, in the upper code notes that the effect Reflection receives an input of a DropShadow, properties the DrowShadow are:
offsetX: Number of pixels on the x axis
offsetY: Number of pixels on the y axis
color: Fill Color of the shadow.
radius: Radio blur for the shadow.

This We'll complete this minimal explanation and demonstration on offers JavaFX declarative syntax and simplicity and power of this language.
I leave a link to the example of netbeans project, then will try to leave the jnlp so they can download. Project


DeclarativeSyntax.rar




Sunday, August 2, 2009

Confirmation In Post Letter Template



JavaFX API provides developers with the ability to create UI interfaces that will be device independent, we can define a division between what would be a Common Desktop profile and a profile. The common profile can be used in desktop applications as well as in mobile applications. In contrast, the profile is Desktop Applications Specs escritorio.El JavaFX SDK has a JavaFX Mobile Emulator in which we can see how our applications are on mobile phones, in a previous post we will see how to use it. Give a brief explanation about the separation of categories and packages come into play, and leave a link to sample files Sun.Este post will be a presentation on JavaFX world and leave a video tutorial on how to create the HelloWorld essential not to fail in a new language. Contents



Common Profile:
  • User Interface Elements
  • Charts
  • Shapes Colors
  • Fill Line Cap Styles and Style
  • Join
  • Text Layout Transformations

Desktop Profile:
  • Cursors Effects

Common Profile:

User Interface Elements
Here all components to create interfaces user, all these components are in the package javafx.scene.control .

Sample File:
UIControls.fx

Charts
JavaFX and provides many types of prefabricated graphics, these can be found in the package javafx.scene.chart see a list of available graphics :
Graphics Area Graphics

Bar Bubble Graphics

Line Charts Pie charts
Scatterplots

Colors
JavaFX provides us with a class that has in javafx.scene.paint.Color package which has predefined color constant turn and specific methods for working with them.

Sample File:
Colors Shapes


The Shapes are the basic ways that we can obviously mixed together we get other more complex figures. This package is in the javafx.scene.shape .

Sample File: Shapes



Fill The Fill Styles are the types of fill that can apply when we paint some elements, these we can add patterns to achieve effect degrade either painting either radial or linear type, and also solid colors.

Sample File: Fill Styles


Line Cap and Join Styles
When we build geometric figures often together and distinguish style lines, this is possible based on javafx.scene package classes. shape which provides the necessary tools for this.

Sample File: Line
Cap and Join Styles

Text
When writing text, we can assign different formats, these features are covered by the package javafx.scene.text , we rotate the letters, move the position, assign distinas typefaces, etc.

Sample File: Text



Transformations We can apply various transformations such as rotations, translaccion coordinate, scaling of images, etc.

Sample File: Transformations



Layout The layout we mark the layout of the elements of the window, there are different types and are stored in the package javafx.scene.layout .

Sample File:

VBox HBox

Desktop Profile:

Effects
We can apply various effects that are already built with JavaFX, these effects can be applied to the JavaFX UI elements.

Sample File: Effects



Cursors can assign different cursors on the elements of JavaFX.

Sample File: Cursors


General Link
I leave a link with a zip that has all the examples of Sun's website, in case of any such link does not go together here are all . Examples


After this little introduction to the graphic elements and different characterizations included in JavaFX proceed to make the first example of our long journey of learning, without another word the Hello World!
I hope the video tutorial is understandable since this is the first thing I do and too many mistakes, I hope can be useful and serve them. Greetings