This repository has been archived by the owner on Jan 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Manhattan routing improved to avoid crossing through diagram elements.
- Loading branch information
1 parent
50858f0
commit 2817d55
Showing
10 changed files
with
630 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
client/packages/sprotty-client/src/features/change-bounds/edges.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2019 EclipseSource and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
import { Action, KeyListener, SModelRoot } from "sprotty/lib"; | ||
import { matchesKeystroke } from "sprotty/lib/utils/keyboard"; | ||
|
||
import { ElementAndRoutingPoints } from "../tools/change-bounds-tool"; | ||
|
||
export class SaveModelEdgesAction implements Action { | ||
static readonly KIND = "saveModelEdges"; | ||
readonly kind = SaveModelEdgesAction.KIND; | ||
constructor(public newRoutingPoints: ElementAndRoutingPoints[]) { } | ||
} | ||
|
||
export class SaveModelKeyboardListener extends KeyListener { | ||
keyDown(element: SModelRoot, event: KeyboardEvent): Action[] { | ||
if (matchesKeystroke(event, 'KeyS', 'ctrlCmd')) { | ||
return [new SaveModelEdgesAction([])]; | ||
} | ||
return []; | ||
} | ||
} |
442 changes: 436 additions & 6 deletions
442
client/packages/sprotty-client/src/features/tools/change-bounds-tool.ts
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...r/glsp-api/src/main/java/com/eclipsesource/glsp/api/action/kind/SaveModelEdgesAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.eclipsesource.glsp.api.action.kind; | ||
|
||
import java.util.List; | ||
|
||
import com.eclipsesource.glsp.api.action.Action; | ||
import com.eclipsesource.glsp.api.model.ElementAndRoutingPoints; | ||
|
||
public class SaveModelEdgesAction extends Action{ | ||
|
||
private List<ElementAndRoutingPoints> newRoutingPoints; | ||
|
||
public SaveModelEdgesAction() { | ||
super(Action.Kind.SAVE_MODEL_EDGES); | ||
} | ||
|
||
public SaveModelEdgesAction(List<ElementAndRoutingPoints> elementAndRoutingPoints) { | ||
this(); | ||
this.newRoutingPoints = elementAndRoutingPoints; | ||
} | ||
|
||
public List<ElementAndRoutingPoints> getNewRoutingPoints() { | ||
return newRoutingPoints; | ||
} | ||
|
||
public void setNewRoutingPoints(List<ElementAndRoutingPoints> newRoutingPoints) { | ||
this.newRoutingPoints = newRoutingPoints; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "SaveModelEdgesAction [newRoutingPoints=" + newRoutingPoints + "]"; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
} |
64 changes: 64 additions & 0 deletions
64
server/glsp-api/src/main/java/com/eclipsesource/glsp/api/model/ElementAndRoutingPoints.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.eclipsesource.glsp.api.model; | ||
|
||
import java.util.List; | ||
|
||
import com.eclipsesource.glsp.graph.GPoint; | ||
|
||
public class ElementAndRoutingPoints { | ||
|
||
private String elementId; | ||
private List<GPoint> routingPoints; | ||
|
||
|
||
public String getElementId() { | ||
return elementId; | ||
|
||
} | ||
public void setElementId(String elementId) { | ||
this.elementId = elementId; | ||
} | ||
public List<GPoint> getRoutingPoints() { | ||
return routingPoints; | ||
} | ||
public void setRoutingPoints(List<GPoint> routingPoints) { | ||
this.routingPoints = routingPoints; | ||
} | ||
@Override | ||
public String toString() { | ||
return "ElementAndRoutingPoints [elementId=" + elementId + ", routingPoints=" + routingPoints + "]"; | ||
} | ||
@Override | ||
public int hashCode() { | ||
final int prime = 31; | ||
int result = 1; | ||
result = prime * result + ((elementId == null) ? 0 : elementId.hashCode()); | ||
result = prime * result + ((routingPoints == null) ? 0 : routingPoints.hashCode()); | ||
return result; | ||
} | ||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) | ||
return true; | ||
if (obj == null) | ||
return false; | ||
if (getClass() != obj.getClass()) | ||
return false; | ||
ElementAndRoutingPoints other = (ElementAndRoutingPoints) obj; | ||
if (elementId == null) { | ||
if (other.elementId != null) | ||
return false; | ||
} else if (!elementId.equals(other.elementId)) | ||
return false; | ||
if (routingPoints == null) { | ||
if (other.routingPoints != null) | ||
return false; | ||
} else if (!routingPoints.equals(other.routingPoints)) | ||
return false; | ||
return true; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
} |
47 changes: 47 additions & 0 deletions
47
...rver/src/main/java/com/eclipsesource/glsp/server/actionhandler/SaveModelEdgesHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.eclipsesource.glsp.server.actionhandler; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import org.apache.log4j.Logger; | ||
import org.eclipse.emf.common.util.EList; | ||
|
||
import com.eclipsesource.glsp.api.action.Action; | ||
import com.eclipsesource.glsp.api.action.kind.SaveModelEdgesAction; | ||
import com.eclipsesource.glsp.api.model.ElementAndRoutingPoints; | ||
import com.eclipsesource.glsp.api.model.GraphicalModelState; | ||
import com.eclipsesource.glsp.graph.GEdge; | ||
import com.eclipsesource.glsp.graph.GModelElement; | ||
import com.eclipsesource.glsp.graph.GPoint; | ||
import com.google.inject.Inject; | ||
|
||
public class SaveModelEdgesHandler extends AbstractActionHandler{ | ||
|
||
private static final Logger LOG = Logger.getLogger(SaveModelActionHandler.class); | ||
|
||
@Inject | ||
private ModelSubmissionHandler modelSubmissionHandler; | ||
|
||
@Override | ||
public boolean handles(Action action) { | ||
return action instanceof SaveModelEdgesAction; | ||
} | ||
@Override | ||
protected Optional<Action> execute(Action action, GraphicalModelState modelState) { | ||
|
||
SaveModelEdgesAction saveModelEdgesAction = (SaveModelEdgesAction)action; | ||
List<ElementAndRoutingPoints> elementAndRoutingPointsList = saveModelEdgesAction.getNewRoutingPoints(); | ||
for(ElementAndRoutingPoints elementAndRoutingPoints : elementAndRoutingPointsList) { | ||
Optional<GModelElement> modelElement = modelState.getIndex().get(elementAndRoutingPoints.getElementId()); | ||
if(modelElement.isPresent() && modelElement.get() instanceof GEdge) { | ||
GEdge edge = (GEdge) modelElement.get(); | ||
EList<GPoint> routingPoints = edge.getRoutingPoints(); | ||
routingPoints.clear(); | ||
routingPoints.addAll(elementAndRoutingPoints.getRoutingPoints()); | ||
|
||
} | ||
|
||
} | ||
return modelSubmissionHandler.doSubmitModel(true, modelState); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters