Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 3f422fc08b13481d8d59bbdf34268ce94456ded1 (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
/*
 * Copyright (c) 2009 Borland Software Corporation
 * 
 * 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
 *
 * Contributors:
 *    Michael Golubev (Borland) - initial API and implementation
 */
package org.eclipse.papyrus.uml.diagram.sequence.figures;

import org.eclipse.draw2d.Ellipse;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.RotatableDecoration;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.swt.graphics.Color;

public class EllipseDecoration extends Ellipse implements RotatableDecoration {

	private boolean myAlwaysFill;

	public EllipseDecoration() {
		setPreferredSize(new Dimension(5, 5));
	}

	public void setAlwaysFill(boolean alwaysFill) {
		myAlwaysFill = alwaysFill;
	}

	public void setLocation(Point p) {
		Dimension delta = getPreferredSize().getScaled(0.5).getNegated();
		super.setLocation(p.getTranslated(delta));
	}

	public void setReferencePoint(Point p) {
	}

	@Override
	protected void outlineShape(Graphics graphics) {
		if(myAlwaysFill) {
			Color oldBack = graphics.getBackgroundColor();
			graphics.setBackgroundColor(graphics.getForegroundColor());
			fillShape(graphics);
			graphics.setBackgroundColor(oldBack);
		}
		super.outlineShape(graphics);
	}
}

Back to the top