SNR 635在ArrayExpress在数轴上表示下列各数什么

小木虫 --- 700万学术达人喜爱的学术科研平台
热门搜索:
&&小白一个,Array Express 和 GEO 求教入门,可再追加金币,拜托各位大神啦~
小白一个,Array Express 和 GEO 求教入门,可再追加金币,拜托各位大神啦~
前几天听人说可以从这两个数据库下载免费基因芯片信息。。。。登陆进去就傻眼了,都不知道是什么。。。。我学细胞生物的,完全不懂生物信息。。。
最主要希望知道:
1、一般挖掘数据下载那个选项?(比如array express中打开有很多文件可以下载)
2、是直接点击下载的那个图标下载吗?(我下载了一个文件,打开全是txt文件,不知道该怎么看)
3、下载到的数据应该怎么分析?有哪些免费分析软件吗?
因为是小白,能想到的问题只有以上。。。大神们多多教导啊~越详细越好~拜托了~
我只是想看看这些公开的芯片,挖掘一下看有没有我能用的数据……没明白你说的那些……从哪里开始啊?
还是不要吓唬楼主了。Linux其实并没有什么很难的,一些基本操作直接网上搜搜都有介绍怎么用的;更何况R并非一定要Linux,Win的用起来也挺好的。大家都是从一点都不懂开始的,其实这个东西也就是个经验,东攒一点西攒一点,多少学一点还是没错的:)
学术必备与600万学术达人在线互动!
扫描下载送金币
北京学而思教育科技有限公司 地址:北京市海淀区北三环甲18号中鼎大厦A座1层102室 电话:010-项目语言:JAVASCRIPT
权限:read-only(如需更高权限请先加入项目)
Index: BitmapText.ts
===================================================================
--- BitmapText.ts (revision 0)
+++ BitmapText.ts (revision 19)
@@ -0,0 +1,519 @@
+//////////////////////////////////////////////////////////////////////////////////////
Copyright (c) , Egret Technology Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Egret nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS &AS IS& AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//////////////////////////////////////////////////////////////////////////////////////
+module egret {
* @private
const enum Keys {
* @private
textFieldWidth,
* @private
textFieldHeight,
* @private
* @private
lineSpacing,
* @private
letterSpacing,
* @private
* @private
fontStringChanged,
* @private
textLinesChanged,
* @language en_US
* Bitmap font adopts the Bitmap+SpriteSheet mode to render text.
* @version Egret 2.4
* @platform Web,Native
* @includeExample egret/text/BitmapText.ts
* @language zh_CN
* 位图字体采用了Bitmap+SpriteSheet的方式来渲染文字。
* @version Egret 2.4
* @platform Web,Native
* @includeExample egret/text/BitmapText.ts
export class BitmapText extends DisplayObject {
* @language en_US
* Create an egret.BitmapText object
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 创建一个 egret.BitmapText 对象
* @version Egret 2.4
* @platform Web,Native
public constructor() {
//this.cacheAsBitmap =
this.$renderRegion = new sys.Region();
this.$BitmapText = {
//textFieldWidth,
//textFieldHeight,
//lineSpacing,
//letterSpacing,
//fontStringChanged,
//textLinesChanged,
* @private
$BitmapText:O
* @language en_US
* A string to display in the text field.
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 要显示的文本内容
* @version Egret 2.4
* @platform Web,Native
public get text():string {
return this.$BitmapText[Keys.text];
public set text(value:string) {
this.$setText(value);
* @private
$setText(value:string):boolean{
var values = this.$BitmapT
if (value == values[Keys.text])
values[Keys.text] =
this.$invalidateContentBounds();
* @private
$getWidth():number {
var w = this.$BitmapText[Keys.textFieldWidth];
return isNaN(w) ? this.$getContentBounds().width :
* @private
$setWidth(value:number):boolean {
//value = +value || 0;
var values = this.$BitmapT
if (value & 0 || value == values[Keys.textFieldWidth]) {
values[Keys.textFieldWidth] =
this.$invalidateContentBounds();
* @private
$invalidateContentBounds():void {
super.$invalidateContentBounds();
this.$BitmapText[Keys.textLinesChanged] =
* @private
$getHeight():number {
var h = this.$BitmapText[Keys.textFieldHeight];
return isNaN(h) ? this.$getContentBounds().height :
* @private
$setHeight(value:number):boolean {
//value = +value || 0;
var values = this.$BitmapT
if (value & 0 || value == values[Keys.textFieldHeight]) {
values[Keys.textFieldHeight] =
this.$invalidateContentBounds();
* @language en_US
* The name of the font to use, or a comma-separated list of font names.
* @default null
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 要使用的字体的名称或用逗号分隔的字体名称列表。
* @default null
* @version Egret 2.4
* @platform Web,Native
public get font():BitmapFont {
return this.$BitmapText[Keys.font];
public set font(value:BitmapFont) {
this.$setFont(value);
$setFont(value:BitmapFont):boolean {
var values = this.$BitmapT
if (values[Keys.font] == value) {
values[Keys.font] =
this.$BitmapText[Keys.fontStringChanged] =
this.$invalidateContentBounds();
* @language en_US
* An integer representing the amount of vertical space between lines.
* @default 0
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 一个整数,表示行与行之间的垂直间距量
* @default 0
* @version Egret 2.4
* @platform Web,Native
public get lineSpacing():number {
return this.$BitmapText[Keys.lineSpacing];
public set lineSpacing(value:number) {
this.$setLineSpacing(value);
$setLineSpacing(value:number):boolean {
value = +value || 0;
var values = this.$BitmapT
if (values[Keys.lineSpacing] == value)
values[Keys.lineSpacing] =
this.$invalidateContentBounds();
* @language en_US
* An integer representing the amount of distance between characters.
* @default 0
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 一个整数,表示字符之间的距量。
* @default 0
* @version Egret 2.4
* @platform Web,Native
public get letterSpacing():number {
return this.$BitmapText[Keys.letterSpacing];
public set letterSpacing(value:number) {
this.$setLetterSpacing(value);
$setLetterSpacing(value:number):boolean {
value = +value || 0;
var values = this.$BitmapT
if (values[Keys.letterSpacing] == value)
values[Keys.letterSpacing] =
this.$invalidateContentBounds();
* @language en_US
* A ratio of the width of the space character. This value is multiplied by the height of the first character is the space character width.
* @default 0.33
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 一个空格字符的宽度比例。这个数值乘以第一个字符的高度即为空格字符的宽。
* @default 0.33
* @version Egret 2.4
* @platform Web,Native
public static EMPTY_FACTOR:number = 0.33;
* @private
$render(context:egret.sys.RenderContext):void {
var self =
var textLines:Array&string& = self.$getTextLines();
var length:number = textLines.
if (length == 0) {
var bitmapFont:BitmapFont = self.$BitmapText[Keys.font];
var emptyHeight:number = bitmapFont._getFirstCharHeight();
var emptyWidth:number = Math.ceil(emptyHeight * BitmapText.EMPTY_FACTOR);
var yPos:number = 0;
var hasSetHeight:boolean = !isNaN(self.$BitmapText[Keys.textFieldHeight]);
var textFieldHeight:number = self.$BitmapText[Keys.textFieldHeight];
var lineHeights:Array&number& = self.$lineH
for (var i:number = 0; i & i++) {
var lineHeight:number = lineHeights[i];
if (hasSetHeight && i & 0 && yPos + lineHeight & textFieldHeight) {
var line:string = textLines[i];
var len:number = line.
var xPos:number = 0;
for (var j:number = 0; j & j++) {
var character = line.charAt(j);
var texture = bitmapFont.getTexture(character);
if (!texture) {
if (character == & &) {
xPos += emptyW
egret.$warn(1011, character);
var bitmapWidth:number = texture._bitmapW
var bitmapHeight:number = texture._bitmapH
context.drawImage(texture._bitmapData, texture._bitmapX, texture._bitmapY,
bitmapWidth, bitmapHeight, xPos + texture._offsetX, yPos + texture._offsetY, texture.$getScaleBitmapWidth(), texture.$getScaleBitmapHeight());
xPos += texture.$getTextureWidth() + self.$BitmapText[Keys.letterSpacing];
yPos += lineHeight + self.$BitmapText[Keys.lineSpacing];
* @private
$measureContentBounds(bounds:Rectangle):void {
var lines:Array&string& = this.$getTextLines();
if (lines.length == 0) {
bounds.setEmpty();
bounds.setTo(this.textOffsetX, this.textOffsetY, this.textWidth - this.textOffsetX,
this.textHeight - this.textOffsetY + (lines.length - 1) * this.$BitmapText[Keys.lineSpacing]);
* @private
private textWidth:number = 0;
* @private
private textHeight:number = 0;
* @private
private textOffsetX:number = 0;
* @private
private textOffsetY:number = 0;
* @private
private textLines:Array&string&;
* @private
public $lineHeights:Array&number& = [];
* @private
* @returns
$getTextLines():Array&string& {
var self =
if (!this.$BitmapText[Keys.textLinesChanged]) {
return self.textL
var textLines:Array&string& = [];
self.textLines = textL
this.$BitmapText[Keys.textLinesChanged] =
var lineHeights:Array&number& = [];
self.$lineHeights = lineH
if (!self.$BitmapText[Keys.text] || !self.$BitmapText[Keys.font]) {
return textL
var textWidth:number = 0;
var textHeight:number = 0;
var textStartX:number = 0;
var textStartY:number = 0;
var hasWidthSet:boolean = !isNaN(self.$BitmapText[Keys.textFieldWidth]);
var textFieldWidth:number = self.$BitmapText[Keys.textFieldWidth];
var bitmapFont:BitmapFont = self.$BitmapText[Keys.font];
var emptyHeight:number = bitmapFont._getFirstCharHeight();
var emptyWidth:number = Math.ceil(emptyHeight * BitmapText.EMPTY_FACTOR);
var text:string = self.$BitmapText[Keys.text];
var textArr:Array&string& = text.split(/(?:\r\n|\r|\n)/);
var length:number = textArr.
var isFirstLine:boolean =
for (var i = 0; i & i++) {
var line:string = textArr[i];
var len = line.
var lineHeight:number = 0;
var xPos:number = 0;
var isFirstChar:boolean =
for (var j = 0; j & j++) {
if (!isFirstChar) {
xPos += self.$BitmapText[Keys.letterSpacing];
var character = line.charAt(j);
var texureWidth:
var textureHeight:
var offsetX:number = 0;
var offsetY:number = 0;
var texture = bitmapFont.getTexture(character);
if (!texture) {
if (character == & &) {
texureWidth = emptyW
textureHeight = emptyH
egret.$warn(1011, character);
if (isFirstChar) {
isFirstChar =
texureWidth = texture.$getTextureWidth();
textureHeight = texture.$getTextureHeight();
offsetX = texture._offsetX;
offsetY = texture._offsetY;
if (isFirstChar) {
isFirstChar =
textStartX = Math.min(offsetX, textStartX);
if (isFirstLine) {
textStartY = Math.min(offsetY, textStartY);
if (hasWidthSet && j & 0 && xPos + texureWidth & textFieldWidth) {
textLines.push(line.substring(0, j));
lineHeights.push(lineHeight);
textHeight += lineH
textWidth = Math.max(xPos, textWidth);
line = line.substring(j);
len = line.
xPos = texureW
lineHeight = textureH
xPos += texureW
lineHeight = Math.max(textureHeight, lineHeight);
if (isFirstLine) {
isFirstLine =
textLines.push(line);
lineHeights.push(lineHeight);
textHeight += lineH
textWidth = Math.max(xPos, textWidth);
self.textWidth = textW
self.textHeight = textH
self.textOffsetX = textStartX;
self.textOffsetY = textStartY;
return textL
Index: native/NativeStageText.ts
===================================================================
--- native/NativeStageText.ts (revision 0)
+++ native/NativeStageText.ts (revision 19)
@@ -0,0 +1,187 @@
+//////////////////////////////////////////////////////////////////////////////////////
Copyright (c) , Egret Technology Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Egret nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS &AS IS& AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//////////////////////////////////////////////////////////////////////////////////////
+module egret {
* @classdesc
* @implements egret.StageText
* @private
* @version Egret 2.4
* @platform Web,Native
export class NativeStageText extends EventDispatcher implements StageText {
* @private
private textValue:string = &&;
* @version Egret 2.4
* @platform Web,Native
constructor() {
this.textValue = &&;
* @private
* @returns
public $getText():string {
if (!this.textValue) {
this.textValue = &&;
return this.textV
* @private
* @param value
$setText(value:string):boolean {
this.textValue =
* @private
$onBlur():void {
* @private
private isFinishDown:boolean =
//全屏键盘
private showScreenKeyboard():void {
var self =
self.dispatchEvent(new egret.Event(&focus&));
Event.dispatchEvent(self, &focus&, false, {&showing& : true});
egret_native.EGT_TextInput = function (appendText:string) {
if (self.$textfield.multiline) {//多行文本
if (self.isFinishDown) {
self.isFinishDown =
self.textValue = appendT
self.dispatchEvent(new egret.Event(&updateText&));
else {//单行文本
self.textValue = appendText.replace(/[\n|\r]/, &&);
//关闭软键盘
egret_native.TextInputOp.setKeybordOpen(false);
self.dispatchEvent(new egret.Event(&updateText&));
self.dispatchEvent(new egret.Event(&blur&));
//点击完成
egret_native.EGT_keyboardFinish = function () {
if (self.$textfield.multiline) {//多行文本
self.isFinishDown =
self.dispatchEvent(new egret.Event(&blur&));
* @private
public $show():void {
var self =
egret_native.EGT_getTextEditerContentText = function () {
return self.$getText();
egret_native.EGT_keyboardDidShow = function () {
//if (egret_native.TextInputOp.isFullScreenKeyBoard()) {//横屏
self.showScreenKeyboard();
egret_native.EGT_keyboardDidShow = function () {
var textfield:egret.TextField = this.$
var inputMode = textfield.multiline ? 0 : 6;
var inputFlag = -1;//textfield.displayAsPassword ? 0 : -1;
var returnType = 1;
var maxLength = textfield.maxChars &= 0 ? -1 : textfield.maxC
egret_native.TextInputOp.setKeybordOpen(true, JSON.stringify({&inputMode& : inputMode,
&inputFlag& : inputFlag,
&returnType& :returnType,
&maxLength& :maxLength}));
* @private
public $hide():void {
this.dispatchEvent(new egret.Event(&blur&));
egret_native.TextInputOp.setKeybordOpen(false);
$resetStageText():void {
public $addToStage():void {
public $removeFromStage():void {
* @private
$textfield:egret.TextF
$setTextField(value:egret.TextField):boolean {
this.$textfield =
StageText = NativeStageT
\ No newline at end of file
Index: BitmapFont.ts
===================================================================
--- BitmapFont.ts (revision 0)
+++ BitmapFont.ts (revision 19)
@@ -0,0 +1,201 @@
+//////////////////////////////////////////////////////////////////////////////////////
Copyright (c) , Egret Technology Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Egret nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS &AS IS& AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//////////////////////////////////////////////////////////////////////////////////////
+module egret {
* @language en_US
* Bitmap font, texture set of a font. It is generally used as the value of the BitmapText.font attribute.
* @see http://bbs.egret-labs.org/thread-918-1-1.html TextureMerger
* @see http://bbs.egret-labs.org/forum.php?mod=viewthread&tid=251 Text(Containing the specific usage of the bitmap font )
* @version Egret 2.4
* @platform Web,Native
* @includeExample egret/text/BitmapFont.ts
* @language zh_CN
* 位图字体,是一个字体的纹理集,通常作为BitmapText.font属性的值。
* @see http://bbs.egret-labs.org/thread-918-1-1.html TextureMerger
* @see http://bbs.egret-labs.org/forum.php?mod=viewthread&tid=251 文本(含位图字体具体用法)
* @version Egret 2.4
* @platform Web,Native
* @includeExample egret/text/BitmapFont.ts
export class BitmapFont extends SpriteSheet {
* @language en_US
* Create an egret.BitmapFont object
* @param texture {egret.Texture} Texture set that use TextureMerger create
* @param config {any} Configure data that use TextureMerger create
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 创建一个 egret.BitmapFont 对象
* @param texture {egret.Texture} 使用TextureMerger生成的纹理集
* @param config {any} 使用TextureMerger生成的配置数据
* @version Egret 2.4
* @platform Web,Native
public constructor(texture:Texture, config:any) {
super(texture);
if(typeof(config)==&string&){
this.charList = this.parseConfig(config);
else if(config&&config.hasOwnProperty(&frames&)){
this.charList = config.
this.charList = {};
* @private
private charList:
* @language en_US
* Obtain corresponding texture through the name attribute
* @param name {string} name Attribute
* @returns {egret.Texture}
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 通过 name 属性获取对应纹理
* @param name {string} name属性
* @returns {egret.Texture}
* @version Egret 2.4
* @platform Web,Native
public getTexture(name:string):Texture {
var texture:Texture = this._textureMap[name];
if (!texture) {
var c:any = this.charList[name];
texture = this.createTexture(name, c.x, c.y, c.w, c.h, c.offX, c.offY,c.sourceW,c.sourceH);
this._textureMap[name] =
* @private
private firstCharHeight:number = 0;
* @private
* @returns
public _getFirstCharHeight():number{
if(this.firstCharHeight==0){
for(var str in this.charList){
var c:any = this.charList[str];
var sourceH:number = c.sourceH;
if(egret.sys.isUndefined(sourceH)){
var h:number = c.h;
if(h===undefined){
var offY:number = c.offY;
if(egret.sys.isUndefined(offY)){
sourceH = h+offY;
if(sourceH&=0){
this.firstCharHeight = sourceH;
return this.firstCharH
* @private
* @param fntText
* @returns
private parseConfig(fntText:string):any {
fntText = fntText.split(&\r\n&).join(&\n&);
var lines:Array&string& = fntText.split(&\n&);
var charsCount:number = this.getConfigByKey(lines[3], &count&);
var chars:any = {};
for (var i:number = 4; i & 4 + charsC i++) {
var charText:string = lines[i];
var letter:string = String.fromCharCode(this.getConfigByKey(charText, &id&));
var c = {};
chars[letter] =
c[&x&] = this.getConfigByKey(charText, &x&);
c[&y&] = this.getConfigByKey(charText, &y&);
c[&w&] = this.getConfigByKey(charText, &width&);
c[&h&] = this.getConfigByKey(charText, &height&);
c[&offX&] = this.getConfigByKey(charText, &xoffset&);
c[&offY&] = this.getConfigByKey(charText, &yoffset&);
* @private
* @param configText
* @param key
* @returns
private getConfigByKey(configText:string, key:string):number {
var itemConfigTextList = configText.split(& &);
for (var i = 0 , length = itemConfigTextList. i & i++) {
var itemConfigText = itemConfigTextList[i];
if (key == itemConfigText.substring(0, key.length)) {
var value:string = itemConfigText.substring(key.length + 1);
return parseInt(value);
\ No newline at end of file
Index: InputController.ts
===================================================================
--- InputController.ts (revision 0)
+++ InputController.ts (revision 19)
@@ -0,0 +1,290 @@
+//////////////////////////////////////////////////////////////////////////////////////
Copyright (c) , Egret Technology Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Egret nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS &AS IS& AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//////////////////////////////////////////////////////////////////////////////////////
+module egret {
* @private
* @version Egret 2.4
* @platform Web,Native
export class InputController extends HashObject {
* @private
private stageText:egret.StageT
* @private
private _text:TextField =
* @private
private _isFocus:boolean =
* @version Egret 2.4
* @platform Web,Native
public constructor() {
* @param text
* @version Egret 2.4
* @platform Web,Native
public init(text:TextField):void {
this._text =
this.stageText = new egret.StageText();
this.stageText.$setTextField(this._text);
* @private
public _addStageText():void {
if (!this._text.$inputEnabled) {
this._text.$touchEnabled =
this.stageText.$addToStage();
this.stageText.addEventListener(&updateText&, this.updateTextHandler, this);
this._text.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onMouseDownHandler, this);
this._text.stage.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onStageDownHandler, this);
this.stageText.addEventListener(&blur&, this.blurHandler, this);
this.stageText.addEventListener(&focus&, this.focusHandler, this);
* @private
public _removeStageText():void {
if (!this._text.$inputEnabled) {
this._text.$touchEnabled =
this.stageText.$removeFromStage();
this.stageText.removeEventListener(&updateText&, this.updateTextHandler, this);
this._text.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onMouseDownHandler, this);
this._text.stage.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onStageDownHandler, this);
this.stageText.removeEventListener(&blur&, this.blurHandler, this);
this.stageText.removeEventListener(&focus&, this.focusHandler, this);
* @private
* @returns
public _getText():string {
return this.stageText.$getText();
* @private
* @param value
public _setText(value:string) {
this.stageText.$setText(value);
* @private
* @param event
private focusHandler(event:Event):void {
//不再显示竖线,并且输入框显示最开始
if (!this._isFocus) {
this._isFocus =
if (!event[&showing&]) {
this._text.$isTyping =
this._text.$invalidateContentBounds();
this._text.dispatchEvent(new egret.FocusEvent(egret.FocusEvent.FOCUS_IN, true));
* @private
* @param event
private blurHandler(event:Event):void {
if (this._isFocus) {
//不再显示竖线,并且输入框显示最开始
this._isFocus =
this._text.$isTyping =
this._text.$invalidateContentBounds();
//失去焦点后调用
this.stageText.$onBlur();
this._text.dispatchEvent(new egret.FocusEvent(egret.FocusEvent.FOCUS_OUT, true));
//点中文本
private onMouseDownHandler(event:TouchEvent) {
event.stopPropagation();
var self =
if (!this._text.visible) {
if (this._isFocus) {
//强制更新输入框位置
this.stageText.$show();
//未点中文本
private onStageDownHandler(event:TouchEvent) {
this.stageText.$hide();
* @private
* @param event
private updateTextHandler(event:Event):void {
var values = this._text.$TextF
var textValue = this.stageText.$getText();
var isChanged:boolean =
if (values[sys.TextKeys.restrictAnd] != null) {//内匹配
var reg = new RegExp(&[& + values[sys.TextKeys.restrictAnd] + &]&, &g&);
var result = textValue.match(reg);
if (result) {
textValue = result.join(&&);
textValue = &&;
isChanged =
if (values[sys.TextKeys.restrictNot] != null) {//外匹配
reg = new RegExp(&[^& + values[sys.TextKeys.restrictNot] + &]&, &g&);
result = textValue.match(reg);
if (result) {
textValue = result.join(&&);
textValue = &&;
isChanged =
if (isChanged && this.stageText.$getText() != textValue) {
this.stageText.$setText(textValue);
this.resetText();
//抛出change事件
this._text.dispatchEvent(new egret.Event(egret.Event.CHANGE, true));
* @private
private resetText():void {
this._text.$setBaseText(this.stageText.$getText());
* @private
public _hideInput():void {
this.stageText.$removeFromStage();
* @private
private updateInput():void {//
if (!this._text.$visible && this.stageText) {
this._hideInput();
* @private
public _updateProperties():void {
if (this._isFocus) {
//整体修改
this.stageText.$resetStageText();
this.updateInput();
var stage:egret.Stage = this._text.$
if (stage == null) {
var item:DisplayObject = this._
var visible:boolean = item.$
while (true) {
if (!visible) {
item = item.
if (item == stage) {
visible = item.$
this.stageText.$setText(this._text.$TextField[egret.sys.TextKeys.text]);
//整体修改
this.stageText.$resetStageText();
this.updateInput();
\ No newline at end of file
Index: HorizontalAlign.ts
===================================================================
--- HorizontalAlign.ts (revision 0)
+++ HorizontalAlign.ts (revision 19)
@@ -0,0 +1,128 @@
+//////////////////////////////////////////////////////////////////////////////////////
Copyright (c) , Egret Technology Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Egret nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS &AS IS& AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//////////////////////////////////////////////////////////////////////////////////////
+module egret {
* @language en_US
* The HorizontalAlign class defines the possible values for the horizontal alignment.
* @see egret.TextField#textAlign
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* HorizontalAlign 类为水平对齐方式定义可能的值。
* @see egret.TextField#textAlign
* @version Egret 2.4
* @platform Web,Native
export class HorizontalAlign{
* @language en_US
* Horizontally align content to the left of the container.
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 将内容与容器的左侧对齐。
* @version Egret 2.4
* @platform Web,Native
public static LEFT:string = &left&;
* @language en_US
* Horizontally align content to the right of the container.
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 将内容与容器的右侧对齐。
* @version Egret 2.4
* @platform Web,Native
public static RIGHT:string = &right&;
* @language en_US
* Horizontally align content in the center of the container.
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 在容器的水平中心对齐内容。
* @version Egret 2.4
* @platform Web,Native
public static CENTER: string = &center&;
* @language en_US
* Horizontal alignment with both edges
* Note: TextFiled does not support this alignment method.
* @constant egret.HorizontalAlign.JUSTIFY
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 水平两端对齐
* 注意:TextFiled不支持此对齐方式。
* @constant egret.HorizontalAlign.JUSTIFY
* @version Egret 2.4
* @platform Web,Native
public static JUSTIFY:string = &justify&;
* @language en_US
* Align the content of the child items, relative to the container. This operation will adjust uniformly the size of all the child items to be the Content Width \& of the container \&.
* The Content Width \& of the container \& is the size of the max. child item. If the size of all child items are less than the width of the container, they will be adjusted to the width of the container.
* Note: TextFiled does not support this alignment method.
* @constant egret.HorizontalAlign.CONTENT_JUSTIFY
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 相对于容器对子项进行内容对齐。这会将所有子项的大小统一调整为容器的&内容宽度&。
* 容器的&内容宽度&是最大子项的大小,如果所有子项都小于容器的宽度,则会将所有子项的大小调整为容器的宽度。
* 注意:TextFiled不支持此对齐方式。
* @constant egret.HorizontalAlign.CONTENT_JUSTIFY
* @version Egret 2.4
* @platform Web,Native
public static CONTENT_JUSTIFY:string = &contentJustify&;
\ No newline at end of file
Index: VerticalAlign.ts
===================================================================
--- VerticalAlign.ts (revision 0)
+++ VerticalAlign.ts (revision 19)
@@ -0,0 +1,123 @@
+//////////////////////////////////////////////////////////////////////////////////////
Copyright (c) , Egret Technology Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Egret nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS &AS IS& AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//////////////////////////////////////////////////////////////////////////////////////
+module egret {
* @language en_US
* The VerticalAlign class defines the possible values for the vertical alignment.
* @see egret.TextField#verticalAlign
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* VerticalAlign 类为垂直对齐方式定义可能的值。
* @see egret.TextField#verticalAlign
* @version Egret 2.4
* @platform Web,Native
export class VerticalAlign{
* @language en_US
* Vertically align content to the top of the container.
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 将内容与容器的顶部对齐。
* @version Egret 2.4
* @platform Web,Native
public static TOP:string = &top&;
* @language en_US
* Vertically align content to the bottom of the container.
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 将内容与容器的底部对齐。
* @version Egret 2.4
* @platform Web,Native
public static BOTTOM:string = &bottom&;
* @language en_US
* Vertically align content in the middle of the container.
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 在容器的垂直中心对齐内容。
* @version Egret 2.4
* @platform Web,Native
public static MIDDLE:string = &middle&;
* @language en_US
* Vertical alignment with both edges
* Note: TextFiled does not support this alignment method.&
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 垂直两端对齐
* 注意:TextFiled不支持此对齐方式。
* @version Egret 2.4
* @platform Web,Native
public static JUSTIFY:string = &justify&;
* @language en_US
* Align the content of the child items, relative to the container. This operation will adjust uniformly the size of all the child items to be the Content Height \& of the container \&.
* The Content Height \& of the container \& is the size of the max. child item. If the size of all child items are less than the height of the container, they will be adjusted to the height of the container.
* Note: TextFiled does not support this alignment method.
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 相对于容器对子项进行内容对齐。这会将所有子项的大小统一调整为容器的&内容高度&。
* 容器的&内容高度&是最大子项的大小,如果所有子项都小于容器的高度,则会将所有子项的大小调整为容器的高度。
* 注意:TextFiled不支持此对齐方式。
* @version Egret 2.4
* @platform Web,Native
public static CONTENT_JUSTIFY:string = &contentJustify&;
\ No newline at end of file
Index: HtmlTextParser.ts
===================================================================
--- HtmlTextParser.ts (revision 0)
+++ HtmlTextParser.ts (revision 19)
@@ -0,0 +1,280 @@
+//////////////////////////////////////////////////////////////////////////////////////
Copyright (c) , Egret Technology Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Egret nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS &AS IS& AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//////////////////////////////////////////////////////////////////////////////////////
+module egret {
* @language en_US
* Convert the text in html format to the object that can be assigned to the egret.TextField#textFlow property
* @see http://docs.egret-labs.org/jkdoc/manual-text-multiformat.html Text mixed in a variety of style
* @version Egret 2.4
* @platform Web,Native
* @includeExample egret/text/HtmlTextParser.ts
* @language zh_CN
* 将html格式文本转换为可赋值给 egret.TextField#textFlow 属性的对象
* @see http://docs.egret-labs.org/jkdoc/manual-text-multiformat.html 多种样式文本混合
* @version Egret 2.4
* @platform Web,Native
* @includeExample egret/text/HtmlTextParser.ts
export class HtmlTextParser{
* @version Egret 2.4
* @platform Web,Native
constructor () {
this.initReplaceArr();
private replaceArr:Array&any& = [];
private initReplaceArr():void {
this.replaceArr = [];
this.replaceArr.push([/&/g, &&&]);
this.replaceArr.push([/&/g, &&&]);
this.replaceArr.push([/&/g, &&&]);
this.replaceArr.push([/&/g, &\&&]);
this.replaceArr.push([/&/g, &\'&]);
* @private
* @param value
* @returns
private replaceSpecial(value:string):string {
for (var i = 0; i & this.replaceArr. i++) {
var k = this.replaceArr[i][0];
var v = this.replaceArr[i][1];
value = value.replace(k, v);
* @private
private resutlArr:Array&egret.ITextElement& = [];
* @language en_US
* Convert the text in html format to the object that can be assigned to the egret.TextField#textFlow property
* @param htmltext {string} Text in html
* @returns {Array&egret.ITextElement&} 可赋值给 egret.TextField#textFlow Object that can be assigned to the egret.TextField#textFlow property
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 将html格式文本转换为可赋值给 egret.TextField#textFlow 属性的对象
* @param htmltext {string} html文本
* @returns {Array&egret.ITextElement&} 可赋值给 egret.TextField#textFlow 属性的对象
* @version Egret 2.4
* @platform Web,Native
public parser(htmltext:string):Array&egret.ITextElement& {
this.stackArray = [];
this.resutlArr = [];
var firstIdx:number = 0;//文本段开始位置
var length:number = htmltext.
while (firstIdx & length) {
var starIdx:number = htmltext.indexOf(&&&, firstIdx);
if (starIdx & 0) {
this.addToResultArr(htmltext.substring(firstIdx));
firstIdx =
this.addToResultArr(htmltext.substring(firstIdx, starIdx));
var fontEnd = htmltext.indexOf(&&&, starIdx);
if (htmltext.charAt(starIdx + 1) == &\/&) {//关闭
this.stackArray.pop();
this.addToArray(htmltext.substring(starIdx + 1, fontEnd));
firstIdx = fontEnd + 1;
return this.resutlA
* @private
* @param value
private addToResultArr(value:string):void {
if (value == &&) {
value = this.replaceSpecial(value);
if (this.stackArray.length & 0) {
this.resutlArr.push({text:value, style:this.stackArray[this.stackArray.length - 1]})
this.resutlArr.push(&egret.ITextElement&{text:value});
//将字符数据转成Json数据
private changeStringToObject(str:string):egret.ITextStyle {
str = str.trim();
var info:any = {};
var header = [];
if (str.charAt(0) == &i& || str.charAt(0) == &b& || str.charAt(0) == &u&)
this.addProperty(info, str, &true&);
else if (header = str.match(/^(font|a)\s/)){
str = str.substring(header[0].length).trim();
var next:number = 0;
while (titles = str.match(this.getHeadReg())) {
var title = titles[0];
var value = &&;
var str = str.substring(title.length).trim();
if (str.charAt(0) == &\&&) {
var next = str.indexOf(&\&&, 1);
value = str.substring(1, next);
next += 1;
else if (str.charAt(0) == &\'&) {
var next = str.indexOf(&\'&, 1);
value = str.substring(1, next);
next += 1;
value = str.match(/(\S)+/)[0];
next = value.
this.addProperty(info, title.substring(0, title.length - 1).trim(), value.trim());
str = str.substring(next).trim();
* @private
* @returns
private getHeadReg():RegExp {
return /^(color|textcolor|strokecolor|stroke|b|bold|i|italic|u|size|fontfamily|href|target)(\s)*=/;
* @private
* @param info
* @param head
* @param value
private addProperty(info:egret.ITextStyle, head:string, value:string):void {
switch (head.toLowerCase()) {
case &color& :
case &textcolor& :
value = value.replace(/#/, &0x&);
info.textColor = parseInt(value);
case &strokecolor& :
value = value.replace(/#/, &0x&);
info.strokeColor = parseInt(value);
case &stroke& :
info.stroke = parseInt(value);
case &b& :
case &bold& :
info.bold = value == &true&;
case &u& :
info.underline = value == &true&;
case &i& :
case &italic& :
info.italic = value == &true&;
case &size& :
info.size = parseInt(value);
case &fontfamily& :
info.fontFamily =
case &href& :
info.href = this.replaceSpecial(value);
case &target& :
info.target = this.replaceSpecial(value);
* @private
private stackArray:Array&egret.ITextStyle&;
* @private
* @param infoStr
private addToArray(infoStr:string):void {
var info:egret.ITextStyle = this.changeStringToObject(infoStr);
if (this.stackArray.length == 0) {
this.stackArray.push(info);
var lastInfo:Object = this.stackArray[this.stackArray.length - 1];
for (var key in lastInfo) {
if (info[key] == null) {
info[key] = lastInfo[key];
this.stackArray.push(info);
\ No newline at end of file
Index: ITextElement.ts
===================================================================
--- ITextElement.ts (revision 0)
+++ ITextElement.ts (revision 19)
@@ -0,0 +1,290 @@
+//////////////////////////////////////////////////////////////////////////////////////
Copyright (c) , Egret Technology Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Egret nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS &AS IS& AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//////////////////////////////////////////////////////////////////////////////////////
+module egret {
* @private
* @version Egret 2.4
* @platform Web,Native
export interface IHitTextElement {
* @version Egret 2.4
* @platform Web,Native
lineIndex:
* @version Egret 2.4
* @platform Web,Native
textElementIndex:
* @language en_US
* Text Style
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 文本样式
* @version Egret 2.4
* @platform Web,Native
export interface ITextStyle {
* @language en_US
* text color
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* @version Egret 2.4
* @platform Web,Native
textColor?:
* @language en_US
* stroke color
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 描边颜色值
* @version Egret 2.4
* @platform Web,Native
strokeColor?:
* @language en_US
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* @version Egret 2.4
* @platform Web,Native
* @language en_US
* stroke width
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 描边大小
* @version Egret 2.4
* @platform Web,Native
* @language en_US
* whether bold
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 是否加粗
* @version Egret 2.4
* @platform Web,Native
* @language en_US
* whether italic
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 是否倾斜
* @version Egret 2.4
* @platform Web,Native
* @language en_US
* fontFamily
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 字体名称
* @version Egret 2.4
* @platform Web,Native
fontFamily?:
* @language en_US
* Link events or address
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 链接事件或者地址
* @version Egret 2.4
* @platform Web,Native
* @language en_US
* @private
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* @private
* @version Egret 2.4
* @platform Web,Native
* @language en_US
* Is underlined
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 是否加下划线
* @version Egret 2.4
* @platform Web,Native
underline?:
* @language en_US
* Used to build the basic structure of text with a variety of mixed styles, mainly for setting textFlow property
* @see http://docs.egret-labs.org/jkdoc/manual-text-multiformat.html Text mixed in a variety of style
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 用于建立多种样式混合文本的基本结构,主要用于设置 textFlow 属性
* @see http://docs.egret-labs.org/jkdoc/manual-text-multiformat.html 多种样式文本混合
* @version Egret 2.4
* @platform Web,Native
export interface ITextElement {
* @language en_US
* String Content
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 字符串内容
* @version Egret 2.4
* @platform Web,Native
* @language en_US
* Text Style
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 文本样式
* @version Egret 2.4
* @platform Web,Native
style?:ITextS
* @private
* @version Egret 2.4
* @platform Web,Native
export interface IWTextElement extends ITextElement {
* @version Egret 2.4
* @platform Web,Native
* 文本最终解析的一行数据格式
* @private
* @version Egret 2.4
* @platform Web,Native
export interface ILineElement {
* 文本占用宽度
* @version Egret 2.4
* @platform Web,Native
* 文本占用高度
* @version Egret 2.4
* @platform Web,Native
* 当前文本字符总数量(包括换行符)
* @version Egret 2.4
* @platform Web,Native
* 是否含有换行符
* @version Egret 2.4
* @platform Web,Native
hasNextLine:
* 本行文本内容
* @version Egret 2.4
* @platform Web,Native
elements:Array&IWTextElement&;
\ No newline at end of file
Index: StageText.ts
===================================================================
--- StageText.ts (revision 0)
+++ StageText.ts (revision 19)
@@ -0,0 +1,102 @@
+//////////////////////////////////////////////////////////////////////////////////////
Copyright (c) , Egret Technology Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Egret nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS &AS IS& AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//////////////////////////////////////////////////////////////////////////////////////
+module egret {
* @private
* @version Egret 2.4
* @platform Web,Native
export interface StageText extends EventDispatcher {
* @private
$textfield:egret.TextF
* @private
* @param textfield
$setTextField(textfield:egret.TextField):
* @private
$resetStageText():
* @private
* @returns
$getText():
* @private
* @param value
$setText(value:string):
* @private
* @private
* @private
$addToStage():
* @private
$removeFromStage():
* @private
$onBlur():
* @version Egret 2.4
* @platform Web,Native
export var StageText:{new():StageText};
\ No newline at end of file
Index: TextField.ts
===================================================================
--- TextField.ts (revision 0)
+++ TextField.ts (revision 19)
@@ -0,0 +1,2044 @@
+//////////////////////////////////////////////////////////////////////////////////////
Copyright (c) , Egret Technology Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Egret nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS &AS IS& AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//////////////////////////////////////////////////////////////////////////////////////
+module egret.sys {
* @private
export const enum TextKeys {
* @private
* @private
lineSpacing,
* @private
textColor,
* @private
textFieldWidth,
* @private
textFieldHeight,
* @private
textWidth,
* @private
textHeight,
* @private
textDrawWidth,
* @private
fontFamily,
* @private
textAlign,
* @private
verticalAlign,
* @private
textColorString,
* @private
fontString,
* @private
* @private
measuredWidths,
* @private
* @private
* @private
fontStringChanged,
* @private
textLinesChanged,
* @private
* @private
displayAsPassword,
* @private
* @private
selectionActivePosition,
* @private
selectionAnchorPosition,
* @private
* @private
strokeColor,
* @private
strokeColorString,
* @private
* @private
* @private
* @private
multiline,
* @private
* @private
borderColor,
* @private
background,
* @private
backgroundColor,
* @private
restrictAnd,
* @private
restrictNot
+module egret {
var SplitRegex = new RegExp(&(?=[\\u00BF-\\u1FFF\\u2C00-\\uD7FF]|\\b|\\s)(?![。,!、》…))}”】\\.\\,\\!\\?\\]\\:])&);
* @language en_US
* TextField is the text rendering class of egret. It conducts rendering by using the browser / device API. Due to different ways of font rendering in different browsers / devices, there may be differences in the rendering
* If developers expect
no differences among all platforms, please use BitmapText
* @see http://docs.egret-labs.org/post/manual/text/createtext.html Create Text
* @event egret.Event.CHANGE Dispatched when entering text user input。
* @event egret.FocusEvent.FOCUS_IN Dispatched after the focus to enter text.
* @event egret.FocusEvent.FOCUS_OUT Enter the text loses focus after dispatch.
* @version Egret 2.4
* @platform Web,Native
* @includeExample egret/text/TextField.ts
* @language zh_CN
* TextField是egret的文本渲染类,采用浏览器/设备的API进行渲染,在不同的浏览器/设备中由于字体渲染方式不一,可能会有渲染差异
* 如果开发者希望所有平台完全无差异,请使用BitmapText
* @see http://docs.egret-labs.org/post/manual/text/createtext.html 创建文本
* @event egret.Event.CHANGE 输入文本有用户输入时调度。
* @event egret.FocusEvent.FOCUS_IN 聚焦输入文本后调度。
* @event egret.FocusEvent.FOCUS_OUT 输入文本失去焦点后调度。
* @version Egret 2.4
* @platform Web,Native
* @includeExample egret/text/TextField.ts
export class TextField extends DisplayObject {
* @language en_US
* default fontFamily
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 默认文本字体
* @version Egret 2.4
* @platform Web,Native
public static default_fontFamily:string = &Arial&;
* @version Egret 2.4
* @platform Web,Native
constructor() {
this.$renderRegion = new sys.Region();
this.$TextField = {
//fontSize
//lineSpacing
2: 0xffffff,
//textColor
//textFieldWidth
//textFieldHeight
//textWidth
//textHeight
//textDrawWidth
8: &sans-serif&,
//fontFamily
9: &left&,
//textAlign
10: &top&,
//verticalAlign
11: &#ffffff&,
//textColorString
//fontString
//measuredWidths
15: false,
16: false,
//fontStringChanged,
18: false,
//textLinesChanged,
19: false,
//wordWrap
20: false,
//displayAsPassword
//maxChars
22: 0, //selectionActivePosition,
23: 0, //selectionAnchorPosition,
24: TextFieldType.DYNAMIC,
25: 0x000000,
//strokeColor
26: &#000000&,
//strokeColorString
//numLines
30: false,
//multiline
31: false,
32: 0x000000,
//borderColor
33: false,
//background
34: 0xffffff,
//backgroundColor
//restrictAnd
//restrictNot
* @private
$TextField:O
* @private
* @returns
private isInput():boolean {
return this.$TextField[sys.TextKeys.type] == TextFieldType.INPUT;
$inputEnabled:boolean =
$setTouchEnabled(value:boolean):boolean {
var result:boolean = super.$setTouchEnabled(value);
if (this.isInput()) {
this.$inputEnabled =
* @language en_US
* The name of the font to use, or a comma-separated list of font names.
* @default &sans-serif&
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 要使用的字体的名称或用逗号分隔的字体名称列表。
* @default &sans-serif&
* @version Egret 2.4
* @platform Web,Native
public get fontFamily():string {
return this.$TextField[sys.TextKeys.fontFamily];
public set fontFamily(value:string) {
this.$setFontFamily(value);
$setFontFamily(value:string):boolean {
var values = this.$TextF
if (values[sys.TextKeys.fontFamily] == value) {
values[sys.TextKeys.fontFamily] =
this.invalidateFontString();
* @language en_US
* The size in pixels of text
* @default 30
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 文本的字号大小。
* @default 30
* @version Egret 2.4
* @platform Web,Native
public get size():number {
return this.$TextField[sys.TextKeys.fontSize];
public set size(value:number) {
this.$setSize(value);
$setSize(value:number):boolean {
value = egret.sys.getNumber(value);
var values = this.$TextF
if (values[sys.TextKeys.fontSize] == value) {
values[sys.TextKeys.fontSize] =
this.invalidateFontString();
// * @private
// * @version Egret 2.4
// * @platform Web,Native
//public get fontSize():number {
return this.$TextField[sys.TextKeys.fontSize];
// * @private
//public set fontSize(value:number) {
value = egret.sys.getNumber(value);
var values = this.$TextF
if (values[sys.TextKeys.fontSize] == value) {
values[sys.TextKeys.fontSize] =
this.invalidateFontString();
* @language en_US
* Specifies whether the text is boldface.
* @default false
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 是否显示为粗体。
* @default false
* @version Egret 2.4
* @platform Web,Native
public get bold():boolean {
return this.$TextField[sys.TextKeys.bold];
public set bold(value:boolean) {
this.$setBold(value);
$setBold(value:boolean):boolean {
value = !!
var values = this.$TextF
if (value == values[sys.TextKeys.bold]) {
values[sys.TextKeys.bold] =
this.invalidateFontString();
* @language en_US
* Determines whether the text is italic font.
* @default false
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 是否显示为斜体。
* @default false
* @version Egret 2.4
* @platform Web,Native
public get italic():boolean {
return this.$TextField[sys.TextKeys.italic];
public set italic(value:boolean) {
this.$setItalic(value);
$setItalic(value:boolean):boolean {
value = !!
var values = this.$TextF
if (value == values[sys.TextKeys.italic]) {
values[sys.TextKeys.italic] =
this.invalidateFontString();
* @private
private invalidateFontString():void {
this.$TextField[sys.TextKeys.fontStringChanged] =
this.$invalidateTextField();
* @private
* 获取字体信息的字符串形式。
private getFontString():string {
var values = this.$TextF
if (values[sys.TextKeys.fontStringChanged]) {
values[sys.TextKeys.fontStringChanged] =
values[sys.TextKeys.fontString] = sys.toFontString(this);
return values[sys.TextKeys.fontString];
* @language en_US
* Horizontal alignment of text.
* @default:egret.HorizontalAlign.LEFT
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 文本的水平对齐方式。
* @default:egret.HorizontalAlign.LEFT
* @version Egret 2.4
* @platform Web,Native
public get textAlign():string {
return this.$TextField[sys.TextKeys.textAlign];
public set textAlign(value:string) {
this.$setTextAlign(value);
$setTextAlign(value:string):boolean {
var values = this.$TextF
if (values[sys.TextKeys.textAlign] == value) {
values[sys.TextKeys.textAlign] =
this.$invalidateTextField();
* @language en_US
* Vertical alignment of text.
* @default:egret.VerticalAlign.TOP
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 文字的垂直对齐方式。
* @default:egret.VerticalAlign.TOP
* @version Egret 2.4
* @platform Web,Native
public get verticalAlign():string {
return this.$TextField[sys.TextKeys.verticalAlign];
public set verticalAlign(value:string) {
this.$setVerticalAlign(value);
$setVerticalAlign(value:string):boolean {
var values = this.$TextF
if (values[sys.TextKeys.verticalAlign] == value) {
values[sys.TextKeys.verticalAlign] =
this.$invalidateTextField();
* @language en_US
* An integer representing the amount of vertical space between lines.
* @default 0
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 一个整数,表示行与行之间的垂直间距量
* @default 0
* @version Egret 2.4
* @platform Web,Native
public get lineSpacing():number {
return this.$TextField[sys.TextKeys.lineSpacing];
public set lineSpacing(value:number) {
this.$setLineSpacing(value);
$setLineSpacing(value:number):boolean {
value = egret.sys.getNumber(value);
var values = this.$TextF
if (values[sys.TextKeys.lineSpacing] == value)
values[sys.TextKeys.lineSpacing] =
this.$invalidateTextField();
* @language en_US
* Color of the text.
* @default 0x000000
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 文本颜色
* @default 0x000000
* @version Egret 2.4
* @platform Web,Native
public get textColor():number {
return this.$TextField[sys.TextKeys.textColor];
public set textColor(value:number) {
this.$setTextColor(value);
$setTextColor(value:number):boolean {
value = +value | 0;
var values = this.$TextF
if (values[sys.TextKeys.textColor] == value) {
values[sys.TextKeys.textColor] =
values[sys.TextKeys.textColorString] = toColorString(value);
this.$invalidate();
* @language en_US
* A Boolean value that indicates whether the text field has word wrap. If the value of wordWrap is true, the text
* if the value is false, the text field does not have word wrap.
* @default true
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
* 一个布尔值,表示文本字段是否自动换行。如果 wordWrap 的值为 true,则该文本字段自动换行;
* 如果值为 false,则该文本字段不自动换行,如果同时显式设置过宽度,超出宽度的部分将被截断。
* @default true
* @version Egret 2.4
* @platform Web,Native
public get wordWrap():boolean {
return this.$TextField[sys.TextKeys.wordWrap];
public set wordWrap(value:boolean) {
value = !!
var values = this.$TextF
if (value == values[sys.TextKeys.wordWrap]) {
if (values[sys.TextKeys.displayAsPassword]) {
values[sys.TextKeys.wordWrap] =
this.$invalidateTextField();
* @private
private inputUtils:InputController =
* @language en_US
* Type of the text field.
* Any one of the following TextFieldType constants: TextFieldType.DYNAMIC (specifies the dynamic text field that users can not edit), or TextFieldType.INPUT (specifies the dynamic text field that users can edit).
* @default egret.TextFieldType.DYNAMIC
* @language zh_CN
* 文本字段的类型。
* 以下 TextFieldType 常量中的任一个:TextFieldType.DYNAMIC(指定用户无法编辑的动态文本字段),或 TextFieldType.INPUT(指定用户可以编辑的输入文本字段)。
* @default egret.TextFieldType.DYNAMIC
public set type(value:string) {
this.$setType(value);
* @private
* @param value
$setType(value:string):boolean {
if (this.$TextField[sys.TextKeys.type] != value) {
this.$TextField[sys.TextKeys.type] =
if (value == TextFieldType.INPUT) {//input,如果没有设置过宽高,则设置默认值为100,30
if (isNaN(this.$TextField[sys.TextKeys.textFieldWidth])) {
this.$setWidth(100);
if (isNaN(this.$TextField[sys.TextKeys.textFieldHeight])) {
this.$setHeight(30);
this.$setTouchEnabled(true);
//创建stageText
if (this.inputUtils == null) {
this.inputUtils = new egret.InputController();
this.inputUtils.init(this);
this.$invalidateTextField();
if (this.$stage) {
this.inputUtils._addStageText();
if (this.inputUtils) {
this.inputUtils._removeStageText();
this.inputUtils =
this.$setTouchEnabled(false);
* @version Egret 2.4
* @platform Web,Native
public get type():string {
return this.$TextField[sys.TextKeys.type];
* @version Egret 2.4
* @platform Web,Native
public get text():string {
return this.$getText();
* @private
* @returns
public $getText():string {
if (this.$TextField[sys.TextKeys.type] == egret.TextFieldType.INPUT) {
return this.inputUtils._getText();
return this.$TextField[sys.TextKeys.text];
* @language en_US
* Serve as a string of the current text field in the text
* @language zh_CN
* 作为文本字段中当前文本的字符串
public set text(value:string) {
this.$setText(value);
* @private
* @param value
$setBaseText(value:string):boolean {
if (value == null) {
value = &&;
value = value.toString();
this.isFlow =
if (this.$TextField[sys.TextKeys.text] != value) {
this.$invalidateTextField();
this.$TextField[sys.TextKeys.text] =
var text:string = &&;
if (this.$TextField[sys.TextKeys.displayAsPassword]) {
text = this.changeToPassText(value);
this.setMiddleStyle([&egret.ITextElement&{text: text}]);
* @private
* @param value
$setText(value:string):boolean {
if (value == null) {
value = &&;
var result:boolean = this.$setBaseText(value);
if (this.inputUtils) {
this.inputUtils._setText(this.$TextField[sys.TextKeys.text]);
* @language en_US
* Specify whether the text field is a password text field.
* If the value of this property is true, the text field is treated as a password text field and hides the input characters using asterisks instead of the actual characters. If false, the text field is not treated as a password text field.
* @default false
* @language zh_CN
* 指定文本字段是否是密码文本字段。
* 如果此属性的值为 true,则文本字段被视为密码文本字段,并使用星号而不是实际字符来隐藏输入的字符。如果为 false,则不会将文本字段视为密码文本字段。
* @default false
public get displayAsPassword():boolean {
return this.$TextField[sys.TextKeys.displayAsPassword];
public set displayAsPassword(value:boolean) {
this.$setDisplayAsPassword(value);
* @private
* @param value
$setDisplayAsPassword(value:boolean):boolean {
var self =
if (this.$TextField[sys.TextKeys.displayAsPassword] != value) {
this.$TextField[sys.TextKeys.displayAsPassword]

我要回帖

更多关于 在建工程贷方表示 的文章

 

随机推荐