/src/eu/stefaner/elasticlists/ui/DefaultGraphicsFactory.as

https://github.com/pombredanne/Elastic-Lists · ActionScript · 165 lines · 115 code · 24 blank · 26 comment · 0 complexity · 1b6682f183340a8d231621ad5f333170 MD5 · raw file

  1. /*
  2. Copyright 2010, Moritz Stefaner
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package eu.stefaner.elasticlists.ui {
  14. import com.bit101.components.PushButton;
  15. import flash.display.DisplayObjectContainer;
  16. import flash.display.Sprite;
  17. import flash.filters.DropShadowFilter;
  18. import flash.text.AntiAliasType;
  19. import flash.text.TextField;
  20. import flash.text.TextFieldAutoSize;
  21. import flash.text.TextFormat;
  22. public class DefaultGraphicsFactory {
  23. public static var highlightColor : uint = 0xEEEE11;
  24. //[Embed(source="/assets/PTS55F.ttf", fontName="regularFont", advancedAntiAliasing="true", mimeType="application/x-font-truetype")]
  25. private var regularFont : Class;
  26. //[Embed(source="/assets/Aller_Bd.ttf", fontName="boldFont", fontWeight='bold', advancedAntiAliasing="true", mimeType="application/x-font-truetype")]
  27. private var boldFont : Class;
  28. public static var regularFontName : String = "regularFont";
  29. public static var boldFontName : String = "boldFont";
  30. public static function getTextField() : TextField {
  31. var t : TextField = new TextField();
  32. t.autoSize = TextFieldAutoSize.LEFT;
  33. t.multiline = false;
  34. t.embedFonts = true;
  35. t.antiAliasType = AntiAliasType.ADVANCED;
  36. var tf : TextFormat = new TextFormat(regularFontName, 10, 0x333333);
  37. t.defaultTextFormat = tf;
  38. return t;
  39. }
  40. public static function getFacetBoxContainerBackground() : Sprite {
  41. var s : Sprite = getPanelBackground();
  42. s.filters = [new DropShadowFilter(2, 45, 0, .2)];
  43. return s;
  44. }
  45. public static function getFacetBoxBackground() : Sprite {
  46. var s : Sprite = new Sprite();
  47. s.graphics.beginFill(0xDDDDDD, 1);
  48. s.graphics.drawRect(0, 0, 100, 100);
  49. return s;
  50. }
  51. public static function getContentItemBackground() : Sprite {
  52. var s : Sprite = new Sprite();
  53. s.graphics.beginFill(0xFFFFFF);
  54. s.graphics.lineStyle(0, 0xCCCCCC, 1);
  55. s.graphics.drawRect(0, 0, 200, 100);
  56. //s.filters = [new DropShadowFilter(2, 45, 0, .2)];
  57. return s;
  58. }
  59. public static function getSelectionMarker() : Sprite {
  60. var s : Sprite = new Sprite();
  61. s.graphics.beginFill(highlightColor);
  62. s.graphics.drawRect(0, 0, 100, 100);
  63. return s;
  64. }
  65. public static function getTitleTextField() : TextField {
  66. var t : TextField = new TextField();
  67. t.autoSize = TextFieldAutoSize.LEFT;
  68. t.multiline = false;
  69. t.embedFonts = true;
  70. t.antiAliasType = AntiAliasType.ADVANCED;
  71. var tf : TextFormat = new TextFormat(boldFontName, 12, 0x333333, true);
  72. t.defaultTextFormat = tf;
  73. return t;
  74. }
  75. public static function getPanelBackground() : Sprite {
  76. var s : Sprite = new Sprite();
  77. s.graphics.beginFill(0xF0F0F0, 1);
  78. s.graphics.drawRect(0, 0, 100, 100);
  79. return s;
  80. }
  81. public static function getContentAreaBackground() : Sprite {
  82. var s : Sprite = new Sprite();
  83. s.graphics.beginFill(0xF0F0F0, 0);
  84. s.graphics.drawRect(0, 0, 100, 100);
  85. return s;
  86. }
  87. public static function getElasticListEntryBackground() : Sprite {
  88. var s : Sprite = new Sprite();
  89. s.graphics.beginFill(0xFFFFFF);
  90. //s.graphics.lineStyle(0, 0xCCCCCC, 1);
  91. s.graphics.drawRect(0, 0, 200, 100);
  92. s.filters = [new DropShadowFilter(2, 45, 0, .2)];
  93. return s;
  94. }
  95. public static function getButton(p : DisplayObjectContainer, x : Number = 0, y : Number = 0, label : String = "", handler : Function = null) : PushButton {
  96. return new PushButton(p, x, y, label, handler);
  97. }
  98. public static function getMapMarkerBackground() : Sprite {
  99. var s : Sprite = new Sprite();
  100. s.graphics.beginFill(0x333333);
  101. //s.graphics.lineStyle(0, 0xCCCCCC, 1, false, "none");
  102. //s.filters = [new DropShadowFilter(2, 45, 0, .2)];
  103. s.graphics.drawCircle(0, 0, 1);
  104. return s;
  105. }
  106. public static function getMapMarkerSelectionMarker() : Sprite {
  107. var s : Sprite = new Sprite();
  108. s.graphics.beginFill(highlightColor);
  109. //s.graphics.lineStyle(0, 0xCCCCCC, 1);
  110. s.graphics.drawCircle(0, 0, 1);
  111. return s;
  112. }
  113. public static function getSliderFacetBoxElementBackground() : Sprite {
  114. var s : Sprite = new Sprite();
  115. s.graphics.beginFill(0xFFFFFF);
  116. //s.graphics.lineStyle(0, 0xCCCCCC, 1);
  117. s.graphics.drawRect(0, 0, 200, 100);
  118. return s;
  119. }
  120. public static function getSliderFacetBoxElementLocalBar() : Sprite {
  121. var s : Sprite = new Sprite();
  122. s.graphics.beginFill(0xFFFFFF);
  123. s.graphics.lineStyle(0, 0xCCCCCC, 1);
  124. s.graphics.drawRect(-1, -2, 2, 2);
  125. s.filters = [new DropShadowFilter(0, 45, 0, .2)];
  126. return s;
  127. }
  128. public static function getSliderFacetBoxElementGlobalBar() : Sprite {
  129. var s : Sprite = new Sprite();
  130. s.graphics.beginFill(0xDDDDDD);
  131. //s.graphics.lineStyle(0, 0xCCCCCC, 1);
  132. s.graphics.drawRect(-1, -2, 2, 2);
  133. return s;
  134. }
  135. }
  136. }