//
// CodeTermListPanel.java
// VideoAnnotate
// Created by Michael D. Fischer on 27/07/2006.
// Copyright (c) 2006, Centre for Social Anthropology and Computing,
// University of Kent. All rights reserved.
//
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// Neither the name of the Centre for Social Anthropology and Computing,
// University of Kent nor the names of its contributors may be used
// to endorse or promote products derived from this software without
// specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE
// COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
// BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
// OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
// OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
import java.awt.Panel;
import java.awt.ScrollPane;
import java.awt.List;
import java.awt.Label;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.Color;
public class CodeTermListPanel extends Panel {
String title=null;
Label titleLabel=null;
CodeList codes=null;
ScrollPane scroll = null;
Panel scrollContents = null;
// Panel codes = null;
public CodeTermListPanel() {
setLayout(null);
titleLabel = new Label();
add(titleLabel);
// Panel codes = new Panel();
scroll = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED);
//add(scroll);
scrollContents = new Panel();
//scroll.add(scrollContents);
add(scrollContents);
setBackground(Color.red);
format();
}
public boolean load(XFile xf) {
CodeList c = new CodeList();
if (!c.load(xf)) return false;
setCodes(c);
return true;
}
public void setCodes(CodeList codes) {
this.codes = codes;
remove(scrollContents);
// scroll.remove(scrollContents);
scrollContents = new Panel();
scrollContents.setSize(this.getSize());
// scrollContents.setLayout(new GridLayout(2,codes.size()/2+1));
scrollContents.setLayout(new GridLayout(18,1));
// scroll.add(scrollContents);
add(scrollContents);
for (int i=0; i < codes.size(); i++) {
CodeTerm ct = (CodeTerm) codes.elementAt(i);
CodeTermCategoryPanel cp = new CodeTermCategoryPanel(ct);
// Label cp = new Label(ct.getName());
// CodeTermPanel cp = new CodeTermPanel(ct);
scrollContents.add(cp);
cp.layout();
}
//scroll.layout();
//format();
//scrollContents.layout();
layout();
}
public void format() {
setVisible(false);
int width= this.getSize().width;
int height= this.getSize().height;
int pw = scrollContents.getSize().width;
int ph = scrollContents.getSize().height;
titleLabel.setSize(72,20);
titleLabel.setLocation(0,0);
scroll.setSize(72,height-22);
scroll.setLocation(0,21);
setVisible(true);
}
public void layout() {
// super.layout();
setLocation(0,0);
format();
//scrollContents.layout();
}
}