1 | |
package br.mia.test.view.graph; |
2 | |
|
3 | |
import java.util.ArrayList; |
4 | |
import java.util.List; |
5 | |
|
6 | |
import org.jgraph.graph.DefaultEdge; |
7 | |
import org.jgraph.graph.GraphConstants; |
8 | |
|
9 | |
import br.mia.test.model.CasoUso; |
10 | |
import br.mia.test.model.Filtro; |
11 | |
import br.mia.test.model.Fluxo; |
12 | |
import br.mia.test.model.Link; |
13 | |
import br.mia.test.model.RegraNegocio; |
14 | |
import br.mia.test.model.Step; |
15 | |
import br.mia.test.model.TestDataValor; |
16 | |
import br.mia.test.testcase.DadosTeste; |
17 | 0 | |
18 | 0 | public class Util { |
19 | |
|
20 | |
private static ArrayList<Fluxo> flows; |
21 | |
|
22 | 0 | public static ArrayList<Fluxo> getFlows() { |
23 | 0 | if (flows == null) { |
24 | 0 | flows = new ArrayList<Fluxo>(); |
25 | 0 | } |
26 | 0 | return flows; |
27 | |
} |
28 | |
|
29 | 0 | public static void setFlows(ArrayList<Fluxo> flows) { |
30 | 0 | Util.flows = flows; |
31 | 0 | } |
32 | |
|
33 | |
public static StepCell criaPasso(Fluxo flow, Step step, |
34 | |
CasoUso useCase, int x, int y, ArrayList<Object> passosCobertos) { |
35 | 0 | int indice; |
36 | 0 | if (flow != null) { |
37 | 0 | indice = flow.getSteps().indexOf(step); |
38 | 0 | } else { |
39 | 0 | indice = 0; |
40 | 0 | } |
41 | 0 | return new StepCell(step.getDescricao(), useCase, step, flow, indice, |
42 | 0 | 20 + x, 20 + y, passosCobertos); |
43 | |
|
44 | |
} |
45 | |
|
46 | |
public static DefaultEdge criaLinkPasso(StepCell cellAnterior, |
47 | 0 | StepCell cell1, List<Object> list) { |
48 | 0 | DefaultEdge edge = new DefaultEdge(); |
49 | 0 | int arrow = GraphConstants.ARROW_CLASSIC; |
50 | 0 | GraphConstants.setLineEnd(edge.getAttributes(), arrow); |
51 | 0 | GraphConstants.setEndFill(edge.getAttributes(), true); |
52 | 0 | |
53 | 0 | edge.setSource(cellAnterior.getChildAt(0)); |
54 | 0 | edge.setTarget(cell1.getChildAt(0)); |
55 | 0 | cell1.setSetaAnterior(edge); |
56 | 0 | if (!(list.contains(edge))) { |
57 | 0 | list.add(edge); |
58 | 0 | } |
59 | 0 | return edge; |
60 | |
} |
61 | |
|
62 | 0 | public static DadoEdge criaLinkDado(StepCell cell, DataCell data) { |
63 | 0 | DadoEdge edge = new DadoEdge(); |
64 | 0 | |
65 | 0 | GraphConstants.setEndFill(edge.getAttributes(), true); |
66 | 0 | |
67 | 0 | edge.setSource(cell.getChildAt(0)); |
68 | 0 | edge.setTarget(data.getChildAt(0)); |
69 | 0 | data.setDadoEdge(edge); |
70 | 0 | return edge; |
71 | |
} |
72 | |
|
73 | 0 | public static ValorEdge criaLinkValor(DataCell cell, ValorCell valor) { |
74 | 0 | ValorEdge edge = new ValorEdge(); |
75 | 0 | |
76 | 0 | GraphConstants.setEndFill(edge.getAttributes(), true); |
77 | 0 | |
78 | 0 | edge.setSource(cell.getChildAt(0)); |
79 | 0 | edge.setTarget(valor.getChildAt(0)); |
80 | 0 | return edge; |
81 | |
} |
82 | |
|
83 | 0 | public static RuleEdge criaLinkRule(StepCell cell, RuleCell data) { |
84 | 0 | RuleEdge edge = new RuleEdge(); |
85 | 0 | |
86 | 0 | edge.setSource(cell.getChildAt(0)); |
87 | 0 | edge.setTarget(data.getChildAt(0)); |
88 | 0 | data.setEdge(edge); |
89 | 0 | return edge; |
90 | |
} |
91 | |
|
92 | 0 | public static RuleCell criaRule(RegraNegocio rule, int x, int y, Step step) { |
93 | 0 | RuleCell cell2 = new RuleCell(rule.getName(), rule, step, 20 + x, |
94 | 0 | 20 + y); |
95 | 0 | |
96 | 0 | return cell2; |
97 | |
} |
98 | |
|
99 | 0 | public static ValorCell criaValor(TestDataValor valor, int x, int y) { |
100 | 0 | ValorCell cell2 = new ValorCell(valor.getValor().toString(), valor, |
101 | 0 | 20 + x, 20 + y); |
102 | 0 | |
103 | 0 | return cell2; |
104 | |
} |
105 | |
|
106 | |
public static CondicionalCell criaCondicao(Filtro filtro, int x, int y, |
107 | |
Step step, Fluxo flow, CasoUso useCase) { |
108 | 0 | |
109 | 0 | if (filtro.getTipoFiltro() == 2) { |
110 | 0 | return new CondicionalCell(filtro.getClasse(), x, y, step, flow, |
111 | 0 | useCase, filtro); |
112 | 0 | } else { |
113 | 0 | if (filtro.getTipoFiltro() == 0) { |
114 | 0 | return new CondicionalCell("Filtro Dado V�lido", x, y, step, |
115 | 0 | flow, useCase, filtro); |
116 | 0 | } else { |
117 | 0 | return new CondicionalCell("Filtro Dado Inv�lido", x, y, step, |
118 | 0 | flow, useCase, filtro); |
119 | |
} |
120 | |
} |
121 | |
|
122 | |
} |
123 | |
|
124 | |
public static FiltroEdge criaLinkCondicao(CondicionalCell condicional, |
125 | |
StepCell step) { |
126 | 0 | |
127 | 0 | FiltroEdge edge = new FiltroEdge(); |
128 | 0 | |
129 | 0 | GraphConstants.setEndFill(edge.getAttributes(), true); |
130 | 0 | GraphConstants.setLineStyle(edge.getAttributes(), |
131 | 0 | GraphConstants.STYLE_SPLINE); |
132 | 0 | |
133 | 0 | edge.setSource(step.getChildAt(0)); |
134 | 0 | edge.setTarget(condicional.getChildAt(0)); |
135 | 0 | condicional.setFiltroEdge(edge); |
136 | 0 | return edge; |
137 | |
|
138 | |
} |
139 | |
|
140 | 0 | public static DataCell criaDado(DadosTeste data, int x, int y, Step step) { |
141 | 0 | DataCell cell2 = new DataCell(data.getName(), data, 20 + x, 20 + y, |
142 | 0 | step); |
143 | 0 | |
144 | 0 | return cell2; |
145 | |
} |
146 | |
|
147 | 0 | public static LinkEdge criaLink(StepCell origem, StepCell destino, Link link) { |
148 | 0 | LinkEdge edge = new LinkEdge(link.getProbabilidade(), link, origem |
149 | 0 | .getStep()); |
150 | 0 | edge.setLink(link); |
151 | 0 | GraphConstants.setLineStyle(edge.getAttributes(), |
152 | 0 | GraphConstants.STYLE_SPLINE); |
153 | 0 | int arrow = GraphConstants.ARROW_CLASSIC; |
154 | 0 | GraphConstants.setLineEnd(edge.getAttributes(), arrow); |
155 | 0 | GraphConstants.setEndFill(edge.getAttributes(), true); |
156 | 0 | |
157 | 0 | edge.setSource(origem.getChildAt(0)); |
158 | 0 | edge.setTarget(destino.getChildAt(0)); |
159 | 0 | origem.setLink(edge); |
160 | 0 | origem.getLinks().add(edge); |
161 | 0 | return edge; |
162 | |
} |
163 | |
|
164 | |
public static DefaultEdge criaLink(StateFlowCell origem, StepCell destino, |
165 | 0 | Link link) { |
166 | 0 | DefaultEdge edge = new DefaultEdge(link.getProbabilidade()); |
167 | 0 | |
168 | 0 | GraphConstants.setLineStyle(edge.getAttributes(), |
169 | 0 | GraphConstants.STYLE_SPLINE); |
170 | 0 | int arrow = GraphConstants.ARROW_CLASSIC; |
171 | 0 | GraphConstants.setLineEnd(edge.getAttributes(), arrow); |
172 | 0 | GraphConstants.setEndFill(edge.getAttributes(), true); |
173 | 0 | |
174 | 0 | edge.setSource(origem.getChildAt(0)); |
175 | 0 | edge.setTarget(destino.getChildAt(0)); |
176 | 0 | |
177 | 0 | return edge; |
178 | |
} |
179 | |
|
180 | |
public static DefaultEdge criaLink(StepCell origem, StateFlowCell destino, |
181 | |
Link link) { |
182 | 0 | |
183 | 0 | DefaultEdge edge = new DefaultEdge(link.getProbabilidade()); |
184 | 0 | |
185 | 0 | GraphConstants.setLineStyle(edge.getAttributes(), |
186 | 0 | GraphConstants.STYLE_SPLINE); |
187 | 0 | int arrow = GraphConstants.ARROW_CLASSIC; |
188 | 0 | GraphConstants.setLineEnd(edge.getAttributes(), arrow); |
189 | 0 | GraphConstants.setEndFill(edge.getAttributes(), true); |
190 | 0 | |
191 | 0 | edge.setSource(origem.getChildAt(0)); |
192 | 0 | edge.setTarget(destino.getChildAt(0)); |
193 | 0 | |
194 | 0 | return edge; |
195 | |
} |
196 | |
|
197 | |
public static DefaultEdge criaLink(StateFlowCell origem, |
198 | 0 | StateFlowCell destino, Link link) { |
199 | 0 | DefaultEdge edge = new DefaultEdge(link.getProbabilidade()); |
200 | 0 | |
201 | 0 | GraphConstants.setLineStyle(edge.getAttributes(), |
202 | 0 | GraphConstants.STYLE_SPLINE); |
203 | 0 | int arrow = GraphConstants.ARROW_CLASSIC; |
204 | 0 | GraphConstants.setLineEnd(edge.getAttributes(), arrow); |
205 | 0 | GraphConstants.setEndFill(edge.getAttributes(), true); |
206 | 0 | |
207 | 0 | edge.setSource(origem.getChildAt(0)); |
208 | 0 | edge.setTarget(destino.getChildAt(0)); |
209 | |
|
210 | 0 | |
211 | 0 | return edge; |
212 | |
} |
213 | |
|
214 | |
} |