diff --git a/AlgebraicDataflowArchitectureModel/src/application/ApplicationLanguage.java b/AlgebraicDataflowArchitectureModel/src/application/ApplicationLanguage.java index 9b0f077..238f283 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/ApplicationLanguage.java +++ b/AlgebraicDataflowArchitectureModel/src/application/ApplicationLanguage.java @@ -9,13 +9,11 @@ import java.util.ResourceBundle; /*********************************************************************** - * - * + * アプリケーションの言語を切り替える(シングルトン) */ public class ApplicationLanguage { private Locale locale = null; private ResourceBundle resBundle = null; -// private Properties properties = null; private static ApplicationLanguage instance = null; @@ -25,6 +23,7 @@ public final static String EN = "en"; /*********************************************************************** + /*********************************************************************** * [ *constructor ] /*********************************************************************** * @@ -36,21 +35,22 @@ } /*********************************************************************** - * [ *public static] - * /*********************************************************************** + /*********************************************************************** + * [ *public static ] + /*********************************************************************** * - * @return */ public static ApplicationLanguage getInstance() { - if (instance == null) - instance = new ApplicationLanguage(); + if (instance == null) instance = new ApplicationLanguage(); return instance; } /*********************************************************************** - * + /*********************************************************************** + * [ *public ] /*********************************************************************** - * + * ローカルの .properties から言語情報を切り替え. + * @param language 変更先の言語 */ public void setLocaleLanguage(final String language) { URL resURL = null; @@ -74,7 +74,8 @@ } /*********************************************************************** - * + * オプション名に対応した名前を返す. + * @param propName 取得したいプロパティの名前 */ public String getOptionByPropName(final String propName) { // return properties.getProperty(propName); diff --git a/AlgebraicDataflowArchitectureModel/src/application/actions/ChangeCallOrderAction.java b/AlgebraicDataflowArchitectureModel/src/application/actions/ChangeCallOrderAction.java index f504228..75e4141 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/actions/ChangeCallOrderAction.java +++ b/AlgebraicDataflowArchitectureModel/src/application/actions/ChangeCallOrderAction.java @@ -15,6 +15,7 @@ public class ChangeCallOrderAction extends AbstractPopupAction { /************************************************************* + /************************************************************* * [ *constructor ] /************************************************************* */ @@ -23,6 +24,7 @@ } /************************************************************* + /************************************************************* * [ *public ] /************************************************************* * @@ -35,20 +37,23 @@ } /************************************************************* + /************************************************************* * [ *private ] /************************************************************* + * コントロールフローの呼び出し順を変更する + * @param cellObj 選択されたエッジ(コントロールフロー)のセル */ private void changeCallOrderOfCallEdge(Object cellObj) { String input = ""; int inputOrder = 0; CallEdgeAttribute callEdgeAttr = (CallEdgeAttribute)graphComponent.getGraph().getModel().getValue(cellObj); - if(callEdgeAttr == null) return; + if (callEdgeAttr == null) return; input = JOptionPane.showInputDialog("Call order"); - if( input == null) return; + if ( input == null) return; - if( !isNumeric(input) ) { + if ( !isNumeric(input) ) { JOptionPane.showMessageDialog(graphComponent, "Input value must type of number."); return; } @@ -56,7 +61,7 @@ inputOrder = Integer.parseInt(input); final int endOfOrderOfSrc = callEdgeAttr.getSourceObjectNode().getOutdegree(); - if(inputOrder <= 0 || endOfOrderOfSrc < inputOrder) { + if (inputOrder <= 0 || endOfOrderOfSrc < inputOrder) { JOptionPane.showMessageDialog(graphComponent, "Input order must be between 1 and " + endOfOrderOfSrc + "."); return; } @@ -68,10 +73,11 @@ } /************************************************************* - * + * フォームに入力された文字列が数値か判定 + * @param str フォームに入力された文字列 */ private boolean isNumeric(final String str) { - if(str == null) return false; + if (str == null) return false; return str.matches("[0-9.]+"); } } \ No newline at end of file diff --git a/AlgebraicDataflowArchitectureModel/src/application/actions/InsertStatelessObjectAction.java b/AlgebraicDataflowArchitectureModel/src/application/actions/InsertStatelessObjectAction.java deleted file mode 100644 index 80c0fb5..0000000 --- a/AlgebraicDataflowArchitectureModel/src/application/actions/InsertStatelessObjectAction.java +++ /dev/null @@ -1,93 +0,0 @@ -package application.actions; - -import java.awt.event.ActionEvent; - -import javax.swing.JOptionPane; - -import com.mxgraph.model.mxCell; -import com.mxgraph.swing.mxGraphComponent; - -import application.editor.stages.ControlFlowDelegationStage; -import application.editor.stages.ControlFlowDelegationStageStatus; -import models.controlFlowModel.ObjectNodeAttribute; - -/************************************************************* - * - */ -public class InsertStatelessObjectAction extends AbstractPopupAction{ - - private ControlFlowDelegationStage stage = null; - - /************************************************************* - * [ *constructor ] - /************************************************************* - */ - public InsertStatelessObjectAction(final ControlFlowDelegationStage stage, final mxGraphComponent graphComponent ,final mxCell cell) { - super(/*propName*/"insertMediator", cell, graphComponent); - this.stage = stage; - } - - /************************************************************* - * [ *public ] - /************************************************************* - * - */ - @Override - public void actionPerformed(ActionEvent e) { - super.actionPerformed(e); - insertObjectNode(targetCell); - this.stage.setState( ControlFlowDelegationStageStatus.SELECTING_AN_EDGE); - } - - /************************************************************ - * - */ - private void insertObjectNode(final Object cellObj) { - if(cellObj == null) return; - - mxCell edgeCell = null; - if(cellObj instanceof mxCell) edgeCell = (mxCell)cellObj; - else return; - - // Inputing name to the dialog. - String objName = JOptionPane.showInputDialog("Object Name:"); - if(objName == null) return; - - if( objName.isEmpty()) { - JOptionPane.showMessageDialog(graphComponent, "You must input a name. \nIt mustn't be empty."); - return; - } - - if( isDuplicatedName(objName) ) { - JOptionPane.showMessageDialog(graphComponent, "The named object has already existed."); - return; - } - - stage.insertObjectNodeCellInControlFlowLayer(edgeCell, objName); - } - - /************************************************************* - * - */ - private boolean isDuplicatedName(final String name) { - mxCell root = (mxCell)graphComponent.getGraph().getDefaultParent(); - - for(int i = 0; i < root.getChildCount(); i++) { - mxCell layerCell = (mxCell)root.getChildAt(i); - for(int j = 0; j < layerCell.getChildCount(); j++) { - mxCell cell = (mxCell)layerCell.getChildAt(j); - - ObjectNodeAttribute attr = null; - if(cell.getValue() instanceof ObjectNodeAttribute) - attr = (ObjectNodeAttribute)cell.getValue(); - else continue; - - if( !(attr.getObjectNode().getName().equals(name))) continue; - return true; - } - } - return false; - } - - -} diff --git a/AlgebraicDataflowArchitectureModel/src/application/actions/IntroduceMediatorObjectAction.java b/AlgebraicDataflowArchitectureModel/src/application/actions/IntroduceMediatorObjectAction.java new file mode 100644 index 0000000..9aba67f --- /dev/null +++ b/AlgebraicDataflowArchitectureModel/src/application/actions/IntroduceMediatorObjectAction.java @@ -0,0 +1,101 @@ +package application.actions; + +import java.awt.event.ActionEvent; + +import javax.swing.JOptionPane; + +import com.mxgraph.model.mxCell; +import com.mxgraph.swing.mxGraphComponent; + +import application.editor.stages.ControlFlowDelegationStage; +import application.editor.stages.ControlFlowDelegationStageStatus; +import models.controlFlowModel.ObjectNodeAttribute; + +/************************************************************* + * + */ +public class IntroduceMediatorObjectAction extends AbstractPopupAction{ + + private ControlFlowDelegationStage stage = null; + + /************************************************************ + /************************************************************* + * [ *constructor ] + /************************************************************* + */ + public IntroduceMediatorObjectAction(final ControlFlowDelegationStage stage, final mxGraphComponent graphComponent ,final mxCell cell) { + super(/*propName*/"insertMediator", cell, graphComponent); + this.stage = stage; + } + + /************************************************************ + /************************************************************* + * [ *public ] + /************************************************************* + * + */ + @Override + public void actionPerformed(ActionEvent e) { + super.actionPerformed(e); + insertObjectNode(targetCell); + this.stage.setState( ControlFlowDelegationStageStatus.SELECTING_AN_EDGE); + } + + /************************************************************ + /************************************************************ + * [ *private ] + /************************************************************ + * 仲介者オブジェクトの導入を実行する. + * @param cellObj 選択されたエッジのセル + */ + private void insertObjectNode(final Object cellObj) { + if (cellObj == null) return; + + mxCell edgeCell = null; + if (cellObj instanceof mxCell) edgeCell = (mxCell)cellObj; + else return; + + // Inputing name to the dialog. + String objName = JOptionPane.showInputDialog("Object Name:"); + if (objName == null) return; + + if (objName.isEmpty()) { + JOptionPane.showMessageDialog(graphComponent, "You must input a name. \nIt mustn't be empty."); + return; + } + + if (isDuplicatedName(objName) ) { + JOptionPane.showMessageDialog(graphComponent, "The named object has already existed."); + return; + } + + stage.insertObjectNodeCellInControlFlowLayer(edgeCell, objName); + } + + /************************************************************* + * 同名のノードがすでにあるか判定する + * @param name つけたいノード名 + */ + private boolean isDuplicatedName(final String name) { + mxCell root = (mxCell)graphComponent.getGraph().getDefaultParent(); + + for (int i = 0; i < root.getChildCount(); i++) { + mxCell layerCell = (mxCell)root.getChildAt(i); + + for (int j = 0; j < layerCell.getChildCount(); j++) { + mxCell cell = (mxCell)layerCell.getChildAt(j); + + ObjectNodeAttribute attr = null; + if (cell.getValue() instanceof ObjectNodeAttribute) + attr = (ObjectNodeAttribute)cell.getValue(); + else continue; + + if ( !(attr.getObjectNode().getName().equals(name)) ) continue; + return true; + } + } + return false; + } + + +} diff --git a/AlgebraicDataflowArchitectureModel/src/application/actions/ShowDependentableMediatorAction.java b/AlgebraicDataflowArchitectureModel/src/application/actions/ShowDependentableMediatorAction.java index 630d7fe..b903957 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/actions/ShowDependentableMediatorAction.java +++ b/AlgebraicDataflowArchitectureModel/src/application/actions/ShowDependentableMediatorAction.java @@ -13,6 +13,7 @@ private ControlFlowDelegationStage stage = null; /************************************************************* + /************************************************************* * [ *constructor ] /************************************************************* */ @@ -21,23 +22,25 @@ this.stage = stage; } + /************************************************************* /************************************************************ * [ *public ] /************************************************************* - * + * DoM適用可能範囲の表示まで実行する. */ @Override public void actionPerformed(ActionEvent e) { super.actionPerformed(e); showDependentableNodesBySelectedEdge(targetCell); stage.setState(ControlFlowDelegationStageStatus.SHOWING_DEPENDENTABLE_NODES); - // -> dependent manipulation is ControlFlowStageEditor + // ⇒ 移行のDoM実行操作は, 【ControlFlowStageEditor】で実行される. } /************************************************************* + /************************************************************* * [ *private ] /************************************************************* - * + * 選択されたセルの, DoM実行な仲介者オブジェクトを表示する. */ private void showDependentableNodesBySelectedEdge(Object cellObj) { CallEdgeAttribute callEdgeAttr = (CallEdgeAttribute)graphComponent.getGraph().getModel().getValue(cellObj); diff --git a/AlgebraicDataflowArchitectureModel/src/application/editor/stages/ControlFlowDelegationCellEditor.java b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/ControlFlowDelegationCellEditor.java index 73bd178..aee891e 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/editor/stages/ControlFlowDelegationCellEditor.java +++ b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/ControlFlowDelegationCellEditor.java @@ -12,7 +12,7 @@ import application.ApplicationWindow; import application.editor.FlowCellEditor; import models.controlFlowModel.CallEdgeAttribute; -import models.controlFlowModel.EntryPointObjectNode; +import models.controlFlowModel.EventChannelObjectNode; import models.controlFlowModel.ObjectNode; import models.controlFlowModel.ObjectNodeAttribute; import models.controlFlowModel.StatefulObjectNode; @@ -27,7 +27,8 @@ * [ *constructor ] /************************************************************* * - * @param graph + * @param stage + * @param graphComponent */ public ControlFlowDelegationCellEditor(ControlFlowDelegationStage stage, mxGraphComponent graphComponent) { super(stage, graphComponent); @@ -44,61 +45,60 @@ ControlFlowDelegationStage cfdStage = (ControlFlowDelegationStage) stage; switch (cfdStage.getCurState()) { - case SELECTING_AN_EDGE: - // Branching based on the edge click event. - // | double clicked > Showing delegaeatable nodes. - ApplicationWindow.logger.log(Level.INFO, "Double clicked"); + case SELECTING_AN_EDGE: + ApplicationWindow.logger.log(Level.INFO, "Double clicked"); - if (graphComponent.getGraph().getModel().isEdge(cellObj)) { - // cache a target edge of cell; - targetEdgeCell = (mxCell) cellObj; - - // Logging - CallEdgeAttribute callEdgeAttr = (CallEdgeAttribute) graphComponent.getGraph().getModel().getValue(targetEdgeCell); - if (callEdgeAttr == null) return; - - String pairNodeStr = "(" + callEdgeAttr.getSourceObjectNode().getName() + ", " + callEdgeAttr.getDestinationObjectNode().getName() + ")" ; - ApplicationWindow.logger.log(Level.INFO, "Selecting Control-Flow (src, dst) = " + pairNodeStr); - - showDelegatableNodesBySelectedEdge(cellObj); - cfdStage.setState(ControlFlowDelegationStageStatus.SHOWING_DELEGATABLE_NODES); - } - break; - - case SHOWING_DELEGATABLE_NODES: - if (graphComponent.getGraph().getModel().isVertex(cellObj)) { - mxCell dstCell = null; - if (cellObj instanceof mxCell) dstCell = (mxCell) cellObj; - else throw new ClassCastException(); - - // invocating delegation method - CallEdgeAttribute callEdgeAttr = (CallEdgeAttribute) graphComponent.getGraph().getModel().getValue(targetEdgeCell); - if (callEdgeAttr == null) return; - - ObjectNode dstObjNode = ((ObjectNodeAttribute) dstCell.getValue()).getObjectNode(); - if (dstObjNode == null) throw new ClassCastException(); - - if (!cfdStage.isExecutableDelegation(callEdgeAttr, dstObjNode)) { - JOptionPane.showMessageDialog(graphComponent, "It's impossible for \"" + dstObjNode.getName() + "\" to delegate."); - ApplicationWindow.logger.log(Level.INFO, "\"" + dstObjNode.getName() + "\"" + " wasn't able to apply to CFD"); - return; + if (graphComponent.getGraph().getModel().isEdge(cellObj)) { + + targetEdgeCell = (mxCell) cellObj; + + // Logging + CallEdgeAttribute callEdgeAttr = (CallEdgeAttribute) graphComponent.getGraph().getModel().getValue(targetEdgeCell); + if (callEdgeAttr == null) return; + + String pairNodeStr = "(" + callEdgeAttr.getSourceObjectNode().getName() + ", " + callEdgeAttr.getDestinationObjectNode().getName() + ")" ; + ApplicationWindow.logger.log(Level.INFO, "Selecting Control-Flow (src, dst) = " + pairNodeStr); + + showDelegatableNodesBySelectedEdge(cellObj); + cfdStage.setState(ControlFlowDelegationStageStatus.SHOWING_DELEGATABLE_NODES); } - - cfdStage.showDelegatedGraph(graphComponent.getGraph(), targetEdgeCell, (mxCell) cellObj); - ApplicationWindow.logger.log(Level.INFO, "Apply CFD to \"" + dstObjNode.getName() + "\""); - - cfdStage.setState(ControlFlowDelegationStageStatus.SELECTING_AN_EDGE); - } else { - // Logging - ApplicationWindow.logger.log(Level.INFO, "CFD was canceled because it was selected a control-flow"); - - cfdStage.resetAllStyleOfCells(); - cfdStage.setState(ControlFlowDelegationStageStatus.SELECTING_AN_EDGE); - } - break; - + break; + + case SHOWING_DELEGATABLE_NODES: + if (graphComponent.getGraph().getModel().isVertex(cellObj)) { + mxCell dstCell = null; + if (cellObj instanceof mxCell) dstCell = (mxCell) cellObj; + else throw new ClassCastException(); + + CallEdgeAttribute callEdgeAttr = (CallEdgeAttribute) graphComponent.getGraph().getModel().getValue(targetEdgeCell); + if (callEdgeAttr == null) return; + + ObjectNode dstObjNode = ((ObjectNodeAttribute) dstCell.getValue()).getObjectNode(); + if (dstObjNode == null) throw new ClassCastException(); + + // dstObjNode はCFD適用可能なノードかどうか? + if (!cfdStage.isExecutableDelegation(callEdgeAttr, dstObjNode)) { + JOptionPane.showMessageDialog(graphComponent, "It's impossible for \"" + dstObjNode.getName() + "\" to delegate."); + ApplicationWindow.logger.log(Level.INFO, "\"" + dstObjNode.getName() + "\"" + " wasn't able to apply to CFD"); + return; + } + + // CFD実行 ⇒ 実行後のグラフを表示. + cfdStage.showDelegatedGraph(graphComponent.getGraph(), targetEdgeCell, (mxCell) cellObj); + ApplicationWindow.logger.log(Level.INFO, "Apply CFD to \"" + dstObjNode.getName() + "\""); + + cfdStage.setState(ControlFlowDelegationStageStatus.SELECTING_AN_EDGE); + } else { + // Logging + ApplicationWindow.logger.log(Level.INFO, "CFD was canceled because it was selected a control-flow"); + + cfdStage.resetAllStyleOfCells(); + cfdStage.setState(ControlFlowDelegationStageStatus.SELECTING_AN_EDGE); + } + break; + case SHOWING_DEPENDENTABLE_NODES: - if (cfdStage.getCachedCell() == null) return; + if (cfdStage.getCachedCell() == null ) return; this.targetEdgeCell = cfdStage.getCachedCell(); if (graphComponent.getGraph().getModel().isVertex(cellObj)) { @@ -106,20 +106,22 @@ if (cellObj instanceof mxCell) targetObjCell = (mxCell) cellObj; else throw new ClassCastException(); - // invocation ObjectNodeAttribute targetObjNodeAttr = (targetObjCell.getValue() instanceof ObjectNodeAttribute) ?(ObjectNodeAttribute)targetObjCell.getValue() :null; - if(targetObjNodeAttr == null) return; + if (targetObjNodeAttr == null) return; ObjectNode targetObjNode = targetObjNodeAttr.getObjectNode(); + + // 仲介者以外のオブジェクトを選択したときの例外処理 if (isNotStatelessObject(targetObjNode)) { JOptionPane.showMessageDialog(graphComponent, "It's impossible for \"" + targetObjNode.getName() + "\" to dependent."); ApplicationWindow.logger.log(Level.INFO, "\"" + targetObjNode.getName() + "\"" + " wasn't able to apply to Depends on Mediator"); return; } - dependentObjectNode(targetObjCell); + // DoMを実行 + dependingObjectNode(targetObjCell); // Logging ApplicationWindow.logger.log(Level.INFO, "Apply Depedents on Mediator to " + "\"" + targetObjNode.getName() + "\""); @@ -149,7 +151,8 @@ /************************************************************* * view ************************************************************** - * + * 選択されたエッジが, CFDによって呼び出し元にできるオブジェクトを表示する. + * @param cellObj コントロールフローのセル */ private void showDelegatableNodesBySelectedEdge(Object cellObj) { CallEdgeAttribute callEdgeAttr = (CallEdgeAttribute) graphComponent.getGraph().getModel().getValue(cellObj); @@ -161,21 +164,23 @@ } /************************************************************ - * + * DoMを実行する. + * @param targetMediatorCell 選択された仲介者オブジェクト */ - private void dependentObjectNode(final mxCell targetMediatorCell) { - if(targetMediatorCell == null) return; + private void dependingObjectNode(final mxCell targetMediatorCell) { + if (targetMediatorCell == null) return; ControlFlowDelegationStage cfdStage = (ControlFlowDelegationStage) stage; - cfdStage.dependsOnMediatorObject(targetEdgeCell, targetMediatorCell); + cfdStage.dependingOnMediatorObject(targetEdgeCell, targetMediatorCell); } /************************************************************ - * + * あるノードが仲介者(状態を持たない)オブジェクトかどうかを判定する. + * @param targetObjNode 選択されたノード */ private boolean isNotStatelessObject(final ObjectNode targetObjNode) { - if(targetObjNode instanceof StatefulObjectNode) return true; - if(targetObjNode instanceof EntryPointObjectNode) return true; + if (targetObjNode instanceof StatefulObjectNode) return true; + if (targetObjNode instanceof EventChannelObjectNode) return true; return false; } diff --git a/AlgebraicDataflowArchitectureModel/src/application/editor/stages/ControlFlowDelegationStage.java b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/ControlFlowDelegationStage.java index d9fbfee..aa60245 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/editor/stages/ControlFlowDelegationStage.java +++ b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/ControlFlowDelegationStage.java @@ -34,7 +34,7 @@ import models.controlFlowModel.CompositeCallEdgeAttribute; import models.controlFlowModel.ControlFlowDelegator; import models.controlFlowModel.ControlFlowGraph; -import models.controlFlowModel.EntryPointObjectNode; +import models.controlFlowModel.EventChannelObjectNode; import models.controlFlowModel.ObjectNode; import models.controlFlowModel.ObjectNodeAttribute; import models.controlFlowModel.StatefulObjectNode; @@ -79,26 +79,31 @@ } /************************************************************* - * + * 今のコントロールフローの操作状態がどうなっているかを取得 */ public ControlFlowDelegationStageStatus getCurState() { return curState; } + /************************************************************* + * 今のコントロールフローの操作状態をセット. + */ public void setState(ControlFlowDelegationStageStatus nextState) { curState = nextState; } /************************************************************* - * + * 「Stage」クラス以外の, 他のクラス上で取得されたセルをセット */ public void setCellOnAnyEvent(final mxCell selectedCell) { this.selectedCellOnAnyEvent = selectedCell; } /************************************************************* - * + * 「Stage」クラス以外の, 他のクラス上で取得されたセルをget + * Action や CellEditor とセルのインスタンス情報を共有するために必要. + * (this.seletedCellOnAnyEvent == null) ならグラフ上のどのセルも選択されていないことになる. */ public mxCell getCachedCell() { return this.selectedCellOnAnyEvent; @@ -140,7 +145,9 @@ } /************************************************************* - * + * ステージ変更時のリスナー作成 + * @param editor + * @return GUI上のイベントリスナー */ @Override public mxIEventListener createChangeEventListener(Editor editor) { @@ -157,7 +164,7 @@ } } - if(curState != ControlFlowDelegationStageStatus.SELECTING_AN_EDGE) return; + if (curState != ControlFlowDelegationStageStatus.SELECTING_AN_EDGE) return; if (terminals.size() == 2) { graph.removeCells(new mxCell[] {cell}); @@ -168,16 +175,17 @@ } /************************************************************* - * + * ステージ変更時のマウスイベントの発行 + * @param editor */ @Override public MouseListener createMouseEventListener(Editor editor) { MouseListener listener = new mxMouseAdapter() { @Override public void mouseReleased(MouseEvent e) { - if(SwingUtilities.isLeftMouseButton(e)) { - if(graphComponent.getCellAt(e.getX(), e.getY()) != null) return; - if(curState.equals(ControlFlowDelegationStageStatus.SELECTING_AN_EDGE)) return; + if (SwingUtilities.isLeftMouseButton(e)) { + if (graphComponent.getCellAt(e.getX(), e.getY()) != null) return; + if (curState.equals(ControlFlowDelegationStageStatus.SELECTING_AN_EDGE)) return; ApplicationWindow.logger.log(Level.INFO, "Reset selection"); resetAllStyleOfCells(); @@ -185,7 +193,7 @@ return; } - else if(SwingUtilities.isRightMouseButton(e)) { + else if (SwingUtilities.isRightMouseButton(e)) { ApplicationWindow.logger.log(Level.INFO, "Open popup menu"); popupMenu.show(e.getX(), e.getY()); } @@ -195,37 +203,38 @@ } /************************************************************* - * manipulating the control-graph + * コントロールフローグラフの操作 /************************************************************* - * control-flow-delegation + * CFDが適用できるノードの表示 + * @param callEdgeAttr 選択された呼び出しエッジの情報 */ public void showDelegatableNodes(final CallEdgeAttribute callEdgeAttr){ mxCell root = (mxCell)graph.getDefaultParent(); graph.getModel().beginUpdate(); try { ObjectNode delegatingNode = callEdgeAttr.getDestinationObjectNode(); - for(int layerNo = Stage.PUSH_FLOW_LAYER; layerNo <= PULL_FLOW_LAYER; layerNo++) { + for (int layerNo = Stage.PUSH_FLOW_LAYER; layerNo <= PULL_FLOW_LAYER; layerNo++) { mxCell layerCell = (mxCell)root.getChildAt(layerNo); - for(Object node : graph.getChildVertices(layerCell)) { - if( !(node instanceof mxCell) ) continue; + for (Object node : graph.getChildVertices(layerCell)) { + if ( !(node instanceof mxCell) ) continue; mxCell cell = (mxCell)node; ObjectNodeAttribute objNodeAttr = (ObjectNodeAttribute)cell.getValue(); - if(objNodeAttr == null) return; + if (objNodeAttr == null) return; ObjectNode objNode = objNodeAttr.getObjectNode(); ControlFlowDelegator delegator = new ControlFlowDelegator(controlFlowGraph); List delegatableNodes = delegator.searchDelegatableNodes(callEdgeAttr.getCallEdge()); - if(delegatableNodes.contains(objNode)) { + if (delegatableNodes.contains(objNode)) { graph.getModel().setStyle(cell, objNodeAttr.getEnableStyle()); } else { graph.getModel().setStyle(cell, objNodeAttr.getDisableStyle()); } - if(delegatingNode.equals(objNodeAttr.getObjectNode())) + if (delegatingNode.equals(objNodeAttr.getObjectNode())) /* base-Node*/graph.getModel().setStyle(cell, objNodeAttr.getDelegatingStyle()); } } @@ -237,7 +246,8 @@ } /************************************************************* - * dependent-on-mediator + * DoMを実行可能なノードの表示 + * @param callEdgeAttr 選択された呼び出しエッジの情報 */ public void showDependentableNodes(final CallEdgeAttribute callEdgeAttr) { mxCell root = (mxCell)graph.getDefaultParent(); @@ -247,24 +257,24 @@ ObjectNode delegatingNode = callEdgeAttr.getDestinationObjectNode(); for(Object node : graph.getChildVertices(layerCell)) { - if( !(node instanceof mxCell) ) continue; + if ( !(node instanceof mxCell) ) continue; mxCell cell = (mxCell)node; ObjectNodeAttribute objNodeAttr = (ObjectNodeAttribute)cell.getValue(); - if(objNodeAttr == null) return; + if (objNodeAttr == null) return; ObjectNode objNode = objNodeAttr.getObjectNode(); ControlFlowDelegator delegator = new ControlFlowDelegator(controlFlowGraph); List delegatableNodes = delegator.searchDependentableMediatorNodes(callEdgeAttr.getCallEdge()); - if(delegatableNodes.contains(objNode)) { + if (delegatableNodes.contains(objNode)) { graph.getModel().setStyle(cell, objNodeAttr.getEnableStyle()); } else { graph.getModel().setStyle(cell, objNodeAttr.getDisableStyle()); } - if(delegatingNode.equals(objNodeAttr.getObjectNode())) + if (delegatingNode.equals(objNodeAttr.getObjectNode())) /* base-Node*/graph.getModel().setStyle(cell, objNodeAttr.getDelegatingStyle()); } } @@ -275,38 +285,41 @@ } /************************************************************* - * Showing the graph that was executed CFD. + * CFD実行後のグラフを表示 + * @param graph 被操作対象のグラフ + * @param targetEdgeCell CFD実行時に選択された呼び出しエッジ + * @param dstObjNodeCell CFDによって呼び出し元となるセル */ public void showDelegatedGraph(mxGraph graph, mxCell targetEdgeCell, final mxCell dstObjNodeCell) { ObjectNode dstObjNode = ((ObjectNodeAttribute)dstObjNodeCell.getValue()).getObjectNode(); - if(dstObjNode == null) throw new ClassCastException(); + if (dstObjNode == null) throw new ClassCastException(); CallEdgeAttribute targetEdgeAttr = (CallEdgeAttribute)targetEdgeCell.getValue(); - if(targetEdgeAttr == null) throw new ClassCastException(); + if (targetEdgeAttr == null) throw new ClassCastException(); ControlFlowDelegator delegator = new ControlFlowDelegator(controlFlowGraph); delegator.delegateCallEdge(targetEdgeAttr.getCallEdge(), dstObjNode); - mxCell root = (mxCell)graph.getDefaultParent(); + mxCell root = (mxCell) graph.getDefaultParent(); mxCell layerCell = null; - switch(targetEdgeAttr.getSelectedOption()) { - case PUSH: - layerCell = (mxCell)root.getChildAt(Stage.PUSH_FLOW_LAYER); - break; - - case PULL: - case PUSHorPULL: - layerCell = (mxCell)root.getChildAt(Stage.PULL_FLOW_LAYER); + switch (targetEdgeAttr.getSelectedOption()) { + case PUSH: + layerCell = (mxCell) root.getChildAt (Stage.PUSH_FLOW_LAYER); + break; + + case PULL: + case PUSHorPULL: + layerCell = (mxCell) root.getChildAt (Stage.PULL_FLOW_LAYER); + break; } try { mxCell dstNodeCell = targetEdgeAttr.getDestinationCell(); - // Removing the target edge from graph model. - if(graph.getModel().getValue(targetEdgeCell) != null) { + // 対象となるコントロールフローをグラフ上から削除. + if (graph.getModel().getValue(targetEdgeCell) != null) { graph.getModel().remove(targetEdgeCell); } - // Insert an edge CallEdgeAttribute newAttr = new CallEdgeAttribute(targetEdgeAttr.getCallEdge(), targetEdgeAttr.getOriginalSourceObjectNode(),dstObjNodeCell, dstNodeCell); graph.insertEdge(layerCell, "", newAttr, dstObjNodeCell, dstNodeCell, "movable=false;"); @@ -318,11 +331,13 @@ } /************************************************************* - * + * 仲介者オブジェクトへの依存(DoM)を実行し, mxGraphを変更する. + * @param targetEdgeCell DoMによって変更されるコントロールフローのセル + * @param targetMediatorObjNodeCell DoMの対象となる仲介者オブジェクトのセル */ - public void dependsOnMediatorObject(mxCell targetEdgeCell, mxCell targetMediatorObjNodeCell) { + public void dependingOnMediatorObject(mxCell targetEdgeCell, mxCell targetMediatorObjNodeCell) { CallEdgeAttribute targetCallEdgeAttr = (CallEdgeAttribute)targetEdgeCell.getValue(); - if(targetCallEdgeAttr == null) return; + if (targetCallEdgeAttr == null) return; mxCell root = (mxCell)graph.getDefaultParent(); mxCell pullFlowLayerCell = (mxCell)root.getChildAt(Stage.PULL_FLOW_LAYER); @@ -330,75 +345,67 @@ graph.getModel().beginUpdate(); try { - // Reconnecting each edges of the node. - // Get each of the transformed object + // 各ノードの情報を取得. ObjectNode srcObjNode = targetCallEdgeAttr.getSourceObjectNode(); ObjectNode dstObjNode = targetCallEdgeAttr.getDestinationObjectNode(); - if(srcObjNode == null || dstObjNode == null) throw new NullPointerException(); - if(!(srcObjNode instanceof ObjectNode && dstObjNode instanceof ObjectNode)) throw new ClassCastException(); + if (srcObjNode == null || dstObjNode == null) throw new NullPointerException(); + if ( !(srcObjNode instanceof ObjectNode && dstObjNode instanceof ObjectNode) ) throw new ClassCastException(); - // Get target "Mediator Object" ObjectNodeAttribute targetObjNodeAttr = (ObjectNodeAttribute)targetMediatorObjNodeCell.getValue(); - if(targetObjNodeAttr == null) throw new NullPointerException(); + if (targetObjNodeAttr == null) throw new NullPointerException(); ObjectNode targetMediatorObjNode = targetObjNodeAttr.getObjectNode(); - if(targetMediatorObjNode == null) throw new NullPointerException(); - if(targetMediatorObjNode instanceof StatefulObjectNode || targetMediatorObjNode instanceof EntryPointObjectNode) return; - - - // Connecting I/O Edges to the insert object. + if (targetMediatorObjNode == null) throw new NullPointerException(); + if (targetMediatorObjNode instanceof StatefulObjectNode || targetMediatorObjNode instanceof EventChannelObjectNode) return; + + // 新たに接続するエッジ情報を生成. CallEdge srcToMediatorEdge = new CallEdge(targetCallEdgeAttr.getSourceObjectNode(), targetMediatorObjNode, targetCallEdgeAttr.getSelectedOption()); CallEdge mediatorToDstEdge = new CallEdge(targetMediatorObjNode, dstObjNode, targetCallEdgeAttr.getSelectedOption()); - if(srcToMediatorEdge == null || mediatorToDstEdge == null) throw new NullPointerException(); + if (srcToMediatorEdge == null || mediatorToDstEdge == null) throw new NullPointerException(); - // Manipulate an edge of the source object node. + // ノード同士の接続情報を更新 srcObjNode.addOutEdge(srcToMediatorEdge); srcObjNode.removeOutEdge(targetCallEdgeAttr.getCallEdge()); - // Manipulate an edge of the destination object node. dstObjNode.removeInEdge(targetCallEdgeAttr.getCallEdge()); - // Connect an edge of the mediation object node. targetMediatorObjNode.addInEdge(srcToMediatorEdge); - // Create composition Attribute of the Call-Edge . - // Get already connected call-edge. + // 既に仲介者に接続されているエッジの情報を CompositeCallEdgeAttr に保持させる. CompositeCallEdgeAttribute compositeEdgeAttr = null; - for(int i = 0; i < pullFlowLayerCell.getChildCount(); i++) { + for (int i = 0; i < pullFlowLayerCell.getChildCount(); i++) { mxCell edgeCell = (mxCell)pullFlowLayerCell.getChildAt(i); - if (!edgeCell.isEdge() ) continue; - if (!(edgeCell.getValue() instanceof CallEdgeAttribute)) continue; + if ( !edgeCell.isEdge() ) continue; + if ( !(edgeCell.getValue() instanceof CallEdgeAttribute) ) continue; CallEdgeAttribute edgeAttr = (CallEdgeAttribute)edgeCell.getValue(); - if (!(edgeAttr.getSourceObjectNode().equals(targetMediatorObjNode)))continue; - if (!(edgeAttr.getDestinationObjectNode().equals(dstObjNode)))continue; + if ( !(edgeAttr.getSourceObjectNode().equals(targetMediatorObjNode)) )continue; + if ( !(edgeAttr.getDestinationObjectNode().equals(dstObjNode)) )continue; compositeEdgeAttr = new CompositeCallEdgeAttribute(edgeAttr); break; } - if(compositeEdgeAttr != null) + if (compositeEdgeAttr != null) compositeEdgeAttr.mergeCallEdgeAttribute(targetCallEdgeAttr); - // Manipulate the cell of the graph. - for(int i = 0; i < pullFlowLayerCell.getChildCount(); i++) { + // mxGraph へ接続状態を反映する. + for (int i = 0; i < pullFlowLayerCell.getChildCount(); i++) { mxCell nodeCell = (mxCell)pullFlowLayerCell.getChildAt(i); - if( !nodeCell.isVertex() ) continue; + if ( !nodeCell.isVertex() ) continue; - // Check "nodeCell" has an instance of ObjectNodeAttribute cellObjNodeAttr = (ObjectNodeAttribute)nodeCell.getValue(); - if(cellObjNodeAttr == null) throw new ClassCastException("dosen't have the value of "); + if (cellObjNodeAttr == null) throw new ClassCastException("dosen't have the value of "); - // Is "nodeCell" the same as the source cell of the call edge? - if(nodeCell.equals(targetCallEdgeAttr.getSourceCell())){ + // nodeCell が呼び出し元のノードか? + if (nodeCell.equals(targetCallEdgeAttr.getSourceCell())){ mxCell srcNodeCell = targetCallEdgeAttr.getSourceCell(); - // If the target call edge hasn't removed yet. - // then it removes from mxGraphModel. - if(graph.getModel().getValue(targetEdgeCell) != null) + // mxGraph に変更対象のコントロールフローが存在するなら削除する. + if (graph.getModel().getValue(targetEdgeCell) != null) graph.getModel().remove(targetEdgeCell); graph.insertEdge(pullFlowLayerCell, null, compositeEdgeAttr, srcNodeCell, targetMediatorObjNodeCell, "movable=false;"); @@ -413,23 +420,23 @@ } /************************************************************* - * + * グラフの選択状態をクリアする. */ public void resetAllStyleOfCells() { mxCell root = (mxCell)graph.getDefaultParent(); graph.getModel().beginUpdate(); try { - for(int layerNo = Stage.PUSH_FLOW_LAYER; layerNo <= Stage.PULL_FLOW_LAYER; layerNo++) { + for (int layerNo = Stage.PUSH_FLOW_LAYER; layerNo <= Stage.PULL_FLOW_LAYER; layerNo++) { mxCell layerCell = (mxCell)root.getChildAt(layerNo); - for(Object node : graph.getChildVertices(layerCell)) { + for (Object node : graph.getChildVertices(layerCell)) { mxCell cell = null; - if(node instanceof mxCell) cell = (mxCell)node; + if (node instanceof mxCell) cell = (mxCell)node; else continue; ObjectNodeAttribute objNodeAttr = (ObjectNodeAttribute)(cell.getValue()); - if(objNodeAttr == null) throw new NullPointerException(""); + if (objNodeAttr == null) throw new NullPointerException(""); graph.getModel().setStyle(cell, objNodeAttr.getDefaultStyle()); } @@ -442,11 +449,13 @@ } /************************************************************* - * Inserting an intermediation object type of . + * コントロールフローに対して, 状態を持たないノードを挿入する. + * @param targetEdge CFDによって変更されるコントロールフロー. + * @param insertObjName 挿入するノードの名前 */ public void insertObjectNodeCellInControlFlowLayer(mxCell targetEdge, final String insertObjName) { CallEdgeAttribute callEdgeAttr = (CallEdgeAttribute)targetEdge.getValue(); - if(callEdgeAttr == null) throw new NullPointerException(); + if (callEdgeAttr == null) throw new NullPointerException(); mxCell root = (mxCell)graph.getDefaultParent(); mxCell layerCell = null; @@ -464,7 +473,7 @@ graph.getModel().beginUpdate(); try { - // Inserting the node type of to the graph. + // オブジェクトは ObjectNode として挿入する. ObjectNode insertObjNode = new ObjectNode(insertObjName); ObjectNodeAttribute objNodeAttr = new ObjectNodeAttribute(insertObjNode); @@ -476,55 +485,51 @@ mxCell insertObjNodeCell = (mxCell)graph.insertVertex(layerCell, null, objNodeAttr, - /* coordinate*/ insertPoint.getX(), insertPoint.getY(), - /* scale */ 40, 40, + /* 座標 */ insertPoint.getX(), insertPoint.getY(), + /* スケール*/ 40, 40, objNodeAttr.getDefaultStyle()); insertObjNodeCell.setValue(objNodeAttr); addObjectNodeToCallGraph(insertObjNode, callEdgeAttr.getSelectedOption()); - // Reconnecting each edges of the node. ObjectNode srcObjNode = callEdgeAttr.getSourceObjectNode(); ObjectNode dstObjNode = callEdgeAttr.getDestinationObjectNode(); - if(srcObjNode == null || dstObjNode == null) throw new NullPointerException(); - if(!(srcObjNode instanceof ObjectNode && dstObjNode instanceof ObjectNode)) throw new ClassCastException(); + if (srcObjNode == null || dstObjNode == null) throw new NullPointerException(); + if ( !(srcObjNode instanceof ObjectNode && dstObjNode instanceof ObjectNode) ) throw new ClassCastException(); - // Connecting I/O Edges to the insert object. CallEdge srcToInsertEdge = callEdgeAttr.getCallEdge(); CallEdge insertToDstEdge = new CallEdge(insertObjNode, dstObjNode, callEdgeAttr.getSelectedOption()); - if(srcToInsertEdge == null || insertToDstEdge == null) throw new NullPointerException(); + if (srcToInsertEdge == null || insertToDstEdge == null) throw new NullPointerException(); - // Remove the destination edge of the object node. - // After add the "srcToInsertEdge" to the destination object node. + // ノードとエッジを再接続する dstObjNode.removeInEdge(srcToInsertEdge); dstObjNode.addInEdge(insertToDstEdge); - srcToInsertEdge.setDestination(insertObjNode); // changing the out of edge of the sourceObjectNode + srcToInsertEdge.setDestination(insertObjNode); // 呼び出し先オブジェクトを変更する. insertObjNode.addInEdge(srcToInsertEdge); insertObjNode.addOutEdge(insertToDstEdge); - // Update the cell of the graph. + // mxGraphを更新する. for(int i =0; i < layerCell.getChildCount(); i++) { mxCell nodeCell = (mxCell)layerCell.getChildAt(i); - if( !nodeCell.isVertex()) continue; + if (!nodeCell.isVertex()) continue; - // Checking "nodeCell" has an instance of ObjectNodeAttribute cellObjNodeAttr = (ObjectNodeAttribute)nodeCell.getValue(); - if(cellObjNodeAttr == null) throw new ClassCastException("dosen't have the value of "); + if (cellObjNodeAttr == null) throw new ClassCastException("dosen't have the value of "); - // Is "nodeCell" the same as the source cell of the call edge? - if(nodeCell.equals(callEdgeAttr.getSourceCell())){ + // nodeCell が呼び出し元のオブジェクトか? + if (nodeCell.equals(callEdgeAttr.getSourceCell())){ mxCell srcNodeCell = callEdgeAttr.getSourceCell(); CallEdgeAttribute newInEdgeAttr = new CallEdgeAttribute(srcToInsertEdge, srcNodeCell, insertObjNodeCell); - // If the target call edge hasn't removed yet. - // then it removes from mxGraphModel. - if(graph.getModel().getValue(targetEdge) != null) + // mxGraph上にtargetEdgeが残っているなら削除する. + if (graph.getModel().getValue(targetEdge) != null) graph.getModel().remove(targetEdge); mxCell outPortCell = (mxCell)srcNodeCell.getChildAt(0); - if(outPortCell != null) { + if + (outPortCell != null) { graph.insertEdge(layerCell, null, newInEdgeAttr, outPortCell, insertObjNodeCell, "movable=false;"); } else { @@ -532,13 +537,13 @@ } continue; } - // Is "nodeCell" the same as the destination cell of the call edge? - else if(nodeCell.equals(callEdgeAttr.getDestinationCell())) { + // nodeCell は呼び出し先オブジェクトか? + else if (nodeCell.equals(callEdgeAttr.getDestinationCell())) { mxCell dstNodeCell = callEdgeAttr.getDestinationCell(); CallEdgeAttribute newOutEdgeAttr = new CallEdgeAttribute(insertToDstEdge, insertObjNodeCell, dstNodeCell); - - // If the target - if(graph.getModel().getValue(targetEdge) != null) + + // mxGraph上にtargetEdgeが残っているなら削除する. + if (graph.getModel().getValue(targetEdge) != null) graph.getModel().remove(targetEdge); graph.insertEdge(layerCell, null, newOutEdgeAttr, insertObjNodeCell, dstNodeCell, "movable=false;"); @@ -553,7 +558,9 @@ } /************************************************************* - * + * CFD適用可能かどうかを判定する + * @param targetEdgeAttr CFDによって呼び出し元が変更されるコントロールフロー + * @param dstObjNode CFDによって呼び出し元となるオブジェクト */ public boolean isExecutableDelegation(final CallEdgeAttribute targetEdgeAttr, final ObjectNode dstObjNode) { ControlFlowDelegator delegator = new ControlFlowDelegator(controlFlowGraph); @@ -566,22 +573,23 @@ /************************************************************* * [ *private ] /************************************************************* - * + * GUI上のグラフを生成する + * @param graph 初期化対象のグラフ + * @param controlFlowGraph */ private mxGraph constructGraph(mxGraph graph, ControlFlowGraph controlFlowGraph) { showOnlyLayer(PUSH_FLOW_LAYER, PULL_FLOW_LAYER); graph.getModel().beginUpdate(); try { - // Creating Control-Flow and separeted Push/Pull which types of + // PUSH/PULLごとに ResourceNode, mxCellのインスタンスを対応させる. Map pushResNodeCells = createCellsOfResourceMap(PUSH_FLOW_LAYER); Map pullResNodeCells = createCellsOfResourceMap(PULL_FLOW_LAYER); - // Creating Entry-Point Object - Map pushFlowEntryNodeCells = createCellsOfInputChannel(PUSH_FLOW_LAYER); + Map pushFlowEventNodeCells = createEventChannelCells(PUSH_FLOW_LAYER); - // Inserting edges of each transfer - graph = insertControlFlowEdges(PUSH_FLOW_LAYER, pushResNodeCells, pushFlowEntryNodeCells); + // PUSH/PULLのmxGraph上の頂点をエッジでつなぐ. + graph = insertControlFlowEdges(PUSH_FLOW_LAYER, pushResNodeCells, pushFlowEventNodeCells); graph = insertControlFlowEdges(PULL_FLOW_LAYER, pullResNodeCells, null); } finally { @@ -592,19 +600,20 @@ /************************************************************* - * When changed from previous stage, it will be called in initializing. + * データフローモデリングステージへ戻るとき, GUI上のコントローフローグラフを削除する. + * @param graph 変更対象のグラフ */ private void clearControlFlowGraphCells(mxGraph graph) { - mxCell root = (mxCell)graph.getDefaultParent(); + mxCell root = (mxCell) graph.getDefaultParent(); graph.getModel().beginUpdate(); try { - // removing child from end of a root cell - root.remove(root.getChildAt(PULL_FLOW_LAYER)); - root.remove(root.getChildAt(PUSH_FLOW_LAYER)); + // Rootのレイヤー以下のPUSH/PULLレイヤーを削除. + root.remove (root.getChildAt(PULL_FLOW_LAYER)); + root.remove (root.getChildAt(PUSH_FLOW_LAYER)); - root.insert(new mxCell()); - root.insert(new mxCell()); + root.insert (new mxCell()); + root.insert (new mxCell()); } finally { graph.getModel().endUpdate(); graph.refresh(); @@ -613,8 +622,10 @@ /************************************************************* - * Creating a map of to and Creating 's vertices - * @return constructed the view of the graph + * mxGraphの指定したレイヤー上にリソースのノードを追加する. + * また, mxGraph上のセルにリソースの情報をマッピングする. + * @param layerNumber mxCellを追加する, PUSH/PULLのレイヤー番号 + * @return ノード(リソース)の情報と, 対応するセルのインスタンスのマップ */ private Map createCellsOfResourceMap(final int layerNumber) { Map resNodeCells = new HashMap<>(); @@ -623,23 +634,24 @@ mxCell nodeLayerCell = (mxCell)root.getChildAt(NODE_LAYER); mxCell layerCell = (mxCell)root.getChildAt(layerNumber); - // create resource vertices + // データフローグラフ上に存在するリソースの情報をコントロールフローグラフに引き継ぐ. for (ResourceNode resNode : controlFlowGraph.getDataFlowGraph().getResouceNodes()) { - + + // 「リソース」に対応するノードのインスタンスを生成. ObjectNode objNode = null; - switch(layerNumber) { + switch (layerNumber) { case PUSH_FLOW_LAYER: - if(controlFlowGraph.getPushCallGraph().getStatefulObjectNode(resNode) != null) + if (controlFlowGraph.getPushCallGraph().getStatefulObjectNode(resNode) != null) objNode = controlFlowGraph.getPushCallGraph().getStatefulObjectNode(resNode); break; case PULL_FLOW_LAYER: - if(controlFlowGraph.getPullCallGraph().getStatefulObjectNode(resNode) != null) + if (controlFlowGraph.getPullCallGraph().getStatefulObjectNode(resNode) != null) objNode = controlFlowGraph.getPullCallGraph().getStatefulObjectNode(resNode); break; } - if(objNode == null) continue; + if (objNode == null) continue; for(int i =0; i < nodeLayerCell.getChildCount(); i++) { mxCell nodeCell = (mxCell)nodeLayerCell.getChildAt(i); @@ -648,16 +660,17 @@ } else 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; + // !不要かもしれない! + // ResourceNodeがちゃんとAttributeを持っているかをチェックして, 不正値検出しようとしてるみたい. + 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 + // ノードの情報をmxCellにマッピング. ObjectNodeAttribute objNodeAttr = new ObjectNodeAttribute(objNode); - mxCell resNodeObjCell = (mxCell)graph.insertVertex(layerCell, null, objNodeAttr, - /* scale */nodeCell.getGeometry().getX(), nodeCell.getGeometry().getY(), - /*coordinate*/nodeCell.getGeometry().getWidth(), nodeCell.getGeometry().getHeight(), + + mxCell resNodeObjCell = (mxCell)graph.insertVertex (layerCell, null, objNodeAttr, + /* サイズ */nodeCell.getGeometry().getX(), nodeCell.getGeometry().getY(), + /* 座標 */nodeCell.getGeometry().getWidth(), nodeCell.getGeometry().getHeight(), objNodeAttr.getDefaultStyle()); resNodeCells.put(resNode, resNodeObjCell); @@ -669,53 +682,56 @@ /************************************************************* - * Create an input channel object + * mxGraphの指定したレイヤー上にイベントチャンネルのノードを追加する. + * また, mxGraph上のセルにイベントチャンネルの情報をマッピングする. + * @param layerNumber 指定したレイヤー(現状PULLは例外扱いしている) + * @return イベントチャンネルの情報と, 対応するセルのインスタンスのマップ */ - private Map createCellsOfInputChannel(final int layerNumber){ - if(layerNumber == PULL_FLOW_LAYER) return null; + private Map createEventChannelCells(final int layerNumber){ + if (layerNumber == PULL_FLOW_LAYER) return null; mxCell root = (mxCell)graph.getDefaultParent(); mxCell layerCell = (mxCell)root.getChildAt(layerNumber); - Map ioChannelCells = new HashMap<>(); + Map eventChannelCells = new HashMap<>(); graph.getModel().beginUpdate(); try { - mxGeometry outPortGeometry = new mxGeometry(1.0, 0.5, PORT_DIAMETER, PORT_DIAMETER); - outPortGeometry.setOffset(new mxPoint(-PORT_RADIUS, -PORT_RADIUS)); - outPortGeometry.setRelative(true); + mxGeometry outPortGeometry = new mxGeometry (1.0, 0.5, PORT_DIAMETER, PORT_DIAMETER); + outPortGeometry.setOffset (new mxPoint(-PORT_RADIUS, -PORT_RADIUS)); + outPortGeometry.setRelative (true); CallGraph callGraph = controlFlowGraph.getPushCallGraph(); - // insert an I/O channel as a vertex + // イベントチャンネルのセルを追加 for (Node node : callGraph.getNodes()) { - EntryPointObjectNode entryPointObjNode = null; - if(node instanceof EntryPointObjectNode) - entryPointObjNode = (EntryPointObjectNode)node; + EventChannelObjectNode entryPointObjNode = null; + if (node instanceof EventChannelObjectNode) + entryPointObjNode = (EventChannelObjectNode) node; else continue; ObjectNodeAttribute entryObjAttr = new ObjectNodeAttribute(entryPointObjNode); - // Taking over geometry information from the channel node with the same name. + // イベントチャンネルの名前と座標値をデータフローグラフから取得. mxCell dataFlowLayerCell = (mxCell)root.getChildAt(Stage.DATA_FLOW_LAYER); - for(int i = 0; i < dataFlowLayerCell.getChildCount(); i++) { + for (int i = 0; i < dataFlowLayerCell.getChildCount(); i++) { mxCell channelCell =(mxCell)dataFlowLayerCell.getChildAt(i); - String entryPointObjNodeName = entryPointObjNode.getIOChannel().getChannelName(); + String eventChObjNodeName = entryPointObjNode.getIOChannel().getChannelName(); String channelCellName = ""; - if(channelCell.getValue() instanceof String) channelCellName = (String) channelCell.getValue(); + if (channelCell.getValue() instanceof String) channelCellName = (String) channelCell.getValue(); else continue; - if(!entryPointObjNodeName.equals(channelCellName))continue; + if (!eventChObjNodeName.equals(channelCellName)) continue; - mxCell entryPointCelll = (mxCell)graph.insertVertex(layerCell, null, entryObjAttr, - /* scale */ channelCell.getGeometry().getX(), channelCell.getGeometry().getY(), - /* geometry*/channelCell.getGeometry().getWidth(), channelCell.getGeometry().getHeight()); - mxCell port_out = new mxCell(null, outPortGeometry, "shape=ellipse;perimter=ellipsePerimeter"); - port_out.setVertex(true); + mxCell entryPointCelll = (mxCell) graph.insertVertex (layerCell, null, entryObjAttr, + /* スケール */ channelCell.getGeometry().getX(), channelCell.getGeometry().getY(), + /* 座標 */ channelCell.getGeometry().getWidth(), channelCell.getGeometry().getHeight()); + mxCell port_out = new mxCell (null, outPortGeometry, "shape=ellipse;perimter=ellipsePerimeter"); + port_out.setVertex (true); - graph.addCell(port_out, entryPointCelll); // insert the output port of a channel - ioChannelCells.put(entryPointObjNode, entryPointCelll); + graph.addCell (port_out, entryPointCelll); + eventChannelCells.put (entryPointObjNode, entryPointCelll); } } } @@ -723,14 +739,18 @@ graph.getModel().endUpdate(); } - return ioChannelCells; + return eventChannelCells; } /************************************************************* - * + * コントロールフローグラフの各頂点セルの間に, エッジのセルを追加する. + * @param layerNumber エッジを追加したいmxGraphのレイヤー + * @param resNodeCells リソースと, その頂点セルのインスタンスのマップ + * @param eventChNodeCells イベントチャンネルと, その頂点セルのインスタンスのマップ */ - private mxGraph insertControlFlowEdges(final int layerNumber,final Map resNodeCells, final Map entryNodeCells) { + private mxGraph insertControlFlowEdges(final int layerNumber, + final Map resNodeCells, final Map eventChNodeCells) { mxCell root = (mxCell)graph.getDefaultParent(); mxCell layerCell = (mxCell)root.getChildAt(layerNumber); @@ -742,8 +762,8 @@ if ( !(callGraphEdge instanceof CallEdge))continue; CallEdge callEdge = (CallEdge) callGraphEdge; - // Is checking node connecting a resource? - if(callEdge.getSource() == null || callEdge.getDestination() == null) continue; + // エッジがノードと接続しているか? + if (callEdge.getSource() == null || callEdge.getDestination() == null) continue; Node srcResNode = null; ResourceNode dstResNode = ((StatefulObjectNode)callEdge.getDestination()).getResource(); @@ -752,13 +772,13 @@ mxCell srcOutPortCell = null; mxCell dstNodeCell = resNodeCells.get(dstResNode); - if(callEdge.getSource() instanceof StatefulObjectNode) { + if (callEdge.getSource() instanceof StatefulObjectNode) { srcResNode = ((StatefulObjectNode)callEdge.getSource()).getResource(); srcNodeCell =resNodeCells.get(srcResNode); } - else if (callEdge.getSource() instanceof EntryPointObjectNode) { - srcResNode = (EntryPointObjectNode)callEdge.getSource(); - srcNodeCell = entryNodeCells.get(srcResNode); + else if (callEdge.getSource() instanceof EventChannelObjectNode) { + srcResNode = (EventChannelObjectNode)callEdge.getSource(); + srcNodeCell = eventChNodeCells.get(srcResNode); srcOutPortCell = (mxCell)srcNodeCell.getChildAt(0); } else continue; @@ -766,13 +786,12 @@ if(srcNodeCell == null || dstNodeCell == null) continue; CallEdgeAttribute callEdgeAttr = new CallEdgeAttribute(callEdge, (ObjectNode)callEdge.getSource(), srcNodeCell, dstNodeCell); - - // If "srcResNode" types of "EntryPointObjectNode" (= channel) - // then parameter references to geometry of "outPort". - if(srcResNode instanceof ResourceNode) { + + if (srcResNode instanceof ResourceNode) { graph.insertEdge(layerCell, null, callEdgeAttr, srcNodeCell, dstNodeCell, "movable=false;"); } - else if(srcResNode instanceof EntryPointObjectNode) { + // イベントチャンネルはoutPortのセルの座標を参照. + else if (srcResNode instanceof EventChannelObjectNode) { graph.insertEdge(layerCell, null, callEdgeAttr, srcOutPortCell, dstNodeCell, "movable=false;"); } @@ -782,22 +801,24 @@ /************************************************************* - * + * 状態を持たないオブジェクトをコントロールフローグラフに追加する. + * @param insertObjNode 追加したいオブジェクトの情報 + * @param selectedOption コントロールフローのデータ転送方式 */ private void addObjectNodeToCallGraph(final ObjectNode insertObjNode, final PushPullValue selectedOption) { - switch(selectedOption) { - case PUSH: - if(controlFlowGraph.getPushCallGraph().getNodes().contains(insertObjNode))return; - controlFlowGraph.getPushCallGraph().addNode(insertObjNode); - - break; - - case PULL: - case PUSHorPULL: - if(controlFlowGraph.getPullCallGraph().getNodes().contains(insertObjNode))return; - controlFlowGraph.getPullCallGraph().addNode(insertObjNode); - - break; + switch (selectedOption) { + case PUSH: + if (controlFlowGraph.getPushCallGraph().getNodes().contains(insertObjNode)) return; + controlFlowGraph.getPushCallGraph().addNode(insertObjNode); + + break; + + case PULL: + case PUSHorPULL: + if (controlFlowGraph.getPullCallGraph().getNodes().contains(insertObjNode)) return; + controlFlowGraph.getPullCallGraph().addNode(insertObjNode); + + break; } } diff --git a/AlgebraicDataflowArchitectureModel/src/application/editor/stages/ControlFlowDelegationStageStatus.java b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/ControlFlowDelegationStageStatus.java index 93a88a4..ed33060 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/editor/stages/ControlFlowDelegationStageStatus.java +++ b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/ControlFlowDelegationStageStatus.java @@ -4,7 +4,7 @@ * */ public enum ControlFlowDelegationStageStatus { - SELECTING_AN_EDGE, - SHOWING_DELEGATABLE_NODES, - SHOWING_DEPENDENTABLE_NODES + SELECTING_AN_EDGE, // いずれかのエッジを選択している状態 + SHOWING_DELEGATABLE_NODES, // CFD適用可能範囲を表示している状態 + SHOWING_DEPENDENTABLE_NODES // DoM適用可能範囲を表示している状態 } diff --git a/AlgebraicDataflowArchitectureModel/src/application/editor/stages/DataFlowModelingStage.java b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/DataFlowModelingStage.java index db1f2f7..8db3522 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/editor/stages/DataFlowModelingStage.java +++ b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/DataFlowModelingStage.java @@ -45,7 +45,7 @@ /************************************************************* * - * @author n-nitta, k-fujii + * Issue : リソースからチャンネルに対して, 新たにエッジを引こうとするとキャンセルされる. */ public class DataFlowModelingStage extends Stage { public int PORT_DIAMETER = 8; @@ -118,13 +118,13 @@ } /************************************************************* - * + * mxGraphのレイヤーを全てクリアする. */ public void clear() { model = null; ((mxGraphModel) graph.getModel()).clear(); - // Construct layers. + // 空のレイヤーを新規作成 mxCell root = (mxCell) graph.getDefaultParent(); graph.getModel().beginUpdate(); try { diff --git a/AlgebraicDataflowArchitectureModel/src/application/views/PopupMenuBase.java b/AlgebraicDataflowArchitectureModel/src/application/views/PopupMenuBase.java index 625774c..6fd1628 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/views/PopupMenuBase.java +++ b/AlgebraicDataflowArchitectureModel/src/application/views/PopupMenuBase.java @@ -29,7 +29,8 @@ /************************************************************* * [ *public ] /************************************************************* - * + * ポップアップを開く. + * @param x, y ポップアップを開いた座標 */ public void show(int x, int y) { popupMenu.show(graphComponent, x, y); diff --git a/AlgebraicDataflowArchitectureModel/src/application/views/controlFlowDelegation/ControlFlowDelegationStagePopupMenu.java b/AlgebraicDataflowArchitectureModel/src/application/views/controlFlowDelegation/ControlFlowDelegationStagePopupMenu.java index dc088bc..2ee9ee3 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/views/controlFlowDelegation/ControlFlowDelegationStagePopupMenu.java +++ b/AlgebraicDataflowArchitectureModel/src/application/views/controlFlowDelegation/ControlFlowDelegationStagePopupMenu.java @@ -10,7 +10,7 @@ import application.actions.AbstractPopupAction; import application.actions.ChangeCallOrderAction; import application.actions.ShowDependentableMediatorAction; -import application.actions.InsertStatelessObjectAction; +import application.actions.IntroduceMediatorObjectAction; import application.editor.stages.ControlFlowDelegationStage; import application.views.PopupMenuBase; import models.controlFlowModel.CallEdgeAttribute; @@ -24,6 +24,7 @@ private mxCell selectedCell = null; /************************************************************* + /************************************************************* * [ *constructor ] /************************************************************* */ @@ -31,26 +32,28 @@ super(graphComponent); this.stage = stage; - addMenuItem(new JMenuItem(new InsertStatelessObjectAction(stage, graphComponent, selectedCell))); + addMenuItem(new JMenuItem(new IntroduceMediatorObjectAction(stage, graphComponent, selectedCell))); addMenuItem(new JMenuItem(new ChangeCallOrderAction(graphComponent, selectedCell))); addMenuItem(new JMenuItem(new ShowDependentableMediatorAction(stage, graphComponent, selectedCell))); } /************************************************************* + /************************************************************* * [ *public ] /************************************************************* * + * */ @Override public void show(int x, int y) { - if( graphComponent.getCellAt(x, y) instanceof mxCell ) { + if (graphComponent.getCellAt(x, y) instanceof mxCell ) { selectedCell =(mxCell) graphComponent.getCellAt(x, y); } else { selectedCell = null; } - if(this.selectedCell == null) return; + if (this.selectedCell == null) return; notifyCellCached(selectedCell); stage.setCellOnAnyEvent(selectedCell); @@ -65,24 +68,27 @@ } /************************************************************* + /************************************************************* * [ *private ] /************************************************************* + * ポップアップ表示時に選択したセルを, Stageに保存させる. + * @param cell 選択したセル */ private void notifyCellCached(final mxCell cell) { - if(cell == null) return; + if (cell == null) return; - for(Component component : popupMenu.getComponents()) { + for (Component component : popupMenu.getComponents()) { JMenuItem menuItem = null; - if(component instanceof JMenuItem) menuItem = (JMenuItem)component; + if (component instanceof JMenuItem) menuItem = (JMenuItem)component; else return; AbstractPopupAction action = null; - if(menuItem.getAction() instanceof AbstractPopupAction) { + if (menuItem.getAction() instanceof AbstractPopupAction) { action = (AbstractPopupAction)menuItem.getAction(); } else return; - - action.updateTargetCell(cell); + + action.updateTargetCell(cell); // 選択したセルをキャッシュする. } } @@ -90,22 +96,22 @@ * */ private void setEnableMenuItems(final boolean isEnable) { - if(this.selectedCell == null) return; + if (this.selectedCell == null) return; - for(Component component : popupMenu.getComponents()) { + for (Component component : popupMenu.getComponents()) { component.setEnabled(isEnable); // pull only - if(!isSelectedPullCallEdge(selectedCell)) { + if (!isSelectedPullCallEdge(selectedCell)) { JMenuItem menuItem = null; - if(component instanceof JMenuItem) menuItem = (JMenuItem)component; + if (component instanceof JMenuItem) menuItem = (JMenuItem)component; - if(menuItem.getAction() instanceof ShowDependentableMediatorAction) { + if (menuItem.getAction() instanceof ShowDependentableMediatorAction) { component.setEnabled(false); continue; } } - + } } diff --git a/AlgebraicDataflowArchitectureModel/src/application/views/controlFlowDelegation/FlowLayerWindow.java b/AlgebraicDataflowArchitectureModel/src/application/views/controlFlowDelegation/FlowLayerWindow.java index 18f9c69..6b49ab8 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/views/controlFlowDelegation/FlowLayerWindow.java +++ b/AlgebraicDataflowArchitectureModel/src/application/views/controlFlowDelegation/FlowLayerWindow.java @@ -15,7 +15,7 @@ import application.editor.stages.ControlFlowDelegationStage; /************************************************************* - * Window to change visibility of layers for the control-flow-modeling. + * レイヤー表示 */ public class FlowLayerWindow extends JDialog implements IStageChangeListener { private String title = "Flow Layer"; @@ -26,6 +26,7 @@ private ControlFlowDelegationStage stage = null; /************************************************************* + /************************************************************* * [ *constructor ] /************************************************************* * @@ -38,12 +39,13 @@ stage = Editor.STAGE_CONTROL_FLOW_DELEGATION; - // initialize buttons + // ボタンの追加. + dataFlowCheckBox = new JCheckBox("Data-Flow", false); pushFlowCheckBox = new JCheckBox("Push-Flow", true); pullFlowCheckBox = new JCheckBox("Pull-Flow", true); - // each add handler + // 各Viewにイベントハンドラを追加 dataFlowCheckBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -66,7 +68,7 @@ pushFlowCheckBox.setEnabled(false); pullFlowCheckBox.setEnabled(false); - // initialize panel + // レイヤーのパネルレイアウトの初期化. Container panel = getContentPane(); panel.setLayout(new GridLayout(/*low*/3, /*col*/1)); panel.add(dataFlowCheckBox); @@ -78,14 +80,15 @@ } /************************************************************* + /************************************************************* * [ *public ] /************************************************************* - * + * ステージが変わったら, レイヤー表示のボタンのアクティブ状態を切り替える. + * @param stage 現在のステージ */ @Override public void stageChanged(Stage newStage) { - if((newStage instanceof ControlFlowDelegationStage)) { - + if (newStage instanceof ControlFlowDelegationStage) { dataFlowCheckBox.setEnabled(true); pushFlowCheckBox.setEnabled(true); pullFlowCheckBox.setEnabled(true); diff --git a/AlgebraicDataflowArchitectureModel/src/generators/CodeGenerator.java b/AlgebraicDataflowArchitectureModel/src/generators/CodeGenerator.java index 825564e..8f05eb4 100644 --- a/AlgebraicDataflowArchitectureModel/src/generators/CodeGenerator.java +++ b/AlgebraicDataflowArchitectureModel/src/generators/CodeGenerator.java @@ -24,7 +24,7 @@ import models.algebra.Term; import models.algebra.Type; import models.algebra.Variable; -import models.controlFlowModel.EntryPointObjectNode; +import models.controlFlowModel.EventChannelObjectNode; import models.controlFlowModel.ObjectNode; import models.controlFlowModel.StatefulObjectNode; import models.dataConstraintModel.Channel; @@ -101,7 +101,7 @@ Set> visited = new HashSet<>(); Map> allNodeSets = graph.getAllNodes(); for (Set nodeSet: allNodeSets.values()) { - if (!(nodeSet.iterator().next() instanceof EntryPointObjectNode)) { + if (!(nodeSet.iterator().next() instanceof EventChannelObjectNode)) { topologicalSort(allNodeSets, nodeSet, visited, objects); } } @@ -114,7 +114,7 @@ // a caller is before the callee for (Node curNode: curNodeSet) { for (Edge e: curNode.getInEdges()) { - if (!(e.getSource() instanceof EntryPointObjectNode)) { + if (!(e.getSource() instanceof EventChannelObjectNode)) { if (!(e instanceof DataFlowEdge) || ((PushPullAttribute)((DataFlowEdge) e).getAttribute()).getOptions().get(0) == PushPullValue.PUSH) { // for a call edge or PUSH data-flow edge topologicalSort(allNodeSets, allNodeSets.get(e.getSource()), visited, orderedList); diff --git a/AlgebraicDataflowArchitectureModel/src/generators/CodeGeneratorFromControlFlowGraph.java b/AlgebraicDataflowArchitectureModel/src/generators/CodeGeneratorFromControlFlowGraph.java index 2455f04..aded588 100644 --- a/AlgebraicDataflowArchitectureModel/src/generators/CodeGeneratorFromControlFlowGraph.java +++ b/AlgebraicDataflowArchitectureModel/src/generators/CodeGeneratorFromControlFlowGraph.java @@ -28,7 +28,7 @@ import models.algebra.ValueUndefined; import models.algebra.Variable; import models.controlFlowModel.ControlFlowGraph; -import models.controlFlowModel.EntryPointObjectNode; +import models.controlFlowModel.EventChannelObjectNode; import models.controlFlowModel.ObjectNode; import models.controlFlowModel.StatefulObjectNode; import models.dataConstraintModel.ChannelMember; @@ -443,14 +443,14 @@ // Declare update or input method in the resource component. ResourceNode resourceNode = ((StatefulObjectNode) node).getResource(); MethodDeclaration updateOrInput = null; - if (!(prevResNode instanceof EntryPointObjectNode) + if (!(prevResNode instanceof EventChannelObjectNode) || (resourcesToReceive != null && resourcesToReceive.size() > 0)) { updateOrInput = getUpdateMethod(inEdge, component, dataFlowInform, langSpec); if (updateOrInput != null) return updateOrInput; // Declare an update method. updateOrInput = declareUpdateMethod(node, inEdge, component, dataFlowInform, langSpec); } else { - DataTransferChannel ch = ((EntryPointObjectNode) prevResNode).getIOChannel(); + DataTransferChannel ch = ((EventChannelObjectNode) prevResNode).getIOChannel(); updateOrInput = getInputMethod(resourceNode, ch, component); if (updateOrInput != null) return updateOrInput; // Declare an input method. @@ -488,7 +488,7 @@ updateOrInput.addStatement(langSpec.getReturnStatement(returnValue) + langSpec.getStatementDelimiter()); } return updateOrInput; - } else if (node instanceof EntryPointObjectNode) { + } else if (node instanceof EventChannelObjectNode) { // Declare an input method. MethodDeclaration input = null; for (Edge outEdge: node.getOutEdges()) { @@ -511,7 +511,7 @@ List updateMethods = getUpdateMethods(component); if (updateMethods.size() > 0) return updateMethods.get(0); MethodDeclaration updateOrInput = null; - if (!(prevResNode instanceof EntryPointObjectNode) + if (!(prevResNode instanceof EventChannelObjectNode) || (resourcesToReceive != null && resourcesToReceive.size() > 0)) { // Declare an update method. updateOrInput = declareUpdateMethod(node, inEdge, component, dataFlowInform, langSpec); @@ -524,7 +524,7 @@ Edge outEdge = node.getOutEdges().iterator().next(); ObjectNode dstNode = (ObjectNode) outEdge.getDestination(); MethodDeclaration calleeMethod = declareAndFillUpdateAndInputMethods(dstNode, outEdge, prevResNode, dataFlowInform, componentMap, langSpec); - if (updateOrInput == null && prevResNode instanceof EntryPointObjectNode) { + if (updateOrInput == null && prevResNode instanceof EventChannelObjectNode) { // Declare an input method. if (calleeMethod.getParameters() != null) { updateOrInput = langSpec.newMethodDeclaration(calleeMethod.getName(), false, null, new ArrayList<>(calleeMethod.getParameters())); @@ -543,7 +543,7 @@ for (Edge outEdge: node.getOutEdges()) { Node dstNode = outEdge.getDestination(); MethodDeclaration calleeMethod = declareAndFillUpdateAndInputMethods(dstNode, outEdge, prevResNode, dataFlowInform, componentMap, langSpec); - if (updateOrInput == null && prevResNode instanceof EntryPointObjectNode) { + if (updateOrInput == null && prevResNode instanceof EventChannelObjectNode) { // Declare an input method. if (calleeMethod.getParameters() != null) { updateOrInput = langSpec.newMethodDeclaration(calleeMethod.getName(), false, null, new ArrayList<>(calleeMethod.getParameters())); diff --git a/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/CallEdgeAttribute.java b/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/CallEdgeAttribute.java index 2658597..0b71a93 100644 --- a/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/CallEdgeAttribute.java +++ b/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/CallEdgeAttribute.java @@ -6,7 +6,7 @@ import models.dataFlowModel.PushPullValue; /************************************************************* - * Information of connection status of the call edge among nodes type of "Object-Node". + * "ObjectNode"間の呼び出しエッジの情報 */ public class CallEdgeAttribute extends EdgeAttribute { private CallEdge callEdge = null; @@ -81,7 +81,7 @@ } /************************************************************* - * + * エッジの呼び出し順を表示する */ @Override public String toString() { diff --git a/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/CompositeCallEdgeAttribute.java b/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/CompositeCallEdgeAttribute.java index 389be85..71548e8 100644 --- a/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/CompositeCallEdgeAttribute.java +++ b/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/CompositeCallEdgeAttribute.java @@ -3,6 +3,10 @@ import java.util.ArrayList; import java.util.List; +/************************************************************* + * 制御フローを表す2本以上のエッジを統合したときの情報. + * e.g.) "仲介者への依存"等で2本の制御フローのエッジが1本になったときなど. + */ public class CompositeCallEdgeAttribute extends CallEdgeAttribute { private CallEdgeAttribute currentEdgeAttr = null; private List mergedCallEdgeAttrs = null; @@ -28,8 +32,8 @@ * */ public void mergeCallEdgeAttribute(final CallEdgeAttribute mergedCallEdgeAttr) { - if(this.currentEdgeAttr == null) return; - if(this.mergedCallEdgeAttrs == null) this.mergedCallEdgeAttrs = new ArrayList(); + if (this.currentEdgeAttr == null) return; + if (this.mergedCallEdgeAttrs == null) this.mergedCallEdgeAttrs = new ArrayList(); this.mergedCallEdgeAttrs.add(mergedCallEdgeAttr); } diff --git a/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/ControlFlowDelegator.java b/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/ControlFlowDelegator.java index 01fca86..1da9ffb 100644 --- a/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/ControlFlowDelegator.java +++ b/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/ControlFlowDelegator.java @@ -7,13 +7,14 @@ import models.dataFlowModel.PushPullValue; /************************************************************* - * it has Delegation of Control-Flow algorithm. + * */ public class ControlFlowDelegator { private ControlFlowGraph controlFlowGraph = null; /************************************************************* + /************************************************************* * [ *constructor ] /************************************************************* * @@ -23,11 +24,13 @@ } /************************************************************* + /************************************************************* * [ *public ] /************************************************************* - * - *@param callEdge - */ + * CFD適用可能範囲を探索する + * @param callEdge + * @return CFD適用可能なノードのリスト + */ public List searchDelegatableNodes(final CallEdge callEdge){ List nodes = new ArrayList<>(); @@ -35,14 +38,14 @@ ObjectNode delegatingNode = (ObjectNode) callEdge.getDestination(); ObjectNode parentNode = (ObjectNode) callEdge.getSource(); - if(parentNode == null || delegatingNode == null) + if (parentNode == null || delegatingNode == null) throw new NullPointerException("parentNode is null."); - if( !(parentNode instanceof ObjectNode && delegatingNode instanceof ObjectNode)) + if ( !(parentNode instanceof ObjectNode && delegatingNode instanceof ObjectNode)) throw new ClassCastException("callEdge.getSource() is not ObjectNode"); // if the relation of "delegatingNode" to "parentNode" is 1 : 1 ? // then return an empty list. - if( isRootNode(parentNode) && ! hasChildrenNode(parentNode) ) return nodes; + if (isRootNode(parentNode) && !hasChildrenNode(parentNode) ) return nodes; // 2. collecting for each transfer method has nodes in the common area. collectCommonTransferNodes(nodes, parentNode, delegatingNode); @@ -50,15 +53,13 @@ // 3. if the transfer method is PUSH-style, // then search delegatable area. collectParentNodesOnPushTransfer(nodes, delegatingNode, parentNode); - - - // switch objects by transfer type + return nodes; } /************************************************************* - * + * DoMが適用可能な仲介者オブジェクトの探索 *@param callEdge */ public List searchDependentableMediatorNodes(final CallEdge callEdge){ @@ -72,7 +73,9 @@ } /************************************************************* - * + * CFDを実行する. + * @param delegatingEdge 委譲するコントロールフロー + * @param dstObjNode 呼び出し元となるノード */ public void delegateCallEdge(CallEdge delegatingEdge, final ObjectNode dstObjNode) { ObjectNode srcObjNode = (ObjectNode)delegatingEdge.getDestination(); @@ -90,12 +93,13 @@ } /************************************************************* - * [* private ] /************************************************************* - * [ search ] + * [ *private ] /************************************************************* - * Collecting nodes in the "nodes" parameter for each transfer method has nodes in the common area. - * @param nodes + * search + /************************************************************* + * PUSH/PULLで共通するCFD適用可能なノードを再帰的に探索する + * @param nodes 適用可能なノードのリスト * @param curObjNode * @param delegatingObjNode * @param selectedOption @@ -114,9 +118,11 @@ } /************************************************************* - * Collecting nodes in the "nodes" parameter for node of the area of PUSH-style transfer method. - * @param result in "nodes" parameter. + * 順序が必要なPUSHのコントロールフローグラフ上のCFD適用可能範囲を再帰的に探索する. + * (自身の親となるノードを再帰的に探索する) + * @param nodes * @param curObjNode + * @param parentDelegatingNode */ private void collectParentNodesOnPushTransfer(List nodes, ObjectNode curObjNode, final ObjectNode parentDelegatingNode) { if( isRootNode(curObjNode) ) return; @@ -133,17 +139,19 @@ if( !(edge instanceof CallEdge)) continue; int callOrder = parentObjNode.getOutEdgeCallOrder((CallEdge)edge); - if(inEdgeCallOrder < callOrder) collectChildNodesOnPushTransfer(nodes, (CallEdge)edge); + if(inEdgeCallOrder < callOrder) collectChildrenNodesOnPushTransfer(nodes, (CallEdge)edge); } collectParentNodesOnPushTransfer(nodes, parentObjNode, parentDelegatingNode); } /************************************************************* - * - * @param node + * 順序が必要なPUSHのコントロールフローグラフ上のCFD適用可能範囲を再帰的に探索する. + * (あるコントロールフローについて, その呼び出し順よりも若いノードを, 呼び出し先を辿ることで再帰的に探索する) + * @param nodes + * @param callEdge */ - private void collectChildNodesOnPushTransfer(List nodes, CallEdge callEdge) { + private void collectChildrenNodesOnPushTransfer(List nodes, CallEdge callEdge) { ObjectNode dstObjNode = (ObjectNode)callEdge.getDestination(); if(dstObjNode == null) return; @@ -159,18 +167,19 @@ if(foundNode == null) continue; if(nodes.contains(foundNode))continue; - collectChildNodesOnPushTransfer(nodes, edge); + collectChildrenNodesOnPushTransfer(nodes, edge); } } /************************************************************* - * - * + * PULLのコントロールフローにおいて, DoM適用可能な仲介者オブジェクトを探索する. + * @param nodes + * @param callEdge */ private void collectDependableObjectNodeOnPullTransfer(List nodes, CallEdge callEdge) { if(callEdge.getSelectedOption() != PushPullValue.PULL) return; - // Are Both Source and Destination Stateful-Object? + // エッジの両端が状態を持つノード(リソース)か? StatefulObjectNode srcObjNode = (callEdge.getSource() instanceof StatefulObjectNode) ? (StatefulObjectNode)callEdge.getSource() : null; @@ -181,19 +190,19 @@ if(srcObjNode == null || dstObjNode == null) return; - // Has a destination connected with an object of a mediator? + // 呼び出し先が仲介者オブジェクトか? for(Edge inEdge : dstObjNode.getInEdges()) { CallEdge inCallEdge = (CallEdge)inEdge; if(inCallEdge == null) continue; - // It is a stateless object? (It is a mediator object?) + // 状態を持たないオブジェクトか?(仲介者オブジェクトか?) ObjectNode inSrcObjNode = (inCallEdge.getSource() instanceof ObjectNode) ? (ObjectNode)inCallEdge.getSource() : null; if(inSrcObjNode == null) continue; if(inSrcObjNode instanceof StatefulObjectNode) continue; - if(inSrcObjNode instanceof EntryPointObjectNode) continue; + if(inSrcObjNode instanceof EventChannelObjectNode) continue; nodes.add(inSrcObjNode); } @@ -201,7 +210,7 @@ /************************************************************* - * + * あるノードがルートかどうか * @param node */ private boolean isRootNode(final ObjectNode node) { @@ -209,7 +218,7 @@ } /************************************************************* - * + * 呼び出し先があるかどうか * @param node */ private boolean hasChildrenNode(final ObjectNode node) { diff --git a/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/ControlFlowGraph.java b/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/ControlFlowGraph.java index c2f9477..8cf4e37 100644 --- a/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/ControlFlowGraph.java +++ b/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/ControlFlowGraph.java @@ -45,7 +45,7 @@ } for (Channel ch: model.getIOChannels()) { DataTransferChannel cio = (DataTransferChannel) ch; - EntryPointObjectNode srcNode = new EntryPointObjectNode(cio); + EventChannelObjectNode srcNode = new EventChannelObjectNode(cio); for (ChannelMember cm: cio.getChannelMembers()) { if (srcNode.getName() == null) { Expression exp = cm.getStateTransition().getMessageExpression(); diff --git a/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/EntryPointObjectNode.java b/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/EntryPointObjectNode.java deleted file mode 100644 index 8100090..0000000 --- a/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/EntryPointObjectNode.java +++ /dev/null @@ -1,40 +0,0 @@ -package models.controlFlowModel; - -import models.dataFlowModel.DataTransferChannel; - -/************************************************************* - * An object is mapped to I/O channel. - * ToDo: Fecthing name from in Data-Flow-Graph - */ -public class EntryPointObjectNode extends ObjectNode { - DataTransferChannel ioChannel = null; - - /************************************************************* - * [ *constructor ] - /************************************************************* - * - */ - public EntryPointObjectNode(DataTransferChannel ioChannel) { - super(null); - this.ioChannel = ioChannel; - } - - public EntryPointObjectNode(String name, DataTransferChannel ioChannel) { - super(name); - this.ioChannel = ioChannel; - } - - /************************************************************* - * [ *public ] - /************************************************************* - * - */ - public DataTransferChannel getIOChannel() { - return ioChannel; - } - - public void setIOChannel(DataTransferChannel ioChannel) { - this.ioChannel = ioChannel; - } - -} diff --git a/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/EventChannelObjectNode.java b/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/EventChannelObjectNode.java new file mode 100644 index 0000000..94d01f7 --- /dev/null +++ b/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/EventChannelObjectNode.java @@ -0,0 +1,41 @@ +package models.controlFlowModel; + +import models.dataFlowModel.DataTransferChannel; + +/************************************************************* + * "コントロールフローモデリング"において, イベントチャンネルを表す"ObjectNode". + */ +public class EventChannelObjectNode extends ObjectNode { + DataTransferChannel ioChannel = null; + + /************************************************************* + /************************************************************* + * [ *constructor ] + /************************************************************* + * + */ + public EventChannelObjectNode(DataTransferChannel ioChannel) { + super(null); + this.ioChannel = ioChannel; + } + + public EventChannelObjectNode(String name, DataTransferChannel ioChannel) { + super(name); + this.ioChannel = ioChannel; + } + + /************************************************************* + /************************************************************* + * [ *public ] + /************************************************************* + * + */ + public DataTransferChannel getIOChannel() { + return ioChannel; + } + + public void setIOChannel(DataTransferChannel ioChannel) { + this.ioChannel = ioChannel; + } + +} diff --git a/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/ObjectNode.java b/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/ObjectNode.java index dedb5af..d99a255 100644 --- a/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/ObjectNode.java +++ b/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/ObjectNode.java @@ -7,12 +7,13 @@ import models.Node; /************************************************************* -* +* "コントロールフローモデリング"上の汎用的なノード. */ public class ObjectNode extends Node { protected String name = ""; /************************************************************* + /************************************************************* * [ *constructor] /************************************************************* */ @@ -24,6 +25,7 @@ } /************************************************************* + /************************************************************* * [ *public ] /************************************************************* * @@ -45,8 +47,8 @@ } public CallEdge findEdgeInInEdges(final CallEdge edge) { - for(Edge e : inEdges) { - if( e instanceof CallEdge) return (CallEdge)e; + for (Edge e : inEdges) { + if (e instanceof CallEdge) return (CallEdge)e; } return null; } @@ -54,21 +56,14 @@ public void insertOutEdge(CallEdge edge, int n) { ((List) outEdges).add(n, edge); } - - public CallEdge findEdgeInOutEdges(final CallEdge edge) { - for(Edge e : outEdges) { - if( e instanceof CallEdge) return (CallEdge)e; - } - return null; - } - + public int getChildrenNum() { return outEdges.size(); } public int getOutEdgeCallOrder(final CallEdge callEdge) { - for(int i = 0; i < outEdges.size(); i++) { - if(callEdge.equals(getOutEdge(i))) return i; + for (int i = 0; i < outEdges.size(); i++) { + if (callEdge.equals(getOutEdge(i))) return i; } return -1; } @@ -78,7 +73,9 @@ } /************************************************************* - * + * 指定したエッジ(出力側)の呼び出し順を変更する. + * @param curOrder 現在の呼び出し順 + * @param newCallOrder 新しい呼び出し順 */ public void sortOutEdgesByCallOrder(final int curOrder, final int newCallOrder) { ArrayList edges = ((ArrayList)outEdges); diff --git a/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/ObjectNodeAttribute.java b/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/ObjectNodeAttribute.java index 5ac52e2..ac863db 100644 --- a/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/ObjectNodeAttribute.java +++ b/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/ObjectNodeAttribute.java @@ -3,9 +3,8 @@ import models.NodeAttribute; /************************************************************* - * - * @author k-fujii - * + * "mxCell"の持つ, "ObjectNode"に関する情報. + * "ObjectNode"のインスタンスに応じて */ public class ObjectNodeAttribute extends NodeAttribute { private ObjectNode objectNode = null; @@ -24,7 +23,7 @@ if(objectNode instanceof StatefulObjectNode) { shapeStyle = "shape=ellipse;perimeter=ellipsePerimeter;"; } - else if(objectNode instanceof EntryPointObjectNode) { + else if(objectNode instanceof EventChannelObjectNode) { shapeStyle = "shape=rectangle;perimeter=rectanglePerimeter;"; } else { @@ -38,7 +37,7 @@ if( objectNode instanceof StatefulObjectNode ) { objectNode.name = objectNode.getName(); } - else if(objectNode instanceof EntryPointObjectNode){ + else if(objectNode instanceof EventChannelObjectNode){ objectNode.name = "entryPoint"; } } @@ -49,7 +48,6 @@ * [ getter ] /************************************************************* * - * @return */ public ObjectNode getObjectNode() { return objectNode; @@ -67,7 +65,7 @@ } /************************************************************* - * + * 選択状態のセルの色を取得 */ public String getEnableStyle() { String style = "fillColor=#7fffd4;"; @@ -80,7 +78,7 @@ } /************************************************************* - * + * 非選択状態のセルの色を取得 */ public String getDisableStyle() { String style = "fillColor=#999999"; @@ -91,7 +89,7 @@ } /************************************************************* - * + * ”制御フローモデリング”の操作が適用可能状態のセルの色を取得 */ public String getDelegatingStyle() { String style = "strokeWidth=4;"; @@ -101,7 +99,7 @@ } /************************************************************* - * showing label of mxCell + * GUI上に表示するセルの名前を返す. */ @Override public String toString() { diff --git a/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/StatefulObjectNode.java b/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/StatefulObjectNode.java index b627259..d5a8b5a 100644 --- a/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/StatefulObjectNode.java +++ b/AlgebraicDataflowArchitectureModel/src/models/controlFlowModel/StatefulObjectNode.java @@ -2,6 +2,9 @@ import models.dataFlowModel.ResourceNode; +/************************************************************* + * "制御フローモデリング"上で状態を持つ"ObjectNode" + */ public class StatefulObjectNode extends ObjectNode { private ResourceNode resource;