Changeset 427 for trunk/src/org/expeditee/items/Dot.java
- Timestamp:
- 01/07/09 13:25:13 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/items/Dot.java
r376 r427 26 26 // Standard Item variables 27 27 28 // private static final int _MINIMUM_DOT_SIZE = 6;28 // private static final int _MINIMUM_DOT_SIZE = 6; 29 29 30 30 private static final int MINIMUM_DOT_SIZE = 2; 31 32 private int _pointType = Item.POINTTYPE_SQUARE;33 34 private boolean _filled = true;35 31 36 32 public Dot(int id) { … … 55 51 } 56 52 57 public void setPointType(int type) {58 _pointType = type;59 }60 61 public void useFilledPoints(boolean val) {62 _filled = val;63 }64 65 53 @Override 66 54 public void setColor(Color c) { … … 116 104 Color highlightColor = getHighlightColor(); 117 105 g.setColor(highlightColor); 118 g.setStroke( HIGHLIGHT_STROKE);106 g.setStroke(DOT_STROKE); 119 107 // g.setStroke() 120 108 // Draw the highlighting rectangle surrounding the dot 121 109 // this is drawn even if its part of a rectangle 122 123 if (isVectorItem())110 111 if (isVectorItem()) 124 112 updatePolygon(); 125 113 126 114 Rectangle rect = getPolygon().getBounds(); 127 115 if (_mode == HighlightMode.Enclosed || … … 129 117 this.getConnected().size() <= 1) 130 118 g.fillRect(rect.x, rect.y, rect.width, rect.height); 131 else if (_mode == HighlightMode.Connected) 119 else if (_mode == HighlightMode.Connected){ 120 g.setStroke(HIGHLIGHT_STROKE); 132 121 g.drawRect(rect.x, rect.y, rect.width, rect.height); 133 else if (_mode == HighlightMode.Normal) {122 }else if (_mode == HighlightMode.Normal) { 134 123 g.fillOval(rect.x, rect.y, rect.width, rect.height); 135 124 } … … 149 138 int width = thick / 2; 150 139 151 if (_pointType == Item.POINTTYPE_CIRCLE) { 152 int points = 40; 153 154 double radians = 0.0; 155 int xPoints[] = new int[points]; 156 int yPoints[] = new int[xPoints.length]; 157 158 for (int i = 0; i < xPoints.length; i++) { 159 xPoints[i] = getX() + (int) (width * Math.cos(radians)); 160 yPoints[i] = getY() + (int) (width * Math.sin(radians)); 161 radians += (2.0 * Math.PI) / xPoints.length; 162 } 163 164 if (_filled) 165 g.fillPolygon(new Polygon(xPoints, yPoints, xPoints.length)); 166 else 167 g.drawPolygon(new Polygon(xPoints, yPoints, xPoints.length)); 168 } else { 140 switch (_type) { 141 case circle: 142 if (_filled) 143 g.fillOval(getX() - width, getY() - width, thick, thick); 144 else { 145 g.drawOval(getX() - width, getY() - width, thick, thick); 146 } 147 break; 148 case diamond: 149 int[] x = new int[4]; 150 int[] y = new int[4]; 151 152 x[0] = x[2] = getX(); 153 x[1] = getX() - width; 154 x[3] = getX() + width; 155 156 y[1] = y[3] = getY(); 157 y[0] = getY() - width; 158 y[2] = getY() + width; 159 160 if (_filled) 161 g.fillPolygon(x, y, 4); 162 else { 163 g.drawPolygon(x, y, 4); 164 } 165 break; 166 case triangle: 167 x = new int[3]; 168 y = new int[3]; 169 170 x[0] = getX(); 171 x[1] = getX() - width; 172 x[2] = getX() + width; 173 174 y[0] = getY() - width; 175 y[1] = y[2] = getY() + width; 176 177 if (_filled) 178 g.fillPolygon(x, y, 3); 179 else { 180 g.drawPolygon(x, y, 3); 181 } 182 break; 183 case roundSquare: 184 int arc = thick / 2; 185 if (_filled) 186 g.fillRoundRect(getX() - width, getY() - width, thick, thick, 187 arc, arc); 188 else { 189 g.drawRoundRect(getX() - width, getY() - width, thick, thick, 190 arc, arc); 191 } 192 break; 193 default: 169 194 if (_filled) 170 195 g.fillRect(getX() - width, getY() - width, thick, thick); 171 else 196 else { 172 197 g.drawRect(getX() - width, getY() - width, thick, thick); 198 } 199 173 200 } 174 201 … … 198 225 199 226 Item.DuplicateItem(this, copy); 200 201 copy.setThickness(getThickness());202 copy.setPointType(_pointType);203 copy.useFilledPoints(_filled);204 227 205 228 return copy;
Note:
See TracChangeset
for help on using the changeset viewer.