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


Java PositionConstants.CENTER属性代码示例

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


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

示例1: drawHorizontalTitleBar

/**
 * rect는 타이틀 바를 그릴 사각형이다. 여기서는 이 사각형에 타이틀 바를 그린다.
 * 타이틀 바를 가로로 생성한 파티션의 왼쪽에 세로로 그린다.
 * 
 * @param figure
 * @param g
 * @param rect
 *            void
 */
private void drawHorizontalTitleBar(IFigure figure, Graphics g, Rectangle rect) {
    g.setBackgroundColor(getBackgroundColor());
    g.fillRectangle(rect);

    Insets padding = getPadding();
    int x = rect.x + padding.left;
    int y = rect.y + padding.top + (rect.height - getTextExtents(figure).height) / 2;

    int textWidth = getTextExtents(figure).width;
    int freeSpace = rect.width - padding.getWidth() - textWidth;

    if (getTextAlignment() == PositionConstants.CENTER)
        freeSpace /= 2;
    if (getTextAlignment() != PositionConstants.LEFT)
        x += freeSpace;

    Font f = getFont(figure);
    FontData fData = f.getFontData()[0];
    fData.setName(this.getFontName());
    fData.setStyle(this.getTextStyle());
    fData.setHeight(this.getFontSize());
    g.setFont(f);
    g.setForegroundColor(this.getTextColor());
    g.drawString(getLabel(), x, y);
}
 
开发者ID:SK-HOLDINGS-CC,项目名称:NEXCORE-UML-Modeler,代码行数:34,代码来源:TitleBarBorder.java

示例2: drawTitleBar

/**
 * rect는 타이틀 바를 그릴 사각형이다. 여기서는 이 사각형에 타이틀 바를 그린다.
 * 
 * @param figure
 * @param g
 * @param rect
 *            void
 */
private void drawTitleBar(IFigure figure, Graphics g, Rectangle rect) {
    g.setBackgroundColor(getBackgroundColor());
    g.fillRectangle(rect);

    Insets padding = getPadding();
    int x = rect.x + padding.left;
    int y = rect.y + padding.top + (rect.height - getTextExtents(figure).height) / 2;

    int textWidth = getTextExtents(figure).width;
    int freeSpace = rect.width - padding.getWidth() - textWidth;

    if (getTextAlignment() == PositionConstants.CENTER)
        freeSpace /= 2;
    if (getTextAlignment() != PositionConstants.LEFT)
        x += freeSpace;

    Font f = getFont(figure);
    FontData fData = f.getFontData()[0];
    fData.setName(this.getFontName());
    fData.setStyle(this.getTextStyle());
    fData.setHeight(this.getFontSize());
    g.setFont(f);
    g.setForegroundColor(this.getTextColor());
    g.drawString(getLabel(), x, y);
}
 
开发者ID:SK-HOLDINGS-CC,项目名称:NEXCORE-UML-Modeler,代码行数:33,代码来源:TitleBarBorder.java

示例3: doNormalAlignment

private void doNormalAlignment(Rectangle result, Rectangle reference) {
	switch (alignment) {
	case PositionConstants.LEFT:
		result.x = reference.x;
		break;
	case PositionConstants.RIGHT:
		result.x = reference.x + reference.width - result.width;
		break;
	case PositionConstants.TOP:
		result.y = reference.y;
		break;
	case PositionConstants.BOTTOM:
		result.y = reference.y + reference.height - result.height;
		break;
	case PositionConstants.CENTER:
		result.x = reference.x + (reference.width / 2) - (result.width / 2);
		break;
	case PositionConstants.MIDDLE:
		result.y = reference.y + (reference.height / 2)
				- (result.height / 2);
		break;
	}
}
 
开发者ID:ghillairet,项目名称:gef-gwt,代码行数:23,代码来源:AlignmentRequest.java

示例4: doNormalAlignment

private void doNormalAlignment(Rectangle result, Rectangle reference) {
    switch (alignment) {
        case PositionConstants.LEFT:
            result.x = reference.x;
            break;
        case PositionConstants.RIGHT:
            result.x = reference.x + reference.width - result.width;
            break;
        case PositionConstants.TOP:
            result.y = reference.y;
            break;
        case PositionConstants.BOTTOM:
            result.y = reference.y + reference.height - result.height;
            break;
        case PositionConstants.CENTER:
            result.x = reference.x + (reference.width / 2) - (result.width / 2);
            break;
        case PositionConstants.MIDDLE:
            result.y = reference.y + (reference.height / 2) - (result.height / 2);
            break;
    }
}
 
开发者ID:henrikor2,项目名称:eclipsensis,代码行数:22,代码来源:DistributionRequest.java

示例5: getPosition

/**
 *  Get the position from string
 * @param position
 * 	  The given string
 * @return
 *    The position
 */
public static int getPosition( String position )
{
	if ( DesignChoiceConstants.BACKGROUND_POSITION_LEFT.equals( position ) )
	{
		return PositionConstants.WEST;
	}
	if ( DesignChoiceConstants.BACKGROUND_POSITION_RIGHT.equals( position ) )
	{
		return PositionConstants.EAST;
	}
	if ( DesignChoiceConstants.BACKGROUND_POSITION_TOP.equals( position ) )
	{
		return PositionConstants.NORTH;
	}
	if ( DesignChoiceConstants.BACKGROUND_POSITION_BOTTOM.equals( position ) )
	{
		return PositionConstants.SOUTH;
	}
	return PositionConstants.CENTER;
}
 
开发者ID:eclipse,项目名称:birt,代码行数:27,代码来源:DesignElementHandleAdapter.java

示例6: paint

public void paint(IFigure figure, Graphics g, Insets insets)
{
	tempRect.setBounds(getPaintRectangle(figure, insets));
	Rectangle rec = tempRect;
	rec.height = 3;
	g.clipRect(rec);
	g.setBackgroundColor(orange);
	g.fillRectangle(rec);

	int x = rec.x + padding.left;
	int y = rec.y + padding.top;

	int textWidth = getTextExtents(figure).width;
	int freeSpace = rec.width - padding.getWidth() - textWidth;

	if (getTextAlignment() == PositionConstants.CENTER)
		freeSpace /= 2;
	if (getTextAlignment() != PositionConstants.LEFT)
		x += freeSpace;

	g.setFont(getFont(figure));
	g.setForegroundColor(getTextColor());
}
 
开发者ID:winture,项目名称:wt-studio,代码行数:23,代码来源:VerticalBlockFrameBorder.java

示例7: paint

public void paint(IFigure figure, Graphics g, Insets insets)
{
	tempRect.setBounds(getPaintRectangle(figure, insets));
	Rectangle rec = tempRect;
	// rec.height = Math.min(rec.height, getTextExtents(figure).height + padding.getHeight());
	rec.height = 3;
	g.clipRect(rec);
	g.setBackgroundColor(orange);
	g.fillRectangle(rec);

	int x = rec.x + padding.left;
	int y = rec.y + padding.top;

	int textWidth = getTextExtents(figure).width;
	int freeSpace = rec.width - padding.getWidth() - textWidth;

	if (getTextAlignment() == PositionConstants.CENTER)
		freeSpace /= 2;
	if (getTextAlignment() != PositionConstants.LEFT)
		x += freeSpace;

	g.setFont(getFont(figure));
	g.setForegroundColor(getTextColor());
	// g.drawString(getLabel(), x, y);
}
 
开发者ID:winture,项目名称:wt-studio,代码行数:25,代码来源:HorizontalBlockFrameBorder.java

示例8: add

/**
 * @see org.eclipse.draw2d.Figure#add(org.eclipse.draw2d.IFigure, java.lang.Object, int)
 */
@Override
public void add(IFigure figure, Object constraint, int index) {
    if (((Label) figure).getTextAlignment() == PositionConstants.CENTER) {
        super.add(figure, constraint, 0);
    } else {
        super.add(figure, constraint, index);
    }
}
 
开发者ID:SK-HOLDINGS-CC,项目名称:NEXCORE-UML-Modeler,代码行数:11,代码来源:CompartmentLabelFigure.java

示例9: execute

@Override
public void execute() {
	setPositionCommands = new ArrayList<SetValueCommand>();
	JRDesignElement designElement = primary.getValue();
	for(MGraphicElement element : selection){
		if (element != primary){
			JRDesignElement selected = element.getValue();
			switch (alignement) {
			case PositionConstants.LEFT:
				createCommand(JRDesignElement.PROPERTY_X, element, designElement.getX());
				break;
			case PositionConstants.RIGHT:
				int rightPost = designElement.getX() + designElement.getWidth() - selected.getWidth();
				createCommand(JRDesignElement.PROPERTY_X, element, rightPost);
				break;
			case PositionConstants.TOP:
				createCommand(JRDesignElement.PROPERTY_Y, element, designElement.getY());
				break;
			case PositionConstants.BOTTOM:
				int bottomPos = designElement.getY() + designElement.getHeight() - selected.getHeight();
				createCommand(JRDesignElement.PROPERTY_Y, element, bottomPos);
				break;
			case PositionConstants.CENTER:
				int centerVert = designElement.getX() + Math.abs(designElement.getWidth() - selected.getWidth())/2;
				createCommand(JRDesignElement.PROPERTY_X, element, centerVert);
				break;
			case PositionConstants.MIDDLE:
				int middle = designElement.getY() + Math.abs(designElement.getHeight() - selected.getHeight())/2;
				createCommand(JRDesignElement.PROPERTY_Y, element, middle);
				break;
			default:
				break;
			}
		}
	}
	//Execute the subcommands
	for(Command cmd : setPositionCommands){
		cmd.execute();
	}
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:40,代码来源:Align2ElementCommand.java

示例10: execute

@Override
public void execute() {
	oldX = jrElement.getX();
	oldY = jrElement.getY();

	int newX = oldX;
	int newY = oldY;
	switch (alignement) {
	case PositionConstants.LEFT:
		newX = 0;
		break;
	case PositionConstants.RIGHT:
		newX = parent.width - jrElement.getWidth();
		break;
	case PositionConstants.TOP:
		newY = 0;
		break;
	case PositionConstants.BOTTOM:
		newY = parent.height - jrElement.getHeight();
		break;
	case PositionConstants.CENTER:
		newX = parent.width / 2 - jrElement.getWidth() / 2;
		break;
	case PositionConstants.MIDDLE:
		newY = parent.height / 2 - jrElement.getHeight() / 2;
		break;
	}
	jrElement.setX(newX);
	jrElement.setY(newY);
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:30,代码来源:AlignCommand.java

示例11: doPrecisionAlignment

private void doPrecisionAlignment(PrecisionRectangle result,
		PrecisionRectangle reference) {
	switch (alignment) {
	case PositionConstants.LEFT:
		result.setPreciseX(reference.preciseX());
		break;
	case PositionConstants.RIGHT:
		result.setPreciseX(reference.preciseX() + reference.preciseWidth()
				- result.preciseWidth());
		break;
	case PositionConstants.TOP:
		result.setPreciseY(reference.preciseY());
		break;
	case PositionConstants.BOTTOM:
		result.setPreciseY(reference.preciseY() + reference.preciseHeight()
				- result.preciseHeight());
		break;
	case PositionConstants.CENTER:
		result.setPreciseX(reference.preciseX()
				+ (reference.preciseWidth() / 2)
				- (result.preciseWidth() / 2));
		break;
	case PositionConstants.MIDDLE:
		result.setPreciseY(reference.preciseY()
				+ (reference.preciseHeight() / 2)
				- (result.preciseHeight() / 2));
		break;
	}

}
 
开发者ID:ghillairet,项目名称:gef-gwt,代码行数:30,代码来源:AlignmentRequest.java

示例12: doPrecisionAlignment

private void doPrecisionAlignment(
    PrecisionRectangle result,
    PrecisionRectangle reference) {
    switch (alignment) {
        case PositionConstants.LEFT:
            result.setX(reference.preciseX);
            break;
        case PositionConstants.RIGHT:
            result.setX(
                reference.preciseX + reference.preciseWidth - result.preciseWidth);
            break;
        case PositionConstants.TOP:
            result.setY(reference.preciseY);
            break;
        case PositionConstants.BOTTOM:
            result.setY(
                reference.preciseY + reference.preciseHeight - result.preciseHeight);
            break;
        case PositionConstants.CENTER:
            result.setX(
                reference.preciseX
                    + (reference.preciseWidth / 2)
                    - (result.preciseWidth / 2));
            break;
        case PositionConstants.MIDDLE:
            result.setY(
                reference.preciseY
                    + (reference.preciseHeight / 2)
                    - (result.preciseHeight / 2));
            break;
    }


}
 
开发者ID:henrikor2,项目名称:eclipsensis,代码行数:34,代码来源:DistributionRequest.java

示例13: paint

public void paint(IFigure figure, Graphics g, Insets insets) {
	tempRect.setBounds(getPaintRectangle(figure, insets));
	Rectangle rec = tempRect;
	rec.height = Math.min(rec.height, getTextExtents(figure).height
			+ padding.getHeight()); 
	g.clipRect(rec);
	g.setForegroundColor(ColorConstants.titleInactiveGradient);  
	g.setBackgroundColor(ColorConstants.white);
	g.fillGradient(rec, true);  

	
	
	int x = rec.x + padding.left;
	int y = rec.y + padding.top;
	Image image=Activator.getImageDescriptor("icons/model_new.gif").createImage();
	g.drawImage(image, new Point(x,y));
       x=x+image.getBounds().width+5;
       image.dispose();
	int textWidth = getTextExtents(figure).width;
	int freeSpace = rec.width - padding.getWidth() - textWidth;

	if (getTextAlignment() == PositionConstants.CENTER)
		freeSpace /= 2;
	if (getTextAlignment() != PositionConstants.LEFT)
		x += freeSpace;

	g.setFont(getFont(figure));
	g.setForegroundColor(ColorConstants.darkBlue);
	g.drawString(getLabel(), x, y);
	
	g.setForegroundColor(ColorConstants.darkBlue);
	g.drawLine(rec.x, rec.y+rec.height-1, rec.width+rec.x+2, rec.y+rec.height-1);
}
 
开发者ID:winture,项目名称:wt-studio,代码行数:33,代码来源:ITitleBorder.java

示例14: paint

public void paint(IFigure figure, Graphics g, Insets insets) {
	tempRect.setBounds(getPaintRectangle(figure, insets));
	Rectangle rec = tempRect;
	rec.height = Math.min(rec.height, getTextExtents(figure).height
			+ padding.getHeight()); 
	g.clipRect(rec);
	g.setForegroundColor(ColorConstants.titleGradient); 
	g.setBackgroundColor(ColorConstants.white);
	g.fillGradient(rec, true);  

	
	
	int x = rec.x + padding.left;
	int y = rec.y + padding.top;
	Image image=Activator.getImageDescriptor(ImageResource.MO).createImage();
	g.drawImage(image, new Point(x,y));
       x=x+Activator.getImageDescriptor(ImageResource.MO).createImage().getBounds().width+5;
	int textWidth = getTextExtents(figure).width;
	int freeSpace = rec.width - padding.getWidth() - textWidth;

	if (getTextAlignment() == PositionConstants.CENTER)
		freeSpace /= 2;
	if (getTextAlignment() != PositionConstants.LEFT)
		x += freeSpace;

	g.setFont(getFont(figure));
	g.setForegroundColor(ColorConstants.darkBlue);
	g.drawString(getLabel(), x, y);
	
	g.setForegroundColor(ColorConstants.darkBlue);
	g.drawLine(rec.x, rec.y+rec.height-1, rec.width+rec.x+2, rec.y+rec.height-1);
}
 
开发者ID:winture,项目名称:wt-studio,代码行数:32,代码来源:MOTitleBorder.java

示例15: paint

public void paint(IFigure figure, Graphics g, Insets insets) {
	tempRect.setBounds(getPaintRectangle(figure, insets));
	Rectangle rec = tempRect;
	rec.height = Math.min(rec.height, getTextExtents(figure).height
			+ padding.getHeight()); 
	g.clipRect(rec);
	g.setForegroundColor(ColorConstants.titleInactiveGradient); 
	g.setBackgroundColor(ColorConstants.white);
	g.fillGradient(rec, true);  

	
	
	int x = rec.x + padding.left;
	int y = rec.y + padding.top;
	Image image=Activator.getImageDescriptor(ImageResource.VO).createImage();
	g.drawImage(image, new Point(x,y));
       x=x+Activator.getImageDescriptor(ImageResource.TABLE).createImage().getBounds().width+5;
	int textWidth = getTextExtents(figure).width;
	int freeSpace = rec.width - padding.getWidth() - textWidth;

	if (getTextAlignment() == PositionConstants.CENTER)
		freeSpace /= 2;
	if (getTextAlignment() != PositionConstants.LEFT)
		x += freeSpace;

	g.setFont(getFont(figure));
	g.setForegroundColor(ColorConstants.darkBlue);
	g.drawString(getLabel(), x, y);
	
	g.setForegroundColor(ColorConstants.darkBlue);
	g.drawLine(rec.x, rec.y+rec.height-1, rec.width+rec.x+2, rec.y+rec.height-1);
}
 
开发者ID:winture,项目名称:wt-studio,代码行数:32,代码来源:VOTitleBorder.java


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