diff options
Diffstat (limited to 'libjava/classpath/javax/swing/text/ComponentView.java')
-rw-r--r-- | libjava/classpath/javax/swing/text/ComponentView.java | 200 |
1 files changed, 145 insertions, 55 deletions
diff --git a/libjava/classpath/javax/swing/text/ComponentView.java b/libjava/classpath/javax/swing/text/ComponentView.java index f6feda21513..16112c8f4de 100644 --- a/libjava/classpath/javax/swing/text/ComponentView.java +++ b/libjava/classpath/javax/swing/text/ComponentView.java @@ -1,5 +1,5 @@ /* ComponentView.java -- - Copyright (C) 2002, 2004 Free Software Foundation, Inc. + Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -41,65 +41,125 @@ import java.awt.Component; import java.awt.Graphics; import java.awt.Shape; +import javax.swing.SwingConstants; + +/** + * A {@link View} implementation that is able to render arbitrary + * {@link Component}s. This uses the attribute + * {@link StyleConstants#ComponentAttribute} to determine the + * <code>Component</code> that should be rendered. This <code>Component</code> + * becomes a direct child of the <code>JTextComponent</code> that contains + * this <code>ComponentView</code>, so this view must not be shared between + * multiple <code>JTextComponent</code>s. + * + * @author original author unknown + * @author Roman Kennke (roman@kennke.org) + */ +// FIXME: This class is a complete stub and needs to be implemented properly. public class ComponentView extends View { - public ComponentView(Element elem) - { - super(elem); - } - - protected Component createComponent() - { - return null; - } - - public float getAlignment(int axis) - { - return 0; - } - - public final Component getComponent() - { - return null; - } - - public float getMaximumSpan(int axis) - { - return 0; - } - - public float getMinimumSpan(int axis) - { - return 0; - } - - public float getPreferredSpan(int axis) - { - return 0; - } - - public Shape modelToView(int pos, Shape a, Position.Bias b) - throws BadLocationException - { - return null; - } - - public void paint(Graphics g, Shape a) - { - } + /** + * Creates a new instance of <code>ComponentView</code> for the specified + * <code>Element</code>. + * + * @param elem the element that this <code>View</code> is rendering + */ + public ComponentView(Element elem) + { + super(elem); + } + + /** + * Creates the <code>Component</code> that this <code>View</code> is + * rendering. The <code>Component</code> is determined using + * the {@link StyleConstants#ComponentAttribute} of the associated + * <code>Element</code>. + * + * @return the component that is rendered + */ + protected Component createComponent() + { + return StyleConstants.getComponent(getElement().getAttributes()); + } + + /** + * Returns the alignment of this <code>View</code> along the specified axis. + * + * @param axis either {@link View#X_AXIS} or {@link View#Y_AXIS} + * + * @return the alignment of this <code>View</code> along the specified axis + */ + public float getAlignment(int axis) + { + return 0; + } + + /** + * Returns the <code>Component</code> that is rendered by this + * <code>ComponentView</code>. + * + * @return the <code>Component</code> that is rendered by this + * <code>ComponentView</code> + */ + public final Component getComponent() + { + return null; + } + + /** + * Returns the maximum span of this <code>View</code> along the specified + * axis. + * + * This will return {@link Component#getMaximumSize()} for the specified + * axis. + * + * @return the maximum span of this <code>View</code> along the specified + * axis + */ + public float getMaximumSpan(int axis) + { + return 0; + } + + public float getMinimumSpan(int axis) + { + // TODO: Implement this properly. + return 0; + } + + public float getPreferredSpan(int axis) + { + // TODO: Implement this properly. + return 0; + } + + public Shape modelToView(int pos, Shape a, Position.Bias b) + throws BadLocationException + { + // TODO: Implement this properly. + return null; + } - public void setParent(View p) - { - } + public void paint(Graphics g, Shape a) + { + // TODO: Implement this properly. + } + + public void setParent(View p) + { + // TODO: Implement this properly. + } - public void setSize(float width, float height) - { - } + public void setSize(float width, float height) + { + // TODO: Implement this properly. + } - public int viewToModel(float x, float y, Shape a, Position.Bias[] bias) - { - return 0; - } + public int viewToModel(float x, float y, Shape a, Position.Bias[] bias) + { + // TODO: Implement this properly. + return 0; + } /** * Maps coordinates from the <code>View</code>'s space into a position @@ -118,4 +178,34 @@ public class ComponentView extends View // FIXME: Implement this properly. return 0; } + + /** + * 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 {@link SwingConstants#NORTH}, + * {@link SwingConstants#SOUTH}, {@link SwingConstants#WEST} or + * {@link SwingConstants#EAST} + * @param biasRet an array of {@link 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."); + } } |