Examples of TabStop


Examples of com.ibm.richtext.styledtext.TabStop

        // I tried (MS Word and Lotus Word Pro).
       
        line.fSegments.removeAllElements();
        line.fCharLength = 0;

        TabStop currentTabStop = new TabStop((int)fLeadingMargin+lineIndent, TabStop.kLeading);

        int segmentLimit = measurer.getPosition();
        boolean firstSegment = true;

        int advanceFromLeadingMargin = lineIndent;

        boolean computeSegs = true;
       
        computeTabbedSegments: do {

            // compute sementLimit:
            if (segmentLimit <= measurer.getPosition()) {
                while (segmentLimit < paragraphLimit) {
                    if (isTab(text.at(segmentLimit++))) {
                        break;
                    }
                }
            }

            // NOTE:  adjust available width for center tab!!!
            //System.out.println("Format width: " + (formatWidth-advanceFromLeadingMargin) +
            //                   ";  segmentLimit: " + segmentLimit);

            int wrappingWidth = Math.max(formatWidth-advanceFromLeadingMargin, 0);
            TextLayout layout = null;
            if (firstSegment || wrappingWidth > 0 || segmentLimit > measurer.getPosition()+1) {
                layout = measurer.nextLayout(wrappingWidth, segmentLimit, !firstSegment);
            }

            if (layout == null) {
                if (firstSegment) {
                    // I doubt this would happen, but check anyway
                    throw new Error("First layout is null!");
                }
                break computeTabbedSegments;
            }
           
            final int measurerPos = measurer.getPosition();
            if (measurerPos < segmentLimit) {
                computeSegs = false;
                if (fFlush == FULLY_JUSTIFIED) {
                    layout = layout.getJustifiedLayout(wrappingWidth);
                }
            }
            else {
                computeSegs = !(measurerPos == paragraphLimit);
            }

            if (firstSegment) {
                firstSegment = false;
                // Have to get ltr off of layout.  Not available from measurer,
                // unfortunately.
                line.fLeftToRight = layout.isLeftToRight();
            }

            BidiSegment segment = new BidiSegment();
            segment.fLayout = layout;
            int layoutAdvance = (int) Math.ceil(layout.getAdvance());

            // position layout relative to leading margin, update logicalPositionOnLine
           
            int relativeTabPosition = currentTabStop.getPosition()-(int)fLeadingMargin;
            int logicalPositionOfLayout;
            switch (currentTabStop.getType()) {
                case TabStop.kTrailing:
                    logicalPositionOfLayout = Math.max(
                                    relativeTabPosition-layoutAdvance,
                                    advanceFromLeadingMargin);
                    break;
                case TabStop.kCenter:
                    logicalPositionOfLayout = Math.max(
                                    relativeTabPosition-(layoutAdvance/2),
                                    advanceFromLeadingMargin);
                    break;
                default// includes decimal tab right now
                    logicalPositionOfLayout = relativeTabPosition;
                    break;
            }

            // position layout in segment
            if (line.fLeftToRight) {
                segment.fDistanceFromLeadingMargin = logicalPositionOfLayout;
            }
            else {
                segment.fDistanceFromLeadingMargin = logicalPositionOfLayout+layoutAdvance;
            }

            // update advanceFromLeadingMargin
            advanceFromLeadingMargin = logicalPositionOfLayout + layoutAdvance;

            // add segment to segment Vector
            line.fSegments.addElement(segment);

            // get next tab
            currentTabStop = fTabRuler.nextTab((int)fLeadingMargin+advanceFromLeadingMargin);
            if (currentTabStop.getType() == TabStop.kLeading ||
                            currentTabStop.getType() == TabStop.kAuto)  {
                advanceFromLeadingMargin = currentTabStop.getPosition();
                //System.out.println("Advance from leading margin:" + advanceFromLeadingMargin);

            }
            else {
               //System.out.println("Non-leading tab, type=" + currentTabStop.getType());
            }

        } while (computeSegs);

        // Now compute fTotalAdvance, fVisibleAdvance.  These metrics may be affected
        // by a trailing tab.

        {
            BidiSegment lastSegment = (BidiSegment) line.fSegments.lastElement();
            TextLayout lastLayout = lastSegment.fLayout;

            if (line.fLeftToRight) {
                line.fTotalAdvance = (int) Math.ceil(lastLayout.getAdvance()) +
                                        lastSegment.fDistanceFromLeadingMargin;
                line.fVisibleAdvance = (int) Math.ceil(lastLayout.getVisibleAdvance()) +
                                        lastSegment.fDistanceFromLeadingMargin;
            }
            else {
                line.fTotalAdvance = lastSegment.fDistanceFromLeadingMargin;
                line.fVisibleAdvance = lastSegment.fDistanceFromLeadingMargin -
                                        (int) Math.ceil(lastLayout.getAdvance() -
                                            lastLayout.getVisibleAdvance());
            }

            if (isTab(text.at(measurer.getPosition()-1))) {
                line.fTotalAdvance = Math.max(line.fTotalAdvance,
                                                currentTabStop.getPosition());
            }
        }
    }
View Full Code Here

Examples of com.ibm.richtext.styledtext.TabStop

        if (fTextPanel != null) {

            StyleModifier modifier;

            if (change == kTrackTab) {
                TabStop newTab = fTrackTab==null? null : fTrackTab.getTabStop();
                modifier = new TabRulerModifier(fOldTab, newTab, fTextPanel.getDefaultValues());
            }
            else {
                Object key;
                Object value;
View Full Code Here

Examples of com.ibm.richtext.styledtext.TabStop

        TabStopBuffer(TabStop tab) {
            this(tab.getPosition(), tab.getType());
        }

        TabStop getTabStop() {
            return new TabStop(fPosition, fType);
        }
View Full Code Here

Examples of com.ibm.richtext.styledtext.TabStop

                if (++index == lengths.length)
                    index = 0;
            }

            // paint tabs
            TabStop tab = fRuler.firstTab();
            while (tab != null && tab.getPosition() < fTrailingMarginPosition) {
                boolean dodraw = true;
                if (tab.getType() == TabStop.kAuto) {
                    if (tab.getPosition() <= Math.max(fLeadingMargin, fFirstLineIndent))
                        dodraw = false;
                    else if (tab.getPosition() >= fTrailingMarginPosition)
                        dodraw = false;
                }

                if (dodraw)
                    drawTab(gCache, tab.getPosition(), tab.getType(), baseline2, baseline10);

                tab = fRuler.nextTab(tab.getPosition());
            }

            gCache.drawLine(0, baseline12, width, baseline12);

            // paint others except for tracked item
View Full Code Here

Examples of com.ibm.richtext.styledtext.TabStop

                fTrackItem = kTrackTab;
                fTrackTab = new TabStopBuffer(alignInt(x), TabStop.kLeading);
                fTrackDelta = fTrackTab.fPosition - x;
                fTrackVisible = true;
            } else {
                TabStop tab = fRuler.firstTab();
                while (tab.getType() != TabStop.kAuto) {
                    if (x < tab.getPosition() - 3)
                        break;
                    if (x < tab.getPosition() + 3) {
                        fOldTab = tab;
                        fTrackTab = new TabStopBuffer(tab);
                        fRuler = fRuler.removeTab(fOldTab.getPosition());

                        if (e.getClickCount() > 1) {
                            switch (fTrackTab.fType) {
                                case TabStop.kLeading: fTrackTab.fType = TabStop.kCenter; break;
                                case TabStop.kCenter: fTrackTab.fType = TabStop.kTrailing; break;
                                case TabStop.kTrailing: fTrackTab.fType = TabStop.kDecimal; break;
                                case TabStop.kDecimal: fTrackTab.fType = TabStop.kLeading; break;
                                default: break;
                            }
                        }
                        fTrackItem = kTrackTab;
                        fTrackDelta = tab.getPosition() - x;
                        fTrackVisible = true;
                        break;
                    }

                    tab = fRuler.nextTab(tab.getPosition());
                }
            }

            if (fTrackItem != kTrackNone) {
                fImageCache.setValid(false);
View Full Code Here

Examples of com.itextpdf.text.TabStop

        int oldCurrentChar = currentChar;
        int uniC = 0;
        PdfChunk ck = null;
        float charWidth = 0;
        PdfChunk lastValidChunk = null;
        TabStop tabStop = null;
        float tabStopAnchorPosition = Float.NaN;
        float tabPosition = Float.NaN;
        boolean surrogate = false;
        for (; currentChar < totalTextLength; ++currentChar) {
            ck = detailChunks[currentChar];
            if (ck.isImage() && minY < yLine) {
                Image img = ck.getImage();
                if (img.isScaleToFitHeight() && yLine + 2 * descender - img.getScaledHeight() - ck.getImageOffsetY() - img.getSpacingBefore() < minY) {
                    float scalePercent = (yLine + 2 * descender - ck.getImageOffsetY() - img.getSpacingBefore() - minY) / img.getScaledHeight();
                  ck.setImageScalePercentage(scalePercent);
                }
            }
            surrogate = Utilities.isSurrogatePair(text, currentChar);
            if (surrogate)
                uniC = ck.getUnicodeEquivalent(Utilities.convertToUtf32(text, currentChar));
            else
                uniC = ck.getUnicodeEquivalent(text[currentChar]);
            if (PdfChunk.noPrint(uniC))
                continue;
            if (surrogate)
                charWidth = ck.getCharWidth(uniC);
            else {
                if (ck.isImage()) {
                    charWidth = ck.getImageWidth();
                } else {
                    charWidth = ck.getCharWidth(text[currentChar]);
                }
            }
            if (width - charWidth < 0) {
              // If the chunk is an image and it is the first one in line, check if resize requested
              // If so, resize to fit the current line width
              if (lastValidChunk == null && ck.isImage()) {
                Image img = ck.getImage();
                if (img.isScaleToFitLineWhenOverflow()) {
                  //float scalePercent = width / img.getWidth() * 100;
                  //img.scalePercent(scalePercent);
                  float scalePercent = width / img.getWidth();
                  ck.setImageScalePercentage(scalePercent);
                  charWidth = width;
                }
              }
            }
            if (ck.isTab()) {
                if (ck.isAttribute(Chunk.TABSETTINGS)) {
                    lastSplit = currentChar;
                    if (tabStop != null) {
                        float tabStopPosition = tabStop.getPosition(tabPosition, originalWidth - width, tabStopAnchorPosition);
                        width = originalWidth - (tabStopPosition + (originalWidth - width - tabPosition));
                        if (width < 0) {
                            tabStopPosition += width;
                            width = 0;
                        }
                        tabStop.setPosition(tabStopPosition);
                    }

                    tabStop = PdfChunk.getTabStop(ck, originalWidth - width);
                    if (tabStop.getPosition() > originalWidth) {
                        tabStop = null;
                        break;
                    }
                    ck.setTabStop(tabStop);
                    if (tabStop.getAlignment() == TabStop.Alignment.LEFT) {
                        width = originalWidth - tabStop.getPosition();
                        tabStop = null;
                        tabPosition = Float.NaN;
                        tabStopAnchorPosition = Float.NaN;
                    } else {
                        tabPosition = originalWidth - width;
                        tabStopAnchorPosition = Float.NaN;
                    }
                } else {
                    Object[] tab = (Object[])ck.getAttribute(Chunk.TAB);
                    //Keep deprecated tab logic for backward compatibility...
                    float tabStopPosition = ((Float)tab[1]).floatValue();
                    boolean newLine = ((Boolean)tab[2]).booleanValue();
                    if (newLine && tabStopPosition < originalWidth - width) {
                        return new PdfLine(0, originalWidth, width, alignment, true, createArrayOfPdfChunks(oldCurrentChar, currentChar - 1), isRTL);
                    }
                    detailChunks[currentChar].adjustLeft(leftX);
                    width = originalWidth - tabStopPosition;
                }
            }
            else if (ck.isSeparator()) {
                Object[] sep = (Object[])ck.getAttribute(Chunk.SEPARATOR);
                DrawInterface di = (DrawInterface)sep[0];
                Boolean vertical = (Boolean)sep[1];
                if (vertical && di instanceof LineSeparator) {
                    float separatorWidth = originalWidth * ((LineSeparator) di).getPercentage() / 100f;
                    width -= separatorWidth;
                    if (width < 0) {
                        width = 0;
                    }
                }
            } else {
                boolean splitChar = ck.isExtSplitCharacter(oldCurrentChar, currentChar, totalTextLength, text, detailChunks);
                if (splitChar && Character.isWhitespace((char)uniC))
                    lastSplit = currentChar;
                if (width - charWidth < 0)
                    break;
                if (tabStop != null && tabStop.getAlignment() == TabStop.Alignment.ANCHOR && Float.isNaN(tabStopAnchorPosition) && tabStop.getAnchorChar() == (char) uniC) {
                    tabStopAnchorPosition = originalWidth - width;
                }
                width -= charWidth;
                if (splitChar)
                    lastSplit = currentChar;
            }
            lastValidChunk = ck;
            if (surrogate)
                ++currentChar;
        }
        if (lastValidChunk == null) {
            // not even a single char fit; must output the first char
            ++currentChar;
            if (surrogate)
                ++currentChar;
            return new PdfLine(0, originalWidth, 0, alignment, false, createArrayOfPdfChunks(currentChar - 1, currentChar - 1), isRTL);
        }

        if (tabStop != null) {
            float tabStopPosition = tabStop.getPosition(tabPosition, originalWidth - width, tabStopAnchorPosition);
            width = originalWidth - (tabStopPosition + (originalWidth - width - tabPosition));
            if (width < 0) {
                tabStopPosition += width;
                width = 0;
            }
            tabStop.setPosition(tabStopPosition);
        }

        if (currentChar >= totalTextLength) {
            // there was more line than text
            return new PdfLine(0, originalWidth, width, alignment, true, createArrayOfPdfChunks(oldCurrentChar, totalTextLength - 1), isRTL);
View Full Code Here

Examples of com.itextpdf.text.TabStop

     */
    public float getWidth(int startIdx, int lastIdx) {
        char c = 0;
        PdfChunk ck = null;
        float width = 0;
        TabStop tabStop = null;
        float tabStopAnchorPosition = Float.NaN;
        float tabPosition = Float.NaN;
        for (; startIdx <= lastIdx; ++startIdx) {
            boolean surrogate = Utilities.isSurrogatePair(text, startIdx);
            if (detailChunks[startIdx].isTab()
                    //Keep deprecated tab logic for backward compatibility...
                    && detailChunks[startIdx].isAttribute(Chunk.TABSETTINGS)) {
                if (tabStop != null) {
                    float tabStopPosition = tabStop.getPosition(tabPosition, width, tabStopAnchorPosition);
                    width = tabStopPosition + (width - tabPosition);
                    tabStop.setPosition(tabStopPosition);
                }
                tabStop = detailChunks[startIdx].getTabStop();
                if (tabStop == null) {
                    tabStop = PdfChunk.getTabStop(detailChunks[startIdx], width);
                    tabPosition = width;
                    tabStopAnchorPosition = Float.NaN;
                } else {
                    width = tabStop.getPosition();
                    tabStop = null;
                    tabPosition = Float.NaN;
                    tabStopAnchorPosition = Float.NaN;
                }
            } else if (surrogate) {
                width += detailChunks[startIdx].getCharWidth(Utilities.convertToUtf32(text, startIdx));
                ++startIdx;
            }
            else {
                c = text[startIdx];
                ck = detailChunks[startIdx];
                if (PdfChunk.noPrint(ck.getUnicodeEquivalent(c)))
                    continue;
                if (tabStop != null && tabStop.getAlignment() != TabStop.Alignment.ANCHOR && Float.isNaN(tabStopAnchorPosition) && tabStop.getAnchorChar() == (char)ck.getUnicodeEquivalent(c)) {
                    tabStopAnchorPosition = width;
                }
                width += detailChunks[startIdx].getCharWidth(c);
            }
        }
        if (tabStop != null) {
            float tabStopPosition = tabStop.getPosition(tabPosition, width, tabStopAnchorPosition);
            width = tabStopPosition + (width - tabPosition);
            tabStop.setPosition(tabStopPosition);
        }
        return width;
    }
View Full Code Here

Examples of com.sun.star.style.TabStop

    XTextCursor cursor = xNoteText.createTextCursor();
    cursor.getStart();

    XPropertySet xCursorProps = unoCast(XPropertySet.class, cursor);
    tabStops = new TabStop[2];
    tabStops[0] = new TabStop(xmargin, TabAlign.LEFT, ',', ' ');
    tabStops[1] = new TabStop(21000 - 2 * xmargin - 2000, TabAlign.RIGHT,
        ',', '.');
    // Remarque : je ne sais plus comment ça marche...

    // Titre de la table de matieres
    try {
View Full Code Here

Examples of com.sun.star.style.TabStop

        XTextCursor cursor = mainText.createTextCursor();
        cursor.getStart();

        XPropertySet xCursorProps = unoCast(XPropertySet.class, cursor);
        TabStop[] tabStops = new TabStop[1];
        tabStops[0] = new TabStop(bundle.getShortTocTabulation(),
            TabAlign.RIGHT, ',', '.');
        xCursorProps.setPropertyValue("ParaTabStops", tabStops);

        StringBuilder planBuilder = new StringBuilder();
        String newLine = "";
View Full Code Here

Examples of io.emmet.TabStop

      if (totalLinks < 1) {
        tabStops.addTabStopToGroup("carets", newValue.length(), newValue.length());
      }
     
      String[] tabGroups = tabStops.getSortedGroupKeys();
      TabStop firstTabStop = tabStops.getFirstTabStop();
     
      if (totalLinks > 1 || firstTabStop != null && firstTabStop.getStart() != firstTabStop.getEnd()) {
        ITextViewer viewer = EclipseEmmetHelper.getTextViewer(editor);
        LinkedModeModel model = new LinkedModeModel();
        int exitPos = -1;
       
        for (int i = 0; i < tabGroups.length; i++) {
          TabStopGroup tabGroup = tabStops.getTabStopGroup(tabGroups[i]);
          LinkedPositionGroup group = null;
         
          if (tabGroups[i].equals("carets") || tabGroups[i].equals("0")) {
            int caretCount = tabGroup.getTabStopList().size();
            for (int j = 0; j < caretCount; j++) {
              TabStop ts = tabGroup.getTabStopList().get(j);
              group = new LinkedPositionGroup();
              group.addPosition(new LinkedPosition(doc, start + ts.getStart(), ts.getLength()));
              model.addGroup(group);
              if (j == caretCount - 1) {
                exitPos = start + ts.getStart();
              }             
            }
          } else {
            group = new LinkedPositionGroup();
           
            for (int j = 0; j < tabGroup.getTabStopList().size(); j++) {
              TabStop ts = tabGroup.getTabStopList().get(j);
              group.addPosition(new LinkedPosition(doc, start + ts.getStart(), ts.getLength()));
            }
           
            model.addGroup(group);
          }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.