Last active
August 29, 2015 14:01
-
-
Save Bombe/858e2d3b8391f5fb53f9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package plugins.WebOfTrust.identicon.face; | |
| import static java.awt.BorderLayout.CENTER; | |
| import static javax.swing.JFrame.EXIT_ON_CLOSE; | |
| import static plugins.WebOfTrust.identicon.face.Face.createFace; | |
| import java.awt.BorderLayout; | |
| import java.awt.Graphics; | |
| import java.awt.Graphics2D; | |
| import java.awt.event.MouseAdapter; | |
| import java.awt.event.MouseEvent; | |
| import java.util.Random; | |
| import javax.swing.JFrame; | |
| import javax.swing.JPanel; | |
| /** | |
| * Simple, non-automated {@link Identiface} tester that shows random {@link | |
| * Face}s when resizing or clicking the frame. | |
| * | |
| * GUID:220CDCE1-33ED-41DC-9E7A-AA2998D00634 | |
| * | |
| * @author <a href="mailto:[email protected]">David ‘Bombe’ Roden</a> | |
| */ | |
| public class IdentifaceTest { | |
| public static void main(String... arguments) { | |
| final JPanel facePanel = new JPanel() { | |
| private final Random random = new Random(); | |
| @Override | |
| protected void paintComponent(Graphics graphics) { | |
| byte[] randomData = new byte[128]; | |
| random.nextBytes(randomData); | |
| Identiface identiface = new Identiface(createFace(randomData)); | |
| ((Graphics2D) graphics).drawRenderedImage(identiface.render(getWidth(), getHeight()), null); | |
| } | |
| }; | |
| facePanel.addMouseListener(new MouseAdapter() { | |
| @Override | |
| public void mouseClicked(MouseEvent mouseEvent) { | |
| facePanel.repaint(); | |
| } | |
| }); | |
| JFrame frame = new JFrame(); | |
| frame.getRootPane().setLayout(new BorderLayout()); | |
| frame.getRootPane().add(facePanel, CENTER); | |
| frame.setDefaultCloseOperation(EXIT_ON_CLOSE); | |
| frame.setSize(512, 512); | |
| frame.setVisible(true); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment