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

CanvasString Class Reference

Inheritance diagram for CanvasString::

ScribbleFigure ScribbleObject CanvasObject List of all members.

Public Methods

 CanvasString (String line, double x, double y, Color color)
 CanvasString (String line, double x, double y, double w, double h, Color color)
 CanvasString (String line, double x, double y, int mode, Color color, float trans, double ccs_scale)
 CanvasString (String line, double x, double y, double w, double h, int mode, Color color, float trans, double ccs_scale)
void draw (Graphics g)
 Draw CanvasObject on 'g', using internal CCS values. More...

Object clone ()
 Return an identical copy of this CanvasObject. More...

boolean isInside (double x, double y)
boolean isNear (double x, double y)
void setDimension (double w, double h)
 Resize CanvasObject to width 'w' and height 'h'. More...

void setZoomFactor (double zoomFactor)
 Scale CanvasObject according to 'zoomFactor'. More...

void doPixelFit (double zoomFactor)
 Round internal ICS values to nearest natural number. More...

 CanvasString (String line, int x, int y, int mode, Color color, double ccs_scale)
 CanvasString (String line, int x, int y, int w, int h, int mode, Color color, double ccs_scale)
boolean isInsideCcs (int x, int y)
 To be removed. More...

boolean isNearCcs (int x, int y)
 To be removed. More...

void setDimension (int w, int h)

Static Public Attributes

final int STD_HEIGHT = 12

Protected Methods

void initString (String line)
void setFont (int h)

Protected Attributes

String line = ""
Label label = null
Font f = null
FontMetrics fm = null

Constructor & Destructor Documentation

CanvasString::CanvasString String    line,
double    x,
double    y,
Color    color
[inline]
 

00030     {
00031         this(line, x, y, 0., (double)STD_HEIGHT, color);
00032     }

CanvasString::CanvasString String    line,
double    x,
double    y,
double    w,
double    h,
Color    color
[inline]
 

00037     {
00038         super(x, y, w, h, color);
00039         initString(line);
00040     }

CanvasString::CanvasString String    line,
double    x,
double    y,
int    mode,
Color    color,
float    trans,
double    ccs_scale
[inline]
 

00045     {
00046         this(line, x, y, 0., (double)STD_HEIGHT,
00047              mode, color, DEF_TRANS, ccs_scale);
00048     }

CanvasString::CanvasString String    line,
double    x,
double    y,
double    w,
double    h,
int    mode,
Color    color,
float    trans,
double    ccs_scale
[inline]
 

00054     {
00055         super(x, y, w, h,
00056               mode, color, false, DEF_LINEW, trans, ccs_scale);
00057         initString(line);
00058     }

CanvasString::CanvasString String    line,
int    x,
int    y,
int    mode,
Color    color,
double    ccs_scale
[inline]
 

00138     {
00139         this(line, x, y, 1, STD_HEIGHT, mode, color, ccs_scale);
00140     }

CanvasString::CanvasString String    line,
int    x,
int    y,
int    w,
int    h,
int    mode,
Color    color,
double    ccs_scale
[inline]
 

00145     {
00146         super(x, y, w, h, mode, color, ccs_scale);
00147         initString(line);
00148     }


Member Function Documentation

void CanvasString::draw Graphics    g [inline, virtual]
 

Draw CanvasObject on 'g', using internal CCS values.

Reimplemented from CanvasObject.

00065     {
00066         g.setFont(f);
00067         setupDrawMode(g);
00068         if (!getTransformOK()) {
00069             transformICStoCCS();
00070         }
00071         g.drawString(line, getX1Ccs(), getY1Ccs() + getHeightCcs() - fm.getMaxDescent());
00072 if (getDrawMode() == XOR_MODE) {
00073     g.drawRect(getX1Ccs(), getY1Ccs(), getWidthCcs(), getHeightCcs());
00074 }
00075     }

Object CanvasString::clone   [inline, virtual]
 

Return an identical copy of this CanvasObject.

Reimplemented from CanvasObject.

00079     {
00080         Color color = drawColor;
00081         if (hasNoColor) {
00082             color = NO_COLOR;
00083         }
00084         return (new CanvasString(line, getX1(), getY1(), getWidth(), getHeight(), getDrawMode(),
00085                                  color, transparency, getZoomFactor()));
00086     }

boolean CanvasString::isInside double    x,
double    y
[inline]
 

00090     {
00091         return inBoundingBox(x, y);
00092     }

boolean CanvasString::isNear double    x,
double    y
[inline]
 

00096     {
00097         return inBoundingBox(x, y);
00098     }

void CanvasString::setDimension double    w,
double    h
[inline]
 

Resize CanvasObject to width 'w' and height 'h'.

Parameters are assumed Image Coordinate System values.

Reimplemented from ScribbleObject.

00102     {
00103         super.setDimension(w, h);
00104         setFont(getHeightCcs());
00105     }

void CanvasString::setZoomFactor double    zoomFactor [inline]
 

Scale CanvasObject according to 'zoomFactor'.

The internal ICS values are taken as base values to calculate the associated CCS values.

Reimplemented from CanvasObject.

00109     {
00110         super.setZoomFactor(zoomFactor);
00111         setFont(getHeightCcs());
00112     }

void CanvasString::doPixelFit double    zoomFactor [inline]
 

Round internal ICS values to nearest natural number.

Although the ICS values are changed, they are not converted to 'integer' internally.

Reimplemented from ScribbleObject.

00116     {
00117         super.doPixelFit(zoomFactor);
00118         setFont(getHeightCcs());
00119     }

boolean CanvasString::isInsideCcs int    x,
int    y
[inline]
 

To be removed.

Reimplemented from CanvasObject.

00152     {
00153         return inBoundingBoxCcs(x, y);
00154     }

boolean CanvasString::isNearCcs int    x,
int    y
[inline]
 

To be removed.

Reimplemented from CanvasObject.

00158     {
00159         return inBoundingBoxCcs(x, y);
00160     }

void CanvasString::setDimension int    w,
int    h
[inline]
 

Reimplemented from ScribbleObject.

00164     {
00165         super.setDimension(w, h);
00166         setFont(getHeightCcs());
00167     }

void CanvasString::initString String    line [inline, protected]
 

00181     {
00182         hasLineWidth = false;
00183         this.line = line;
00184 
00185         if (!getTransformOK()) {
00186             transformICStoCCS();
00187         }
00188 
00189         setFont(getHeightCcs());
00190     }

void CanvasString::setFont int    h [inline, protected]
 

00194     {
00195         this.f = new Font("SanSerif", Font.PLAIN, h);
00196         label = new Label(line);
00197         fm = label.getFontMetrics(f);
00198 
00199         if (!getTransformOK()) {
00200             transformICStoCCS();
00201         }
00202 
00203         setWidthCcs(fm.stringWidth(line));
00204     }


Member Data Documentation

final int CanvasString::STD_HEIGHT = 12 [static]
 

String CanvasString::line = "" [protected]
 

Label CanvasString::label = null [protected]
 

Font CanvasString::f = null [protected]
 

FontMetrics CanvasString::fm = null [protected]
 


The documentation for this class was generated from the following file:
Generated on Tue Feb 3 14:19:40 2004 for JavaReference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001