View Javadoc
1 /* 2 * Created on Oct 27, 2003 3 * 4 */ 5 package portaview.view; 6 7 import java.awt.BorderLayout; 8 import java.awt.Component; 9 import java.awt.event.ActionEvent; 10 import java.awt.event.ActionListener; 11 import java.util.List; 12 13 import javax.swing.BorderFactory; 14 import javax.swing.JButton; 15 import javax.swing.JLabel; 16 import javax.swing.JPanel; 17 import javax.swing.SwingConstants; 18 19 import portaview.Displayer; 20 import portaview.Registry; 21 import portaview.model.PortaViewCollection; 22 import portaview.model.PortaViewModel; 23 24 /*** 25 * Represents a PortaViewPanel that list out the PortaViews on the left. 26 * @author William Lee 27 */ 28 public class PortaViewPanel extends IconPanel 29 { 30 private PortaViewCollection portaViews = null; 31 private List portaViewViews = null; 32 33 /*** 34 * Given a list of PortaView models, draw the view. 35 * @param portaViews 36 */ 37 public PortaViewPanel(PortaViewCollection portaViews) 38 { 39 super(portaViews); 40 } 41 42 /*** 43 * Adds an component before the first view in the panel. 44 */ 45 public Component decorateFirstView(Component comp) 46 { 47 JPanel rtn = new JPanel(new BorderLayout()); 48 rtn.add(comp, BorderLayout.CENTER); 49 JLabel lbl = new JLabel("This PortaView:"); 50 lbl.setHorizontalAlignment(SwingConstants.CENTER); 51 lbl.setVerticalAlignment(SwingConstants.CENTER); 52 rtn.add(lbl, BorderLayout.NORTH); 53 54 JButton fullScreen = new JButton("Full Screen View"); 55 fullScreen.addActionListener(new ActionListener() 56 { 57 public void actionPerformed(ActionEvent e) 58 { 59 Displayer disp = Registry.getMainApplication().getDisplayer(); 60 disp.setVisible(true); 61 disp.getView().refreshImage(); 62 Registry.getMainApplication().setDisplayActive(true); 63 } 64 }); 65 rtn.add(fullScreen, BorderLayout.SOUTH); 66 return rtn; 67 } 68 69 /*** 70 * Decorates the second view. 71 * @param comp the PortaViewView to decorate 72 * @return the component with a label that says "Other PortaView(s):" 73 */ 74 public Component decorateSecondView(Component comp) 75 { 76 JPanel rtn = new JPanel(new BorderLayout()); 77 rtn.add(comp, BorderLayout.CENTER); 78 JLabel lbl = new JLabel("Other PortaView(s):"); 79 lbl.setHorizontalAlignment(SwingConstants.CENTER); 80 lbl.setVerticalAlignment(SwingConstants.CENTER); 81 rtn.add(lbl, BorderLayout.NORTH); 82 rtn.setBorder(BorderFactory.createEmptyBorder(20,0,0,0)); 83 return rtn; 84 } 85 86 /*** 87 * Generates a PortaViewView from the PortaViewModel. 88 * @see portaview.view.IconPanel#getViewFromModel(java.lang.Object) 89 */ 90 public Object getViewFromModel(Object model, IconPanel ipanel) 91 { 92 PortaViewModel element = (PortaViewModel) model; 93 PortaViewView view = 94 new PortaViewView(element, (PortaViewPanel) ipanel); 95 return view; 96 } 97 98 /*** 99 * Remove the view and clean up the observers. 100 * @see portaview.view.IconPanel#removeView(java.lang.Object) 101 */ 102 public void removeView(Object view) 103 { 104 PortaViewView pvv = (PortaViewView) view; 105 pvv.getPortaViewModel().deleteObserver(pvv); 106 } 107 }

This page was automatically generated by Maven