Inheritance diagram for SegmentGraphicsPanel::
Public Methods | |
SegmentGraphicsPanel (FrameNavigatorUser u, int imWidth, int imHeight) | |
void | setNumberOfFrames (int maxFrame) |
void | setUser (FrameNavigatorUser u) |
void | setShowGrid (boolean show) |
void | paint (Graphics g) |
void | clearImage () |
void | updateSegs (HxCorba.VxSegmentationOperations seg, String name, Color col) |
void | setCurrentFrame (int frameNr) |
void | updateSegs (HxCorba.VxTimeSpan[] times, String name, Color col) |
Protected Methods | |
void | paintComponent (Graphics g) |
|
00024 { 00025 _initialWidth = imWidth; 00026 //_imHeight = imHeight; 00027 addMouseListener(new JumpMouseListener()); 00028 addMouseMotionListener(new GridMouseListener()); 00029 00030 //_image = new BufferedImage(imWidth, imHeight, BufferedImage.TYPE_INT_RGB); 00031 00032 _curFrame = 0; 00033 _user = u; 00034 _fScale = 1.0; 00035 _maxFrame = _initialWidth; 00036 00037 clearImage(); 00038 } |
|
Reimplemented from FrameNavigator.
00041 { 00042 _maxFrame = maxFrame; 00043 _fScale = (double) _initialWidth / maxFrame; 00044 00045 clearImage(); 00046 } |
|
Reimplemented from FrameNavigator.
00049 { 00050 _user = u; 00051 } |
|
00054 { 00055 _showGrid = show; 00056 repaint(); 00057 } |
|
00060 { 00061 Dimension d = getSize(); 00062 g.setColor(Color.white); 00063 g.fillRect(0, 0, d.width, d.height); 00064 00065 if(_showGrid) { 00066 g.setColor(Color.lightGray); 00067 g.drawImage(_gridImage, 0, 5, null); 00068 for(int x=0; x < d.width; x+= _gridWidth) 00069 g.drawLine(x, 0, x, d.height); 00070 } 00071 00072 int fr = (int) (_fScale * _curFrame); 00073 g.setColor(Color.green); 00074 g.drawLine(fr, 0, fr, d.height); 00075 } |
|
00078 { 00079 super.paint(g); 00080 00081 if(_dragPos > 0) { 00082 g.setColor(Color.gray); 00083 g.drawLine(_dragPos, 0, _dragPos, getSize().height); 00084 g.drawString(""+(_dragGrid * _gridStep), _dragPos+5, 10+5); 00085 } 00086 } |
|
00089 { 00090 //Graphics2D imGraphics = _image.createGraphics(); 00091 //imGraphics.setColor(Color.white); 00092 //imGraphics.fillRect(0, 0, _initialWidth, _imHeight); 00093 00094 removeAll(); 00095 00096 int width = (int)(_maxFrame * _fScale); 00097 _segOffset = INITIAL_OFFSET; 00098 setPreferredSize(new Dimension(width, _segOffset)); 00099 revalidate(); 00100 00101 _gridStep = closestNiceNum((int)(GRID_DISTANCE / _fScale)); 00102 _gridWidth = (int)(_gridStep * _fScale); 00103 00104 if(width < getSize().width) width = getSize().width; 00105 00106 _gridImage = makeBufferedImage(width, SEG_HEIGHT); 00107 Graphics2D imGraphics = _gridImage.createGraphics(); 00108 imGraphics.setColor(Color.lightGray); 00109 int label = 0; 00110 for(int x=0; x<width; x+=_gridWidth, label += _gridStep) 00111 imGraphics.drawString(""+label, x+5, 10); 00112 00113 repaint(); 00114 } |
|
00131 { 00132 updateSegs(seg.getTimeSpans(), name, col); 00133 } |
|
Reimplemented from FrameNavigator.
00136 { 00137 _curFrame = frameNr; 00138 // make sure curFrame is visible 00139 int sf = (int) (_fScale * _curFrame); 00140 JViewport viewport = (JViewport)getParent(); 00141 Rectangle r = viewport.getViewRect(); 00142 if ((sf < r.x) || (sf > r.x + r.width)) { 00143 sf = sf - 10; 00144 if (sf < 0) 00145 sf = 0; 00146 viewport.setViewPosition(new Point(sf, 0)); 00147 } 00148 00149 repaint(); 00150 } |
|
00246 { 00247 int width = (int)(_maxFrame * _fScale); 00248 00249 JComponent component; 00250 00251 try { 00252 BufferedImage im = makeBufferedImage(width, SEG_HEIGHT+1); 00253 Graphics2D imGraphics = im.createGraphics(); 00254 imGraphics.setColor(col); 00255 for (int i=0; i<times.length; i++) { 00256 int x = times[i].start; 00257 int w = times[i].end - x; 00258 double sx = _fScale * x; 00259 double sw = _fScale * w; 00260 Shape shp = new java.awt.geom.Rectangle2D.Double(sx, 0, sw, SEG_HEIGHT); 00261 imGraphics.draw(shp); 00262 } 00263 00264 component = makeImageComponent(im); 00265 } 00266 catch(OutOfMemoryError err) { // image too big 00267 component = new JLabel(" OutOfMemoryError!"); 00268 component.setSize(component.getPreferredSize()); 00269 component.setForeground(col); 00270 } 00271 00272 component.setLocation(0, _segOffset); 00273 component.setToolTipText(name); 00274 component.putClientProperty(TIMES_PROP, times); 00275 component.putClientProperty(COLOR_PROP, col); 00276 add(component); 00277 00278 _segOffset += SEG_HEIGHT + SEG_DISTANCE; 00279 setPreferredSize(new Dimension(width, _segOffset)); 00280 revalidate(); 00281 repaint(); 00282 } |