001    package jigcell.compare.ui;
002    
003    import java.net.URL;
004    import jigcell.compare.IComponentDescription;
005    
006    /**
007     * Description for one of the Comparator components.  The description is loaded from an URL and displayed as HTML text.
008     *
009     * <p>
010     * This code is licensed under the DARPA BioCOMP Open Source License.  See LICENSE for more details.
011     * </p>
012     *
013     * @author Nicholas Allen
014     */
015    
016    public class HTMLComponentDescription implements IComponentDescription {
017    
018       /**
019        * Width of the HTML viewer
020        */
021    
022       protected int width;
023    
024       /**
025        * Cached copy of the description
026        */
027    
028       protected String resource;
029    
030       /**
031        * Location of the component description
032        */
033    
034       protected URL location;
035    
036       /**
037        * Creates a new component description.
038        *
039        * @param resource Description resource
040        * @param width Width of HTML viewer
041        */
042    
043       public HTMLComponentDescription (String resource, int width) {
044          this.resource = resource;
045          this.width = width;
046       }
047    
048       /**
049        * Creates a new component description.
050        *
051        * @param location URL for resource
052        * @param width Width of HTML viewer
053        */
054    
055       public HTMLComponentDescription (URL location, int width) {
056          this.location = location;
057          this.width = width;
058       }
059    
060       /**
061        * Creates a display for the component description.
062        */
063    
064       public synchronized Object createDisplay () {
065          return location == null ? InterfaceBuilder.createHTMLViewer (resource, width) : InterfaceBuilder.createHTMLViewer (location, width);
066       }
067    
068       /**
069        * The location of the component description.
070        */
071    
072       public URL getLocation () {
073          return location;
074       }
075    
076       /**
077        * Sets the location of the component description.
078        *
079        * @param location Location
080        */
081    
082       public synchronized void setLocation (URL location) {
083          this.location = location;
084       }
085    }