Skip to content

Commit

Permalink
New about box.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Luc Paour committed Aug 18, 2002
1 parent 58b7a5c commit 1461043
Show file tree
Hide file tree
Showing 5 changed files with 230 additions and 288 deletions.
331 changes: 226 additions & 105 deletions com/gallery/GalleryRemote/AboutBox.java
@@ -1,5 +1,5 @@
/*
* Gallery Remote - a File Upload Utility for Gallery
* Gallery Remote - a File Upload Utility for Gallery
*
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2001 Bharat Mediratta
Expand All @@ -18,125 +18,246 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

package com.gallery.GalleryRemote;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import java.util.*;

public class AboutBox extends javax.swing.JFrame {

// IMPORTANT: Source code between BEGIN/END comment pair will be regenerated
// every time the form is saved. All manual changes will be overwritten.
// BEGIN GENERATED CODE
// member declarations
javax.swing.JLabel jLabel1 = new javax.swing.JLabel();
javax.swing.JLabel jLabel2 = new javax.swing.JLabel();
javax.swing.JLabel jLabelVersion = new javax.swing.JLabel();
javax.swing.JLabel jLabel3 = new javax.swing.JLabel();
javax.swing.JLabel jLabel4 = new javax.swing.JLabel();
javax.swing.JLabel jLabel5 = new javax.swing.JLabel();
// END GENERATED CODE
/**
* Gallery Remote About Box
*
*@author paour
*@created August 18, 2002
*/
public class AboutBox extends JDialog
{
public static int TOP = 60;
public static int BOTTOM = 30;

/**
* Constructor for the AboutBox object
*/
public AboutBox() {
}


public void setVersionString(String versionString) {
jLabelVersion.setText(versionString);
super();
init();
}

public void initComponents() throws Exception {
// IMPORTANT: Source code between BEGIN/END comment pair will be regenerated
// every time the form is saved. All manual changes will be overwritten.
// BEGIN GENERATED CODE
// the following code sets the frame's initial state

jLabel1.setSize(new java.awt.Dimension(320, 50));
jLabel1.setLocation(new java.awt.Point(30, 30));
jLabel1.setVisible(true);
jLabel1.setVerticalAlignment(javax.swing.JLabel.TOP);
jLabel1.setText("Gallery Remote");
jLabel1.setFont(new java.awt.Font("Dialog", 1, 36));

jLabel2.setSize(new java.awt.Dimension(104, 20));
jLabel2.setLocation(new java.awt.Point(10, 80));
jLabel2.setVisible(true);
jLabel2.setVerticalAlignment(javax.swing.JLabel.TOP);
jLabel2.setText("Version:");
jLabel2.setHorizontalAlignment(javax.swing.JLabel.RIGHT);

jLabelVersion.setSize(new java.awt.Dimension(200, 20));
jLabelVersion.setLocation(new java.awt.Point(120, 80));
jLabelVersion.setVisible(true);
jLabelVersion.setVerticalAlignment(javax.swing.JLabel.TOP);
jLabelVersion.setText("00000");

jLabel3.setSize(new java.awt.Dimension(160, 20));
jLabel3.setLocation(new java.awt.Point(250, 170));
jLabel3.setVisible(true);
jLabel3.setText("© 2001 Chris Smith");
jLabel3.setHorizontalAlignment(javax.swing.JLabel.RIGHT);

jLabel4.setSize(new java.awt.Dimension(250, 20));
jLabel4.setLocation(new java.awt.Point(160, 190));
jLabel4.setVisible(true);
jLabel4.setText("A part of the Gallery Open Source Project");
jLabel4.setHorizontalAlignment(javax.swing.JLabel.RIGHT);

jLabel5.setSize(new java.awt.Dimension(250, 20));
jLabel5.setLocation(new java.awt.Point(160, 210));
jLabel5.setVisible(true);
jLabel5.setText("http://gallery.sourceforge.net");
jLabel5.setHorizontalAlignment(javax.swing.JLabel.RIGHT);

setLocation(new java.awt.Point(0, 0));
setSize(new java.awt.Dimension(428, 263));
setBackground(java.awt.Color.white);
getContentPane().setLayout(null);
setTitle("com.gallery.GalleryRemote.AboutBox");
getContentPane().add(jLabel1);
getContentPane().add(jLabel2);
getContentPane().add(jLabelVersion);
getContentPane().add(jLabel3);
getContentPane().add(jLabel4);
getContentPane().add(jLabel5);


addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent e) {
thisWindowClosing(e);
}
});

// END GENERATED CODE
/**
* Constructor for the AboutBox object
*
*@param owner Description of Parameter
*/
public AboutBox( Frame owner ) {
super( owner );
init();
}

private boolean mShown = false;

public void addNotify() {
super.addNotify();

if (mShown)
return;

// resize frame to account for menubar
JMenuBar jMenuBar = getJMenuBar();
if (jMenuBar != null) {
int jMenuBarHeight = jMenuBar.getPreferredSize().height;
Dimension dimension = getSize();
dimension.height += jMenuBarHeight;
setSize(dimension);
}

mShown = true;

private void init() {
setModal( true );
getContentPane().add( new AboutPanel(), BorderLayout.CENTER );
setTitle( "About Gallery Remote" );

pack();

Dimension s = Toolkit.getDefaultToolkit().getScreenSize();

setLocation( (int) ( s.getWidth() - getWidth() ) / 2, (int) ( s.getHeight() - getHeight() ) / 2 );

addMouseListener(
new java.awt.event.MouseAdapter()
{
public void mouseClicked( MouseEvent e ) {
thisWindowClosing();
}
} );
addWindowListener(
new java.awt.event.WindowAdapter()
{
public void windowClosing( MouseEvent e ) {
thisWindowClosing();
}
} );
}

// Close the window when the close box is clicked
void thisWindowClosing(java.awt.event.WindowEvent e) {
setVisible(false);
// Close the window when the box is clicked
void thisWindowClosing() {
setVisible( false );
dispose();
}



/**
* AboutPanel: scrolling panel of credits for About boxes
*
*@author paour
*@created August 16, 2002
*/
public class AboutPanel extends JComponent
{
ImageIcon image;
Vector text;
int scrollPosition;
AnimationThread thread;
int maxWidth;
FontMetrics fm;
int initialPosition;

/**
* Constructor for the AboutPanel object
*/
public AboutPanel() {
setFont( UIManager.getFont( "Label.font" ) );
fm = getFontMetrics( getFont() );

//setForeground(new Color(96, 96, 96));
image = new ImageIcon( getClass().getResource(
"/remote1.gif" ) );

setBorder( new MatteBorder( 1, 1, 1, 1, Color.gray ) );

text = new Vector( 50 );
StringTokenizer st = new StringTokenizer(
GalleryRemote.getInstance().properties.getProperty( "aboutText" ), "\n" );
while ( st.hasMoreTokens() ) {
String line = st.nextToken();
text.addElement( line );
maxWidth = Math.max( maxWidth,
fm.stringWidth( line ) + 10 );
}
initialPosition = getHeight() - BOTTOM - BOTTOM - TOP - TOP;
scrollPosition = initialPosition;

thread = new AnimationThread();
}

/**
* Gets the preferredSize attribute of the AboutPanel object
*
*@return The preferredSize value
*@since
*/
public Dimension getPreferredSize() {
return new Dimension( 1 + image.getIconWidth(),
1 + image.getIconHeight() );
}

/**
* Description of the Method
*
*@param g Description of Parameter
*@since
*/
public void paintComponent( Graphics g ) {
//g.setColor(new Color(96, 96, 96));
image.paintIcon( this, g, 1, 1 );

FontMetrics fm = g.getFontMetrics();

String version = GalleryRemote.getInstance().properties.getProperty( "version" );
g.drawString( version, ( getWidth() - fm.stringWidth( version ) ) / 2,
getHeight() - 5 );

g = g.create( ( getWidth() - maxWidth ) / 2, TOP, maxWidth,
getHeight() - TOP - BOTTOM );

int height = fm.getHeight();
int firstLine = scrollPosition / height;

int firstLineOffset = height - scrollPosition % height;
int lines = ( getHeight() - TOP - BOTTOM ) / height;

int y = firstLineOffset;

for ( int i = 0; i <= lines; i++ ) {
if ( i + firstLine >= 0 && i + firstLine < text.size() ) {
String line = (String) text.get( i + firstLine );
g.drawString( line, ( maxWidth - fm.stringWidth( line ) ) / 2, y );
}
y += fm.getHeight();
}
}

/**
* Adds a feature to the Notify attribute of the AboutPanel object
*
*@since
*/
public void addNotify() {
super.addNotify();
thread.start();
}

/**
* Description of the Method
*
*@since
*/
public void removeNotify() {
super.removeNotify();
thread.kill();
}

/**
* Animation thread
*
*@author paour
*@created August 16, 2002
*/
class AnimationThread extends Thread
{
private boolean running = true;


AnimationThread() {
super( "About box animation thread" );
setPriority( Thread.MIN_PRIORITY );
}


/**
* Description of the Method
*
*@since
*/
public void kill() {
running = false;
}


/**
* Main processing method for the AnimationThread object
*
*@since
*/
public void run() {
FontMetrics fm = getFontMetrics( getFont() );
int max = ( text.size() * fm.getHeight() );

while ( running ) {
long start = System.currentTimeMillis();

scrollPosition += 2;

if ( scrollPosition > max ) {
scrollPosition = initialPosition;
}

try {
Thread.sleep( 100 );
} catch ( Exception e ) {
}

repaint( getWidth() / 2 - maxWidth,
TOP, maxWidth * 2,
getHeight() - TOP - BOTTOM );
}
}
}
}
}

0 comments on commit 1461043

Please sign in to comment.