Hi there.This is my first post here.I need help urgently.
I getting desperate because I got a deadline for a project in 3 weeks time.I'm trying to do a 2 X 2 matrix multiplication applet that simulate systolic architecture.Should be something like the Wallace Tree Simulation. It can be seen here:
http://media.pearsoncmg.com/aw/aw_carpinel_compsys_1/wallace/
I got little knowledge of Java but I have to finish this in 3 weeks time.
Anyone expert in Java that could help me here?
Here it is the code that I did so far:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.lang.Math;
import java.awt.geom.*;
import javax.swing.border.*;
import javax.swing.event.*;
import java.awt.event.MouseEvent;
import java.net.*;
public class MatrixMultiplication extends Applet{
Toolkit tk = Toolkit.getDefaultToolkit();
Dimension d = tk.getScreenSize();
Button continueButton = new Button("Continue");
JRadioButton two;
public int size = 2;
String name = new String("Matrix Multiplication: 2 x 2");
Button calculate = new Button("Calculate");
public Button About = new Button("About");
public Button Help = new Button("Help");
public void init() {
this.setBackground(Color.white);
Panel radioPanel = new Panel();
radioPanel.setBackground(Color.white);
radioPanel.setLayout(new GridLayout(9,1));
two = new JRadioButton(" 2 x 2",true);
two.setBackground(Color.white);
ButtonGroup radioGroup = new ButtonGroup();
ButtonGroup radioGroup2 = new ButtonGroup();
radioGroup.add(two);
JLabel label = new JLabel("<html>Matrix Multiplication</html>");
JLabel label2 = new JLabel("<html>Please click continue to simulate</html>");
radioPanel.add(label);
radioPanel.add(label2);
radioPanel.add(two);
add(radioPanel);
setLayout(new FlowLayout(FlowLayout.CENTER));
add(continueButton);
Help.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
URL codeBaseURL = getCodeBase();
URL helpURL;
URL aboutURL;
try
{
helpURL = new URL( codeBaseURL.toString() + "help.html" );
getAppletContext().showDocument( helpURL, "_blank" );
aboutURL = new URL( codeBaseURL.toString() + "about.html" );
getAppletContext().showDocument( aboutURL, "_blank" );
}
catch ( Exception e ) { }
}
});
About.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
}
});
add(Help);
add(About);
}
class AboutDialogue extends javax.swing.JFrame implements HyperlinkListener {
/** Creates new form About */
public AboutDialogue() {
initComponents();
this.setSize(new java.awt.Dimension(500, 350));
this.setBackground(Color.white);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension DialogSize = getSize();
Point DialogLocation = new Point( ( screenSize.width
- DialogSize.width ) / 2, ( screenSize.height -
DialogSize.height ) / 2 );
setLocation( DialogLocation );
}
//Listens for hyperlink clicks
public void hyperlinkUpdate(HyperlinkEvent event) {
if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
try
{
getAppletContext().showDocument( event.getURL(), "_blank" );
}
catch ( Exception e ) { }
}
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
private void initComponents() {
AboutLabel = new javax.swing.JLabel();
LowerPanel = new javax.swing.JPanel();
OkButton = new javax.swing.JButton();
CentralPane = new javax.swing.JScrollPane();
MainText = new javax.swing.JEditorPane();
setTitle("About Matrix Multiplication applyed to Systolic Architecture");
setBackground(Color.white);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
exitForm(evt);
}
});
AboutLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
AboutLabel.setText("About Matrix Multiplication applyed to Systolic Architecture");
AboutLabel.setMaximumSize(new java.awt.Dimension(41, 55));
AboutLabel.setMinimumSize(new java.awt.Dimension(41, 55));
AboutLabel.setPreferredSize(new java.awt.Dimension(41, 35));
AboutLabel.setOpaque(false);
AboutLabel.setBackground(Color.white);
getContentPane().add(AboutLabel, java.awt.BorderLayout.NORTH);
LowerPanel.setPreferredSize(new java.awt.Dimension(10, 45));
LowerPanel.setOpaque(false);
LowerPanel.setBackground(Color.white);
OkButton.setText("Ok");
OkButton.setPreferredSize(new java.awt.Dimension(100, 26));
OkButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
OkButtonActionPerformed(evt);
}
});
LowerPanel.add(OkButton);
getContentPane().add(LowerPanel, java.awt.BorderLayout.SOUTH);
CentralPane.setPreferredSize(new java.awt.Dimension(177, 150));
CentralPane.getViewport().setOpaque(false);
String AboutText="<html>\n<body><b>The Matrix Multiplication Simulator</b><br><br>Copyright 2007,UK<br><br>\n";
AboutText+="Developer: Orlando Vilas Boas Dantas.\n</body></html>";
MainText.setEditable(false);
MainText.setContentType("text/html");
MainText.setText(AboutText);
MainText.setCaretPosition(0);
//MainText.setVerticalAlignment(javax.swing.SwingConstants.TOP);
MainText.setOpaque(false);
MainText.setBackground(Color.white);
MainText.addHyperlinkListener(this);
CentralPane.setViewportView(MainText);
getContentPane().add(CentralPane, java.awt.BorderLayout.CENTER);
pack();
}
private void OkButtonActionPerformed(java.awt.event.ActionEvent evt) {
// Add your handling code here:
this.hide();
}
/** Exit the Application */
private void exitForm(java.awt.event.WindowEvent evt) {
System.exit(0);
}
// Variables declaration - do not modify
private javax.swing.JButton OkButton;
private javax.swing.JPanel LowerPanel;
private javax.swing.JLabel AboutLabel;
private javax.swing.JScrollPane CentralPane;
private javax.swing.JEditorPane MainText;
// End of variables declaration
}
}
I know...the code is a mess...!I can't figure out.
Why doesn't work?
I'm so desperate that I even thought on asking the same thing on experts-exchange but I dunno if they're going to come out with some answer, and I have to pay for it
So any help would be great guys.
Thanks