001: /*
002: *
003: *
004: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License version
009: * 2 only, as published by the Free Software Foundation.
010: *
011: * This program is distributed in the hope that it will be useful, but
012: * WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * General Public License version 2 for more details (a copy is
015: * included at /legal/license.txt).
016: *
017: * You should have received a copy of the GNU General Public License
018: * version 2 along with this work; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA
021: *
022: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023: * Clara, CA 95054 or visit www.sun.com if you need additional
024: * information or have any questions.
025: */
026: package com.sun.perseus.model;
027:
028: import com.sun.perseus.j2d.GraphicsProperties;
029:
030: import com.sun.perseus.util.SVGConstants;
031:
032: /**
033: * <code>GraphicsNode</code> is the interface that all <code>ModelNode</code>
034: * (see {@link com.sun.perseus.model.ModelNode ModelNode}) which correspond
035: * to graphical content implement.
036: * <br />
037: * <code>GraphicsNode</code>s have a notion of visibility and display. If a
038: * node is not <em>displayed</em>, then it does not paint and none of its
039: * children (if present) are painted. If a node is invisible, then it does
040: * no paint itself, but it paints it's children. In other words, it a node
041: * is invisible, its chidren may be visible (depending on the children's
042: * own visibility setting), but if a node is not displayed,
043: * then its children are not displayed either, no matter what their own
044: * display setting is. This corresponds to the CSS 2 concept of visibility
045: * and display.
046: * <br />
047: * IMPORTANT NOTE: Setting a property on a <code>GraphicsNode</code>
048: * automatically sets the inherited and color relative flags to false.
049: *
050: * @see ModelNode
051: *
052: * @version $Id: GraphicsNode.java,v 1.5 2006/06/29 10:47:31 ln156897 Exp $
053: */
054: public interface GraphicsNode extends DecoratedNode, GraphicsProperties {
055: /**
056: * The fill property controls the color of the fill operation
057: * @see com.sun.perseus.j2d.GraphicsProperties#setFill
058: */
059: int PROPERTY_FILL = 1;
060:
061: /**
062: * The stroke property controls the color of the stroke
063: * @see com.sun.perseus.j2d.GraphicsProperties#setStroke
064: */
065: int PROPERTY_STROKE = 1 << 1;
066:
067: /**
068: * The color property controls the 'current color'. The current
069: * color defines the value of the fill or stroke properties when they
070: * are 'color relative'.
071: * @see #setColorRelative
072: * @see com.sun.perseus.j2d.GraphicsProperties#setColor
073: */
074: int PROPERTY_COLOR = 1 << 2;
075:
076: /**
077: * The fill rule property controls how the interior of shapes is computed.
078: * @see com.sun.perseus.j2d.GraphicsProperties#WIND_EVEN_ODD
079: * @see com.sun.perseus.j2d.GraphicsProperties#WIND_NON_ZERO
080: * @see com.sun.perseus.j2d.GraphicsProperties#setFillRule
081: */
082: int PROPERTY_FILL_RULE = 1 << 3;
083:
084: /**
085: * The stroke width property controls how wide the stroke is.
086: * @see com.sun.perseus.j2d.GraphicsProperties#setStrokeWidth
087: */
088: int PROPERTY_STROKE_WIDTH = 1 << 4;
089:
090: /**
091: * The stroke line join property defines the style of miter, i.e.,
092: * the style of elbows between segments.
093: *
094: * @see com.sun.perseus.j2d.GraphicsProperties#JOIN_MITER
095: * @see com.sun.perseus.j2d.GraphicsProperties#JOIN_ROUND
096: * @see com.sun.perseus.j2d.GraphicsProperties#JOIN_BEVEL
097: * @see com.sun.perseus.j2d.GraphicsProperties#setStrokeLineJoin
098: *
099: */
100: int PROPERTY_STROKE_LINE_JOIN = 1 << 5;
101:
102: /**
103: * The stroke line cap property defines the style of line caps,
104: * i.e., the style of the end and begining of line strokes.
105: * @see com.sun.perseus.j2d.GraphicsProperties#CAP_BUTT
106: * @see com.sun.perseus.j2d.GraphicsProperties#CAP_ROUND
107: * @see com.sun.perseus.j2d.GraphicsProperties#CAP_SQUARE
108: * @see com.sun.perseus.j2d.GraphicsProperties#setStrokeLineCap
109: */
110: int PROPERTY_STROKE_LINE_CAP = 1 << 6;
111:
112: /**
113: * Provides a way to limit the extent of 'spikes' out
114: * of angle elbows.
115: * @see com.sun.perseus.j2d.GraphicsProperties#setStrokeMiterLimit
116: */
117: int PROPERTY_STROKE_MITER_LIMIT = 1 << 7;
118:
119: /**
120: * Array defining the stroke's dash pattern.
121: * @see com.sun.perseus.j2d.GraphicsProperties#setStrokeDashArray
122: */
123: int PROPERTY_STROKE_DASH_ARRAY = 1 << 8;
124:
125: /**
126: * Offset in the stroke dash array
127: * @see #PROPERTY_STROKE_DASH_ARRAY
128: * @see com.sun.perseus.j2d.GraphicsProperties#setStrokeDashOffset
129: */
130: int PROPERTY_STROKE_DASH_OFFSET = 1 << 9;
131:
132: /**
133: * Controls the offset in the dash array, in
134: * user space
135: * @see com.sun.perseus.j2d.GraphicsProperties#setDisplay
136: */
137: int PROPERTY_DISPLAY = 1 << 10;
138:
139: /**
140: * Controls whether a node is visible or not. Children of
141: * a node which is not visible can still be visible.
142: * @see com.sun.perseus.j2d.GraphicsProperties#setVisibility
143: */
144: int PROPERTY_VISIBILITY = 1 << 11;
145:
146: /**
147: * Controls the opacity used in a fill operation.
148: * @see com.sun.perseus.j2d.GraphicsProperties#setFillOpacity
149: */
150: int PROPERTY_FILL_OPACITY = 1 << 12;
151:
152: /**
153: * Controls the opacity used in a stroking operation.
154: * @see com.sun.perseus.j2d.GraphicsProperties#setStrokeOpacity
155: */
156: int PROPERTY_STROKE_OPACITY = 1 << 13;
157:
158: /**
159: * Controls the opacity used in blending the offscreen image
160: * into the current background.
161: * @see com.sun.perseus.j2d.GraphicsProperties#setOpacity
162: */
163: int PROPERTY_OPACITY = 1 << 14;
164:
165: /**
166: * @param propertyIndex index of the property to check
167: * @return true if the input property is color relative. False
168: * otherwise
169: * @see #setColorRelative
170: */
171: boolean isColorRelative(int propertyIndex);
172:
173: /**
174: * Returns true if the input property can be color-relative.
175: *
176: * @param propertyIndex the index of the property which may be
177: * color-relative.
178: * @return true if the input property can be color relative. False
179: * otherwise.
180: */
181: boolean isColorRelativeProperty(final int propertyIndex);
182:
183: /**
184: * Sets the input property as a color-relative property. There are
185: * two color-relative properties on a <code>GraphicsNode</code>:
186: * <code>fill</code> and <code>stroke</code>. For all other properties,
187: * setting the property as color relative should not have effect.
188: * For <code>fill</code> and <code>stroke</code>, setting them as
189: * color relative means that the <code>color</code> property should
190: * be used for the corresponding fill or draw operations.
191: *
192: * @param propertyIndex index of the property
193: * @param isColorRelative the new state fot the property's color relative
194: * value.
195: */
196: void setColorRelative(int propertyIndex, boolean isColorRelative);
197:
198: /**
199: * Default inheritance setting (Y=yes, N=no):
200: * <pre>
201: * - Y fill
202: * - Y stroke
203: * - Y color
204: * - Y fill rule
205: *
206: * - Y stroke width
207: * - Y line join
208: * - Y line cap
209: * - Y miter limit
210: *
211: * - Y dash array
212: * - Y dash offset
213: * - N display
214: * - Y visibility
215: *
216: * - Y fill opacity
217: * - Y stroke opacity
218: * - N opacity
219: * </pre>
220: */
221: int DEFAULT_INHERITANCE = 0x3BFF;
222:
223: /**
224: * Default color relative (Y=yes, N=no):
225: * <pre>
226: * - N fill
227: * - N stroke
228: * - N color
229: * - N fill rule
230: *
231: * - N stroke width
232: * - N line join
233: * - N line cap
234: * - N miter limit
235: *
236: * - N dash array
237: * - N dash offset
238: * - N display
239: * - N visibility
240: *
241: * - N fill opacity
242: * - N stroke opacity
243: * - N opacity
244: * </pre>
245: */
246: int DEFAULT_COLOR_RELATIVE = 0x0000;
247:
248: /**
249: * Number of properties in a GraphicsNode
250: */
251: int NUMBER_OF_PROPERTIES = 15;
252: }
|