/[classpath]/classpath/javax/swing/text/Utilities.java
ViewVC logotype

Diff of /classpath/javax/swing/text/Utilities.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4.2.1 by gnu_andrew, Fri Jan 14 10:24:17 2005 UTC revision 1.4.2.2 by gnu_andrew, Sat Jan 15 17:02:21 2005 UTC
# Line 91  public class Utilities Line 91  public class Utilities
91      FontMetrics metrics = g.getFontMetrics();      FontMetrics metrics = g.getFontMetrics();
92      int ascent = metrics.getAscent();      int ascent = metrics.getAscent();
93    
94        int pixelWidth = 0;
95        int pos = 0;
96        int len = 0;
97    
98      for (int offset = s.offset; offset < (s.offset + s.count); ++offset)      for (int offset = s.offset; offset < (s.offset + s.count); ++offset)
99        {        {
100          switch (buffer[offset])          char c = buffer[offset];
101            if (len > 0 && (c == '\t' || c == '\n'))
102              {
103                g.drawChars(buffer, pos, len, pixelX, pixelY + ascent);            
104                pixelX += pixelWidth;
105                pixelWidth = 0;
106                pos = offset+1;
107                len = 0;
108              }
109              
110            switch (c)
111            {            {
112            case '\t':            case '\t':
113              // In case we have a tab, we just 'jump' over the tab.              // In case we have a tab, we just 'jump' over the tab.
114              // When we have no tab expander we just use the width of 'm'.              // When we have no tab expander we just use the width of ' '.
115              if (e != null)              if (e != null)
116                pixelX = (int) e.nextTabStop((float) pixelX,                pixelX = (int) e.nextTabStop((float) pixelX,
117                                             startOffset + offset - s.offset);                                             startOffset + offset - s.offset);
# Line 105  public class Utilities Line 119  public class Utilities
119                pixelX += metrics.charWidth(' ');                pixelX += metrics.charWidth(' ');
120              break;              break;
121            case '\n':            case '\n':
122              // In case we have a newline, we must draw              // In case we have a newline, we must jump to the next line.
             // the buffer and jump on the next line.  
             g.drawChars(buffer, offset, 1, pixelX, y);  
123              pixelY += metrics.getHeight();              pixelY += metrics.getHeight();
124              pixelX = x;              pixelX = x;
125              break;              break;
126            default:            default:
127              // Here we draw the char.              ++len;
128              g.drawChars(buffer, offset, 1, pixelX, pixelY + ascent);              pixelWidth += metrics.charWidth(buffer[offset]);
             pixelX += metrics.charWidth(buffer[offset]);  
129              break;              break;
130            }            }
131        }        }
132    
133        if (len > 0)
134          g.drawChars(buffer, pos, len, pixelX, pixelY + ascent);            
135        
136      return pixelX;      return pixelX;
137    }    }
138    

Legend:
Removed from v.1.4.2.1  
changed lines
  Added in v.1.4.2.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26