--- /dev/null
+/*
+ * BioJava development code
+ *
+ * This code may be freely distributed and modified under the
+ * terms of the GNU Lesser General Public Licence. This should
+ * be distributed with the code. If you do not have a copy,
+ * see:
+ *
+ * http://www.gnu.org/copyleft/lesser.html
+ *
+ * Copyright for this code is held jointly by the individual
+ * authors. These should be listed in @author doc comments.
+ *
+ * For more information on the BioJava project and its aims,
+ * or to join the biojava-l mailing list, visit the home page
+ * at:
+ *
+ * http://www.biojava.org/
+ *
+ * Created on 17.10.2004
+ * @author Andreas Prlic
+ *
+ */
+
+package org.biojava.dasobert.das ;
+
+//import org.biojava.services.das.registry.*;
+import org.biojava.dasobert.das.DAS_StylesheetRetrieve;
+import org.biojava.dasobert.dasregistry.Das1Source;
+import org.biojava.dasobert.dasregistry.DasCoordinateSystem;
+import org.biojava.dasobert.dasregistry.DasSource;
+import java.io.IOException ;
+import java.text.DateFormat ;
+import java.text.SimpleDateFormat ;
+import java.util.*;
+
+
+import java.net.URL;
+
+/** Manages all data about a DAS source that SPICE requires */
+public class SpiceDasSource
+extends Das1Source
+
+{
+
+
+ boolean status ;
+ boolean registered ; // a flag to trace if source comes from registry or from user vonfig
+ Map[] typeStyles;
+ Map[] threeDstyles;
+ public static String DEFAULT_NICKNAME = "MyDASsource";
+ public static String DEFAULT_CAPABILITY = "features";
+ public SpiceDasSource() {
+ super();
+
+ status = true ; // default source is actived and used .
+ registered = true ; // default true = source comes from registry
+ setNickname(DEFAULT_NICKNAME);
+ typeStyles = null;
+ threeDstyles = null;
+ String[] caps = new String[1];
+ caps[0] = DEFAULT_CAPABILITY;
+ setCapabilities(caps);
+ }
+
+ public void loadStylesheet(){
+ DAS_StylesheetRetrieve dsr = new DAS_StylesheetRetrieve();
+ String cmd = getUrl()+"stylesheet";
+ URL url = null;
+ try {
+ url = new URL(cmd);
+ } catch (Exception e){
+ e.printStackTrace();
+ return ;
+ }
+ Map[] styles = dsr.retrieve(url);
+
+ if ( styles != null){
+ typeStyles = styles;
+ } else {
+ typeStyles = new Map[0];
+ }
+
+
+ Map[] t3dStyles = dsr.get3DStyle();
+ if ( t3dStyles != null){
+ threeDstyles = t3dStyles;
+ } else {
+ threeDstyles = new Map[0];
+ }
+ }
+
+ /** returns the Stylesheet that is provided by a DAS source.
+ * It provides info of how to draw a particular feature.
+ * returns null if not attempt has been made to load the stylesheet.
+ * afterwards it returns a Map[0] or the Map[] containing the style data.
+ *
+ * @return
+ */
+ public Map[] getStylesheet(){
+ return typeStyles;
+ }
+
+ /** get the stylesheet containing the instructions how to paint in 3D.
+ *
+ * @return
+ */
+ public Map[] get3DStylesheet(){
+ return threeDstyles;
+ }
+
+ /** a flag if this das source is active
+ * or
+ * @param flag
+ */
+ public void setStatus(boolean flag) { status = flag ; }
+ public boolean getStatus() { return status ; }
+
+ public void setRegistered(boolean flag) { registered = flag ; }
+ public boolean getRegistered() { return registered ; }
+
+
+ /** convert DasSource to SpiceDasSource */
+ public static SpiceDasSource fromDasSource(DasSource ds) {
+ SpiceDasSource s = new SpiceDasSource();
+ s.setUrl(ds.getUrl());
+ s.setAdminemail(ds.getAdminemail());
+ s.setDescription(ds.getDescription());
+ s.setCoordinateSystem(ds.getCoordinateSystem());
+ s.setCapabilities(ds.getCapabilities());
+ s.setRegisterDate(ds.getRegisterDate());
+ s.setLeaseDate(ds.getLeaseDate());
+ s.setNickname(ds.getNickname());
+
+
+ // testcode now part of coordinate system...
+ //s.setTestCode(ds.getTestCode());
+ s.setId(ds.getId());
+ s.setLabels(ds.getLabels());
+ s.setHelperurl(ds.getHelperurl());
+ return s;
+ }
+
+
+ public String toString() {
+ String txt = getId() + " " + getNickname() + " " + getUrl() ;
+ return txt;
+ }
+
+
+}