chukwa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ey...@apache.org
Subject svn commit: r770000 [5/11] - in /hadoop/chukwa: branches/chukwa-0.1/ branches/chukwa-0.1/src/web/hicc/jsp/ branches/chukwa-0.1/src/web/hicc/lib/ branches/chukwa-0.1/src/web/hicc/lib/timeline/ branches/chukwa-0.1/src/web/hicc/lib/timeline/ext/ branches/...
Date Wed, 29 Apr 2009 23:33:56 GMT
Added: hadoop/chukwa/branches/chukwa-0.1/src/web/hicc/lib/timeline/scripts/painters.js
URL: http://svn.apache.org/viewvc/hadoop/chukwa/branches/chukwa-0.1/src/web/hicc/lib/timeline/scripts/painters.js?rev=770000&view=auto
==============================================================================
--- hadoop/chukwa/branches/chukwa-0.1/src/web/hicc/lib/timeline/scripts/painters.js (added)
+++ hadoop/chukwa/branches/chukwa-0.1/src/web/hicc/lib/timeline/scripts/painters.js Wed Apr 29 23:33:50 2009
@@ -0,0 +1,334 @@
+/*==================================================
+ *  Duration Event Painter
+ *==================================================
+ */
+
+Timeline.DurationEventPainter = function(params) {
+    this._params = params;
+    this._theme = params.theme;
+    this._layout = params.layout;
+    
+    this._showText = params.showText;
+    this._showLineForNoText = ("showLineForNoText" in params) ? 
+        params.showLineForNoText : params.theme.event.instant.showLineForNoText;
+        
+    this._filterMatcher = null;
+    this._highlightMatcher = null;
+};
+
+Timeline.DurationEventPainter.prototype.initialize = function(band, timeline) {
+    this._band = band;
+    this._timeline = timeline;
+    this._layout.initialize(band, timeline);
+    
+    this._eventLayer = null;
+    this._highlightLayer = null;
+};
+
+Timeline.DurationEventPainter.prototype.getLayout = function() {
+    return this._layout;
+};
+
+Timeline.DurationEventPainter.prototype.setLayout = function(layout) {
+    this._layout = layout;
+};
+
+Timeline.DurationEventPainter.prototype.getFilterMatcher = function() {
+    return this._filterMatcher;
+};
+
+Timeline.DurationEventPainter.prototype.setFilterMatcher = function(filterMatcher) {
+    this._filterMatcher = filterMatcher;
+};
+
+Timeline.DurationEventPainter.prototype.getHighlightMatcher = function() {
+    return this._highlightMatcher;
+};
+
+Timeline.DurationEventPainter.prototype.setHighlightMatcher = function(highlightMatcher) {
+    this._highlightMatcher = highlightMatcher;
+};
+
+Timeline.DurationEventPainter.prototype.paint = function() {
+    var eventSource = this._band.getEventSource();
+    if (eventSource == null) {
+        return;
+    }
+    
+    if (this._highlightLayer != null) {
+        this._band.removeLayerDiv(this._highlightLayer);
+    }
+    this._highlightLayer = this._band.createLayerDiv(105);
+    this._highlightLayer.setAttribute("name", "event-highlights");
+    this._highlightLayer.style.display = "none";
+    
+    if (this._eventLayer != null) {
+        this._band.removeLayerDiv(this._eventLayer);
+    }
+    this._eventLayer = this._band.createLayerDiv(110);
+    this._eventLayer.setAttribute("name", "events");
+    this._eventLayer.style.display = "none";
+    
+    var minDate = this._band.getMinDate();
+    var maxDate = this._band.getMaxDate();
+    
+    var doc = this._timeline.getDocument();
+    
+    var p = this;
+    var eventLayer = this._eventLayer;
+    var highlightLayer = this._highlightLayer;
+    
+    var showText = this._showText;
+    var theme = this._params.theme;
+    var eventTheme = theme.event;
+    var trackOffset = eventTheme.track.offset;
+    var trackHeight = ("trackHeight" in this._params) ? this._params.trackHeight : eventTheme.track.height;
+    var trackGap = ("trackGap" in this._params) ? this._params.trackGap : eventTheme.track.gap;
+    
+    //if (this._timeline.isHorizontal()) {
+        var appendIcon = function(evt, div) {
+            var icon = evt.getIcon();
+            var img = Timeline.Graphics.createTranslucentImage(
+                doc, icon != null ? icon : eventTheme.instant.icon
+            );
+            div.appendChild(img);
+            div.style.cursor = "pointer";
+            
+            Timeline.DOM.registerEvent(div, "mousedown", function(elmt, domEvt, target) {
+                p._onClickInstantEvent(img, domEvt, evt);
+            });
+        };
+        var createHighlightDiv = function(highlightIndex, startPixel, length, highlightOffset, highlightWidth) {
+            if (highlightIndex >= 0) {
+                var color = eventTheme.highlightColors[Math.min(highlightIndex, eventTheme.highlightColors.length - 1)];
+                
+                var div = doc.createElement("div");
+                div.style.position = "absolute";
+                div.style.overflow = "hidden";
+                div.style.left = (startPixel - 3) + "px";
+                div.style.width = (length + 6) + "px";
+                div.style.top = highlightOffset + "em";
+                div.style.height = highlightWidth + "em";
+                div.style.background = color;
+                //Timeline.Graphics.setOpacity(div, 50);
+                
+                highlightLayer.appendChild(div);
+            }
+        };
+        
+        var createInstantDiv = function(evt, startPixel, endPixel, streamOffset, highlightIndex, highlightOffset, highlightWidth) {
+            if (evt.isImprecise()) { // imprecise time
+                var length = Math.max(endPixel - startPixel, 1);
+            
+                var divImprecise = doc.createElement("div");
+                divImprecise.style.position = "absolute";
+                divImprecise.style.overflow = "hidden";
+                
+                divImprecise.style.top = streamOffset;
+                divImprecise.style.height = trackHeight + "em";
+                divImprecise.style.left = startPixel + "px";
+                divImprecise.style.width = length + "px";
+                
+                divImprecise.style.background = eventTheme.instant.impreciseColor;
+                if (eventTheme.instant.impreciseOpacity < 100) {
+                    Timeline.Graphics.setOpacity(divImprecise, eventTheme.instant.impreciseOpacity);
+                }
+                
+                eventLayer.appendChild(divImprecise);
+            }
+            
+            var div = doc.createElement("div");
+            div.style.position = "absolute";
+            div.style.overflow = "hidden";
+            eventLayer.appendChild(div);
+            
+            var foreground = evt.getTextColor();
+            var background = evt.getColor();
+            
+            var realign = -8; // shift left so that icon is centered on startPixel
+            var length = 16;
+            if (showText) {
+                div.style.width = eventTheme.label.width + "px";
+                div.style.color = foreground != null ? foreground : eventTheme.label.outsideColor;
+                
+                appendIcon(evt, div);
+                div.appendChild(doc.createTextNode(evt.getText()));
+            } else {
+                if (p._showLineForNoText) {
+                    div.style.width = "1px";
+                    div.style.borderLeft = "1px solid " + (background != null ? background : eventTheme.instant.lineColor);
+                    realign = 0; // no shift
+                    length = 1;
+                } else {
+                    appendIcon(evt, div);
+                }
+            }
+            
+            div.style.top = streamOffset;
+            div.style.height = trackHeight + "em";
+            div.style.left = (startPixel + realign) + "px";
+            
+            createHighlightDiv(highlightIndex, (startPixel + realign), length, highlightOffset, highlightWidth);
+        };
+        var createDurationDiv = function(evt, startPixel, endPixel, streamOffset, highlightIndex, highlightOffset, highlightWidth) {
+            var attachClickEvent = function(elmt) {
+                elmt.style.cursor = "pointer";
+                Timeline.DOM.registerEvent(elmt, "mousedown", function(elmt, domEvt, target) {
+                    p._onClickDurationEvent(domEvt, evt, target);
+                });
+            };
+            
+            var length = Math.max(endPixel - startPixel, 1);
+            if (evt.isImprecise()) { // imprecise time
+                var div = doc.createElement("div");
+                div.style.position = "absolute";
+                div.style.overflow = "hidden";
+                
+                div.style.top = streamOffset;
+                div.style.height = trackHeight + "em";
+                div.style.left = startPixel + "px";
+                div.style.width = length + "px";
+                
+                div.style.background = eventTheme.duration.impreciseColor;
+                if (eventTheme.duration.impreciseOpacity < 100) {
+                    Timeline.Graphics.setOpacity(div, eventTheme.duration.impreciseOpacity);
+                }
+                
+                eventLayer.appendChild(div);
+                
+                var startDate = evt.getLatestStart();
+                var endDate = evt.getEarliestEnd();
+                
+                var startPixel2 = Math.round(p._band.dateToPixelOffset(startDate));
+                var endPixel2 = Math.round(p._band.dateToPixelOffset(endDate));
+            } else {
+                var startPixel2 = startPixel;
+                var endPixel2 = endPixel;
+            }
+            
+            var foreground = evt.getTextColor();
+            var outside = true;
+            if (startPixel2 <= endPixel2) {
+                length = Math.max(endPixel2 - startPixel2, 1);
+                outside = !(length > eventTheme.label.width);
+                
+                div = doc.createElement("div");
+                div.style.position = "absolute";
+                div.style.overflow = "hidden";
+                
+                div.style.top = streamOffset;
+                div.style.height = trackHeight + "em";
+                div.style.left = startPixel2 + "px";
+                div.style.width = length + "px";
+                
+                var background = evt.getColor();
+                
+                div.style.background = background != null ? background : eventTheme.duration.color;
+                if (eventTheme.duration.opacity < 100) {
+                    Timeline.Graphics.setOpacity(div, eventTheme.duration.opacity);
+                }
+                
+                eventLayer.appendChild(div);
+            } else {
+                var temp = startPixel2;
+                startPixel2 = endPixel2;
+                endPixel2 = temp;
+            }
+            if (div == null) {
+                console.log(evt);
+            }
+            attachClickEvent(div);
+                
+            if (showText) {
+                var divLabel = doc.createElement("div");
+                divLabel.style.position = "absolute";
+                
+                divLabel.style.top = streamOffset;
+                divLabel.style.height = trackHeight + "em";
+                divLabel.style.left = ((length > eventTheme.label.width) ? startPixel2 : endPixel2) + "px";
+                divLabel.style.width = eventTheme.label.width + "px";
+                divLabel.style.color = foreground != null ? foreground : (outside ? eventTheme.label.outsideColor : eventTheme.label.insideColor);
+                divLabel.style.overflow = "hidden";
+                divLabel.appendChild(doc.createTextNode(evt.getText()));
+                
+                eventLayer.appendChild(divLabel);
+                attachClickEvent(divLabel);
+            }
+            
+            createHighlightDiv(highlightIndex, startPixel, endPixel - startPixel, highlightOffset, highlightWidth);
+        };
+    //}
+    var createEventDiv = function(evt, highlightIndex) {
+        var startDate = evt.getStart();
+        var endDate = evt.getEnd();
+        
+        var startPixel = Math.round(p._band.dateToPixelOffset(startDate));
+        var endPixel = Math.round(p._band.dateToPixelOffset(endDate));
+        
+        var streamOffset = (trackOffset + 
+            p._layout.getTrack(evt) * (trackHeight + trackGap));
+            
+        if (evt.isInstant()) {
+            createInstantDiv(evt, startPixel, endPixel, streamOffset + "em", 
+                highlightIndex, streamOffset - trackGap, trackHeight + 2 * trackGap);
+        } else {
+            createDurationDiv(evt, startPixel, endPixel, streamOffset + "em",
+                highlightIndex, streamOffset - trackGap, trackHeight + 2 * trackGap);
+        }
+    };
+    
+    var filterMatcher = (this._filterMatcher != null) ? 
+        this._filterMatcher :
+        function(evt) { return true; };
+    var highlightMatcher = (this._highlightMatcher != null) ? 
+        this._highlightMatcher :
+        function(evt) { return -1; };
+    
+    var iterator = eventSource.getEventIterator(minDate, maxDate);
+    while (iterator.hasNext()) {
+        var evt = iterator.next();
+        if (filterMatcher(evt)) {
+            createEventDiv(evt, highlightMatcher(evt));
+        }
+    }
+    
+    this._highlightLayer.style.display = "block";
+    this._eventLayer.style.display = "block";
+};
+
+Timeline.DurationEventPainter.prototype.softPaint = function() {
+};
+
+Timeline.DurationEventPainter.prototype._onClickInstantEvent = function(icon, domEvt, evt) {
+    domEvt.cancelBubble = true;
+    
+    var c = Timeline.DOM.getPageCoordinates(icon);
+    this._showBubble(
+        c.left + Math.ceil(icon.offsetWidth / 2), 
+        c.top + Math.ceil(icon.offsetHeight / 2),
+        evt
+    );
+};
+
+Timeline.DurationEventPainter.prototype._onClickDurationEvent = function(domEvt, evt, target) {
+    domEvt.cancelBubble = true;
+    if ("pageX" in domEvt) {
+        var x = domEvt.pageX;
+        var y = domEvt.pageY;
+    } else {
+        var c = Timeline.DOM.getPageCoordinates(target);
+        var x = domEvt.offsetX + c.left;
+        var y = domEvt.offsetY + c.top;
+    }
+    this._showBubble(x, y, evt);
+};
+
+Timeline.DurationEventPainter.prototype._showBubble = function(x, y, evt) {
+    var div = this._band.openBubbleForPoint(
+        x, y,
+        this._theme.event.bubble.width,
+        this._theme.event.bubble.height
+    );
+    
+    evt.fillInfoBubble(div, this._theme, this._band.getLabeller());
+};
\ No newline at end of file

Added: hadoop/chukwa/branches/chukwa-0.1/src/web/hicc/lib/timeline/scripts/sources.js
URL: http://svn.apache.org/viewvc/hadoop/chukwa/branches/chukwa-0.1/src/web/hicc/lib/timeline/scripts/sources.js?rev=770000&view=auto
==============================================================================
--- hadoop/chukwa/branches/chukwa-0.1/src/web/hicc/lib/timeline/scripts/sources.js (added)
+++ hadoop/chukwa/branches/chukwa-0.1/src/web/hicc/lib/timeline/scripts/sources.js Wed Apr 29 23:33:50 2009
@@ -0,0 +1,426 @@
+/*==================================================
+ *  Default Event Source
+ *==================================================
+ */
+
+
+Timeline.DefaultEventSource = function(eventIndex) {
+    this._events = (eventIndex instanceof Object) ? eventIndex : new Timeline.EventIndex();
+    this._listeners = [];
+};
+
+Timeline.DefaultEventSource.prototype.addListener = function(listener) {
+    this._listeners.push(listener);
+};
+
+Timeline.DefaultEventSource.prototype.removeListener = function(listener) {
+    for (var i = 0; i < this._listeners.length; i++) {
+        if (this._listeners[i] == listener) {
+            this._listeners.splice(i, 1);
+            break;
+        }
+    }
+};
+
+Timeline.DefaultEventSource.prototype.loadXML = function(xml, url) {
+    var base = this._getBaseURL(url);
+    
+    var wikiURL = xml.documentElement.getAttribute("wiki-url");
+    var wikiSection = xml.documentElement.getAttribute("wiki-section");
+
+    var dateTimeFormat = xml.documentElement.getAttribute("date-time-format");
+    var parseDateTimeFunction = this._events.getUnit().getParser(dateTimeFormat);
+
+    var node = xml.documentElement.firstChild;
+    var added = false;
+    while (node != null) {
+        if (node.nodeType == 1) {
+            var description = "";
+            if (node.firstChild != null && node.firstChild.nodeType == 3) {
+                description = node.firstChild.nodeValue;
+            }
+            var evt = new Timeline.DefaultEventSource.Event(
+                parseDateTimeFunction(node.getAttribute("start")),
+                parseDateTimeFunction(node.getAttribute("end")),
+                parseDateTimeFunction(node.getAttribute("latestStart")),
+                parseDateTimeFunction(node.getAttribute("earliestEnd")),
+                node.getAttribute("isDuration") != "true",
+                node.getAttribute("title"),
+                description,
+                this._resolveRelativeURL(node.getAttribute("image"), base),
+                this._resolveRelativeURL(node.getAttribute("link"), base),
+                this._resolveRelativeURL(node.getAttribute("icon"), base),
+                node.getAttribute("color"),
+                node.getAttribute("textColor")
+            );
+            evt._node = node;
+            evt.getProperty = function(name) {
+                return this._node.getAttribute(name);
+            };
+            evt.setWikiInfo(wikiURL, wikiSection);
+            
+            this._events.add(evt);
+            
+            added = true;
+        }
+        node = node.nextSibling;
+    }
+
+    if (added) {
+        this._fire("onAddMany", []);
+    }
+};
+
+
+Timeline.DefaultEventSource.prototype.loadJSON = function(data, url) {
+    var base = this._getBaseURL(url);
+    var added = false;  
+    if (data && data.events){
+        var wikiURL = ("wikiURL" in data) ? data.wikiURL : null;
+        var wikiSection = ("wikiSection" in data) ? data.wikiSection : null;
+    
+        var dateTimeFormat = ("dateTimeFormat" in data) ? data.dateTimeFormat : null;
+        var parseDateTimeFunction = this._events.getUnit().getParser(dateTimeFormat);
+       
+        for (var i=0; i < data.events.length; i++){
+            var event = data.events[i];
+            var evt = new Timeline.DefaultEventSource.Event(
+                parseDateTimeFunction(event.start),
+                parseDateTimeFunction(event.end),
+                parseDateTimeFunction(event.latestStart),
+                parseDateTimeFunction(event.earliestEnd),
+                event.isDuration || false,
+                event.title,
+                event.description,
+                this._resolveRelativeURL(event.image, base),
+                this._resolveRelativeURL(event.link, base),
+                this._resolveRelativeURL(event.icon, base),
+                event.color,
+                event.textColor
+            );
+            evt._obj = event;
+            evt.getProperty = function(name) {
+                return this._obj[name];
+            };
+            evt.setWikiInfo(wikiURL, wikiSection);
+
+            this._events.add(evt);
+            added = true;
+        }
+    }
+   
+    if (added) {
+        this._fire("onAddMany", []);
+    }
+};
+
+/*
+ *  Contributed by Morten Frederiksen, http://www.wasab.dk/morten/
+ */
+Timeline.DefaultEventSource.prototype.loadSPARQL = function(xml, url) {
+    var base = this._getBaseURL(url);
+    
+    var dateTimeFormat = 'iso8601';
+    var parseDateTimeFunction = this._events.getUnit().getParser(dateTimeFormat);
+
+    if (xml == null) {
+        return;
+    }
+    
+    /*
+     *  Find <results> tag
+     */
+    var node = xml.documentElement.firstChild;
+    while (node != null && (node.nodeType != 1 || node.nodeName != 'results')) {
+        node = node.nextSibling;
+    }
+    
+    var wikiURL = null;
+    var wikiSection = null;
+    if (node != null) {
+        wikiURL = node.getAttribute("wiki-url");
+        wikiSection = node.getAttribute("wiki-section");
+        
+        node = node.firstChild;
+    }
+    
+    var added = false;
+    while (node != null) {
+        if (node.nodeType == 1) {
+            var bindings = { };
+            var binding = node.firstChild;
+            while (binding != null) {
+                if (binding.nodeType == 1 && 
+                    binding.firstChild != null && 
+                    binding.firstChild.nodeType == 1 && 
+                    binding.firstChild.firstChild != null && 
+                    binding.firstChild.firstChild.nodeType == 3) {
+                    bindings[binding.getAttribute('name')] = binding.firstChild.firstChild.nodeValue;
+                }
+                binding = binding.nextSibling;
+            }
+            
+            if (bindings["start"] == null && bindings["date"] != null) {
+                bindings["start"] = bindings["date"];
+            }
+            
+            var evt = new Timeline.DefaultEventSource.Event(
+                parseDateTimeFunction(bindings["start"]),
+                parseDateTimeFunction(bindings["end"]),
+                parseDateTimeFunction(bindings["latestStart"]),
+                parseDateTimeFunction(bindings["earliestEnd"]),
+                bindings["isDuration"] != "true",
+                bindings["title"],
+                bindings["description"],
+                this._resolveRelativeURL(bindings["image"], base),
+                this._resolveRelativeURL(bindings["link"], base),
+                this._resolveRelativeURL(bindings["icon"], base),
+                bindings["color"],
+                bindings["textColor"]
+            );
+            evt._bindings = bindings;
+            evt.getProperty = function(name) {
+                return this._bindings[name];
+            };
+            evt.setWikiInfo(wikiURL, wikiSection);
+            
+            this._events.add(evt);
+            added = true;
+        }
+        node = node.nextSibling;
+    }
+
+    if (added) {
+        this._fire("onAddMany", []);
+    }
+};
+
+Timeline.DefaultEventSource.prototype.add = function(evt) {
+    this._events.add(evt);
+    this._fire("onAddOne", [evt]);
+};
+
+Timeline.DefaultEventSource.prototype.addMany = function(events) {
+    for (var i = 0; i < events.length; i++) {
+        this._events.add(events[i]);
+    }
+    this._fire("onAddMany", []);
+};
+
+Timeline.DefaultEventSource.prototype.clear = function() {
+    this._events.removeAll();
+    this._fire("onClear", []);
+};
+
+Timeline.DefaultEventSource.prototype.getEventIterator = function(startDate, endDate) {
+    return this._events.getIterator(startDate, endDate);
+};
+
+Timeline.DefaultEventSource.prototype.getAllEventIterator = function() {
+    return this._events.getAllIterator();
+};
+
+Timeline.DefaultEventSource.prototype.getCount = function() {
+    return this._events.getCount();
+};
+
+Timeline.DefaultEventSource.prototype.getEarliestDate = function() {
+    return this._events.getEarliestDate();
+};
+
+Timeline.DefaultEventSource.prototype.getLatestDate = function() {
+    return this._events.getLatestDate();
+};
+
+Timeline.DefaultEventSource.prototype._fire = function(handlerName, args) {
+    for (var i = 0; i < this._listeners.length; i++) {
+        var listener = this._listeners[i];
+        if (handlerName in listener) {
+            try {
+                listener[handlerName].apply(listener, args);
+            } catch (e) {
+                Timeline.Debug.exception(e);
+            }
+        }
+    }
+};
+
+Timeline.DefaultEventSource.prototype._getBaseURL = function(url) {
+    if (url.indexOf("://") < 0) {
+        var url2 = this._getBaseURL(document.location.href);
+        if (url.substr(0,1) == "/") {
+            url = url2.substr(0, url2.indexOf("/", url2.indexOf("://") + 3)) + url;
+        } else {
+            url = url2 + url;
+        }
+    }
+    
+    var i = url.lastIndexOf("/");
+    if (i < 0) {
+        return "";
+    } else {
+        return url.substr(0, i+1);
+    }
+};
+
+Timeline.DefaultEventSource.prototype._resolveRelativeURL = function(url, base) {
+    if (url == null || url == "") {
+        return url;
+    } else if (url.indexOf("://") > 0) {
+        return url;
+    } else if (url.substr(0,1) == "/") {
+        return base.substr(0, base.indexOf("/", base.indexOf("://") + 3)) + url;
+    } else {
+        return base + url;
+    }
+};
+
+
+Timeline.DefaultEventSource.Event = function(
+        start, end, latestStart, earliestEnd, instant, 
+        text, description, image, link,
+        icon, color, textColor) {
+        
+    this._id = "e" + Math.floor(Math.random() * 1000000);
+    
+    this._instant = instant || (end == null);
+    
+    this._start = start;
+    this._end = (end != null) ? end : start;
+    
+    this._latestStart = (latestStart != null) ? latestStart : (instant ? this._end : this._start);
+    this._earliestEnd = (earliestEnd != null) ? earliestEnd : (instant ? this._start : this._end);
+    
+    this._text = Timeline.HTML.deEntify(text);
+    this._description = Timeline.HTML.deEntify(description);
+    this._image = (image != null && image != "") ? image : null;
+    this._link = (link != null && link != "") ? link : null;
+    
+    this._icon = (icon != null && icon != "") ? icon : null;
+    this._color = (color != null && color != "") ? color : null;
+    this._textColor = (textColor != null && textColor != "") ? textColor : null;
+    
+    this._wikiURL = null;
+    this._wikiSection = null;
+};
+
+Timeline.DefaultEventSource.Event.prototype = {
+    getID:          function() { return this._id; },
+    
+    isInstant:      function() { return this._instant; },
+    isImprecise:    function() { return this._start != this._latestStart || this._end != this._earliestEnd; },
+    
+    getStart:       function() { return this._start; },
+    getEnd:         function() { return this._end; },
+    getLatestStart: function() { return this._latestStart; },
+    getEarliestEnd: function() { return this._earliestEnd; },
+    
+    getText:        function() { return this._text; },
+    getDescription: function() { return this._description; },
+    getImage:       function() { return this._image; },
+    getLink:        function() { return this._link; },
+    
+    getIcon:        function() { return this._icon; },
+    getColor:       function() { return this._color; },
+    getTextColor:   function() { return this._textColor; },
+    
+    getProperty:    function(name) { return null; },
+    
+    getWikiURL:     function() { return this._wikiURL; },
+    getWikiSection: function() { return this._wikiSection; },
+    setWikiInfo: function(wikiURL, wikiSection) {
+        this._wikiURL = wikiURL;
+        this._wikiSection = wikiSection;
+    },
+    
+    fillDescription: function(elmt) {
+        elmt.innerHTML = this._description;
+    },
+    fillWikiInfo: function(elmt) {
+        if (this._wikiURL != null && this._wikiSection != null) {
+            var wikiID = this.getProperty("wikiID");
+            if (wikiID == null || wikiID.length == 0) {
+                wikiID = this.getText();
+            }
+            wikiID = wikiID.replace(/\s/g, "_");
+            
+            var url = this._wikiURL + this._wikiSection.replace(/\s/g, "_") + "/" + wikiID;
+            var a = document.createElement("a");
+            a.href = url;
+            a.target = "new";
+            a.innerHTML = Timeline.strings[Timeline.Platform.clientLocale].wikiLinkLabel;
+            
+            elmt.appendChild(document.createTextNode("["));
+            elmt.appendChild(a);
+            elmt.appendChild(document.createTextNode("]"));
+        } else {
+            elmt.style.display = "none";
+        }
+    },
+    fillTime: function(elmt, labeller) {
+        if (this._instant) {
+            if (this.isImprecise()) {
+                elmt.appendChild(elmt.ownerDocument.createTextNode(labeller.labelPrecise(this._start)));
+                elmt.appendChild(elmt.ownerDocument.createElement("br"));
+                elmt.appendChild(elmt.ownerDocument.createTextNode(labeller.labelPrecise(this._end)));
+            } else {
+                elmt.appendChild(elmt.ownerDocument.createTextNode(labeller.labelPrecise(this._start)));
+            }
+        } else {
+            if (this.isImprecise()) {
+                elmt.appendChild(elmt.ownerDocument.createTextNode(
+                    labeller.labelPrecise(this._start) + " ~ " + labeller.labelPrecise(this._latestStart)));
+                elmt.appendChild(elmt.ownerDocument.createElement("br"));
+                elmt.appendChild(elmt.ownerDocument.createTextNode(
+                    labeller.labelPrecise(this._earliestEnd) + " ~ " + labeller.labelPrecise(this._end)));
+            } else {
+                elmt.appendChild(elmt.ownerDocument.createTextNode(labeller.labelPrecise(this._start)));
+                elmt.appendChild(elmt.ownerDocument.createElement("br"));
+                elmt.appendChild(elmt.ownerDocument.createTextNode(labeller.labelPrecise(this._end)));
+            }
+        }
+    },
+    fillInfoBubble: function(elmt, theme, labeller) {
+        var doc = elmt.ownerDocument;
+        
+        var title = this.getText();
+        var link = this.getLink();
+        var image = this.getImage();
+        
+        if (image != null) {
+            var img = doc.createElement("img");
+            img.src = image;
+            
+            theme.event.bubble.imageStyler(img);
+            elmt.appendChild(img);
+        }
+        
+        var divTitle = doc.createElement("div");
+        var textTitle = doc.createTextNode(title);
+        if (link != null) {
+            var a = doc.createElement("a");
+            a.href = link;
+            a.appendChild(textTitle);
+            divTitle.appendChild(a);
+        } else {
+            divTitle.appendChild(textTitle);
+        }
+        theme.event.bubble.titleStyler(divTitle);
+        elmt.appendChild(divTitle);
+        
+        var divBody = doc.createElement("div");
+        this.fillDescription(divBody);
+        theme.event.bubble.bodyStyler(divBody);
+        elmt.appendChild(divBody);
+        
+        var divTime = doc.createElement("div");
+        this.fillTime(divTime, labeller);
+        theme.event.bubble.timeStyler(divTime);
+        elmt.appendChild(divTime);
+        
+        var divWiki = doc.createElement("div");
+        this.fillWikiInfo(divWiki);
+        theme.event.bubble.wikiStyler(divWiki);
+        elmt.appendChild(divWiki);
+    }
+};
\ No newline at end of file

Added: hadoop/chukwa/branches/chukwa-0.1/src/web/hicc/lib/timeline/scripts/themes.js
URL: http://svn.apache.org/viewvc/hadoop/chukwa/branches/chukwa-0.1/src/web/hicc/lib/timeline/scripts/themes.js?rev=770000&view=auto
==============================================================================
--- hadoop/chukwa/branches/chukwa-0.1/src/web/hicc/lib/timeline/scripts/themes.js (added)
+++ hadoop/chukwa/branches/chukwa-0.1/src/web/hicc/lib/timeline/scripts/themes.js Wed Apr 29 23:33:50 2009
@@ -0,0 +1,127 @@
+/*==================================================
+ *  Classic Theme
+ *==================================================
+ */
+
+
+Timeline.ClassicTheme = new Object();
+
+Timeline.ClassicTheme.implementations = [];
+
+Timeline.ClassicTheme.create = function(locale) {
+    if (locale == null) {
+        locale = Timeline.Platform.getDefaultLocale();
+    }
+    
+    var f = Timeline.ClassicTheme.implementations[locale];
+    if (f == null) {
+        f = Timeline.ClassicTheme._Impl;
+    }
+    return new f();
+};
+
+Timeline.ClassicTheme._Impl = function() {
+    this.firstDayOfWeek = 0; // Sunday
+    
+    this.ether = {
+        backgroundColors: [
+            "#EEE",
+            "#DDD",
+            "#CCC",
+            "#AAA"
+        ],
+        highlightColor:     "white",
+        highlightOpacity:   50,
+        interval: {
+            line: {
+                show:       true,
+                color:      "#aaa",
+                opacity:    25
+            },
+            weekend: {
+                color:      "#FFFFE0",
+                opacity:    30
+            },
+            marker: {
+                hAlign:     "Bottom",
+                hBottomStyler: function(elmt) {
+                    elmt.className = "timeline-ether-marker-bottom";
+                },
+                hBottomEmphasizedStyler: function(elmt) {
+                    elmt.className = "timeline-ether-marker-bottom-emphasized";
+                },
+                hTopStyler: function(elmt) {
+                    elmt.className = "timeline-ether-marker-top";
+                },
+                hTopEmphasizedStyler: function(elmt) {
+                    elmt.className = "timeline-ether-marker-top-emphasized";
+                },
+                    
+                vAlign:     "Right",
+                vRightStyler: function(elmt) {
+                    elmt.className = "timeline-ether-marker-right";
+                },
+                vRightEmphasizedStyler: function(elmt) {
+                    elmt.className = "timeline-ether-marker-right-emphasized";
+                },
+                vLeftStyler: function(elmt) {
+                    elmt.className = "timeline-ether-marker-left";
+                },
+                vLeftEmphasizedStyler:function(elmt) {
+                    elmt.className = "timeline-ether-marker-left-emphasized";
+                }
+            }
+        }
+    };
+    
+    this.event = {
+        track: {
+            offset:         0.5, // em
+            height:         1.5, // em
+            gap:            0.5  // em
+        },
+        instant: {
+            icon:           Timeline.urlPrefix + "images/dull-blue-circle.png",
+            lineColor:      "#58A0DC",
+            impreciseColor: "#58A0DC",
+            impreciseOpacity: 20,
+            showLineForNoText: true
+        },
+        duration: {
+            color:          "#58A0DC",
+            opacity:        100,
+            impreciseColor: "#58A0DC",
+            impreciseOpacity: 20
+        },
+        label: {
+            insideColor:    "white",
+            outsideColor:   "black",
+            width:          200 // px
+        },
+        highlightColors: [
+            "#FFFF00",
+            "#FFC000",
+            "#FF0000",
+            "#0000FF"
+        ],
+        bubble: {
+            width:          250, // px
+            height:         125, // px
+            titleStyler: function(elmt) {
+                elmt.className = "timeline-event-bubble-title";
+            },
+            bodyStyler: function(elmt) {
+                elmt.className = "timeline-event-bubble-body";
+            },
+            imageStyler: function(elmt) {
+                elmt.className = "timeline-event-bubble-image";
+            },
+            wikiStyler: function(elmt) {
+                elmt.className = "timeline-event-bubble-wiki";
+            },
+            timeStyler: function(elmt) {
+                elmt.className = "timeline-event-bubble-time";
+            }
+        }
+    };
+};
\ No newline at end of file

Added: hadoop/chukwa/branches/chukwa-0.1/src/web/hicc/lib/timeline/scripts/timeline.js
URL: http://svn.apache.org/viewvc/hadoop/chukwa/branches/chukwa-0.1/src/web/hicc/lib/timeline/scripts/timeline.js?rev=770000&view=auto
==============================================================================
--- hadoop/chukwa/branches/chukwa-0.1/src/web/hicc/lib/timeline/scripts/timeline.js (added)
+++ hadoop/chukwa/branches/chukwa-0.1/src/web/hicc/lib/timeline/scripts/timeline.js Wed Apr 29 23:33:50 2009
@@ -0,0 +1,895 @@
+/*==================================================
+ *  Timeline
+ *==================================================
+ */
+
+Timeline.strings = {}; // localization string tables
+
+Timeline.create = function(elmt, bandInfos, orientation, unit) {
+    return new Timeline._Impl(elmt, bandInfos, orientation, unit);
+};
+
+Timeline.HORIZONTAL = 0;
+Timeline.VERTICAL = 1;
+
+Timeline._defaultTheme = null;
+
+Timeline.createBandInfo = function(params) {
+    var theme = ("theme" in params) ? params.theme : Timeline.getDefaultTheme();
+    
+    var eventSource = ("eventSource" in params) ? params.eventSource : null;
+    
+    var ether = new Timeline.LinearEther({ 
+        centersOn:          ("date" in params) ? params.date : new Date(),
+        interval:           Timeline.DateTime.gregorianUnitLengths[params.intervalUnit],
+        pixelsPerInterval:  params.intervalPixels
+    });
+    
+    var etherPainter = new Timeline.GregorianEtherPainter({
+        unit:       params.intervalUnit, 
+        multiple:   ("multiple" in params) ? params.multiple : 1,
+        theme:      theme,
+        align:      ("align" in params) ? params.align : undefined
+    });
+    
+    var layout = new Timeline.StaticTrackBasedLayout({
+        eventSource:    eventSource,
+        ether:          ether,
+        showText:       ("showEventText" in params) ? params.showEventText : true,
+        theme:          theme
+    });
+    
+    var eventPainterParams = {
+        showText:   ("showEventText" in params) ? params.showEventText : true,
+        layout:     layout,
+        theme:      theme
+    };
+    if ("trackHeight" in params) {
+        eventPainterParams.trackHeight = params.trackHeight;
+    }
+    if ("trackGap" in params) {
+        eventPainterParams.trackGap = params.trackGap;
+    }
+    var eventPainter = new Timeline.DurationEventPainter(eventPainterParams);
+    
+    return {   
+        width:          params.width,
+        eventSource:    eventSource,
+        timeZone:       ("timeZone" in params) ? params.timeZone : 0,
+        ether:          ether,
+        etherPainter:   etherPainter,
+        eventPainter:   eventPainter
+    };
+};
+
+Timeline.createHotZoneBandInfo = function(params) {
+    var theme = ("theme" in params) ? params.theme : Timeline.getDefaultTheme();
+    
+    var eventSource = ("eventSource" in params) ? params.eventSource : null;
+    
+    var ether = new Timeline.HotZoneEther({ 
+        centersOn:          ("date" in params) ? params.date : new Date(),
+        interval:           Timeline.DateTime.gregorianUnitLengths[params.intervalUnit],
+        pixelsPerInterval:  params.intervalPixels,
+        zones:              params.zones
+    });
+    
+    var etherPainter = new Timeline.HotZoneGregorianEtherPainter({
+        unit:       params.intervalUnit, 
+        zones:      params.zones,
+        theme:      theme,
+        align:      ("align" in params) ? params.align : undefined
+    });
+    
+    var layout = new Timeline.StaticTrackBasedLayout({
+        eventSource:    eventSource,
+        ether:          ether,
+        theme:          theme
+    });
+    
+    var eventPainterParams = {
+        showText:   ("showEventText" in params) ? params.showEventText : true,
+        layout:     layout,
+        theme:      theme
+    };
+    if ("trackHeight" in params) {
+        eventPainterParams.trackHeight = params.trackHeight;
+    }
+    if ("trackGap" in params) {
+        eventPainterParams.trackGap = params.trackGap;
+    }
+    var eventPainter = new Timeline.DurationEventPainter(eventPainterParams);
+    
+    return {   
+        width:          params.width,
+        eventSource:    eventSource,
+        timeZone:       ("timeZone" in params) ? params.timeZone : 0,
+        ether:          ether,
+        etherPainter:   etherPainter,
+        eventPainter:   eventPainter
+    };
+};
+
+Timeline.getDefaultTheme = function() {
+    if (Timeline._defaultTheme == null) {
+        Timeline._defaultTheme = Timeline.ClassicTheme.create(Timeline.Platform.getDefaultLocale());
+    }
+    return Timeline._defaultTheme;
+};
+
+Timeline.setDefaultTheme = function(theme) {
+    Timeline._defaultTheme = theme;
+};
+
+Timeline.loadXML = function(url, f) {
+    var fError = function(statusText, status, xmlhttp) {
+        alert("Failed to load data xml from " + url + "\n" + statusText);
+    };
+    var fDone = function(xmlhttp) {
+        var xml = xmlhttp.responseXML;
+        if (!xml.documentElement && xmlhttp.responseStream) {
+            xml.load(xmlhttp.responseStream);
+        } 
+        f(xml, url);
+    };
+    Timeline.XmlHttp.get(url, fError, fDone);
+};
+
+
+Timeline.loadJSON = function(url, f) {
+    var fError = function(statusText, status, xmlhttp) {
+        alert("Failed to load json data from " + url + "\n" + statusText);
+    };
+    var fDone = function(xmlhttp) {
+        f(eval('(' + xmlhttp.responseText + ')'), url);
+    };
+    Timeline.XmlHttp.get(url, fError, fDone);
+};
+
+
+Timeline._Impl = function(elmt, bandInfos, orientation, unit) {
+    this._containerDiv = elmt;
+    
+    this._bandInfos = bandInfos;
+    this._orientation = orientation == null ? Timeline.HORIZONTAL : orientation;
+    this._unit = (unit != null) ? unit : Timeline.NativeDateUnit;
+    
+    this._initialize();
+};
+
+Timeline._Impl.prototype.dispose = function() {
+    for (var i = 0; i < this._bands.length; i++) {
+        this._bands[i].dispose();
+    }
+    this._bands = null;
+    this._bandInfos = null;
+    this._containerDiv.innerHTML = "";
+};
+
+Timeline._Impl.prototype.getBandCount = function() {
+    return this._bands.length;
+};
+
+Timeline._Impl.prototype.getBand = function(index) {
+    return this._bands[index];
+};
+
+Timeline._Impl.prototype.layout = function() {
+    this._distributeWidths();
+};
+
+Timeline._Impl.prototype.paint = function() {
+    for (var i = 0; i < this._bands.length; i++) {
+        this._bands[i].paint();
+    }
+};
+
+Timeline._Impl.prototype.getDocument = function() {
+    return this._containerDiv.ownerDocument;
+};
+
+Timeline._Impl.prototype.addDiv = function(div) {
+    this._containerDiv.appendChild(div);
+};
+
+Timeline._Impl.prototype.removeDiv = function(div) {
+    this._containerDiv.removeChild(div);
+};
+
+Timeline._Impl.prototype.isHorizontal = function() {
+    return this._orientation == Timeline.HORIZONTAL;
+};
+
+Timeline._Impl.prototype.isVertical = function() {
+    return this._orientation == Timeline.VERTICAL;
+};
+
+Timeline._Impl.prototype.getPixelLength = function() {
+    return this._orientation == Timeline.HORIZONTAL ? 
+        this._containerDiv.offsetWidth : this._containerDiv.offsetHeight;
+};
+
+Timeline._Impl.prototype.getPixelWidth = function() {
+    return this._orientation == Timeline.VERTICAL ? 
+        this._containerDiv.offsetWidth : this._containerDiv.offsetHeight;
+};
+
+Timeline._Impl.prototype.getUnit = function() {
+    return this._unit;
+};
+
+Timeline._Impl.prototype.loadXML = function(url, f) {
+    var tl = this;
+    
+    
+    var fError = function(statusText, status, xmlhttp) {
+        alert("Failed to load data xml from " + url + "\n" + statusText);
+        tl.hideLoadingMessage();
+    };
+    var fDone = function(xmlhttp) {
+        try {
+            var xml = xmlhttp.responseXML;
+            if (!xml.documentElement && xmlhttp.responseStream) {
+                xml.load(xmlhttp.responseStream);
+            } 
+            f(xml, url);
+        } finally {
+            tl.hideLoadingMessage();
+        }
+    };
+    
+    this.showLoadingMessage();
+    window.setTimeout(function() { Timeline.XmlHttp.get(url, fError, fDone); }, 0);
+};
+
+Timeline._Impl.prototype.loadJSON = function(url, f) {
+    var tl = this;
+    
+    
+    var fError = function(statusText, status, xmlhttp) {
+        alert("Failed to load json data from " + url + "\n" + statusText);
+        tl.hideLoadingMessage();
+    };
+    var fDone = function(xmlhttp) {
+        try {
+            f(eval('(' + xmlhttp.responseText + ')'), url);
+        } finally {
+            tl.hideLoadingMessage();
+        }
+    };
+    
+    this.showLoadingMessage();
+    window.setTimeout(function() { Timeline.XmlHttp.get(url, fError, fDone); }, 0);
+};
+
+Timeline._Impl.prototype._initialize = function() {
+    var containerDiv = this._containerDiv;
+    var doc = containerDiv.ownerDocument;
+    
+    containerDiv.className = 
+        containerDiv.className.split(" ").concat("timeline-container").join(" ");
+        
+    while (containerDiv.firstChild) {
+        containerDiv.removeChild(containerDiv.firstChild);
+    }
+    
+    /*
+     *  inserting copyright and link to simile
+     */
+    var elmtCopyright = Timeline.Graphics.createTranslucentImage(doc, Timeline.urlPrefix + (this.isHorizontal() ? "images/copyright-vertical.png" : "images/copyright.png"));
+    elmtCopyright.className = "timeline-copyright";
+    elmtCopyright.title = "Timeline (c) SIMILE - http://simile.mit.edu/timeline/";
+    Timeline.DOM.registerEvent(elmtCopyright, "click", function() { window.location = "http://simile.mit.edu/timeline/"; });
+    containerDiv.appendChild(elmtCopyright);
+    
+    /*
+     *  creating bands
+     */
+    this._bands = [];
+    for (var i = 0; i < this._bandInfos.length; i++) {
+        var band = new Timeline._Band(this, this._bandInfos[i], i);
+        this._bands.push(band);
+    }
+    this._distributeWidths();
+    
+    /*
+     *  sync'ing bands
+     */
+    for (var i = 0; i < this._bandInfos.length; i++) {
+        var bandInfo = this._bandInfos[i];
+        if ("syncWith" in bandInfo) {
+            this._bands[i].setSyncWithBand(
+                this._bands[bandInfo.syncWith], 
+                ("highlight" in bandInfo) ? bandInfo.highlight : false
+            );
+        }
+    }
+    
+    /*
+     *  creating loading UI
+     */
+    var message = Timeline.Graphics.createMessageBubble(doc);
+    message.containerDiv.className = "timeline-message-container";
+    containerDiv.appendChild(message.containerDiv);
+    
+    message.contentDiv.className = "timeline-message";
+    message.contentDiv.innerHTML = "<img src='" + Timeline.urlPrefix + "images/progress-running.gif' /> Loading...";
+    
+    this.showLoadingMessage = function() { message.containerDiv.style.display = "block"; };
+    this.hideLoadingMessage = function() { message.containerDiv.style.display = "none"; };
+};
+
+Timeline._Impl.prototype._distributeWidths = function() {
+    var length = this.getPixelLength();
+    var width = this.getPixelWidth();
+    var cumulativeWidth = 0;
+    
+    for (var i = 0; i < this._bands.length; i++) {
+        var band = this._bands[i];
+        var bandInfos = this._bandInfos[i];
+        var widthString = bandInfos.width;
+        
+        var x = widthString.indexOf("%");
+        if (x > 0) {
+            var percent = parseInt(widthString.substr(0, x));
+            var bandWidth = percent * width / 100;
+        } else {
+            var bandWidth = parseInt(widthString);
+        }
+        
+        band.setBandShiftAndWidth(cumulativeWidth, bandWidth);
+        band.setViewLength(length);
+        
+        cumulativeWidth += bandWidth;
+    }
+};
+
+/*==================================================
+ *  Band
+ *==================================================
+ */
+Timeline._Band = function(timeline, bandInfo, index) {
+    this._timeline = timeline;
+    this._bandInfo = bandInfo;
+    this._index = index;
+    
+    this._locale = ("locale" in bandInfo) ? bandInfo.locale : Timeline.Platform.getDefaultLocale();
+    this._timeZone = ("timeZone" in bandInfo) ? bandInfo.timeZone : 0;
+    this._labeller = ("labeller" in bandInfo) ? bandInfo.labeller : 
+        timeline.getUnit().createLabeller(this._locale, this._timeZone);
+    
+    this._dragging = false;
+    this._changing = false;
+    this._originalScrollSpeed = 5; // pixels
+    this._scrollSpeed = this._originalScrollSpeed;
+    this._onScrollListeners = [];
+    
+    var b = this;
+    this._syncWithBand = null;
+    this._syncWithBandHandler = function(band) {
+        b._onHighlightBandScroll();
+    };
+    this._selectorListener = function(band) {
+        b._onHighlightBandScroll();
+    };
+    
+    /*
+     *  Install a textbox to capture keyboard events
+     */
+    var inputDiv = this._timeline.getDocument().createElement("div");
+    inputDiv.className = "timeline-band-input";
+    this._timeline.addDiv(inputDiv);
+    
+    this._keyboardInput = document.createElement("input");
+    this._keyboardInput.type = "text";
+    inputDiv.appendChild(this._keyboardInput);
+    Timeline.DOM.registerEventWithObject(this._keyboardInput, "keydown", this, this._onKeyDown);
+    Timeline.DOM.registerEventWithObject(this._keyboardInput, "keyup", this, this._onKeyUp);
+    
+    /*
+     *  The band's outer most div that slides with respect to the timeline's div
+     */
+    this._div = this._timeline.getDocument().createElement("div");
+    this._div.className = "timeline-band";
+    this._timeline.addDiv(this._div);
+    
+    Timeline.DOM.registerEventWithObject(this._div, "mousedown", this, this._onMouseDown);
+    Timeline.DOM.registerEventWithObject(this._div, "mousemove", this, this._onMouseMove);
+    Timeline.DOM.registerEventWithObject(this._div, "mouseup", this, this._onMouseUp);
+    Timeline.DOM.registerEventWithObject(this._div, "mouseout", this, this._onMouseOut);
+    Timeline.DOM.registerEventWithObject(this._div, "dblclick", this, this._onDblClick);
+    
+    /*
+     *  The inner div that contains layers
+     */
+    this._innerDiv = this._timeline.getDocument().createElement("div");
+    this._innerDiv.className = "timeline-band-inner";
+    this._div.appendChild(this._innerDiv);
+    
+    /*
+     *  Initialize parts of the band
+     */
+    this._ether = bandInfo.ether;
+    bandInfo.ether.initialize(timeline);
+        
+    this._etherPainter = bandInfo.etherPainter;
+    bandInfo.etherPainter.initialize(this, timeline);
+    
+    this._eventSource = bandInfo.eventSource;
+    if (this._eventSource) {
+        this._eventListener = {
+            onAddMany: function() { b._onAddMany(); },
+            onClear:   function() { b._onClear(); }
+        }
+        this._eventSource.addListener(this._eventListener);
+    }
+        
+    this._eventPainter = bandInfo.eventPainter;
+    bandInfo.eventPainter.initialize(this, timeline);
+    
+    this._decorators = ("decorators" in bandInfo) ? bandInfo.decorators : [];
+    for (var i = 0; i < this._decorators.length; i++) {
+        this._decorators[i].initialize(this, timeline);
+    }
+        
+    this._bubble = null;
+};
+
+Timeline._Band.SCROLL_MULTIPLES = 5;
+
+Timeline._Band.prototype.dispose = function() {
+    this.closeBubble();
+    
+    if (this._eventSource) {
+        this._eventSource.removeListener(this._eventListener);
+        this._eventListener = null;
+        this._eventSource = null;
+    }
+    
+    this._timeline = null;
+    this._bandInfo = null;
+    
+    this._labeller = null;
+    this._ether = null;
+    this._etherPainter = null;
+    this._eventPainter = null;
+    this._decorators = null;
+    
+    this._onScrollListeners = null;
+    this._syncWithBandHandler = null;
+    this._selectorListener = null;
+    
+    this._div = null;
+    this._innerDiv = null;
+    this._keyboardInput = null;
+    this._bubble = null;
+};
+
+Timeline._Band.prototype.addOnScrollListener = function(listener) {
+    this._onScrollListeners.push(listener);
+};
+
+Timeline._Band.prototype.removeOnScrollListener = function(listener) {
+    for (var i = 0; i < this._onScrollListeners.length; i++) {
+        if (this._onScrollListeners[i] == listener) {
+            this._onScrollListeners.splice(i, 1);
+            break;
+        }
+    }
+};
+
+Timeline._Band.prototype.setSyncWithBand = function(band, highlight) {
+    if (this._syncWithBand) {
+        this._syncWithBand.removeOnScrollListener(this._syncWithBandHandler);
+    }
+    
+    this._syncWithBand = band;
+    this._syncWithBand.addOnScrollListener(this._syncWithBandHandler);
+    this._highlight = highlight;
+    this._positionHighlight();
+};
+
+Timeline._Band.prototype.getLocale = function() {
+    return this._locale;
+};
+
+Timeline._Band.prototype.getTimeZone = function() {
+    return this._timeZone;
+};
+
+Timeline._Band.prototype.getLabeller = function() {
+    return this._labeller;
+};
+
+Timeline._Band.prototype.getIndex = function() {
+    return this._index;
+};
+
+Timeline._Band.prototype.getEther = function() {
+    return this._ether;
+};
+
+Timeline._Band.prototype.getEtherPainter = function() {
+    return this._etherPainter;
+};
+
+Timeline._Band.prototype.getEventSource = function() {
+    return this._eventSource;
+};
+
+Timeline._Band.prototype.getEventPainter = function() {
+    return this._eventPainter;
+};
+
+Timeline._Band.prototype.layout = function() {
+    this.paint();
+};
+
+Timeline._Band.prototype.paint = function() {
+    this._etherPainter.paint();
+    this._paintDecorators();
+    this._paintEvents();
+};
+
+Timeline._Band.prototype.softLayout = function() {
+    this.softPaint();
+};
+
+Timeline._Band.prototype.softPaint = function() {
+    this._etherPainter.softPaint();
+    this._softPaintDecorators();
+    this._softPaintEvents();
+};
+
+Timeline._Band.prototype.setBandShiftAndWidth = function(shift, width) {
+    var inputDiv = this._keyboardInput.parentNode;
+    var middle = shift + Math.floor(width / 2);
+    if (this._timeline.isHorizontal()) {
+        this._div.style.top = shift + "px";
+        this._div.style.height = width + "px";
+        
+        inputDiv.style.top = middle + "px";
+        inputDiv.style.left = "-1em";
+    } else {
+        this._div.style.left = shift + "px";
+        this._div.style.width = width + "px";
+        
+        inputDiv.style.left = middle + "px";
+        inputDiv.style.top = "-1em";
+    }
+};
+
+Timeline._Band.prototype.getViewWidth = function() {
+    if (this._timeline.isHorizontal()) {
+        return this._div.offsetHeight;
+    } else {
+        return this._div.offsetWidth;
+    }
+};
+
+Timeline._Band.prototype.setViewLength = function(length) {
+    this._viewLength = length;
+    this._recenterDiv();
+    this._onChanging();
+};
+
+Timeline._Band.prototype.getViewLength = function() {
+    return this._viewLength;
+};
+
+Timeline._Band.prototype.getTotalViewLength = function() {
+    return Timeline._Band.SCROLL_MULTIPLES * this._viewLength;
+};
+
+Timeline._Band.prototype.getViewOffset = function() {
+    return this._viewOffset;
+};
+
+Timeline._Band.prototype.getMinDate = function() {
+    return this._ether.pixelOffsetToDate(this._viewOffset);
+};
+
+Timeline._Band.prototype.getMaxDate = function() {
+    return this._ether.pixelOffsetToDate(this._viewOffset + Timeline._Band.SCROLL_MULTIPLES * this._viewLength);
+};
+
+Timeline._Band.prototype.getMinVisibleDate = function() {
+    return this._ether.pixelOffsetToDate(0);
+};
+
+Timeline._Band.prototype.getMaxVisibleDate = function() {
+    return this._ether.pixelOffsetToDate(this._viewLength);
+};
+
+Timeline._Band.prototype.getCenterVisibleDate = function() {
+    return this._ether.pixelOffsetToDate(this._viewLength / 2);
+};
+
+Timeline._Band.prototype.setMinVisibleDate = function(date) {
+    if (!this._changing) {
+        this._moveEther(Math.round(-this._ether.dateToPixelOffset(date)));
+    }
+};
+
+Timeline._Band.prototype.setMaxVisibleDate = function(date) {
+    if (!this._changing) {
+        this._moveEther(Math.round(this._viewLength - this._ether.dateToPixelOffset(date)));
+    }
+};
+
+Timeline._Band.prototype.setCenterVisibleDate = function(date) {
+    if (!this._changing) {
+        this._moveEther(Math.round(this._viewLength / 2 - this._ether.dateToPixelOffset(date)));
+    }
+};
+
+Timeline._Band.prototype.dateToPixelOffset = function(date) {
+    return this._ether.dateToPixelOffset(date) - this._viewOffset;
+};
+
+Timeline._Band.prototype.pixelOffsetToDate = function(pixels) {
+    return this._ether.pixelOffsetToDate(pixels + this._viewOffset);
+};
+
+Timeline._Band.prototype.createLayerDiv = function(zIndex) {
+    var div = this._timeline.getDocument().createElement("div");
+    div.className = "timeline-band-layer";
+    div.style.zIndex = zIndex;
+    this._innerDiv.appendChild(div);
+    
+    var innerDiv = this._timeline.getDocument().createElement("div");
+    innerDiv.className = "timeline-band-layer-inner";
+    if (Timeline.Platform.browser.isIE) {
+        innerDiv.style.cursor = "move";
+    } else {
+        innerDiv.style.cursor = "-moz-grab";
+    }
+    div.appendChild(innerDiv);
+    
+    return innerDiv;
+};
+
+Timeline._Band.prototype.removeLayerDiv = function(div) {
+    this._innerDiv.removeChild(div.parentNode);
+};
+
+Timeline._Band.prototype.closeBubble = function() {
+    if (this._bubble != null) {
+        this._bubble.close();
+        this._bubble = null;
+    }
+};
+
+Timeline._Band.prototype.openBubbleForPoint = function(pageX, pageY, width, height) {
+    this.closeBubble();
+    
+    this._bubble = Timeline.Graphics.createBubbleForPoint(
+        this._timeline.getDocument(), pageX, pageY, width, height);
+        
+    return this._bubble.content;
+};
+
+Timeline._Band.prototype.scrollToCenter = function(date) {
+    var pixelOffset = this._ether.dateToPixelOffset(date);
+    if (pixelOffset < -this._viewLength / 2) {
+        this.setCenterVisibleDate(this.pixelOffsetToDate(pixelOffset + this._viewLength));
+    } else if (pixelOffset > 3 * this._viewLength / 2) {
+        this.setCenterVisibleDate(this.pixelOffsetToDate(pixelOffset - this._viewLength));
+    }
+    this._autoScroll(Math.round(this._viewLength / 2 - this._ether.dateToPixelOffset(date)));
+};
+
+Timeline._Band.prototype._onMouseDown = function(innerFrame, evt, target) {
+    this.closeBubble();
+    
+    this._dragging = true;
+    this._dragX = evt.clientX;
+    this._dragY = evt.clientY;
+};
+
+Timeline._Band.prototype._onMouseMove = function(innerFrame, evt, target) {
+    if (this._dragging) {
+        var diffX = evt.clientX - this._dragX;
+        var diffY = evt.clientY - this._dragY;
+        
+        this._dragX = evt.clientX;
+        this._dragY = evt.clientY;
+        
+        this._moveEther(this._timeline.isHorizontal() ? diffX : diffY);
+        this._positionHighlight();
+    }
+};
+
+Timeline._Band.prototype._onMouseUp = function(innerFrame, evt, target) {
+    this._dragging = false;
+    this._keyboardInput.focus();
+};
+
+Timeline._Band.prototype._onMouseOut = function(innerFrame, evt, target) {
+    var coords = Timeline.DOM.getEventRelativeCoordinates(evt, innerFrame);
+    coords.x += this._viewOffset;
+    if (coords.x < 0 || coords.x > innerFrame.offsetWidth ||
+        coords.y < 0 || coords.y > innerFrame.offsetHeight) {
+        this._dragging = false;
+    }
+};
+
+Timeline._Band.prototype._onDblClick = function(innerFrame, evt, target) {
+    var coords = Timeline.DOM.getEventRelativeCoordinates(evt, innerFrame);
+    var distance = coords.x - (this._viewLength / 2 - this._viewOffset);
+    
+    this._autoScroll(-distance);
+};
+
+Timeline._Band.prototype._onKeyDown = function(keyboardInput, evt, target) {
+    if (!this._dragging) {
+        switch (evt.keyCode) {
+        case 27: // ESC
+            break;
+        case 37: // left arrow
+        case 38: // up arrow
+            this._scrollSpeed = Math.min(50, Math.abs(this._scrollSpeed * 1.05));
+            this._moveEther(this._scrollSpeed);
+            break;
+        case 39: // right arrow
+        case 40: // down arrow
+            this._scrollSpeed = -Math.min(50, Math.abs(this._scrollSpeed * 1.05));
+            this._moveEther(this._scrollSpeed);
+            break;
+        default:
+            return true;
+        }
+        this.closeBubble();
+        
+        Timeline.DOM.cancelEvent(evt);
+        return false;
+    }
+    return true;
+};
+
+Timeline._Band.prototype._onKeyUp = function(keyboardInput, evt, target) {
+    if (!this._dragging) {
+        this._scrollSpeed = this._originalScrollSpeed;
+        
+        switch (evt.keyCode) {
+        case 35: // end
+            this.setCenterVisibleDate(this._eventSource.getLatestDate());
+            break;
+        case 36: // home
+            this.setCenterVisibleDate(this._eventSource.getEarliestDate());
+            break;
+        case 33: // page up
+            this._autoScroll(this._timeline.getPixelLength());
+            break;
+        case 34: // page down
+            this._autoScroll(-this._timeline.getPixelLength());
+            break;
+        default:
+            return true;
+        }
+        
+        this.closeBubble();
+        
+        Timeline.DOM.cancelEvent(evt);
+        return false;
+    }
+    return true;
+};
+
+Timeline._Band.prototype._autoScroll = function(distance) {
+    var b = this;
+    var a = Timeline.Graphics.createAnimation(function(abs, diff) {
+        b._moveEther(diff);
+    }, 0, distance, 1000);
+    a.run();
+};
+
+Timeline._Band.prototype._moveEther = function(shift) {
+    this.closeBubble();
+    
+    this._viewOffset += shift;
+    this._ether.shiftPixels(-shift);
+    if (this._timeline.isHorizontal()) {
+        this._div.style.left = this._viewOffset + "px";
+    } else {
+        this._div.style.top = this._viewOffset + "px";
+    }
+    
+    if (this._viewOffset > -this._viewLength * 0.5 ||
+        this._viewOffset < -this._viewLength * (Timeline._Band.SCROLL_MULTIPLES - 1.5)) {
+        
+        this._recenterDiv();
+    } else {
+        this.softLayout();
+    }
+    
+    this._onChanging();
+}
+
+Timeline._Band.prototype._onChanging = function() {
+    this._changing = true;
+
+    this._fireOnScroll();
+    this._setSyncWithBandDate();
+    
+    this._changing = false;
+};
+
+Timeline._Band.prototype._fireOnScroll = function() {
+    for (var i = 0; i < this._onScrollListeners.length; i++) {
+        this._onScrollListeners[i](this);
+    }
+};
+
+Timeline._Band.prototype._setSyncWithBandDate = function() {
+    if (this._syncWithBand) {
+        var centerDate = this._ether.pixelOffsetToDate(this.getViewLength() / 2);
+        this._syncWithBand.setCenterVisibleDate(centerDate);
+    }
+};
+
+Timeline._Band.prototype._onHighlightBandScroll = function() {
+    if (this._syncWithBand) {
+        var centerDate = this._syncWithBand.getCenterVisibleDate();
+        var centerPixelOffset = this._ether.dateToPixelOffset(centerDate);
+        
+        this._moveEther(Math.round(this._viewLength / 2 - centerPixelOffset));
+        
+        if (this._highlight) {
+            this._etherPainter.setHighlight(
+                this._syncWithBand.getMinVisibleDate(), 
+                this._syncWithBand.getMaxVisibleDate());
+        }
+    }
+};
+
+Timeline._Band.prototype._onAddMany = function() {
+    this._paintEvents();
+};
+
+Timeline._Band.prototype._onClear = function() {
+    this._paintEvents();
+};
+
+Timeline._Band.prototype._positionHighlight = function() {
+    if (this._syncWithBand) {
+        var startDate = this._syncWithBand.getMinVisibleDate();
+        var endDate = this._syncWithBand.getMaxVisibleDate();
+        
+        if (this._highlight) {
+            this._etherPainter.setHighlight(startDate, endDate);
+        }
+    }
+};
+
+Timeline._Band.prototype._recenterDiv = function() {
+    this._viewOffset = -this._viewLength * (Timeline._Band.SCROLL_MULTIPLES - 1) / 2;
+    if (this._timeline.isHorizontal()) {
+        this._div.style.left = this._viewOffset + "px";
+        this._div.style.width = (Timeline._Band.SCROLL_MULTIPLES * this._viewLength) + "px";
+    } else {
+        this._div.style.top = this._viewOffset + "px";
+        this._div.style.height = (Timeline._Band.SCROLL_MULTIPLES * this._viewLength) + "px";
+    }
+    this.layout();
+};
+
+Timeline._Band.prototype._paintEvents = function() {
+    this._eventPainter.paint();
+};
+
+Timeline._Band.prototype._softPaintEvents = function() {
+    this._eventPainter.softPaint();
+};
+
+Timeline._Band.prototype._paintDecorators = function() {
+    for (var i = 0; i < this._decorators.length; i++) {
+        this._decorators[i].paint();
+    }
+};
+
+Timeline._Band.prototype._softPaintDecorators = function() {
+    for (var i = 0; i < this._decorators.length; i++) {
+        this._decorators[i].softPaint();
+    }
+};

Added: hadoop/chukwa/branches/chukwa-0.1/src/web/hicc/lib/timeline/scripts/units.js
URL: http://svn.apache.org/viewvc/hadoop/chukwa/branches/chukwa-0.1/src/web/hicc/lib/timeline/scripts/units.js?rev=770000&view=auto
==============================================================================
--- hadoop/chukwa/branches/chukwa-0.1/src/web/hicc/lib/timeline/scripts/units.js (added)
+++ hadoop/chukwa/branches/chukwa-0.1/src/web/hicc/lib/timeline/scripts/units.js Wed Apr 29 23:33:50 2009
@@ -0,0 +1,68 @@
+/*==================================================
+ *  Default Unit
+ *==================================================
+ */
+
+Timeline.NativeDateUnit = new Object();
+
+Timeline.NativeDateUnit.createLabeller = function(locale, timeZone) {
+    return new Timeline.GregorianDateLabeller(locale, timeZone);
+};
+
+Timeline.NativeDateUnit.makeDefaultValue = function() {
+    return new Date();
+};
+
+Timeline.NativeDateUnit.cloneValue = function(v) {
+    return new Date(v.getTime());
+};
+
+Timeline.NativeDateUnit.getParser = function(format) {
+    if (typeof format == "string") {
+        format = format.toLowerCase();
+    }
+    return (format == "iso8601" || format == "iso 8601") ?
+        Timeline.DateTime.parseIso8601DateTime : 
+        Timeline.DateTime.parseGregorianDateTime;
+};
+
+Timeline.NativeDateUnit.parseFromObject = function(o) {
+    return Timeline.DateTime.parseGregorianDateTime(o);
+};
+
+Timeline.NativeDateUnit.toNumber = function(v) {
+    return v.getTime();
+};
+
+Timeline.NativeDateUnit.fromNumber = function(n) {
+    return new Date(n);
+};
+
+Timeline.NativeDateUnit.compare = function(v1, v2) {
+    var n1, n2;
+    if (typeof v1 == "object") {
+        n1 = v1.getTime();
+    } else {
+        n1 = Number(v1);
+    }
+    if (typeof v2 == "object") {
+        n2 = v2.getTime();
+    } else {
+        n2 = Number(v2);
+    }
+    
+    return n1 - n2;
+};
+
+Timeline.NativeDateUnit.earlier = function(v1, v2) {
+    return Timeline.NativeDateUnit.compare(v1, v2) < 0 ? v1 : v2;
+};
+
+Timeline.NativeDateUnit.later = function(v1, v2) {
+    return Timeline.NativeDateUnit.compare(v1, v2) > 0 ? v1 : v2;
+};
+
+Timeline.NativeDateUnit.change = function(v, n) {
+    return new Date(v.getTime() + n);
+};
+

Added: hadoop/chukwa/branches/chukwa-0.1/src/web/hicc/lib/timeline/scripts/util/data-structure.js
URL: http://svn.apache.org/viewvc/hadoop/chukwa/branches/chukwa-0.1/src/web/hicc/lib/timeline/scripts/util/data-structure.js?rev=770000&view=auto
==============================================================================
--- hadoop/chukwa/branches/chukwa-0.1/src/web/hicc/lib/timeline/scripts/util/data-structure.js (added)
+++ hadoop/chukwa/branches/chukwa-0.1/src/web/hicc/lib/timeline/scripts/util/data-structure.js Wed Apr 29 23:33:50 2009
@@ -0,0 +1,247 @@
+/*==================================================
+ *  Sorted Array
+ *==================================================
+ */
+
+Timeline.SortedArray = function(compare, initialArray) {
+    this._a = (initialArray instanceof Array) ? initialArray : [];
+    this._compare = compare;
+};
+
+Timeline.SortedArray.prototype.add = function(elmt) {
+    var sa = this;
+    var index = this.find(function(elmt2) {
+        return sa._compare(elmt2, elmt);
+    });
+    
+    if (index < this._a.length) {
+        this._a.splice(index, 0, elmt);
+    } else {
+        this._a.push(elmt);
+    }
+};
+
+Timeline.SortedArray.prototype.remove = function(elmt) {
+    var sa = this;
+    var index = this.find(function(elmt2) {
+        return sa._compare(elmt2, elmt);
+    });
+    
+    while (index < this._a.length && this._compare(this._a[index], elmt) == 0) {
+        if (this._a[index] == elmt) {
+            this._a.splice(index, 1);
+            return true;
+        } else {
+            index++;
+        }
+    }
+    return false;
+};
+
+Timeline.SortedArray.prototype.removeAll = function() {
+    this._a = [];
+};
+
+Timeline.SortedArray.prototype.elementAt = function(index) {
+    return this._a[index];
+};
+
+Timeline.SortedArray.prototype.length = function() {
+    return this._a.length;
+};
+
+Timeline.SortedArray.prototype.find = function(compare) {
+    var a = 0;
+    var b = this._a.length;
+    
+    while (a < b) {
+        var mid = Math.floor((a + b) / 2);
+        var c = compare(this._a[mid]);
+        if (mid == a) {
+            return c < 0 ? a+1 : a;
+        } else if (c < 0) {
+            a = mid;
+        } else {
+            b = mid;
+        }
+    }
+    return a;
+};
+
+Timeline.SortedArray.prototype.getFirst = function() {
+    return (this._a.length > 0) ? this._a[0] : null;
+};
+
+Timeline.SortedArray.prototype.getLast = function() {
+    return (this._a.length > 0) ? this._a[this._a.length - 1] : null;
+};
+
+/*==================================================
+ *  Event Index
+ *==================================================
+ */
+
+Timeline.EventIndex = function(unit) {
+    var eventIndex = this;
+    
+    this._unit = (unit != null) ? unit : Timeline.NativeDateUnit;
+    this._events = new Timeline.SortedArray(
+        function(event1, event2) {
+            return eventIndex._unit.compare(event1.getStart(), event2.getStart());
+        }
+    );
+    this._indexed = true;
+};
+
+Timeline.EventIndex.prototype.getUnit = function() {
+    return this._unit;
+};
+
+Timeline.EventIndex.prototype.add = function(evt) {
+    this._events.add(evt);
+    this._indexed = false;
+};
+
+Timeline.EventIndex.prototype.removeAll = function() {
+    this._events.removeAll();
+    this._indexed = false;
+};
+
+Timeline.EventIndex.prototype.getCount = function() {
+    return this._events.length();
+};
+
+Timeline.EventIndex.prototype.getIterator = function(startDate, endDate) {
+    if (!this._indexed) {
+        this._index();
+    }
+    return new Timeline.EventIndex._Iterator(this._events, startDate, endDate, this._unit);
+};
+
+Timeline.EventIndex.prototype.getAllIterator = function() {
+    return new Timeline.EventIndex._AllIterator(this._events);
+};
+
+Timeline.EventIndex.prototype.getEarliestDate = function() {
+    var evt = this._events.getFirst();
+    return (evt == null) ? null : evt.getStart();
+};
+
+Timeline.EventIndex.prototype.getLatestDate = function() {
+    var evt = this._events.getLast();
+    if (evt == null) {
+        return null;
+    }
+    
+    if (!this._indexed) {
+        this._index();
+    }
+    
+    var index = evt._earliestOverlapIndex;
+    var date = this._events.elementAt(index).getEnd();
+    for (var i = index + 1; i < this._events.length(); i++) {
+        date = this._unit.later(date, this._events.elementAt(i).getEnd());
+    }
+    
+    return date;
+};
+
+Timeline.EventIndex.prototype._index = function() {
+    /*
+     *  For each event, we want to find the earliest preceding
+     *  event that overlaps with it, if any.
+     */
+    
+    var l = this._events.length();
+    for (var i = 0; i < l; i++) {
+        var evt = this._events.elementAt(i);
+        evt._earliestOverlapIndex = i;
+    }
+    
+    var toIndex = 1;
+    for (var i = 0; i < l; i++) {
+        var evt = this._events.elementAt(i);
+        var end = evt.getEnd();
+        
+        toIndex = Math.max(toIndex, i + 1);
+        while (toIndex < l) {
+            var evt2 = this._events.elementAt(toIndex);
+            var start2 = evt2.getStart();
+            
+            if (this._unit.compare(start2, end) < 0) {
+                evt2._earliestOverlapIndex = i;
+                toIndex++;
+            } else {
+                break;
+            }
+        }
+    }
+    this._indexed = true;
+};
+
+Timeline.EventIndex._Iterator = function(events, startDate, endDate, unit) {
+    this._events = events;
+    this._startDate = startDate;
+    this._endDate = endDate;
+    this._unit = unit;
+    
+    this._currentIndex = events.find(function(evt) {
+        return unit.compare(evt.getStart(), startDate);
+    });
+    if (this._currentIndex - 1 >= 0) {
+        this._currentIndex = this._events.elementAt(this._currentIndex - 1)._earliestOverlapIndex;
+    }
+    this._currentIndex--;
+    
+    this._maxIndex = events.find(function(evt) {
+        return unit.compare(evt.getStart(), endDate);
+    });
+    
+    this._hasNext = false;
+    this._next = null;
+    this._findNext();
+};
+
+Timeline.EventIndex._Iterator.prototype = {
+    hasNext: function() { return this._hasNext; },
+    next: function() {
+        if (this._hasNext) {
+            var next = this._next;
+            this._findNext();
+            
+            return next;
+        } else {
+            return null;
+        }
+    },
+    _findNext: function() {
+        var unit = this._unit;
+        while ((++this._currentIndex) < this._maxIndex) {
+            var evt = this._events.elementAt(this._currentIndex);
+            if (unit.compare(evt.getStart(), this._endDate) < 0 &&
+                unit.compare(evt.getEnd(), this._startDate) > 0) {
+                
+                this._next = evt;
+                this._hasNext = true;
+                return;
+            }
+        }
+        this._next = null;
+        this._hasNext = false;
+    }
+};
+
+Timeline.EventIndex._AllIterator = function(events) {
+    this._events = events;
+    this._index = 0;
+};
+
+Timeline.EventIndex._AllIterator.prototype = {
+    hasNext: function() {
+        return this._index < this._events.length();
+    },
+    next: function() {
+        return this._index < this._events.length() ?
+            this._events.elementAt(this._index++) : null;
+    }
+};
\ No newline at end of file

Added: hadoop/chukwa/branches/chukwa-0.1/src/web/hicc/lib/timeline/scripts/util/date-time.js
URL: http://svn.apache.org/viewvc/hadoop/chukwa/branches/chukwa-0.1/src/web/hicc/lib/timeline/scripts/util/date-time.js?rev=770000&view=auto
==============================================================================
--- hadoop/chukwa/branches/chukwa-0.1/src/web/hicc/lib/timeline/scripts/util/date-time.js (added)
+++ hadoop/chukwa/branches/chukwa-0.1/src/web/hicc/lib/timeline/scripts/util/date-time.js Wed Apr 29 23:33:50 2009
@@ -0,0 +1,327 @@
+/*==================================================
+ *  Date/Time Utility Functions and Constants
+ *==================================================
+ */
+
+Timeline.DateTime = new Object();
+
+Timeline.DateTime.MILLISECOND    = 0;
+Timeline.DateTime.SECOND         = 1;
+Timeline.DateTime.MINUTE         = 2;
+Timeline.DateTime.HOUR           = 3;
+Timeline.DateTime.DAY            = 4;
+Timeline.DateTime.WEEK           = 5;
+Timeline.DateTime.MONTH          = 6;
+Timeline.DateTime.YEAR           = 7;
+Timeline.DateTime.DECADE         = 8;
+Timeline.DateTime.CENTURY        = 9;
+Timeline.DateTime.MILLENNIUM     = 10;
+
+Timeline.DateTime.EPOCH          = -1;
+Timeline.DateTime.ERA            = -2;
+
+Timeline.DateTime.gregorianUnitLengths = [];
+    (function() {
+        var d = Timeline.DateTime;
+        var a = d.gregorianUnitLengths;
+        
+        a[d.MILLISECOND] = 1;
+        a[d.SECOND]      = 1000;
+        a[d.MINUTE]      = a[d.SECOND] * 60;
+        a[d.HOUR]        = a[d.MINUTE] * 60;
+        a[d.DAY]         = a[d.HOUR] * 24;
+        a[d.WEEK]        = a[d.DAY] * 7;
+        a[d.MONTH]       = a[d.DAY] * 31;
+        a[d.YEAR]        = a[d.DAY] * 365;
+        a[d.DECADE]      = a[d.YEAR] * 10;
+        a[d.CENTURY]     = a[d.YEAR] * 100;
+        a[d.MILLENNIUM]  = a[d.YEAR] * 1000;
+    })();
+
+Timeline.DateTime.parseGregorianDateTime = function(o) {
+    if (o == null) {
+        return null;
+    } else if (o instanceof Date) {
+        return o;
+    }
+    
+    var s = o.toString();
+    if (s.length > 0 && s.length < 8) {
+        var space = s.indexOf(" ");
+        if (space > 0) {
+            var year = parseInt(s.substr(0, space));
+            var suffix = s.substr(space + 1);
+            if (suffix.toLowerCase() == "bc") {
+                year = 1 - year;
+            }
+        } else {
+            var year = parseInt(s);
+        }
+            
+        var d = new Date(0);
+        d.setUTCFullYear(year);
+        
+        return d;
+    }
+    
+    try {
+        return new Date(Date.parse(s));
+    } catch (e) {
+        return null;
+    }
+};
+
+Timeline.DateTime._iso8601DateRegExp = "^(-?)([0-9]{4})(" + [
+        "(-?([0-9]{2})(-?([0-9]{2}))?)", // -month-dayOfMonth
+        "(-?([0-9]{3}))",                // -dayOfYear
+        "(-?W([0-9]{2})(-?([1-7]))?)"    // -Wweek-dayOfWeek
+    ].join("|") + ")?$";
+
+Timeline.DateTime.setIso8601Date = function(dateObject, string) {
+    /*
+     *  This function has been adapted from dojo.date, v.0.3.0
+     *  http://dojotoolkit.org/.
+     */
+     
+    var regexp = Timeline.DateTime._iso8601DateRegExp;
+    var d = string.match(new RegExp(regexp));
+    if(!d) {
+        throw new Error("Invalid date string: " + string);
+    }
+    
+    var sign = (d[1] == "-") ? -1 : 1; // BC or AD
+    var year = sign * d[2];
+    var month = d[5];
+    var date = d[7];
+    var dayofyear = d[9];
+    var week = d[11];
+    var dayofweek = (d[13]) ? d[13] : 1;
+
+    dateObject.setUTCFullYear(year);
+    if (dayofyear) { 
+        dateObject.setUTCMonth(0);
+        dateObject.setUTCDate(Number(dayofyear));
+    } else if (week) {
+        dateObject.setUTCMonth(0);
+        dateObject.setUTCDate(1);
+        var gd = dateObject.getUTCDay();
+        var day =  (gd) ? gd : 7;
+        var offset = Number(dayofweek) + (7 * Number(week));
+        
+        if (day <= 4) { 
+            dateObject.setUTCDate(offset + 1 - day); 
+        } else { 
+            dateObject.setUTCDate(offset + 8 - day); 
+        }
+    } else {
+        if (month) { 
+            dateObject.setUTCDate(1);
+            dateObject.setUTCMonth(month - 1); 
+        }
+        if (date) { 
+            dateObject.setUTCDate(date); 
+        }
+    }
+    
+    return dateObject;
+};
+
+Timeline.DateTime.setIso8601Time = function (dateObject, string) {
+    /*
+     *  This function has been adapted from dojo.date, v.0.3.0
+     *  http://dojotoolkit.org/.
+     */
+     
+    // first strip timezone info from the end
+    var timezone = "Z|(([-+])([0-9]{2})(:?([0-9]{2}))?)$";
+    var d = string.match(new RegExp(timezone));
+
+    var offset = 0; // local time if no tz info
+    if (d) {
+        if (d[0] != 'Z') {
+            offset = (Number(d[3]) * 60) + Number(d[5]);
+            offset *= ((d[2] == '-') ? 1 : -1);
+        }
+        string = string.substr(0, string.length - d[0].length);
+    }
+
+    // then work out the time
+    var regexp = "^([0-9]{2})(:?([0-9]{2})(:?([0-9]{2})(\.([0-9]+))?)?)?$";
+    var d = string.match(new RegExp(regexp));
+    if(!d) {
+        dojo.debug("invalid time string: " + string);
+        return false;
+    }
+    var hours = d[1];
+    var mins = Number((d[3]) ? d[3] : 0);
+    var secs = (d[5]) ? d[5] : 0;
+    var ms = d[7] ? (Number("0." + d[7]) * 1000) : 0;
+
+    dateObject.setUTCHours(hours);
+    dateObject.setUTCMinutes(mins);
+    dateObject.setUTCSeconds(secs);
+    dateObject.setUTCMilliseconds(ms);
+    
+    return dateObject;
+};
+
+Timeline.DateTime.setIso8601 = function (dateObject, string){
+    /*
+     *  This function has been copied from dojo.date, v.0.3.0
+     *  http://dojotoolkit.org/.
+     */
+     
+    var comps = (string.indexOf("T") == -1) ? string.split(" ") : string.split("T");
+    
+    Timeline.DateTime.setIso8601Date(dateObject, comps[0]);
+    if (comps.length == 2) { 
+        Timeline.DateTime.setIso8601Time(dateObject, comps[1]); 
+    }
+    return dateObject;
+};
+
+Timeline.DateTime.parseIso8601DateTime = function (string) {
+    try {
+        return Timeline.DateTime.setIso8601(new Date(0), string);
+    } catch (e) {
+        return null;
+    }
+};
+
+Timeline.DateTime.roundDownToInterval = function(date, intervalUnit, timeZone, multiple, firstDayOfWeek) {
+    var timeShift = timeZone * 
+        Timeline.DateTime.gregorianUnitLengths[Timeline.DateTime.HOUR];
+        
+    var date2 = new Date(date.getTime() + timeShift);
+    var clearInDay = function(d) {
+        d.setUTCMilliseconds(0);
+        d.setUTCSeconds(0);
+        d.setUTCMinutes(0);
+        d.setUTCHours(0);
+    };
+    var clearInYear = function(d) {
+        clearInDay(d);
+        d.setUTCDate(1);
+        d.setUTCMonth(0);
+    };
+    
+    switch(intervalUnit) {
+    case Timeline.DateTime.MILLISECOND:
+        var x = date2.getUTCMilliseconds();
+        date2.setUTCMilliseconds(x - (x % multiple));
+        break;
+    case Timeline.DateTime.SECOND:
+        date2.setUTCMilliseconds(0);
+        
+        var x = date2.getUTCSeconds();
+        date2.setUTCSeconds(x - (x % multiple));
+        break;
+    case Timeline.DateTime.MINUTE:
+        date2.setUTCMilliseconds(0);
+        date2.setUTCSeconds(0);
+        
+        var x = date2.getUTCMinutes();
+        date2.setTime(date2.getTime() - 
+            (x % multiple) * Timeline.DateTime.gregorianUnitLengths[Timeline.DateTime.MINUTE]);
+        break;
+    case Timeline.DateTime.HOUR:
+        date2.setUTCMilliseconds(0);
+        date2.setUTCSeconds(0);
+        date2.setUTCMinutes(0);
+        
+        var x = date2.getUTCHours();
+        date2.setUTCHours(x - (x % multiple));
+        break;
+    case Timeline.DateTime.DAY:
+        clearInDay(date2);
+        break;
+    case Timeline.DateTime.WEEK:
+        clearInDay(date2);
+        var d = (date2.getUTCDay() + 7 - firstDayOfWeek) % 7;
+        date2.setTime(date2.getTime() - 
+            d * Timeline.DateTime.gregorianUnitLengths[Timeline.DateTime.DAY]);
+        break;
+    case Timeline.DateTime.MONTH:
+        clearInDay(date2);
+        date2.setUTCDate(1);
+        
+        var x = date2.getUTCMonth();
+        date2.setUTCMonth(x - (x % multiple));
+        break;
+    case Timeline.DateTime.YEAR:
+        clearInYear(date2);
+        
+        var x = date2.getUTCFullYear();
+        date2.setUTCFullYear(x - (x % multiple));
+        break;
+    case Timeline.DateTime.DECADE:
+        clearInYear(date2);
+        date2.setUTCFullYear(Math.floor(date2.getUTCFullYear() / 10) * 10);
+        break;
+    case Timeline.DateTime.CENTURY:
+        clearInYear(date2);
+        date2.setUTCFullYear(Math.floor(date2.getUTCFullYear() / 100) * 100);
+        break;
+    case Timeline.DateTime.MILLENNIUM:
+        clearInYear(date2);
+        date2.setUTCFullYear(Math.floor(date2.getUTCFullYear() / 1000) * 1000);
+        break;
+    }
+    
+    date.setTime(date2.getTime() - timeShift);
+};
+
+Timeline.DateTime.roundUpToInterval = function(date, intervalUnit, timeZone, multiple, firstDayOfWeek) {
+    var originalTime = date.getTime();
+    Timeline.DateTime.roundDownToInterval(date, intervalUnit, timeZone, multiple, firstDayOfWeek);
+    if (date.getTime() < originalTime) {
+        date.setTime(date.getTime() + 
+            Timeline.DateTime.gregorianUnitLengths[intervalUnit] * multiple);
+    }
+};
+
+Timeline.DateTime.incrementByInterval = function(date, intervalUnit) {
+    switch(intervalUnit) {
+    case Timeline.DateTime.MILLISECOND:
+        date.setTime(date.getTime() + 1)
+        break;
+    case Timeline.DateTime.SECOND:
+        date.setTime(date.getTime() + 1000);
+        break;
+    case Timeline.DateTime.MINUTE:
+        date.setTime(date.getTime() + 
+            Timeline.DateTime.gregorianUnitLengths[Timeline.DateTime.MINUTE]);
+        break;
+    case Timeline.DateTime.HOUR:
+        date.setTime(date.getTime() + 
+            Timeline.DateTime.gregorianUnitLengths[Timeline.DateTime.HOUR]);
+        break;
+    case Timeline.DateTime.DAY:
+        date.setUTCDate(date.getUTCDate() + 1);
+        break;
+    case Timeline.DateTime.WEEK:
+        date.setUTCDate(date.getUTCDate() + 7);
+        break;
+    case Timeline.DateTime.MONTH:
+        date.setUTCMonth(date.getUTCMonth() + 1);
+        break;
+    case Timeline.DateTime.YEAR:
+        date.setUTCFullYear(date.getUTCFullYear() + 1);
+        break;
+    case Timeline.DateTime.DECADE:
+        date.setUTCFullYear(date.getUTCFullYear() + 10);
+        break;
+    case Timeline.DateTime.CENTURY:
+        date.setUTCFullYear(date.getUTCFullYear() + 100);
+        break;
+    case Timeline.DateTime.MILLENNIUM:
+        date.setUTCFullYear(date.getUTCFullYear() + 1000);
+        break;
+    }
+};
+
+Timeline.DateTime.removeTimeZoneOffset = function(date, timeZone) {
+    return new Date(date.getTime() + 
+        timeZone * Timeline.DateTime.gregorianUnitLengths[Timeline.DateTime.HOUR]);
+};
+

Added: hadoop/chukwa/branches/chukwa-0.1/src/web/hicc/lib/timeline/scripts/util/debug.js
URL: http://svn.apache.org/viewvc/hadoop/chukwa/branches/chukwa-0.1/src/web/hicc/lib/timeline/scripts/util/debug.js?rev=770000&view=auto
==============================================================================
--- hadoop/chukwa/branches/chukwa-0.1/src/web/hicc/lib/timeline/scripts/util/debug.js (added)
+++ hadoop/chukwa/branches/chukwa-0.1/src/web/hicc/lib/timeline/scripts/util/debug.js Wed Apr 29 23:33:50 2009
@@ -0,0 +1,14 @@
+/*==================================================
+ *  Debug Utility Functions
+ *==================================================
+ */
+
+Timeline.Debug = new Object();
+
+Timeline.Debug.log = function(msg) {
+};
+
+Timeline.Debug.exception = function(e) {
+    alert("Caught exception: " + (Timeline.Platform.isIE ? e.message : e));
+};
+

Added: hadoop/chukwa/branches/chukwa-0.1/src/web/hicc/lib/timeline/scripts/util/dom.js
URL: http://svn.apache.org/viewvc/hadoop/chukwa/branches/chukwa-0.1/src/web/hicc/lib/timeline/scripts/util/dom.js?rev=770000&view=auto
==============================================================================
--- hadoop/chukwa/branches/chukwa-0.1/src/web/hicc/lib/timeline/scripts/util/dom.js (added)
+++ hadoop/chukwa/branches/chukwa-0.1/src/web/hicc/lib/timeline/scripts/util/dom.js Wed Apr 29 23:33:50 2009
@@ -0,0 +1,76 @@
+/*==================================================
+ *  DOM Utility Functions
+ *==================================================
+ */
+
+Timeline.DOM = new Object();
+
+Timeline.DOM.registerEventWithObject = function(elmt, eventName, obj, handler) {
+    Timeline.DOM.registerEvent(elmt, eventName, function(elmt2, evt, target) {
+        return handler.call(obj, elmt2, evt, target);
+    });
+};
+
+Timeline.DOM.registerEvent = function(elmt, eventName, handler) {
+    var handler2 = function(evt) {
+        evt = (evt) ? evt : ((event) ? event : null);
+        if (evt) {
+            var target = (evt.target) ? 
+                evt.target : ((evt.srcElement) ? evt.srcElement : null);
+            if (target) {
+                target = (target.nodeType == 1 || target.nodeType == 9) ? 
+                    target : target.parentNode;
+            }
+            
+            return handler(elmt, evt, target);
+        }
+        return true;
+    }
+    
+    if (Timeline.Platform.browser.isIE) {
+        elmt.attachEvent("on" + eventName, handler2);
+    } else {
+        elmt.addEventListener(eventName, handler2, false);
+    }
+};
+
+Timeline.DOM.getPageCoordinates = function(elmt) {
+    var left = 0;
+    var top = 0;
+    
+    if (elmt.nodeType != 1) {
+        elmt = elmt.parentNode;
+    }
+    
+    while (elmt != null) {
+        left += elmt.offsetLeft;
+        top += elmt.offsetTop;
+        
+        elmt = elmt.offsetParent;
+    }
+    return { left: left, top: top };
+};
+
+Timeline.DOM.getEventRelativeCoordinates = function(evt, elmt) {
+    if (Timeline.Platform.browser.isIE) {
+        return {
+            x: evt.offsetX,
+            y: evt.offsetY
+        };
+    } else {
+        var coords = Timeline.DOM.getPageCoordinates(elmt);
+        return {
+            x: evt.pageX - coords.left,
+            y: evt.pageY - coords.top
+        };
+    }
+};
+
+Timeline.DOM.cancelEvent = function(evt) {
+    evt.returnValue = false;
+    evt.cancelBubble = true;
+    if ("preventDefault" in evt) {
+        evt.preventDefault();
+    }
+};
+



Mime
View raw message