KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > lobobrowser > html > renderer > RSpacing


1 /*
2     GNU LESSER GENERAL PUBLIC LICENSE
3     Copyright (C) 2006 The Lobo Project
4
5     This library is free software; you can redistribute it and/or
6     modify it under the terms of the GNU Lesser General Public
7     License as published by the Free Software Foundation; either
8     version 2.1 of the License, or (at your option) any later version.
9
10     This library 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 GNU
13     Lesser General Public License for more details.
14
15     You should have received a copy of the GNU Lesser General Public
16     License along with this library; if not, write to the Free Software
17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19     Contact info: xamjadmin@users.sourceforge.net
20 */

21 /*
22  * Created on May 21, 2005
23  */

24 package org.lobobrowser.html.renderer;
25
26 import java.awt.*;
27
28 import org.lobobrowser.html.domimpl.ModelNode;
29
30 class RSpacing extends BaseBoundableRenderable {
31     public RSpacing(ModelNode me, RenderableContainer container, int width, int height) {
32         super(container, me);
33         // Dimensions set when constructed.
34
this.width = width;
35         this.height = height;
36     }
37     
38     protected void invalidateLayoutLocal() {
39     }
40     
41     public boolean onMouseClick(java.awt.event.MouseEvent JavaDoc event, int x, int y) {
42         ModelNode me = this.modelNode;
43         if(me != null) {
44             return HtmlController.getInstance().onMouseClick(me, event, x, y);
45         }
46         else {
47             return true;
48         }
49     }
50
51     public boolean onDoubleClick(java.awt.event.MouseEvent JavaDoc event, int x, int y) {
52         ModelNode me = this.modelNode;
53         if(me != null) {
54             return HtmlController.getInstance().onDoubleClick(me, event, x, y);
55         }
56         else {
57             return true;
58         }
59     }
60
61     public boolean onMousePressed(java.awt.event.MouseEvent JavaDoc event, int x, int y) {
62         ModelNode me = this.modelNode;
63         if(me != null) {
64             return HtmlController.getInstance().onMouseDown(me, event, x, y);
65         }
66         else {
67             return true;
68         }
69     }
70
71     public boolean onMouseReleased(java.awt.event.MouseEvent JavaDoc event, int x, int y) {
72         ModelNode me = this.modelNode;
73         if(me != null) {
74             return HtmlController.getInstance().onMouseUp(me, event, x, y);
75         }
76         else {
77             return true;
78         }
79     }
80     
81     public boolean onMouseDisarmed(java.awt.event.MouseEvent JavaDoc event) {
82         ModelNode me = this.modelNode;
83         if(me != null) {
84             return HtmlController.getInstance().onMouseDisarmed(me, event);
85         }
86         else {
87             return true;
88         }
89     }
90     
91     /* (non-Javadoc)
92      * @see net.sourceforge.xamj.domimpl.markup.Renderable#paint(java.awt.Graphics)
93      */

94     public final void paint(Graphics g) {
95         // Nothing to paint in spacing.
96
}
97     
98     /* (non-Javadoc)
99      * @see org.xamjwg.html.renderer.BoundableRenderable#paintSelection(java.awt.Graphics, boolean, org.xamjwg.html.renderer.RenderablePoint, org.xamjwg.html.renderer.RenderablePoint)
100      */

101     public boolean paintSelection(Graphics g, boolean inSelection, RenderableSpot startPoint, RenderableSpot endPoint) {
102         if(this == startPoint.renderable || this == endPoint.renderable) {
103             if(inSelection) {
104                 return false;
105             }
106         }
107         else if(!inSelection) {
108             return false;
109         }
110         g.setColor(SELECTION_COLOR);
111         g.setXORMode(SELECTION_XOR);
112         g.fillRect(0, 0, this.width, this.height);
113         g.setPaintMode();
114         return true;
115     }
116     
117     public boolean extractSelectionText(StringBuffer JavaDoc buffer, boolean inSelection, RenderableSpot startPoint, RenderableSpot endPoint) {
118         if(this == startPoint.renderable || this == endPoint.renderable) {
119             if(inSelection) {
120                 return false;
121             }
122         }
123         else if(!inSelection) {
124             return false;
125         }
126         return true;
127     }
128     
129     /* (non-Javadoc)
130      * @see org.xamjwg.html.renderer.BoundableRenderable#getRenderable(int, int)
131      */

132     public RenderableSpot getLowestRenderableSpot(int x, int y) {
133         return new RenderableSpot(this, x, y);
134     }
135 }
136
Popular Tags