1 /*******************************************************************************
2 * Copyright (c) 2007, 2011 Association for Decentralized Information Management in
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.diagram.connection.tests.actions;
14 import java.awt.Graphics2D;
15 import java.awt.geom.Line2D;
17 import org.simantics.diagram.connection.RouteGraph;
18 import org.simantics.diagram.connection.RouteLineHalf;
19 import org.simantics.diagram.connection.actions.IAction;
20 import org.simantics.diagram.connection.rendering.IRouteGraphRenderer;
22 public class HighlightReconnectPointsAction implements IAction {
24 public static final double DEGENERATED_LINE_LENGTH = 0.8;
25 public static final double CROSS_SIZE = 0.5;
30 public HighlightReconnectPointsAction(RouteGraph rg) {
34 public HighlightReconnectPointsAction(RouteGraph rg, double crossSize) {
36 this.crossSize = crossSize;
40 public void render(Graphics2D g, IRouteGraphRenderer renderer, double mouseX, double mouseY) {
41 renderer.render(g, rg);
42 for(RouteLineHalf lh : rg.getLineHalves()) {
43 if(lh.getLine().getLength() < DEGENERATED_LINE_LENGTH)
45 double x = lh.getLink().getX();
46 double y = lh.getLink().getY();
47 if(lh.getLine().isHorizontal()) {
48 if(lh.getLink() == lh.getLine().getBegin())
54 if(lh.getLink() == lh.getLine().getBegin())
59 g.draw(new Line2D.Double(x-crossSize,y-crossSize,x+crossSize,y+crossSize));
60 g.draw(new Line2D.Double(x-crossSize,y+crossSize,x+crossSize,y-crossSize));