Horus Doc || Java GUI Reference || Doxygen's quick Index  

IcsCanvas Class Reference

The root of the canvas hierarchy. More...

Inheritance diagram for IcsCanvas::

LayeredCanvas VisCanvas ActiveCanvas ScribbleCanvas ThumbnailCanvas List of all members.

Public Methods

Dimension getDimensionICS ()
 Get the dimension of the canvas in ICS (the unzoomed canvas). More...

void setDimensionICS (Dimension d)
 Set the dimension of the canvas in ICS (the unzoomed canvas). More...

Dimension getDimensionCCS ()
 Get the dimension of the canvas in CCS (the zoomed canvas). More...

void setDimensionCCS (Dimension d)
 Set the dimension of the canvas in CCS (the zoomed canvas). More...

Dimension getObjectExtent ()
 Get the extent of all objects on the canvas. More...

void setObjectExtent (Dimension d)
 Set the extent of all objects on the canvas. More...

Dimension getViewportSize ()
 Get the dimension of the viewport. More...

void checkViewportSize (Dimension d)
 This function will be called by the scrollpane upon change events. More...

Dimension getMinimumSize ()
 Overrides Component interface. More...

Dimension getPreferredSize ()
 Overrides JComponent interface. More...

int getID ()
double getZoomFactor ()
void setZoomFactor (double zoomFactor)
Color getBackgroundColor ()
void setBackgroundColor (Color c)
Color getDefaultDrawColor ()
void setDefaultDrawColor (Color color)
void setUser (IcsCanvasUser user)
void drawBackground ()
 Draw the background color on the entire canvas. More...

void zoom (double zoomVal)
 Zoom to the given value. More...

void doPaintComponent (Graphics bufGraphics)
 Paint the component in the given graphics. More...

void handleMousePress (MouseEvent e)
 Interface for MouseListener events, called by LayeredCanvasPane. More...

void handleMouseEnter (MouseEvent e)
void handleMouseExit (MouseEvent e)
void handleMouseClick (MouseEvent e)
void handleMouseRelease (MouseEvent e)
void handleMouseMove (MouseEvent e)
 Interface for MouseMotionListener events, called by LayeredCanvasPane. More...

void handleMouseDrag (MouseEvent e)

Static Public Attributes

final Color STD_BCOLOR = Color.white
final Color STD_DCOLOR = Color.red
final int MIN_SIZE = 3
final int EXT_MARGIN = 0
final double STD_ZOOM = 1.0f
boolean DEBUG_LAYOUT = false
boolean DEBUG_EVENTS = false

Protected Methods

void dump ()

Detailed Description

The root of the canvas hierarchy.

IcsCanvas takes care of the sizing of all canvas specializations. It also "communicates" the screen size to "Swing", typically in conjunction with LayeredCanvasPane. For IcsCanvas, this is done typically via getPreferredSize, handleSetSize, and setSize.

The "size" of a canvas has many interpretations that should all be kept in sync: _dimICS : the size of the canvas in the Image Coordinate System (ICS) _dimCCS : the size of the canvas in the Canvas Coordinate System (CCS) _objectExtent : the extent of all objects on the canvas (in ICS) _viewportSize : the size of the viewport on the screen (in CCS)

Upon construction, a canvas may have a default size in ICS. Also, the size may declared to be fixed. The ICS dimension of a fixed size canvas will not change during its lifetime. This is typically used for thumbnails.

The following rules define the sizing behaviour of the canvas:


Member Function Documentation

Dimension IcsCanvas::getDimensionICS   [inline]
 

Get the dimension of the canvas in ICS (the unzoomed canvas).

00107 {
00108 if (DEBUG_LAYOUT)
00109 OutputStreamArea.println("getDimensionICS (" + _id + "): " + _dimICS);
00110     return new Dimension(_dimICS);
00111 }

void IcsCanvas::setDimensionICS Dimension    d [inline]
 

Set the dimension of the canvas in ICS (the unzoomed canvas).

Actually, the "set" may not succeed at all (e.g. if the canvas is fixed) or only partially. In any case, the CCS will be adjusted accordingly. Also calls super.setSize to inform Java of changes.

00121 {
00122 if (DEBUG_LAYOUT)
00123 OutputStreamArea.println("setDimensionICS (" + _id + "): " + d);
00124     if (_fixedSize)
00125         return;
00126 
00127     // do not shrink beyond the extent of the objects on the canvases
00128     // in the LayeredCanvasPane or the requested dimension
00129 
00130     int reqWidth = Math.max(_objectExtent.width, d.width);
00131     int reqHeight = Math.max(_objectExtent.height, d.height);
00132     if (_user != null) { // check other canvas extents
00133         Dimension oExt = _user.getMaxObjectExtent();
00134         reqWidth = Math.max(reqWidth, oExt.width);
00135         reqHeight = Math.max(reqHeight, oExt.height);
00136     }
00137 
00138     // may only grow if the viewport is larger than the required dimension
00139 
00140     Dimension vSize = Converter.CCStoICS(_viewportSize, _zoomFactor);
00141     reqWidth = Math.max(reqWidth, vSize.width);
00142     reqHeight = Math.max(reqHeight, vSize.height);
00143 
00144     _dimICS = new Dimension(reqWidth, reqHeight);
00145 if (DEBUG_LAYOUT)
00146 OutputStreamArea.println("               : setting to       " + _dimICS);
00147     _dimCCS = Converter.ICStoCCS(_dimICS, _zoomFactor);
00148     super.setSize(new Dimension(_dimCCS));
00149     if (_user != null)
00150         _user.handleSetSize(_dimCCS);
00151 }

Dimension IcsCanvas::getDimensionCCS   [inline]
 

Get the dimension of the canvas in CCS (the zoomed canvas).

00157 {
00158 if (DEBUG_LAYOUT)
00159 OutputStreamArea.println("getDimensionCCS called (" + _id + "): " + _dimCCS);
00160     return new Dimension(_dimCCS);
00161 }

void IcsCanvas::setDimensionCCS Dimension    d [inline]
 

Set the dimension of the canvas in CCS (the zoomed canvas).

Is done via setDimensionICS.

00168 {
00169 if (DEBUG_LAYOUT)
00170 OutputStreamArea.println("setDimensionCCS called (" + _id + "): " + d);
00171     setDimensionICS(Converter.CCStoICS(d, _zoomFactor));
00172 }

Dimension IcsCanvas::getObjectExtent   [inline]
 

Get the extent of all objects on the canvas.

00178 {
00179     return new Dimension(_objectExtent);
00180 }

void IcsCanvas::setObjectExtent Dimension    d [inline]
 

Set the extent of all objects on the canvas.

Also does a setDimensionICS to update the size of the canvas.

00187 {
00188     _objectExtent = new Dimension(d);
00189     setDimensionICS(d);
00190 }

Dimension IcsCanvas::getViewportSize   [inline]
 

Get the dimension of the viewport.

00196 {
00197 if (DEBUG_LAYOUT)
00198 OutputStreamArea.println("getViewportSize called (" + _id + "): " + _viewportSize);
00199     return new Dimension(_viewportSize);
00200 }

void IcsCanvas::checkViewportSize Dimension    d [inline]
 

This function will be called by the scrollpane upon change events.

Also updates the size of the canvas via setDimensionICS.

00207 {
00208     if ((d.width != _viewportSize.width) ||
00209                                     (d.height != _viewportSize.height)) {
00210 if (DEBUG_LAYOUT)
00211 OutputStreamArea.println("checkViewportSize called (" + _id + "): " + d);
00212         _viewportSize = new Dimension(d);
00213         setDimensionICS(Converter.CCStoICS(d, _zoomFactor));
00214     }
00215 }

Dimension IcsCanvas::getMinimumSize   [inline]
 

Overrides Component interface.

00221 {
00222 if (DEBUG_LAYOUT)
00223 OutputStreamArea.println("getMinimumSize called (" + _id + "): ");
00224     return new Dimension(MIN_SIZE, MIN_SIZE);
00225 }

Dimension IcsCanvas::getPreferredSize   [inline]
 

Overrides JComponent interface.

Returns the object extent.

00231 {
00232 if (DEBUG_LAYOUT)
00233 OutputStreamArea.println("getPreferredSize called (" + _id + "): " +
00234                      Converter.ICStoCCS(_objectExtent, _zoomFactor));
00235     return Converter.ICStoCCS(_objectExtent, _zoomFactor);
00236 }

int IcsCanvas::getID   [inline]
 

00240 {
00241     return _id;
00242 }

double IcsCanvas::getZoomFactor   [inline]
 

00246 {
00247     return _zoomFactor;
00248 }

void IcsCanvas::setZoomFactor double    zoomFactor [inline]
 

00252 {
00253     _zoomFactor = zoomFactor;
00254 }

Color IcsCanvas::getBackgroundColor   [inline]
 

00258 {
00259     return _backgroundColor;
00260 }

void IcsCanvas::setBackgroundColor Color    c [inline]
 

00264 {
00265     _backgroundColor = c;
00266 }

Color IcsCanvas::getDefaultDrawColor   [inline]
 

00270 {
00271     return _drawColor;
00272 }

void IcsCanvas::setDefaultDrawColor Color    color [inline]
 

00276 {
00277     _drawColor = color;
00278 }

void IcsCanvas::setUser IcsCanvasUser    user [inline]
 

00282 {
00283     _user = user;
00284 }

void IcsCanvas::drawBackground   [inline]
 

Draw the background color on the entire canvas.

00293 {
00294     Graphics g = getGraphics();
00295     if (g != null) {
00296         g.setColor(_backgroundColor);
00297         g.fillRect(0, 0, _dimCCS.width, _dimCCS.height);
00298         g.dispose();
00299     }
00300 }

void IcsCanvas::zoom double    zoomVal [inline]
 

Zoom to the given value.

Will adjust the canvas size by setting the CCS extent.

Reimplemented in ScribbleCanvas, and VisCanvas.

00307 {
00308     if (zoomVal == _zoomFactor)
00309         return;
00310 
00311     Dimension d = Converter.ICStoCCS(_objectExtent, zoomVal);
00312 
00313     if (d.width < MIN_SIZE || d.height < MIN_SIZE) {
00314 if (DEBUG_LAYOUT)
00315 OutputStreamArea.println("zoom (" + _id + ") denied : extent too small: " + d);
00316         return;
00317     }
00318 
00319     _zoomFactor = zoomVal;
00320 
00321 if (DEBUG_LAYOUT)
00322 OutputStreamArea.println("zoom (" + _id + "): d " + d);
00323 
00324     setDimensionCCS(d);
00325 }

void IcsCanvas::doPaintComponent Graphics    bufGraphics [inline]
 

Paint the component in the given graphics.

This is just because paintComponent is protected.

00332 {
00333     paintComponent(bufGraphics);
00334 }

void IcsCanvas::handleMousePress MouseEvent    e [inline]
 

Interface for MouseListener events, called by LayeredCanvasPane.

Reimplemented in ActiveCanvas, ScribbleCanvas, and VisCanvas.

00342 { /* ignore */ }

void IcsCanvas::handleMouseEnter MouseEvent    e [inline]
 

Reimplemented in ActiveCanvas, ScribbleCanvas, and VisCanvas.

00343 { /* ignore */ }

void IcsCanvas::handleMouseExit MouseEvent    e [inline]
 

Reimplemented in ActiveCanvas, ScribbleCanvas, and VisCanvas.

00344 { /* ignore */ }

void IcsCanvas::handleMouseClick MouseEvent    e [inline]
 

00345 { /* ignore */ }

void IcsCanvas::handleMouseRelease MouseEvent    e [inline]
 

00346 { /* ignore */ }

void IcsCanvas::handleMouseMove MouseEvent    e [inline]
 

Interface for MouseMotionListener events, called by LayeredCanvasPane.

Reimplemented in ActiveCanvas, ScribbleCanvas, and VisCanvas.

00351 { /* ignore */ }

void IcsCanvas::handleMouseDrag MouseEvent    e [inline]
 

Reimplemented in ScribbleCanvas.

00352 { /* ignore */ }

void IcsCanvas::dump   [inline, protected]
 

00359 {
00360     OutputStreamArea.println("--------- (" + _id + ") dimICS " + _dimICS);
00361     OutputStreamArea.println("--------- (" + _id + ") dimCCS " + _dimCCS);
00362     OutputStreamArea.println("--------- (" + _id + ") objExt " + _objectExtent);
00363     OutputStreamArea.println("--------- (" + _id + ") viewP  " + _viewportSize);
00364 }


Member Data Documentation

final Color IcsCanvas::STD_BCOLOR = Color.white [static]
 

final Color IcsCanvas::STD_DCOLOR = Color.red [static]
 

final int IcsCanvas::MIN_SIZE = 3 [static]
 

final int IcsCanvas::EXT_MARGIN = 0 [static]
 

final double IcsCanvas::STD_ZOOM = 1.0f [static]
 

boolean IcsCanvas::DEBUG_LAYOUT = false [static]
 

boolean IcsCanvas::DEBUG_EVENTS = false [static]
 


The documentation for this class was generated from the following file:
Generated on Mon Jan 27 15:11:20 2003 for JavaReference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001