Pixels.java

00001 
00004 package edu.stanford.hci.r3.units;
00005 
00006 import edu.stanford.hci.r3.config.Configuration;
00007 
00019 public class Pixels extends Units {
00020 
00024         public static final String CONFIG_FILE_KEY = "pixels.pixelsperinch.file";
00025 
00026         public static final String CONFIG_FILE_VALUE = "/config/PixelsPerInch.xml";
00027 
00028         private static final double DEFAULT_PIXELS_PER_INCH = readPixelsPerInchFromConfigFile();
00029 
00033         public static final Pixels ONE = new Pixels(1);
00034 
00038         private static final String PROPERTY_NAME = "pixelsPerInch";
00039 
00044         public static Pixels getPixelsPerInchObject(int ppi) {
00045                 return new Pixels(1, ppi);
00046         }
00047 
00054         private static double readPixelsPerInchFromConfigFile() {
00055                 final String property = Configuration.getPropertyFromConfigFile(PROPERTY_NAME,
00056                                 CONFIG_FILE_KEY);
00057                 final double ppi = Double.parseDouble(property);
00058                 return ppi;
00059         }
00060 
00064         private double pixelsPerInch = DEFAULT_PIXELS_PER_INCH;
00065 
00069         public Pixels() {
00070                 super(1);
00071         }
00072 
00076         public Pixels(double numPixels) {
00077                 super(numPixels);
00078         }
00079 
00083         public Pixels(double numPixels, double pixPerInch) {
00084                 super(numPixels);
00085                 pixelsPerInch = pixPerInch;
00086         }
00087 
00091         @Override
00092         protected double getNumberOfUnitsInOneInch() {
00093                 return pixelsPerInch;
00094         }
00095 
00100         public double getPixelsPerInch() {
00101                 return pixelsPerInch;
00102         }
00103 }

Generated on Sat Apr 14 18:21:37 2007 for R3 Paper Toolkit by  doxygen 1.4.7