diff --git a/AlgebraicDataflowArchitectureModel/src/application/editor/stages/DependencyCellEditor.java b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/DependencyCellEditor.java index 889b232..6de3df5 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/editor/stages/DependencyCellEditor.java +++ b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/DependencyCellEditor.java @@ -49,12 +49,12 @@ } /** - * Determines whether the given cell is an interface node (rhombus shape) + * Determines whether the given cell is an interface node (Interface shape) */ private boolean isInterfaceNode(mxCell cell) { if (cell == null || !cell.isVertex()) return false; String style = cell.getStyle(); - return style != null && style.contains("shape=rhombus"); + return style != null && style.contains("shape=interface"); } /** @@ -219,7 +219,7 @@ // Remove the original edge graphComponent.getGraph().getModel().remove(edgeCell); - // Insert the interface node (rhombus) into the DEPENDENCY_LAYER + // Insert the interface node (Interface) into the DEPENDENCY_LAYER mxCell interfaceNode = (mxCell) graphComponent.getGraph().insertVertex( layerCell, null, @@ -228,7 +228,7 @@ midY - ddmStage.DEPENDENCY_NODE_SIZE / 2, ddmStage.DEPENDENCY_NODE_SIZE, ddmStage.DEPENDENCY_NODE_SIZE, - "shape=rhombus;fillColor=#BBFFBB;perimeter=rhombusPerimeter;resizable=0;" + "shape=interface;strokeColor=green;fillColor=#BBFFBB;perimeter=rectanglePerimeter;resizable=0;" ); // Get the original edge's style and value diff --git a/AlgebraicDataflowArchitectureModel/src/application/editor/stages/DependencyModelingStage.java b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/DependencyModelingStage.java index b55a78f..0887d60 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/editor/stages/DependencyModelingStage.java +++ b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/DependencyModelingStage.java @@ -4,6 +4,7 @@ import application.editor.Editor; import application.editor.FlowCellEditor; import application.editor.Stage; +import com.mxgraph.canvas.mxGraphics2DCanvas; import com.mxgraph.model.mxCell; import com.mxgraph.model.mxGeometry; import com.mxgraph.model.mxGraphModel; @@ -21,6 +22,7 @@ import models.dataConstraintModel.ResourcePath; import models.dataFlowModel.*; import models.dependencyModel.DependencyGraph; +import models.dependencyModel.mxInterfaceShape; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -28,6 +30,11 @@ import java.util.*; public class DependencyModelingStage extends Stage { + + static { + mxGraphics2DCanvas.putShape("interface", new mxInterfaceShape()); + } + public final int DEPENDENCY_NODE_SIZE = 50; private DependencyModelingStageStatus curState = null; @@ -336,7 +343,7 @@ if (srcCell != null && dstCell != null) { String style = "strokeWidth=3;strokeColor=green;movable=false"; if (callEdge.getSelectedOption() == models.dataFlowModel.PushPullValue.PULL) { - style = "strokeWidth=3;strokeColor=green;dashed=true;movable=false"; + style = "strokeWidth=3;strokeColor=green;movable=false"; } graph.insertEdge(layerCell, null, null, srcCell, dstCell, style); } diff --git a/AlgebraicDataflowArchitectureModel/src/models/dependencyModel/mxInterfaceShape.java b/AlgebraicDataflowArchitectureModel/src/models/dependencyModel/mxInterfaceShape.java new file mode 100644 index 0000000..2ceeda3 --- /dev/null +++ b/AlgebraicDataflowArchitectureModel/src/models/dependencyModel/mxInterfaceShape.java @@ -0,0 +1,36 @@ +package models.dependencyModel; + +import com.mxgraph.canvas.mxGraphics2DCanvas; +import com.mxgraph.shape.mxBasicShape; +import com.mxgraph.view.mxCellState; + +import java.awt.*; + +public class mxInterfaceShape extends mxBasicShape { + + @Override + public void paintShape(mxGraphics2DCanvas canvas, mxCellState state) { + Rectangle rect = state.getRectangle(); + int x = rect.x; + int y = rect.y; + int w = rect.width; + int h = rect.height; + + int adjustedH = (int)(h * 2.0 / 3.0); + int yOffset = (h - adjustedH) / 2; + + int offset = (int)(w * 0.2); + + int[] xPoints = {x + offset, x + w, x + w - offset, x}; + int[] yPoints = {y + yOffset, y + yOffset, y + yOffset + adjustedH, y + yOffset + adjustedH}; + + Polygon parallelogram = new Polygon(xPoints, yPoints, 4); + + if (canvas.getGraphics() != null) { + canvas.getGraphics().setColor(getFillColor(canvas, state)); + canvas.getGraphics().fillPolygon(parallelogram); + canvas.getGraphics().setColor(getStrokeColor(canvas, state)); + canvas.getGraphics().drawPolygon(parallelogram); + } + } +}