Back to index

wims  3.65+svn20090927
Public Member Functions | Package Functions | Package Attributes | Static Package Attributes
rene.viewer.Line Class Reference
Collaboration diagram for rene.viewer.Line:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Line (String s, TextDisplay td)
 Line (String s, TextDisplay td, Color c)
 Generate a line containing s in the textdisplay td.
void expandTabs (int tabwidth)
void draw (Graphics g, int x, int y)
 Draw a line.
boolean chosen ()

Package Functions

int length ()
int getpos (int x, int offset)
void append (String s)
void chosen (boolean f)
void block (int pos, int mode)
String getblock ()

Package Attributes

TextDisplay TD
boolean Chosen
int Pos
int Posend
int Block
Color C
Color IC
char a []

Static Package Attributes

static final int NONE = 0
static final int START = 1
static final int END = 2
static final int FULL = 4

Detailed Description

Definition at line 5 of file Line.java.


Constructor & Destructor Documentation

rene.viewer.Line.Line ( String  s,
TextDisplay  td 
) [inline]

Definition at line 14 of file Line.java.

       {      this(s,td,Color.black);
       }
rene.viewer.Line.Line ( String  s,
TextDisplay  td,
Color  c 
) [inline]

Generate a line containing s in the textdisplay td.

Display color is c.

Parameters:
s
td
c

Definition at line 25 of file Line.java.

    {  TD=td;
       C=c;
       // Create a color that is very bright, but resembles the line color
       IC=new Color(C.getRed()/4+192,C.getGreen()/4+192,C.getBlue()/4+192);
       Block=NONE;
       a=s.toCharArray();
    }

Member Function Documentation

void rene.viewer.Line.append ( String  s) [inline, package]

Definition at line 149 of file Line.java.

    {  a=(new String(a)+s).toCharArray();
    }
void rene.viewer.Line.block ( int  pos,
int  mode 
) [inline, package]

Definition at line 156 of file Line.java.

    {  switch (mode)
       {      case NONE : Block=NONE; break;
              case FULL : Block=FULL; break;
              case START :
                     Block|=START; Pos=pos; break;
              case END :
                     Block|=END; Posend=pos; break;
       }
    }
void rene.viewer.Line.chosen ( boolean  f) [inline, package]

Definition at line 152 of file Line.java.

    {  Chosen=f;
    }

Definition at line 155 of file Line.java.

{ return Chosen; }
void rene.viewer.Line.draw ( Graphics  g,
int  x,
int  y 
) [inline]

Draw a line.

If the line is in a block, draw it white on black or on dark gray, depending on the focus. Drawing in blocks does not use antialias.

Parameters:
g
x
y

Definition at line 76 of file Line.java.

    {  int i1=0,i2,p=0;
       x-=TD.Offset*TD.FM.charWidth(' ');
       if (Chosen) // Complete line is chosen (in Lister)
       {      // To see, if the display has the focus:
              if (TD.hasFocus()) g.setColor(Color.darkGray);
              else g.setColor(Color.gray);
              g.fillRect(0,y-TD.Ascent,TD.getSize().width,TD.Height);
              g.setColor(IC); // draw in light color
                     TD.antialias(false);
              g.drawChars(a,0,a.length,x,y);
                     TD.antialias(true);
       }
       else if ((Block&FULL)!=0) // Line in full block (in Viewer)
       {      g.setColor(Color.darkGray);
              g.fillRect(x,y-TD.Ascent,TD.FM.charsWidth(a,0,a.length),TD.Height);
              g.setColor(Color.white);
              TD.antialias(false);
              g.drawChars(a,0,a.length,x,y);
              TD.antialias(true);
       }
       else if ((Block&START)!=0)
       {      if (Pos>0) // Draw text before block
              {      g.setColor(C);
                     g.drawChars(a,0,Pos,x,y);
                     x+=TD.FM.charsWidth(a,0,Pos);
              }
              if ((Block&END)!=0) // draw text in block
              {      if (Posend>Pos)
                     {      int h=TD.FM.charsWidth(a,Pos,Posend-Pos);
                            g.setColor(Color.darkGray);
                            g.fillRect(x,y-TD.Ascent,h,TD.Height);
                            g.setColor(Color.white);
                                   TD.antialias(false);
                            g.drawChars(a,Pos,Posend-Pos,x,y);
                                   TD.antialias(true);
                            g.setColor(C);
                            x+=h;
                            if (a.length>Posend)
                            {      g.drawChars(a,Posend,a.length-Posend,x,y);
                            }
                     }
                     else g.drawChars(a,Pos,a.length-Pos,x,y);
              }
              else // draw the rest of the line in block 
              {      int h=TD.FM.charsWidth(a,Pos,a.length-Pos);
                     g.setColor(Color.darkGray);
                     g.fillRect(x,y-TD.Ascent,h,TD.Height);
                     g.setColor(Color.white);
                            TD.antialias(false);
                     g.drawChars(a,Pos,a.length-Pos,x,y);      
                            TD.antialias(true);
              }
       }
       else if ((Block&END)!=0)
       {      int h=TD.FM.charsWidth(a,0,Posend);
              g.setColor(Color.darkGray);
                     g.fillRect(x,y-TD.Ascent,h,TD.Height);
                     g.setColor(Color.white);
                     TD.antialias(false);
              g.drawChars(a,0,Posend,x,y);       
                     TD.antialias(true);
              g.setColor(C);
              x+=h;
              if (a.length>Posend)
              {      g.drawChars(a,Posend,a.length-Posend,x,y);
              }
       }
       else
       {      g.setColor(C);
              g.drawChars(a,0,a.length,x,y);
       }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void rene.viewer.Line.expandTabs ( int  tabwidth) [inline]

Definition at line 34 of file Line.java.

    {  int pos=0;
       for (int i=0; i<a.length; i++)
       {      pos++;
              if (a[i]=='\t') pos=(pos/tabwidth+1)*tabwidth;
       }
       char b[]=new char[pos];
       pos=0;
       for (int i=0; i<a.length; i++)
       {      if (a[i]=='\t')
              {      int newpos=((pos+1)/tabwidth+1)*tabwidth;
                     for (int k=pos; k<newpos; k++) b[k]=' ';
                     pos=newpos;
              }
              else b[pos++]=a[i];
       }
       a=b;   
    }

Here is the caller graph for this function:

String rene.viewer.Line.getblock ( ) [inline, package]

Definition at line 166 of file Line.java.

    {  if (Block==FULL)
       {      return new String(a,0,a.length); 
       }
       else if ((Block&START)!=0)
       {      if ((Block&END)!=0)
              {      return new String(a,Pos,Posend-Pos);
              }
              else return new String(a,Pos,a.length-Pos);
       }
       else if ((Block&END)!=0) return new String(a,0,Posend);
       else return "";
    }
int rene.viewer.Line.getpos ( int  x,
int  offset 
) [inline, package]

Definition at line 55 of file Line.java.

    {  int l[]=TD.getwidth(a);
       int h=offset-TD.Offset*TD.FM.charWidth(' ');
       if (x<h) return 0;
       int i=0;
       while (x>h && i<a.length)
       {      h+=l[i];
              i++;
       }
       return i;
    }

Here is the call graph for this function:

int rene.viewer.Line.length ( ) [inline, package]

Definition at line 52 of file Line.java.

    {  return a.length;
    }

Here is the caller graph for this function:


Member Data Documentation

char rene.viewer.Line.a[] [package]

Definition at line 12 of file Line.java.

int rene.viewer.Line.Block [package]

Definition at line 9 of file Line.java.

Color rene.viewer.Line.C [package]

Definition at line 11 of file Line.java.

Definition at line 7 of file Line.java.

final int rene.viewer.Line.END = 2 [static, package]

Definition at line 10 of file Line.java.

final int rene.viewer.Line.FULL = 4 [static, package]

Definition at line 10 of file Line.java.

Color rene.viewer.Line.IC [package]

Definition at line 11 of file Line.java.

final int rene.viewer.Line.NONE = 0 [static, package]

Definition at line 10 of file Line.java.

int rene.viewer.Line.Pos [package]

Definition at line 8 of file Line.java.

int rene.viewer.Line.Posend [package]

Definition at line 8 of file Line.java.

final int rene.viewer.Line.START = 1 [static, package]

Definition at line 10 of file Line.java.

Definition at line 6 of file Line.java.


The documentation for this class was generated from the following file: