001 package nl.cwi.sen1.visbase.factbrowser.data; 002 003 import java.util.ArrayList; 004 import java.util.Collections; 005 import java.util.Observable; 006 007 /** 008 * This class represents the FactTypes which are used within facts. It will be 009 * used to couple FactTypes to visualisation plugins. This class acts as a 010 * container in which the visualisation plugins are added. When a new 011 * visualisation is added all the member Facts are notified so they can update 012 * there view. 013 * 014 * @author Renze de Vries 015 * @date 14-02-2007 016 * 017 */ 018 public class RStoreFactType extends Observable { 019 private String factType; 020 021 private ArrayList<VisualisationPlugin> visualisationPlugins; 022 023 /** 024 * This is the default constructor and is mainly used as a failsafe. The 025 * constructor to use is the following: RStoreFactType(String factType) 026 * 027 * @author Renze de Vries 028 * @date 14-02-2007 029 */ 030 public RStoreFactType() { 031 factType = ""; 032 visualisationPlugins = new ArrayList<VisualisationPlugin>(); 033 } 034 035 /** 036 * The constructor with the factType which looks for example like this: 037 * <str, str> or something similar. 038 * 039 * @param factType 040 * The FactType 041 * 042 * @author Renze de Vries 043 * @date 14-02-2007 044 */ 045 public RStoreFactType(String factType) { 046 this.factType = factType; 047 visualisationPlugins = new ArrayList<VisualisationPlugin>(); 048 } 049 050 /** 051 * Return the FactType string for comparison elsewhere 052 * 053 * @return The String FactType 054 * 055 * @author Renze de Vries 056 * @date 14-02-2007 057 */ 058 public String getFactType() { 059 return factType; 060 } 061 062 /** 063 * This method makes it possible to add a visualisation plugin to the 064 * container. When a plugin is added notify all the observing Facts. 065 * When the new VisalisationPlugin is added to the container we need to 066 * resort the container. This is so the VisualisationPlguins are always 067 * displayed in the same order. 068 * 069 * @param visPlugin 070 * The plugin to add to the container. 071 * 072 * @author Renze de Vries 073 * @date 14-02-2007 074 */ 075 public void addVisualisationPlugin(VisualisationPlugin visPlugin) { 076 077 //check if the visualisationPlugin is not already present 078 if(!visualisationPlugins.contains(visPlugin)) 079 { 080 visualisationPlugins.add(visPlugin); 081 } 082 083 Collections.sort(visualisationPlugins); 084 085 this.setChanged(); 086 this.notifyObservers(); 087 } 088 089 /** 090 * This method returns the list with all the visualisation plugins 091 * 092 * @return The List with visualisation plugins 093 * 094 * @author Renze de Vries 095 * @date 14-02-2007 096 */ 097 public ArrayList<VisualisationPlugin> getVisualisationPlugins() { 098 return visualisationPlugins; 099 } 100 101 }