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_;
|
var state = this.state_;
|
||||||
if (!ol.style.Text.equals(state.textStyle, textStyle)) {
|
if (!ol.style.Text.equals(state.textStyle, textStyle)) {
|
||||||
if (goog.isDefAndNotNull(textStyle)) {
|
if (goog.isDefAndNotNull(textStyle)) {
|
||||||
context.font = goog.isDef(textStyle.font) ?
|
var textStyleFont = textStyle.getFont();
|
||||||
textStyle.font : ol.render.canvas.defaultFont;
|
context.font = goog.isDef(textStyleFont) ?
|
||||||
context.textAlign = goog.isDef(textStyle.textAlign) ?
|
textStyleFont : ol.render.canvas.defaultFont;
|
||||||
textStyle.textAlign : ol.render.canvas.defaultTextAlign;
|
var textStyleTextAlign = textStyle.getTextAlign();
|
||||||
context.textBaseline = goog.isDef(textStyle.textBaseline) ?
|
context.textAlign = goog.isDef(textStyleTextAlign) ?
|
||||||
textStyle.textBaseline : ol.render.canvas.defaultTextBaseline;
|
textStyleTextAlign : ol.render.canvas.defaultTextAlign;
|
||||||
|
var textStyleTextBaseline = textStyle.getTextBaseline();
|
||||||
|
context.textBaseline = goog.isDef(textStyleTextBaseline) ?
|
||||||
|
textStyleTextBaseline : ol.render.canvas.defaultTextBaseline;
|
||||||
}
|
}
|
||||||
state.textStyle = textStyle;
|
state.textStyle = textStyle;
|
||||||
}
|
}
|
||||||
|
|||||||
+74
-11
@@ -11,39 +11,46 @@ ol.style.Text = function(opt_options) {
|
|||||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
var options = goog.isDef(opt_options) ? opt_options : {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @private
|
||||||
* @type {string|undefined}
|
* @type {string|undefined}
|
||||||
*/
|
*/
|
||||||
this.font = options.font;
|
this.font_ = options.font;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @private
|
||||||
* @type {number|undefined}
|
* @type {number|undefined}
|
||||||
*/
|
*/
|
||||||
this.rotation = options.rotation;
|
this.rotation_ = options.rotation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @private
|
||||||
* @type {string|undefined}
|
* @type {string|undefined}
|
||||||
*/
|
*/
|
||||||
this.text = options.text;
|
this.text_ = options.text;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @private
|
||||||
* @type {string|undefined}
|
* @type {string|undefined}
|
||||||
*/
|
*/
|
||||||
this.textAlign = options.textAlign;
|
this.textAlign_ = options.textAlign;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @private
|
||||||
* @type {string|undefined}
|
* @type {string|undefined}
|
||||||
*/
|
*/
|
||||||
this.textBaseline = options.textBaseline;
|
this.textBaseline_ = options.textBaseline;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @private
|
||||||
* @type {ol.style.Fill}
|
* @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}
|
* @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(textStyle1)) {
|
||||||
if (!goog.isNull(textStyle2)) {
|
if (!goog.isNull(textStyle2)) {
|
||||||
return textStyle1 === textStyle2 || (
|
return textStyle1 === textStyle2 || (
|
||||||
textStyle1.font == textStyle2.font &&
|
textStyle1.getFont() == textStyle2.getFont() &&
|
||||||
textStyle1.text == textStyle2.text &&
|
textStyle1.getText() == textStyle2.getText() &&
|
||||||
textStyle1.textAlign == textStyle2.textAlign &&
|
textStyle1.getTextAlign() == textStyle2.getTextAlign() &&
|
||||||
textStyle1.textBaseline == textStyle2.textBaseline);
|
textStyle1.getTextBaseline() == textStyle2.getTextBaseline());
|
||||||
} else {
|
} else {
|
||||||
return false;
|
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