/android/LGame-Android-0.2.95/src/org/loon/framework/android/game/core/graphics/window/UIFactory.java

http://loon-simple.googlecode.com/ · Java · 138 lines · 36 code · 17 blank · 85 comment · 2 complexity · 99354a19e8f3dd32743788e593e0aaee MD5 · raw file

  1. package org.loon.framework.android.game.core.graphics.window;
  2. import java.util.HashMap;
  3. import org.loon.framework.android.game.core.graphics.LComponent;
  4. import org.loon.framework.android.game.core.graphics.LImage;
  5. import org.loon.framework.android.game.core.graphics.device.LGraphics;
  6. /**
  7. *
  8. * Copyright 2008 - 2009
  9. *
  10. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  11. * use this file except in compliance with the License. You may obtain a copy of
  12. * the License at
  13. *
  14. * http://www.apache.org/licenses/LICENSE-2.0
  15. *
  16. * Unless required by applicable law or agreed to in writing, software
  17. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  18. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  19. * License for the specific language governing permissions and limitations under
  20. * the License.
  21. *
  22. * @project loonframework
  23. * @author chenpeng
  24. * @email?ceponline@yahoo.com.cn
  25. * @version 0.1
  26. */
  27. public abstract class UIFactory {
  28. private final HashMap<String, Object> uiResource = new HashMap<String, Object>(30);
  29. /**
  30. * ???????????
  31. */
  32. public boolean immutable = false;
  33. /**
  34. * ???????
  35. *
  36. */
  37. public UIFactory() {
  38. }
  39. /**
  40. * ???????
  41. *
  42. * @return
  43. */
  44. public abstract String getUIName();
  45. /**
  46. * ???????
  47. *
  48. * @return
  49. */
  50. public abstract String[] getUIDescription();
  51. /**
  52. * ????UI????????
  53. *
  54. * @param component
  55. * @param width
  56. * @param height
  57. * @return
  58. */
  59. public abstract LImage[] createUI(LComponent component, int width,
  60. int height);
  61. /**
  62. * ????UI
  63. *
  64. * @param component
  65. * @param ui
  66. */
  67. public abstract void processUI(LComponent component, LImage[] ui);
  68. /**
  69. * ??UI?????
  70. *
  71. * @param g
  72. * @param x
  73. * @param y
  74. * @param component
  75. * @param ui
  76. */
  77. public abstract void createUI(LGraphics g, int x, int y,
  78. LComponent component, LImage[] ui);
  79. /**
  80. * ?????UI??
  81. *
  82. * @param key
  83. * @param component
  84. * @return
  85. */
  86. public Object get(String key, LComponent component) {
  87. if (component == null) {
  88. return this.uiResource.get(key);
  89. }
  90. return (component.getUIResource().containsKey(key)) ? component
  91. .getUIResource().get(key) : this.uiResource.get(key);
  92. }
  93. /**
  94. * ??????UI?
  95. *
  96. * @param key
  97. * @param value
  98. */
  99. public void put(String key, Object value) {
  100. this.uiResource.put(key, value);
  101. }
  102. /**
  103. * ??????
  104. *
  105. * @param key
  106. * @return
  107. */
  108. protected final Object remove(String key) {
  109. return this.uiResource.remove(key);
  110. }
  111. /**
  112. * ??????????????
  113. *
  114. * @return
  115. */
  116. public final String[] getUIResource() {
  117. String[] temp = new String[this.uiResource.size()];
  118. String[] keys = (String[]) this.uiResource.keySet().toArray(temp);
  119. return keys;
  120. }
  121. }