home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1998 / MacHack 1998.toast / Papers / OS Shell in Java / Facade / DesktopImage.java < prev    next >
Encoding:
Java Source  |  1998-06-18  |  2.7 KB  |  121 lines  |  [TEXT/dosa]

  1. //    DesktopImage.java : this is a Java source code file for the program Facade.
  2. //    Copyright 1998, Andrew S. Downs
  3. //    andrew.downs@tulane.edu
  4. //
  5. //    This source code is distributed as freeware.
  6. //    Just keep this author information in the file.  Enjoy!
  7.  
  8. import java.awt.*;
  9. import java.awt.event.*;
  10. import java.awt.image.*;
  11. import java.io.*;
  12. import java.util.*;
  13.  
  14. public class DesktopImage extends DesktopComponent implements Serializable /*, MouseListener, MouseMotionListener */ {
  15.     boolean drag = false;
  16.     
  17.     int initialX = 0;
  18.     int initialY = 0;
  19.  
  20.     transient Image theImage;
  21.     Point labelLocation;
  22.     String path;
  23.     
  24.     DesktopImage() {
  25.         super();
  26. //        this.addMouseListener( this );
  27. //        this.addMouseMotionListener( this );
  28.     }
  29.  
  30.     public void setImage( Image i ) {
  31.         this.theImage = i;
  32.     }
  33.  
  34.     public Image getImage() {
  35.         return this.theImage;
  36.     }
  37.  
  38.     public void setPath( String s ) {
  39.         this.path = s;
  40.     }
  41.  
  42.     public String getPath() {
  43.         return this.path;
  44.     }
  45.  
  46.     public void setLabelLocation( Point p ) {
  47.         this.labelLocation = p;
  48.     }
  49.  
  50.     public void setLabelLocation( int x, int y ) {
  51.         this.labelLocation = new Point( x, y );
  52.     }
  53.  
  54.     public Point getLabelLocation() {
  55.         return this.labelLocation;
  56.     }
  57.  
  58.     private void writeObject( ObjectOutputStream s ) throws IOException {
  59.         s.defaultWriteObject();
  60.     }
  61.  
  62.     private void readObject( ObjectInputStream s ) throws ClassNotFoundException, IOException {
  63.         s.defaultReadObject();
  64.     }
  65. /*
  66.     public void mouseClicked( MouseEvent e ) {
  67.         if ( e.getClickCount() == 1 ) {
  68.         }
  69.         else if ( e.getClickCount() == 2 ) {
  70.             if ( Desktop.windowExists( this.getPath() ) ) {
  71. //                Desktop.setTopFrame( this.getPath() );
  72. System.out.println( "DEBUG: setting top frame from DImage..." );
  73.             }
  74.             else {
  75.                 DesktopFrame dw = new DesktopFrame( this.getPath() );
  76. //                    DesktopFrame dw = new DesktopFrame();
  77. //                    dw.setBounds( 100, 100, 200, 200 );
  78.                 dw.setLabel( this.getLabel() );
  79.                 dw.setPath( this.getPath() );
  80.                 dw.pack();
  81.                 dw.validate();
  82.                 dw.show();
  83.                 dw.toFront();
  84.                 dw.repaint();
  85.             }
  86.         }
  87.     }
  88.     
  89.  
  90.     public void mouseDragged( MouseEvent e ) {
  91.         if ( this.drag ) {
  92. //            Desktop.adjustClipRect( this.getBounds() );
  93.             this.setLocation( this.getBounds().x - this.initialX + e.getX(), this.getBounds().y - this.initialY + e.getY() );
  94.             repaint();
  95.         }
  96.     }
  97.     
  98.     public void mouseMoved( MouseEvent e ) {
  99.     }
  100.     
  101.     public void mouseEntered( MouseEvent e ) {
  102.     }
  103.         
  104.     public void mouseExited( MouseEvent e ) {
  105.     }
  106.         
  107.     public void mousePressed( MouseEvent e ) {
  108.         this.initialX = e.getX();
  109.         this.initialY = e.getY();
  110.         this.drag = true;
  111.     }
  112.  
  113.     public void mouseReleased( MouseEvent e ) {
  114.         this.initialX = 0;
  115.         this.initialY = 0;
  116.         this.drag = false;
  117.     }
  118. */
  119. }
  120.  
  121.