当前位置: 首页>>代码示例>>Java>>正文


Java Bias类代码示例

本文整理汇总了Java中javax.swing.text.Position.Bias的典型用法代码示例。如果您正苦于以下问题:Java Bias类的具体用法?Java Bias怎么用?Java Bias使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Bias类属于javax.swing.text.Position包,在下文中一共展示了Bias类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: modelToView

import javax.swing.text.Position.Bias; //导入依赖的package包/类
@Override
public Shape modelToView(int pos, Shape a, Bias b) throws BadLocationException {
    // line coordinates
    Element map = getElement();
    int lineIndex = map.getElementIndex(pos);
    Rectangle lineArea = lineToRect(a, lineIndex);
    
    // determine span from the start of the line
    tabBase = lineArea.x;
    Element line = map.getElement(lineIndex);
    int lineStart = line.getStartOffset();
    Segment s = getSegment();
    getText(lineStart, pos - lineStart, s);
    int xOffs = Utilities.getTabbedTextWidth(s, metrics, tabBase, this, lineStart);

    // fill in the results and return
    lineArea.x += xOffs;
    lineArea.width = 1;
    lineArea.height = metrics.getHeight();
    return lineArea;        
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:ExtPlainView.java

示例2: getNextMatch

import javax.swing.text.Position.Bias; //导入依赖的package包/类
@Override
public int getNextMatch(String prefix, int startIndex, Bias bias) {
    ListModel model = getModel();
    if (!(model instanceof TableModel)) {
        return super.getNextMatch(prefix, startIndex, bias);
    }
    TableModel tablesModel = (TableModel)model;
    int max = tablesModel.getSize();
    int increment = (bias == Bias.Forward) ? 1 : -1;
    int index = startIndex;
    prefix = prefix.toUpperCase();
    do {
        Table table = tablesModel.getElementAt(index);
        String tableName = table.getName().toUpperCase();
        if (tableName.startsWith(prefix)) {
            return index;
        }
        index = (index + increment + max) % max;
    } while (index != startIndex);
    return -1;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:TableUISupport.java

示例3: getPreferredSpan

import javax.swing.text.Position.Bias; //导入依赖的package包/类
public float getPreferredSpan(int axis) {
        switch (axis) {
            case Y_AXIS:
                return getEditorUI().getLineHeight();
            case X_AXIS:
//                try {
                    int offset = Math.max(0, getEndOffset() - 1);
                    Shape retShape = modelToView(offset, new Rectangle(), Position.Bias.Forward, false);
                    int ret = retShape.getBounds().x + retShape.getBounds().width;
                    return Math.max(ret, 1f);
//                } catch (BadLocationException ble) {
//                    LOG.log(Level.INFO, "Can't determine x-axis span", ble); //NOI18N
//                }
        }
        
        return 1f;
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:DrawEngineLineView.java

示例4: modelToView

import javax.swing.text.Position.Bias; //导入依赖的package包/类
static Rectangle2D modelToView(JTextComponent tc, int pos, Position.Bias bias) throws BadLocationException {
Document doc = tc.getDocument();
if (doc instanceof AbstractDocument) {
    ((AbstractDocument)doc).readLock();
}
try {
    Rectangle alloc = getVisibleEditorRect(tc);
    if (alloc != null) {
               View rootView = tc.getUI().getRootView(tc);
	rootView.setSize(alloc.width, alloc.height);
	Shape s = rootView.modelToView(pos, alloc, bias);
	if (s != null) {
	  return s.getBounds2D();
	}
    }
} finally {
    if (doc instanceof AbstractDocument) {
	((AbstractDocument)doc).readUnlock();
    }
}
return null;
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:Utilities.java

示例5: damageRange

import javax.swing.text.Position.Bias; //导入依赖的package包/类
@Override
public void damageRange(JTextComponent t, int p0, int p1, Bias p0Bias, Bias p1Bias) {
    View rootView = getRootView(getComponent());
    boolean doDamageRange = true;
    if (rootView.getViewCount() > 0) {
        View view = rootView.getView(0);
        if (view instanceof LockView) {
            LockView lockView = (LockView) view;
            lockView.lock();
            try {
                GapDocumentView docView = (GapDocumentView)view.getView(0);
                doDamageRange = docView.checkDamageRange(p0, p1, p0Bias, p1Bias);
            } finally {
                lockView.unlock();
            }
        }
    }
    if (doDamageRange) {
        // Patch since this used to be a fallback and the original views' impl cleared char area at p1 too
        Document doc = t.getDocument();
        if (doc != null && p1 < doc.getLength()) {
            p1++;
        }
        super.damageRange(t, p0, p1, p0Bias, p1Bias);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:BaseTextUI.java

示例6: testCRLF197538

import javax.swing.text.Position.Bias; //导入依赖的package包/类
public void testCRLF197538() throws Exception {
    prepareTest("test\r\ntest\r\ntest\r\n");

    PositionRef start1 = ces.createPositionRef(5, Bias.Forward);
    PositionRef end1 = ces.createPositionRef(9, Bias.Forward);
    ModificationResult.Difference diff1 = new ModificationResult.Difference(ModificationResult.Difference.Kind.CHANGE, start1, end1, "test", "abcde", Source.create(testFile));
    PositionRef start2 = ces.createPositionRef(10, Bias.Forward);
    PositionRef end2 = ces.createPositionRef(13, Bias.Forward);
    ModificationResult.Difference diff2 = new ModificationResult.Difference(ModificationResult.Difference.Kind.CHANGE, start2, end2, "tes", "a", Source.create(testFile));

    ModificationResult result = new ModificationResult();

    result.diffs = new HashMap<FileObject, List<ModificationResult.Difference>>();
    result.diffs.put(testFile, Arrays.asList(diff1, diff2));

    result.commit();

    assertEquals("test\r\nabcde\r\nat\r\n", testFile.asText());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:ModificationResultTest.java

示例7: yForLineContaining

import javax.swing.text.Position.Bias; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public int yForLineContaining(Rectangle alloc, int offs)
							throws BadLocationException {
	if (isAllocationValid()) {
		// TODO: make cached Y_AXIS offsets valid even with folding enabled
		// to speed this back up!
		Rectangle r = (Rectangle)modelToView(offs, alloc, Bias.Forward);
		if (r!=null) {
			if (host.isCodeFoldingEnabled()) {
				int line = host.getLineOfOffset(offs);
				FoldManager fm = host.getFoldManager();
				if (fm.isLineHidden(line)) {
					return -1;
				}
			}
			return r.y;
		}
	}
	return -1;
}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:24,代码来源:WrappedSyntaxView.java

示例8: modelToViewChecked

import javax.swing.text.Position.Bias; //导入依赖的package包/类
@Override
public Shape modelToViewChecked(int offset, Shape alloc, Position.Bias bias) {
    int startOffset = getStartOffset();
    Rectangle2D.Double mutableBounds = ViewUtils.shape2Bounds(alloc);
    int charIndex = offset - startOffset;
    if (charIndex == 1) {
        mutableBounds.x += firstTabWidth;
    } else if (charIndex > 1) {
        int extraTabCount = getLength() - 1;
        if (extraTabCount > 0) {
            mutableBounds.x += firstTabWidth + (charIndex - 1) * ((width - firstTabWidth) / extraTabCount);
        }
    }
    mutableBounds.width = 1;
    return mutableBounds;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:TabView.java

示例9: getNextVisualPositionX

import javax.swing.text.Position.Bias; //导入依赖的package包/类
/**
 * Find next visual position in Y direction.
 * In case of no line-wrap the method should return -1 for a given valid offset.
 * and a valid offset when -1 is given as parameter.
 * @param offset offset inside line or -1 to "enter" a line at the given x.
 */
int getNextVisualPositionX(ParagraphView pView, int offset, Bias bias, Shape pAlloc, boolean eastDirection, Bias[] biasRet) {
    // Children already ensured to be measured by parent
    int viewCount = size();
    int index = (offset == -1)
            ? (eastDirection ? 0 : viewCount - 1)
            : getViewIndex(pView, offset);
    int increment = eastDirection ? 1 : -1;
    int retOffset = -1;
    // Cycle through individual views in left or right direction
    for (; retOffset == -1 && index >= 0 && index < viewCount; index += increment) {
        EditorView view = get(index); // Ensure valid children
        Shape viewAlloc = getChildAllocation(index, pAlloc);
        retOffset = view.getNextVisualPositionFromChecked(offset, bias, viewAlloc, 
                eastDirection ? SwingConstants.EAST : SwingConstants.WEST, biasRet);
        if (retOffset == -1) {
            offset = -1; // Continue by entering the paragraph from outside
        }
    }
    return retOffset;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:ParagraphViewChildren.java

示例10: indexToView

import javax.swing.text.Position.Bias; //导入依赖的package包/类
static Shape indexToView(TextLayout textLayout, Rectangle2D textLayoutBounds,
            int index, Position.Bias bias, int maxIndex, Shape alloc)
   {
       if (textLayout == null) {
           return alloc; // Leave given bounds
       }
       assert (maxIndex <= textLayout.getCharacterCount()) : "textLayout.getCharacterCount()=" + // NOI18N
               textLayout.getCharacterCount() + " < maxIndex=" + maxIndex; // NOI18N
       // If offset is >getEndOffset() use view-end-offset - otherwise it would throw exception from textLayout.getCaretInfo()
int charIndex = Math.min(index, maxIndex);
       // When e.g. creating fold-preview the offset can be < startOffset
       charIndex = Math.max(charIndex, 0);
       TextHitInfo startHit;
       TextHitInfo endHit;
       if (bias == Position.Bias.Forward) {
           startHit = TextHitInfo.leading(charIndex);
       } else { // backward bias
           startHit = TextHitInfo.trailing(charIndex - 1);
       }
       endHit = (charIndex < maxIndex) ? TextHitInfo.trailing(charIndex) : startHit;
       if (textLayoutBounds == null) {
           textLayoutBounds = ViewUtils.shapeAsRect(alloc);
       }
       return TextLayoutUtils.getRealAlloc(textLayout, textLayoutBounds, startHit, endHit);
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:HighlightsViewUtils.java

示例11: getNextVisualPositionY

import javax.swing.text.Position.Bias; //导入依赖的package包/类
int getNextVisualPositionY(DocumentView docView, int offset, Bias bias, Shape docViewAlloc, boolean southDirection, Bias[] biasRet) {
    double x = HighlightsViewUtils.getMagicX(docView, docView, offset, bias, docViewAlloc);
    int pIndex = docView.getViewIndex(offset, bias);
    int viewCount = size();
    int increment = southDirection ? 1 : -1;
    int retOffset = -1;
    for (; retOffset == -1 && pIndex >= 0 && pIndex < viewCount; pIndex += increment) {
        // Get paragraph view with valid children
        ParagraphView pView = get(pIndex);
        Shape pAlloc = getChildAllocation(docView, pIndex, docViewAlloc);
        if (ensureParagraphViewChildrenValid(docView, pIndex, pView)) {
            pView = get(pIndex);
            pAlloc = getChildAllocation(docView, pIndex, docViewAlloc);
        }
        if (pView.checkLayoutUpdate(pIndex, pAlloc)) {
            pAlloc = getChildAllocation(docView, pIndex, docViewAlloc);
        }
        docView.op.getTextLayoutCache().activate(pView);
        retOffset = pView.children.getNextVisualPositionY(pView, offset, bias, pAlloc, southDirection, biasRet, x);
        if (retOffset == -1) {
            offset = -1; // Continue by entering the paragraph from outside
        }
    }
    return retOffset;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:DocumentViewChildren.java

示例12: getNextVisualPositionX

import javax.swing.text.Position.Bias; //导入依赖的package包/类
int getNextVisualPositionX(DocumentView docView, int offset, Bias bias, Shape docViewAlloc, boolean eastDirection, Bias[] biasRet) {
    int pIndex = docView.getViewIndex(offset, bias);
    int viewCount = size();
    int increment = eastDirection ? 1 : -1;
    int retOffset = -1;
    for (; retOffset == -1 && pIndex >= 0 && pIndex < viewCount; pIndex += increment) {
        // Get paragraph view with valid children
        ParagraphView pView = get(pIndex);
        Shape pAlloc = getChildAllocation(docView, pIndex, docViewAlloc);
        if (ensureParagraphViewChildrenValid(docView, pIndex, pView)) {
            pView = get(pIndex);
            pAlloc = getChildAllocation(docView, pIndex, docViewAlloc);
        }
        if (pView.checkLayoutUpdate(pIndex, pAlloc)) {
            pAlloc = getChildAllocation(docView, pIndex, docViewAlloc);
        }
        retOffset = pView.children.getNextVisualPositionX(pView, offset, bias, pAlloc, eastDirection, biasRet);
        if (retOffset == -1) {
            offset = -1; // Continue by entering the paragraph from outside
        }
    }
    return retOffset;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:DocumentViewChildren.java

示例13: createClassOccurrence

import javax.swing.text.Position.Bias; //导入依赖的package包/类
private Occurrence createClassOccurrence(String matched, SpringBean bean) throws BadLocationException {
    Location loc = bean.getLocation();
    if (loc == null) {
        return null;
    }
    int startOffset = loc.getOffset();
    if (startOffset == -1) {
        return null;
    }
    AttributeValueFinder finder = new AttributeValueFinder(syntaxSupport, startOffset); // NOI18N
    if (!finder.find("class")) {
        return null;
    }
    int foundOffset = finder.getFoundOffset();
    String foundValue = finder.getValue();
    int index = foundValue.indexOf(matched);
    if (index == -1) {
        return null;
    }
    String displayText = createClassDisplayText(finder, foundValue, index, matched.length());
    PositionRef startRef = docAccess.createPositionRef(foundOffset + index, Bias.Forward);
    PositionRef endRef = docAccess.createPositionRef(foundOffset + index + matched.length(), Bias.Backward);
    return new JavaElementRefOccurrence(displayText, docAccess.getFileObject(), new PositionBounds(startRef, endRef));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:JavaElementRefFinder.java

示例14: findResult

import javax.swing.text.Position.Bias; //导入依赖的package包/类
private void findResult() {
    
    if (isCanceled())
        return;

    int len = sdoc.getLength();

    if (startOffset >= len || endOffset > len) {
        if (!isCanceled() && ERR.isLoggable(ErrorManager.WARNING)) {
            ERR.log(ErrorManager.WARNING, "document changed, but not canceled?" );
            ERR.log(ErrorManager.WARNING, "len = " + len );
            ERR.log(ErrorManager.WARNING, "startOffset = " + startOffset );
            ERR.log(ErrorManager.WARNING, "endOffset = " + endOffset );
        }
        cancel();

        return;
    }

    try {
        result[0] = NbDocument.createPosition(sdoc, startOffset, Bias.Forward);
        result[1] = NbDocument.createPosition(sdoc, endOffset, Bias.Backward);
    } catch (BadLocationException e) {
        ERR.notify(ErrorManager.ERROR, e);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:ErrorHintsProvider.java

示例15: prepareSpansFor

import javax.swing.text.Position.Bias; //导入依赖的package包/类
public static List<PositionBounds> prepareSpansFor(FileObject file, Iterable<? extends int[]> spans) {
    List<PositionBounds> result = new ArrayList<PositionBounds>();

    try {
        DataObject d = DataObject.find(file);
        EditorCookie ec = d.getLookup().lookup(EditorCookie.class);
        CloneableEditorSupport ces = (CloneableEditorSupport) ec;

        result = new LinkedList<PositionBounds>();

        for (int[] span : spans) {
            PositionRef start = ces.createPositionRef(span[0], Bias.Forward);
            PositionRef end = ces.createPositionRef(span[1], Bias.Forward);

            result.add(new PositionBounds(start, end));
        }
    } catch (DataObjectNotFoundException ex) {
        Exceptions.printStackTrace(ex);
    }

    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:Utilities.java


注:本文中的javax.swing.text.Position.Bias类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。