|
1 /* |
|
2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 package com.nokia.microedition.m2g; |
|
20 |
|
21 import org.w3c.dom.svg.*; |
|
22 |
|
23 /** |
|
24 * This interface represents an "SVGRect" datatype, consisting of a minimum X, minimum Y, width |
|
25 * and height values. |
|
26 */ |
|
27 public class M2GSVGRect implements SVGRect |
|
28 { |
|
29 //-------------------------------------------------- |
|
30 // STATIC CONSTANTS |
|
31 //-------------------------------------------------- |
|
32 private static final int X = 0; |
|
33 private static final int Y = 1; |
|
34 private static final int W = 2; |
|
35 private static final int H = 3; |
|
36 |
|
37 //-------------------------------------------------- |
|
38 // VARIABLES |
|
39 //-------------------------------------------------- |
|
40 private float[] iComponents; |
|
41 |
|
42 //-------------------------------------------------- |
|
43 // METHODS |
|
44 //-------------------------------------------------- |
|
45 /** |
|
46 * Contructor |
|
47 */ |
|
48 protected M2GSVGRect() |
|
49 { |
|
50 iComponents = new float[4]; |
|
51 iComponents[X] = 0; |
|
52 iComponents[Y] = 0; |
|
53 iComponents[W] = 0; |
|
54 iComponents[H] = 0; |
|
55 } |
|
56 |
|
57 /** |
|
58 * Contructor |
|
59 * @param aX - |
|
60 * @param aY - |
|
61 * @param aWidth - |
|
62 * @param aHeight - |
|
63 */ |
|
64 protected M2GSVGRect(float aX, float aY, float aWidth, float aHeight) |
|
65 { |
|
66 iComponents = new float[4]; |
|
67 iComponents[X] = aX; |
|
68 iComponents[Y] = aY; |
|
69 iComponents[W] = aWidth; |
|
70 iComponents[H] = aHeight; |
|
71 } |
|
72 |
|
73 /** |
|
74 * Returns reference to a components |
|
75 * @return components |
|
76 */ |
|
77 float[] getComponents() |
|
78 { |
|
79 return iComponents; |
|
80 } |
|
81 |
|
82 /** |
|
83 * @see org.w3c.dom.svg.SVGRect#getX() |
|
84 */ |
|
85 public float getX() |
|
86 { |
|
87 return iComponents[X]; |
|
88 } |
|
89 |
|
90 /** |
|
91 * @see org.w3c.dom.svg.SVGRect#getY() |
|
92 */ |
|
93 public float getY() |
|
94 { |
|
95 return iComponents[Y]; |
|
96 } |
|
97 |
|
98 /** |
|
99 * @see org.w3c.dom.svg.SVGRect#getWidth() |
|
100 */ |
|
101 public float getWidth() |
|
102 { |
|
103 return iComponents[W]; |
|
104 } |
|
105 |
|
106 /** |
|
107 * @see org.w3c.dom.svg.SVGRect#getHeight() |
|
108 */ |
|
109 public float getHeight() |
|
110 { |
|
111 return iComponents[H]; |
|
112 } |
|
113 |
|
114 /** |
|
115 * Checks if all components are zero |
|
116 * @returns true is every component is zero |
|
117 */ |
|
118 public boolean isZero() |
|
119 { |
|
120 for (int index = 0; index < iComponents.length; index++) |
|
121 { |
|
122 if (iComponents[index] != 0) |
|
123 { |
|
124 return false; |
|
125 } |
|
126 } |
|
127 return true; |
|
128 } |
|
129 |
|
130 /** |
|
131 * @see org.w3c.dom.svg.SVGRect#setX() |
|
132 */ |
|
133 public void setX(float value) |
|
134 { |
|
135 iComponents[X] = value; |
|
136 } |
|
137 |
|
138 /** |
|
139 * @see org.w3c.dom.svg.SVGRect#setY() |
|
140 */ |
|
141 public void setY(float value) |
|
142 { |
|
143 iComponents[Y] = value; |
|
144 } |
|
145 |
|
146 /** |
|
147 * @see org.w3c.dom.svg.SVGRect#setWidth() |
|
148 */ |
|
149 public void setWidth(float value) |
|
150 { |
|
151 iComponents[W] = value; |
|
152 } |
|
153 |
|
154 /** |
|
155 * @see org.w3c.dom.svg.SVGRect#setHeight() |
|
156 */ |
|
157 public void setHeight(float value) |
|
158 { |
|
159 iComponents[H] = value; |
|
160 } |
|
161 } |