-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbroken.txt
283 lines (204 loc) · 7.56 KB
/
broken.txt
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
/*import javax.swing.JLabel;
package org.workcraft.util;
import org.workcraft.dom.visual.VisualModel;
import org.workcraft.interop.Exporter;
public class Crap {
if (model instanceof VisualModel)
if (exporter.getCompatibility(model) == Exporter.NOT_COMPATIBLE)
if (exporter.getCompatibility(((VisualModel)model).getMathModel()) == Exporter.NOT_COMPATIBLE)
throw new RuntimeException ("Exporter is not applicable to the model.");
else
model = ((VisualModel)model).getMathModel();
create a DotExporter
implement LayoutableBalsaCircuit
MainMenu.setMenuForWorkspaceEntry:
separation between visual and math exporters
if (!haveVisual)
addExportSeparator("Visual");
private void addExportSeparator (String text) {
mnExport.add(new JLabel(text));
mnExport.addSeparator();
}
Implement DotGFile:
if (entry != null && entry.getModelEntry() != null && entry.getModelEntry().getMathModel() instanceof STGModel)
return true;
if (arg.getNode().endsWith(".g"))
return true;
return false;
DotGProvider.java should be used.
VisualScenario.shape() :(
VisualScenario.graphicalContent() :(
VisualCircuitComponent.shape() :(
Automatically create a visual model:
ModelDescriptor descriptor = modelEntry.getDescriptor();
VisualModel visualModel = (modelEntry.getModel() instanceof VisualModel) ? (VisualModel) modelEntry.getModel() : null;
if (visualModel == null)
try {
VisualModelDescriptor vmd = descriptor.getVisualModelDescriptor();
if (vmd == null)
throw new RuntimeException();
visualModel = vmd.create((MathModel)modelEntry.getModel(), modelEntry.getStorage());
modelEntry.setModel(visualModel);
DotLayout layout = new DotLayout(framework);
layout.applyTo(we).run();
} catch (LayoutException e) {
// Layout failed for whatever reason, ignore
} catch (ServiceNotAvailableException e) {
// Layout failed for whatever reason, ignore
} catch (VisualModelInstantiationException e) {
JOptionPane.showMessageDialog(MainWindow.this, "A visual model could not be created for the selected model.\nPlease refer to the Problems window for details.\n", "Error", JOptionPane.ERROR_MESSAGE);
e.printStackTrace();
return null;
}
Reflectively get tools:
Class<? extends CustomToolsProvider> customTools = Annotations.getCustomToolsProvider(editor.getModel().getClass());
if(customTools != null)
{
boolean selected = true;
CustomToolsProvider provider = null;
try {
provider = customTools.getConstructor().newInstance();
} catch (Exception e) {
e.printStackTrace();
}
if(provider != null)
for(GraphEditorTool tool : provider.getTools(editor))
{
addTool(tool, selected);
selected = false;
}
}
else
{
throw new NotImplementedException();
}
for (Class<? extends GraphEditorTool> tool : Annotations.getCustomTools(editor.getModel().getClass()))
try {
addTool(tool.newInstance() , false);
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
Track model changes!
workspaceEntry.setChanged(true);
read-only properties in property editor?
PropertyEditorTableModel.isCellEditable
property-editor: "#EXCEPTION"?
property-editor: need to pass to the renderer the following?
focus, selected, coordinates
property-editor: find out why this was needed:
@Override
public void editingStopped(ChangeEvent e) {
TableCellEditor editor = getCellEditor();
if (editor != null) {
Object value = editor.getCellEditorValue();
try
{
setValueAt(value, editingRow, editingColumn);
removeEditor();
}
catch(Throwable t)
{
ExceptionDialog.show(null, "Cannot change property", t);
PrintStream p = null;
PrintWriter w = null;
t.printStackTrace(p);
t.printStackTrace(w);
JOptionPane.showMessageDialog(null, t.getMessage() + "\n", "Cannot change property", JOptionPane.WARNING_MESSAGE);
}
}
}
currentLevel: move outside of the model, and:
public void setValue(Container value) {
selection.setValue(HashTreePSet.<Node>empty());
super.setValue(value);
};
protected void currentLevelDown(VisualModel model) {
Collection<? extends Node> selection = eval(model.selection());
if(selection.size() == 1)
{
Node selectedNode = selection.iterator().next();
if(selectedNode instanceof Container)
model.currentLevel().setValue((Container)selectedNode);
}
}
protected void currentLevelUp(VisualModel model) {
Container level = eval(model.currentLevel());
Container parent = Hierarchy.getNearestAncestor(GlobalCache.eval(level.parent()), Container.class);
if(parent!=null)
{
model.currentLevel().setValue(parent);
model.selection().setValue(HashTreePSet.<Node>singleton(level));
}
}
also, make group(), ungroup(), clear() behave the same way as before (in relation to selection and currentLevel), also filter selection by existing nodes
private Collection<Node> getGroupableSelection()
{
ArrayList<Node> result = new ArrayList<Node>();
for(Node node : getOrderedCurrentLevelSelection())
if(node instanceof VisualTransformableNode)
result.add((VisualTransformableNode)node);
return result;
}
public Collection<Node> getOrderedCurrentLevelSelection() {
List<Node> result = new ArrayList<Node>();
for(Node node : GlobalCache.eval(eval(currentLevel).children()))
{
if(GlobalCache.eval(selection).contains(node) && node instanceof VisualNode)
result.add((VisualNode)node);
}
return result;
}
properties: auto-collect them!
new ExpressionBase<Properties>() {
@Override
protected Properties evaluate(EvaluationContext context) {
Collection<? extends Node> selection = context.resolve(visualModel.selection());
if (selection.size() == 1) {
Node selected = selection.iterator().next();
Mix mix = new Mix();
Properties visualModelProperties = visualModel.getProperties(selected);
mix.add(visualModelProperties);
if (selected instanceof Properties)
mix.add((Properties)selected);
if (selected instanceof DependentNode) {
for (Node n : ((DependentNode)selected).getMathReferences()) {
mix.add(visualModel.getMathModel().getProperties(n));
if (n instanceof Properties)
mix.add((Properties)n);
}
}
if(mix.isEmpty())
return null;
else
return mix;
}
return null;
}
});
MiscellaneousModelActions: implement them
DefaultAnchorGenerator: make sure it works
HitTester: stick this logic somewhere?
/*return new HitTester<Node>() {
@Override
public Node hitTest(Point2D point) {
return HitMan.hitTestForSelection(tp, point, model);
}
private Point2D transformToCurrentSpace(Point2D pointInRootSpace)
{
Point2D newPoint = new Point2D.Double();
TransformHelper.getTransform(model.getRoot(), eval(model.currentLevel())).transform(pointInRootSpace, newPoint);
return newPoint;
}
@Override
public PSet<Node> boxHitTest(Point2D boxStart, Point2D boxEnd) {
boxStart = transformToCurrentSpace(boxStart); // TODO: find out why current
boxEnd = transformToCurrentSpace(boxEnd);
return HashTreePSet.from(HitMan.boxHitTest(tp, eval(model.currentLevel()), boxStart, boxEnd));
}
};*/
p.registerClass(Exporter.class, AbstractSVGExporter.class);
visual connection: DrawableNew, ReflectiveTouchable
}
*/