class gplpane extends JPanel
{
gplpanel jp;
BufferedImage vectimg;
point p=new point(-5,55,"England");
point q=new point(-110,33,"LosAngeles");
point r=new point(80,20,"Hyderabad");
point p2=new point(20,-45,"p2");
point q2=new point(-60,-30,"q2");
point r2=new point(50,-20,"r2");
point s2=new point(-20,-50,"s2");
point p3=new point(-90,45,"control station");
line l1=new line(p,q,"Route 1");
line l2=new line(p,r,"Route 2");
line l3=new line(p,r,"Route 3");
polygon pol=new polygon("cyclone_effected",true);
circle cir=new circle(30,"Winds",120,-44,false);
rectangle rec=new rectangle(new point(20,78),new
point(40,67),"F_place1",true);
gvector v[]=new gvector[10];
gvector v1[]=new gvector[10];
legend l[]=new legend[10];
legend ld[]=new legend[10];
gplpane(Image img)
{
super();
initialise(); //l
and v objects are initialised.
jp=new gplpanel(l,new range(-180,180,90,-90,6),img,v);
// initialising the gpl panel.
}
public void paint(Graphics g)
{
super.paintComponent(g);
//vectimg=new BufferedImage(this.getWidth(),this.getHeight(),BufferedImage.TYPE_INT_RGB);
vectimg=jp.drawimage(this.getWidth(),this.getHeight(),this);
// returns the Buffered image for you with the rendering
g.drawImage(vectimg,0,0,this.getWidth(),this.getHeight(),this);
// look at the presentation slides for the corresponding display
}
public void initialise()
{
pol.addpoint(s2);
pol.addpoint(p2);
pol.addpoint(r2);
pol.addpoint(q2);
Vector temp=new Vector();
temp.add(pol);
v[0]=new gvector(temp,Color.lightGray);
l[0]=new legend("Cyclone",Color.lightGray,true,"polygon");
temp=new Vector();
temp.add(p);
temp.add(q);
temp.add(r);
l[1]=new legend("Cities",Color.magenta,false,"point");
v[1]=new gvector(temp,Color.magenta);
temp=new Vector();
temp.add(l1);
temp.add(l2);
l[2]=new legend("flight routes",Color.blue,false,"line");
v[2]=new gvector(temp,Color.blue);
temp=new Vector ();
temp.add(cir);
l[3]=new legend("Heavy winds",Color.black,false,"circle");
v[3]=new gvector(temp,Color.black);
temp=new Vector ();
temp.add(rec);
l[4]=new legend("Freezing places",Color.red,true,"rectangle");
v[4]=new gvector(temp,Color.red);
temp=new Vector ();
temp.add(p3);
l[5]=new legend("control station",Color.red,false,"point");
v[5]=new gvector(temp,Color.red);
}
}
class window extends JInternalFrame
{
JMenuBar menuBar;
Dimension screenSize = new Dimension(800,700);
final int inset=50;
Container parent;
gplpane p;
window(String bkimgs,Container prnt)
{
super("GPL Query Display
: GPL_",true,true,true,true);
setPreferredSize(screenSize);
parent=prnt;
JPanel top=new JPanel();
top.setBorder(new EmptyBorder(10, 10, 10, 10));
top.setLayout(new BorderLayout());
Toolkit tk=this.getToolkit();
Image img= tk.getImage(bkimgs);
p=new gplpane(img);
top.add(p,BorderLayout.CENTER);
setContentPane(top);
pack();
setLocation(100,100);
}
}
class GPL extends JFrame
{
public static final Integer DOCLAYER = new Integer(5);
JDesktopPane desktop;
window GPL_1,GPL_2,GPL_i;
GPL()
{
super("GPL QUERY DISPLAY");
final int inset = 50;
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setBounds (inset,inset,screenSize.width
- inset*2, screenSize.height - inset*2);
desktop = new JDesktopPane();
getContentPane().add(desktop);
this.addWindowListener(new
WindowAdapter() {
public void windowClosing(WindowEvent
e) {
System.exit(0);
}});
}
public window addwindow(String s)
{
GPL_i=new window(s,this.getContentPane());
desktop.add(GPL_i,DOCLAYER);
return GPL_i;
}
}
public class testing
{
String bkimgfilename="Z:\\temp_papers\\GPL\\amap.jpg";
// make it point to the context map in your directory.**********
testing()
{
GPL g=new GPL();
window GPL_1=g.addwindow(bkimgfilename);
//window GPL_2=g.addwindow(2,bkimgfilename,v1,ld,new
range(-180,180,0,180,2));
g.setVisible(true);
}
public static void main(String[] arg)
{
new testing();
}
}