|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
InvisibleView.java | 0% | 0% | 0% | 0% |
|
1 |
/*
|
|
2 |
* SimplyHTML, a word processor based on Java, HTML and CSS
|
|
3 |
* Copyright (C) 2002 Ulrich Hilger
|
|
4 |
*
|
|
5 |
* This program is free software; you can redistribute it and/or
|
|
6 |
* modify it under the terms of the GNU General Public License
|
|
7 |
* as published by the Free Software Foundation; either version 2
|
|
8 |
* of the License, or (at your option) any later version.
|
|
9 |
*
|
|
10 |
* This program is distributed in the hope that it will be useful,
|
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
* GNU General Public License for more details.
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License
|
|
16 |
* along with this program; if not, write to the Free Software
|
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
18 |
*/
|
|
19 |
|
|
20 |
import javax.swing.text.*;
|
|
21 |
import java.awt.*;
|
|
22 |
|
|
23 |
|
|
24 |
/**
|
|
25 |
* A view to hide HTML tags (e.g. comments)
|
|
26 |
*
|
|
27 |
* @author Ulrich Hilger
|
|
28 |
* @author Light Development
|
|
29 |
* @author <a href="http://www.lightdev.com">http://www.lightdev.com</a>
|
|
30 |
* @author <a href="mailto:info@lightdev.com">info@lightdev.com</a>
|
|
31 |
* @author published under the terms and conditions of the
|
|
32 |
* GNU General Public License,
|
|
33 |
* for details see file gpl.txt in the distribution
|
|
34 |
* package of this software
|
|
35 |
*
|
|
36 |
* @version stage 11, April 27, 2003
|
|
37 |
*/
|
|
38 |
|
|
39 |
public class InvisibleView extends View { |
|
40 |
|
|
41 |
/** indicates whether or not this view is to be shown in its component */
|
|
42 |
boolean isVisible = false; |
|
43 |
|
|
44 |
/**
|
|
45 |
* constructor
|
|
46 |
*/
|
|
47 | 0 |
public InvisibleView(Element e) {
|
48 | 0 |
super(e);
|
49 |
} |
|
50 |
|
|
51 |
/**
|
|
52 |
* Determines the preferred span for this view along an
|
|
53 |
* axis.
|
|
54 |
*
|
|
55 |
* @param axis may be either <code>View.X_AXIS</code> or
|
|
56 |
* <code>View.Y_AXIS</code>
|
|
57 |
* @return the span the view would like to be rendered into.
|
|
58 |
* Typically the view is told to render into the span
|
|
59 |
* that is returned, although there is no guarantee.
|
|
60 |
* The parent may choose to resize or break the view
|
|
61 |
* @see View#getPreferredSpan
|
|
62 |
*/
|
|
63 | 0 |
public float getPreferredSpan(int axis) { |
64 | 0 |
return 0;
|
65 |
} |
|
66 |
|
|
67 |
/**
|
|
68 |
* Determines the maximum span for this view along an
|
|
69 |
* axis.
|
|
70 |
*
|
|
71 |
* @param axis may be either <code>View.X_AXIS</code> or
|
|
72 |
* <code>View.Y_AXIS</code>
|
|
73 |
* @return the maximum span the view can be rendered into
|
|
74 |
* @see View#getPreferredSpan
|
|
75 |
*/
|
|
76 | 0 |
public float getMaximumSpan() { |
77 | 0 |
return 0;
|
78 |
} |
|
79 |
|
|
80 |
/**
|
|
81 |
* Determines the minimum span for this view along an
|
|
82 |
* axis.
|
|
83 |
*
|
|
84 |
* @param axis may be either <code>View.X_AXIS</code> or
|
|
85 |
* <code>View.Y_AXIS</code>
|
|
86 |
* @return the minimum span the view can be rendered into
|
|
87 |
* @see View#getPreferredSpan
|
|
88 |
*/
|
|
89 | 0 |
public float getMinimumSpan() { |
90 | 0 |
return 0;
|
91 |
} |
|
92 |
|
|
93 |
/**
|
|
94 |
* Renders using the given rendering surface and area on that
|
|
95 |
* surface. The view may need to do layout and create child
|
|
96 |
* views to enable itself to render into the given allocation.
|
|
97 |
*
|
|
98 |
* @param g the rendering surface to use
|
|
99 |
* @param allocation the allocated region to render into
|
|
100 |
* @see View#paint
|
|
101 |
*/
|
|
102 | 0 |
public void paint(Graphics g, Shape allocation) { |
103 | 0 |
if (isVisible) {
|
104 |
// paint something here
|
|
105 |
} |
|
106 |
else {
|
|
107 | 0 |
setSize(0, 0); |
108 |
} |
|
109 |
} |
|
110 |
|
|
111 |
/**
|
|
112 |
* Provides a mapping from the view coordinate space to the logical
|
|
113 |
* coordinate space of the model. The <code>biasReturn</code>
|
|
114 |
* argument will be filled in to indicate that the point given is
|
|
115 |
* closer to the next character in the model or the previous
|
|
116 |
* character in the model.
|
|
117 |
*
|
|
118 |
* @param x the X coordinate >= 0
|
|
119 |
* @param y the Y coordinate >= 0
|
|
120 |
* @param a the allocated region in which to render
|
|
121 |
* @return the location within the model that best represents the
|
|
122 |
* given point in the view >= 0. The <code>biasReturn</code>
|
|
123 |
* argument will be
|
|
124 |
* filled in to indicate that the point given is closer to the next
|
|
125 |
* character in the model or the previous character in the model.
|
|
126 |
*/
|
|
127 | 0 |
public int viewToModel(float x, float y, Shape a, Position.Bias[] parm4) { |
128 | 0 |
return 0;
|
129 |
} |
|
130 |
|
|
131 |
/**
|
|
132 |
* Provides a mapping, for a given character,
|
|
133 |
* from the document model coordinate space
|
|
134 |
* to the view coordinate space.
|
|
135 |
*
|
|
136 |
* @param pos the position of the desired character (>=0)
|
|
137 |
* @param a the area of the view, which encompasses the requested character
|
|
138 |
* @param b the bias toward the previous character or the
|
|
139 |
* next character represented by the offset, in case the
|
|
140 |
* position is a boundary of two views; <code>b</code> will have one
|
|
141 |
* of these values:
|
|
142 |
* <ul>
|
|
143 |
* <li> <code>Position.Bias.Forward</code>
|
|
144 |
* <li> <code>Position.Bias.Backward</code>
|
|
145 |
* </ul>
|
|
146 |
* @return the bounding box, in view coordinate space,
|
|
147 |
* of the character at the specified position
|
|
148 |
* @exception BadLocationException if the specified position does
|
|
149 |
* not represent a valid location in the associated document
|
|
150 |
* @exception IllegalArgumentException if <code>b</code> is not one of the
|
|
151 |
* legal <code>Position.Bias</code> values listed above
|
|
152 |
* @see View#viewToModel
|
|
153 |
*/
|
|
154 | 0 |
public Shape modelToView(int pos, Shape a, Position.Bias b) throws javax.swing.text.BadLocationException { |
155 | 0 |
return new Rectangle(0, 0); |
156 |
} |
|
157 |
|
|
158 |
/**
|
|
159 |
* Establishes the parent view for this view. This is
|
|
160 |
* guaranteed to be called before any other methods if the
|
|
161 |
* parent view is functioning properly. This is also
|
|
162 |
* the last method called, since it is called to indicate
|
|
163 |
* the view has been removed from the hierarchy as
|
|
164 |
* well. When this method is called to set the parent to
|
|
165 |
* null, this method does the same for each of its children,
|
|
166 |
* propogating the notification that they have been
|
|
167 |
* disconnected from the view tree. If this is
|
|
168 |
* reimplemented, <code>super.setParent()</code> should
|
|
169 |
* be called.
|
|
170 |
*
|
|
171 |
* @param parent the new parent, or <code>null</code> if the view is
|
|
172 |
* being removed from a parent
|
|
173 |
*/
|
|
174 | 0 |
public void setParent(View parent) { |
175 | 0 |
if (parent != null) { |
176 | 0 |
Container host = parent.getContainer(); |
177 | 0 |
if (host != null) { |
178 | 0 |
isVisible = ((JTextComponent)host).isEditable(); |
179 |
} |
|
180 |
} |
|
181 | 0 |
super.setParent(parent);
|
182 |
} |
|
183 |
|
|
184 |
/**
|
|
185 |
* @return true if the Component is visible.
|
|
186 |
*/
|
|
187 | 0 |
public boolean isVisible() { |
188 | 0 |
return isVisible;
|
189 |
} |
|
190 |
|
|
191 |
} |
|