1234567891011121314151617181920212223242526272829303132333435363738394041 |
- package view;
- import java.awt.Color;
- import java.awt.Point;
- import java.awt.Polygon;
- import java.awt.Shape;
- import java.awt.geom.AffineTransform;
- /**
- * Contains helper functions for the views.
- * @author kolja
- *
- */
- public class RenderHelper {
- public static final Color BACKGROUND_COLOR = new Color(0x2b2b2b);
- public static final Color FOREGROUND_COLOR = new Color(0xa9b7c6);
- public static final Color BREAKPOINT_COLOR = new Color(0x6c2020);
- public static final Color CURRENT_LINE_COLOR = new Color(0x606366);
-
- /**
- * creates an arrow shape to draw it, for example as part of an edge.
- * @param fromPt the starting point of the arrow
- * @param toPt the destination point of the arrow
- * @return the shape
- */
- public static Shape createArrowShape(Point fromPt, Point toPt) {
- Polygon arrowPolygon = new Polygon();
- arrowPolygon.addPoint(-3,6);
- arrowPolygon.addPoint(3,0);
- arrowPolygon.addPoint(-3,-6);
- arrowPolygon.addPoint(-3,6);
- double rotate = Math.atan2( ( toPt.y - fromPt.y ) , ( toPt.x - fromPt.x ) );
- AffineTransform transform = new AffineTransform();
- transform.translate(toPt.x, toPt.y);
- transform.rotate(rotate);
- return transform.createTransformedShape(arrowPolygon);
- }
- }
|