You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2006/01/27 00:58:20 UTC
svn commit: r372668 [4/16] - in
/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource:
./ src/ src/alg/ src/animation/ src/collections/ src/crypto/ src/data/
src/dnd/ src/event/ src/flash/ src/flash/flash6/ src...
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/flash.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/flash.js?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/flash.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/flash.js Thu Jan 26 15:56:50 2006
@@ -0,0 +1,703 @@
+/*
+ Copyright (c) 2004-2005, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.flash");
+
+dojo.require("dojo.string.*");
+dojo.require("dojo.uri.*");
+
+/**
+ Provides an easy object for interacting with the Flash plugin. This
+ object provides methods to determine the current version of the Flash
+ plugin (dojo.flash.info); execute Flash instance methods
+ independent of the Flash version
+ being used (dojo.flash.comm); write out the necessary markup to
+ dynamically insert a Flash object into the page (dojo.flash.Embed; and
+ do dynamic installation and upgrading of the current Flash plugin in
+ use (dojo.flash.Install).
+
+ To use dojo.flash, you must first wait until Flash is finished loading
+ and initializing before you attempt communication or interaction.
+ To know when Flash is finished use dojo.event:
+
+ dojo.event.bind(dojo.flash, "loaded", myInstance, "myCallback");
+
+ Then, while the page is still loading provide the file name
+ and the major version of Flash that will be used for Flash/JavaScript
+ communication (see "Flash Communication" below for information on the
+ different kinds of Flash/JavaScript communication supported and how they
+ depend on the version of Flash installed):
+
+ dojo.flash.setSwf({flash8: "src/storage/storage_flash8.swf"});
+
+ This will cause dojo.flash to load and initialize your
+ Flash file "src/storage/storage_flash8.swf, and use the Flash 8
+ ExternalInterface for Flash/JavaScript communication.
+
+ If you want to use Flash 6 features for communication between
+ Flash and JavaScript, use the following:
+
+ dojo.flash.setSwf({flash6: "src/storage/storage_flash6.swf"});
+
+ Flash 6 is currently the best way to do Flash/JavaScript communication
+ (see the section "Flash Communication" below for further
+ details), but doesn't work on all browers. If you want dojo.flash to
+ pick the best way of communicating
+ based on the platform, specify Flash files for both forms of
+ communication:
+
+ dojo.flash.setSwf({flash6: "src/storage/storage_flash6.swf",
+ flash8: "src/storage/storage_flash8.swf"});
+
+ If no SWF files are specified, then Flash is not initialized.
+
+ Your Flash must use DojoExternalInterface to expose Flash methods and
+ to call JavaScript; see "Flash Communication" below for details.
+
+ setSwf can take an optional 'visible' attribute to control whether
+ the Flash file is visible or not; the default is visible:
+
+ dojo.flash.setSwf({flash6: "src/storage/storage_flash6.swf",
+ flash8: "src/storage/storage_flash8.swf",
+ visible: false});
+
+ Once finished, you can query Flash version information:
+
+ dojo.flash.info.version
+
+ Or can communicate with Flash methods that were exposed:
+
+ var results = dojo.flash.comm.sayHello("Some Message");
+
+ Only string values are currently supported.
+
+ -------------------
+ Flash Communication
+ -------------------
+
+ dojo.flash allows Flash/JavaScript communication in
+ a way that can pass large amounts of data back and forth reliably,
+ very fast, and with synchronous method calls. The dojo.flash
+ framework encapsulates the specific way in which this communication occurs,
+ presenting a common interface to JavaScript irrespective of the underlying
+ Flash version.
+
+ There are currently three major ways to do Flash/JavaScript communication
+ in the Flash community:
+
+ 1) Flash 6+ - Uses Flash methods, such as SetVariable and TCallLabel,
+ and the fscommand handler to do communication. Strengths: Very fast,
+ mature, and can send extremely large amounts of data; can do
+ synchronous method calls. Problems: Does not work on Safari; works on
+ Firefox/Mac OS X only if Flash 8 plugin is installed; cryptic to work with.
+
+ 2) Flash 8+ - Uses ExternalInterface, which provides a way for Flash
+ methods to register themselves for callbacks from JavaScript, and a way
+ for Flash to call JavaScript. Strengths: Works on Safari; elegant to
+ work with; can do synchronous method calls. Problems: Extremely buggy
+ (fails if there are new lines in the data, for example); two orders of
+ magnitude slower than the Flash 6+ method; locks up the browser while
+ it is communicating.
+
+ 3) Flash 6+ - Uses two seperate Flash applets, one that we
+ create over and over, passing input data into it using the PARAM tag,
+ which then uses a Flash LocalConnection to pass the data to the main Flash
+ applet; communication back to Flash is accomplished using a getURL
+ call with a javascript protocol handler, such as "javascript:myMethod()".
+ Strengths: the most cross browser, cross platform pre-Flash 8 method
+ of Flash communication known; works on Safari. Problems: Timing issues;
+ clunky and complicated; slow; can only send very small amounts of
+ data (several K); all method calls are asynchronous.
+
+ dojo.flash.comm uses only the first two methods. This framework
+ was created primarily for dojo.storage, which needs to pass very large
+ amounts of data synchronously and reliably across the Flash/JavaScript
+ boundary. We use the first method, the Flash 6 method, on all platforms
+ that support it, while using the Flash 8 ExternalInterface method
+ only on Safari with some special code to help correct ExternalInterface's
+ bugs.
+
+ Since dojo.flash needs to have two versions of the Flash
+ file it wants to generate, a Flash 6 and a Flash 8 version to gain
+ true cross-browser compatibility, several tools are provided to ease
+ development on the Flash side.
+
+ In your Flash file, if you want to expose Flash methods that can be
+ called, use the DojoExternalInterface class to register methods. This
+ class is an exact API clone of the standard ExternalInterface class, but
+ can work in Flash 6+ browsers. Under the covers it uses the best
+ mechanism to do communication:
+
+ class HelloWorld{
+ function HelloWorld(){
+ // Initialize the DojoExternalInterface class
+ DojoExternalInterface.initialize();
+
+ // Expose your methods
+ DojoExternalInterface.addCallback("sayHello", this, this.sayHello);
+
+ // Tell JavaScript that you are ready to have method calls
+ DojoExternalInterface.loaded();
+
+ // Call some JavaScript
+ DojoExternalInterface.call("someJavaScriptMethod");
+ }
+
+ function sayHello(){ ... }
+
+ static main(){ ... }
+ }
+
+ DojoExternalInterface adds to new functions to the ExternalInterface
+ API: initialize() and loaded(). Initialize() must be called before
+ any addCallback() or call() methods are run, and loaded() must be
+ called after you are finished adding your callbacks. Calling loaded()
+ will fire the dojo.flash.loaded() event, so that JavaScript can know that
+ Flash has finished loading and adding its callbacks, and can begin to
+ interact with the Flash file.
+
+ To generate your SWF files, use the ant task
+ "buildFlash". You must have the open source Motion Twin ActionScript
+ compiler (mtasc) installed and in your path to use the "buildFlash"
+ ant task; download and install mtasc from http://www.mtasc.org/.
+
+ buildFlash usage:
+
+ ant buildFlash -Ddojo.flash.file=../tests/flash/HelloWorld.as
+
+ where "dojo.flash.file" is the relative path to your Flash
+ ActionScript file.
+
+ This will generate two SWF files, one ending in _flash6.swf and the other
+ ending in _flash8.swf in the same directory as your ActionScript method:
+
+ HelloWorld_flash6.swf
+ HelloWorld_flash8.swf
+
+ Initialize dojo.flash with the filename and Flash communication version to
+ use during page load; see the documentation for dojo.flash for details:
+
+ dojo.flash.setSwf({flash6: "tests/flash/HelloWorld_flash6.swf",
+ flash8: "tests/flash/HelloWorld_flash8.swf"});
+
+ Now, your Flash methods can be called from JavaScript as if they are native
+ Flash methods, mirrored exactly on the JavaScript side:
+
+ dojo.flash.comm.sayHello();
+
+ Only Strings are supported being passed back and forth currently.
+
+ -------------------
+ Notes
+ -------------------
+
+ If you have both Flash 6 and Flash 8 versions of your file:
+
+ dojo.flash.setSwf({flash6: "tests/flash/HelloWorld_flash6.swf",
+ flash8: "tests/flash/HelloWorld_flash8.swf"});
+
+ but want to force the browser to use a certain version of Flash for
+ all platforms (for testing, for example), use the djConfig
+ variable 'forceFlashComm' with the version number to force:
+
+ var djConfig = { forceFlashComm: 6 };
+
+ Two values are currently supported, 6 and 8, for the two styles of
+ communication described above.
+
+ Also note that dojo.flash can currently only work with one Flash applet
+ on the page; it and the API do not yet support multiple Flash applets on
+ the same page.
+
+ @author Brad Neuberg, bkn3@columbia.edu
+*/
+
+dojo.flash = {
+ flash6_version: null,
+ flash8_version: null,
+ _visible: true,
+
+ /** Sets the SWF files and versions we are using. */
+ setSwf: function(fileInfo){
+ if(fileInfo == null || dojo.lang.isUndefined(fileInfo)){
+ return;
+ }
+
+ if(fileInfo.flash6 != null && !dojo.lang.isUndefined(fileInfo.flash6)){
+ this.flash6_version = fileInfo.flash6;
+ }
+
+ if(fileInfo.flash8 != null && !dojo.lang.isUndefined(fileInfo.flash8)){
+ this.flash8_version = fileInfo.flash8;
+ }
+
+ if(fileInfo.visible){
+ this._visible = fileInfo.visible;
+ }
+
+ // now initialize ourselves
+ this._initialize();
+ },
+
+ /** Returns whether we are using Flash 6 for communication on this platform. */
+ useFlash6: function(){
+ if(this.flash6_version == null){
+ return false;
+ }else if (this.flash6_version != null && dojo.flash.info.commVersion == 6){
+ // if we have a flash 6 version of this SWF, and this browser supports
+ // communicating using Flash 6 features...
+ return true;
+ }else{
+ return false;
+ }
+ },
+
+ /** Returns whether we are using Flash 8 for communication on this platform. */
+ useFlash8: function(){
+ if(this.flash8_version == null){
+ return false;
+ }else if (this.flash8_version != null && dojo.flash.info.commVersion == 8){
+ // if we have a flash 8 version of this SWF, and this browser supports
+ // communicating using Flash 8 features...
+ return true;
+ }else{
+ return false;
+ }
+ },
+
+ /** Initializes dojo.flash. */
+ _initialize: function(){
+ // do nothing if no SWF files are defined
+ if(this.flash6_version == null && this.flash8_version == null){
+ this.info = new Object();
+ this.info.capable = false;
+ return;
+ }
+
+ // find out if Flash is installed
+ this.info = new dojo.flash.Info();
+
+ // if we are not installed, install Flash
+ if(this.info.capable == false){
+ var installer = new dojo.flash.Install();
+ installer.install();
+ }else if(this.info.capable == true){
+ // write the flash object into the page
+ dojo.flash.obj = new dojo.flash.Embed();
+ dojo.flash.obj.setVisible(this._visible);
+ dojo.flash.obj.write();
+
+ // initialize the way we do Flash/JavaScript communication
+ dojo.flash.comm = new dojo.flash.Communicator();
+ }
+ },
+
+ /**
+ A callback when the Flash subsystem is finished loading and can be
+ worked with. To be notified when Flash is finished loading, connect
+ your callback to this method using the following:
+
+ dojo.event.connect(dojo.flash, "loaded", myInstance, "myCallback");
+ */
+ loaded: function(){
+ }
+};
+
+
+/**
+ A class that helps us determine whether Flash is available,
+ it's major and minor versions, and what Flash version features should
+ be used for Flash/JavaScript communication. Parts of this code
+ are adapted from the automatic Flash plugin detection code autogenerated
+ by the Macromedia Flash 8 authoring environment.
+
+ An instance of this class can be accessed on dojo.flash.info after
+ the page is finished loading.
+
+ This constructor must be called before the page is finished loading.
+*/
+dojo.flash.Info = function(){
+ // Visual basic helper required to detect Flash Player ActiveX control
+ // version information on Internet Explorer
+ if(dojo.render.html.ie){
+ document.writeln('<script language="VBScript" type="text/vbscript"\>');
+ document.writeln('Function VBGetSwfVer(i)');
+ document.writeln(' on error resume next');
+ document.writeln(' Dim swControl, swVersion');
+ document.writeln(' swVersion = 0');
+ document.writeln(' set swControl = CreateObject("ShockwaveFlash.ShockwaveFlash." + CStr(i))');
+ document.writeln(' if (IsObject(swControl)) then');
+ document.writeln(' swVersion = swControl.GetVariable("$version")');
+ document.writeln(' end if');
+ document.writeln(' VBGetSwfVer = swVersion');
+ document.writeln('End Function');
+ document.writeln('</script\>');
+ }
+
+ this._detectVersion();
+ this._detectCommunicationVersion();
+}
+
+dojo.flash.Info.prototype = {
+ /** The full version string, such as "8r22". */
+ version: -1,
+
+ /**
+ The major, minor, and revisions of the plugin. For example, if the
+ plugin is 8r22, then the major version is 8, the minor version is 0,
+ and the revision is 22.
+ */
+ versionMajor: -1,
+ versionMinor: -1,
+ versionRevision: -1,
+
+ /** Whether this platform has Flash already installed. */
+ capable: false,
+
+ /**
+ The major version number for how our Flash and JavaScript communicate.
+ This can currently be the following values:
+ 6 - We use a combination of the Flash plugin methods, such as SetVariable
+ and TCallLabel, along with fscommands, to do communication.
+ 8 - We use the ExternalInterface API.
+ -1 - For some reason neither method is supported, and no communication
+ is possible.
+ */
+ commVersion: 6,
+
+ /**
+ Asserts that this environment has the given major, minor, and revision
+ numbers for the Flash player. Returns true if the player is equal
+ or above the given version, false otherwise.
+
+ Example: To test for Flash Player 7r14:
+
+ dojo.flash.info.isVersionOrAbove(7, 0, 14)
+ */
+ isVersionOrAbove: function(reqMajorVer, reqMinorVer, reqVer){
+ // make the revision a decimal (i.e. transform revision 14 into
+ // 0.14
+ reqVer = parseFloat("." + reqVer);
+ if(this.versionMajor > reqMajorVer && this.version >= reqVer){
+ return true;
+ }else if(this.version >= reqVer && this.versionMinor >= reqMinorVer){
+ return true;
+ }else{
+ return false;
+ }
+ },
+
+ _detectVersion: function(){
+ var versionStr;
+
+ // loop backwards through the versions until we find the newest version
+ for(var testVersion = 25; testVersion > 0; testVersion--){
+ if(dojo.render.html.ie){
+ versionStr = VBGetSwfVer(testVersion);
+ }else{
+ versionStr = this._JSFlashInfo(testVersion);
+ }
+
+ if(versionStr == -1 ){
+ this.capable = false;
+ return;
+ }else if(versionStr != 0){
+ var versionArray;
+ if(dojo.render.html.ie){
+ var tempArray = versionStr.split(" ");
+ var tempString = tempArray[1];
+ versionArray = tempString.split(",");
+ }else{
+ versionArray = versionStr.split(".");
+ }
+
+ this.versionMajor = versionArray[0];
+ this.versionMinor = versionArray[1];
+ this.versionRevision = versionArray[2];
+
+ // 7.0r24 == 7.24
+ versionString = this.versionMajor + "." + this.versionRevision;
+ this.version = parseFloat(versionString);
+
+ this.capable = true;
+
+ break;
+ }
+ }
+ },
+
+ /**
+ JavaScript helper required to detect Flash Player PlugIn version
+ information. Internet Explorer uses a corresponding Visual Basic
+ version to interact with the Flash ActiveX control.
+ */
+ _JSFlashInfo: function(testVersion){
+ // NS/Opera version >= 3 check for Flash plugin in plugin array
+ if(navigator.plugins != null && navigator.plugins.length > 0){
+ if(navigator.plugins["Shockwave Flash 2.0"] ||
+ navigator.plugins["Shockwave Flash"]){
+ var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
+ var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
+ var descArray = flashDescription.split(" ");
+ var tempArrayMajor = descArray[2].split(".");
+ var versionMajor = tempArrayMajor[0];
+ var versionMinor = tempArrayMajor[1];
+ if(descArray[3] != ""){
+ tempArrayMinor = descArray[3].split("r");
+ }else{
+ tempArrayMinor = descArray[4].split("r");
+ }
+ var versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
+ var version = versionMajor + "." + versionMinor + "."
+ + versionRevision;
+
+ return version;
+ }
+ }
+
+ return -1;
+ },
+
+ /**
+ Detects the mechanisms that should be used for Flash/JavaScript
+ communication, setting 'commVersion' to either 6 or 8. If the value is
+ 6, we use Flash Plugin 6+ features, such as GetVariable, TCallLabel,
+ and fscommand, to do Flash/JavaScript communication; if the value is
+ 8, we use the ExternalInterface API for communication.
+ */
+ _detectCommunicationVersion: function(){
+ // we prefer Flash 6 features over Flash 8, because they are much faster
+ // and much less buggy
+
+ // does the Flash plugin have some of the Flash methods?
+
+ // otherwise, is the ExternalInterface API present?
+ }
+};
+
+/** A class that is used to write out the Flash object into the page. */
+dojo.flash.Embed = function(){
+}
+
+dojo.flash.Embed.prototype = {
+ /**
+ The width of this Flash applet. The default is the minimal width
+ necessary to show the Flash settings dialog.
+ */
+ width: 215,
+
+ /**
+ The height of this Flash applet. The default is the minimal height
+ necessary to show the Flash settings dialog.
+ */
+ width: 138,
+
+ /** The id of the Flash object. */
+ id: "flashObject",
+
+ /** Controls whether this is a visible Flash applet or not. */
+ _visible: true,
+
+ /**
+ Writes the Flash into the page. This must be called before the page
+ is finished loading.
+ */
+ write: function(){
+ // determine our container div's styling
+ var containerStyle = new dojo.string.Builder();
+ containerStyle.append("width: " + this.width + "px; ");
+ containerStyle.append("height: " + this.height + "px; ");
+ if(this._visible == false){
+ containerStyle.append("position: absolute; ");
+ containerStyle.append("z-index: 100; ");
+ containerStyle.append("top: -1000px; ");
+ containerStyle.append("left: -1000px; ");
+ }
+ containerStyle = containerStyle.toString();
+
+ // Flash 6
+ if(dojo.flash.useFlash6()){
+ var swfloc = dojo.flash.flash6_version;
+
+ document.writeln('<div id="' + this.id + 'Div" style="' + containerStyle + '">');
+ document.writeln(' <embed id="' + this.id + '" src="' + swfloc + '" ');
+ document.writeln(' quality="high" bgcolor="#ffffff" ');
+ document.writeln(' width="' + this.width + '" height="' + this.height + '" name="' + this.id + '" ');
+ document.writeln(' align="middle" allowScriptAccess="sameDomain" ');
+ document.writeln(' type="application/x-shockwave-flash" swLiveConnect="true" ');
+ document.writeln(' pluginspage="http://www.macromedia.com/go/getflashplayer"> ');
+ document.writeln('</div>');
+ }
+ // Flash 8
+ else if (dojo.flash.useFlash8()){
+ var swfloc = dojo.uri.dojoUri(dojo.flash.flash8_version).toString();
+ }
+ },
+
+ /** Gets the Flash object DOM node. */
+ get: function(){
+ return (dojo.render.html.ie) ? window[this.id] : document[this.id];
+ },
+
+ /** Sets the visibility of this Flash object. */
+ setVisible: function(){
+ //FIXME: Dynamically make the movie visible or not
+ },
+
+ /** Centers the flash applet on the page. */
+ center: function(){
+ }
+};
+
+
+/**
+ A class that is used to communicate between Flash and JavaScript in
+ a way that can pass large amounts of data back and forth reliably,
+ very fast, and with synchronous method calls. This class encapsulates the
+ specific way in which this communication occurs,
+ presenting a common interface to JavaScript irrespective of the underlying
+ Flash version.
+*/
+dojo.flash.Communicator = function(){
+ if(dojo.flash.useFlash6()){
+ this._writeFlash6();
+ }else if (dojo.flash.useFlash8()){
+ this._writeFlash8();
+ }
+}
+
+dojo.flash.Communicator.prototype = {
+ _writeFlash6: function(){
+ var id = dojo.flash.obj.id;
+
+ // global function needed for Flash 6 callback;
+ // we write it out as a script tag because the VBScript hook for IE
+ // callbacks does not work properly if this function is evalled() from
+ // within the Dojo system
+ document.writeln('<script language="JavaScript">');
+ document.writeln(' function ' + id + '_DoFSCommand(command, args){ ');
+ document.writeln(' dojo.flash.comm._handleFSCommand(command, args); ');
+ document.writeln('}');
+ document.writeln('</script>');
+
+ // hook for Internet Explorer to receive FSCommands from Flash
+ if(dojo.render.html.ie){
+ document.writeln('<SCRIPT LANGUAGE=VBScript\> ');
+ document.writeln('on error resume next ');
+ document.writeln('Sub ' + id + '_FSCommand(ByVal command, ByVal args)');
+ document.writeln(' call ' + id + '_DoFSCommand(command, args)');
+ document.writeln('end sub');
+ document.writeln('</SCRIPT\> ');
+ }
+ },
+
+ _writeFlash8: function(){
+ // nothing needed for Flash 8 communication; happens automatically
+ },
+
+ /** Handles fscommand's from Flash to JavaScript. Flash 6 communication. */
+ _handleFSCommand: function(command, args){
+ if(command == "addCallback"){ // add Flash method for JavaScript callback
+ this._fscommandAddCallback(command, args);
+ }else if (command == "call"){ // Flash to JavaScript method call
+ this._fscommandCall(command, args);
+ }
+ },
+
+ _fscommandAddCallback: function(command, args){
+ var functionName = args;
+
+ // do a trick, where we link this function name to our wrapper
+ // function, _call, that does the actual JavaScript to Flash call
+ var callFunc = function(){
+ return dojo.flash.comm._call(functionName, arguments);
+ };
+ dojo.flash.comm[functionName] = callFunc;
+
+ // indicate that the call was successful
+ dojo.flash.obj.get().SetVariable("_succeeded", true);
+ },
+
+ _fscommandCall: function(command, args){
+ var plugin = dojo.flash.obj.get();
+ var functionName = args;
+
+ // get the number of arguments to this method call and build them up
+ var numArgs = parseInt(plugin.GetVariable("_numArgs"));
+ var flashArgs = new Array();
+ for(var i = 0; i < numArgs; i++){
+ var currentArg = plugin.GetVariable("_" + i);
+ flashArgs.push(currentArg);
+ }
+
+ // get the function instance; we technically support more capabilities
+ // than ExternalInterface, which can only call global functions; if
+ // the method name has a dot in it, such as "dojo.flash.loaded", we
+ // eval it so that the method gets run against an instance
+ var runMe;
+ if(functionName.indexOf(".") == -1){ // global function
+ runMe = window[functionName];
+ }else{
+ // instance function
+ runMe = eval(functionName);
+ }
+
+ // make the call and get the results
+ var results = null;
+ if(!dojo.lang.isUndefined(runMe) && runMe != null){
+ results = runMe.apply(null, flashArgs);
+ }
+
+ // return the results to flash
+ plugin.SetVariable("_returnResult", results);
+ },
+
+ /**
+ The actual function that will execute a JavaScript to Flash call; used
+ by the Flash 6 communication method.
+ */
+ _call: function(functionName, args){
+ // we do JavaScript to Flash method calls by setting a Flash variable
+ // "_functionName" with the function name; "_numArgs" with the number
+ // of arguments; and "_0", "_1", etc for each numbered argument. Flash
+ // reads these, executes the function call, and returns the result
+ // in "_returnResult"
+ var plugin = dojo.flash.obj.get();
+ plugin.SetVariable("_functionName", functionName);
+ plugin.SetVariable("_numArgs", args.length);
+ for(var i = 0; i < args.length; i++){
+ plugin.SetVariable("_" + i, args[i]);
+ }
+
+ // now tell Flash to execute this method using the Flash Runner
+ plugin.SetVariable("_execute", true);
+ plugin.Play();
+
+ // get the results
+ var results = plugin.GetVariable("_returnResult");
+ dojo.debug("inside, results="+results);
+
+ return results;
+ }
+}
+
+/**
+ Figures out the best way to automatically install the Flash plugin
+ for this browser and platform.
+*/
+dojo.flash.Install = function(){
+}
+
+dojo.flash.Install.prototype = {
+ install: function(){
+ }
+}
+
+// vim:ts=4:noet:tw=0:
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/flash/flash6/DojoExternalInterface.as
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/flash/flash6/DojoExternalInterface.as?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/flash/flash6/DojoExternalInterface.as (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/flash/flash6/DojoExternalInterface.as Thu Jan 26 15:56:50 2006
@@ -0,0 +1,154 @@
+/**
+ An implementation of Flash 8's ExternalInterface that works with Flash 6
+ and which is source-compatible with Flash 8.
+
+ @author Brad Neuberg, bkn3@columbia.edu
+*/
+
+class DojoExternalInterface{
+ public static var available:Boolean;
+ private static var callbacks = new Object();
+
+ public static function initialize(){
+ // FIXME: Set available variable
+ // FIXME: do a test run to see if we can communicate from Flash to JavaScript
+ // and back again to make sure we can actually communicate (set 'available'
+ // variable)
+
+ initializeFlashRunner();
+ }
+
+ public static function addCallback(methodName:String, instance:Object,
+ method:Function) : Boolean{
+ // A variable that indicates whether the call below succeeded
+ _root._succeeded = null;
+
+ // Callbacks are registered with the JavaScript side as follows.
+ // On the Flash side, we maintain a lookup table that associates
+ // the methodName with the actual instance and method that are
+ // associated with this method.
+ // Using fscommand, we send over the action "addCallback", with the
+ // argument being the methodName to add, such as "foobar".
+ // The JavaScript takes these values and registers the existence of
+ // this callback point.
+
+ // precede the method name with a _ character in case it starts
+ // with a number
+ callbacks["_" + methodName] = {_instance: instance, _method: method};
+ fscommand("addCallback", methodName);
+
+ // The API for ExternalInterface says we have to make sure the call
+ // succeeded; check to see if there is a value
+ // for _succeeded, which is set by the JavaScript side
+ if(_root._succeeded == null){
+ return false;
+ }else{
+ return true;
+ }
+ }
+
+ public static function call(methodName:String) : Object{
+ // FIXME: support full JSON serialization
+
+ // First, we pack up all of the arguments to this call and set them
+ // as Flash variables, which the JavaScript side will unpack using
+ // plugin.GetVariable(). We set the number of arguments as "_numArgs",
+ // and add each argument as a variable, such as "_1", "_2", etc., starting
+ // from 0.
+ // We then execute an fscommand with the action "call" and the
+ // argument being the method name. JavaScript takes the method name,
+ // retrieves the arguments using GetVariable, executes the method,
+ // and then places the return result in a Flash variable
+ // named "_returnResult".
+ _root._numArgs = arguments.length - 1;
+ for(var i = 1; i < arguments.length; i++){
+ var argIndex = i - 1;
+ _root["_" + argIndex] = arguments[i];
+ }
+
+ _root._returnResult = undefined;
+ fscommand("call", methodName);
+ return _root.returnResult;
+ }
+
+ /**
+ Called by Flash to indicate to JavaScript that we are ready to have
+ our Flash functions called. Calling loaded()
+ will fire the dojo.flash.loaded() event, so that JavaScript can know that
+ Flash has finished loading and adding its callbacks, and can begin to
+ interact with the Flash file.
+ */
+ public static function loaded(){
+ call("dojo.flash.loaded");
+ }
+
+ /**
+ When JavaScript wants to communicate with Flash it simply sets
+ the Flash variable "_execute" to true; this method creates the
+ internal Movie Clip, called the Flash Runner, that makes this
+ magic happen.
+ */
+ private static function initializeFlashRunner(){
+ // create our Flash runner movie clip and instance, and attach it to
+ // the root stage
+ _root.createEmptyMovieClip("_flashRunner_mc");
+ _root.attachMovie("_flashRunner_mc", "_flashRunner");
+
+ // get the actual object instance of the Flash runner movie clip and
+ // make it invisible
+ var _flashRunner:MovieClip = _root._flashRunner;
+ _flashRunner._visible = false;
+
+ // ActionScript 2 has no way to dynamically add new script to a
+ // dynamic Movie Clip's keyframes or labels. Instead, we use the
+ // onEnterFrame handler, which is called invoked continually at the frame
+ // rate of the SWF file. When the JavaScript wants to tell the
+ // Flash Runner to execute, it simply sets the Flash variable
+ // "_execute" to true, and our onEnterFrame handler knows to execute
+ // a Flash method
+ _root._execute = "false";
+ _flashRunner.onEnterFrame = function(){
+ // SetVariable on the JavaScript side turns all values into strings,
+ // so this comes over as "true" not a Boolean true
+ if(_root._execute == "true"){
+ // reset the execution request
+ _root._execute = "false";
+
+ // handle and execute it
+ DojoExternalInterface._handleJSCall();
+ }
+ }
+ }
+
+ /**
+ Handles and executes a JavaScript to Flash method call. Used by
+ initializeFlashRunner.
+ */
+ public static function _handleJSCall(){
+ // get our parameters
+ var numArgs = parseInt(_root._numArgs);
+ var jsArgs = new Array();
+ for(var i = 0; i < numArgs; i++){
+ var currentValue = _root["_" + i];
+ jsArgs.push(currentValue);
+ }
+
+ // get our function name
+ var functionName = _root._functionName;
+
+ // now get the actual instance and method object to execute on,
+ // using our lookup table that was constructed by calls to
+ // addCallback on initialization
+ var instance = callbacks["_" + functionName]._instance;
+ var method = callbacks["_" + functionName]._method;
+
+ // execute it
+ var results = method.apply(instance, jsArgs);
+ getURL("javascript:dojo.debug('FLASH: result="+results+"')");
+
+ // return the results
+ _root._returnResult = results;
+ }
+}
+
+// vim:ts=4:noet:tw=0:
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/flash/flash8/DojoExternalInterface.as
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/flash/flash8/DojoExternalInterface.as?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/flash/flash8/DojoExternalInterface.as (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/flash/flash8/DojoExternalInterface.as Thu Jan 26 15:56:50 2006
@@ -0,0 +1,44 @@
+/**
+ A wrapper around Flash 8's ExternalInterface; this is needed so that we
+ can do a Flash 6 implementation of ExternalInterface, and be able
+ to support having a single codebase that uses DojoExternalInterface
+ across Flash versions rather than having two seperate source bases,
+ where one uses ExternalInterface and the other uses DojoExternalInterface.
+
+ @author Brad Neuberg, bkn3@columbia.edu
+*/
+import flash.external.ExternalInterface;
+
+class DojoExternalInterface{
+ public static var available:Boolean;
+
+ public static function initialize(){
+ // set whether communication is available
+ DojoExternalInterface.available = ExternalInterface.available;
+ DojoExternalInterface.call("loaded");
+ }
+
+ public static function addCallback(methodName:String, instance:Object,
+ method:Function) : Boolean{
+ return ExternalInterface.addCallback(methodName, instance, method);
+ }
+
+ public static function call(methodName:String) : Object{
+ // we might have any number of optional arguments, so we have to
+ // pass them in dynamically
+ return ExternalInterface.call.apply(ExternalInterface, arguments);
+ }
+
+ /**
+ Called by Flash to indicate to JavaScript that we are ready to have
+ our Flash functions called. Calling loaded()
+ will fire the dojo.flash.loaded() event, so that JavaScript can know that
+ Flash has finished loading and adding its callbacks, and can begin to
+ interact with the Flash file.
+ */
+ public static function loaded(){
+ DojoExternalInterface.call("dojo.flash.loaded");
+ }
+}
+
+// vim:ts=4:noet:tw=0:
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/fx/__package__.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/fx/__package__.js?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/fx/__package__.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/fx/__package__.js Thu Jan 26 15:56:50 2006
@@ -0,0 +1,14 @@
+/*
+ Copyright (c) 2004-2005, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.hostenv.conditionalLoadModule({
+ browser: ["dojo.fx.html"]
+});
+dojo.hostenv.moduleLoaded("dojo.fx.*");
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/fx/html.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/fx/html.js?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/fx/html.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/fx/html.js Thu Jan 26 15:56:50 2006
@@ -0,0 +1,565 @@
+/*
+ Copyright (c) 2004-2005, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.fx.html");
+
+dojo.require("dojo.html");
+dojo.require("dojo.style");
+dojo.require("dojo.lang");
+dojo.require("dojo.animation.*");
+dojo.require("dojo.event.*");
+dojo.require("dojo.graphics.color");
+
+dojo.fx.duration = 500;
+
+dojo.fx.html._makeFadeable = function(node){
+ if(dojo.render.html.ie){
+ // only set the zoom if the "tickle" value would be the same as the
+ // default
+ if( (node.style.zoom.length == 0) &&
+ (dojo.style.getStyle(node, "zoom") == "normal") ){
+ // make sure the node "hasLayout"
+ // NOTE: this has been tested with larger and smaller user-set text
+ // sizes and works fine
+ node.style.zoom = "1";
+ // node.style.zoom = "normal";
+ }
+ // don't set the width to auto if it didn't already cascade that way.
+ // We don't want to f anyones designs
+ if( (node.style.width.length == 0) &&
+ (dojo.style.getStyle(node, "width") == "auto") ){
+ node.style.width = "auto";
+ }
+ }
+}
+
+dojo.fx.html.fadeOut = function(node, duration, callback, dontPlay) {
+ return dojo.fx.html.fade(node, duration, dojo.style.getOpacity(node), 0, callback, dontPlay);
+};
+
+dojo.fx.html.fadeIn = function(node, duration, callback, dontPlay) {
+ return dojo.fx.html.fade(node, duration, dojo.style.getOpacity(node), 1, callback, dontPlay);
+};
+
+dojo.fx.html.fadeHide = function(node, duration, callback, dontPlay) {
+ node = dojo.byId(node);
+ if(!duration) { duration = 150; } // why not have a default?
+ return dojo.fx.html.fadeOut(node, duration, function(node) {
+ node.style.display = "none";
+ if(typeof callback == "function") { callback(node); }
+ });
+};
+
+dojo.fx.html.fadeShow = function(node, duration, callback, dontPlay) {
+ node = dojo.byId(node);
+ if(!duration) { duration = 150; } // why not have a default?
+ node.style.display = "block";
+ return dojo.fx.html.fade(node, duration, 0, 1, callback, dontPlay);
+};
+
+dojo.fx.html.fade = function(node, duration, startOpac, endOpac, callback, dontPlay) {
+ node = dojo.byId(node);
+ dojo.fx.html._makeFadeable(node);
+ var anim = new dojo.animation.Animation(
+ new dojo.math.curves.Line([startOpac],[endOpac]),
+ duration||dojo.fx.duration, 0);
+ dojo.event.connect(anim, "onAnimate", function(e) {
+ dojo.style.setOpacity(node, e.x);
+ });
+ if(callback) {
+ dojo.event.connect(anim, "onEnd", function(e) {
+ callback(node, anim);
+ });
+ }
+ if(!dontPlay) { anim.play(true); }
+ return anim;
+};
+
+dojo.fx.html.slideTo = function(node, duration, endCoords, callback, dontPlay) {
+ if(!dojo.lang.isNumber(duration)) {
+ var tmp = duration;
+ duration = endCoords;
+ endCoords = tmp;
+ }
+ node = dojo.byId(node);
+
+ var top = node.offsetTop;
+ var left = node.offsetLeft;
+ var pos = dojo.style.getComputedStyle(node, 'position');
+
+ if (pos == 'relative' || pos == 'static') {
+ top = parseInt(dojo.style.getComputedStyle(node, 'top')) || 0;
+ left = parseInt(dojo.style.getComputedStyle(node, 'left')) || 0;
+ }
+
+ return dojo.fx.html.slide(node, duration, [left, top],
+ endCoords, callback, dontPlay);
+};
+
+dojo.fx.html.slideBy = function(node, duration, coords, callback, dontPlay) {
+ if(!dojo.lang.isNumber(duration)) {
+ var tmp = duration;
+ duration = coords;
+ coords = tmp;
+ }
+ node = dojo.byId(node);
+
+ var top = node.offsetTop;
+ var left = node.offsetLeft;
+ var pos = dojo.style.getComputedStyle(node, 'position');
+
+ if (pos == 'relative' || pos == 'static') {
+ top = parseInt(dojo.style.getComputedStyle(node, 'top')) || 0;
+ left = parseInt(dojo.style.getComputedStyle(node, 'left')) || 0;
+ }
+
+ return dojo.fx.html.slideTo(node, duration, [left+coords[0], top+coords[1]],
+ callback, dontPlay);
+};
+
+dojo.fx.html.slide = function(node, duration, startCoords, endCoords, callback, dontPlay) {
+ if(!dojo.lang.isNumber(duration)) {
+ var tmp = duration;
+ duration = endCoords;
+ endCoords = startCoords;
+ startCoords = tmp;
+ }
+ node = dojo.byId(node);
+
+ if (dojo.style.getComputedStyle(node, 'position') == 'static') {
+ node.style.position = 'relative';
+ }
+
+ var anim = new dojo.animation.Animation(
+ new dojo.math.curves.Line(startCoords, endCoords),
+ duration||dojo.fx.duration, 0);
+ dojo.event.connect(anim, "onAnimate", function(e) {
+ with( node.style ) {
+ left = e.x + "px";
+ top = e.y + "px";
+ }
+ });
+ if(callback) {
+ dojo.event.connect(anim, "onEnd", function(e) {
+ callback(node, anim);
+ });
+ }
+ if(!dontPlay) { anim.play(true); }
+ return anim;
+};
+
+// Fade from startColor to the node's background color
+dojo.fx.html.colorFadeIn = function(node, duration, startColor, delay, callback, dontPlay) {
+ if(!dojo.lang.isNumber(duration)) {
+ var tmp = duration;
+ duration = startColor;
+ startColor = tmp;
+ }
+ node = dojo.byId(node);
+ var color = dojo.html.getBackgroundColor(node);
+ var bg = dojo.style.getStyle(node, "background-color").toLowerCase();
+ var wasTransparent = bg == "transparent" || bg == "rgba(0, 0, 0, 0)";
+ while(color.length > 3) { color.pop(); }
+
+ var rgb = new dojo.graphics.color.Color(startColor).toRgb();
+ var anim = dojo.fx.html.colorFade(node, duration||dojo.fx.duration, startColor, color, callback, true);
+ dojo.event.connect(anim, "onEnd", function(e) {
+ if( wasTransparent ) {
+ node.style.backgroundColor = "transparent";
+ }
+ });
+ if( delay > 0 ) {
+ node.style.backgroundColor = "rgb(" + rgb.join(",") + ")";
+ if(!dontPlay) { setTimeout(function(){anim.play(true)}, delay); }
+ } else {
+ if(!dontPlay) { anim.play(true); }
+ }
+ return anim;
+};
+// alias for (probably?) common use/terminology
+dojo.fx.html.highlight = dojo.fx.html.colorFadeIn;
+dojo.fx.html.colorFadeFrom = dojo.fx.html.colorFadeIn;
+
+// Fade from node's background color to endColor
+dojo.fx.html.colorFadeOut = function(node, duration, endColor, delay, callback, dontPlay) {
+ if(!dojo.lang.isNumber(duration)) {
+ var tmp = duration;
+ duration = endColor;
+ endColor = tmp;
+ }
+ node = dojo.byId(node);
+ var color = new dojo.graphics.color.Color(dojo.html.getBackgroundColor(node)).toRgb();
+
+ var rgb = new dojo.graphics.color.Color(endColor).toRgb();
+ var anim = dojo.fx.html.colorFade(node, duration||dojo.fx.duration, color, rgb, callback, delay > 0 || dontPlay);
+ if( delay > 0 ) {
+ node.style.backgroundColor = "rgb(" + color.join(",") + ")";
+ if(!dontPlay) { setTimeout(function(){anim.play(true)}, delay); }
+ }
+ return anim;
+};
+// FIXME: not sure which name is better. an alias here may be bad.
+dojo.fx.html.unhighlight = dojo.fx.html.colorFadeOut;
+dojo.fx.html.colorFadeTo = dojo.fx.html.colorFadeOut;
+
+// Fade node background from startColor to endColor
+dojo.fx.html.colorFade = function(node, duration, startColor, endColor, callback, dontPlay) {
+ if(!dojo.lang.isNumber(duration)) {
+ var tmp = duration;
+ duration = endColor;
+ endColor = startColor;
+ startColor = tmp;
+ }
+ node = dojo.byId(node);
+ var startRgb = new dojo.graphics.color.Color(startColor).toRgb();
+ var endRgb = new dojo.graphics.color.Color(endColor).toRgb();
+ var anim = new dojo.animation.Animation(
+ new dojo.math.curves.Line(startRgb, endRgb),
+ duration||dojo.fx.duration, 0);
+ dojo.event.connect(anim, "onAnimate", function(e) {
+ node.style.backgroundColor = "rgb(" + e.coordsAsInts().join(",") + ")";
+ });
+ if(callback) {
+ dojo.event.connect(anim, "onEnd", function(e) {
+ callback(node, anim);
+ });
+ }
+ if( !dontPlay ) { anim.play(true); }
+ return anim;
+};
+
+dojo.fx.html.wipeShow = function(node, duration, callback, dontPlay) {
+ node = dojo.byId(node);
+ var overflow = dojo.html.getStyle(node, "overflow");
+ node.style.overflow = "hidden";
+ node.style.height = 0;
+ dojo.html.show(node);
+ var anim = new dojo.animation.Animation([[0], [node.scrollHeight]], duration||dojo.fx.duration, 0);
+ dojo.event.connect(anim, "onAnimate", function(e) {
+ node.style.height = e.x + "px";
+ });
+ dojo.event.connect(anim, "onEnd", function() {
+ node.style.overflow = overflow;
+ node.style.height = "auto";
+ if(callback) { callback(node, anim); }
+ });
+ if(!dontPlay) { anim.play(); }
+ return anim;
+}
+
+dojo.fx.html.wipeHide = function(node, duration, callback, dontPlay) {
+ node = dojo.byId(node);
+ var overflow = dojo.html.getStyle(node, "overflow");
+ node.style.overflow = "hidden";
+ var anim = new dojo.animation.Animation([[node.offsetHeight], [0]], duration||dojo.fx.duration, 0);
+ dojo.event.connect(anim, "onAnimate", function(e) {
+ node.style.height = e.x + "px";
+ });
+ dojo.event.connect(anim, "onEnd", function() {
+ node.style.overflow = overflow;
+ dojo.html.hide(node);
+ if(callback) { callback(node, anim); }
+ });
+ if(!dontPlay) { anim.play(); }
+ return anim;
+}
+
+dojo.fx.html.wiper = function(node, controlNode) {
+ this.node = dojo.byId(node);
+ if(controlNode) {
+ dojo.event.connect(dojo.byId(controlNode), "onclick", this, "toggle");
+ }
+}
+dojo.lang.extend(dojo.fx.html.wiper, {
+ duration: dojo.fx.duration,
+ _anim: null,
+
+ toggle: function() {
+ if(!this._anim) {
+ var type = "wipe" + (dojo.html.isVisible(this.node) ? "Hide" : "Show");
+ this._anim = dojo.fx[type](this.node, this.duration, dojo.lang.hitch(this, "_callback"));
+ }
+ },
+
+ _callback: function() {
+ this._anim = null;
+ }
+});
+
+dojo.fx.html.wipeIn = function(node, duration, callback, dontPlay) {
+ node = dojo.byId(node);
+ var savedHeight = dojo.html.getStyle(node, "height");
+ dojo.html.show(node);
+ var height = node.offsetHeight;
+ var anim = dojo.fx.html.wipeInToHeight(node, duration, height, function(e) {
+ node.style.height = savedHeight || "auto";
+ if(callback) { callback(node, anim); }
+ }, dontPlay);
+};
+
+dojo.fx.html.wipeInToHeight = function(node, duration, height, callback, dontPlay) {
+ node = dojo.byId(node);
+ var savedOverflow = dojo.html.getStyle(node, "overflow");
+ // FIXME: should we be setting display to something other than "" for the table elements?
+ node.style.height = "0px";
+ node.style.display = "none";
+ if(savedOverflow == "visible") {
+ node.style.overflow = "hidden";
+ }
+ var dispType = dojo.lang.inArray(node.tagName.toLowerCase(), ['tr', 'td', 'th']) ? "" : "block";
+ node.style.display = dispType;
+
+ var anim = new dojo.animation.Animation(
+ new dojo.math.curves.Line([0], [height]),
+ duration||dojo.fx.duration, 0);
+ dojo.event.connect(anim, "onAnimate", function(e) {
+ node.style.height = Math.round(e.x) + "px";
+ });
+ dojo.event.connect(anim, "onEnd", function(e) {
+ if(savedOverflow != "visible") {
+ node.style.overflow = savedOverflow;
+ }
+ if(callback) { callback(node, anim); }
+ });
+ if( !dontPlay ) { anim.play(true); }
+ return anim;
+}
+
+dojo.fx.html.wipeOut = function(node, duration, callback, dontPlay) {
+ node = dojo.byId(node);
+ var savedOverflow = dojo.html.getStyle(node, "overflow");
+ var savedHeight = dojo.html.getStyle(node, "height");
+ var height = node.offsetHeight;
+ node.style.overflow = "hidden";
+
+ var anim = new dojo.animation.Animation(
+ new dojo.math.curves.Line([height], [0]),
+ duration||dojo.fx.duration, 0);
+ dojo.event.connect(anim, "onAnimate", function(e) {
+ node.style.height = Math.round(e.x) + "px";
+ });
+ dojo.event.connect(anim, "onEnd", function(e) {
+ node.style.display = "none";
+ node.style.overflow = savedOverflow;
+ node.style.height = savedHeight || "auto";
+ if(callback) { callback(node, anim); }
+ });
+ if( !dontPlay ) { anim.play(true); }
+ return anim;
+};
+
+dojo.fx.html.explode = function(start, endNode, duration, callback, dontPlay) {
+ var startCoords = dojo.html.toCoordinateArray(start);
+
+ var outline = document.createElement("div");
+ with(outline.style) {
+ position = "absolute";
+ border = "1px solid black";
+ display = "none";
+ }
+ dojo.html.body().appendChild(outline);
+
+ endNode = dojo.byId(endNode);
+ with(endNode.style) {
+ visibility = "hidden";
+ display = "block";
+ }
+ var endCoords = dojo.html.toCoordinateArray(endNode);
+
+ with(endNode.style) {
+ display = "none";
+ visibility = "visible";
+ }
+
+ var anim = new dojo.animation.Animation(
+ new dojo.math.curves.Line(startCoords, endCoords),
+ duration||dojo.fx.duration, 0
+ );
+ dojo.event.connect(anim, "onBegin", function(e) {
+ outline.style.display = "block";
+ });
+ dojo.event.connect(anim, "onAnimate", function(e) {
+ with(outline.style) {
+ left = e.x + "px";
+ top = e.y + "px";
+ width = e.coords[2] + "px";
+ height = e.coords[3] + "px";
+ }
+ });
+
+ dojo.event.connect(anim, "onEnd", function() {
+ endNode.style.display = "block";
+ outline.parentNode.removeChild(outline);
+ if(callback) { callback(endNode, anim); }
+ });
+ if(!dontPlay) { anim.play(); }
+ return anim;
+};
+
+dojo.fx.html.implode = function(startNode, end, duration, callback, dontPlay) {
+ var startCoords = dojo.html.toCoordinateArray(startNode);
+ var endCoords = dojo.html.toCoordinateArray(end);
+
+ startNode = dojo.byId(startNode);
+ var outline = document.createElement("div");
+ with(outline.style) {
+ position = "absolute";
+ border = "1px solid black";
+ display = "none";
+ }
+ dojo.html.body().appendChild(outline);
+
+ var anim = new dojo.animation.Animation(
+ new dojo.math.curves.Line(startCoords, endCoords),
+ duration||dojo.fx.duration, 0
+ );
+ dojo.event.connect(anim, "onBegin", function(e) {
+ startNode.style.display = "none";
+ outline.style.display = "block";
+ });
+ dojo.event.connect(anim, "onAnimate", function(e) {
+ with(outline.style) {
+ left = e.x + "px";
+ top = e.y + "px";
+ width = e.coords[2] + "px";
+ height = e.coords[3] + "px";
+ }
+ });
+
+ dojo.event.connect(anim, "onEnd", function() {
+ outline.parentNode.removeChild(outline);
+ if(callback) { callback(startNode, anim); }
+ });
+ if(!dontPlay) { anim.play(); }
+ return anim;
+};
+
+dojo.fx.html.Exploder = function(triggerNode, boxNode) {
+ triggerNode = dojo.byId(triggerNode);
+ boxNode = dojo.byId(boxNode);
+ var _this = this;
+
+ // custom options
+ this.waitToHide = 500;
+ this.timeToShow = 100;
+ this.waitToShow = 200;
+ this.timeToHide = 70;
+ this.autoShow = false;
+ this.autoHide = false;
+
+ var animShow = null;
+ var animHide = null;
+
+ var showTimer = null;
+ var hideTimer = null;
+
+ var startCoords = null;
+ var endCoords = null;
+
+ this.showing = false;
+
+ this.onBeforeExplode = null;
+ this.onAfterExplode = null;
+ this.onBeforeImplode = null;
+ this.onAfterImplode = null;
+ this.onExploding = null;
+ this.onImploding = null;
+
+ this.timeShow = function() {
+ clearTimeout(showTimer);
+ showTimer = setTimeout(_this.show, _this.waitToShow);
+ }
+
+ this.show = function() {
+ clearTimeout(showTimer);
+ clearTimeout(hideTimer);
+ //triggerNode.blur();
+
+ if( (animHide && animHide.status() == "playing")
+ || (animShow && animShow.status() == "playing")
+ || _this.showing ) { return; }
+
+ if(typeof _this.onBeforeExplode == "function") { _this.onBeforeExplode(triggerNode, boxNode); }
+ animShow = dojo.fx.html.explode(triggerNode, boxNode, _this.timeToShow, function(e) {
+ _this.showing = true;
+ if(typeof _this.onAfterExplode == "function") { _this.onAfterExplode(triggerNode, boxNode); }
+ });
+ if(typeof _this.onExploding == "function") {
+ dojo.event.connect(animShow, "onAnimate", this, "onExploding");
+ }
+ }
+
+ this.timeHide = function() {
+ clearTimeout(showTimer);
+ clearTimeout(hideTimer);
+ if(_this.showing) {
+ hideTimer = setTimeout(_this.hide, _this.waitToHide);
+ }
+ }
+
+ this.hide = function() {
+ clearTimeout(showTimer);
+ clearTimeout(hideTimer);
+ if( animShow && animShow.status() == "playing" ) {
+ return;
+ }
+
+ _this.showing = false;
+ if(typeof _this.onBeforeImplode == "function") { _this.onBeforeImplode(triggerNode, boxNode); }
+ animHide = dojo.fx.html.implode(boxNode, triggerNode, _this.timeToHide, function(e){
+ if(typeof _this.onAfterImplode == "function") { _this.onAfterImplode(triggerNode, boxNode); }
+ });
+ if(typeof _this.onImploding == "function") {
+ dojo.event.connect(animHide, "onAnimate", this, "onImploding");
+ }
+ }
+
+ // trigger events
+ dojo.event.connect(triggerNode, "onclick", function(e) {
+ if(_this.showing) {
+ _this.hide();
+ } else {
+ _this.show();
+ }
+ });
+ dojo.event.connect(triggerNode, "onmouseover", function(e) {
+ if(_this.autoShow) {
+ _this.timeShow();
+ }
+ });
+ dojo.event.connect(triggerNode, "onmouseout", function(e) {
+ if(_this.autoHide) {
+ _this.timeHide();
+ }
+ });
+
+ // box events
+ dojo.event.connect(boxNode, "onmouseover", function(e) {
+ clearTimeout(hideTimer);
+ });
+ dojo.event.connect(boxNode, "onmouseout", function(e) {
+ if(_this.autoHide) {
+ _this.timeHide();
+ }
+ });
+
+ // document events
+ dojo.event.connect(document.documentElement || dojo.html.body(), "onclick", function(e) {
+ if(_this.autoHide && _this.showing
+ && !dojo.dom.isDescendantOf(e.target, boxNode)
+ && !dojo.dom.isDescendantOf(e.target, triggerNode) ) {
+ _this.hide();
+ }
+ });
+
+ return this;
+};
+
+dojo.lang.mixin(dojo.fx, dojo.fx.html);
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/fx/svg.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/fx/svg.js?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/fx/svg.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/fx/svg.js Thu Jan 26 15:56:50 2006
@@ -0,0 +1,100 @@
+/*
+ Copyright (c) 2004-2005, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.fx.svg");
+
+dojo.require("dojo.svg");
+dojo.require("dojo.lang");
+dojo.require("dojo.animation.*");
+dojo.require("dojo.event.*");
+
+dojo.fx.svg.fadeOut = function(node, duration, callback){
+ return dojo.fx.svg.fade(node, duration, dojo.svg.getOpacity(node), 0, callback);
+};
+dojo.fx.svg.fadeIn = function(node, duration, callback){
+ return dojo.fx.svg.fade(node, duration, dojo.svg.getOpacity(node), 1, callback);
+};
+dojo.fx.svg.fadeHide = function(node, duration, callback){
+ if(!duration) { duration = 150; } // why not have a default?
+ return dojo.fx.svg.fadeOut(node, duration, function(node) {
+ if(typeof callback == "function") { callback(node); }
+ });
+};
+dojo.fx.svg.fadeShow = function(node, duration, callback){
+ if(!duration) { duration = 150; } // why not have a default?
+ return dojo.fx.svg.fade(node, duration, 0, 1, callback);
+};
+dojo.fx.svg.fade = function(node, duration, startOpac, endOpac, callback){
+ var anim = new dojo.animation.Animation(
+ new dojo.math.curves.Line([startOpac],[endOpac]),
+ duration,
+ 0
+ );
+ dojo.event.connect(anim, "onAnimate", function(e){
+ dojo.svg.setOpacity(node, e.x);
+ });
+ if (callback) {
+ dojo.event.connect(anim, "onEnd", function(e){
+ callback(node, anim);
+ });
+ };
+ anim.play(true);
+ return anim;
+};
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// TODO
+/////////////////////////////////////////////////////////////////////////////////////////
+
+// SLIDES
+dojo.fx.svg.slideTo = function(node, endCoords, duration, callback) { };
+dojo.fx.svg.slideBy = function(node, coords, duration, callback) { };
+dojo.fx.svg.slide = function(node, startCoords, endCoords, duration, callback) {
+ var anim = new dojo.animation.Animation(
+ new dojo.math.curves.Line([startCoords],[endCoords]),
+ duration,
+ 0
+ );
+ dojo.event.connect(anim, "onAnimate", function(e){
+ dojo.svg.setCoords(node, {x: e.x, y: e.y });
+ });
+ if (callback) {
+ dojo.event.connect(anim, "onEnd", function(e){
+ callback(node, anim);
+ });
+ };
+ anim.play(true);
+ return anim;
+};
+
+// COLORS
+dojo.fx.svg.colorFadeIn = function(node, startRGB, duration, delay, callback) { };
+dojo.fx.svg.highlight = dojo.fx.svg.colorFadeIn;
+dojo.fx.svg.colorFadeFrom = dojo.fx.svg.colorFadeIn;
+
+dojo.fx.svg.colorFadeOut = function(node, endRGB, duration, delay, callback) { };
+dojo.fx.svg.unhighlight = dojo.fx.svg.colorFadeOut;
+dojo.fx.svg.colorFadeTo = dojo.fx.svg.colorFadeOut;
+
+dojo.fx.svg.colorFade = function(node, startRGB, endRGB, duration, callback, dontPlay) { };
+
+// WIPES
+dojo.fx.svg.wipeIn = function(node, duration, callback, dontPlay) { };
+dojo.fx.svg.wipeInToHeight = function(node, duration, height, callback, dontPlay) { }
+dojo.fx.svg.wipeOut = function(node, duration, callback, dontPlay) { };
+
+// Explode and Implode
+dojo.fx.svg.explode = function(startNode, endNode, duration, callback) { };
+dojo.fx.svg.explodeFromBox = function(startCoords, endNode, duration, callback) { };
+dojo.fx.svg.implode = function(startNode, endNode, duration, callback) { };
+dojo.fx.svg.implodeToBox = function(startNode, endCoords, duration, callback) { };
+dojo.fx.svg.Exploder = function(triggerNode, boxNode) { };
+
+// html mixes in, we want SVG to remain separate
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/graphics/Colorspace.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/graphics/Colorspace.js?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/graphics/Colorspace.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/graphics/Colorspace.js Thu Jan 26 15:56:50 2006
@@ -0,0 +1,944 @@
+/*
+ Copyright (c) 2004-2005, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.graphics.Colorspace");
+
+dojo.require("dojo.lang");
+dojo.require("dojo.math.matrix");
+
+//
+// to convert to YUV:
+// c.whitePoint = 'D65';
+// c.RGBWorkingSpace = 'pal_secam_rgb';
+// var out = c.convert([r,g,b], 'RGB', 'XYZ');
+//
+// to convert to YIQ:
+// c.whitePoint = 'D65';
+// c.RGBWorkingSpace = 'ntsc_rgb';
+// var out = c.convert([r,g,b], 'RGB', 'XYZ');
+//
+
+dojo.graphics.Colorspace =function(){
+
+ this.whitePoint = 'D65';
+ this.stdObserver = '10';
+ this.chromaticAdaptationAlg = 'bradford';
+ this.RGBWorkingSpace = 's_rgb';
+ this.useApproxCIELabMapping = 1; // see http://www.brucelindbloom.com/LContinuity.html
+
+ this.chainMaps = {
+ 'RGB_to_xyY' : ['XYZ'],
+ 'xyY_to_RGB' : ['XYZ'],
+ 'RGB_to_Lab' : ['XYZ'],
+ 'Lab_to_RGB' : ['XYZ'],
+ 'RGB_to_LCHab': ['XYZ', 'Lab'],
+ 'LCHab_to_RGB': ['Lab'],
+ 'xyY_to_Lab' : ['XYZ'],
+ 'Lab_to_xyY' : ['XYZ'],
+ 'XYZ_to_LCHab': ['Lab'],
+ 'LCHab_to_XYZ': ['Lab'],
+ 'xyY_to_LCHab': ['XYZ', 'Lab'],
+ 'LCHab_to_xyY': ['Lab', 'XYZ'],
+ 'RGB_to_Luv' : ['XYZ'],
+ 'Luv_to_RGB' : ['XYZ'],
+ 'xyY_to_Luv' : ['XYZ'],
+ 'Luv_to_xyY' : ['XYZ'],
+ 'Lab_to_Luv' : ['XYZ'],
+ 'Luv_to_Lab' : ['XYZ'],
+ 'LCHab_to_Luv': ['Lab', 'XYZ'],
+ 'Luv_to_LCHab': ['XYZ', 'Lab'],
+ 'RGB_to_LCHuv' : ['XYZ', 'Luv'],
+ 'LCHuv_to_RGB' : ['Luv', 'XYZ'],
+ 'XYZ_to_LCHuv' : ['Luv'],
+ 'LCHuv_to_XYZ' : ['Luv'],
+ 'xyY_to_LCHuv' : ['XYZ', 'Luv'],
+ 'LCHuv_to_xyY' : ['Luv', 'XYZ'],
+ 'Lab_to_LCHuv' : ['XYZ', 'Luv'],
+ 'LCHuv_to_Lab' : ['Luv', 'XYZ'],
+ 'LCHab_to_LCHuv': ['Lab', 'XYZ', 'Luv'],
+ 'LCHuv_to_LCHab': ['Luv', 'XYZ', 'Lab'],
+ 'XYZ_to_CMY' : ['RGB'],
+ 'CMY_to_XYZ' : ['RGB'],
+ 'xyY_to_CMY' : ['RGB'],
+ 'CMY_to_xyY' : ['RGB'],
+ 'Lab_to_CMY' : ['RGB'],
+ 'CMY_to_Lab' : ['RGB'],
+ 'LCHab_to_CMY' : ['RGB'],
+ 'CMY_to_LCHab' : ['RGB'],
+ 'Luv_to_CMY' : ['RGB'],
+ 'CMY_to_Luv' : ['RGB'],
+ 'LCHuv_to_CMY' : ['RGB'],
+ 'CMY_to_LCHuv' : ['RGB'],
+ 'XYZ_to_HSL' : ['RGB'],
+ 'HSL_to_XYZ' : ['RGB'],
+ 'xyY_to_HSL' : ['RGB'],
+ 'HSL_to_xyY' : ['RGB'],
+ 'Lab_to_HSL' : ['RGB'],
+ 'HSL_to_Lab' : ['RGB'],
+ 'LCHab_to_HSL' : ['RGB'],
+ 'HSL_to_LCHab' : ['RGB'],
+ 'Luv_to_HSL' : ['RGB'],
+ 'HSL_to_Luv' : ['RGB'],
+ 'LCHuv_to_HSL' : ['RGB'],
+ 'HSL_to_LCHuv' : ['RGB'],
+ 'CMY_to_HSL' : ['RGB'],
+ 'HSL_to_CMY' : ['RGB'],
+ 'CMYK_to_HSL' : ['RGB'],
+ 'HSL_to_CMYK' : ['RGB'],
+ 'XYZ_to_HSV' : ['RGB'],
+ 'HSV_to_XYZ' : ['RGB'],
+ 'xyY_to_HSV' : ['RGB'],
+ 'HSV_to_xyY' : ['RGB'],
+ 'Lab_to_HSV' : ['RGB'],
+ 'HSV_to_Lab' : ['RGB'],
+ 'LCHab_to_HSV' : ['RGB'],
+ 'HSV_to_LCHab' : ['RGB'],
+ 'Luv_to_HSV' : ['RGB'],
+ 'HSV_to_Luv' : ['RGB'],
+ 'LCHuv_to_HSV' : ['RGB'],
+ 'HSV_to_LCHuv' : ['RGB'],
+ 'CMY_to_HSV' : ['RGB'],
+ 'HSV_to_CMY' : ['RGB'],
+ 'CMYK_to_HSV' : ['RGB'],
+ 'HSV_to_CMYK' : ['RGB'],
+ 'HSL_to_HSV' : ['RGB'],
+ 'HSV_to_HSL' : ['RGB'],
+ 'XYZ_to_CMYK' : ['RGB'],
+ 'CMYK_to_XYZ' : ['RGB'],
+ 'xyY_to_CMYK' : ['RGB'],
+ 'CMYK_to_xyY' : ['RGB'],
+ 'Lab_to_CMYK' : ['RGB'],
+ 'CMYK_to_Lab' : ['RGB'],
+ 'LCHab_to_CMYK' : ['RGB'],
+ 'CMYK_to_LCHab' : ['RGB'],
+ 'Luv_to_CMYK' : ['RGB'],
+ 'CMYK_to_Luv' : ['RGB'],
+ 'LCHuv_to_CMYK' : ['RGB'],
+ 'CMYK_to_LCHuv' : ['RGB']
+ };
+
+
+ return this;
+}
+
+dojo.graphics.Colorspace.prototype.convert = function(col, model_from, model_to){
+
+ var k = model_from+'_to_'+model_to;
+
+ if (this[k]){
+ return this[k](col);
+ }else{
+ if (this.chainMaps[k]){
+
+ var cur = model_from;
+ var models = this.chainMaps[k].concat();
+ models.push(model_to);
+
+ for(var i=0; i<models.length; i++){
+
+ col = this.convert(col, cur, models[i]);
+ cur = models[i];
+ }
+
+ return col;
+
+ }else{
+
+ dojo.debug("Can't convert from "+model_from+' to '+model_to);
+ }
+ }
+}
+
+dojo.graphics.Colorspace.prototype.munge = function(keys, args){
+
+ if (dojo.lang.isArray(args[0])){
+ args = args[0];
+ }
+
+ var out = new Array();
+
+ for (var i=0; i<keys.length; i++){
+ out[keys.charAt(i)] = args[i];
+ }
+
+ return out;
+}
+
+dojo.graphics.Colorspace.prototype.getWhitePoint = function(){
+
+ var x = 0;
+ var y = 0;
+ var t = 0;
+
+ // ref: http://en.wikipedia.org/wiki/White_point
+ // TODO: i need some good/better white point values
+
+ switch(this.stdObserver){
+ case '2' :
+ switch(this.whitePoint){
+ case 'E' : x=1/3 ; y=1/3 ; t=5400; break; //Equal energy
+ case 'D50' : x=0.34567; y=0.35850; t=5000; break;
+ case 'D55' : x=0.33242; y=0.34743; t=5500; break;
+ case 'D65' : x=0.31271; y=0.32902; t=6500; break;
+ case 'D75' : x=0.29902; y=0.31485; t=7500; break;
+ case 'A' : x=0.44757; y=0.40745; t=2856; break; //Incandescent tungsten
+ case 'B' : x=0.34842; y=0.35161; t=4874; break;
+ case 'C' : x=0.31006; y=0.31616; t=6774; break;
+ case '9300': x=0.28480; y=0.29320; t=9300; break; //Blue phosphor monitors
+ case 'F2' : x=0.37207; y=0.37512; t=4200; break; //Cool White Fluorescent
+ case 'F7' : x=0.31285; y=0.32918; t=6500; break; //Narrow Band Daylight Fluorescent
+ case 'F11' : x=0.38054; y=0.37691; t=4000; break; //Narrow Band White Fluorescent
+ default: dojo.debug('White point '+this.whitePoint+" isn't defined for Std. Observer "+this.strObserver);
+ };
+ break;
+ case '10' :
+ switch(this.whitePoint){
+ case 'E' : x=1/3 ; y=1/3 ; t=5400; break; //Equal energy
+ case 'D50' : x=0.34773; y=0.35952; t=5000; break;
+ case 'D55' : x=0.33411; y=0.34877; t=5500; break;
+ case 'D65' : x=0.31382; y=0.33100; t=6500; break;
+ case 'D75' : x=0.29968; y=0.31740; t=7500; break;
+ case 'A' : x=0.45117; y=0.40594; t=2856; break; //Incandescent tungsten
+ case 'B' : x=0.3498 ; y=0.3527 ; t=4874; break;
+ case 'C' : x=0.31039; y=0.31905; t=6774; break;
+ case 'F2' : x=0.37928; y=0.36723; t=4200; break; //Cool White Fluorescent
+ case 'F7' : x=0.31565; y=0.32951; t=6500; break; //Narrow Band Daylight Fluorescent
+ case 'F11' : x=0.38543; y=0.37110; t=4000; break; //Narrow Band White Fluorescent
+ default: dojo.debug('White point '+this.whitePoint+" isn't defined for Std. Observer "+this.strObserver);
+ };
+ break;
+ default:
+ dojo.debug("Std. Observer "+this.strObserver+" isn't defined");
+ }
+
+ var z = 1 - x - y;
+
+ var wp = {'x':x, 'y':y, 'z':z, 't':t};
+
+ wp.Y = 1;
+
+ var XYZ = this.xyY_to_XYZ([wp.x, wp.y, wp.Y]);
+
+ wp.X = XYZ[0];
+ wp.Y = XYZ[1];
+ wp.Z = XYZ[2];
+
+ return wp
+}
+
+dojo.graphics.Colorspace.prototype.getPrimaries = function(){
+
+ // ref: http://www.fho-emden.de/~hoffmann/ciexyz29082000.pdf
+ // ref: http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
+
+ var m = [];
+
+ switch(this.RGBWorkingSpace){
+
+ case 'adobe_rgb_1998' : m = [2.2, 'D65', 0.6400, 0.3300, 0.297361, 0.2100, 0.7100, 0.627355, 0.1500, 0.0600, 0.075285]; break;
+ case 'apple_rgb' : m = [1.8, 'D65', 0.6250, 0.3400, 0.244634, 0.2800, 0.5950, 0.672034, 0.1550, 0.0700, 0.083332]; break;
+ case 'best_rgb' : m = [2.2, 'D50', 0.7347, 0.2653, 0.228457, 0.2150, 0.7750, 0.737352, 0.1300, 0.0350, 0.034191]; break;
+ case 'beta_rgb' : m = [2.2, 'D50', 0.6888, 0.3112, 0.303273, 0.1986, 0.7551, 0.663786, 0.1265, 0.0352, 0.032941]; break;
+ case 'bruce_rgb' : m = [2.2, 'D65', 0.6400, 0.3300, 0.240995, 0.2800, 0.6500, 0.683554, 0.1500, 0.0600, 0.075452]; break;
+ case 'cie_rgb' : m = [2.2, 'E' , 0.7350, 0.2650, 0.176204, 0.2740, 0.7170, 0.812985, 0.1670, 0.0090, 0.010811]; break;
+ case 'color_match_rgb' : m = [1.8, 'D50', 0.6300, 0.3400, 0.274884, 0.2950, 0.6050, 0.658132, 0.1500, 0.0750, 0.066985]; break;
+ case 'don_rgb_4' : m = [2.2, 'D50', 0.6960, 0.3000, 0.278350, 0.2150, 0.7650, 0.687970, 0.1300, 0.0350, 0.033680]; break;
+ case 'eci_rgb' : m = [1.8, 'D50', 0.6700, 0.3300, 0.320250, 0.2100, 0.7100, 0.602071, 0.1400, 0.0800, 0.077679]; break;
+ case 'ekta_space_ps5' : m = [2.2, 'D50', 0.6950, 0.3050, 0.260629, 0.2600, 0.7000, 0.734946, 0.1100, 0.0050, 0.004425]; break;
+ case 'ntsc_rgb' : m = [2.2, 'C' , 0.6700, 0.3300, 0.298839, 0.2100, 0.7100, 0.586811, 0.1400, 0.0800, 0.114350]; break;
+ case 'pal_secam_rgb' : m = [2.2, 'D65', 0.6400, 0.3300, 0.222021, 0.2900, 0.6000, 0.706645, 0.1500, 0.0600, 0.071334]; break;
+ case 'pro_photo_rgb' : m = [1.8, 'D50', 0.7347, 0.2653, 0.288040, 0.1596, 0.8404, 0.711874, 0.0366, 0.0001, 0.000086]; break;
+ case 'smpte-c_rgb' : m = [2.2, 'D65', 0.6300, 0.3400, 0.212395, 0.3100, 0.5950, 0.701049, 0.1550, 0.0700, 0.086556]; break;
+ case 's_rgb' : m = [2.2, 'D65', 0.6400, 0.3300, 0.212656, 0.3000, 0.6000, 0.715158, 0.1500, 0.0600, 0.072186]; break;
+ case 'wide_gamut_rgb' : m = [2.2, 'D50', 0.7350, 0.2650, 0.258187, 0.1150, 0.8260, 0.724938, 0.1570, 0.0180, 0.016875]; break;
+
+ default: dojo.debug("RGB working space "+this.RGBWorkingSpace+" isn't defined");
+ }
+
+ var p = {};
+
+ p.name = this.RGBWorkingSpace;
+ p.gamma = m[0];
+ p.wp = m[1];
+
+ p.xr = m[2];
+ p.yr = m[3];
+ p.Yr = m[4];
+
+ p.xg = m[5];
+ p.yg = m[6];
+ p.Yg = m[7];
+
+ p.xb = m[8];
+ p.yb = m[9];
+ p.Yb = m[10];
+
+ // if WP doesn't match current WP, convert the primaries over
+
+ if (p.wp != this.whitePoint){
+
+ var r = this.XYZ_to_xyY( this.chromaticAdaptation( this.xyY_to_XYZ([p.xr, p.yr, p.Yr]), p.wp, this.whitePoint ) );
+ var g = this.XYZ_to_xyY( this.chromaticAdaptation( this.xyY_to_XYZ([p.xg, p.yg, p.Yg]), p.wp, this.whitePoint ) );
+ var b = this.XYZ_to_xyY( this.chromaticAdaptation( this.xyY_to_XYZ([p.xb, p.yb, p.Yb]), p.wp, this.whitePoint ) );
+
+ p.xr = r[0];
+ p.yr = r[1];
+ p.Yr = r[2];
+
+ p.xg = g[0];
+ p.yg = g[1];
+ p.Yg = g[2];
+
+ p.xb = b[0];
+ p.yb = b[1];
+ p.Yb = b[2];
+
+ p.wp = this.whitePoint;
+ }
+
+ p.zr = 1 - p.xr - p.yr;
+ p.zg = 1 - p.xg - p.yg;
+ p.zb = 1 - p.xb - p.yb;
+
+ return p;
+}
+
+dojo.graphics.Colorspace.prototype.epsilon = function(){
+
+ return this.useApproxCIELabMapping ? 0.008856 : 216 / 24289;
+}
+
+dojo.graphics.Colorspace.prototype.kappa = function(){
+
+ return this.useApproxCIELabMapping ? 903.3 : 24389 / 27;
+}
+
+dojo.graphics.Colorspace.prototype.XYZ_to_xyY = function(){
+ var src = this.munge('XYZ', arguments);
+
+ var sum = src.X + src.Y + src.Z;
+
+ if (sum == 0){
+
+ var wp = this.getWhitePoint();
+ var x = wp.x;
+ var y = wp.y;
+ }else{
+ var x = src.X / sum;
+ var y = src.Y / sum;
+ }
+
+ var Y = src.Y;
+
+
+ return [x, y, Y];
+}
+
+dojo.graphics.Colorspace.prototype.xyY_to_XYZ = function(){
+ var src = this.munge('xyY', arguments);
+
+ if (src.y == 0){
+
+ var X = 0;
+ var Y = 0;
+ var Z = 0;
+ }else{
+ var X = (src.x * src.Y) / src.y;
+ var Y = src.Y;
+ var Z = ((1 - src.x - src.y) * src.Y) / src.y;
+ }
+
+ return [X, Y, Z];
+}
+
+dojo.graphics.Colorspace.prototype.RGB_to_XYZ = function(){
+ var src = this.munge('RGB', arguments);
+
+ var m = this.getRGB_XYZ_Matrix();
+ var pr = this.getPrimaries();
+
+ if (this.RGBWorkingSpace == 's_rgb'){
+
+ var r = (src.R > 0.04045) ? Math.pow(((src.R + 0.055) / 1.055), 2.4) : src.R / 12.92;
+ var g = (src.G > 0.04045) ? Math.pow(((src.G + 0.055) / 1.055), 2.4) : src.G / 12.92;
+ var b = (src.B > 0.04045) ? Math.pow(((src.B + 0.055) / 1.055), 2.4) : src.B / 12.92;
+
+ }else{
+
+ var r = Math.pow(src.R, pr.gamma);
+ var g = Math.pow(src.G, pr.gamma);
+ var b = Math.pow(src.B, pr.gamma);
+ }
+
+ var XYZ = dojo.math.matrix.multiply([[r, g, b]], m);
+
+ return [XYZ[0][0], XYZ[0][1], XYZ[0][2]];
+}
+
+dojo.graphics.Colorspace.prototype.XYZ_to_RGB = function(){
+ var src = this.munge('XYZ', arguments);
+
+ var mi = this.getXYZ_RGB_Matrix();
+ var pr = this.getPrimaries();
+
+ var rgb = dojo.math.matrix.multiply([[src.X, src.Y, src.Z]], mi);
+ var r = rgb[0][0];
+ var g = rgb[0][1];
+ var b = rgb[0][2];
+
+ if (this.RGBWorkingSpace == 's_rgb'){
+
+ var R = (r > 0.0031308) ? (1.055 * Math.pow(r, 1.0/2.4)) - 0.055 : 12.92 * r;
+ var G = (g > 0.0031308) ? (1.055 * Math.pow(g, 1.0/2.4)) - 0.055 : 12.92 * g;
+ var B = (b > 0.0031308) ? (1.055 * Math.pow(b, 1.0/2.4)) - 0.055 : 12.92 * b;
+ }else{
+ var R = Math.pow(r, 1/pr.gamma);
+ var G = Math.pow(g, 1/pr.gamma);
+ var B = Math.pow(b, 1/pr.gamma);
+ }
+
+ return [R, G, B];
+}
+
+dojo.graphics.Colorspace.prototype.XYZ_to_Lab = function(){
+ var src = this.munge('XYZ', arguments);
+
+ var wp = this.getWhitePoint();
+
+ var xr = src.X / wp.X;
+ var yr = src.Y / wp.Y;
+ var zr = src.Z / wp.Z;
+
+ var fx = (xr > this.epsilon()) ? Math.pow(xr, 1/3) : (this.kappa() * xr + 16) / 116;
+ var fy = (yr > this.epsilon()) ? Math.pow(yr, 1/3) : (this.kappa() * yr + 16) / 116;
+ var fz = (zr > this.epsilon()) ? Math.pow(zr, 1/3) : (this.kappa() * zr + 16) / 116;
+
+ var L = 116 * fy - 16;
+ var a = 500 * (fx - fy);
+ var b = 200 * (fy - fz);
+
+ return [L, a, b];
+}
+
+dojo.graphics.Colorspace.prototype.Lab_to_XYZ = function(){
+ var src = this.munge('Lab', arguments);
+
+ var wp = this.getWhitePoint();
+
+ var yr = (src.L > (this.kappa() * this.epsilon())) ? Math.pow((src.L + 16) / 116, 3) : src.L / this.kappa();
+
+ var fy = (yr > this.epsilon()) ? (src.L + 16) / 116 : (this.kappa() * yr + 16) / 116;
+
+ var fx = (src.a / 500) + fy;
+ var fz = fy - (src.b / 200);
+
+ var fxcube = Math.pow(fx, 3);
+ var fzcube = Math.pow(fz, 3);
+
+ var xr = (fxcube > this.epsilon()) ? fxcube : (116 * fx - 16) / this.kappa();
+ var zr = (fzcube > this.epsilon()) ? fzcube : (116 * fz - 16) / this.kappa();
+
+ var X = xr * wp.X;
+ var Y = yr * wp.Y;
+ var Z = zr * wp.Z;
+
+ return [X, Y, Z];
+}
+
+dojo.graphics.Colorspace.prototype.Lab_to_LCHab = function(){
+ var src = this.munge('Lab', arguments);
+
+ var L = src.L;
+ var C = Math.pow(src.a * src.a + src.b * src.b, 0.5);
+ var H = Math.atan2(src.b, src.a) * (180 / Math.PI);
+
+ if (H < 0){ H += 360; }
+ if (H > 360){ H -= 360; }
+
+ return [L, C, H];
+}
+
+dojo.graphics.Colorspace.prototype.LCHab_to_Lab = function(){
+ var src = this.munge('LCH', arguments);
+
+ var H_rad = src.H * (Math.PI / 180);
+
+ var L = src.L;
+
+ var a = src.C / Math.pow(Math.pow(Math.tan(H_rad), 2) + 1, 0.5);
+ if ((90 < src.H) && (src.H < 270)){ a= -a; }
+
+ var b = Math.pow(Math.pow(src.C, 2) - Math.pow(a, 2), 0.5);
+ if (src.H > 180){ b = -b; }
+
+ return [L, a, b];
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// this function converts an XYZ color array (col) from one whitepoint (src_w) to another (dst_w)
+//
+
+dojo.graphics.Colorspace.prototype.chromaticAdaptation = function(col, src_w, dst_w){
+
+ col = this.munge('XYZ', [col]);
+
+ //
+ // gather white point data for the source and dest
+ //
+
+ var old_wp = this.whitePoint;
+
+ this.whitePoint = src_w;
+ var wp_src = this.getWhitePoint();
+
+ this.whitePoint = dst_w;
+ var wp_dst = this.getWhitePoint();
+
+ this.whitePoint = old_wp;
+
+
+ //
+ // get a transformation matricies
+ //
+
+ switch(this.chromaticAdaptationAlg){
+ case 'xyz_scaling':
+ var ma = [[1,0,0],[0,1,0],[0,0,1]];
+ var mai = [[1,0,0],[0,1,0],[0,0,1]];
+ break;
+ case 'bradford':
+ var ma = [[0.8951, -0.7502, 0.0389],[0.2664, 1.7135, -0.0685],[-0.1614, 0.0367, 1.0296]];
+ var mai = [[0.986993, 0.432305, -0.008529],[-0.147054, 0.518360, 0.040043],[0.159963, 0.049291, 0.968487]];
+ break;
+ case 'von_kries':
+ var ma = [[0.40024, -0.22630, 0.00000],[0.70760, 1.16532, 0.00000],[-0.08081, 0.04570, 0.91822]]
+ var mai = [[1.859936, 0.361191, 0.000000],[-1.129382, 0.638812, 0.000000],[0.219897, -0.000006, 1.089064]]
+ break;
+ default:
+ dojo.debug("The "+this.chromaticAdaptationAlg+" chromatic adaptation algorithm matricies are not defined");
+ }
+
+
+ //
+ // calculate the cone response domains
+ //
+
+ var domain_src = dojo.math.matrix.multiply( [[wp_src.x, wp_src.y, wp_src.z]], ma);
+ var domain_dst = dojo.math.matrix.multiply( [[wp_dst.x, wp_dst.y, wp_dst.z]], ma);
+
+
+ //
+ // construct the centre matrix
+ //
+
+ var centre = [
+ [domain_dst[0][0]/domain_src[0][0], 0, 0],
+ [0, domain_dst[0][1]/domain_src[0][1], 0],
+ [0, 0, domain_dst[0][2]/domain_src[0][2]]
+ ];
+
+
+ //
+ // caclulate 'm'
+ //
+
+ var m = dojo.math.matrix.multiply( dojo.math.matrix.multiply( ma, centre ), mai );
+
+
+ //
+ // construct source color matrix
+ //
+
+ var dst = dojo.math.matrix.multiply( [[ col.X, col.Y, col.Z ]], m );
+
+ return dst[0];
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////
+
+dojo.graphics.Colorspace.prototype.getRGB_XYZ_Matrix = function(){
+
+ var wp = this.getWhitePoint();
+ var pr = this.getPrimaries();
+
+ var Xr = pr.xr / pr.yr;
+ var Yr = 1;
+ var Zr = (1 - pr.xr - pr.yr) / pr.yr;
+
+ var Xg = pr.xg / pr.yg;
+ var Yg = 1;
+ var Zg = (1 - pr.xg - pr.yg) / pr.yg;
+
+ var Xb = pr.xb / pr.yb;
+ var Yb = 1;
+ var Zb = (1 - pr.xb - pr.yb) / pr.yb;
+
+ var m1 = [[Xr, Yr, Zr],[Xg, Yg, Zg],[Xb, Yb, Zb]];
+ var m2 = [[wp.X, wp.Y, wp.Z]];
+ var sm = dojo.math.matrix.multiply(m2, dojo.math.matrix.inverse(m1));
+
+ var Sr = sm[0][0];
+ var Sg = sm[0][1];
+ var Sb = sm[0][2];
+
+ var m4 = [[Sr*Xr, Sr*Yr, Sr*Zr],
+ [Sg*Xg, Sg*Yg, Sg*Zg],
+ [Sb*Xb, Sb*Yb, Sb*Zb]];
+
+ return m4;
+}
+
+dojo.graphics.Colorspace.prototype.getXYZ_RGB_Matrix = function(){
+
+ var m = this.getRGB_XYZ_Matrix();
+
+ return dojo.math.matrix.inverse(m);
+}
+
+dojo.graphics.Colorspace.prototype.XYZ_to_Luv = function(){
+
+ var src = this.munge('XYZ', arguments);
+
+ var wp = this.getWhitePoint();
+
+ var ud = (4 * src.X) / (src.X + 15 * src.Y + 3 * src.Z);
+ var vd = (9 * src.Y) / (src.X + 15 * src.Y + 3 * src.Z);
+
+ var udr = (4 * wp.X) / (wp.X + 15 * wp.Y + 3 * wp.Z);
+ var vdr = (9 * wp.Y) / (wp.X + 15 * wp.Y + 3 * wp.Z);
+
+ var yr = src.Y / wp.Y;
+
+ var L = (yr > this.epsilon()) ? 116 * Math.pow(yr, 1/3) - 16 : this.kappa() * yr;
+ var u = 13 * L * (ud-udr);
+ var v = 13 * L * (vd-vdr);
+
+ return [L, u, v];
+}
+
+dojo.graphics.Colorspace.prototype.Luv_to_XYZ = function(){
+
+ var src = this.munge('Luv', arguments);
+
+ var wp = this.getWhitePoint();
+
+ var uz = (4 * wp.X) / (wp.X + 15 * wp.Y + 3 * wp.Z);
+ var vz = (9 * wp.Y) / (wp.X + 15 * wp.Y + 3 * wp.Z);
+
+ var Y = (src.L > this.kappa() * this.epsilon()) ? Math.pow((src.L + 16) / 116, 3) : src.L / this.kappa();
+
+ var a = (1 / 3) * (((52 * src.L) / (src.u + 13 * src.L * uz)) - 1);
+ var b = -5 * Y;
+ var c = - (1 / 3);
+ var d = Y * (((39 * src.L) / (src.v + 13 * src.L * vz)) - 5);
+
+ var X = (d - b) / (a - c);
+ var Z = X * a + b;
+
+ return [X, Y, Z];
+}
+
+dojo.graphics.Colorspace.prototype.Luv_to_LCHuv = function(){
+
+ var src = this.munge('Luv', arguments);
+
+ var L = src.L;
+ var C = Math.pow(src.u * src.u + src.v * src.v, 0.5);
+ var H = Math.atan2(src.v, src.u) * (180 / Math.PI);
+
+ if (H < 0){ H += 360; }
+ if (H > 360){ H -= 360; }
+
+ return [L, C, H];
+}
+
+dojo.graphics.Colorspace.prototype.LCHuv_to_Luv = function(){
+
+ var src = this.munge('LCH', arguments);
+
+ var H_rad = src.H * (Math.PI / 180);
+
+ var L = src.L;
+ var u = src.C / Math.pow(Math.pow(Math.tan(H_rad), 2) + 1, 0.5);
+ var v = Math.pow(src.C * src.C - u * u, 0.5);
+
+ if ((90 < src.H) && (src.H < 270)){ u *= -1; }
+ if (src.H > 180){ v *= -1; }
+
+ return [L, u, v];
+}
+
+dojo.graphics.Colorspace.colorTemp_to_whitePoint = function(T){
+
+ if (T < 4000){
+ dojo.debug("Can't find a white point for temperatures under 4000K");
+ return [0,0];
+ }
+
+ if (T > 25000){
+ dojo.debug("Can't find a white point for temperatures over 25000K");
+ return [0,0];
+ }
+
+ var T1 = T;
+ var T2 = T * T;
+ var T3 = T2 * T;
+
+ var ten9 = Math.pow(10, 9);
+ var ten6 = Math.pow(10, 6);
+ var ten3 = Math.pow(10, 3);
+
+ if (T <= 7000){
+
+ var x = (-4.6070 * ten9 / T3) + (2.9678 * ten6 / T2) + (0.09911 * ten3 / T) + 0.244063;
+ }else{
+ var x = (-2.0064 * ten9 / T3) + (1.9018 * ten6 / T2) + (0.24748 * ten3 / T) + 0.237040;
+ }
+
+ var y = -3.000 * x * x + 2.870 * x - 0.275;
+
+ return [x, y];
+}
+
+dojo.graphics.Colorspace.prototype.RGB_to_CMY = function(){
+
+ var src = this.munge('RGB', arguments);
+
+ var C = 1 - src.R;
+ var M = 1 - src.G;
+ var Y = 1 - src.B;
+
+ return [C, M, Y];
+}
+
+dojo.graphics.Colorspace.prototype.CMY_to_RGB = function(){
+
+ var src = this.munge('CMY', arguments);
+
+ var R = 1 - src.C;
+ var G = 1 - src.M;
+ var B = 1 - src.Y;
+
+ return [R, G, B];
+}
+
+dojo.graphics.Colorspace.prototype.RGB_to_CMYK = function(){
+
+ var src = this.munge('RGB', arguments);
+
+ var K = Math.min(1-src.R, 1-src.G, 1-src.B);
+ var C = (1 - src.R - K) / (1 - K);
+ var M = (1 - src.G - K) / (1 - K);
+ var Y = (1 - src.B - K) / (1 - K);
+
+ return [C, M, Y, K];
+}
+
+dojo.graphics.Colorspace.prototype.CMYK_to_RGB = function(){
+
+ var src = this.munge('CMYK', arguments);
+
+ var R = 1 - Math.min(1, src.C * (1-src.K) + src.K);
+ var G = 1 - Math.min(1, src.M * (1-src.K) + src.K);
+ var B = 1 - Math.min(1, src.Y * (1-src.K) + src.K);
+
+ return [R, G, B];
+}
+
+dojo.graphics.Colorspace.prototype.CMY_to_CMYK = function(){
+
+ var src = this.munge('CMY', arguments);
+
+ var K = Math.min(src.C, src.M, src.Y);
+ var C = (src.C - K) / (1 - K);
+ var M = (src.M - K) / (1 - K);
+ var Y = (src.Y - K) / (1 - K);
+
+ return [C, M, Y, K];
+}
+
+dojo.graphics.Colorspace.prototype.CMYK_to_CMY = function(){
+
+ var src = this.munge('CMYK', arguments);
+
+ var C = Math.min(1, src.C * (1-src.K) + src.K);
+ var M = Math.min(1, src.M * (1-src.K) + src.K);
+ var Y = Math.min(1, src.Y * (1-src.K) + src.K);
+
+ return [C, M, Y];
+}
+
+dojo.graphics.Colorspace.prototype.RGB_to_HSV = function(){
+
+ var src = this.munge('RGB', arguments);
+
+ // Based on C Code in "Computer Graphics -- Principles and Practice,"
+ // Foley et al, 1996, p. 592.
+
+ var min = Math.min(src.R, src.G, src.B);
+ var V = Math.max(src.R, src.G, src.B);
+
+ var delta = V - min;
+
+ var H = null;
+ var S = (V == 0) ? 0 : delta / V;
+
+ if (S == 0){
+ H = 0;
+ }else{
+ if (src.R == V){
+ H = 60 * (src.G - src.B) / delta;
+ }else{
+ if (src.G == V){
+ H = 120 + 60 * (src.B - src.R) / delta;
+ }else{
+ if (src.B == V){
+ // between magenta and cyan
+ H = 240 + 60 * (src.R - src.G) / delta;
+ }
+ }
+ }
+ if (H < 0){
+ H += 360;
+ }
+ }
+
+ H = (H == 0) ? 360 : H;
+
+ return [H, S, V];
+}
+
+dojo.graphics.Colorspace.prototype.HSV_to_RGB = function(){
+
+ var src = this.munge('HSV', arguments);
+
+ if (src.H == 360){ src.H = 0;}
+
+ // Based on C Code in "Computer Graphics -- Principles and Practice,"
+ // Foley et al, 1996, p. 593.
+
+ var r = null;
+ var g = null;
+ var b = null;
+
+ if (src.S == 0){
+ // color is on black-and-white center line
+ // achromatic: shades of gray
+ R = src.V;
+ G = src.V;
+ B = src.V;
+ }else{
+ // chromatic color
+ var hTemp = src.H / 60; // h is now IN [0,6]
+ var i = Math.floor(hTemp); // largest integer <= h
+ var f = hTemp - i; // fractional part of h
+
+ var p = src.V * (1 - src.S);
+ var q = src.V * (1 - (src.S * f));
+ var t = src.V * (1 - (src.S * (1 - f)));
+
+ switch(i){
+ case 0: R = src.V; G = t ; B = p ; break;
+ case 1: R = q ; G = src.V; B = p ; break;
+ case 2: R = p ; G = src.V; B = t ; break;
+ case 3: R = p ; G = q ; B = src.V; break;
+ case 4: R = t ; G = p ; B = src.V; break;
+ case 5: R = src.V; G = p ; B = q ; break;
+ }
+ }
+
+ return [R, G, B];
+}
+
+dojo.graphics.Colorspace.prototype.RGB_to_HSL = function(){
+
+ var src = this.munge('RGB', arguments);
+
+ //
+ // based on C code from http://astronomy.swin.edu.au/~pbourke/colour/hsl/
+ //
+
+
+ var min = Math.min(src.R, src.G, src.B);
+ var max = Math.max(src.R, src.G, src.B);
+ var delta = max - min;
+
+ var H = 0;
+ var S = 0;
+ var L = (min + max) / 2;
+
+ if ((L > 0) && (L < 1)){
+ S = delta / ((L < 0.5) ? (2 * L) : (2 - 2 * L));
+ }
+
+ if (delta > 0) {
+ if ((max == src.R) && (max != src.G)){
+ H += (src.G - src.B) / delta;
+ }
+ if ((max == src.G) && (max != src.B)){
+ H += (2 + (src.B - src.R) / delta);
+ }
+ if ((max == src.B) && (max != src.R)){
+ H += (4 + (src.R - src.G) / delta);
+ }
+ H *= 60;
+ }
+
+ H = (H == 0) ? 360 : H;
+
+ return [H, S, L];
+}
+
+dojo.graphics.Colorspace.prototype.HSL_to_RGB = function(){
+
+ var src = this.munge('HSL', arguments);
+
+ //
+ // based on C code from http://astronomy.swin.edu.au/~pbourke/colour/hsl/
+ //
+
+ while (src.H < 0){ src.H += 360; }
+ while (src.H >= 360){ src.H -= 360; }
+
+ var R = 0;
+ var G = 0;
+ var B = 0;
+
+ if (src.H < 120){
+ R = (120 - src.H) / 60;
+ G = src.H / 60;
+ B = 0;
+ }else if (src.H < 240){
+ R = 0;
+ G = (240 - src.H) / 60;
+ B = (src.H - 120) / 60;
+ }else{
+ R = (src.H - 240) / 60;
+ G = 0;
+ B = (360 - src.H) / 60;
+ }
+
+ R = 2 * src.S * Math.min(R, 1) + (1 - src.S);
+ G = 2 * src.S * Math.min(G, 1) + (1 - src.S);
+ B = 2 * src.S * Math.min(B, 1) + (1 - src.S);
+
+ if (src.L < 0.5){
+ R = src.L * R;
+ G = src.L * G;
+ B = src.L * B;
+ }else{
+ R = (1 - src.L) * R + 2 * src.L - 1;
+ G = (1 - src.L) * G + 2 * src.L - 1;
+ B = (1 - src.L) * B + 2 * src.L - 1;
+ }
+
+ return [R, G, B];
+}
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/graphics/__package__.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/graphics/__package__.js?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/graphics/__package__.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/graphics/__package__.js Thu Jan 26 15:56:50 2006
@@ -0,0 +1,14 @@
+/*
+ Copyright (c) 2004-2005, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.hostenv.conditionalLoadModule({
+ browser: ["dojo.graphics.htmlEffects"]
+});
+dojo.hostenv.moduleLoaded("dojo.graphics.*");