/** * User: Nikita.Skvortsov * Date: 12/14/10 */ package jetbrains.buildServer.flex.client { import flare.display.TextSprite; import flare.vis.data.DataSprite; import flare.vis.data.render.ShapeRenderer; import flash.display.Graphics; import flash.text.TextFormat; public class TeamCityBuildConfigRender extends ShapeRenderer { // constants public static const RECT:String = "rectangle"; private static const MARGIN:int = 10; // properties private var _font:String = "tahoma"; private var _fontSize:Number = 14; public function TeamCityBuildConfigRender() { super(); } // methods override public function render(d:DataSprite):void { var lineAlpha:Number = d.lineAlpha; var fillAlpha:Number = d.fillAlpha; var g:Graphics = d.graphics; g.clear(); if (fillAlpha > 0) { g.beginFill(d.fillColor & 0xFFFFFF, fillAlpha); } if (lineAlpha > 0) g.lineStyle(d.lineWidth, d.lineColor, lineAlpha); var format:TextFormat = new TextFormat(); var props:Object = d.props; format.font = font; format.size = fontSize; switch (d.shape) { case RECT: var label:String = d.data.toString(); var textSprite: TextSprite = new TextSprite(label,format,TextSprite.DEVICE); var boxX:int = -(textSprite.width/2 + MARGIN); var boxY:int = -(textSprite.height/2 + MARGIN); var boxW:int = textSprite.width + MARGIN*2; var boxH:int = textSprite.height + MARGIN*2; g.drawRect(boxX, boxY, boxW, boxH); d.addChild(textSprite); textSprite.x = boxX + MARGIN; textSprite.y = boxY + MARGIN; break; default: super.render(d); } } public function get font():String { return _font; } public function get fontSize():Number { return _fontSize; } public function set font(font:String):void { _font = font; } public function set fontSize(fontSize:Number):void { _fontSize = fontSize; } } }