Commits

Cat's Eye Technologies  committed 3c75670

Import of Whothm version 1.0 revision 2011.0116 sources.

  • Participants
  • Parent commits 6387e93
  • Tags rel_1_0_2011_0116

Comments (0)

Files changed (17)

-JAVAC?="/cygdrive/c/Program Files (x86)/Java/jdk1.6.0_20/bin/javac"
-JAVA?="/cygdrive/c/Program Files (x86)/Java/jre6/bin/java"
+# Makefile for jwhothm.
+# $Id: Makefile 887 2011-01-11 05:47:53Z cpressey $
+
+JAVAC?="/cygdrive/c/Program Files/Java/jdk1.6.0_22/bin/javac"
+JAVA?="/cygdrive/c/Program Files/Java/jre6/bin/java"
 JAR?=jar
 
-JFLAGS="-Xlint:deprecation"
+JFLAGS?="-Xlint:deprecation"
 
 CDIR=bin/tc/catseye/whothm
 
         $(CDIR)/Rectangle.class \
         $(CDIR)/TruthTable.class \
         $(CDIR)/Canvas.class \
-        $(CDIR)/Bitmap.class \
+        $(CDIR)/BitMap.class \
         $(CDIR)/Machine.class \
         $(CDIR)/ContentPane.class \
         $(CDIR)/Applet.class \
 $(CDIR)/Applet.class: src/Applet.java $(CDIR)/ContentPane.class
 	$(JAVAC) $(JFLAGS) -cp bin -d bin src/Applet.java
 
-doc/whothm.jar:
-	jar cvf doc/whothm.jar -C bin tc/catseye/whothm/*.class
+whothm.jar:
+	$(JAR) cvf whothm.jar -C bin tc/catseye/whothm/*.class
 
 clean:
 	rm -rf $(CDIR)/*.class

File bin/tc/catseye/whothm/BitMap.class

Binary file modified.

File bin/tc/catseye/whothm/Canvas.class

Binary file modified.

File bin/tc/catseye/whothm/Command.class

Binary file modified.

File bin/tc/catseye/whothm/ContentPane$1.class

Binary file modified.

File bin/tc/catseye/whothm/ContentPane$2.class

Binary file modified.

File bin/tc/catseye/whothm/ContentPane.class

Binary file modified.

File bin/tc/catseye/whothm/DeltaCommand.class

Binary file modified.

File bin/tc/catseye/whothm/DeltaIndirectCommand.class

Binary file modified.

File bin/tc/catseye/whothm/DrawCommand.class

Binary file modified.

File bin/tc/catseye/whothm/Machine.class

Binary file modified.

File doc/jwhothm.html

-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/2002/REC-xhtml1-20020801/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<!-- encoding: UTF-8 -->
+<html lang="en">
 <head>
 <title>JWhothm - Implementation of Whothm in a Java Applet</title>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 </head>
 <body>
 

File doc/whothm.html

-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/2002/REC-xhtml1-20020801/DTD/xhtml1-strict.dtd">
+<?xml version="1.0"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <!-- encoding: UTF-8 -->
 <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
 <head>

File src/BitMap.java

         return width;
     }
 
+    public int getPixelHeight() {
+        return pixel_height;
+    }
+
+    public int getPixelWidth() {
+        return pixel_width;
+    }
+
     public void alterWidth(int delta) {
         int newWidth = width + delta;
 

File src/Canvas.java

 import java.awt.Color;
 import java.awt.Graphics;
 import java.awt.Rectangle;
+import java.awt.Dimension;
 
-import javax.swing.JViewport;
+import javax.swing.JPanel;
 
-public class Canvas extends JViewport {
+public class Canvas extends JPanel {
     private BitMap bm;
 
     public Canvas(BitMap bm) {
+        super();
         this.bm = bm;
     }
 
-    public void paint(Graphics g) {
-        g.setColor(Color.yellow);
+    public void resize() {
+        int width = bm.getPixelWidth() * bm.getWidth();
+        int height = bm.getPixelHeight() * bm.getHeight();
+        Dimension area = new Dimension(width, height);
+        setPreferredSize(area);
+        revalidate();
+        repaint();
+    }
+
+    protected void paintComponent(Graphics g) {
+        super.paintComponent(g);
+
+        g.setColor(Color.yellow);  
         Rectangle r = g.getClipBounds();
         g.fillRect(r.x, r.y, r.width, r.height);
         bm.render(g);

File src/ContentPane.java

         canvas = new Canvas(bitmap);
         canvas.setBackground(Color.yellow);
         canvas.setMinimumSize(new Dimension(100, 50));
+        JScrollPane canvasScrollPane = new JScrollPane(canvas);
 
         progBox = new JTextArea();
         progBox.setText(
             public void keyPressed(KeyEvent event) {
                 if (event.getKeyCode() == KeyEvent.VK_PAGE_UP) {
                     bitmap.alterPixelSize(-1);
-                    canvas.repaint();
+                    canvas.resize();
                     event.consume();
                 } else if (event.getKeyCode() == KeyEvent.VK_PAGE_DOWN) {
                     bitmap.alterPixelSize(+1);
-                    canvas.repaint();
+                    canvas.resize();
                     event.consume();
                 }
             }
             public void keyReleased(KeyEvent event) { }
         });
+        JScrollPane progScrollPane = new JScrollPane(progBox);
 
         JButton buttonRun = new JButton("Run");
         buttonRun.setMnemonic(KeyEvent.VK_R);
 
         JPanel progPanel = new JPanel(new BorderLayout());
         progPanel.setMinimumSize(new Dimension(100, 50));
-        progPanel.add(progBox, BorderLayout.CENTER);
+        progPanel.add(progScrollPane, BorderLayout.CENTER);
         progPanel.add(buttonRun, BorderLayout.PAGE_END);
 
         JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
-            progPanel, canvas);
+            progPanel, canvasScrollPane);
         splitPane.setOneTouchExpandable(true);
         splitPane.setDividerLocation(150);
 
         this.add(splitPane, BorderLayout.CENTER);
         this.add(statusBar, BorderLayout.PAGE_END);
         this.setOpaque(true);
+        canvas.resize();
     }
 }

File src/Machine.java

 package tc.catseye.whothm;
 
 import java.util.ArrayList;
-import java.util.Map;
-import java.util.HashMap;
 
 abstract class Command {
     public abstract void execute(Machine m);