summaryrefslogtreecommitdiff
path: root/javax/swing/text/View.java
blob: 249a1e6e9dfbf390f0b39aa3c66a806267604193 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package javax.swing.text;

import java.awt.*;
import javax.swing.*;
import java.util.*;

public abstract class View implements SwingConstants
{
    static int BadBreakWeight;    
    static int ExcellentBreakWeight;
    static int ForcedBreakWeight;
    static int GoodBreakWeight;

    final static int X_AXIS = 0;
    final static int Y_AXIS = 1;
    
    float width, height;
    Element elt;
    View parent;


    Vector v = new Vector();

    int getViewCount() 
    {
	return v.size();
    }

    View getView(int a)
    {
	return (View) v.get(a);
    }
    
    void remove(int i)
    {
	v.removeElementAt(i);
    }
    
    void insert(int off, View view)
    {
	v.insertElementAt(view, off);	
    }	    
    void append(View view)
    {
	v.addElement(view);
    }
	
    void paint(Graphics g, Shape allocation)
    {
	System.out.println("view.paint() !!!!");
    }

    void setParent(View a)
    {
	parent = a;
    }
    View getParent()
    {
	return parent;
    }
    
    void setSize(int w, int h)
    {
	width  = w;
	height = h;
    }

    View(Element elem)
    {
	elt = elem;
    }

    Document getDocument()
    {
	return getElement().getDocument();
    }
    
    Element getElement()
    {
        return elt;
    }

    float getPreferredSpan(int a)
    {
	switch (a)
	    {
	    case X_AXIS:  return width;
	    case Y_AXIS:  return height;
	    default:
		{
		    System.err.println("I sure wish Java had enums !!! ");
		    return 0;
		}
	    }
    }
}