Add getters to ol.style.Text
This commit is contained in:
@@ -487,12 +487,15 @@ ol.render.canvas.Immediate.prototype.setTextStyle = function(textStyle) {
|
||||
var state = this.state_;
|
||||
if (!ol.style.Text.equals(state.textStyle, textStyle)) {
|
||||
if (goog.isDefAndNotNull(textStyle)) {
|
||||
context.font = goog.isDef(textStyle.font) ?
|
||||
textStyle.font : ol.render.canvas.defaultFont;
|
||||
context.textAlign = goog.isDef(textStyle.textAlign) ?
|
||||
textStyle.textAlign : ol.render.canvas.defaultTextAlign;
|
||||
context.textBaseline = goog.isDef(textStyle.textBaseline) ?
|
||||
textStyle.textBaseline : ol.render.canvas.defaultTextBaseline;
|
||||
var textStyleFont = textStyle.getFont();
|
||||
context.font = goog.isDef(textStyleFont) ?
|
||||
textStyleFont : ol.render.canvas.defaultFont;
|
||||
var textStyleTextAlign = textStyle.getTextAlign();
|
||||
context.textAlign = goog.isDef(textStyleTextAlign) ?
|
||||
textStyleTextAlign : ol.render.canvas.defaultTextAlign;
|
||||
var textStyleTextBaseline = textStyle.getTextBaseline();
|
||||
context.textBaseline = goog.isDef(textStyleTextBaseline) ?
|
||||
textStyleTextBaseline : ol.render.canvas.defaultTextBaseline;
|
||||
}
|
||||
state.textStyle = textStyle;
|
||||
}
|
||||
|
||||
@@ -11,39 +11,46 @@ ol.style.Text = function(opt_options) {
|
||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {string|undefined}
|
||||
*/
|
||||
this.font = options.font;
|
||||
this.font_ = options.font;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number|undefined}
|
||||
*/
|
||||
this.rotation = options.rotation;
|
||||
this.rotation_ = options.rotation;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {string|undefined}
|
||||
*/
|
||||
this.text = options.text;
|
||||
this.text_ = options.text;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {string|undefined}
|
||||
*/
|
||||
this.textAlign = options.textAlign;
|
||||
this.textAlign_ = options.textAlign;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {string|undefined}
|
||||
*/
|
||||
this.textBaseline = options.textBaseline;
|
||||
this.textBaseline_ = options.textBaseline;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.style.Fill}
|
||||
*/
|
||||
this.fill = goog.isDef(options.fill) ? options.fill : null;
|
||||
this.fill_ = goog.isDef(options.fill) ? options.fill : null;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.style.Stroke}
|
||||
*/
|
||||
this.stroke = goog.isDef(options.stroke) ? options.stroke : null;
|
||||
this.stroke_ = goog.isDef(options.stroke) ? options.stroke : null;
|
||||
};
|
||||
|
||||
|
||||
@@ -56,10 +63,10 @@ ol.style.Text.equals = function(textStyle1, textStyle2) {
|
||||
if (!goog.isNull(textStyle1)) {
|
||||
if (!goog.isNull(textStyle2)) {
|
||||
return textStyle1 === textStyle2 || (
|
||||
textStyle1.font == textStyle2.font &&
|
||||
textStyle1.text == textStyle2.text &&
|
||||
textStyle1.textAlign == textStyle2.textAlign &&
|
||||
textStyle1.textBaseline == textStyle2.textBaseline);
|
||||
textStyle1.getFont() == textStyle2.getFont() &&
|
||||
textStyle1.getText() == textStyle2.getText() &&
|
||||
textStyle1.getTextAlign() == textStyle2.getTextAlign() &&
|
||||
textStyle1.getTextBaseline() == textStyle2.getTextBaseline());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@@ -71,3 +78,59 @@ ol.style.Text.equals = function(textStyle1, textStyle2) {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {string|undefined} Font.
|
||||
*/
|
||||
ol.style.Text.prototype.getFont = function() {
|
||||
return this.font_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {ol.style.Fill} Fill style.
|
||||
*/
|
||||
ol.style.Text.prototype.getFill = function() {
|
||||
return this.fill_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {number|undefined} Rotation.
|
||||
*/
|
||||
ol.style.Text.prototype.getRotation = function() {
|
||||
return this.rotation_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {ol.style.Stroke} Stroke style.
|
||||
*/
|
||||
ol.style.Text.prototype.getStroke = function() {
|
||||
return this.stroke_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {string|undefined} Text.
|
||||
*/
|
||||
ol.style.Text.prototype.getText = function() {
|
||||
return this.text_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {string|undefined} Text align.
|
||||
*/
|
||||
ol.style.Text.prototype.getTextAlign = function() {
|
||||
return this.textAlign_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {string|undefined} Text baseline.
|
||||
*/
|
||||
ol.style.Text.prototype.getTextBaseline = function() {
|
||||
return this.textBaseline_;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user