org.eclipse.draw2d.geometry.Dimension Java Examples

The following examples show how to use org.eclipse.draw2d.geometry.Dimension. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProcessEditPartFactory.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
* @generated
*/
public void relocate(CellEditor celleditor) {
	Text text = (Text) celleditor.getControl();
	Rectangle rect = getWrapLabel().getTextBounds().getCopy();
	getWrapLabel().translateToAbsolute(rect);
	if (!text.getFont().isDisposed()) {
		if (getWrapLabel().isTextWrapOn() && getWrapLabel().getText().length() > 0) {
			//Adjust editor location
			rect.x = rect.x - 5;
			if (rect.width < 75) {
				rect.width = 75;
			}
			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);
	}
}
 
Example #2
Source File: UpdatePoolSizeCommand.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void increaseWidth() {
	ChangeBoundsRequest setRequest1 = new ChangeBoundsRequest(RequestConstants.REQ_RESIZE) ; 
	List<EditPart> epToMove = new ArrayList<EditPart>();
	epToMove.add(gep);
	for(Object o : gep.getChildren()){
		if(o instanceof CustomPoolCompartmentEditPart){
			for(CustomLaneEditPart lane : ((CustomPoolCompartmentEditPart)o).getPoolLanes()){
				epToMove.add(lane);
			}
		}
		
	}
	setRequest1.setEditParts(epToMove);
	setRequest1.setResizeDirection(PositionConstants.EAST);
	setRequest1.setSizeDelta(new Dimension(150,0));
	gep.getDiagramEditDomain().getDiagramCommandStack().execute(gep.getCommand(setRequest1));
}
 
Example #3
Source File: TableCellEditPart.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
protected Dimension getCellDimension( )
{
	int h = 0;
	int w = 0;

	TableEditPart tablePart = (TableEditPart) getParent( );

	int rNumber = getRowNumber( );
	int cNumber = getColumnNumber( );

	if ( rNumber > 0 && cNumber > 0 )
	{
		for ( int i = rNumber; i < rNumber + getRowSpan( ); i++ )
		{
			h += tablePart.caleVisualHeight( i );
		}

		for ( int j = cNumber; j < cNumber + getColSpan( ); j++ )
		{
			w += tablePart.caleVisualWidth( j );
		}
	}
	return new Dimension( w, h );
}
 
Example #4
Source File: ListBandRenderFigure.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public Dimension getPreferredSize( int wHint, int hHint )
{
	invalidateTree( );

	Dimension dim = super.getPreferredSize( wHint, hHint );

	if ( dim.height < HEIGHT )
	{
		dim.height = HEIGHT;
	}
	if ( wHint > 0 && dim.width < wHint)
	{
		dim.width = wHint;
	}
	return dim;
}
 
Example #5
Source File: MultipleGuideHandle.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Calculate the size.
 * 
 * @return
 */
protected Dimension calculateIndicatorDimension( )
{
	Dimension retValue = new Dimension( );
	List children = getChildren( );
	for ( int i = 0; i < children.size( ); i++ )
	{
		Figure figure = (Figure) children.get( i );
		if ( figure instanceof ShowSourceFigure )
		{
			continue;
		}
		// retValue = retValue.union( figure.getSize( ) );
		retValue.width = retValue.width + figure.getSize( ).width;
		retValue.height = Math.max( retValue.height,
				figure.getSize( ).height );
	}

	return retValue;
}
 
Example #6
Source File: ReportResizeTracker.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private Dimension getFigureSize()
{
	IFigure figure = getOwner( ).getFigure( );
	Dimension dim = figure.getSize( );
	if (figure instanceof IOutsideBorder)
	{
		Border border = ((IOutsideBorder)figure).getOutsideBorder( );
		Insets insets = border.getInsets( figure );
		if (PositionConstants.EAST == getResizeDirection())
		{
			dim.width = dim.width - insets.right - insets.left;
		}
		else if (PositionConstants.SOUTH == getResizeDirection())
		{
			dim.height = dim.height - insets.bottom - insets.top;
		}
	}
	return dim;
}
 
Example #7
Source File: NodeElementEditPart.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
protected Rectangle getRectangle() {
    final NodeElement element = (NodeElement) getModel();

    final Point point = new Point(element.getX(), element.getY());

    final Dimension dimension = new Dimension(element.getWidth(), element.getHeight());

    final Dimension minimumSize = figure.getMinimumSize();

    if (dimension.width != -1 && dimension.width < minimumSize.width) {
        dimension.width = minimumSize.width;
    }
    if (dimension.height != -1 && dimension.height < minimumSize.height) {
        dimension.height = minimumSize.height;
    }

    return new Rectangle(point, dimension);
}
 
Example #8
Source File: DesignerRepresentation.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private void showNullChart( Dimension dSize )
{
	// Display error message for null chart. This behavior is consistent
	// with invalid table.
	String MSG = Messages.getString( "DesignerRepresentation.msg.InvalidChart" ); //$NON-NLS-1$
	logger.log( ILogger.ERROR,
			Messages.getString( "DesignerRepresentation.log.UnableToFind" ) ); //$NON-NLS-1$

	Device dv = Display.getCurrent( );
	Font font = FontManager.getFont( "Dialog", 10, SWT.ITALIC ); //$NON-NLS-1$
	gc.setFont( font );
	FontMetrics fm = gc.getFontMetrics( );
	gc.setForeground( dv.getSystemColor( SWT.COLOR_RED ) );
	gc.setBackground( dv.getSystemColor( SWT.COLOR_WHITE ) );
	gc.fillRectangle( 0, 0, dSize.width - 1, dSize.height - 1 );
	gc.drawRectangle( 0, 0, dSize.width - 1, dSize.height - 1 );
	String[] texts = splitOnBreaks( MSG, font, dSize.width - 10 );
	int y = 5;
	for ( String text : texts )
	{
		gc.drawText( text, 5, y );
		y += fm.getHeight( );
	}
}
 
Example #9
Source File: SetConstraintCommandTest.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void testSetConstraintLabelCmd( )
{

	LabelHandle label = getElementFactory( ).newLabel( "TestLabel" );

	SetConstraintCommand cmd = new SetConstraintCommand( );
	Dimension size = new Dimension( 50, 100 ); //pixel
	cmd.setModel( label );
	cmd.setSize( size );
	cmd.execute( );

	DimensionHandle width = label.getWidth( );
	DimensionHandle height = label.getHeight( );
	assertTrue( width.getUnits( ).equals( DesignChoiceConstants.UNITS_IN ) );
	assertTrue( height.getUnits( ).equals( DesignChoiceConstants.UNITS_IN ) );
	double widthPixel = MetricUtility.inchToPixel( width.getMeasure( ) );
	double heightPixel = MetricUtility.inchToPixel( height.getMeasure( ) );
	assertEquals( 50, (int) widthPixel );
	assertEquals( 100, (int) heightPixel );

}
 
Example #10
Source File: TableEditPart.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public Dimension getPreferredSize( )
{
	Dimension retValue = getFigure( ).getParent( )
			.getClientArea( )
			.getSize( );
	Rectangle rect = getBounds( );

	if ( rect.width > 0 )
	{
		retValue.width = rect.width;
	}
	if ( rect.height > 0 )
	{
		retValue.height = rect.height;
	}
	return retValue;
}
 
Example #11
Source File: FirstCellLayout.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
protected Dimension calculateMinimumSize( IFigure container, int wHint, int hHint )
{
	if ( wHint > -1 )
		wHint = Math.max( 0, wHint - container.getInsets( ).getWidth( ) );
	if ( hHint > -1 )
		hHint = Math.max( 0, hHint - container.getInsets( ).getHeight( ) );
	
	List list = container.getChildren( );
	//Rectangle rect = container.getClientArea( );
	Dimension retValue = new Dimension();
	Rectangle contraint = getChildContraint( container );
	for (int i=0; i<list.size( ); i++)
	{
		Figure child = (Figure)list.get( i );
		Dimension min = child.getMinimumSize( (wHint-contraint.width) > 0?wHint-contraint.width:-1  , hHint );
		retValue.width = retValue.width + min.width;
		retValue.height = Math.max( retValue.height,min.height);
	}	
	retValue.width += container.getInsets( ).getWidth( );
	retValue.height += container.getInsets( ).getHeight( );
	//retValue.union( getBorderPreferredSize( container ) );
	return retValue;
}
 
Example #12
Source File: PolygonController.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void setPreferredSize ( final Dimension size )
{
    if ( size == null )
    {
        super.setPreferredSize ( this.points.getBounds ().expand ( 10, 10 ).getSize () );
    }
    else
    {
        super.setPreferredSize ( size );
    }
}
 
Example #13
Source File: PMClassFigure.java    From JDeodorant with MIT License 5 votes vote down vote up
public Dimension calculateSize(){
	Dimension size = new Dimension();
	int minSize = 20;
	int maxSize = 150 ;
	double width, height;
	double range =(double) (MAX_NUM - MIN_NUM);
	width =  (((numOfAttributes - MIN_NUM)/range) * maxSize) + minSize;
	height =  (((numOfMethods - MIN_NUM)/range) * maxSize) + minSize;
	
	size.width = (int) width;
	size.height = (int) height;
	return size;
}
 
Example #14
Source File: ListLayout.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected Dimension calculateMinimumSize( IFigure container, int wHint,
		int hHint )
{
	Dimension dim = new Dimension( );

	List list = container.getChildren( );
	int size = list.size( );
	int height = 0;
	int width = 0;
	for ( int i = 0; i < size; i++ )
	{
		IFigure figure = (IFigure) list.get( i );
		Dimension min = figure.getMinimumSize( wHint, hHint );
		height = height + min.height;
		if ( min.width > width )
		{
			width = min.width;
		}
	}
	if ( height > 0 )
	{
		dim.height = height
				+ container.getInsets( ).getHeight( )
				+ ( size - 1 )
				* verticalSpan;
	}

	dim.width = width + container.getInsets( ).getWidth( );
	//dim.expand(container.getInsets().getWidth(),
	// container.getInsets().getHeight());
	return dim;
}
 
Example #15
Source File: CreateElementCommand.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
public CreateElementCommand(ERDiagram diagram,
		NodeElement element, int x,
		int y, Dimension size, List<NodeElement> enclosedElementList) {
	this.diagram = diagram;
	this.element = element;

	if (this.element instanceof Category && size != null) {
		this.element
				.setLocation(new Location(x, y, size.width, size.height));
	} else {
		this.element.setLocation(new Location(x, y, ERTable.DEFAULT_WIDTH,
				ERTable.DEFAULT_HEIGHT));
	}

	if (element instanceof ERTable) {
		ERTable table = (ERTable) element;
		table.setLogicalName(ERTable.NEW_LOGICAL_NAME);
		table.setPhysicalName(ERTable.NEW_PHYSICAL_NAME);

	} else if (element instanceof View) {
		View view = (View) element;
		view.setLogicalName(View.NEW_LOGICAL_NAME);
		view.setPhysicalName(View.NEW_PHYSICAL_NAME);
	}

	this.enclosedElementList = enclosedElementList;
}
 
Example #16
Source File: IntermediateThrowSignalEventEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @generated
 */
public SignalThrowEventFigure() {

	GridLayout layoutThis = new GridLayout();
	layoutThis.numColumns = 1;
	layoutThis.makeColumnsEqualWidth = true;
	this.setLayoutManager(layoutThis);

	this.setURI("platform:/plugin/org.bonitasoft.studio.pics/icons/figures/ThrowSignalEvent.svgz");
	this.setPreferredSize(new Dimension(getMapMode().DPtoLP(30), getMapMode().DPtoLP(30)));
	this.setMaximumSize(new Dimension(getMapMode().DPtoLP(30), getMapMode().DPtoLP(30)));
}
 
Example #17
Source File: LineController.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void setPreferredSize ( final Dimension size )
{
    if ( size == null )
    {
        super.setPreferredSize ( this.points.getBounds ().expand ( 10, 10 ).getSize () );
    }
    else
    {
        super.setPreferredSize ( size );
    }
}
 
Example #18
Source File: StartMessageEventEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) {
	if (borderItemEditPart instanceof StartMessageEventLabelEditPart) {
		BorderItemLocator locator = new BorderItemLocator(getMainFigure(), PositionConstants.SOUTH);
		locator.setBorderItemOffset(new Dimension(-20, -20));
		borderItemContainer.add(borderItemEditPart.getFigure(), locator);
	} else {
		super.addBorderItem(borderItemContainer, borderItemEditPart);
	}
}
 
Example #19
Source File: Activity2EditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @generated
 */
public ActivityFigure() {

	GridLayout layoutThis = new GridLayout();
	layoutThis.numColumns = 1;
	layoutThis.makeColumnsEqualWidth = true;
	layoutThis.marginWidth = 20;
	layoutThis.marginHeight = 5;
	this.setLayoutManager(layoutThis);

	this.setPreferredSize(new Dimension(getMapMode().DPtoLP(100), getMapMode().DPtoLP(50)));
	this.setMinimumSize(new Dimension(getMapMode().DPtoLP(100), getMapMode().DPtoLP(50)));
	this.setURI("platform:/plugin/org.bonitasoft.studio.pics/icons/figures/Activity.svgz");
	createContents();
}
 
Example #20
Source File: EventTooltip.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Dimension getPreferredSize(int w, int h) {
	Dimension dimension = super.getPreferredSize(-1, -1);
	if (dimension.width > 150)
		dimension = super.getPreferredSize(150, -1);

	return dimension;
}
 
Example #21
Source File: EditorRulerProvider.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected void initLayoutSize( ModuleHandle module )
{
	if ( module != null )
	{
		Dimension dim = EditorRulerComposite.getMasterPageSize( SessionHandleAdapter.getInstance( )
				.getFirstMasterPageHandle( module ) );

		layoutSize = new Rectangle( 0, 0, dim.width, dim.height );
	}
}
 
Example #22
Source File: XORGateway2EditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) {
	if (borderItemEditPart instanceof XORGatewayLabel2EditPart) {
		BorderItemLocator locator = new BorderItemLocator(getMainFigure(), PositionConstants.SOUTH);
		locator.setBorderItemOffset(new Dimension(-20, -20));
		borderItemContainer.add(borderItemEditPart.getFigure(), locator);
	} else {
		super.addBorderItem(borderItemContainer, borderItemEditPart);
	}
}
 
Example #23
Source File: ProcBuilderTests.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void initProcBuilderWithDefaultContent(final String diagramName,
        final String poolName, final String description, final List<String> categories,
        final File diagramFile) throws ProcBuilderException {
    procBuilder.createDiagram(diagramName, diagramName, "1.0", diagramFile);

    procBuilder.addPool(poolName, poolName, "1.0", new Point(0, 0), new Dimension(1000, 200));
    procBuilder.setAttributeOnCurrentContainer(ProcessPackage.eINSTANCE.getAbstractProcess_Categories(), categories);
    procBuilder.addEvent("Start", "Start", new Point(20, 20), new Dimension(50, 50), EventType.START);

    procBuilder.setAttributeOnCurrentStep(ProcessPackage.eINSTANCE.getElement_Documentation(), description);
}
 
Example #24
Source File: DAxis.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Calculate span of a textual form of object in scale's orientation
 *
 * @param obj
 *            object
 * @return span in pixel
 */
public int calculateSpan(Object obj) {
	final Dimension extent = getDimension(obj);
	if (isHorizontal()) {
		return extent.width;
	}
	return extent.height;
}
 
Example #25
Source File: SendTask2EditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @generated
 */
public ActivityFigure() {

	GridLayout layoutThis = new GridLayout();
	layoutThis.numColumns = 1;
	layoutThis.makeColumnsEqualWidth = true;
	layoutThis.marginWidth = 20;
	layoutThis.marginHeight = 5;
	this.setLayoutManager(layoutThis);

	this.setPreferredSize(new Dimension(getMapMode().DPtoLP(100), getMapMode().DPtoLP(50)));
	this.setMinimumSize(new Dimension(getMapMode().DPtoLP(100), getMapMode().DPtoLP(50)));
	this.setURI("platform:/plugin/org.bonitasoft.studio.pics/icons/figures/Activity.svgz");
	createContents();
}
 
Example #26
Source File: Annotation.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * update (dx, dy) if (x0, y0) has been updated by dragging.
 * 
 * @param size
 *            the label size
 * @return
 */
private void updatedxdyFromX0Y0() {
	Dimension size = infoLabel.getPreferredSize();
	int h = size.height;
	int w = size.width;
	if (y0 != 0) {
		dy = y0 + h / 2.0;
		dx = x0 * dy / y0;
		if (new Range(0, x0).inRange(dx) && new Range(0, y0).inRange(dy)
				&& new Range(x0 - w / 2.0, x0 + w / 2.0).inRange(dx))
			return;

		dy = y0 - h / 2.0;
		dx = x0 * dy / y0;
		if (new Range(0, x0).inRange(dx) && new Range(0, y0).inRange(dy)
				&& new Range(x0 - w / 2.0, x0 + w / 2.0).inRange(dx))
			return;
	} else
		dy = 0;
	if (x0 != 0) {
		dx = x0 - size.width / 2.0;
		dy = y0 * dx / x0;
		if (new Range(0, x0).inRange(dx) && new Range(0, y0).inRange(dy)
				&& new Range(y0 - h / 2.0, y0 + h / 2.0).inRange(dy))
			return;

		dx = x0 + size.width / 2.0;
		dy = y0 * dx / x0;
		if (new Range(0, x0).inRange(dx) && new Range(0, y0).inRange(dy)
				&& new Range(y0 - h / 2.0, y0 + h / 2.0).inRange(dy))
			return;
	} else
		dx = 0;
}
 
Example #27
Source File: DummyEditpart.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected IFigure createFigure( )
{
	Figure figure = new Figure( );
	figure.setMaximumSize( new Dimension( 0, 0 ) );
	figure.setSize( 0, 0 );
	return figure;
}
 
Example #28
Source File: CustomDrawerFigure.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createScrollpane() {
	scrollpane = new ScrollPane();
	scrollpane.getViewport().setContentsTracksWidth(true);
	scrollpane.setMinimumSize(new Dimension(0, 0));
	scrollpane.setHorizontalScrollBarVisibility(ScrollPane.NEVER);

	scrollpane.setLayoutManager(new OverlayScrollPaneLayout());
	scrollpane.setContents(new Figure());
	scrollpane.getContents().setOpaque(true);
	scrollpane.getContents().setBackgroundColor(PaletteColorUtil.WIDGET_LIST_BACKGROUND);
}
 
Example #29
Source File: CompartmentCreationEditPolicy.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Command getCreateElementAndViewCommand(
		CreateViewAndElementRequest request) {
	String semanticHint = request.getViewAndElementDescriptor()
			.getSemanticHint();
	if (fixedSizeElements.contains(semanticHint))
		request.setSize(new Dimension(-1, -1));
	return super.getCreateElementAndViewCommand(request);
}
 
Example #30
Source File: CommitmentTaskEditPart.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @generated
 */
public CommitmentTaskFigure() {

	GridLayout layoutThis = new GridLayout();
	layoutThis.numColumns = 1;
	layoutThis.makeColumnsEqualWidth = true;
	this.setLayoutManager(layoutThis);

	this.setCornerDimensions(new Dimension(getMapMode().DPtoLP(8), getMapMode().DPtoLP(8)));
	this.setBorder(new MarginBorder(getMapMode().DPtoLP(5), getMapMode().DPtoLP(5), getMapMode().DPtoLP(5),
			getMapMode().DPtoLP(5)));
	createContents();
}