From cc5eeb00b9f23b8855dee792c7d8cd95cecf71ce Mon Sep 17 00:00:00 2001 From: Victor Date: Sun, 2 Mar 2014 19:31:11 +0200 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=20=D0=BE=D0=B3=D1=80=D0=B0=D0=BD=D0=B8=D1=87=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BE=D0=B1=D0=BB=D0=B0=D1=81=D1=82=D0=B8?= =?UTF-8?q?=20=D0=B2=D1=8B=D0=B2=D0=BE=D0=B4=D0=B0=20=D0=B2=20GraphicsExt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/com/annimon/graphics/GraphicsExt.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/com/annimon/graphics/GraphicsExt.java b/src/com/annimon/graphics/GraphicsExt.java index 3842551..29c3e36 100644 --- a/src/com/annimon/graphics/GraphicsExt.java +++ b/src/com/annimon/graphics/GraphicsExt.java @@ -32,6 +32,10 @@ public class GraphicsExt { clip = null; } + public void setClip(Clip clip) { + this.clip = clip; + } + public void clip(double x, double y, double width, double height) { if (clip != null) clip.setClip(x, y, width, height); else clip = new Clip(x, y, width, height); @@ -80,7 +84,12 @@ public class GraphicsExt { public void line(Point from, Point to) { double[] p1 = transformMatrix.applyTransform(from.getVector3()); double[] p2 = transformMatrix.applyTransform(to.getVector3()); - g.drawLine(convertX(p1[0]), convertY(p1[1]), convertX(p2[0]), convertY(p2[1])); + if (clip != null) { + double[] coords = clip.clip(p1[0], p1[1], p2[0], p2[1]); + g.drawLine(convertX(coords[0]), convertY(coords[1]), convertX(coords[2]), convertY(coords[3])); + } else { + g.drawLine(convertX(p1[0]), convertY(p1[1]), convertX(p2[0]), convertY(p2[1])); + } } private int convertX(double x) {