Package at.bestsolution.efxclipse.styledtext

Examples of at.bestsolution.efxclipse.styledtext.StyleRange


    document.setDocumentPartitioner(partitioner);
    update();
  }
 
  private StyleRange createStyleRange(int start, int length, TextAttribute attribute) {
    StyleRange r = new StyleRange(start, length, attribute.getForeground(), attribute.getBackground());
    r.font = attribute.getFont();
    return r;
  }
View Full Code Here


   */
  protected void addRange(TextPresentation presentation, int offset, int length, TextAttribute attr) {
    if (attr != null) {
      int style= attr.getStyle();
      int fontStyle= style & (StyleRange.ITALIC | StyleRange.BOLD | StyleRange.NORMAL);
      StyleRange styleRange= new StyleRange(offset, length, attr.getForeground(), attr.getBackground(), fontStyle);
      styleRange.strikeout= (style & TextAttribute.STRIKETHROUGH) != 0;
      styleRange.underline= (style & TextAttribute.UNDERLINE) != 0;
      styleRange.font= attr.getFont();
      presentation.addStyleRange(styleRange);
    }
View Full Code Here

  private void applyTextPresentation(TextPresentation presentation) {

    List<StyleRange> list= new ArrayList<>(presentation.getDenumerableRanges());
    Iterator<StyleRange> e = presentation.getAllStyleRangeIterator();
    while (e.hasNext()) {
      StyleRange range= e.next();
      range= modelStyleRange2WidgetStyleRange(range);
      if (range != null)
        list.add(range);
    }
View Full Code Here

   *
   * @param presentation the presentation to be added
   */
  private void addPresentation(TextPresentation presentation) {

    StyleRange range= presentation.getDefaultStyleRange();
    if (range != null) {

      range= modelStyleRange2WidgetStyleRange(range);
      if (range != null)
        textWidget.setStyleRange(range);
View Full Code Here

   * @since 2.1
   */
  protected StyleRange modelStyleRange2WidgetStyleRange(StyleRange range) {
    IRegion region= modelRange2WidgetRange(new Region(range.start, range.length));
    if (region != null) {
      StyleRange result= (StyleRange) range.clone();
      result.start= region.getOffset();
      result.length= region.getLength();
      return result;
    }
    return null;
View Full Code Here

   */
  protected TextPresentation createPresentation(IRegion damage, IDocument document) {
    try {
      if (fRepairers == null || fRepairers.isEmpty()) {
        TextPresentation presentation= new TextPresentation(damage, 100);
        presentation.setDefaultStyleRange(new StyleRange(damage.getOffset(), damage.getLength(), null, null));
        return presentation;
      }

      TextPresentation presentation= new TextPresentation(damage, 1000);

View Full Code Here

   * is relative to the start of the result window.
   *
   * @return this presentation's default style range
   */
  public StyleRange getDefaultStyleRange() {
    StyleRange range= createWindowRelativeRange(fResultWindow, fDefaultRange);
    if (range == null)
      return null;
    return (StyleRange)range.clone();

  }
View Full Code Here

    int start= range.start;
    int length= range.length;
    int end= start + length;

    if (fRanges.size() == 0) {
      StyleRange defaultRange= getDefaultStyleRange();
      if (defaultRange == null)
        defaultRange= range;

      defaultRange.start= start;
      defaultRange.length= length;
      applyStyle(range, defaultRange, merge);
      fRanges.add(defaultRange);
    } else {
      IRegion rangeRegion= new Region(start, length);
      int first= getFirstIndexInWindow(rangeRegion);

      if (first == fRanges.size()) {
        StyleRange defaultRange= getDefaultStyleRange();
        if (defaultRange == null)
          defaultRange= range;
        defaultRange.start= start;
        defaultRange.length= length;
        applyStyle(range, defaultRange, merge);
        fRanges.add(defaultRange);
        return;
      }

      int last= getFirstIndexAfterWindow(rangeRegion);
      for (int i= first; i < last && length > 0; i++) {

        StyleRange current= (StyleRange)fRanges.get(i);
        int currentStart= current.start;
        int currentEnd= currentStart + current.length;

        if (end <= currentStart) {
          fRanges.add(i, range);
          return;
        }

        if (start >= currentEnd)
          continue;

        StyleRange currentCopy= null;
        if (end < currentEnd)
          currentCopy= (StyleRange)current.clone();

        if (start < currentStart) {
          // Apply style to new default range and add it
          StyleRange defaultRange= getDefaultStyleRange();
          if (defaultRange == null)
            defaultRange= new StyleRange();

          defaultRange.start= start;
          defaultRange.length= currentStart - start;
          applyStyle(range, defaultRange, merge);
          fRanges.add(i, defaultRange);
          i++; last++;


          // Apply style to first part of current range
          current.length= Math.min(end, currentEnd) - currentStart;
          applyStyle(range, current, merge);
        }

        if (start >= currentStart) {
          // Shorten the current range
          current.length= start - currentStart;

          // Apply the style to the rest of the current range and add it
          if (current.length > 0) {
            current= (StyleRange)current.clone();
            i++; last++;
            fRanges.add(i, current);
          }
          applyStyle(range, current, merge);
          current.start= start;
          current.length= Math.min(end, currentEnd) - start;
        }

        if (end < currentEnd) {
          // Add rest of current range
          currentCopy.start= end;
          currentCopy.length= currentEnd - end;
          i++; last++;
          fRanges.add(i,  currentCopy);
        }

        // Update range
        range.start=  currentEnd;
        range.length= Math.max(end - currentEnd, 0);
        start= range.start;
        length= range.length;
      }
      if (length > 0) {
        // Apply style to new default range and add it
        StyleRange defaultRange= getDefaultStyleRange();
        if (defaultRange == null)
          defaultRange= range;
        defaultRange.start= start;
        defaultRange.length= end - start;
        applyStyle(range, defaultRange, merge);
View Full Code Here

  private void applyStyleRanges(StyleRange[] ranges, boolean merge) {
    int j= 0;
    ArrayList oldRanges= fRanges;
    ArrayList newRanges= new ArrayList(2*ranges.length + oldRanges.size());
    for (int i= 0, n= ranges.length; i < n; i++) {
      StyleRange range= ranges[i];
      fRanges= oldRanges; // for getFirstIndexAfterWindow(...)
      for (int m= getFirstIndexAfterWindow(new Region(range.start, range.length)); j < m; j++)
        newRanges.add(oldRanges.get(j));
      fRanges= newRanges; // for mergeStyleRange(...)
      applyStyleRange(range, merge);
View Full Code Here

    if (window != null) {
      int start= window.getOffset();
      int i= -1, j= fRanges.size();
      while (j - i > 1) {
        int k= (i + j) >> 1;
        StyleRange r= (StyleRange) fRanges.get(k);
        if (r.start + r.length > start)
          j= k;
        else
          i= k;
      }
View Full Code Here

TOP

Related Classes of at.bestsolution.efxclipse.styledtext.StyleRange

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.