Commits

Anonymous committed 2168775

refactored and added java doc - merged ivan branch

  • Participants
  • Parent commits c258d44

Comments (0)

Files changed (6)

File src/ca/usask/cs/giraffe/ui/anim/AnimationDisplay.java

 import javax.swing.JPanel;
 
 public class AnimationDisplay extends JPanel {	
+	
+	/**
+	 * Maps for storing boxes
+	 */
 	public HashMap<String, Primitive> primBoxes;
 	public HashMap<String, Array> arrBoxes;
-	public HashMap<String, Struct> structBoxes;
 	
+	/**
+	 * Size to be manipulated when adding animation 
+	 */
 	public Dimension size;
 	
-	Function function;   	
+	/**
+	 * Used to set proper function attributes 
+	 */
+	Function function;   
 	
-
-	  private String op = "p"; // decides operation - default p for primitive
-	  
-	  public AnimationDisplay(){
-		  	
-		    setLayout(null);
-            reset();
-            
-	  }
+	/**
+	 * To send to the DisplayObject, will be used to check which image to display and proper sizes
+	 * 
+	 */
+	private String op = "p"; // decides operation - default p for primitive
+  
+	
+	/**
+	 * Constructor - sets the layout and resets
+	 */
+	public AnimationDisplay(){
+		setLayout(null);
+		reset();
+	}
 	
+	/**
+	 * returns the adjusted size
+	 */
 	@Override
 	public Dimension getPreferredSize(){
 		return size;		
 	}
 	
-	//FIXME javadoc
+	/**
+	 * Called to adjust the size of the window only as wide and tall as the tallest and
+	 * widest component in the window
+	 */
 	private void updateSize(){
 		Point bottomLeft = new Point();
 		
 		size = new Dimension(bottomLeft.x, bottomLeft.y);		
 		setSize(size);		
 	}
+	
 	/**
-	 * 
+	 * Calculates all necessary values given from the animation descriptor
+	 * @param ad animation descriptor to appear
+	 * @throws WrongSubclassException 
 	 */
+	private void primAppearAnim(AnimationDescriptor ad, double time) throws WrongSubclassException{
+		
+		//get name and location
+		String name = ad.varname().getName();	
+		Point2D location = ad.location();
+		
+		// create the box
+		int width = DisplayProperties.NAME_WIDTH + DisplayProperties.VALUE_WIDTH + 2;
+		int height = DisplayProperties.PRIM_HEIGHT;
+		Primitive prim = new Primitive(name,op, width, height);
+		
+		// add it to the screen
+		add(prim);
+
+		//set its location
+		int x = (int) location.getX();
+		int y = (int) location.getY();
+		prim.setLocation(x,y);
+    
+		// make this frame redisplay its subcomponents
+		repaint(); 
+		prim.setBackground(Color.gray);
+			
+	    // make the box appear at specified time
+	    prim.appear(time);      
+	    
+	    // add box to map for future reference	  	        
+	    primBoxes.put(name, prim); 
+	}
 	
 	/**
+	 * Calculates all necessary data to appear an array
+	 * @param ad animation descriptor used for array metadata
+	 * @throws WrongSubclassException 
+	 */
+	private void arrAppearAnim(AnimationDescriptor ad, double time) throws WrongSubclassException{
+		String name = ad.varname().getName();	
+  		Point2D location = ad.location();
+  		int arrLength = ad.vartype().getArraySize(); 		  		
+  		
+  		//find location of array
+  		int x = (int) location.getX();
+  		int y = (int) location.getY();
+  		
+  		
+  		//set location of first prim boxes
+  		int startx = x + DisplayProperties.NAME_WIDTH + DisplayProperties.ARRAY_WIDTH_OVERHEAD/2;
+  		int starty = y + DisplayProperties.ARRAY_HEIGHT_OVERHEAD/2;
+  		
+  		//initialize elements array storing primitives
+  		Primitive[] elements = new Primitive[arrLength];
+  		int elemWidth = DisplayProperties.INDEX_WIDTH + DisplayProperties.VALUE_WIDTH;
+  		for (int i = 0; i < arrLength; i++){
+  			//set the name of the prim box to be the index
+  			int width = DisplayProperties.VALUE_WIDTH + DisplayProperties.INDEX_WIDTH;
+  			int height = DisplayProperties.PRIM_HEIGHT;
+	        Primitive prim = new Primitive(Integer.toString(i),"a", width, height);
+	        
+	        //add the box to the screen
+	  		add(prim);
+	  		
+	  		//make it visible
+	  		prim.setVisible(false);			  		
+	  		int ix;
+	  		int iy;
+	  		//adjust location for each element
+	  		if (DisplayProperties.ARRAYS_HORIZONTAL){
+		  		 ix = startx + i*elemWidth;//offset to array box plus the index width
+		  		 iy = starty;
+	  		} else {
+	  			ix = startx;
+	  			iy = starty + i *DisplayProperties.PRIM_HEIGHT;			  			
+	  		}
+	  		prim.setLocation(ix,iy);    
+	  		
+	  		// store primitive for future reference	    
+        	elements[i] = prim;     	
+	    }
+  		
+  	    //number of boxes times there width plus the overhead
+  		int width;
+  		int height;
+  		if (DisplayProperties.ARRAYS_HORIZONTAL){
+  			width = DisplayProperties.NAME_WIDTH + DisplayProperties.ARRAY_WIDTH_OVERHEAD +
+  					(arrLength * elemWidth);			  		
+	  		//prim height plus overhead
+	  		height = DisplayProperties.PRIM_HEIGHT + DisplayProperties.ARRAY_HEIGHT_OVERHEAD;
+  		} else {
+  			// vertical
+  			width = DisplayProperties.NAME_WIDTH + DisplayProperties.ARRAY_WIDTH_OVERHEAD + 
+  					elemWidth;
+  			height = DisplayProperties.ARRAY_HEIGHT_OVERHEAD + arrLength * DisplayProperties.PRIM_HEIGHT;		
+  		}
+  		// create the box
+  		Array arr = new Array(name, arrLength, elements, width, height); 		  		
+  		
+  		// add main array box to the screen
+  		arr.setLocation(x,y);
+  		add(arr);	
+  		
+  		//have all elements appear simultaneously
+  		arr.appear(time);
+  		validate(); 
+  		
+	        // add box to map for future reference	  	        
+	        arrBoxes.put(name, arr);
+	}
+	/**
 	 * performs the animations specified
 	 * 
 	 * @param ads the animation specifications
 	 * 
 	 */
 	public void performAnimations(LinkedList<AnimationDescriptor> ads, double time)  {		
+		
 		updateSize();
+		
 		if (ads.isEmpty()){
 			//GiraffeLogger.error("there is no animations to be displayed");
 			return;
 		}
-		System.out.println(ads.size());
 		
 		AnimationDescriptor ad = ads.pop(); // perform the animation specified by "ad"
 		
 			GiraffeLogger.error("Null AD");
 			return;
 		}
-		GiraffeLogger.debug(""+ad.type());
-
-		
-		int arrLength; // the size of the array
-		String name, value; // name and value of the array
-		
 
 		/**
 		 * Check goal of animation that needs to be done
 		 * 		Then check the type of animation
 		 */
 		try {  		  
-			
-			
-		if (ad.type() == AnimationType.APPEAR) {
-		  	if (ad.vartype().isPrimitive()){
-				
-					//get name and location
-				name = ad.varname().getName();	
-		  		Point2D location = ad.location();
-		  		GiraffeLogger.debug("Name: " + name + " Location: " + location);
-		  		
-		  		// create the box
-		  		int width = DisplayProperties.NAME_WIDTH + DisplayProperties.VALUE_WIDTH + 2;
-		  		int height = DisplayProperties.PRIM_HEIGHT;
-		  		Primitive prim = new Primitive(name,op, width, height);
-		  		
-		  		// add it to the screen
-		  		add(prim);
-		
-		  		
-		  		
-		  		//set its location
-		  		int x = (int) location.getX();
-		  		int y = (int) location.getY();
-		  		prim.setLocation(x,y);
-		        
-		        // make this frame redisplay its subcomponents
-		  		repaint(); 
-		  		prim.setBackground(Color.gray);
-		  		
-		        // make the box appear at specified time
-		        prim.appear(time);      
-		        
-		        // add box to map for future reference	  	        
-		        primBoxes.put(name, prim); 
-		        
-			} 
+			if (ad.type() == AnimationType.APPEAR) {
+			  	if (ad.vartype().isPrimitive()){
+			        primAppearAnim(ad, time);
+				} 
 		  	else if (ad.vartype().isArray()){
-			  	name = ad.varname().getName();	
-		  		Point2D location = ad.location();
-		  	
-		  		arrLength = ad.vartype().getArraySize(); 		  		
-		  		
-		  		//find location of array
-		  		int x = (int) location.getX();
-		  		int y = (int) location.getY();
-		  		
-		  		
-		  		//set location of first prim boxes
-		  		int startx = x + DisplayProperties.NAME_WIDTH + DisplayProperties.ARRAY_WIDTH_OVERHEAD/2;
-		  		int starty = y + DisplayProperties.ARRAY_HEIGHT_OVERHEAD/2;
-		  		
-		  		//initialize elements array storing primitives
-		  		Primitive[] elements = new Primitive[arrLength];
-		  		int elemWidth = DisplayProperties.INDEX_WIDTH + DisplayProperties.VALUE_WIDTH;
-		  		for (int i = 0; i < arrLength; i++){
-		  			//set the name of the prim box to be the index
-		  			int width = DisplayProperties.VALUE_WIDTH + DisplayProperties.INDEX_WIDTH;
-		  			int height = DisplayProperties.PRIM_HEIGHT;
-			        Primitive prim = new Primitive(Integer.toString(i),"a", width, height);
-			        
-			        //add the box to the screen
-			  		add(prim);
-			  		
-			  		//make it visible
-			  		prim.setVisible(false);			  		
-			  		int ix;
-			  		int iy;
-			  		//adjust location for each element
-			  		if (DisplayProperties.ARRAYS_HORIZONTAL){
-				  		 ix = startx + i*elemWidth;//offset to array box plus the index width
-				  		 iy = starty;
-			  		} else {
-			  			ix = startx;
-			  			iy = starty + i *DisplayProperties.PRIM_HEIGHT;			  			
-			  		}
-			  		prim.setLocation(ix,iy);    
-			  		
-			  		// store primitive for future reference	    
-		        	elements[i] = prim;     	
-			    }
-		  		
-		  	    //number of boxes times there width plus the overhead
-		  		int width;
-		  		int height;
-		  		if (DisplayProperties.ARRAYS_HORIZONTAL){
-		  			width = DisplayProperties.NAME_WIDTH + DisplayProperties.ARRAY_WIDTH_OVERHEAD +
-		  					(arrLength * elemWidth);			  		
-			  		//prim height plus overhead
-			  		height = DisplayProperties.PRIM_HEIGHT + DisplayProperties.ARRAY_HEIGHT_OVERHEAD;
-		  		} else {
-		  			// vertical
-		  			width = DisplayProperties.NAME_WIDTH + DisplayProperties.ARRAY_WIDTH_OVERHEAD + 
-		  					elemWidth;
-		  			height = DisplayProperties.ARRAY_HEIGHT_OVERHEAD + arrLength * DisplayProperties.PRIM_HEIGHT;		
-		  		}
-		  		// create the box
-		  		Array arr = new Array(name, arrLength, elements, width, height); 		  		
-		  		
-		  		// add main array box to the screen
-		  		arr.setLocation(x,y);
-		  		add(arr);	
-		  		
-		  		//have all elements appear simultaneously
-		  		arr.appear(time);
-		  		validate(); 
-		  		
-	  	        // add box to map for future reference	  	        
-	  	        arrBoxes.put(name, arr);
+			  	arrAppearAnim(ad, time);
 		  }
 		  else if (ad.vartype().isStruct()){
 			  GiraffeLogger.error("Appear for structs are not implemented");
         function.setSize(200,40);
 		primBoxes = new HashMap<String, Primitive>();
 		arrBoxes = new HashMap<String, Array>();
-		structBoxes = new HashMap<String, Struct>();
 		updateSize();
 
 	}

File src/ca/usask/cs/giraffe/ui/anim/Array.java

 
 public class Array extends DisplayObject implements ActionListener {
 	
-	
-	
-	
+	/**
+	 * Stores the array of primitives
+	 */
 	private Primitive[] elements; //Stores the array elements
-	private String op = "a"; //operation is set to array
-	boolean arrNotInit = true;
 	
 	/**
-	 * Image or Box Properties
+	 * Image paths for images
 	 */
-	// FIXME javadoc
-	private Image topImage;
-	private Image middleImage;
-	private Image bottomImage;	
 	private String topPath = "images/atop.png";	
 	private String middlePath = "images/amiddle.png";	
 	private String bottomPath = "images/abottom.png";	
-	private final static int TOP_BOTTOM_IMAGE_HEIGHT = 18;
-	
-	private Graphics2D arrg;	
-	
-	private double time; // time for current animation
 	
+	/**
+	 * Images for each piece of the array image - for piecing together
+	 */
+	private Image topImage;
+	private Image middleImage;
+	private Image bottomImage;	
 	
+	private final static int TOP_BOTTOM_IMAGE_HEIGHT = 18; //represents the value of top and bottom images height
 	
-
+	/**
+	 * time for current animation
+	 */
+	private double time;
 	Timer aTimer;
 	
 
 		else return elements.length;
 	}
 	
-	/**
-	 * ******BOX PROPERTIES*******
-	 */
-	
 		
 	/**
 	 * Gets the element of the array
 		return elements[index];
 	}
 	
-	/** APPEAR **/
-	
 	/**
 	 * Appear the outer shell array box and name
 	 * @param animTime
 	 * @param elems are the elements inside the array
 	 */
-    // FIXME lift this into superclass of Array and Primitive for refactoring
 	public void appear(double animTime) {
 		time = animTime;
 		type = AnimationType.APPEAR;
 		setVisible(true);				
 	}	
 	
+	/**
+	 * calls primitive appear animation for every element in the array
+	 */
 	public void appearArrayContent(){		
 		// appear all elements
 		for (int i = 0; i < elements.length; i++) {
 		}
 	}	
 
-	
-	/****** PAINTING*****/
-	
-	
+	/**
+	 * paints
+	 */
 	protected void paintComponent(Graphics g) {
 
 		// set up graphics
 		super.paintComponent(g);
-		arrg = (Graphics2D) g; //initialize boxandname graphic
+		Graphics2D arrg = (Graphics2D) g; //initialize boxandname graphic
 		arrg.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //set render methods
 		
 		
 				if (percent < 50)
 					nColor = computeGrayscale(100);
 				else 
-					nColor = computeGrayscale((100-percent)*2);
-								
+					nColor = computeGrayscale((100-percent)*2);			
 				break;			
 			default:
 		}		
 		arrg.drawString(name, nameOff.x, nameOff.y);			
 	}
 	
+	/**
+	 * Calls to primitive appear for a quick stop;
+	 */
 	@Override
 	public void stopAnimation(){
 		super.stopAnimation();

File src/ca/usask/cs/giraffe/ui/anim/DisplayObject.java

  */
 public abstract class DisplayObject extends JPanel implements ActionListener {
 	
-	protected static final int WHITE = 220;
-	protected static final int BLACK = 0;
+	protected static final int WHITE = 220; //RBG color code
+	protected static final int BLACK = 0;//RBG color code
 	
 	protected Timer timer; // timer used for animations
 	protected AnimationType type;
 	 */
 	public abstract void appear(double animTime);
 	
-	protected Point nameOff;
-	
-	protected Font nameFont;//stores size of name along with type of print
-	
+	/**
+	 * Name of primitive or array
+	 */
 	protected String name;
 	
+	/**
+	 * Sets the proper adjusted point for where to start drawing name string
+	 */
+	protected Point nameOff;
 	
-	
-	
+	/**
+	 * Font type of the name (either primitive or array)
+	 */
+	protected Font nameFont;
 	
 
 	/**
 				(DisplayProperties.PRIM_HEIGHT/2) + fm.getDescent()); 		
 	}
 	
-	
-	// FIXME javadoc
+	/**
+	 * Computes a color of paint to send for painting that is adjusted accordingly with the
+	 * parameter percent
+	 * @param percent the amount complete of the operation
+	 * @return the paint with adjusted color from percent
+	 */
 	protected Paint computeGrayscale(int percent){
 		double nameColor = percent * 220.0 / 100.0;
 		if (nameColor > 220) nameColor = 220;
 						(int)nameColor), true);					
 	}	
 	
-	public void actionPerformed(ActionEvent e) { // FIXME refactor into repaint		
+	/**
+	 * Calls painting procedure
+	 */
+	public void actionPerformed(ActionEvent e) { 	
 		if (percent < 100) {			
 			percent += delta;
 			repaint();
 		else stopAnimation();	
 	}
 	
+	/**
+	 * prepares animation to be used by adjusting framerate accordingly with the given
+	 * parameter
+	 * @param animTime the animation time in which the animation needs to complete (percent = 100)
+	 */
 	protected void initAnimation(double animTime) {		
 		percent = 0;
 		int nframes = (int) (animTime * DisplayProperties.FPS);		
 		timer.start();
 	}
 	
-	//FIXME javadoc
+	/**
+	 * Stops the animation whenever the timer is stopped, then resets the percent value  
+	 * to be complete and tells to repaint so that animation looks like it would as if
+	 * it had finished
+	 */
 	protected void stopAnimation(){
 		if (timer != null){
 			percent = 100;	
 			timer.stop();
 		}
 	}
-	
-	
-
 }

File src/ca/usask/cs/giraffe/ui/anim/DisplayProperties.java

  * Feel free to change these values to make the Data Display more aesthetically
  * pleasing.
  * 
- * 
- * 
- * Visual explanation of constants:
- * 
- * Primitives:
- * 
- * 	   NAME_WIDTH 				VALUE_WIDTH 
- * 0-------------------------0------------------0 
- * |	 		  			 | 			  		| PRIM_HEIGHT
- * | NAME   	  			 | VALUE        	|
- * 0-------------------------0------------------0
- * 
- * 
- * Arrays:
- * 
- * NAME_WIDTH + arraysize*(INDEX_WIDTH + VALUE_WIDTH) + ARRAY_WIDTH_OVERHEAD
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `
- * INDEX_WIDTH ` ` 0-------0-------0-------0-------0 ` ` NAME | INDEX | VALUE |
- * INDEX | VALUE | ` PRIM_HEIGHT + ARRAY_HEIGHT_OVERHEAD `
- * 0-------0-------0-------0-------0 ` ` `
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- * 
- * NOTE: ~ and ` indicates there is no border surrounding the box. Just so that
- * structures don't have so many lines
- * 
- * Structures:
- * 
- * TYPE_WIDTH + NAME_WIDTH + structsize*(arraysize*(INDEX_WIDTH + VALUE_WIDTH) +
- * ARRAY_WIDTH_OVERHEAD)
- * 0------------0-------------------------------------------------0 | NAME_WIDTH
- * | PRIM_HEIGHT + ARRAY_HEIGHT_OVERHEAD |
- * 0-------0-------0-------0-------0-------0-------0 | | | | | | | 0-------0 | |
- * | NAME | FIELD | VALUE | | | | | 0-------0 | | | | | | | |
- * 0-------0-------0-------0-------0 | | PRIM_HEIGHT*primS +
- * ARRAY_HEIGHT_OVERHEAD*arryS + STRUCT_HEIGHT_OVERHEAD | | NAME | INDEX | VALUE
- * | INDEX | VALUE | | | | | 0-------0-------0-------0-------0 | | | | | | | |
- * 0-------0-------0-------0-------0 | | | | | NAME | VALUE | | | | |
- * 0-------0-------0-------0-------0 | | | | | | |
- * 0-------0-------0-------0-------0-------0-------0 |
- * 0------------0-------------------------------------------------0
+ * TODO: ADD PRETTY PICTURES from previous commit
  * 
  * NOTE: Currently doesn't support nested structures
  * 
  */
 public interface DisplayProperties {
 
-	//FIXME
-	public static int STRING_PAD = 5;	
-	public static int FPS = 30;
-	
+	/**
+	 * The amount of pixels to surround any given string
+	 */
+	public static int STRING_PAD = 5;
 	
-	// primitives
 	/**
-	 * height of the function name text box
+	 * The default number of frames displayed per second in any animation
 	 */
-	public static int FUNCTION_NAME_HEIGHT = 40;
+	public static int FPS = 30;
 	
+	
+	// primitives
 	/**
 	 * the height of a primitive box
 	 */
 	 * heights of the elements)
 	 */
 	public static final int ARRAY_HEIGHT_OVERHEAD = 40;
-
 	
+	//structs
+	/**
+	 * distance above struct
+	 */
+	public static final int STRUCT_HEIGHT_OVERHEAD = 5;
+		
 	
-	// structs
+	//function
 	/**
-	 * width of an struct type name
+	 * Padding between the top of the screen and the function display
 	 */
-	public static final int TYPE_WIDTH = 20;
+	public static int FUNCTION_NAME_HEIGHT = 30;
+	
 	/**
-	 * The additional width needed to display a structure (in addition to the
-	 * NAME_WIDTH and the INDEX_WIDTH and VALUE_WIDTHs of all the elements)
+	 * The font size of the function display
 	 */
-	public static final int STRUCT_WIDTH_OVERHEAD = 10;
-
+	public static final int FUNCTION_FONT_SIZE = 24;
+	
 	/**
-	 * The additional height needed to display an array (in addition to the
-	 * heights of the elements)
+	 * Padding between the left side of screen and function display
 	 */
-	public static final int STRUCT_HEIGHT_OVERHEAD = 10;
+	public static final int FUNCTION_WIDTH_PADDING = 5;
+	
+	
+	//defaults
+	/**
+	 * The value in which a font is set to by default when creating a new font 
+	 */
+	public static final int DEFAULT_FONT_SIZE = 15;
+	
+	/**
+	 * The type of font set by default
+	 */
+	public static final String DEFAULT_FONT_TYPE = "Times New Roman";
+	
+	
 
 }

File src/ca/usask/cs/giraffe/ui/anim/Function.java

 
 public class Function extends JPanel{
 	
-
+	/**
+	 * The font used to display the function
+	 */
 	private Font funcFont;
+	
+	/**
+	 * The value of the function (or name the function that is currently set to)
+	 */
 	private String value;
 	
+	/**
+	 * Constructor - simply sets function to be visible
+	 */
 	public Function() {
         setVisible(true);
     }
+	
+	/**
+	 * Adjusts the value to the new given parameter
+	 * @param val the new function value to be set to
+	 */
 	public void changeValue(String val){
 		value = val;		
 		repaint();
 	}
+	
+	/**
+	 * Performs the repainting
+	 * @param e
+	 */
 	public void actionPerformed(ActionEvent e) {
 		repaint();
 	}
 	
+	/**
+	 * paints
+	 */
 	protected void paintComponent(Graphics g) {
 		
 		// set up graphics
 		super.paintComponent(g);
 		Graphics2D g2d = (Graphics2D) g; //initialize box and name graphic
 		
-		funcFont = new Font("Times New Roman", Font.BOLD, 24);// set the default font size
+		funcFont = new Font("Times New Roman", Font.BOLD, DisplayProperties.FUNCTION_FONT_SIZE);// set the default font size
 		g2d.setFont(funcFont);
 		if (value !=  null){
-			GiraffeLogger.warning("new function: " + value);
-			g2d.drawString(value, 0, 30);
+			g2d.drawString(value, DisplayProperties.FUNCTION_WIDTH_PADDING, DisplayProperties.FUNCTION_NAME_HEIGHT);
 		}
 	}
 

File src/ca/usask/cs/giraffe/ui/anim/Primitive.java

 	 */	
 	private Point valOff;
 	
-	/* create box values */
-
-	
-	boolean boxNotInit = true;
-	
+	/** 
+	 * Set image paths
+	 */
 	private String primPath = "images/box.png";
 	private String arrPath = "images/abox.png";	
 	
 	 */
 	Image img;
 	
-	//name and value information	
+	/**
+	 * name and value information	
+	 */
 	private String val; //value of the primitive
 
-	//for appearing strings	
-	private Font valFont; // same a name but for val
-	
-		
-	private String operation = "p"; // set the operation to be primitive	
+	/**
+	 * the primitive value font for appearing strings	
+	 */
+	private Font valFont; 
 	
+	/**
+	 * 	a constant used to check where the operation has been set from
+	 *  default - p	
+	 */
+	private String operation = "p"; 
 
+	
 	/**
 	 * Constructor
 	 * @param namey sets the name the primitive box
 	 */
 	
 	public void computeValFontAndOffset(int width){	
-		int fontsize = 15; //FIXME magic number
-		Font font = new Font("Times New Roman", Font.BOLD, fontsize);// set the default font size
+		int fontsize = DisplayProperties.DEFAULT_FONT_SIZE;
+		Font font = new Font(DisplayProperties.DEFAULT_FONT_TYPE, Font.BOLD, fontsize);// set the default font size
 		FontMetrics fm = this.getFontMetrics(font);		
 		int valWidth = fm.stringWidth(val);//store the width to be size of string
 		while (valWidth > DisplayProperties.VALUE_WIDTH-DisplayProperties.STRING_PAD){ // while the width is bigger then the images width - 10 (50)
 			fontsize--;
-			font = new Font("Times New Roman", Font.BOLD, fontsize);	
+			font = new Font(DisplayProperties.DEFAULT_FONT_TYPE, Font.BOLD, fontsize);	
 			fm = this.getFontMetrics(font);
 			valWidth = fm.stringWidth(val);//adjust the name width							
 		}
 				(DisplayProperties.PRIM_HEIGHT/2) + fm.getDescent()); // FIXME magic number		
 	}
 	
-	
-	
-	
-	
-	
 
 	/**
 	 *  Appears both the box and the name of it
-	 * @param op is the operation thats used to assign proper location (array vs prim)
 	 * @param animTime the amount of time the animation should take in total
 	 */
 	public void appear(double animTime){
 		setVisible(true);
 		initAnimation(animTime);
 	}
-
-	public void changeValue(String value, double animTime) {
-		GiraffeLogger.debug("Changing value to: " + value);		
-		stopAnimation(); // stop any running animations					
-		val = value; // TODO: check that value is not null
+	
+	/**
+	 * Changes the value of animation
+	 * @param value the new value to be set to
+	 * @param animTime the amount of time to finish the animation in
+	 */
+	public void changeValue(String value, double animTime) {		
+		stopAnimation(); // stop any running animations	
+		val = value; 
+		if (val == null){
+			val = "";
+		}
 		type = AnimationType.CHANGE_VALUE;
 		if (operation == "a"){
 			computeValFontAndOffset(DisplayProperties.INDEX_WIDTH);
 		initAnimation(animTime);	
 	}
 
-	
-	
-	/****** PAINTING ******/	
 	/*
 	 * does the actual painting to the screen
 	 * @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
 		// set up graphics
 		super.paintComponent(g);
 		Graphics2D boxg = (Graphics2D) g; //initialize boxandname graphic
-		
-		
 		boxg.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //set render methods
 				
 		// determine opacity, name and value color
 					break;
 				case CHANGE_VALUE:					
 					boxg.setFont(valFont); //scale name and set it as size	
-					//draw the value to the screen					
+					//draw the value to the screen
+					
 					//adjust color
 					boxg.setPaint(vColor);				
 					//draw