From fe8efe1bcce87fdaf3c001e4f001663221c61ff5 Mon Sep 17 00:00:00 2001 From: hneemann Date: Thu, 30 Jun 2016 08:17:29 +0200 Subject: [PATCH] renamed the ModelDescription to ModelCreator --- .../digital/draw/library/CustomElement.java | 12 ++++---- ...odelDescription.java => ModelCreator.java} | 23 +++++++-------- .../digital/draw/shapes/DataShape.java | 6 ++-- .../de/neemann/digital/draw/shapes/Shape.java | 6 ++-- .../java/de/neemann/digital/gui/Main.java | 28 +++++++++---------- .../java/de/neemann/digital/package-info.java | 2 +- .../java/de/neemann/digital/TestExecuter.java | 10 +++---- .../builder/circuit/CircuitBuilderTest.java | 6 ++-- .../neemann/digital/integration/TestAnd.java | 4 +-- .../digital/integration/ToBreakRunner.java | 4 +-- 10 files changed, 51 insertions(+), 50 deletions(-) rename src/main/java/de/neemann/digital/draw/model/{ModelDescription.java => ModelCreator.java} (88%) diff --git a/src/main/java/de/neemann/digital/draw/library/CustomElement.java b/src/main/java/de/neemann/digital/draw/library/CustomElement.java index ffed8eff2..a84dd900e 100644 --- a/src/main/java/de/neemann/digital/draw/library/CustomElement.java +++ b/src/main/java/de/neemann/digital/draw/library/CustomElement.java @@ -6,7 +6,7 @@ import de.neemann.digital.core.ObservableValues; import de.neemann.digital.core.element.Element; import de.neemann.digital.draw.elements.Circuit; import de.neemann.digital.draw.elements.PinException; -import de.neemann.digital.draw.model.ModelDescription; +import de.neemann.digital.draw.model.ModelCreator; import de.neemann.digital.draw.model.NetList; /** @@ -37,19 +37,19 @@ public class CustomElement implements Element { } /** - * Gets a {@link ModelDescription} of this circuit. - * Every time this method is called a new {@link ModelDescription} is created. + * Gets a {@link ModelCreator} of this circuit. + * Every time this method is called a new {@link ModelCreator} is created. * * @param subName name of the circuit, used to name unique elements - * @return the {@link ModelDescription} + * @return the {@link ModelCreator} * @throws PinException PinException * @throws NodeException NodeException */ - public ModelDescription getModelDescription(String subName) throws PinException, NodeException { + public ModelCreator getModelDescription(String subName) throws PinException, NodeException { if (netList == null) netList = new NetList(circuit); - return new ModelDescription(circuit, library, true, name, new NetList(netList), subName); + return new ModelCreator(circuit, library, true, name, new NetList(netList), subName); } @Override diff --git a/src/main/java/de/neemann/digital/draw/model/ModelDescription.java b/src/main/java/de/neemann/digital/draw/model/ModelCreator.java similarity index 88% rename from src/main/java/de/neemann/digital/draw/model/ModelDescription.java rename to src/main/java/de/neemann/digital/draw/model/ModelCreator.java index 63130ade8..9859b9a2a 100644 --- a/src/main/java/de/neemann/digital/draw/model/ModelDescription.java +++ b/src/main/java/de/neemann/digital/draw/model/ModelCreator.java @@ -24,7 +24,7 @@ import java.util.*; * * @author hneemann */ -public class ModelDescription implements Iterable { +public class ModelCreator implements Iterable { private final Circuit circuit; private final NetList netList; @@ -42,7 +42,7 @@ public class ModelDescription implements Iterable { * @throws PinException PinException * @throws NodeException NodeException */ - public ModelDescription(Circuit circuit, ElementLibrary library) throws PinException, NodeException { + public ModelCreator(Circuit circuit, ElementLibrary library) throws PinException, NodeException { this(circuit, library, false); } @@ -55,7 +55,7 @@ public class ModelDescription implements Iterable { * @throws PinException PinException * @throws NodeException NodeException */ - public ModelDescription(Circuit circuit, ElementLibrary library, boolean readAsCustom) throws PinException, NodeException { + public ModelCreator(Circuit circuit, ElementLibrary library, boolean readAsCustom) throws PinException, NodeException { this(circuit, library, readAsCustom, "unknown", new NetList(circuit), ""); } @@ -71,7 +71,7 @@ public class ModelDescription implements Iterable { * @throws PinException PinException * @throws NodeException NodeException */ - public ModelDescription(Circuit circuit, ElementLibrary library, boolean isNestedCircuit, String fileName, NetList netList, String subName) throws PinException, NodeException { + public ModelCreator(Circuit circuit, ElementLibrary library, boolean isNestedCircuit, String fileName, NetList netList, String subName) throws PinException, NodeException { this.circuit = circuit; this.netList = netList; entries = new ArrayList<>(); @@ -119,13 +119,13 @@ public class ModelDescription implements Iterable { } // connect all custom elements to the parents net - ArrayList cmdl = new ArrayList<>(); + ArrayList cmdl = new ArrayList<>(); Iterator it = entries.iterator(); while (it.hasNext()) { ModelEntry me = it.next(); if (me.getElement() instanceof CustomElement) { // at first look for custom elements CustomElement ce = (CustomElement) me.getElement(); - ModelDescription child = ce.getModelDescription(combineNames(subName, me.getVisualElement().getElementAttributes().getCleanLabel())); + ModelCreator child = ce.getModelDescription(combineNames(subName, me.getVisualElement().getElementAttributes().getCleanLabel())); cmdl.add(child); for (Pin p : me.getPins()) { // connect the custom elements to the parents net @@ -143,7 +143,7 @@ public class ModelDescription implements Iterable { it.remove(); } } - for (ModelDescription md : cmdl) { // put the elements of the custom element to the parent + for (ModelCreator md : cmdl) { // put the elements of the custom element to the parent entries.addAll(md.entries); netList.add(md.netList); } @@ -207,10 +207,11 @@ public class ModelDescription implements Iterable { } /** - * Needs to be called after create model is called! + * Needs to be called after createModel is called! * Connects the gui to the model * - * @param guiObserver + * @param guiObserver the observer which can be attached to {@link de.neemann.digital.core.ObservableValue}s + * which have a state dependant graphical representation. */ public void connectToGui(Observer guiObserver) { for (ModelEntry e : entries) @@ -242,7 +243,7 @@ public class ModelDescription implements Iterable { } /** - * Returns a list of all ModelEntries which contain a element of the given name + * Returns a list of all ModelEntries which contain an element of the given name * * @param elementName the name of the element * @return the list @@ -256,7 +257,7 @@ public class ModelDescription implements Iterable { } /** - * @return the circuit whih was used to create this model description + * @return the circuit which was used to create this model description */ public Circuit getCircuit() { return circuit; diff --git a/src/main/java/de/neemann/digital/draw/shapes/DataShape.java b/src/main/java/de/neemann/digital/draw/shapes/DataShape.java index 9ec1a12ad..19be37911 100644 --- a/src/main/java/de/neemann/digital/draw/shapes/DataShape.java +++ b/src/main/java/de/neemann/digital/draw/shapes/DataShape.java @@ -10,7 +10,7 @@ import de.neemann.digital.core.element.PinDescriptions; import de.neemann.digital.draw.elements.IOState; import de.neemann.digital.draw.elements.Pins; import de.neemann.digital.draw.graphics.Graphic; -import de.neemann.digital.draw.model.ModelDescription; +import de.neemann.digital.draw.model.ModelCreator; import de.neemann.digital.draw.model.ModelEntry; import de.neemann.digital.gui.components.CircuitComponent; import de.neemann.digital.gui.components.OrderMerger; @@ -68,9 +68,9 @@ public class DataShape implements Shape { } @Override - public void registerModel(ModelDescription modelDescription, Model model, ModelEntry element) { + public void registerModel(ModelCreator modelCreator, Model model, ModelEntry element) { ArrayList signals = model.getSignalsCopy(); - new OrderMerger(modelDescription.getCircuit().getMeasurementOrdering()) { + new OrderMerger(modelCreator.getCircuit().getMeasurementOrdering()) { @Override public boolean equals(Signal a, String b) { return a.getName().equals(b); diff --git a/src/main/java/de/neemann/digital/draw/shapes/Shape.java b/src/main/java/de/neemann/digital/draw/shapes/Shape.java index 0dc336868..baf6a4918 100644 --- a/src/main/java/de/neemann/digital/draw/shapes/Shape.java +++ b/src/main/java/de/neemann/digital/draw/shapes/Shape.java @@ -4,7 +4,7 @@ import de.neemann.digital.core.Model; import de.neemann.digital.core.Observer; import de.neemann.digital.draw.elements.IOState; import de.neemann.digital.draw.elements.Pins; -import de.neemann.digital.draw.model.ModelDescription; +import de.neemann.digital.draw.model.ModelCreator; import de.neemann.digital.draw.model.ModelEntry; /** @@ -43,10 +43,10 @@ public interface Shape extends Drawable { * Allows the shape to make its drawing dependent of the model by registering a Observer to the model. * It is used by {@link DataShape} to create and show the data graph. * - * @param modelDescription the models description + * @param modelCreator the models description * @param model the model itself * @param element the ModelElement this shape belongs to */ - default void registerModel(ModelDescription modelDescription, Model model, ModelEntry element) { + default void registerModel(ModelCreator modelCreator, Model model, ModelEntry element) { } } diff --git a/src/main/java/de/neemann/digital/gui/Main.java b/src/main/java/de/neemann/digital/gui/Main.java index 509e8ebd8..d9753476c 100644 --- a/src/main/java/de/neemann/digital/gui/Main.java +++ b/src/main/java/de/neemann/digital/gui/Main.java @@ -19,7 +19,7 @@ import de.neemann.digital.draw.elements.PinException; import de.neemann.digital.draw.elements.VisualElement; import de.neemann.digital.draw.graphics.*; import de.neemann.digital.draw.library.ElementLibrary; -import de.neemann.digital.draw.model.ModelDescription; +import de.neemann.digital.draw.model.ModelCreator; import de.neemann.digital.draw.model.RealTimeClock; import de.neemann.digital.draw.shapes.ShapeFactory; import de.neemann.digital.gui.components.*; @@ -102,7 +102,7 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave, E private FileHistory fileHistory; private Model model; - private ModelDescription modelDescription; + private ModelCreator modelCreator; private boolean realtimeClockRunning; private State elementState; @@ -432,7 +432,7 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave, E try { model.doMicroStep(false); circuitComponent.removeHighLighted(); - modelDescription.addNodeElementsTo(model.nodesToUpdate(), circuitComponent.getHighLighted()); + modelCreator.addNodeElementsTo(model.nodesToUpdate(), circuitComponent.getHighLighted()); circuitComponent.repaint(); doStep.setEnabled(model.needsUpdate()); } catch (Exception e1) { @@ -465,7 +465,7 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave, E @Override public void actionPerformed(ActionEvent e) { try { - Model model = new ModelDescription(circuitComponent.getCircuit(), library).createModel(false); + Model model = new ModelCreator(circuitComponent.getCircuit(), library).createModel(false); SpeedTest speedTest = new SpeedTest(model); double frequency = speedTest.calculate(); @@ -515,7 +515,7 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave, E @Override public void actionPerformed(ActionEvent e) { try { - Model model = new ModelDescription(circuitComponent.getCircuit(), library).createModel(false); + Model model = new ModelCreator(circuitComponent.getCircuit(), library).createModel(false); new TableDialog(Main.this, new ModelAnalyser(model).analyse(), shapeFactory, filename) .setPinMap(new PinMap().addModel(model)) .setVisible(true); @@ -542,7 +542,7 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave, E private void orderMeasurements() { try { - Model m = new ModelDescription(circuitComponent.getCircuit(), library).createModel(false); + Model m = new ModelCreator(circuitComponent.getCircuit(), library).createModel(false); elementState.enter(); ArrayList names = new ArrayList<>(); for (Signal s : m.getSignals()) @@ -605,7 +605,7 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave, E if (model != null) model.close(); - modelDescription = null; + modelCreator = null; model = null; } @@ -614,12 +614,12 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave, E circuitComponent.removeHighLighted(); circuitComponent.setModeAndReset(true); - modelDescription = new ModelDescription(circuitComponent.getCircuit(), library); + modelCreator = new ModelCreator(circuitComponent.getCircuit(), library); if (model != null) model.close(); - model = modelDescription.createModel(true); + model = modelCreator.createModel(true); statusLabel.setText(Lang.get("msg_N_nodes", model.size())); @@ -634,11 +634,11 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave, E if (realtimeClockRunning) { // if clock is running, enable automatic update of gui GuiModelObserver gmo = new GuiModelObserver(circuitComponent, updateEvent); - modelDescription.connectToGui(gmo); + modelCreator.connectToGui(gmo); model.addObserver(gmo); } else // all repainting is initiated by user actions! - modelDescription.connectToGui(null); + modelCreator.connectToGui(null); doStep.setEnabled(false); runToBreakAction.setEnabled(!realtimeClockRunning && model.isFastRunModel()); @@ -676,8 +676,8 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave, E if (cause instanceof NodeException) { NodeException e = (NodeException) cause; circuitComponent.addHighLightedWires(e.getValues()); - if (modelDescription != null) - modelDescription.addNodeElementsTo(e.getNodes(), circuitComponent.getHighLighted()); + if (modelCreator != null) + modelCreator.addNodeElementsTo(e.getNodes(), circuitComponent.getHighLighted()); } else if (cause instanceof PinException) { PinException e = (PinException) cause; circuitComponent.addHighLighted(e.getVisualElement()); @@ -800,7 +800,7 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave, E @Override public void hasChanged() { - modelDescription.addNodeElementsTo(model.nodesToUpdate(), circuitComponent.getHighLighted()); + modelCreator.addNodeElementsTo(model.nodesToUpdate(), circuitComponent.getHighLighted()); model.fireManualChangeEvent(); circuitComponent.repaint(); doStep.setEnabled(model.needsUpdate()); diff --git a/src/main/java/de/neemann/digital/package-info.java b/src/main/java/de/neemann/digital/package-info.java index 6d08aeedd..b8c06f06e 100644 --- a/src/main/java/de/neemann/digital/package-info.java +++ b/src/main/java/de/neemann/digital/package-info.java @@ -16,7 +16,7 @@ * classes which you can find in the core package. * This classes form the simulation model represented by the {@link de.neemann.digital.core.Model} class. * Furthermore this representation is called the model. - * In the package draw.model you can find the class {@link de.neemann.digital.draw.model.ModelDescription}. + * In the package draw.model you can find the class {@link de.neemann.digital.draw.model.ModelCreator}. * This class takes a circuit represented by a Circuit instance and creates * a Model instance representation. * Some of the elements out of the Circuit representation you can also find diff --git a/src/test/java/de/neemann/digital/TestExecuter.java b/src/test/java/de/neemann/digital/TestExecuter.java index f80ab954b..1f74f5ec5 100644 --- a/src/test/java/de/neemann/digital/TestExecuter.java +++ b/src/test/java/de/neemann/digital/TestExecuter.java @@ -8,7 +8,7 @@ import de.neemann.digital.core.element.Element; import de.neemann.digital.draw.elements.Circuit; import de.neemann.digital.draw.elements.PinException; import de.neemann.digital.draw.library.ElementLibrary; -import de.neemann.digital.draw.model.ModelDescription; +import de.neemann.digital.draw.model.ModelCreator; import de.neemann.digital.draw.model.ModelEntry; import de.neemann.digital.draw.shapes.ShapeFactory; import de.neemann.digital.integration.Resources; @@ -37,7 +37,7 @@ public class TestExecuter { File filename = new File(Resources.getRoot(), name); Circuit circuit = Circuit.loadCircuit(filename, new ShapeFactory(library)); - ModelDescription mb = new ModelDescription(circuit, library); + ModelCreator mb = new ModelCreator(circuit, library); return new TestExecuter(mb.createModel(false), true).setUp(mb); } @@ -99,9 +99,9 @@ public class TestExecuter { setOutputs(me.getIoState().getInputs()); } - public TestExecuter setUp(ModelDescription modelDescription) { - List inputs = modelDescription.getEntries("In"); - List outputs = modelDescription.getEntries("Out"); + public TestExecuter setUp(ModelCreator modelCreator) { + List inputs = modelCreator.getEntries("In"); + List outputs = modelCreator.getEntries("Out"); for (ModelEntry input : inputs) { assertEquals(0, input.getIoState().inputCount()); diff --git a/src/test/java/de/neemann/digital/builder/circuit/CircuitBuilderTest.java b/src/test/java/de/neemann/digital/builder/circuit/CircuitBuilderTest.java index 09d19ca2a..709d3d4c6 100644 --- a/src/test/java/de/neemann/digital/builder/circuit/CircuitBuilderTest.java +++ b/src/test/java/de/neemann/digital/builder/circuit/CircuitBuilderTest.java @@ -5,7 +5,7 @@ import de.neemann.digital.analyse.expression.Expression; import de.neemann.digital.analyse.expression.Variable; import de.neemann.digital.draw.elements.Circuit; import de.neemann.digital.draw.library.ElementLibrary; -import de.neemann.digital.draw.model.ModelDescription; +import de.neemann.digital.draw.model.ModelCreator; import de.neemann.digital.draw.shapes.ShapeFactory; import junit.framework.TestCase; @@ -31,7 +31,7 @@ public class CircuitBuilderTest extends TestCase { .addCombinatorial("y", y) .createCircuit(); - ModelDescription m = new ModelDescription(circuit, library); + ModelCreator m = new ModelCreator(circuit, library); TestExecuter te = new TestExecuter(m.createModel(false)).setUp(m); te.check(0, 0, 0); @@ -56,7 +56,7 @@ public class CircuitBuilderTest extends TestCase { .addCombinatorial("Y_1", y1) .createCircuit(); - ModelDescription m = new ModelDescription(circuit, library); + ModelCreator m = new ModelCreator(circuit, library); TestExecuter te = new TestExecuter(m.createModel(false)).setUp(m); te.check(0, 0); te.checkC(1, 0); diff --git a/src/test/java/de/neemann/digital/integration/TestAnd.java b/src/test/java/de/neemann/digital/integration/TestAnd.java index 3a63638e2..696d2087d 100644 --- a/src/test/java/de/neemann/digital/integration/TestAnd.java +++ b/src/test/java/de/neemann/digital/integration/TestAnd.java @@ -5,7 +5,7 @@ import de.neemann.digital.core.Model; import de.neemann.digital.core.Node; import de.neemann.digital.draw.elements.Circuit; import de.neemann.digital.draw.library.ElementLibrary; -import de.neemann.digital.draw.model.ModelDescription; +import de.neemann.digital.draw.model.ModelCreator; import de.neemann.digital.draw.model.ModelEntry; import de.neemann.digital.draw.shapes.ShapeFactory; import junit.framework.TestCase; @@ -30,7 +30,7 @@ public class TestAnd extends TestCase { File filename = new File(Resources.getRoot(), "dig/and.dig"); Circuit circuit = Circuit.loadCircuit(filename, new ShapeFactory(new ElementLibrary())); - ModelDescription md = new ModelDescription(circuit, library); + ModelCreator md = new ModelCreator(circuit, library); Model model = md.createModel(false); List nodes = model.getNodes(); diff --git a/src/test/java/de/neemann/digital/integration/ToBreakRunner.java b/src/test/java/de/neemann/digital/integration/ToBreakRunner.java index 0fb60794b..aecb44078 100644 --- a/src/test/java/de/neemann/digital/integration/ToBreakRunner.java +++ b/src/test/java/de/neemann/digital/integration/ToBreakRunner.java @@ -6,7 +6,7 @@ import de.neemann.digital.core.NodeException; import de.neemann.digital.draw.elements.Circuit; import de.neemann.digital.draw.elements.PinException; import de.neemann.digital.draw.library.ElementLibrary; -import de.neemann.digital.draw.model.ModelDescription; +import de.neemann.digital.draw.model.ModelCreator; import de.neemann.digital.draw.shapes.ShapeFactory; import de.neemann.digital.gui.LibrarySelector; @@ -71,7 +71,7 @@ public class ToBreakRunner { LibrarySelector librarySelector = new LibrarySelector(library, shapeFactory, null); librarySelector.setFilePath(filename.getParentFile()); - ModelDescription md = new ModelDescription(circuit, library); + ModelCreator md = new ModelCreator(circuit, library); model = md.createModel(false); if (doInit) model.init(true);