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


Java LineMetrics.getLeading方法代码示例

本文整理汇总了Java中java.awt.font.LineMetrics.getLeading方法的典型用法代码示例。如果您正苦于以下问题:Java LineMetrics.getLeading方法的具体用法?Java LineMetrics.getLeading怎么用?Java LineMetrics.getLeading使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.font.LineMetrics的用法示例。


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

示例1: getLogicalBounds

import java.awt.font.LineMetrics; //导入方法依赖的package包/类
public Rectangle2D getLogicalBounds() {
    setFRCTX();
    initPositions();

    LineMetrics lm = font.getLineMetrics("", frc);

    float minX, minY, maxX, maxY;
    // horiz only for now...
    minX = 0;
    minY = -lm.getAscent();
    maxX = 0;
    maxY = lm.getDescent() + lm.getLeading();
    if (glyphs.length > 0) {
        maxX = positions[positions.length - 2];
    }

    return new Rectangle2D.Float(minX, minY, maxX - minX, maxY - minY);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:StandardGlyphVector.java

示例2: getLogicalBounds

import java.awt.font.LineMetrics; //导入方法依赖的package包/类
@Override
public Rectangle2D getLogicalBounds() {
    initPositions();

    LineMetrics lm = font.getLineMetrics("", frc);

    float minX, minY, maxX, maxY;
    // horiz only for now...
    minX = 0;
    minY = -lm.getAscent();
    maxX = 0;
    maxY = lm.getDescent() + lm.getLeading();
    if (glyphs.length() > 0) {
        maxX = positions[positions.length - 2];
    }

    return new Rectangle2D.Float(minX, minY, maxX - minX, maxY - minY);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:StandardGlyphVector.java

示例3: calculateBaselineOffset

import java.awt.font.LineMetrics; //导入方法依赖的package包/类
/**
 * Calculates the vertical offset between the baseline and the specified 
 * text anchor.
 * 
 * @param g2  the graphics device.
 * @param anchor  the anchor.
 * 
 * @return the offset.
 */
public float calculateBaselineOffset(Graphics2D g2, TextAnchor anchor) {
    float result = 0.0f;
    final FontMetrics fm = g2.getFontMetrics(this.font);
    final LineMetrics lm = fm.getLineMetrics("ABCxyz", g2);
    if (anchor.isTop()) {
        result = lm.getAscent();
    }
    else if (anchor.isHalfAscent()) {
        result = lm.getAscent() / 2.0f;
    }
    else if (anchor.isVerticalCenter()) {
        result = lm.getAscent() / 2.0f - lm.getDescent() / 2.0f;
    }
    else if (anchor.isBottom()) {
        result = -lm.getDescent() - lm.getLeading();
    }
    return result;                                             
}
 
开发者ID:mdzio,项目名称:ccu-historian,代码行数:28,代码来源:TextFragment.java

示例4: calculateBaselineOffset

import java.awt.font.LineMetrics; //导入方法依赖的package包/类
/**
 * Calculates the vertical offset between the baseline and the specified 
 * text anchor.
 * 
 * @param g2  the graphics device.
 * @param anchor  the anchor.
 * 
 * @return the offset.
 */
public float calculateBaselineOffset(Graphics2D g2, TextAnchor anchor) {
    float result = 0.0f;
    FontMetrics fm = g2.getFontMetrics(this.font);
    LineMetrics lm = fm.getLineMetrics("ABCxyz", g2);
    if (anchor.isTop()) {
        result = lm.getAscent();
    }
    else if (anchor.isHalfAscent()) {
        result = lm.getAscent() / 2.0f;
    }
    else if (anchor.isVerticalCenter()) {
        result = lm.getAscent() / 2.0f - lm.getDescent() / 2.0f;
    }
    else if (anchor.isBottom()) {
        result = -lm.getDescent() - lm.getLeading();
    }
    return result;                                             
}
 
开发者ID:jfree,项目名称:jfreechart,代码行数:28,代码来源:TextFragment.java

示例5: GVTLineMetrics

import java.awt.font.LineMetrics; //导入方法依赖的package包/类
/**
 * Constructs a GVTLineMetrics object based on the specified line metrics.
 *
 * @param lineMetrics The lineMetrics object that this metrics object will
 * be based upon.
 */
public GVTLineMetrics(LineMetrics lineMetrics) {
    this.ascent = lineMetrics.getAscent();
    this.baselineIndex = lineMetrics.getBaselineIndex();
    this.baselineOffsets = lineMetrics.getBaselineOffsets();
    this.descent = lineMetrics.getDescent();
    this.height = lineMetrics.getHeight();
    this.leading = lineMetrics.getLeading();
    this.numChars = lineMetrics.getNumChars();
    this.strikethroughOffset = lineMetrics.getStrikethroughOffset();
    this.strikethroughThickness = lineMetrics.getStrikethroughThickness();
    this.underlineOffset = lineMetrics.getUnderlineOffset();
    this.underlineThickness = lineMetrics.getUnderlineThickness();
    this.overlineOffset = -this.ascent;
    this.overlineThickness = this.underlineThickness;
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:22,代码来源:GVTLineMetrics.java

示例6: createLegendItem

import java.awt.font.LineMetrics; //导入方法依赖的package包/类
/**
 * Creates a legend item
 *
 * @param graphics  the graphics device.
 * @param item  the legend item.
 * @param x  the x coordinate.
 * @param y  the y coordinate.
 *
 * @return the legend item.
 */
private DrawableLegendItem createLegendItem(Graphics graphics,
                                            LegendItem item, double x, double y) {

    int innerGap = 2;
    FontMetrics fm = graphics.getFontMetrics();
    LineMetrics lm = fm.getLineMetrics(item.getLabel(), graphics);
    float textHeight = lm.getHeight();

    DrawableLegendItem drawable = new DrawableLegendItem(item);

    float xloc = (float) (x + innerGap + 1.15f * textHeight);
    float yloc = (float) (y + innerGap + (textHeight - lm.getLeading() - lm.getDescent()));

    drawable.setLabelPosition(new Point2D.Float(xloc, yloc));

    float boxDim = textHeight * 0.70f;
    xloc = (float) (x + innerGap + 0.15f * textHeight);
    yloc = (float) (y + innerGap + 0.15f * textHeight);

    drawable.setMarker(new Rectangle2D.Float(xloc, yloc, boxDim, boxDim));

    float width = (float) (drawable.getLabelPosition().getX() - x
                           + fm.stringWidth(item.getLabel()) + 0.5 * textHeight);

    float height = 2 * innerGap + textHeight;
    drawable.setBounds(x, y, width, height);
    return drawable;

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:40,代码来源:MeterLegend.java

示例7: adicRodape

import java.awt.font.LineMetrics; //导入方法依赖的package包/类
private void adicRodape(Graphics g, int iPag) {
	Graphics2D g2d = ( Graphics2D ) g.create();
	g2d.setPaint(Color.black);
	g2d.setFont(mRodFont);
	LineMetrics metrics = mRodFont.getLineMetrics(mDataStr, g2d.getFontRenderContext());
	int iTamTexto = getFontMetrics(mRodFont).stringWidth(mDataStr);
	int iPosYTexto = ( int ) ( iMY - metrics.getDescent() - metrics.getLeading() );
	int iPosRodY = ( int ) ( iMY - metrics.getHeight() );
	g2d.setStroke(new BasicStroke(2));
	g2d.drawLine(0, iPosRodY, iMX, iPosRodY);
	g2d.drawString(( iPag + 1 ) + " de " + iNumPags, 0, iPosYTexto);
	g2d.drawString(mDataStr, iMX - iTamTexto, iPosYTexto);
	g2d.dispose();
}
 
开发者ID:cams7,项目名称:erp,代码行数:15,代码来源:ImprimeLayout.java

示例8: deriveTextBoundsAnchorOffsets

import java.awt.font.LineMetrics; //导入方法依赖的package包/类
/**
 * A utility method that calculates the anchor offsets for a string.
 * Normally, the (x, y) coordinate for drawing text is a point on the
 * baseline at the left of the text string.  If you add these offsets to
 * (x, y) and draw the string, then the anchor point should coincide with
 * the (x, y) point.
 *
 * @param g2  the graphics device (not <code>null</code>).
 * @param text  the text.
 * @param anchor  the anchor point.
 *
 * @return  The offsets.
 */
private static float[] deriveTextBoundsAnchorOffsets(Graphics2D g2,
        String text, TextAnchor anchor) {

    float[] result = new float[2];
    FontRenderContext frc = g2.getFontRenderContext();
    Font f = g2.getFont();
    FontMetrics fm = g2.getFontMetrics(f);
    Rectangle2D bounds = getTextBounds(text, fm);
    LineMetrics metrics = f.getLineMetrics(text, frc);
    float ascent = metrics.getAscent();
    float halfAscent = ascent / 2.0f;
    float descent = metrics.getDescent();
    float leading = metrics.getLeading();
    float xAdj = 0.0f;
    float yAdj = 0.0f;

    if (anchor.isHorizontalCenter()) {
        xAdj = (float) -bounds.getWidth() / 2.0f;
    }
    else if (anchor.isRight()) {
        xAdj = (float) -bounds.getWidth();
    }

    if (anchor.isTop()) {
        yAdj = -descent - leading + (float) bounds.getHeight();
    }
    else if (anchor.isHalfAscent()) {
        yAdj = halfAscent;
    }
    else if (anchor.isVerticalCenter()) {
        yAdj = -descent - leading + (float) (bounds.getHeight() / 2.0);
    }
    else if (anchor.isBaseline()) {
        yAdj = 0.0f;
    }
    else if (anchor.isBottom()) {
        yAdj = -metrics.getDescent() - metrics.getLeading();
    }
    result[0] = xAdj;
    result[1] = yAdj;
    return result;

}
 
开发者ID:mdzio,项目名称:ccu-historian,代码行数:57,代码来源:TextUtils.java

示例9: deriveTextBoundsAnchorOffsets

import java.awt.font.LineMetrics; //导入方法依赖的package包/类
/**
 * A utility method that calculates the anchor offsets for a string.
 * Normally, the (x, y) coordinate for drawing text is a point on the
 * baseline at the left of the text string.  If you add these offsets to
 * (x, y) and draw the string, then the anchor point should coincide with
 * the (x, y) point.
 *
 * @param g2  the graphics device (not <code>null</code>).
 * @param text  the text.
 * @param anchor  the anchor point.
 * @param textBounds  the text bounds (if not <code>null</code>, this
 *                    object will be updated by this method to match the
 *                    string bounds).
 *
 * @return  The offsets.
 */
private static float[] deriveTextBoundsAnchorOffsets(Graphics2D g2,
        String text, TextAnchor anchor, Rectangle2D textBounds) {

    float[] result = new float[3];
    FontRenderContext frc = g2.getFontRenderContext();
    Font f = g2.getFont();
    FontMetrics fm = g2.getFontMetrics(f);
    Rectangle2D bounds = TextUtilities.getTextBounds(text, g2, fm);
    LineMetrics metrics = f.getLineMetrics(text, frc);
    float ascent = metrics.getAscent();
    result[2] = -ascent;
    float halfAscent = ascent / 2.0f;
    float descent = metrics.getDescent();
    float leading = metrics.getLeading();
    float xAdj = 0.0f;
    float yAdj = 0.0f;

    if (anchor.isHorizontalCenter()) {
        xAdj = (float) -bounds.getWidth() / 2.0f;
    }
    else if (anchor.isRight()) {
        xAdj = (float) -bounds.getWidth();
    }

    if (anchor.isTop()) {
        yAdj = -descent - leading + (float) bounds.getHeight();
    }
    else if (anchor.isHalfAscent()) {
        yAdj = halfAscent;
    }
    else if (anchor.isVerticalCenter()) {
        yAdj = -descent - leading + (float) (bounds.getHeight() / 2.0);
    }
    else if (anchor.isBaseline()) {
        yAdj = 0.0f;
    }
    else if (anchor.isBottom()) {
        yAdj = -metrics.getDescent() - metrics.getLeading();
    }
    if (textBounds != null) {
        textBounds.setRect(bounds);
    }
    result[0] = xAdj;
    result[1] = yAdj;
    return result;

}
 
开发者ID:mdzio,项目名称:ccu-historian,代码行数:64,代码来源:TextUtilities.java

示例10: deriveRotationAnchorOffsets

import java.awt.font.LineMetrics; //导入方法依赖的package包/类
/**
 * A utility method that calculates the rotation anchor offsets for a
 * string.  These offsets are relative to the text starting coordinate
 * (<code>BASELINE_LEFT</code>).
 *
 * @param g2  the graphics device.
 * @param text  the text.
 * @param anchor  the anchor point.
 *
 * @return The offsets.
 */
private static float[] deriveRotationAnchorOffsets(Graphics2D g2,
        String text, TextAnchor anchor) {

    float[] result = new float[2];
    FontRenderContext frc = g2.getFontRenderContext();
    LineMetrics metrics = g2.getFont().getLineMetrics(text, frc);
    FontMetrics fm = g2.getFontMetrics();
    Rectangle2D bounds = TextUtilities.getTextBounds(text, g2, fm);
    float ascent = metrics.getAscent();
    float halfAscent = ascent / 2.0f;
    float descent = metrics.getDescent();
    float leading = metrics.getLeading();
    float xAdj = 0.0f;
    float yAdj = 0.0f;

    if (anchor.isLeft()) {
        xAdj = 0.0f;
    }
    else if (anchor.isHorizontalCenter()) {
        xAdj = (float) bounds.getWidth() / 2.0f;
    }
    else if (anchor.isRight()) {
        xAdj = (float) bounds.getWidth();
    }

    if (anchor.isTop()) {
        yAdj = descent + leading - (float) bounds.getHeight();
    }
    else if (anchor.isVerticalCenter()) {
        yAdj = descent + leading - (float) (bounds.getHeight() / 2.0);
    }
    else if (anchor.isHalfAscent()) {
        yAdj = -halfAscent;
    }
    else if (anchor.isBaseline()) {
        yAdj = 0.0f;
    }
    else if (anchor.isBottom()) {
        yAdj = metrics.getDescent() + metrics.getLeading();
    }
    result[0] = xAdj;
    result[1] = yAdj;
    return result;

}
 
开发者ID:mdzio,项目名称:ccu-historian,代码行数:57,代码来源:TextUtilities.java

示例11: deriveTextBoundsAnchorOffsets

import java.awt.font.LineMetrics; //导入方法依赖的package包/类
/**
 * A utility method that calculates the anchor offsets for a string.
 * Normally, the (x, y) coordinate for drawing text is a point on the
 * baseline at the left of the text string.  If you add these offsets to
 * (x, y) and draw the string, then the anchor point should coincide with
 * the (x, y) point.
 *
 * @param g2  the graphics device (not {@code null}).
 * @param text  the text.
 * @param anchor  the anchor point.
 * @param textBounds  the text bounds (if not {@code null}, this
 *                    object will be updated by this method to match the
 *                    string bounds).
 *
 * @return  The offsets.
 */
private static float[] deriveTextBoundsAnchorOffsets(Graphics2D g2,
        String text, TextAnchor anchor, Rectangle2D textBounds) {

    float[] result = new float[3];
    FontRenderContext frc = g2.getFontRenderContext();
    Font f = g2.getFont();
    FontMetrics fm = g2.getFontMetrics(f);
    Rectangle2D bounds = TextUtils.getTextBounds(text, g2, fm);
    LineMetrics metrics = f.getLineMetrics(text, frc);
    float ascent = metrics.getAscent();
    result[2] = -ascent;
    float halfAscent = ascent / 2.0f;
    float descent = metrics.getDescent();
    float leading = metrics.getLeading();
    float xAdj = 0.0f;
    float yAdj = 0.0f;

    if (anchor.isHorizontalCenter()) {
        xAdj = (float) -bounds.getWidth() / 2.0f;
    }
    else if (anchor.isRight()) {
        xAdj = (float) -bounds.getWidth();
    }

    if (anchor.isTop()) {
        yAdj = -descent - leading + (float) bounds.getHeight();
    }
    else if (anchor.isHalfAscent()) {
        yAdj = halfAscent;
    }
    else if (anchor.isVerticalCenter()) {
        yAdj = -descent - leading + (float) (bounds.getHeight() / 2.0);
    }
    else if (anchor.isBaseline()) {
        yAdj = 0.0f;
    }
    else if (anchor.isBottom()) {
        yAdj = -metrics.getDescent() - metrics.getLeading();
    }
    if (textBounds != null) {
        textBounds.setRect(bounds);
    }
    result[0] = xAdj;
    result[1] = yAdj;
    return result;

}
 
开发者ID:jfree,项目名称:jfreechart,代码行数:64,代码来源:TextUtils.java

示例12: deriveRotationAnchorOffsets

import java.awt.font.LineMetrics; //导入方法依赖的package包/类
/**
 * A utility method that calculates the rotation anchor offsets for a
 * string.  These offsets are relative to the text starting coordinate
 * ({@code BASELINE_LEFT}).
 *
 * @param g2  the graphics device.
 * @param text  the text.
 * @param anchor  the anchor point.
 *
 * @return The offsets.
 */
private static float[] deriveRotationAnchorOffsets(Graphics2D g2,
        String text, TextAnchor anchor) {

    float[] result = new float[2];
    FontRenderContext frc = g2.getFontRenderContext();
    LineMetrics metrics = g2.getFont().getLineMetrics(text, frc);
    FontMetrics fm = g2.getFontMetrics();
    Rectangle2D bounds = TextUtils.getTextBounds(text, g2, fm);
    float ascent = metrics.getAscent();
    float halfAscent = ascent / 2.0f;
    float descent = metrics.getDescent();
    float leading = metrics.getLeading();
    float xAdj = 0.0f;
    float yAdj = 0.0f;

    if (anchor.isLeft()) {
        xAdj = 0.0f;
    }
    else if (anchor.isHorizontalCenter()) {
        xAdj = (float) bounds.getWidth() / 2.0f;
    }
    else if (anchor.isRight()) {
        xAdj = (float) bounds.getWidth();
    }

    if (anchor.isTop()) {
        yAdj = descent + leading - (float) bounds.getHeight();
    }
    else if (anchor.isVerticalCenter()) {
        yAdj = descent + leading - (float) (bounds.getHeight() / 2.0);
    }
    else if (anchor.isHalfAscent()) {
        yAdj = -halfAscent;
    }
    else if (anchor.isBaseline()) {
        yAdj = 0.0f;
    }
    else if (anchor.isBottom()) {
        yAdj = metrics.getDescent() + metrics.getLeading();
    }
    result[0] = xAdj;
    result[1] = yAdj;
    return result;

}
 
开发者ID:jfree,项目名称:jfreechart,代码行数:57,代码来源:TextUtils.java

示例13: nextLayout

import java.awt.font.LineMetrics; //导入方法依赖的package包/类
public AbstractTextLayout nextLayout(float requestedWrappingHeight, int requestedEndIndex)
{
	// System.out.println("nextLayout requestedWrappingHeight="+requestedWrappingHeight+", requestedEndIndex="+requestedEndIndex);
	
	final char[] CHAR_HOLDER = new char[1];
	
	VerticalTextLayout vtl = new VerticalTextLayout();
	
	int accumulatedHeight = 0;
	int characters = 0;
	
	int initialIndex = attributedCharacterIterator.getIndex();
	
	float maxCharWidth = 16.0f; // TODO no
	boolean roomy = true;
	
	char theChar = 0;
	
	for (theChar = attributedCharacterIterator.current(); 
			theChar!=AttributedCharacterIterator.DONE && roomy && (requestedEndIndex==-1 || attributedCharacterIterator.getIndex()<requestedEndIndex);
			theChar=attributedCharacterIterator.next())
	{
		Font theFont = Font.getFont(attributedCharacterIterator.getAttributes()); // TODO only do this at end of run
		
		// System.out.println("theFont="+theFont+ "theChar="+theChar);
		
		CHAR_HOLDER[0]=theChar;
		LineMetrics lm = theFont.getLineMetrics(CHAR_HOLDER, 0, 1, fontRenderContext);
		
		if (accumulatedHeight + lm.getHeight() <requestedWrappingHeight)
		{
			if (lm.getAscent()>vtl.getAscent())
				vtl.setAscent(lm.getAscent());

			if (lm.getDescent()>vtl.getDescent())
				vtl.setDescent(lm.getDescent());

			if (lm.getLeading()>vtl.getLeading())
				vtl.setLeading(lm.getLeading());

			// TODO check width

			accumulatedHeight += lm.getHeight();

			characters++; // TODO redundant to ACI.getCharacterCount() ?
		}
		else
			roomy = false;
	}
	
	// System.out.println("accumulatedHeight="+accumulatedHeight);
	// System.out.println("characters="+characters);
	
	if (accumulatedHeight==0 || characters==0)
		return null;
	
	vtl.setAttributedCharacterIterator(attributedCharacterIterator);
	vtl.setBeginIndex(initialIndex);
	
	if (theChar==AttributedCharacterIterator.DONE)
	{
		vtl.setEndIndex(attributedCharacterIterator.getIndex());
	}
	else
		vtl.setEndIndex(attributedCharacterIterator.getIndex()+1);
	
	vtl.setCharacterCount(vtl.getEndIndex()-vtl.getBeginIndex()); // TODO is this right?
	
	vtl.setBounds(new Rectangle2D.Float(0.0f, 0.0f, maxCharWidth, accumulatedHeight)); // TODO ?
	
	return vtl;
}
 
开发者ID:dhorlick,项目名称:balloonist,代码行数:73,代码来源:VerticalLineBreakMeasurer.java

示例14: determineLeading

import java.awt.font.LineMetrics; //导入方法依赖的package包/类
protected float determineLeading(Font font)
{
	LineMetrics lineMetrics = font.getLineMetrics(" ", context.getFontRenderContext());
	return lineMetrics.getLeading();
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:6,代码来源:SimpleTextLineWrapper.java


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