From c47fa64d719ab7f5062a87fbf5cc55a7916c5c53 Mon Sep 17 00:00:00 2001 From: Jeremy Laine Date: Mon, 1 Dec 2003 19:18:34 +0000 Subject: [PATCH] added custom code --- ekit/com/hexidec/ekit/EkitApplet.java | 2 +- ekit/com/hexidec/ekit/EkitCore.java | 28 +++++++++++----------- .../ekit/component/ExtendedHTMLEditorKit.java | 16 ++++++++++--- .../hexidec/ekit/component/RelativeImageView.java | 9 ++++--- 4 files changed, 34 insertions(+), 21 deletions(-) diff --git a/ekit/com/hexidec/ekit/EkitApplet.java b/ekit/com/hexidec/ekit/EkitApplet.java index 9400970..e7e9201 100644 --- a/ekit/com/hexidec/ekit/EkitApplet.java +++ b/ekit/com/hexidec/ekit/EkitApplet.java @@ -86,7 +86,7 @@ public class EkitApplet extends JApplet boolean showMenuIcons = true; if(this.getParameter("MENUICONS") != null) { showMenuIcons = this.getParameter("MENUICONS").equalsIgnoreCase("true"); } - ekitCore = new EkitCore(sRawDocument, urlCSS, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, base64); + ekitCore = new EkitCore(sRawDocument, urlCSS, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, base64, this.getParameter("BASEURL")); /* Obtain image servlet information */ ekitCore.setServletURL(this.getParameter("SERVLETURL")); diff --git a/ekit/com/hexidec/ekit/EkitCore.java b/ekit/com/hexidec/ekit/EkitCore.java index ef23e15..07df9cb 100644 --- a/ekit/com/hexidec/ekit/EkitCore.java +++ b/ekit/com/hexidec/ekit/EkitCore.java @@ -286,7 +286,7 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc * @param base64 [boolean] Specifies whether the raw document is Base64 encoded or not. * @param debugMode [boolean] Specifies whether to show the Debug menu or not. */ - public EkitCore(String sDocument, String sStyleSheet, String sRawDocument, URL urlStyleSheet, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, String sLanguage, String sCountry, boolean base64, boolean debugMode) + public EkitCore(String sDocument, String sStyleSheet, String sRawDocument, URL urlStyleSheet, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, String sLanguage, String sCountry, boolean base64, boolean debugMode, String baseurl) { super(); @@ -330,7 +330,7 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc /* Create the editor kit, document, and stylesheet */ jtpMain = new JTextPane(); - htmlKit = new ExtendedHTMLEditorKit(); + htmlKit = new ExtendedHTMLEditorKit(baseurl); htmlDoc = (ExtendedHTMLDocument)(htmlKit.createDefaultDocument()); styleSheet = htmlDoc.getStyleSheet(); htmlKit.setDefaultCursor(new Cursor(Cursor.TEXT_CURSOR)); @@ -741,7 +741,7 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc */ public EkitCore(String sDocument, String sStyleSheet, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, String sLanguage, String sCountry, boolean base64) { - this(sDocument, sStyleSheet, null, null, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, base64, false); + this(sDocument, sStyleSheet, null, null, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, base64, false,""); } /** Default Language Constructor @@ -753,7 +753,7 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc */ public EkitCore(String sDocument, String sStyleSheet, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, boolean base64) { - this(sDocument, sStyleSheet, null, null, showViewSource, showMenuIcons, editModeExclusive, null, null, base64, false); + this(sDocument, sStyleSheet, null, null, showViewSource, showMenuIcons, editModeExclusive, null, null, base64, false, ""); } /** Raw/Base64 Document & Style Sheet URL Constructor (Ideal for EkitApplet) @@ -765,9 +765,9 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc * @param sLanguage [String] The language portion of the Internationalization Locale to run Ekit in. * @param sCountry [String] The country portion of the Internationalization Locale to run Ekit in. */ - public EkitCore(String sRawDocument, URL urlStyleSheet, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, String sLanguage, String sCountry, boolean base64) + public EkitCore(String sRawDocument, URL urlStyleSheet, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, String sLanguage, String sCountry, boolean base64, String baseurl) { - this(null, null, sRawDocument, urlStyleSheet, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, base64, false); + this(null, null, sRawDocument, urlStyleSheet, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, base64, false, baseurl); } /** Document Constructor @@ -780,7 +780,7 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc */ public EkitCore(String sRawDocument, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, String sLanguage, String sCountry, boolean base64) { - this(null, null, sRawDocument, null, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, base64, false); + this(null, null, sRawDocument, null, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, base64, false,""); } /** Default Language & Document Constructor @@ -791,7 +791,7 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc */ public EkitCore(String sRawDocument, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, boolean base64) { - this(null, null, sRawDocument, null, showViewSource, showMenuIcons, editModeExclusive, null, null, base64, false); + this(null, null, sRawDocument, null, showViewSource, showMenuIcons, editModeExclusive, null, null, base64, false,""); } /** Flags & Language Constructor @@ -803,7 +803,7 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc */ public EkitCore(boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, String sLanguage, String sCountry) { - this(null, null, null, null, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, false, false); + this(null, null, null, null, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, false, false,""); } /** Flags Constructor @@ -813,7 +813,7 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc */ public EkitCore(boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive) { - this(null, null, null, null, showViewSource, showMenuIcons, editModeExclusive, null, null, false, false); + this(null, null, null, null, showViewSource, showMenuIcons, editModeExclusive, null, null, false, false,""); } /** Language & Debug Constructor @@ -823,7 +823,7 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc */ public EkitCore(String sLanguage, String sCountry, boolean debugMode) { - this(null, null, null, null, false, true, true, sLanguage, sCountry, false, debugMode); + this(null, null, null, null, false, true, true, sLanguage, sCountry, false, debugMode,""); } /** Language Constructor @@ -832,7 +832,7 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc */ public EkitCore(String sLanguage, String sCountry) { - this(null, null, null, null, false, true, true, sLanguage, sCountry, false, false); + this(null, null, null, null, false, true, true, sLanguage, sCountry, false, false,""); } /** Debug Constructor @@ -840,14 +840,14 @@ public class EkitCore extends JPanel implements ActionListener, KeyListener, Doc */ public EkitCore(boolean debugMode) { - this(null, null, null, null, false, true, true, null, null, false, debugMode); + this(null, null, null, null, false, true, true, null, null, false, debugMode,""); } /** Empty Constructor */ public EkitCore() { - this(null, null, null, null, false, true, true, null, null, false, false); + this(null, null, null, null, false, true, true, null, null, false, false,""); } /* ActionListener method */ diff --git a/ekit/com/hexidec/ekit/component/ExtendedHTMLEditorKit.java b/ekit/com/hexidec/ekit/component/ExtendedHTMLEditorKit.java index bb2b14a..07c1122 100644 --- a/ekit/com/hexidec/ekit/component/ExtendedHTMLEditorKit.java +++ b/ekit/com/hexidec/ekit/component/ExtendedHTMLEditorKit.java @@ -44,17 +44,24 @@ import javax.swing.text.Document; public class ExtendedHTMLEditorKit extends HTMLEditorKit { + private String BaseUrl = ""; + /** Constructor */ public ExtendedHTMLEditorKit() { } + + public ExtendedHTMLEditorKit(String baseurl) + { + BaseUrl = baseurl; + } /** Method for returning a ViewFactory which handles the image rendering. */ public ViewFactory getViewFactory() { - return new HTMLFactoryExtended(); + return new HTMLFactoryExtended(BaseUrl); } /* WACKY GERMAN CODE */ @@ -76,10 +83,13 @@ public class ExtendedHTMLEditorKit extends HTMLEditorKit */ public static class HTMLFactoryExtended extends HTMLFactory implements ViewFactory { + private String BaseUrl; + /** Constructor */ - public HTMLFactoryExtended() + public HTMLFactoryExtended(String baseurl) { + BaseUrl = baseurl; } /** Method to handle IMG tags and @@ -93,7 +103,7 @@ public class ExtendedHTMLEditorKit extends HTMLEditorKit HTML.Tag tagType = (HTML.Tag)obj; if(tagType == HTML.Tag.IMG) { - return new RelativeImageView(elem); + return new RelativeImageView(elem,BaseUrl); } } return super.create(elem); diff --git a/ekit/com/hexidec/ekit/component/RelativeImageView.java b/ekit/com/hexidec/ekit/component/RelativeImageView.java index 95adcee..6ef7b6c 100644 --- a/ekit/com/hexidec/ekit/component/RelativeImageView.java +++ b/ekit/com/hexidec/ekit/component/RelativeImageView.java @@ -100,15 +100,17 @@ public class RelativeImageView extends View implements ImageObserver, MouseListe private Component fComponent; private Point fGrowBase; // base of drag while growing image private boolean fGrowProportionally; // should grow be proportional? + private String BaseUrl; private boolean bLoading; // set to true while the receiver is locked, to indicate the reciever is loading the image. This is used in imageUpdate. /** Constructor * Creates a new view that represents an IMG element. * @param elem the element to create a view for */ - public RelativeImageView(Element elem) + public RelativeImageView(Element elem,String baseurl) { super(elem); + BaseUrl = baseurl; initialize(elem); StyleSheet sheet = getStyleSheet(); attr = sheet.getViewAttributes(this); @@ -131,7 +133,7 @@ public class RelativeImageView extends View implements ImageObserver, MouseListe fElement = elem; // request image from document's cache AttributeSet attr = elem.getAttributes(); - if(isURL()) + if(true || isURL()) { URL src = getSourceURL(); if(src != null) @@ -358,9 +360,10 @@ public class RelativeImageView extends View implements ImageObserver, MouseListe { return null; } - URL reference = ((HTMLDocument)getDocument()).getBase(); + //URL reference = ((HTMLDocument)getDocument()).getBase(); try { + URL reference = new URL(BaseUrl); URL u = new URL(reference,src); return u; } -- 2.1.4