--- /dev/null
+/*\r * Copyright (c) 2006 Stanford University.\r * All rights reserved.\r *\r * Redistribution and use in source and binary forms, with or without\r * modification, are permitted provided that the following conditions\r * are met:\r * - Redistributions of source code must retain the above copyright\r * notice, this list of conditions and the following disclaimer.\r * - Redistributions in binary form must reproduce the above copyright\r * notice, this list of conditions and the following disclaimer in the\r * documentation and/or other materials provided with the\r * distribution.\r * - Neither the name of the Stanford University nor the names of\r * its contributors may be used to endorse or promote products derived\r * from this software without specific prior written permission.\r *\r * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STANFORD\r * UNIVERSITY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\r * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\r * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\r * OF THE POSSIBILITY OF SUCH DAMAGE.\r */\r\rpackage net.tinyos.mviz;\r\rimport java.awt.*;\r\r\rpublic class DMote\rextends DShape \rimplements DMoteModelListener\r{\r \r private DDocument document;\r private DMoteModel model;\r \r public DMote(DMoteModel model, DDocument document, DLayer layer) {\r super(model, document, layer);\r this.document = document;\r this.model = model;\r }\r \r\r static int counter =0;\r public void paintShape(Graphics g) {\r int x = model.getLocX();\r int y = model.getLocY();\r //System.out.println("Mode " + layer.paintMode);\r switch(layer.paintMode){\r case DLayer.IMG:\r Image img = model.getImage();\r java.awt.MediaTracker tracker = new java.awt.MediaTracker(this);\r tracker.addImage(img, 0);\r if (document.selected == model) {\r g.setColor(Color.RED);\r g.fillOval(x-22, y-22, 44, 44);\r }\r g.drawImage(img, x-20, y-20, 40, 40, document.canvas);\r try {tracker.waitForAll();}\r catch(InterruptedException e){} \r //System.out.println("Draw image " + img + " " + x + " " + y + " " + img.getHeight(document.canvas) + " " + tracker.isErrorAny());\r\r //img = model.getIcon().getImage();\r //System.out.println("Draw image " + img + " " + x + " " + y);\r //document.canvas.getGraphics().drawImage(img, x, y, this.model.root);\r break;\r case DLayer.OVAL:\r if (document.selected != model) {\r g.setColor(Color.GRAY);\r }\r else {\r g.setColor(Color.RED);\r }\r counter++;\r g.fillOval(x-20, y-20, 40, 40);\r break;\r case DLayer.TXT_MOTE:\r g.setFont(new Font("Helvetica", Font.PLAIN, 8));\r g.setColor(Color.BLACK);\r g.drawString(document.sensed_motes.elementAt(layer.index) + ": " + (int)model.getValue(layer.index), x+22, y-2);\r break;\r default:\r }\r\r }\r\r}\r\r\r
\ No newline at end of file