<commit_before>/**
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

goog.provide('org.apache.flex.core.graphics.Rect');

goog.require('org.apache.flex.core.graphics.GraphicShape');



/**
 * @constructor
 * @extends {org.apache.flex.core.graphics.GraphicShape}
 */
org.apache.flex.core.graphics.Rect = function() {
  org.apache.flex.core.graphics.Rect.base(this, 'constructor');

  /**
   * @private
   * @type {number}
   */
  this.fillColor_ = 0;
};
goog.inherits(org.apache.flex.core.graphics.Rect,
    org.apache.flex.core.graphics.GraphicShape);


/**
 * Metadata
 *
 * @type {Object.<string, Array.<Object>>}
 */
org.apache.flex.core.graphics.Rect.prototype.FLEXJS_CLASS_INFO =
    { names: [{ name: 'Rect',
                qName: 'org.apache.flex.core.graphics.Rect' }] };


/**
 * @expose
 * @param {number} x The x position of the top-left corner of the rectangle.
 * @param {number} y The y position of the top-left corner.
 * @param {number} width The width of the rectangle.
 * @param {number} height The height of the rectangle.
 */
org.apache.flex.core.graphics.Rect.prototype.drawRect = function(x, y, width, height) {
	var color = Number(this.get_fill().get_color()).toString(16);
	if (color.length == 2) color = '00' + color;
	if (color.length == 4) color = '00' + color;
	
	var strokeColor = Number(this.get_stroke().get_color()).toString(16);
	if (strokeColor.length == 2) strokeColor = '00' + strokeColor;
	if (strokeColor.length == 4) strokeColor = '00' + strokeColor;

	var style = 'fill:#' + String(color) + ';stroke:'+ String(strokeColor) + ';stroke-width:' + String(this.get_stroke().get_weight());

	var rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');
	rect.setAttribute('style', style);
	rect.setAttribute('x', String(x));
	rect.setAttribute('y', String(y));
	rect.setAttribute('width', String(width));
	rect.setAttribute('height', String(height));
	this.element.appendChild(rect);
};
<commit_msg>Fix formatting of style attribute + add fill-opacity attribute<commit_after>/**
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

goog.provide('org.apache.flex.core.graphics.Rect');

goog.require('org.apache.flex.core.graphics.GraphicShape');



/**
 * @constructor
 * @extends {org.apache.flex.core.graphics.GraphicShape}
 */
org.apache.flex.core.graphics.Rect = function() {
  org.apache.flex.core.graphics.Rect.base(this, 'constructor');

  /**
   * @private
   * @type {number}
   */
  this.fillColor_ = 0;
};
goog.inherits(org.apache.flex.core.graphics.Rect,
    org.apache.flex.core.graphics.GraphicShape);


/**
 * Metadata
 *
 * @type {Object.<string, Array.<Object>>}
 */
org.apache.flex.core.graphics.Rect.prototype.FLEXJS_CLASS_INFO =
    { names: [{ name: 'Rect',
                qName: 'org.apache.flex.core.graphics.Rect' }] };


/**
 * @expose
 * @param {number} x The x position of the top-left corner of the rectangle.
 * @param {number} y The y position of the top-left corner.
 * @param {number} width The width of the rectangle.
 * @param {number} height The height of the rectangle.
 */
org.apache.flex.core.graphics.Rect.prototype.drawRect = function(x, y, width, height) {
	var color = Number(this.get_fill().get_color()).toString(16);
	if (color.length == 2) color = '00' + color;
	if (color.length == 4) color = '00' + color;
	
	var strokeColor = Number(this.get_stroke().get_color()).toString(16);
	if (strokeColor.length == 2) strokeColor = '00' + strokeColor;
	if (strokeColor.length == 4) strokeColor = '00' + strokeColor;

	var style = 'fill:#' + String(color) + ';stroke:#'+ String(strokeColor) + ';stroke-width:' + String(this.get_stroke().get_weight());

	var rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');
	rect.setAttribute('style', style);
	rect.setAttribute('x', String(x));
	rect.setAttribute('y', String(y));
	rect.setAttribute('width', String(width));
	rect.setAttribute('height', String(height));
	rect.setAttribute('fill-opacity', String(this.get_fill().get_alpha()));
	this.element.appendChild(rect);
};

{'fraction_non_alphanumeric': 0.15737249454256796, 'fraction_numerical': 0.010319507838856917, 'mean_word_length': 4.1692307692307695, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4739272', 'n_tokens_mistral': 1613, 'n_tokens_neox': 1559, 'n_words': 415}