Commit 8a9b03b1 authored by rhaase's avatar rhaase
Browse files

Replaced by PathDrawer

parent 60cff782
package de.mpicbg.scf.skeletonanalysis;
import ij.ImagePlus;
import ij.gui.Line;
import ij.gui.OvalRoi;
import ij.gui.Overlay;
import ij.gui.Roi;
import sc.fiji.analyzeSkeleton.Edge;
import sc.fiji.analyzeSkeleton.Graph;
import sc.fiji.analyzeSkeleton.Point;
import sc.fiji.analyzeSkeleton.Vertex;
import java.awt.*;
import java.util.ArrayList;
/**
* Author: Robert Haase, Scientific Computing Facility, MPI-CBG Dresden, rhaase@mpi-cbg.de
* Date: September 2016
*/
@Deprecated
public class GraphDrawer {
Graph source;
ImagePlus target;
public GraphDrawer(Graph source, ImagePlus target)
{
this.source = source;
this.target = target;
System.out.println("Root: " + source.getRoot().toString());
drawVertex(source.getRoot(), Color.yellow);
}
public void draw()
{
for (Edge edge : source.getEdges()) {
drawEdge(edge);
}
}
private void drawEdge(Edge edge) {
drawVertex(edge.getV1(), Color.green);
drawVertex(edge.getV2(), Color.green);
/*for (Point point : edge.getSlabs()) {
drawPoint(point, Color.red);
}*/
drawPoint(edge.getSlabs().get(0), Color.red);
drawPoint(edge.getSlabs().get(edge.getSlabs().size() - 1), Color.red);
drawPolygon(edge.getSlabs(), Color.red);
}
private void drawVertex(Vertex v, Color color) {
//drawPoint(v.getPoints().get(0), Color.red);
Point average = SkeletonAnalyser.getCenterOfJunction(v);
drawPoint(average, Color.green);
}
private void drawPoint(Point point, Color color) {
double radius = 1;
if (color.equals(Color.red))
{
radius = 1;
}
if (color.equals(Color.yellow))
{
radius = 2;
}
if (color.equals(Color.green))
{
radius = 3;
}
Roi roi = new OvalRoi(point.x-radius / 2+0.5, point.y- radius / 2+0.5, radius+0.5, radius+0.5);
roi.setStrokeColor(color);
//target.setRoi(roi);
fixRoiInOverlay(roi);
}
private void fixRoiInOverlay(Roi roi) {
if (target.getOverlay() == null) {
target.setOverlay(new Overlay());
}
target.getOverlay().add(roi);
}
private void drawPolygon(ArrayList<Point> list, Color color)
{
Point predecessor = null;
for (Point point : list)
{
if (predecessor != null)
{
Roi roi = new Line(point.x+0.5, point.y+0.5, predecessor.x+0.5, predecessor.y+0.5);
//()Roi(point.x, point.y, 2, 2);
roi.setStrokeColor(color);
fixRoiInOverlay(roi);
}
predecessor = point;
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment