Imported GNU Classpath 0.90
Imported GNU Classpath 0.90 * scripts/makemake.tcl: LocaleData.java moved to gnu/java/locale. * sources.am: Regenerated. * gcj/javaprims.h: Regenerated. * Makefile.in: Regenerated. * gcj/Makefile.in: Regenerated. * include/Makefile.in: Regenerated. * testsuite/Makefile.in: Regenerated. * gnu/java/lang/VMInstrumentationImpl.java: New override. * gnu/java/net/local/LocalSocketImpl.java: Likewise. * gnu/classpath/jdwp/VMMethod.java: Likewise. * gnu/classpath/jdwp/VMVirtualMachine.java: Update to latest interface. * java/lang/Thread.java: Add UncaughtExceptionHandler. * java/lang/reflect/Method.java: Implements GenericDeclaration and isSynthetic(), * java/lang/reflect/Field.java: Likewise. * java/lang/reflect/Constructor.java * java/lang/Class.java: Implements Type, GenericDeclaration, getSimpleName() and getEnclosing*() methods. * java/lang/Class.h: Add new public methods. * java/lang/Math.java: Add signum(), ulp() and log10(). * java/lang/natMath.cc (log10): New function. * java/security/VMSecureRandom.java: New override. * java/util/logging/Logger.java: Updated to latest classpath version. * java/util/logging/LogManager.java: New override. From-SVN: r113887
This commit is contained in:
parent
eaec4980e1
commit
4f9533c772
1640 changed files with 126485 additions and 104808 deletions
|
@ -1,5 +1,5 @@
|
|||
/* Utilities.java --
|
||||
Copyright (C) 2004, 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -48,6 +48,7 @@ import java.text.BreakIterator;
|
|||
* inside this package.
|
||||
*
|
||||
* @author Roman Kennke (roman@ontographics.com)
|
||||
* @author Robert Schuster (robertschuster@fsfe.org)
|
||||
*/
|
||||
public class Utilities
|
||||
{
|
||||
|
@ -99,8 +100,10 @@ public class Utilities
|
|||
int pixelWidth = 0;
|
||||
int pos = s.offset;
|
||||
int len = 0;
|
||||
|
||||
int end = s.offset + s.count;
|
||||
|
||||
for (int offset = s.offset; offset < (s.offset + s.count); ++offset)
|
||||
for (int offset = s.offset; offset < end; ++offset)
|
||||
{
|
||||
char c = buffer[offset];
|
||||
if (c == '\t' || c == '\n')
|
||||
|
@ -140,7 +143,7 @@ public class Utilities
|
|||
if (len > 0)
|
||||
g.drawChars(buffer, pos, len, pixelX, pixelY + ascent);
|
||||
|
||||
return pixelX;
|
||||
return pixelX + pixelWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -236,35 +239,39 @@ public class Utilities
|
|||
// At the end of the for loop, this holds the requested model location
|
||||
int pos;
|
||||
int currentX = x0;
|
||||
|
||||
int width = 0;
|
||||
|
||||
for (pos = 0; pos < s.count; pos++)
|
||||
{
|
||||
char nextChar = s.array[s.offset+pos];
|
||||
|
||||
if (nextChar == 0)
|
||||
{
|
||||
if (! round)
|
||||
pos--;
|
||||
break;
|
||||
}
|
||||
|
||||
if (nextChar != '\t')
|
||||
currentX += fm.charWidth(nextChar);
|
||||
width = fm.charWidth(nextChar);
|
||||
else
|
||||
{
|
||||
if (te == null)
|
||||
currentX += fm.charWidth(' ');
|
||||
width = fm.charWidth(' ');
|
||||
else
|
||||
currentX = (int) te.nextTabStop(currentX, pos);
|
||||
width = ((int) te.nextTabStop(currentX, pos)) - currentX;
|
||||
}
|
||||
|
||||
if (currentX > x)
|
||||
if (round)
|
||||
{
|
||||
if (! round)
|
||||
pos--;
|
||||
break;
|
||||
if (currentX + (width>>1) > x)
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (currentX + width > x)
|
||||
break;
|
||||
}
|
||||
|
||||
currentX += width;
|
||||
}
|
||||
|
||||
|
||||
return pos + p0;
|
||||
}
|
||||
|
||||
|
@ -315,21 +322,31 @@ public class Utilities
|
|||
String text = c.getText();
|
||||
BreakIterator wb = BreakIterator.getWordInstance();
|
||||
wb.setText(text);
|
||||
|
||||
int last = wb.following(offs);
|
||||
int current = wb.next();
|
||||
int cp;
|
||||
|
||||
while (current != BreakIterator.DONE)
|
||||
{
|
||||
for (int i = last; i < current; i++)
|
||||
{
|
||||
// FIXME: Should use isLetter(int) and text.codePointAt(int)
|
||||
// instead, but isLetter(int) isn't implemented yet
|
||||
if (Character.isLetter(text.charAt(i)))
|
||||
cp = text.codePointAt(i);
|
||||
|
||||
// Return the last found bound if there is a letter at the current
|
||||
// location or is not whitespace (meaning it is a number or
|
||||
// punctuation). The first case means that 'last' denotes the
|
||||
// beginning of a word while the second case means it is the start
|
||||
// of some else.
|
||||
if (Character.isLetter(cp)
|
||||
|| !Character.isWhitespace(cp))
|
||||
return last;
|
||||
}
|
||||
last = current;
|
||||
current = wb.next();
|
||||
}
|
||||
return BreakIterator.DONE;
|
||||
|
||||
throw new BadLocationException("no more word", offs);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -358,9 +375,7 @@ public class Utilities
|
|||
{
|
||||
for (int i = last; i < offs; i++)
|
||||
{
|
||||
// FIXME: Should use isLetter(int) and text.codePointAt(int)
|
||||
// instead, but isLetter(int) isn't implemented yet
|
||||
if (Character.isLetter(text.charAt(i)))
|
||||
if (Character.isLetter(text.codePointAt(i)))
|
||||
return last;
|
||||
}
|
||||
last = current;
|
||||
|
@ -510,24 +525,28 @@ public class Utilities
|
|||
int x0, int x, TabExpander e,
|
||||
int startOffset)
|
||||
{
|
||||
int mark = Utilities.getTabbedTextOffset(s, metrics, x0, x, e, startOffset);
|
||||
int mark = Utilities.getTabbedTextOffset(s, metrics, x0, x, e, startOffset, false);
|
||||
BreakIterator breaker = BreakIterator.getWordInstance();
|
||||
breaker.setText(s);
|
||||
|
||||
// If mark is equal to the end of the string, just use that position
|
||||
if (mark == s.count + s.offset)
|
||||
// If startOffset and s.offset differ then we need to use
|
||||
// that difference two convert the offset between the two metrics.
|
||||
int shift = startOffset - s.offset;
|
||||
|
||||
// If mark is equal to the end of the string, just use that position.
|
||||
if (mark >= shift + s.count)
|
||||
return mark;
|
||||
|
||||
// Try to find a word boundary previous to the mark at which we
|
||||
// can break the text
|
||||
int preceding = breaker.preceding(mark + 1);
|
||||
// can break the text.
|
||||
int preceding = breaker.preceding(mark + 1 - shift);
|
||||
|
||||
if (preceding != 0)
|
||||
return preceding;
|
||||
else
|
||||
// If preceding is 0 we couldn't find a suitable word-boundary so
|
||||
// just break it on the character boundary
|
||||
return mark;
|
||||
return preceding + shift;
|
||||
|
||||
// If preceding is 0 we couldn't find a suitable word-boundary so
|
||||
// just break it on the character boundary
|
||||
return mark;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -619,8 +638,22 @@ public class Utilities
|
|||
if(offs == -1)
|
||||
return -1;
|
||||
|
||||
// Effectively calculates the y value of the previous line.
|
||||
Point pt = c.modelToView(offs+1).getLocation();
|
||||
Point pt = null;
|
||||
|
||||
// Note: Some views represent the position after the last
|
||||
// typed character others do not. Converting offset 3 in "a\nb"
|
||||
// in a PlainView will return a valid rectangle while in a
|
||||
// WrappedPlainView this will throw a BadLocationException.
|
||||
// This behavior has been observed in the RI.
|
||||
try
|
||||
{
|
||||
// Effectively calculates the y value of the next line.
|
||||
pt = c.modelToView(offs+1).getLocation();
|
||||
}
|
||||
catch(BadLocationException ble)
|
||||
{
|
||||
return offset;
|
||||
}
|
||||
|
||||
pt.x = x;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue