aboutsummaryrefslogtreecommitdiff
path: root/libjava/javax/swing/text/View.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/javax/swing/text/View.java')
-rw-r--r--libjava/javax/swing/text/View.java153
1 files changed, 104 insertions, 49 deletions
diff --git a/libjava/javax/swing/text/View.java b/libjava/javax/swing/text/View.java
index f9e44a90f54..46f42b50374 100644
--- a/libjava/javax/swing/text/View.java
+++ b/libjava/javax/swing/text/View.java
@@ -1,5 +1,5 @@
/* View.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.
@@ -35,6 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.text;
import java.awt.Container;
@@ -57,91 +58,113 @@ public abstract class View implements SwingConstants
private Element elt;
private View parent;
- /**
+ /**
* Creates a new <code>View</code> instance.
*
* @param elem an <code>Element</code> value
- */
- public View(Element elem)
- {
- elt = elem;
- }
+ */
+ public View(Element elem)
+ {
+ elt = elem;
+ }
public abstract void paint(Graphics g, Shape s);
- public void setParent(View a)
- {
- parent = a;
- }
-
+ public void setParent(View parent)
+ {
+ this.parent = parent;
+ }
+
public View getParent()
- {
+ {
return parent;
- }
-
- public void setSize(int w, int h)
- {
- width = w;
- height = h;
- }
+ }
public Container getContainer()
- {
+ {
+ View parent = getParent();
return parent != null ? parent.getContainer() : null;
- }
-
+ }
+
public Document getDocument()
- {
+ {
return getElement().getDocument();
- }
-
+ }
+
public Element getElement()
- {
+ {
return elt;
- }
+ }
public abstract float getPreferredSpan(int axis);
+
+ public int getResizeWeight(int axis)
+ {
+ return 0;
+ }
+
+ public float getMaximumSpan(int axis)
+ {
+ if (getResizeWeight(axis) <= 0)
+ return getPreferredSpan(axis);
+
+ return Integer.MAX_VALUE;
+ }
+
+ public float getMinimumSpan(int axis)
+ {
+ if (getResizeWeight(axis) <= 0)
+ return getPreferredSpan(axis);
+
+ return Integer.MAX_VALUE;
+ }
+
+ public void setSize(float width, float height)
+ {
+ // The default implementation does nothing.
+ }
public float getAlignment(int axis)
- {
+ {
return 0.5f;
- }
-
+ }
+
public AttributeSet getAttributes()
- {
- return elt.getAttributes();
- }
-
+ {
+ return getElement().getAttributes();
+ }
+
public boolean isVisible()
- {
+ {
return true;
- }
+ }
public int getViewCount()
- {
+ {
return 0;
- }
-
+ }
+
public View getView(int index)
- {
+ {
return null;
- }
+ }
public ViewFactory getViewFactory()
- {
+ {
+ View parent = getParent();
return parent != null ? parent.getViewFactory() : null;
}
public void replace(int offset, int length, View[] views)
- {
+ {
// Default implementation does nothing.
}
public void insert(int offset, View view)
- {
+ {
View[] array = { view };
replace(offset, 1, array);
- }
+ }
public void append(View view)
{
@@ -152,7 +175,7 @@ public abstract class View implements SwingConstants
public void removeAll()
{
replace(0, getViewCount(), null);
- }
+ }
public void remove(int index)
{
@@ -167,12 +190,12 @@ public abstract class View implements SwingConstants
public int getStartOffset()
{
- return elt.getStartOffset();
+ return getElement().getStartOffset();
}
public int getEndOffset()
{
- return elt.getEndOffset();
+ return getElement().getEndOffset();
}
public Shape getChildAllocation(int index, Shape a)
@@ -205,5 +228,37 @@ public abstract class View implements SwingConstants
return null;
}
+
+ /**
+ * @since 1.3
+ */
+ public Graphics getGraphics()
+ {
+ return getContainer().getGraphics();
+ }
+
+ public void preferenceChanged(View child, boolean width, boolean height)
+ {
+ if (parent != null)
+ parent.preferenceChanged(this, width, height);
+ }
+
+ public int getBreakWeight(int axis, float pos, float len)
+ {
+ return BadBreakWeight;
+ }
+
+ public View breakView(int axis, int offset, float pos, float len)
+ {
+ return this;
+ }
+
+ /**
+ * @since 1.3
+ */
+ public int getViewIndex(int pos, Position.Bias b)
+ {
+ return -1;
+ }
}