home *** CD-ROM | disk | FTP | other *** search
- package netscape.application;
-
- import java.net.MalformedURLException;
- import java.net.URL;
- import netscape.util.Enumeration;
- import netscape.util.Hashtable;
-
- public class TextViewHTMLMarkerImp extends TextViewHTMLMarker {
- TextAttachment textAttachmentCache;
-
- public Hashtable attributesForMarker(Hashtable var1, Hashtable var2, TextView var3) {
- if (!super.marker.equals("HR") && !super.marker.equals("IMG")) {
- return var2;
- } else {
- Hashtable var4;
- if (var2 != null && var2.count() > 0) {
- var4 = (Hashtable)TextView.hashtablePool.allocateObject();
- Enumeration var7 = var2.keys();
-
- while(var7.hasMoreElements()) {
- Object var8 = var7.nextElement();
- var4.put(var8, var2.get(var8));
- }
- } else {
- var4 = (Hashtable)TextView.hashtablePool.allocateObject();
- }
-
- TextAttachment var6 = this.textAttachment(var3.baseURL(), var3);
- var4.put("TextAttachmentKey", var6);
- if (super.marker.equals("IMG")) {
- Hashtable var12 = ((TextViewHTMLElement)this).hashtableForHTMLAttributes(super.attributes);
- String var5;
- if (var12 != null && (var5 = (String)var12.get("ALIGN")) != null) {
- int var13 = 0;
- if (var5.equals("TOP")) {
- int var9 = 0;
- Font var11 = (Font)var4.get("FontKey");
- if (var11 == null) {
- var11 = (Font)var3.defaultAttributes().get("FontKey");
- }
-
- if (var11 != null) {
- FontMetrics var10 = new FontMetrics(var11);
- var9 = var10.ascent();
- }
-
- var13 = var6.height() - var9;
- } else if (var5.equals("MIDDLE")) {
- var13 = var6.height() / 2;
- }
-
- var4.put("TextAttachmentBaselineOffsetKey", new Integer(var13));
- }
- }
-
- return var4;
- }
- }
-
- public String prefix(Hashtable var1, char var2) {
- return super.marker.equals("HR") ? "\n\n" : "";
- }
-
- public String string(Hashtable var1) {
- return super.marker.equals("BR") ? "\n" : "@";
- }
-
- private TextAttachment textAttachment(URL var1, TextView var2) {
- if (this.textAttachmentCache == null) {
- if (super.marker.equals("HR")) {
- this.textAttachmentCache = new HRTextAttachment();
- } else if (super.marker.equals("IMG")) {
- int var7 = -1;
- int var8 = -1;
- Hashtable var3 = ((TextViewHTMLElement)this).hashtableForHTMLAttributes(super.attributes);
- String var4;
- if (var3 != null && (var4 = (String)var3.get("SRC")) != null) {
- try {
- String var9 = (String)var3.get("WIDTH");
- if (var9 != null) {
- var7 = Integer.parseInt(var9);
- }
-
- var9 = (String)var3.get("HEIGHT");
- if (var9 != null) {
- var8 = Integer.parseInt(var9);
- }
- } catch (NumberFormatException var11) {
- var8 = -1;
- var7 = -1;
- }
-
- try {
- URL var5 = new URL(var1, var4);
- Bitmap var6;
- if ((var6 = Bitmap.bitmapFromURL(var5)) != null) {
- var6.loadData();
- }
-
- if (var6 != null && var6.isValid()) {
- this.textAttachmentCache = new ImageAttachment(var6);
- }
- } catch (MalformedURLException var10) {
- System.err.println("Malformed URL " + var4);
- }
- }
-
- if (this.textAttachmentCache == null) {
- this.textAttachmentCache = new BrokenImageAttachment();
- }
- }
- }
-
- return this.textAttachmentCache;
- }
- }
-