/**
  * Iterate over the lines represented by the child elements of the element this view represents,
  * looking for the line that is the longest. The <em>longLine</em> variable is updated to
  * represent the longest line contained. The <em>font</em> variable is updated to indicate the
  * font used to calculate the longest line.
  */
 void calculateLongestLine() {
   Component c = getContainer();
   font = c.getFont();
   metrics = c.getFontMetrics(font);
   tabSize = getTabSize() * metrics.charWidth(' ');
   Element lines = getElement();
   int n = lines.getElementCount();
   for (int i = 0; i < n; i++) {
     Element line = lines.getElement(i);
     float w = getLineWidth(i);
     if (w > longLineWidth) {
       longLineWidth = w;
       longLine = line;
     }
   }
 }
Пример #2
0
 final void updateMetrics() {
   Component host = getContainer();
   Font f = host.getFont();
   metrics = host.getFontMetrics(f); // Metrics for the default font.
   tabSize = getTabSize() * metrics.charWidth('m');
 }
Пример #3
0
 /**
  * Fetches the font metrics associated with the component hosting this view.
  *
  * @return the metrics
  */
 protected FontMetrics getFontMetrics() {
   Component c = getContainer();
   return c.getFontMetrics(c.getFont());
 }