58
44
if (myObject instanceof InhibitorArc) {
59
45
menuItem = new JMenuItem(new EditWeightAction(contentPane,
61
47
menuItem.setText("Edit Weight");
62
48
popup.insert(menuItem, popupIndex++);
64
menuItem = new JMenuItem(new SplitArcAction((Arc)myObject,
50
menuItem = new JMenuItem(new SplitArcAction((Arc) myObject, e
66
52
menuItem.setText("Split Arc Segment");
67
53
popup.insert(menuItem, popupIndex++);
69
popup.insert(new JPopupMenu.Separator(), popupIndex++);
70
/*CB Joakim Byg - timed arcs should not be handled here*/
71
} else if (myObject instanceof NormalArc && !(myObject instanceof TimedArc) && !(myObject instanceof TransportArc)) {
73
if (((NormalArc)myObject).isJoined()){
77
if (((NormalArc)myObject).getSource() instanceof Place){
78
PTArc = (NormalArc)myObject;
79
TPArc = ((NormalArc)myObject).getInverse();
81
PTArc = ((NormalArc)myObject).getInverse();
82
TPArc = (NormalArc)myObject;
85
// if (!PTArc.isTagged()) { //pendentnou
86
menuItem = new JMenuItem(new EditWeightAction(contentPane, PTArc));
87
menuItem.setText("Edit Weight (PT Arc)");
88
popup.insert(menuItem, popupIndex++);
89
// menuItem = new JMenuItem(
90
// new EditTaggedAction(contentPane, PTArc));
91
// menuItem.setText("Make Tagged (PT Arc)");
92
// popup.insert(menuItem, popupIndex++);
94
// menuItem = new JMenuItem(
95
// new EditTaggedAction(contentPane, PTArc));
96
// menuItem.setText("Make Non-Tagged (PT Arc)");
97
// popup.insert(menuItem, popupIndex++);
99
popup.insert(new JPopupMenu.Separator(), popupIndex++);
101
// if (!TPArc.isTagged()) {
102
menuItem = new JMenuItem(new EditWeightAction(contentPane, TPArc));
103
menuItem.setText("Edit Weight (TP Arc)");
104
popup.insert(menuItem, popupIndex++);
105
// menuItem = new JMenuItem(
106
// new EditTaggedAction(contentPane, TPArc));
107
// menuItem.setText("Make Tagged (TP Arc)");
108
// popup.insert(menuItem, popupIndex++);
110
// menuItem = new JMenuItem(
111
// new EditTaggedAction(contentPane, TPArc));
112
// menuItem.setText("Make Non-Tagged (TP Arc)");
113
// popup.insert(menuItem, popupIndex++);
116
popup.insert(new JPopupMenu.Separator(), popupIndex++);
118
menuItem = new JMenuItem(new InsertPointAction((Arc)myObject,
120
menuItem.setText("Insert Point");
122
menuItem = new JMenuItem(new SplitArcAction((Arc)myObject,
124
menuItem.setText("Split Arc Segment");
126
popup.insert(menuItem, popupIndex++);
128
menuItem = new JMenuItem(
129
new SplitArcsAction((NormalArc)myObject, true));
130
menuItem.setText("Split Arcs (PT / TP)");
131
popup.insert(menuItem, popupIndex++);
133
popup.insert(new JPopupMenu.Separator(), popupIndex++);
135
menuItem = new JMenuItem(new DeleteInverseArcAction(PTArc));
136
menuItem.setText("Delete (PT Arc)");
137
popup.insert(menuItem, popupIndex++);
139
menuItem = new JMenuItem(new DeleteInverseArcAction(TPArc));
140
menuItem.setText("Delete (TP Arc)");
141
popup.insert(menuItem, popupIndex++);
143
menuItem = new JMenuItem(new DeleteBothAction((NormalArc)myObject));
144
menuItem.setText("Delete Both");
145
popup.insert(menuItem, 8);
148
// if(!((NormalArc)myObject).isTagged()) {
149
//menuItem = new JMenuItem(new EditWeightAction(contentPane,
151
//menuItem.setText("Edit Weight");
152
//popup.insert(menuItem, popupIndex++);
155
// menuItem = new JMenuItem(
156
// new EditTaggedAction(contentPane,(NormalArc)myObject));
157
// if (((NormalArc)myObject).isTagged()) {
158
// menuItem.setText("Make Non-Tagged");
160
// menuItem.setText("Make Tagged");
162
// popup.insert(menuItem, popupIndex++);
164
//menuItem = new JMenuItem(new SplitArcAction((Arc)myObject,
166
//menuItem.setText("Split Arc Segment");
168
if(CreateGui.getModel().isUsingColors() && myObject instanceof ColoredOutputArc){
169
menuItem = new JMenuItem();
170
menuItem.setText("Properties");
171
menuItem.addActionListener(new ActionListener(){
172
public void actionPerformed(ActionEvent e) {
173
showOutputValueEditor((ColoredOutputArc)myObject);
176
popup.insert(menuItem, popupIndex++);
179
menuItem = new JMenuItem(new SplitArcAction((Arc)myObject,
181
menuItem.setText("Insert Point");
182
popup.insert(menuItem, popupIndex++);
185
if (((NormalArc)myObject).hasInverse()){
186
menuItem = new JMenuItem(
187
new SplitArcsAction((NormalArc)myObject, false));
189
menuItem.setText("Join Arcs (PT / TP)");
190
popup.insert(menuItem, popupIndex++);
192
popup.insert(new JPopupMenu.Separator(), popupIndex);
55
popup.insert(new JPopupMenu.Separator(), popupIndex++);
56
/* CB Joakim Byg - timed arcs should not be handled here */
57
} else if (myObject instanceof TimedOutputArcComponent
58
&& !(myObject instanceof TimedInputArcComponent)
59
&& !(myObject instanceof TransportArcComponent)) {
62
menuItem = new JMenuItem(new SplitArcAction((Arc) myObject, e
64
menuItem.setText("Insert Point");
65
popup.insert(menuItem, popupIndex++);
67
popup.insert(new JPopupMenu.Separator(), popupIndex);
200
73
public void mousePressed(MouseEvent e) {
201
74
super.mousePressed(e);
202
if (CreateGui.getApp().isEditionAllowed() == false){
75
if (CreateGui.getApp().isEditionAllowed() == false) {
205
if (e.getClickCount() == 2){
206
Arc arc = (Arc)myObject;
207
if (e.isControlDown()){
78
if (e.getClickCount() == 2) {
79
Arc arc = (Arc) myObject;
80
if (e.isControlDown()) {
208
81
CreateGui.getView().getUndoManager().addNewEdit(
209
82
arc.getArcPath().insertPoint(
210
new Point2D.Float(arc.getX() + e.getX(),
211
arc.getY() + e.getY()), e.isAltDown()));
83
new Point2D.Float(arc.getX() + e.getX(), arc
85
+ e.getY()), e.isAltDown()));
213
if(CreateGui.getModel().isUsingColors()){
214
if(arc instanceof ColoredOutputArc){
215
showOutputValueEditor((ColoredOutputArc)arc);
218
arc.getSource().select();
219
arc.getTarget().select();
87
arc.getSource().select();
88
arc.getTarget().select();
227
private void showOutputValueEditor(ColoredOutputArc arc) {
228
EscapableDialog guiDialog =
229
new EscapableDialog(CreateGui.getApp(), Pipe.TOOL + " " + Pipe.VERSION, true);
231
Container contentPane = guiDialog.getContentPane();
234
contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS));
236
// 2 Add Place editor
237
contentPane.add( new OutputValueEditorPanel(guiDialog.getRootPane(), arc, CreateGui.getModel(), CreateGui.getView().getUndoManager()));
239
guiDialog.setResizable(false);
241
// Make window fit contents' preferred size
244
// Move window to the middle of the screen
245
guiDialog.setLocationRelativeTo(null);
246
guiDialog.setVisible(true);
251
96
public void mouseDragged(MouseEvent e) {
252
97
switch (CreateGui.getApp().getMode()) {
257
Arc currentObject = (Arc)myObject;
102
Arc currentObject = (Arc) myObject;
258
103
Point oldLocation = currentObject.getLocation();
259
104
// Calculate translation in mouse
260
105
int transX = (Grid.getModifiedX(e.getX() - dragInit.x));
261
106
int transY = (Grid.getModifiedY(e.getY() - dragInit.y));
262
((GuiView)contentPane).getSelectionObject().translateSelection(
107
((DrawingSurfaceImpl) contentPane).getSelectionObject()
108
.translateSelection(transX, transY);
264
109
dragInit.translate(
265
110
-(currentObject.getLocation().x - oldLocation.x - transX),
266
111
-(currentObject.getLocation().y - oldLocation.y - transY));
272
public void mouseWheelMoved (MouseWheelEvent e) {
116
public void mouseWheelMoved(MouseWheelEvent e) {
274
if (CreateGui.getApp().isEditionAllowed() == false){
118
if (CreateGui.getApp().isEditionAllowed() == false) {
278
Arc arc = ((Arc)myObject);
279
if (arc instanceof NormalArc){
122
Arc arc = ((Arc) myObject);
123
if (arc instanceof TimedOutputArcComponent) {
281
// if (e.isControlDown()) {
282
// if (arc.getWeight() == 1) {
283
// if (((NormalArc)arc).hasInvisibleInverse()) {
284
// if (arc.getSource() instanceof Place){
285
// if (e.isShiftDown()) {
286
// arc = ((NormalArc)arc).getInverse();
289
// if (!e.isShiftDown()) {
290
// arc = ((NormalArc)arc).getInverse();
294
// CreateGui.getView().getUndoManager().addNewEdit(
295
// ((NormalArc)arc).setTagged(!((NormalArc)arc).isTagged()));
300
if (((NormalArc)arc).hasInvisibleInverse()) {
301
if (arc.getSource() instanceof Place){
302
if (e.isShiftDown()) {
303
arc = ((NormalArc)arc).getInverse();
306
if (!e.isShiftDown()) {
307
arc = ((NormalArc)arc).getInverse();
125
// if (e.isControlDown()) {
126
// if (arc.getWeight() == 1) {
127
// if (((NormalArc)arc).hasInvisibleInverse()) {
128
// if (arc.getSource() instanceof Place){
129
// if (e.isShiftDown()) {
130
// arc = ((NormalArc)arc).getInverse();
133
// if (!e.isShiftDown()) {
134
// arc = ((NormalArc)arc).getInverse();
138
// CreateGui.getView().getUndoManager().addNewEdit(
139
// ((NormalArc)arc).setTagged(!((NormalArc)arc).isTagged()));
144
* if (((NormalArc)arc).hasInvisibleInverse()) { if (arc.getSource()
145
* instanceof Place){ if (e.isShiftDown()) { arc =
146
* ((NormalArc)arc).getInverse(); } } else { if (!e.isShiftDown()) {
147
* arc = ((NormalArc)arc).getInverse(); } } }
313
int oldWeight = arc.getWeight();
314
int newWeight = oldWeight - e.getWheelRotation();
318
if (newWeight != oldWeight) {
319
CreateGui.getView().getUndoManager().addNewEdit(
320
arc.setWeight(newWeight));
327
class SplitArcsAction extends AbstractAction {
332
private static final long serialVersionUID = 6647793002696424279L;
337
public SplitArcsAction(NormalArc _arc, boolean _joined){
342
public void actionPerformed(ActionEvent e) {
344
CreateGui.getView().getUndoManager().addNewEdit(
347
CreateGui.getView().getUndoManager().addNewEdit(
356
class DeleteInverseArcAction extends AbstractAction {
361
private static final long serialVersionUID = -7956567157135376160L;
362
NormalArc arc, inverse;
366
public DeleteInverseArcAction(NormalArc _arc){
368
inverse = arc.getInverse();
369
switchArcs = arc.inView();
373
public void actionPerformed(ActionEvent e) {
374
UndoManager undoManager = CreateGui.getView().getUndoManager();
377
undoManager.addNewEdit(arc.split());
379
undoManager.addNewEdit(inverse.split());
381
undoManager.deleteSelection(arc);
151
* int oldWeight = arc.getWeight(); int newWeight = oldWeight -
152
* e.getWheelRotation(); if (newWeight < 1) { newWeight = 1; } if
153
* (newWeight != oldWeight) {
154
* CreateGui.getView().getUndoManager().addNewEdit(
155
* arc.setWeight(newWeight)); arc.repaint(); }