diff --git a/src/android/readme b/src/android/readme index 831d79eab5def2cd29fe8c4e091db856134820d6..eb12c04fe403b4ad847ae3f4699b00c1b8e25a1c 100644 --- a/src/android/readme +++ b/src/android/readme @@ -22,4 +22,7 @@ List devices connected to your PC / Mac: $adb devices Installing apk on your phone / tablet via usb -$adb install bin/appli.apk \ No newline at end of file +$adb install bin/appli.apk + +Removing the application +*adb uninstall appli.apk diff --git a/src/avatartranslator/directsimulation/AvatarSimulationBlock.java b/src/avatartranslator/directsimulation/AvatarSimulationBlock.java index 5ebaa09d97f116041bc5e3e96bfd90401be4baa1..4e8fd78a396a1e2cc361436086d4de00ae118ae0 100644 --- a/src/avatartranslator/directsimulation/AvatarSimulationBlock.java +++ b/src/avatartranslator/directsimulation/AvatarSimulationBlock.java @@ -61,6 +61,7 @@ public class AvatarSimulationBlock { private AvatarSimulationTransaction lastTransaction; private Vector <AvatarSimulationTransaction> transactions; private boolean completed; + public boolean selected; // Free use for graphic purpose //private int elapsedTime; diff --git a/src/avatartranslator/directsimulation/AvatarSpecificationSimulation.java b/src/avatartranslator/directsimulation/AvatarSpecificationSimulation.java index 14276a3cd895618d9c14717a08523235bb8146d8..998ba3775c2bc1353a3a8ad2159593c4635585cf 100644 --- a/src/avatartranslator/directsimulation/AvatarSpecificationSimulation.java +++ b/src/avatartranslator/directsimulation/AvatarSpecificationSimulation.java @@ -73,6 +73,7 @@ public class AvatarSpecificationSimulation { private AvatarSimulationInteraction asi; private long clockValue; private Vector<AvatarSimulationBlock> blocks; + private Vector<AvatarSimulationBlock> selectedBlocks; private AvatarSimulationBlock previousBlock; private Vector<AvatarSimulationAsynchronousTransaction> asynchronousMessages; private Vector<AvatarSimulationPendingTransaction> pendingTransactions; @@ -117,6 +118,20 @@ public class AvatarSpecificationSimulation { return blocks; } + public void computeSelectedSimulationBlocks() { + selectedBlocks = new Vector<AvatarSimulationBlock>(); + for (AvatarSimulationBlock block: blocks) { + if (block.selected) { + selectedBlocks.add(block); + } + } + } + + public Vector<AvatarSimulationBlock> getSelectedSimulationBlocks() { + + return selectedBlocks; + } + public Vector<AvatarSimulationTransaction> getAllTransactions() { return allTransactions; } @@ -163,6 +178,8 @@ public class AvatarSpecificationSimulation { } } + computeSelectedSimulationBlocks(); + // Create all simulation asynchronous channels asynchronousMessages = new Vector<AvatarSimulationAsynchronousTransaction>(); diff --git a/src/ui/avatarinteractivesimulation/AvatarInteractiveSimulationActions.java b/src/ui/avatarinteractivesimulation/AvatarInteractiveSimulationActions.java index 32700b5157feaa6aac591331e5def24edc9e0b1f..b5cdac59e66bbf2f94276c033bec2905a6a732e7 100755 --- a/src/ui/avatarinteractivesimulation/AvatarInteractiveSimulationActions.java +++ b/src/ui/avatarinteractivesimulation/AvatarInteractiveSimulationActions.java @@ -94,8 +94,11 @@ public class AvatarInteractiveSimulationActions extends AbstractAction { public static final int ACT_PRINT_CPUS = 28; public static final int ACT_PRINT_BUS = 29; + + public static final int ACT_ZOOM_IN = 30; + public static final int ACT_ZOOM_OUT = 31; - public static final int NB_ACTION = 30; + public static final int NB_ACTION = 32; private static final TAction [] actions = new TAction[NB_ACTION]; @@ -175,6 +178,10 @@ public class AvatarInteractiveSimulationActions extends AbstractAction { actions[ACT_PRINT_BENCHMARK] = new TAction("print-benchmark", "Print benchmark", IconManager.imgic29, IconManager.imgic29, "Print benchmark", "Print benchmark at simulator side", 'R'); actions[ACT_SAVE_BENCHMARK] = new TAction("save-benchmark", "Save benchmark", IconManager.imgic25, IconManager.imgic25, "Save benchmark", "Save benchmark at simulator side", 'R'); + actions[ACT_ZOOM_IN] = new TAction("zoommore-command", "Zoom +", IconManager.imgic317, IconManager.imgic317, "Zoom +", "Zoom +", '0'); + actions[ACT_ZOOM_OUT] = new TAction("zoomless-command", "Zoom -", IconManager.imgic315, IconManager.imgic315, "Zoom -", "Zoom -", '0'); + + } public String getActionCommand() { diff --git a/src/ui/avatarinteractivesimulation/AvatarMainCommandsToolBar.java b/src/ui/avatarinteractivesimulation/AvatarMainCommandsToolBar.java index 6fe0cda704519d00a915aac0eec1b061e80f169b..5f318836ba00a7347d7cf3f0013e5e1880be0706 100755 --- a/src/ui/avatarinteractivesimulation/AvatarMainCommandsToolBar.java +++ b/src/ui/avatarinteractivesimulation/AvatarMainCommandsToolBar.java @@ -75,6 +75,8 @@ public class AvatarMainCommandsToolBar extends AvatarInteractiveSimulationBar { jfais.actions[AvatarInteractiveSimulationActions.ACT_RESET_SIMU].setEnabled(b); jfais.actions[AvatarInteractiveSimulationActions.ACT_RUN_X_COMMANDS].setEnabled(b); + + } protected void setButtons() { @@ -102,6 +104,16 @@ public class AvatarMainCommandsToolBar extends AvatarInteractiveSimulationBar { button = this.add(jfais.actions[AvatarInteractiveSimulationActions.ACT_RUN_X_COMMANDS]); button.addMouseListener(jfais.mouseHandler); + + this.addSeparator(); + this.addSeparator(); + + button = this.add(jfais.actions[AvatarInteractiveSimulationActions.ACT_ZOOM_OUT]); + button.addMouseListener(jfais.mouseHandler); + + button = this.add(jfais.actions[AvatarInteractiveSimulationActions.ACT_ZOOM_IN]); + button.addMouseListener(jfais.mouseHandler); + /*this.addSeparator(); diff --git a/src/ui/avatarinteractivesimulation/AvatarSpecificationSimulationSDPanel.java b/src/ui/avatarinteractivesimulation/AvatarSpecificationSimulationSDPanel.java index 936b5b2247c0975c6ede305280383c29f799e634..de5be543a3db363ef92885916cfe57f30debdaf1 100644 --- a/src/ui/avatarinteractivesimulation/AvatarSpecificationSimulationSDPanel.java +++ b/src/ui/avatarinteractivesimulation/AvatarSpecificationSimulationSDPanel.java @@ -76,6 +76,7 @@ public class AvatarSpecificationSimulationSDPanel extends JPanel implements Mous // Drawing parameters private int minSpaceBetweenLifeLines = 5; private int spaceBetweenLifeLines = 150; + private int basicSpaceBetweenLifeLines = 150; private boolean spaceBetweenLifeLinesComputed = false; private int spaceAtEnd = 50; private int spaceAtTop = 50; @@ -87,6 +88,13 @@ public class AvatarSpecificationSimulationSDPanel extends JPanel implements Mous private int lengthAsync = 50; private int spaceBroadcast = 25; + + private double[] zoomValues = {0.2, 0.3, 0.5, 0.60, 0.80, 1.0, 1.2, 1.5, 2, 2.5, 3, 4}; + private int zoomIndex = 5; + private int maxZoomIndex = 11; + + + private AvatarSpecificationSimulation ass; // Transactions @@ -108,6 +116,8 @@ public class AvatarSpecificationSimulationSDPanel extends JPanel implements Mous public AvatarSpecificationSimulationSDPanel(AvatarSpecificationSimulation _ass) { ass = _ass; + + ass.computeSelectedSimulationBlocks(); points = new Vector<Point>(); transactionsOfPoints = new Vector<AvatarSimulationTransaction>(); @@ -131,6 +141,7 @@ public class AvatarSpecificationSimulationSDPanel extends JPanel implements Mous if (!spaceBetweenLifeLinesComputed) { computeSpaceBetweenLifeLines(g); + basicSpaceBetweenLifeLines = spaceBetweenLifeLines; } @@ -168,15 +179,17 @@ public class AvatarSpecificationSimulationSDPanel extends JPanel implements Mous String name; int w; - Vector<AvatarSimulationBlock> blocks = ass.getSimulationBlocks(); + Vector<AvatarSimulationBlock> blocks = ass.getSelectedSimulationBlocks(); for(AvatarSimulationBlock block: blocks) { - g.drawLine(currentX + (spaceBetweenLifeLines/4), currentY, currentX + (3*spaceBetweenLifeLines/4), currentY); - g.drawLine(currentX + (spaceBetweenLifeLines/2), currentY, currentX + (spaceBetweenLifeLines/2), currentY + verticalSpaceUnderBlocks); - name = block.getBlock().getName(); - w = g.getFontMetrics().stringWidth(name); - g.drawString(name, currentX + ((spaceBetweenLifeLines-w)/2), currentY - spaceVerticalText); - currentX += spaceBetweenLifeLines; + if (block.selected) { + g.drawLine(currentX + (spaceBetweenLifeLines/4), currentY, currentX + (3*spaceBetweenLifeLines/4), currentY); + g.drawLine(currentX + (spaceBetweenLifeLines/2), currentY, currentX + (spaceBetweenLifeLines/2), currentY + verticalSpaceUnderBlocks); + name = block.getBlock().getName(); + w = g.getFontMetrics().stringWidth(name); + g.drawString(name, currentX + ((spaceBetweenLifeLines-w)/2), currentY - spaceVerticalText); + currentX += spaceBetweenLifeLines; + } } maxX = currentX; @@ -208,7 +221,8 @@ public class AvatarSpecificationSimulationSDPanel extends JPanel implements Mous // Draw only the last drawnTransactions Vector<AvatarSimulationTransaction> allTransactions = ass.getAllTransactions(); - Vector<AvatarSimulationBlock> blocks = ass.getSimulationBlocks(); + //Vector<AvatarSimulationBlock> blocks = ass.getSimulationBlocks(); + Vector<AvatarSimulationBlock> blocks = ass.getSelectedSimulationBlocks(); if (allTransactions.size() > 0) { ast = allTransactions.get(Math.max(0, allTransactions.size()-1000)); @@ -222,45 +236,47 @@ public class AvatarSpecificationSimulationSDPanel extends JPanel implements Mous ast.stamp = stamp; index = blocks.indexOf(ast.asb); - xOfBlock = currentX + (index * spaceBetweenLifeLines) + spaceBetweenLifeLines/2; - - points.clear(); - transactionsOfPoints.clear(); - - if (ast.executedElement instanceof AvatarState) { - newCurrentY = drawState(g, ast, (AvatarState)(ast.executedElement), xOfBlock, currentY); - } else if (ast.executedElement instanceof AvatarTransition) { - newCurrentY = drawTransition(g, (AvatarTransition)(ast.executedElement), ast, xOfBlock, currentY); - } else if (ast.executedElement instanceof AvatarActionOnSignal) { - newCurrentY = drawAvatarActionOnSignal(g, (AvatarActionOnSignal)(ast.executedElement), ast, xOfBlock, currentY, currentX); - } else if (ast.executedElement instanceof AvatarStopState) { - newCurrentY = drawAvatarStopState(g, ast, xOfBlock, currentY, currentX); - } else if (ast.executedElement instanceof AvatarRandom) { - newCurrentY = drawRandom(g, (AvatarRandom)(ast.executedElement), ast, xOfBlock, currentY); - } - - if ((yMouse>= currentY) && (yMouse <= newCurrentY)) { - for(int cpt = 0; cpt<points.size(); cpt++) { - drawIDInfo(g, points.get(cpt).x, points.get(cpt).y, transactionsOfPoints.get(cpt).id); - } - } + if (index != -1) { + xOfBlock = currentX + (index * spaceBetweenLifeLines) + spaceBetweenLifeLines/2; - - // Draw the line of other blocks - if (currentY != newCurrentY) { - xOfBlock = currentX + spaceBetweenLifeLines/2; - for(AvatarSimulationBlock block: blocks) { - if (block != ast.asb) { - g.drawLine(xOfBlock, currentY, xOfBlock, newCurrentY); + points.clear(); + transactionsOfPoints.clear(); + + if (ast.executedElement instanceof AvatarState) { + newCurrentY = drawState(g, ast, (AvatarState)(ast.executedElement), xOfBlock, currentY); + } else if (ast.executedElement instanceof AvatarTransition) { + newCurrentY = drawTransition(g, (AvatarTransition)(ast.executedElement), ast, xOfBlock, currentY); + } else if (ast.executedElement instanceof AvatarActionOnSignal) { + newCurrentY = drawAvatarActionOnSignal(g, (AvatarActionOnSignal)(ast.executedElement), ast, xOfBlock, currentY, currentX); + } else if (ast.executedElement instanceof AvatarStopState) { + newCurrentY = drawAvatarStopState(g, ast, xOfBlock, currentY, currentX); + } else if (ast.executedElement instanceof AvatarRandom) { + newCurrentY = drawRandom(g, (AvatarRandom)(ast.executedElement), ast, xOfBlock, currentY); + } + + if ((yMouse>= currentY) && (yMouse <= newCurrentY)) { + for(int cpt = 0; cpt<points.size(); cpt++) { + drawIDInfo(g, points.get(cpt).x, points.get(cpt).y, transactionsOfPoints.get(cpt).id); } - xOfBlock += spaceBetweenLifeLines; } - if (ast.clockValueWhenFinished != clockValue) { - clockValue = ast.clockValueWhenFinished; - if (yMouse >= newCurrentY) { - clockValueMouse = clockValue; + + + // Draw the line of other blocks + if (currentY != newCurrentY) { + xOfBlock = currentX + spaceBetweenLifeLines/2; + for(AvatarSimulationBlock block: blocks) { + if (block != ast.asb) { + g.drawLine(xOfBlock, currentY, xOfBlock, newCurrentY); + } + xOfBlock += spaceBetweenLifeLines; + } + if (ast.clockValueWhenFinished != clockValue) { + clockValue = ast.clockValueWhenFinished; + if (yMouse >= newCurrentY) { + clockValueMouse = clockValue; + } + g.drawString("@" + clockValue, 10, newCurrentY+g.getFontMetrics().getHeight()/2); } - g.drawString("@" + clockValue, 10, newCurrentY+g.getFontMetrics().getHeight()/2); } } @@ -426,30 +442,32 @@ public class AvatarSpecificationSimulationSDPanel extends JPanel implements Mous //TraceManager.addDev("Working on message name:" + messageName); // Drawing the arrow // Assume a different block in the two transactions - int index = ass.getSimulationBlocks().indexOf(ast.linkedTransaction.asb); - int xOf2ndBlock = startX + (index * spaceBetweenLifeLines) + spaceBetweenLifeLines/2; - - currentY += 10; - g.setColor(ColorManager.AVATAR_RECEIVE_SIGNAL); - g.drawLine(xOf2ndBlock, currentY-1, currentX, currentY-1); - g.setColor(c); - GraphicLib.arrowWithLine(g, 1, 0, 10, xOf2ndBlock, currentY, currentX, currentY, true); - points.add(new Point(xOf2ndBlock, currentY)); - transactionsOfPoints.add(ast.linkedTransaction); - transactionsOfPoints.add(ast); - points.add(new Point(currentX, currentY)); - - - // Putting the message name - w = g.getFontMetrics().stringWidth(messageName); - int xtmp = (xOf2ndBlock + currentX)/2 - w/2; - g.drawString(messageName, xtmp, currentY-2); - - - currentY += 10; - - // Vertical line of receiving block - g.drawLine(currentX, currentY-20, currentX, currentY); + int index = ass.getSelectedSimulationBlocks().indexOf(ast.linkedTransaction.asb); + if (index != -1) { + int xOf2ndBlock = startX + (index * spaceBetweenLifeLines) + spaceBetweenLifeLines/2; + + currentY += 10; + g.setColor(ColorManager.AVATAR_RECEIVE_SIGNAL); + g.drawLine(xOf2ndBlock, currentY-1, currentX, currentY-1); + g.setColor(c); + GraphicLib.arrowWithLine(g, 1, 0, 10, xOf2ndBlock, currentY, currentX, currentY, true); + points.add(new Point(xOf2ndBlock, currentY)); + transactionsOfPoints.add(ast.linkedTransaction); + transactionsOfPoints.add(ast); + points.add(new Point(currentX, currentY)); + + + // Putting the message name + w = g.getFontMetrics().stringWidth(messageName); + int xtmp = (xOf2ndBlock + currentX)/2 - w/2; + g.drawString(messageName, xtmp, currentY-2); + + + currentY += 10; + + // Vertical line of receiving block + g.drawLine(currentX, currentY-20, currentX, currentY); + } return currentY; } } else { @@ -651,7 +669,7 @@ public class AvatarSpecificationSimulationSDPanel extends JPanel implements Mous String name; int w; - Vector<AvatarSimulationBlock> blocks = ass.getSimulationBlocks(); + Vector<AvatarSimulationBlock> blocks = ass.getSelectedSimulationBlocks(); int x = spaceAtEnd; for(AvatarSimulationBlock block: blocks) { @@ -684,4 +702,18 @@ public class AvatarSpecificationSimulationSDPanel extends JPanel implements Mous return image; } + public void zoomIn() { + zoomIndex ++; + zoomIndex = Math.min(maxZoomIndex, zoomIndex); + spaceBetweenLifeLines = (int)(basicSpaceBetweenLifeLines*zoomValues[zoomIndex]); + repaint(); + } + + public void zoomOut() { + zoomIndex --; + zoomIndex = Math.max(0, zoomIndex); + spaceBetweenLifeLines = (int)(basicSpaceBetweenLifeLines*zoomValues[zoomIndex]); + repaint(); + } + } \ No newline at end of file diff --git a/src/ui/avatarinteractivesimulation/JFrameAvatarInteractiveSimulation.java b/src/ui/avatarinteractivesimulation/JFrameAvatarInteractiveSimulation.java index ad4bafd29cafe93e4c6bd5351366f92342934c2a..34c1d5443ed78bfa308b7c20c25f197b35a237dc 100755 --- a/src/ui/avatarinteractivesimulation/JFrameAvatarInteractiveSimulation.java +++ b/src/ui/avatarinteractivesimulation/JFrameAvatarInteractiveSimulation.java @@ -144,6 +144,11 @@ public class JFrameAvatarInteractiveSimulation extends JFrame implements AvatarS private TransactionTableModel transactiontm; private JScrollPane jspTransactionInfo; + // DisplayedBlocks + private JPanel displayedBlockPanel; + private JScrollPane jspDisplayedBlocks; + private Vector<JCheckBox> displayedBlocks; + // Sequence Diagram private AvatarSpecificationSimulationSDPanel sdpanel; @@ -699,6 +704,38 @@ public class JFrameAvatarInteractiveSimulation extends JFrame implements AvatarS jspTransactionInfo.setPreferredSize(new Dimension(250, 300)); transactionPanel.add(jspTransactionInfo, BorderLayout.CENTER); + + // Displayed blocks + displayedBlockPanel = new JPanel(); + displayedBlockPanel.setLayout(new GridBagLayout()); + GridBagConstraints c = new GridBagConstraints(); + + c.gridheight = 1; + c.weighty = 1.0; + c.weightx = 1.0; + c.gridwidth = GridBagConstraints.REMAINDER; //end row + c.fill = GridBagConstraints.BOTH; + c.gridheight = 1; + + displayedBlocks = new Vector<JCheckBox>(); + for(AvatarSimulationBlock block: ass.getSimulationBlocks()) { + JCheckBox jcb = new JCheckBox(block.getName(), true); + block.selected = true; + jcb.addActionListener(this); + TraceManager.addDev("Adding block: " + block); + displayedBlocks.add(jcb); + displayedBlockPanel.add(jcb, c); + } + ass.computeSelectedSimulationBlocks(); + + jspDisplayedBlocks = new JScrollPane(displayedBlockPanel); + jspDisplayedBlocks.setWheelScrollingEnabled(true); + jspDisplayedBlocks.getVerticalScrollBar().setUnitIncrement(10); + jspDisplayedBlocks.setPreferredSize(new Dimension(250, 300)); + infoTab.addTab("Displayed blocks", IconManager.imgic1202, jspDisplayedBlocks, "Displayed blocks"); + + + // Variables /*variablePanel = new JPanel(); variablePanel.setLayout(new BorderLayout()); @@ -937,8 +974,8 @@ public class JFrameAvatarInteractiveSimulation extends JFrame implements AvatarS actions[AvatarInteractiveSimulationActions.ACT_SAVE_TXT].setEnabled(b); actions[AvatarInteractiveSimulationActions.ACT_PRINT_BENCHMARK].setEnabled(b); actions[AvatarInteractiveSimulationActions.ACT_SAVE_BENCHMARK].setEnabled(b); - //actions[AvatarInteractiveSimulationActions.ACT_SAVE_STATE].setEnabled(b); - //actions[AvatarInteractiveSimulationActions.ACT_RESTORE_STATE].setEnabled(b); + actions[AvatarInteractiveSimulationActions.ACT_ZOOM_IN].setEnabled(b); + actions[AvatarInteractiveSimulationActions.ACT_ZOOM_OUT].setEnabled(b); setLabelColors(); @@ -1010,6 +1047,18 @@ public class JFrameAvatarInteractiveSimulation extends JFrame implements AvatarS } } + public void zoomIn() { + if (sdpanel != null) { + sdpanel.zoomIn(); + } + } + + public void zoomOut() { + if (sdpanel != null) { + sdpanel.zoomOut(); + } + } + public void setContentOfListOfPendingTransactions() { EventQueue.invokeLater(this); } @@ -1186,10 +1235,28 @@ public class JFrameAvatarInteractiveSimulation extends JFrame implements AvatarS actSaveTxt(); return; //TraceManager.addDev("Start simulation!"); - } else if (command.equals(actions[AvatarInteractiveSimulationActions.ACT_SAVE_SD_PNG].getActionCommand())) { - actSaveSDPNG(); + } else if (command.equals(actions[AvatarInteractiveSimulationActions.ACT_ZOOM_IN].getActionCommand())) { + zoomIn(); return; //TraceManager.addDev("Start simulation!"); + } else if (command.equals(actions[AvatarInteractiveSimulationActions.ACT_ZOOM_OUT].getActionCommand())) { + zoomOut(); + return; + + } + + + // Check for source of jcheckbox + int index = 0; + for(JCheckBox jcb: displayedBlocks) { + if (evt.getSource() == jcb) { + ass.getSimulationBlocks().get(index).selected = jcb.isSelected(); + TraceManager.addDev("Block " + ass.getSimulationBlocks().get(index) + " is now " + ass.getSimulationBlocks().get(index).selected); + ass.computeSelectedSimulationBlocks(); + sdpanel.repaint(); + return; + } + index ++; } }