Hi,
For some reason the method getNextVisualPositionFrom was declared
abstract in javax.swing.text.View and also had the wrong signature. I
fixed this. I also had to fix all the other views. Some of them have
this method removed completely now (since it is no more abstract),
others only have the signatures fixed.
2005-11-23 Roman Kennke <[EMAIL PROTECTED]>
* javax/swing/text/View.java
(getNextVisualPositionFrom): Fixed signature and (partly)
implemented this method.
* javax/swing/text/Utilities.java
(getPositionAbove): Fixed to use the correct signature for the
call
to above method.
(getPositionBelow): Fixed to use the correct signature for the
call
to above method.
* javax/swing/text/ComponentView.java
(getNextVisualPositionFrom): Removed method. This is not specified
to be implemented.
* javax/swing/text/CompositeView.java
(getNextVisualPositionFrom): Removed method with wrong signature.
A method with the correct signature is already in place.
* javax/swing/text/FlowView.java
(LogicalView.getNextVisualPositionFrom): Removed method with wrong
signature.
* javax/swing/text/GlyphView.java
(getNextVisualPositionFrom): Removed method with wrong signature.
A method with the correct signature is already in place.
* javax/swing/text/IconView.java
(getNextVisualPositionFrom): Removed method. This is not specified
to be implemented.
* javax/swing/text/PlainView.java
(getNextVisualPositionFrom): Removed method. This is not specified
to be implemented.
* javax/swing/text/WrappedPlainView.java
(WrappedLine.getNextVisualPositionFrom): Removed method with wrong
signature.
* javax/swing/plaf/basic/BasicTextUI.java
(RootView.getNextVisualPositionFrom): Fixed signature.
/Roman
Index: javax/swing/text/View.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/View.java,v
retrieving revision 1.23
diff -u -r1.23 View.java
--- javax/swing/text/View.java 3 Nov 2005 14:09:22 -0000 1.23
+++ javax/swing/text/View.java 23 Nov 2005 11:58:16 -0000
@@ -599,9 +599,9 @@
* Returns the document position that is (visually) nearest to the given
* document position <code>pos</code> in the given direction <code>d</code>.
*
- * @param c the text component
* @param pos the document position
* @param b the bias for <code>pos</code>
+ * @param a the allocation for this view
* @param d the direction, must be either [EMAIL PROTECTED] SwingConstants#NORTH},
* [EMAIL PROTECTED] SwingConstants#SOUTH}, [EMAIL PROTECTED] SwingConstants#WEST} or
* [EMAIL PROTECTED] SwingConstants#EAST}
@@ -615,9 +615,31 @@
*
* @throws BadLocationException if <code>pos</code> is not a valid offset in
* the document model
+ * @throws IllegalArgumentException if <code>d</code> is not a valid direction
*/
- public abstract int getNextVisualPositionFrom(JTextComponent c, int pos,
- Position.Bias b, int d,
- Position.Bias[] biasRet)
- throws BadLocationException;
+ public int getNextVisualPositionFrom(int pos, Position.Bias b,
+ Shape a, int d,
+ Position.Bias[] biasRet)
+ throws BadLocationException
+ {
+ int ret = pos;
+ switch (d)
+ {
+ case WEST:
+ ret = pos - 1;
+ break;
+ case EAST:
+ ret = pos + 1;
+ break;
+ case NORTH:
+ // TODO: Implement this
+ break;
+ case SOUTH:
+ // TODO: Implement this
+ break;
+ default:
+ throw new IllegalArgumentException("Illegal value for d");
+ }
+ return ret;
+ }
}
Index: javax/swing/text/Utilities.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/Utilities.java,v
retrieving revision 1.18
diff -u -r1.18 Utilities.java
--- javax/swing/text/Utilities.java 3 Nov 2005 14:09:22 -0000 1.18
+++ javax/swing/text/Utilities.java 23 Nov 2005 11:58:16 -0000
@@ -45,6 +45,7 @@
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
@@ -573,10 +574,11 @@
View rootView = c.getUI().getRootView(c);
Rectangle r = c.modelToView(offset);
int offs = c.viewToModel(new Point(x, r.y));
- int pos = rootView.getNextVisualPositionFrom(c, offs,
- Position.Bias.Forward,
- SwingConstants.NORTH,
- new Position.Bias[1]);
+ int pos = rootView.getNextVisualPositionFrom(offs,
+ Position.Bias.Forward,
+ SwingUtilities.calculateInnerArea(c, null),
+ SwingConstants.NORTH,
+ new Position.Bias[1]);
return pos;
}
@@ -599,10 +601,11 @@
View rootView = c.getUI().getRootView(c);
Rectangle r = c.modelToView(offset);
int offs = c.viewToModel(new Point(x, r.y));
- int pos = rootView.getNextVisualPositionFrom(c, offs,
- Position.Bias.Forward,
- SwingConstants.SOUTH,
- new Position.Bias[1]);
+ int pos = rootView.getNextVisualPositionFrom(offs,
+ Position.Bias.Forward,
+ SwingUtilities.calculateInnerArea(c, null),
+ SwingConstants.SOUTH,
+ new Position.Bias[1]);
return pos;
}
}
Index: javax/swing/text/ComponentView.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/ComponentView.java,v
retrieving revision 1.13
diff -u -r1.13 ComponentView.java
--- javax/swing/text/ComponentView.java 17 Nov 2005 20:31:51 -0000 1.13
+++ javax/swing/text/ComponentView.java 23 Nov 2005 11:58:16 -0000
@@ -264,34 +264,4 @@
Element el = getElement();
return el.getStartOffset();
}
-
- /**
- * Returns the document position that is (visually) nearest to the given
- * document position <code>pos</code> in the given direction <code>d</code>.
- *
- * @param c the text component
- * @param pos the document position
- * @param b the bias for <code>pos</code>
- * @param d the direction, must be either [EMAIL PROTECTED] SwingConstants#NORTH},
- * [EMAIL PROTECTED] SwingConstants#SOUTH}, [EMAIL PROTECTED] SwingConstants#WEST} or
- * [EMAIL PROTECTED] SwingConstants#EAST}
- * @param biasRet an array of [EMAIL PROTECTED] Position.Bias} that can hold at least
- * one element, which is filled with the bias of the return position
- * on method exit
- *
- * @return the document position that is (visually) nearest to the given
- * document position <code>pos</code> in the given direction
- * <code>d</code>
- *
- * @throws BadLocationException if <code>pos</code> is not a valid offset in
- * the document model
- */
- public int getNextVisualPositionFrom(JTextComponent c, int pos,
- Position.Bias b, int d,
- Position.Bias[] biasRet)
- throws BadLocationException
- {
- // FIXME: Implement this method.
- throw new AssertionError("Not yet implemented");
- }
}
Index: javax/swing/text/FlowView.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/FlowView.java,v
retrieving revision 1.6
diff -u -r1.6 FlowView.java
--- javax/swing/text/FlowView.java 17 Nov 2005 20:31:51 -0000 1.6
+++ javax/swing/text/FlowView.java 23 Nov 2005 11:58:16 -0000
@@ -396,37 +396,6 @@
throw new AssertionError("This method must not be called in "
+ "LogicalView.");
}
-
- /**
- * Returns the document position that is (visually) nearest to the given
- * document position <code>pos</code> in the given direction <code>d</code>.
- *
- * @param c the text component
- * @param pos the document position
- * @param b the bias for <code>pos</code>
- * @param d the direction, must be either [EMAIL PROTECTED] SwingConstants#NORTH},
- * [EMAIL PROTECTED] SwingConstants#SOUTH}, [EMAIL PROTECTED] SwingConstants#WEST} or
- * [EMAIL PROTECTED] SwingConstants#EAST}
- * @param biasRet an array of [EMAIL PROTECTED] Position.Bias} that can hold at least
- * one element, which is filled with the bias of the return position
- * on method exit
- *
- * @return the document position that is (visually) nearest to the given
- * document position <code>pos</code> in the given direction
- * <code>d</code>
- *
- * @throws BadLocationException if <code>pos</code> is not a valid offset in
- * the document model
- */
- public int getNextVisualPositionFrom(JTextComponent c, int pos,
- Position.Bias b, int d,
- Position.Bias[] biasRet)
- throws BadLocationException
- {
- assert false : "getNextVisualPositionFrom() must not be called in "
- + "LogicalView";
- return 0;
- }
}
/**
Index: javax/swing/text/IconView.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/IconView.java,v
retrieving revision 1.6
diff -u -r1.6 IconView.java
--- javax/swing/text/IconView.java 17 Nov 2005 20:31:51 -0000 1.6
+++ javax/swing/text/IconView.java 23 Nov 2005 11:58:16 -0000
@@ -158,34 +158,4 @@
return el.getStartOffset();
}
- /**
- * Returns the document position that is (visually) nearest to the given
- * document position <code>pos</code> in the given direction <code>d</code>.
- *
- * @param c the text component
- * @param pos the document position
- * @param b the bias for <code>pos</code>
- * @param d the direction, must be either [EMAIL PROTECTED] SwingConstants#NORTH},
- * [EMAIL PROTECTED] SwingConstants#SOUTH}, [EMAIL PROTECTED] SwingConstants#WEST} or
- * [EMAIL PROTECTED] SwingConstants#EAST}
- * @param biasRet an array of [EMAIL PROTECTED] Position.Bias} that can hold at least
- * one element, which is filled with the bias of the return position
- * on method exit
- *
- * @return the document position that is (visually) nearest to the given
- * document position <code>pos</code> in the given direction
- * <code>d</code>
- *
- * @throws BadLocationException if <code>pos</code> is not a valid offset in
- * the document model
- */
- public int getNextVisualPositionFrom(JTextComponent c, int pos,
- Position.Bias b, int d,
- Position.Bias[] biasRet)
- throws BadLocationException
- {
- // TODO: Implement this properly.
- throw new AssertionError("Not implemented yet.");
- }
-
}
Index: javax/swing/text/PlainView.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/PlainView.java,v
retrieving revision 1.32
diff -u -r1.32 PlainView.java
--- javax/swing/text/PlainView.java 3 Nov 2005 23:19:34 -0000 1.32
+++ javax/swing/text/PlainView.java 23 Nov 2005 11:58:18 -0000
@@ -530,35 +530,5 @@
lineBuffer = new Segment();
return lineBuffer;
}
-
- /**
- * Returns the document position that is (visually) nearest to the given
- * document position <code>pos</code> in the given direction <code>d</code>.
- *
- * @param c the text component
- * @param pos the document position
- * @param b the bias for <code>pos</code>
- * @param d the direction, must be either [EMAIL PROTECTED] SwingConstants#NORTH},
- * [EMAIL PROTECTED] SwingConstants#SOUTH}, [EMAIL PROTECTED] SwingConstants#WEST} or
- * [EMAIL PROTECTED] SwingConstants#EAST}
- * @param biasRet an array of [EMAIL PROTECTED] Position.Bias} that can hold at least
- * one element, which is filled with the bias of the return position
- * on method exit
- *
- * @return the document position that is (visually) nearest to the given
- * document position <code>pos</code> in the given direction
- * <code>d</code>
- *
- * @throws BadLocationException if <code>pos</code> is not a valid offset in
- * the document model
- */
- public int getNextVisualPositionFrom(JTextComponent c, int pos,
- Position.Bias b, int d,
- Position.Bias[] biasRet)
- throws BadLocationException
- {
- // TODO: Implement this properly.
- throw new AssertionError("Not implemented yet.");
- }
}
Index: javax/swing/plaf/basic/BasicTextUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicTextUI.java,v
retrieving revision 1.56
diff -u -r1.56 BasicTextUI.java
--- javax/swing/plaf/basic/BasicTextUI.java 15 Nov 2005 20:32:46 -0000 1.56
+++ javax/swing/plaf/basic/BasicTextUI.java 23 Nov 2005 11:58:25 -0000
@@ -334,9 +334,9 @@
* Returns the document position that is (visually) nearest to the given
* document position <code>pos</code> in the given direction <code>d</code>.
*
- * @param c the text component
* @param pos the document position
* @param b the bias for <code>pos</code>
+ * @param a the allocation for the view
* @param d the direction, must be either [EMAIL PROTECTED] SwingConstants#NORTH},
* [EMAIL PROTECTED] SwingConstants#SOUTH}, [EMAIL PROTECTED] SwingConstants#WEST} or
* [EMAIL PROTECTED] SwingConstants#EAST}
@@ -351,12 +351,11 @@
* @throws BadLocationException if <code>pos</code> is not a valid offset in
* the document model
*/
- public int getNextVisualPositionFrom(JTextComponent c, int pos,
- Position.Bias b, int d,
- Position.Bias[] biasRet)
+ public int getNextVisualPositionFrom(int pos, Position.Bias b, Shape a,
+ int d, Position.Bias[] biasRet)
throws BadLocationException
{
- return view.getNextVisualPositionFrom(c, pos, b, d, biasRet);
+ return view.getNextVisualPositionFrom(pos, b, a, d, biasRet);
}
}
_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches