diff --git a/modules/distribution/pom.xml b/modules/distribution/pom.xml
index 78b8d4a4..07187467 100644
--- a/modules/distribution/pom.xml
+++ b/modules/distribution/pom.xml
@@ -96,6 +96,73 @@
org.apache.maven.plugins
maven-antrun-plugin
+
+
+
+ 2-identity-h2-table-gen
+ package
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ run
+
+
+
+
+
+
+ social-h2-table-gen
+ package
+
+
+
+
+
+
+
+
+
+
+
+
+
+ run
+
+
+
+
create-device-mgt-schema
@@ -124,33 +191,33 @@
-
-
- create-idp-mgt-schema
- package
-
- run
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
create-api-mgt-schema
@@ -179,175 +246,175 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
@@ -457,6 +524,12 @@
+
+
+
+
+
**/version.txt
- **/master-datasources.xml
+
**/carbon.xml
**/registry.xml
**/client-truststore.jks
**/wso2carbon.jks
**/WSO2AM_DB.h2.db
-
**/WSO2DM_DB.h2.db
**/conf/axis2/axis2_client.xml
**/conf/etc/launch.ini
+ **/client-truststore.jks
+ **/wso2carbon.jks
+
+
+ **/registry.xml
+ **/axis2/axis2.xml
+ **/org.wso2.carbon.identity.relyingparty.ui-3.1.0.SNAPSHOT.jar
+ **/org.wso2.carbon.identity.user.registration.ui-3.1.0.SNAPSHOT.jar
+
+ **/log4j.properties
+ **/email/email-admin-config.xml
+ **/claim-config.xml
+ **/ciphertool.bat
+ **/ciphertool.sh
+ **/cipher-text.properties
+ **/cipher-tool.properties
+ **/lib/org.wso2.ciphertool-1.0.0-wso2v3.jar
@@ -63,9 +79,15 @@
**/stratos.xml
**/multitenancy-packages.xml
**/usage-throttling-agent-config.xml
- **/cloud-services-desc.xml
+
+
+
- true
+
+
+ **/tenant-mgt.xml
+
+
@@ -76,6 +98,15 @@
**/tenant-mgt.xml
+
+
+
+
+ ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/resources
+
+ ${pom.artifactId}-${pom.version}/repository/resources
+
+
src/repository/resources/styles/css
${pom.artifactId}-${pom.version}/resources/allthemes/Default/admin
@@ -113,11 +144,7 @@
${pom.artifactId}-${pom.version}/modules/
- **/carbon/
- **/jaggery-test/
- **/process/
- **/uuid/
- **/i18n/
+ */**
@@ -125,8 +152,7 @@
${pom.artifactId}-${pom.version}/repository/conf
**/api-manager.xml
- **/security/
-
+ **/sso-idp-config.xml
@@ -137,6 +163,11 @@
**/entitlement.properties
**/trusted-idp-config.xml
+
+ **/cipher-text.properties
+ **/cipher-tool.properties
+ **/cipher-standalone-config.properties
+
@@ -148,15 +179,16 @@
**/**
-
- src/repository/conf/datasources
- ${pom.artifactId}-${pom.version}/repository/conf/datasources
-
-
- **/master-datasources.xml
- **/cdm-datasources.xml
-
-
+
+
+
+
+
+
+
+
+
+
src/repository/resources
${pom.artifactId}-${pom.version}/repository/resources
@@ -270,6 +302,165 @@
+
+
+
+
+
+
+ ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/deployment/server/jaggeryapps
+
+ ${pom.artifactId}-${pom.version}/repository/deployment/server/jaggeryapps/
+
+
+ */**
+
+
+
+
+
+
+ lib/home
+
+ ${pom.artifactId}-${pom.version}/repository/deployment/server/webapps/STRATOS_ROOT
+
+
+
+
+
+ ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/client
+ ${pom.artifactId}-${pom.version}/lib
+
+ */**
+
+
+
+
+
+
+
+ ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/deployment/server/jaxwebapps
+
+ ${pom.artifactId}-${pom.version}/repository/deployment/server/jaxwebapps
+
+
+ oauth2endpoints.war
+
+
+
+
+
+ target/jaxwebapps
+ ${pom.artifactId}-${pom.version}/repository/deployment/server/jaxwebapps
+
+
+ **/**
+
+
+
+
+
+ ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/bin
+ ${pom.artifactId}-${pom.version}/bin/
+
+ **/ciphertool.sh
+ **/ciphertool.bat
+
+
+
+
+
+ ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/lib
+ ${pom.artifactId}-${pom.version}/lib/
+
+ **/org.wso2.ciphertool-1.0.0-wso2v3.jar
+
+
+
+
+
+ src/repository/conf/etc
+ ${pom.artifactId}-${pom.version}/repository/conf/etc/
+
+ **/**
+
+
+
+
+
+
+ src/repository/conf
+ ${pom.artifactId}-${pom.version}/repository/conf/identity/
+
+ **/sso-idp-config.xml
+
+
+
+
+
+ src/repository/conf/identity
+ ${pom.artifactId}-${pom.version}/repository/conf/identity/
+
+ **/**
+
+
+
+
+
+ src/repository/conf/bam
+ ${pom.artifactId}-${pom.version}/repository/conf/bam
+
+ **/es-bam.xml
+
+
+
+
+
+
+ ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/resources/security/
+
+ ${pom.artifactId}-${pom.version}/repository/resources/security/
+
+
+ **/sso_redirect.html
+
+
+
+
+
+
+ ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/deployment/server/webapps
+
+ ${pom.artifactId}-${pom.version}/repository/deployment/server/webapps
+
+
+ shindig.war
+
+
+
+
+
+ src/repository/bam
+ ${pom.artifactId}-${pom.version}/repository/bam/
+
+ **/**
+
+
+
+
+
+ src/repository/conf/security
+ ${pom.artifactId}-${pom.version}/repository/conf/identity/
+
+ **/application-authenticators.xml
+
+ **/application-authentication.xml
+
+
+
+
+
+
@@ -576,15 +767,16 @@
644
+
-
-
- ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/etc/webapp-authenticator-config.xml
-
- ${pom.artifactId}-${pom.version}/repository/conf/etc
- true
- 644
-
+
+
+
+
+
+
+
+
@@ -657,7 +849,7 @@
644
-
+
target/wso2carbon-core-${carbon.kernel.version}/repository/conf/carbon.xml
${pom.artifactId}-${pom.version}/repository/conf/
@@ -681,5 +873,125 @@
644
+
+
+
+
+
+
+ ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/governance.xml
+
+ ${pom.artifactId}-${pom.version}/repository/conf
+ true
+ 644
+
+
+
+
+ src/repository/conf/registry.xml
+ ${pom.artifactId}-${pom.version}/repository/conf/
+ true
+
+
+
+
+ src/repository/conf/multitenancy/cloud-services-desc.xml
+ ${pom.artifactId}-${pom.version}/repository/conf/multitenancy/
+ true
+
+
+
+
+
+ ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/log4j.properties
+
+ ${pom.artifactId}-${pom.version}/repository/conf/
+
+
+
+
+
+ target/wso2carbon-core-${carbon.kernel.version}/repository/conf/axis2/axis2.xml
+ ${pom.artifactId}-${pom.version}/repository/conf/axis2/
+ true
+ 644
+
+
+
+
+ ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/identity/identity-mgt.properties
+
+ ${pom.artifactId}-${pom.version}/repository/conf/identity
+ true
+ 644
+
+
+
+
+
+ ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/email/email-admin-config.xml
+
+ ${pom.artifactId}-${pom.version}/repository/conf/email
+ true
+ 644
+
+
+
+
+
+ ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/claim-config.xml
+
+ ${pom.artifactId}-${pom.version}/repository/conf
+ true
+ 644
+
+
+
+
+ src/repository/database/WSO2IDENTITY_DB.h2.db
+ ${pom.artifactId}-${pom.version}/repository/database
+ 644
+
+
+
+
+ ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/social.xml
+
+ ${pom.artifactId}-${pom.version}/repository/conf/
+ true
+ 644
+
+
+
+
+
+ ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/datasources/social-datasources.xml
+
+ ${pom.artifactId}-${pom.version}/repository/conf/datasources/
+ true
+ 644
+
+
+
+
+
+ ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/association-config.xml
+
+ ${pom.artifactId}-${pom.version}/repository/conf/etc
+ true
+ 644
+
+
+
+
+
+ ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/shindig.properties
+ ${pom.artifactId}-${pom.version}/repository/conf
+ true
+ 644
+
+
+
+
diff --git a/modules/distribution/src/repository/conf/api-manager.xml b/modules/distribution/src/repository/conf/api-manager.xml
index 74219103..ec166a68 100755
--- a/modules/distribution/src/repository/conf/api-manager.xml
+++ b/modules/distribution/src/repository/conf/api-manager.xml
@@ -8,36 +8,36 @@
EMM
-
-
- false
+
+
+ false
-
-
+
+
-
-
+
+
-
-
+
-
+ JDBC driver for the database.
+ -->
+
X-JWT-Assertion
-
-
+
+
-
-
-
-
-
+
+
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
- Production and Sandbox
-
- https://${carbon.local.ip}:${mgt.transport.https.port}/services/
-
- admin
-
- admin
-
- http://${carbon.local.ip}:${mgt.transport.http.port},https://${carbon.local.ip}:${mgt.transport.https.port}
-
+
+
+
+
+ Production and Sandbox
+
+ https://${carbon.local.ip}:${mgt.transport.https.port}/services/
+
+ admin
+
+ admin
+
+ http://${carbon.local.ip}:${http.nio.port},https://${carbon.local.ip}:${https.nio.port}
+
-
+
false
-
- referer
+
+ referer
-
- false
+
+ false
-
+
@@ -212,23 +212,23 @@
-->
-
+
-
- false
+
+ false
-
- UA-XXXXXXXX-X
+
+ UA-XXXXXXXX-X
-
+
@@ -276,26 +276,26 @@
10397
10000
10397
-
- true
-
-
+
+ true
+
+
-
+
-
- oauth2/token
-
-
- false
+
+ oauth2/token
+
+
+ false
@@ -356,27 +356,27 @@
-->
false
-
-
- true
-
-
- true
-
-
-
+ -->
+ true
+
+
+ true
+
+
+
@@ -398,27 +398,27 @@
related to those operations
-->
-
-
-
-
-
-
+
+
+
+
+
+
-
+
+ false
+
+
-
- false
-
-
-
-
-
+
+
+
-
-
-
+
+
+ -->
-
-
- true
-
- https://localhost:9443,http://localhost:9763
+
+ true
-
- authorization,Access-Control-Allow-Origin,Content-Type
+
+ https://localhost:9443,http://localhost:9763
-
- GET,POST,PUT,DELETE,OPTIONS
+
+ authorization,Access-Control-Allow-Origin,Content-Type
+
+
+ GET,POST,PUT,DELETE,OPTIONS
diff --git a/modules/distribution/src/repository/conf/datasources/master-datasources.xml b/modules/distribution/src/repository/conf/datasources/master-datasources.xml
index d0e734fc..c564318d 100755
--- a/modules/distribution/src/repository/conf/datasources/master-datasources.xml
+++ b/modules/distribution/src/repository/conf/datasources/master-datasources.xml
@@ -98,132 +98,6 @@
-
- FireAlarmDM_DS
- The datasource used for Firealarm database
-
- jdbc/FireAlarmDM_DB
-
-
-
- jdbc:h2:repository/database/FireAlarmDM_DB;DB_CLOSE_ON_EXIT=FALSE
- wso2carbon
- wso2carbon
- org.h2.Driver
- 50
- 60000
- true
- SELECT 1
- 30000
-
-
-
-
-
- ArduinoDM_DS
- The datasource used for Arduino database
-
- jdbc/ArduinoDM_DB
-
-
-
- jdbc:h2:repository/database/ArduinoDM_DB;DB_CLOSE_ON_EXIT=FALSE
- wso2carbon
- wso2carbon
- org.h2.Driver
- 50
- 60000
- true
- SELECT 1
- 30000
-
-
-
-
-
- AndroidSenseDM_DB
- The datasource used for Android database
-
- jdbc/AndroidSenseDM_DB
-
-
-
- jdbc:h2:repository/database/AndroidSenseDM_DB;DB_CLOSE_ON_EXIT=FALSE
- wso2carbon
- wso2carbon
- org.h2.Driver
- 50
- 60000
- true
- SELECT 1
- 30000
-
-
-
-
-
- SensebotDM_DS
- The datasource used for Sensebot database
-
- jdbc/SensebotDM_DB
-
-
-
- jdbc:h2:repository/database/SensebotDM_DB;DB_CLOSE_ON_EXIT=FALSE
- wso2carbon
- wso2carbon
- org.h2.Driver
- 50
- 60000
- true
- SELECT 1
- 30000
-
-
-
-
-
- DigitalDisplayDM_DS
- The datasource used for Digital Display database
-
- jdbc/DigitalDisplayDM_DB
-
-
-
- jdbc:h2:repository/database/DigitalDisplayDM_DB;DB_CLOSE_ON_EXIT=FALSE
- wso2carbon
- wso2carbon
- org.h2.Driver
- 50
- 60000
- true
- SELECT 1
- 30000
-
-
-
-
-
- RaspberrypiDM_DS
- The datasource used for Raspberrypi database
-
- jdbc/RaspberrypiDM_DB
-
-
-
- jdbc:h2:repository/database/RaspberrypiDM_DB;DB_CLOSE_ON_EXIT=FALSE
- wso2carbon
- wso2carbon
- org.h2.Driver
- 50
- 60000
- true
- SELECT 1
- 30000
-
-
-
-
JAGH2
The datasource used for by the Jaggery Storage Manager
diff --git a/modules/distribution/src/repository/conf/emm-config.xml b/modules/distribution/src/repository/conf/emm-config.xml
deleted file mode 100644
index 4350f3d2..00000000
--- a/modules/distribution/src/repository/conf/emm-config.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-
-
-
-
-
-
- 60000
-
-
-
- https://192.168.1.2:9443/emm/scep
- https://192.168.1.2:9443/emm/profile
- https://192.168.1.2:9443/emm/checkin
- https://192.168.1.2:9443/emm/server
-
-
- http://192.168.1.2:9763/emm/api/devices/iostokenregister
-
-
-
- ${carbon.home}/repository/resources/security/wso2emm.jks
-
- JKS
-
- wso2carbon
-
- cacert
-
- cacert
-
- racert
-
- racert
-
-
-
-
diff --git a/modules/distribution/src/repository/conf/identity.xml b/modules/distribution/src/repository/conf/identity.xml
index 737af4f6..929d6ea6 100755
--- a/modules/distribution/src/repository/conf/identity.xml
+++ b/modules/distribution/src/repository/conf/identity.xml
@@ -37,6 +37,13 @@
true
+
+ 120
+ 20160
+ 20160
+ 1140
+
+
@@ -68,10 +75,42 @@
+
+ https://localhost:9443/openidserver
+ https://localhost:9443/openid/
+
+ false
+
+ 7200
+
+ false
+
+ false
+
+ 36000
+
+ false
+ org.wso2.carbon.identity.provider.openid.claims.DefaultClaimsRetriever
+
+
- https://10.100.5.3:9443/oauth/request-token
+ -1
+ -1
+ -1
+ -1
+ https://localhost:9443/oauth/request-token
+ https://localhost:9443/oauth/access-token
+ https://localhost:9443/oauth/authorize-url
+
+
+
+
+
+
300
@@ -80,17 +119,21 @@
3600
3600
+
+ 84600
300
true
-
-
- org.wso2.carbon.identity.oauth.tokenprocessor.PlainTextPersistenceProcessor
-
+
+ true
+
+ org.wso2.carbon.identity.oauth.tokenprocessor.PlainTextPersistenceProcessor
+
- org.wso2.carbon.identity.oauth2.token.handlers.clientauth.BasicAuthClientAuthHandler
+
+ false
+
+
org.wso2.carbon.apimgt.keymgt.handlers.ExtendedPasswordGrantHandler
@@ -128,10 +173,17 @@
urn:ietf:params:oauth:grant-type:saml2-bearer
org.wso2.carbon.identity.oauth2.token.handlers.grant.saml.SAML2BearerGrantHandler
+
+ iwa:ntlm
+ org.wso2.carbon.identity.oauth2.token.handlers.grant.iwa.ntlm.NTLMAuthenticationGrantHandler
+
+
false
+ IDN_OAUTH2_ACCESS_TOKEN_A. -->
-
+
false
org.wso2.carbon.identity.oauth2.authcontext.JWTTokenGenerator
org.wso2.carbon.identity.oauth2.authcontext.DefaultClaimsRetriever
@@ -167,21 +219,23 @@
15
-
-
-
+
+
+
-
-
+
+ org.wso2.carbon.identity.openidconnect.DefaultIDTokenBuilder
+ https://localhost:9443/oauth2endpoints/token
+ http://wso2.org/claims/givenname
+ org.wso2.carbon.identity.openidconnect.SAMLAssertionClaimsCallback
+ 3600
+ http://wso2.org/claims
+ org.wso2.carbon.identity.oauth.endpoint.user.impl.UserInfoUserStoreClaimRetriever
+ org.wso2.carbon.identity.oauth.endpoint.user.impl.UserInforRequestDefaultValidator
+ org.wso2.carbon.identity.oauth.endpoint.user.impl.UserInfoISAccessTokenValidator
+ org.wso2.carbon.identity.oauth.endpoint.user.impl.UserInfoJSONResponseBuilder
+ false
+
@@ -198,6 +252,8 @@
+ 157680000
+ 157680000
localhost
https://localhost:9443/samlsso
5
@@ -209,6 +265,7 @@
http://wso2.org/claims
false
org.wso2.carbon.identity.sso.saml.builders.claims.DefaultClaimsRetriever
+ org.wso2.carbon.identity.sso.saml.builders.assertion.DefaultSAMLAssertionBuilder
org.wso2.carbon.identity.sso.saml.builders.encryption.DefaultSSOEncrypter
org.wso2.carbon.identity.sso.saml.builders.signature.DefaultSSOSigner
org.wso2.carbon.identity.sso.saml.validators.SAML2HTTPRedirectDeflateSignatureValidator
@@ -216,7 +273,7 @@
5
- false
+ false
@@ -240,9 +297,28 @@
${carbon.home}/repository/resources/security/wso2carbon.jks
wso2carbon
+
+ localhost
+
+
+ 5
+
+
+ 10
+ local://services
+
+
+
+
+
false
-
+
\ No newline at end of file
diff --git a/modules/distribution/src/repository/conf/identity/service-providers/sp_dashboard.xml b/modules/distribution/src/repository/conf/identity/service-providers/sp_dashboard.xml
new file mode 100644
index 00000000..c300d67c
--- /dev/null
+++ b/modules/distribution/src/repository/conf/identity/service-providers/sp_dashboard.xml
@@ -0,0 +1,49 @@
+
+ 2
+ wso2_sp_dashboard
+ Default Service Provider
+
+
+
+ wso2.my.dashboard
+ samlsso
+
+
+
+
+
+
+
+ 1
+
+
+ BasicAuthenticator
+ basicauth
+ true
+
+
+
+ true
+ true
+
+
+
+
+
+
+
+ true
+
+
+
diff --git a/modules/distribution/src/repository/conf/security/application-authentication.xml b/modules/distribution/src/repository/conf/security/application-authentication.xml
new file mode 100644
index 00000000..9f02a255
--- /dev/null
+++ b/modules/distribution/src/repository/conf/security/application-authentication.xml
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+
+
+
+ jdbc/WSO2CarbonDB
+
+
+
+
+ smart
+
+
+ /sso/login
+
+
+
+ org.wso2.carbon.identity.application.authentication.framework.handler.request.impl.DefaultRequestCoordinator
+ org.wso2.carbon.identity.application.authentication.framework.handler.request.impl.DefaultAuthenticationRequestHandler
+ org.wso2.carbon.identity.application.authentication.framework.handler.request.impl.DefaultLogoutRequestHandler
+ org.wso2.carbon.identity.application.authentication.framework.handler.sequence.impl.DefaultStepBasedSequenceHandler
+ org.wso2.carbon.identity.application.authentication.framework.handler.sequence.impl.DefaultRequestPathBasedSequenceHandler
+ org.wso2.carbon.identity.application.authentication.framework.handler.step.impl.DefaultStepHandler
+ org.wso2.carbon.identity.application.authentication.framework.handler.hrd.impl.DefaultHomeRealmDiscoverer
+ org.wso2.carbon.identity.application.authentication.framework.handler.claims.impl.DefaultClaimHandler
+ org.wso2.carbon.identity.application.authentication.framework.handler.provisioning.impl.DefaultProvisioningHandler
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ /authenticationendpoint/login.do
+ /repository/resources/security/client-truststore.jks
+ wso2carbon
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ org.wso2.carbon.identity.application.mgt.dao.impl.ApplicationDAOImpl
+ org.wso2.carbon.identity.application.mgt.dao.impl.OAuthApplicationDAOImpl
+ org.wso2.carbon.identity.application.mgt.dao.impl.SAMLApplicationDAOImpl
+ org.wso2.carbon.identity.application.mgt.dao.impl.IdentityProviderDAOImpl
+ http://wso2.org/claims
+
+
+
diff --git a/modules/distribution/src/repository/conf/security/application-authenticators.xml b/modules/distribution/src/repository/conf/security/application-authenticators.xml
new file mode 100644
index 00000000..c13c0401
--- /dev/null
+++ b/modules/distribution/src/repository/conf/security/application-authenticators.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/distribution/src/repository/conf/sso-idp-config.xml b/modules/distribution/src/repository/conf/sso-idp-config.xml
new file mode 100755
index 00000000..99f61be9
--- /dev/null
+++ b/modules/distribution/src/repository/conf/sso-idp-config.xml
@@ -0,0 +1,52 @@
+
+
+ https://stratos-local.wso2.com/carbon/tenant-register/select_domain.jsp
+
+
+ store
+ https://localhost:9443/store/acs
+ true
+ /store/login.jag
+
+
+ social
+ https://localhost:9443/social/acs
+ true
+ /social/login
+
+
+ publisher
+ https://localhost:9443/publisher/acs
+ true
+ /publisher/controllers/login.jag
+
+
+ emm
+ https://localhost:9443/emm/acs
+ true
+ /emm/login
+
+
+ mam
+ https://localhost:9443/mam/acs
+ true
+ /mam/login
+
+
+
diff --git a/modules/distribution/src/repository/conf/tomcat/context.xml b/modules/distribution/src/repository/conf/tomcat/context.xml
index 33db120f..96452af2 100644
--- a/modules/distribution/src/repository/conf/tomcat/context.xml
+++ b/modules/distribution/src/repository/conf/tomcat/context.xml
@@ -35,4 +35,16 @@
-->
+
+
diff --git a/modules/distribution/src/repository/database/WSO2IDENTITY_DB.h2.db b/modules/distribution/src/repository/database/WSO2IDENTITY_DB.h2.db
new file mode 100644
index 00000000..16a8b5c8
Binary files /dev/null and b/modules/distribution/src/repository/database/WSO2IDENTITY_DB.h2.db differ
diff --git a/modules/distribution/src/repository/dbscripts/cdm/h2.sql b/modules/distribution/src/repository/dbscripts/cdm/h2.sql
new file mode 100644
index 00000000..3ceea15a
--- /dev/null
+++ b/modules/distribution/src/repository/dbscripts/cdm/h2.sql
@@ -0,0 +1,26 @@
+CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE
+(
+ ID INT(11) auto_increment NOT NULL,
+ NAME VARCHAR(300) NULL DEFAULT NULL,
+ PRIMARY KEY (ID)
+);
+
+CREATE TABLE IF NOT EXISTS DM_DEVICE
+(
+ ID INT auto_increment NOT NULL,
+ DESCRIPTION TEXT NULL DEFAULT NULL,
+ NAME VARCHAR(100) NULL DEFAULT NULL,
+ DATE_OF_ENROLLMENT BIGINT NULL DEFAULT NULL,
+ DATE_OF_LAST_UPDATE BIGINT NULL DEFAULT NULL,
+ OWNERSHIP VARCHAR(45) NULL DEFAULT NULL,
+ STATUS VARCHAR(15) NULL DEFAULT NULL,
+ DEVICE_TYPE_ID INT(11) NULL DEFAULT NULL,
+ DEVICE_IDENTIFICATION VARCHAR(300) NULL DEFAULT NULL,
+ OWNER VARCHAR(45) NULL DEFAULT NULL,
+ TENANT_ID INTEGER DEFAULT 0,
+ PRIMARY KEY (ID),
+ CONSTRAINT fk_DM_DEVICE_DM_DEVICE_TYPE2 FOREIGN KEY (DEVICE_TYPE_ID )
+ REFERENCES DM_DEVICE_TYPE (ID ) ON DELETE NO ACTION ON UPDATE NO ACTION
+);
+-- TO:DO - Remove this INSERT sql statement.
+Insert into DM_DEVICE_TYPE (NAME) VALUES ('android');
diff --git a/modules/distribution/src/repository/dbscripts/cdm/mysql.sql b/modules/distribution/src/repository/dbscripts/cdm/mysql.sql
new file mode 100644
index 00000000..bc04de87
--- /dev/null
+++ b/modules/distribution/src/repository/dbscripts/cdm/mysql.sql
@@ -0,0 +1,35 @@
+-- -----------------------------------------------------
+-- Table `DM_DEVICE_TYPE`
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS `DM_DEVICE_TYPE` (
+ `ID` INT(11) NOT NULL ,
+ `NAME` VARCHAR(300) NULL DEFAULT NULL ,
+ PRIMARY KEY (`ID`) )
+ENGINE = InnoDB
+DEFAULT CHARACTER SET = latin1;
+
+
+-- -----------------------------------------------------
+-- Table `DM_DEVICE`
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS `DM_DEVICE` (
+ `ID` VARCHAR(20) NOT NULL ,
+ `DESCRIPTION` TEXT NULL DEFAULT NULL ,
+ `NAME` VARCHAR(100) NULL DEFAULT NULL ,
+ `DATE_OF_ENROLLMENT` DATETIME NULL DEFAULT NULL ,
+ `DATE_OF_LAST_UPDATE` DATETIME NULL DEFAULT NULL ,
+ `OWNERSHIP` VARCHAR(45) NULL DEFAULT NULL ,
+ `STATUS` VARCHAR(15) NULL DEFAULT NULL ,
+ `DEVICE_TYPE_ID` INT(11) NULL DEFAULT NULL ,
+ `DEVICE_IDENTIFICATION` VARCHAR(300) NULL DEFAULT NULL ,
+ `OWNER` VARCHAR(45) NULL DEFAULT NULL ,
+ TENANT_ID INTEGER DEFAULT 0,
+ PRIMARY KEY (`ID`) ,
+ INDEX `fk_DM_DEVICE_DM_DEVICE_TYPE2_idx` (`DEVICE_TYPE_ID` ASC) ,
+ CONSTRAINT `fk_DM_DEVICE_DM_DEVICE_TYPE2`
+ FOREIGN KEY (`DEVICE_TYPE_ID` )
+ REFERENCES `DM_DEVICE_TYPE` (`ID` )
+ ON DELETE NO ACTION
+ ON UPDATE NO ACTION)
+ENGINE = InnoDB
+DEFAULT CHARACTER SET = latin1;
diff --git a/modules/distribution/src/repository/dbscripts/cdm/plugins/h2.sql b/modules/distribution/src/repository/dbscripts/cdm/plugins/h2.sql
new file mode 100644
index 00000000..39610edd
--- /dev/null
+++ b/modules/distribution/src/repository/dbscripts/cdm/plugins/h2.sql
@@ -0,0 +1,82 @@
+
+-- -----------------------------------------------------
+-- Table `MBL_DEVICE`
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS `MBL_DEVICE` (
+ `MOBILE_DEVICE_ID` VARCHAR(45) NOT NULL ,
+ `REG_ID` VARCHAR(45) NULL DEFAULT NULL ,
+ `IMEI` VARCHAR(45) NULL DEFAULT NULL ,
+ `IMSI` VARCHAR(45) NULL DEFAULT NULL ,
+ `OS_VERSION` VARCHAR(45) NULL DEFAULT NULL ,
+ `DEVICE_MODEL` VARCHAR(45) NULL DEFAULT NULL ,
+ `VENDOR` VARCHAR(45) NULL DEFAULT NULL ,
+ `LATITUDE` VARCHAR(45) NULL DEFAULT NULL,
+ `LONGITUDE` VARCHAR(45) NULL DEFAULT NULL,
+ PRIMARY KEY (`MOBILE_DEVICE_ID`) );
+
+
+-- -----------------------------------------------------
+-- Table `MBL_FEATURE`
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS `MBL_FEATURE` (
+ `FEATURE_ID` INT NOT NULL AUTO_INCREMENT ,
+ `CODE` VARCHAR(45) NOT NULL ,
+ `NAME` VARCHAR(100) NULL ,
+ `DESCRIPTION` VARCHAR(200) NULL ,
+ PRIMARY KEY (`FEATURE_ID`) );
+
+-- -----------------------------------------------------
+-- Table `MBL_OPERATION`
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS `MBL_OPERATION` (
+ `OPERATION_ID` INT NOT NULL AUTO_INCREMENT ,
+ `FEATURE_CODE` VARCHAR(45) NOT NULL ,
+ `CREATED_DATE` BIGINT NULL ,
+ PRIMARY KEY (`OPERATION_ID`));
+
+-- -----------------------------------------------------
+-- Table `MBL_DEVICE_OPERATION_MAPPING`
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS `MBL_DEVICE_OPERATION_MAPPING` (
+ `DEVICE_ID` VARCHAR(45) NOT NULL ,
+ `OPERATION_ID` INT NOT NULL ,
+ `SENT_DATE` BIGINT NULL ,
+ `RECEIVED_DATE` BIGINT NULL ,
+ PRIMARY KEY (`DEVICE_ID`, `OPERATION_ID`) ,
+ CONSTRAINT `fk_MBL_DEVICE_OPERATION_MBL_DEVICE`
+ FOREIGN KEY (`DEVICE_ID` )
+ REFERENCES `MBL_DEVICE` (`MOBILE_DEVICE_ID` )
+ ON DELETE NO ACTION
+ ON UPDATE NO ACTION,
+ CONSTRAINT `fk_MBL_DEVICE_OPERATION_MBL_OPERATION1`
+ FOREIGN KEY (`OPERATION_ID` )
+ REFERENCES `MBL_OPERATION` (`OPERATION_ID` )
+ ON DELETE NO ACTION
+ ON UPDATE NO ACTION);
+
+-- -----------------------------------------------------
+-- Table `MBL_OPERATION_PROPERTY`
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS `MBL_OPERATION_PROPERTY` (
+ `OPERATION_ID` INT NOT NULL ,
+ `PROPERTY` VARCHAR(45) NOT NULL ,
+ `VALUE` TEXT NULL ,
+ PRIMARY KEY (`OPERATION_ID`, `PROPERTY`) ,
+ CONSTRAINT `fk_MBL_OPERATION_PROPERTY_MBL_OPERATION1`
+ FOREIGN KEY (`OPERATION_ID` )
+ REFERENCES `MBL_OPERATION` (`OPERATION_ID` )
+ ON DELETE NO ACTION
+ ON UPDATE NO ACTION);
+
+-- -----------------------------------------------------
+-- Table `MBL_FEATURE_PROPERTY`
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS `MBL_FEATURE_PROPERTY` (
+ `PROPERTY` VARCHAR(45) NOT NULL ,
+ `FEATURE_ID` VARCHAR(45) NOT NULL ,
+ PRIMARY KEY (`PROPERTY`) ,
+ CONSTRAINT `fk_MBL_FEATURE_PROPERTY_MBL_FEATURE1`
+ FOREIGN KEY (`FEATURE_ID` )
+ REFERENCES `MBL_FEATURE` (`FEATURE_ID` )
+ ON DELETE NO ACTION
+ ON UPDATE NO ACTION);
diff --git a/modules/distribution/src/repository/dbscripts/cdm/plugins/mysql.sql b/modules/distribution/src/repository/dbscripts/cdm/plugins/mysql.sql
new file mode 100644
index 00000000..10adee8d
--- /dev/null
+++ b/modules/distribution/src/repository/dbscripts/cdm/plugins/mysql.sql
@@ -0,0 +1,99 @@
+-- -----------------------------------------------------
+-- Table `MBL_DEVICE`
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS `MBL_DEVICE` (
+ `MOBILE_DEVICE_ID` VARCHAR(45) NOT NULL,
+ `REG_ID` VARCHAR(45) NULL DEFAULT NULL,
+ `IMEI` VARCHAR(45) NULL DEFAULT NULL,
+ `IMSI` VARCHAR(45) NULL DEFAULT NULL,
+ `OS_VERSION` VARCHAR(45) NULL DEFAULT NULL,
+ `DEVICE_MODEL` VARCHAR(45) NULL DEFAULT NULL,
+ `VENDOR` VARCHAR(45) NULL DEFAULT NULL,
+ `LATITUDE` VARCHAR(45) NULL DEFAULT NULL,
+ `LONGITUDE` VARCHAR(45) NULL DEFAULT NULL,
+ PRIMARY KEY (`MOBILE_DEVICE_ID`))
+ENGINE = InnoDB;
+
+
+-- -----------------------------------------------------
+-- Table `MBL_FEATURE`
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS `MBL_FEATURE` (
+ `FEATURE_ID` INT NOT NULL AUTO_INCREMENT,
+ `CODE` VARCHAR(45) NULL,
+ `NAME` VARCHAR(100) NULL,
+ `DESCRIPTION` VARCHAR(200) NULL,
+ PRIMARY KEY (`FEATURE_ID`))
+ENGINE = InnoDB;
+
+
+-- -----------------------------------------------------
+-- Table `MBL_OPERATION`
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS `MBL_OPERATION` (
+ `OPERATION_ID` INT NOT NULL AUTO_INCREMENT,
+ `FEATURE_CODE` VARCHAR(45) NULL,
+ `CREATED_DATE` INT NULL,
+ PRIMARY KEY (`OPERATION_ID`))
+ENGINE = InnoDB;
+
+
+-- -----------------------------------------------------
+-- Table `MBL_DEVICE_OPERATION_MAPING`
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS `MBL_DEVICE_OPERATION_MAPPING` (
+ `DEVICE_ID` VARCHAR(45) NOT NULL,
+ `OPERATION_ID` INT NOT NULL,
+ `SENT_DATE` INT NULL,
+ `RECEIVED_DATE` INT NULL,
+ PRIMARY KEY (`DEVICE_ID`, `OPERATION_ID`),
+ INDEX `fk_MBL_DEVICE_OPERATION_MBL_OPERATION1_idx` (`OPERATION_ID` ASC),
+ CONSTRAINT `fk_MBL_DEVICE_OPERATION_MBL_DEVICE`
+ FOREIGN KEY (`DEVICE_ID`)
+ REFERENCES `MBL_DEVICE` (`MOBILE_DEVICE_ID`)
+ ON DELETE NO ACTION
+ ON UPDATE NO ACTION,
+ CONSTRAINT `fk_MBL_DEVICE_OPERATION_MBL_OPERATION1`
+ FOREIGN KEY (`OPERATION_ID`)
+ REFERENCES `MBL_OPERATION` (`OPERATION_ID`)
+ ON DELETE NO ACTION
+ ON UPDATE NO ACTION)
+ENGINE = InnoDB;
+
+
+-- -----------------------------------------------------
+-- Table `MBL_OPERATION_PROPERTY`
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS `MBL_OPERATION_PROPERTY` (
+ `OPERATION_PROPERTY_ID` INT NOT NULL AUTO_INCREMENT,
+ `OPERATION_ID` INT NULL,
+ `PROPERTY_ID` INT NULL,
+ `VALUE` TEXT NULL,
+ PRIMARY KEY (`OPERATION_PROPERTY_ID`),
+ INDEX `fk_MBL_OPERATION_PROPERTY_MBL_OPERATION1_idx` (`OPERATION_ID` ASC),
+ CONSTRAINT `fk_MBL_OPERATION_PROPERTY_MBL_OPERATION1`
+ FOREIGN KEY (`OPERATION_ID`)
+ REFERENCES `MBL_OPERATION` (`OPERATION_ID`)
+ ON DELETE NO ACTION
+ ON UPDATE NO ACTION)
+ENGINE = InnoDB;
+
+
+-- -----------------------------------------------------
+-- Table `MBL_FEATURE_PROPERTY`
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS `MBL_FEATURE_PROPERTY` (
+ `PROPERTY_ID` INT NOT NULL AUTO_INCREMENT,
+ `PROPERTY` VARCHAR(100) NULL,
+ `FEATURE_ID` VARCHAR(45) NULL,
+ PRIMARY KEY (`PROPERTY_ID`),
+ INDEX `fk_MBL_FEATURE_PROPERTY_MBL_FEATURE1_idx` (`FEATURE_ID` ASC),
+ CONSTRAINT `fk_MBL_FEATURE_PROPERTY_MBL_FEATURE1`
+ FOREIGN KEY (`FEATURE_ID`)
+ REFERENCES `MBL_FEATURE` (`FEATURE_ID`)
+ ON DELETE NO ACTION
+ ON UPDATE NO ACTION)
+ENGINE = InnoDB;
+
+
+
diff --git a/modules/distribution/src/repository/resources/build.xml b/modules/distribution/src/repository/resources/build.xml
new file mode 100644
index 00000000..d231184c
--- /dev/null
+++ b/modules/distribution/src/repository/resources/build.xml
@@ -0,0 +1,50 @@
+
+
+
+
+
+ ant publish
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/modules/distribution/src/repository/resources/dashboard/dashboard.xml b/modules/distribution/src/repository/resources/dashboard/dashboard.xml
new file mode 100644
index 00000000..1c3df925
--- /dev/null
+++ b/modules/distribution/src/repository/resources/dashboard/dashboard.xml
@@ -0,0 +1,162 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ /registry/resource/_system/config/repository/dashboards/gadgets/impact-analysis.xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ /carbon/impactAnalysis/impact.xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ /registry/resource/_system/config/repository/dashboards/gadgets/life-cycle-info.xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 200
+
+
+
+
+
+
+
+ 200
+ 0,3
+
+
+
+
+
+
+ Impact Data
+
+
+
+
+
+
+ {"layout":[{"id":"","width":"50%","layout":[{"id":"10","type":"gadget"}],"type":"columnContainer"},{"id":"","width":"50%","layout":[{"id":"20","type":"gadget"}],"type":"columnContainer"}]}
+
+
+
+
+
+
+
+
+
+ Lifecycle Data
+
+
+
+
+
+
+ G1#30
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/modules/distribution/src/repository/resources/dashboard/gadgets/css/gadgets.css b/modules/distribution/src/repository/resources/dashboard/gadgets/css/gadgets.css
new file mode 100644
index 00000000..157e15c5
--- /dev/null
+++ b/modules/distribution/src/repository/resources/dashboard/gadgets/css/gadgets.css
@@ -0,0 +1,63 @@
+body {
+ background-color: white;
+ padding: 0px;
+ margin: 0px;
+ font-family: "Lucida Grande","Lucida Sans","Microsoft Sans Serif", "Lucida Sans Unicode","Verdana","Sans-serif","trebuchet ms" !important;
+ color: #111;
+ font-size:12px;
+ font-size-adjust:none;
+ font-stretch:normal;
+ font-style:normal;
+ font-variant:normal;
+ font-weight:normal;
+ line-height:1.25em;
+}
+.main-table {
+ border: 0px;
+ padding: 0px;
+ margin-top: 5px;
+ margin-bottom: 0px;
+ margin-left: 0px;
+ margin-right: 0px;
+}
+.main-table thead tr th{
+ padding: 0px;
+ text-align: left;
+ vertical-align: top;
+ border: 0px;
+}
+.main-table tbody tr td {
+ padding: 0px;
+ text-align: left;
+ vertical-align: top;
+ border: 0px;
+}
+.main-table tr td {
+ padding: 0px;
+ text-align: left;
+ vertical-align: top;
+ border: 0px;
+}
+.tablib_selected {
+ color: #2F7ABD;
+ font-weight: normal;
+}
+.pleaseText {
+ margin-top: 5px;
+ text-align: center;
+}
+.titleText {
+ margin-top: 5px;
+ text-align: center;
+}
+select {
+ font-size: 10px;
+ margin-bottom: 2px;
+}
+input {
+ font-size: 10px;
+ margin-bottom: 2px;
+}
+span.userNameText {
+ font-size: 11px;
+}
\ No newline at end of file
diff --git a/modules/distribution/src/repository/resources/dashboard/gadgets/css/help.css b/modules/distribution/src/repository/resources/dashboard/gadgets/css/help.css
new file mode 100644
index 00000000..737de365
--- /dev/null
+++ b/modules/distribution/src/repository/resources/dashboard/gadgets/css/help.css
@@ -0,0 +1,58 @@
+div#help-wrapper {
+background-color:white;
+color:#111111;
+font-family:"Lucida Grande","Lucida Sans","Microsoft Sans Serif","Lucida Sans Unicode","Verdana","Sans-serif","trebuchet ms";
+font-size:12px;
+font-size-adjust:none;
+font-stretch:normal;
+font-style:normal;
+font-variant:normal;
+font-weight:normal;
+line-height:1.25em;
+margin:0;
+padding:0;
+}
+div#help-wrapper p {
+margin-left:0;
+margin-right:0;
+}
+td {
+}
+a:link {
+}
+a:visited {
+}
+a:hover {
+}
+a:active {
+}
+div#help-wrapper h1 {
+color:#F47B20;
+font-size:16px;
+font-weight:bold;
+}
+
+div#help-wrapper h2 {
+color:#111111;
+font-size:14px;
+font-weight:bold;
+}
+a img {
+border:0 none;
+}
+table.styled {
+border:0 solid #CCCCCC;
+border-collapse:collapse;
+}
+table.styled tr td {
+border:1px solid #CCCCCC;
+padding:3px;
+}
+table.styled tr td.subHeader {
+border:0 solid #CCCCCC;
+font-size:125%;
+font-weight:bold;
+padding-bottom:5px;
+padding-top:10px;
+}
+
diff --git a/modules/distribution/src/repository/resources/dashboard/gadgets/encoder-decoder.js b/modules/distribution/src/repository/resources/dashboard/gadgets/encoder-decoder.js
new file mode 100644
index 00000000..412717a7
--- /dev/null
+++ b/modules/distribution/src/repository/resources/dashboard/gadgets/encoder-decoder.js
@@ -0,0 +1,184 @@
+function urlDecode(str) {
+ str = str.replace(new RegExp('\\+', 'g'), ' ');
+ return unescape(str);
+}
+function urlEncode(str) {
+ str = escape(str);
+ str = str.replace(new RegExp('\\+', 'g'), '%2B');
+ return str.replace(new RegExp('%20', 'g'), '+');
+}
+
+var END_OF_INPUT = -1;
+
+var base64Chars = new Array(
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
+ 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
+ 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
+ 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
+ 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
+ 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
+ 'w', 'x', 'y', 'z', '0', '1', '2', '3',
+ '4', '5', '6', '7', '8', '9', '+', '/'
+ );
+
+var reverseBase64Chars = new Array();
+for (var i = 0; i < base64Chars.length; i++) {
+ reverseBase64Chars[base64Chars[i]] = i;
+}
+
+var base64Str;
+var base64Count;
+function setBase64Str(str) {
+ base64Str = str;
+ base64Count = 0;
+}
+function readBase64() {
+ if (!base64Str) return END_OF_INPUT;
+ if (base64Count >= base64Str.length) return END_OF_INPUT;
+ var c = base64Str.charCodeAt(base64Count) & 0xff;
+ base64Count++;
+ return c;
+}
+function encodeBase64(str) {
+ setBase64Str(str);
+ var result = '';
+ var inBuffer = new Array(3);
+ var lineCount = 0;
+ var done = false;
+ while (!done && (inBuffer[0] = readBase64()) != END_OF_INPUT) {
+ inBuffer[1] = readBase64();
+ inBuffer[2] = readBase64();
+ result += (base64Chars[ inBuffer[0] >> 2 ]);
+ if (inBuffer[1] != END_OF_INPUT) {
+ result += (base64Chars [(( inBuffer[0] << 4 ) & 0x30) | (inBuffer[1] >> 4) ]);
+ if (inBuffer[2] != END_OF_INPUT) {
+ result += (base64Chars [((inBuffer[1] << 2) & 0x3c) | (inBuffer[2] >> 6) ]);
+ result += (base64Chars [inBuffer[2] & 0x3F]);
+ } else {
+ result += (base64Chars [((inBuffer[1] << 2) & 0x3c)]);
+ result += ('=');
+ done = true;
+ }
+ } else {
+ result += (base64Chars [(( inBuffer[0] << 4 ) & 0x30)]);
+ result += ('=');
+ result += ('=');
+ done = true;
+ }
+ lineCount += 4;
+ if (lineCount >= 76) {
+ result += ('\n');
+ lineCount = 0;
+ }
+ }
+ return result;
+}
+function readReverseBase64() {
+ if (!base64Str) return END_OF_INPUT;
+ while (true) {
+ if (base64Count >= base64Str.length) return END_OF_INPUT;
+ var nextCharacter = base64Str.charAt(base64Count);
+ base64Count++;
+ if (reverseBase64Chars[nextCharacter]) {
+ return reverseBase64Chars[nextCharacter];
+ }
+ if (nextCharacter == 'A') return 0;
+ }
+ return END_OF_INPUT;
+}
+
+function ntos(n) {
+ n = n.toString(16);
+ if (n.length == 1) n = "0" + n;
+ n = "%" + n;
+ return unescape(n);
+}
+
+function decodeBase64(str) {
+ setBase64Str(str);
+ var result = "";
+ var inBuffer = new Array(4);
+ var done = false;
+ while (!done && (inBuffer[0] = readReverseBase64()) != END_OF_INPUT
+ && (inBuffer[1] = readReverseBase64()) != END_OF_INPUT) {
+ inBuffer[2] = readReverseBase64();
+ inBuffer[3] = readReverseBase64();
+ result += ntos((((inBuffer[0] << 2) & 0xff) | inBuffer[1] >> 4));
+ if (inBuffer[2] != END_OF_INPUT) {
+ result += ntos((((inBuffer[1] << 4) & 0xff) | inBuffer[2] >> 2));
+ if (inBuffer[3] != END_OF_INPUT) {
+ result += ntos((((inBuffer[2] << 6) & 0xff) | inBuffer[3]));
+ } else {
+ done = true;
+ }
+ } else {
+ done = true;
+ }
+ }
+ return result;
+}
+
+var digitArray = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f');
+function toHex(n) {
+ var result = ''
+ var start = true;
+ for (var i = 32; i > 0;) {
+ i -= 4;
+ var digit = (n >> i) & 0xf;
+ if (!start || digit != 0) {
+ start = false;
+ result += digitArray[digit];
+ }
+ }
+ return (result == '' ? '0' : result);
+}
+
+function pad(str, len, pad) {
+ var result = str;
+ for (var i = str.length; i < len; i++) {
+ result = pad + result;
+ }
+ return result;
+}
+
+function encodeHex(str) {
+ var result = "";
+ for (var i = 0; i < str.length; i++) {
+ result += pad(toHex(str.charCodeAt(i) & 0xff), 2, '0');
+ }
+ return result;
+}
+
+var hexv = {
+ "00":0,"01":1,"02":2,"03":3,"04":4,"05":5,"06":6,"07":7,"08":8,"09":9,"0A":10,"0B":11,"0C":12,"0D":13,"0E":14,"0F":15,
+ "10":16,"11":17,"12":18,"13":19,"14":20,"15":21,"16":22,"17":23,"18":24,"19":25,"1A":26,"1B":27,"1C":28,"1D":29,"1E":30,"1F":31,
+ "20":32,"21":33,"22":34,"23":35,"24":36,"25":37,"26":38,"27":39,"28":40,"29":41,"2A":42,"2B":43,"2C":44,"2D":45,"2E":46,"2F":47,
+ "30":48,"31":49,"32":50,"33":51,"34":52,"35":53,"36":54,"37":55,"38":56,"39":57,"3A":58,"3B":59,"3C":60,"3D":61,"3E":62,"3F":63,
+ "40":64,"41":65,"42":66,"43":67,"44":68,"45":69,"46":70,"47":71,"48":72,"49":73,"4A":74,"4B":75,"4C":76,"4D":77,"4E":78,"4F":79,
+ "50":80,"51":81,"52":82,"53":83,"54":84,"55":85,"56":86,"57":87,"58":88,"59":89,"5A":90,"5B":91,"5C":92,"5D":93,"5E":94,"5F":95,
+ "60":96,"61":97,"62":98,"63":99,"64":100,"65":101,"66":102,"67":103,"68":104,"69":105,"6A":106,"6B":107,"6C":108,"6D":109,"6E":110,"6F":111,
+ "70":112,"71":113,"72":114,"73":115,"74":116,"75":117,"76":118,"77":119,"78":120,"79":121,"7A":122,"7B":123,"7C":124,"7D":125,"7E":126,"7F":127,
+ "80":128,"81":129,"82":130,"83":131,"84":132,"85":133,"86":134,"87":135,"88":136,"89":137,"8A":138,"8B":139,"8C":140,"8D":141,"8E":142,"8F":143,
+ "90":144,"91":145,"92":146,"93":147,"94":148,"95":149,"96":150,"97":151,"98":152,"99":153,"9A":154,"9B":155,"9C":156,"9D":157,"9E":158,"9F":159,
+ "A0":160,"A1":161,"A2":162,"A3":163,"A4":164,"A5":165,"A6":166,"A7":167,"A8":168,"A9":169,"AA":170,"AB":171,"AC":172,"AD":173,"AE":174,"AF":175,
+ "B0":176,"B1":177,"B2":178,"B3":179,"B4":180,"B5":181,"B6":182,"B7":183,"B8":184,"B9":185,"BA":186,"BB":187,"BC":188,"BD":189,"BE":190,"BF":191,
+ "C0":192,"C1":193,"C2":194,"C3":195,"C4":196,"C5":197,"C6":198,"C7":199,"C8":200,"C9":201,"CA":202,"CB":203,"CC":204,"CD":205,"CE":206,"CF":207,
+ "D0":208,"D1":209,"D2":210,"D3":211,"D4":212,"D5":213,"D6":214,"D7":215,"D8":216,"D9":217,"DA":218,"DB":219,"DC":220,"DD":221,"DE":222,"DF":223,
+ "E0":224,"E1":225,"E2":226,"E3":227,"E4":228,"E5":229,"E6":230,"E7":231,"E8":232,"E9":233,"EA":234,"EB":235,"EC":236,"ED":237,"EE":238,"EF":239,
+ "F0":240,"F1":241,"F2":242,"F3":243,"F4":244,"F5":245,"F6":246,"F7":247,"F8":248,"F9":249,"FA":250,"FB":251,"FC":252,"FD":253,"FE":254,"FF":255
+};
+
+function decodeHex(str) {
+ str = str.toUpperCase().replace(new RegExp("s/[^0-9A-Z]//g"));
+ var result = "";
+ var nextchar = "";
+ for (var i = 0; i < str.length; i++) {
+ nextchar += str.charAt(i);
+ if (nextchar.length == 2) {
+ result += ntos(hexv[nextchar]);
+ nextchar = "";
+ }
+ }
+ return result;
+
+}
diff --git a/modules/distribution/src/repository/resources/dashboard/gadgets/flash/digital.swf b/modules/distribution/src/repository/resources/dashboard/gadgets/flash/digital.swf
new file mode 100644
index 00000000..edb3af93
Binary files /dev/null and b/modules/distribution/src/repository/resources/dashboard/gadgets/flash/digital.swf differ
diff --git a/modules/distribution/src/repository/resources/dashboard/gadgets/flash/funnelgraph.swf b/modules/distribution/src/repository/resources/dashboard/gadgets/flash/funnelgraph.swf
new file mode 100644
index 00000000..afd5a6e8
Binary files /dev/null and b/modules/distribution/src/repository/resources/dashboard/gadgets/flash/funnelgraph.swf differ
diff --git a/modules/distribution/src/repository/resources/dashboard/gadgets/flash/hclustergraph.swf b/modules/distribution/src/repository/resources/dashboard/gadgets/flash/hclustergraph.swf
new file mode 100644
index 00000000..c72f2626
Binary files /dev/null and b/modules/distribution/src/repository/resources/dashboard/gadgets/flash/hclustergraph.swf differ
diff --git a/modules/distribution/src/repository/resources/dashboard/gadgets/flash/lineargraph.swf b/modules/distribution/src/repository/resources/dashboard/gadgets/flash/lineargraph.swf
new file mode 100644
index 00000000..1cf1156e
Binary files /dev/null and b/modules/distribution/src/repository/resources/dashboard/gadgets/flash/lineargraph.swf differ
diff --git a/modules/distribution/src/repository/resources/dashboard/gadgets/flash/meter.swf b/modules/distribution/src/repository/resources/dashboard/gadgets/flash/meter.swf
new file mode 100644
index 00000000..79fbf80a
Binary files /dev/null and b/modules/distribution/src/repository/resources/dashboard/gadgets/flash/meter.swf differ
diff --git a/modules/distribution/src/repository/resources/dashboard/gadgets/flash/open-flash-chart.swf b/modules/distribution/src/repository/resources/dashboard/gadgets/flash/open-flash-chart.swf
new file mode 100644
index 00000000..bcadfa1b
Binary files /dev/null and b/modules/distribution/src/repository/resources/dashboard/gadgets/flash/open-flash-chart.swf differ
diff --git a/modules/distribution/src/repository/resources/dashboard/gadgets/flash/wedgegraph.swf b/modules/distribution/src/repository/resources/dashboard/gadgets/flash/wedgegraph.swf
new file mode 100644
index 00000000..0420938d
Binary files /dev/null and b/modules/distribution/src/repository/resources/dashboard/gadgets/flash/wedgegraph.swf differ
diff --git a/modules/distribution/src/repository/resources/dashboard/gadgets/images/bar.jpg b/modules/distribution/src/repository/resources/dashboard/gadgets/images/bar.jpg
new file mode 100644
index 00000000..6dfe9e64
Binary files /dev/null and b/modules/distribution/src/repository/resources/dashboard/gadgets/images/bar.jpg differ
diff --git a/modules/distribution/src/repository/resources/dashboard/gadgets/images/digital.jpg b/modules/distribution/src/repository/resources/dashboard/gadgets/images/digital.jpg
new file mode 100644
index 00000000..6e290498
Binary files /dev/null and b/modules/distribution/src/repository/resources/dashboard/gadgets/images/digital.jpg differ
diff --git a/modules/distribution/src/repository/resources/dashboard/gadgets/images/down-icon.gif b/modules/distribution/src/repository/resources/dashboard/gadgets/images/down-icon.gif
new file mode 100644
index 00000000..297dcd18
Binary files /dev/null and b/modules/distribution/src/repository/resources/dashboard/gadgets/images/down-icon.gif differ
diff --git a/modules/distribution/src/repository/resources/dashboard/gadgets/images/gauge.jpg b/modules/distribution/src/repository/resources/dashboard/gadgets/images/gauge.jpg
new file mode 100644
index 00000000..708f689e
Binary files /dev/null and b/modules/distribution/src/repository/resources/dashboard/gadgets/images/gauge.jpg differ
diff --git a/modules/distribution/src/repository/resources/dashboard/gadgets/images/iogauge.jpg b/modules/distribution/src/repository/resources/dashboard/gadgets/images/iogauge.jpg
new file mode 100644
index 00000000..be2809f6
Binary files /dev/null and b/modules/distribution/src/repository/resources/dashboard/gadgets/images/iogauge.jpg differ
diff --git a/modules/distribution/src/repository/resources/dashboard/gadgets/images/meter.jpg b/modules/distribution/src/repository/resources/dashboard/gadgets/images/meter.jpg
new file mode 100644
index 00000000..0f5520db
Binary files /dev/null and b/modules/distribution/src/repository/resources/dashboard/gadgets/images/meter.jpg differ
diff --git a/modules/distribution/src/repository/resources/dashboard/gadgets/images/rmeter.jpg b/modules/distribution/src/repository/resources/dashboard/gadgets/images/rmeter.jpg
new file mode 100644
index 00000000..3d8a29ce
Binary files /dev/null and b/modules/distribution/src/repository/resources/dashboard/gadgets/images/rmeter.jpg differ
diff --git a/modules/distribution/src/repository/resources/dashboard/gadgets/images/temp.jpg b/modules/distribution/src/repository/resources/dashboard/gadgets/images/temp.jpg
new file mode 100644
index 00000000..c65157fa
Binary files /dev/null and b/modules/distribution/src/repository/resources/dashboard/gadgets/images/temp.jpg differ
diff --git a/modules/distribution/src/repository/resources/dashboard/gadgets/impact-analysis.xml b/modules/distribution/src/repository/resources/dashboard/gadgets/impact-analysis.xml
new file mode 100644
index 00000000..39c519d8
--- /dev/null
+++ b/modules/distribution/src/repository/resources/dashboard/gadgets/impact-analysis.xml
@@ -0,0 +1,223 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+]]>
+
+
+
+
+
+
+
+
+
+ Available Services :
+
+
+
+
+
+
+]]>
+
+
+
+
+
diff --git a/modules/distribution/src/repository/resources/dashboard/gadgets/js/count-graph.js b/modules/distribution/src/repository/resources/dashboard/gadgets/js/count-graph.js
new file mode 100644
index 00000000..4d30f3bb
--- /dev/null
+++ b/modules/distribution/src/repository/resources/dashboard/gadgets/js/count-graph.js
@@ -0,0 +1,23 @@
+
+var countGraph;
+
+function isNumeric(sText){
+ var validChars = "0123456789.";
+ var isNumber = true;
+ var character;
+ for (var i = 0; i < sText.length && isNumber == true; i++) {
+ character = sText.charAt(i);
+ if (validChars.indexOf(character) == -1) {
+ isNumber = false;
+ }
+ }
+ return isNumber;
+}
+
+function initCountGraph(memoryXScale) {
+ if (memoryXScale < 1 || !isNumeric(memoryXScale)) {
+ return;
+ }
+ countGraph = new carbonGraph(memoryXScale);
+}
+
diff --git a/modules/distribution/src/repository/resources/dashboard/gadgets/js/endpoint-count.js b/modules/distribution/src/repository/resources/dashboard/gadgets/js/endpoint-count.js
new file mode 100644
index 00000000..dd7e3d64
--- /dev/null
+++ b/modules/distribution/src/repository/resources/dashboard/gadgets/js/endpoint-count.js
@@ -0,0 +1,31 @@
+// Memory
+var endpointInvocationGraph;
+
+function initStats(memoryXScale) {
+ if (memoryXScale != null) {
+ initReqCountGraphs(memoryXScale);
+ } else {
+ initReqCountGraphs(30);
+ }
+}
+
+function isNumeric(sText){
+ var validChars = "0123456789.";
+ var isNumber = true;
+ var character;
+ for (var i = 0; i < sText.length && isNumber == true; i++) {
+ character = sText.charAt(i);
+ if (validChars.indexOf(character) == -1) {
+ isNumber = false;
+ }
+ }
+ return isNumber;
+}
+
+function initReqCountGraphs(memoryXScale) {
+ if (memoryXScale < 1 || !isNumeric(memoryXScale)) {
+ return;
+ }
+ endpointInvocationGraph = new carbonGraph(memoryXScale);
+}
+
diff --git a/modules/distribution/src/repository/resources/dashboard/gadgets/js/excanvas.js b/modules/distribution/src/repository/resources/dashboard/gadgets/js/excanvas.js
new file mode 100644
index 00000000..7914cb93
--- /dev/null
+++ b/modules/distribution/src/repository/resources/dashboard/gadgets/js/excanvas.js
@@ -0,0 +1,785 @@
+// Copyright 2006 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+
+// Known Issues:
+//
+// * Patterns are not implemented.
+// * Radial gradient are not implemented. The VML version of these look very
+// different from the canvas one.
+// * Clipping paths are not implemented.
+// * Coordsize. The width and height attribute have higher priority than the
+// width and height style values which isn't correct.
+// * Painting mode isn't implemented.
+// * Canvas width/height should is using content-box by default. IE in
+// Quirks mode will draw the canvas using border-box. Either change your
+// doctype to HTML5
+// (http://www.whatwg.org/specs/web-apps/current-work/#the-doctype)
+// or use Box Sizing Behavior from WebFX
+// (http://webfx.eae.net/dhtml/boxsizing/boxsizing.html)
+// * Optimize. There is always room for speed improvements.
+
+// only add this code if we do not already have a canvas implementation
+if (!window.CanvasRenderingContext2D) {
+
+(function () {
+
+ // alias some functions to make (compiled) code shorter
+ var m = Math;
+ var mr = m.round;
+ var ms = m.sin;
+ var mc = m.cos;
+
+ // this is used for sub pixel precision
+ var Z = 10;
+ var Z2 = Z / 2;
+
+ var G_vmlCanvasManager_ = {
+ init: function (opt_doc) {
+ var doc = opt_doc || document;
+ if (/MSIE/.test(navigator.userAgent) && !window.opera) {
+ var self = this;
+ doc.attachEvent("onreadystatechange", function () {
+ self.init_(doc);
+ });
+ }
+ },
+
+ init_: function (doc) {
+ if (doc.readyState == "complete") {
+ // create xmlns
+ if (!doc.namespaces["g_vml_"]) {
+ doc.namespaces.add("g_vml_", "urn:schemas-microsoft-com:vml");
+ }
+
+ // setup default css
+ var ss = doc.createStyleSheet();
+ ss.cssText = "canvas{display:inline-block;overflow:hidden;" +
+ // default size is 300x150 in Gecko and Opera
+ "text-align:left;width:300px;height:150px}" +
+ "g_vml_\\:*{behavior:url(#default#VML)}";
+
+ // find all canvas elements
+ var els = doc.getElementsByTagName("canvas");
+ for (var i = 0; i < els.length; i++) {
+ if (!els[i].getContext) {
+ this.initElement(els[i]);
+ }
+ }
+ }
+ },
+
+ fixElement_: function (el) {
+ // in IE before version 5.5 we would need to add HTML: to the tag name
+ // but we do not care about IE before version 6
+ var outerHTML = el.outerHTML;
+
+ var newEl = el.ownerDocument.createElement(outerHTML);
+ // if the tag is still open IE has created the children as siblings and
+ // it has also created a tag with the name "/FOO"
+ if (outerHTML.slice(-2) != "/>") {
+ var tagName = "/" + el.tagName;
+ var ns;
+ // remove content
+ while ((ns = el.nextSibling) && ns.tagName != tagName) {
+ ns.removeNode();
+ }
+ // remove the incorrect closing tag
+ if (ns) {
+ ns.removeNode();
+ }
+ }
+ el.parentNode.replaceChild(newEl, el);
+ return newEl;
+ },
+
+ /**
+ * Public initializes a canvas element so that it can be used as canvas
+ * element from now on. This is called automatically before the page is
+ * loaded but if you are creating elements using createElement you need to
+ * make sure this is called on the element.
+ * @param {HTMLElement} el The canvas element to initialize.
+ * @return {HTMLElement} the element that was created.
+ */
+ initElement: function (el) {
+ el = this.fixElement_(el);
+ el.getContext = function () {
+ if (this.context_) {
+ return this.context_;
+ }
+ return this.context_ = new CanvasRenderingContext2D_(this);
+ };
+
+ // do not use inline function because that will leak memory
+ el.attachEvent('onpropertychange', onPropertyChange);
+ el.attachEvent('onresize', onResize);
+
+ var attrs = el.attributes;
+ if (attrs.width && attrs.width.specified) {
+ // TODO: use runtimeStyle and coordsize
+ // el.getContext().setWidth_(attrs.width.nodeValue);
+ el.style.width = attrs.width.nodeValue + "px";
+ } else {
+ el.width = el.clientWidth;
+ }
+ if (attrs.height && attrs.height.specified) {
+ // TODO: use runtimeStyle and coordsize
+ // el.getContext().setHeight_(attrs.height.nodeValue);
+ el.style.height = attrs.height.nodeValue + "px";
+ } else {
+ el.height = el.clientHeight;
+ }
+ //el.getContext().setCoordsize_()
+ return el;
+ }
+ };
+
+ function onPropertyChange(e) {
+ var el = e.srcElement;
+
+ switch (e.propertyName) {
+ case 'width':
+ el.style.width = el.attributes.width.nodeValue + "px";
+ el.getContext().clearRect();
+ break;
+ case 'height':
+ el.style.height = el.attributes.height.nodeValue + "px";
+ el.getContext().clearRect();
+ break;
+ }
+ }
+
+ function onResize(e) {
+ var el = e.srcElement;
+ if (el.firstChild) {
+ el.firstChild.style.width = el.clientWidth + 'px';
+ el.firstChild.style.height = el.clientHeight + 'px';
+ }
+ }
+
+ G_vmlCanvasManager_.init();
+
+ // precompute "00" to "FF"
+ var dec2hex = [];
+ for (var i = 0; i < 16; i++) {
+ for (var j = 0; j < 16; j++) {
+ dec2hex[i * 16 + j] = i.toString(16) + j.toString(16);
+ }
+ }
+
+ function createMatrixIdentity() {
+ return [
+ [1, 0, 0],
+ [0, 1, 0],
+ [0, 0, 1]
+ ];
+ }
+
+ function matrixMultiply(m1, m2) {
+ var result = createMatrixIdentity();
+
+ for (var x = 0; x < 3; x++) {
+ for (var y = 0; y < 3; y++) {
+ var sum = 0;
+
+ for (var z = 0; z < 3; z++) {
+ sum += m1[x][z] * m2[z][y];
+ }
+
+ result[x][y] = sum;
+ }
+ }
+ return result;
+ }
+
+ function copyState(o1, o2) {
+ o2.fillStyle = o1.fillStyle;
+ o2.lineCap = o1.lineCap;
+ o2.lineJoin = o1.lineJoin;
+ o2.lineWidth = o1.lineWidth;
+ o2.miterLimit = o1.miterLimit;
+ o2.shadowBlur = o1.shadowBlur;
+ o2.shadowColor = o1.shadowColor;
+ o2.shadowOffsetX = o1.shadowOffsetX;
+ o2.shadowOffsetY = o1.shadowOffsetY;
+ o2.strokeStyle = o1.strokeStyle;
+ o2.arcScaleX_ = o1.arcScaleX_;
+ o2.arcScaleY_ = o1.arcScaleY_;
+ }
+
+ function processStyle(styleString) {
+ var str, alpha = 1;
+
+ styleString = String(styleString);
+ if (styleString.substring(0, 3) == "rgb") {
+ var start = styleString.indexOf("(", 3);
+ var end = styleString.indexOf(")", start + 1);
+ var guts = styleString.substring(start + 1, end).split(",");
+
+ str = "#";
+ for (var i = 0; i < 3; i++) {
+ str += dec2hex[Number(guts[i])];
+ }
+
+ if ((guts.length == 4) && (styleString.substr(3, 1) == "a")) {
+ alpha = guts[3];
+ }
+ } else {
+ str = styleString;
+ }
+
+ return [str, alpha];
+ }
+
+ function processLineCap(lineCap) {
+ switch (lineCap) {
+ case "butt":
+ return "flat";
+ case "round":
+ return "round";
+ case "square":
+ default:
+ return "square";
+ }
+ }
+
+ /**
+ * This class implements CanvasRenderingContext2D interface as described by
+ * the WHATWG.
+ * @param {HTMLElement} surfaceElement The element that the 2D context should
+ * be associated with
+ */
+ function CanvasRenderingContext2D_(surfaceElement) {
+ this.m_ = createMatrixIdentity();
+
+ this.mStack_ = [];
+ this.aStack_ = [];
+ this.currentPath_ = [];
+
+ // Canvas context properties
+ this.strokeStyle = "#000";
+ this.fillStyle = "#000";
+
+ this.lineWidth = 1;
+ this.lineJoin = "miter";
+ this.lineCap = "butt";
+ this.miterLimit = Z * 1;
+ this.globalAlpha = 1;
+ this.canvas = surfaceElement;
+
+ var el = surfaceElement.ownerDocument.createElement('div');
+ el.style.width = surfaceElement.clientWidth + 'px';
+ el.style.height = surfaceElement.clientHeight + 'px';
+ el.style.overflow = 'hidden';
+ el.style.position = 'absolute';
+ surfaceElement.appendChild(el);
+
+ this.element_ = el;
+ this.arcScaleX_ = 1;
+ this.arcScaleY_ = 1;
+ }
+
+ var contextPrototype = CanvasRenderingContext2D_.prototype;
+ contextPrototype.clearRect = function() {
+ this.element_.innerHTML = "";
+ this.currentPath_ = [];
+ };
+
+ contextPrototype.beginPath = function() {
+ // TODO: Branch current matrix so that save/restore has no effect
+ // as per safari docs.
+
+ this.currentPath_ = [];
+ };
+
+ contextPrototype.moveTo = function(aX, aY) {
+ this.currentPath_.push({type: "moveTo", x: aX, y: aY});
+ this.currentX_ = aX;
+ this.currentY_ = aY;
+ };
+
+ contextPrototype.lineTo = function(aX, aY) {
+ this.currentPath_.push({type: "lineTo", x: aX, y: aY});
+ this.currentX_ = aX;
+ this.currentY_ = aY;
+ };
+
+ contextPrototype.bezierCurveTo = function(aCP1x, aCP1y,
+ aCP2x, aCP2y,
+ aX, aY) {
+ this.currentPath_.push({type: "bezierCurveTo",
+ cp1x: aCP1x,
+ cp1y: aCP1y,
+ cp2x: aCP2x,
+ cp2y: aCP2y,
+ x: aX,
+ y: aY});
+ this.currentX_ = aX;
+ this.currentY_ = aY;
+ };
+
+ contextPrototype.quadraticCurveTo = function(aCPx, aCPy, aX, aY) {
+ // the following is lifted almost directly from
+ // http://developer.mozilla.org/en/docs/Canvas_tutorial:Drawing_shapes
+ var cp1x = this.currentX_ + 2.0 / 3.0 * (aCPx - this.currentX_);
+ var cp1y = this.currentY_ + 2.0 / 3.0 * (aCPy - this.currentY_);
+ var cp2x = cp1x + (aX - this.currentX_) / 3.0;
+ var cp2y = cp1y + (aY - this.currentY_) / 3.0;
+ this.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, aX, aY);
+ };
+
+ contextPrototype.arc = function(aX, aY, aRadius,
+ aStartAngle, aEndAngle, aClockwise) {
+ aRadius *= Z;
+ var arcType = aClockwise ? "at" : "wa";
+
+ var xStart = aX + (mc(aStartAngle) * aRadius) - Z2;
+ var yStart = aY + (ms(aStartAngle) * aRadius) - Z2;
+
+ var xEnd = aX + (mc(aEndAngle) * aRadius) - Z2;
+ var yEnd = aY + (ms(aEndAngle) * aRadius) - Z2;
+
+ // IE won't render arches drawn counter clockwise if xStart == xEnd.
+ if (xStart == xEnd && !aClockwise) {
+ xStart += 0.125; // Offset xStart by 1/80 of a pixel. Use something
+ // that can be represented in binary
+ }
+
+ this.currentPath_.push({type: arcType,
+ x: aX,
+ y: aY,
+ radius: aRadius,
+ xStart: xStart,
+ yStart: yStart,
+ xEnd: xEnd,
+ yEnd: yEnd});
+
+ };
+
+ contextPrototype.rect = function(aX, aY, aWidth, aHeight) {
+ this.moveTo(aX, aY);
+ this.lineTo(aX + aWidth, aY);
+ this.lineTo(aX + aWidth, aY + aHeight);
+ this.lineTo(aX, aY + aHeight);
+ this.closePath();
+ };
+
+ contextPrototype.strokeRect = function(aX, aY, aWidth, aHeight) {
+ // Will destroy any existing path (same as FF behaviour)
+ this.beginPath();
+ this.moveTo(aX, aY);
+ this.lineTo(aX + aWidth, aY);
+ this.lineTo(aX + aWidth, aY + aHeight);
+ this.lineTo(aX, aY + aHeight);
+ this.closePath();
+ this.stroke();
+ };
+
+ contextPrototype.fillRect = function(aX, aY, aWidth, aHeight) {
+ // Will destroy any existing path (same as FF behaviour)
+ this.beginPath();
+ this.moveTo(aX, aY);
+ this.lineTo(aX + aWidth, aY);
+ this.lineTo(aX + aWidth, aY + aHeight);
+ this.lineTo(aX, aY + aHeight);
+ this.closePath();
+ this.fill();
+ };
+
+ contextPrototype.createLinearGradient = function(aX0, aY0, aX1, aY1) {
+ var gradient = new CanvasGradient_("gradient");
+ return gradient;
+ };
+
+ contextPrototype.createRadialGradient = function(aX0, aY0,
+ aR0, aX1,
+ aY1, aR1) {
+ var gradient = new CanvasGradient_("gradientradial");
+ gradient.radius1_ = aR0;
+ gradient.radius2_ = aR1;
+ gradient.focus_.x = aX0;
+ gradient.focus_.y = aY0;
+ return gradient;
+ };
+
+ contextPrototype.drawImage = function (image, var_args) {
+ var dx, dy, dw, dh, sx, sy, sw, sh;
+
+ // to find the original width we overide the width and height
+ var oldRuntimeWidth = image.runtimeStyle.width;
+ var oldRuntimeHeight = image.runtimeStyle.height;
+ image.runtimeStyle.width = 'auto';
+ image.runtimeStyle.height = 'auto';
+
+ // get the original size
+ var w = image.width;
+ var h = image.height;
+
+ // and remove overides
+ image.runtimeStyle.width = oldRuntimeWidth;
+ image.runtimeStyle.height = oldRuntimeHeight;
+
+ if (arguments.length == 3) {
+ dx = arguments[1];
+ dy = arguments[2];
+ sx = sy = 0;
+ sw = dw = w;
+ sh = dh = h;
+ } else if (arguments.length == 5) {
+ dx = arguments[1];
+ dy = arguments[2];
+ dw = arguments[3];
+ dh = arguments[4];
+ sx = sy = 0;
+ sw = w;
+ sh = h;
+ } else if (arguments.length == 9) {
+ sx = arguments[1];
+ sy = arguments[2];
+ sw = arguments[3];
+ sh = arguments[4];
+ dx = arguments[5];
+ dy = arguments[6];
+ dw = arguments[7];
+ dh = arguments[8];
+ } else {
+ throw "Invalid number of arguments";
+ }
+
+ var d = this.getCoords_(dx, dy);
+
+ var w2 = sw / 2;
+ var h2 = sh / 2;
+
+ var vmlStr = [];
+
+ var W = 10;
+ var H = 10;
+
+ // For some reason that I've now forgotten, using divs didn't work
+ vmlStr.push(' ' ,
+ '',
+ '');
+
+ this.element_.insertAdjacentHTML("BeforeEnd",
+ vmlStr.join(""));
+ };
+
+ contextPrototype.stroke = function(aFill) {
+ var lineStr = [];
+ var lineOpen = false;
+ var a = processStyle(aFill ? this.fillStyle : this.strokeStyle);
+ var color = a[0];
+ var opacity = a[1] * this.globalAlpha;
+
+ var W = 10;
+ var H = 10;
+
+ lineStr.push(' max.x) {
+ max.x = c.x;
+ }
+ if (min.y == null || c.y < min.y) {
+ min.y = c.y;
+ }
+ if (max.y == null || c.y > max.y) {
+ max.y = c.y;
+ }
+ }
+ }
+ lineStr.push(' ">');
+
+ if (typeof this.fillStyle == "object") {
+ var focus = {x: "50%", y: "50%"};
+ var width = (max.x - min.x);
+ var height = (max.y - min.y);
+ var dimension = (width > height) ? width : height;
+
+ focus.x = mr((this.fillStyle.focus_.x / width) * 100 + 50) + "%";
+ focus.y = mr((this.fillStyle.focus_.y / height) * 100 + 50) + "%";
+
+ var colors = [];
+
+ // inside radius (%)
+ if (this.fillStyle.type_ == "gradientradial") {
+ var inside = (this.fillStyle.radius1_ / dimension * 100);
+
+ // percentage that outside radius exceeds inside radius
+ var expansion = (this.fillStyle.radius2_ / dimension * 100) - inside;
+ } else {
+ var inside = 0;
+ var expansion = 100;
+ }
+
+ var insidecolor = {offset: null, color: null};
+ var outsidecolor = {offset: null, color: null};
+
+ // We need to sort 'colors' by percentage, from 0 > 100 otherwise ie
+ // won't interpret it correctly
+ this.fillStyle.colors_.sort(function (cs1, cs2) {
+ return cs1.offset - cs2.offset;
+ });
+
+ for (var i = 0; i < this.fillStyle.colors_.length; i++) {
+ var fs = this.fillStyle.colors_[i];
+
+ colors.push( (fs.offset * expansion) + inside, "% ", fs.color, ",");
+
+ if (fs.offset > insidecolor.offset || insidecolor.offset == null) {
+ insidecolor.offset = fs.offset;
+ insidecolor.color = fs.color;
+ }
+
+ if (fs.offset < outsidecolor.offset || outsidecolor.offset == null) {
+ outsidecolor.offset = fs.offset;
+ outsidecolor.color = fs.color;
+ }
+ }
+ colors.pop();
+
+ lineStr.push('');
+ } else if (aFill) {
+ lineStr.push('');
+ } else {
+ lineStr.push(
+ ''
+ );
+ }
+
+ lineStr.push("");
+
+ this.element_.insertAdjacentHTML("beforeEnd", lineStr.join(""));
+
+ //this.currentPath_ = [];
+ };
+
+ contextPrototype.fill = function() {
+ this.stroke(true);
+ };
+
+ contextPrototype.closePath = function() {
+ this.currentPath_.push({type: "close"});
+ };
+
+ /**
+ * @private
+ */
+ contextPrototype.getCoords_ = function(aX, aY) {
+ return {
+ x: Z * (aX * this.m_[0][0] + aY * this.m_[1][0] + this.m_[2][0]) - Z2,
+ y: Z * (aX * this.m_[0][1] + aY * this.m_[1][1] + this.m_[2][1]) - Z2
+ }
+ };
+
+ contextPrototype.save = function() {
+ var o = {};
+ copyState(this, o);
+ this.aStack_.push(o);
+ this.mStack_.push(this.m_);
+ this.m_ = matrixMultiply(createMatrixIdentity(), this.m_);
+ };
+
+ contextPrototype.restore = function() {
+ copyState(this.aStack_.pop(), this);
+ this.m_ = this.mStack_.pop();
+ };
+
+ contextPrototype.translate = function(aX, aY) {
+ var m1 = [
+ [1, 0, 0],
+ [0, 1, 0],
+ [aX, aY, 1]
+ ];
+
+ this.m_ = matrixMultiply(m1, this.m_);
+ };
+
+ contextPrototype.rotate = function(aRot) {
+ var c = mc(aRot);
+ var s = ms(aRot);
+
+ var m1 = [
+ [c, s, 0],
+ [-s, c, 0],
+ [0, 0, 1]
+ ];
+
+ this.m_ = matrixMultiply(m1, this.m_);
+ };
+
+ contextPrototype.scale = function(aX, aY) {
+ this.arcScaleX_ *= aX;
+ this.arcScaleY_ *= aY;
+ var m1 = [
+ [aX, 0, 0],
+ [0, aY, 0],
+ [0, 0, 1]
+ ];
+
+ this.m_ = matrixMultiply(m1, this.m_);
+ };
+
+ /******** STUBS ********/
+ contextPrototype.clip = function() {
+ // TODO: Implement
+ };
+
+ contextPrototype.arcTo = function() {
+ // TODO: Implement
+ };
+
+ contextPrototype.createPattern = function() {
+ return new CanvasPattern_;
+ };
+
+ // Gradient / Pattern Stubs
+ function CanvasGradient_(aType) {
+ this.type_ = aType;
+ this.radius1_ = 0;
+ this.radius2_ = 0;
+ this.colors_ = [];
+ this.focus_ = {x: 0, y: 0};
+ }
+
+ CanvasGradient_.prototype.addColorStop = function(aOffset, aColor) {
+ aColor = processStyle(aColor);
+ this.colors_.push({offset: 1-aOffset, color: aColor});
+ };
+
+ function CanvasPattern_() {}
+
+ // set up externs
+ G_vmlCanvasManager = G_vmlCanvasManager_;
+ CanvasRenderingContext2D = CanvasRenderingContext2D_;
+ CanvasGradient = CanvasGradient_;
+ CanvasPattern = CanvasPattern_;
+
+})();
+
+} // if
diff --git a/modules/distribution/src/repository/resources/dashboard/gadgets/js/graph.js b/modules/distribution/src/repository/resources/dashboard/gadgets/js/graph.js
new file mode 100644
index 00000000..61824afb
--- /dev/null
+++ b/modules/distribution/src/repository/resources/dashboard/gadgets/js/graph.js
@@ -0,0 +1,44 @@
+/*This js mainly concern with the data structures related to graphs*/
+function carbonGraph(xscale) {
+ this.array = new Array();
+ for (var i = 0; i < xscale; i++) {
+ this.array[i] = [i, 0.0];
+ }
+ this.xscale = xscale;
+}
+
+function getData() {
+ return this.array;
+}
+
+function addData(newValue) {
+
+ //shift to left
+ for (var i = 0; i < this.xscale - 1; i++) {
+ this.array[i] = [i,this.array[i + 1][1]]; // (x,y)
+ }
+
+ //add the value to the last postion
+ this.array[this.xscale - 1] = [this.xscale - 1,newValue];
+}
+
+function graphTickGenerator() {
+ var tickArray = [];
+ var startTick = 10;
+ var i = startTick - 1;
+ var weight = this.xscale / 10;
+ do {
+ var t = (startTick - i) * weight - 1;
+ var v = i * weight;
+ if (v == 0) {
+ v = "0";
+ }
+ tickArray.push([t, v]);
+ i--;
+ } while (i > -1);
+ return tickArray;
+}
+
+carbonGraph.prototype.get = getData;
+carbonGraph.prototype.add = addData;
+carbonGraph.prototype.tick = graphTickGenerator;
\ No newline at end of file
diff --git a/modules/distribution/src/repository/resources/dashboard/gadgets/js/help-populator.js b/modules/distribution/src/repository/resources/dashboard/gadgets/js/help-populator.js
new file mode 100644
index 00000000..688d4606
--- /dev/null
+++ b/modules/distribution/src/repository/resources/dashboard/gadgets/js/help-populator.js
@@ -0,0 +1,43 @@
+function clientSideInclude(id, url) {
+ var req = false;
+ // For Safari, Firefox, and other non-MS browsers
+ if (window.XMLHttpRequest) {
+ try {
+ req = new XMLHttpRequest();
+ } catch (e) {
+ req = false;
+ }
+ } else if (window.ActiveXObject) {
+ // For Internet Explorer on Windows
+ try {
+ req = new ActiveXObject("Msxml2.XMLHTTP");
+ } catch (e) {
+ try {
+ req = new ActiveXObject("Microsoft.XMLHTTP");
+ } catch (e) {
+ req = false;
+ }
+ }
+ }
+ var element = document.getElementById(id);
+ if (!element) {
+ alert("Bad id " + id +
+ "passed to clientSideInclude." +
+ "You need a div or span element " +
+ "with this id in your page.");
+ return;
+ }
+ if (req) {
+ // Synchronous request, wait till we have it all
+ req.open('GET', url, false);
+ req.send(null);
+ element.innerHTML = req.responseText;
+ } else {
+ element.innerHTML =
+ "Sorry, your browser does not support " +
+ "XMLHTTPRequest objects. This page requires " +
+ "Internet Explorer 5 or better for Windows, " +
+ "or Firefox for any system, or Safari. Other " +
+ "compatible browsers may also exist.";
+ }
+}
diff --git a/modules/distribution/src/repository/resources/dashboard/gadgets/js/jit.js b/modules/distribution/src/repository/resources/dashboard/gadgets/js/jit.js
new file mode 100644
index 00000000..269fbc7d
--- /dev/null
+++ b/modules/distribution/src/repository/resources/dashboard/gadgets/js/jit.js
@@ -0,0 +1,9049 @@
+(function () {
+
+/*
+ File: Core.js
+
+ Description:
+
+ Provides common utility functions and the Class object used internally by the library.
+
+ Also provides the object for manipulating JSON tree structures
+
+ Some of the Basic utility functions and the Class system are based in the MooTools Framework . Copyright (c) 2006-2009 Valerio Proietti, . MIT license .
+
+ Author:
+
+ Nicolas Garcia Belmonte
+
+ Copyright:
+
+ Copyright 2008-2009 by Nicolas Garcia Belmonte.
+
+ Homepage:
+
+
+
+ Version:
+
+ 1.1.3
+
+ License:
+
+ BSD 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 the organization 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 Nicolas Garcia Belmonte ``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 Nicolas Garcia Belmonte 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.
+ */
+
+
+function $empty() {};
+
+function $extend(original, extended){
+ for (var key in (extended || {})) original[key] = extended[key];
+ return original;
+};
+
+function $lambda(value){
+ return (typeof value == 'function') ? value : function(){
+ return value;
+ };
+};
+
+var $time = Date.now || function(){
+ return +new Date;
+};
+
+function $splat(obj){
+ var type = $type(obj);
+ return (type) ? ((type != 'array') ? [obj] : obj) : [];
+};
+
+var $type = function(elem) {
+ return $type.s.call(elem).match(/^\[object\s(.*)\]$/)[1].toLowerCase();
+};
+$type.s = Object.prototype.toString;
+
+function $each(iterable, fn){
+ var type = $type(iterable);
+ if(type == 'object') {
+ for (var key in iterable) fn(iterable[key], key);
+ } else {
+ for(var i=0; i < iterable.length; i++) fn(iterable[i], i);
+ }
+};
+
+function $merge(){
+ var mix = {};
+ for (var i = 0, l = arguments.length; i < l; i++){
+ var object = arguments[i];
+ if ($type(object) != 'object') continue;
+ for (var key in object){
+ var op = object[key], mp = mix[key];
+ mix[key] = (mp && $type(op) == 'object' && $type(mp) == 'object') ? $merge(mp, op) : $unlink(op);
+ }
+ }
+ return mix;
+};
+
+function $unlink(object){
+ var unlinked;
+ switch ($type(object)){
+ case 'object':
+ unlinked = {};
+ for (var p in object) unlinked[p] = $unlink(object[p]);
+ break;
+ case 'array':
+ unlinked = [];
+ for (var i = 0, l = object.length; i < l; i++) unlinked[i] = $unlink(object[i]);
+ break;
+ default: return object;
+ }
+ return unlinked;
+};
+
+function $rgbToHex(srcArray, array){
+ if (srcArray.length < 3) return null;
+ if (srcArray.length == 4 && srcArray[3] == 0 && !array) return 'transparent';
+ var hex = [];
+ for (var i = 0; i < 3; i++){
+ var bit = (srcArray[i] - 0).toString(16);
+ hex.push((bit.length == 1) ? '0' + bit : bit);
+ }
+ return (array) ? hex : '#' + hex.join('');
+};
+
+function $destroy(elem) {
+ $clean(elem);
+ if(elem.parentNode) elem.parentNode.removeChild(elem);
+ if(elem.clearAttributes) elem.clearAttributes();
+};
+
+function $clean(elem) {
+ for(var ch = elem.childNodes, i=0; i < ch.length; i++) {
+ $destroy(ch[i]);
+ }
+};
+
+function $addEvent(obj, type, fn) {
+ if (obj.addEventListener)
+ obj.addEventListener(type, fn, false);
+ else
+ obj.attachEvent('on' + type, fn);
+};
+
+function $hasClass(obj, klass) {
+ return (' ' + obj.className + ' ').indexOf(' ' + klass + ' ') > -1;
+};
+
+function $addClass(obj, klass) {
+ if(!$hasClass(obj, klass)) obj.className = (obj.className + " " + klass);
+};
+
+function $removeClass(obj, klass) {
+ obj.className = obj.className.replace(new RegExp('(^|\\s)' + klass + '(?:\\s|$)'), '$1');
+};
+
+function $get(id) {
+ return document.getElementById(id);
+};
+
+var Class = function(properties){
+ properties = properties || {};
+ var klass = function(){
+// not defining any attributes in Class properties.
+// for (var key in this){
+// if (typeof this[key] != 'function') this[key] = $unlink(this[key]);
+// }
+ this.constructor = klass;
+ if (Class.prototyping) return this;
+ var instance = (this.initialize) ? this.initialize.apply(this, arguments) : this;
+ return instance;
+ };
+
+ for (var mutator in Class.Mutators){
+ if (!properties[mutator]) continue;
+ properties = Class.Mutators[mutator](properties, properties[mutator]);
+ delete properties[mutator];
+ }
+
+ $extend(klass, this);
+ klass.constructor = Class;
+ klass.prototype = properties;
+ return klass;
+};
+
+Class.Mutators = {
+
+ Extends: function(self, klass){
+ Class.prototyping = klass.prototype;
+ var subclass = new klass;
+ delete subclass.parent;
+ subclass = Class.inherit(subclass, self);
+ delete Class.prototyping;
+ return subclass;
+ },
+
+ Implements: function(self, klasses){
+ $each($splat(klasses), function(klass){
+ Class.prototying = klass;
+ $extend(self, ($type(klass) == 'function') ? new klass : klass);
+ delete Class.prototyping;
+ });
+ return self;
+ }
+
+};
+
+$extend(Class, {
+
+ inherit: function(object, properties){
+ var caller = arguments.callee.caller;
+ for (var key in properties){
+ var override = properties[key];
+ var previous = object[key];
+ var type = $type(override);
+ if (previous && type == 'function'){
+ if (override != previous){
+ if (caller){
+ override.__parent = previous;
+ object[key] = override;
+ } else {
+ Class.override(object, key, override);
+ }
+ }
+ } else if(type == 'object'){
+ object[key] = $merge(previous, override);
+ } else {
+ object[key] = override;
+ }
+ }
+
+ if (caller) object.parent = function(){
+ return arguments.callee.caller.__parent.apply(this, arguments);
+ };
+
+ return object;
+ },
+
+ override: function(object, name, method){
+ var parent = Class.prototyping;
+ if (parent && object[name] != parent[name]) parent = null;
+ var override = function(){
+ var previous = this.parent;
+ this.parent = parent ? parent[name] : object[name];
+ var value = method.apply(this, arguments);
+ this.parent = previous;
+ return value;
+ };
+ object[name] = override;
+ }
+
+});
+
+
+Class.prototype.implement = function(){
+ var proto = this.prototype;
+ $each(Array.prototype.slice.call(arguments || []), function(properties){
+ Class.inherit(proto, properties);
+ });
+ return this;
+};
+
+/*
+ Object: TreeUtil
+
+ Some common JSON tree manipulation methods.
+*/
+this.TreeUtil = {
+
+ /*
+ Method: prune
+
+ Clears all tree nodes having depth greater than maxLevel.
+
+ Parameters:
+
+ tree - A JSON tree object. For more information please see .
+ maxLevel - An integer specifying the maximum level allowed for this tree. All nodes having depth greater than max level will be deleted.
+
+ */
+ prune: function(tree, maxLevel) {
+ this.each(tree, function(elem, i) {
+ if(i == maxLevel && elem.children) {
+ delete elem.children;
+ elem.children = [];
+ }
+ });
+ },
+
+ /*
+ Method: getParent
+
+ Returns the parent node of the node having _id_ as id.
+
+ Parameters:
+
+ tree - A JSON tree object. See also .
+ id - The _id_ of the child node whose parent will be returned.
+
+ Returns:
+
+ A tree JSON node if any, or false otherwise.
+
+ */
+ getParent: function(tree, id) {
+ if(tree.id == id) return false;
+ var ch = tree.children;
+ if(ch && ch.length > 0) {
+ for(var i=0; i.
+ id - A node *unique* identifier.
+
+ Returns:
+
+ A subtree having a root node matching the given id. Returns null if no subtree matching the id is found.
+
+ */
+ getSubtree: function(tree, id) {
+ if(tree.id == id) return tree;
+ for(var i=0, ch=tree.children; i.
+ maxLevel - _optional_ A subtree's max level.
+
+ Returns:
+
+ An array having objects with two properties.
+
+ - The _node_ property contains the leaf node.
+ - The _level_ property specifies the depth of the node.
+
+ */
+ getLeaves: function (node, maxLevel) {
+ var leaves = [], levelsToShow = maxLevel || Number.MAX_VALUE;
+ this.each(node, function(elem, i) {
+ if(i < levelsToShow &&
+ (!elem.children || elem.children.length == 0 )) {
+ leaves.push({
+ 'node':elem,
+ 'level':levelsToShow - i
+ });
+ }
+ });
+ return leaves;
+ },
+
+
+ /*
+ Method: eachLevel
+
+ Iterates on tree nodes with relative depth less or equal than a specified level.
+
+ Parameters:
+
+ tree - A JSON tree or subtree. See also .
+ initLevel - An integer specifying the initial relative level. Usually zero.
+ toLevel - An integer specifying a top level. This method will iterate only through nodes with depth less than or equal this number.
+ action - A function that receives a node and an integer specifying the actual level of the node.
+
+ Example:
+ (start code js)
+ TreeUtil.eachLevel(tree, 0, 3, function(node, depth) {
+ alert(node.name + ' ' + depth);
+ });
+ (end code)
+ */
+ eachLevel: function(tree, initLevel, toLevel, action) {
+ if(initLevel <= toLevel) {
+ action(tree, initLevel);
+ for(var i=0, ch = tree.children; i.
+ action - A function that receives a node.
+
+ Example:
+ (start code js)
+ TreeUtil.each(tree, function(node) {
+ alert(node.name);
+ });
+ (end code)
+
+ */
+ each: function(tree, action) {
+ this.eachLevel(tree, 0, Number.MAX_VALUE, action);
+ },
+
+ /*
+ Method: loadSubtrees
+
+ Appends subtrees to leaves by requesting new subtrees
+ with the _request_ method.
+
+ Parameters:
+
+ tree - A JSON tree node. .
+ controller - An object that implements a request method.
+
+ Example:
+ (start code js)
+ TreeUtil.loadSubtrees(leafNode, {
+ request: function(nodeId, level, onComplete) {
+ //Pseudo-code to make an ajax request for a new subtree
+ // that has as root id _nodeId_ and depth _level_ ...
+ Ajax.request({
+ 'url': 'http://subtreerequesturl/',
+
+ onSuccess: function(json) {
+ onComplete.onComplete(nodeId, json);
+ }
+ });
+ }
+ });
+ (end code)
+ */
+ loadSubtrees: function(tree, controller) {
+ var maxLevel = controller.request && controller.levelsToShow;
+ var leaves = this.getLeaves(tree, maxLevel),
+ len = leaves.length,
+ selectedNode = {};
+ if(len == 0) controller.onComplete();
+ for(var i=0, counter=0; i, ,
+ */
+/*
+ Class: Canvas
+
+ A multi-purpose Canvas Class. This Class can be used with the ExCanvas library to provide
+ cross browser Canvas based visualizations.
+
+ Parameters:
+
+ id - The canvas id. This id will be used as prefix for the canvas widget DOM elements ids.
+ options - An object containing multiple options such as
+
+ - _injectInto_ This property is _required_ and it specifies the id of the DOM element
+ to which the Canvas widget will be appended
+ - _width_ The width of the Canvas widget. Default's to 200px
+ - _height_ The height of the Canvas widget. Default's to 200px
+ - _backgroundColor_ Used for compatibility with IE. The canvas' background color.
+ Default's to '#333'
+ - _styles_ A hash containing canvas specific style properties such as _fillStyle_ and _strokeStyle_ among others.
+
+ Example:
+
+ Suppose we have this HTML
+
+ (start code xml)
+
+ (end code)
+
+ Now we create a new Canvas instance
+
+ (start code js)
+ //Create a new canvas instance
+ var canvas = new Canvas('mycanvas', {
+ //Where to inject the canvas. Any div container will do.
+ 'injectInto':'infovis',
+ //width and height for canvas. Default's to 200.
+ 'width': 900,
+ 'height':500,
+ //Canvas styles
+ 'styles': {
+ 'fillStyle': '#ccddee',
+ 'strokeStyle': '#772277'
+ }
+ });
+ (end code)
+
+ The generated HTML will look like this
+
+ (start code xml)
+
+ (end code)
+
+ As you can see, the generated HTML consists of a canvas DOM element of id _mycanvas-canvas_ and a div label container
+ of id _mycanvas-label_, wrapped in a main div container of id _mycanvas_.
+ You can also add a background canvas, for making background drawings.
+ This is how the background concentric circles are drawn
+
+ Example:
+
+ (start code js)
+ //Create a new canvas instance.
+ var canvas = new Canvas('mycanvas', {
+ //Where to inject the canvas. Any div container will do.
+ 'injectInto':'infovis',
+ //width and height for canvas. Default's to 200.
+ 'width': 900,
+ 'height':500,
+ //Canvas styles
+ 'styles': {
+ 'fillStyle': '#ccddee',
+ 'strokeStyle': '#772277'
+ },
+ //Add a background canvas for plotting
+ //concentric circles.
+ 'backgroundCanvas': {
+ //Add Canvas styles for the bck canvas.
+ 'styles': {
+ 'fillStyle': '#444',
+ 'strokeStyle': '#444'
+ },
+ //Add the initialization and plotting functions.
+ 'impl': {
+ 'init': function() {},
+ 'plot': function(canvas, ctx) {
+ var times = 6, d = 100;
+ var pi2 = Math.PI*2;
+ for(var i=1; i<=times; i++) {
+ ctx.beginPath();
+ ctx.arc(0, 0, i * d, 0, pi2, true);
+ ctx.stroke();
+ ctx.closePath();
+ }
+ }
+ }
+ }
+ });
+ (end code)
+
+ The _backgroundCanvas_ object contains a canvas _styles_ property and
+ an _impl_ key to be used for implementing background canvas specific code.
+
+ The _init_ method is only called once, at the instanciation of the background canvas.
+ The _plot_ method is called for plotting a Canvas image.
+ */
+this.Canvas = (function(){
+ var config = {
+ 'injectInto': 'id',
+
+ 'width': 200,
+ 'height': 200,
+ //deprecated
+ 'backgroundColor': '#333333',
+
+ 'styles': {
+ 'fillStyle': '#000000',
+ 'strokeStyle': '#000000'
+ },
+
+ 'backgroundCanvas': false
+ };
+
+ function hasCanvas(){
+ hasCanvas.t = hasCanvas.t || typeof(HTMLCanvasElement);
+ return "function" == hasCanvas.t || "object" == hasCanvas.t;
+ };
+
+ function create(tag, prop, styles){
+ var elem = document.createElement(tag);
+ (function(obj, prop){
+ if (prop) {
+ for (var p in prop) {
+ obj[p] = prop[p];
+ }
+ }
+ return arguments.callee;
+ })(elem, prop)(elem.style, styles);
+ //feature check
+ if (tag == "canvas" && !hasCanvas() && G_vmlCanvasManager) {
+ elem = G_vmlCanvasManager.initElement(document.body.appendChild(elem));
+ }
+
+ return elem;
+ };
+
+ function get(id){
+ return document.getElementById(id);
+ };
+
+ function translateToCenter(canvas, ctx, w, h){
+ var width = w ? (canvas.width - w) : canvas.width;
+ var height = h ? (canvas.height - h) : canvas.height;
+ ctx.translate(width / 2, height / 2);
+ };
+
+ return function(id, opt){
+ var ctx, bkctx, mainContainer, labelContainer, canvas, bkcanvas;
+ if (arguments.length < 1)
+ throw "Arguments missing";
+ var idLabel = id + "-label", idCanvas = id + "-canvas", idBCanvas = id + "-bkcanvas";
+ opt = $merge(config, opt || {});
+ //create elements
+ var dim = {
+ 'width': opt.width,
+ 'height': opt.height
+ };
+ mainContainer = create("div", {
+ 'id': id
+ }, $merge(dim, {
+ 'position': 'relative'
+ }));
+ labelContainer = create("div", {
+ 'id': idLabel
+ }, {
+ 'overflow': 'visible',
+ 'position': 'absolute',
+ 'top': 0,
+ 'left': 0,
+ 'width': dim.width + 'px',
+ 'height': 0
+ });
+ var dimPos = {
+ 'position': 'absolute',
+ 'top': 0,
+ 'left': 0,
+ 'width': dim.width + 'px',
+ 'height': dim.height + 'px'
+ };
+ canvas = create("canvas", $merge({
+ 'id': idCanvas
+ }, dim), dimPos);
+ var bc = opt.backgroundCanvas;
+ if (bc) {
+ bkcanvas = create("canvas", $merge({
+ 'id': idBCanvas
+ }, dim), dimPos);
+ //append elements
+ mainContainer.appendChild(bkcanvas);
+ }
+ mainContainer.appendChild(canvas);
+ mainContainer.appendChild(labelContainer);
+ get(opt.injectInto).appendChild(mainContainer);
+
+ //create contexts
+ ctx = canvas.getContext('2d');
+ translateToCenter(canvas, ctx);
+ var st = opt.styles;
+ var s;
+ for (s in st)
+ ctx[s] = st[s];
+ if (bc) {
+ bkctx = bkcanvas.getContext('2d');
+ st = bc.styles;
+ for (s in st) {
+ bkctx[s] = st[s];
+ }
+ translateToCenter(bkcanvas, bkctx);
+ bc.impl.init(bkcanvas, bkctx);
+ bc.impl.plot(bkcanvas, bkctx);
+ }
+ //create methods
+ return {
+ 'id': id,
+ /*
+ Method: getCtx
+
+ Returns the main canvas context object
+
+ Returns:
+
+ Main canvas context
+
+ Example:
+
+ (start code js)
+ var ctx = canvas.getCtx();
+ //Now I can use the native canvas context
+ //and for example change some canvas styles
+ ctx.globalAlpha = 1;
+ (end code)
+ */
+ getCtx: function(){
+ return ctx;
+ },
+
+ /*
+ Method: getElement
+ Returns the main Canvas DOM wrapper
+
+ Returns:
+ DOM canvas wrapper generated, (i.e the div wrapper element with id _mycanvas_)
+
+ Example:
+ (start code js)
+ var wrapper = canvas.getElement();
+ //Returns ...
as element
+ (end code)
+ */
+ getElement: function(){
+ return mainContainer;
+ },
+
+ /*
+ Method: resize
+
+ Resizes the canvas.
+
+ Parameters:
+
+ width - New canvas width.
+ height - New canvas height.
+
+ This method can be used with the , or visualizations to resize
+ the visualizations
+
+ Example:
+
+ (start code js)
+ function resizeViz(width, height) {
+ canvas.resize(width, height);
+ rgraph.refresh(); //ht.refresh or st.refresh() also work.
+ rgraph.onAfterCompute();
+ }
+ (end code)
+
+ */
+ resize: function(width, height){
+ var pwidth = canvas.width, pheight = canvas.height;
+ canvas.width = width;
+ canvas.height = height;
+ canvas.style.width = width + "px";
+ canvas.style.height = height + "px";
+ if (bc) {
+ bkcanvas.width = width;
+ bkcanvas.height = height;
+ bkcanvas.style.width = width + "px";
+ bkcanvas.style.height = height + "px";
+ }
+ //small ExCanvas fix
+ if(!hasCanvas()) {
+ translateToCenter(canvas, ctx, pwidth, pheight);
+ } else {
+ translateToCenter(canvas, ctx);
+ }
+
+ var st = opt.styles;
+ var s;
+ for (s in st) {
+ ctx[s] = st[s];
+ }
+ if (bc) {
+ st = bc.styles;
+ for (s in st)
+ bkctx[s] = st[s];
+ //same ExCanvas fix here
+ if(!hasCanvas()) {
+ translateToCenter(bkcanvas, bkctx, pwidth, pheight);
+ } else {
+ translateToCenter(bkcanvas, bkctx);
+ }
+
+ bc.impl.init(bkcanvas, bkctx);
+ bc.impl.plot(bkcanvas, bkctx);
+ }
+ },
+
+ /*
+ Method: getSize
+
+ Returns canvas dimensions.
+
+ Returns:
+
+ An object with _width_ and _height_ properties.
+ Example:
+ (start code js)
+ canvas.getSize(); //returns { width: 900, height: 500 }
+ (end code)
+ */
+ getSize: function(){
+ return {
+ 'width': canvas.width,
+ 'height': canvas.height
+ };
+ },
+
+ path: function(type, action){
+ ctx.beginPath();
+ action(ctx);
+ ctx[type]();
+ ctx.closePath();
+ },
+
+ /*
+ Method: clear
+
+ Clears the canvas object.
+ */
+ clear: function(){
+ var size = this.getSize();
+ ctx.clearRect(-size.width / 2, -size.height / 2, size.width, size.height);
+ },
+
+ /*
+ Method: clearReactangle
+
+ Same as but only clears a section of the canvas.
+
+ Parameters:
+
+ top - An integer specifying the top of the rectangle.
+ right - An integer specifying the right of the rectangle.
+ bottom - An integer specifying the bottom of the rectangle.
+ left - An integer specifying the left of the rectangle.
+ */
+ clearRectangle: function(top, right, bottom, left){
+ //if using excanvas
+ if (!hasCanvas()) {
+ var f0 = ctx.fillStyle;
+ ctx.fillStyle = opt.backgroundColor;
+ ctx.fillRect(left, top, Math.abs(right - left), Math.abs(bottom - top));
+ ctx.fillStyle = f0;
+ }
+ else {
+ ctx.clearRect(left, top, Math.abs(right - left), Math.abs(bottom - top));
+ }
+ }
+ };
+ };
+
+})();
+
+
+
+/*
+ * File: Polar.js
+ *
+ * Defines the class.
+ *
+ * Description:
+ *
+ * The class, just like the class, is used by the , and as a 2D point representation.
+ *
+ * See also:
+ *
+ *
+ *
+*/
+
+/*
+ Class: Polar
+
+ A multi purpose polar representation.
+
+ Description:
+
+ The class, just like the class, is used by the , and as a 2D point representation.
+
+ See also:
+
+
+
+ Parameters:
+
+ theta - An angle.
+ rho - The norm.
+*/
+
+this.Polar = function(theta, rho) {
+ this.theta = theta;
+ this.rho = rho;
+};
+
+Polar.prototype = {
+ /*
+ Method: getc
+
+ Returns a complex number.
+
+ Parameters:
+
+ simple - _optional_ If *true*, this method will return only an object holding x and y properties and not a instance. Default's *false*.
+
+ Returns:
+
+ A complex number.
+ */
+ getc: function(simple) {
+ return this.toComplex(simple);
+ },
+
+ /*
+ Method: getp
+
+ Returns a representation.
+
+ Returns:
+
+ A variable in polar coordinates.
+ */
+ getp: function() {
+ return this;
+ },
+
+
+ /*
+ Method: set
+
+ Sets a number.
+
+ Parameters:
+
+ v - A or instance.
+
+ */
+ set: function(v) {
+ v = v.getp();
+ this.theta = v.theta; this.rho = v.rho;
+ },
+
+ /*
+ Method: setc
+
+ Sets a number.
+
+ Parameters:
+
+ x - A number real part.
+ y - A number imaginary part.
+
+ */
+ setc: function(x, y) {
+ this.rho = Math.sqrt(x * x + y * y);
+ this.theta = Math.atan2(y, x);
+ if(this.theta < 0) this.theta += Math.PI * 2;
+ },
+
+ /*
+ Method: setp
+
+ Sets a polar number.
+
+ Parameters:
+
+ theta - A number angle property.
+ rho - A number rho property.
+
+ */
+ setp: function(theta, rho) {
+ this.theta = theta;
+ this.rho = rho;
+ },
+
+ /*
+ Method: clone
+
+ Returns a copy of the current object.
+
+ Returns:
+
+ A copy of the real object.
+ */
+ clone: function() {
+ return new Polar(this.theta, this.rho);
+ },
+
+ /*
+ Method: toComplex
+
+ Translates from polar to cartesian coordinates and returns a new instance.
+
+ Parameters:
+
+ simple - _optional_ If *true* this method will only return an object with x and y properties (and not the whole instance). Default's *false*.
+
+ Returns:
+
+ A new instance.
+ */
+ toComplex: function(simple) {
+ var x = Math.cos(this.theta) * this.rho;
+ var y = Math.sin(this.theta) * this.rho;
+ if(simple) return { 'x': x, 'y': y};
+ return new Complex(x, y);
+ },
+
+ /*
+ Method: add
+
+ Adds two instances.
+
+ Parameters:
+
+ polar - A number.
+
+ Returns:
+
+ A new Polar instance.
+ */
+ add: function(polar) {
+ return new Polar(this.theta + polar.theta, this.rho + polar.rho);
+ },
+
+ /*
+ Method: scale
+
+ Scales a polar norm.
+
+ Parameters:
+
+ number - A scale factor.
+
+ Returns:
+
+ A new Polar instance.
+ */
+ scale: function(number) {
+ return new Polar(this.theta, this.rho * number);
+ },
+
+ /*
+ Method: equals
+
+ Comparison method.
+
+ Returns *true* if the theta and rho properties are equal.
+
+ Parameters:
+
+ c - A number.
+
+ Returns:
+
+ *true* if the theta and rho parameters for these objects are equal. *false* otherwise.
+ */
+ equals: function(c) {
+ return this.theta == c.theta && this.rho == c.rho;
+ },
+
+ /*
+ Method: $add
+
+ Adds two instances affecting the current object.
+
+ Paramters:
+
+ polar - A instance.
+
+ Returns:
+
+ The changed object.
+ */
+ $add: function(polar) {
+ this.theta = this.theta + polar.theta; this.rho += polar.rho;
+ return this;
+ },
+
+ /*
+ Method: $madd
+
+ Adds two instances affecting the current object. The resulting theta angle is modulo 2pi.
+
+ Parameters:
+
+ polar - A instance.
+
+ Returns:
+
+ The changed object.
+ */
+ $madd: function(polar) {
+ this.theta = (this.theta + polar.theta) % (Math.PI * 2); this.rho += polar.rho;
+ return this;
+ },
+
+
+ /*
+ Method: $scale
+
+ Scales a polar instance affecting the object.
+
+ Parameters:
+
+ number - A scaling factor.
+
+ Returns:
+
+ The changed object.
+ */
+ $scale: function(number) {
+ this.rho *= number;
+ return this;
+ },
+
+ /*
+ Method: interpolate
+
+ Calculates a polar interpolation between two points at a given delta moment.
+
+ Parameters:
+
+ elem - A instance.
+ delta - A delta factor ranging [0, 1].
+
+ Returns:
+
+ A new instance representing an interpolation between _this_ and _elem_
+ */
+ interpolate: function(elem, delta) {
+ var pi = Math.PI, pi2 = pi * 2;
+ var ch = function(t) {
+ return (t < 0)? (t % pi2) + pi2 : t % pi2;
+ };
+ var tt = this.theta, et = elem.theta;
+ var sum;
+ if(Math.abs(tt - et) > pi) {
+ if(tt > et) {
+ sum =ch((et + ((tt - pi2) - et) * delta)) ;
+ } else {
+ sum =ch((et - pi2 + (tt - (et - pi2)) * delta));
+ }
+ } else {
+ sum =ch((et + (tt - et) * delta)) ;
+ }
+ var r = (this.rho - elem.rho) * delta + elem.rho;
+ return {
+ 'theta': sum,
+ 'rho': r
+ };
+ }
+};
+
+
+var $P = function(a, b) { return new Polar(a, b); };
+
+Polar.KER = $P(0, 0);
+
+
+
+/*
+ * File: Complex.js
+ *
+ * Defines the class.
+ *
+ * Description:
+ *
+ * The class, just like the class, is used by the , and as a 2D point representation.
+ *
+ * See also:
+ *
+ *
+ *
+*/
+
+/*
+ Class: Complex
+
+ A multi-purpose Complex Class with common methods.
+
+ Description:
+
+ The class, just like the class, is used by the , and as a 2D point representation.
+
+ See also:
+
+
+
+ Parameters:
+
+ x - _optional_ A Complex number real part.
+ y - _optional_ A Complex number imaginary part.
+
+*/
+
+this.Complex = function(x, y) {
+ this.x = x;
+ this.y = y;
+};
+
+Complex.prototype = {
+ /*
+ Method: getc
+
+ Returns a complex number.
+
+ Returns:
+
+ A complex number.
+ */
+ getc: function() {
+ return this;
+ },
+
+ /*
+ Method: getp
+
+ Returns a representation of this number.
+
+ Parameters:
+
+ simple - _optional_ If *true*, this method will return only an object holding theta and rho properties and not a instance. Default's *false*.
+
+ Returns:
+
+ A variable in coordinates.
+ */
+ getp: function(simple) {
+ return this.toPolar(simple);
+ },
+
+
+ /*
+ Method: set
+
+ Sets a number.
+
+ Parameters:
+
+ c - A or instance.
+
+ */
+ set: function(c) {
+ c = c.getc(true);
+ this.x = c.x;
+ this.y = c.y;
+ },
+
+ /*
+ Method: setc
+
+ Sets a complex number.
+
+ Parameters:
+
+ x - A number Real part.
+ y - A number Imaginary part.
+
+ */
+ setc: function(x, y) {
+ this.x = x;
+ this.y = y;
+ },
+
+ /*
+ Method: setp
+
+ Sets a polar number.
+
+ Parameters:
+
+ theta - A number theta property.
+ rho - A number rho property.
+
+ */
+ setp: function(theta, rho) {
+ this.x = Math.cos(theta) * rho;
+ this.y = Math.sin(theta) * rho;
+ },
+
+ /*
+ Method: clone
+
+ Returns a copy of the current object.
+
+ Returns:
+
+ A copy of the real object.
+ */
+ clone: function() {
+ return new Complex(this.x, this.y);
+ },
+
+ /*
+ Method: toPolar
+
+ Transforms cartesian to polar coordinates.
+
+ Parameters:
+
+ simple - _optional_ If *true* this method will only return an object with theta and rho properties (and not the whole instance). Default's *false*.
+
+ Returns:
+
+ A new instance.
+ */
+
+ toPolar: function(simple) {
+ var rho = this.norm();
+ var atan = Math.atan2(this.y, this.x);
+ if(atan < 0) atan += Math.PI * 2;
+ if(simple) return { 'theta': atan, 'rho': rho };
+ return new Polar(atan, rho);
+ },
+ /*
+ Method: norm
+
+ Calculates a number norm.
+
+ Returns:
+
+ A real number representing the complex norm.
+ */
+ norm: function () {
+ return Math.sqrt(this.squaredNorm());
+ },
+
+ /*
+ Method: squaredNorm
+
+ Calculates a number squared norm.
+
+ Returns:
+
+ A real number representing the complex squared norm.
+ */
+ squaredNorm: function () {
+ return this.x*this.x + this.y*this.y;
+ },
+
+ /*
+ Method: add
+
+ Returns the result of adding two complex numbers.
+
+ Does not alter the original object.
+
+ Parameters:
+
+ pos - A instance.
+
+ Returns:
+
+ The result of adding two complex numbers.
+ */
+ add: function(pos) {
+ return new Complex(this.x + pos.x, this.y + pos.y);
+ },
+
+ /*
+ Method: prod
+
+ Returns the result of multiplying two numbers.
+
+ Does not alter the original object.
+
+ Parameters:
+
+ pos - A instance.
+
+ Returns:
+
+ The result of multiplying two complex numbers.
+ */
+ prod: function(pos) {
+ return new Complex(this.x*pos.x - this.y*pos.y, this.y*pos.x + this.x*pos.y);
+ },
+
+ /*
+ Method: conjugate
+
+ Returns the conjugate of this number.
+
+ Does not alter the original object.
+
+ Returns:
+
+ The conjugate of this number.
+ */
+ conjugate: function() {
+ return new Complex(this.x, -this.y);
+ },
+
+
+ /*
+ Method: scale
+
+ Returns the result of scaling a instance.
+
+ Does not alter the original object.
+
+ Parameters:
+
+ factor - A scale factor.
+
+ Returns:
+
+ The result of scaling this complex to a factor.
+ */
+ scale: function(factor) {
+ return new Complex(this.x * factor, this.y * factor);
+ },
+
+ /*
+ Method: equals
+
+ Comparison method.
+
+ Returns *true* if both real and imaginary parts are equal.
+
+ Parameters:
+
+ c - A instance.
+
+ Returns:
+
+ A boolean instance indicating if both numbers are equal.
+ */
+ equals: function(c) {
+ return this.x == c.x && this.y == c.y;
+ },
+
+ /*
+ Method: $add
+
+ Returns the result of adding two numbers.
+
+ Alters the original object.
+
+ Parameters:
+
+ pos - A instance.
+
+ Returns:
+
+ The result of adding two complex numbers.
+ */
+ $add: function(pos) {
+ this.x += pos.x; this.y += pos.y;
+ return this;
+ },
+
+ /*
+ Method: $prod
+
+ Returns the result of multiplying two numbers.
+
+ Alters the original object.
+
+ Parameters:
+
+ pos - A instance.
+
+ Returns:
+
+ The result of multiplying two complex numbers.
+ */
+ $prod:function(pos) {
+ var x = this.x, y = this.y;
+ this.x = x*pos.x - y*pos.y;
+ this.y = y*pos.x + x*pos.y;
+ return this;
+ },
+
+ /*
+ Method: $conjugate
+
+ Returns the conjugate for this .
+
+ Alters the original object.
+
+ Returns:
+
+ The conjugate for this complex.
+ */
+ $conjugate: function() {
+ this.y = -this.y;
+ return this;
+ },
+
+ /*
+ Method: $scale
+
+ Returns the result of scaling a instance.
+
+ Alters the original object.
+
+ Parameters:
+
+ factor - A scale factor.
+
+ Returns:
+
+ The result of scaling this complex to a factor.
+ */
+ $scale: function(factor) {
+ this.x *= factor; this.y *= factor;
+ return this;
+ },
+
+ /*
+ Method: $div
+
+ Returns the division of two numbers.
+
+ Alters the original object.
+
+ Parameters:
+
+ pos - A number.
+
+ Returns:
+
+ The result of scaling this complex to a factor.
+ */
+ $div: function(pos) {
+ var x = this.x, y = this.y;
+ var sq = pos.squaredNorm();
+ this.x = x * pos.x + y * pos.y; this.y = y * pos.x - x * pos.y;
+ return this.$scale(1 / sq);
+ }
+};
+
+var $C = function(a, b) { return new Complex(a, b); };
+
+Complex.KER = $C(0, 0);
+
+
+
+/*
+ * File: Graph.js
+ *
+ * Generic , and classes.
+ *
+ * Used by:
+ *
+ * , and .
+ *
+*/
+
+/*
+ Class: Graph
+
+ A generic Graph class.
+
+ Description:
+
+ When a json graph/tree structure is loaded by , an internal representation is created.
+
+ In most cases you'll be dealing with an already created structure, so methods like or won't
+ be of many use. However methods like and are pretty useful.
+
+ provides also iterators for and advanced and useful graph operations and methods.
+
+ Used by:
+
+ , , and .
+
+ Access:
+
+ An instance of this class can be accessed by using the _graph_ parameter of a , or instance
+
+ Example:
+
+ (start code js)
+ var st = new ST(canvas, config);
+ st.graph.getNode //or any other method.
+
+ var ht = new Hypertree(canvas, config);
+ ht.graph.getNode //or any other method.
+
+ var rg = new RGraph(canvas, config);
+ rg.graph.getNode //or any other method.
+ (end code)
+
+*/
+
+this.Graph = new Class({
+
+ initialize: function(opt) {
+ var innerOptions = {
+ 'complex': false,
+ 'Node': {}
+ };
+ this.opt = $merge(innerOptions, opt || {});
+ this.nodes= {};
+ },
+
+/*
+ Method: getNode
+
+ Returns a by _id_.
+
+ Parameters:
+
+ id - A id.
+
+ Returns:
+
+ A having _id_ as id. Returns *false* otherwise.
+
+ Example:
+
+ (start code js)
+ var node = graph.getNode('someid');
+ (end code)
+*/
+ getNode: function(id) {
+ if(this.hasNode(id)) return this.nodes[id];
+ return false;
+ },
+
+/*
+ Method: getAdjacence
+
+ Returns an array of objects connecting nodes with ids _id_ and _id2_.
+
+ Parameters:
+
+ id - A id.
+ id2 - A id.
+
+ Returns:
+
+ An Array of objects. Returns *false* if there's not a connecting those two nodes.
+*/
+ getAdjacence: function (id, id2) {
+ var adjs = [];
+ if(this.hasNode(id) && this.hasNode(id2)
+ && this.nodes[id].adjacentTo({ 'id':id2 }) && this.nodes[id2].adjacentTo({ 'id':id })) {
+ adjs.push(this.nodes[id].getAdjacency(id2));
+ adjs.push(this.nodes[id2].getAdjacency(id));
+ return adjs;
+ }
+ return false;
+ },
+
+ /*
+ Method: addNode
+
+ Adds a node.
+
+ Parameters:
+
+ obj - An object containing as properties
+
+ - _id_ node's id
+ - _name_ node's name
+ - _data_ node's data hash
+
+ See also:
+
+
+ */
+ addNode: function(obj) {
+ if(!this.nodes[obj.id]) {
+ this.nodes[obj.id] = new Graph.Node($extend({
+ 'id': obj.id,
+ 'name': obj.name,
+ 'data': obj.data
+ }, this.opt.Node), this.opt.complex);
+ }
+ return this.nodes[obj.id];
+ },
+
+ /*
+ Method: addAdjacence
+
+ Connects nodes specified by _obj_ and _obj2_. If not found, nodes are created.
+
+ Parameters:
+
+ obj - a object.
+ obj2 - Another object.
+ data - A DataSet object. Used to store some extra information in the object created.
+
+ See also:
+
+ ,
+ */
+ addAdjacence: function (obj, obj2, data) {
+ var adjs = [];
+ if(!this.hasNode(obj.id)) { this.addNode(obj); }
+ if(!this.hasNode(obj2.id)) { this.addNode(obj2); }
+ obj = this.nodes[obj.id]; obj2 = this.nodes[obj2.id];
+
+ for(var i in this.nodes) {
+ if(this.nodes[i].id == obj.id) {
+ if(!this.nodes[i].adjacentTo(obj2)) {
+ adjs.push(this.nodes[i].addAdjacency(obj2, data));
+ }
+ }
+
+ if(this.nodes[i].id == obj2.id) {
+ if(!this.nodes[i].adjacentTo(obj)) {
+ adjs.push(this.nodes[i].addAdjacency(obj, data));
+ }
+ }
+ }
+ return adjs;
+ },
+
+ /*
+ Method: removeNode
+
+ Removes a matching the specified _id_.
+
+ Parameters:
+
+ id - A node's id.
+
+ */
+ removeNode: function(id) {
+ if(this.hasNode(id)) {
+ var node = this.nodes[id];
+ for(var i=0 in node.adjacencies) {
+ var adj = node.adjacencies[i];
+ this.removeAdjacence(id, adj.nodeTo.id);
+ }
+ delete this.nodes[id];
+ }
+ },
+
+/*
+ Method: removeAdjacence
+
+ Removes a matching _id1_ and _id2_.
+
+ Parameters:
+
+ id1 - A id.
+ id2 - A id.
+*/
+ removeAdjacence: function(id1, id2) {
+ if(this.hasNode(id1)) this.nodes[id1].removeAdjacency(id2);
+ if(this.hasNode(id2)) this.nodes[id2].removeAdjacency(id1);
+ },
+
+ /*
+ Method: hasNode
+
+ Returns a Boolean instance indicating if the node belongs to the or not.
+
+ Parameters:
+
+ id - Node id.
+
+ Returns:
+
+ A Boolean instance indicating if the node belongs to the graph or not.
+ */
+ hasNode: function(id) {
+ return id in this.nodes;
+ }
+});
+
+/*
+ Class: Graph.Node
+
+ A node.
+
+ Parameters:
+
+ obj - An object containing an 'id', 'name' and 'data' properties as described in .
+ complex - Whether node position properties should contain or instances.
+
+ See also:
+
+
+
+ Description:
+
+ An instance of is usually passed as parameter for most configuration/controller methods in the
+ , and classes.
+
+ A object has as properties
+
+ id - Node id.
+ name - Node name.
+ data - Node data property containing a hash (i.e {}) with custom options. For more information see .
+ selected - Whether the node is selected or not. Used by for selecting nodes that are between the root node and the selected node.
+ angleSpan - For radial layouts such as the ones performed by the and the . Contains _begin_ and _end_ properties containing angle values describing the angle span for this subtree.
+ alpha - Current opacity value.
+ startAlpha - Opacity begin value. Used for interpolation.
+ endAlpha - Opacity end value. Used for interpolation.
+ pos - Current position. Can be a or instance.
+ startPos - Starting position. Used for interpolation.
+ endPos - Ending position. Used for interpolation.
+*/
+Graph.Node = new Class({
+
+ initialize: function(opt, complex) {
+ var innerOptions = {
+ 'id': '',
+ 'name': '',
+ 'data': {},
+ 'adjacencies': {},
+
+ 'selected': false,
+ 'drawn': false,
+ 'exist': false,
+
+ 'angleSpan': {
+ 'begin': 0,
+ 'end' : 0
+ },
+
+ 'alpha': 1,
+ 'startAlpha': 1,
+ 'endAlpha': 1,
+
+ 'pos': (complex && $C(0, 0)) || $P(0, 0),
+ 'startPos': (complex && $C(0, 0)) || $P(0, 0),
+ 'endPos': (complex && $C(0, 0)) || $P(0, 0)
+ };
+
+ $extend(this, $extend(innerOptions, opt));
+ },
+
+ /*
+ Method: adjacentTo
+
+ Indicates if the node is adjacent to the node specified by id
+
+ Parameters:
+
+ id - A node id.
+
+ Returns:
+
+ A Boolean instance indicating whether this node is adjacent to the specified by id or not.
+
+ Example:
+ (start code js)
+ node.adjacentTo('mynodeid');
+ (end code)
+ */
+ adjacentTo: function(node) {
+ return node.id in this.adjacencies;
+ },
+
+ /*
+ Method: getAdjacency
+
+ Returns a object connecting the current and the node having _id_ as id.
+
+ Parameters:
+
+ id - A node id.
+
+ Returns:
+
+ A object or undefined.
+ */
+ getAdjacency: function(id) {
+ return this.adjacencies[id];
+ },
+ /*
+ Method: addAdjacency
+
+ Connects the current node and the given node.
+
+ Parameters:
+
+ node - A .
+ data - Some custom hash information.
+ */
+ addAdjacency: function(node, data) {
+ var adj = new Graph.Adjacence(this, node, data);
+ return this.adjacencies[node.id] = adj;
+ },
+
+ /*
+ Method: removeAdjacency
+
+ Removes a by _id_.
+
+ Parameters:
+
+ id - A node id.
+ */
+ removeAdjacency: function(id) {
+ delete this.adjacencies[id];
+ }
+});
+
+/*
+ Class: Graph.Adjacence
+
+ A adjacence (or edge). Connects two .
+
+ Parameters:
+
+ nodeFrom - A .
+ nodeTo - A .
+ data - Some custom hash data.
+
+ See also:
+
+
+
+ Description:
+
+ An instance of is usually passed as parameter for some configuration/controller methods in the
+ , and classes.
+
+ A object has as properties
+
+ nodeFrom - A connected by this edge.
+ nodeTo - Another connected by this edge.
+ data - Node data property containing a hash (i.e {}) with custom options. For more information see .
+ alpha - Current opacity value.
+ startAlpha - Opacity begin value. Used for interpolation.
+ endAlpha - Opacity end value. Used for interpolation.
+*/
+Graph.Adjacence = function(nodeFrom, nodeTo, data) {
+ this.nodeFrom = nodeFrom;
+ this.nodeTo = nodeTo;
+ this.data = data || {};
+ this.alpha = 1;
+ this.startAlpha = 1;
+ this.endAlpha = 1;
+};
+
+/*
+ Object: Graph.Util
+
+ traversal and processing utility object.
+*/
+Graph.Util = {
+ /*
+ filter
+
+ For internal use only. Provides a filtering function based on flags.
+ */
+ filter: function(param) {
+ if(!param || !($type(param) == 'string')) return function() { return true; };
+ var props = param.split(" ");
+ return function(elem) {
+ for(var i=0; i by _id_.
+
+ Parameters:
+
+ graph - A instance.
+ id - A id.
+
+ Returns:
+
+ A node.
+
+ Example:
+
+ (start code js)
+ Graph.Util.getNode(graph, 'nodeid');
+ (end code)
+ */
+ getNode: function(graph, id) {
+ return graph.getNode(id);
+ },
+
+ /*
+ Method: eachNode
+
+ Iterates over nodes performing an _action_.
+
+ Parameters:
+
+ graph - A instance.
+ action - A callback function having a as first formal parameter.
+
+ Example:
+ (start code js)
+ Graph.Util.each(graph, function(node) {
+ alert(node.name);
+ });
+ (end code)
+ */
+ eachNode: function(graph, action, flags) {
+ var filter = this.filter(flags);
+ for(var i in graph.nodes) {
+ if(filter(graph.nodes[i])) action(graph.nodes[i]);
+ }
+ },
+
+ /*
+ Method: eachAdjacency
+
+ Iterates over adjacencies applying the _action_ function.
+
+ Parameters:
+
+ node - A .
+ action - A callback function having as first formal parameter.
+
+ Example:
+ (start code js)
+ Graph.Util.eachAdjacency(node, function(adj) {
+ alert(adj.nodeTo.name);
+ });
+ (end code)
+ */
+ eachAdjacency: function(node, action, flags) {
+ var adj = node.adjacencies, filter = this.filter(flags);
+ for(var id in adj) {
+ if(filter(adj[id])) {
+ action(adj[id], id);
+ }
+ }
+ },
+
+ /*
+ Method: computeLevels
+
+ Performs a BFS traversal setting the correct depth for each node.
+
+ The depth of each node can then be accessed by
+ >node._depth
+
+ Parameters:
+
+ graph - A .
+ id - A starting node id for the BFS traversal.
+ startDepth - _optional_ A minimum depth value. Default's 0.
+
+ */
+ computeLevels: function(graph, id, startDepth, flags) {
+ startDepth = startDepth || 0;
+ var filter = this.filter(flags);
+ this.eachNode(graph, function(elem) {
+ elem._flag = false;
+ elem._depth = -1;
+ }, flags);
+ var root = graph.getNode(id);
+ root._depth = startDepth;
+ var queue = [root];
+ while(queue.length != 0) {
+ var node = queue.pop();
+ node._flag = true;
+ this.eachAdjacency(node, function(adj) {
+ var n = adj.nodeTo;
+ if(n._flag == false && filter(n)) {
+ if(n._depth < 0) n._depth = node._depth + 1 + startDepth;
+ queue.unshift(n);
+ }
+ }, flags);
+ }
+ },
+
+ /*
+ Method: eachBFS
+
+ Performs a BFS traversal applying _action_ to each .
+
+ Parameters:
+
+ graph - A .
+ id - A starting node id for the BFS traversal.
+ action - A callback function having a as first formal parameter.
+
+ Example:
+ (start code js)
+ Graph.Util.eachBFS(graph, 'mynodeid', function(node) {
+ alert(node.name);
+ });
+ (end code)
+ */
+ eachBFS: function(graph, id, action, flags) {
+ var filter = this.filter(flags);
+ this.clean(graph);
+ var queue = [graph.getNode(id)];
+ while(queue.length != 0) {
+ var node = queue.pop();
+ node._flag = true;
+ action(node, node._depth);
+ this.eachAdjacency(node, function(adj) {
+ var n = adj.nodeTo;
+ if(n._flag == false && filter(n)) {
+ n._flag = true;
+ queue.unshift(n);
+ }
+ }, flags);
+ }
+ },
+
+ /*
+ Method: eachLevel
+
+ Iterates over a node's subgraph applying _action_ to the nodes of relative depth between _levelBegin_ and _levelEnd_.
+
+ Parameters:
+
+ node - A .
+ levelBegin - A relative level value.
+ levelEnd - A relative level value.
+ action - A callback function having a as first formal parameter.
+
+ */
+ eachLevel: function(node, levelBegin, levelEnd, action, flags) {
+ var d = node._depth, filter = this.filter(flags), that = this;
+ levelEnd = levelEnd === false? Number.MAX_VALUE -d : levelEnd;
+ (function loopLevel(node, levelBegin, levelEnd) {
+ var d = node._depth;
+ if(d >= levelBegin && d <= levelEnd && filter(node)) action(node, d);
+ if(d < levelEnd) {
+ that.eachAdjacency(node, function(adj) {
+ var n = adj.nodeTo;
+ if(n._depth > d) loopLevel(n, levelBegin, levelEnd);
+ });
+ }
+ })(node, levelBegin + d, levelEnd + d);
+ },
+
+ /*
+ Method: eachSubgraph
+
+ Iterates over a node's children recursively.
+
+ Parameters:
+ node - A .
+ action - A callback function having a as first formal parameter.
+
+ Example:
+ (start code js)
+ Graph.Util.eachSubgraph(node, function(node) {
+ alert(node.name);
+ });
+ (end code)
+ */
+ eachSubgraph: function(node, action, flags) {
+ this.eachLevel(node, 0, false, action, flags);
+ },
+
+ /*
+ Method: eachSubnode
+
+ Iterates over a node's children (without deeper recursion).
+
+ Parameters:
+ node - A .
+ action - A callback function having a as first formal parameter.
+
+ Example:
+ (start code js)
+ Graph.Util.eachSubnode(node, function(node) {
+ alert(node.name);
+ });
+ (end code)
+ */
+ eachSubnode: function(node, action, flags) {
+ this.eachLevel(node, 1, 1, action, flags);
+ },
+
+ /*
+ Method: anySubnode
+
+ Returns *true* if any subnode matches the given condition.
+
+ Parameters:
+ node - A .
+ cond - A callback function returning a Boolean instance. This function has as first formal parameter a .
+
+ Returns:
+ A boolean value.
+
+ Example:
+ (start code js)
+ Graph.Util.anySubnode(node, function(node) { return node.name == "mynodename"; });
+ (end code)
+ */
+ anySubnode: function(node, cond, flags) {
+ var flag = false;
+ cond = cond || $lambda(true);
+ var c = $type(cond) == 'string'? function(n) { return n[cond]; } : cond;
+ this.eachSubnode(node, function(elem) {
+ if(c(elem)) flag = true;
+ }, flags);
+ return flag;
+ },
+
+ /*
+ Method: getSubnodes
+
+ Collects all subnodes for a specified node. The _level_ parameter filters nodes having relative depth of _level_ from the root node.
+
+ Parameters:
+ node - A .
+ level - _optional_ A starting relative depth for collecting nodes. Default's 0.
+
+ Returns:
+ An array of nodes.
+
+ */
+ getSubnodes: function(node, level, flags) {
+ var ans = [], that = this;
+ level = level || 0;
+ var levelStart, levelEnd;
+ if($type(level) == 'array') {
+ levelStart = level[0];
+ levelEnd = level[1];
+ } else {
+ levelStart = level;
+ levelEnd = Number.MAX_VALUE - node._depth;
+ }
+ this.eachLevel(node, levelStart, levelEnd, function(n) {
+ ans.push(n);
+ }, flags);
+ return ans;
+ },
+
+
+ /*
+ Method: getParents
+
+ Returns an Array of wich are parents of the given node.
+
+ Parameters:
+ node - A .
+
+ Returns:
+ An Array of .
+
+ Example:
+ (start code js)
+ var pars = Graph.Util.getParents(node);
+ if(pars.length > 0) {
+ //do stuff with parents
+ }
+ (end code)
+ */
+ getParents: function(node) {
+ var ans = [];
+ this.eachAdjacency(node, function(adj) {
+ var n = adj.nodeTo;
+ if(n._depth < node._depth) ans.push(n);
+ });
+ return ans;
+ },
+
+ /*
+ Method: isDescendantOf
+
+ Returns a Boolean instance indicating if some node is descendant of the node with the given id.
+
+ Parameters:
+ node - A .
+ id - A id.
+
+ Returns:
+ Ture if _node_ is descendant of the node with the given _id_. False otherwise.
+
+ Example:
+ (start code js)
+ var pars = Graph.Util.isDescendantOf(node, "nodeid");
+ (end code)
+ */
+ isDescendantOf: function(node, id) {
+ if(node.id == id) return true;
+ var pars = this.getParents(node), ans = false;
+ for ( var i = 0; !ans && i < pars.length; i++) {
+ ans = ans || this.isDescendantOf(pars[i], id);
+ }
+ return ans;
+ },
+
+ /*
+ Method: clean
+
+ Cleans flags from nodes (by setting the _flag_ property to false).
+
+ Parameters:
+ graph - A instance.
+ */
+ clean: function(graph) { this.eachNode(graph, function(elem) { elem._flag = false; }); }
+};
+
+
+
+/*
+ * File: Graph.Op.js
+ *
+ * Defines an abstract class for performing Operations.
+*/
+
+/*
+ Object: Graph.Op
+
+ Generic Operations.
+
+ Description:
+
+ An abstract class holding unary and binary powerful graph operations such as removingNodes, removingEdges, adding two graphs and morphing.
+
+ Implemented by:
+
+ , and .
+
+ Access:
+
+ The subclasses for this abstract class can be accessed by using the _op_ property of the , or instances created.
+
+ See also:
+
+ , , , , , , .
+*/
+Graph.Op = {
+
+ options: {
+ type: 'nothing',
+ duration: 2000,
+ hideLabels: true,
+ fps:30
+ },
+
+ /*
+ Method: removeNode
+
+ Removes one or more from the visualization.
+ It can also perform several animations like fading sequentially, fading concurrently, iterating or replotting.
+
+ Parameters:
+
+ node - The node's id. Can also be an array having many ids.
+ opt - Animation options. It's an object with optional properties
+
+ - _type_ Type of the animation. Can be "nothing", "replot", "fade:seq", "fade:con" or "iter". Default's "nothing".
+ - _duration_ Duration of the animation in milliseconds. Default's 2000.
+ - _fps_ Frames per second for the animation. Default's 30.
+ - _hideLabels_ Hide labels during the animation. Default's *true*.
+ - _transition_ Transitions defined in the class. Default's the default transition option of the
+ , or instance created.
+
+ Example:
+ (start code js)
+ var rg = new RGraph(canvas, config); //could be new ST or new Hypertree also.
+ rg.op.removeNode('nodeid', {
+ type: 'fade:seq',
+ duration: 1000,
+ hideLabels: false,
+ transition: Trans.Quart.easeOut
+ });
+ //or also
+ rg.op.removeNode(['someid', 'otherid'], {
+ type: 'fade:con',
+ duration: 1500
+ });
+ (end code)
+ */
+
+ removeNode: function(node, opt) {
+ var viz = this.viz;
+ var options = $merge(this.options, viz.controller, opt);
+ var n = $splat(node);
+ var i, that, nodeObj;
+ switch(options.type) {
+ case 'nothing':
+ for(i=0; i class. Default's the default transition option of the
+ , or instance created.
+
+ Example:
+ (start code js)
+ var rg = new RGraph(canvas, config); //could be new ST or new Hypertree also.
+ rg.op.removeEdge(['nodeid', 'otherid'], {
+ type: 'fade:seq',
+ duration: 1000,
+ hideLabels: false,
+ transition: Trans.Quart.easeOut
+ });
+ //or also
+ rg.op.removeEdge([['someid', 'otherid'], ['id3', 'id4']], {
+ type: 'fade:con',
+ duration: 1500
+ });
+ (end code)
+
+ */
+ removeEdge: function(vertex, opt) {
+ var viz = this.viz;
+ var options = $merge(this.options, viz.controller, opt);
+ var v = ($type(vertex[0]) == 'string')? [vertex] : vertex;
+ var i, that, adjs;
+ switch(options.type) {
+ case 'nothing':
+ for(i=0; i
+
+ Parameters:
+
+ json - A json tree or graph structure. See also .
+ opt - Animation options. It's an object with optional properties
+
+ - _type_ Type of the animation. Can be "nothing", "replot", "fade:seq" or "fade:con". Default's "nothing".
+ - _duration_ Duration of the animation in milliseconds. Default's 2000.
+ - _fps_ Frames per second for the animation. Default's 30.
+ - _hideLabels_ Hide labels during the animation. Default's *true*.
+ - _transition_ Transitions defined in the class. Default's the default transition option of the
+ , or instance created.
+
+ Example:
+ (start code js)
+ //json contains a tree or graph structure.
+
+ var rg = new RGraph(canvas, config); //could be new ST or new Hypertree also.
+ rg.op.sum(json, {
+ type: 'fade:seq',
+ duration: 1000,
+ hideLabels: false,
+ transition: Trans.Quart.easeOut
+ });
+ //or also
+ rg.op.sum(json, {
+ type: 'fade:con',
+ duration: 1500
+ });
+ (end code)
+
+ */
+ sum: function(json, opt) {
+ var viz = this.viz;
+ var options = $merge(this.options, viz.controller, opt), root = viz.root;
+ var GUtil, graph;
+ viz.root = opt.id || viz.root;
+ switch(options.type) {
+ case 'nothing':
+ graph = viz.construct(json);
+ GUtil = Graph.Util;
+ GUtil.eachNode(graph, function(elem) {
+ GUtil.eachAdjacency(elem, function(adj) {
+ viz.graph.addAdjacence(adj.nodeFrom, adj.nodeTo, adj.data);
+ });
+ });
+ break;
+
+ case 'replot':
+ viz.refresh(true);
+ this.sum(json, { type: 'nothing' });
+ viz.refresh(true);
+ break;
+
+ case 'fade:seq': case 'fade': case 'fade:con':
+ GUtil = Graph.Util;
+ that = this;
+ graph = viz.construct(json);
+
+ //set alpha to 0 for nodes to add.
+ var fadeEdges = this.preprocessSum(graph);
+ var modes = !fadeEdges? ['fade:nodes'] : ['fade:nodes', 'fade:vertex'];
+ viz.reposition();
+ if(options.type != 'fade:con') {
+ viz.fx.animate($merge(options, {
+ modes: ['linear'],
+ onComplete: function() {
+ viz.fx.animate($merge(options, {
+ modes: modes,
+ onComplete: function() {
+ options.onComplete();
+ }
+ }));
+ }
+ }));
+ } else {
+ GUtil.eachNode(viz.graph, function(elem) {
+ if (elem.id != root && elem.pos.getp().equals(Polar.KER)) {
+ elem.pos.set(elem.endPos); elem.startPos.set(elem.endPos);
+ }
+ });
+ viz.fx.animate($merge(options, {
+ modes: ['linear'].concat(modes)
+ }));
+ }
+ break;
+
+ default: this.doError();
+ }
+ },
+
+ /*
+ Method: morph
+
+ This method will _morph_ the current visualized graph into the new _json_ representation passed in the method.
+
+ Can also perform multiple animations. The _json_ object must at least have the root node in common with the current visualized graph.
+
+ Parameters:
+
+ json - A json tree or graph structure. See also .
+ opt - Animation options. It's an object with optional properties
+
+ - _type_ Type of the animation. Can be "nothing", "replot", or "fade". Default's "nothing".
+ - _duration_ Duration of the animation in milliseconds. Default's 2000.
+ - _fps_ Frames per second for the animation. Default's 30.
+ - _hideLabels_ Hide labels during the animation. Default's *true*.
+ - _transition_ Transitions defined in the class. Default's the default transition option of the
+ , or instance created.
+
+ Example:
+ (start code js)
+ //json contains a tree or graph structure.
+
+ var rg = new RGraph(canvas, config); //could be new ST or new Hypertree also.
+ rg.op.morph(json, {
+ type: 'fade',
+ duration: 1000,
+ hideLabels: false,
+ transition: Trans.Quart.easeOut
+ });
+ //or also
+ rg.op.morph(json, {
+ type: 'fade',
+ duration: 1500
+ });
+ (end code)
+
+ */
+ morph: function(json, opt) {
+ var viz = this.viz;
+ var options = $merge(this.options, viz.controller, opt), root = viz.root;
+ var GUtil, graph;
+ viz.root = opt.id || viz.root;
+ switch(options.type) {
+ case 'nothing':
+ graph = viz.construct(json);
+ GUtil = Graph.Util;
+ GUtil.eachNode(graph, function(elem) {
+ GUtil.eachAdjacency(elem, function(adj) {
+ viz.graph.addAdjacence(adj.nodeFrom, adj.nodeTo, adj.data);
+ });
+ });
+ GUtil.eachNode(viz.graph, function(elem) {
+ GUtil.eachAdjacency(elem, function(adj) {
+ if(!graph.getAdjacence(adj.nodeFrom.id, adj.nodeTo.id)) {
+ viz.graph.removeAdjacence(adj.nodeFrom.id, adj.nodeTo.id);
+ }
+ });
+ if(!graph.hasNode(elem.id)) viz.graph.removeNode(elem.id);
+ });
+
+ break;
+
+ case 'replot':
+ viz.fx.clearLabels(true);
+ this.morph(json, { type: 'nothing' });
+ viz.refresh(true);
+ viz.refresh(true);
+ break;
+
+ case 'fade:seq': case 'fade': case 'fade:con':
+ GUtil = Graph.Util;
+ that = this;
+ graph = viz.construct(json);
+ //preprocessing for adding nodes.
+ var fadeEdges = this.preprocessSum(graph);
+ //preprocessing for nodes to delete.
+ GUtil.eachNode(viz.graph, function(elem) {
+ if(!graph.hasNode(elem.id)) {
+ elem.alpha = 1; elem.startAlpha = 1; elem.endAlpha = 0; elem.ignore = true;
+ }
+ });
+ GUtil.eachNode(viz.graph, function(elem) {
+ if(elem.ignore) return;
+ GUtil.eachAdjacency(elem, function(adj) {
+ if(adj.nodeFrom.ignore || adj.nodeTo.ignore) return;
+ var nodeFrom = graph.getNode(adj.nodeFrom.id);
+ var nodeTo = graph.getNode(adj.nodeTo.id);
+ if(!nodeFrom.adjacentTo(nodeTo)) {
+ var adjs = viz.graph.getAdjacence(nodeFrom.id, nodeTo.id);
+ fadeEdges = true;
+ adjs[0].alpha = 1; adjs[0].startAlpha = 1; adjs[0].endAlpha = 0; adjs[0].ignore = true;
+ adjs[1].alpha = 1; adjs[1].startAlpha = 1; adjs[1].endAlpha = 0; adjs[1].ignore = true;
+ }
+ });
+ });
+ var modes = !fadeEdges? ['fade:nodes'] : ['fade:nodes', 'fade:vertex'];
+ viz.reposition();
+ GUtil.eachNode(viz.graph, function(elem) {
+ if (elem.id != root && elem.pos.getp().equals(Polar.KER)) {
+ elem.pos.set(elem.endPos); elem.startPos.set(elem.endPos);
+ }
+ });
+ viz.fx.animate($merge(options, {
+ modes: ['polar'].concat(modes),
+ onComplete: function() {
+ GUtil.eachNode(viz.graph, function(elem) {
+ if(elem.ignore) viz.graph.removeNode(elem.id);
+ });
+ GUtil.eachNode(viz.graph, function(elem) {
+ GUtil.eachAdjacency(elem, function(adj) {
+ if(adj.ignore) viz.graph.removeAdjacence(adj.nodeFrom.id, adj.nodeTo.id);
+ });
+ });
+ options.onComplete();
+ }
+ }));
+ break;
+
+ default: this.doError();
+ }
+ },
+
+ preprocessSum: function(graph) {
+ var viz = this.viz;
+ var GUtil = Graph.Util;
+ GUtil.eachNode(graph, function(elem) {
+ if(!viz.graph.hasNode(elem.id)) {
+ viz.graph.addNode(elem);
+ var n = viz.graph.getNode(elem.id);
+ n.alpha = 0; n.startAlpha = 0; n.endAlpha = 1;
+ }
+ });
+ var fadeEdges = false;
+ GUtil.eachNode(graph, function(elem) {
+ GUtil.eachAdjacency(elem, function(adj) {
+ var nodeFrom = viz.graph.getNode(adj.nodeFrom.id);
+ var nodeTo = viz.graph.getNode(adj.nodeTo.id);
+ if(!nodeFrom.adjacentTo(nodeTo)) {
+ var adjs = viz.graph.addAdjacence(nodeFrom, nodeTo, adj.data);
+ if(nodeFrom.startAlpha == nodeFrom.endAlpha
+ && nodeTo.startAlpha == nodeTo.endAlpha) {
+ fadeEdges = true;
+ adjs[0].alpha = 0; adjs[0].startAlpha = 0; adjs[0].endAlpha = 1;
+ adjs[1].alpha = 0; adjs[1].startAlpha = 0; adjs[1].endAlpha = 1;
+ }
+ }
+ });
+ });
+ return fadeEdges;
+ }
+};
+
+
+
+/*
+ * File: Graph.Plot.js
+ *
+ * Defines an abstract class for performing rendering and animation.
+ *
+ */
+
+
+/*
+ Object: Graph.Plot
+
+ Generic rendering and animation methods.
+
+ Description:
+
+ An abstract class for plotting a generic graph structure.
+
+ Implemented by:
+
+ , , .
+
+ Access:
+
+ The subclasses for this abstract class can be accessed by using the _fx_ property of the , , or instances created.
+
+ See also:
+
+ , , ,