1 18 package org.apache.batik.svggen; 19 20 import java.awt.*; 21 import java.awt.geom.*; 22 23 35 public class NegativeLengths implements Painter { 36 public void paint(Graphics2D g){ 37 g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, 38 RenderingHints.VALUE_ANTIALIAS_ON); 39 40 g.setPaint(Color.black); 41 42 g.drawString("Rectangle", 10, 20); 44 45 Rectangle rect = new Rectangle(10, 30, -10, -8); 47 g.draw(rect); 48 49 rect = new Rectangle(30, 30, -10, 0); 51 g.draw(rect); 52 53 rect = new Rectangle(50, 30, -10, 8); 55 g.draw(rect); 56 57 rect = new Rectangle(70, 30, 0, -8); 59 g.draw(rect); 60 61 rect = new Rectangle(90, 30, 0, 0); 63 g.draw(rect); 64 65 rect = new Rectangle(110, 30, 0, 8); 67 g.draw(rect); 68 69 rect = new Rectangle(130, 30, 10, -8); 71 g.draw(rect); 72 73 rect = new Rectangle(150, 30, 5, 0); 75 g.draw(rect); 76 77 rect = new Rectangle(170, 30, 5, 8); 79 g.draw(rect); 80 81 82 g.translate(0, 35); 83 84 g.drawString("RoundRectangle2D", 10, 20); 88 89 RoundRectangle2D rrect = new RoundRectangle2D.Double(10, 30, -10, -8, 2, 2); 91 g.draw(rrect); 92 93 rrect = new RoundRectangle2D.Double(30, 30, -10, 0, 2, 2); 95 g.draw(rrect); 96 97 rrect = new RoundRectangle2D.Double(50, 30, -10, 8, 2, 2); 99 g.draw(rrect); 100 101 rrect = new RoundRectangle2D.Double(70, 30, 0, -8, 2, 2); 103 g.draw(rrect); 104 105 rrect = new RoundRectangle2D.Double(90, 30, 0, 0, 2, 2); 107 g.draw(rrect); 108 109 rrect = new RoundRectangle2D.Double(110, 30, 0, 8, 2, 2); 111 g.draw(rrect); 112 113 rrect = new RoundRectangle2D.Double(130, 30, 5, -8, 2, 2); 115 g.draw(rrect); 116 117 rrect = new RoundRectangle2D.Double(150, 30, 5, 0, 2, 2); 119 g.draw(rrect); 120 121 rrect = new RoundRectangle2D.Double(170, 30, 5, 8, 2, 2); 123 g.draw(rrect); 124 125 126 g.translate(0, 35); 127 128 g.drawString("RoundRectangle2D, negative radius", 10, 20); 132 133 rrect = new RoundRectangle2D.Double(10, 30, -10, -8, -2, -2); 135 g.draw(rrect); 136 137 rrect = new RoundRectangle2D.Double(30, 30, -10, 0, -2, -2); 139 g.draw(rrect); 140 141 rrect = new RoundRectangle2D.Double(50, 30, -10, 8, -2, -2); 143 g.draw(rrect); 144 145 rrect = new RoundRectangle2D.Double(70, 30, 0, -8, -2, -2); 147 g.draw(rrect); 148 149 rrect = new RoundRectangle2D.Double(90, 30, 0, 0, -2, -2); 151 g.draw(rrect); 152 153 rrect = new RoundRectangle2D.Double(110, 30, 0, 8, -2, -2); 155 g.draw(rrect); 156 157 rrect = new RoundRectangle2D.Double(130, 30, 5, -8, -2, -2); 159 g.draw(rrect); 160 161 rrect = new RoundRectangle2D.Double(150, 30, 5, 0, -2, -2); 163 g.draw(rrect); 164 165 rrect = new RoundRectangle2D.Double(170, 30, 5, 8, -2, -2); 167 g.draw(rrect); 168 169 g.translate(0, 35); 170 171 g.drawString("Circle", 10, 20); 175 176 Ellipse2D circle = new Ellipse2D.Double(10, 30, -10, -10); 178 g.draw(circle); 179 180 circle = new Ellipse2D.Double(30, 30, 0, 0); 182 g.draw(circle); 183 184 circle = new Ellipse2D.Double(50, 30, 5, 5); 186 g.draw(circle); 187 188 g.translate(0, 35); 189 190 g.drawString("Ellipse", 10, 20); 194 195 Ellipse2D ellipse = new Ellipse2D.Double(10, 30, -10, -8); 197 g.draw(ellipse); 198 199 ellipse = new Ellipse2D.Double(30, 30, -10, 0); 201 g.draw(ellipse); 202 203 ellipse = new Ellipse2D.Double(50, 30, -10, 8); 205 g.draw(ellipse); 206 207 ellipse = new Ellipse2D.Double(70, 30, 0, -8); 209 g.draw(ellipse); 210 211 ellipse = new Ellipse2D.Double(90, 30, 0, 0); 213 g.draw(ellipse); 214 215 ellipse = new Ellipse2D.Double(110, 30, 0, 8); 217 g.draw(ellipse); 218 219 ellipse = new Ellipse2D.Double(130, 30, 5, -8); 221 g.draw(ellipse); 222 223 ellipse = new Ellipse2D.Double(150, 30, 5, 0); 225 g.draw(ellipse); 226 227 ellipse = new Ellipse2D.Double(170, 30, 5, 8); 229 g.draw(ellipse); 230 231 232 g.translate(0, 35); 233 234 g.drawString("fill3Drect", 10, 20); 236 237 g.setColor(new Color(192, 192, 192)); 239 g.fill3DRect(10, 30, -10, -8, true); 240 241 g.fill3DRect(30, 30, -10, 0, true); 243 244 g.fill3DRect(50, 30, -10, 8, true); 246 247 g.fill3DRect(70, 30, 0, -8, true); 249 250 g.fill3DRect(90, 30, 0, 0, true); 252 253 g.fill3DRect(110, 30, 0, 8, true); 255 256 g.fill3DRect(130, 30, 5, -8, true); 258 259 g.fill3DRect(150, 30, 5, 0, true); 261 262 g.fill3DRect(170, 30, 5, 8, true); 264 265 g.translate(0, 40); 266 267 rect = new Rectangle(10, 30, 10, -30); 269 g.setPaint(Color.gray); 270 g.fill(rect); 271 g.setPaint(Color.black); 272 g.clip(rect); 273 g.drawString("Hello There", 10, 25); 274 } 275 } 276 277 278 | Popular Tags |