Advertisement
Python253

Mengenlehreuhr EN + JS

Mar 20th, 2023 (edited)
1,058
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. The Berlin set theory clock
  3. There are endless ways to tell the time, and one of the stranger ways uses the Berlin Clock(R) invented by Dieter Binninger. The clock was first installed in 1975 on the Kurfürstendamm in Berlin-Charlottenburg near the Uhlandstraße underground station. It was originally donated to the city of Berlin and the district of Charlottenburg in trust.
  4.  
  5. In 1995 the clock was switched off, but years before that it was hardly in working condition. The operating costs (electricity and maintenance) of the clock are around 5000 euros annually, and neither the city of Berlin nor the district of Charlottenburg want or wanted to bear this price for the landmark. In 1996, the clock was brought to the Europa Center and set up near the tourist information office, where it was then financed by Europa Center dealers. The Europa Center thus has another unusual clock in addition to the water clock in the main hall, which has already been photographed by countless visitors. The small title picture refers to a photo of the Berlin clock (https://web.archive.org/web/20060123075005/http://www.surveyor.in-berlin.de/berlin/uhr/blnuhr.jpg) in front of the Europa Center in March 1998. While the clock on the Kudamm showed the time on both sides, the rear side is switched off at its new location. In December 1999, the commemorative plaque in front of the clock that was still visible in the photo was removed for the 750th anniversary of Berlin (1987). After 2002, the watch underwent a refurbishment in which the colored glass elements were replaced with distinct black bezels. The new yellow glass elements are clearly more orange than yellow, as a photo of the Berlin watch (https://web.archive.org/web/20050907051447/http://www.surveyor.in-berlin.de/berlin/uhr/blnuhr-orig2004.jpg) from 2004 shows.
  6.  
  7. With a Java-enabled WWW client and color screen, the following display shows the current time in the form of the Berlin set theory clock:
  8.  
  9. The Java program of this clock with a fixed display size can be seen at the end of this Pastebin Page.
  10.  
  11. The clock is based on the principle of set theory and is therefore the first of its kind. The 24-hour time is determined by adding the lit lamps. The top light is a turn signal that goes on and off once every two seconds. In the first line of red lamps, each lamp represents 5 hours. In the line below, each red lamp represents 1 hour. For example, if 2 lights are switched on in the top line and 3 lights in the line below, it is 5+5+3 = 1 p.m. or 1 p.m. In the third row, the narrower lights each represent five minutes. In this row are 11 lights with the 3rd, 6th and 9th being red instead of yellow to mark the 1st quarter, half and 3rd quarter. In the last row of four yellow lights, each light represents 1 minute.
  12.  
  13.  
  14. An expensive table version of this clock used to be found in Berlin souvenir shops before the fall of the Wall. If you are short-sighted, you can use it to estimate the time in a large room based on the amount of light, even if you cannot see the individual bulbs. On the other hand, the time is almost impossible to read in a sunlit room, although the brightness of the LEDs can be adjusted. The table version has a size of about twenty centimeters, unlike the original, the lights are very constant and it has two alarm times with a signal tone that can hardly be overheard. If there is a power failure for a moment, the clock will flash with all the lights indicating that the time needs to be reset.
  15.  
  16. In the 1980s and early 1990s, some department stores also sold the Berlin watch. - In addition to the table version, there was a wall clock with light bulbs and a picture clock, also with LEDs but without alarm and brightness control. The watches were made in Berlin-Rudow on Zwickauer Damm.
  17.  
  18. After the death of the inventor and factory owner in the mid-1990s, the original watches will no longer be made. Since the end of 1999, no new copy of the Berlin watch has been seen for sale. The clock in the picture next to it is from 1990. After the turn of the millennium it broke due to a relatively common error. A defective capacitor causes the clock to flash and beep irregularly. If you unscrew the watch, the smaller of the two protruding gray barrels is broken with this defect. You can probably also see soot deposits around the barrels. Replacing the capacitors corrects this error (really!), and so the clock has been working again since the end of February 2003... (The picture of the open clock (235kB JPEG) (https://web.archive.org/web/20060123075130/http://www.surveyor.in-berlin.de/berlin/uhr/blnuhr-offen.jpg) already shows the new capacitors soldered in with the correct polarization, the unsoldered ones before and the tools needed for a repair.)
  19.  
  20.  
  21.  
  22. JavaScript: */
  23.  
  24. // The Berlin clock (R) as a Java (1.0) applet
  25. //
  26. // 19-07-98 -- jd --
  27.  
  28. import java.awt.*;
  29. import java.applet.*;
  30. import java.util.Date;
  31.  
  32. public class bclock extends java.applet.Applet implements Runnable {
  33.  
  34.     Thread bclockThread;
  35.     Date startDate;
  36.  
  37.     public void init() {
  38.         resize(242,180); // fixed size, at first... doesn't work...
  39.     }
  40.     public void start() {
  41.         if (bclockThread == null) {
  42.             bclockThread = new Thread(this, "bclock");
  43.             bclockThread.start();
  44.         }
  45.     }
  46.     public void run() {
  47.         while (bclockThread != null) {
  48.             repaint();
  49.             try {
  50.                 bclockThread.sleep(1000);
  51.             } catch (InterruptedException e){
  52.             }
  53.         }
  54.     }
  55.     public void update(Graphics g) {
  56.         Date now = new Date();
  57.         int min,stu,i;
  58.  
  59.         if (now.getSeconds() % 2 > 0) { g.setColor(Color.black); }
  60.         else { g.setColor(Color.yellow); }
  61.         g.fillOval(100,4,40,40);
  62.         stu = now.getHours();
  63.         min = now.getMinutes();
  64.         if (min == 0 && stu == 0) { stu = 24; }
  65.         for (i = 0; i < 4; i++) {
  66.             if (stu / ((i+1) * 5) > 0) { g.setColor(Color.red); }
  67.             else { g.setColor(Color.black); }
  68.             g.fillRoundRect(i*60+2,46,58,30,4,4);
  69.         }
  70.         for (i = 0; i < 4; i++) {
  71.             if (stu % 5 > i) { g.setColor(Color.red); }
  72.             else { g.setColor(Color.black); }
  73.             g.fillRoundRect(i*60+2,78,58,30,4,4);
  74.         }
  75.         for (i = 0; i < 11; i++) {
  76.             if (min / ((i+1) * 5) > 0) {
  77.                 if (i == 2 || i == 5 || i == 8) { g.setColor(Color.red); }
  78.                 else { g.setColor(Color.yellow); }
  79.             }
  80.             else { g.setColor(Color.black); }
  81.             g.fillRoundRect(i*20+10,110,18,30,4,4);
  82.         }
  83.         for (i = 0; i < 4; i++) {
  84.             if (min % 5 > i) { g.setColor(Color.yellow); }
  85.             else { g.setColor(Color.black); }
  86.             g.fillRoundRect(i*60+2,142,58,30,4,4);
  87.         }
  88.        
  89.     }
  90.     public void paint(Graphics g) {
  91.     update(g); // makes it flicker free
  92.     }
  93.     public void stop() {
  94.         bclockThread.stop();
  95.         bclockThread = null;
  96.     }
  97. }
  98.  
  99.  
  100.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement