1 21 24 package org.lobobrowser.html.renderer; 25 import java.awt.*; 26 27 import org.lobobrowser.html.domimpl.ModelNode; 28 import org.lobobrowser.html.style.RenderState; 29 30 class RBlank extends BaseBoundableRenderable { 31 public final int ascentPlusLeading; 33 private final FontMetrics fontMetrics; 34 35 public RBlank(ModelNode me, FontMetrics fm, RenderableContainer container, int ascentPlusLeading, int width, int height) { 36 super(container, me); 37 this.fontMetrics = fm; 38 this.ascentPlusLeading = ascentPlusLeading; 39 this.width = width; 41 this.height = height; 42 } 43 44 protected void invalidateLayoutLocal() { 45 } 46 47 public boolean onMouseClick(java.awt.event.MouseEvent event, int x, int y) { 48 ModelNode me = this.modelNode; 49 if(me != null) { 50 return HtmlController.getInstance().onMouseClick(me, event, x, y); 51 } 52 else { 53 return true; 54 } 55 } 56 57 public boolean onDoubleClick(java.awt.event.MouseEvent event, int x, int y) { 58 ModelNode me = this.modelNode; 59 if(me != null) { 60 return HtmlController.getInstance().onDoubleClick(me, event, x, y); 61 } 62 else { 63 return true; 64 } 65 } 66 67 public boolean onMousePressed(java.awt.event.MouseEvent event, int x, int y) { 68 ModelNode me = this.modelNode; 69 if(me != null) { 70 return HtmlController.getInstance().onMouseDown(me, event, x, y); 71 } 72 else { 73 return true; 74 } 75 } 76 77 public boolean onMouseReleased(java.awt.event.MouseEvent event, int x, int y) { 78 ModelNode me = this.modelNode; 79 if(me != null) { 80 return HtmlController.getInstance().onMouseUp(me, event, x, y); 81 } 82 else { 83 return true; 84 } 85 } 86 87 public boolean onMouseDisarmed(java.awt.event.MouseEvent event) { 88 ModelNode me = this.modelNode; 89 if(me != null) { 90 return HtmlController.getInstance().onMouseDisarmed(me, event); 91 } 92 else { 93 return true; 94 } 95 } 96 97 100 public final void paint(Graphics g) { 101 RenderState rs = this.modelNode.getRenderState(); 102 Color bkg = rs.getTextBackgroundColor(); 103 if(bkg != null) { 104 Color oldColor = g.getColor(); 105 try { 106 g.setColor(bkg); 107 g.fillRect(0, 0, this.width, this.height); 108 } finally { 109 g.setColor(oldColor); 110 } 111 } 112 int td = rs.getTextDecorationMask(); 113 if(td != 0) { 114 if((td & RenderState.MASK_TEXTDECORATION_UNDERLINE) != 0) { 115 int lineOffset = this.ascentPlusLeading + 2; 116 g.drawLine(0, lineOffset, this.width, lineOffset); 117 } 118 if ((td & RenderState.MASK_TEXTDECORATION_LINE_THROUGH) != 0) { 119 FontMetrics fm = this.fontMetrics; 120 int lineOffset = fm.getLeading() + (fm.getAscent() + fm.getDescent()) / 2; 121 g.drawLine(0, lineOffset, this.width, lineOffset); 122 } 123 if ((td & RenderState.MASK_TEXTDECORATION_OVERLINE) != 0) { 124 int lineOffset = this.fontMetrics.getLeading(); 125 g.drawLine(0, lineOffset, this.width, lineOffset); 126 } 127 if ((td & RenderState.MASK_TEXTDECORATION_BLINK) != 0) { 128 } 130 } 131 Color over = rs.getOverlayColor(); 132 if(over != null) { 133 Color oldColor = g.getColor(); 134 try { 135 g.setColor(over); 136 g.fillRect(0, 0, width, height); 137 } finally { 138 g.setColor(oldColor); 139 } 140 } 141 } 142 143 146 public boolean paintSelection(Graphics g, boolean inSelection, RenderableSpot startPoint, RenderableSpot endPoint) { 147 if(this == startPoint.renderable || this == endPoint.renderable) { 148 if(inSelection) { 149 return false; 150 } 151 } 152 else if(!inSelection) { 153 return false; 154 } 155 g.setColor(SELECTION_COLOR); 156 g.setXORMode(SELECTION_XOR); 157 g.fillRect(0, 0, this.width, this.height); 158 g.setPaintMode(); 159 return true; 160 } 161 162 public boolean extractSelectionText(StringBuffer buffer, boolean inSelection, RenderableSpot startPoint, RenderableSpot endPoint) { 163 if(this == startPoint.renderable || this == endPoint.renderable) { 164 if(inSelection) { 165 return false; 166 } 167 } 168 else if(!inSelection) { 169 return false; 170 } 171 buffer.append(' '); 172 return true; 173 } 174 175 178 public RenderableSpot getLowestRenderableSpot(int x, int y) { 179 return new RenderableSpot(this, x, y); 180 } 181 } 182 | Popular Tags |