diff --git a/corefx/src/main/java/com/core/graph/CoreVertexLabelRenderer.java b/corefx/src/main/java/com/core/graph/CoreVertexLabelRenderer.java new file mode 100644 index 00000000..88d03b67 --- /dev/null +++ b/corefx/src/main/java/com/core/graph/CoreVertexLabelRenderer.java @@ -0,0 +1,36 @@ +package com.core.graph; + +import edu.uci.ics.jung.visualization.renderers.DefaultVertexLabelRenderer; + +import javax.swing.*; +import javax.swing.border.EmptyBorder; +import java.awt.*; + +public class CoreVertexLabelRenderer extends DefaultVertexLabelRenderer { + + CoreVertexLabelRenderer(Color pickedVertexLabelColor) { + super(pickedVertexLabelColor); + } + + @Override + public Component getVertexLabelRendererComponent(JComponent vv, Object value, Font font, boolean isSelected, V vertex) { + super.setForeground(Color.WHITE); + if (isSelected) { + this.setForeground(this.pickedVertexLabelColor); + } + + super.setBackground(Color.BLACK); + if (font != null) { + this.setFont(font); + } else { + this.setFont(vv.getFont()); + } + + this.setIcon(null); + EmptyBorder padding = new EmptyBorder(5, 5, 5, 5); + this.setBorder(padding); + this.setValue(value); + setFont(getFont().deriveFont(Font.BOLD)); + return this; + } +} diff --git a/corefx/src/main/java/com/core/graph/NetworkGraph.java b/corefx/src/main/java/com/core/graph/NetworkGraph.java index 418d503d..383a6108 100644 --- a/corefx/src/main/java/com/core/graph/NetworkGraph.java +++ b/corefx/src/main/java/com/core/graph/NetworkGraph.java @@ -70,6 +70,7 @@ public class NetworkGraph { // node render properties renderContext.setVertexLabelTransformer(CoreNode::getName); + renderContext.setVertexLabelRenderer(new CoreVertexLabelRenderer(Color.YELLOW)); renderContext.setVertexShapeTransformer(node -> { double offset = -(IconUtils.ICON_SIZE / 2.0); return new Ellipse2D.Double(offset, offset, IconUtils.ICON_SIZE, IconUtils.ICON_SIZE);