|
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 package com.nokia.microedition.m2g; |
|
19 |
|
20 import org.w3c.dom.svg.*; |
|
21 |
|
22 /** |
|
23 * This interface represents an "SVGPoint" datatype, |
|
24 * identified by its x and y components. |
|
25 */ |
|
26 public class M2GSVGPoint implements SVGPoint |
|
27 { |
|
28 //-------------------------------------------------- |
|
29 // VARIABLES |
|
30 //-------------------------------------------------- |
|
31 private M2GSVGSVGElement iElement; |
|
32 private float iX; |
|
33 private float iY; |
|
34 |
|
35 //-------------------------------------------------- |
|
36 // METHODS |
|
37 //-------------------------------------------------- |
|
38 /** |
|
39 * Constructor |
|
40 * @param aRootElement |
|
41 */ |
|
42 protected M2GSVGPoint(M2GSVGSVGElement aElement) |
|
43 { |
|
44 iElement = aElement; |
|
45 iX = 0; |
|
46 iY = 0; |
|
47 } |
|
48 |
|
49 /** |
|
50 * Check set validity |
|
51 * @param aValue Value |
|
52 * @return true if setting can be done |
|
53 */ |
|
54 protected boolean check(float aValue) |
|
55 { |
|
56 if (Float.isNaN(aValue)) |
|
57 { |
|
58 // throw IllegalArgumentException(); |
|
59 return false; |
|
60 } |
|
61 if (iElement != null) |
|
62 { |
|
63 String zoomAndPan = iElement.getTrait("zoomAndPan"); |
|
64 if ((zoomAndPan != null) && zoomAndPan.equals("disable")) |
|
65 { |
|
66 return false; |
|
67 } |
|
68 return true; |
|
69 } |
|
70 return false; |
|
71 } |
|
72 |
|
73 /** |
|
74 * @see org.w3c.dom.svg.SVGPath#getX() |
|
75 */ |
|
76 public float getX() |
|
77 { |
|
78 synchronized (this) |
|
79 { |
|
80 return iX; |
|
81 } |
|
82 } |
|
83 |
|
84 /** |
|
85 * @see org.w3c.dom.svg.SVGPath#getX() |
|
86 */ |
|
87 public float getY() |
|
88 { |
|
89 synchronized (this) |
|
90 { |
|
91 return iY; |
|
92 } |
|
93 } |
|
94 |
|
95 /** |
|
96 * @see org.w3c.dom.svg.SVGPath#setX() |
|
97 */ |
|
98 public void setX(float value) |
|
99 { |
|
100 synchronized (this) |
|
101 { |
|
102 if (check(value)) |
|
103 { |
|
104 iX = value; |
|
105 if (iElement != null) |
|
106 { |
|
107 iElement.updateTransformMatrix(); |
|
108 } |
|
109 } |
|
110 } |
|
111 } |
|
112 |
|
113 /** |
|
114 * @see org.w3c.dom.svg.SVGPath#setY() |
|
115 */ |
|
116 public void setY(float value) |
|
117 { |
|
118 synchronized (this) |
|
119 { |
|
120 if (check(value)) |
|
121 { |
|
122 iY = value; |
|
123 if (iElement != null) |
|
124 { |
|
125 iElement.updateTransformMatrix(); |
|
126 } |
|
127 } |
|
128 } |
|
129 } |
|
130 } |