1
2
3
4
5
6
7 package com.vikash.firsttool.Diagram.DiagramBars;
8 import com.vikash.firsttool.Diagram.*;
9 import com.vikash.firsttool.UI.*;
10 import java.net.URL;
11 import java.awt.event.*;
12 import java.awt.*;
13
14 import javax.swing.*;
15 import javax.swing.Action;
16 import javax.swing.JToolBar;
17
18 /***
19 *
20 * @author studajb
21 */
22 public class TreatmentEffectBar extends JToolBar {
23 EditorPanel panel;
24 ButtonGroup group;
25 /*** Creates a new instance of TreatmentEffectBar */
26 public TreatmentEffectBar(final EditorPanel panel) {
27 this.panel=panel;
28 group=new ButtonGroup();
29 CreateIcon("Select","Select","Select");
30 CreateIcon("Treatment","vertex","Treatment");
31 CreateIcon("UnwantedIncident","vertex","UnwantedIncident");
32 CreateIcon("Risk","vertex","Risk");
33 CreateIcon("TreatmentEffect","vertex","TreatmentEffect");
34 CreateIcon("TreatmentEvaluation","dependency","<html><p align=\"center\">"+"TreatmentEvaluation"+"<br>"+"TreatmentEffect ----> Treatment"+"</p></html>");
35 CreateIcon("RiskEvaluation","dependency","<html><p align=\"center\">"+"RiskEvaluation"+"<br>"+"Risk ----> UnwantedIncident"+"</p></html>");
36 CreateIcon("Avoid","dependency","<html><p align=\"center\">"+"Avoid"+"<br>"+"Treatment ----> UnwantedIncident"+"</p></html>");
37 CreateIcon("ReduceConsequence","dependency","<html><p align=\"center\">"+"ReduceConsequence"+"<br>"+"Treatment ----> UnwantedIncident"+"</p></html>");
38 CreateIcon("ReduceLikelihood","dependency","<html><p align=\"center\">"+"ReduceLikelihood"+"<br>"+"Treatment ----> UnwantedIncident"+"</p></html>");
39 CreateIcon("Transfer","dependency","<html><p align=\"center\">"+"Transfer"+"<br>"+"Treatment ----> UnwantedIncident"+"</p></html>");
40 CreateIcon("Association","association","<html><p align=\"center\">"+"Association"+"<br>"+"TreatmentEffect ----> Risk"+"</p></html>");
41 }
42 private void CreateIcon(String name,String type,String tooltip){
43
44 URL iconurl=getClass().getClassLoader().getResource("com/vikash/firsttool/resources/"+name+".gif");
45 Action iconaction= new DrawAction(tooltip,new ImageIcon(iconurl),name,panel,type);
46 JToggleButton button = new JToggleButton(iconaction);
47 button.setPreferredSize(new Dimension(30,30));
48 button.setMaximumSize(new Dimension(30,30));
49 group.add(button);
50 add(button);
51 }
52 }