diff --git a/src/sig/Panel.java b/src/sig/Panel.java index 9d9101f..ff7ebe0 100644 --- a/src/sig/Panel.java +++ b/src/sig/Panel.java @@ -9,13 +9,16 @@ import java.awt.image.MemoryImageSource; import java.util.ArrayList; import java.util.List; +import javax.swing.JFrame; import javax.swing.JPanel; public class Panel extends JPanel implements Runnable { + JFrame window; public int pixel[]; public int width=1280; public int height=720; final int CIRCLE_PRECISION=32; + final int OUTLINE_COL=Color.BRIGHT_WHITE.getColor(); private Thread thread; private Image imageBuffer; private MemoryImageSource mImageProducer; @@ -25,9 +28,12 @@ public class Panel extends JPanel implements Runnable { double x_offset=0; double y_offset=0; int frameCount=0; + long lastSecond=0; + int lastFrameCount=0; - public Panel() { + public Panel(JFrame f) { super(true); + this.window=f; thread = new Thread(this, "MyPanel Thread"); } @@ -69,6 +75,14 @@ public class Panel extends JPanel implements Runnable { mImageProducer.newPixels(); // draw it on panel g.drawImage(this.imageBuffer, 0, 0, this); + + + if (window!=null&&System.currentTimeMillis()-lastSecond>=1000) { + window.setTitle(PolygonFill.PROGRAM_NAME+" - FPS: "+(frameCount-lastFrameCount)); + lastFrameCount=frameCount; + lastSecond=System.currentTimeMillis(); + } + frameCount++; } /** @@ -200,7 +214,7 @@ public class Panel extends JPanel implements Runnable { int index = (scanLine+(int)y_offset)*width+x+(int)x_offset; if (index=0) { Draw(p,index,col.getColor()); - } + } } } List new_active_edges = new ArrayList(); diff --git a/src/sig/PolygonFill.java b/src/sig/PolygonFill.java index 47b7db6..ed953ee 100644 --- a/src/sig/PolygonFill.java +++ b/src/sig/PolygonFill.java @@ -3,9 +3,10 @@ package sig; import javax.swing.JFrame; public class PolygonFill { + public static final String PROGRAM_NAME="Polygon Fill Renderer"; public static void main(String[] args) { - Panel p = new Panel(); - JFrame f = new JFrame("Polygon Fill Renderer"); + JFrame f = new JFrame(PROGRAM_NAME); + Panel p = new Panel(f); p.init(); @@ -14,7 +15,6 @@ public class PolygonFill { f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); - int i=0; p.render(); } }