Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: b837dd49b4e49613c5f90f5c371043d7fbd08ff1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*****************************************************************************
 * Copyright (c) 2012 CEA LIST.
 *
 *    
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 *****************************************************************************/
package org.eclipse.papyrus.uml.diagram.timing.custom.figures;

import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.papyrus.uml.diagram.common.figure.node.IPapyrusUMLElementFigure;
import org.eclipse.papyrus.uml.diagram.common.figure.node.PapyrusNodeFigure;
import org.eclipse.swt.graphics.Image;

public class SmallSquareFigure extends PapyrusNodeFigure implements IPapyrusUMLElementFigure {

	public static final int SQUARE_SIZE = 5;

	/** How many pixels the Figure must be moved upwards and leftwards in order to center it */
	public static final int RADIUS = SQUARE_SIZE / 2;

	public SmallSquareFigure() {
		super();
	}

	@Override
	public void paintFigure(final Graphics g) {
		g.pushState();

		final int middleX = this.bounds.x + this.bounds.width / 2;
		final int middleY = this.bounds.y + this.bounds.height / 2;

		g.setLineWidth(1);

		g.fillRectangle(middleX - SQUARE_SIZE / 2, middleY - SQUARE_SIZE / 2, SQUARE_SIZE, SQUARE_SIZE);
		g.popState();
	}

	@Override
	public Dimension getPreferredSize(final int wHint, final int hHint) {
		return new Dimension(SQUARE_SIZE, SQUARE_SIZE);
	}

	public void setStereotypeDisplay(final String stereotypes, final Image image) {
		// nothing
	}

}

Back to the top