/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package image;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.MediaTracker;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.awt.image.ConvolveOp;
import java.awt.image.Kernel;
import java.awt.image.ColorConvertOp;
import java.awt.color.ColorSpace;
//import java.awt.image.AffineTransformOp;
import java.awt.geom.AffineTransform;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.TitledBorder;
public class efekblur extends JFrame {
CPanel displayPanel;
JButton sharpenButton, blurringButton, edButton, GrayButton,MirrorButton,resetButton;
public efekblur() {
super();
Container container = getContentPane();
setTitle("Proses Image by FIRMAN RUDY W->2007420008");
displayPanel = new CPanel();
container.add(displayPanel);
JPanel panel = new JPanel();
panel.setLayout(new GridLayout(3, 2));
panel
.setBorder(new TitledBorder(
"Click Botton diBawah untuk mengoperasikan Gambar and Reset untuk kembali..."));
sharpenButton = new JButton("Sharpen");
sharpenButton.addActionListener(new ButtonListener());
blurringButton = new JButton("Blur");
blurringButton.addActionListener(new ButtonListener());
edButton = new JButton("Edge Detect");
edButton.addActionListener(new ButtonListener());
GrayButton = new JButton("Gray");
GrayButton.addActionListener(new ButtonListener());
MirrorButton = new JButton("Mirror");
MirrorButton.addActionListener(new ButtonListener());
resetButton = new JButton("Reset");
resetButton.addActionListener(new ButtonListener());
panel.add(sharpenButton);
panel.add(blurringButton);
panel.add(edButton);
panel.add(GrayButton);
panel.add(MirrorButton);
panel.add(resetButton);
container.add(BorderLayout.SOUTH, panel);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
setSize(displayPanel.getWidth(), displayPanel.getHeight() + 10);
setVisible(true);
}
static AffineTransform mirrorTransform;
static { // Create and initialize the AffineTransform
mirrorTransform = AffineTransform.getTranslateInstance(140, 0);
mirrorTransform.scale(-1.0, 1.0); // flip horizontally
}
public static void main(String arg[]) {
new efekblur();
}
class ButtonListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
JButton button = (JButton) e.getSource();
if (button.equals(sharpenButton)) {
displayPanel.sharpen();
displayPanel.repaint();
} else if (button.equals(blurringButton)) {
displayPanel.blur();
displayPanel.repaint();
} else if (button.equals(edButton)) {
displayPanel.edgeDetect();
displayPanel.repaint();
} else if (button.equals(GrayButton)) {
displayPanel.gray();
displayPanel.repaint();
} else if (button.equals(MirrorButton)) {
displayPanel.mirror();
displayPanel.repaint();
} else if (button.equals(resetButton)) {
displayPanel.reset();
displayPanel.repaint();
}
}
}
}
class CPanel extends JLabel {
Image displayImage;
BufferedImage biSrc;
BufferedImage biDest; // Destination image is mandetory.
BufferedImage bi; // Only an additional reference.
Graphics2D big;
CPanel() {
setBackground(Color.black);
loadImage();
setSize(displayImage.getWidth(this), displayImage.getWidth(this));
createBufferedImages();
bi = biSrc;
}
public void loadImage() {
displayImage = Toolkit.getDefaultToolkit().getImage("kartun.jpg");
MediaTracker mt = new MediaTracker(this);
mt.addImage(displayImage, 1);
try {
mt.waitForAll();
} catch (Exception e) {
System.out.println("Exception while loading.");
}
if (displayImage.getWidth(this) == -1) {
System.out.println("No jpg file");
System.exit(0);
}
}
public void createBufferedImages() {
biSrc = new BufferedImage(displayImage.getWidth(this), displayImage
.getHeight(this), BufferedImage.TYPE_INT_RGB);
big = biSrc.createGraphics();
big.drawImage(displayImage, 0, 0, this);
biDest = new BufferedImage(displayImage.getWidth(this), displayImage
.getHeight(this), BufferedImage.TYPE_INT_RGB);
}
public void sharpen() {
float data[] = { -1.0f, -1.0f, -1.0f, -1.0f, 9.0f, -1.0f, -1.0f, -1.0f,
-1.0f };
Kernel kernel = new Kernel(3, 3, data);
ConvolveOp convolve = new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP,
null);
convolve.filter(biSrc, biDest);
bi = biDest;
}
public void blur() {
float data[] = { 0.0625f, 0.125f, 0.0625f, 0.125f, 0.25f, 0.125f,
0.0625f, 0.125f, 0.0625f };
Kernel kernel = new Kernel(3, 3, data);
ConvolveOp convolve = new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP,
null);
convolve.filter(biSrc, biDest);
bi = biDest;
}
public void edgeDetect() {
float data[] = { 1.0f, 0.0f, -1.0f, 1.0f, 0.0f, -1.0f, 1.0f, 0.0f,
-1.0f };
Kernel kernel = new Kernel(3, 3, data);
ConvolveOp convolve = new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP,
null);
convolve.filter(biSrc, biDest);
bi = biDest;
}
public void reset() {
big.setColor(Color.black);
big.clearRect(0, 0, bi.getWidth(this), bi.getHeight(this));
big.drawImage(displayImage, 0, 0, this);
bi = biSrc;
}
public void mirror(){
// new AffineTransformOp(mirrorTransform
// .getTranslateInstance(AffineTransformOp.TYPE_BILINEAR), null);
//AffineTransformOp.TYPE_BILINEAR),
//AffineTransformOp.filter(bi, bi);
//AffineTransform.getTranslateInstance(140, 0);
}
public void gray(){
ColorConvertOp colorConvert = new ColorConvertOp(ColorSpace
.getInstance(ColorSpace.CS_GRAY), null);
colorConvert.filter(bi, bi);
}
public void update(Graphics g) {
g.clearRect(0, 0, getWidth(), getHeight());
paintComponent(g);
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2D = (Graphics2D) g;
g2D.drawImage(bi, 0, 0, this);
}
}
Jumat, 19 Juni 2009
Jumat, 24 April 2009
What is java
What is Java?
Java allows you to play online games, chat with people around the world, calculate your mortgage interest, and view images in 3D, just to name a few. It's also integral to the intranet applications and other e-business solutions that are the foundation of corporate computing.
Learn About Java Technology
To date, the Java platform has attracted more than 6.5 million software developers. It's used in every major industry segment and has a presence in a wide range of devices, computers, and networks.
Java technology's versatility, efficiency, platform portability, and security make it the ideal technology for network computing. From laptops to datacenters, game consoles to scientific supercomputers, cell phones to the Internet, Java is everywhere!
Java powers more than 4.5 billion devices including:
800+ million PCs
2.1 billion mobile phones and other handheld devices (source: Ovum)
3.5 billion smart cards
Set-top boxes, printers, Web cams, games, car navigation systems, lottery terminals, medical devices, parking payment stations, and more.
To see places of Java in Action in your daily life, explore java.com.
Why Software Developers Choose Java
Java has been tested, refined, extended, and proven by a dedicated community. And numbering more than 6.5 million developers, it's the largest and most active on the planet. With its versatilty, efficiency, and portability, Java has become invaluable to developers by enabling them to:
Write software on one platform and run it on virtually any other platform
Create programs to run within a Web browser and Web services
Develop server-side applications for online forums, stores, polls, HTML forms processing, and more
Combine applications or services using the Java language to create highly customized applications or services
Write powerful and efficient applications for mobile phones, remote processors, low-cost consumer products, and practically any other device with a digital heartbeat
Some Ways Software Developers Learn Java
Today, many colleges and universities offer courses in programming for the Java platform. In addition, developers can also enhance their Java programming skills by reading Sun's java.sun.com Web site, subscribing to Java technology-focused newsletters, using the Java Tutorial and the New to Java Programming Center, and signing up for Web, virtual, or instructor-led courses.
What Is JavaFX
JavaFX extends your web experience by delivering rich media and content across all the screens of your life. As users, you will be able to run JavaFX applications in a browser or drag and drop them onto the desktop. It's a seamless interface!
JavaFX is powered by Java: JavaFX extends the power of Java by allowing developers to use any Java library within JavaFX applications. This way developers can expand their capabilities in Java and make use of the revolutionary presentation technology that JavaFX provides to build engaging visual experiences.
Highlights of JavaFX:
Allows users to view JavaFX applications in a browser or break free of the browser by dragging and dropping the same application onto the desktop
Enables an efficient designer-to-developer workflow with Project Nile: designers can work in their tools of choice while collaborating with Web scripters who use the NetBeans IDE with JavaFX
Extends Java technology by enabling use of any Java library within a JavaFX application
Allows developers to integrate vector graphics, animation, audio, and video Web assets into a rich, interactive, immersive application
To learn more about JavaFX technology, visit javafx.com or java.sun.com/javafx web sites for more information.
Java allows you to play online games, chat with people around the world, calculate your mortgage interest, and view images in 3D, just to name a few. It's also integral to the intranet applications and other e-business solutions that are the foundation of corporate computing.
Learn About Java Technology
To date, the Java platform has attracted more than 6.5 million software developers. It's used in every major industry segment and has a presence in a wide range of devices, computers, and networks.
Java technology's versatility, efficiency, platform portability, and security make it the ideal technology for network computing. From laptops to datacenters, game consoles to scientific supercomputers, cell phones to the Internet, Java is everywhere!
Java powers more than 4.5 billion devices including:
800+ million PCs
2.1 billion mobile phones and other handheld devices (source: Ovum)
3.5 billion smart cards
Set-top boxes, printers, Web cams, games, car navigation systems, lottery terminals, medical devices, parking payment stations, and more.
To see places of Java in Action in your daily life, explore java.com.
Why Software Developers Choose Java
Java has been tested, refined, extended, and proven by a dedicated community. And numbering more than 6.5 million developers, it's the largest and most active on the planet. With its versatilty, efficiency, and portability, Java has become invaluable to developers by enabling them to:
Write software on one platform and run it on virtually any other platform
Create programs to run within a Web browser and Web services
Develop server-side applications for online forums, stores, polls, HTML forms processing, and more
Combine applications or services using the Java language to create highly customized applications or services
Write powerful and efficient applications for mobile phones, remote processors, low-cost consumer products, and practically any other device with a digital heartbeat
Some Ways Software Developers Learn Java
Today, many colleges and universities offer courses in programming for the Java platform. In addition, developers can also enhance their Java programming skills by reading Sun's java.sun.com Web site, subscribing to Java technology-focused newsletters, using the Java Tutorial and the New to Java Programming Center, and signing up for Web, virtual, or instructor-led courses.
What Is JavaFX
JavaFX extends your web experience by delivering rich media and content across all the screens of your life. As users, you will be able to run JavaFX applications in a browser or drag and drop them onto the desktop. It's a seamless interface!
JavaFX is powered by Java: JavaFX extends the power of Java by allowing developers to use any Java library within JavaFX applications. This way developers can expand their capabilities in Java and make use of the revolutionary presentation technology that JavaFX provides to build engaging visual experiences.
Highlights of JavaFX:
Allows users to view JavaFX applications in a browser or break free of the browser by dragging and dropping the same application onto the desktop
Enables an efficient designer-to-developer workflow with Project Nile: designers can work in their tools of choice while collaborating with Web scripters who use the NetBeans IDE with JavaFX
Extends Java technology by enabling use of any Java library within a JavaFX application
Allows developers to integrate vector graphics, animation, audio, and video Web assets into a rich, interactive, immersive application
To learn more about JavaFX technology, visit javafx.com or java.sun.com/javafx web sites for more information.
Langganan:
Postingan (Atom)