/src/org/mt4j/components/visibleComponents/StyleInfo.java

http://mt4j.googlecode.com/ · Java · 436 lines · 162 code · 61 blank · 213 comment · 0 complexity · e364b9aa31ebdfdb5dc3a94525652ee4 MD5 · raw file

  1. /***********************************************************************
  2. * mt4j Copyright (c) 2008 - 2009, C.Ruff, Fraunhofer-Gesellschaft All rights reserved.
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. *
  17. ***********************************************************************/
  18. package org.mt4j.components.visibleComponents;
  19. import javax.media.opengl.GL;
  20. import org.mt4j.util.MTColor;
  21. import org.mt4j.util.opengl.GLMaterial;
  22. /**
  23. * The Class StyleInfo.
  24. * @author Christopher Ruff
  25. */
  26. public class StyleInfo {
  27. private MTColor fillColor;
  28. private MTColor strokeColor;
  29. /** The draw smooth. */
  30. private boolean drawSmooth;
  31. /** The no stroke. */
  32. private boolean noStroke;
  33. /** The no fill. */
  34. private boolean noFill;
  35. /** The stroke weight. */
  36. private float strokeWeight;
  37. /** The fill draw mode. */
  38. private int fillDrawMode;
  39. /** The line stipple pattern. */
  40. private short lineStipplePattern;
  41. /** The material. */
  42. private GLMaterial material;
  43. /**
  44. * Instantiates a new style info.
  45. */
  46. public StyleInfo(){
  47. this(
  48. new MTColor(255,255,255,255),
  49. new MTColor(255,255,255,255),
  50. true,
  51. false,
  52. false,
  53. 1.0f,
  54. GL.GL_TRIANGLE_FAN,
  55. (short)0
  56. );
  57. }
  58. /**
  59. * Instantiates a new style info.
  60. * @param fillColor the fill color
  61. * @param strokeColor the stroke color
  62. * @param drawSmooth the draw smooth
  63. * @param noStroke the no stroke
  64. * @param noFill the no fill
  65. * @param strokeWeight the stroke weight
  66. * @param fillDrawMode the fill draw mode
  67. * @param lineStipplePattern the line stipple pattern
  68. */
  69. public StyleInfo(
  70. MTColor fillColor,
  71. MTColor strokeColor,
  72. boolean drawSmooth,
  73. boolean noStroke,
  74. boolean noFill,
  75. float strokeWeight,
  76. int fillDrawMode,
  77. short lineStipplePattern
  78. ) {
  79. super();
  80. this.fillColor = fillColor;
  81. this.strokeColor = strokeColor;
  82. this.drawSmooth = drawSmooth;
  83. this.noStroke = noStroke;
  84. this.noFill = noFill;
  85. this.strokeWeight = strokeWeight;
  86. this.fillDrawMode = fillDrawMode;
  87. this.lineStipplePattern = lineStipplePattern;
  88. this.material = null;
  89. }
  90. /**
  91. * Checks if is draw smooth.
  92. *
  93. * @return true, if is draw smooth
  94. */
  95. public boolean isDrawSmooth() {
  96. return drawSmooth;
  97. }
  98. /**
  99. * Sets the draw smooth.
  100. *
  101. * @param drawSmooth the new draw smooth
  102. */
  103. public void setDrawSmooth(boolean drawSmooth) {
  104. this.drawSmooth = drawSmooth;
  105. }
  106. /**
  107. * Sets the fill color.
  108. *
  109. * @param r the r
  110. * @param g the g
  111. * @param b the b
  112. * @param a the a
  113. */
  114. public void setFillColor(float r, float g, float b, float a){
  115. this.setFillRed(r);
  116. this.setFillGreen(g);
  117. this.setFillBlue(b);
  118. this.setFillAlpha(a);
  119. }
  120. public void setFillColor(MTColor fillColor){
  121. this.fillColor = fillColor;
  122. }
  123. public MTColor getFillColor(){
  124. return this.fillColor;
  125. }
  126. /**
  127. * Sets the fill alpha.
  128. *
  129. * @param fillAlpha the new fill alpha
  130. */
  131. public void setFillAlpha(float fillAlpha) {
  132. this.fillColor.setAlpha(fillAlpha);
  133. }
  134. /**
  135. * Gets the fill alpha.
  136. *
  137. * @return the fill alpha
  138. */
  139. public float getFillAlpha() {
  140. return this.fillColor.getAlpha();
  141. }
  142. /**
  143. * Gets the fill blue.
  144. *
  145. * @return the fill blue
  146. */
  147. public float getFillBlue() {
  148. return this.fillColor.getB();
  149. }
  150. /**
  151. * Sets the fill blue.
  152. *
  153. * @param fillBlue the new fill blue
  154. */
  155. public void setFillBlue(float fillBlue) {
  156. this.fillColor.setB(fillBlue);
  157. }
  158. /**
  159. * Gets the fill green.
  160. *
  161. * @return the fill green
  162. */
  163. public float getFillGreen() {
  164. return this.fillColor.getG();
  165. }
  166. /**
  167. * Sets the fill green.
  168. *
  169. * @param fillGreen the new fill green
  170. */
  171. public void setFillGreen(float fillGreen) {
  172. this.fillColor.setG(fillGreen);
  173. }
  174. /**
  175. * Gets the fill red.
  176. *
  177. * @return the fill red
  178. */
  179. public float getFillRed() {
  180. return this.fillColor.getR();
  181. }
  182. /**
  183. * Sets the fill red.
  184. *
  185. * @param fillRed the new fill red
  186. */
  187. public void setFillRed(float fillRed) {
  188. this.fillColor.setR(fillRed);
  189. }
  190. /**
  191. * Checks if is no fill.
  192. *
  193. * @return true, if is no fill
  194. */
  195. public boolean isNoFill() {
  196. return noFill;
  197. }
  198. /**
  199. * Sets the no fill.
  200. *
  201. * @param noFill the new no fill
  202. */
  203. public void setNoFill(boolean noFill) {
  204. this.noFill = noFill;
  205. }
  206. /**
  207. * Checks if is no stroke.
  208. *
  209. * @return true, if is no stroke
  210. */
  211. public boolean isNoStroke() {
  212. return noStroke;
  213. }
  214. /**
  215. * Sets the no stroke.
  216. *
  217. * @param noStroke the new no stroke
  218. */
  219. public void setNoStroke(boolean noStroke) {
  220. this.noStroke = noStroke;
  221. }
  222. /**
  223. * Sets the stroke color.
  224. *
  225. * @param r the r
  226. * @param g the g
  227. * @param b the b
  228. * @param a the a
  229. */
  230. public void setStrokeColor(float r, float g, float b, float a){
  231. this.setStrokeRed(r);
  232. this.setStrokeGreen(g);
  233. this.setStrokeBlue(b);
  234. this.setStrokeAlpha(a);
  235. }
  236. public void setStrokeColor(MTColor strokeColor){
  237. this.strokeColor = strokeColor;
  238. }
  239. public MTColor getStrokeColor() {
  240. return this.strokeColor;
  241. }
  242. /**
  243. * Gets the stroke alpha.
  244. *
  245. * @return the stroke alpha
  246. */
  247. public float getStrokeAlpha() {
  248. return this.strokeColor.getAlpha();
  249. }
  250. /**
  251. * Sets the stroke alpha.
  252. *
  253. * @param strokeAlpha the new stroke alpha
  254. */
  255. public void setStrokeAlpha(float strokeAlpha) {
  256. this.strokeColor.setAlpha(strokeAlpha);
  257. }
  258. /**
  259. * Gets the stroke blue.
  260. *
  261. * @return the stroke blue
  262. */
  263. public float getStrokeBlue() {
  264. return this.strokeColor.getB();
  265. }
  266. /**
  267. * Sets the stroke blue.
  268. *
  269. * @param strokeBlue the new stroke blue
  270. */
  271. public void setStrokeBlue(float strokeBlue) {
  272. this.strokeColor.setB(strokeBlue);
  273. }
  274. /**
  275. * Gets the stroke green.
  276. *
  277. * @return the stroke green
  278. */
  279. public float getStrokeGreen() {
  280. return this.strokeColor.getG();
  281. }
  282. /**
  283. * Sets the stroke green.
  284. *
  285. * @param strokeGreen the new stroke green
  286. */
  287. public void setStrokeGreen(float strokeGreen) {
  288. this.strokeColor.setG(strokeGreen);
  289. }
  290. /**
  291. * Gets the stroke red.
  292. *
  293. * @return the stroke red
  294. */
  295. public float getStrokeRed() {
  296. return this.strokeColor.getR();
  297. }
  298. /**
  299. * Sets the stroke red.
  300. *
  301. * @param strokeRed the new stroke red
  302. */
  303. public void setStrokeRed(float strokeRed) {
  304. this.strokeColor.setR(strokeRed);
  305. }
  306. /**
  307. * Gets the stroke weight.
  308. *
  309. * @return the stroke weight
  310. */
  311. public float getStrokeWeight() {
  312. return strokeWeight;
  313. }
  314. /**
  315. * Sets the stroke weight.
  316. *
  317. * @param strokeWeight the new stroke weight
  318. */
  319. public void setStrokeWeight(float strokeWeight) {
  320. this.strokeWeight = strokeWeight;
  321. }
  322. /**
  323. * Gets the fill draw mode.
  324. *
  325. * @return the fill draw mode
  326. */
  327. public int getFillDrawMode() {
  328. return fillDrawMode;
  329. }
  330. /**
  331. * Sets the draw mode which will be used for creating display lists.
  332. * <br>Modes are the opengl draw modes, e.g. GL_POLYGON, GL_TRIANGLE_FAN, GL_LINES etc.
  333. * <br>Default mode is GL_TRIANGLE_FAN
  334. *
  335. * @param fillDrawMode the fill draw mode
  336. */
  337. public void setFillDrawMode(int fillDrawMode) {
  338. this.fillDrawMode = fillDrawMode;
  339. }
  340. /**
  341. * Sets a line stipple pattern for drawing outlines.
  342. * <br>Only supported under opengl!
  343. * <br>Example: shape.setLineStipple((short)0xDDDD);
  344. * <br>Default value is '0'. No stipple should be used then.
  345. *
  346. * @param stipplePattern the stipple pattern
  347. */
  348. public void setLineStipple(short stipplePattern){
  349. lineStipplePattern = stipplePattern;
  350. }
  351. /**
  352. * Gets the line stipple.
  353. *
  354. * @return the line stipple
  355. */
  356. public short getLineStipple() {
  357. return lineStipplePattern;
  358. }
  359. /**
  360. * Gets the material.
  361. *
  362. * @return the material
  363. */
  364. public GLMaterial getMaterial() {
  365. return material;
  366. }
  367. /**
  368. * Sets the material.
  369. *
  370. * @param material the new material
  371. */
  372. public void setMaterial(GLMaterial material) {
  373. this.material = material;
  374. }
  375. }