diff --git a/docs/developers.rst b/docs/developers.rst index d9f58aef70..327746601b 100644 --- a/docs/developers.rst +++ b/docs/developers.rst @@ -110,9 +110,7 @@ the instrumentation is in place and the page is loaded. The ``startTest`` funct be called with function as an argument that should be called when page is ready to run the unit tests. This is provided as a convenience for the default behavior of :py:func:`selenium_test.BaseTest.wait` with no arguments. Developers can -extend this behavior as necessary to provide more complicated use cases. As an -example, see the ``d3Animation`` test case which sets a custom variable in a callback -script for a test that is run asynchronously. +extend this behavior as necessary to provide more complicated use cases. The compiled version of these tests are placed inside the deployment root so the users can manually see the test diff --git a/docs/users.rst b/docs/users.rst index 73ed77ffbb..27eb270ade 100644 --- a/docs/users.rst +++ b/docs/users.rst @@ -215,11 +215,6 @@ documentation for each of the classes. `geo.jsonReader `_, which is an extendable geojson reader. -`geo.clock `_ - The clock object is attached to the map and is resposible for maintaining a user - definable concept of time. The clock can run, paused, and restarted. The - clock triggers events on the map to synchronize animations. - The API documentation is in the process of being updated. You can always find the latest version at `http://opengeoscience.github.io/geojs/apidocs/geo.html `_. diff --git a/src/clock.js b/examples/dynamicData/clock.js similarity index 94% rename from src/clock.js rename to examples/dynamicData/clock.js index 059f3898d3..9c6cbb1698 100644 --- a/src/clock.js +++ b/examples/dynamicData/clock.js @@ -1,6 +1,3 @@ -var inherit = require('./inherit'); -var object = require('./object'); - ////////////////////////////////////////////////////////////////////////////// /** * Stores the current time for a map, triggers time keeping events, and @@ -11,16 +8,14 @@ var object = require('./object'); * @returns {geo.clock} */ ////////////////////////////////////////////////////////////////////////////// -var clock = function (opts) { +geo.clock = function (opts) { 'use strict'; - if (!(this instanceof clock)) { - return new clock(opts); + if (!(this instanceof geo.clock)) { + return new geo.clock(opts); } + geo.object.call(this, opts); opts = opts || {}; - object.call(this, opts); - - var geo_event = require('./event'); ////////////////////////////////////////////////////////////////////////////// /** @@ -59,7 +54,7 @@ var clock = function (opts) { */ ////////////////////////////////////////////////////////////////////////////// this._attached = function () { - return (m_object instanceof object); + return (m_object instanceof geo.object); }; ////////////////////////////////////////////////////////////////////////////// @@ -76,7 +71,7 @@ var clock = function (opts) { if (m_now !== previous && m_this._attached()) { - m_this.object().geoTrigger(geo_event.clock.change, { + m_this.object().geoTrigger(geo.event.clock.change, { previous: previous, current: m_now, clock: m_this @@ -269,7 +264,7 @@ var clock = function (opts) { window.setTimeout(frame, 1000 / m_this.framerate()); } } else if (m_this._attached()) { - m_this.object().geoTrigger(geo_event.clock[m_this.state()], { + m_this.object().geoTrigger(geo.event.clock[m_this.state()], { current: m_this.now(), clock: m_this }); @@ -278,7 +273,7 @@ var clock = function (opts) { // trigger the play event if (m_this._attached()) { - m_this.object().geoTrigger(geo_event.clock.play, { + m_this.object().geoTrigger(geo.event.clock.play, { current: m_this.now(), clock: m_this }); @@ -291,7 +286,13 @@ var clock = function (opts) { window.setTimeout(frame, 1000 / m_this.framerate()); } }; + }; -inherit(clock, object); -module.exports = clock; +geo.inherit(geo.clock, geo.object); +geo.event.clock = { + play: 'geo_clock_play', + stop: 'geo_clock_stop', + pause: 'geo_clock_pause', + change: 'geo_clock_change' +}; diff --git a/examples/dynamicData/example.json b/examples/dynamicData/example.json index d0df2b278f..26db93dd66 100644 --- a/examples/dynamicData/example.json +++ b/examples/dynamicData/example.json @@ -2,7 +2,7 @@ "path": "dynamicData", "title": "Dynamic Data", "exampleCss": ["main.css"], - "exampleJs": ["main.js"], + "exampleJs": ["main.js", "clock.js"], "about": { "text": "Rendering data that changes with time." }, diff --git a/examples/dynamicData/main.js b/examples/dynamicData/main.js index 4954a4f85b..f45e2f62d1 100644 --- a/examples/dynamicData/main.js +++ b/examples/dynamicData/main.js @@ -6,9 +6,10 @@ $(function () { var map = geo.map({node: '#map', zoom: 3}); // Add and start a clock - var clock = map.clock(); + var clock = geo.clock(); var omega = 10000; + clock.object(map); clock.start(0) .step(1) .end(omega) diff --git a/src/event.js b/src/event.js index 2bc38bd036..1acec9a947 100644 --- a/src/event.js +++ b/src/event.js @@ -332,18 +332,6 @@ geo_event.transitioncancel = 'geo_transitioncancel'; ////////////////////////////////////////////////////////////////////////////// geo_event.parallelprojection = 'geo_parallelprojection'; -//////////////////////////////////////////////////////////////////////////// -/** - * @namespace - */ -//////////////////////////////////////////////////////////////////////////// -geo_event.clock = { - play: 'geo_clock_play', - stop: 'geo_clock_stop', - pause: 'geo_clock_pause', - change: 'geo_clock_change' -}; - //////////////////////////////////////////////////////////////////////////// /** * This event object provides mouse/keyboard events that can be handled diff --git a/src/index.js b/src/index.js index 99d7ee1ff5..dfc38e7ce6 100644 --- a/src/index.js +++ b/src/index.js @@ -35,7 +35,6 @@ module.exports = $.extend({ annotationLayer: require('./annotationLayer'), camera: require('./camera'), choroplethFeature: require('./choroplethFeature'), - clock: require('./clock'), contourFeature: require('./contourFeature'), domRenderer: require('./domRenderer'), event: require('./event'), diff --git a/src/map.js b/src/map.js index e4764faa5a..1eaa639815 100644 --- a/src/map.js +++ b/src/map.js @@ -56,7 +56,6 @@ var sceneObject = require('./sceneObject'); * *** Advanced parameters *** * @param {geo.camera?} camera The camera to control the view * @param {geo.mapInteractor?} interactor The UI event handler - * @param {geo.clock?} clock The clock used to synchronize time events * @param {array} [animationQueue] An array used to synchonize animations. If * specified, this should be an empty array or the same array as passed to * other map instances. @@ -91,7 +90,6 @@ var map = function (arg) { var registry = require('./registry'); var geo_event = require('./event'); var mapInteractor = require('./mapInteractor'); - var clock = require('./clock'); var uiLayer = require('./ui/uiLayer'); //////////////////////////////////////////////////////////////////////////// @@ -119,7 +117,6 @@ var map = function (arg) { m_validZoomRange = {min: 0, max: 16, origMin: 0}, m_transition = null, m_queuedTransition = null, - m_clock = null, m_discreteZoom = arg.discreteZoom ? true : false, m_allowRotation = (typeof arg.allowRotation === 'function' ? arg.allowRotation : (arg.allowRotation === undefined ? @@ -991,23 +988,6 @@ var map = function (arg) { return m_this; }; - //////////////////////////////////////////////////////////////////////////// - /** - * Get or set the map clock - */ - //////////////////////////////////////////////////////////////////////////// - this.clock = function (arg) { - if (arg === undefined) { - return m_clock; - } - m_clock = arg; - - if (m_clock) { - m_clock.object(m_this); - } - return m_this; - }; - //////////////////////////////////////////////////////////////////////////// /** * Get or set the min/max zoom range. @@ -1972,7 +1952,6 @@ var map = function (arg) { if (arg.interactor !== null) { this.interactor(arg.interactor || mapInteractor({discreteZoom: m_discreteZoom})); } - this.clock(arg.clock || clock()); function resizeSelf() { m_this.resize(0, 0, m_node.width(), m_node.height()); diff --git a/testing/test-cases/selenium-tests/d3Animation/include.css b/testing/test-cases/selenium-tests/d3Animation/include.css deleted file mode 100644 index 355579c9fd..0000000000 --- a/testing/test-cases/selenium-tests/d3Animation/include.css +++ /dev/null @@ -1,3 +0,0 @@ -body { - overflow: hidden; -} diff --git a/testing/test-cases/selenium-tests/d3Animation/include.html b/testing/test-cases/selenium-tests/d3Animation/include.html deleted file mode 100644 index f1756fd785..0000000000 --- a/testing/test-cases/selenium-tests/d3Animation/include.html +++ /dev/null @@ -1 +0,0 @@ -
diff --git a/testing/test-cases/selenium-tests/d3Animation/include.js b/testing/test-cases/selenium-tests/d3Animation/include.js deleted file mode 100644 index 13ed9e2a61..0000000000 --- a/testing/test-cases/selenium-tests/d3Animation/include.js +++ /dev/null @@ -1,63 +0,0 @@ -/*global window, geo*/ -window.startTest = function (done) { - "use strict"; - - var mapOptions = {center: {y: 40, x: -105}}, - myMap = window.geoTests.createOsmMap(mapOptions), - layer = myMap.createLayer("feature", {"renderer": "d3"}), - points = layer.createFeature("point"), - clock = myMap.clock(); - - function draw(data) { - - points - .data(data.slice(0, 10)) - .position(function (d) { return {x: d.lon, y: d.lat}; }) - .style({ - radius: 5, - fillColor: "red", - stroke: false - }) - .draw(); - - myMap.geoOn(geo.event.clock.change, function () { - var i = clock.now().valueOf(); - var latlng = data.slice(i, i + 10); - points.data(latlng).draw(); - }); - - clock.start(0).end(100).step(1).now(0); - - myMap.onIdle(done); - } - - window.geoTests.loadCitiesData(draw); - - window.animateForward = function (nFrames, done) { - var i; - for (i = 0; i < nFrames; i += 1) { - clock.stepForward(); - } - if (done) { - myMap.onIdle(done); - } - }; - - window.animateBackward = function (nFrames, done) { - var i; - for (i = 0; i < nFrames; i += 1) { - clock.stepBackward(); - } - if (done) { - myMap.onIdle(done); - } - }; - - window.animateToEnd = function (done) { - clock.loop(0); - clock.state("play"); - myMap.geoOn(geo.event.clock.stop, function () { - myMap.onIdle(done); - }); - }; -}; diff --git a/testing/test-cases/selenium-tests/d3Animation/testd3Animate.py b/testing/test-cases/selenium-tests/d3Animation/testd3Animate.py deleted file mode 100644 index 819e8f28c1..0000000000 --- a/testing/test-cases/selenium-tests/d3Animation/testd3Animate.py +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/env python - -import time - -from selenium_test import FirefoxTest, ChromeTest,\ - setUpModule, tearDownModule - - -class d3AnimationBase(object): - testCase = ('d3Animation',) - - def loadPage(self): - self.resizeWindow(640, 480) - self.loadURL('d3Animation/index.html') - self.wait() - self.resizeWindow(640, 480) - time.sleep(1) - - def testd3AnimateForward(self): - self.loadPage() - - testName = 'd3AnimateFrame15' - self.runScript( - ''' - window.animateForward(15, function () { - window.animateForwardFinished = true; - }); - ''' - ) - self.wait('window.animateForwardFinished') - self.screenshotTest(testName) - - def testd3AnimateBackward(self): - self.loadPage() - - testName = 'd3AnimateFrame75' - self.runScript('window.animateForward(80);') - self.runScript( - ''' - window.animateBackward(5, function () { - window.animateBackwardFinished = true; - }); - ''' - ) - self.wait('window.animateBackwardFinished') - self.screenshotTest(testName) - - def testd3AnimateToEnd(self): - self.loadPage() - - testName = 'd3AnimateEnd' - self.runScript( - '''window.animateToEnd(function () { - window.animationTestFinished = true; - }); - ''' - ) - self.wait('window.animationTestFinished') - self.screenshotTest(testName) - - -class FirefoxOSM(d3AnimationBase, FirefoxTest): - testCase = d3AnimationBase.testCase + ('firefox',) - testRevision = 11 - - -class ChromeOSM(d3AnimationBase, ChromeTest): - testCase = d3AnimationBase.testCase + ('chrome',) - testRevision = 12 - - -if __name__ == '__main__': - import unittest - unittest.main()