1 22 23 24 package net.sourceforge.chart2d; 25 26 27 import java.awt.*; 28 import java.awt.geom.*; 29 import java.util.*; 30 31 32 35 final class FancyDot extends FancyShape { 36 37 38 private Rectangle2D.Float bounds, clipBounds; 39 private Ellipse2D.Float dot; 40 private FancyDot[] warningDots; 41 private boolean needsUpdate; 42 43 44 47 FancyDot() { 48 needsUpdate = true; 49 } 50 51 52 56 final void setBounds (Rectangle2D.Float b) { 57 bounds = b; 58 needsUpdate = true; 59 } 60 61 62 66 final void setClipBounds (Rectangle2D.Float b) { 67 clipBounds = b; 68 needsUpdate = true; 69 } 70 71 72 76 final Rectangle2D.Float getBounds() { 77 return bounds; 78 } 79 80 81 85 final Rectangle2D.Float getClipBounds() { 86 return clipBounds; 87 } 88 89 90 94 final void paint (Graphics2D g2D) { 95 96 update(); 97 98 Paint oldPaint = g2D.getPaint(); 99 g2D.setPaint (getPaint()); 100 101 Shape oldClip = g2D.getClip(); 102 java.awt.geom.Area clipArea = new java.awt.geom.Area (clipBounds); 103 clipArea.intersect (new java.awt.geom.Area (oldClip)); 104 g2D.setClip (clipArea); 105 106 g2D.fill (dot); 107 108 if (getOutlineExistence() && bounds.width > 2f && bounds.height > 2f) { 109 g2D.setPaint (getOutlinePaint()); 110 g2D.draw (dot); 111 } 112 113 g2D.setPaint (oldPaint); 114 g2D.setClip (oldClip); 115 116 if (getWarningRegions() != null) { 117 for (int i = 0; i < warningDots.length; ++i) warningDots[i].paint (g2D); 118 } 119 } 120 121 122 125 final void update() { 126 127 super.update(); 128 129 if (needsUpdate) { 130 131 dot = new Ellipse2D.Float (bounds.x, bounds.y, bounds.width, bounds.height); 132 133 if (getWarningRegions() != null) { 134 135 warningDots = new FancyDot[getWarningRegions().size()]; 136 for (int i = 0; i < warningDots.length; ++i) { 137 138 FancyDot warningDot = new FancyDot(); 139 warningDot.setBounds (bounds); 140 warningDot.setWarningRegions (null); 141 warningDot.setLightBounds (getLightBounds()); 142 warningDot.setLightSource (getLightSource()); 143 warningDot.setOutlineExistence (getOutlineExistence()); 144 warningDot.setOutlineColor (getOutlineColor()); 145 warningDot.setType (getType()); 146 warningDot.setGraphBounds (getGraphBounds()); 147 WarningRegion warningRegion = (WarningRegion)getWarningRegions().get (i); 148 Rectangle2D tempRect2D = bounds.createIntersection (warningRegion.getBackgroundBounds()); 149 Rectangle2D.Float clipBoundsWR = new Rectangle2D.Float(); 150 clipBoundsWR.setRect (tempRect2D); 151 warningDot.setClipBounds (clipBoundsWR); 152 warningDot.setColor (warningRegion.getComponentColor()); 153 warningDots[i] = warningDot; 154 } 155 } 156 needsUpdate = false; 157 } 158 } 159 } | Popular Tags |