Changeset 283
- Timestamp:
- 08/27/08 14:13:27 (16 years ago)
- Location:
- trunk/src/org/expeditee/gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/gui/Popup.java
r215 r283 2 2 3 3 import java.awt.BasicStroke; 4 import java.awt.Color; 4 5 import java.awt.Component; 5 6 import java.awt.Container; … … 11 12 import javax.swing.JPanel; 12 13 14 import org.expeditee.items.ItemUtils; 15 13 16 /** 14 17 * … … 29 32 private static final BasicStroke DEFAULT_STROKE = new BasicStroke(2.0f); 30 33 31 private BasicStroke _lineStroke = DEFAULT_STROKE; 34 private BasicStroke _borderStroke = DEFAULT_STROKE; 35 private Color _borderColor = Color.BLACK; 32 36 33 37 private boolean _isReadyToPaint = false; … … 59 63 super.paint(g); 60 64 61 if (_lineStroke != null) { 62 // Draw iwidget-like border for consistancy 63 ((Graphics2D)g).setStroke(_lineStroke); 65 // Draw border - if not transparent 66 if (_borderStroke != null && _borderColor != null) { 67 g.setColor(_borderColor); 68 ((Graphics2D)g).setStroke(_borderStroke); 64 69 g.drawRect(0, 0, getWidth(), getHeight()); 65 70 } … … 149 154 150 155 /** 156 * Invalidates self. 151 157 * 152 158 * @param thickness … … 156 162 assert(thickness >= 0); 157 163 158 if (thickness == 0) _lineStroke = null; 159 else _lineStroke = new BasicStroke(thickness); 164 if (_borderStroke != null && _borderStroke.getLineWidth() == thickness) 165 return; 166 167 boolean posInvalidate = true; 168 169 if (thickness < _borderStroke.getLineWidth()) { 170 invalidateAppearance(); 171 posInvalidate = false; 172 } 173 174 if (thickness == 0) _borderStroke = null; 175 else _borderStroke = new BasicStroke(thickness); 176 177 if (posInvalidate) invalidateAppearance(); 160 178 161 179 } … … 166 184 */ 167 185 public float getBorderThickness() { 168 if (_lineStroke == null) return 0.0f; 169 return _lineStroke.getLineWidth(); 170 } 171 186 if (_borderStroke == null) return 0.0f; 187 return _borderStroke.getLineWidth(); 188 189 } 190 191 /** 192 * Sets the border color around the popup. 193 * Invalidates self. 194 * 195 * @param c 196 * The new color. Null for transparent. 197 */ 198 public void setBorderColor(Color c) { 199 200 if (c == null && _borderColor != null) 201 invalidateAppearance(); 202 203 if (c != _borderColor) { 204 _borderColor = c; 205 invalidateAppearance(); 206 } 207 } 208 209 /** 210 * 211 * @return 212 * The border color for the popup. NUll if transparent 213 */ 214 public Color getBorderColor() { 215 return _borderColor; 216 } 217 218 /** 219 * Invalidates the whole popup so that it must be fully repainted. 220 */ 221 public void invalidateAppearance() { 222 223 if (_borderColor != null && _borderStroke != null && _borderStroke.getLineWidth() > 0) { // border 224 FrameGraphics.invalidateArea(ItemUtils.expandRectangle(getBounds(), 225 (int)Math.ceil(getBorderThickness()) + 1)); 226 } else { // no border 227 FrameGraphics.invalidateArea(getBounds()); 228 } 229 230 } 231 232 172 233 173 234 } -
trunk/src/org/expeditee/gui/PopupManager.java
r277 r283 17 17 import javax.swing.SwingUtilities; 18 18 19 import org.expeditee.items.ItemUtils;20 21 19 /** 22 20 * A centralized container for all custom popups in expeditee. … … 173 171 invokersToClear.add(_popups.get(p)); 174 172 175 invalidatePopup(p);173 p.invalidateAppearance(); 176 174 p.setVisible(false); 177 175 Browser._theBrowser.getLayeredPane().remove(p); … … 243 241 } 244 242 245 invalidatePopup(p);243 p.invalidateAppearance(); 246 244 p.setVisible(false); 247 245 Browser._theBrowser.getLayeredPane().remove(p); … … 331 329 // Invalidate the popup border 332 330 if (p.getBorderThickness() > 0.0f) { 333 invalidatePopup(p);331 p.invalidateAppearance(); 334 332 } 335 333 } … … 480 478 481 479 } 482 }483 484 485 private void invalidatePopup(Popup p) {486 FrameGraphics.invalidateArea(ItemUtils.expandRectangle(p.getBounds(),487 (int)Math.ceil(p.getBorderThickness())));488 480 } 489 481 … … 621 613 // Invalidate the popup border 622 614 if (ap.popup.getBorderThickness() > 0.0f) { 623 invalidatePopup(ap.popup);615 ap.popup.invalidateAppearance(); 624 616 } 625 617 }
Note:
See TracChangeset
for help on using the changeset viewer.