From 33613a85afc4b1481367fbe92a17ee59c240250b Mon Sep 17 00:00:00 2001 From: Sven Eisenhauer Date: Fri, 10 Nov 2023 15:11:48 +0100 Subject: add new repo --- .../hjp5/examples/Schranke.java | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Master/Reference Architectures and Patterns/hjp5/examples/Schranke.java (limited to 'Master/Reference Architectures and Patterns/hjp5/examples/Schranke.java') diff --git a/Master/Reference Architectures and Patterns/hjp5/examples/Schranke.java b/Master/Reference Architectures and Patterns/hjp5/examples/Schranke.java new file mode 100644 index 0000000..25f798d --- /dev/null +++ b/Master/Reference Architectures and Patterns/hjp5/examples/Schranke.java @@ -0,0 +1,53 @@ +/* Schranke.java */ + +import java.awt.*; +import java.applet.*; + +public class Schranke +extends Applet +{ + private int[] dx; + private Color[] color; + + public void init() + { + String tmp; + + dx = new int[2]; + try { + dx[0] = Integer.parseInt( + getParameter("redwidth") + ); + dx[1] = Integer.parseInt( + getParameter("whitewidth") + ); + } catch (NumberFormatException e) { + dx[0] = 10; + dx[1] = 10; + } + color = new Color[2]; + color[0] = Color.red; + color[1] = Color.white; + } + + public void paint(Graphics g) + { + int maxX = getSize().width; + int maxY = getSize().height; + int x = 0; + int flg = 0; + Polygon p; + while (x <= maxX+maxY/2) { + p = new Polygon(); + p.addPoint(x,0); + p.addPoint(x+dx[flg],0); + p.addPoint(x+dx[flg]-maxY/2,maxY); + p.addPoint(x-maxY/2,maxY); + p.addPoint(x,0); + g.setColor(color[flg]); + g.fillPolygon(p); + x += dx[flg]; + flg = (flg==0) ? 1 : 0; + } + } +} \ No newline at end of file -- cgit v1.2.3