001: /*
002: * Copyright Javelin Software, All rights reserved.
003: */
004:
005: package com.javelin.swinglets.plaf.html;
006:
007: import java.awt.*;
008: import java.util.*;
009: import java.io.*;
010:
011: import com.javelin.swinglets.*;
012: import com.javelin.swinglets.table.*;
013: import com.javelin.swinglets.plaf.*;
014: import com.javelin.swinglets.border.*;
015:
016: /**
017: * HTMLLookAndFeel defines a look and feel.
018: *
019: * @author Robin Sharp
020: */
021:
022: public class HTMLLookAndFeel extends SLookAndFeel {
023: /**
024: * Get the look and feel class for this UI.
025: */
026: public Class getLookAndFeel() {
027: return HTMLLookAndFeel.class;
028: }
029:
030: /**
031: * Intialise the SUIDefaults.
032:
033: */
034: protected void initClassDefaults(SUIDefaults defaults) {
035: //Init SUIClasses
036: defaults.put(SFileChooser.class, HTMLFileChooserUI.class);
037: defaults.put(SButton.class, HTMLButtonUI.class);
038: defaults.put(SToggleButton.class, HTMLButtonUI.class);
039: defaults.put(SCheckBox.class, HTMLCheckBoxUI.class);
040: defaults.put(SComboBox.class, HTMLComboBoxUI.class);
041: defaults.put(SList.class, HTMLListUI.class);
042: defaults.put(SFrame.class, HTMLFrameUI.class);
043: defaults.put(SInternalFrame.class, HTMLInternalFrameUI.class);
044: defaults.put(SDialog.class, HTMLDialogUI.class);
045: defaults.put(SIcon.class, HTMLIconUI.class);
046: defaults.put(SLabel.class, HTMLLabelUI.class);
047: defaults.put(SPanel.class, HTMLPanelUI.class);
048: defaults.put(SSplitPane.class, HTMLSplitPaneUI.class);
049: defaults.put(STabbedPane.class, HTMLTabbedPaneUI.class);
050: defaults.put(STable.class, HTMLTableUI.class);
051: defaults.put(STableHeader.class, HTMLTableHeaderUI.class);
052: defaults.put(STableFooter.class, HTMLTableFooterUI.class);
053: defaults.put(STree.class, HTMLTreeUI.class);
054: defaults.put(STextField.class, HTMLTextFieldUI.class);
055: defaults.put(SPasswordField.class, HTMLPasswordFieldUI.class);
056: defaults.put(STextArea.class, HTMLTextAreaUI.class);
057: defaults.put(SCharacter.class, HTMLCharacterUI.class);
058: defaults.put(SForm.class, HTMLFormUI.class);
059: defaults.put(SRadioButton.class, HTMLRadioButtonUI.class);
060: defaults.put(SButtonGroup.class, HTMLButtonGroupUI.class);
061: defaults.put(SToolBar.class, HTMLToolBarUI.class);
062: defaults.put(SSeparator.class, HTMLSeparatorUI.class);
063: defaults.put(SMenuBar.class, HTMLMenuBarUI.class);
064: defaults.put(SMenu.class, HTMLMenuUI.class);
065: defaults.put(SMenuItem.class, HTMLMenuItemUI.class);
066: defaults.put(SHidden.class, HTMLHiddenUI.class);
067: defaults.put(SServlet.class, HTMLServletUI.class);
068: defaults.put(SObject.class, HTMLObjectUI.class);
069: defaults.put(SInclude.class, HTMLIncludeUI.class);
070:
071: //LayoutUI
072: defaults.put(SFlowLayout.class, HTMLFlowLayoutUI.class);
073: defaults.put(SGridLayout.class, HTMLGridLayoutUI.class);
074: defaults.put(SBorderLayout.class, HTMLBorderLayoutUI.class);
075:
076: //BorderUI
077: defaults.put(SEmptyBorder.class, HTMLEmptyBorderUI.class);
078: defaults.put(SBevelBorder.class, HTMLBevelBorderUI.class);
079: defaults.put(SCompoundBorder.class, HTMLCompoundBorderUI.class);
080:
081: defaults.put(SMatteBorder.class, HTMLMatteBorderUI.class);
082:
083: //Default Renderers
084: defaults.put(TABLE_DEFAULT_CELL_RENDERER,
085: HTMLDefaultTableCellRenderer.class);
086: defaults.put(TABLE_DEFAULT_HEADER_RENDERER,
087: HTMLDefaultTableHeaderRenderer.class);
088: defaults.put(TABLE_DEFAULT_FOOTER_RENDERER,
089: HTMLDefaultTableFooterRenderer.class);
090: defaults.put(TREE_DEFAULT_CELL_RENDERER,
091: HTMLDefaultTreeCellRenderer.class);
092: defaults.put(TABBED_DEFAULT_CELL_RENDERER,
093: HTMLImageTabbedCellRenderer.class);
094: }
095:
096: /**
097: * Get the name of the look and feel.
098: */
099: public String getName() {
100: return "HTML";
101: }
102:
103: /**
104: * Get the content type for the look and feel.
105: */
106: public String getContentType() {
107: return "text/html";
108: }
109:
110: /**
111: * Does the look and feel require a Writer (char)
112: * stream or a OutputStream (byte) stream.
113: */
114: public boolean isWriter() {
115: return true;
116: }
117:
118: /**
119: * Get a SComponentUI for a SComponent.
120: */
121: public SComponentUI getUI(SComponent component) {
122: try {
123: Class clazz = (Class) getUIDefaults().getUIClass(
124: component.getUIClass());
125: if (clazz != null) {
126: return (SComponentUI) clazz.newInstance();
127: }
128: } catch (Exception e) {
129: e.printStackTrace();
130: }
131: return null;
132: }
133:
134: /**
135: * Get a SLayoutUI for a SLayout.
136: */
137: public SLayoutUI getLayoutUI(SLayoutManager layoutManager) {
138: try {
139: Class clazz = (Class) getUIDefaults().getUIClass(
140: layoutManager.getUIClass());
141: if (clazz != null) {
142: return (SLayoutUI) clazz.newInstance();
143: }
144: } catch (Exception e) {
145: e.printStackTrace();
146: }
147: return null;
148: }
149:
150: /**
151: * Get a SBorderUI for a SBorder.
152: */
153: public SBorderUI getBorderUI(SBorder border) {
154: try {
155: Class clazz = (Class) getUIDefaults().getUIClass(
156: border.getClass());
157: if (clazz != null) {
158: return (SBorderUI) clazz.newInstance();
159: }
160: } catch (Exception e) {
161: e.printStackTrace();
162: }
163: return null;
164: }
165:
166: // PRIVATE /////////////////////////////////////////////////////////////
167:
168: protected Hashtable defaults = new Hashtable();
169:
170: }
|