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 17.10.2004
21 * @author Andreas Prlic
25 package org.biojava.dasobert.das ;
27 //import org.biojava.services.das.registry.*;
28 import org.biojava.dasobert.das.DAS_StylesheetRetrieve;
29 import org.biojava.dasobert.dasregistry.Das1Source;
30 import org.biojava.dasobert.dasregistry.DasCoordinateSystem;
31 import org.biojava.dasobert.dasregistry.DasSource;
32 import java.io.IOException ;
33 import java.text.DateFormat ;
34 import java.text.SimpleDateFormat ;
40 /** Manages all data about a DAS source that SPICE requires */
41 public class SpiceDasSource
48 boolean registered ; // a flag to trace if source comes from registry or from user vonfig
51 public static String DEFAULT_NICKNAME = "MyDASsource";
52 public static String DEFAULT_CAPABILITY = "features";
53 public SpiceDasSource() {
56 status = true ; // default source is actived and used .
57 registered = true ; // default true = source comes from registry
58 setNickname(DEFAULT_NICKNAME);
61 String[] caps = new String[1];
62 caps[0] = DEFAULT_CAPABILITY;
63 setCapabilities(caps);
66 public void loadStylesheet(){
67 DAS_StylesheetRetrieve dsr = new DAS_StylesheetRetrieve();
68 String cmd = getUrl()+"stylesheet";
72 } catch (Exception e){
76 Map[] styles = dsr.retrieve(url);
81 typeStyles = new Map[0];
85 Map[] t3dStyles = dsr.get3DStyle();
86 if ( t3dStyles != null){
87 threeDstyles = t3dStyles;
89 threeDstyles = new Map[0];
93 /** returns the Stylesheet that is provided by a DAS source.
94 * It provides info of how to draw a particular feature.
95 * returns null if not attempt has been made to load the stylesheet.
96 * afterwards it returns a Map[0] or the Map[] containing the style data.
100 public Map[] getStylesheet(){
104 /** get the stylesheet containing the instructions how to paint in 3D.
108 public Map[] get3DStylesheet(){
112 /** a flag if this das source is active
116 public void setStatus(boolean flag) { status = flag ; }
117 public boolean getStatus() { return status ; }
119 public void setRegistered(boolean flag) { registered = flag ; }
120 public boolean getRegistered() { return registered ; }
123 /** convert DasSource to SpiceDasSource */
124 public static SpiceDasSource fromDasSource(DasSource ds) {
125 SpiceDasSource s = new SpiceDasSource();
126 s.setUrl(ds.getUrl());
127 s.setAdminemail(ds.getAdminemail());
128 s.setDescription(ds.getDescription());
129 s.setCoordinateSystem(ds.getCoordinateSystem());
130 s.setCapabilities(ds.getCapabilities());
131 s.setRegisterDate(ds.getRegisterDate());
132 s.setLeaseDate(ds.getLeaseDate());
133 s.setNickname(ds.getNickname());
136 // testcode now part of coordinate system...
137 //s.setTestCode(ds.getTestCode());
139 s.setLabels(ds.getLabels());
140 s.setHelperurl(ds.getHelperurl());
145 public String toString() {
146 String txt = getId() + " " + getNickname() + " " + getUrl() ;