001: /*
002: * Copyright Javelin Software, All rights reserved.
003: */
004:
005: package com.javelin.swinglets.plaf.jfc;
006:
007: import java.awt.*;
008: import java.util.*;
009: import java.io.*;
010:
011: import javax.swing.*;
012:
013: import com.javelin.swinglets.*;
014: import com.javelin.swinglets.table.*;
015: import com.javelin.swinglets.border.*;
016: import com.javelin.swinglets.plaf.*;
017:
018: /**
019: * JFCLookAndFeel defines a look and feel.
020: *
021: * @author Robin Sharp
022: */
023:
024: public class JFCLookAndFeel extends SLookAndFeel {
025: /**
026: * Intialise the SUIDefaults.
027: */
028: protected void initClassDefaults(SUIDefaults defaults) {
029: //Init SUIClasses
030: /*
031: defaults.put( SFileChooser.class, JFCFileChooserUI.class );
032: defaults.put( SButton.class, JFCButtonUI.class );
033: defaults.put( SCheckBox.class, JFCCheckBoxUI.class );
034: defaults.put( SComboBox.class, JFCComboBoxUI.class );
035: defaults.put( SList.class, JFCListUI.class );
036: defaults.put( SIcon.class, JFCIconUI.class );
037: */
038: defaults.put(SFrame.class, JFCFrameUI.class);
039: defaults.put(SLabel.class, JFCLabelUI.class);
040: defaults.put(SPanel.class, JFCPanelUI.class);
041: /*
042: defaults.put( SSplitPane.class, JFCSplitPaneUI.class );
043: defaults.put( STabbedPane.class, JFCTabbedPaneUI.class );
044: defaults.put( STable.class, JFCTableUI.class );
045: defaults.put( STableHeader.class, JFCTableHeaderUI.class );
046: defaults.put( STree.class, JFCTreeUI.class );
047: defaults.put( STextField.class, JFCTextFieldUI.class );
048: defaults.put( SPasswordField.class, JFCPasswordFieldUI.class );
049: defaults.put( STextArea.class, JFCTextAreaUI.class );
050: defaults.put( SCharacter.class, JFCCharacterUI.class );
051: defaults.put( SForm.class, JFCFormUI.class );
052: defaults.put( SRadioButton.class, JFCRadioButtonUI.class );
053: defaults.put( SButtonGroup.class, JFCButtonGroupUI.class );
054: defaults.put( SToolBar.class, JFCToolBarUI.class );
055: defaults.put( SMenuBar.class, JFCMenuBarUI.class );
056: defaults.put( SMenu.class, JFCMenuUI.class );
057: defaults.put( SMenuItem.class, JFCMenuItemUI.class );
058: defaults.put( SHidden.class, JFCHiddenUI.class );
059: defaults.put( SServlet.class, JFCServletUI.class );
060: defaults.put( SApplet.class, JFCAppletUI.class );
061: */
062:
063: //Layout UI
064: defaults.put(SFlowLayout.class, JFCFlowLayoutUI.class);
065: defaults.put(SBorderLayout.class, JFCBorderLayoutUI.class);
066: /*
067: defaults.put( SGridLayout.class, JFCGridLayoutUI.class );
068:
069: //Border UI
070: defaults.put( SEmptyBorder.class, JFCBorderUI.class );
071: defaults.put( SBevelBorder.class, JFCBorderUI.class );
072: defaults.put( SCompoundBorder.class, JFCBorderUI.class );
073: defaults.put( SMatteBorder.class, JFCBorderUI.class );
074:
075: //Default Renderers
076: defaults.put( TABLE_DEFAULT_CELL_RENDERER, JFCDefaultTableCellRenderer.class );
077: defaults.put( TABLE_DEFAULT_HEADER_RENDERER, JFCDefaultTableHeaderRenderer.class );
078: //defaults.put( TREE_DEFAULT_CELL_RENDERER, JFCDefaultTreeCellRenderer.class );
079:
080: //Init Tree
081: defaults.put( TREE_OPEN_ICON, new SIcon( "images/metal/open.gif" ).setToolTipText( "+" ) );
082: defaults.put( TREE_CLOSED_ICON, new SIcon( "images/metal/closed.gif" ).setToolTipText( "-" ) );
083: defaults.put( TREE_LEAF_ICON, new SIcon( "images/metal/doc.gif" ).setToolTipText( "0" ) );
084: */
085: }
086:
087: /**
088: * Get the name of the look and feel.
089: */
090: public String getName() {
091: return "JFC";
092: }
093:
094: /**
095: * Get the content type for the look and feel.
096: */
097: public String getContentType() {
098: return "application/java";
099: }
100:
101: /**
102: * Does the look and feel require a Writer (char)
103: * stream or a OutputStream (byte) stream.
104: */
105: public boolean isWriter() {
106: return true;
107: }
108:
109: /**
110: * Get a SComponentUI for a SComponent.
111: */
112: public SComponentUI getUI(SComponent component) {
113: try {
114: Class clazz = (Class) getUIDefaults().getUIClass(
115: component.getUIClass());
116: if (clazz != null) {
117: SComponentUI componentUI = (SComponentUI) clazz
118: .newInstance();
119: componentUI.addListeners(component);
120: return componentUI;
121: }
122: } catch (Exception e) {
123: e.printStackTrace();
124: }
125: return null;
126: }
127:
128: /**
129: * Get a SLayoutUI for a SLayout.
130: */
131: public SLayoutUI getLayoutUI(SLayoutManager layoutManager) {
132: try {
133: Class clazz = (Class) getUIDefaults().getUIClass(
134: layoutManager.getUIClass());
135: if (clazz != null) {
136: return (SLayoutUI) clazz.newInstance();
137: }
138: } catch (Exception e) {
139: e.printStackTrace();
140: }
141: return null;
142: }
143:
144: /**
145: * Get a SBorderUI for a SBorder.
146: */
147: public SBorderUI getBorderUI(SBorder border) {
148: try {
149: Class clazz = (Class) getUIDefaults().getUIClass(
150: border.getClass());
151: if (clazz != null) {
152: return (SBorderUI) clazz.newInstance();
153: }
154: } catch (Exception e) {
155: e.printStackTrace();
156: }
157: return null;
158: }
159:
160: // PRIVATE /////////////////////////////////////////////////////////////
161:
162: private Hashtable defaults = new Hashtable();
163:
164: }
|