Ignore:
Timestamp:
07/14/08 10:05:43 (16 years ago)
Author:
ra33
Message:

Fixed a few problems with painting etc.. and finished search stuff

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/items/Text.java

    r131 r137  
    3838public class Text extends Item {
    3939        public static String LINE_SEPARATOR = System.getProperty("line.separator");
    40         public static char[] BULLETS = {'\u2219' , '\u2218', '\u2217'};
     40
     41        public static char[] BULLETS = { '\u2219', '\u2218', '\u2217' };
     42
    4143        private static char DEFAULT_BULLET = BULLETS[2];
     44
    4245        private static String DEFAULT_BULLET_STRING = DEFAULT_BULLET + " ";
    43        
     46
    4447        private String[] _processedText = null;
    4548
     
    97100
    98101        private int _selectionEnd = -1;
    99        
     102
    100103        // text is broken up into lines
    101104        private StringBuffer _text = new StringBuffer();
     
    125128                setID(id);
    126129        }
    127        
     130
    128131        /**
    129132         * Creates a text item which is not added to the frame.
     133         *
    130134         * @param text
    131135         */
     
    190194        }
    191195
    192        
    193196        /**
    194197         * Sets the justification of this Text item. The given integer should
     
    277280         */
    278281        public void removeText(String text) {
    279                
     282
    280283                if (_text.length() > 0 && _text.indexOf(text) == 0) {
    281                         //invalidateAll();
     284                        // invalidateAll();
    282285                        _text.delete(0, text.length());
    283286                }
    284                
    285287
    286288        }
     
    289291                int length = _text.length();
    290292                if (length > 0) {
    291                         //invalidateAll();
     293                        // invalidateAll();
    292294                        int pos = _text.indexOf(textToRemove);
    293295                        int textToRemoveLength = textToRemove.length();
     
    296298                        }
    297299                }
    298                
     300
    299301        }
    300302
     
    366368         */
    367369        private char getNextBullet(char bullet) {
    368                 for(int i = 0; i < BULLETS.length - 1; i++){
    369                         if(BULLETS[i]== bullet)
    370                                 return BULLETS[i+1];
     370                for (int i = 0; i < BULLETS.length - 1; i++) {
     371                        if (BULLETS[i] == bullet)
     372                                return BULLETS[i + 1];
    371373                }
    372374                return BULLETS[0];
     
    374376
    375377        private char getPreviousBullet(char bullet) {
    376                 for(int i = 1; i < BULLETS.length; i++){
    377                         if(BULLETS[i]== bullet)
     378                for (int i = 1; i < BULLETS.length; i++) {
     379                        if (BULLETS[i] == bullet)
    378380                                return BULLETS[i - 1];
    379381                }
     
    470472                if (_selectionStart < 0 || _selectionEnd < 0)
    471473                        return null;
    472                
     474
    473475                invalidateAll();
    474                
     476
    475477                if (_selectionEnd > _text.length())
    476478                        _selectionEnd = _text.length();
     
    484486                _text.insert(left, newText);
    485487                rebuild(true);
    486                
     488
    487489                invalidateAll();
    488490
     
    520522                TextLayout current = null;
    521523                int line;
    522                
     524
    523525                invalidateAll();
    524526
     
    617619                        }
    618620
    619                         if (_text.length() == 0){
     621                        if (_text.length() == 0) {
    620622                                rebuild(false);
    621623                                return new Point2D.Float(this._x, this._y);
     
    664666                                                x,
    665667                                                (getX() - Item.MARGIN_RIGHT - (2 * getGravity()) + getBoundsWidth()));
    666                
     668
    667669                invalidateAll();
    668                
     670
    669671                return new Point2D.Float(Math.round(x), Math.round(getY() + y
    670672                                + caret[1]));
     
    813815                // rejustify();
    814816                rebuild(false);
    815                
     817
    816818                invalidateAll();
    817819        }
     
    11331135        private void rebuild(boolean limitWidth) {
    11341136                // if there is no text, there is nothing to do
    1135                 if (_text == null || _text.length() == 0){
    1136 //                      Frame parent = getParent();
    1137 //                      if(parent != null)
    1138 //                              parent.removeItem(this);
     1137                if (_text == null || _text.length() == 0) {
     1138                        // Frame parent = getParent();
     1139                        // if(parent != null)
     1140                        // parent.removeItem(this);
    11391141                        return;
    11401142                }
    1141                
     1143
    11421144                AttributedString paragraphText = new AttributedString(_text.toString());
    11431145                paragraphText.addAttribute(TextAttribute.FONT, getPaintFont());
     
    11881190
    11891191                updatePolygon();
    1190                
     1192
    11911193        }
    11921194
     
    13141316                        return;
    13151317                }
    1316                
     1318
     1319                // check if its a vector item and paint all the vector stuff too if this
     1320                // item is a free item
     1321                // This will allow for dragging vectors around the place!
     1322                if (hasVector() && isFloating()) {
     1323                        FrameGraphics.requestRefresh(false);
     1324                        // TODO make this use a more efficient paint method...
     1325                        // Have the text item return a bigger repaint area if it has an
     1326                        // associated vector
     1327                }
     1328
    13171329                // the background is only cleared if required
    13181330                if (getBackgroundColor() != null) {
     
    14181430                paintLink(g);
    14191431        }
    1420        
     1432
    14211433        @Override
    14221434        protected Rectangle getLinkDrawArea() { // TODO: Revise
     
    14931505                        if (isAnnotation())
    14941506                                return;
    1495                         if (!isLineEnd() && _text.length() > 0 && _text.charAt(0) == DEFAULT_BULLET) {
     1507                        if (!isLineEnd() && _text.length() > 0
     1508                                        && _text.charAt(0) == DEFAULT_BULLET) {
    14961509                                newPoint.setLocation(insertText(""
    14971510                                                + (char) KeyEvent.VK_BACK_SPACE, mouseX, mouseY, 1));
     
    15101523                                newPoint.setLocation(insertText(""
    15111524                                                + (char) KeyEvent.VK_BACK_SPACE, mouseX, mouseY, 1));
    1512                                 newPoint
    1513                                                 .setLocation(insertText( DEFAULT_BULLET_STRING, newPoint.x, newPoint.y, 0));
     1525                                newPoint.setLocation(insertText(DEFAULT_BULLET_STRING,
     1526                                                newPoint.x, newPoint.y, 0));
    15141527                        } else {
    15151528                                newPoint.setLocation(insertText(""
     
    15571570                        _lineBreaker.deleteChar(inserting.getIterator(), pos);
    15581571                }
    1559                
    1560                
    1561                
     1572
    15621573        }
    15631574
     
    17271738        @Override
    17281739        protected int getLinkYOffset() {
    1729                 if (_textLayouts.size() == 0) return  0;
     1740                if (_textLayouts.size() == 0)
     1741                        return 0;
    17301742                return Math.round(-(_textLayouts.get(0).getAscent() / 2));
    17311743        }
     
    17481760
    17491761        public static boolean isBulletChar(char c) {
    1750                 for(int i = 0; i < BULLETS.length; i++){
    1751                         if(BULLETS[i]== c)
     1762                for (int i = 0; i < BULLETS.length; i++) {
     1763                        if (BULLETS[i] == c)
    17521764                                return true;
    17531765                }
    1754                 return c== '*' || c == '+' || c == '>' || c == '-' || c == 'o';
    1755         }
    1756        
     1766                return c == '*' || c == '+' || c == '>' || c == '-' || c == 'o';
     1767        }
     1768
    17571769        public boolean hasOverlay() {
    1758                 if(!isAnnotation() || getLink()==null)
     1770                if (!isAnnotation() || getLink() == null)
    17591771                        return false;
    1760                 return ItemUtils.startsWithTag(this, "@ao") ||ItemUtils.startsWithTag(this, "@v");
     1772                return ItemUtils.startsWithTag(this, "@ao")
     1773                                || ItemUtils.startsWithTag(this, "@v");
    17611774        }
    17621775
Note: See TracChangeset for help on using the changeset viewer.