/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
* Copyright 2008, 2010 Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
* 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,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright 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 Corporation 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.
*/
package rippleeffect;
import java.lang.System;
import javafx.scene.Scene;
import javafx.scene.Group;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.scene.shape.Rectangle;
import javafx.scene.paint.Color;
import javafx.scene.input.MouseEvent;
import javafx.scene.image.Image;
import rippleeffect.view.ImageCanvas;
import rippleeffect.view.ImageButton;
import rippleeffect.view.ControlPanel;
var stageDragInitialX:Number;
var stageDragInitialY:Number;
var inBrowser = "true".equals(FX.getArgument("isApplet") as String);
public var stageWidth = 370.0;
public var stageHeight = 450.0;
var imageURL:String[] = [
"parliament.png", "boston.png", "lotus.png", "kerala.png", "sailboat.png", "sunset.png"
];
var imageURLIndex = 0;
var imageCanvas:ImageCanvas = ImageCanvas { };
public function showNextImage() {
imageURLIndex++;
if(imageURLIndex >= (sizeof imageURL)) {
imageURLIndex = 0;
}
imageCanvas.url = "{__DIR__}images/{imageURL[ imageURLIndex ]}";
}
public function showPrevImage() {
imageURLIndex--;
if(imageURLIndex < 0) {
imageURLIndex = (sizeof imageURL) - 1;
}
imageCanvas.url = "{__DIR__}images/{imageURL[imageURLIndex]}";
}
public function setImage(url:String) {
println(">>> JavaFX.setImage({url})");
imageCanvas.url = url;
}
var closeButton = ImageButton {
translateX: stageWidth - 28
translateY: 5
normalImage:Image { url: "{__DIR__}images/close_normal.png" }
overImage:Image { url: "{__DIR__}images/close_hover.png" }
pressedImage:Image { url: "{__DIR__}images/close_pressed.png" }
visible: not inBrowser
onMouseClicked:function(e) {
FX.exit();
}
}
var border:Rectangle = Rectangle {
x: 0
y: 0
width: stageWidth
height: stageHeight
strokeWidth: 5.0
fill: Color.TRANSPARENT
stroke: Color.GRAY
arcWidth: 20
arcHeight: 20
onMousePressed:function(e) {
if(not inBrowser) {
stageDragInitialX = e.screenX - stage.x;
stageDragInitialY = e.screenY - stage.y;
}
}
onMouseDragged:function(e) {
if(not inBrowser) {
stage.x = e.screenX - stageDragInitialX;
stage.y = e.screenY - stageDragInitialY;
}
}
}
var group = Group {
content: [ imageCanvas, closeButton, border ]
clip:Rectangle {
x: 0
y: 0
width: stageWidth
height: stageHeight
arcWidth: 20
arcHeight: 20
}
}
var stage = Stage {
title: "Ripple Effect"
scene:Scene {
content: group
fill: Color.TRANSPARENT
width: stageWidth
height: stageHeight
}
style: StageStyle.TRANSPARENT
}
function run() {
imageCanvas.url = "{__DIR__}images/parliament.png";
imageCanvas.play();
}