package cc.glsn.v15.housefund; import java.awt.Component; import java.awt.Container; import java.awt.Font; import java.awt.GridBagConstraints; import java.sql.ResultSet; import java.sql.SQLException; import java.text.DecimalFormat; import java.text.SimpleDateFormat; import java.util.Set; import java.util.TreeMap; import java.util.TreeSet; import javax.swing.JLabel; import cc.glsn.v15.SQLConnection; class Globals { public static String Ver="baboon"; private static final String SQLDriver="com.mysql.jdbc.Driver"; private static final String SQLURL="jdbc:mysql://silo.int.fireduck.com/housefund"; private static final String SQLUser="housefund"; private static final String SQLPass="c4ec9396de701f58bd7d1bf89d26b65a3b"; public static final int NormalFontSize = 16; public static final int FlagRight=1; public static final int FlagEndRow=2; public static final int FlagRed=4; public static final int FlagsNoFont = 8; public static void addComponent(Component Comp,Container P,int Flags) { if (Comp==null) Comp=new JLabel(""); if ((Flags & FlagsNoFont) == 0) { Comp.setFont(getFont(NormalFontSize)); } java.awt.GridBagConstraints c=new java.awt.GridBagConstraints(); c.gridheight=1; c.gridwidth=1; c.weightx=0.0; c.weighty=0.0; c.fill=GridBagConstraints.NONE; c.insets=new java.awt.Insets(4,4,4,4); c.anchor=GridBagConstraints.WEST; if ((Flags & FlagRight) > 0) c.anchor=GridBagConstraints.EAST; if ((Flags & FlagEndRow) > 0) { c.gridwidth=GridBagConstraints.REMAINDER; } P.add(Comp,c); } public static void addItem(Object Text,Container P,int Flags) { if (Text==null) Text=new String(""); java.awt.GridBagConstraints c=new java.awt.GridBagConstraints(); c.gridheight=1; c.gridwidth=1; c.weightx=0.0; c.weighty=0.0; c.fill=GridBagConstraints.NONE; c.insets=new java.awt.Insets(4,4,4,4); c.anchor=GridBagConstraints.WEST; if ((Flags & FlagRight) > 0) c.anchor=GridBagConstraints.EAST; if ((Flags & FlagEndRow) > 0) { c.gridwidth=GridBagConstraints.REMAINDER; } JLabel L=new JLabel(Text.toString()); //System.out.println(Text); L.setFont(getFont(NormalFontSize)); if ((Flags & FlagRed) > 0) { L.setForeground(java.awt.Color.RED); } P.add(L,c); } protected static SQLConnection getSQL() throws SQLException { return new SQLConnection(Globals.SQLDriver,Globals.SQLURL,Globals.SQLUser,Globals.SQLPass); } protected static Set getAllUsers() { TreeSet Names=new TreeSet(); Names.add("alex"); Names.add("allen"); Names.add("andrew"); Names.add("joe"); Names.add("jeff"); Names.add("paul"); return Names; } protected static DecimalFormat getMoneyFormat() { return new DecimalFormat("$0.00"); } protected static DecimalFormat getPercentFormat() { return new DecimalFormat("0.000"); } protected static SimpleDateFormat getDateFormat() { return new SimpleDateFormat("yyyy.MMM.dd"); } protected static Font getFont(int Size, int Flags) { return new Font("Franklin Gothic Medium",Flags,Size); } protected static Font getFont(int Size) { return new Font("Franklin Gothic Medium",0,Size); } static TreeMap nameCache; protected static synchronized String getFullName(String name) throws SQLException { if (nameCache==null) { nameCache=new TreeMap(); } if (!nameCache.containsKey(name)) { SQLConnection c=getSQL(); ResultSet R=c.doSingleQuery("select * from people where shortname='" + name +"'"); R.first(); nameCache.put(name,R.getString("fullname")); } return nameCache.get(name); } }