// Medusa is a graph viewer which allows interactive editing of networks
// (edges and nodes) and also connects to databases.
//
// Copyright (C) 2006 Sean Hooper
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or (at
// your option) any later version.
//
// This program 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 General
// Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the
// Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330,
// Boston, MA 02111-1307 USA
package medusa;
import java.awt.Color;
import java.util.Hashtable;
import java.io.*;
import java.util.regex.*;
public class MedusaSettings {
// Table of colors, which allows colors to be changed
Hashtable colorTable = new Hashtable();
// And also the interaction names.
Hashtable interactionTable = new Hashtable();
Color[] colorList={new Color(0,180,0),
new Color(255,0,0),
new Color(0,0,255),
new Color(140,140,255),
new Color(30,30,30),
new Color(200,0,200),
new Color(0,160,200),
new Color(170,200,0),
randomColor(),
randomColor(),
randomColor(),
randomColor()
};
//public Iterator
public Color randomColor(){
int r=(int)(Math.random()*255);
int g=(int)(Math.random()*255);
int b=Math.min(255,255*2-r-g);
//System.out.println(r+" "+g+" "+b);
return new Color(r,g,b);
}
public MedusaSettings(){
init();
}
public Color getColorFromParam(String param){
String[] rgb=param.split(",");
int red,green,blue;
red=Integer.parseInt(rgb[0]);
green=Integer.parseInt(rgb[1]);
blue=Integer.parseInt(rgb[2]);
return new Color(red,green,blue);
}
public MedusaSettings(String settingsParam){
// handles a line of colors for the applet version
// this requires correct input!
if (settingsParam!=null){
//System.out.println("debug Stringsettings "+settingsParam);
readParam(settingsParam);
}
else {
init();
}
}
public void readParam(String settingsParam){
String[] colors=settingsParam.split(";");
Color c;
for (int i=0; i();
colorTable = new Hashtable();
initColorTable();
// load new settings
while ( (inLine=in.readLine())!=null){
String result[]=inLine.split("\\t");
Matcher matcher=xyPattern.matcher(inLine);
// set names
interactionTable.put(new Integer(result[0]), result[1]);
// set color, if present
if (matcher.find()){
int red=Integer.parseInt(matcher.group(1));
int green=Integer.parseInt(matcher.group(2));
int blue=Integer.parseInt(matcher.group(3));
colorTable.put(new Integer(result[0]),new Color(red,green,blue));
}
}
in.close();
}
public int getSize(){
return interactionTable.size();
}
public void report(){
for (int i=1; i
Ads help maintain this website.