001: /*
002: * The contents of this file are subject to the
003: * Mozilla Public License Version 1.1 (the "License");
004: * you may not use this file except in compliance with the License.
005: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006: *
007: * Software distributed under the License is distributed on an "AS IS"
008: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
009: * See the License for the specific language governing rights and
010: * limitations under the License.
011: *
012: * The Initial Developer of the Original Code is Simulacra Media Ltd.
013: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014: *
015: * All Rights Reserved.
016: *
017: * Contributor(s):
018: */
019: package org.openharmonise.him.metadata.range.swing.relatedevents;
020:
021: import java.awt.*;
022: import java.util.*;
023: import java.util.Iterator;
024:
025: import javax.swing.*;
026: import javax.swing.JPanel;
027:
028: /**
029: * @author Michael Bell
030: * @version $Revision: 1.1 $
031: *
032: */
033: public class RelatedEventHeadingPanel extends JPanel {
034:
035: int m_nDateWidth = 0;
036: int m_nRelationshipWidth = 0;
037: int m_nTextWidth = 0;
038:
039: /**
040: *
041: */
042: public RelatedEventHeadingPanel(int nDateWidth, int nRelnWidth,
043: int nTextWidth) {
044: super ();
045: m_nDateWidth = nDateWidth;
046: m_nRelationshipWidth = nRelnWidth;
047: m_nTextWidth = nTextWidth;
048:
049: setup();
050: }
051:
052: /**
053: *
054: */
055: private void setup() {
056: FlowLayout layout = new FlowLayout(FlowLayout.CENTER,
057: RelatedEventValueDisplay.m_nSpace, 0);
058:
059: this .setLayout(layout);
060: ArrayList comps = new ArrayList();
061:
062: String fontName = "Dialog";
063: int fontSize = 13;
064: Font font = new Font(fontName, Font.BOLD, fontSize);
065:
066: JLabel startDate = new JLabel("Start Date");
067: startDate.setFont(font);
068:
069: Dimension dim = startDate.getPreferredSize();
070: int nLabelHeight = dim.height;
071: Dimension dateDim = new Dimension(m_nDateWidth, nLabelHeight);
072: startDate.setPreferredSize(dateDim);
073: startDate.setHorizontalAlignment(SwingConstants.CENTER);
074: this .add(startDate);
075: comps.add(startDate);
076: JLabel endDate = new JLabel("End Date");
077: endDate.setFont(font);
078: endDate.setHorizontalAlignment(SwingConstants.CENTER);
079:
080: endDate.setPreferredSize(dateDim);
081: this .add(endDate);
082: comps.add(endDate);
083:
084: Dimension relnDim = new Dimension(m_nRelationshipWidth,
085: nLabelHeight);
086:
087: JLabel type = new JLabel("Type");
088: type.setFont(font);
089: type.setPreferredSize(relnDim);
090: type.setHorizontalAlignment(SwingConstants.CENTER);
091:
092: this .add(type);
093: comps.add(type);
094:
095: JLabel text = new JLabel("Text");
096: text.setFont(font);
097: Dimension textDim = new Dimension(m_nTextWidth, nLabelHeight);
098: text.setPreferredSize(textDim);
099: text.setHorizontalAlignment(SwingConstants.CENTER);
100:
101: this .add(text);
102: comps.add(text);
103:
104: JLabel people = new JLabel("People");
105: people.setFont(font);
106: people.setPreferredSize(relnDim);
107: people.setHorizontalAlignment(SwingConstants.CENTER);
108: this .add(people);
109: comps.add(people);
110: JLabel place = new JLabel("Place");
111: place.setFont(font);
112: place.setPreferredSize(relnDim);
113: place.setHorizontalAlignment(SwingConstants.CENTER);
114:
115: this .add(place);
116: comps.add(place);
117:
118: int nWidth = 0;
119:
120: Iterator iter = comps.iterator();
121:
122: while (iter.hasNext()) {
123: Component comp = (Component) iter.next();
124: nWidth = nWidth + comp.getPreferredSize().width;
125: }
126:
127: }
128:
129: }
|