Changeset 1369 for trunk/src/org/expeditee/items/Text.java
- Timestamp:
- 05/23/19 12:20:07 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/items/Text.java
r1296 r1369 136 136 * the user. Initially set to be as wide as possible. 137 137 */ 138 private Integer _width = -Integer.MAX_VALUE; 139 140 private Integer _minWidth = -Integer.MAX_VALUE; 141 138 142 private Integer _maxWidth = -Integer.MAX_VALUE; 139 140 private Integer _minWidth = -Integer.MAX_VALUE;141 143 142 144 private Justification _justification = Justification.left; … … 186 188 // The font to display this text in 187 189 private Font _font; 190 private Font _substituteFont; 191 private boolean _useSubstituteFont = false; 188 192 189 193 // The optional mask character to us in place of the text's content. … … 395 399 } 396 400 397 _ maxWidth = width;401 _width = width; 398 402 rebuild(true); 399 403 invalidateAll(); … … 414 418 invalidateAll(); 415 419 } 420 421 public void setMaxWidth(Integer width) { 422 invalidateAll(); 423 424 if (width == null) { 425 setJustification(Justification.left); 426 setRightMargin(DisplayController.getFramePaintAreaWidth(), false); 427 return; 428 } 429 430 _maxWidth = width; 431 rebuild(true); 432 invalidateAll(); 433 } 434 416 435 417 436 /** … … 428 447 @Override 429 448 public Integer getWidth() { 430 if (_ maxWidth == null || _maxWidth <= 0) {449 if (_width == null || _width <= 0) { 431 450 return null; 432 451 } 433 452 434 return _ maxWidth;453 return _width; 435 454 } 436 455 437 456 public Integer getAbsoluteWidth() { 438 if (_ maxWidth == null) {457 if (_width == null) { 439 458 return Integer.MAX_VALUE; 440 459 } 441 460 442 return Math.abs(_ maxWidth);461 return Math.abs(_width); 443 462 } 444 463 … … 449 468 return _minWidth; 450 469 } 470 471 public Integer getMaxWidth() { 472 if (_maxWidth == null || _maxWidth <= 0) { 473 return null; 474 } 475 return _maxWidth; 476 } 451 477 452 478 public Integer getAbsoluteMinWidth() { … … 456 482 return Math.abs(_minWidth); 457 483 } 458 484 485 public Integer getAbsoluteMaxWidth() { 486 if (_maxWidth == null) { 487 return Integer.MIN_VALUE; 488 } 489 return Math.abs(_maxWidth); 490 } 491 459 492 @Override 460 493 public Colour getHighlightColor() { … … 1300 1333 */ 1301 1334 public Font getPaintFont() { 1302 finalFont f = getFont();1335 Font f = getFont(); 1303 1336 if (f == null) { 1304 1337 _font = EcosystemManager.getFontManager().getDefaultFont().clone(); 1305 return _font; 1338 f = _font; 1339 1340 if (_useSubstituteFont) { 1341 f = _substituteFont; 1342 } 1306 1343 } 1307 1344 return f; … … 1693 1730 1694 1731 int minWidth = getAbsoluteMinWidth(); 1732 int maxWidth = getAbsoluteMaxWidth(); 1695 1733 1696 1734 minX = Math.min(minX, bounds.getMinX()); 1697 1735 maxX = minWidth < Integer.MAX_VALUE ? Math.max(minX + minWidth, bounds.getMaxX()) 1698 1736 : Math.max(maxX, bounds.getMaxX()); 1737 if ((maxWidth - minX) < maxX) { 1738 this._useSubstituteFont = true; 1739 this._substituteFont.setSize(this._substituteFont.getSize() - 1); 1740 } else { 1741 this._useSubstituteFont = false; 1742 this._substituteFont = this._font; 1743 } 1699 1744 minY = Math.min(minY, (int) (bounds.getMinY() + y)); 1700 1745 maxY = Math.max(maxY, (int) (bounds.getMaxY() + y)); … … 1808 1853 float width = Float.MAX_VALUE; 1809 1854 if (limitWidth) { 1810 if (_ maxWidth == null) {1855 if (_width == null) { 1811 1856 width = DisplayController.getFramePaintAreaWidth() - getX(); 1812 1857 } else { … … 1889 1934 1890 1935 private boolean hasFixedWidth() { 1891 assert (_ maxWidth != null);1892 if (_ maxWidth == null) {1936 assert (_width != null); 1937 if (_width == null) { 1893 1938 justify(false); 1894 1939 } 1895 return _ maxWidth > 0;1940 return _width > 0; 1896 1941 } 1897 1942
Note:
See TracChangeset
for help on using the changeset viewer.