Wednesday, December 8, 2010

(2) JPanel

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Line2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.Random;
import javax.imageio.ImageIO;
import javax.swing.JButton;
import javax.swing.JPanel;

public class FinalScienceProjectPart2 extends JPanel {
BufferedImage inputSourceImage; JPG IMAGE (100*100)
Random generator = new Random(); RANDOM NUMBER GENERATOR
int[][] processedImage;2-D Array, holds color values of image pixels
int[] edgepoints, rgbs; list of edge points, list of values of color
int[] totaldata, xDerivativeList,yDerivativeList; //derivatives 
       List of total derivative data, list of X Derivatives, list of Y Derivatives
int wpixel, hpixel, average, numofaverages
- Width # of pixels in image
- Height # of pixels in image
- Average of averages of line of derivatives
- number of slope averages
int i = 0; Counts "totaldata"
int derivativeCounter = 0; Counts "XDerivativeList" and "YDerivativeList"
int edgecounter = 0; Counts "edgepoints"
double efficiency; Percent Efficiency (signal to noise ratio)

double percentNoise = 10; Noise value, usually out of 256
// Noise value. Total value is usually 256.

int edgeColor = 255; Color that the edges will be outlined in
double maxpercent = .80; All numbers above 80% of max, are an edge
Boolean noiseOn = true; Tells to add noise or not


//SCREEN SETTINGS

int titleHeight=20, buttonHeight=30, screenWidth, screenHeight, graphStartX, space=20, mag=5,buttonWidth = 12, PAD = 10;


1. height of title bar
2. height required for buttons
3. Width of Screen
4. Height of Screen
5. X coordinate in which the graph starts at
6. certain amount of space added
7. magnifies the image by 5
8. width of buttons
9. space in between graph

JButton circle = new JButton("Circle"); Button to show circle
JButton square = new JButton("Square"); Button to show square
JButton triangle = new JButton("Triangle"); Button to show triangle

public FinalScienceProjectPart2(){ 
setFocusable(true);
  setBackground(color.WHITE);
setDoubleBuffered(true);
setVisible(true);
generateButtons();
~~~~~~~~~~~~~~~~~~~GENERAGEBUTTONS() <-- CLICK HERE~~~~~~~~~~~~~~~
setInputImage("/Users/kyla/Desktop/circle_jpg.jpg");
}




Part 3 <-- PART 3!

No comments:

Post a Comment