Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a flag to turn edge labels on and off. #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.ArrayList;

import org.kuali.maven.plugins.graph.pojo.Edge;
import org.kuali.maven.plugins.graph.pojo.GraphDescriptor;
import org.kuali.maven.plugins.graph.pojo.GraphNode;
import org.kuali.maven.plugins.graph.pojo.MavenContext;
import org.kuali.maven.plugins.graph.pojo.Scope;
Expand All @@ -36,6 +37,11 @@
public class EdgeGenerator {
StyleProcessor sp = new StyleProcessor();
Counter counter = new Counter(1);
Boolean showEdgeLabels;

public EdgeGenerator(GraphDescriptor gd) {
this.showEdgeLabels = gd.getShowEdgeLabels();
}

/**
* <p>
Expand Down Expand Up @@ -103,7 +109,11 @@ public Edge getStyledEdge(GraphNode parent, GraphNode child, boolean optional, S
Edge edge = new Edge(parent, child);
edge.setId(id);
sp.copyStyleProperties(edge, style);
edge.setLabel(label);

if (!Boolean.FALSE.equals(showEdgeLabels)) {
edge.setLabel(label);
}

return edge;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,15 @@ public abstract class BaseGraphMojo extends BaseMavenMojo {
*/
private boolean showDuplicates;

/**
* <p>
* Show labels on the graph edges.
* </p>
*
* @parameter expression="${graph.showEdgeLabels}" default-value="true"
*/
private boolean showEdgeLabels = true;

/**
* <p>
* Determines how conflicts in the dependency tree are displayed. Valid options are <code>IGNORE</code>,
Expand Down Expand Up @@ -363,4 +372,11 @@ public void setShowTypes(boolean showTypes) {
this.showTypes = showTypes;
}

public boolean isShowEdgeLabels() {
return showEdgeLabels;
}

public void setShowEdgeLabels(boolean showEdgeLabels) {
this.showEdgeLabels = showEdgeLabels;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ protected List<? extends Processor> getEdgeProcessors(GraphDescriptor gd) {
Processor conflictsProcessor = new HideConflictsProcessor(gd);
switch (gd.getLayout()) {
case LINKED:
processors.add(new LinkedEdgeProcessor());
processors.add(new LinkedEdgeProcessor(gd));
if (conflicts == Conflicts.LABEL) {
logger.debug("labeling conflicts");
processors.add(new ReduceClutterProcessor());
Expand All @@ -488,7 +488,7 @@ protected List<? extends Processor> getEdgeProcessors(GraphDescriptor gd) {
}
return processors;
case FLAT:
processors.add(new FlatEdgeProcessor());
processors.add(new FlatEdgeProcessor(gd));
if (conflicts == Conflicts.LABEL) {
logger.debug("labeling conflicts");
processors.add(conflictsProcessor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class GraphDescriptor {
Boolean showTypes;
Boolean showClassifiers;
Boolean showDuplicates;
Boolean showEdgeLabels;
Conflicts conflicts;
Boolean cascadeOptional;
Boolean showLegend;
Expand Down Expand Up @@ -328,4 +329,11 @@ public void setShowClassifiers(Boolean showClassifiers) {
this.showClassifiers = showClassifiers;
}

public Boolean getShowEdgeLabels() {
return showEdgeLabels;
}

public void setShowEdgeLabels(Boolean showEdgeLabels) {
this.showEdgeLabels = showEdgeLabels;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@

import org.kuali.maven.plugins.graph.dot.EdgeGenerator;
import org.kuali.maven.plugins.graph.pojo.Edge;
import org.kuali.maven.plugins.graph.pojo.GraphDescriptor;
import org.kuali.maven.plugins.graph.pojo.MavenContext;
import org.kuali.maven.plugins.graph.tree.Node;

public class FlatEdgeProcessor implements Processor {
EdgeGenerator generator = new EdgeGenerator();
EdgeGenerator generator;

public FlatEdgeProcessor(GraphDescriptor gd) {
generator = new EdgeGenerator(gd);
}

@Override
public void process(Node<MavenContext> node) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,13 @@

public class HideConflictsProcessor implements Processor {
TreeHelper helper = new TreeHelper();
EdgeGenerator generator = new EdgeGenerator();
EdgeGenerator generator;
GraphDescriptor descriptor;

public HideConflictsProcessor() {
this(null);
}

public HideConflictsProcessor(GraphDescriptor descriptor) {
super();
this.descriptor = descriptor;
this.generator = new EdgeGenerator(descriptor);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import org.kuali.maven.plugins.graph.dot.EdgeGenerator;
import org.kuali.maven.plugins.graph.pojo.Edge;
import org.kuali.maven.plugins.graph.pojo.GraphDescriptor;
import org.kuali.maven.plugins.graph.pojo.GraphNode;
import org.kuali.maven.plugins.graph.pojo.MavenContext;
import org.kuali.maven.plugins.graph.pojo.Scope;
Expand All @@ -29,7 +30,11 @@
public class LinkedEdgeProcessor implements Processor {
private static final Logger logger = LoggerFactory.getLogger(LinkedEdgeProcessor.class);
public static final String REPLACEMENT_LABEL = "replacement";
EdgeGenerator generator = new EdgeGenerator();
EdgeGenerator generator;

public LinkedEdgeProcessor(GraphDescriptor gd) {
generator = new EdgeGenerator(gd);
}

@Override
public void process(Node<MavenContext> node) {
Expand Down