next up previous contents index
Next: Arc Up: Base Classes Previous: Attribute types

Base class structures

All base classes are subclasses of the following DJComponent class:
class DJComponent {
      dj int x;
      dj int y;
      dj Point location;
      dj int width;
      dj int height;
      dj Dimension size;
      dj Color color;
      dj boolean visible;
}
  For each base component, the attributes x and y specify the position, i.e., xy-coordinates of the left-upper corner, and the attributes width and height specify the size of the component. The attribute visible indicates whether the components is visible or not. The default value for this attribute is true.

When a base class component is created, the following constraints are imposed to the geometric attributes by default:

     x       in leftMargin..panelWidth-rightMargin
     y       in topMargin..panelHeight-bottomMargin
     width   in 0..panelWidth - leftMargin - rightMargin
     height  in 0..panelHeight - topMargin - bottomMargin


  
Figure: Base classes.
\begin{figure}
\begin{center}
\epsfile{file=bases.ps,width=8cm}\end{center}\end{figure}

Figure [*] shows how base class components look like and the following is the program that makes the figure.

class AllComponents {
	dj int component_height < 50;
	dj int component_width;

	dj Arc arc{startAngle==20;arcAngle==150};
	dj Button button{text=="Button"};
	dj Circle circle;
	dj Label label{text=="Label"};
	dj Line line{x==x1;y==y1;x2-x1==width;y2-y1==height};
	dj Oval oval{2*width == 3*height};
	dj Polygon polygon{n==6;
				  x == xs[0];
				  y == ys[0];
				  xs[1]==xs[0];
				  ys[1]==ys[0]+height/2;
				  xs[2]==xs[0]+width/2;
				  ys[2]==ys[0]+height;
				  xs[3]==xs[0]+width;
				  ys[3]==ys[1];
				  xs[4]==xs[0]+width/2;
				  ys[4]==ys[0];
	                          xs[5]==xs[0];
			          ys[5]==ys[0]};
	dj Rectangle rectangle{2*width == 3*height};
	dj RoundRectangle rrectangle{arcWidth>=width/4;arcHeight>=height/4};
	dj Square square;
	dj Star star{n==5};

	dj TextArea textarea{text=="Text field \n line2 \n line3";rows==4; columns==30};

	dj TextField textfield{text=="Text Field";};

	dj Triangle triangle {
			x2==x1+width; y2==y1;
			x3==x1; y3==y1-height};

	dj Image img1{name=="animal1.gif"},img2{name=="animal2.gif"};

	dj Label l_arc{text=="Arc";color==red},
		 l_button{text=="Button";color==red},
		 l_circle{text=="Circle";color==red},
		 l_label{text=="Label";color==red},
		 l_line{text=="Line";color==red},
		 l_oval{text=="Oval";color==red},
		 l_polygon{text=="Polygon";color==red},
		 l_rectangle{text=="Rectangle";color==red},
		 l_rrectangle{text=="RoundRectangle";width>100;color==red},
		 l_square{text=="Square";color==red},
		 l_star{text=="Star";color==red},
		 l_textarea{text=="TextArea";color==red},
		 l_textfield{text=="TextField";color==red},
		 l_triangle{text=="Triangle";color==red},
		 l_image1{text=="Image";color==red},
		 l_image2{text=="Image";color==red};


	table({	{l_arc,arc,button,l_button},
		{l_circle,circle,label,l_label},
		{l_line,line,oval,l_oval},
		{l_rrectangle,rrectangle,rectangle,l_rectangle},
		{l_polygon,polygon,square,l_square},
		{l_star,star,textarea,l_textarea},
		{l_textfield,textfield,triangle,l_triangle},
	 	{l_image1,img1,img2,l_image2}}, 20,20);

	for (o in {l_arc,l_circle,l_line,l_polygon,l_rrectangle,l_star,l_textfield,l_image1}) 
	o.alignment == RIGHT;

	for (o in {arc,button,circle,label,polygon,
		   square,star,textarea,
		   textfield,triangle,img1,img2}) 
		o.height == component_height;

}

In the following of this section, we describe the structures of all base classes.


 

Neng-Fa Zhou
1999-02-16