1 package demo.notification.whiteboard; 2 3 import java.util.Iterator ; 4 import java.util.List ; 5 6 import org.omg.CORBA.ORB ; 7 import org.omg.CosEventComm.Disconnected; 8 import org.omg.CosNotification.StructuredEvent; 9 import org.omg.CosNotifyChannelAdmin.StructuredProxyPushConsumer; 10 11 15 16 public class ExtendedPixelImage extends BrushSizePixelImage implements WhiteboardVars { 17 18 StructuredProxyPushConsumer myConsumer_; 19 StructuredEvent event_; 20 ORB orb_; 21 22 public void setPixels(int[] pixels) { 23 for (int x=0; x<m_pixels.length;x++) 24 m_pixels[x] = pixels[x]; 25 } 26 27 public ExtendedPixelImage(int w, int h) { 28 super(w,h); 29 } 30 31 public void setOrb(ORB orb) { 32 orb_ = orb; 33 } 34 35 public void setEvent(StructuredEvent event) { 36 event_ = event; 37 } 38 39 synchronized public void clearAll() { 41 WhiteboardUpdate _update = new WhiteboardUpdate(); 42 _update.clear(true); 43 super.clearAll(); 44 } 45 46 public void localClearAll() { 48 super.clearAll(); 49 } 50 51 synchronized public void drawLine(int x0, 55 int y0, 56 int x1, 57 int y1, 58 int red, 59 int green, 60 int blue, 61 int brushSize) { 62 int x = getBrushSize(); 63 setBrushSize(brushSize); 64 super.drawLine(x0,y0,x1,y1,red,green,blue); 65 setBrushSize(x); 66 } 67 68 synchronized public void drawLine(int x0, 71 int y0, 72 int x1, 73 int y1, 74 int red, 75 int green, 76 int blue) { 77 78 WhiteboardUpdate _update = new WhiteboardUpdate(); 79 80 super.drawLine(x0,y0,x1,y1,red,green,blue); 81 _update.line(new LineData(x0, y0, x1, y1, red, green, blue, getBrushSize())); 82 83 try { 84 if (myConsumer_ != null) { 85 WhiteboardUpdateHelper.insert(event_.remainder_of_body, _update); 86 myConsumer_.push_structured_event(event_); 87 } 88 } catch (Disconnected d) { 89 d.printStackTrace(); 90 myConsumer_ = null; 91 } 92 } 93 94 synchronized public void drawLine(UpdateLine ul, boolean v) { 98 drawLine(ul); 99 } 101 102 void drawLine(UpdateLine ul) { 104 if ( !ul.clearScreen() ) 105 drawLine( ul.getX0(), 106 ul.getY0(), 107 ul.getX1(), 108 ul.getY1(), 109 ul.getRed(), 110 ul.getGreen(), 111 ul.getBlue(), 112 ul.getBrushSize() ); 113 else 114 super.clearAll(); 115 } 116 117 public void drawLine(List uls) { 119 Iterator i = uls.iterator(); 120 while (i.hasNext()) { 121 drawLine((UpdateLine)i.next() ); 122 } 123 } 124 } 125 | Popular Tags |