[O] Reformat code

This commit is contained in:
Hykilpikonna
2022-11-09 23:49:19 -05:00
parent 13c408bbdd
commit 64d4d49bdb
217 changed files with 53970 additions and 46112 deletions
+92 -80
View File
@@ -1,6 +1,7 @@
package mars;
import java.awt.*;
import javax.swing.*;
package mars;
import javax.swing.*;
import java.awt.*;
/*
Copyright (c) 2003-2010, Pete Sanderson and Kenneth Vollmar
@@ -31,88 +32,99 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* Produces MARS splash screen.<br>
* Adapted from http://www.java-tips.org/content/view/1267/2/<br>
* Produces MARS splash screen.<br> Adapted from http://www.java-tips.org/content/view/1267/2/<br>
*/
public class MarsSplashScreen extends JWindow {
private int duration;
public MarsSplashScreen(int d) {
duration = d;
}
/**
* A simple little method to show a title screen in the center
* of the screen for the amount of time given in the constructor
*/
public void showSplash() {
ImageBackgroundPanel content = new ImageBackgroundPanel();
this.setContentPane(content);
// Set the window's bounds, centering the window
// Wee bit of a hack. I've hardcoded the image dimensions of
// MarsSurfacePathfinder.jpg, because obtaining them via
// getHeight() and getWidth() is not trival -- it is possible
// that at the time of the call the image has not completed
// loading so the Image object doesn't know how big it is.
// So observers are involved -- see the API.
int width = 390;
int height =215;
Toolkit tk = Toolkit.getDefaultToolkit();
Dimension screen = tk.getScreenSize();
int x = (screen.width-width)/2;
int y = (screen.height-height)/2;
setBounds(x,y,width,height);
// Build the splash screen
JLabel title = new JLabel("MARS: Mips Assembler and Runtime Simulator", JLabel.CENTER);
JLabel copyrt1 = new JLabel
("<html><br><br>Version "+Globals.version+" Copyright (c) "+Globals.copyrightYears+"</html>", JLabel.CENTER);
JLabel copyrt2 = new JLabel
("<html><br><br>"+Globals.copyrightHolders+"</html>", JLabel.CENTER);
title.setFont(new Font("Sans-Serif", Font.BOLD, 16));
title.setForeground(Color.black);
copyrt1.setFont(new Font("Sans-Serif", Font.BOLD, 14));
copyrt2.setFont(new Font("Sans-Serif", Font.BOLD, 14));
copyrt1.setForeground(Color.white);
copyrt2.setForeground(Color.white);
public class MarsSplashScreen extends JWindow
{
content.add(title,BorderLayout.NORTH);
content.add(copyrt1,BorderLayout.CENTER);
content.add(copyrt2,BorderLayout.SOUTH);
private final int duration;
// Display it
setVisible(true);
// Wait a little while, maybe while loading resources
try { Thread.sleep(duration); }
catch (Exception e) {}
setVisible(false);
}
class ImageBackgroundPanel extends JPanel
{
Image image;
public ImageBackgroundPanel()
{
public MarsSplashScreen(int d)
{
duration = d;
}
/**
* A simple little method to show a title screen in the center of the screen for the amount of time given in the
* constructor
*/
public void showSplash()
{
ImageBackgroundPanel content = new ImageBackgroundPanel();
this.setContentPane(content);
// Set the window's bounds, centering the window
// Wee bit of a hack. I've hardcoded the image dimensions of
// MarsSurfacePathfinder.jpg, because obtaining them via
// getHeight() and getWidth() is not trival -- it is possible
// that at the time of the call the image has not completed
// loading so the Image object doesn't know how big it is.
// So observers are involved -- see the API.
int width = 390;
int height = 215;
Toolkit tk = Toolkit.getDefaultToolkit();
Dimension screen = tk.getScreenSize();
int x = (screen.width - width) / 2;
int y = (screen.height - height) / 2;
setBounds(x, y, width, height);
// Build the splash screen
JLabel title = new JLabel("MARS: Mips Assembler and Runtime Simulator", JLabel.CENTER);
JLabel copyrt1 = new JLabel
("<html><br><br>Version " + Globals.version + " Copyright (c) " + Globals.copyrightYears + "</html>", JLabel.CENTER);
JLabel copyrt2 = new JLabel
("<html><br><br>" + Globals.copyrightHolders + "</html>", JLabel.CENTER);
title.setFont(new Font("Sans-Serif", Font.BOLD, 16));
title.setForeground(Color.black);
copyrt1.setFont(new Font("Sans-Serif", Font.BOLD, 14));
copyrt2.setFont(new Font("Sans-Serif", Font.BOLD, 14));
copyrt1.setForeground(Color.white);
copyrt2.setForeground(Color.white);
content.add(title, BorderLayout.NORTH);
content.add(copyrt1, BorderLayout.CENTER);
content.add(copyrt2, BorderLayout.SOUTH);
// Display it
setVisible(true);
// Wait a little while, maybe while loading resources
try
{
Thread.sleep(duration);
}
catch (Exception e)
{
}
setVisible(false);
}
class ImageBackgroundPanel extends JPanel
{
Image image;
public ImageBackgroundPanel()
{
try
{
image = new ImageIcon(Toolkit.getDefaultToolkit().getImage(this.getClass().getResource(Globals.imagesPath+"MarsSurfacePathfinder.jpg"))).getImage();
image = new ImageIcon(Toolkit.getDefaultToolkit().getImage(this.getClass().getResource(Globals.imagesPath + "MarsSurfacePathfinder.jpg"))).getImage();
}
catch (Exception e) {System.out.println(e); /*handled in paintComponent()*/ }
}
@Override
protected void paintComponent(Graphics g)
{
super.paintComponent(g);
catch (Exception e)
{
System.out.println(e); /*handled in paintComponent()*/
}
}
@Override
protected void paintComponent(Graphics g)
{
super.paintComponent(g);
if (image != null)
g.drawImage(image, 0,0,this.getWidth(),this.getHeight(),this);
}
}
}
{
g.drawImage(image, 0, 0, this.getWidth(), this.getHeight(), this);
}
}
}
}