/**
 * Generated by Apache Royale Compiler from org\apache\royale\html\accessories\ToolTipBead.as
 * org.apache.royale.html.accessories.ToolTipBead
 *
 * @fileoverview
 *
 * @suppress {checkTypes|accessControls}
 */

goog.provide('org.apache.royale.html.accessories.ToolTipBead');

goog.require('org.apache.royale.core.IPopUpHost');
goog.require('org.apache.royale.core.IStrand');
goog.require('org.apache.royale.core.IUIBase');
goog.require('org.apache.royale.events.IEventDispatcher');
goog.require('org.apache.royale.events.MouseEvent');
goog.require('org.apache.royale.geom.Point');
goog.require('org.apache.royale.html.ToolTip');
goog.require('org.apache.royale.utils.PointUtils');
goog.require('org.apache.royale.utils.UIUtils');
goog.require('org.apache.royale.core.IBead');
goog.require('org.apache.royale.utils.Language');



/**
 *  constructor.
 *
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion Royale 0.9
 * @constructor
 * @implements {org.apache.royale.core.IBead}
 */
org.apache.royale.html.accessories.ToolTipBead = function() {

this.org_apache_royale_html_accessories_ToolTipBead__xPos = org.apache.royale.html.accessories.ToolTipBead.RIGHT;
this.org_apache_royale_html_accessories_ToolTipBead__yPos = org.apache.royale.html.accessories.ToolTipBead.BOTTOM;
};


/**
 * Prevent renaming of class. Needed for reflection.
 */
goog.exportSymbol('org.apache.royale.html.accessories.ToolTipBead', org.apache.royale.html.accessories.ToolTipBead);


/**
 * @export
 * @const
 * @type {number}
 */
org.apache.royale.html.accessories.ToolTipBead.TOP = 10000;


/**
 * @export
 * @const
 * @type {number}
 */
org.apache.royale.html.accessories.ToolTipBead.BOTTOM = 10001;


/**
 * @export
 * @const
 * @type {number}
 */
org.apache.royale.html.accessories.ToolTipBead.LEFT = 10002;


/**
 * @export
 * @const
 * @type {number}
 */
org.apache.royale.html.accessories.ToolTipBead.RIGHT = 10003;


/**
 * @export
 * @const
 * @type {number}
 */
org.apache.royale.html.accessories.ToolTipBead.MIDDLE = 10004;


/**
 * @private
 * @type {string}
 */
org.apache.royale.html.accessories.ToolTipBead.prototype.org_apache_royale_html_accessories_ToolTipBead__toolTip;


/**
 * @protected
 * @type {org.apache.royale.html.ToolTip}
 */
org.apache.royale.html.accessories.ToolTipBead.prototype.tt;


/**
 * @protected
 * @type {org.apache.royale.core.IPopUpHost}
 */
org.apache.royale.html.accessories.ToolTipBead.prototype.host;


/**
 * @private
 * @type {number}
 */
org.apache.royale.html.accessories.ToolTipBead.prototype.org_apache_royale_html_accessories_ToolTipBead__xPos;


/**
 * @private
 * @type {number}
 */
org.apache.royale.html.accessories.ToolTipBead.prototype.org_apache_royale_html_accessories_ToolTipBead__yPos;


/**
 * @protected
 * @type {org.apache.royale.core.IStrand}
 */
org.apache.royale.html.accessories.ToolTipBead.prototype._strand;


/**
 * @asprivate
 * @royaleignorecoercion org.apache.royale.core.IUIBase
 * @royaleignorecoercion org.apache.royale.events.IEventDispatcher
 * @protected
 * @param {org.apache.royale.events.MouseEvent} event
 */
org.apache.royale.html.accessories.ToolTipBead.prototype.rollOverHandler = function(event) {
  if (!this.toolTip || this.tt)
    return;
  this._strand.addEventListener(org.apache.royale.events.MouseEvent.MOUSE_OUT, org.apache.royale.utils.Language.closure(this.rollOutHandler, this, 'rollOutHandler'), false);
  var /** @type {Object} */ comp = this._strand;
  this.host = org.apache.royale.utils.UIUtils.findPopUpHost(comp);
  if (this.tt)
    this.host.popUpParent.removeElement(this.tt);
  this.tt = new org.apache.royale.html.ToolTip();
  this.tt.text = this.toolTip;
  var /** @type {org.apache.royale.geom.Point} */ pt = this.determinePosition(event, event.target);
  this.tt.x = pt.x;
  this.tt.y = pt.y;
  this.host.popUpParent.addElement(this.tt, false);
};


/**
 * @asprivate
 * Determines the position of the toolTip.
 * @royaleignorecoercion org.apache.royale.core.IUIBase
 * @protected
 * @param {org.apache.royale.events.MouseEvent} event
 * @param {Object} base
 * @return {org.apache.royale.geom.Point}
 */
org.apache.royale.html.accessories.ToolTipBead.prototype.determinePosition = function(event, base) {
  var /** @type {Object} */ comp = this._strand;
  var /** @type {number} */ xFactor = 1;
  var /** @type {number} */ yFactor = 1;
  var /** @type {org.apache.royale.geom.Point} */ pt;
  var /** @type {boolean} */ relative = this.org_apache_royale_html_accessories_ToolTipBead__xPos > org.apache.royale.html.accessories.ToolTipBead.TOP && this.org_apache_royale_html_accessories_ToolTipBead__yPos > org.apache.royale.html.accessories.ToolTipBead.TOP;
  if (this.org_apache_royale_html_accessories_ToolTipBead__xPos == org.apache.royale.html.accessories.ToolTipBead.LEFT) {
    xFactor = Number["POSITIVE_INFINITY"];
  } else if (this.org_apache_royale_html_accessories_ToolTipBead__xPos == org.apache.royale.html.accessories.ToolTipBead.MIDDLE) {
    xFactor = 2;
  } else if (this.org_apache_royale_html_accessories_ToolTipBead__xPos == org.apache.royale.html.accessories.ToolTipBead.RIGHT) {
    xFactor = 1;
  }
  if (this.org_apache_royale_html_accessories_ToolTipBead__yPos == org.apache.royale.html.accessories.ToolTipBead.TOP) {
    yFactor = Number["POSITIVE_INFINITY"];
  } else if (this.org_apache_royale_html_accessories_ToolTipBead__yPos == org.apache.royale.html.accessories.ToolTipBead.MIDDLE) {
    yFactor = 2;
  } else if (this.org_apache_royale_html_accessories_ToolTipBead__yPos == org.apache.royale.html.accessories.ToolTipBead.BOTTOM) {
    yFactor = 1;
  }
  pt = new org.apache.royale.geom.Point(comp.width / xFactor, comp.height / yFactor);
  pt = org.apache.royale.utils.PointUtils.localToGlobal(pt, comp);
  return pt;
};


/**
 * @asprivate
 * @royaleignorecoercion org.apache.royale.core.IUIBase
 * @protected
 * @param {org.apache.royale.events.MouseEvent} event
 */
org.apache.royale.html.accessories.ToolTipBead.prototype.rollOutHandler = function(event) {
  org.apache.royale.utils.Language.as(this._strand, org.apache.royale.events.IEventDispatcher, true).removeEventListener(org.apache.royale.events.MouseEvent.MOUSE_OUT, org.apache.royale.utils.Language.closure(this.rollOutHandler, this, 'rollOutHandler'), false);
  var /** @type {Object} */ comp = this._strand;
  if (this.tt) {
    this.host.popUpParent.removeElement(this.tt);
    this.tt = null;
  }
};


org.apache.royale.html.accessories.ToolTipBead.prototype.get__toolTip = function() {
  return this.org_apache_royale_html_accessories_ToolTipBead__toolTip;
};


org.apache.royale.html.accessories.ToolTipBead.prototype.set__toolTip = function(value) {
  this.org_apache_royale_html_accessories_ToolTipBead__toolTip = value;
};


org.apache.royale.html.accessories.ToolTipBead.prototype.get__xPos = function() {
  return this.org_apache_royale_html_accessories_ToolTipBead__xPos;
};


org.apache.royale.html.accessories.ToolTipBead.prototype.set__xPos = function(pos) {
  this.org_apache_royale_html_accessories_ToolTipBead__xPos = pos;
};


org.apache.royale.html.accessories.ToolTipBead.prototype.get__yPos = function() {
  return this.org_apache_royale_html_accessories_ToolTipBead__yPos;
};


org.apache.royale.html.accessories.ToolTipBead.prototype.set__yPos = function(pos) {
  this.org_apache_royale_html_accessories_ToolTipBead__yPos = pos;
};


org.apache.royale.html.accessories.ToolTipBead.prototype.set__strand = function(value) {
  this._strand = value;
  this._strand.addEventListener(org.apache.royale.events.MouseEvent.MOUSE_OVER, org.apache.royale.utils.Language.closure(this.rollOverHandler, this, 'rollOverHandler'), false);
};


Object.defineProperties(org.apache.royale.html.accessories.ToolTipBead.prototype, /** @lends {org.apache.royale.html.accessories.ToolTipBead.prototype} */ {
/**
  * @export
  * @type {string} */
toolTip: {
get: org.apache.royale.html.accessories.ToolTipBead.prototype.get__toolTip,
set: org.apache.royale.html.accessories.ToolTipBead.prototype.set__toolTip},
/**
  * @export
  * @type {number} */
xPos: {
get: org.apache.royale.html.accessories.ToolTipBead.prototype.get__xPos,
set: org.apache.royale.html.accessories.ToolTipBead.prototype.set__xPos},
/**
  * @export
  * @type {number} */
yPos: {
get: org.apache.royale.html.accessories.ToolTipBead.prototype.get__yPos,
set: org.apache.royale.html.accessories.ToolTipBead.prototype.set__yPos},
/**
  * @export
  * @type {org.apache.royale.core.IStrand} */
strand: {
set: org.apache.royale.html.accessories.ToolTipBead.prototype.set__strand}}
);


/**
 * Metadata
 *
 * @type {Object.<string, Array.<Object>>}
 */
org.apache.royale.html.accessories.ToolTipBead.prototype.ROYALE_CLASS_INFO = { names: [{ name: 'ToolTipBead', qName: 'org.apache.royale.html.accessories.ToolTipBead', kind: 'class' }], interfaces: [org.apache.royale.core.IBead] };



/**
 * Reflection
 *
 * @return {Object.<string, Function>}
 */
org.apache.royale.html.accessories.ToolTipBead.prototype.ROYALE_REFLECTION_INFO = function () {
  return {
    variables: function () {return {};},
    accessors: function () {
      return {
        'toolTip': { type: 'String', access: 'readwrite', declaredBy: 'org.apache.royale.html.accessories.ToolTipBead'},
        'xPos': { type: 'int', access: 'readwrite', declaredBy: 'org.apache.royale.html.accessories.ToolTipBead'},
        'yPos': { type: 'int', access: 'readwrite', declaredBy: 'org.apache.royale.html.accessories.ToolTipBead'},
        'strand': { type: 'org.apache.royale.core.IStrand', access: 'writeonly', declaredBy: 'org.apache.royale.html.accessories.ToolTipBead'}
      };
    },
    methods: function () {
      return {
        'ToolTipBead': { type: '', declaredBy: 'org.apache.royale.html.accessories.ToolTipBead'}
      };
    }
  };
};