📄 chessmover.java
字号:
/*------------------------------------------------------------------------------Name: ChessMover.javaProject: xmlBlaster.orgCopyright: xmlBlaster.org, see xmlBlaster-LICENSE fileComment: The demo class which moves around the chess peacesVersion: $Id: ChessMover.java 13299 2005-03-24 10:58:29Z ruff $------------------------------------------------------------------------------*/package javaclients.svg.rhino;import org.xmlBlaster.util.XmlBlasterException;import org.xmlBlaster.client.I_XmlBlasterAccess;import org.xmlBlaster.util.Global;import org.xmlBlaster.client.qos.ConnectQos;import org.xmlBlaster.util.MsgUnit;import java.util.Random;/* This is a simple demo client which moves around the chess pieces used in chessRhino.svg. It has been tested with batik 1.5 but it should even work with Mozilla.*/public class ChessMover{ private static final String ME = "ChessMover"; protected I_XmlBlasterAccess connection = null; private Random random = null; private long sleepTime = 0L; public ChessMover (String[] args) throws XmlBlasterException { Global glob = new Global(args); sleepTime = Long.parseLong(args[1]); random = new Random(100L); this.connection = glob.getXmlBlasterAccess(); ConnectQos connectQos = new ConnectQos(glob, "chessMover", "secret"); this.connection.connect(connectQos, null); } public void publish () throws XmlBlasterException { int id = random.nextInt(32); int x = random.nextInt(450); int y = random.nextInt(450); String key = "<?xml version='1.0'?><key oid='" + id + "'><chess>some chess name</chess></key>"; String qos = "<qos></qos>"; String transform = "translate(" + x + "," + y + ")"; String content = "<chess><id>" + id + "A</id><transform>" + transform + "</transform></chess>"; MsgUnit msg = new MsgUnit(key, content.getBytes(), qos); this.connection.publish(msg); try { Thread.sleep(this.sleepTime); } catch (Exception ex) {} } public static void main (String[] args) { try { ChessMover mover = new ChessMover(args); while (true) { mover.publish(); } } catch (Exception ex) { System.err.println(ex.toString()); System.err.println("usage: java javaclients.svg.rhino.ChessMover -interval updateInterval"); System.err.println("where updateInterval is the time in ms between each move"); System.exit(1); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -