?? plantester.java
字號(hào):
/*
A basic extension of the java.awt.Frame class
*/
import java.awt.*;
import java.io.*;
import java.util.*;
public class PlanTester extends Frame
{
public void planTest() {
/* this is just an empty 2x2 maze with one horizontal wall (parallel to the
X-axis) between the bottom left node and the top left node. */
// Maze works as maze[x][y][direction], where x and y are like
// a regular cartesian axis system, and direction is zero straight
// up (along +y) and then increases counter-clockwise.
int[][][] maze = new int[][][]
{ new int[][] { new int[] {1,1,1,0}, new int[] {1,1,1,0} },
new int[][] { new int[] {0,0,1,1}, new int[] {1,0,0,1} }};
int[] init1 = new int[] {0,0,1};
int[] goal1 = new int[] {0,1,2};
int[] init2 = new int[] {1,0,1};
int[] goal2 = new int[] {0,1,3};
Vector inits = new Vector();
Vector goals = new Vector();
inits.addElement(init1); inits.addElement(init2);
goals.addElement(goal1); goals.addElement(goal2);
MazeWorld world = new MazeWorld(maze,inits,goals);
SequentialPlanner testPlanner = new SequentialPlanner(world,textArea);
Vector thePlan;
thePlan = testPlanner.SequentialPlan(inits, goals, 9);
if (thePlan != null) testPlanner.printPlan(thePlan);
// textArea1.append(plan+"\n");
}
public PlanTester()
{
// This code is automatically generated by Visual Cafe when you add
// components to the visual environment. It instantiates and initializes
// the components. To modify the code, only use code syntax that matches
// what Visual Cafe can generate, or Visual Cafe may be unable to back
// parse your Java file into its visual environment.
//{{INIT_CONTROLS
setLayout(null);
setVisible(false);
setSize(insets().left + insets().right + 652,insets().top + insets().bottom + 269);
textArea = new java.awt.TextArea();
textArea.setBounds(insets().left + 0,insets().top + 0,653,271);
add(textArea);
setTitle("Sample Planner!");
//}}
this.setVisible(true);
planTest();
//{{INIT_MENUS
//}}
//{{REGISTER_LISTENERS
SymWindow aSymWindow = new SymWindow();
this.addWindowListener(aSymWindow);
SymMouse aSymMouse = new SymMouse();
//}}
}
public PlanTester(String title)
{
this();
setTitle(title);
}
public synchronized void show()
{
move(50, 50);
super.show();
}
public void addNotify()
{
// Record the size of the window prior to calling parents addNotify.
Dimension d = getSize();
super.addNotify();
if (fComponentsAdjusted)
return;
// Adjust components according to the insets
setSize(insets().left + insets().right + d.width, insets().top + insets().bottom + d.height);
Component components[] = getComponents();
for (int i = 0; i < components.length; i++)
{
Point p = components[i].getLocation();
p.translate(insets().left, insets().top);
components[i].setLocation(p);
}
fComponentsAdjusted = true;
}
// Used for addNotify check.
boolean fComponentsAdjusted = false;
//{{DECLARE_CONTROLS
java.awt.TextArea textArea;
//}}
//{{DECLARE_MENUS
//}}
class SymWindow extends java.awt.event.WindowAdapter
{
public void windowClosing(java.awt.event.WindowEvent event)
{
Object object = event.getSource();
if (object == PlanTester.this)
Frame1_WindowClosing(event);
}
}
void Frame1_WindowClosing(java.awt.event.WindowEvent event)
{
hide(); // hide the Frame
}
class SymMouse extends java.awt.event.MouseAdapter
{
public void mouseClicked(java.awt.event.MouseEvent event)
{
Object object = event.getSource();
}
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -