10 package com.generalrobotix.ui.view.vsensor;
13 import java.awt.Canvas;
14 import java.awt.FlowLayout;
15 import java.awt.Graphics;
16 import java.awt.Image;
17 import java.awt.image.ColorModel;
18 import java.awt.image.MemoryImageSource;
21 import javax.swing.JFrame;
31 @SuppressWarnings(
"serial")
37 private boolean updated_ =
false;
48 canvas_ =
new CanvasDraw (
52 canvas_.setSize(width, height);
53 canvas_.setBackground(java.awt.Color.white);
55 getContentPane().setLayout(
new FlowLayout());
56 getContentPane().add(canvas_);
67 canvas_.setColorBuffer(colorBuffer);
78 @SuppressWarnings(
"serial")
79 final class CanvasDraw
extends Canvas {
84 private MemoryImageSource mis_;
87 private ColorModel cm_ = ColorModel.getRGBdefault();
90 private int[] colorBuffer_;
101 public CanvasDraw(java.awt.GraphicsConfiguration gconfig,
int width,
int height) {
108 mis_ =
new MemoryImageSource (
121 public void setColorBuffer(
int[] colorBuffer) {
122 colorBuffer_ = colorBuffer;
123 mis_.newPixels(colorBuffer, cm_, 0, width_);
130 public void update(Graphics g) {
141 public void paint(Graphics g) {
146 if (colorBuffer_ ==
null)
150 img_ = createImage(mis_);
151 g.drawImage(img_, 0, 0,
this);
#define null
our own NULL pointer
ColorBufferBrowser(int width, int height, String title)
static final GraphicsConfiguration graphicsConfiguration
png_infop png_uint_32 * width
png_infop png_uint_32 png_uint_32 * height
void setColorBuffer(int[] colorBuffer)