Java 类javax.swing.text.View 实例源码

项目:incubator-netbeans    文件:FoldView.java   
@Override
public float getPreferredSpan(int axis) {
    if (axis == View.X_AXIS) {
        String desc = fold.getDescription(); // For empty desc a single-space text layout is returned
        float advance = 0;
        if (desc.length() > 0) {
            TextLayout textLayout = getTextLayout();
            if (textLayout == null) {
                return 0f;
            }
            advance = textLayout.getAdvance();
        }
        return advance + (2 * EXTRA_MARGIN_WIDTH);
    } else {
        EditorView.Parent parent = (EditorView.Parent) getParent();
        return (parent != null) ? parent.getViewRenderContext().getDefaultRowHeight() : 0f;
    }
}
项目:OpenJSharp    文件:BasicTabbedPaneUI.java   
protected int calculateTabHeight(int tabPlacement, int tabIndex, int fontHeight) {
    int height = 0;
    Component c = tabPane.getTabComponentAt(tabIndex);
    if (c != null) {
        height = c.getPreferredSize().height;
    } else {
        View v = getTextViewForTab(tabIndex);
        if (v != null) {
            // html
            height += (int) v.getPreferredSpan(View.Y_AXIS);
        } else {
            // plain text
            height += fontHeight;
        }
        Icon icon = getIconForTab(tabIndex);

        if (icon != null) {
            height = Math.max(height, icon.getIconHeight());
        }
    }
    Insets tabInsets = getTabInsets(tabPlacement, tabIndex);
    height += tabInsets.top + tabInsets.bottom + 2;
    return height;
}
项目:incubator-netbeans    文件:DrawEngineDocView.java   
public @Override void setParent(View parent) {
    if (parent != null) { // start listening
        JTextComponent component = (JTextComponent)parent.getContainer();
        TextUI tui = component.getUI();
        if (tui instanceof BaseTextUI){
            editorUI = ((BaseTextUI)tui).getEditorUI();
            if (editorUI!=null){
                editorUI.addPropertyChangeListener(this);
            }
        }
    }

    super.setParent(parent);

    if (parent == null) {
        if (editorUI!=null){
            editorUI.removePropertyChangeListener(this);
            editorUI = null;
        }
    }
}
项目:openjdk-jdk10    文件:SynthTabbedPaneUI.java   
private void paintText(SynthContext ss,
                         Graphics g, int tabPlacement,
                         Font font, FontMetrics metrics, int tabIndex,
                         String title, Rectangle textRect,
                         boolean isSelected) {
    g.setFont(font);

    View v = getTextViewForTab(tabIndex);
    if (v != null) {
        // html
        v.paint(g, textRect);
    } else {
        // plain text
        int mnemIndex = tabPane.getDisplayedMnemonicIndexAt(tabIndex);

        g.setColor(ss.getStyle().getColor(ss, ColorType.TEXT_FOREGROUND));
        ss.getStyle().getGraphicsUtils(ss).paintText(ss, g, title,
                              textRect, mnemIndex);
    }
}
项目:jdk8u-jdk    文件:AquaTabbedPaneUI.java   
protected void paintTitle(final Graphics2D g2d, final Font font, final FontMetrics metrics, final Rectangle textRect, final int tabIndex, final String title) {
    final View v = getTextViewForTab(tabIndex);
    if (v != null) {
        v.paint(g2d, textRect);
        return;
    }

    if (title == null) return;

    final Color color = tabPane.getForegroundAt(tabIndex);
    if (color instanceof UIResource) {
        // sja fix getTheme().setThemeTextColor(g, isSelected, isPressed && tracking, tabPane.isEnabledAt(tabIndex));
        if (tabPane.isEnabledAt(tabIndex)) {
            g2d.setColor(Color.black);
        } else {
            g2d.setColor(Color.gray);
        }
    } else {
        g2d.setColor(color);
    }

    g2d.setFont(font);
    SwingUtilities2.drawString(tabPane, g2d, title, textRect.x, textRect.y + metrics.getAscent());
}
项目:OpenJSharp    文件:AquaTabbedPaneCopyFromBasicUI.java   
private void updateHtmlViews(int index) {
    final String title = tabPane.getTitleAt(index);
    final boolean isHTML = BasicHTML.isHTMLString(title);
    if (isHTML) {
        if (htmlViews == null) { // Initialize vector
            htmlViews = createHTMLVector();
        } else { // Vector already exists
            final View v = BasicHTML.createHTMLView(tabPane, title);
            htmlViews.insertElementAt(v, index);
        }
    } else { // Not HTML
        if (htmlViews != null) { // Add placeholder
            htmlViews.insertElementAt(null, index);
        } // else nada!
    }
    updateMnemonics();
}
项目:incubator-netbeans    文件:ViewUtilitiesImpl.java   
public int updateIndex(int viewIndex, int offset, View view, FlyView.Parent flyParent) {
    while (--viewIndex >= 0) {
        int startOffset = (flyParent != null)
            ? flyParent.getStartOffset(viewIndex)
            : view.getView(viewIndex).getStartOffset();
        if (startOffset != offset) { // view starts below offset
            if (lowerAdjacent) {
                viewIndex--; // return the lower view that ends at offset
            }

            break;
        }
    }

    return viewIndex + 1;
}
项目:Moenagade    文件:Baseline.java   
/**
   * Returns the baseline for single line text components, like
   * <code>JTextField</code>.
   */
  private static int getSingleLineTextBaseline(JTextComponent textComponent,
                                               int h) {
      View rootView = textComponent.getUI().getRootView(textComponent);
      if (rootView.getViewCount() > 0) {
          Insets insets = textComponent.getInsets();
          int height = h - insets.top - insets.bottom;
          int y = insets.top;
          View fieldView = rootView.getView(0);
   int vspan = (int)fieldView.getPreferredSpan(View.Y_AXIS);
   if (height != vspan) {
int slop = height - vspan;
y += slop / 2;
   }
          FontMetrics fm = textComponent.getFontMetrics(
                               textComponent.getFont());
          y += fm.getAscent();
          return y;
      }
      return -1;
  }
项目:incubator-netbeans    文件:DrawEngineTest.java   
@RandomlyFails
public void testBackwardBias() throws Throwable {
    JEditorPane jep = createJep(PYRAMID);
    View rootView = Utilities.getRootView(jep, DrawEngineDocView.class);
    for(int i = 1; i < rootView.getViewCount(); i++) {
        int backwardBiasOffset = rootView.getView(i).getStartOffset();
        int previousLineEOLOffset = rootView.getView(i - 1).getEndOffset() - 1;

        Rectangle r1 = jep.getUI().modelToView(jep, backwardBiasOffset, Position.Bias.Backward);
        Rectangle r2 = jep.getUI().modelToView(jep, previousLineEOLOffset, Position.Bias.Forward);

        assertEquals("Wrong backward bias offset translation: offset = " + backwardBiasOffset
            + ", previousLineEOLOffset = " + previousLineEOLOffset
            + ", docLen = " + jep.getDocument().getLength(), r2, r1);
    }
}
项目:openjdk-jdk10    文件:AquaTabbedPaneContrastUI.java   
protected void paintTitle(final Graphics2D g2d, final Font font, final FontMetrics metrics, final Rectangle textRect, final int tabIndex, final String title) {
    final View v = getTextViewForTab(tabIndex);
    if (v != null) {
        v.paint(g2d, textRect);
        return;
    }

    if (title == null) return;

    final Color color = tabPane.getForegroundAt(tabIndex);
    if (color instanceof UIResource) {
        g2d.setColor(getNonSelectedTabTitleColor());
        if (tabPane.getSelectedIndex() == tabIndex) {
            boolean pressed = isPressedAt(tabIndex);
            boolean enabled = tabPane.isEnabled() && tabPane.isEnabledAt(tabIndex);
            Color textColor = getSelectedTabTitleColor(enabled, pressed);
            Color shadowColor = getSelectedTabTitleShadowColor(enabled);
            AquaUtils.paintDropShadowText(g2d, tabPane, font, metrics, textRect.x, textRect.y, 0, 1, textColor, shadowColor, title);
            return;
        }
    } else {
        g2d.setColor(color);
    }
    g2d.setFont(font);
    SwingUtilities2.drawString(tabPane, g2d, title, textRect.x, textRect.y + metrics.getAscent());
}
项目:incubator-netbeans    文件:GapBoxView.java   
/**
 * Provides a mapping from the document model coordinate space
 * to the coordinate space of the view mapped to it.
 *
 * @param pos the position to convert &gt;= 0
 * @param a the allocated region to render into
 * @param b the bias toward the previous character or the
 *  next character represented by the offset, in case the
 *  position is a boundary of two views.
 * @return the bounding box of the given position is returned
 * @exception BadLocationException  if the given position does
 *   not represent a valid location in the associated document
 * @exception IllegalArgumentException for an invalid bias argument
 * @see View#viewToModel
 */
public Shape modelToView(int pos, Shape a, Position.Bias b) throws BadLocationException {
    int index = getViewIndex(pos, b);
    if (index >= 0) {
        Shape ca = getChildAllocation(index, a);

        // forward to the child view
        ViewLayoutState child = getChild(index);
        View cv = child.getView();
        return cv.modelToView(pos, ca, b);
    } else {
        Document doc = getDocument();
        int docLen = (doc != null) ? doc.getLength() : -1;
        throw new BadLocationException("Offset " + pos + " with bias " + b + " is outside of the view" //NOI18N
            + ", children = " + getViewCount() //NOI18N
            + (getViewCount() > 0 ? " covering offsets <" +  //NOI18N
                getView(0).getStartOffset() + ", " +  //NOI18N
                getView(getViewCount() - 1).getEndOffset() + ">" : "") + //NOI18N
                ", docLen=" + docLen
            , pos);
    }
}
项目:OpenJSharp    文件:SynthToolTipUI.java   
/**
 * Paints the specified component.
 *
 * @param context context for the component being painted
 * @param g the {@code Graphics} object used for painting
 * @see #update(Graphics,JComponent)
 */
protected void paint(SynthContext context, Graphics g) {
    JToolTip tip = (JToolTip)context.getComponent();

    Insets insets = tip.getInsets();
    View v = (View)tip.getClientProperty(BasicHTML.propertyKey);
    if (v != null) {
        Rectangle paintTextR = new Rectangle(insets.left, insets.top,
              tip.getWidth() - (insets.left + insets.right),
              tip.getHeight() - (insets.top + insets.bottom));
        v.paint(g, paintTextR);
    } else {
        g.setColor(context.getStyle().getColor(context,
                                               ColorType.TEXT_FOREGROUND));
        g.setFont(style.getFont(context));
        context.getStyle().getGraphicsUtils(context).paintText(
            context, g, tip.getTipText(), insets.left, insets.top, -1);
    }
}
项目:jdk8u-jdk    文件:AquaTabbedPaneCopyFromBasicUI.java   
protected int calculateTabWidth(final int tabPlacement, final int tabIndex, final FontMetrics metrics) {
    final Insets tabInsets = getTabInsets(tabPlacement, tabIndex);
    int width = tabInsets.left + tabInsets.right + 3;
    final Component tabComponent = tabPane.getTabComponentAt(tabIndex);
    if (tabComponent != null) {
        width += tabComponent.getPreferredSize().width;
    } else {
        final Icon icon = getIconForTab(tabIndex);
        if (icon != null) {
            width += icon.getIconWidth() + textIconGap;
        }
        final View v = getTextViewForTab(tabIndex);
        if (v != null) {
            // html
            width += (int)v.getPreferredSpan(View.X_AXIS);
        } else {
            // plain text
            final String title = tabPane.getTitleAt(tabIndex);
            width += SwingUtilities2.stringWidth(tabPane, metrics, title);
        }
    }
    return width;
}
项目:jdk8u-jdk    文件:BasicTabbedPaneUI.java   
protected int calculateTabWidth(int tabPlacement, int tabIndex, FontMetrics metrics) {
    Insets tabInsets = getTabInsets(tabPlacement, tabIndex);
    int width = tabInsets.left + tabInsets.right + 3;
    Component tabComponent = tabPane.getTabComponentAt(tabIndex);
    if (tabComponent != null) {
        width += tabComponent.getPreferredSize().width;
    } else {
        Icon icon = getIconForTab(tabIndex);
        if (icon != null) {
            width += icon.getIconWidth() + textIconGap;
        }
        View v = getTextViewForTab(tabIndex);
        if (v != null) {
            // html
            width += (int) v.getPreferredSpan(View.X_AXIS);
        } else {
            // plain text
            String title = tabPane.getTitleAt(tabIndex);
            width += SwingUtilities2.stringWidth(tabPane, metrics, title);
        }
    }
    return width;
}
项目:jdk8u-jdk    文件:AquaTabbedPaneCopyFromBasicUI.java   
protected void layoutLabel(final int tabPlacement, final FontMetrics metrics, final int tabIndex, final String title, final Icon icon, final Rectangle tabRect, final Rectangle iconRect, final Rectangle textRect, final boolean isSelected) {
    textRect.x = textRect.y = iconRect.x = iconRect.y = 0;

    final View v = getTextViewForTab(tabIndex);
    if (v != null) {
        tabPane.putClientProperty("html", v);
    }

    SwingUtilities.layoutCompoundLabel(tabPane, metrics, title, icon, SwingConstants.CENTER, SwingConstants.CENTER, SwingConstants.CENTER, SwingConstants.TRAILING, tabRect, iconRect, textRect, textIconGap);

    tabPane.putClientProperty("html", null);

    final int xNudge = getTabLabelShiftX(tabPlacement, tabIndex, isSelected);
    final int yNudge = getTabLabelShiftY(tabPlacement, tabIndex, isSelected);
    iconRect.x += xNudge;
    iconRect.y += yNudge;
    textRect.x += xNudge;
    textRect.y += yNudge;
}
项目:jdk8u-jdk    文件:bug6670274.java   
private static void check(TestTabbedPaneUI ui, int... indices) {
    for(int i = 0; i < ui.getTabbedPane().getTabCount(); i++) {
        System.out.print("Checking tab #" + i);
        View view = ui.getTextViewForTab(i);
        boolean found = false;
        for (int j = 0; j < indices.length; j++) {
            if (indices[j]== i) {
                found = true;
                break;
            }
        }
        System.out.print("; view = " + view);
        if (found) {
            if (view == null) {
                throw new RuntimeException("View is unexpectedly null");
            }
        } else if (view != null) {
            throw new RuntimeException("View is unexpectedly not null");
        }
        System.out.println(" ok");
    }
    System.out.println("");
}
项目:jdk8u-jdk    文件:AquaTabbedPaneContrastUI.java   
protected void paintTitle(final Graphics2D g2d, final Font font, final FontMetrics metrics, final Rectangle textRect, final int tabIndex, final String title) {
    final View v = getTextViewForTab(tabIndex);
    if (v != null) {
        v.paint(g2d, textRect);
        return;
    }

    if (title == null) return;

    final Color color = tabPane.getForegroundAt(tabIndex);
    if (color instanceof UIResource) {
        g2d.setColor(getNonSelectedTabTitleColor());
        if (tabPane.getSelectedIndex() == tabIndex) {
            boolean pressed = isPressedAt(tabIndex);
            boolean enabled = tabPane.isEnabled() && tabPane.isEnabledAt(tabIndex);
            Color textColor = getSelectedTabTitleColor(enabled, pressed);
            Color shadowColor = getSelectedTabTitleShadowColor(enabled);
            AquaUtils.paintDropShadowText(g2d, tabPane, font, metrics, textRect.x, textRect.y, 0, 1, textColor, shadowColor, title);
            return;
        }
    } else {
        g2d.setColor(color);
    }
    g2d.setFont(font);
    SwingUtilities2.drawString(tabPane, g2d, title, textRect.x, textRect.y + metrics.getAscent());
}
项目:powertext    文件:RTextAreaHighlighter.java   
protected void paintListLayered(Graphics g, int lineStart, int lineEnd,
        Shape viewBounds, JTextComponent editor, View view,
        List<? extends HighlightInfo> highlights) {
    for (int i=highlights.size()-1; i>=0; i--) {
        HighlightInfo tag = highlights.get(i);
        if (tag instanceof LayeredHighlightInfo) {
            LayeredHighlightInfo lhi = (LayeredHighlightInfo)tag;
            int highlightStart = lhi.getStartOffset();
            int highlightEnd = lhi.getEndOffset() + 1; // "+1" workaround for Java highlight issues
            if ((lineStart < highlightStart && lineEnd > highlightStart) ||
                    (lineStart >= highlightStart && lineStart < highlightEnd)) {
                lhi.paintLayeredHighlights(g, lineStart, lineEnd, viewBounds,
                                editor, view);
            }
        }
    }
}
项目:incubator-netbeans    文件:DemoPanel.java   
@Override
public void setTipText(String tipText) {
    super.setTipText(tipText);
    if( getPreferredSize().width > 400 ) {
        View v = (View) getClientProperty("html"); //NOI18N
        if( null != v )
            v.setSize(300.0f, 300.0f);
    }
}
项目:incubator-netbeans    文件:FoldViewFactory.java   
public FoldViewFactory(View documentView) {
    super(documentView);
    foldHierarchy = FoldHierarchy.get(textComponent());
    // the view factory may get eventually GCed, but the FoldHierarchy can survive, snce it is tied to the component.
    weakL = WeakListeners.create(FoldHierarchyListener.class, this, foldHierarchy);
    foldHierarchy.addFoldHierarchyListener(weakL);
    // Go through folds and search for collapsed fold.
    foldHierarchy.lock();
    try {
        @SuppressWarnings("unchecked")
        Iterator<Fold> it = FoldUtilities.collapsedFoldIterator(foldHierarchy, 0, Integer.MAX_VALUE);
        collapsedFoldEncountered = it.hasNext();
    } finally {
        foldHierarchy.unlock();
    }

    displayAllFoldsExpanded = Boolean.TRUE.equals(textComponent().getClientProperty(DISPLAY_ALL_FOLDS_EXPANDED_PROPERTY));

    String mime = DocumentUtilities.getMimeType(document());

    Lookup lkp = MimeLookup.getLookup(mime);
    colorSource = lkp.lookupResult(FontColorSettings.class);
    colorSource.addLookupListener(WeakListeners.create(LookupListener.class, this, colorSource));
    colorSettings = (FontColorSettings)colorSource.allInstances().iterator().next();
    prefs = lkp.lookup(Preferences.class);
    prefs.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, this, prefs));

    initViewFlags();
}
项目:incubator-netbeans    文件:EditorView.java   
@Override
public Document getDocument() {
    View parent = getParent();
    // By default do not assume non-null element for view construction => return null
    // Possibly use getElement().getDocument() in descendants
    return (parent != null) ? parent.getDocument() : null;
}
项目:OpenJSharp    文件:BasicToolTipUI.java   
public Dimension getMaximumSize(JComponent c) {
    Dimension d = getPreferredSize(c);
    View v = (View) c.getClientProperty(BasicHTML.propertyKey);
    if (v != null) {
        d.width += v.getMaximumSpan(View.X_AXIS) - v.getPreferredSpan(View.X_AXIS);
    }
    return d;
}
项目:OpenJSharp    文件:AquaButtonUI.java   
public Dimension getMaximumSize(final JComponent c) {
    final Dimension d = getPreferredSize(c);

    final View v = (View)c.getClientProperty(BasicHTML.propertyKey);
    if (v != null) {
        d.width += v.getMaximumSpan(View.X_AXIS) - v.getPreferredSpan(View.X_AXIS);
    }

    return d;
}
项目:OpenJSharp    文件:BasicMenuItemUI.java   
public Dimension getMaximumSize(JComponent c) {
    Dimension d = null;
    View v = (View) c.getClientProperty(BasicHTML.propertyKey);
    if (v != null) {
        d = getPreferredSize(c);
        d.width += v.getMaximumSpan(View.X_AXIS) - v.getPreferredSpan(View.X_AXIS);
    }
    return d;
}
项目:OpenJSharp    文件:MultiTextUI.java   
/**
 * Invokes the <code>getRootView</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public View getRootView(JTextComponent a) {
    View returnValue =
        ((TextUI) (uis.elementAt(0))).getRootView(a);
    for (int i = 1; i < uis.size(); i++) {
        ((TextUI) (uis.elementAt(i))).getRootView(a);
    }
    return returnValue;
}
项目:jdk8u-jdk    文件:BasicLabelUI.java   
/**
 * @return getPreferredSize(c)
 */
public Dimension getMaximumSize(JComponent c) {
    Dimension d = getPreferredSize(c);
    View v = (View) c.getClientProperty(BasicHTML.propertyKey);
    if (v != null) {
        d.width += v.getMaximumSpan(View.X_AXIS) - v.getPreferredSpan(View.X_AXIS);
    }
    return d;
}
项目:VASSAL-src    文件:Chatter.java   
public View create(javax.swing.text.Element elem) {
  JTextComponent c = getComponent();
  if (c instanceof JTextArea) {
    JTextArea area = (JTextArea) c;
    View v;
    if (area.getLineWrap()) {
      v = new WrappedView(elem, area.getWrapStyleWord());
    }
    else {
      v = new PView(elem);
    }
    return v;
  }
  return null;
}
项目:openjdk-jdk10    文件:FPMethodCalledTest.java   
static void createAndShowGUI(Test test) {

        try {
            UIManager.setLookAndFeel(new MetalLookAndFeel());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

        frame = new JFrame();
        frame.setSize(300, 300);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JPanel panel = new JPanel(new FlowLayout());

        String text = "AAAAAAA";
        textField = test.isPasswordField()
                ? new JPasswordField(text)
                : new JTextField(text);

        textField.setUI(new MetalTextFieldUI() {

            @Override
            public View create(Element elem) {
                return test.createView(elem);
            }
        });

        panel.add(textField);
        frame.getContentPane().add(panel);
        frame.setVisible(true);
    }
项目:jdk8u-jdk    文件:BasicMenuItemUI.java   
public Dimension getMaximumSize(JComponent c) {
    Dimension d = null;
    View v = (View) c.getClientProperty(BasicHTML.propertyKey);
    if (v != null) {
        d = getPreferredSize(c);
        d.width += v.getMaximumSpan(View.X_AXIS) - v.getPreferredSpan(View.X_AXIS);
    }
    return d;
}
项目:incubator-netbeans    文件:SkipLinesViewFactory.java   
@Override
public float getPreferredSpan(int axis) {
    EditorView.Parent parent = (EditorView.Parent) getParent();
    if (axis == View.X_AXIS) {
        float advance = 0;
        TextLayout textLayout = getTextLayout();
        if (textLayout == null) {
            return 0f;
        }
        return textLayout.getAdvance();
    } else {
        return (parent != null) ? parent.getViewRenderContext().getDefaultRowHeight() : 0f;
    }
}
项目:openjdk-jdk10    文件:AquaTabbedPaneCopyFromBasicUI.java   
private void setHtmlView(View v, boolean inserted, int index) {
    if (inserted || index >= htmlViews.size()) {
        htmlViews.insertElementAt(v, index);
    } else {
        htmlViews.setElementAt(v, index);
    }
}
项目:powertext    文件:RSyntaxTextAreaHighlighter.java   
@Override
public void paintLayeredHighlights(Graphics g, int lineStart, int lineEnd,
                    Shape viewBounds, JTextComponent editor, View view) {
    paintListLayered(g, lineStart,lineEnd, viewBounds, editor, view, markedOccurrences);
    super.paintLayeredHighlights(g, lineStart, lineEnd, viewBounds, editor, view);
    paintListLayered(g, lineStart,lineEnd, viewBounds, editor, view, parserHighlights);
}
项目:openjdk-jdk10    文件:AquaButtonUI.java   
public Dimension getMinimumSize(final JComponent c) {
    final Dimension d = getPreferredSize(c);
    final View v = (View)c.getClientProperty(BasicHTML.propertyKey);
    if (v != null) {
        d.width -= v.getPreferredSpan(View.X_AXIS) - v.getMinimumSpan(View.X_AXIS);
    }
    return d;
}
项目:Equella    文件:FlatterTabbedPaneUI.java   
@Override
protected void paintText(Graphics g, int tabPlacement, Font font, FontMetrics metrics, int tabIndex, String title,
    Rectangle textRect, boolean isSelected)
{
    g.setFont(font);

    View v = getTextViewForTab(tabIndex);
    if( v != null )
    {
        // html
        v.paint(g, textRect);
    }
    else
    {
        // plain text
        int mnemIndex = tabPane.getDisplayedMnemonicIndexAt(tabIndex);

        if( tabPane.isEnabled() && tabPane.isEnabledAt(tabIndex) )
        {
            g.setColor(isSelected ? Color.white : Color.black);
            BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex, textRect.x,
                textRect.y + metrics.getAscent());
        }
        else
        { // tab disabled
            g.setColor(tabPane.getBackgroundAt(tabIndex).brighter());
            BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex, textRect.x,
                textRect.y + metrics.getAscent());
            g.setColor(tabPane.getBackgroundAt(tabIndex).darker());
            BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex, textRect.x,
                textRect.y + metrics.getAscent());
        }
    }
}
项目:powertext    文件:WrappedSyntaxView.java   
/**
 * Gives notification that something was removed from the
 * document in a location that this view is responsible for.
 * This is implemented to simply update the children.
 *
 * @param changes The change information from the associated document.
 * @param a the current allocation of the view
 * @param f the factory to use to rebuild if the view has children
 * @see View#removeUpdate
 */
@Override
public void removeUpdate(DocumentEvent changes, Shape a, ViewFactory f) {

    updateChildren(changes, a);

    Rectangle alloc = ((a != null) && isAllocationValid()) ?
                                getInsideAllocation(a) : null;
    int pos = changes.getOffset();
    View v = getViewAtPosition(pos, alloc);
    if (v != null) {
        v.removeUpdate(changes, alloc, f);
    }

}
项目:featurea    文件:ClasspathHtmlEditorKit.java   
@Override
public View create(Element elem) {
    Object o = elem.getAttributes().getAttribute(StyleConstants.NameAttribute);
    if (o instanceof HTML.Tag) {
        HTML.Tag kind = (HTML.Tag) o;
        if (kind == HTML.Tag.IMG) {
            return new ClasspathImageView(elem);
        }
    }
    return super.create(elem);
}
项目:OpenJSharp    文件:BasicLabelUI.java   
/**
 * @return getPreferredSize(c)
 */
public Dimension getMaximumSize(JComponent c) {
    Dimension d = getPreferredSize(c);
    View v = (View) c.getClientProperty(BasicHTML.propertyKey);
    if (v != null) {
        d.width += v.getMaximumSpan(View.X_AXIS) - v.getPreferredSpan(View.X_AXIS);
    }
    return d;
}
项目:jdk8u-jdk    文件:AquaButtonUI.java   
public Dimension getMaximumSize(final JComponent c) {
    final Dimension d = getPreferredSize(c);

    final View v = (View)c.getClientProperty(BasicHTML.propertyKey);
    if (v != null) {
        d.width += v.getMaximumSpan(View.X_AXIS) - v.getPreferredSpan(View.X_AXIS);
    }

    return d;
}
项目:incubator-netbeans    文件:DocumentView.java   
@Override
public float getPreferredSpan(int axis) {
    // Since this may be called e.g. from BasicTextUI.getPreferredSize()
    // this method needs to acquire mutex
    if (lock()) {
        try {
            checkDocumentLockedIfLogging(); // Should only be called with read-locked document
            op.checkViewsInited();
            // Ensure the width and height are updated before unlock() gets called (which is too late)
            op.checkRealSpanChange();
            if (!op.isChildrenValid()) {
                return 1f; // Return 1f until parent and etc. gets initialized
            }
            float span;
            if (axis == View.X_AXIS) {
                span = preferredWidth;
            } else { // Y_AXIS
                span = preferredHeight + op.getExtraVirtualHeight();
            }
            return span;
        } finally {
            unlock();
        }
    } else {
        return 1f;
    }
}
项目:incubator-netbeans    文件:TabView.java   
@Override
public float getPreferredSpan(int axis) {
    DocumentView docView = getDocumentView();
    return (axis == View.X_AXIS)
        ? width // Return last width computed by getTabbedSpan()
        : ((docView != null) ? docView.op.getDefaultRowHeight() : 0f);
}