home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / pc / java / unuy2wen / cybcerone / utils / scaler.java < prev    next >
Encoding:
Java Source  |  1996-08-14  |  1.0 KB  |  41 lines

  1. // Scaler.java
  2. // 28.03.96
  3. //
  4. // handles scaling, used to make 2 versions of cybcerone, big and small
  5.  
  6. package cybcerone.utils;
  7.  
  8. import java.awt.Rectangle;
  9.  
  10. /**
  11.  * Controls all the scaling to make the small version of Cybcerone.
  12.  */
  13. public class Scaler {
  14.   private static float scale = (float) 1.0;
  15.  
  16.   /** Take this number and scale it */
  17.   public static final int scale (int num) {
  18.     return Math.round (num * scale);
  19.   }
  20.  
  21.   /** Make a rectangle from these numbers and scale it */
  22.   public static final Rectangle scale (int x, int y, int width, int height) {
  23.     return new Rectangle (scale (x), scale (y), scale (width), scale (height));
  24.   }
  25.  
  26.   /** Scale this rectangle */
  27.   public static final Rectangle scale (Rectangle rec) {
  28.     return new Rectangle (scale (rec.x), scale (rec.y), 
  29.               scale (rec.width), scale (rec.height));
  30.   }
  31.  
  32.   /** Set the scaling */
  33.   public static void setScale (float newScale) {
  34.     scale = newScale;
  35.   }
  36.  
  37.   /** Get the scaling factor */
  38.   public static float getScale () { return scale; }
  39.  
  40. }
  41.