summaryrefslogtreecommitdiffstats
path: root/Master/Reference Architectures and Patterns/hjp5/examples/Schranke.java
diff options
context:
space:
mode:
authorSven Eisenhauer <sven@sven-eisenhauer.net>2023-11-10 15:11:48 +0100
committerSven Eisenhauer <sven@sven-eisenhauer.net>2023-11-10 15:11:48 +0100
commit33613a85afc4b1481367fbe92a17ee59c240250b (patch)
tree670b842326116b376b505ec2263878912fca97e2 /Master/Reference Architectures and Patterns/hjp5/examples/Schranke.java
downloadStudium-33613a85afc4b1481367fbe92a17ee59c240250b.tar.gz
Studium-33613a85afc4b1481367fbe92a17ee59c240250b.tar.bz2
add new repoHEADmaster
Diffstat (limited to 'Master/Reference Architectures and Patterns/hjp5/examples/Schranke.java')
-rw-r--r--Master/Reference Architectures and Patterns/hjp5/examples/Schranke.java53
1 files changed, 53 insertions, 0 deletions
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