56
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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 |
package org.w3c.dom.svg;
|
|
18 |
import org.w3c.dom.DOMException;
|
|
19 |
|
|
20 |
|
|
21 |
/**
|
|
22 |
* This interface represents an "SVGPath" datatype used to define the path geometry.
|
|
23 |
* Corresponds to SVG path specification or the "d" attribute.
|
|
24 |
*
|
|
25 |
*
|
|
26 |
* <p>The native implementations must support the following simplifications or
|
|
27 |
* canonicalization of path segments. Any simplifications should be lossless.
|
|
28 |
*
|
|
29 |
* <ul>
|
|
30 |
* <li>Relative commands (c, h, l, m, q, s, t, and v) must be converted to their absolute counterparts·</li>
|
|
31 |
* <li>Horizontal and Vertical lines (H, h, V, and v) must be converted to general lines (L and l)·</li>
|
|
32 |
* <li>Translate command S to command C·</li>
|
|
33 |
* <li>Translate command T to command Q.</li>
|
|
34 |
* </ul>
|
|
35 |
* </p>
|
|
36 |
*/
|
|
37 |
public interface SVGPath
|
|
38 |
{
|
|
39 |
|
|
40 |
/**
|
|
41 |
* Numeric value is ASCII code of the letter 'M'.
|
|
42 |
*/
|
|
43 |
public static final short MOVE_TO = 77;
|
|
44 |
|
|
45 |
/**
|
|
46 |
* Numeric value is ASCII code of the letter 'L'.
|
|
47 |
*/
|
|
48 |
public static final short LINE_TO = 76;
|
|
49 |
|
|
50 |
/**
|
|
51 |
* Numeric value is ASCII code of the letter 'C'.
|
|
52 |
*/
|
|
53 |
public static final short CURVE_TO = 67;
|
|
54 |
|
|
55 |
/**
|
|
56 |
* Numeric value is ASCII code of the letter 'Q'.
|
|
57 |
*/
|
|
58 |
public static final short QUAD_TO = 81;
|
|
59 |
|
|
60 |
/**
|
|
61 |
* Numeric value is ASCII code of the letter 'Z'.
|
|
62 |
*/
|
|
63 |
public static final short CLOSE = 90;
|
|
64 |
|
|
65 |
|
|
66 |
/**
|
|
67 |
* Return number of segments in this path.
|
|
68 |
*
|
|
69 |
* @return the number of segments in this path.
|
|
70 |
*/
|
|
71 |
public int getNumberOfSegments();
|
|
72 |
|
|
73 |
/**
|
|
74 |
* Returns segment command by zero-based command index. Returns one of MOVE_TO, LINE_TO, CURVE_TO, QUAD_TO or CLOSE.
|
|
75 |
*
|
|
76 |
* @param cmdIndex the command index for the segment command to retrieve.
|
|
77 |
* @return the segment command for the specified cmdIndex.
|
|
78 |
* @throws DOMException with error code INDEX_SIZE_ERR if segment index out of bounds.
|
|
79 |
*
|
|
80 |
*/
|
|
81 |
public short getSegment(int cmdIndex)
|
|
82 |
throws DOMException;
|
|
83 |
|
|
84 |
/**
|
|
85 |
* Returns segment parameter by zero-based command index and zero-based parametr index.
|
|
86 |
*
|
|
87 |
* @param cmdIndex the command index for the segment parameter to retrieve.
|
|
88 |
* @param paramIndex the parameter index for the segment parameter to retrieve.
|
|
89 |
* @return the segment parameter for the specified cmdIndex and paramIndex.
|
|
90 |
* @throws DOMException with error code INDEX_SIZE_ERR if segment index out of bounds or param index out of bounds for this segment's type.
|
|
91 |
*/
|
|
92 |
public float getSegmentParam(int cmdIndex, int paramIndex)
|
|
93 |
throws DOMException;
|
|
94 |
|
|
95 |
/**
|
|
96 |
* Appends 'M' (absolute move) segment to the path with the specified coordinates.
|
|
97 |
*
|
|
98 |
* @param x the x-axis coordinate for the specified point.
|
|
99 |
* @param y the y-axis coordinate for the specified point.
|
|
100 |
*/
|
|
101 |
public void moveTo(float x, float y);
|
|
102 |
|
|
103 |
/**
|
|
104 |
* Appends 'L' (absolute line) segment to the path with the specified coordinates.
|
|
105 |
*
|
|
106 |
* @param x the x-axis coordinate of the specified point.
|
|
107 |
* @param y the y-axis coordinate of the specified point.
|
|
108 |
*/
|
|
109 |
public void lineTo(float x, float y);
|
|
110 |
|
|
111 |
/**
|
|
112 |
* Appends 'Q' (absolute quadratic curve) segment to the path.
|
|
113 |
*
|
|
114 |
* @param x1 the x-axis coordinate of the first control point.
|
|
115 |
* @param y1 the y-axis coordinate of the first control point.
|
|
116 |
* @param x2 the x-axis coordinate of the final end point.
|
|
117 |
* @param y2 the y-axis coordinate of the final end point.
|
|
118 |
*
|
|
119 |
*/
|
|
120 |
public void quadTo(float x1, float y1, float x2, float y2);
|
|
121 |
|
|
122 |
/**
|
|
123 |
* Appends 'C' (absolute cubic curve) segment to the path.
|
|
124 |
*
|
|
125 |
* @param x1 the x-axis coordinate of the first control point.
|
|
126 |
* @param y1 the y-axis coordinate of the first control point.
|
|
127 |
* @param x2 the x-axis coordinate of the second end point.
|
|
128 |
* @param y2 the y-axis coordinate of the second end point.
|
|
129 |
* @param x3 the x-axis coordinate of the final end point.
|
|
130 |
* @param y3 the y-axis coordinate of the final end point.
|
|
131 |
*
|
|
132 |
*/
|
|
133 |
public void curveTo(float x1, float y1, float x2, float y2, float x3, float y3);
|
|
134 |
|
|
135 |
/**
|
|
136 |
* Appends 'Z' (close path) segment to the path
|
|
137 |
*/
|
|
138 |
public void close();
|
|
139 |
}
|