/*
* @(#)CSetBuilderUI.java 0.0.0 99/07/02
*
* Copyright (c) 1999 by Willie Wheeler. All rights reserved.
*/
package stats.plaf.concrete;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.plaf.ComponentUI;
import stats.SetBuilder;
import stats.plaf.SetBuilderUI;
/**
* Notes: Willie needs to go through the code and replace references to
* samples, sample elements, etc., with references to data sets, data,
* etc.
*
* @version 0.0.0 07/02/99
* @author Willie Wheeler
*/
public class CSetBuilderUI extends SetBuilderUI implements ActionListener {
/**
* SetBuilder for which we are providing a PLAF.
*/
protected SetBuilder builder;
protected ImageIcon[] atoms;
protected Image[] atomImages;
protected JPanel samplePanel;
// Action commands generated by atom and sample element buttons.
protected static final String ADD = "add";
protected static final String REMOVE = "remove";
/**
* Creates a new CSetBuilderUI instance.
*/
public static ComponentUI createUI(JComponent c) {
return new CSetBuilderUI();
}
/**
* Installs this UI as the PLAF for the passed
* SetBuilder.
*/
public void installUI(JComponent c) {
System.err.println("CSetBuilderUI.installUI() entered.");
builder = (SetBuilder)c;
setAtoms(builder.getAtoms());
installDefaults();
installComponents();
}
protected void installDefaults() {
builder.setOpaque(true);
builder.setLayout(new BorderLayout());
}
protected void installComponents() {
JSplitPane splitPane = new JSplitPane();
splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
builder.add(splitPane, BorderLayout.CENTER);
// Build top panel for atom label and atom panel.
JPanel topPanel = new JPanel();
topPanel.setLayout(new BorderLayout());
// Build atom label.
JLabel atomLabel = new JLabel("Atoms", JLabel.CENTER);
topPanel.add(atomLabel, BorderLayout.NORTH);
// Build atom panel.
JPanel atomPanel = new JPanel();
atomPanel.setBackground(Color.white);
atomPanel.setLayout(new GridLayout(1, atoms.length));
for(int i=0; ithis UI as the PLAF for the passed SetBuilder.
*/
public void uninstallUI(JComponent c) {
uninstallComponents();
uninstallDefaults();
builder = null;
}
protected void uninstallComponents() { builder.removeAll(); }
protected void uninstallDefaults() { builder.setLayout(null); }
public void setAtoms(ImageIcon[] atoms) {
this.atoms = atoms;
// Build scaled images from the atom icons. These scaled images will
// be used for the sample.
Image image = null;
atomImages = new Image[atoms.length];
for(int i=0; i