Skip to main content
summaryrefslogtreecommitdiffstats
blob: 8107a381f40042cc44c52c42058aa74720b1f28a (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*******************************************************************************
 * Copyright (c) 2001, 2006 IBM Corporation and others.
 * 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:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.wst.wsdl.ui.internal.asd.design.figures;

import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.Polygon;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.PointList;
import org.eclipse.gef.editparts.AbstractGraphicalEditPart;

public class LinkIconFigure extends Polygon {
	private AbstractGraphicalEditPart editPart;
	private Point figLocation;
	  private PointList points = new PointList();
	  public int horizontalBuffer = 5;
	  public int verticalBuffer = 7;

	  public LinkIconFigure(AbstractGraphicalEditPart ep) {
		  editPart = ep;
		  
		  // Draw the arrow
		  points.addPoint(new Point(horizontalBuffer + 0, 4 + verticalBuffer));
		  points.addPoint(new Point(horizontalBuffer + 9, 4 + verticalBuffer));
		  points.addPoint(new Point(horizontalBuffer + 9, 0 + verticalBuffer));
		  points.addPoint(new Point(horizontalBuffer + 14, 5 + verticalBuffer));
		  points.addPoint(new Point(horizontalBuffer + 9, 10 + verticalBuffer));
		  points.addPoint(new Point(horizontalBuffer + 9, 6 + verticalBuffer));
		  points.addPoint(new Point(horizontalBuffer + 0, 6 + verticalBuffer));
		  points.addPoint(new Point(horizontalBuffer + 0, 4 + verticalBuffer));
		  
		  setFill(true);	  
		  setPoints(points);
	  }
	  
	  public void paintFigure(Graphics graphics) {
		  super.paintFigure(graphics);
	  }
	  
	  public void setFigureLocation(Point newStartingLocation) {
		  int dy = newStartingLocation.y;

		  if (figLocation != null) {
			  dy = newStartingLocation.y - figLocation.y;
		  }

		  // Update the points
		  PointList newPoints = new PointList();
		  PointList pList = getPoints();
		  for (int index = 0; index < pList.size(); index++) {
			  Point point = pList.getPoint(index);
			  // Add 5 for the padding
			  Point newPoint = new Point(point.x + horizontalBuffer, point.y + dy);
			  newPoints.addPoint(newPoint);
		  }
		  setPoints(newPoints);

		  figLocation = newStartingLocation;
	  }
	  
	  public void primTranslate(int dx, int dy) {
			bounds.x += dx;
			bounds.y += dy;
			
			PointList pList = getPoints();
			PointList newList = new PointList();
			for (int index = 0; index < pList.size(); index++) {
				Point point = pList.getPoint(index);
				Point newPoint = new Point(point.x + dx, point.y);
				newList.addPoint(newPoint);
			}
			setPoints(newList);
			
			if (useLocalCoordinates()) {
				fireCoordinateSystemChanged();
				return;
			}
		}
	  
	  public AbstractGraphicalEditPart getAssociatedEditPart() {
		  return editPart;
	  }
}

Back to the top