示例#1
0
 protected void paintComponent(Graphics g) {
   Dimension size = this.getSize();
   int x = 0;
   int y = 0;
   g.setColor(new Color((int) seq1, (int) seq2, (int) seq3));
   g.fillRect(x, y, size.width, size.height);
 }
示例#2
0
 /**
  * Adds pixel to queue and calls repaint() whenever we have MAX_ITEMS pixels in the queue or
  * when MAX_TIME msecs have elapsed (whichever comes first). The advantage compared to just
  * calling repaint() after adding a pixel to the queue is that repaint() can most often draw
  * multiple points at the same time.
  */
 public void drawPoint(DrawCommand c) {
   if (c == null || gr == null) return;
   Color col = new Color(c.rgb);
   gr.setColor(col);
   gr.fillOval(c.x, c.y, 10, 10);
   repaint();
   if (state != null) {
     synchronized (state) {
       state.put(new Point(c.x, c.y), col);
     }
   }
 }
示例#3
0
 /** Draw the entire panel from the state */
 @SuppressWarnings("rawtypes")
 public void drawState() {
   // clear();
   Map.Entry entry;
   Point pt;
   Color col;
   synchronized (state) {
     for (Iterator it = state.entrySet().iterator(); it.hasNext(); ) {
       entry = (Map.Entry) it.next();
       pt = (Point) entry.getKey();
       col = (Color) entry.getValue();
       gr.setColor(col);
       gr.fillOval(pt.x, pt.y, 10, 10);
     }
   }
   repaint();
 }
示例#4
0
 /** Clear all contents */
 public void clear() {
   if (gr == null) return;
   gr.clearRect(0, 0, getSize().width, getSize().height);
   repaint();
   if (state != null) {
     synchronized (state) {
       state.clear();
     }
   }
 }
示例#5
0
 public void paintComponent(Graphics g) {
   super.paintComponent(g);
   if (img != null) {
     g.drawImage(img, 0, 0, null);
   }
 }