PageRenderTime 31ms CodeModel.GetById 20ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/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 ***********************************************************************/
 18package org.mt4j.components.visibleComponents;
 19
 20import javax.media.opengl.GL;
 21
 22import org.mt4j.util.MTColor;
 23import org.mt4j.util.opengl.GLMaterial;
 24
 25
 26/**
 27 * The Class StyleInfo.
 28 * @author Christopher Ruff
 29 */
 30public class StyleInfo {
 31	
 32	private MTColor fillColor;
 33	
 34	private MTColor strokeColor;
 35	
 36	/** The draw smooth. */
 37	private boolean drawSmooth;
 38	
 39	/** The no stroke. */
 40	private boolean noStroke;
 41	
 42	/** The no fill. */
 43	private boolean noFill;
 44	
 45	/** The stroke weight. */
 46	private float strokeWeight;
 47	
 48	/** The fill draw mode. */
 49	private int fillDrawMode;
 50	
 51	/** The line stipple pattern. */
 52	private short lineStipplePattern;
 53	
 54	/** The material. */
 55	private GLMaterial material;
 56	
 57	/**
 58	 * Instantiates a new style info.
 59	 */
 60	public StyleInfo(){
 61		this(
 62				new MTColor(255,255,255,255),
 63				new MTColor(255,255,255,255),
 64				true,
 65				false,
 66				false,
 67				1.0f,
 68				GL.GL_TRIANGLE_FAN,
 69				(short)0				
 70			);
 71	}
 72	
 73	/**
 74	 * Instantiates a new style info.
 75	 * @param fillColor the fill color
 76	 * @param strokeColor the stroke color
 77	 * @param drawSmooth the draw smooth
 78	 * @param noStroke the no stroke
 79	 * @param noFill the no fill
 80	 * @param strokeWeight the stroke weight
 81	 * @param fillDrawMode the fill draw mode
 82	 * @param lineStipplePattern the line stipple pattern
 83	 */
 84	public StyleInfo(
 85			MTColor fillColor,
 86			MTColor strokeColor,
 87			boolean drawSmooth, 
 88			boolean noStroke, 
 89			boolean noFill, 
 90			float strokeWeight, 
 91			int fillDrawMode, 
 92			short lineStipplePattern			
 93		) {
 94		super();
 95		this.fillColor = fillColor;
 96		this.strokeColor = strokeColor;
 97		this.drawSmooth = drawSmooth;
 98		this.noStroke = noStroke;
 99		this.noFill = noFill;
100		this.strokeWeight = strokeWeight;
101		this.fillDrawMode = fillDrawMode;
102		this.lineStipplePattern = lineStipplePattern;
103		
104		this.material = null;
105	}
106
107
108	
109	/**
110	 * Checks if is draw smooth.
111	 * 
112	 * @return true, if is draw smooth
113	 */
114	public boolean isDrawSmooth() {
115		return drawSmooth;
116	}
117
118	/**
119	 * Sets the draw smooth.
120	 * 
121	 * @param drawSmooth the new draw smooth
122	 */
123	public void setDrawSmooth(boolean drawSmooth) {
124		this.drawSmooth = drawSmooth;
125	}
126
127
128	
129	/**
130	 * Sets the fill color.
131	 * 
132	 * @param r the r
133	 * @param g the g
134	 * @param b the b
135	 * @param a the a
136	 */
137	public void setFillColor(float r, float g, float b, float a){
138		this.setFillRed(r);
139		this.setFillGreen(g);
140		this.setFillBlue(b);
141		this.setFillAlpha(a);
142	}
143	
144	public void setFillColor(MTColor fillColor){
145		this.fillColor = fillColor;
146	}
147	
148	public MTColor getFillColor(){
149		return this.fillColor;
150	}
151
152	/**
153	 * Sets the fill alpha.
154	 * 
155	 * @param fillAlpha the new fill alpha
156	 */
157	public void setFillAlpha(float fillAlpha) {
158		this.fillColor.setAlpha(fillAlpha);
159	}
160	/**
161	 * Gets the fill alpha.
162	 * 
163	 * @return the fill alpha
164	 */
165	public float getFillAlpha() {
166		return this.fillColor.getAlpha();
167	}
168	/**
169	 * Gets the fill blue.
170	 * 
171	 * @return the fill blue
172	 */
173	public float getFillBlue() {
174		return this.fillColor.getB();
175	}
176
177	/**
178	 * Sets the fill blue.
179	 * 
180	 * @param fillBlue the new fill blue
181	 */
182	public void setFillBlue(float fillBlue) {
183		this.fillColor.setB(fillBlue);
184	}
185
186	/**
187	 * Gets the fill green.
188	 * 
189	 * @return the fill green
190	 */
191	public float getFillGreen() {
192		return this.fillColor.getG();
193	}
194
195	/**
196	 * Sets the fill green.
197	 * 
198	 * @param fillGreen the new fill green
199	 */
200	public void setFillGreen(float fillGreen) {
201		this.fillColor.setG(fillGreen);
202	}
203
204	/**
205	 * Gets the fill red.
206	 * 
207	 * @return the fill red
208	 */
209	public float getFillRed() {
210		return this.fillColor.getR();
211	}
212
213	/**
214	 * Sets the fill red.
215	 * 
216	 * @param fillRed the new fill red
217	 */
218	public void setFillRed(float fillRed) {
219		this.fillColor.setR(fillRed);
220	}
221
222	/**
223	 * Checks if is no fill.
224	 * 
225	 * @return true, if is no fill
226	 */
227	public boolean isNoFill() {
228		return noFill;
229	}
230
231	/**
232	 * Sets the no fill.
233	 * 
234	 * @param noFill the new no fill
235	 */
236	public void setNoFill(boolean noFill) {
237		this.noFill = noFill;
238	}
239
240	/**
241	 * Checks if is no stroke.
242	 * 
243	 * @return true, if is no stroke
244	 */
245	public boolean isNoStroke() {
246		return noStroke;
247	}
248
249	/**
250	 * Sets the no stroke.
251	 * 
252	 * @param noStroke the new no stroke
253	 */
254	public void setNoStroke(boolean noStroke) {
255		this.noStroke = noStroke;
256	}
257	
258	/**
259	 * Sets the stroke color.
260	 * 
261	 * @param r the r
262	 * @param g the g
263	 * @param b the b
264	 * @param a the a
265	 */
266	public void setStrokeColor(float r, float g, float b, float a){
267		this.setStrokeRed(r);
268		this.setStrokeGreen(g);
269		this.setStrokeBlue(b);
270		this.setStrokeAlpha(a);
271	}
272	
273	public void setStrokeColor(MTColor strokeColor){
274		this.strokeColor = strokeColor;
275	}
276
277	public MTColor getStrokeColor() {
278		return this.strokeColor;
279	}
280	
281	/**
282	 * Gets the stroke alpha.
283	 * 
284	 * @return the stroke alpha
285	 */
286	public float getStrokeAlpha() {
287		return this.strokeColor.getAlpha();
288	}
289
290	/**
291	 * Sets the stroke alpha.
292	 * 
293	 * @param strokeAlpha the new stroke alpha
294	 */
295	public void setStrokeAlpha(float strokeAlpha) {
296		this.strokeColor.setAlpha(strokeAlpha);
297	}
298
299	/**
300	 * Gets the stroke blue.
301	 * 
302	 * @return the stroke blue
303	 */
304	public float getStrokeBlue() {
305		return this.strokeColor.getB();
306	}
307
308	/**
309	 * Sets the stroke blue.
310	 * 
311	 * @param strokeBlue the new stroke blue
312	 */
313	public void setStrokeBlue(float strokeBlue) {
314		this.strokeColor.setB(strokeBlue);
315	}
316
317	/**
318	 * Gets the stroke green.
319	 * 
320	 * @return the stroke green
321	 */
322	public float getStrokeGreen() {
323		return this.strokeColor.getG();
324	}
325
326	/**
327	 * Sets the stroke green.
328	 * 
329	 * @param strokeGreen the new stroke green
330	 */
331	public void setStrokeGreen(float strokeGreen) {
332		this.strokeColor.setG(strokeGreen);
333	}
334
335	/**
336	 * Gets the stroke red.
337	 * 
338	 * @return the stroke red
339	 */
340	public float getStrokeRed() {
341		return this.strokeColor.getR();
342	}
343
344	/**
345	 * Sets the stroke red.
346	 * 
347	 * @param strokeRed the new stroke red
348	 */
349	public void setStrokeRed(float strokeRed) {
350		this.strokeColor.setR(strokeRed);
351	}
352
353	/**
354	 * Gets the stroke weight.
355	 * 
356	 * @return the stroke weight
357	 */
358	public float getStrokeWeight() {
359		return strokeWeight;
360	}
361
362	/**
363	 * Sets the stroke weight.
364	 * 
365	 * @param strokeWeight the new stroke weight
366	 */
367	public void setStrokeWeight(float strokeWeight) {
368		this.strokeWeight = strokeWeight;
369	}
370	
371	
372	/**
373	 * Gets the fill draw mode.
374	 * 
375	 * @return the fill draw mode
376	 */
377	public int getFillDrawMode() {
378		return fillDrawMode;
379	}
380	
381	/**
382	 * Sets the draw mode which will be used for creating display lists.
383	 * <br>Modes are the opengl draw modes, e.g. GL_POLYGON, GL_TRIANGLE_FAN, GL_LINES etc.
384	 * <br>Default mode is GL_TRIANGLE_FAN
385	 * 
386	 * @param fillDrawMode the fill draw mode
387	 */
388	public void setFillDrawMode(int fillDrawMode) {
389		this.fillDrawMode = fillDrawMode;
390	}
391	
392	/**
393	 * Sets a line stipple pattern for drawing outlines.
394	 * <br>Only supported under opengl!
395	 * <br>Example: shape.setLineStipple((short)0xDDDD);
396	 * <br>Default value is '0'. No stipple should be used then.
397	 * 
398	 * @param stipplePattern the stipple pattern
399	 */
400	public void setLineStipple(short stipplePattern){
401		lineStipplePattern = stipplePattern;
402	}
403	
404	
405	/**
406	 * Gets the line stipple.
407	 * 
408	 * @return the line stipple
409	 */
410	public short getLineStipple() {
411		return lineStipplePattern;
412	}
413
414	
415	/**
416	 * Gets the material.
417	 * 
418	 * @return the material
419	 */
420	public GLMaterial getMaterial() {
421		return material;
422	}
423
424	/**
425	 * Sets the material.
426	 * 
427	 * @param material the new material
428	 */
429	public void setMaterial(GLMaterial material) {
430		this.material = material;
431	}
432
433
434	
435	
436}