/* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common Development * and Distribution License("CDDL") (collectively, the "License"). You * may not use this file except in compliance with the License. You can obtain * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific * language governing permissions and limitations under the License. * * When distributing the software, include this License Header Notice in each * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt. * Sun designates this particular file as subject to the "Classpath" exception * as provided by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the License * Header, with the fields enclosed by brackets [] replaced by your own * identifying information: "Portions Copyrighted [year] * [name of copyright owner]" * * Contributor(s): * * If you wish your version of this file to be governed by only the CDDL or * only the GPL Version 2, indicate your decision by adding "[Contributor] * elects to include this software in this distribution under the [CDDL or GPL * Version 2] license." If you don't indicate a single choice of license, a * recipient has the option to distribute your version of this file under * either the CDDL, the GPL Version 2 or to extend the choice of license to * its licensees as provided above. However, if you add GPL Version 2 code * and therefore, elected the GPL Version 2 license, then the option applies * only if the new code is made subject to such option by the copyright * holder. */ package javafxapplication1; import javafx.scene.*; import javafx.scene.input.MouseEvent; import javafx.scene.media.Media; import javafx.scene.media.MediaPlayer; import javafx.scene.media.MediaView; import javafx.scene.paint.Color; import javafx.scene.shape.Rectangle; import javafx.scene.text.Font; import javafx.scene.text.Text; import javafx.stage.Stage; /** * @author arungupta */ var voted = false; var wsClient = new WebserviceClient; class Result extends CustomNode { override function create():Node { var resultPercent = wsClient.showResults(); var resultString = "{resultPercent} voters liked this clip"; return Group { content: [ Rectangle { fill: Color.BLUE x: 187 y: 145 width: 244 height: 38 arcWidth: 20 arcHeight: 20 onMouseClicked: function( e: MouseEvent ):Void { delete myScene.content[1] } }, Text { x: 199 y: 170 fill: Color.WHITE font: Font { size: 18 } content: resultString } ] } } }; class Vote extends CustomNode { override function create():Node { return Group { content: [ Rectangle { fill: Color.GREEN x: 185 y: 145 width: 243 height: 38 arcWidth: 20 arcHeight: 20 }, Text { x: 195 y: 170 fill: Color.WHITE font: Font { size: 18 } content: "I love it" }, Rectangle{ x: 191 y: 148 smooth: false width: 73 height: 32 fill: Color.TRANSPARENT onMouseClicked: function( e: MouseEvent ):Void { println("clicked I love it"); voted = true; wsClient.voteLoveIt(); delete myScene.content[1] } }, Text{ x: 305 y: 170 fill: Color.WHITE font: Font { size: 18 } content: "Not so great" }, Rectangle { x: 301 y: 148 smooth: false width: 118 height: 32 fill: Color.TRANSPARENT onMouseClicked: function( e: MouseEvent ):Void { voted = true; println("clicked Not so great"); wsClient.voteNotSoGreat(); delete myScene.content[1] } } ] } } }; var myMedia: Media = Media { source: "http://sun.edgeboss.net/download/sun/media/1460825906/1460825906_2957290001_DayEarth-Bluray.flv" }; var myPlayer: MediaPlayer = MediaPlayer{ autoPlay: true media: bind myMedia }; var myScene: Scene = Scene { content: MediaView { fitWidth: 625 fitHeight: 360 mediaPlayer: bind myPlayer onMouseEntered: function( e: MouseEvent ):Void { println("mouse entered"); if (voted == false) { insert Vote{} into myScene.content; } else { insert Result{} into myScene.content; } } onMouseExited: function( e: MouseEvent ):Void { delete myScene.content[1] } } } Stage { title: "GlassFish Media Player" width: 625 height: 360 resizable: false scene: myScene }