2 * BioJava development code
4 * This code may be freely distributed and modified under the
5 * terms of the GNU Lesser General Public Licence. This should
6 * be distributed with the code. If you do not have a copy,
9 * http://www.gnu.org/copyleft/lesser.html
11 * Copyright for this code is held jointly by the individual
12 * authors. These should be listed in @author doc comments.
14 * For more information on the BioJava project and its aims,
15 * or to join the biojava-l mailing list, visit the home page
18 * http://www.biojava.org/
20 * Created on Aug 3, 2005
23 package org.biojava.dasobert.das;
25 import java.io.InputStream;
28 import java.util.logging.Logger;
30 import javax.xml.parsers.ParserConfigurationException;
31 import javax.xml.parsers.SAXParser;
32 import javax.xml.parsers.SAXParserFactory;
34 import org.xml.sax.InputSource;
35 import org.xml.sax.XMLReader;
37 /** this stores the stylesheet config for a DAS source.
39 * @author Andreas Prlic
42 public class DAS_StylesheetRetrieve {
43 static Logger logger = Logger.getLogger("org.biojava.spice");
48 public DAS_StylesheetRetrieve() {
53 /** retrieve a StyleSheet from a URL
54 * The style sheet is represented as a Map[],
55 * where each Map contains the description of how to draw a features of a particular type.
58 public Map[] retrieve(URL dasStylesheetRequest){
60 logger.finest("requesting stylesheet from " + dasStylesheetRequest);
62 InputStream inStream = null;
65 HttpURLConnection huc = DAS_FeatureRetrieve.openHttpURLConnection(dasStylesheetRequest);
67 logger.finest("got connection: "+huc.getResponseMessage());
68 //String contentEncoding = huc.getContentEncoding();
69 inStream = huc.getInputStream();
72 SAXParserFactory spfactory =
73 SAXParserFactory.newInstance();
75 spfactory.setValidating(false);
77 SAXParser saxParser = null ;
81 spfactory.newSAXParser();
82 } catch (ParserConfigurationException e) {
86 DAS_Stylesheet_Handler cont_handle = new DAS_Stylesheet_Handler() ;
87 XMLReader xmlreader = saxParser.getXMLReader();
89 xmlreader.setContentHandler(cont_handle);
90 xmlreader.setErrorHandler(new org.xml.sax.helpers.DefaultHandler());
91 InputSource insource = new InputSource() ;
92 insource.setByteStream(inStream);
95 xmlreader.parse(insource);
96 Map[] typeMap = cont_handle.getTypeStyles();
98 t3DMap = cont_handle.get3DStyles();
101 } catch (Exception e) {
102 logger.finest(e.getMessage());
108 public Map[] get3DStyle(){