1 23 24 package de.progra.charting.render.shape; 25 26 import java.awt.geom.RectangularShape ; 27 import java.awt.geom.Rectangle2D ; 28 import java.awt.geom.PathIterator ; 29 import java.awt.geom.AffineTransform ; 30 31 36 public class Diamond2D extends RectangularShape { 37 38 protected double x, y, width, height; 39 40 41 public Diamond2D(double x, double y, double width, double height) { 42 this.x = x; 43 this.y = y; 44 this.width = width; 45 this.height = height; 46 } 47 48 49 public double getHeight() { 50 return height; 51 } 52 53 54 public double getWidth() { 55 return width; 56 } 57 58 59 public double getX() { 60 return x; 61 } 62 63 64 public double getY() { 65 return y; 66 } 67 68 69 public boolean isEmpty() { 70 return (width <= 0.0) || (height <= 0.0); 71 } 72 73 74 public void setFrame(double x, double y, double width, double height) { 75 this.x = x; 76 this.y = y; 77 this.width = width; 78 this.height = height; 79 } 80 81 public Rectangle2D getBounds2D() { 82 return new Rectangle2D.Double (x, y, height, width); 83 } 84 85 86 public PathIterator getPathIterator(AffineTransform at) { 87 return new PathIterator () { 88 int state = 0; 89 int maxstate = 4; 90 float[][] fcurrentSegment = { {(float)(x + width/2), (float)y, 0f, 0f, 0f, 0f}, 91 {(float)x, (float)(y + height/2), 0f, 0f, 0f, 0f}, 92 {(float)(x + width/2), (float)(y + height), 0f, 0f, 0f, 0f}, 93 {(float)(x + width), (float)(y + height/2), 0f, 0f, 0f, 0f}, 94 {0f, 0f, 0f, 0f, 0f, 0f} }; 95 96 97 double[][] dcurrentSegment = {{x + width/2, y, 0.0, 0.0, 0.0, 0.0}, 98 {x, y + height/2, 0.0, 0.0, 0.0, 0.0}, 99 {x + width/2, y + height, 0.0, 0.0, 0.0, 0.0}, 100 {x + width, y + height/2, 0.0, 0.0, 0.0, 0.0}, 101 {0.0, 0.0, 0.0, 0.0, 0.0, 0.0} }; 102 103 int[] segment = { PathIterator.SEG_MOVETO, PathIterator.SEG_LINETO, PathIterator.SEG_LINETO, PathIterator.SEG_LINETO, PathIterator.SEG_CLOSE}; 104 105 public int currentSegment(double[] coords) { 106 coords[0] = dcurrentSegment[state][0]; 107 coords[1] = dcurrentSegment[state][1]; 108 return segment[state]; 109 } 110 111 public int currentSegment(float[] coords){ 112 coords[0] = fcurrentSegment[state][0]; 113 coords[1] = fcurrentSegment[state][1]; 114 return segment[state]; 115 } 116 117 public int getWindingRule() { return PathIterator.WIND_NON_ZERO; } 118 public boolean isDone() { return (state == maxstate); } 119 public void next() { state++ ; } 120 }; 121 } 122 123 public boolean contains(double x, double y, double w, double h) { 124 return false; 125 } 126 127 public boolean contains(double x, double y) { 128 return false; 129 } 130 131 public boolean intersects(double x, double y, double w, double h) { 132 return false; 133 } 134 135 } 136 | Popular Tags |