Berbagai Contoh BasicShapes pada JavaFX 1.3


Ini contoh berbagai shape dasar (BasicShapes) pada JavaFX 1.3

package bab8_antarmuka;

import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.shape.Arc;
import javafx.scene.shape.ArcType;
import javafx.scene.paint.Color;
import javafx.scene.image.ImageView;
import javafx.scene.image.Image;
import javafx.scene.shape.Rectangle;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Line;
import javafx.scene.text.Text;
import javafx.scene.text.Font;
import javafx.scene.shape.Ellipse;
import javafx.scene.shape.Polygon;
import javafx.scene.shape.CubicCurve;
import javafx.scene.Group;
import javafx.scene.shape.Polyline;
import javafx.scene.shape.QuadCurve;
import javafx.geometry.Insets;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;

/**
* @author bhangun
*/

var arc=Arc {
centerX: 100, centerY: 100
radiusX: 40, radiusY: 15
startAngle: 18, length: 120
type: ArcType.OPEN
fill: Color.GREEN
}
var imageView=ImageView {
image: Image {
url: “{__DIR__}myPicture.png”
}
}
var rectangle=Rectangle {
x: 10, y: 10
width: 140, height: 90
fill: Color.BLACK
}
var circle=Circle {
centerX: 100, centerY: 100
radius: 40
fill: Color.BLACK
}
var line=Line {
startX: 10, startY: 10
endX: 230, endY: 100
strokeWidth: 1
stroke: Color.BLACK
}
var text=Text {
font : Font {
size: 24
}
x: 10, y: 30
content: “HelloWorld”
}
var ellipse=Ellipse {
centerX: 100, centerY: 100
radiusX: 40, radiusY: 15
fill: Color.GREEN
}
var polygon=Polygon {
points : [ 0,0, 100,0, 100,100 ]
fill: Color.YELLOW
}

var cubicCurve=CubicCurve {
startX: 0  startY: 50
controlX1: 25 controlY1: 0
controlX2: 75 controlY2: 100
endX: 100 endY: 50
}

var polyline=Polyline {
points : [ 0,0, 100,0, 100,100 ]
strokeWidth: 2.0
stroke: Color.RED
}
var quadCurve=QuadCurve {
startX: 0.0 startY: 50.0
endX: 50.0 endY: 50.0
controlX: 25.0 controlY: 0.0
}

var basicShapes= Group {
content: [
HBox {
content: [
VBox {
padding: Insets {top: 10 right: 4 bottom: 4 left: 10 }
spacing: 10
content: [
arc,
imageView,
rectangle,
circle,
line,
]
}
VBox {
padding: Insets {top: 10 right: 4 bottom: 4 left: 10 }
spacing: 10
content: [
text,
ellipse,
polygon,
cubicCurve,
polyline,
quadCurve]}
]}]
}

Stage {
title: “Basic Shapes”
scene: Scene {
width: 400
height: 400
content: [
basicShapes
]
}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: