Package javax.swing.plaf

Examples of javax.swing.plaf.TextUI


         *            wrap this components UI
         * @return a {@link PromptTextUI} which wraps the <code>textComponent</code>s UI.
         */
        @Override
        public PromptTextUI wrapUI(JTextComponent textComponent) {
            TextUI textUI = textComponent.getUI();

            if (textUI instanceof PromptTextUI) {
                return (PromptTextUI) textUI;
            } else if (textComponent instanceof JXSearchField) {
                return new SearchFieldUI(textUI);
            } else if (textComponent instanceof JTextField) {
                return new BuddyTextFieldUI(textUI);
            } else if (textComponent instanceof JTextArea) {
                return new PromptTextAreaUI(textUI);
            }
            throw new IllegalArgumentException("ui implementation not supported: "
                    + textUI.getClass());
        }
View Full Code Here


         * rectangles equals null, do nothing.
         *
         */
        public void paint(final Graphics g, final int p0, final int p1,
                          final Shape shape, final JTextComponent jtc) {
            TextUI textUI = jtc.getUI();
            if (textUI == null) {
                return;
            }

            int start = Math.min(p0, p1);
            int end = Math.max(p0, p1);
            Rectangle startRect = null;
            Rectangle endRect = null;
            Rectangle shapeBounds = shape.getBounds();

            try {
                startRect = textUI.modelToView(jtc, start,
                                               Position.Bias.Forward);
                endRect = textUI.modelToView(jtc, end, Position.Bias.Backward);
            } catch (final BadLocationException e) {
            }

            if (startRect == null || endRect == null) {
                return;
View Full Code Here

   * @see {@link #removeMarkOccurrencesHighlight(Object)}
   */
  Object addMarkedOccurrenceHighlight(int start, int end,
      MarkOccurrencesHighlightPainter p) throws BadLocationException {
    Document doc = textArea.getDocument();
    TextUI mapper = textArea.getUI();
    // Always layered highlights for marked occurrences.
    HighlightInfo i = new LayeredHighlightInfo();
    i.painter = p;
    i.p0 = doc.createPosition(start);
    // HACK: Use "end-1" to prevent chars the user types at the "end" of
    // the highlight to be absorbed into the highlight (default Highlight
    // behavior).
    i.p1 = doc.createPosition(end-1);
    markedOccurrences.add(i);
    mapper.damageRange(textArea, start, end);
    return i;
  }
View Full Code Here

   */
  Object addParserHighlight(ParserNotice notice, HighlightPainter p)
                throws BadLocationException {

    Document doc = textArea.getDocument();
    TextUI mapper = textArea.getUI();
    int start = notice.getOffset();
    int end = start + notice.getLength();

    // Always layered highlights for parser highlights.
    HighlightInfo i = new LayeredHighlightInfo();
    i.painter = p;
    i.p0 = doc.createPosition(start);
    i.p1 = doc.createPosition(end);
    i.notice = notice;//i.color = notice.getColor();

    parserHighlights.add(i);
    mapper.damageRange(textArea, start, end);
    return i;

  }
View Full Code Here

            textArea.repaint(lhi.x, lhi.y, lhi.width, lhi.height);
          }
      }
      else {
        HighlightInfo info = (HighlightInfo) tag;
        TextUI ui = textArea.getUI();
        ui.damageRange(textArea, info.getStartOffset(),info.getEndOffset());
        //safeDamageRange(info.p0, info.p1);
      }

    }
View Full Code Here

          textArea.repaint(lhi.x, lhi.y, lhi.width, lhi.height);
        }
    }
    else {
      HighlightInfo info = (HighlightInfo) tag;
      TextUI ui = textArea.getUI();
      ui.damageRange(textArea, info.getStartOffset(),info.getEndOffset());
      //safeDamageRange(info.p0, info.p1);
    }
    list.remove(tag);
  }
View Full Code Here

    }

    try {

      // Determine locations.
      TextUI mapper = c.getUI();
      Rectangle p0 = mapper.modelToView(c, offs0);
      Rectangle p1 = mapper.modelToView(c, offs1);
      Paint paint = getPaint();
      if (paint==null)
        g2d.setColor(c.getSelectionColor());
      else
        g2d.setPaint(paint);
View Full Code Here

            Object useMap = attr.getAttribute(HTML.Attribute.USEMAP);
            if (useMap != null && (useMap instanceof String)) {
                Map m = hdoc.getMap((String)useMap);
                if (m != null && offset < hdoc.getLength()) {
                    Rectangle bounds;
                    TextUI ui = html.getUI();
                    try {
                        Shape lBounds = ui.modelToView(html, offset,
                                                   Position.Bias.Forward);
                        Shape rBounds = ui.modelToView(html, offset + 1,
                                                   Position.Bias.Backward);
                        bounds = lBounds.getBounds();
                        bounds.add((rBounds instanceof Rectangle) ?
                                    (Rectangle)rBounds : rBounds.getBounds());
                    } catch (BadLocationException ble) {
View Full Code Here

        private boolean doesElementContainLocation(JEditorPane editor,
                                                   Element e, int offset,
                                                   int x, int y) {
            if (e != null && offset > 0 && e.getStartOffset() == offset) {
                try {
                    TextUI ui = editor.getUI();
                    Shape s1 = ui.modelToView(editor, offset,
                                              Position.Bias.Forward);
                    if (s1 == null) {
                        return false;
                    }
                    Rectangle r1 = (s1 instanceof Rectangle) ? (Rectangle)s1 :
                                    s1.getBounds();
                    Shape s2 = ui.modelToView(editor, e.getEndOffset(),
                                              Position.Bias.Backward);
                    if (s2 != null) {
                        Rectangle r2 = (s2 instanceof Rectangle) ? (Rectangle)s2 :
                                    s2.getBounds();
                        r1.add(r2);
View Full Code Here

         */
        public void paint(Graphics g, int offs0, int offs1, Shape bounds, JTextComponent c) {
      Rectangle alloc = bounds.getBounds();
      try {
    // --- determine locations ---
    TextUI mapper = c.getUI();
    Rectangle p0 = mapper.modelToView(c, offs0);
    Rectangle p1 = mapper.modelToView(c, offs1);

    // --- render ---
    Color color = getColor();

    if (color == null) {
View Full Code Here

TOP

Related Classes of javax.swing.plaf.TextUI

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.