Mercurial > hg > Applications > AliceVNC
view src/main/java/jp/ac/u_ryukyu/alicevnc/ReceiveUpdateRectangle.java @ 12:66c06ebbced1
refactor
author | YU |
---|---|
date | Tue, 23 Sep 2014 16:13:23 +0900 |
parents | aff2d0bb9c50 |
children | f4ecd1f01f0b |
line wrap: on
line source
package jp.ac.u_ryukyu.alicevnc; import java.util.ArrayList; import com.glavsoft.exceptions.TransportException; import com.glavsoft.rfb.encoding.EncodingType; import com.glavsoft.rfb.encoding.decoder.AliceVNCMessage; import com.glavsoft.rfb.encoding.decoder.FramebufferUpdateRectangle; import com.glavsoft.rfb.encoding.decoder.RichCursorDecoder; import com.glavsoft.rfb.encoding.decoder.ZRLEDecoder; import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; public class ReceiveUpdateRectangle extends CodeSegment{ private Receiver info = ids.create(CommandType.PEEK); private Receiver info1 = ids.create(CommandType.TAKE); private Receiver info2 = ids.create(CommandType.PEEK); public ReceiveUpdateRectangle(){ info.setKey("Holder"); info1.setKey("aliceVNCMessage"); info2.setKey("_CLIST"); } @Override public void run() { try { RenderAndControllerHolder holder = info.asClass(RenderAndControllerHolder.class); AliceVNCMessage message = info1.asClass(AliceVNCMessage.class); if (message.getEncodingType() == EncodingType.ZRLE){ ZRLEDecoder decoder = new ZRLEDecoder(); FramebufferUpdateRectangle rect = new FramebufferUpdateRectangle( message.x, message.y, message.width, message.height); rect.encodingType = message.getEncodingType(); byte[] buf = message.buf; int offset = message.offset; decoder.setColorDataOnRenderer(holder.getRenderer(), rect, buf, offset); holder.getRepaintController().repaintBitmap(rect); } else if (message.getEncodingType() == EncodingType.DESKTOP_SIZE) { holder.setRenderer( holder.getRepaintController().createRenderer(null ,message.width, message.height, message.getPixelFormat()) ); } else if (message.getEncodingType() == EncodingType.RICH_CURSOR) { RichCursorDecoder.getInstance().decode(holder.getRenderer(), message); holder.getRepaintController().repaintCursor(); } @SuppressWarnings("unchecked") ArrayList<String> clist = info2.asClass(ArrayList.class); for (String node : clist){ if (!"parent".equals(node)) ods.put(node, "aliceVNCMessage", info1.getVal()); } this.recycle(); } catch (TransportException e) { e.printStackTrace(); } } }