JInternalFrame中的动态影像

时间:2015-12-24 17:20:19

标签: java swing

我正在写一个应用程序显示火车运动的地图。地图本身使用库class GS1128 < Code128 def initialize(data, type, ai) self.application_identifier = ai super(data, type) end ... end JGrpahx上添加组件计数来显示图表。这是这个框架的代码:

JInternalFrame

现在想在图形的边缘制作火车动画,我了解到动画电影只能通过public static mxGraph graph = new mxGraph(); public static Object parent = graph.getDefaultParent(); private static boolean shown = false; public TrainMapView() { super("Train Map", true, //resizable true, //closable true, //maximizable true);//iconifiable mxGraphComponent graphComponent = new mxGraphComponent(graph); graphComponent.setEnabled(false); getContentPane().add(graphComponent); TrainMoveAnimation trainMoveAnimation = new TrainMoveAnimation(); trainMoveAnimation.start(); // getContentPane().add(trainMoveAnimation); setSize(500, 500); setVisible(true); //necessary as of 1.3 shown=true; } public static boolean isShown() { return shown; } public Object addVertex(String name, int x, int y) { return graph.insertVertex(parent, null, name, x, y, 20, 20, "shape=and"); } public void addEdge(int price, Object obj1, Object obj2) { graph.insertEdge(parent, null, ""+price, obj1, obj2); graph.insertEdge(parent, null, "", obj2, obj1); } @Override public void doDefaultCloseAction() { shown=false; super.doDefaultCloseAction(); } public TrainMapView update(){ graph = new mxGraph(); parent = graph.getDefaultParent(); TrainMapView mapView = new TrainMapView(); List<Object> vertexes = new ArrayList<>(TrainMap.getAllStations().size()); for (Station station: TrainMap.getAllStations()){ vertexes.add(addVertex(station.getTitle(),station.getX(),station.getY())); System.out.println(station.getTitle()); } for (int i = 0; i < 256; i++) { for (int j = i+1; j < 256; j++) { if (TrainMap.getMatrix()[i][j]>0){ addEdge(TrainMap.getMatrix()[i][j],vertexes.get(i),vertexes.get(j)); //addEdge(vertexes.get(j),vertexes.get(i)); } } } return mapView; } 完成。 创建了实现动画的JPanel,但我现在无法理解我如何与面板框架结合,因为如果我只是添加到框架,面板将覆盖图形。

以下是代码窗格:

JPanel

0 个答案:

没有答案