diff --git a/AlgebraicDataflowArchitectureModel/models/Clock.dtram b/AlgebraicDataflowArchitectureModel/models/Clock.dtram new file mode 100644 index 0000000..380ceca --- /dev/null +++ b/AlgebraicDataflowArchitectureModel/models/Clock.dtram @@ -0,0 +1,27 @@ +model { +channel CIO1 { + out min(m, tick) == mod(m + 1, 60) +} +channel HourUpdate { + in hour(h, update(h')) == h' + out hour_hand(h_ang, update(h')) == h' / 6 * PI +} +channel MinUpdate { + in min(m, update(m')) == m' + out min_hand(m_ang, update(m')) == m' / 30 * PI +} +channel Clock { + in min(m, update(m')) == m' + out hour(h, update(m')) == if(eq(m', 0), mod(h + 1, 24), h) +} +} +geometry { + node c HourUpdate:520,340,30,30 + node c MinUpdate:520,100,30,30 + node c Clock:280,220,30,30 + node r min_hand:670,100,80,30 + node r min:250,100,80,30 + node r hour:270,340,80,30 + node r hour_hand:680,340,80,30 + node ioc CIO1:100,100,30,30 +} diff --git a/AlgebraicDataflowArchitectureModel/src/application/editor/Editor.java b/AlgebraicDataflowArchitectureModel/src/application/editor/Editor.java index 115c5fb..32629c8 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/editor/Editor.java +++ b/AlgebraicDataflowArchitectureModel/src/application/editor/Editor.java @@ -372,6 +372,9 @@ try { DAGLayout ctl = new DAGLayout(graph); ctl.execute(dataFlowLayer); +// for(int i = 0; i < root.getChildCount(); i++) { +// ctl.execute(root.getChildAt(i)); +// } } finally { graph.getModel().endUpdate(); } @@ -379,14 +382,15 @@ public void setTreeLayout() { mxCell root = (mxCell) graph.getDefaultParent(); - mxCell dataFlowLayer = (mxCell) root.getChildAt(Stage.DATA_FLOW_LAYER); graph.getModel().beginUpdate(); try { mxCompactTreeLayout ctl = new mxCompactTreeLayout(graph); ctl.setLevelDistance(100); // ctl.setHorizontal(false); ctl.setEdgeRouting(false); - ctl.execute(dataFlowLayer); + for(int i = 0; i < root.getChildCount(); i++) { + ctl.execute(root.getChildAt(i)); + } } finally { graph.getModel().endUpdate(); } @@ -394,11 +398,12 @@ public void setCircleLayout() { mxCell root = (mxCell) graph.getDefaultParent(); - mxCell dataFlowLayer = (mxCell) root.getChildAt(Stage.DATA_FLOW_LAYER); graph.getModel().beginUpdate(); try { mxCircleLayout ctl = new mxCircleLayout(graph); - ctl.execute(dataFlowLayer); + for(int i = 0; i < root.getChildCount(); i++) { + ctl.execute(root.getChildAt(i)); + } } finally { graph.getModel().endUpdate(); } diff --git a/AlgebraicDataflowArchitectureModel/src/application/editor/Stage.java b/AlgebraicDataflowArchitectureModel/src/application/editor/Stage.java index 7eadbbf..76cbb8c 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/editor/Stage.java +++ b/AlgebraicDataflowArchitectureModel/src/application/editor/Stage.java @@ -47,8 +47,8 @@ protected void showOnlyLayer(mxGraph graph, final int... argsOfLayers) { mxCell rootCell = (mxCell) graph.getDefaultParent(); if(rootCell== null) return; - if(rootCell.getChildCount() <= 0) return; - + if(rootCell.getChildCount() <= 0) return; + for(int i = 0; i < rootCell.getChildCount(); i++) { graph.getModel().setVisible(rootCell.getChildAt(i), false); } diff --git a/AlgebraicDataflowArchitectureModel/src/application/editor/stages/ControlFlowDelegationCellEditor.java b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/ControlFlowDelegationCellEditor.java index 0285782..a9bd803 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/editor/stages/ControlFlowDelegationCellEditor.java +++ b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/ControlFlowDelegationCellEditor.java @@ -1,15 +1,21 @@ package application.editor.stages; import java.util.EventObject; +import java.util.List; +import com.mxgraph.model.mxCell; import com.mxgraph.swing.mxGraphComponent; import application.editor.FlowCellEditor; -import models.controlFlowModel.CallEdge; import models.controlFlowModel.CallEdgeAttribute; import models.controlFlowModel.ControlFlowDelegator; +import models.controlFlowModel.ObjectNode; +import models.controlFlowModel.ObjectNodeAttribute; +import models.dataFlowModel.PushPullValue; public class ControlFlowDelegationCellEditor extends FlowCellEditor { + + private ControlFlowDelegationStageStatus curState = ControlFlowDelegationStageStatus.SELECTING_AN_EDGE; /************************************************************* * [ *constructor ] @@ -30,14 +36,34 @@ public void startEditing(Object cellObj, EventObject eventObj) { if( editingCell != null) stopEditing(true); - if( graphComponent.getGraph().getModel().isEdge(cellObj) ) { - CallEdgeAttribute callEdgeAttr = (CallEdgeAttribute)graphComponent.getGraph().getModel().getValue(cellObj); - - if(callEdgeAttr == null) return; - System.out.println("Edge: " + callEdgeAttr.getSelectedOption().name()); - ((ControlFlowDelegationStage)stage).getDelegatableNodes(callEdgeAttr.getCallEdge()); - } - + switch(curState) { + case SELECTING_AN_EDGE: + + if( graphComponent.getGraph().getModel().isEdge(cellObj) ) { + System.out.println("Selecting"); + CallEdgeAttribute callEdgeAttr = (CallEdgeAttribute)graphComponent.getGraph().getModel().getValue(cellObj); + + if(callEdgeAttr == null) return; + System.out.println("Edge: " + callEdgeAttr.getSelectedOption().name()); + + showDelegatableArea(callEdgeAttr); + + curState = ControlFlowDelegationStageStatus.SHOWING_DELEGATABLE_NODES; + } + break; + + case SHOWING_DELEGATABLE_NODES: + if( graphComponent.getGraph().getModel().isVertex(cellObj) ) { + System.out.println("move delegating state."); + // invocating delegation method + } + else { + System.out.println("cancel showing state."); + resetGraph(); + curState = ControlFlowDelegationStageStatus.SELECTING_AN_EDGE; + } + break; + } } /************************************************************* @@ -47,4 +73,70 @@ public void stopEditing(boolean cancel) { } + + /************************************************************* + * [ *private ] + /************************************************************* + * + */ + private void showDelegatableArea(final CallEdgeAttribute callEdgeAttr) { + mxCell root = (mxCell)graphComponent.getGraph().getDefaultParent(); + mxCell controlGraphLayer = (mxCell)root.getChildAt(stage.CONTROL_FLOW_LAYER); + + List delegatableNodes = ((ControlFlowDelegationStage)stage).getDelegatableNodes(callEdgeAttr.getCallEdge()); + + graphComponent.getGraph().getModel().beginUpdate(); + + try { + ObjectNode delegatingNode = callEdgeAttr.getSelectedOption().equals(PushPullValue.PUSH) + ? callEdgeAttr.getSourceObjectNode() + : callEdgeAttr.getDestinationObjectNode(); + + for(Object node : graphComponent.getGraph().getChildVertices(controlGraphLayer)) { + if( !(node instanceof mxCell) ) continue; + mxCell cell = (mxCell)node; + + ObjectNodeAttribute objNodeAttr = (ObjectNodeAttribute)cell.getValue(); + if(objNodeAttr == null) throw new NullPointerException(""); + + ObjectNode objNode = objNodeAttr.getObjectNode(); + if(delegatableNodes.contains(objNode)) // enable + graphComponent.getGraph().getModel().setStyle(cell, objNodeAttr.getEnableStyle()); + else // disable + graphComponent.getGraph().getModel().setStyle(cell, objNodeAttr.getDisableStyle()); + + // base-Node + if(delegatingNode.equals(objNodeAttr.getObjectNode())) + graphComponent.getGraph().getModel().setStyle(cell, objNodeAttr.getDefaultStyle()); + } + } + finally { + graphComponent.getGraph().getModel().endUpdate(); + } + } + + /************************************************************* + * + */ + private void resetGraph() { + mxCell root = (mxCell)graphComponent.getGraph().getDefaultParent(); + mxCell controlGraphLayer = (mxCell)root.getChildAt(stage.CONTROL_FLOW_LAYER); + + graphComponent.getGraph().getModel().beginUpdate(); + + try { + for(Object node : graphComponent.getGraph().getChildVertices(controlGraphLayer)) { + if( !(node instanceof mxCell) ) continue; + mxCell cell = (mxCell)node; + ObjectNodeAttribute objNodeAttr = (ObjectNodeAttribute)cell.getValue(); + if(objNodeAttr == null) throw new NullPointerException(""); + + graphComponent.getGraph().getModel().setStyle(cell, objNodeAttr.getDefaultStyle()); + } + } + finally { + graphComponent.getGraph().getModel().endUpdate(); + } + } + } diff --git a/AlgebraicDataflowArchitectureModel/src/application/editor/stages/ControlFlowDelegationStage.java b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/ControlFlowDelegationStage.java index 98e4725..aec3621 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/editor/stages/ControlFlowDelegationStage.java +++ b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/ControlFlowDelegationStage.java @@ -17,10 +17,12 @@ import models.controlFlowModel.ControlFlowDelegator; import models.controlFlowModel.ControlFlowGraph; import models.controlFlowModel.ObjectNode; +import models.controlFlowModel.ObjectNodeAttribute; import models.controlFlowModel.StatefulObjectNode; import models.dataConstraintModel.IdentifierTemplate; import models.dataFlowModel.DataFlowGraph; import models.dataFlowModel.ResourceNode; +import models.dataFlowModel.ResourceNodeAttribute; public class ControlFlowDelegationStage extends Stage { public final int PORT_DIAMETER = 8; @@ -97,9 +99,7 @@ * @param graph * @param dataFlowGraph */ - private mxGraph constructGraph(mxGraph graph, ControlFlowGraph controlFlowGraph) { - mxCell root = (mxCell) graph.getDefaultParent(); - + private mxGraph constructGraph(mxGraph graph, ControlFlowGraph controlFlowGraph) { showOnlyLayer(graph, CONTROL_FLOW_LAYER); // Creating Control-Flow and separeted Push/Pull which types of @@ -159,15 +159,32 @@ Map resNodeCells = new HashMap<>(); mxCell root = (mxCell)graph.getDefaultParent(); + mxCell nodeLayerCell = (mxCell)root.getChildAt(NODE_LAYER); mxCell layerCell = (mxCell)root.getChildAt(layerNumber); // create resource vertices for (ResourceNode resNode : controlFlowGraph.getDataFlowGraph().getResouceNodes()) { - IdentifierTemplate id = resNode.getIdentifierTemplate(); - Object resNodeObj = graph.insertVertex(layerCell, null, - id.getResourceName(), 20, 20, 80, 30, - "shape=ellipse;perimeter=ellipsePerimeter"); // insert a resource as a vertex - resNodeCells.put(resNode, resNodeObj); + ObjectNode objNode = controlFlowGraph.getPushCallGraph().getStatefulObjectNode(resNode) != null + ? controlFlowGraph.getPushCallGraph().getStatefulObjectNode(resNode) + : controlFlowGraph.getPullCallGraph().getStatefulObjectNode(resNode); + + for(int i =0; i < nodeLayerCell.getChildCount(); i++) { + mxCell nodeCell = (mxCell)nodeLayerCell.getChildAt(i); + if( !(nodeCell.getValue() instanceof ResourceNodeAttribute) ) continue; + + // Checking if the "node" has a cell of the data-flow-layer is the same as "resNode". + ResourceNodeAttribute resNodeAttr = (ResourceNodeAttribute)nodeCell.getValue(); + if( !resNodeAttr.getResourceNode().equals(resNode) ) continue; + + // Getting information from the cell in the data-flow-layer, + // After that, insert a resource as a vertex + ObjectNodeAttribute objNodeAttr = new ObjectNodeAttribute(objNode); + Object resNodeObj = graph.insertVertex(layerCell, null, objNodeAttr, + /* scale */nodeCell.getGeometry().getX(), nodeCell.getGeometry().getY(), + /*coordinate*/nodeCell.getGeometry().getWidth(), nodeCell.getGeometry().getHeight(), + objNodeAttr.getDefaultStyle()); + resNodeCells.put(resNode, resNodeObj); + } } return resNodeCells; diff --git a/AlgebraicDataflowArchitectureModel/src/application/editor/stages/ControlFlowDelegationStageStatus.java b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/ControlFlowDelegationStageStatus.java new file mode 100644 index 0000000..9cf8f99 --- /dev/null +++ b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/ControlFlowDelegationStageStatus.java @@ -0,0 +1,10 @@ +package application.editor.stages; + +/************************************************************* + * + * @author k-fujii + */ +public enum ControlFlowDelegationStageStatus { + SELECTING_AN_EDGE, + SHOWING_DELEGATABLE_NODES, +} diff --git a/AlgebraicDataflowArchitectureModel/src/application/editor/stages/DataFlowModelingStage.java b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/DataFlowModelingStage.java index 76176e5..7c2c599 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/editor/stages/DataFlowModelingStage.java +++ b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/DataFlowModelingStage.java @@ -19,6 +19,7 @@ import models.dataConstraintModel.IdentifierTemplate; import models.dataFlowModel.DataTransferChannelGenerator; import models.dataFlowModel.DataTransferModel; +import models.dataFlowModel.ResourceNodeAttribute; import models.visualModel.FormulaChannelGenerator; import parser.Parser; import parser.Parser.TokenStream; @@ -69,6 +70,13 @@ root.insert(new mxCell()); // CONTROL_FLOW_LAYER root.insert(new mxCell()); // PUSH_FLOW_LAYER root.insert(new mxCell()); // PULL_FLOW_LAYER + +// mxCell nodeLayerCell = new mxCell(); +// root.insert(nodeLayerCell); // NODE_LAYER, DATA_FLOW_LAYER +// nodeLayerCell.insert(new mxCell()); // CONTROL_FLOW_LAYER +// nodeLayerCell.insert(new mxCell()); // PUSH_FLOW_LAYER +// nodeLayerCell.insert(new mxCell()); // PULL_FLOW_LAYER + showOnlyLayer(graph, NODE_LAYER, DATA_FLOW_LAYER); } finally { graph.getModel().endUpdate(); @@ -141,9 +149,13 @@ // create resource vertices for (IdentifierTemplate res: model.getIdentifierTemplates()) { - Object resource = graph.insertVertex(dataFlowLayer, null, - res.getResourceName(), 20, 20, 80, 30, - "shape=ellipse;perimeter=ellipsePerimeter"); // insert a resource as a vertex + // insert a resource as a vertex + ResourceNodeAttribute resNodeAttr = new ResourceNodeAttribute(model.getDataFlowGraph().getResouceNode(res)); + Object resource = graph.insertVertex( + dataFlowLayer, null, resNodeAttr, + /*coordinate*/20, 20, + /* scale */80, 30, + resNodeAttr.getDefaultStyle()); resources.put(res, resource); } diff --git a/AlgebraicDataflowArchitectureModel/src/application/layouts/DAGLayout.java b/AlgebraicDataflowArchitectureModel/src/application/layouts/DAGLayout.java index 0a1a204..fcb0426 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/layouts/DAGLayout.java +++ b/AlgebraicDataflowArchitectureModel/src/application/layouts/DAGLayout.java @@ -15,15 +15,34 @@ import com.mxgraph.view.mxGraph; import com.mxgraph.view.mxGraphView; +import models.controlFlowModel.ObjectNodeAttribute; import models.dataConstraintModel.ChannelGenerator; import models.dataConstraintModel.IdentifierTemplate; +import models.dataFlowModel.ResourceNodeAttribute; +/************************************************************* + * DAG-Layout sorting algorithm. + * @author k-okada, k-fujii + * + */ public class DAGLayout extends mxGraphLayout { - public DAGLayout(mxGraph arg0) { - super(arg0); + /************************************************************* + * [ *constructor] + /************************************************************* + * + * @param cell + */ + public DAGLayout(mxGraph cell) { + super(cell); } - + + /************************************************************* + * [ *public ] + /************************************************************* + * Executing a layout sorting algorithm. + */ + @Override public void execute(Object parent) { mxIGraphModel model = graph.getModel(); @@ -60,6 +79,8 @@ for (int j = 0; j < map.get(i).size(); j++) { mxGeometry geom = (mxGeometry) map.get(i).get(j).getGeometry().clone(); mxCellState state = view.getState(map.get(i).get(j)); + + if (checkmoved(moved, map.get(i).get(j))) { if ("ellipse".equals(state.getStyle().get("shape"))){ geom.setX(50 + j*200); diff --git a/AlgebraicDataflowArchitectureModel/src/models/Edge.java b/AlgebraicDataflowArchitectureModel/src/models/Edge.java index 9ea2037..71ab977 100644 --- a/AlgebraicDataflowArchitectureModel/src/models/Edge.java +++ b/AlgebraicDataflowArchitectureModel/src/models/Edge.java @@ -1,6 +1,8 @@ package models; -public class Edge { +import java.io.Serializable; + +public class Edge implements Serializable { protected Node source; protected Node destination; private EdgeAttribute attribute; diff --git a/AlgebraicDataflowArchitectureModel/src/models/Node.java b/AlgebraicDataflowArchitectureModel/src/models/Node.java index f2537f6..589cc4f 100644 --- a/AlgebraicDataflowArchitectureModel/src/models/Node.java +++ b/AlgebraicDataflowArchitectureModel/src/models/Node.java @@ -1,11 +1,12 @@ package models; +import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.Set; -public class Node implements Cloneable { +public class Node implements Cloneable, Serializable { protected Collection inEdges = null; protected Collection outEdges = null; private NodeAttribute attribute; diff --git a/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/CallEdgeAttribute.java b/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/CallEdgeAttribute.java index e16d9fe..5d0ee42 100644 --- a/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/CallEdgeAttribute.java +++ b/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/CallEdgeAttribute.java @@ -29,18 +29,19 @@ } public ObjectNode getSourceObjectNode() { - if(callEdge.getSource() instanceof ObjectNode) throw new ClassCastException("sourceNode isn't type of "); + if( !(callEdge.getSource() instanceof ObjectNode) ) throw new ClassCastException("sourceNode isn't type of "); return (ObjectNode)callEdge.getSource(); } public ObjectNode getDestinationObjectNode() { - if(callEdge.getDestination() instanceof ObjectNode) throw new ClassCastException("destinationNode isn't type of "); + if( !(callEdge.getDestination() instanceof ObjectNode) ) throw new ClassCastException("destinationNode isn't type of "); return (ObjectNode)callEdge.getDestination(); } /************************************************************* * */ + @Override public String toString() { return callEdge.getSelectedOption().name(); } diff --git a/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/CallGraph.java b/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/CallGraph.java index fbd3356..2b5458e 100644 --- a/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/CallGraph.java +++ b/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/CallGraph.java @@ -47,6 +47,8 @@ dstObjNode.addInEdge(edge); } + + public StatefulObjectNode getStatefulObjectNode(ResourceNode resNode) { return statefulObjMap.get(resNode); } diff --git a/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/ControlFlowDelegator.java b/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/ControlFlowDelegator.java index 917dae9..86517ec 100644 --- a/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/ControlFlowDelegator.java +++ b/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/ControlFlowDelegator.java @@ -11,21 +11,17 @@ import models.dataFlowModel.PushPullAttribute; import models.dataFlowModel.PushPullValue; -/**-------------------------------------------------------------------------------- +/************************************************************* * it has Delegation of Control-Flow algorithm. */ public class ControlFlowDelegator { private ControlFlowGraph controlFlowGraph = null; - /**-------------------------------------------------------------------------------- - * [ *public ] - /**-------------------------------------------------------------------------------- + /************************************************************* + * [ *constructor ] + /************************************************************* * - * Todo: - * 1. object-nodeとmxCellを対応付ける - * 2. mxGraphを再構築? - * 3. mxGraphModelから委譲可能なmxCellのリストと */ public ControlFlowDelegator(final ControlFlowGraph controlFlowGraph) { this.controlFlowGraph = controlFlowGraph; @@ -39,14 +35,6 @@ */ public List searchDelegatableNodes(final CallEdge callEdge){ List nodes = new ArrayList<>(); - - CallGraph callGraph = null; - if(callEdge.getSelectedOption().equals(PushPullValue.PUSH)) { - callGraph = controlFlowGraph.getPushCallGraph(); - } - else { - callGraph = controlFlowGraph.getPullCallGraph(); - } // 1. adding parentNode ObjectNode delegatingNode = callEdge.getSelectedOption().equals(PushPullValue.PUSH) @@ -66,16 +54,18 @@ // 2. searchinge and adding children node of parentNode + // same area of each transfer methods searchOutOfNodes(nodes, parentNode, delegatingNode, callEdge.getSelectedOption()); // add to nodes in PUSH - // if() return nodes; // switch objects by transfer type return nodes; } /************************************************************* + * [* private ] + /************************************************************* * */ private void searchOutOfNodes(List nodes, ObjectNode currentNode, final ObjectNode delegatingNode, final PushPullValue selectedOption){ @@ -83,7 +73,7 @@ switch(selectedOption) { case PUSH: if(currentNode.getInEdges().size() == 0) return; - // get child of base-node + for(Edge e : currentNode.getInEdges()) { ObjectNode foundNode = (ObjectNode)e.getSource(); @@ -97,7 +87,7 @@ case PULL: case PUSHorPULL: if(currentNode.getOutEdges().size() == 0) return; - // get child of base-node + for(Edge e : currentNode.getOutEdges()) { ObjectNode foundNode = (ObjectNode)e.getDestination(); diff --git a/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/ObjectNode.java b/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/ObjectNode.java index 3fa5ca6..7907683 100644 --- a/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/ObjectNode.java +++ b/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/ObjectNode.java @@ -6,7 +6,7 @@ import models.Edge; import models.Node; -public class ObjectNode extends Node { +public class ObjectNode extends Node{ private String name; public ObjectNode(String name) { diff --git a/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/ObjectNodeAttribute.java b/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/ObjectNodeAttribute.java new file mode 100644 index 0000000..8b3f18d --- /dev/null +++ b/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/ObjectNodeAttribute.java @@ -0,0 +1,78 @@ +package models.controlFlowModel; + +import models.NodeAttribute; + +/************************************************************* + * + * @author k-fujii + * + */ +public class ObjectNodeAttribute extends NodeAttribute{ + private ObjectNode objectNode = null; + + /************************************************************* + * [ *constructor ] + /************************************************************* + * + */ + public ObjectNodeAttribute(ObjectNode objectNode) { + this.objectNode = objectNode; + this.objectNode.setAttribute(this); + + if( objectNode instanceof StatefulObjectNode ) { + this.objectNode.setName(objectNode.getName()); + } + else { + this.objectNode.setName("objectNode"); + } + } + + /************************************************************* + * [ *public ] + /************************************************************* + * [ getter ] + /************************************************************* + * + * @return + */ + public ObjectNode getObjectNode() { + return objectNode; + } + + /************************************************************* + * + */ + public String getDefaultStyle() { + return objectNode instanceof StatefulObjectNode + ? "shape=ellipse;perimeter=ellipsePerimeter;" + : "shape=hexagon;perimeter=hexagonPerimeter"; + } + + /************************************************************* + * + */ + public String getEnableStyle() { + return objectNode instanceof StatefulObjectNode + ? "shape=ellipse;perimeter=ellipsePerimeter;fillColor=#ffcc33" + : "shape=hexagon;perimeter=hexagonPerimeter;fillColor=#ffcc33"; + } + + /************************************************************* + * + */ + public String getDisableStyle() { + return objectNode instanceof StatefulObjectNode + ? "shape=ellipse;perimeter=ellipsePerimeter;fillColor=#999999" + : "shape=hexagon;perimeter=hexagonPerimeter;fillColor=#999999"; + } + + /************************************************************* + * showing label of mxCell + */ + @Override + public String toString() { + return objectNode instanceof StatefulObjectNode + ? ((StatefulObjectNode) objectNode).getResource().getIdentifierTemplate().getResourceName() + : objectNode.getName(); + } +} diff --git a/AlgebraicDataflowArchitectureModel/src/models/dataFlowModel/ResourceNodeAttribute.java b/AlgebraicDataflowArchitectureModel/src/models/dataFlowModel/ResourceNodeAttribute.java new file mode 100644 index 0000000..d03c305 --- /dev/null +++ b/AlgebraicDataflowArchitectureModel/src/models/dataFlowModel/ResourceNodeAttribute.java @@ -0,0 +1,63 @@ +package models.dataFlowModel; + +import models.NodeAttribute; + +/************************************************************* + * + * @author k-fujii + * + */ +public class ResourceNodeAttribute extends NodeAttribute { + private ResourceNode resourceNode = null; + + /************************************************************* + * [ *constructor ] + /************************************************************* + * + */ + public ResourceNodeAttribute(ResourceNode resNode) { + this.resourceNode = resNode; + this.resourceNode.setAttribute(this); + } + + /************************************************************* + * [ *public ] + /************************************************************* + * [ getter ] + /************************************************************* + * + * @return + */ + public ResourceNode getResourceNode() { + return resourceNode; + } + + /************************************************************* + * + */ + public String getResourceName() { + return resourceNode.getIdentifierTemplate().getResourceName(); + } + + /************************************************************* + * + * @return + */ + public String getDefaultStyle() { + String style =""; + style += "shape=ellipse;"; + style += "perimeter=ellipsePerimeter"; + + return style; + } + + + /************************************************************* + * + * @return + */ + @Override + public String toString() { + return resourceNode.getIdentifierTemplate().getResourceName(); + } +}