1 19 20 package org.netbeans.modules.xml.nbprefuse; 21 22 import java.awt.BorderLayout ; 23 import java.awt.Dimension ; 24 import java.beans.PropertyChangeEvent ; 25 import java.beans.PropertyChangeListener ; 26 import javax.swing.JComponent ; 27 import javax.swing.JPanel ; 28 import org.openide.util.NbBundle; 29 30 34 public class AnalysisViewer extends JPanel implements 35 36 PropertyChangeListener { 37 public static final String PROP_GRAPH_NODE_SELECTION_CHANGE = 38 "prop-graph-node-selection-changed"; 39 public static final String PROP_GRAPH_NODE_SELECTION_CHANGED_RELAY = 40 "prop-graph-node-selection-changed-relay"; 41 42 public static final long serialVersionUID = -7710166579907141983L; 43 transient private View currentView; 44 private boolean reshowOnResize = true; 45 46 47 50 public AnalysisViewer() { 51 initComponents(); 52 initialize(); 53 } 54 55 private void initialize() { 56 setMinimumSize(new Dimension (180,30)); 57 } 66 67 public void setCurrentView(final View view){ 68 this.currentView = view; 69 } 70 71 public void removeToolBar() { 72 validate(); 74 repaint(); 75 } 76 77 private void showCurrentView(){ 78 if (currentView != null){ 79 showView(currentView); 80 } 81 } 82 public void addDisplayPanel(JPanel displayPanel) { 83 displayContainerPnl.removeAll(); 84 displayContainerPnl.setLayout(new BorderLayout ()); 85 displayContainerPnl.add(displayPanel, BorderLayout.CENTER); 86 } 87 88 89 public boolean showView(View view) { 90 currentView = view; 91 92 if (view.showView(this)){ 93 validate(); 94 repaint(); 95 } 96 return true; 97 } 98 99 103 public JPanel getPanel() { 104 return this; 105 } 106 107 111 115 116 public void propertyChange(PropertyChangeEvent evt){ 117 String propertyName = evt.getPropertyName(); 118 if (propertyName.equals( 119 PROP_GRAPH_NODE_SELECTION_CHANGE)){ 120 firePropertyChange(PROP_GRAPH_NODE_SELECTION_CHANGED_RELAY, 125 evt.getOldValue(),evt.getNewValue()); 126 127 } 128 } 129 130 136 public boolean getReshowOnResize(){ 137 return this.reshowOnResize; 138 } 139 140 145 public void setReshowOnResize(boolean reshowOnResize){ 146 this.reshowOnResize = reshowOnResize; 147 } 148 149 150 155 private void initComponents() { 157 displayContainerPnl = new javax.swing.JPanel (); 158 159 setLayout(new java.awt.BorderLayout ()); 160 161 setBackground(java.awt.Color.white); 162 setPreferredSize(new java.awt.Dimension (200, 200)); 163 displayContainerPnl.setLayout(null); 164 165 displayContainerPnl.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray)); 166 add(displayContainerPnl, java.awt.BorderLayout.CENTER); 167 168 } 170 171 private javax.swing.JPanel displayContainerPnl; 173 175 } 176 | Popular Tags |