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


Java FigureUtilities类代码示例

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


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

示例1: paintFigure

import org.eclipse.draw2d.FigureUtilities; //导入依赖的package包/类
@Override
protected void paintFigure(Graphics g) {
	super.paintFigure(g);
	final int LEG = 5;
	Rectangle r = getBounds();
	g.setLineWidth(1);
	g.setForegroundColor(valid ? ColorConstants.black : PandionJConstants.Colors.ERROR);
	
	g.drawLine(r.x, r.y, r.x, r.y+r.height-1);
	g.drawLine(r.x, r.y, r.x+LEG, r.y);
	g.drawLine(r.x, r.y+r.height-1, r.x+LEG, r.y+r.height-1);

	g.drawLine(r.x+r.width-1, r.y, r.x+r.width-1, r.y+r.height);
	g.drawLine(r.x+r.width-1, r.y, r.x+r.width-1-LEG, r.y);
	g.drawLine(r.x+r.width-1, r.y+r.height-1, r.x+r.width-1-LEG, r.y+r.height-1);

	if(!valid) {
		g.setForegroundColor(PandionJConstants.Colors.ERROR);
		String text = "Invalid matrix";
		int textWidth = FigureUtilities.getTextWidth(text, g.getFont());
		Point p = r.getLocation().translate(r.width/2 - textWidth/2, 5);
		g.drawText(text, p);
	}
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:25,代码来源:MatrixWidget.java

示例2: relocate

import org.eclipse.draw2d.FigureUtilities; //导入依赖的package包/类
public void relocate(CellEditor celleditor) {
	Text text = (Text) celleditor.getControl();
	Rectangle rect = null;
	if(bounds == null) { 
		rect = figure.getBounds().getCopy();
	} else { 
		rect = bounds.getCopy();
	}
	figure.translateToAbsolute(rect);
	org.eclipse.swt.graphics.Rectangle trim = text.computeTrim(0, 0, 0, 0);
	rect.translate(trim.x, trim.y);
	rect.width += trim.width;
	rect.height = HEIGHT;
	if (text.getFont() != null){
		rect.height = FigureUtilities.getStringExtents("T", text.getFont()).height + 4;
	}
	text.setBounds(rect.x, rect.y - rect.height, rect.width, rect.height);
}
 
开发者ID:ShoukriKattan,项目名称:ForgedUI-Eclipse,代码行数:19,代码来源:ElementCellEditorLocator.java

示例3: paintMessage

import org.eclipse.draw2d.FigureUtilities; //导入依赖的package包/类
protected void paintMessage(Graphics graphics, Rectangle parentRect) {
	String message = Utils.getString(this.message, "");
	List<String> text = SWTWordWrap.wrap(message, resolution.width - 24, graphics.getFont());
	if (text != null && text.size() > 0){
		int oneLineHeight = getMargin()
			+ FigureUtilities.getStringExtents("X", graphics.getFont()).height;
		graphics.pushState();
		graphics.clipRect(parentRect);

		int y = parentRect.y;
		for (int i = 0; y < parentRect.bottom() && i < text.size(); i++) {
			Rectangle lineRect = new Rectangle(parentRect.x, y, parentRect.width,
					oneLineHeight + getMargin());
			Drawer.drawString(graphics, text.get(i), lineRect, Alignments.left, Alignments.top, getMargin());
			y += oneLineHeight;
		}
		graphics.popState();
	}
}
 
开发者ID:ShoukriKattan,项目名称:ForgedUI-Eclipse,代码行数:20,代码来源:EmailDialogFigure.java

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: createDescText

import org.eclipse.draw2d.FigureUtilities; //导入依赖的package包/类
/**
 * Creates the <code>Text</code> where the description of the entry is to be
 * displayed.
 * 
 * @param panel
 *            The Composite in which the <code>Text</code> is to be created
 * @return The newly created <code>Text</code>
 */
protected Text createDescText(Composite panel) {
	String desc = entry.getDescription();
	Text description = createText(panel, SWT.MULTI | SWT.WRAP | SWT.BORDER
			| SWT.V_SCROLL, desc);
	GridData data = new GridData(GridData.FILL_HORIZONTAL);
	data.widthHint = 150;
	data.heightHint = description.computeTrim(0, 0, 10, FigureUtilities
			.getFontMetrics(description.getFont()).getHeight() * 2).height;
	description.setLayoutData(data);
	if (getPermission() >= PaletteEntry.PERMISSION_LIMITED_MODIFICATION) {
		description.addModifyListener(new ModifyListener() {
			public void modifyText(ModifyEvent e) {
				handleDescriptionChanged(((Text) e.getSource()).getText());
			}
		});
	}
	return description;
}
 
开发者ID:ghillairet,项目名称:gef-gwt,代码行数:27,代码来源:DefaultEntryPage.java

示例13: relocate

import org.eclipse.draw2d.FigureUtilities; //导入依赖的package包/类
/**
 * @generated
 */
public void relocate(CellEditor celleditor) {
	Text text = (Text) celleditor.getControl();
	Rectangle rect = getWrapLabel().getTextBounds().getCopy();
	getWrapLabel().translateToAbsolute(rect);
	if (getWrapLabel().isTextWrapOn()
			&& getWrapLabel().getText().length() > 0) {
		rect.setSize(new Dimension(text.computeSize(rect.width,
				SWT.DEFAULT)));
	} else {
		int avr = FigureUtilities.getFontMetrics(text.getFont())
				.getAverageCharWidth();
		rect.setSize(new Dimension(text.computeSize(SWT.DEFAULT,
				SWT.DEFAULT)).expand(avr * 2, 0));
	}
	if (!rect.equals(new Rectangle(text.getBounds()))) {
		text.setBounds(rect.x, rect.y, rect.width, rect.height);
	}
}
 
开发者ID:road-framework,项目名称:ROADDesigner,代码行数:22,代码来源:SmcEditPartFactory.java

示例14: 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

示例15: canDrawNumber

import org.eclipse.draw2d.FigureUtilities; //导入依赖的package包/类
private boolean canDrawNumber(String num, Point startPoint ,Graphics g)
{
	Transposer transposer = new Transposer();
	transposer.setEnabled( !isHorizontal() );
	Rectangle rect =  transposer.t( g.getClip( Rectangle.SINGLETON ));
	Dimension strSize = FigureUtilities.getStringExtents(num, getFont());
	startPoint = transposer.t(startPoint);
	
	if (strSize.width + startPoint.x > rect.x  +  rect.width)
	{
		return false;
	}
	rect = transposer.t( getEndRect( g
			.getClip( Rectangle.SINGLETON ) ));
	
	if (rect.width == 0)
	{
		return true;
	}
	if (strSize.width + startPoint.x > rect.x)
	{
		return false;
	}
	return true;
}
 
开发者ID:eclipse,项目名称:birt,代码行数:26,代码来源:EditorRulerFigure.java


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