Search in sources :

Example 1 with AnalyseException

use of de.neemann.digital.analyse.AnalyseException in project Digital by hneemann.

the class Main method createAnalyseMenu.

/**
 * Creates the analyse menu
 *
 * @param menuBar the menu bar
 */
private void createAnalyseMenu(JMenuBar menuBar) {
    JMenu analyse = new JMenu(Lang.get("menu_analyse"));
    menuBar.add(analyse);
    analyse.add(new ToolTipAction(Lang.get("menu_analyse")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                Model model = new ModelCreator(circuitComponent.getCircuit(), library).createModel(false);
                try {
                    if (model.isInvalidSignal())
                        new ErrorMessage(Lang.get("msg_invalidSignalsAnalysed")).show(Main.this);
                    else
                        new TableDialog(Main.this, new ModelAnalyser(model).analyse(), library, shapeFactory, getBaseFileName()).setVisible(true);
                    ensureModelIsStopped();
                } finally {
                    model.close();
                }
            } catch (PinException | NodeException | AnalyseException | ElementNotFoundException | BacktrackException | RuntimeException e1) {
                showErrorWithoutARunningModel(Lang.get("msg_analyseErr"), e1);
            }
        }
    }.setToolTip(Lang.get("menu_analyse_tt")).setAccelerator("F9").createJMenuItem());
    analyse.add(new ToolTipAction(Lang.get("menu_synthesise")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            TruthTable tt = new TruthTable(3).addResult();
            new TableDialog(Main.this, tt, library, shapeFactory, getBaseFileName()).setVisible(true);
            ensureModelIsStopped();
        }
    }.setToolTip(Lang.get("menu_synthesise_tt")).createJMenuItem());
    analyse.add(new ToolTipAction(Lang.get("menu_expression")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            new ExpressionDialog(Main.this, library, shapeFactory, getBaseFileName()).setVisible(true);
        }
    }.setToolTip(Lang.get("menu_expression_tt")).createJMenuItem());
}
Also used : ModelAnalyser(de.neemann.digital.analyse.ModelAnalyser) ElementNotFoundException(de.neemann.digital.draw.library.ElementNotFoundException) AnalyseException(de.neemann.digital.analyse.AnalyseException) ModelCreator(de.neemann.digital.draw.model.ModelCreator) TableDialog(de.neemann.digital.gui.components.table.TableDialog) ValueTableDialog(de.neemann.digital.gui.components.testing.ValueTableDialog) TruthTable(de.neemann.digital.analyse.TruthTable) LibraryTreeModel(de.neemann.digital.gui.components.tree.LibraryTreeModel) ExpressionDialog(de.neemann.digital.gui.components.expression.ExpressionDialog)

Example 2 with AnalyseException

use of de.neemann.digital.analyse.AnalyseException in project Digital by hneemann.

the class TableDialog method calculateExpressions.

private void calculateExpressions() {
    try {
        ExpressionListener expressionListener = new HTMLExpressionListener();
        if (createJK.isSelected())
            expressionListener = new ExpressionListenerJK(expressionListener);
        lastGeneratedExpressions = new ExpressionListenerStore(expressionListener);
        new ExpressionCreator(model.getTable()).create(lastGeneratedExpressions);
        kvMap.setResult(model.getTable(), lastGeneratedExpressions.getResults());
    } catch (ExpressionException | FormatterException | AnalyseException e1) {
        lastGeneratedExpressions = null;
        new ErrorMessage(Lang.get("msg_errorDuringCalculation")).addCause(e1).show(this);
    }
}
Also used : FormatterException(de.neemann.digital.analyse.expression.format.FormatterException) AnalyseException(de.neemann.digital.analyse.AnalyseException) ErrorMessage(de.neemann.gui.ErrorMessage) ExpressionException(de.neemann.digital.analyse.expression.ExpressionException)

Aggregations

AnalyseException (de.neemann.digital.analyse.AnalyseException)2 ModelAnalyser (de.neemann.digital.analyse.ModelAnalyser)1 TruthTable (de.neemann.digital.analyse.TruthTable)1 ExpressionException (de.neemann.digital.analyse.expression.ExpressionException)1 FormatterException (de.neemann.digital.analyse.expression.format.FormatterException)1 ElementNotFoundException (de.neemann.digital.draw.library.ElementNotFoundException)1 ModelCreator (de.neemann.digital.draw.model.ModelCreator)1 ExpressionDialog (de.neemann.digital.gui.components.expression.ExpressionDialog)1 TableDialog (de.neemann.digital.gui.components.table.TableDialog)1 ValueTableDialog (de.neemann.digital.gui.components.testing.ValueTableDialog)1 LibraryTreeModel (de.neemann.digital.gui.components.tree.LibraryTreeModel)1 ErrorMessage (de.neemann.gui.ErrorMessage)1