1 /* 2 * Copyright (c) 2016 Helmut Neemann 3 * Use of this source code is governed by the GPL v3 license 4 * that can be found in the LICENSE file. 5 */ 6 package de.neemann.digital.draw.shapes; 7 8 import de.neemann.digital.draw.elements.IOState; 9 import de.neemann.digital.draw.elements.Pin; 10 import de.neemann.digital.draw.elements.Pins; 11 import de.neemann.digital.draw.graphics.Graphic; 12 import de.neemann.digital.draw.graphics.Polygon; 13 import de.neemann.digital.draw.graphics.Style; 14 import de.neemann.digital.draw.graphics.Vector; 15 16 import static de.neemann.digital.core.element.PinInfo.input; 17 import static de.neemann.digital.core.element.PinInfo.output; 18 import static de.neemann.digital.draw.shapes.GenericShape.SIZE; 19 import static de.neemann.digital.draw.shapes.GenericShape.SIZE2; 20 21 /** 22 * The delays shape 23 */ 24 public class DelayShape implements Shape { 25 26 27 /** 28 * Creates a new instance 29 */ DelayShape()30 public DelayShape() { 31 } 32 33 @Override getPins()34 public Pins getPins() { 35 return new Pins() 36 .add(new Pin(new Vector(SIZE * 2, 0), output("out"))) 37 .add(new Pin(new Vector(0, 0), input("in"))); 38 } 39 40 @Override applyStateMonitor(IOState ioState)41 public Interactor applyStateMonitor(IOState ioState) { 42 return null; 43 } 44 45 @Override drawTo(Graphic graphic, Style heighLight)46 public void drawTo(Graphic graphic, Style heighLight) { 47 graphic.drawPolygon( 48 new Polygon(true) 49 .add(1, -SIZE2) 50 .add(SIZE * 2 - 1, -SIZE2) 51 .add(SIZE * 2 - 1, SIZE2) 52 .add(1, SIZE2), Style.NORMAL); 53 graphic.drawLine(new Vector(SIZE2, 0), new Vector(SIZE * 2 - SIZE2, 0), Style.THIN); 54 int bar = SIZE2 / 2; 55 graphic.drawLine(new Vector(SIZE2, bar), new Vector(SIZE2, -bar), Style.THIN); 56 graphic.drawLine(new Vector(SIZE * 2 - SIZE2, bar), new Vector(SIZE * 2 - SIZE2, -bar), Style.THIN); 57 } 58 } 59