1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419
|
/*
*
* Copyright (C) 1999, Institute for MicroTherapy
*
* This software and supporting documentation were developed by
*
* University of Witten/Herdecke
* Department of Radiology and MicroTherapy
* Institute for MicroTherapy
* Medical computer science
*
* Universitaetsstrasse 142
* 44799 Bochum, Germany
*
* http://www.microtherapy.de/go/cs
* mailto:computer.science@microtherapy.de
*
* THIS SOFTWARE IS MADE AVAILABLE, AS IS, AND THE INSTITUTE MAKES NO
* WARRANTY REGARDING THE SOFTWARE, ITS PERFORMANCE, ITS MERCHANTABILITY
* OR FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER DISEASES
* OR ITS CONFORMITY TO ANY SPECIFICATION. THE ENTIRE RISK AS TO QUALITY
* AND PERFORMANCE OF THE SOFTWARE IS WITH THE USER.
*
* Author : $Author: kleber $
* Last update : $Date: 2001/06/06 10:32:30 $
* Revision : $Revision: 1.1.1.1 $
* State: $State: Exp $
*/
package viewer.gui;
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import jToolkit.gui.*;
import viewer.main.*;
import main.*;
import java.util.*;
import viewer.presentation.*;
import java.awt.event.*;
/**
* Contains the layer manager
*/
public class LayerJPanel extends JDialog implements CommandButtonListener
{
public static final int EDIT =0;
public static final int DEL =1;
public static final int NEW =2;
public static final int MOVETO= 3;
public static final int DELAN= 4;
public static final int DEACTIVATE= 5;
public static final int ACTIVATE= 6;
public static final int CLOSE = 10;
CommandJButton moveButton;
CommandJButton delAnButton;
CommandJButton editButton;
CommandJButton delButton;
CommandJButton newButton;
CommandJButton closeButton;
JComboBox layerCombo;
JTextArea txtArea;
DefaultListModel model;
JComboBox moveToCombo;
JList list;
ScreenImageHandler screenImageHandler;
LayerNameItemListener layerNameItemListener = new LayerNameItemListener();
/**
* if true the deaktivate list will be visbile.
*
* @since 30.03.1999
*/
public boolean deactiveAnnotationListisVisible = false;
public LayerJPanel(ScreenImageHandler screenImageHandler, JFrame parent, Component relativeLocation)
{
super(parent, "Layer Manager" , true);
setLocation(350,350);
GridBagLayout gbl = new GridBagLayout();
GridBagConstraints gbc = new GridBagConstraints();
this.screenImageHandler = screenImageHandler;
//setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));
getContentPane().setLayout(new BorderLayout(5,5));
// row 1
JPanel layerPanel = new JPanel();
layerPanel.setBorder(new TitledBorder("Layer Settings"));
layerPanel.setLayout(gbl);
gbc.anchor = GridBagConstraints.NORTHWEST;
layerPanel.add(new JLabel("Graphic Layer"));
layerPanel.add(Box.createHorizontalStrut(10),gbc);
layerCombo= new JComboBox();
layerCombo.addItemListener(layerNameItemListener);
gbc.fill = GridBagConstraints.BOTH;
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.weightx = 1.0;
layerPanel.add(layerCombo,gbc);
// row 2
gbc.fill = GridBagConstraints.NONE;
gbc.weightx = 0.0;
layerPanel.add(Box.createVerticalStrut(3),gbc);
gbc.gridwidth = 1;
layerPanel.add(new JLabel("Description"),gbc);
layerPanel.add(Box.createHorizontalStrut(10),gbc);
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.weightx = 1.0;
txtArea = new JTextArea(10,20);
txtArea.setEditable(false);
gbc.fill = GridBagConstraints.BOTH;
//txtArea.setRows(10);
JScrollPane sp = new JScrollPane(txtArea,ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
layerPanel.add(sp,gbc);
//row 3
gbc.fill = GridBagConstraints.NONE;
gbc.weightx = 0.0;
layerPanel.add(Box.createVerticalStrut(3),gbc);
gbc.gridwidth = 1;
layerPanel.add(new JLabel(""),gbc);
JPanel buttonPanel = new JPanel();
editButton = new CommandJButton( "Edit",null,this,EDIT);
delButton = new CommandJButton( "Del",null,this,DEL);
newButton = new CommandJButton( "New",null,this,NEW);
buttonPanel.add(editButton);
buttonPanel.add(newButton);
buttonPanel.add(delButton);
gbc.weightx = 1.0;
layerPanel.add(Box.createVerticalStrut(3),gbc);
gbc.fill = GridBagConstraints.BOTH;
layerPanel.add(buttonPanel,gbc);
//add
getContentPane().add(layerPanel,BorderLayout.NORTH);
//Annotation
JPanel annPanel = new JPanel(new BorderLayout(5,5));
annPanel.setBorder(new TitledBorder("Annotation"));
layerPanel.setLayout(gbl);
//Object[] o = {"Klaus","Heiz"};
model = new DefaultListModel();
list = new JList(model);
JScrollPane spList = new JScrollPane(list);
list.setVisibleRowCount(10);
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION );
annPanel.add(spList,BorderLayout.CENTER);
moveButton = new CommandJButton( "Move to",null,this,MOVETO);
delAnButton = new CommandJButton( "Del",null,this,DELAN);
JPanel downPanel = new JPanel(new GridBagLayout());
GridBagConstraints gbcPanel = new GridBagConstraints();
gbcPanel.anchor = GridBagConstraints.NORTHWEST;
downPanel.add(delAnButton,gbcPanel);
gbcPanel.weightx = 0.0;
downPanel.add(moveButton,gbcPanel);
gbcPanel.gridwidth = GridBagConstraints.REMAINDER;
gbcPanel.weightx = 1.0;
gbcPanel.fill = GridBagConstraints.BOTH;
moveToCombo= new JComboBox();
downPanel.add(moveToCombo,gbcPanel);
annPanel.add(downPanel,BorderLayout.SOUTH);
getContentPane().add(annPanel,BorderLayout.CENTER);
closeButton = new CommandJButton( "Close",null,this,CLOSE);
JPanel closePanel = new JPanel();
closePanel.add(closeButton);
getContentPane().add(closePanel,BorderLayout.SOUTH);
pack();
setValue();
}
public void buttonClicked (int ID)
{
if (ID == CLOSE)
{
setVisible(false);
dispose();
return;
}
if (ID == DEL)
{
if ((layerCombo.getSelectedIndex()>=0)&&((layerCombo.getSelectedIndex()!=screenImageHandler.presentationStateGraphicsHandler.getListPresentationStateGraphicLayer().size())))
{
screenImageHandler.presentationStateGraphicsHandler.deleteLayer(layerCombo.getSelectedIndex());
screenImageHandler.buildImageBuffer(false,false,false,true, true);
Controller.instance().fireNotification(new SendLayerEvent(this,screenImageHandler.getLayers(),screenImageHandler.presentationStateGraphicsHandler.getCurrentLayerIndex()));
setValue();
}
return;
}
if (ID == DELAN)
{
System.out.println("Delete");
if ((list.getSelectedIndex()>=0)&&(list.getSelectedIndex() < screenImageHandler.presentationStateGraphicsHandler.getPresentationStateGraphicLayer(layerCombo.getSelectedIndex()).listPresentationStateObject.size()))
{
screenImageHandler.presentationStateGraphicsHandler.getPresentationStateGraphicLayer(layerCombo.getSelectedIndex()).deleteObjectAt(list.getSelectedIndex());
screenImageHandler.buildImageBuffer(false,false,false,true, true);
setValue();
}
//deletes overlay
else
{
if ((list.getSelectedIndex()>=0)|| !deactiveAnnotationListisVisible)
{
int index = list.getSelectedIndex()- screenImageHandler.presentationStateGraphicsHandler.getCurrentLayer().listPresentationStateObject.size();
screenImageHandler.presentationStateGraphicsHandler.ps.deactivateOverlay(layerCombo.getSelectedIndex(),index);
screenImageHandler.buildImageBuffer(false,false,false,true, true);
setValue();
}
}
}
if (ID == EDIT)
{
if ((layerCombo.getSelectedIndex()>=0)&&((layerCombo.getSelectedIndex()!=screenImageHandler.presentationStateGraphicsHandler.getListPresentationStateGraphicLayer().size())))
{
(new EditLayerPanel(this, screenImageHandler ,true)).show();
Controller.instance().fireNotification(new SendLayerEvent(this,screenImageHandler.getLayers(),screenImageHandler.presentationStateGraphicsHandler.getCurrentLayerIndex()));
setValue();
}
}
if (ID == NEW)
{
(new EditLayerPanel(this,screenImageHandler ,false)).show();
Controller.instance().fireNotification(new SendLayerEvent(this,screenImageHandler.getLayers(),screenImageHandler.presentationStateGraphicsHandler.getCurrentLayerIndex()));
setValue();
}
if (ID == MOVETO)
{
moveLayer();
}
}
/*
* Updates the content of this panel.
*
* @since 30.03.1999
*/
public void setValue()
{
Vector listGraphicLayer = screenImageHandler.presentationStateGraphicsHandler.getListPresentationStateGraphicLayer();
PresentationStateGraphicLayer nextLayer = null;
int nextLayerIndex = -1;
model.removeAllElements();
layerCombo.removeItemListener(layerNameItemListener);
if (layerCombo.getItemCount() > 0)layerCombo.removeAllItems();
if (moveToCombo.getItemCount() > 0)moveToCombo.removeAllItems();
//if a presentation state is available then fill the widgets
if (screenImageHandler.presentationStateGraphicsHandler.havePresentationState)
{
//fill the layerNameChoice and the moveToChoce with the GraphicLayers of the presentation state
for (int i = 0; i < listGraphicLayer.size(); i++)
{
nextLayer = (PresentationStateGraphicLayer) (listGraphicLayer.elementAt(i));
layerCombo.addItem(new String(i + " " +nextLayer.getName()));
moveToCombo.addItem(new String(i + " " +nextLayer.getName()));
}
//Adds an abstract layer in the layerNameChoice which contains the deactive layers
if (screenImageHandler.presentationStateGraphicsHandler.overlayList.haveOverlays())
layerCombo.addItem(new String("inactive"));
//if there is no current layer active then activate the first layer
if (screenImageHandler.presentationStateGraphicsHandler.getCurrentLayerIndex() == -1) screenImageHandler.presentationStateGraphicsHandler.setCurrentLayerIndex(nextLayerIndex);
//Fill the Annotation list
if (listGraphicLayer.size() != 0)
{
if (!deactiveAnnotationListisVisible)
{
layerCombo.setSelectedIndex(screenImageHandler.presentationStateGraphicsHandler.getCurrentLayerIndex());
txtArea.setText(screenImageHandler.presentationStateGraphicsHandler.getCurrentLayer().getDescription());
for (int i = 0 ; i < screenImageHandler.presentationStateGraphicsHandler.getCurrentLayer().listPresentationStateObject.size(); i++)
{
model.addElement(((PresentationStateLayerObject) screenImageHandler.presentationStateGraphicsHandler.getCurrentLayer().listPresentationStateObject.elementAt(i)).getListText());
}
for (int i = 0; i < screenImageHandler.presentationStateGraphicsHandler.ps.getNumberOfActiveOverlays(screenImageHandler.presentationStateGraphicsHandler.getCurrentLayerIndex()); i++)
{
model.addElement(screenImageHandler.presentationStateGraphicsHandler.overlayList.getListText(screenImageHandler.presentationStateGraphicsHandler.getCurrentLayerIndex(),i));
}
}
else
{
layerCombo.setSelectedIndex(listGraphicLayer.size());
txtArea.setText("inactive overlays");
for (int i = 0; i < screenImageHandler.presentationStateGraphicsHandler.ps.getNumberOfOverlaysInImage(); i++)
{
if (screenImageHandler.presentationStateGraphicsHandler.ps.getOverlayInImageActivationLayer(i) == -1)
model.addElement(screenImageHandler.presentationStateGraphicsHandler.overlayList.getImageListText(i));
}
for (int i = 0; i < screenImageHandler.presentationStateGraphicsHandler.ps.getNumberOfOverlaysInPresentationState(); i++)
{
if (screenImageHandler.presentationStateGraphicsHandler.ps.getOverlayInPresentationStateActivationLayer(i) == -1)
model.addElement(screenImageHandler.presentationStateGraphicsHandler.overlayList.getPresentationStateListText(i));
}
}
}
list.setSelectedIndex(screenImageHandler.presentationStateGraphicsHandler.getCurrentLayerObjectIndex());
}
else this.setEnabled(false);
layerCombo.addItemListener(layerNameItemListener);
}
class LayerNameItemListener implements ItemListener
{
public void itemStateChanged(ItemEvent e)
{
changeLayer( e);
}
}
public void changeLayer(ItemEvent e)
{
if (layerCombo.getItemCount() >0)
{
//if selecteds item is a layer
if (layerCombo.getSelectedIndex() != screenImageHandler.presentationStateGraphicsHandler.listPresentationStateGraphicLayer.size())
{
deactiveAnnotationListisVisible = false;
screenImageHandler.presentationStateGraphicsHandler.setCurrentLayerIndex(layerCombo.getSelectedIndex());
setValue();
}
//if selected Item is the deactive List
else
{
deactiveAnnotationListisVisible = true;
setValue();
}
}
}
public void moveLayer()
{
if ((moveToCombo.getSelectedIndex() >-1)&&(layerCombo.getSelectedIndex() >-1)&&(list.getSelectedIndex() >-1))
{
if (moveToCombo.getSelectedIndex() <screenImageHandler.presentationStateGraphicsHandler.listPresentationStateGraphicLayer.size())
{
//Moves annotations and activate overlays
if (layerCombo.getSelectedIndex()<screenImageHandler.presentationStateGraphicsHandler.listPresentationStateGraphicLayer.size())
{
//Moves annotations
if (list.getSelectedIndex()< screenImageHandler.presentationStateGraphicsHandler.getCurrentLayer().listPresentationStateObject.size())
{
System.out.println("move Annotation to Layer");
screenImageHandler.presentationStateGraphicsHandler.moveToLayer( moveToCombo.getSelectedIndex(),
layerCombo.getSelectedIndex(),
list.getSelectedIndex(), screenImageHandler.getApplyTo());
}
//Moves overlays
else
{
int status = screenImageHandler.presentationStateGraphicsHandler.ps.moveOverlay(layerCombo.getSelectedIndex(),
list.getSelectedIndex()- screenImageHandler.presentationStateGraphicsHandler.getCurrentLayer().listPresentationStateObject.size(),
moveToCombo.getSelectedIndex());
}
//Repaints only if color is different
if (!screenImageHandler.presentationStateGraphicsHandler.getLayerAtIndex(moveToCombo.getSelectedIndex()).getColor(8).equals(screenImageHandler.presentationStateGraphicsHandler.getLayerAtIndex(layerCombo.getSelectedIndex()).getColor(8)))
{
screenImageHandler.buildImageBuffer(false,false, false,true, true);
}
}
//Moves deactivate Overlays
else
{
System.out.println("activate Overlay");
screenImageHandler.presentationStateGraphicsHandler.overlayList.activateOverlay(list.getSelectedIndex(),moveToCombo.getSelectedIndex());
screenImageHandler.buildImageBuffer(false,false,false,true, true);
}
setValue();
}
}
}
}
/*
* CVS Log
* $Log: LayerJPanel.java,v $
* Revision 1.1.1.1 2001/06/06 10:32:30 kleber
* Init commit for DICOMscope 3.5
* Create new CVS
*
*/
|