home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / jfc.bin / LabelView.java < prev    next >
Text File  |  1998-02-26  |  23KB  |  682 lines

  1. /*
  2.  * @(#)LabelView.java    1.33 98/01/28
  3.  * 
  4.  * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  */
  20. package com.sun.java.swing.text;
  21.  
  22. import java.awt.*;
  23. import com.sun.java.swing.event.*;
  24.  
  25. /**
  26.  * Styled chunk of text that represents a view mapped over
  27.  * an element in the text model.  The view supports breaking
  28.  * for the purpose of formatting.   The fragments produced
  29.  * by breaking share the view that has primary responsibility
  30.  * for the element (ie they are nested classes and carry only 
  31.  * a small amount of state of their own) so they can share it's 
  32.  * resources.
  33.  * <p>
  34.  * This view is generally responsible for displaying character
  35.  * level attributes in some way.  Since this view represents 
  36.  * text that may have tabs embedded in it, it implements the
  37.  * <code>TabableView</code> interface.  Tabs will only be
  38.  * expanded if this view is embedded in a container that does
  39.  * tab expansion.  ParagraphView is an example of a container
  40.  * that does tab expansion.
  41.  *
  42.  * @author Timothy Prinzing
  43.  * @version 1.33 01/28/98
  44.  */
  45. public class LabelView extends View implements TabableView {
  46.  
  47.     /**
  48.      * Constructs a new view wrapped on an element.
  49.      *
  50.      * @param elem the element
  51.      */
  52.     public LabelView(Element elem) {
  53.     super(elem);
  54.     text = new Segment();
  55.     }
  56.  
  57.     /**
  58.      * Load the text buffer with the given range
  59.      * of text.  This is used by the fragments 
  60.      * broken off of this view as well as this 
  61.      * view itself.
  62.      */
  63.     final void loadText(int p0, int p1) {
  64.     try {
  65.         Document doc = getDocument();
  66.         doc.getText(p0, p1 - p0, text);
  67.     } catch (BadLocationException bl) {
  68.         throw new StateInvariantError("LabelView: Stale view: " + bl);
  69.     }
  70.     }
  71.  
  72.     /**
  73.      * Paint the given range.  This is used by the
  74.      * fragments broken off of this view as well as this
  75.      * view itself.
  76.      */
  77.     final void paintText(Graphics g, Shape a, int p0, int p1) {
  78.     Rectangle alloc = a.getBounds();
  79.     sync();
  80.     loadText(p0, p1);
  81.     int y = alloc.y + alloc.height - metrics.getDescent();
  82.     g.setFont(font);
  83.     g.setColor(fg);
  84.     Utilities.drawTabbedText(text, alloc.x, y, g, expander, p0);
  85.     if (underline) {
  86.         y += 1;
  87.         g.drawLine(alloc.x, y, alloc.x + alloc.width, y);
  88.     }
  89.     }
  90.  
  91.     /**
  92.      * Synchronize the view's cached values with the model.
  93.      * This causes the font, metrics, color, etc to be 
  94.      * recached if the cache has been invalidated.
  95.      */
  96.     final void sync() {
  97.     if (font == null) {
  98.         Element e = getElement();
  99.         Document d = getDocument();
  100.         if (d instanceof StyledDocument) {
  101.         StyledDocument doc = (StyledDocument) d;
  102.         AttributeSet attr = e.getAttributes();
  103.         font = doc.getFont(attr);
  104.         fg = doc.getForeground(attr);
  105.         underline = StyleConstants.isUnderline(attr);
  106.         metrics = Toolkit.getDefaultToolkit().getFontMetrics(font);
  107.         } else {
  108.         throw new StateInvariantError("LabelView needs StyledDocument");
  109.         }
  110.     }
  111.     }
  112.  
  113.     /**
  114.      * Determines the preferred span for this view along an
  115.      * axis. This is shared by the broken views.
  116.      *
  117.      * @param axis may be either X_AXIS or Y_AXIS
  118.      * @param x the location to calculate the span from.
  119.      * @returns  the span the view would like to be rendered into.
  120.      *           Typically the view is told to render into the span
  121.      *           that is returned, although there is no guarantee.  
  122.      *           The parent may choose to resize or break the view.
  123.      */
  124.     final float getPreferredSpan(int axis, int p0, int p1, int x) {
  125.     sync();
  126.     switch (axis) {
  127.     case View.X_AXIS:
  128.         loadText(p0, p1);
  129.         int width = Utilities.getTabbedTextWidth(text, metrics, x, expander, p0);
  130.         return Math.max(width, 1);
  131.     case View.Y_AXIS:
  132.         return metrics.getHeight();
  133.     default:
  134.         throw new IllegalArgumentException("Invalid axis: " + axis);
  135.     }
  136.     }
  137.  
  138.     /**
  139.      * Provides a mapping from the document model coordinate space
  140.      * to the coordinate space of the view mapped to it.
  141.      * This is shared by the broken views.
  142.      *
  143.      * @param pos the position to convert
  144.      * @param a the allocated region to render into
  145.      * @return the bounding box of the given position
  146.      * @exception BadLocationException  if the given position does not represent a
  147.      *   valid location in the associated document
  148.      * @see View#modelToView
  149.      */
  150.     Shape modelToView(int pos, Shape a, int p0, int p1) throws BadLocationException {
  151.     Rectangle alloc = a.getBounds();
  152.     if ((pos >= p0) && (pos <= p1)) {
  153.         // determine range to the left of the position
  154.         loadText(p0, pos);
  155.         sync();
  156.         int width = Utilities.getTabbedTextWidth(text, metrics, alloc.x, expander, p0);
  157.         return new Rectangle(alloc.x + width, alloc.y, 0, metrics.getHeight());
  158.     }
  159.     throw new BadLocationException("modelToView - can't convert", p1);
  160.     }
  161.  
  162.     /**
  163.      * Provides a mapping from the view coordinate space to the logical
  164.      * coordinate space of the model.
  165.      *
  166.      * @param x the X coordinate
  167.      * @param y the Y coordinate
  168.      * @param a the allocated region to render into
  169.      * @return the location within the model that best represents the
  170.      *  given point of view
  171.      * @see View#viewToModel
  172.      */
  173.     int viewToModel(float x, float y, Shape a, int p0, int p1) {
  174.     Rectangle alloc = a.getBounds();
  175.     sync();
  176.     loadText(p0, p1);
  177.     int offs = Utilities.getTabbedTextOffset(text, metrics, 
  178.                          alloc.x, (int) x, expander, p0);
  179.     return p0 + offs;
  180.     }
  181.  
  182.     int getBreakWeight(int axis, float pos, float len, int p0, int p1) {
  183.     if (axis == View.X_AXIS) {
  184.         sync();
  185.         loadText(p0, p1);
  186.         int index = Utilities.getTabbedTextOffset(text, metrics, 
  187.                               (int)pos, (int)(pos+len), 
  188.                               expander, p0);
  189.         if (index == 0) {
  190.         // break is at the start offset
  191.         return BadBreakWeight;
  192.         }
  193.         for (int i = text.offset + Math.min(index, text.count - 1); 
  194.          i >= text.offset; i--) {
  195.  
  196.         char ch = text.array[i];
  197.         if (Character.isWhitespace(ch)) {
  198.             // found whitespace
  199.             return ExcellentBreakWeight;
  200.         }
  201.         }
  202.         // no whitespace
  203.         return GoodBreakWeight;
  204.     }
  205.     return super.getBreakWeight(axis, pos, len);
  206.     }
  207.  
  208.     // --- TabableView methods --------------------------------------
  209.  
  210.     /**
  211.      * Determines the desired span when using the given 
  212.      * tab expansion implementation.  
  213.      *
  214.      * @param x the position the view would be located
  215.      *  at for the purpose of tab expansion.
  216.      * @param e how to expand the tabs when encountered.
  217.      * @return the desired span
  218.      * @see TabableView#getTabbedSpan
  219.      */
  220.     public float getTabbedSpan(float x, TabExpander e) {
  221.     expander = e;
  222.     this.x = (int) x;
  223.     return getPreferredSpan(X_AXIS, getStartOffset(), getEndOffset(), this.x);
  224.     }
  225.     
  226.     /**
  227.      * Determine the span along the same axis as tab 
  228.      * expansion for a portion of the view.  This is
  229.      * intended for use by the TabExpander for cases
  230.      * where the tab expansion involves aligning the
  231.      * portion of text that doesn't have whitespace 
  232.      * relative to the tab stop.  There is therefore
  233.      * an assumption that the range given does not
  234.      * contain tabs.
  235.      * <p>
  236.      * This method can be called while servicing the
  237.      * getTabbedSpan or getPreferredSize.  It has to
  238.      * arrange for it's own text buffer to make the
  239.      * measurements.
  240.      */
  241.     public float getPartialSpan(int p0, int p1) {
  242.     // PENDING should probably use a static buffer since there 
  243.     // should be only one thread accessing it.
  244.     int width = 0;
  245.     try {
  246.         Segment s = new Segment();
  247.         getDocument().getText(p0, p1, s);
  248.         width = Utilities.getTabbedTextWidth(s, metrics, x, expander, p0);
  249.     } catch (BadLocationException bl) {
  250.     }
  251.     return width;
  252.     }
  253.  
  254.     // --- View methods ---------------------------------------------
  255.  
  256.     /**
  257.      * Renders a portion of a text style run.
  258.      *
  259.      * @param g the rendering surface to use
  260.      * @param a the allocated region to render into
  261.      */
  262.     public void paint(Graphics g, Shape a) {
  263.     paintText(g, a, getStartOffset(), getEndOffset());
  264.     }
  265.  
  266.     /**
  267.      * Determines the preferred span for this view along an
  268.      * axis. 
  269.      *
  270.      * @param axis may be either X_AXIS or Y_AXIS
  271.      * @returns  the span the view would like to be rendered into.
  272.      *           Typically the view is told to render into the span
  273.      *           that is returned, although there is no guarantee.  
  274.      *           The parent may choose to resize or break the view.
  275.      */
  276.     public float getPreferredSpan(int axis) {
  277.     return getPreferredSpan(axis, getStartOffset(), getEndOffset(), this.x);
  278.     }
  279.  
  280.     /**
  281.      * Determines the desired alignment for this view along an
  282.      * axis.  For the label, the alignment is along the font
  283.      * baseline for the y axis, and the superclasses alignment
  284.      * along the x axis.
  285.      *
  286.      * @param axis may be either X_AXIS or Y_AXIS
  287.      * @returns the desired alignment.  This should be a value
  288.      *   between 0.0 and 1.0 where 0 indicates alignment at the
  289.      *   origin and 1.0 indicates alignment to the full span
  290.      *   away from the origin.  An alignment of 0.5 would be the
  291.      *   center of the view.
  292.      */
  293.     public float getAlignment(int axis) {
  294.     if (axis == View.Y_AXIS) {
  295.         float h = metrics.getHeight();
  296.         float d = metrics.getDescent();
  297.         float align = (h - d) / h;
  298.         return align;
  299.     } 
  300.     return super.getAlignment(axis);
  301.     }
  302.  
  303.  
  304.     /**
  305.      * Provides a mapping from the document model coordinate space
  306.      * to the coordinate space of the view mapped to it.
  307.      *
  308.      * @param pos the position to convert
  309.      * @param a the allocated region to render into
  310.      * @return the bounding box of the given position
  311.      * @exception BadLocationException  if the given position does not represent a
  312.      *   valid location in the associated document
  313.      * @see View#modelToView
  314.      */
  315.     public Shape modelToView(int pos, Shape a) throws BadLocationException {
  316.     return modelToView(pos, a, getStartOffset(), getEndOffset());
  317.     }
  318.  
  319.     /**
  320.      * Provides a mapping from the view coordinate space to the logical
  321.      * coordinate space of the model.
  322.      *
  323.      * @param x the X coordinate
  324.      * @param y the Y coordinate
  325.      * @param a the allocated region to render into
  326.      * @return the location within the model that best represents the
  327.      *  given point of view
  328.      * @see View#viewToModel
  329.      */
  330.     public int viewToModel(float x, float y, Shape a) {
  331.     return viewToModel(x, y, a, getStartOffset(), getEndOffset());
  332.     }
  333.  
  334.     /**
  335.      * Gives notification from the document that attributes were changed
  336.      * in a location that this view is responsible for.
  337.      *
  338.      * @param e the change information from the associated document
  339.      * @param a the current allocation of the view
  340.      * @param f the factory to use to rebuild if the view has children
  341.      * @see View#changedUpdate
  342.      */
  343.     public void changedUpdate(DocumentEvent e, Shape a, ViewFactory f) {
  344.     font = null;
  345.     }
  346.  
  347.     /**
  348.      * Determines how attractive a break opportunity in 
  349.      * this view is.  This can be used for determining which
  350.      * view is the most attractive to call <code>breakView</code>
  351.      * on in the process of formatting.  The
  352.      * higher the weight, the more attractive the break.  A
  353.      * value equal to or lower than <code>BadBreakWeight</code>
  354.      * should not be considered for a break.  A value greater
  355.      * than or equal to <code>ForcedBreakWeight</code> should
  356.      * be broken.
  357.      * <p>
  358.      * This is implemented to forward to the superclass for 
  359.      * the Y_AXIS and along the X_AXIS the following values
  360.      * may be returned.
  361.      * <dl>
  362.      * <dt><b>ExcellentBreakWeight</b>
  363.      * <dd>if there is whitespace proceeding the desired break 
  364.      *   location.  
  365.      * <dt><b>BadBreakWeight</b>
  366.      * <dd>if the desired break location results in a break
  367.      *   location of the starting offset.
  368.      * <dt><b>GoodBreakWeight</b>
  369.      * <dd>if the other conditions don't occur.
  370.      * </dl>
  371.      * This will normally result in the behavior of breaking
  372.      * on a whitespace location if one can be found, otherwise
  373.      * breaking between characters.
  374.      *
  375.      * @param axis may be either X_AXIS or Y_AXIS
  376.      * @param pos the potential location of the start of the 
  377.      *   broken view.  This may be useful for calculating tab
  378.      *   positions.
  379.      * @param len specifies the relative length from <em>pos</em>
  380.      *   where a potential break is desired.
  381.      * @return the weight, which should be a value between
  382.      *   ForcedBreakWeight and BadBreakWeight.
  383.      * @see LabelView
  384.      * @see ParagraphView
  385.      * @see BadBreakWeight
  386.      * @see GoodBreakWeight
  387.      * @see ExcellentBreakWeight
  388.      * @see ForcedBreakWeight
  389.      */
  390.     public int getBreakWeight(int axis, float pos, float len) {
  391.     return getBreakWeight(axis, pos, len, getStartOffset(), getEndOffset());
  392.     }
  393.  
  394.     /**
  395.      * Breaks this view on the given axis at the given length.
  396.      * This is implemented to attempt to break on a whitespace
  397.      * location, and returns a fragment with the whitespace at
  398.      * the end.  If a whitespace location can't be found, the
  399.      * nearest character is used.
  400.      *
  401.      * @param axis may be either X_AXIS or Y_AXIS
  402.      * @param p0 the location in the model where the
  403.      *  fragment should start it's representation.
  404.      * @param pos the position along the axis that the
  405.      *  broken view would occupy.  This may be useful for
  406.      *  things like tab calculations.
  407.      * @param len specifies the distance along the axis
  408.      *  where a potential break is desired.  
  409.      * @param a the current allocation of the view
  410.      * @return the fragment of the view that represents the
  411.      *  given span, if the view can be broken.  If the view
  412.      *  doesn't support breaking behavior, the view itself is
  413.      *  returned.
  414.      * @see View#breakView
  415.      */
  416.     public View breakView(int axis, int p0, float pos, float len) {
  417.     if (axis == View.X_AXIS) {
  418.         sync();
  419.         loadText(p0, getEndOffset());
  420.         int index = Utilities.getTabbedTextOffset(text, metrics, 
  421.                               (int)pos, (int)(pos+len), 
  422.                               expander, p0);
  423.         for (int i = text.offset + Math.min(index, text.count - 1); 
  424.          i >= text.offset; i--) {
  425.  
  426.         char ch = text.array[i];
  427.         if (Character.isWhitespace(ch)) {
  428.             // found whitespace, break here
  429.             index = i - text.offset + 1;
  430.             break;
  431.         }
  432.         }
  433.         int p1 = p0 + index;
  434.         return new LabelFragment(getElement(), p0, p1);
  435.     }
  436.     return this;
  437.     }
  438.  
  439.     /**
  440.      * Create a view that represents a portion of the element.
  441.      * This is potentially useful during formatting operations
  442.      * for taking measurements of fragments of the view.  If 
  443.      * the view doesn't support fragmenting (the default), it 
  444.      * should return itself.  
  445.      * <p>
  446.      * This view does support fragmenting.  It is implemented
  447.      * to return a nested class that shares state in this view 
  448.      * representing only a portion of the view.
  449.      *
  450.      * @param p0 the starting offset.  This should be a value
  451.      *   greater or equal to the element starting offset and
  452.      *   less than the element ending offset.
  453.      * @param p1 the ending offset.  This should be a value
  454.      *   less than or equal to the elements end offset and
  455.      *   greater than the elements starting offset.
  456.      * @returns the view fragment, or itself if the view doesn't
  457.      *   support breaking into fragments.
  458.      * @see LabelView
  459.      */
  460.     public View createFragment(int p0, int p1) {
  461.     Element elem = getElement();
  462.     return new LabelFragment(elem, p0, p1);
  463.     }
  464.  
  465.     // --- variables ------------------------------------------------
  466.  
  467.     Font font;
  468.     FontMetrics metrics;
  469.     Color fg;
  470.     Segment text;
  471.     boolean underline;
  472.  
  473.     /**
  474.      * how to expand tabs
  475.      */
  476.     TabExpander expander;
  477.  
  478.     /**
  479.      * location for determining tab expansion against.
  480.      */
  481.     int x;
  482.  
  483.     /**
  484.      * A label that represents only a portion of a character
  485.      * style run element.  This carries very little state
  486.      * of it's own and depends heavily upon the outer class.
  487.      */
  488.     class LabelFragment extends View {
  489.  
  490.     /**
  491.      * Constructs a new view wrapped on an element.
  492.      *
  493.      * @param elem the element
  494.      * @param p0 the beginning of the range
  495.      * @param p1 the end of the range
  496.      */
  497.         public LabelFragment(Element elem, int p0, int p1) {
  498.         super(elem);
  499.         offset = (short) (p0 - elem.getStartOffset());
  500.         length = (short) (p1 - p0);
  501.     }
  502.  
  503.     // --- TabableView methods --------------------------------------
  504.  
  505.     /**
  506.      * Determines the desired span when using the given 
  507.      * tab expansion implementation.  
  508.      *
  509.      * @param x the position the view would be located
  510.      *  at for the purpose of tab expansion.
  511.      * @param e how to expand the tabs when encountered.
  512.      * @return the desired span
  513.      * @see TabableView#getTabbedSpan
  514.      */
  515.         public float getTabbedSpan(float x, TabExpander e) {
  516.         LabelView.this.expander = e;
  517.         this.x = (int) x;
  518.         return LabelView.this.getPreferredSpan(X_AXIS, getStartOffset(), 
  519.                            getEndOffset(), this.x);
  520.     }
  521.     
  522.     /**
  523.      * Determine the span along the same axis as tab 
  524.      * expansion for a portion of the view.  This is
  525.      * intended for use by the TabExpander for cases
  526.      * where the tab expansion involves aligning the
  527.      * portion of text that doesn't have whitespace 
  528.      * relative to the tab stop.  There is therefore
  529.      * an assumption that the range given does not
  530.      * contain tabs.
  531.      */
  532.         public float getPartialSpan(int p0, int p1) {
  533.         return LabelView.this.getPartialSpan(p0, p1);
  534.     }
  535.  
  536.     // --- View methods ----------------------------
  537.  
  538.     /**
  539.      * Fetches the portion of the model that this view is responsible for.
  540.      *
  541.      * @return the starting offset into the model
  542.      * @see View#getStartOffset
  543.      */
  544.         public int getStartOffset() {
  545.         Element e = getElement();
  546.         return e.getStartOffset() + offset;
  547.     }
  548.  
  549.     /**
  550.      * Fetches the portion of the model that this view is responsible for.
  551.      *
  552.      * @return the ending offset into the model
  553.      * @see View#getEndOffset
  554.      */
  555.         public int getEndOffset() {
  556.         Element e = getElement();
  557.         return e.getStartOffset() + offset + length;
  558.     }
  559.  
  560.     /**
  561.      * Renders a portion of a text style run.
  562.      *
  563.      * @param g the rendering surface to use
  564.      * @param a the allocated region to render into
  565.      */
  566.         public void paint(Graphics g, Shape a) {
  567.         paintText(g, a, getStartOffset(), getEndOffset());
  568.     }
  569.  
  570.     /**
  571.      * Determines the preferred span for this view along an
  572.      * axis. 
  573.      *
  574.      * @param axis may be either X_AXIS or Y_AXIS
  575.      * @returns  the span the view would like to be rendered into.
  576.      *           Typically the view is told to render into the span
  577.      *           that is returned, although there is no guarantee.  
  578.      *           The parent may choose to resize or break the view.
  579.      */
  580.         public float getPreferredSpan(int axis) {
  581.         return LabelView.this.getPreferredSpan(axis, getStartOffset(), getEndOffset(), this.x);
  582.     }
  583.  
  584.     /**
  585.      * Determines the desired alignment for this view along an
  586.      * axis.  For the label, the alignment is along the font
  587.      * baseline for the y axis, and the superclasses alignment
  588.      * along the x axis.
  589.      *
  590.      * @param axis may be either X_AXIS or Y_AXIS
  591.      * @returns the desired alignment.  This should be a value
  592.      *   between 0.0 and 1.0 where 0 indicates alignment at the
  593.      *   origin and 1.0 indicates alignment to the full span
  594.      *   away from the origin.  An alignment of 0.5 would be the
  595.      *   center of the view.
  596.      */
  597.         public float getAlignment(int axis) {
  598.         return LabelView.this.getAlignment(axis);
  599.     }
  600.  
  601.  
  602.     /**
  603.      * Provides a mapping from the document model coordinate space
  604.      * to the coordinate space of the view mapped to it.
  605.      *
  606.      * @param pos the position to convert
  607.      * @param a the allocated region to render into
  608.      * @return the bounding box of the given position
  609.      * @exception BadLocationException  if the given position does not represent a
  610.      *   valid location in the associated document
  611.      * @see View#modelToView
  612.      */
  613.         public Shape modelToView(int pos, Shape a) throws BadLocationException {
  614.         return LabelView.this.modelToView(pos, a, getStartOffset(), getEndOffset());
  615.     }
  616.  
  617.     /**
  618.      * Provides a mapping from the view coordinate space to the logical
  619.      * coordinate space of the model.
  620.      *
  621.      * @param x the X coordinate
  622.      * @param y the Y coordinate
  623.      * @param a the allocated region to render into
  624.      * @return the location within the model that best represents the
  625.      *  given point of view
  626.      * @see View#viewToModel
  627.      */
  628.         public int viewToModel(float x, float y, Shape a) {
  629.         return LabelView.this.viewToModel(x, y, a, getStartOffset(), getEndOffset());
  630.     }
  631.  
  632.     /**
  633.      * Gives notification from the document that attributes were changed
  634.      * in a location that this view is responsible for.
  635.      *
  636.      * @param e the change information from the associated document
  637.      * @param a the current allocation of the view
  638.      * @param f the factory to use to rebuild if the view has children
  639.      * @see View#changedUpdate
  640.      */
  641.         public void changedUpdate(DocumentEvent e, Shape a, ViewFactory f) {
  642.         LabelView.this.changedUpdate(e, a, f);
  643.     }
  644.  
  645.     /**
  646.      * @see LabelView#getBreakWeight
  647.      */
  648.         public int getBreakWeight(int axis, float x, float len) {
  649.         return LabelView.this.getBreakWeight(axis, x, len, 
  650.                          getStartOffset(), getEndOffset());
  651.     }
  652.  
  653.     /**
  654.      * Breaks this view on the given axis at the given length.
  655.      *
  656.      * @param axis may be either X_AXIS or Y_AXIS
  657.      * @param offset the location in the model where the
  658.      *  fragment should start it's representation.
  659.      * @param pos the position along the axis that the
  660.      *  broken view would occupy.  This may be useful for
  661.      *  things like tab calculations.
  662.      * @param len specifies the distance along the axis
  663.      *  where a potential break is desired.  
  664.      * @param a the current allocation of the view
  665.      * @return the fragment of the view that represents the
  666.      *  given span, if the view can be broken.  If the view
  667.      *  doesn't support breaking behavior, the view itself is
  668.      *  returned.
  669.      * @see View#breakView
  670.      */
  671.         public View breakView(int axis, int offset, float pos, float len) {
  672.         return LabelView.this.breakView(axis, offset, pos, len);
  673.     }
  674.  
  675.     // ---- variables ---------------------------------
  676.     short offset;
  677.     short length;
  678.     int x;
  679.     }
  680. }
  681.  
  682.