[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cp-patches] FYI: Implementation of CompositeView and others
From: |
Roman Kennke |
Subject: |
[cp-patches] FYI: Implementation of CompositeView and others |
Date: |
Tue, 02 Aug 2005 11:36:23 +0200 |
User-agent: |
Mozilla Thunderbird 1.0.2 (X11/20050317) |
Hi,
I implemented most of javax.swing.text.CompositeView. Note that I had to
add some stub methods to other View classes, I will implement these ASAP.
2005-08-02 Roman Kennke <address@hidden>
* javax/swing/plaf/basic/BasicTextUI.java
(RootView.viewToModel): New method.
* javax/swing/text/BoxView.java
(isBefore): New method. This is a stub method to implement the
new abstract method from CompositeView.
(isAfter): New method. This is a stub method to implement the
new abstract method from CompositeView.
(getViewAtPoint): New method. This is a stub method to
implement the
new abstract method from CompositeView.
(childAllocation): New method. This is a stub method to
implement the
new abstract method from CompositeView.
* javax/swing/text/ComponentView.java
(viewToModel): New method. This is a stub method to implement the
new abstract method from View.
* javax/swing/text/CompositeView.java
(loadChildren): Implemented new method.
(setParent): Implemented new method.
(getViewCount): Implemented new method.
(getView): Implemented new method.
(replace): Implemented new method.
(getChildAllocation): Implemented new method.
(modelToView(int, Shape, Position.Bias)): Implemented this method.
(modelToView(int, Position.Bias, int, Position.Bias, Shape):
Implemented new method.
(viewToModel): Implemented new method.
(getNextVisualPositionFrom): Implemented new method.
(getViewIndex): Implemented new method.
(isBefore): New abstract method.
(isAfter): New abstract method.
(getViewAtPoint): New abstract method.
(childAllocation): New abstract method.
(getViewAtPosition): Implemented new method.
(getViewIndexAtPosition): Implemented new method.
(getInsideAllocation): Implemented new method.
(setParagraphInsets): Implemented new method.
(setInsets): Implemented new method.
(getLeftInset): Implemented new method.
(getRightInset): Implemented new method.
(getTopInset): Implemented new method.
(getBottomInset): Implemented new method.
(getNextNorthSouthVisualPositionFrom): New method.
(getNextEastWestVisualPositionFrom): New method.
(flipEastAndWestAtEnds): Implemented new method.
* javax/swing/text/GlyphView.java
(viewToModel): New method. This is a stub method to implement the
new abstract method from View.
* javax/swing/text/IconView.java
(viewToModel): New method. This is a stub method to implement the
new abstract method from View.
* javax/swing/text/PlainView.java
(viewToModel): New method. This is a stub method to implement the
new abstract method from View.
* javax/swing/text/View.java
(viewToModel): New abstract method.
/Roman
? javax/swing/DumpHierarchy.java
Index: javax/swing/plaf/basic/BasicTextUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicTextUI.java,v
retrieving revision 1.29
diff -u -r1.29 BasicTextUI.java
--- javax/swing/plaf/basic/BasicTextUI.java 29 Jul 2005 14:13:09 -0000
1.29
+++ javax/swing/plaf/basic/BasicTextUI.java 2 Aug 2005 09:32:56 -0000
@@ -229,10 +229,24 @@
public Shape modelToView(int position, Shape a, Position.Bias bias)
throws BadLocationException
{
- if (view == null)
- return null;
-
return ((View) view).modelToView(position, a, bias);
+ }
+
+ /**
+ * Maps coordinates from the <code>View</code>'s space into a position
+ * in the document model.
+ *
+ * @param x the x coordinate in the view space
+ * @param y the y coordinate in the view space
+ * @param a the allocation of this <code>View</code>
+ * @param b the bias to use
+ *
+ * @return the position in the document that corresponds to the screen
+ * coordinates <code>x, y</code>
+ */
+ public int viewToModel(float x, float y, Shape a, Position.Bias b)
+ {
+ return view.viewToModel(x, y, a, b);
}
/**
Index: javax/swing/text/BoxView.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/BoxView.java,v
retrieving revision 1.1
diff -u -r1.1 BoxView.java
--- javax/swing/text/BoxView.java 29 Jul 2005 09:56:10 -0000 1.1
+++ javax/swing/text/BoxView.java 2 Aug 2005 09:32:57 -0000
@@ -39,6 +39,7 @@
package javax.swing.text;
import java.awt.Graphics;
+import java.awt.Rectangle;
import java.awt.Shape;
// TODO: Implement this class.
@@ -83,5 +84,72 @@
{
// TODO: Implement me.
return 0F;
+ }
+
+ /**
+ * Returns <code>true</code> if the specified point lies before the
+ * given <code>Rectangle</code>, <code>false</code> otherwise.
+ *
+ * "Before" is typically defined as being to the left or above.
+ *
+ * @param x the X coordinate of the point
+ * @param y the Y coordinate of the point
+ * @param r the rectangle to test the point against
+ *
+ * @return <code>true</code> if the specified point lies before the
+ * given <code>Rectangle</code>, <code>false</code> otherwise
+ */
+ protected boolean isBefore(int x, int y, Rectangle r)
+ {
+ // TODO: Implement this properly.
+ return false;
+ }
+
+ /**
+ * Returns <code>true</code> if the specified point lies after the
+ * given <code>Rectangle</code>, <code>false</code> otherwise.
+ *
+ * "After" is typically defined as being to the right or below.
+ *
+ * @param x the X coordinate of the point
+ * @param y the Y coordinate of the point
+ * @param r the rectangle to test the point against
+ *
+ * @return <code>true</code> if the specified point lies after the
+ * given <code>Rectangle</code>, <code>false</code> otherwise
+ */
+ protected boolean isAfter(int x, int y, Rectangle r)
+ {
+ // TODO: Implement this properly.
+ return false;
+ }
+
+ /**
+ * Returns the child <code>View</code> at the specified location.
+ *
+ * @param x the X coordinate
+ * @param y the Y coordinate
+ * @param r the allocation of this <code>CompositeView</code>
+ *
+ * @return the child <code>View</code> at the specified location
+ */
+ protected View getViewAtPoint(int x, int y, Rectangle r)
+ {
+ // TODO: Implement this properly.
+ return null;
+ }
+
+ /**
+ * Computes the allocation for a child <code>View</code>. The parameter
+ * <code>a</code> stores the allocation of this <code>CompositeView</code>
+ * and is then adjusted to hold the allocation of the child view.
+ *
+ * @param index the index of the child <code>View</code>
+ * @param a the allocation of this <code>CompositeView</code> before the
+ * call, the allocation of the child on exit
+ */
+ protected void childAllocation(int index, Rectangle a)
+ {
+ // TODO: Implement this properly.
}
}
Index: javax/swing/text/ComponentView.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/ComponentView.java,v
retrieving revision 1.7
diff -u -r1.7 ComponentView.java
--- javax/swing/text/ComponentView.java 2 Jul 2005 20:32:51 -0000 1.7
+++ javax/swing/text/ComponentView.java 2 Aug 2005 09:32:57 -0000
@@ -100,4 +100,22 @@
{
return 0;
}
+
+ /**
+ * Maps coordinates from the <code>View</code>'s space into a position
+ * in the document model.
+ *
+ * @param x the x coordinate in the view space
+ * @param y the y coordinate in the view space
+ * @param a the allocation of this <code>View</code>
+ * @param b the bias to use
+ *
+ * @return the position in the document that corresponds to the screen
+ * coordinates <code>x, y</code>
+ */
+ public int viewToModel(float x, float y, Shape a, Position.Bias b)
+ {
+ // FIXME: Implement this properly.
+ return 0;
+ }
}
Index: javax/swing/text/CompositeView.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/CompositeView.java,v
retrieving revision 1.1
diff -u -r1.1 CompositeView.java
--- javax/swing/text/CompositeView.java 29 Jul 2005 09:56:10 -0000 1.1
+++ javax/swing/text/CompositeView.java 2 Aug 2005 09:32:57 -0000
@@ -38,14 +38,41 @@
package javax.swing.text;
+import java.awt.Insets;
+import java.awt.Rectangle;
import java.awt.Shape;
-// TODO: Implement this class.
+import javax.swing.SwingConstants;
+
+/**
+ * An abstract base implementation of address@hidden View} that manages child
+ * <code>View</code>s.
+ *
+ * @author Roman Kennke (address@hidden)
+ */
public abstract class CompositeView
extends View
{
/**
+ * The child views of this <code>CompositeView</code>.
+ */
+ View[] children;
+
+ /**
+ * The allocation of this <code>View</code> minus its insets. This is
+ * initialized in address@hidden #getInsideAllocation} and reused and
modified in
+ * address@hidden childAllocation}.
+ */
+ Rectangle insideAllocation;
+
+ /**
+ * The insets of this <code>CompositeView</code>. This is initialized
+ * in address@hidden #setInsets}.
+ */
+ Insets insets;
+
+ /**
* Creates a new <code>CompositeView</code> for the given
* <code>Element</code>.
*
@@ -54,6 +81,102 @@
public CompositeView(Element element)
{
super(element);
+ children = new View[0];
+ insets = new Insets(0, 0, 0, 0);
+ }
+
+ /**
+ * Loads the child views of this <code>CompositeView</code>. This method
+ * is called from address@hidden #setParent} to initialize the child views of
+ * this composite view.
+ *
+ * @param f the view factory to use for creating new child views
+ *
+ * @see address@hidden #setParent}
+ */
+ protected void loadChildren(ViewFactory f)
+ {
+ Element el = getElement();
+ int count = el.getElementCount();
+ children = new View[count];
+ for (int i = 0; i < count; ++i)
+ {
+ Element child = el.getElement(i);
+ View view = f.create(child);
+ children[i] = view;
+ }
+ }
+
+ /**
+ * Sets the parent of this <code>View</code>.
+ * In addition to setting the parent, this calls address@hidden
#loadChildren}, if
+ * this <code>View</code> does not already have its children initialized.
+ *
+ * @param p the parent to set
+ */
+ public void setParent(View parent)
+ {
+ super.setParent(parent);
+ if ((children == null) || children.length == 0)
+ loadChildren(getViewFactory());
+ }
+
+ /**
+ * Returns the number of child views.
+ *
+ * @return the number of child views
+ */
+ public int getViewCount()
+ {
+ return children.length;
+ }
+
+ /**
+ * Returns the child view at index <code>n</code>.
+ *
+ * @param n the index of the requested child view
+ *
+ * @return the child view at index <code>n</code>
+ */
+ public View getView(int n)
+ {
+ return children[n];
+ }
+
+ /**
+ * Replaces child views by some other child views. If there are no views to
+ * remove (<code>length == 0</code>), the result is a simple insert, if
+ * there are no children to add (<code>view == null</code>) the result
+ * is a simple removal.
+ *
+ * @param offset the start offset from where to remove children
+ * @param length the number of children to remove
+ * @param views the views that replace the removed children
+ */
+ public void replace(int offset, int length, View[] views)
+ {
+ View[] newChildren = new View[children.length - length + views.length];
+ System.arraycopy(children, 0, newChildren, 0, offset);
+ System.arraycopy(views, 0, newChildren, offset, views.length);
+ System.arraycopy(children, offset + length, newChildren,
+ offset + views.length,
+ children.length - (offset + length));
+ children = newChildren;
+ }
+
+ /**
+ * Returns the allocation for the specified child <code>View</code>.
+ *
+ * @param index the index of the child view
+ * @param a the allocation for this view
+ *
+ * @return the allocation for the specified child <code>View</code>
+ */
+ public Shape getChildAllocation(int index, Shape a)
+ {
+ Rectangle r = getInsideAllocation(a);
+ childAllocation(index, r);
+ return r;
}
/**
@@ -75,10 +198,423 @@
* @throws IllegalArgumentException if b is not one of the above listed
* valid values
*/
- public Shape modelToView(int pos, Shape a, Position.Bias b)
+ public Shape modelToView(int pos, Shape a, Position.Bias bias)
throws BadLocationException
{
- // Implement me.
- return null;
+ int childIndex = getViewIndex(pos, bias);
+ View child = children[childIndex];
+ return child.modelToView(pos, a, bias);
+ }
+
+ /**
+ * Maps a region in the document into the coordinate space of the View.
+ *
+ * @param p1 the beginning position inside the document
+ * @param b1 the direction bias for the beginning position
+ * @param p2 the end position inside the document
+ * @param b2 the direction bias for the end position
+ * @param a the area that is occupied by the view
+ *
+ * @return a rectangle that gives the span of the document region
+ * inside the view coordinate space
+ *
+ * @throws BadLocationException if <code>p1</code> or <code>p2</code> are
+ * invalid
+ * @throws IllegalArgumentException if b1 or b2 is not one of the above
+ * listed valid values
+ */
+ public Shape modelToView(int p1, Position.Bias b1,
+ int p2, Position.Bias b2, Shape a)
+ throws BadLocationException
+ {
+ // TODO: This is most likely not 100% ok, figure out what else is to
+ // do here.
+ return super.modelToView(p1, b1, p2, b2, a);
+ }
+
+ /**
+ * Maps coordinates from the <code>View</code>'s space into a position
+ * in the document model.
+ *
+ * @param x the x coordinate in the view space
+ * @param y the y coordinate in the view space
+ * @param a the allocation of this <code>View</code>
+ * @param b the bias to use
+ *
+ * @return the position in the document that corresponds to the screen
+ * coordinates <code>x, y</code>
+ */
+ public int viewToModel(float x, float y, Shape a, Position.Bias b)
+ {
+ Rectangle r = getInsideAllocation(a);
+ View view = getViewAtPoint((int) x, (int) y, r);
+ return view.viewToModel(x, y, a, b);
+ }
+
+ /**
+ * Returns the next model location that is visible in eiter north / south
+ * direction or east / west direction. This is used to determine the
+ * placement of the caret when navigating around the document with
+ * the arrow keys.
+ *
+ * This is a convenience method for
+ * address@hidden #getNextNorthSouthVisualPositionFrom} and
+ * address@hidden #getNextEastWestVisualPositionFrom}.
+ *
+ * @param pos the model position to start search from
+ * @param the bias for <code>pos</code>
+ * @param a the allocated region for this view
+ * @param direction the direction from the current position, can be one of
+ * the following:
+ * <ul>
+ * <li>address@hidden SwingConstants#WEST}</li>
+ * <li>address@hidden SwingConstants#EAST}</li>
+ * <li>address@hidden SwingConstants#NORTH}</li>
+ * <li>address@hidden SwingConstants#SOUTH}</li>
+ * </ul>
+ * @param biasRet the bias of the return value gets stored here
+ *
+ * @return the position inside the model that represents the next visual
+ * location
+ *
+ * @throws BadLocationException if <code>pos</code> is not a valid location
+ * inside the document model
+ * @throws IllegalArgumentException if <code>direction</code> is invalid
+ */
+ public int getNextVisualPositionFrom(int pos, Position.Bias b, Shape a,
+ int direction, Position.Bias[] biasRet)
+ {
+ int retVal = -1;
+ switch (direction)
+ {
+ case SwingConstants.WEST:
+ case SwingConstants.EAST:
+ retVal = getNextEastWestVisualPositionFrom(pos, b, a, direction,
+ biasRet);
+ break;
+ case SwingConstants.NORTH:
+ case SwingConstants.SOUTH:
+ retVal = getNextNorthSouthVisualPositionFrom(pos, b, a, direction,
+ biasRet);
+ break;
+ default:
+ throw new IllegalArgumentException("Illegal value for direction.");
+ }
+ return retVal;
+ }
+
+ /**
+ * Returns the index of the child view that represents the specified
+ * model location.
+ *
+ * @param pos the model location for which to determine the child view index
+ * @param b the bias to be applied to <code>pos</code>
+ *
+ * @return the index of the child view that represents the specified
+ * model location
+ */
+ public int getViewIndex(int pos, Position.Bias b)
+ {
+ // FIXME: Handle bias somehow.
+ return getViewIndexAtPosition(pos);
+ }
+
+ /**
+ * Returns <code>true</code> if the specified point lies before the
+ * given <code>Rectangle</code>, <code>false</code> otherwise.
+ *
+ * "Before" is typically defined as being to the left or above.
+ *
+ * @param x the X coordinate of the point
+ * @param y the Y coordinate of the point
+ * @param r the rectangle to test the point against
+ *
+ * @return <code>true</code> if the specified point lies before the
+ * given <code>Rectangle</code>, <code>false</code> otherwise
+ */
+ protected abstract boolean isBefore(int x, int y, Rectangle r);
+
+ /**
+ * Returns <code>true</code> if the specified point lies after the
+ * given <code>Rectangle</code>, <code>false</code> otherwise.
+ *
+ * "After" is typically defined as being to the right or below.
+ *
+ * @param x the X coordinate of the point
+ * @param y the Y coordinate of the point
+ * @param r the rectangle to test the point against
+ *
+ * @return <code>true</code> if the specified point lies after the
+ * given <code>Rectangle</code>, <code>false</code> otherwise
+ */
+ protected abstract boolean isAfter(int x, int y, Rectangle r);
+
+ /**
+ * Returns the child <code>View</code> at the specified location.
+ *
+ * @param x the X coordinate
+ * @param y the Y coordinate
+ * @param r the allocation of this <code>CompositeView</code>
+ *
+ * @return the child <code>View</code> at the specified location
+ */
+ protected abstract View getViewAtPoint(int x, int y, Rectangle r);
+
+ /**
+ * Computes the allocation for a child <code>View</code>. The parameter
+ * <code>a</code> stores the allocation of this <code>CompositeView</code>
+ * and is then adjusted to hold the allocation of the child view.
+ *
+ * @param index the index of the child <code>View</code>
+ * @param a the allocation of this <code>CompositeView</code> before the
+ * call, the allocation of the child on exit
+ */
+ protected abstract void childAllocation(int index, Rectangle a);
+
+ /**
+ * Returns the child <code>View</code> that contains the given model
+ * position. The given <code>Rectangle</code> gives the parent's allocation
+ * and is changed to the child's allocation on exit.
+ *
+ * @param pos the model position to query the child <code>View</code> for
+ * @param a the parent allocation on entry and the child allocation on exit
+ *
+ * @return the child view at the given model position
+ */
+ protected View getViewAtPosition(int pos, Rectangle a)
+ {
+ int i = getViewIndexAtPosition(pos);
+ View view = children[i];
+ childAllocation(i, a);
+ return view;
+ }
+
+ /**
+ * Returns the index of the child <code>View</code> for the given model
+ * position.
+ *
+ * @param pos the model position for whicht the child <code>View</code> is
+ * queried
+ *
+ * @return the index of the child <code>View</code> for the given model
+ * position
+ */
+ protected int getViewIndexAtPosition(int pos)
+ {
+ // We have one child view allocated for each child element in
+ // loadChildren(), so this should work.
+ Element el = getElement();
+ int index = el.getElementIndex(pos);
+ return index;
+ }
+
+ /**
+ * Returns the allocation that is given to this <code>CompositeView</code>
+ * minus this <code>CompositeView</code>'s insets.
+ *
+ * Also this translates from an immutable allocation to a mutable allocation
+ * that is typically reused and further narrowed, like in
+ * address@hidden childAllocation}.
+ *
+ * @param a the allocation given to this <code>CompositeView</code>
+ *
+ * @return the allocation that is given to this <code>CompositeView</code>
+ * minus this <code>CompositeView</code>'s insets or
+ * <code>null</code> if a was <code>null</code>
+ */
+ protected Rectangle getInsideAllocation(Shape a)
+ {
+ if (a == null)
+ return null;
+
+ Rectangle alloc = a.getBounds();
+ // Initialize the inside allocation rectangle. This is done inside
+ // a synchronized block in order to avoid multiple threads creating
+ // this instance simultanously.
+ Rectangle inside;
+ synchronized(this)
+ {
+ inside = insideAllocation;
+ if (inside == null)
+ {
+ inside = new Rectangle();
+ insideAllocation = inside;
+ }
+ }
+ inside.x = alloc.x - insets.left;
+ inside.y = alloc.y - insets.top;
+ inside.width = alloc.width - insets.left - insets.right;
+ inside.height = alloc.height - insets.top - insets.bottom;
+ return inside;
+ }
+
+ /**
+ * Sets the insets defined by attributes in <code>attributes</code>. This
+ * queries the attribute keys address@hidden StyleConstants#SpaveAbove},
+ * address@hidden StyleConstants#SpaveBelow}, address@hidden
StyleConstants#LeftIndent} and
+ * address@hidden StyleConstants#RightIndent} and calls address@hidden
#setInsets} to
+ * actually set the insets on this <code>CompositeView</code>.
+ *
+ * @param attributes the attributes from which to query the insets
+ */
+ protected void setParagraphInsets(AttributeSet attributes)
+ {
+ Float l = (Float) attributes.getAttribute(StyleConstants.LeftIndent);
+ short left = 0;
+ if (l != null)
+ left = l.shortValue();
+ Float r = (Float) attributes.getAttribute(StyleConstants.RightIndent);
+ short right = 0;
+ if (r != null)
+ right = r.shortValue();
+ Float t = (Float) attributes.getAttribute(StyleConstants.SpaceAbove);
+ short top = 0;
+ if (t != null)
+ top = t.shortValue();
+ Float b = (Float) attributes.getAttribute(StyleConstants.SpaceBelow);
+ short bottom = 0;
+ if (b != null)
+ bottom = b.shortValue();
+ setInsets(top, left, bottom, right);
+ }
+
+ /**
+ * Sets the insets of this <code>CompositeView</code>.
+ *
+ * @param top the top inset
+ * @param left the left inset
+ * @param bottom the bottom inset
+ * @param right the right inset
+ */
+ protected void setInsets(short top, short left, short bottom, short right)
+ {
+ insets.top = top;
+ insets.left = left;
+ insets.bottom = bottom;
+ insets.right = right;
+ }
+
+ /**
+ * Returns the left inset of this <code>CompositeView</code>.
+ *
+ * @return the left inset of this <code>CompositeView</code>
+ */
+ protected short getLeftInset()
+ {
+ return (short) insets.left;
+ }
+
+ /**
+ * Returns the right inset of this <code>CompositeView</code>.
+ *
+ * @return the right inset of this <code>CompositeView</code>
+ */
+ protected short getRightInset()
+ {
+ return (short) insets.right;
+ }
+
+ /**
+ * Returns the top inset of this <code>CompositeView</code>.
+ *
+ * @return the top inset of this <code>CompositeView</code>
+ */
+ protected short getTopInset()
+ {
+ return (short) insets.top;
+ }
+
+ /**
+ * Returns the bottom inset of this <code>CompositeView</code>.
+ *
+ * @return the bottom inset of this <code>CompositeView</code>
+ */
+ protected short getBottomInset()
+ {
+ return (short) insets.bottom;
+ }
+
+ /**
+ * Returns the next model location that is visible in north or south
+ * direction.
+ * This is used to determine the
+ * placement of the caret when navigating around the document with
+ * the arrow keys.
+ *
+ * @param pos the model position to start search from
+ * @param the bias for <code>pos</code>
+ * @param a the allocated region for this view
+ * @param direction the direction from the current position, can be one of
+ * the following:
+ * <ul>
+ * <li>address@hidden SwingConstants#NORTH}</li>
+ * <li>address@hidden SwingConstants#SOUTH}</li>
+ * </ul>
+ * @param biasRet the bias of the return value gets stored here
+ *
+ * @return the position inside the model that represents the next visual
+ * location
+ *
+ * @throws BadLocationException if <code>pos</code> is not a valid location
+ * inside the document model
+ * @throws IllegalArgumentException if <code>direction</code> is invalid
+ */
+ protected int getNextNorthSouthVisualPositionFrom(int pos, Position.Bias b,
+ Shape a, int direction,
+ Position.Bias[] biasRet)
+ {
+ // FIXME: Implement this correctly.
+ return pos;
+ }
+
+ /**
+ * Returns the next model location that is visible in east or west
+ * direction.
+ * This is used to determine the
+ * placement of the caret when navigating around the document with
+ * the arrow keys.
+ *
+ * @param pos the model position to start search from
+ * @param the bias for <code>pos</code>
+ * @param a the allocated region for this view
+ * @param direction the direction from the current position, can be one of
+ * the following:
+ * <ul>
+ * <li>address@hidden SwingConstants#EAST}</li>
+ * <li>address@hidden SwingConstants#WEST}</li>
+ * </ul>
+ * @param biasRet the bias of the return value gets stored here
+ *
+ * @return the position inside the model that represents the next visual
+ * location
+ *
+ * @throws BadLocationException if <code>pos</code> is not a valid location
+ * inside the document model
+ * @throws IllegalArgumentException if <code>direction</code> is invalid
+ */
+ protected int getNextEastWestVisualPositionFrom(int pos, Position.Bias b,
+ Shape a, int direction,
+ Position.Bias[] biasRet)
+ {
+ // FIXME: Implement this correctly.
+ return pos;
+ }
+
+ /**
+ * Determines if the next view in horinzontal direction is located to
+ * the east or west of the view at position <code>pos</code>. Usually
+ * the <code>View</code>s are laid out from the east to the west, so
+ * we unconditionally return <code>false</code> here. Subclasses that
+ * support bidirectional text may wish to override this method.
+ *
+ * @param pos the position in the document
+ * @param bias the bias to be applied to <code>pos</code>
+ *
+ * @return <code>true</code> if the next <code>View</code> is located
+ * to the EAST, <code>false</code> otherwise
+ */
+ protected boolean flipEastAndWestAtEnds(int pos, Position.Bias bias)
+ {
+ return false;
}
}
Index: javax/swing/text/GlyphView.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/GlyphView.java,v
retrieving revision 1.1
diff -u -r1.1 GlyphView.java
--- javax/swing/text/GlyphView.java 29 Jul 2005 09:56:10 -0000 1.1
+++ javax/swing/text/GlyphView.java 2 Aug 2005 09:32:57 -0000
@@ -108,4 +108,22 @@
// Implement me.
return null;
}
+
+ /**
+ * Maps coordinates from the <code>View</code>'s space into a position
+ * in the document model.
+ *
+ * @param x the x coordinate in the view space
+ * @param y the y coordinate in the view space
+ * @param a the allocation of this <code>View</code>
+ * @param b the bias to use
+ *
+ * @return the position in the document that corresponds to the screen
+ * coordinates <code>x, y</code>
+ */
+ public int viewToModel(float x, float y, Shape a, Position.Bias b)
+ {
+ // FIXME: Implement this properly.
+ return 0;
+ }
}
Index: javax/swing/text/IconView.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/IconView.java,v
retrieving revision 1.1
diff -u -r1.1 IconView.java
--- javax/swing/text/IconView.java 29 Jul 2005 09:56:10 -0000 1.1
+++ javax/swing/text/IconView.java 2 Aug 2005 09:32:57 -0000
@@ -107,4 +107,22 @@
// Implement me.
return null;
}
+
+ /**
+ * Maps coordinates from the <code>View</code>'s space into a position
+ * in the document model.
+ *
+ * @param x the x coordinate in the view space
+ * @param y the y coordinate in the view space
+ * @param a the allocation of this <code>View</code>
+ * @param b the bias to use
+ *
+ * @return the position in the document that corresponds to the screen
+ * coordinates <code>x, y</code>
+ */
+ public int viewToModel(float x, float y, Shape a, Position.Bias b)
+ {
+ // FIXME: Implement this properly.
+ return 0;
+ }
}
Index: javax/swing/text/PlainView.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/PlainView.java,v
retrieving revision 1.9
diff -u -r1.9 PlainView.java
--- javax/swing/text/PlainView.java 2 Jul 2005 20:32:51 -0000 1.9
+++ javax/swing/text/PlainView.java 2 Aug 2005 09:32:57 -0000
@@ -237,5 +237,23 @@
return span;
}
+
+ /**
+ * Maps coordinates from the <code>View</code>'s space into a position
+ * in the document model.
+ *
+ * @param x the x coordinate in the view space
+ * @param y the y coordinate in the view space
+ * @param a the allocation of this <code>View</code>
+ * @param b the bias to use
+ *
+ * @return the position in the document that corresponds to the screen
+ * coordinates <code>x, y</code>
+ */
+ public int viewToModel(float x, float y, Shape a, Position.Bias b)
+ {
+ // FIXME: Implement this properly.
+ return 0;
+ }
}
Index: javax/swing/text/View.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/View.java,v
retrieving revision 1.14
diff -u -r1.14 View.java
--- javax/swing/text/View.java 29 Jul 2005 09:56:10 -0000 1.14
+++ javax/swing/text/View.java 2 Aug 2005 09:32:57 -0000
@@ -513,4 +513,18 @@
Shape s2 = modelToView(p2, a, b2);
return s1.getBounds().union(s2.getBounds());
}
+
+ /**
+ * Maps coordinates from the <code>View</code>'s space into a position
+ * in the document model.
+ *
+ * @param x the x coordinate in the view space
+ * @param y the y coordinate in the view space
+ * @param a the allocation of this <code>View</code>
+ * @param b the bias to use
+ *
+ * @return the position in the document that corresponds to the screen
+ * coordinates <code>x, y</code>
+ */
+ public abstract int viewToModel(float x, float y, Shape a, Position.Bias b);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [cp-patches] FYI: Implementation of CompositeView and others,
Roman Kennke <=