001 /* steelme theme manager for Java
002 * Copyright (C) 2000 - 2004 T.J. Willis
003 *
004 * This program is free software; you can redistribute it and/or
005 * modify it under the terms of the GNU General Public License
006 * as published by the Free Software Foundation; either version 2
007 * of the License, or (at your option) any later version.
008 *
009 * This program is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012 * GNU General Public License for more details.
013 *
014 * You should have received a copy of the GNU General Public License
015 * along with this program; if not, write to the Free Software
016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
017 *
018 * $Header: /cvsroot/steelme/steelme/src/net/sourceforge/steelme/LookAndFeelToCSS.java,v 1.2 2004/05/15 16:11:46 tj_willis Exp $
019 */
020 package net.sourceforge.steelme;
021
022 import javax.swing.text.html.*;
023 import javax.swing.*;
024 import java.awt.Color;
025
026 /**
027 * A pluggable strategy for converting a LookAndFeel to a Cascading
028 * Stylesheet.
029 * @author <a href="mailto:tj_willis@users.sourceforge.net"> T.J. Willis </a>
030 * @version 1.0
031 */
032 public abstract class LookAndFeelToCSS {
033
034 /**
035 * Implementation will return a StyleSheet that represents the
036 * given LookAndFeel or UnsupportedLookAndFeelException if it cannot.
037 *
038 * @param laf a <code>LookAndFeel</code> value
039 * @return a <code>StyleSheet</code> value
040 * @exception UnsupportedLookAndFeelException if an error occurs
041 */
042 public abstract StyleSheet convert(LookAndFeel laf) throws UnsupportedLookAndFeelException;
043
044
045 /**
046 * Returns a string of the form "#FFFFFF" representing the given Color.
047 *
048 * @param c a <code>Color</code> value
049 * @return a <code>String</code> value
050 */
051 public static String hexString(Color c) {
052 String s = "#";
053 int v = 65536 * c.getRed() + 256 * c.getGreen() + c.getBlue();
054 s += Integer.toHexString(v);
055 return s;
056 }
057 }