package com.mockturtlesolutions.jpHtools.database;
//Copyright (C) 2005 Daniel P. Dougherty
//
//This library is free software; you can redistribute it and/or
//modify it under the terms of the GNU Lesser General Public
//License as published by the Free Software Foundation; either
//version 2.1 of the License, or (at your option) any later version.
//
//This library is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
//Lesser General Public License for more details.
//
//You should have received a copy of the GNU Lesser General Public
//License along with this library; if not, write to the Free Software
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
//$Id: pHtoolsPrefs.java,v 1.5 2007/07/14 22:07:45 mock_turtle Exp $
import java.io.*;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.awt.Color;
import java.awt.Font;
import java.util.HashSet;
import java.util.Set;
import java.util.Iterator;
import com.mockturtlesolutions.snifflib.reposconfig.database.*;
import com.mockturtlesolutions.snifflib.graphics.*;
import com.mockturtlesolutions.snifflib.guitools.components.DomainNameFilter;
import com.mockturtlesolutions.snifflib.guitools.components.LeastPartDomainNameFilter;
import com.mockturtlesolutions.snifflib.sqldig.database.SQLConfig;
/**
Instantiation of this class requires successful aquisition of the current
system configuration. A class instance can be accessed to provide infomation
about the configuration.
*/
public class pHtoolsPrefs extends SQLConfig implements SLLineSegmentRendererPreferences, SLAxesPreferences, SLFigurePreferences, SLLegendPreferences
{
public pHtoolsPrefs()
{
this.ConfigEnvironmentVariable="PHTOOLSPREFS";
this.UsrConfigFile=(String)System.getProperty("user.home").concat(File.separator).concat(".mypHtoolsprefs"); //User-specific configuration.
this.SysConfigFile = System.getenv(this.ConfigEnvironmentVariable);
this.setSplitString(",");
}
public HashSet getFileChooserConfigs()
{
HashSet out = super.getFileChooserConfigs();
out.add("iconmapfile");
return(out);
}
public HashSet getDirectoryChooserConfigs()
{
HashSet out = super.getFileChooserConfigs();
out.add("bufferdescriptiondirectory");
out.add("reportdescriptiondirectory");
return(out);
}
public HashSet getDomainNameFilterConfigs()
{
HashSet out = super.getDomainNameFilterConfigs();
out.add("legenddomainnamefilter");
return(out);
}
public HashSet getIntegerConfigs()
{
HashSet out = super.getIntegerConfigs();
out.add("linethickness");
out.add("axeslinethickness");
out.add("linemarkersize");
return(out);
}
public HashSet getColorConfigs()
{
HashSet out = super.getColorConfigs();
out.add("figurebackgroundcolor");
out.add("axesbackgroundcolor");
out.add("axestitlecolor");
out.add("axescolor");
out.add("axesxlabelcolor");
out.add("axesylabelcolor");
out.add("axeszlabelcolor");
out.add("legendfontcolor");
return(out);
}
public HashSet getTrueFalseConfigs()
{
HashSet out = super.getTrueFalseConfigs();
out.add("axeson");
out.add("axesgridon");
out.add("axesboxon");
return(out);
}
public HashSet getFontConfigs()
{
HashSet out = super.getFontConfigs();
out.add("axesxlabelfont");
out.add("axesylabelfont");
out.add("axeszlabelfont");
out.add("axesfont");
out.add("axestitlefont");
out.add("legendfont");
return(out);
}
public LinkedHashMap getDefaultConfig()
{
LinkedHashMap configmap = new LinkedHashMap();
configmap.put("bufferdescriptiondirectory",System.getProperty("user.home").concat(File.separator).concat(".pHtoolsBufferDescriptionTemplates"));
configmap.put("reportdescriptiondirectory",System.getProperty("user.home").concat(File.separator).concat(".pHtoolsReportDescriptionTemplates"));
configmap.put("recentcontains","NaCl");
configmap.put("recenttitrants","HCl");
configmap.put("recentpHprobes","f190");
configmap.put("lastrepository","default");
configmap.put("domainname","com.yourdomain");
configmap.put("iconmapfile",System.getProperty("user.home").concat(File.separator).concat(".pHtoolsDomainIconMappings"));
configmap.put("createdon","2008-00-00");
configmap.put("createdby","nobody");
configmap.put("performedby","nobody");
configmap.put("performedon","2008-00-00");
configmap.put("defaultTeXViewer","");
configmap.put("defaultEditor","");
configmap.put("legendfont","SansSerif-plain-18");
configmap.put("legendfontcolor","0");
configmap.put("legenddomainnamefilter","None,com.mockturtlesolutions.jpHtools.workbench.SpeciesNameFilter");
configmap.put("axesxlabelfont","SansSerif-bold-18");
configmap.put("axesylabelfont","SansSerif-bold-18");
configmap.put("axeszlabelfont","SansSerif-bold-18");
configmap.put("axesfont","SansSerif-bold-16");
configmap.put("axestitlefont","SansSerif-bold-16");
configmap.put("axeslinethickness","2");
configmap.put("axeson","true");
configmap.put("axesgridon","true");
configmap.put("axesboxon","true");
configmap.put("figurebackgroundcolor","-1");
configmap.put("axesbackgroundcolor","-1");
configmap.put("axestitlecolor","0");
configmap.put("axescolor","0");
configmap.put("axesxlabelcolor","0");
configmap.put("axesylabelcolor","0");
configmap.put("axeszlabelcolor","0");
configmap.put("linethickness","2");
configmap.put("linemarkersize","6");
return(configmap);
}
public int getDefaultAxesLineThickness(String repos)
{
Integer val = new Integer(this.getConfigValue(repos,"axeslinethickness"));
return(val.intValue());
}
public int getDefaultLineThickness(String repos)
{
Integer val = new Integer(this.getConfigValue(repos,"linethickness"));
return(val.intValue());
}
public int getDefaultMarkerSize(String repos)
{
Integer val = new Integer(this.getConfigValue(repos,"linemarkersize"));
return(val.intValue());
}
public Color getDefaultAxesBackgroundColor(String repos)
{
Integer ccode = new Integer(this.getConfigValue(repos,"axesbackgroundcolor"));
return(new Color(ccode.intValue()));
}
public Color getDefaultAxesTitleColor(String repos)
{
Integer ccode = new Integer(this.getConfigValue(repos,"axestitlecolor"));
return(new Color(ccode.intValue()));
}
public Color getDefaultAxesColor(String repos)
{
Integer ccode = new Integer(this.getConfigValue(repos,"axescolor"));
return(new Color(ccode.intValue()));
}
public Color getDefaultAxesXLabelColor(String repos)
{
Integer ccode = new Integer(this.getConfigValue(repos,"axesxlabelcolor"));
return(new Color(ccode.intValue()));
}
public Color getDefaultAxesYLabelColor(String repos)
{
Integer ccode = new Integer(this.getConfigValue(repos,"axesylabelcolor"));
return(new Color(ccode.intValue()));
}
public Color getDefaultAxesZLabelColor(String repos)
{
Integer ccode = new Integer(this.getConfigValue(repos,"axeszlabelcolor"));
return(new Color(ccode.intValue()));
}
public Font getDefaultLegendFont(String repos)
{
String fcode = this.getConfigValue(repos,"legendfont");
return(Font.decode(fcode));
}
public Color getDefaultLegendFontColor(String repos)
{
Integer ccode = new Integer(this.getConfigValue(repos,"legendfontcolor"));
return(new Color(ccode.intValue()));
}
public DomainNameFilter getDefaultLegendDomainNameFilter(String repos)
{
DomainNameFilter out = null;
String filterClass = this.getFirstSplitConfigValue(repos,"legenddomainnamefilter");
if (filterClass == null)
{
return(out);
}
// String[] filterClasses = this.getSplitConfigValue(repos,"legenddomainnamefilter");
//
// if (filterClasses == null)
// {
// return(out);
// }
// String filterClass = null;
//
// if (filterClasses.length > 0)
// {
// filterClass = filterClasses[0];
// }
// else
// {
// return(out);
// }
Class con;
if (filterClass.equalsIgnoreCase("none"))
{
return(out);
}
else
{ try
{
con = Class.forName(filterClass);
out = (DomainNameFilter)con.newInstance();
}
catch (Exception e)
{
throw new RuntimeException("Problem instantiating DomainNameFilter "+filterClass+".",e);
}
}
return(out);
}
public Font getDefaultAxesXLabelFont(String repos)
{
String fcode = this.getConfigValue(repos,"axesxlabelfont");
return(Font.decode(fcode));
}
public Font getDefaultAxesYLabelFont(String repos)
{
String fcode = this.getConfigValue(repos,"axesylabelfont");
return(Font.decode(fcode));
}
public Font getDefaultAxesZLabelFont(String repos)
{
String fcode = this.getConfigValue(repos,"axeszlabelfont");
return(Font.decode(fcode));
}
public Font getDefaultAxesFont(String repos)
{
String fcode = this.getConfigValue(repos,"axesfont");
return(Font.decode(fcode));
}
public Font getDefaultAxesTitleFont(String repos)
{
String fcode = this.getConfigValue(repos,"axestitlefont");
return(Font.decode(fcode));
}
public boolean getDefaultAxesOn(String repos)
{
Boolean bcode = new Boolean(this.getConfigValue(repos,"axeson"));
return(bcode.booleanValue());
}
public boolean getDefaultAxesGridOn(String repos)
{
Boolean bcode = new Boolean(this.getConfigValue(repos,"axesgridon"));
return(bcode.booleanValue());
}
public boolean getDefaultAxesBoxOn(String repos)
{
Boolean bcode = new Boolean(this.getConfigValue(repos,"axesboxon"));
return(bcode.booleanValue());
}
public Color getDefaultFigureBackgroundColor(String repos)
{
Integer ccode = new Integer(this.getConfigValue(repos,"figurebackgroundcolor"));
return(new Color(ccode.intValue()));
}
public void addDomainNameFilter()
{
}
}