2 * Copyright (C) 2010 The Android Open Source Project
4 * Licensed under the Eclipse Public License, Version 1.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.eclipse.org/org/documents/epl-v10.php
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.android.ide.eclipse.adt.editors.layout.gscripts;
20 * Represents a graphical context that rules can use to draw on the canvas.
22 * The wrapper GC is only valid during the context of a paint operation.
23 * This means {@link IViewRule}s should not cache this object and call it at
24 * just about any time, it is only valid during a call that actually receives
27 public interface IGraphics {
30 * Registers a color using 0x00rrggbb where each component is
33 * Transparency is handled separately using {@link #setAlpha(int)}.
35 * If the same color is registered twice, the same object will
38 IColor registerColor(int rgb);
41 * Returns the height, in pixels, of the default font.
46 * Sets the foreground color. The foreground color is used
47 * for drawing operations including when text is drawn.
49 void setForeground(IColor color);
52 * Sets the background color. The background color is used
53 * for fill operations.
55 void setBackground(IColor color);
58 * Sets the receiver's alpha value which must be
59 * between 0 (transparent) and 255 (opaque).
61 * This operation requires the operating system's advanced
62 * graphics subsystem which may not be available on some
65 * @return False if the GC doesn't support alpha.
67 boolean setAlpha(int alpha);
70 * A line style for {@link IGraphics#setLineStyle(LineStyle)}.
73 /** Style for solid lines. */
75 /** Style for dashed lines. */
77 /** Style for dotted lines. */
79 /** Style for alternating dash-dot lines. */
81 /** Style for dash-dot-dot lines. */
86 * Sets the current line style.
88 void setLineStyle(LineStyle style);
91 * Sets the width that will be used when drawing lines.
92 * The operation is ignored if <var>width</var> is less than 1.
94 void setLineWidth(int width);
97 * Draws a line between 2 points, using the current foreground
100 void drawLine(int x1, int y1, int x2, int y2);
102 * Draws a line between 2 points, using the current foreground
105 void drawLine(Point p1, Point p2);
108 * Draws a rectangle outline between 2 points, using the current
109 * foreground color and alpha.
111 void drawRect(int x1, int y1, int x2, int y2);
113 * Draws a rectangle outline between 2 points, using the current
114 * foreground color and alpha.
116 void drawRect(Point p1, Point p2);
118 * Draws a rectangle outline between 2 points, using the current
119 * foreground color and alpha.
121 void drawRect(Rect r);
124 * Fills a rectangle outline between 2 points, using the current
125 * background color and alpha.
127 void fillRect(int x1, int y1, int x2, int y2);
129 * Fills a rectangle outline between 2 points, using the current
130 * background color and alpha.
132 void fillRect(Point p1, Point p2);
134 * Fills a rectangle outline between 2 points, using the current
135 * background color and alpha.
137 void fillRect(Rect r);
140 * Draws the given string, using the current foreground color.
141 * No tab expansion or carriage return processing will be performed.
143 * @param string the string to be drawn.
144 * @param x the x coordinate of the top left corner of the text.
145 * @param y the y coordinate of the top left corner of the text.
147 void drawString(String string, int x, int y);
150 * Draws the given string, using the current foreground color.
151 * No tab expansion or carriage return processing will be performed.
153 * @param string the string to be drawn.
154 * @param topLeft the top left corner of the text.
156 void drawString(String string, Point topLeft);