📄 remotemonitorcontrol.java
字号:
/** no hardware to obtain so we just setup the monitor */ if(this.getFormatSize () != null) { monitorComponent = new RemoteMonitorCanvas(this.getFormatSize ()); }else{ if (LOG.isEnabledFor (Level.INFO)) { LOG.info("Cannot instantiate RemoteMonitor - Format size is NULL."); } } if (LOG.isEnabledFor (Level.INFO)) { LOG.info ("obtainHardware"); } } public void releaseHardware() { /** no real hardware to release*/ if(monitorComponent != null) { monitorComponent = null; } if(incomingBuffer != null) { incomingBuffer.clear (); incomingBuffer = null; } if (LOG.isEnabledFor (Level.INFO)) { LOG.info ("releaseMonitor"); } } public void stopMonitor() { this.setMonitorState(this.STOPPED); if (LOG.isEnabledFor (Level.INFO)) { LOG.info ("stopMonitor"); } } protected void displayImage() { getMonitorComponent().newImage((ByteArrayInputStream)incomingBuffer.getFirst ()); incomingBuffer.removeFirst (); } public void pauseMonitor() { this.setMonitorState(this.PAUSED); } public void resumeMonitor() { this.setMonitorState(this.STARTED); } public void setReceiveState(int receiveState) { this.receiveState = receiveState; } public int getReceiveState() { return this.receiveState; } private int getMonitorState () { return this.monitorState; } private void setMonitorState (int monitorState) { this.monitorState = monitorState; } public int getImagesPerMessage () { return this.imagesPerMessage; } public int getImageCompression () { return imageCompression; } /** * Sets the human readable name of the remote peer */ protected void setOriginator (String originator) { this.originator = originator; } /** * Gets the human readable name of the remote peer */ public String getOriginator () { return this.originator; } public int getBufferSize() { if( incomingBuffer != null) { return incomingBuffer.size (); } return 0; } public long getTimeOfLastMessage () { return this.timeOfLastMessage; } public RemoteMonitorCanvas getMonitorComponent() { return this.monitorComponent; } /** * Accessor for incoming speex buffer size */ /** * statistical accessor */ public long getMessagesReceived () { return this.messagesReceived; } /** * statistical accessor */ public long getBytesReceived () { return this.bytesReceived; } /** * statistical accessor */ public long getAverageImageDecodeTime () { return this.averageImageDecodeTime; } /** * statistical accessor */ public long getImageDecodeTime () { return this.imageDecodeTime; } public int getImageSize() { return this.imageSize; } public int averageImageSize() { return this.averageImageSize; } /** * statistical accessor */ private void setEncodedMessageSize (int imagesPerMessage) { this.imagesPerMessage = imagesPerMessage; } public Dimension getFormatSize() { return this.formatSize != null ? formatSize : new Dimension(0,0); } public void setFormatSize(Dimension formatSize) { if(formatSize != null) { this.formatSize = formatSize; }else{ this.formatSize = new Dimension(0,0); } } public void setFormatType(String formatType) { if(formatType!=null) { this.formatType = formatType; }else{ this.formatType = this.UNKNOWN_MIME_TYPE; } } public String getFormatType() { return this.formatType!=null ? this.formatType : this.UNKNOWN_MIME_TYPE; } public long getImageDrawTime() { return this.imageDrawTime; } public long getAverageImageDrawTime() { return this.averageImageDrawTime; } public boolean isReceive() { return this.receive; } public void setReceive(boolean receive) { if (LOG.isEnabledFor (Level.INFO)) { LOG.info("setReceive "+receive); } this.receive = receive; } public void setImageCompression(int imageCompression) { this.imageCompression = imageCompression; } private ViJxtaCallControl getCallControl() { return this.viJxtaCallControl; } class MyLock extends Object { private boolean locked = true; public boolean isLocked() { return this.locked; } public void setLocked(boolean locked) { this.locked = locked; } } class RemoteMonitorCanvas extends JComponent {//Canvas { private Dimension size = null; private ImageReader reader = null; private Image image ; public RemoteMonitorCanvas (Dimension size) { super (); this.size = size; Iterator readers = ImageIO.getImageReadersByFormatName ("jpeg"); reader = (ImageReader)readers.next (); } public Dimension getPreferredSize () { if(size == null) { size = new Dimension(0,0); } return size; } public void paintComponent (Graphics g) { //super.paintComponent (g); Graphics2D g2 = (Graphics2D) g; g2.drawImage (image,0,0,null); g2.dispose(); } public void newImage (ByteArrayInputStream encodedImageStream) { try { long in = System.currentTimeMillis (); // this is just a impl of ImageInputStreamImpl.. we can subclass // later and make our own MemoryCacheImageInputStream imageStream = new MemoryCacheImageInputStream(encodedImageStream); reader.setInput (imageStream); BufferedImage bufferedImage = reader.read (0); long out = System.currentTimeMillis (); imageDecodeTime = out - in; in = System.currentTimeMillis (); // Copy image to buffered image. image = bufferedImage; //maybe image update???? //imageUpdate(image,0,0,0, image.getWidth(null),image.getHeight(null)); // paintComponent(this.getGraphics()); repaint(); /* Graphics g = this.getGraphics (); //g.setColor(Color.white); //g.fillRect(0, 0, image.getWidth(null), //image.getHeight(null)); g.drawImage (bufferedImage, 0, 0, null); g.dispose (); **/ out = System.currentTimeMillis (); imageDrawTime = out - in; }catch(Exception x) { x.printStackTrace (); } } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -