Imported GNU Classpath 0.90

Imported GNU Classpath 0.90
       * scripts/makemake.tcl: Set gnu/java/awt/peer/swing to ignore.
       * gnu/classpath/jdwp/VMFrame.java (SIZE): New constant.
       * java/lang/VMCompiler.java: Use gnu.java.security.hash.MD5.
       * java/lang/Math.java: New override file.
       * java/lang/Character.java: Merged from Classpath.
       (start, end): Now 'int's.
       (canonicalName): New field.
       (CANONICAL_NAME, NO_SPACES_NAME, CONSTANT_NAME): New constants.
       (UnicodeBlock): Added argument.
       (of): New overload.
       (forName): New method.
       Updated unicode blocks.
       (sets): Updated.
       * sources.am: Regenerated.
       * Makefile.in: Likewise.

From-SVN: r111942
This commit is contained in:
Mark Wielaard 2006-03-10 21:46:48 +00:00
parent 27079765d0
commit 8aa540d2f7
1367 changed files with 188789 additions and 22762 deletions

View file

@ -41,12 +41,8 @@ package javax.swing.text;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Rectangle;
import java.text.BreakIterator;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
/**
* A set of utilities to deal with text. This is used by several other classes
* inside this package.
@ -73,6 +69,10 @@ public class Utilities
* are taken into account. Tabs are expanded using the
* specified {@link TabExpander}.
*
*
* The X and Y coordinates denote the start of the <em>baseline</em> where
* the text should be drawn.
*
* @param s the text fragment to be drawn.
* @param x the x position for drawing.
* @param y the y position for drawing.
@ -88,15 +88,14 @@ public class Utilities
// This buffers the chars to be drawn.
char[] buffer = s.array;
// The current x and y pixel coordinates.
int pixelX = x;
int pixelY = y;
// The font metrics of the current selected font.
FontMetrics metrics = g.getFontMetrics();
int ascent = metrics.getAscent();
// The current x and y pixel coordinates.
int pixelX = x;
int pixelY = y - ascent;
int pixelWidth = 0;
int pos = s.offset;
int len = 0;
@ -238,9 +237,10 @@ public class Utilities
int pos;
int currentX = x0;
for (pos = p0; pos < s.count; pos++)
for (pos = 0; pos < s.count; pos++)
{
char nextChar = s.array[s.offset+pos];
if (nextChar == 0)
{
if (! round)
@ -256,6 +256,7 @@ public class Utilities
else
currentX = (int) te.nextTabStop(currentX, pos);
}
if (currentX > x)
{
if (! round)
@ -263,7 +264,8 @@ public class Utilities
break;
}
}
return pos;
return pos + p0;
}
/**
@ -510,10 +512,10 @@ public class Utilities
{
int mark = Utilities.getTabbedTextOffset(s, metrics, x0, x, e, startOffset);
BreakIterator breaker = BreakIterator.getWordInstance();
breaker.setText(s.toString());
breaker.setText(s);
// If mark is equal to the end of the string, just use that position
if (mark == s.count)
if (mark == s.count + s.offset)
return mark;
// Try to find a word boundary previous to the mark at which we
@ -571,15 +573,29 @@ public class Utilities
public static final int getPositionAbove(JTextComponent c, int offset, int x)
throws BadLocationException
{
View rootView = c.getUI().getRootView(c);
Rectangle r = c.modelToView(offset);
int offs = c.viewToModel(new Point(x, r.y));
int pos = rootView.getNextVisualPositionFrom(offs,
Position.Bias.Forward,
SwingUtilities.calculateInnerArea(c, null),
SwingConstants.NORTH,
new Position.Bias[1]);
return pos;
int offs = getRowStart(c, offset);
if(offs == -1)
return -1;
// Effectively calculates the y value of the previous line.
Point pt = c.modelToView(offs-1).getLocation();
pt.x = x;
// Calculate a simple fitting offset.
offs = c.viewToModel(pt);
// Find out the real x positions of the calculated character and its
// neighbour.
int offsX = c.modelToView(offs).getLocation().x;
int offsXNext = c.modelToView(offs+1).getLocation().x;
// Chose the one which is nearer to us and return its offset.
if (Math.abs(offsX-x) <= Math.abs(offsXNext-x))
return offs;
else
return offs+1;
}
/**
@ -598,14 +614,31 @@ public class Utilities
public static final int getPositionBelow(JTextComponent c, int offset, int x)
throws BadLocationException
{
View rootView = c.getUI().getRootView(c);
Rectangle r = c.modelToView(offset);
int offs = c.viewToModel(new Point(x, r.y));
int pos = rootView.getNextVisualPositionFrom(offs,
Position.Bias.Forward,
SwingUtilities.calculateInnerArea(c, null),
SwingConstants.SOUTH,
new Position.Bias[1]);
return pos;
}
int offs = getRowEnd(c, offset);
if(offs == -1)
return -1;
// Effectively calculates the y value of the previous line.
Point pt = c.modelToView(offs+1).getLocation();
pt.x = x;
// Calculate a simple fitting offset.
offs = c.viewToModel(pt);
if (offs == c.getDocument().getLength())
return offs;
// Find out the real x positions of the calculated character and its
// neighbour.
int offsX = c.modelToView(offs).getLocation().x;
int offsXNext = c.modelToView(offs+1).getLocation().x;
// Chose the one which is nearer to us and return its offset.
if (Math.abs(offsX-x) <= Math.abs(offsXNext-x))
return offs;
else
return offs+1;
}
}