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


Java FigureUtilities.getTextExtents方法代码示例

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


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

示例1: getDimension

import org.eclipse.draw2d.FigureUtilities; //导入方法依赖的package包/类
@Override
protected Dimension getDimension(TextAttribute textAttr, ResourceManager resourceManager) {
  try {
    String text = textAttr.text.getExpression();
    int fontSize = ((IntToken) textAttr.textSize.getToken()).intValue();
    String fontFamily = textAttr.fontFamily.stringValue();
    boolean italic = ((BooleanToken) textAttr.italic.getToken()).booleanValue();
    boolean bold = ((BooleanToken) textAttr.bold.getToken()).booleanValue();
    int style = SWT.NORMAL | (italic ? SWT.ITALIC : SWT.NORMAL) | (bold ? SWT.BOLD : SWT.NORMAL);
    Font f = resourceManager.createFont(FontDescriptor.createFrom(fontFamily, fontSize, style));
    return FigureUtilities.getTextExtents(text, f);
  } catch (IllegalActionException e) {
    LOGGER.error("Error reading dimensions for " + textAttr.getFullName(), e);
    return new Dimension(0, 0);
  }
}
 
开发者ID:eclipse,项目名称:triquetrum,代码行数:17,代码来源:TextDrawingStrategy.java

示例2: hasSpaceToDraw

import org.eclipse.draw2d.FigureUtilities; //导入方法依赖的package包/类
/**
 * Returns the state indicating if there is a space to draw tick label.
 * 
 * @param previousPosition
 *            the previously drawn tick label position.
 * @param tickLabelPosition
 *            the tick label position.
 *  @param previousTickLabel
 *            the prevoius tick label.          
 * @param tickLabel
 *            the tick label text
 * @return true if there is a space to draw tick label
 */
private boolean hasSpaceToDraw(int previousPosition, int tickLabelPosition,
        String previousTickLabel, String tickLabel) {
    Dimension tickLabelSize = FigureUtilities.getTextExtents(tickLabel, scale.getFont());
    Dimension previousTickLabelSize = FigureUtilities.getTextExtents(previousTickLabel, scale.getFont());
    int interval = tickLabelPosition - previousPosition;
    int textLength = (int) (scale.isHorizontal() ? (tickLabelSize.width/2.0 + previousTickLabelSize.width/2.0)  
    		: tickLabelSize.height);
    boolean noLapOnPrevoius = true;
   
    boolean noLapOnEnd = true;
    if(tickLabelPosition != tickLabelPositions.get(tickLabelPositions.size() - 1)){ //if it is not the end tick label.
    	noLapOnPrevoius = interval > (textLength+TICK_LABEL_GAP);
    	Dimension endTickLabelSize = FigureUtilities.getTextExtents(
    		tickLabels.get(tickLabels.size()-1), scale.getFont());
    	interval = tickLabelPositions.get(tickLabelPositions.size() - 1) - tickLabelPosition;
    	textLength = (int) (scale.isHorizontal() ? (tickLabelSize.width/2.0 + endTickLabelSize.width/2.0)
    			: tickLabelSize.height);
    	noLapOnEnd = interval > textLength+TICK_LABEL_GAP;
    }       
    return noLapOnPrevoius && noLapOnEnd;        
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:35,代码来源:LinearScaleTickLabels.java

示例3: updateTickLabelMaxLengthAndHeight

import org.eclipse.draw2d.FigureUtilities; //导入方法依赖的package包/类
/**
 * Gets max length of tick label.
 */
private void updateTickLabelMaxLengthAndHeight() {
    int maxLength = 0;
    int maxHeight = 0; 
    for (int i = 0; i < tickLabels.size(); i++) {
        if (tickVisibilities.size() > i && tickVisibilities.get(i) == true) {
        	Dimension p = FigureUtilities.getTextExtents(tickLabels.get(i), scale.getFont());
        	if (tickLabels.get(0).startsWith("-") && !tickLabels.get(i).startsWith("-")) {
                p.width += FigureUtilities.getTextExtents("-", getFont()).width;
            }
            if (p.width > maxLength) {
                maxLength = p.width;
            }
            if(p.height > maxHeight){
            	maxHeight = p.height;
            }
        }
    }
    tickLabelMaxLength = maxLength;
    tickLabelMaxHeight = maxHeight;
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:24,代码来源:LinearScaleTickLabels.java

示例4: drawYTick

import org.eclipse.draw2d.FigureUtilities; //导入方法依赖的package包/类
/**
 * Draw the Y tick.
 * 
 * @param grahpics
 *            the graphics context
 */
private void drawYTick(Graphics grahpics) {
    // draw tick labels
    grahpics.setFont(scale.getFont());
    int fontHeight = tickLabelMaxHeight;
    for (int i = 0; i < tickLabelPositions.size(); i++) {
        if (tickVisibilities.size() == 0 || tickLabels.size() == 0) {
            break;
        }

        if (tickVisibilities.get(i) == true) {
            String text = tickLabels.get(i);
            int x = 0;
            if (tickLabels.get(0).startsWith("-") && !text.startsWith("-")) {
                x += FigureUtilities.getTextExtents("-", getFont()).width;
            }
            int y = (int) Math.ceil(scale.getLength() - tickLabelPositions.get(i)
                    - fontHeight / 2.0);
            grahpics.drawText(text, x, y);
        }
    }
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:28,代码来源:LinearScaleTickLabels.java

示例5: updateMarkerElments

import org.eclipse.draw2d.FigureUtilities; //导入方法依赖的package包/类
/**
 * @return the markerValues
 */
public void updateMarkerElments() {
	labels = new String[markersMap.size()];
	markerColorsList.clear();
	markerValues = new double[markersMap.size()];
	markerLabelDimensions = new Dimension[markersMap.size()];
	markerPositions = new int[markerValues.length];
	int i = 0;
	for(String label : markersMap.keySet()) {
		labels[i] = label;
		markerValues[i] = markersMap.get(label).value;
		markerPositions[i] = scale.getValuePosition(markerValues[i], true);
		markerLabelDimensions[i] = FigureUtilities.getTextExtents(label, getFont());
		markerColorsList.add(
				XYGraphMediaFactory.getInstance().getColor(markersMap.get(label).color));
		i++;
	}
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:21,代码来源:LinearScaledMarker.java

示例6: getPreferredSize

import org.eclipse.draw2d.FigureUtilities; //导入方法依赖的package包/类
@Override
public Dimension getPreferredSize(int wHint, int hHint) {
	updateTick();
	Dimension size = new Dimension(wHint, hHint);
	
	if(scale.isHorizontal()) {
		size.width = scale.getSize().width;
		size.height = FigureUtilities.getTextExtents("dummy", getFont()).height
						+ GAP_BTW_MARK_LABEL + TICK_LENGTH;
	} else {
		updateTickLabelMaxLength();
		size.width = (int)tickLabelMaxLength + GAP_BTW_MARK_LABEL + TICK_LENGTH;	
		size.height = scale.getSize().height;
	}			
	return size;
	
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:18,代码来源:LinearScaledMarker.java

示例7: getPreferredSize

import org.eclipse.draw2d.FigureUtilities; //导入方法依赖的package包/类
/**
 * Edited by [email protected]
 * Add case that no title axis
 */
@Override
public Dimension getPreferredSize(final int wHint, final int hHint) {
	final Dimension d = super.getPreferredSize(wHint, hHint);
	if (isVisible()) {
		if (title.length() > 0) {
			if (isHorizontal())
				d.height += FigureUtilities.getTextExtents(title, titleFont).height;
			else
				d.width += FigureUtilities.getTextExtents(title, titleFont).height;
		} else {
			if (isHorizontal())
				d.height += 2;
			else
				d.width += 5;
		}
	} else { // Not visible, flatten it to use zero height resp. width
		if (isHorizontal())
			d.height = 0;
		else
			d.width = 0;
	}
	return d;
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:28,代码来源:Axis.java

示例8: getPreferredSize

import org.eclipse.draw2d.FigureUtilities; //导入方法依赖的package包/类
@Override
	public Dimension getPreferredSize(int wHint, int hHint) {
		int maxWidth =0;
		int hEnd =  INNER_GAP;
		int height = ICON_WIDTH + INNER_GAP;
//		int i=0;
		for(Trace trace : traceList){
			hEnd = hEnd + OUT_GAP + ICON_WIDTH + INNER_GAP +  
					+ FigureUtilities.getTextExtents(trace.getName(), getFont()).width;
			
			if(hEnd	> wHint){
				hEnd= INNER_GAP + OUT_GAP + ICON_WIDTH + INNER_GAP +  
					+ FigureUtilities.getTextExtents(trace.getName(), getFont()).width;
				height += ICON_WIDTH + INNER_GAP;				
			}	
			if(maxWidth < hEnd) 
				maxWidth = hEnd;
//			i++;
		}
		return new Dimension(maxWidth, height);
	}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:22,代码来源:Legend.java

示例9: updateInfomation

import org.eclipse.draw2d.FigureUtilities; //导入方法依赖的package包/类
protected void updateInfomation(String label)
{
	if (infoLabel == null)
	{
		return;
	}
	infoLabel.setText( label );
	Dimension size = FigureUtilities.getTextExtents(  label, infoLabel.getFont( ) );
	//Insets insets = getInfomationLabel( ).getInsets( );
	Insets insets = INSETS;
	Dimension newSize  = size.getCopy( ).expand( insets.getWidth( ), insets.getHeight( ) ) ;
	if (size.width > maxWidth)
	{
		maxWidth = size.width;
	}
	else
	{
		newSize = new Dimension(maxWidth, size.height).expand( insets.getWidth( ), insets.getHeight( ) );
	}
	infoLabel.setSize( newSize);
	setLabelLocation( );
	adjustLocation(  );
}
 
开发者ID:eclipse,项目名称:birt,代码行数:24,代码来源:EditorDragGuidePolicy.java

示例10: calculateIndicatorDimension

import org.eclipse.draw2d.FigureUtilities; //导入方法依赖的package包/类
protected Dimension calculateIndicatorDimension( Font font, int width )
{
	gap = 0;
	Dimension iconDimension = new Dimension( );
	if ( image != null )
	{
		iconDimension = new Dimension( image );
		gap = 2;
	}
	Dimension d = FigureUtilities.getTextExtents( indicatorLabel, font );
	int incheight = 0;
	if ( iconDimension.height > d.height )
	{
		incheight = iconDimension.height - d.height;
	}
	d.expand( iconDimension.width
			+ gap
			+ gapInsets.left
			+ gapInsets.right
			+ 2
			* width
			+ 2, incheight + gapInsets.top + gapInsets.bottom );

	return d;
}
 
开发者ID:eclipse,项目名称:birt,代码行数:26,代码来源:MultipleGuideHandle.java

示例11: calculateIndicatorDimension

import org.eclipse.draw2d.FigureUtilities; //导入方法依赖的package包/类
private Dimension calculateIndicatorDimension( Graphics g, int width )
{
	gap = 0;
	Dimension iconDimension = new Dimension( );
	if ( image != null )
	{
		iconDimension = new Dimension( image );
		gap = 2;
	}
	Dimension d = FigureUtilities.getTextExtents( indicatorLabel,
			g.getFont( ) );
	int incheight = 0;
	if ( iconDimension.height > d.height )
	{
		incheight = iconDimension.height - d.height;
	}
	d.expand( iconDimension.width
			+ gap
			+ gapInsets.left
			+ gapInsets.right
			+ 2
			* width
			+ 2, incheight + gapInsets.top + gapInsets.bottom );

	return d;
}
 
开发者ID:eclipse,项目名称:birt,代码行数:27,代码来源:TableGuideHandle.java

示例12: updateInfomation

import org.eclipse.draw2d.FigureUtilities; //导入方法依赖的package包/类
public void updateInfomation(String label, Point p)
{
	if (labelFigure == null)
	{
		return;
	}
	labelFigure.setText( label );
	Dimension size = FigureUtilities.getTextExtents(  label, labelFigure.getFont( ) );
	//Insets insets = getInfomationLabel( ).getInsets( );
	Insets insets = INSETS;
	Dimension newSize  = size.getCopy( ).expand( insets.getWidth( ), insets.getHeight( ) ) ;
	if (size.width > maxWidth)
	{
		maxWidth = size.width;
	}
	else
	{
		newSize = new Dimension(maxWidth, size.height).expand( insets.getWidth( ), insets.getHeight( ) );
	}
	labelFigure.setSize( newSize);
	setLabelLocation( p );
	adjustLocation( p );
}
 
开发者ID:eclipse,项目名称:birt,代码行数:24,代码来源:ShowDragInfomationProcessor.java

示例13: relocate

import org.eclipse.draw2d.FigureUtilities; //导入方法依赖的package包/类
public void relocate(IFigure figure) {
	Dimension minimum = FigureUtilities.getTextExtents(text, figure.getFont());
	figure.setSize(minimum);
	Point location = polyline.getPoints().getMidpoint();
	Point offsetCopy = offset.getCopy();
	offsetCopy.translate(location);
	figure.setLocation(offsetCopy);
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:9,代码来源:TransitionLabelLocator.java

示例14: showTargetFeedback

import org.eclipse.draw2d.FigureUtilities; //导入方法依赖的package包/类
@Override
public void showTargetFeedback(final Request request) {
    final ERDiagram diagram = (ERDiagram) getHost().getRoot().getContents().getModel();

    if (diagram.isTooltip()) {
        final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager();
        final double zoom = zoomManager.getZoom();

        final TableView tableView = (TableView) getHost().getModel();
        final Rectangle tableBounds = getHostFigure().getBounds();

        final String name = TableViewEditPart.getTableViewName(tableView, diagram);

        final Label label = new Label();
        label.setText(name);
        label.setBorder(new SimpleRaisedBorder());
        label.setBackgroundColor(ColorConstants.orange);
        label.setOpaque(true);

        final Dimension dim = FigureUtilities.getTextExtents(name, Display.getCurrent().getSystemFont());

        label.setBounds(new Rectangle((int) (zoom * (tableBounds.x + 33)), (int) (zoom * (tableBounds.y + 5)), (int) (dim.width * 1.5), 20));

        addFeedback(label);
    }
    super.showTargetFeedback(request);
}
 
开发者ID:roundrop,项目名称:ermasterr,代码行数:28,代码来源:TableViewGraphicalNodeEditPolicy.java

示例15: showTargetFeedback

import org.eclipse.draw2d.FigureUtilities; //导入方法依赖的package包/类
@Override
public void showTargetFeedback(Request request) {
	ERDiagram diagram = (ERDiagram) this.getHost().getRoot().getContents()
			.getModel();

	if (diagram.isTooltip()) {
		ZoomManager zoomManager = ((ScalableFreeformRootEditPart) this
				.getHost().getRoot()).getZoomManager();
		double zoom = zoomManager.getZoom();

		TableView tableView = (TableView) this.getHost().getModel();
		Rectangle tableBounds = this.getHostFigure().getBounds();

		String name = TableViewEditPart.getTableViewName(tableView, diagram);

		Label label = new Label();
		label.setText(name);
		label.setBorder(new SimpleRaisedBorder());
		label.setBackgroundColor(ColorConstants.orange);
		label.setOpaque(true);

		Dimension dim = FigureUtilities.getTextExtents(name, Display
				.getCurrent().getSystemFont());

		label.setBounds(new Rectangle((int) (zoom * (tableBounds.x + 33)),
				(int) (zoom * (tableBounds.y + 5)),
				(int) (dim.width * 1.5), 20));

		this.addFeedback(label);
	}
	super.showTargetFeedback(request);
}
 
开发者ID:kozake,项目名称:ermaster-k,代码行数:33,代码来源:TableViewGraphicalNodeEditPolicy.java


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