Return-Path: Delivered-To: apmail-hadoop-chukwa-commits-archive@minotaur.apache.org Received: (qmail 96872 invoked from network); 29 Apr 2009 23:34:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 29 Apr 2009 23:34:49 -0000 Received: (qmail 14681 invoked by uid 500); 29 Apr 2009 23:34:49 -0000 Delivered-To: apmail-hadoop-chukwa-commits-archive@hadoop.apache.org Received: (qmail 14666 invoked by uid 500); 29 Apr 2009 23:34:49 -0000 Mailing-List: contact chukwa-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: chukwa-dev@hadoop.apache.org Delivered-To: mailing list chukwa-commits@hadoop.apache.org Received: (qmail 14624 invoked by uid 99); 29 Apr 2009 23:34:47 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Apr 2009 23:34:47 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Apr 2009 23:34:44 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 000CF2388CE2; Wed, 29 Apr 2009 23:34:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r770000 [9/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 -0000 To: chukwa-commits@hadoop.apache.org From: eyang@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090429233401.000CF2388CE2@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Added: hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/ether-painters.js URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/ether-painters.js?rev=770000&view=auto ============================================================================== --- hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/ether-painters.js (added) +++ hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/ether-painters.js Wed Apr 29 23:33:50 2009 @@ -0,0 +1,566 @@ +/*================================================== + * Gregorian Ether Painter + *================================================== + */ + +Timeline.GregorianEtherPainter = function(params) { + this._params = params; + this._theme = params.theme; + this._unit = params.unit; + this._multiple = ("multiple" in params) ? params.multiple : 1; +}; + +Timeline.GregorianEtherPainter.prototype.initialize = function(band, timeline) { + this._band = band; + this._timeline = timeline; + + this._backgroundLayer = band.createLayerDiv(0); + this._backgroundLayer.setAttribute("name", "ether-background"); // for debugging + this._backgroundLayer.style.background = this._theme.ether.backgroundColors[band.getIndex()]; + + this._markerLayer = null; + this._lineLayer = null; + + var align = ("align" in this._params && this._params.align != undefined) ? this._params.align : + this._theme.ether.interval.marker[timeline.isHorizontal() ? "hAlign" : "vAlign"]; + var showLine = ("showLine" in this._params) ? this._params.showLine : + this._theme.ether.interval.line.show; + + this._intervalMarkerLayout = new Timeline.EtherIntervalMarkerLayout( + this._timeline, this._band, this._theme, align, showLine); + + this._highlight = new Timeline.EtherHighlight( + this._timeline, this._band, this._theme, this._backgroundLayer); +} + +Timeline.GregorianEtherPainter.prototype.setHighlight = function(startDate, endDate) { + this._highlight.position(startDate, endDate); +} + +Timeline.GregorianEtherPainter.prototype.paint = function() { + if (this._markerLayer) { + this._band.removeLayerDiv(this._markerLayer); + } + this._markerLayer = this._band.createLayerDiv(100); + this._markerLayer.setAttribute("name", "ether-markers"); // for debugging + this._markerLayer.style.display = "none"; + + if (this._lineLayer) { + this._band.removeLayerDiv(this._lineLayer); + } + this._lineLayer = this._band.createLayerDiv(1); + this._lineLayer.setAttribute("name", "ether-lines"); // for debugging + this._lineLayer.style.display = "none"; + + var minDate = this._band.getMinDate(); + var maxDate = this._band.getMaxDate(); + + var timeZone = this._band.getTimeZone(); + var labeller = this._band.getLabeller(); + + Timeline.DateTime.roundDownToInterval(minDate, this._unit, timeZone, this._multiple, this._theme.firstDayOfWeek); + + var p = this; + var incrementDate = function(date) { + for (var i = 0; i < p._multiple; i++) { + Timeline.DateTime.incrementByInterval(date, p._unit); + } + }; + + while (minDate.getTime() < maxDate.getTime()) { + this._intervalMarkerLayout.createIntervalMarker( + minDate, labeller, this._unit, this._markerLayer, this._lineLayer); + + incrementDate(minDate); + } + this._markerLayer.style.display = "block"; + this._lineLayer.style.display = "block"; +}; + +Timeline.GregorianEtherPainter.prototype.softPaint = function() { +}; + +/*================================================== + * Hot Zone Gregorian Ether Painter + *================================================== + */ + +Timeline.HotZoneGregorianEtherPainter = function(params) { + this._params = params; + this._theme = params.theme; + + this._zones = [{ + startTime: Number.NEGATIVE_INFINITY, + endTime: Number.POSITIVE_INFINITY, + unit: params.unit, + multiple: 1 + }]; + for (var i = 0; i < params.zones.length; i++) { + var zone = params.zones[i]; + var zoneStart = Timeline.DateTime.parseGregorianDateTime(zone.start).getTime(); + var zoneEnd = Timeline.DateTime.parseGregorianDateTime(zone.end).getTime(); + + for (var j = 0; j < this._zones.length && zoneEnd > zoneStart; j++) { + var zone2 = this._zones[j]; + + if (zoneStart < zone2.endTime) { + if (zoneStart > zone2.startTime) { + this._zones.splice(j, 0, { + startTime: zone2.startTime, + endTime: zoneStart, + unit: zone2.unit, + multiple: zone2.multiple + }); + j++; + + zone2.startTime = zoneStart; + } + + if (zoneEnd < zone2.endTime) { + this._zones.splice(j, 0, { + startTime: zoneStart, + endTime: zoneEnd, + unit: zone.unit, + multiple: (zone.multiple) ? zone.multiple : 1 + }); + j++; + + zone2.startTime = zoneEnd; + zoneStart = zoneEnd; + } else { + zone2.multiple = zone.multiple; + zone2.unit = zone.unit; + zoneStart = zone2.endTime; + } + } // else, try the next existing zone + } + } +}; + +Timeline.HotZoneGregorianEtherPainter.prototype.initialize = function(band, timeline) { + this._band = band; + this._timeline = timeline; + + this._backgroundLayer = band.createLayerDiv(0); + this._backgroundLayer.setAttribute("name", "ether-background"); // for debugging + this._backgroundLayer.style.background = this._theme.ether.backgroundColors[band.getIndex()]; + + this._markerLayer = null; + this._lineLayer = null; + + var align = ("align" in this._params && this._params.align != undefined) ? this._params.align : + this._theme.ether.interval.marker[timeline.isHorizontal() ? "hAlign" : "vAlign"]; + var showLine = ("showLine" in this._params) ? this._params.showLine : + this._theme.ether.interval.line.show; + + this._intervalMarkerLayout = new Timeline.EtherIntervalMarkerLayout( + this._timeline, this._band, this._theme, align, showLine); + + this._highlight = new Timeline.EtherHighlight( + this._timeline, this._band, this._theme, this._backgroundLayer); +} + +Timeline.HotZoneGregorianEtherPainter.prototype.setHighlight = function(startDate, endDate) { + this._highlight.position(startDate, endDate); +} + +Timeline.HotZoneGregorianEtherPainter.prototype.paint = function() { + if (this._markerLayer) { + this._band.removeLayerDiv(this._markerLayer); + } + this._markerLayer = this._band.createLayerDiv(100); + this._markerLayer.setAttribute("name", "ether-markers"); // for debugging + this._markerLayer.style.display = "none"; + + if (this._lineLayer) { + this._band.removeLayerDiv(this._lineLayer); + } + this._lineLayer = this._band.createLayerDiv(1); + this._lineLayer.setAttribute("name", "ether-lines"); // for debugging + this._lineLayer.style.display = "none"; + + var minDate = this._band.getMinDate(); + var maxDate = this._band.getMaxDate(); + + var timeZone = this._band.getTimeZone(); + var labeller = this._band.getLabeller(); + + var p = this; + var incrementDate = function(date, zone) { + for (var i = 0; i < zone.multiple; i++) { + Timeline.DateTime.incrementByInterval(date, zone.unit); + } + }; + + var zStart = 0; + while (zStart < this._zones.length) { + if (minDate.getTime() < this._zones[zStart].endTime) { + break; + } + zStart++; + } + var zEnd = this._zones.length - 1; + while (zEnd >= 0) { + if (maxDate.getTime() > this._zones[zEnd].startTime) { + break; + } + zEnd--; + } + + for (var z = zStart; z <= zEnd; z++) { + var zone = this._zones[z]; + + var minDate2 = new Date(Math.max(minDate.getTime(), zone.startTime)); + var maxDate2 = new Date(Math.min(maxDate.getTime(), zone.endTime)); + + Timeline.DateTime.roundDownToInterval(minDate2, zone.unit, timeZone, zone.multiple, this._theme.firstDayOfWeek); + Timeline.DateTime.roundUpToInterval(maxDate2, zone.unit, timeZone, zone.multiple, this._theme.firstDayOfWeek); + + while (minDate2.getTime() < maxDate2.getTime()) { + this._intervalMarkerLayout.createIntervalMarker( + minDate2, labeller, zone.unit, this._markerLayer, this._lineLayer); + + incrementDate(minDate2, zone); + } + } + this._markerLayer.style.display = "block"; + this._lineLayer.style.display = "block"; +}; + +Timeline.HotZoneGregorianEtherPainter.prototype.softPaint = function() { +}; + +/*================================================== + * Year Count Ether Painter + *================================================== + */ + +Timeline.YearCountEtherPainter = function(params) { + this._params = params; + this._theme = params.theme; + this._startDate = Timeline.DateTime.parseGregorianDateTime(params.startDate); + this._multiple = ("multiple" in params) ? params.multiple : 1; +}; + +Timeline.YearCountEtherPainter.prototype.initialize = function(band, timeline) { + this._band = band; + this._timeline = timeline; + + this._backgroundLayer = band.createLayerDiv(0); + this._backgroundLayer.setAttribute("name", "ether-background"); // for debugging + this._backgroundLayer.style.background = this._theme.ether.backgroundColors[band.getIndex()]; + + this._markerLayer = null; + this._lineLayer = null; + + var align = ("align" in this._params) ? this._params.align : + this._theme.ether.interval.marker[timeline.isHorizontal() ? "hAlign" : "vAlign"]; + var showLine = ("showLine" in this._params) ? this._params.showLine : + this._theme.ether.interval.line.show; + + this._intervalMarkerLayout = new Timeline.EtherIntervalMarkerLayout( + this._timeline, this._band, this._theme, align, showLine); + + this._highlight = new Timeline.EtherHighlight( + this._timeline, this._band, this._theme, this._backgroundLayer); +}; + +Timeline.YearCountEtherPainter.prototype.setHighlight = function(startDate, endDate) { + this._highlight.position(startDate, endDate); +}; + +Timeline.YearCountEtherPainter.prototype.paint = function() { + if (this._markerLayer) { + this._band.removeLayerDiv(this._markerLayer); + } + this._markerLayer = this._band.createLayerDiv(100); + this._markerLayer.setAttribute("name", "ether-markers"); // for debugging + this._markerLayer.style.display = "none"; + + if (this._lineLayer) { + this._band.removeLayerDiv(this._lineLayer); + } + this._lineLayer = this._band.createLayerDiv(1); + this._lineLayer.setAttribute("name", "ether-lines"); // for debugging + this._lineLayer.style.display = "none"; + + var minDate = new Date(this._startDate.getTime()); + var maxDate = this._band.getMaxDate(); + var yearDiff = this._band.getMinDate().getUTCFullYear() - this._startDate.getUTCFullYear(); + minDate.setUTCFullYear(this._band.getMinDate().getUTCFullYear() - yearDiff % this._multiple); + + var p = this; + var incrementDate = function(date) { + for (var i = 0; i < p._multiple; i++) { + Timeline.DateTime.incrementByInterval(date, Timeline.DateTime.YEAR); + } + }; + var labeller = { + labelInterval: function(date, intervalUnit) { + var diff = date.getUTCFullYear() - p._startDate.getUTCFullYear(); + return { + text: diff, + emphasized: diff == 0 + }; + } + }; + + while (minDate.getTime() < maxDate.getTime()) { + this._intervalMarkerLayout.createIntervalMarker( + minDate, labeller, Timeline.DateTime.YEAR, this._markerLayer, this._lineLayer); + + incrementDate(minDate); + } + this._markerLayer.style.display = "block"; + this._lineLayer.style.display = "block"; +}; + +Timeline.YearCountEtherPainter.prototype.softPaint = function() { +}; + +/*================================================== + * Quarterly Ether Painter + *================================================== + */ + +Timeline.QuarterlyEtherPainter = function(params) { + this._params = params; + this._theme = params.theme; + this._startDate = Timeline.DateTime.parseGregorianDateTime(params.startDate); +}; + +Timeline.QuarterlyEtherPainter.prototype.initialize = function(band, timeline) { + this._band = band; + this._timeline = timeline; + + this._backgroundLayer = band.createLayerDiv(0); + this._backgroundLayer.setAttribute("name", "ether-background"); // for debugging + this._backgroundLayer.style.background = this._theme.ether.backgroundColors[band.getIndex()]; + + this._markerLayer = null; + this._lineLayer = null; + + var align = ("align" in this._params) ? this._params.align : + this._theme.ether.interval.marker[timeline.isHorizontal() ? "hAlign" : "vAlign"]; + var showLine = ("showLine" in this._params) ? this._params.showLine : + this._theme.ether.interval.line.show; + + this._intervalMarkerLayout = new Timeline.EtherIntervalMarkerLayout( + this._timeline, this._band, this._theme, align, showLine); + + this._highlight = new Timeline.EtherHighlight( + this._timeline, this._band, this._theme, this._backgroundLayer); +}; + +Timeline.QuarterlyEtherPainter.prototype.setHighlight = function(startDate, endDate) { + this._highlight.position(startDate, endDate); +}; + +Timeline.QuarterlyEtherPainter.prototype.paint = function() { + if (this._markerLayer) { + this._band.removeLayerDiv(this._markerLayer); + } + this._markerLayer = this._band.createLayerDiv(100); + this._markerLayer.setAttribute("name", "ether-markers"); // for debugging + this._markerLayer.style.display = "none"; + + if (this._lineLayer) { + this._band.removeLayerDiv(this._lineLayer); + } + this._lineLayer = this._band.createLayerDiv(1); + this._lineLayer.setAttribute("name", "ether-lines"); // for debugging + this._lineLayer.style.display = "none"; + + var minDate = new Date(0); + var maxDate = this._band.getMaxDate(); + + minDate.setUTCFullYear(Math.max(this._startDate.getUTCFullYear(), this._band.getMinDate().getUTCFullYear())); + minDate.setUTCMonth(this._startDate.getUTCMonth()); + + var p = this; + var incrementDate = function(date) { + date.setUTCMonth(date.getUTCMonth() + 3); + }; + var labeller = { + labelInterval: function(date, intervalUnit) { + var quarters = (4 + (date.getUTCMonth() - p._startDate.getUTCMonth()) / 3) % 4; + if (quarters != 0) { + return { text: "Q" + (quarters + 1), emphasized: false }; + } else { + return { text: "Y" + (date.getUTCFullYear() - p._startDate.getUTCFullYear() + 1), emphasized: true }; + } + } + }; + + while (minDate.getTime() < maxDate.getTime()) { + this._intervalMarkerLayout.createIntervalMarker( + minDate, labeller, Timeline.DateTime.YEAR, this._markerLayer, this._lineLayer); + + incrementDate(minDate); + } + this._markerLayer.style.display = "block"; + this._lineLayer.style.display = "block"; +}; + +Timeline.QuarterlyEtherPainter.prototype.softPaint = function() { +}; + +/*================================================== + * Ether Interval Marker Layout + *================================================== + */ + +Timeline.EtherIntervalMarkerLayout = function(timeline, band, theme, align, showLine) { + var horizontal = timeline.isHorizontal(); + if (horizontal) { + if (align == "Top") { + this.positionDiv = function(div, offset) { + div.style.left = offset + "px"; + div.style.top = "0px"; + }; + } else { + this.positionDiv = function(div, offset) { + div.style.left = offset + "px"; + div.style.bottom = "0px"; + }; + } + } else { + if (align == "Left") { + this.positionDiv = function(div, offset) { + div.style.top = offset + "px"; + div.style.left = "0px"; + }; + } else { + this.positionDiv = function(div, offset) { + div.style.top = offset + "px"; + div.style.right = "0px"; + }; + } + } + + var markerTheme = theme.ether.interval.marker; + var lineTheme = theme.ether.interval.line; + var weekendTheme = theme.ether.interval.weekend; + + var stylePrefix = (horizontal ? "h" : "v") + align; + var labelStyler = markerTheme[stylePrefix + "Styler"]; + var emphasizedLabelStyler = markerTheme[stylePrefix + "EmphasizedStyler"]; + var day = Timeline.DateTime.gregorianUnitLengths[Timeline.DateTime.DAY]; + + this.createIntervalMarker = function(date, labeller, unit, markerDiv, lineDiv) { + var offset = Math.round(band.dateToPixelOffset(date)); + + if (showLine && unit != Timeline.DateTime.WEEK) { + var divLine = timeline.getDocument().createElement("div"); + divLine.style.position = "absolute"; + + if (lineTheme.opacity < 100) { + Timeline.Graphics.setOpacity(divLine, lineTheme.opacity); + } + + if (horizontal) { + divLine.style.borderLeft = "1px solid " + lineTheme.color; + divLine.style.left = offset + "px"; + divLine.style.width = "1px"; + divLine.style.top = "0px"; + divLine.style.height = "100%"; + } else { + divLine.style.borderTop = "1px solid " + lineTheme.color; + divLine.style.top = offset + "px"; + divLine.style.height = "1px"; + divLine.style.left = "0px"; + divLine.style.width = "100%"; + } + lineDiv.appendChild(divLine); + } + if (unit == Timeline.DateTime.WEEK) { + var firstDayOfWeek = theme.firstDayOfWeek; + + var saturday = new Date(date.getTime() + (6 - firstDayOfWeek - 7) * day); + var monday = new Date(saturday.getTime() + 2 * day); + + var saturdayPixel = Math.round(band.dateToPixelOffset(saturday)); + var mondayPixel = Math.round(band.dateToPixelOffset(monday)); + var length = Math.max(1, mondayPixel - saturdayPixel); + + var divWeekend = timeline.getDocument().createElement("div"); + divWeekend.style.position = "absolute"; + + divWeekend.style.background = weekendTheme.color; + if (weekendTheme.opacity < 100) { + Timeline.Graphics.setOpacity(divWeekend, weekendTheme.opacity); + } + + if (horizontal) { + divWeekend.style.left = saturdayPixel + "px"; + divWeekend.style.width = length + "px"; + divWeekend.style.top = "0px"; + divWeekend.style.height = "100%"; + } else { + divWeekend.style.top = saturdayPixel + "px"; + divWeekend.style.height = length + "px"; + divWeekend.style.left = "0px"; + divWeekend.style.width = "100%"; + } + lineDiv.appendChild(divWeekend); + } + + var label = labeller.labelInterval(date, unit); + + var div = timeline.getDocument().createElement("div"); + div.innerHTML = label.text; + div.style.position = "absolute"; + (label.emphasized ? emphasizedLabelStyler : labelStyler)(div); + + this.positionDiv(div, offset); + markerDiv.appendChild(div); + + return div; + }; +}; + +/*================================================== + * Ether Highlight Layout + *================================================== + */ + +Timeline.EtherHighlight = function(timeline, band, theme, backgroundLayer) { + var horizontal = timeline.isHorizontal(); + + this._highlightDiv = null; + this._createHighlightDiv = function() { + if (this._highlightDiv == null) { + this._highlightDiv = timeline.getDocument().createElement("div"); + this._highlightDiv.setAttribute("name", "ether-highlight"); // for debugging + this._highlightDiv.style.position = "absolute"; + this._highlightDiv.style.background = theme.ether.highlightColor; + + var opacity = theme.ether.highlightOpacity; + if (opacity < 100) { + Timeline.Graphics.setOpacity(this._highlightDiv, opacity); + } + + backgroundLayer.appendChild(this._highlightDiv); + } + } + + this.position = function(startDate, endDate) { + this._createHighlightDiv(); + + var startPixel = Math.round(band.dateToPixelOffset(startDate)); + var endPixel = Math.round(band.dateToPixelOffset(endDate)); + var length = Math.max(endPixel - startPixel, 3); + if (horizontal) { + this._highlightDiv.style.left = startPixel + "px"; + this._highlightDiv.style.width = length + "px"; + this._highlightDiv.style.top = "2px"; + this._highlightDiv.style.height = (band.getViewWidth() - 4) + "px"; + } else { + this._highlightDiv.style.top = startPixel + "px"; + this._highlightDiv.style.height = length + "px"; + this._highlightDiv.style.left = "2px"; + this._highlightDiv.style.width = (band.getViewWidth() - 4) + "px"; + } + } +}; + Added: hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/ethers.js URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/ethers.js?rev=770000&view=auto ============================================================================== --- hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/ethers.js (added) +++ hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/ethers.js Wed Apr 29 23:33:50 2009 @@ -0,0 +1,250 @@ +/*================================================== + * Linear Ether + *================================================== + */ + +Timeline.LinearEther = function(params) { + this._params = params; + this._interval = params.interval; + this._pixelsPerInterval = params.pixelsPerInterval; +}; + +Timeline.LinearEther.prototype.initialize = function(timeline) { + this._timeline = timeline; + this._unit = timeline.getUnit(); + + if ("startsOn" in this._params) { + this._start = this._unit.parseFromObject(this._params.startsOn); + } else if ("endsOn" in this._params) { + this._start = this._unit.parseFromObject(this._params.endsOn); + this.shiftPixels(-this._timeline.getPixelLength()); + } else if ("centersOn" in this._params) { + this._start = this._unit.parseFromObject(this._params.centersOn); + this.shiftPixels(-this._timeline.getPixelLength() / 2); + } else { + this._start = this._unit.makeDefaultValue(); + this.shiftPixels(-this._timeline.getPixelLength() / 2); + } +}; + +Timeline.LinearEther.prototype.setDate = function(date) { + this._start = this._unit.cloneValue(date); +}; + +Timeline.LinearEther.prototype.shiftPixels = function(pixels) { + var numeric = this._interval * pixels / this._pixelsPerInterval; + this._start = this._unit.change(this._start, numeric); +}; + +Timeline.LinearEther.prototype.dateToPixelOffset = function(date) { + var numeric = this._unit.compare(date, this._start); + return this._pixelsPerInterval * numeric / this._interval; +}; + +Timeline.LinearEther.prototype.pixelOffsetToDate = function(pixels) { + var numeric = pixels * this._interval / this._pixelsPerInterval; + return this._unit.change(this._start, numeric); +}; + +/*================================================== + * Hot Zone Ether + *================================================== + */ + +Timeline.HotZoneEther = function(params) { + this._params = params; + this._interval = params.interval; + this._pixelsPerInterval = params.pixelsPerInterval; +}; + +Timeline.HotZoneEther.prototype.initialize = function(timeline) { + this._timeline = timeline; + this._unit = timeline.getUnit(); + + this._zones = [{ + startTime: Number.NEGATIVE_INFINITY, + endTime: Number.POSITIVE_INFINITY, + magnify: 1 + }]; + var params = this._params; + for (var i = 0; i < params.zones.length; i++) { + var zone = params.zones[i]; + var zoneStart = this._unit.parseFromObject(zone.start); + var zoneEnd = this._unit.parseFromObject(zone.end); + + for (var j = 0; j < this._zones.length && this._unit.compare(zoneEnd, zoneStart) > 0; j++) { + var zone2 = this._zones[j]; + + if (this._unit.compare(zoneStart, zone2.endTime) < 0) { + if (this._unit.compare(zoneStart, zone2.startTime) > 0) { + this._zones.splice(j, 0, { + startTime: zone2.startTime, + endTime: zoneStart, + magnify: zone2.magnify + }); + j++; + + zone2.startTime = zoneStart; + } + + if (this._unit.compare(zoneEnd, zone2.endTime) < 0) { + this._zones.splice(j, 0, { + startTime: zoneStart, + endTime: zoneEnd, + magnify: zone.magnify * zone2.magnify + }); + j++; + + zone2.startTime = zoneEnd; + zoneStart = zoneEnd; + } else { + zone2.magnify *= zone.magnify; + zoneStart = zone2.endTime; + } + } // else, try the next existing zone + } + } + + if ("startsOn" in this._params) { + this._start = this._unit.parseFromObject(this._params.startsOn); + } else if ("endsOn" in this._params) { + this._start = this._unit.parseFromObject(this._params.endsOn); + this.shiftPixels(-this._timeline.getPixelLength()); + } else if ("centersOn" in this._params) { + this._start = this._unit.parseFromObject(this._params.centersOn); + this.shiftPixels(-this._timeline.getPixelLength() / 2); + } else { + this._start = this._unit.makeDefaultValue(); + this.shiftPixels(-this._timeline.getPixelLength() / 2); + } +}; + +Timeline.HotZoneEther.prototype.setDate = function(date) { + this._start = this._unit.cloneValue(date); +}; + +Timeline.HotZoneEther.prototype.shiftPixels = function(pixels) { + this._start = this.pixelOffsetToDate(pixels); +}; + +Timeline.HotZoneEther.prototype.dateToPixelOffset = function(date) { + return this._dateDiffToPixelOffset(this._start, date); +}; + +Timeline.HotZoneEther.prototype.pixelOffsetToDate = function(pixels) { + return this._pixelOffsetToDate(pixels, this._start); +}; + +Timeline.HotZoneEther.prototype._dateDiffToPixelOffset = function(fromDate, toDate) { + var scale = this._getScale(); + var fromTime = fromDate; + var toTime = toDate; + + var pixels = 0; + if (this._unit.compare(fromTime, toTime) < 0) { + var z = 0; + while (z < this._zones.length) { + if (this._unit.compare(fromTime, this._zones[z].endTime) < 0) { + break; + } + z++; + } + + while (this._unit.compare(fromTime, toTime) < 0) { + var zone = this._zones[z]; + var toTime2 = this._unit.earlier(toTime, zone.endTime); + + pixels += (this._unit.compare(toTime2, fromTime) / (scale / zone.magnify)); + + fromTime = toTime2; + z++; + } + } else { + var z = this._zones.length - 1; + while (z >= 0) { + if (this._unit.compare(fromTime, this._zones[z].startTime) > 0) { + break; + } + z--; + } + + while (this._unit.compare(fromTime, toTime) > 0) { + var zone = this._zones[z]; + var toTime2 = this._unit.later(toTime, zone.startTime); + + pixels += (this._unit.compare(toTime2, fromTime) / (scale / zone.magnify)); + + fromTime = toTime2; + z--; + } + } + return pixels; +}; + +Timeline.HotZoneEther.prototype._pixelOffsetToDate = function(pixels, fromDate) { + var scale = this._getScale(); + var time = fromDate; + if (pixels > 0) { + var z = 0; + while (z < this._zones.length) { + if (this._unit.compare(time, this._zones[z].endTime) < 0) { + break; + } + z++; + } + + while (pixels > 0) { + var zone = this._zones[z]; + var scale2 = scale / zone.magnify; + + if (zone.endTime == Number.POSITIVE_INFINITY) { + time = this._unit.change(time, pixels * scale2); + pixels = 0; + } else { + var pixels2 = this._unit.compare(zone.endTime, time) / scale2; + if (pixels2 > pixels) { + time = this._unit.change(time, pixels * scale2); + pixels = 0; + } else { + time = zone.endTime; + pixels -= pixels2; + } + } + z++; + } + } else { + var z = this._zones.length - 1; + while (z >= 0) { + if (this._unit.compare(time, this._zones[z].startTime) > 0) { + break; + } + z--; + } + + pixels = -pixels; + while (pixels > 0) { + var zone = this._zones[z]; + var scale2 = scale / zone.magnify; + + if (zone.startTime == Number.NEGATIVE_INFINITY) { + time = this._unit.change(time, -pixels * scale2); + pixels = 0; + } else { + var pixels2 = this._unit.compare(time, zone.startTime) / scale2; + if (pixels2 > pixels) { + time = this._unit.change(time, -pixels * scale2); + pixels = 0; + } else { + time = zone.startTime; + pixels -= pixels2; + } + } + z--; + } + } + return time; +}; + +Timeline.HotZoneEther.prototype._getScale = function() { + return this._interval / this._pixelsPerInterval; +}; Added: hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/ext/japanese-eras.js URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/ext/japanese-eras.js?rev=770000&view=auto ============================================================================== --- hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/ext/japanese-eras.js (added) +++ hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/ext/japanese-eras.js Wed Apr 29 23:33:50 2009 @@ -0,0 +1,395 @@ +/*================================================== + * Japanese Era Date Labeller + *================================================== + */ + +Timeline.JapaneseEraDateLabeller = function(locale, timeZone, useRomanizedName) { + var o = new Timeline.GregorianDateLabeller(locale, timeZone); + + o._useRomanizedName = (useRomanizedName); + o._oldLabelInterval = o.labelInterval; + o.labelInterval = Timeline.JapaneseEraDateLabeller._labelInterval; + + return o; +}; + +Timeline.JapaneseEraDateLabeller._labelInterval = function(date, intervalUnit) { + var text; + var emphasized = false; + + var date2 = Timeline.DateTime.removeTimeZoneOffset(date, this._timeZone); + + switch(intervalUnit) { + case Timeline.DateTime.YEAR: + case Timeline.DateTime.DECADE: + case Timeline.DateTime.CENTURY: + case Timeline.DateTime.MILLENNIUM: + var y = date2.getUTCFullYear(); + if (y >= Timeline.JapaneseEraDateLabeller._eras.elementAt(0).startingYear) { + var eraIndex = Timeline.JapaneseEraDateLabeller._eras.find(function(era) { + return era.startingYear - y; + } + ); + if (eraIndex < Timeline.JapaneseEraDateLabeller._eras.length()) { + var era = Timeline.JapaneseEraDateLabeller._eras.elementAt(eraIndex); + if (y < era.startingYear) { + era = Timeline.JapaneseEraDateLabeller._eras.elementAt(eraIndex - 1); + } + } else { + var era = Timeline.JapaneseEraDateLabeller._eras.elementAt(eraIndex - 1); + } + + text = (this._useRomanizedName ? era.romanizedName : era.japaneseName) + " " + (y - era.startingYear + 1); + emphasized = intervalUnit == Timeline.DateTime.YEAR && y == era.startingYear; + break; + } // else, fall through + default: + return this._oldLabelInterval(date, intervalUnit); + } + + return { text: text, emphasized: emphasized }; +}; + +/*================================================== + * Japanese Era Ether Painter + *================================================== + */ + +Timeline.JapaneseEraEtherPainter = function(params, band, timeline) { + this._params = params; + this._theme = params.theme; +}; + +Timeline.JapaneseEraEtherPainter.prototype.initialize = function(band, timeline) { + this._band = band; + this._timeline = timeline; + + this._backgroundLayer = band.createLayerDiv(0); + this._backgroundLayer.setAttribute("name", "ether-background"); // for debugging + this._backgroundLayer.style.background = this._theme.ether.backgroundColors[band.getIndex()]; + + this._markerLayer = null; + this._lineLayer = null; + + var align = ("align" in this._params) ? this._params.align : + this._theme.ether.interval.marker[timeline.isHorizontal() ? "hAlign" : "vAlign"]; + var showLine = ("showLine" in this._params) ? this._params.showLine : + this._theme.ether.interval.line.show; + + this._intervalMarkerLayout = new Timeline.EtherIntervalMarkerLayout( + this._timeline, this._band, this._theme, align, showLine); + + this._highlight = new Timeline.EtherHighlight( + this._timeline, this._band, this._theme, this._backgroundLayer); +} + +Timeline.JapaneseEraEtherPainter.prototype.setHighlight = function(startDate, endDate) { + this._highlight.position(startDate, endDate); +} + +Timeline.JapaneseEraEtherPainter.prototype.paint = function() { + if (this._markerLayer) { + this._band.removeLayerDiv(this._markerLayer); + } + this._markerLayer = this._band.createLayerDiv(100); + this._markerLayer.setAttribute("name", "ether-markers"); // for debugging + this._markerLayer.style.display = "none"; + + if (this._lineLayer) { + this._band.removeLayerDiv(this._lineLayer); + } + this._lineLayer = this._band.createLayerDiv(1); + this._lineLayer.setAttribute("name", "ether-lines"); // for debugging + this._lineLayer.style.display = "none"; + + var minYear = this._band.getMinDate().getUTCFullYear(); + var maxYear = this._band.getMaxDate().getUTCFullYear(); + var eraIndex = Timeline.JapaneseEraDateLabeller._eras.find(function(era) { + return era.startingYear - minYear; + } + ); + + var l = Timeline.JapaneseEraDateLabeller._eras.length(); + for (var i = eraIndex; i < l; i++) { + var era = Timeline.JapaneseEraDateLabeller._eras.elementAt(i); + if (era.startingYear > maxYear) { + break; + } + + var d = new Date(0); + d.setUTCFullYear(era.startingYear); + + var labeller = { + labelInterval: function(date, intervalUnit) { + return { + text: era.japaneseName, + emphasized: true + }; + } + }; + + this._intervalMarkerLayout.createIntervalMarker( + d, labeller, Timeline.DateTime.YEAR, this._markerLayer, this._lineLayer); + } + this._markerLayer.style.display = "block"; + this._lineLayer.style.display = "block"; +}; + +Timeline.JapaneseEraEtherPainter.prototype.softPaint = function() { +}; + + +Timeline.JapaneseEraDateLabeller._eras = new Timeline.SortedArray( + function(e1, e2) { + return e1.startingYear - e2.startingYear; + }, + [ + { startingYear: 645, japaneseName: '大化', romanizedName: "Taika" }, + { startingYear: 650, japaneseName: '白雉', romanizedName: "Hakuchi" }, + { startingYear: 686, japaneseName: '朱鳥', romanizedName: "Shuchō" }, + { startingYear: 701, japaneseName: '大宝', romanizedName: "Taihō" }, + { startingYear: 704, japaneseName: '慶雲', romanizedName: "Keiun" }, + { startingYear: 708, japaneseName: '和銅', romanizedName: "Wadō" }, + { startingYear: 715, japaneseName: '霊亀', romanizedName: "Reiki" }, + { startingYear: 717, japaneseName: '養老', romanizedName: "Yōrō" }, + { startingYear: 724, japaneseName: '神亀', romanizedName: "Jinki" }, + { startingYear: 729, japaneseName: '天平', romanizedName: "Tenpyō" }, + { startingYear: 749, japaneseName: '天平感宝', romanizedName: "Tenpyō-kanpō" }, + { startingYear: 749, japaneseName: '天平勝宝', romanizedName: "Tenpyō-shōhō" }, + { startingYear: 757, japaneseName: '天平宝字', romanizedName: "Tenpyō-hōji" }, + { startingYear: 765, japaneseName: '天平神護', romanizedName: "Tenpyō-jingo" }, + { startingYear: 767, japaneseName: '神護景雲', romanizedName: "Jingo-keiun" }, + { startingYear: 770, japaneseName: '宝亀', romanizedName: "Hōki" }, + { startingYear: 781, japaneseName: '天応', romanizedName: "Ten'ō" }, + { startingYear: 782, japaneseName: '延暦', romanizedName: "Enryaku" }, + { startingYear: 806, japaneseName: '大同', romanizedName: "Daidō" }, + { startingYear: 810, japaneseName: '弘仁', romanizedName: "Kōnin" }, + { startingYear: 824, japaneseName: '天長', romanizedName: "Tenchō" }, + { startingYear: 834, japaneseName: '承和', romanizedName: "Jōwa" }, + { startingYear: 848, japaneseName: '嘉祥', romanizedName: "Kajō" }, + { startingYear: 851, japaneseName: '仁寿', romanizedName: "Ninju" }, + { startingYear: 854, japaneseName: '斉衡', romanizedName: "Saikō" }, + { startingYear: 857, japaneseName: '天安', romanizedName: "Tennan" }, + { startingYear: 859, japaneseName: '貞観', romanizedName: "Jōgan" }, + { startingYear: 877, japaneseName: '元慶', romanizedName: "Gangyō" }, + { startingYear: 885, japaneseName: '仁和', romanizedName: "Ninna" }, + { startingYear: 889, japaneseName: '寛平', romanizedName: "Kanpyō" }, + { startingYear: 898, japaneseName: '昌泰', romanizedName: "Shōtai" }, + { startingYear: 901, japaneseName: '延喜', romanizedName: "Engi" }, + { startingYear: 923, japaneseName: '延長', romanizedName: "Enchō" }, + { startingYear: 931, japaneseName: '承平', romanizedName: "Jōhei" }, + { startingYear: 938, japaneseName: '天慶', romanizedName: "Tengyō" }, + { startingYear: 947, japaneseName: '天暦', romanizedName: "Tenryaku" }, + { startingYear: 957, japaneseName: '天徳', romanizedName: "Tentoku" }, + { startingYear: 961, japaneseName: '応和', romanizedName: "Ōwa" }, + { startingYear: 964, japaneseName: '康保', romanizedName: "Kōhō" }, + { startingYear: 968, japaneseName: '安和', romanizedName: "Anna" }, + { startingYear: 970, japaneseName: '天禄', romanizedName: "Tenroku" }, + { startingYear: 973, japaneseName: '天延', romanizedName: "Ten'en" }, + { startingYear: 976, japaneseName: '貞元', romanizedName: "Jōgen" }, + { startingYear: 978, japaneseName: '天元', romanizedName: "Tengen" }, + { startingYear: 983, japaneseName: '永観', romanizedName: "Eikan" }, + { startingYear: 985, japaneseName: '寛和', romanizedName: "Kanna" }, + { startingYear: 987, japaneseName: '永延', romanizedName: "Eien" }, + { startingYear: 988, japaneseName: '永祚', romanizedName: "Eiso" }, + { startingYear: 990, japaneseName: '正暦', romanizedName: "Shōryaku" }, + { startingYear: 995, japaneseName: '長徳', romanizedName: "Chōtoku" }, + { startingYear: 999, japaneseName: '長保', romanizedName: "Chōhō" }, + { startingYear: 1004, japaneseName: '寛弘', romanizedName: "Kankō" }, + { startingYear: 1012, japaneseName: '長和', romanizedName: "Chōwa" }, + { startingYear: 1017, japaneseName: '寛仁', romanizedName: "Kannin" }, + { startingYear: 1021, japaneseName: '治安', romanizedName: "Jian" }, + { startingYear: 1024, japaneseName: '万寿', romanizedName: "Manju" }, + { startingYear: 1028, japaneseName: '長元', romanizedName: "Chōgen" }, + { startingYear: 1037, japaneseName: '長暦', romanizedName: "Chōryaku" }, + { startingYear: 1040, japaneseName: '長久', romanizedName: "ChōkyÅ«" }, + { startingYear: 1044, japaneseName: '寛徳', romanizedName: "Kantoku" }, + { startingYear: 1046, japaneseName: '永承', romanizedName: "Eishō" }, + { startingYear: 1053, japaneseName: '天喜', romanizedName: "Tengi" }, + { startingYear: 1058, japaneseName: '康平', romanizedName: "Kōhei" }, + { startingYear: 1065, japaneseName: '治暦', romanizedName: "Jiryaku" }, + { startingYear: 1069, japaneseName: '延久', romanizedName: "EnkyÅ«" }, + { startingYear: 1074, japaneseName: '承保', romanizedName: "Jōhō" }, + { startingYear: 1077, japaneseName: '承暦', romanizedName: "Jōryaku" }, + { startingYear: 1081, japaneseName: '永保', romanizedName: "Eihō" }, + { startingYear: 1084, japaneseName: '応徳', romanizedName: "Ōtoku" }, + { startingYear: 1087, japaneseName: '寛治', romanizedName: "Kanji" }, + { startingYear: 1094, japaneseName: '嘉保', romanizedName: "Kahō" }, + { startingYear: 1096, japaneseName: '永長', romanizedName: "Eichō" }, + { startingYear: 1097, japaneseName: '承徳', romanizedName: "Jōtoku" }, + { startingYear: 1099, japaneseName: '康和', romanizedName: "Kōwa" }, + { startingYear: 1104, japaneseName: '長治', romanizedName: "Chōji" }, + { startingYear: 1106, japaneseName: '嘉承', romanizedName: "Kajō" }, + { startingYear: 1108, japaneseName: '天仁', romanizedName: "Tennin" }, + { startingYear: 1110, japaneseName: '天永', romanizedName: "Ten'ei" }, + { startingYear: 1113, japaneseName: '永久', romanizedName: "EikyÅ«" }, + { startingYear: 1118, japaneseName: '元永', romanizedName: "Gen'ei" }, + { startingYear: 1120, japaneseName: '保安', romanizedName: "Hōan" }, + { startingYear: 1124, japaneseName: '天治', romanizedName: "Tenji" }, + { startingYear: 1126, japaneseName: '大治', romanizedName: "Daiji" }, + { startingYear: 1131, japaneseName: '天承', romanizedName: "Tenshō" }, + { startingYear: 1132, japaneseName: '長承', romanizedName: "Chōshō" }, + { startingYear: 1135, japaneseName: '保延', romanizedName: "Hōen" }, + { startingYear: 1141, japaneseName: '永治', romanizedName: "Eiji" }, + { startingYear: 1142, japaneseName: '康治', romanizedName: "Kōji" }, + { startingYear: 1144, japaneseName: '天養', romanizedName: "Ten'yō" }, + { startingYear: 1145, japaneseName: '久安', romanizedName: "KyÅ«an" }, + { startingYear: 1151, japaneseName: '仁平', romanizedName: "Ninpei" }, + { startingYear: 1154, japaneseName: '久寿', romanizedName: "KyÅ«ju" }, + { startingYear: 1156, japaneseName: '保元', romanizedName: "Hōgen" }, + { startingYear: 1159, japaneseName: '平治', romanizedName: "Heiji" }, + { startingYear: 1160, japaneseName: '永暦', romanizedName: "Eiryaku" }, + { startingYear: 1161, japaneseName: '応保', romanizedName: "Ōhō" }, + { startingYear: 1163, japaneseName: '長寛', romanizedName: "Chōkan" }, + { startingYear: 1165, japaneseName: '永万', romanizedName: "Eiman" }, + { startingYear: 1166, japaneseName: '仁安', romanizedName: "Ninnan" }, + { startingYear: 1169, japaneseName: '嘉応', romanizedName: "Kaō" }, + { startingYear: 1171, japaneseName: '承安', romanizedName: "Jōan" }, + { startingYear: 1175, japaneseName: '安元', romanizedName: "Angen" }, + { startingYear: 1177, japaneseName: '治承', romanizedName: "Jishō" }, + { startingYear: 1181, japaneseName: '養和', romanizedName: "Yōwa" }, + { startingYear: 1182, japaneseName: '寿永', romanizedName: "Juei" }, + { startingYear: 1184, japaneseName: '元暦', romanizedName: "Genryaku" }, + { startingYear: 1185, japaneseName: '文治', romanizedName: "Bunji" }, + { startingYear: 1190, japaneseName: '建久', romanizedName: "KenkyÅ«" }, + { startingYear: 1199, japaneseName: '正治', romanizedName: "Shōji" }, + { startingYear: 1201, japaneseName: '建仁', romanizedName: "Kennin" }, + { startingYear: 1204, japaneseName: '元久', romanizedName: "GenkyÅ«" }, + { startingYear: 1206, japaneseName: '建永', romanizedName: "Ken'ei" }, + { startingYear: 1207, japaneseName: '承元', romanizedName: "Jōgen" }, + { startingYear: 1211, japaneseName: '建暦', romanizedName: "Kenryaku" }, + { startingYear: 1213, japaneseName: '建保', romanizedName: "Kenpō" }, + { startingYear: 1219, japaneseName: '承久', romanizedName: "JōkyÅ«" }, + { startingYear: 1222, japaneseName: '貞応', romanizedName: "Jōō" }, + { startingYear: 1224, japaneseName: '元仁', romanizedName: "Gennin" }, + { startingYear: 1225, japaneseName: '嘉禄', romanizedName: "Karoku" }, + { startingYear: 1227, japaneseName: '安貞', romanizedName: "Antei" }, + { startingYear: 1229, japaneseName: '寛喜', romanizedName: "Kanki" }, + { startingYear: 1232, japaneseName: '貞永', romanizedName: "Jōei" }, + { startingYear: 1233, japaneseName: '天福', romanizedName: "Tenpuku" }, + { startingYear: 1234, japaneseName: '文暦', romanizedName: "Bunryaku" }, + { startingYear: 1235, japaneseName: '嘉禎', romanizedName: "Katei" }, + { startingYear: 1238, japaneseName: '暦仁', romanizedName: "Ryakunin" }, + { startingYear: 1239, japaneseName: '延応', romanizedName: "En'ō" }, + { startingYear: 1240, japaneseName: '仁治', romanizedName: "Ninji" }, + { startingYear: 1243, japaneseName: '寛元', romanizedName: "Kangen" }, + { startingYear: 1247, japaneseName: '宝治', romanizedName: "Hōji" }, + { startingYear: 1249, japaneseName: '建長', romanizedName: "Kenchō" }, + { startingYear: 1256, japaneseName: '康元', romanizedName: "Kōgen" }, + { startingYear: 1257, japaneseName: '正嘉', romanizedName: "Shōka" }, + { startingYear: 1259, japaneseName: '正元', romanizedName: "Shōgen" }, + { startingYear: 1260, japaneseName: '文応', romanizedName: "Bun'ō" }, + { startingYear: 1261, japaneseName: '弘長', romanizedName: "Kōcho" }, + { startingYear: 1264, japaneseName: '文永', romanizedName: "Bun'ei" }, + { startingYear: 1275, japaneseName: '建治', romanizedName: "Kenji" }, + { startingYear: 1278, japaneseName: '弘安', romanizedName: "Kōan" }, + { startingYear: 1288, japaneseName: '正応', romanizedName: "Shōō" }, + { startingYear: 1293, japaneseName: '永仁', romanizedName: "Einin" }, + { startingYear: 1299, japaneseName: '正安', romanizedName: "Shōan" }, + { startingYear: 1302, japaneseName: '乾元', romanizedName: "Kengen" }, + { startingYear: 1303, japaneseName: '嘉元', romanizedName: "Kagen" }, + { startingYear: 1306, japaneseName: '徳治', romanizedName: "Tokuji" }, + { startingYear: 1308, japaneseName: '延慶', romanizedName: "Enkei" }, + { startingYear: 1311, japaneseName: '応長', romanizedName: "Ōchō" }, + { startingYear: 1312, japaneseName: '正和', romanizedName: "Shōwa" }, + { startingYear: 1317, japaneseName: '文保', romanizedName: "Bunpō" }, + { startingYear: 1319, japaneseName: '元応', romanizedName: "Gen'ō" }, + { startingYear: 1321, japaneseName: '元亨', romanizedName: "Genkyō" }, + { startingYear: 1324, japaneseName: '正中', romanizedName: "ShōchÅ«" }, + { startingYear: 1326, japaneseName: '嘉暦', romanizedName: "Karyaku" }, + { startingYear: 1329, japaneseName: '元徳', romanizedName: "Gentoku" }, + { startingYear: 1331, japaneseName: '元弘', romanizedName: "Genkō" }, + { startingYear: 1334, japaneseName: '建武', romanizedName: "Kenmu" }, + { startingYear: 1336, japaneseName: '延元', romanizedName: "Engen" }, + { startingYear: 1340, japaneseName: '興国', romanizedName: "Kōkoku" }, + { startingYear: 1346, japaneseName: '正平', romanizedName: "Shōhei" }, + { startingYear: 1370, japaneseName: '建徳', romanizedName: "Kentoku" }, + { startingYear: 1372, japaneseName: '文中', romanizedName: "BunchÅ«" }, + { startingYear: 1375, japaneseName: '天授', romanizedName: "Tenju" }, + { startingYear: 1381, japaneseName: '弘和', romanizedName: "Kōwa" }, + { startingYear: 1384, japaneseName: '元中', romanizedName: "GenchÅ«" }, + { startingYear: 1332, japaneseName: '正慶', romanizedName: "Shōkei" }, + { startingYear: 1338, japaneseName: '暦応', romanizedName: "Ryakuō" }, + { startingYear: 1342, japaneseName: '康永', romanizedName: "Kōei" }, + { startingYear: 1345, japaneseName: '貞和', romanizedName: "Jōwa" }, + { startingYear: 1350, japaneseName: '観応', romanizedName: "Kan'ō" }, + { startingYear: 1352, japaneseName: '文和', romanizedName: "Bunna" }, + { startingYear: 1356, japaneseName: '延文', romanizedName: "Enbun" }, + { startingYear: 1361, japaneseName: '康安', romanizedName: "Kōan" }, + { startingYear: 1362, japaneseName: '貞治', romanizedName: "Jōji" }, + { startingYear: 1368, japaneseName: '応安', romanizedName: "Ōan" }, + { startingYear: 1375, japaneseName: '永和', romanizedName: "Eiwa" }, + { startingYear: 1379, japaneseName: '康暦', romanizedName: "Kōryaku" }, + { startingYear: 1381, japaneseName: '永徳', romanizedName: "Eitoku" }, + { startingYear: 1384, japaneseName: '至徳', romanizedName: "Shitoku" }, + { startingYear: 1387, japaneseName: '嘉慶', romanizedName: "Kakei" }, + { startingYear: 1389, japaneseName: '康応', romanizedName: "Kōō" }, + { startingYear: 1390, japaneseName: '明徳', romanizedName: "Meitoku" }, + { startingYear: 1394, japaneseName: '応永', romanizedName: "Ōei" }, + { startingYear: 1428, japaneseName: '正長', romanizedName: "Shōchō" }, + { startingYear: 1429, japaneseName: '永享', romanizedName: "Eikyō" }, + { startingYear: 1441, japaneseName: '嘉吉', romanizedName: "Kakitsu" }, + { startingYear: 1444, japaneseName: '文安', romanizedName: "Bunnan" }, + { startingYear: 1449, japaneseName: '宝徳', romanizedName: "Hōtoku" }, + { startingYear: 1452, japaneseName: '享徳', romanizedName: "Kyōtoku" }, + { startingYear: 1455, japaneseName: '康正', romanizedName: "Kōshō" }, + { startingYear: 1457, japaneseName: '長禄', romanizedName: "Chōroku" }, + { startingYear: 1460, japaneseName: '寛正', romanizedName: "Kanshō" }, + { startingYear: 1466, japaneseName: '文正', romanizedName: "Bunshō" }, + { startingYear: 1467, japaneseName: '応仁', romanizedName: "Ōnin" }, + { startingYear: 1469, japaneseName: '文明', romanizedName: "Bunmei" }, + { startingYear: 1487, japaneseName: '長享', romanizedName: "Chōkyō" }, + { startingYear: 1489, japaneseName: '延徳', romanizedName: "Entoku" }, + { startingYear: 1492, japaneseName: '明応', romanizedName: "Meiō" }, + { startingYear: 1501, japaneseName: '文亀', romanizedName: "Bunki" }, + { startingYear: 1504, japaneseName: '永正', romanizedName: "Eishō" }, + { startingYear: 1521, japaneseName: '大永', romanizedName: "Daiei" }, + { startingYear: 1528, japaneseName: '享禄', romanizedName: "Kyōroku" }, + { startingYear: 1532, japaneseName: '天文', romanizedName: "Tenbun" }, + { startingYear: 1555, japaneseName: '弘治', romanizedName: "Kōji" }, + { startingYear: 1558, japaneseName: '永禄', romanizedName: "Eiroku" }, + { startingYear: 1570, japaneseName: '元亀', romanizedName: "Genki" }, + { startingYear: 1573, japaneseName: '天正', romanizedName: "Tenshō" }, + { startingYear: 1592, japaneseName: '文禄', romanizedName: "Bunroku" }, + { startingYear: 1596, japaneseName: '慶長', romanizedName: "Keichō" }, + { startingYear: 1615, japaneseName: '元和', romanizedName: "Genna" }, + { startingYear: 1624, japaneseName: '寛永', romanizedName: "Kan'ei" }, + { startingYear: 1644, japaneseName: '正保', romanizedName: "Shōhō" }, + { startingYear: 1648, japaneseName: '慶安', romanizedName: "Keian" }, + { startingYear: 1652, japaneseName: '承応', romanizedName: "Jōō" }, + { startingYear: 1655, japaneseName: '明暦', romanizedName: "Meireki" }, + { startingYear: 1658, japaneseName: '万治', romanizedName: "Manji" }, + { startingYear: 1661, japaneseName: '寛文', romanizedName: "Kanbun" }, + { startingYear: 1673, japaneseName: '延宝', romanizedName: "Enpō" }, + { startingYear: 1681, japaneseName: '天和', romanizedName: "Tenna" }, + { startingYear: 1684, japaneseName: '貞享', romanizedName: "Jōkyō" }, + { startingYear: 1688, japaneseName: '元禄', romanizedName: "Genroku" }, + { startingYear: 1704, japaneseName: '宝永', romanizedName: "Hōei" }, + { startingYear: 1711, japaneseName: '正徳', romanizedName: "Shōtoku" }, + { startingYear: 1716, japaneseName: '享保', romanizedName: "Kyōhō" }, + { startingYear: 1736, japaneseName: '元文', romanizedName: "Genbun" }, + { startingYear: 1741, japaneseName: '寛保', romanizedName: "Kanpō" }, + { startingYear: 1744, japaneseName: '延享', romanizedName: "Enkyō" }, + { startingYear: 1748, japaneseName: '寛延', romanizedName: "Kan'en" }, + { startingYear: 1751, japaneseName: '宝暦', romanizedName: "Hōreki" }, + { startingYear: 1764, japaneseName: '明和', romanizedName: "Meiwa" }, + { startingYear: 1772, japaneseName: '安永', romanizedName: "An'ei" }, + { startingYear: 1781, japaneseName: '天明', romanizedName: "Tenmei" }, + { startingYear: 1789, japaneseName: '寛政', romanizedName: "Kansei" }, + { startingYear: 1801, japaneseName: '享和', romanizedName: "Kyōwa" }, + { startingYear: 1804, japaneseName: '文化', romanizedName: "Bunka" }, + { startingYear: 1818, japaneseName: '文政', romanizedName: "Bunsei" }, + { startingYear: 1830, japaneseName: '天保', romanizedName: "Tenpō" }, + { startingYear: 1844, japaneseName: '弘化', romanizedName: "Kōka" }, + { startingYear: 1848, japaneseName: '嘉永', romanizedName: "Kaei" }, + { startingYear: 1854, japaneseName: '安政', romanizedName: "Ansei" }, + { startingYear: 1860, japaneseName: '万延', romanizedName: "Man'en" }, + { startingYear: 1861, japaneseName: '文久', romanizedName: "BunkyÅ«" }, + { startingYear: 1864, japaneseName: '元治', romanizedName: "Genji" }, + { startingYear: 1865, japaneseName: '慶応', romanizedName: "Keiō" }, + { startingYear: 1868, japaneseName: '明治', romanizedName: "Meiji" }, + { startingYear: 1912, japaneseName: '大正', romanizedName: "Taishō" }, + { startingYear: 1926, japaneseName: '昭和', romanizedName: "Shōwa" }, + { startingYear: 1989, japaneseName: '平成', romanizedName: "Heisei" } + ] +); Added: hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/cs/labellers.js URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/cs/labellers.js?rev=770000&view=auto ============================================================================== --- hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/cs/labellers.js (added) +++ hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/cs/labellers.js Wed Apr 29 23:33:50 2009 @@ -0,0 +1,30 @@ +/*================================================== + * Localization of labellers.js + *================================================== + */ + +Timeline.GregorianDateLabeller.monthNames["cs"] = [ + "Leden", "Únor", "Bøezen", "Duben", "Kvìten", "Èerven", "Èervenec", "Srpen", "Záøí", "Øíjen", "Listopad", "Prosinec" +]; + +Timeline.GregorianDateLabeller.dayNames["cs"] = [ + "Ne", "Po", "Út", "St", "Èt", "Pá", "So" +]; + +Timeline.GregorianDateLabeller.labelIntervalFunctions["cs"] = function(date, intervalUnit) { + var text; + var emphasized = false; + + var date2 = Timeline.DateTime.removeTimeZoneOffset(date, this._timeZone); + + switch(intervalUnit) { + case Timeline.DateTime.DAY: + case Timeline.DateTime.WEEK: + text = date2.getUTCDate() + ". " + (date2.getUTCMonth() + 1) + "."; + break; + default: + return this.defaultLabelInterval(date, intervalUnit); + } + + return { text: text, emphasized: emphasized }; +}; Added: hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/cs/timeline.js URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/cs/timeline.js?rev=770000&view=auto ============================================================================== --- hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/cs/timeline.js (added) +++ hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/cs/timeline.js Wed Apr 29 23:33:50 2009 @@ -0,0 +1,9 @@ +/*================================================== + * Common localization strings + *================================================== + */ + +Timeline.strings["cs"] = { + wikiLinkLabel: "Diskuze" +}; + Added: hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/de/labellers.js URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/de/labellers.js?rev=770000&view=auto ============================================================================== --- hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/de/labellers.js (added) +++ hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/de/labellers.js Wed Apr 29 23:33:50 2009 @@ -0,0 +1,27 @@ +/*================================================== + * Localization of labellers.js + *================================================== + */ + +Timeline.GregorianDateLabeller.monthNames["de"] = [ + "Jan", "Feb", "Mrz", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez" +]; + +Timeline.GregorianDateLabeller.labelIntervalFunctions["de"] = function(date, intervalUnit) { + var text; + var emphasized = false; + + var date2 = Timeline.DateTime.removeTimeZoneOffset(date, this._timeZone); + + switch(intervalUnit) { + case Timeline.DateTime.DAY: + case Timeline.DateTime.WEEK: + text = date2.getUTCDate() + ". " + + Timeline.GregorianDateLabeller.getMonthName(date2.getUTCMonth(), this._locale); + break; + default: + return this.defaultLabelInterval(date, intervalUnit); + } + + return { text: text, emphasized: emphasized }; +}; \ No newline at end of file Added: hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/de/timeline.js URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/de/timeline.js?rev=770000&view=auto ============================================================================== --- hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/de/timeline.js (added) +++ hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/de/timeline.js Wed Apr 29 23:33:50 2009 @@ -0,0 +1,8 @@ +/*================================================== + * Common localization strings + *================================================== + */ + +Timeline.strings["de"] = { + wikiLinkLabel: "Diskutieren" +}; Added: hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/en/labellers.js URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/en/labellers.js?rev=770000&view=auto ============================================================================== --- hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/en/labellers.js (added) +++ hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/en/labellers.js Wed Apr 29 23:33:50 2009 @@ -0,0 +1,8 @@ +/*================================================== + * Localization of labellers.js + *================================================== + */ + +Timeline.GregorianDateLabeller.monthNames["en"] = [ + "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" +]; Added: hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/en/timeline.js URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/en/timeline.js?rev=770000&view=auto ============================================================================== --- hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/en/timeline.js (added) +++ hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/en/timeline.js Wed Apr 29 23:33:50 2009 @@ -0,0 +1,9 @@ +/*================================================== + * Common localization strings + *================================================== + */ + +Timeline.strings["en"] = { + wikiLinkLabel: "Discuss" +}; + Added: hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/es/labellers.js URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/es/labellers.js?rev=770000&view=auto ============================================================================== --- hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/es/labellers.js (added) +++ hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/es/labellers.js Wed Apr 29 23:33:50 2009 @@ -0,0 +1,8 @@ +/*================================================== + * Localization of labellers.js + *================================================== + */ + +Timeline.GregorianDateLabeller.monthNames["es"] = [ + "Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic" +]; Added: hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/es/timeline.js URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/es/timeline.js?rev=770000&view=auto ============================================================================== --- hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/es/timeline.js (added) +++ hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/es/timeline.js Wed Apr 29 23:33:50 2009 @@ -0,0 +1,9 @@ +/*================================================== + * Common localization strings + *================================================== + */ + +Timeline.strings["es"] = { + wikiLinkLabel: "Discute" +}; + Added: hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/fr/labellers.js URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/fr/labellers.js?rev=770000&view=auto ============================================================================== --- hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/fr/labellers.js (added) +++ hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/fr/labellers.js Wed Apr 29 23:33:50 2009 @@ -0,0 +1,8 @@ +/*================================================== + * Localization of labellers.js + *================================================== + */ + +Timeline.GregorianDateLabeller.monthNames["fr"] = [ + "jan", "fev", "mar", "avr", "mai", "jui", "jui", "aou", "sep", "oct", "nov", "dec" +]; Added: hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/fr/timeline.js URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/fr/timeline.js?rev=770000&view=auto ============================================================================== --- hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/fr/timeline.js (added) +++ hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/fr/timeline.js Wed Apr 29 23:33:50 2009 @@ -0,0 +1,9 @@ +/*================================================== + * Common localization strings + *================================================== + */ + +Timeline.strings["fr"] = { + wikiLinkLabel: "Discute" +}; + Added: hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/it/labellers.js URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/it/labellers.js?rev=770000&view=auto ============================================================================== --- hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/it/labellers.js (added) +++ hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/it/labellers.js Wed Apr 29 23:33:50 2009 @@ -0,0 +1,8 @@ +/*================================================== + * Localization of labellers.js + *================================================== + */ + +Timeline.GregorianDateLabeller.monthNames["it"] = [ + "Gen", "Feb", "Mar", "Apr", "Mag", "Giu", "Lug", "Ago", "Set", "Ott", "Nov", "Dic" +]; Added: hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/it/timeline.js URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/it/timeline.js?rev=770000&view=auto ============================================================================== --- hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/it/timeline.js (added) +++ hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/it/timeline.js Wed Apr 29 23:33:50 2009 @@ -0,0 +1,9 @@ +/*================================================== + * Common localization strings + *================================================== + */ + +Timeline.strings["it"] = { + wikiLinkLabel: "Discuti" +}; + Added: hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/ru/labellers.js URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/ru/labellers.js?rev=770000&view=auto ============================================================================== --- hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/ru/labellers.js (added) +++ hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/ru/labellers.js Wed Apr 29 23:33:50 2009 @@ -0,0 +1,10 @@ +/*================================================== + * Localization of labellers.js + * + * UTF-8 encoded + *================================================== + */ + +Timeline.GregorianDateLabeller.monthNames["ru"] = [ + "Янв", "Фев", "Мар", "Апр", "Май", "Июн", "Июл", "Авг", "Сен", "Окт", "Ноя", "Дек" +]; Added: hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/ru/timeline.js URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/ru/timeline.js?rev=770000&view=auto ============================================================================== --- hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/ru/timeline.js (added) +++ hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/ru/timeline.js Wed Apr 29 23:33:50 2009 @@ -0,0 +1,9 @@ +/*================================================== + * Common localization strings + *================================================== + */ + +Timeline.strings["ru"] = { + wikiLinkLabel: "обсудите" +}; + Added: hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/se/labellers.js URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/se/labellers.js?rev=770000&view=auto ============================================================================== --- hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/se/labellers.js (added) +++ hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/se/labellers.js Wed Apr 29 23:33:50 2009 @@ -0,0 +1,12 @@ +/*================================================== + * Localization of labellers.js + *================================================== + */ + +Timeline.GregorianDateLabeller.monthNames["se"] = [ + "Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec" +]; + +Timeline.GregorianDateLabeller.dayNames["se"] = [ + "Sön", "MÃ¥n", "Tis", "Ons", "Tors", "Fre", "Lör" +]; Added: hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/se/timeline.js URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/se/timeline.js?rev=770000&view=auto ============================================================================== --- hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/se/timeline.js (added) +++ hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/se/timeline.js Wed Apr 29 23:33:50 2009 @@ -0,0 +1,9 @@ +/*================================================== + * Common localization strings + *================================================== + */ + +Timeline.strings["se"] = { + wikiLinkLabel: "Discuss" +}; + Added: hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/vi/labellers.js URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/vi/labellers.js?rev=770000&view=auto ============================================================================== --- hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/vi/labellers.js (added) +++ hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/vi/labellers.js Wed Apr 29 23:33:50 2009 @@ -0,0 +1,26 @@ +/*================================================== + * Localization of labellers.js + *================================================== + */ + +Timeline.GregorianDateLabeller.monthNames["vi"] = [ + "Tháng 1", "Tháng 2", "Tháng 3", "Tháng 4", "Tháng 5", "Tháng 6", "Tháng 7", "Tháng 8", "Tháng 9", "Tháng 10", "Tháng 11", "Tháng 12" +]; + +Timeline.GregorianDateLabeller.labelIntervalFunctions["vi"] = function(date, intervalUnit) { + var text; + var emphasized = false; + + var date2 = Timeline.DateTime.removeTimeZoneOffset(date, this._timeZone); + + switch(intervalUnit) { + case Timeline.DateTime.DAY: + case Timeline.DateTime.WEEK: + text = date2.getUTCDate() + "/" + (date2.getUTCMonth() + 1); + break; + default: + return this.defaultLabelInterval(date, intervalUnit); + } + + return { text: text, emphasized: emphasized }; +}; Added: hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/vi/timeline.js URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/vi/timeline.js?rev=770000&view=auto ============================================================================== --- hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/vi/timeline.js (added) +++ hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/vi/timeline.js Wed Apr 29 23:33:50 2009 @@ -0,0 +1,9 @@ +/*================================================== + * Common localization strings + *================================================== + */ + +Timeline.strings["vi"] = { + wikiLinkLabel: "Bàn luận" +}; + Added: hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/zh/labellers.js URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/zh/labellers.js?rev=770000&view=auto ============================================================================== --- hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/zh/labellers.js (added) +++ hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/zh/labellers.js Wed Apr 29 23:33:50 2009 @@ -0,0 +1,27 @@ +/*================================================== + * Localization of labellers.js + *================================================== + */ + +Timeline.GregorianDateLabeller.monthNames["zh"] = [ + "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月" +]; + +Timeline.GregorianDateLabeller.labelIntervalFunctions["zh"] = function(date, intervalUnit) { + var text; + var emphasized = false; + + var date2 = Timeline.DateTime.removeTimeZoneOffset(date, this._timeZone); + + switch(intervalUnit) { + case Timeline.DateTime.DAY: + case Timeline.DateTime.WEEK: + text = Timeline.GregorianDateLabeller.getMonthName(date2.getUTCMonth(), this._locale) + + date2.getUTCDate() + "日"; + break; + default: + return this.defaultLabelInterval(date, intervalUnit); + } + + return { text: text, emphasized: emphasized }; +}; \ No newline at end of file Added: hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/zh/timeline.js URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/zh/timeline.js?rev=770000&view=auto ============================================================================== --- hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/zh/timeline.js (added) +++ hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/l10n/zh/timeline.js Wed Apr 29 23:33:50 2009 @@ -0,0 +1,9 @@ +/*================================================== + * Common localization strings + *================================================== + */ + +Timeline.strings["zh"] = { + wikiLinkLabel: "讨论" +}; + Added: hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/labellers.js URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/labellers.js?rev=770000&view=auto ============================================================================== --- hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/labellers.js (added) +++ hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/labellers.js Wed Apr 29 23:33:50 2009 @@ -0,0 +1,91 @@ +/*================================================== + * Gregorian Date Labeller + *================================================== + */ + +Timeline.GregorianDateLabeller = function(locale, timeZone) { + this._locale = locale; + this._timeZone = timeZone; +}; + +Timeline.GregorianDateLabeller.monthNames = []; +Timeline.GregorianDateLabeller.dayNames = []; +Timeline.GregorianDateLabeller.labelIntervalFunctions = []; + +Timeline.GregorianDateLabeller.getMonthName = function(month, locale) { + return Timeline.GregorianDateLabeller.monthNames[locale][month]; +}; + +Timeline.GregorianDateLabeller.prototype.labelInterval = function(date, intervalUnit) { + var f = Timeline.GregorianDateLabeller.labelIntervalFunctions[this._locale]; + if (f == null) { + f = Timeline.GregorianDateLabeller.prototype.defaultLabelInterval; + } + return f.call(this, date, intervalUnit); +}; + +Timeline.GregorianDateLabeller.prototype.labelPrecise = function(date) { + return Timeline.DateTime.removeTimeZoneOffset( + date, + this._timeZone //+ (new Date().getTimezoneOffset() / 60) + ).toUTCString(); +}; + +Timeline.GregorianDateLabeller.prototype.defaultLabelInterval = function(date, intervalUnit) { + var text; + var emphasized = false; + + date = Timeline.DateTime.removeTimeZoneOffset(date, this._timeZone); + + switch(intervalUnit) { + case Timeline.DateTime.MILLISECOND: + text = date.getUTCMilliseconds(); + break; + case Timeline.DateTime.SECOND: + text = date.getUTCSeconds(); + break; + case Timeline.DateTime.MINUTE: + var m = date.getUTCMinutes(); + if (m == 0) { + text = date.getUTCHours() + ":00"; + emphasized = true; + } else { + text = m; + } + break; + case Timeline.DateTime.HOUR: + text = date.getUTCHours() + "hr"; + break; + case Timeline.DateTime.DAY: + text = Timeline.GregorianDateLabeller.getMonthName(date.getUTCMonth(), this._locale) + " " + date.getUTCDate(); + break; + case Timeline.DateTime.WEEK: + text = Timeline.GregorianDateLabeller.getMonthName(date.getUTCMonth(), this._locale) + " " + date.getUTCDate(); + break; + case Timeline.DateTime.MONTH: + var m = date.getUTCMonth(); + if (m != 0) { + text = Timeline.GregorianDateLabeller.getMonthName(m, this._locale); + break; + } // else, fall through + case Timeline.DateTime.YEAR: + case Timeline.DateTime.DECADE: + case Timeline.DateTime.CENTURY: + case Timeline.DateTime.MILLENNIUM: + var y = date.getUTCFullYear(); + if (y > 0) { + text = date.getUTCFullYear(); + } else { + text = (1 - y) + "BC"; + } + emphasized = + (intervalUnit == Timeline.DateTime.MONTH) || + (intervalUnit == Timeline.DateTime.DECADE && y % 100 == 0) || + (intervalUnit == Timeline.DateTime.CENTURY && y % 1000 == 0); + break; + default: + text = date.toUTCString(); + } + return { text: text, emphasized: emphasized }; +} + Added: hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/layouts.js URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/layouts.js?rev=770000&view=auto ============================================================================== --- hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/layouts.js (added) +++ hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/layouts.js Wed Apr 29 23:33:50 2009 @@ -0,0 +1,128 @@ +/*================================================== + * Static Track Based Layout + *================================================== + */ + + +Timeline.StaticTrackBasedLayout = function(params) { + this._eventSource = params.eventSource; + this._ether = params.ether; + this._theme = params.theme; + this._showText = ("showText" in params) ? params.showText : true; + + this._laidout = false; + + var layout = this; + if (this._eventSource != null) { + this._eventSource.addListener({ + onAddMany: function() { + layout._laidout = false; + } + }); + } +}; + +Timeline.StaticTrackBasedLayout.prototype.initialize = function(timeline) { + this._timeline = timeline; +}; + +Timeline.StaticTrackBasedLayout.prototype.getTrack = function(evt) { + if (!this._laidout) { + this._tracks = []; + this._layout(); + this._laidout = true; + } + return this._tracks[evt.getID()]; +}; + +Timeline.StaticTrackBasedLayout.prototype.getTrackCount = function() { + if (!this._laidout) { + this._tracks = []; + this._layout(); + this._laidout = true; + } + return this._trackCount; +}; + +Timeline.StaticTrackBasedLayout.prototype._layout = function() { + if (this._eventSource == null) { + return; + } + + var streams = [ Number.NEGATIVE_INFINITY ]; + var layout = this; + var showText = this._showText; + var theme = this._theme; + var eventTheme = theme.event; + + var layoutInstant = function(evt, startPixel, endPixel, streamOffset) { + var finalPixel = startPixel - 1; + if (evt.isImprecise()) { // imprecise time + finalPixel = endPixel; + } + if (showText) { + finalPixel = Math.max(finalPixel, startPixel + eventTheme.label.width); + } + + return finalPixel; + }; + var layoutDuration = function(evt, startPixel, endPixel, streamOffset) { + if (evt.isImprecise()) { // imprecise time + var startDate = evt.getStart(); + var endDate = evt.getEnd(); + + var startPixel2 = Math.round(layout._ether.dateToPixelOffset(startDate)); + var endPixel2 = Math.round(layout._ether.dateToPixelOffset(endDate)); + } else { + var startPixel2 = startPixel; + var endPixel2 = endPixel; + } + + var finalPixel = endPixel2; + var length = Math.max(endPixel2 - startPixel2, 1); + + if (showText) { + if (length < eventTheme.label.width) { + finalPixel = endPixel2 + eventTheme.label.width; + } + } + + return finalPixel; + }; + var layoutEvent = function(evt) { + var startDate = evt.getStart(); + var endDate = evt.getEnd(); + + var startPixel = Math.round(layout._ether.dateToPixelOffset(startDate)); + var endPixel = Math.round(layout._ether.dateToPixelOffset(endDate)); + + var streamIndex = 0; + for (; streamIndex < streams.length; streamIndex++) { + if (streams[streamIndex] < startPixel) { + break; + } + } + if (streamIndex >= streams.length) { + streams.push(Number.NEGATIVE_INFINITY); + } + + var streamOffset = (eventTheme.track.offset + + streamIndex * (eventTheme.track.height + eventTheme.track.gap)) + "em"; + + layout._tracks[evt.getID()] = streamIndex; + + if (evt.isInstant()) { + streams[streamIndex] = layoutInstant(evt, startPixel, endPixel, streamOffset); + } else { + streams[streamIndex] = layoutDuration(evt, startPixel, endPixel, streamOffset); + } + }; + + var iterator = this._eventSource.getAllEventIterator(); + while (iterator.hasNext()) { + var evt = iterator.next(); + layoutEvent(evt); + } + + this._trackCount = streams.length; +}; \ No newline at end of file