Back to index

wims  3.65+svn20090927
Public Member Functions | Package Attributes
WIMSchem.MultiLineToolTipUI Class Reference

List of all members.

Public Member Functions

void paint (Graphics g, JComponent c)
Dimension getPreferredSize (JComponent c)

Package Attributes

String[] strs
int maxWidth = 0

Detailed Description

Definition at line 43 of file ToolButton.java.


Member Function Documentation

Dimension WIMSchem.MultiLineToolTipUI.getPreferredSize ( JComponent  c) [inline]

Definition at line 70 of file ToolButton.java.

    {
       Font font=c.getFont();
       FontRenderContext frc=new FontRenderContext(null,false,false);
       String tipText=((JToolTip) c).getTipText();
       if (tipText==null) tipText="";
       while (tipText.endsWith("\n")) {tipText=tipText.substring(0,tipText.length()-1);}
       BufferedReader br=new BufferedReader(new StringReader(tipText));
       String line;
       int maxWidth=0,totalHeight=0;
       Vector<String> v=new Vector<String>();
       try 
       {
           while ((line=br.readLine())!=null) 
           {
              int width=(int)font.getStringBounds(line,frc).getWidth();
              maxWidth=(maxWidth<width) ? width : maxWidth;
              v.addElement(line);
              totalHeight+=(int)font.getLineMetrics(line,frc).getHeight()+2;
           }
       } 
       catch (IOException ex) 
       {
           ex.printStackTrace();
       }
       int lines=v.size();
       if (lines<1) 
       {
           strs=null; 
           lines=1;
       }
       else 
       {
           strs=new String[lines];
           int i=0;
           for (Enumeration e=v.elements();e.hasMoreElements();i++) strs[i]=(String)e.nextElement();
       }
       this.maxWidth=maxWidth;
       return new Dimension(maxWidth+6,totalHeight+4);
    }

Here is the call graph for this function:

void WIMSchem.MultiLineToolTipUI.paint ( Graphics  g,
JComponent  c 
) [inline]

Definition at line 48 of file ToolButton.java.

    {
       Font font=g.getFont();
       FontMetrics metrics=g.getFontMetrics();
       FontRenderContext frc=new FontRenderContext(null,false,false);
       Dimension size=c.getSize();
       g.setColor(c.getBackground());
       g.fillRect(0,0,size.width,size.height);
       g.setColor(c.getForeground());
       g.drawRect(0,0,size.width-1,size.height-1);
       if (strs!=null) 
       {
           int y=0;
           for (int i=0;i<strs.length;i++) 
           {
              y+=(int)font.getLineMetrics(strs[i],frc).getHeight()+2;
              g.drawString(strs[i],3,y);
              //g.drawString(strs[i],3,(metrics.getHeight())*(i+1));
           }
       }
    }

Member Data Documentation

Definition at line 46 of file ToolButton.java.

String [] WIMSchem.MultiLineToolTipUI.strs [package]

Definition at line 45 of file ToolButton.java.


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