The source code of restaurant2.java :
import java.awt.*;
class restaurant2 extends Link
{
public boolean active;
public int touch(int radius)
{
DPoint ScrDp=jshape.GetMouseScrDp();
DPoint ScrMinDp=new DPoint(ScrDp.x-radius,ScrDp.y+radius);
DPoint ScrMaxDp=new DPoint(ScrDp.x+radius,ScrDp.y-radius);
DPoint MapMinDp=jshape.ScrToMapDp(ScrMinDp);
DPoint MapMaxDp=jshape.ScrToMapDp(ScrMaxDp);
for (int i=1;i<=jshape.GetFeatureCount(1);i++)
{
DPoint FeatureDp=jshape.GetFeatureExtent(1,i).min;
if ((FeatureDp.dx >= MapMinDp.dx) && (FeatureDp.dx <= MapMaxDp.dx) &&
(FeatureDp.dy >= MapMinDp.dy) && (FeatureDp.dy <= MapMaxDp.dy))
{
return (i);
};
};
return (0);
}
public int dispatch(String command,String argument)
{
if (command.equals("init0"))
{
Language.ButtonUserPanel=false;
Language.ButtonUser1Text="Restaurant";
};
if (command.equals("reset"))
{
Language.ButtonUserPanel=false;
Language.ButtonUser1Text="";
};
if (command.equals("init"))
{
active=false;
jshape.SetPopupLabelFont(new Font("TimesRoman",Font.PLAIN,12));
jshape.SetPopupLabelColor(new Color(128,0,0));
};
if (command.equals("paint"))
{
Graphics g=jshape.GetPaintGraphics();
g.setColor(new Color(128,0,0));
g.drawString("(c) shiuhlin",4,16);
};
if (command.equals("user1"))
{
if (argument.equals("1"))
{
jshape.LockUserButton();
active=true;
jshape.BoldButton(jshape.GetUserButton());
}
else
{
active=false;
jshape.PlainButton(jshape.GetUserButton());
jshape.SetCursor(Cursor.DEFAULT_CURSOR);
};
};
if (command.equals("mousemove"))
{
int index;
if (active == true)
{
if ((index=touch(4)) != 0)
{
jshape.SetCursor(Cursor.HAND_CURSOR);
DPoint ScrDp=jshape.GetMouseScrDp();
jshape.ShowPopupLabel(ScrDp.x+8,ScrDp.y+4,jshape.GetAttribute(1,index,1));
jshape.ShowBrowserStatus(jshape.GetAttribute(1,index,1));
}
else
{
jshape.SetCursor(Cursor.DEFAULT_CURSOR);
jshape.HidePopupLabel();
jshape.ShowBrowserStatus("");
};
};
};
if (command.equals("mousedown"))
{
int index;
if (active == true)
{
if ((index=touch(4)) != 0)
{
String URLStr=jshape.GetDocumentBase()+"url/html/";
URLStr+=jshape.GetAttribute(1,index,2);
URLStr+=".htm";
jshape.ShowBrowserStatus(URLStr);
jshape.GoToICE(URLStr);
jshape.HidePopupLabel();
};
};
};
return (0);
}
}