⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 compositeview.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
   *         model location   */  public int getViewIndex(int pos, Position.Bias b)  {    // FIXME: Handle bias somehow.    return getViewIndexAtPosition(pos);  }  /**   * Returns <code>true</code> if the specified point lies before the   * given <code>Rectangle</code>, <code>false</code> otherwise.   *   * &quot;Before&quot; is typically defined as being to the left or above.   *   * @param x the X coordinate of the point   * @param y the Y coordinate of the point   * @param r the rectangle to test the point against   *   * @return <code>true</code> if the specified point lies before the   *         given <code>Rectangle</code>, <code>false</code> otherwise   */  protected abstract boolean isBefore(int x, int y, Rectangle r);  /**   * Returns <code>true</code> if the specified point lies after the   * given <code>Rectangle</code>, <code>false</code> otherwise.   *   * &quot;After&quot; is typically defined as being to the right or below.   *   * @param x the X coordinate of the point   * @param y the Y coordinate of the point   * @param r the rectangle to test the point against   *   * @return <code>true</code> if the specified point lies after the   *         given <code>Rectangle</code>, <code>false</code> otherwise   */  protected abstract boolean isAfter(int x, int y, Rectangle r);  /**   * Returns the child <code>View</code> at the specified location.   *   * @param x the X coordinate   * @param y the Y coordinate   * @param r the inner allocation of this <code>BoxView</code> on entry,   *        the allocation of the found child on exit   *   * @return the child <code>View</code> at the specified location   */  protected abstract View getViewAtPoint(int x, int y, Rectangle r);  /**   * Computes the allocation for a child <code>View</code>. The parameter   * <code>a</code> stores the allocation of this <code>CompositeView</code>   * and is then adjusted to hold the allocation of the child view.   *   * @param index the index of the child <code>View</code>   * @param a the allocation of this <code>CompositeView</code> before the   *        call, the allocation of the child on exit   */  protected abstract void childAllocation(int index, Rectangle a);  /**   * Returns the child <code>View</code> that contains the given model   * position. The given <code>Rectangle</code> gives the parent's allocation   * and is changed to the child's allocation on exit.   *   * @param pos the model position to query the child <code>View</code> for   * @param a the parent allocation on entry and the child allocation on exit   *   * @return the child view at the given model position   */  protected View getViewAtPosition(int pos, Rectangle a)  {    int i = getViewIndexAtPosition(pos);    View view = children[i];    childAllocation(i, a);    return view;  }  /**   * Returns the index of the child <code>View</code> for the given model   * position.   *   * @param pos the model position for whicht the child <code>View</code> is   *        queried   *   * @return the index of the child <code>View</code> for the given model   *         position   */  protected int getViewIndexAtPosition(int pos)  {    int index = -1;    for (int i = 0; i < children.length; i++)      {        if (children[i].getStartOffset() <= pos            && children[i].getEndOffset() > pos)          {            index = i;            break;          }      }    return index;  }  /**   * Returns the allocation that is given to this <code>CompositeView</code>   * minus this <code>CompositeView</code>'s insets.   *   * Also this translates from an immutable allocation to a mutable allocation   * that is typically reused and further narrowed, like in   * {@link #childAllocation}.   *   * @param a the allocation given to this <code>CompositeView</code>   *   * @return the allocation that is given to this <code>CompositeView</code>   *         minus this <code>CompositeView</code>'s insets or   *         <code>null</code> if a was <code>null</code>   */  protected Rectangle getInsideAllocation(Shape a)  {    if (a == null)      return null;    Rectangle alloc = a.getBounds();    // Initialize the inside allocation rectangle. This is done inside    // a synchronized block in order to avoid multiple threads creating    // this instance simultanously.    Rectangle inside;    synchronized(this)      {        inside = insideAllocation;        if (inside == null)          {            inside = new Rectangle();            insideAllocation = inside;          }      }    inside.x = alloc.x + insets.left;    inside.y = alloc.y + insets.top;    inside.width = alloc.width - insets.left - insets.right;    inside.height = alloc.height - insets.top - insets.bottom;    return inside;  }  /**   * Sets the insets defined by attributes in <code>attributes</code>. This   * queries the attribute keys {@link StyleConstants#SpaceAbove},   * {@link StyleConstants#SpaceBelow}, {@link StyleConstants#LeftIndent} and   * {@link StyleConstants#RightIndent} and calls {@link #setInsets} to   * actually set the insets on this <code>CompositeView</code>.   *   * @param attributes the attributes from which to query the insets   */  protected void setParagraphInsets(AttributeSet attributes)  {    Float l = (Float) attributes.getAttribute(StyleConstants.LeftIndent);    short left = 0;    if (l != null)      left = l.shortValue();    Float r = (Float) attributes.getAttribute(StyleConstants.RightIndent);    short right = 0;    if (r != null)      right = r.shortValue();    Float t = (Float) attributes.getAttribute(StyleConstants.SpaceAbove);    short top = 0;    if (t != null)      top = t.shortValue();    Float b = (Float) attributes.getAttribute(StyleConstants.SpaceBelow);    short bottom = 0;    if (b != null)      bottom = b.shortValue();    setInsets(top, left, bottom, right);  }  /**   * Sets the insets of this <code>CompositeView</code>.   *   * @param top the top inset   * @param left the left inset   * @param bottom the bottom inset   * @param right the right inset   */  protected void setInsets(short top, short left, short bottom, short right)  {    insets.top = top;    insets.left = left;    insets.bottom = bottom;    insets.right = right;  }  /**   * Returns the left inset of this <code>CompositeView</code>.   *   * @return the left inset of this <code>CompositeView</code>   */  protected short getLeftInset()  {    return (short) insets.left;  }  /**   * Returns the right inset of this <code>CompositeView</code>.   *   * @return the right inset of this <code>CompositeView</code>   */  protected short getRightInset()  {    return (short) insets.right;  }  /**   * Returns the top inset of this <code>CompositeView</code>.   *   * @return the top inset of this <code>CompositeView</code>   */  protected short getTopInset()  {    return (short) insets.top;  }  /**   * Returns the bottom inset of this <code>CompositeView</code>.   *   * @return the bottom inset of this <code>CompositeView</code>   */  protected short getBottomInset()  {    return (short) insets.bottom;  }  /**   * Returns the next model location that is visible in north or south   * direction.   * This is used to determine the   * placement of the caret when navigating around the document with   * the arrow keys.   *   * @param pos the model position to start search from   * @param b the bias for <code>pos</code>   * @param a the allocated region for this view   * @param direction the direction from the current position, can be one of   *        the following:   *        <ul>   *        <li>{@link SwingConstants#NORTH}</li>   *        <li>{@link SwingConstants#SOUTH}</li>   *        </ul>   * @param biasRet the bias of the return value gets stored here   *   * @return the position inside the model that represents the next visual   *         location   *   * @throws BadLocationException if <code>pos</code> is not a valid location   *         inside the document model   * @throws IllegalArgumentException if <code>direction</code> is invalid   */  protected int getNextNorthSouthVisualPositionFrom(int pos, Position.Bias b,                                                    Shape a, int direction,                                                    Position.Bias[] biasRet)    throws BadLocationException  {    // FIXME: Implement this correctly.    return pos;  }  /**   * Returns the next model location that is visible in east or west   * direction.   * This is used to determine the   * placement of the caret when navigating around the document with   * the arrow keys.   *   * @param pos the model position to start search from   * @param b the bias for <code>pos</code>   * @param a the allocated region for this view   * @param direction the direction from the current position, can be one of   *        the following:   *        <ul>   *        <li>{@link SwingConstants#EAST}</li>   *        <li>{@link SwingConstants#WEST}</li>   *        </ul>   * @param biasRet the bias of the return value gets stored here   *   * @return the position inside the model that represents the next visual   *         location   *   * @throws BadLocationException if <code>pos</code> is not a valid location   *         inside the document model   * @throws IllegalArgumentException if <code>direction</code> is invalid   */  protected int getNextEastWestVisualPositionFrom(int pos, Position.Bias b,                                                  Shape a, int direction,                                                  Position.Bias[] biasRet)    throws BadLocationException  {    // FIXME: Implement this correctly.    return pos;  }  /**   * Determines if the next view in horinzontal direction is located to   * the east or west of the view at position <code>pos</code>. Usually   * the <code>View</code>s are laid out from the east to the west, so   * we unconditionally return <code>false</code> here. Subclasses that   * support bidirectional text may wish to override this method.   *   * @param pos the position in the document   * @param bias the bias to be applied to <code>pos</code>   *   * @return <code>true</code> if the next <code>View</code> is located   *         to the EAST, <code>false</code> otherwise   */  protected boolean flipEastAndWestAtEnds(int pos, Position.Bias bias)  {    return false;  }  /**   * Returns the document position that is (visually) nearest to the given   * document position <code>pos</code> in the given direction <code>d</code>.   *   * @param c the text component   * @param pos the document position   * @param b the bias for <code>pos</code>   * @param d the direction, must be either {@link SwingConstants#NORTH},   *        {@link SwingConstants#SOUTH}, {@link SwingConstants#WEST} or   *        {@link SwingConstants#EAST}   * @param biasRet an array of {@link Position.Bias} that can hold at least   *        one element, which is filled with the bias of the return position   *        on method exit   *   * @return the document position that is (visually) nearest to the given   *         document position <code>pos</code> in the given direction   *         <code>d</code>   *   * @throws BadLocationException if <code>pos</code> is not a valid offset in   *         the document model   */  public int getNextVisualPositionFrom(JTextComponent c, int pos,                                       Position.Bias b, int d,                                       Position.Bias[] biasRet)    throws BadLocationException  {    // TODO: Implement this properly.    throw new AssertionError("Not implemented yet.");  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -