Legal Terms and Copyright Notice
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
*
* Copyright © 2010, Oracle and/or its affiliates. All rights reserved.
* Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
* Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.
*
* This file is available and licensed under the following license:
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright notice,
trademark notice, this list of conditions, and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
trademark notice, this list of conditions, and the following disclaimer in
the documentation and/or other materials provided with the distribution.
* * Neither the name of Oracle nor the names of its contributors may be used
to endorse or promote products derived from this software without specific
prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Main.fx
*
* Created on 2009/02/26, 8:54:51
*/
package tubefilling;
import javafx.lang.FX;
import javafx.scene.Cursor;
import javafx.scene.Group;
import javafx.scene.input.MouseEvent;
import javafx.scene.paint.Color;
import javafx.scene.paint.LinearGradient;
import javafx.scene.paint.Stop;
import javafx.scene.Scene;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import tubefilling.TubeFill;
/**
* @author Vaibhav
*/
var tubes: TubeFill[];
var height: Number[] = [120.0, 100.0, 50.0, 90.0];
var name: String[] = ["India", " USA", "Brazil", "Australia"];
for(i in [0..3]){
insert
TubeFill {
translateX: -80 + i * 140
translateY: -40
fillHeight: height[i]
grad: LinearGradient {
startX: 0.0
startY: 0.0
endX: 1.0
endY: 0.0
stops: [
Stop {
color: Color.BLACK // was DARKBLUE
offset: 0.0
},
Stop {
color: Color.SADDLEBROWN // was LIGHTBLUE
offset: 0.5
},
Stop {
color: Color.BLACK // was DARKBLUE
offset: 1.0
},
]
}
} into tubes
}
//Initalize values for x-axis
//Initialize values for stage location on screen
var stageX = 200;
var stageY = 200;
//Create title bar at top of window
var opacity = 0.6;
var dragRect = Rectangle {
x: 0,
y: 0
width: 670,
height: 20
fill: LinearGradient {
startX: 0.0
startY: 0.0
endX: 0.0
endY: 1.0
stops: [
Stop {
color: Color.GRAY
offset: 0.0
},
Stop {
color: Color.BLACK
offset: 1.0
},
]
}
stroke: Color.BLACK
strokeWidth: 2
opacity: 0.9
onMouseDragged: function( e: MouseEvent ):Void {
stageX += e.dragX;
stageY += e.dragY;
}
};
//Create Close button on right side of title bar
var close = Rectangle {
x: 650,
y: 3
arcHeight: 2
arcWidth: 2
width: 15,
height: 15
fill: LinearGradient {
startX: 0.0
startY: 0.0
endX: 0.0
endY: 1.0
stops: [
Stop {
color: Color.ORANGE
offset: 0.0
},
Stop {
color: Color.DARKRED
offset: 0.5
},
Stop {
color: Color.ORANGE
offset: 1.0
},
]
}
stroke: Color.BLACK
strokeWidth: 2
opacity: bind opacity
onMouseClicked: function( e: MouseEvent ):Void {
FX.exit();
}
onMouseMoved: function( e: MouseEvent ):Void {
opacity = 1.0
}
onMouseExited: function( e: MouseEvent ):Void {
opacity = 0.6
}
};
var button = Text {
fill: Color.WHITE
font: Font {
name: "Arial Bold"
size: 14
}
x: 654,
y: 15
content: "x"
}
var op_button = 0.8;
Stage {
x: bind stageX
y: bind stageY
title: "Petrol Cost Across the World"
width: 670
height: 350
style: StageStyle.TRANSPARENT
scene: Scene {
fill: Color.DARKKHAKI
content: [
dragRect, close, button
//Add titles below each tube
Group {
content: for(i in [0..3]) { [
Text {
fill: Color.BLACK
font: Font {
name: "Arial Bold"
size: 12
}
x: 90 + i * 140,
y: 270
content: name[i]
}
]
}
},
tubes
//Create background behind tubes
Rectangle {
x: 30,
y: 35
width: 600,
height: 250
fill: Color.WHITE
opacity: 0.2
stroke: Color.BLACK
strokeWidth: 2
},
//Create title text
Text {
fill: Color.WHITE
font: Font {
size: 12
name: "Arial Bold"
letterSpacing: 0.25
}
x: 20,
y: 15
content: "Petrol Cost Around the World"
}
/* Reload button */
Rectangle {
x: 300,
y: 300
width: 80,
height: 20
fill: LinearGradient {
startX: 0.0
startY: 0.0
endX: 0.0
endY: 1.0
stops: [
Stop {
color: Color.BLACK
offset: 0.0
},
Stop {
color: Color.GRAY
offset: 1.0
},
]
}
stroke: Color.BLACK
opacity: bind op_button
cursor: Cursor.HAND
onMouseClicked: function( e: MouseEvent ):Void {
for(i in [0..3]) {
tubes[i].t.playFromStart();
}
}
onMouseEntered: function( e: MouseEvent ):Void {
op_button = 1.0;
}
onMouseExited: function( e: MouseEvent ):Void {
op_button = 0.8;
}
}
Text {
fill: Color.WHITE
font: Font {
size: 12
name: "Arial Bold"
}
x: 321,
y: 316
content: "Reload"
}
/* end of reload button */
]
}
}