This commit is contained in:
hneemann 2017-02-24 21:33:02 +01:00
parent 2262d7e3d2
commit 83e2bbe5fb
14 changed files with 62 additions and 38 deletions

View File

@ -9,7 +9,7 @@ import de.neemann.digital.draw.shapes.Drawable;
import java.util.Collection; import java.util.Collection;
/** /**
* A simple wire described by two points * A simple wire described by two points.
* *
* @author hneemann * @author hneemann
*/ */
@ -167,7 +167,7 @@ public class Wire implements Drawable, Moveable {
/** /**
* Returns true if wires are equal. * Returns true if wires are equal.
* It is not possible to overwrite Object.equals() because some algorithms * It is not possible to overwrite Object.equals() because some algorithms
* (eg. highlighting) are depending on an object based equals! * (eg. highlighting) are relying on an object based equals!
* *
* @param wire the other wire * @param wire the other wire
* @return true if both wires are equal * @return true if both wires are equal
@ -191,7 +191,7 @@ public class Wire implements Drawable, Moveable {
/** /**
* Sets the {@link ObservableValue} which is represented by this wire * Sets the {@link ObservableValue} which is represented by this wire
* *
* @param value * @param value the {@link ObservableValue}
*/ */
public void setValue(ObservableValue value) { public void setValue(ObservableValue value) {
this.value = value; this.value = value;
@ -205,7 +205,7 @@ public class Wire implements Drawable, Moveable {
} }
/** /**
* Turns of the visualisation of the wire dots * Disables the visualisation of the wire dots
*/ */
public void noDot() { public void noDot() {
p1Dot = false; p1Dot = false;
@ -213,7 +213,7 @@ public class Wire implements Drawable, Moveable {
} }
/** /**
* Turns on the wire dot for the given position * Enables the wire dot for the given position
* *
* @param p the position * @param p the position
*/ */
@ -223,7 +223,7 @@ public class Wire implements Drawable, Moveable {
} }
/** /**
* @return a moveable representing point one * @return a movable representing point one
*/ */
public Moveable getMovableP1() { public Moveable getMovableP1() {
return new Moveable() { return new Moveable() {
@ -240,7 +240,7 @@ public class Wire implements Drawable, Moveable {
} }
/** /**
* @return a moveable representing point two * @return a movable representing point two
*/ */
public Moveable getMovableP2() { public Moveable getMovableP2() {
return new Moveable() { return new Moveable() {

View File

@ -2,7 +2,7 @@ package de.neemann.digital.draw.graphics;
/** /**
* Interface used to draw the circuit. * Interface used to draw the circuit.
* There a implementations to draw on a {@link java.awt.Graphics2D} instance ({@link GraphicSwing}) but also * There are implementations to draw on a {@link java.awt.Graphics2D} instance ({@link GraphicSwing}) but also
* implementations which create export formats like SVG ({@link GraphicSVG}). * implementations which create export formats like SVG ({@link GraphicSVG}).
* *
* @author hneemann * @author hneemann
@ -21,7 +21,7 @@ public interface Graphic {
/** /**
* Draws a polygon * Draws a polygon
* *
* @param p the polygon * @param p the polygon to draw
* @param style the style * @param style the style
*/ */
void drawPolygon(Polygon p, Style style); void drawPolygon(Polygon p, Style style);

View File

@ -7,6 +7,10 @@ import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
/** /**
* Merges all single lines which are drawn to polygons.
* Needed to create a nicer svg export because of the creation of longer strokes
* instead of single lines.
*
* @author hneemann * @author hneemann
*/ */
public class GraphicLineCollector implements Graphic { public class GraphicLineCollector implements Graphic {

View File

@ -4,7 +4,7 @@ import de.neemann.digital.draw.graphics.*;
/** /**
* Filters out all the lines. * Filters out all the lines.
* All other drawing elements a delegated to the given class. * All other drawing elements are delegated to the given class.
* *
* @author hneemann * @author hneemann
*/ */
@ -23,6 +23,7 @@ public class GraphicSkipLines implements Graphic {
@Override @Override
public void drawLine(Vector p1, Vector p2, Style style) { public void drawLine(Vector p1, Vector p2, Style style) {
// lines are skipped
} }
@Override @Override

View File

@ -9,9 +9,10 @@ import de.neemann.digital.draw.graphics.Graphic;
*/ */
public interface Drawable { public interface Drawable {
/** /**
* Draws a element depending on its state * Draws an element depending on its state.
* *
* @param graphic interface to draw to * @param graphic interface to draw to
* @param highLight true if a highlighted drawing is required
*/ */
void drawTo(Graphic graphic, boolean highLight); void drawTo(Graphic graphic, boolean highLight);
} }

View File

@ -31,11 +31,20 @@ public abstract class SevenShape implements Shape {
private static final int SL = 2; private static final int SL = 2;
private static final Polygon A = new Polygon(true) private static final Polygon A = new Polygon(true)
.add(X0, Y0).add(X0 + TH, Y0 - TH).add(X0 + LH - TH, Y0 - TH).add(X0 + LH, Y0).add(X0 + LH - TH, Y0 + TH).add(X0 + TH, Y0 + TH); .add(X0, Y0).add(X0 + TH, Y0 - TH)
.add(X0 + LH - TH, Y0 - TH)
.add(X0 + LH, Y0)
.add(X0 + LH - TH, Y0 + TH)
.add(X0 + TH, Y0 + TH);
private static final Polygon G = A.transform(v -> v.add(-SL, LV + 4)); private static final Polygon G = A.transform(v -> v.add(-SL, LV + 4));
private static final Polygon D = A.transform(v -> v.add(-SL * 2, 2 * LV + 8)); private static final Polygon D = A.transform(v -> v.add(-SL * 2, 2 * LV + 8));
private static final Polygon F = new Polygon(true) private static final Polygon F = new Polygon(true)
.add(X1, Y1).add(X1 + TH, Y1 + TH).add(X1 + TH - SL, Y1 + LV - TH).add(X1 - SL, Y1 + LV).add(X1 - TH - SL, Y1 + LV - TH).add(X1 - TH, Y1 + TH); .add(X1, Y1)
.add(X1 + TH, Y1 + TH)
.add(X1 + TH - SL, Y1 + LV - TH)
.add(X1 - SL, Y1 + LV)
.add(X1 - TH - SL, Y1 + LV - TH)
.add(X1 - TH, Y1 + TH);
private static final Polygon B = F.transform(v -> v.add(LH + 4, 0)); private static final Polygon B = F.transform(v -> v.add(LH + 4, 0));
private static final Polygon C = F.transform(v -> v.add(LH + 4 - SL, LV + 4)); private static final Polygon C = F.transform(v -> v.add(LH + 4 - SL, LV + 4));
private static final Polygon E = F.transform(v -> v.add(-SL, LV + 4)); private static final Polygon E = F.transform(v -> v.add(-SL, LV + 4));

View File

@ -18,20 +18,21 @@ public interface Shape extends Drawable {
* Puts the pins name and the pins x-y-position together! * Puts the pins name and the pins x-y-position together!
* This information is used to calculate the models connections from the wiring in the circuit. * This information is used to calculate the models connections from the wiring in the circuit.
* Don't create your own {@link de.neemann.digital.core.element.PinInfo} instance! Try to use * Don't create your own {@link de.neemann.digital.core.element.PinInfo} instance! Try to use
* the instances available from the {@link de.neemann.digital.core.element.ElementTypeDescription}s. * the instances passed to the constructor of the shape via the {@link ShapeFactory}s {@link ShapeFactory#Creator} interface.
* *
* @return the pins * @return the pins
*/ */
Pins getPins(); Pins getPins();
/** /**
* If the look of the shape depends on an input or output state, the * This method call connects the created model element to the shape which represents the model node.
* shape can register the guiObserver to one of the the input or output ObservableValues. * If the look of the shape depends on an inputs state, the shape has to register the guiObserver
* To access the actual state while drawing, the Shape needs to store the IOState in a member * to all of the inputs ObservableValues it depends on.
* variable. * To access the actual state while drawing, the Shape needs to store the IOState or the needed inputs
* in a member variable.
* <p> * <p>
* If the shape returns an interactor, this interactors clicked method is called if the * If the shape returns an interactor, this interactors clicked method is called if the
* shape is clicked in running mode. * shape is clicked in running mode. If the shape is not interactive siply return null.
* *
* @param ioState the state of the element, never null * @param ioState the state of the element, never null
* @param guiObserver can be used to update the GUI by calling hasChanged, maybe null * @param guiObserver can be used to update the GUI by calling hasChanged, maybe null
@ -42,6 +43,8 @@ public interface Shape extends Drawable {
/** /**
* Allows the shape to make its drawing dependent of the model by registering a Observer to the model. * 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. * It is used by {@link DataShape} to create and show the data graph.
* This method is necessary if a shape does not depend only on its inputs or outputs but if it
* depends on the global model state.
* *
* @param modelCreator the models description * @param modelCreator the models description
* @param model the model itself * @param model the model itself

View File

@ -118,7 +118,7 @@ public final class ShapeFactory {
* Returns a shape matching the given name. * Returns a shape matching the given name.
* If no shape is found, a special "missing shape" shape is returned. * If no shape is found, a special "missing shape" shape is returned.
* *
* @param elementName the elemnets name * @param elementName the elements name
* @param elementAttributes the elements attributes * @param elementAttributes the elements attributes
* @return the shape * @return the shape
*/ */

View File

@ -24,7 +24,6 @@ public class TunnelShape implements Shape {
private final PinDescription input; private final PinDescription input;
private final String label; private final String label;
//private ObservableValue inValue;
/** /**
* Creates a new instance * Creates a new instance
@ -45,20 +44,11 @@ public class TunnelShape implements Shape {
@Override @Override
public InteractorInterface applyStateMonitor(IOState ioState, Observer guiObserver) { public InteractorInterface applyStateMonitor(IOState ioState, Observer guiObserver) {
//inValue = ioState.getInput(0).addObserverToValue(guiObserver);
return null; return null;
} }
@Override @Override
public void drawTo(Graphic gr, boolean highLight) { public void drawTo(Graphic gr, boolean highLight) {
// if (inValue != null) {
// Style style = Style.getWireStyle(inValue);
// gr.drawPolygon(new Polygon(true)
// .add(1, 0)
// .add(SIZE - 1, SIZE2 - 4)
// .add(SIZE - 1, -SIZE2 + 4), style);
// }
gr.drawPolygon(new Polygon(true) gr.drawPolygon(new Polygon(true)
.add(0, 0) .add(0, 0)
.add(WIDTH, HEIGHT) .add(WIDTH, HEIGHT)

View File

@ -1,10 +1,16 @@
package de.neemann.digital.gui; package de.neemann.digital.gui;
import de.neemann.digital.core.Model; import de.neemann.digital.core.Model;
import de.neemann.digital.core.ModelEvent;
import de.neemann.digital.core.NodeException; import de.neemann.digital.core.NodeException;
/** /**
* Modifier which can be used to modify the model while it is started * Modifier which can be used to modify the model while it is started.
* <p>
* Its used by the {@link de.neemann.digital.gui.remote.RemoteSever}. The remote server passes an instance to
* the start method ({@link Main#createAndStartModel(boolean, ModelEvent, ModelModifier)}) to modify the model
* after its generation. It modifies the ROM node by copying the program to execute to the programm memory.
* <p>
* Created by hneemann on 17.12.16. * Created by hneemann on 17.12.16.
*/ */
public interface ModelModifier { public interface ModelModifier {

View File

@ -6,7 +6,9 @@ import de.neemann.digital.lang.Lang;
import java.io.File; import java.io.File;
/** /**
* Handler to control the simulator * Handler to control the simulator.
* The handler simply interprets the incoming request and calls the suited method
* of the {@link DigitalRemoteInterface} which is implemented by the {@link de.neemann.digital.gui.Main} class.
*/ */
public class DigitalHandler implements HandlerInterface { public class DigitalHandler implements HandlerInterface {
private final DigitalRemoteInterface digitalRemoteInterface; private final DigitalRemoteInterface digitalRemoteInterface;

View File

@ -1,7 +1,7 @@
package de.neemann.digital.gui.remote; package de.neemann.digital.gui.remote;
/** /**
* Interface to implement a simple server * Interface to implement a simple server.
* <p/> * <p/>
* Created by helmut.neemann on 23.06.2016. * Created by helmut.neemann on 23.06.2016.
*/ */

View File

@ -7,7 +7,9 @@ import java.net.ServerSocket;
import java.net.Socket; import java.net.Socket;
/** /**
* Simple server to remote control the simulator * Simple server to remote control the simulator.
* Every incoming request is passed to the {@link HandlerInterface}.
* The returned string is then returned to the client as response.
* <p/> * <p/>
* Created by helmut.neemann on 23.06.2016. * Created by helmut.neemann on 23.06.2016.
*/ */

View File

@ -1,5 +1,11 @@
/** /**
* Classes to implement a remote server for simulator control * Classes to implement a remote server for simulator control.
* Is used to allow a assembly IDE to control the simulator.
* In this way the assembly IDE is able to load executables to the program ROM and
* start the simulation (resets the processor). After that you can start single clock steps,
* run to break and so on.
* Every command returns the actual ROM address to the assembly IDE which can be used to highlight
* the actual executed assembly instruction within the IDE.
* <p/> * <p/>
* Created by helmut.neemann on 23.06.2016. * Created by helmut.neemann on 23.06.2016.
*/ */