Changeset 24 for src/main/java/weka/clusterers/forMetisMQI/util
- Timestamp:
- Oct 6, 2010, 4:02:40 PM (14 years ago)
- Location:
- src/main/java/weka/clusterers/forMetisMQI/util
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/weka/clusterers/forMetisMQI/util/GraphsFrame.java
r23 r24 16 16 */ 17 17 private static final long serialVersionUID = 1L; 18 19 private static GraphsFrame instance = null; 18 20 19 21 private int numberOfPanels = 0; … … 23 25 private JButton nextButton = null; 24 26 private JButton prevButton = null; 27 28 public static GraphsFrame instance() { 29 if(instance == null) { 30 instance = new GraphsFrame("Graphs Frame"); 31 } 32 return instance; 33 } 34 35 private GraphsFrame() { 36 37 } 25 38 26 p ublicGraphsFrame(String name) {39 private GraphsFrame(String name) { 27 40 super(name); 28 41 setBounds(new Rectangle(800, 700)); 42 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 43 29 44 30 45 graphPanel = new JPanel(); -
src/main/java/weka/clusterers/forMetisMQI/util/Util.java
r23 r24 4 4 import java.awt.Dimension; 5 5 import java.awt.Paint; 6 import java.util.Collection; 6 7 import java.util.HashMap; 7 8 import java.util.HashSet; … … 9 10 import java.util.Map; 10 11 import java.util.Set; 12 import java.util.Map.Entry; 11 13 12 import javax.swing.JFrame;13 14 import javax.swing.JPanel; 14 15 … … 20 21 import weka.clusterers.forMetisMQI.graph.UndirectedGraph; 21 22 import edu.uci.ics.jung.algorithms.layout.FRLayout; 23 import edu.uci.ics.jung.algorithms.layout.KKLayout; 22 24 import edu.uci.ics.jung.algorithms.layout.Layout; 23 25 import edu.uci.ics.jung.graph.Graph; … … 27 29 public class Util { 28 30 29 public static JPanel panelCluster(Graph<Node, Edge> g, Set<Node> cluster) { 31 public static JPanel panelCluster(Graph<Node, Edge> g, Collection<Node> cluster) { 32 Set<Node> setNodes = new HashSet<Node>(); 33 setNodes.addAll(cluster); 30 34 Set<Set<Node>> clusters = new HashSet<Set<Node>>(); 31 clusters.add( cluster);35 clusters.add(setNodes); 32 36 return panelClusters(g, clusters); 33 37 } 34 38 39 public static JPanel panelClusters(Graph<Node, Edge> g, Set<Set<Node>> clusters) { 40 return panelClusters(g,clusters,new ToStringLabeller<Node>()); 41 } 35 42 36 public static JPanel panelClusters(Graph<Node, Edge> g, Set<Set<Node>> clusters ) {37 Layout<Node, Edge> layout = new FRLayout<Node, Edge>(g);43 public static JPanel panelClusters(Graph<Node, Edge> g, Set<Set<Node>> clusters, Transformer<Node,String> transformer) { 44 Layout<Node, Edge> layout = new KKLayout<Node, Edge>(g); 38 45 layout.setSize(new Dimension(800, 600)); // sets the initial size of the space 39 46 // The BasicVisualizationServer<V,E> is parameterized by the edge types … … 80 87 vv.setPreferredSize(new Dimension(800, 600)); // Sets the viewing area 81 88 // size 82 vv.getRenderContext().setVertexLabelTransformer( 83 new ToStringLabeller<Node>()); 84 vv.getRenderContext().setEdgeLabelTransformer( 85 new ToStringLabeller<Edge>()); 89 vv.getRenderContext().setVertexLabelTransformer(transformer); 86 90 vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint); 87 91 return vv; … … 89 93 90 94 public static JPanel panelGraph(Graph<Node, Edge> g){ 91 Layout<Node, Edge> layout = new FRLayout<Node, Edge>(g);95 Layout<Node, Edge> layout = new KKLayout<Node, Edge>(g); 92 96 layout.setSize(new Dimension(800,600)); // sets the initial size of the space 93 97 // The BasicVisualizationServer<V,E> is parameterized by the edge types … … 96 100 vv.setPreferredSize(new Dimension(800,600)); //Sets the viewing area size 97 101 vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<Node>()); 98 vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller<Edge>()); 102 vv.getRenderContext().setEdgeLabelTransformer( 103 new Transformer<Edge, String>() { 104 public String transform(Edge e) { 105 return ""; 106 } 107 }); 99 108 return vv; 100 109 } … … 120 129 return vv; 121 130 } 131 132 static public JPanel panelContractedGraph(CoarserGraphElement cge, Collection<Node> cluster) { 133 Set<Node> setNodes = new HashSet<Node>(); 134 setNodes.addAll(cluster); 135 Set<Set<Node>> clusters = new HashSet<Set<Node>>(); 136 clusters.add(setNodes); 137 return panelClusters(cge.getContracted(), clusters, new ContractedVertexTransformer(cge)); 138 } 139 140 static public JPanel panelContractedGraph(CoarserGraphElement cge) { 141 Layout<Node, Edge> layout = new KKLayout<Node, Edge>(cge.getContracted()); 142 layout.setSize(new Dimension(800,600)); // sets the initial size of the space 143 // The BasicVisualizationServer<V,E> is parameterized by the edge types 144 BasicVisualizationServer<Node,Edge> vv = 145 new BasicVisualizationServer<Node,Edge>(layout); 146 vv.setPreferredSize(new Dimension(800,600)); //Sets the viewing area size 147 vv.getRenderContext().setVertexLabelTransformer(new ContractedVertexTransformer(cge)); 148 return vv; 149 } 150 122 151 123 152 /**
Note: See TracChangeset
for help on using the changeset viewer.