All pastes #287799 Raw Edit

Miscellany

public text v1 · immutable
#287799 ·published 2006-12-21 19:58 UTC
rendered paste body
package MuDiMoTo;

import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JInternalFrame;
import javax.swing.JPanel;

import atd.Boundary;
import atd.CompositeActorRole;
import atd.ElementaryActorRole;
import atd.Executor;
import atd.Initiator;
import atd.TransactionType;

public class MShapesBar extends JInternalFrame{
	private DiagramController controller;
	public enum DiagramType{ATD, PSD, OFD};
	public MShapesBar(){
		super("Shapes", true, true, true);
		setSize(new Dimension(200 , 100));
		this.setLocation(200,475);
		//load(DiagramType.ATD);
		//setFloatable(false);
	}
	
	public void setController(DiagramController controller){
		this.controller = controller;
	}
	public void load(DiagramType diagramType){
		JButton[] buttons = null;
		Dimension iconsize = new Dimension(40,40);
		switch(diagramType){
		case ATD:
			buttons = new JButton[]{
					//Page 159
					new JButton("Boundary of organization", new ImageIcon( (new Boundary(0, "Organization")).createImage(iconsize) )
								),
					new JButton("Elementary Actor Role", new ImageIcon( (new ElementaryActorRole(0,"Example")).createImage(iconsize) ) 
								),
					new JButton("Composite Actor Role", new ImageIcon( (new CompositeActorRole(0,"Example")).createImage(iconsize) )
								),
					//new JButton("Production Bank"),
					new JButton("Transaction Type", new ImageIcon( (new TransactionType(0,"Example")).createImage(iconsize) )
								),
					new JButton("Initiator", ( new Initiator(1) ).getIcon(iconsize)),
					//new JButton("Information"),
					new JButton("Executor", ( new Executor(1) ).getIcon(iconsize))
					};
			
			break;
		case PSD:
			buttons = new JButton[]{
					//Page 174
					new JButton("Responsibility area"),
					new JButton("C Act"),
					new JButton("Execution Act"),
					new JButton("Causal"),
					new JButton("Conditional"),
					new JButton("External activation"),
					new JButton("Self activation")
					};
			break;
		case OFD:
			buttons = new JButton[]{
					//Page 197
					new JButton("Entity Type"),
					new JButton("Fact Type"),
					new JButton("Derived Type"),
					new JButton("External Type"),
					new JButton("Result Type"),
					new JButton("Category"),
					new JButton("Object Class"),
					new JButton("Derived Object Class"),
					new JButton("External Object Class"),
					new JButton("Extension"),
					new JButton("Scale")
					};
			break;	
		}
		clear();
		JPanel contentPanel = new JPanel(new GridBagLayout());
		for(JButton button : buttons){
			contentPanel.add(button, GridBagConstraints.RELATIVE);//specify where
			//http://java.sun.com/docs/books/tutorial/uiswing/dnd/intro.html
			//button.setTransferHandler(new MShapeTransferHandler());
			button.addActionListener(controller);
			button.setVisible(true);
			//button.addMouseListener(controller);
			//button.addMouseMotionListener(controller);
		}
		contentPanel.setVisible(true);
		setContentPane(contentPanel);
		this.updateUI();
		//Sucks makes the toolbar floatable, but not always on top
		//BasicToolBarUI toolbarUI = (BasicToolBarUI) this.getUI();
		//toolbarUI.setFloating(true, new Point(10,100));
			
	}
	public void clear(){
		this.removeAll();
	}
}