2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
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.
16 package com
.intellij
.ui
;
18 import com
.intellij
.util
.ui
.UIUtil
;
21 import java
.awt
.font
.FontRenderContext
;
22 import java
.awt
.font
.GlyphVector
;
23 import java
.awt
.geom
.AffineTransform
;
24 import java
.awt
.image
.BufferedImage
;
25 import java
.awt
.image
.BufferedImageOp
;
26 import java
.awt
.image
.ImageObserver
;
27 import java
.awt
.image
.RenderedImage
;
28 import java
.awt
.image
.renderable
.RenderableImage
;
29 import java
.text
.AttributedCharacterIterator
;
33 * @author Vladimir Kondratyev
35 public class IdeGraphics2D
extends Graphics2D
{
36 private final Graphics2D myDelegate
;
38 public IdeGraphics2D(Graphics2D g2d
){
40 setRenderingHint(RenderingHints
.KEY_ANTIALIASING
,RenderingHints
.VALUE_ANTIALIAS_ON
);
41 setRenderingHint(RenderingHints
.KEY_TEXT_ANTIALIASING
,RenderingHints
.VALUE_TEXT_ANTIALIAS_ON
);
44 public void addRenderingHints(Map hints
) {
45 myDelegate
.addRenderingHints(hints
);
48 public void clearRect(int x
, int y
, int width
, int height
) {
49 myDelegate
.clearRect(x
, y
, width
, height
);
52 public void clip(Shape s
) {
56 public void clipRect(int x
, int y
, int width
, int height
) {
57 myDelegate
.clipRect(x
, y
, width
, height
);
60 public void copyArea(int x
, int y
, int width
, int height
, int dx
, int dy
) {
61 myDelegate
.copyArea(x
, y
, width
, height
, dx
, dy
);
64 public Graphics
create() {
65 return new IdeGraphics2D((Graphics2D
)myDelegate
.create());
68 public void dispose() {
72 public void draw(Shape s
) {
76 public void drawArc(int x
, int y
, int width
, int height
, int startAngle
, int arcAngle
) {
77 myDelegate
.drawArc(x
, y
, width
, height
, startAngle
, arcAngle
);
80 public void drawGlyphVector(GlyphVector g
, float x
, float y
) {
81 myDelegate
.drawGlyphVector(g
, x
, y
);
84 public void drawImage(BufferedImage img
, BufferedImageOp op
, int x
, int y
) {
85 myDelegate
.drawImage(img
, op
, x
, y
);
88 public boolean drawImage(Image img
, int dx1
, int dy1
, int dx2
, int dy2
, int sx1
, int sy1
, int sx2
, int sy2
, Color bgcolor
, ImageObserver observer
) {
89 return myDelegate
.drawImage(img
, dx1
, dy1
, dx2
, dy2
, sx1
, sy1
, sx2
, sy2
, bgcolor
, observer
);
92 public boolean drawImage(Image img
, int dx1
, int dy1
, int dx2
, int dy2
, int sx1
, int sy1
, int sx2
, int sy2
, ImageObserver observer
) {
93 return myDelegate
.drawImage(img
, dx1
, dy1
, dx2
, dy2
, sx1
, sy1
, sx2
, sy2
, observer
);
96 public boolean drawImage(Image img
, int x
, int y
, Color bgcolor
, ImageObserver observer
) {
97 return myDelegate
.drawImage(img
, x
, y
, bgcolor
, observer
);
100 public boolean drawImage(Image img
, int x
, int y
, ImageObserver observer
) {
101 return myDelegate
.drawImage(img
, x
, y
, observer
);
104 public boolean drawImage(Image img
, int x
, int y
, int width
, int height
, Color bgcolor
, ImageObserver observer
) {
105 return myDelegate
.drawImage(img
, x
, y
, width
, height
, bgcolor
, observer
);
108 public boolean drawImage(Image img
, int x
, int y
, int width
, int height
, ImageObserver observer
) {
109 return myDelegate
.drawImage(img
, x
, y
, width
, height
, observer
);
112 public boolean drawImage(Image img
, AffineTransform xform
, ImageObserver obs
) {
113 return myDelegate
.drawImage(img
, xform
, obs
);
116 public void drawLine(int x1
, int y1
, int x2
, int y2
) {
117 UIUtil
.drawLine(myDelegate
, x1
, y1
, x2
, y2
);
120 public void drawOval(int x
, int y
, int width
, int height
) {
121 myDelegate
.drawOval(x
, y
, width
, height
);
124 public void drawPolygon(int xPoints
[], int yPoints
[], int nPoints
) {
125 myDelegate
.drawPolygon(xPoints
, yPoints
, nPoints
);
128 public void drawPolyline(int xPoints
[], int yPoints
[], int nPoints
) {
129 myDelegate
.drawPolyline(xPoints
, yPoints
, nPoints
);
132 public void drawRenderableImage(RenderableImage img
, AffineTransform xform
) {
133 myDelegate
.drawRenderableImage(img
, xform
);
136 public void drawRenderedImage(RenderedImage img
, AffineTransform xform
) {
137 myDelegate
.drawRenderedImage(img
, xform
);
140 public void drawRoundRect(int x
, int y
, int width
, int height
, int arcWidth
, int arcHeight
) {
141 myDelegate
.drawRoundRect(x
, y
, width
, height
, arcWidth
, arcHeight
);
144 public void drawString(AttributedCharacterIterator iterator
, float x
, float y
) {
145 myDelegate
.drawString(iterator
, x
, y
);
148 public void drawString(AttributedCharacterIterator iterator
, int x
, int y
) {
149 myDelegate
.drawString(iterator
, x
, y
);
152 public void drawString(String s
, float x
, float y
) {
153 myDelegate
.drawString(s
, x
, y
);
156 public void drawString(String str
, int x
, int y
) {
157 myDelegate
.drawString(str
, x
, y
);
160 public void fill(Shape s
) {
164 public void fillArc(int x
, int y
, int width
, int height
, int startAngle
, int arcAngle
) {
165 myDelegate
.fillArc(x
, y
, width
, height
, startAngle
, arcAngle
);
168 public void fillOval(int x
, int y
, int width
, int height
) {
169 myDelegate
.fillOval(x
, y
, width
, height
);
172 public void fillPolygon(int xPoints
[], int yPoints
[], int nPoints
) {
173 myDelegate
.fillPolygon(xPoints
, yPoints
, nPoints
);
176 public void fillRect(int x
, int y
, int width
, int height
) {
177 myDelegate
.fillRect(x
, y
, width
, height
);
180 public void fillRoundRect(int x
, int y
, int width
, int height
, int arcWidth
, int arcHeight
) {
181 myDelegate
.fillRoundRect(x
, y
, width
, height
, arcWidth
, arcHeight
);
184 public Color
getBackground() {
185 return myDelegate
.getBackground();
188 public Shape
getClip() {
189 return myDelegate
.getClip();
192 public Rectangle
getClipBounds() {
193 return myDelegate
.getClipBounds();
196 public Color
getColor() {
197 return myDelegate
.getColor();
200 public Composite
getComposite() {
201 return myDelegate
.getComposite();
204 public GraphicsConfiguration
getDeviceConfiguration() {
205 return myDelegate
.getDeviceConfiguration();
208 public Font
getFont() {
209 return myDelegate
.getFont();
212 public FontMetrics
getFontMetrics(Font f
) {
213 return myDelegate
.getFontMetrics(f
);
216 public FontRenderContext
getFontRenderContext() {
217 return myDelegate
.getFontRenderContext();
220 public Paint
getPaint() {
221 return myDelegate
.getPaint();
224 public Object
getRenderingHint(RenderingHints
.Key hintKey
) {
225 return myDelegate
.getRenderingHint(hintKey
);
228 public RenderingHints
getRenderingHints() {
229 return myDelegate
.getRenderingHints();
232 public Stroke
getStroke() {
233 return myDelegate
.getStroke();
236 public AffineTransform
getTransform() {
237 return myDelegate
.getTransform();
240 public boolean hit(Rectangle rect
, Shape s
, boolean onStroke
) {
241 return myDelegate
.hit(rect
, s
, onStroke
);
244 public void rotate(double theta
) {
245 myDelegate
.rotate(theta
);
248 public void rotate(double theta
, double x
, double y
) {
249 myDelegate
.rotate(theta
, x
, y
);
252 public void scale(double sx
, double sy
) {
253 myDelegate
.scale(sx
, sy
);
256 public void setBackground(Color color
) {
257 myDelegate
.setBackground(color
);
260 public void setClip(Shape sh
) {
261 myDelegate
.setClip(sh
);
264 public void setClip(int x
, int y
, int w
, int h
) {
265 myDelegate
.setClip(x
, y
, w
, h
);
268 public void setColor(Color color
) {
269 myDelegate
.setColor(color
);
272 public void setComposite(Composite comp
) {
273 myDelegate
.setComposite(comp
);
276 public void setFont(Font font
) {
277 myDelegate
.setFont(font
);
280 public void setPaint(Paint paint
) {
281 myDelegate
.setPaint(paint
);
284 public void setPaintMode() {
285 myDelegate
.setPaintMode();
288 public void setRenderingHint(RenderingHints
.Key hintKey
, Object hintValue
) {
289 myDelegate
.setRenderingHint(hintKey
, hintValue
);
292 public void setRenderingHints(Map hints
) {
293 myDelegate
.setRenderingHints(hints
);
297 * Sets the Stroke in the current graphics state.
298 * @param s The Stroke object to be used to stroke a Path in
299 * the rendering process.
302 public void setStroke(Stroke s
) {
303 myDelegate
.setStroke(s
);
306 public void setTransform(AffineTransform Tx
) {
307 myDelegate
.setTransform(Tx
);
310 public void setXORMode(Color c
) {
311 myDelegate
.setXORMode(c
);
314 public void shear(double shx
, double shy
) {
315 myDelegate
.shear(shx
, shy
);
318 public void transform(AffineTransform xform
) {
319 myDelegate
.transform(xform
);
322 public void translate(double tx
, double ty
) {
323 myDelegate
.translate(tx
, ty
);
326 public void translate(int x
, int y
) {
327 myDelegate
.translate(x
, y
);