The following document contains the results of PMD's CPD 4.2.2.
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/L2RTreeLayoutDemo.java | 209 |
| edu/uci/ics/jung/samples/TreeLayoutDemo.java | 196 |
content.add(controls, BorderLayout.SOUTH);
}
class Rings implements VisualizationServer.Paintable {
Collection<Double> depths;
public Rings() {
depths = getDepths();
}
private Collection<Double> getDepths() {
Set<Double> depths = new HashSet<Double>();
Map<String,PolarPoint> polarLocations = radialLayout.getPolarLocations();
for(String v : graph.getVertices()) {
PolarPoint pp = polarLocations.get(v);
depths.add(pp.getRadius());
}
return depths;
}
public void paint(Graphics g) {
g.setColor(Color.lightGray);
Graphics2D g2d = (Graphics2D)g;
Point2D center = radialLayout.getCenter();
Ellipse2D ellipse = new Ellipse2D.Double();
for(double d : depths) {
ellipse.setFrameFromDiagonal(center.getX()-d, center.getY()-d,
center.getX()+d, center.getY()+d);
Shape shape = vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).transform(ellipse);
g2d.draw(shape);
}
}
public boolean useTransform() {
return true;
}
}
/**
*
*/
private void createTree() {
graph.addVertex("V0");
graph.addEdge(edgeFactory.create(), "V0", "V1");
graph.addEdge(edgeFactory.create(), "V0", "V2");
graph.addEdge(edgeFactory.create(), "V1", "V4");
graph.addEdge(edgeFactory.create(), "V2", "V3");
graph.addEdge(edgeFactory.create(), "V2", "V5");
graph.addEdge(edgeFactory.create(), "V4", "V6");
graph.addEdge(edgeFactory.create(), "V4", "V7");
graph.addEdge(edgeFactory.create(), "V3", "V8");
graph.addEdge(edgeFactory.create(), "V6", "V9");
graph.addEdge(edgeFactory.create(), "V4", "V10");
graph.addVertex("A0");
graph.addEdge(edgeFactory.create(), "A0", "A1");
graph.addEdge(edgeFactory.create(), "A0", "A2");
graph.addEdge(edgeFactory.create(), "A0", "A3");
graph.addVertex("B0");
graph.addEdge(edgeFactory.create(), "B0", "B1");
graph.addEdge(edgeFactory.create(), "B0", "B2");
graph.addEdge(edgeFactory.create(), "B1", "B4");
graph.addEdge(edgeFactory.create(), "B2", "B3");
graph.addEdge(edgeFactory.create(), "B2", "B5");
graph.addEdge(edgeFactory.create(), "B4", "B6");
graph.addEdge(edgeFactory.create(), "B4", "B7");
graph.addEdge(edgeFactory.create(), "B3", "B8");
graph.addEdge(edgeFactory.create(), "B6", "B9");
}
/**
* a driver for this demo
*/
public static void main(String[] args) {
JFrame frame = new JFrame();
Container content = frame.getContentPane();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
content.add(new TreeLayoutDemo());
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/TreeCollapseDemo.java | 244 |
| edu/uci/ics/jung/samples/TreeLayoutDemo.java | 194 |
controls.add(modeBox);
content.add(controls, BorderLayout.SOUTH);
}
class Rings implements VisualizationServer.Paintable {
Collection<Double> depths;
public Rings() {
depths = getDepths();
}
private Collection<Double> getDepths() {
Set<Double> depths = new HashSet<Double>();
Map<String,PolarPoint> polarLocations = radialLayout.getPolarLocations();
for(String v : graph.getVertices()) {
PolarPoint pp = polarLocations.get(v);
depths.add(pp.getRadius());
}
return depths;
}
public void paint(Graphics g) {
g.setColor(Color.lightGray);
Graphics2D g2d = (Graphics2D)g;
Point2D center = radialLayout.getCenter();
Ellipse2D ellipse = new Ellipse2D.Double();
for(double d : depths) {
ellipse.setFrameFromDiagonal(center.getX()-d, center.getY()-d,
center.getX()+d, center.getY()+d);
Shape shape = vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).transform(ellipse);
g2d.draw(shape);
}
}
public boolean useTransform() {
return true;
}
}
/**
*
*/
private void createTree() {
graph.addVertex("V0");
graph.addEdge(edgeFactory.create(), "V0", "V1");
graph.addEdge(edgeFactory.create(), "V0", "V2");
graph.addEdge(edgeFactory.create(), "V1", "V4");
graph.addEdge(edgeFactory.create(), "V2", "V3");
graph.addEdge(edgeFactory.create(), "V2", "V5");
graph.addEdge(edgeFactory.create(), "V4", "V6");
graph.addEdge(edgeFactory.create(), "V4", "V7");
graph.addEdge(edgeFactory.create(), "V3", "V8");
graph.addEdge(edgeFactory.create(), "V6", "V9");
graph.addEdge(edgeFactory.create(), "V4", "V10");
graph.addVertex("A0");
graph.addEdge(edgeFactory.create(), "A0", "A1");
graph.addEdge(edgeFactory.create(), "A0", "A2");
graph.addEdge(edgeFactory.create(), "A0", "A3");
graph.addVertex("B0");
graph.addEdge(edgeFactory.create(), "B0", "B1");
graph.addEdge(edgeFactory.create(), "B0", "B2");
graph.addEdge(edgeFactory.create(), "B1", "B4");
graph.addEdge(edgeFactory.create(), "B2", "B3");
graph.addEdge(edgeFactory.create(), "B2", "B5");
graph.addEdge(edgeFactory.create(), "B4", "B6");
graph.addEdge(edgeFactory.create(), "B4", "B7");
graph.addEdge(edgeFactory.create(), "B3", "B8");
graph.addEdge(edgeFactory.create(), "B6", "B9");
}
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/L2RTreeLayoutDemo.java | 209 |
| edu/uci/ics/jung/samples/TreeCollapseDemo.java | 245 |
content.add(controls, BorderLayout.SOUTH);
}
class Rings implements VisualizationServer.Paintable {
Collection<Double> depths;
public Rings() {
depths = getDepths();
}
private Collection<Double> getDepths() {
Set<Double> depths = new HashSet<Double>();
Map<String,PolarPoint> polarLocations = radialLayout.getPolarLocations();
for(String v : graph.getVertices()) {
PolarPoint pp = polarLocations.get(v);
depths.add(pp.getRadius());
}
return depths;
}
public void paint(Graphics g) {
g.setColor(Color.lightGray);
Graphics2D g2d = (Graphics2D)g;
Point2D center = radialLayout.getCenter();
Ellipse2D ellipse = new Ellipse2D.Double();
for(double d : depths) {
ellipse.setFrameFromDiagonal(center.getX()-d, center.getY()-d,
center.getX()+d, center.getY()+d);
Shape shape = vv.getRenderContext().
getMultiLayerTransformer().getTransformer(Layer.LAYOUT).transform(ellipse);
g2d.draw(shape);
}
}
public boolean useTransform() {
return true;
}
}
/**
*
*/
private void createTree() {
graph.addVertex("V0");
graph.addEdge(edgeFactory.create(), "V0", "V1");
graph.addEdge(edgeFactory.create(), "V0", "V2");
graph.addEdge(edgeFactory.create(), "V1", "V4");
graph.addEdge(edgeFactory.create(), "V2", "V3");
graph.addEdge(edgeFactory.create(), "V2", "V5");
graph.addEdge(edgeFactory.create(), "V4", "V6");
graph.addEdge(edgeFactory.create(), "V4", "V7");
graph.addEdge(edgeFactory.create(), "V3", "V8");
graph.addEdge(edgeFactory.create(), "V6", "V9");
graph.addEdge(edgeFactory.create(), "V4", "V10");
graph.addVertex("A0");
graph.addEdge(edgeFactory.create(), "A0", "A1");
graph.addEdge(edgeFactory.create(), "A0", "A2");
graph.addEdge(edgeFactory.create(), "A0", "A3");
graph.addVertex("B0");
graph.addEdge(edgeFactory.create(), "B0", "B1");
graph.addEdge(edgeFactory.create(), "B0", "B2");
graph.addEdge(edgeFactory.create(), "B1", "B4");
graph.addEdge(edgeFactory.create(), "B2", "B3");
graph.addEdge(edgeFactory.create(), "B2", "B5");
graph.addEdge(edgeFactory.create(), "B4", "B6");
graph.addEdge(edgeFactory.create(), "B4", "B7");
graph.addEdge(edgeFactory.create(), "B3", "B8");
graph.addEdge(edgeFactory.create(), "B6", "B9");
}
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/GraphZoomScrollPaneDemo.java | 195 |
| edu/uci/ics/jung/samples/VisualizationImageServerDemo.java | 86 |
content.add(label);
frame.pack();
frame.setVisible(true);
}
/**
* create some vertices
* @param count how many to create
* @return the Vertices in an array
*/
private String[] createVertices(int count) {
String[] v = new String[count];
for (int i = 0; i < count; i++) {
v[i] = "V"+i;
graph.addVertex(v[i]);
}
return v;
}
/**
* create edges for this demo graph
* @param v an array of Vertices to connect
*/
void createEdges(String[] v) {
graph.addEdge(new Double(Math.random()), v[0], v[1], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[0], v[3], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[0], v[4], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[4], v[5], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[3], v[5], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[1], v[2], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[1], v[4], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[8], v[2], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[3], v[8], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[6], v[7], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[7], v[5], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[0], v[9], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[9], v[8], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[7], v[6], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[6], v[5], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[4], v[2], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[5], v[4], EdgeType.DIRECTED);
}
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/DrawnIconVertexDemo.java | 152 |
| edu/uci/ics/jung/samples/UnicodeLabelDemo.java | 177 |
}
/**
* create some vertices
* @param count how many to create
* @return the Vertices in an array
*/
private Integer[] createVertices(int count) {
Integer[] v = new Integer[count];
for (int i = 0; i < count; i++) {
v[i] = new Integer(i);
graph.addVertex(v[i]);
}
return v;
}
/**
* create edges for this demo graph
* @param v an array of Vertices to connect
*/
void createEdges(Integer[] v) {
graph.addEdge(new Double(Math.random()), v[0], v[1], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[0], v[3], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[0], v[4], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[4], v[5], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[3], v[5], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[1], v[2], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[1], v[4], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[8], v[2], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[3], v[8], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[6], v[7], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[7], v[5], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[0], v[9], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[9], v[8], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[7], v[6], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[6], v[5], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[4], v[2], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[5], v[4], EdgeType.DIRECTED);
}
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/VertexCollapseDemo.java | 188 |
| edu/uci/ics/jung/samples/VertexCollapseDemoWithLayouts.java | 204 |
double sumx = 0;
double sumy = 0;
for(Object v : picked) {
Point2D p = (Point2D)layout.transform(v);
sumx += p.getX();
sumy += p.getY();
}
Point2D cp = new Point2D.Double(sumx/picked.size(), sumy/picked.size());
vv.getRenderContext().getParallelEdgeIndexFunction().reset();
layout.setGraph(g);
layout.setLocation(clusterGraph, cp);
vv.getPickedVertexState().clear();
vv.repaint();
}
}});
JButton compressEdges = new JButton("Compress Edges");
compressEdges.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Collection picked = vv.getPickedVertexState().getPicked();
if(picked.size() == 2) {
Pair pair = new Pair(picked);
Graph graph = layout.getGraph();
Collection edges = new HashSet(graph.getIncidentEdges(pair.getFirst()));
edges.retainAll(graph.getIncidentEdges(pair.getSecond()));
exclusions.addAll(edges);
vv.repaint();
}
}});
JButton expandEdges = new JButton("Expand Edges");
expandEdges.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Collection picked = vv.getPickedVertexState().getPicked();
if(picked.size() == 2) {
Pair pair = new Pair(picked);
Graph graph = layout.getGraph();
Collection edges = new HashSet(graph.getIncidentEdges(pair.getFirst()));
edges.retainAll(graph.getIncidentEdges(pair.getSecond()));
exclusions.removeAll(edges);
vv.repaint();
}
}});
JButton expand = new JButton("Expand");
expand.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Collection picked = new HashSet(vv.getPickedVertexState().getPicked());
for(Object v : picked) {
if(v instanceof Graph) {
Graph g = collapser.expand(layout.getGraph(), (Graph)v);
vv.getRenderContext().getParallelEdgeIndexFunction().reset();
layout.setGraph(g);
}
vv.getPickedVertexState().clear();
vv.repaint();
}
}});
JButton reset = new JButton("Reset");
reset.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
layout.setGraph(graph);
exclusions.clear();
vv.repaint();
}});
JButton help = new JButton("Help");
help.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog((JComponent)e.getSource(), instructions, "Help", JOptionPane.PLAIN_MESSAGE);
}
});
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/DrawnIconVertexDemo.java | 173 |
| edu/uci/ics/jung/samples/VisualizationImageServerDemo.java | 109 |
void createEdges(String[] v) {
graph.addEdge(new Double(Math.random()), v[0], v[1], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[0], v[3], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[0], v[4], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[4], v[5], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[3], v[5], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[1], v[2], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[1], v[4], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[8], v[2], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[3], v[8], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[6], v[7], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[7], v[5], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[0], v[9], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[9], v[8], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[7], v[6], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[6], v[5], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[4], v[2], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[5], v[4], EdgeType.DIRECTED);
}
/**
* a driver for this demo
*/
public static void main(String[] args)
{
new VisualizationImageServerDemo();
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/DrawnIconVertexDemo.java | 173 |
| edu/uci/ics/jung/samples/GraphZoomScrollPaneDemo.java | 219 |
void createEdges(String[] v) {
graph.addEdge(new Double(Math.random()), v[0], v[1], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[0], v[3], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[0], v[4], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[4], v[5], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[3], v[5], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[1], v[2], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[1], v[4], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[8], v[2], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[3], v[8], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[6], v[7], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[7], v[5], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[0], v[9], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[9], v[8], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[7], v[6], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[6], v[5], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[4], v[2], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[5], v[4], EdgeType.DIRECTED);
}
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/VertexCollapseDemo.java | 109 |
| edu/uci/ics/jung/samples/VertexCollapseDemoWithLayouts.java | 124 |
collapser = new GraphCollapser(graph);
layout = new FRLayout(graph);
Dimension preferredSize = new Dimension(400,400);
final VisualizationModel visualizationModel =
new DefaultVisualizationModel(layout, preferredSize);
vv = new VisualizationViewer(visualizationModel, preferredSize);
vv.getRenderContext().setVertexShapeTransformer(new ClusterVertexShapeFunction());
final PredicatedParallelEdgeIndexFunction eif = PredicatedParallelEdgeIndexFunction.getInstance();
final Set exclusions = new HashSet();
eif.setPredicate(new Predicate() {
public boolean evaluate(Object e) {
return exclusions.contains(e);
}});
vv.getRenderContext().setParallelEdgeIndexFunction(eif);
vv.setBackground(Color.white);
// add a listener for ToolTips
vv.setVertexToolTipTransformer(new ToStringLabeller() {
/* (non-Javadoc)
* @see edu.uci.ics.jung.visualization.decorators.DefaultToolTipFunction#getToolTipText(java.lang.Object)
*/
@Override
public String transform(Object v) {
if(v instanceof Graph) {
return ((Graph)v).getVertices().toString();
}
return super.transform(v);
}});
/**
* the regular graph mouse for the normal view
*/
final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse();
vv.setGraphMouse(graphMouse);
Container content = getContentPane();
GraphZoomScrollPane gzsp = new GraphZoomScrollPane(vv);
content.add(gzsp);
JComboBox modeBox = graphMouse.getModeComboBox();
modeBox.addItemListener(graphMouse.getModeListener());
graphMouse.setMode(ModalGraphMouse.Mode.PICKING);
final ScalingControl scaler = new CrossoverScalingControl();
JButton plus = new JButton("+");
plus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv, 1.1f, vv.getCenter());
}
});
JButton minus = new JButton("-");
minus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv, 1/1.1f, vv.getCenter());
}
});
JButton collapse = new JButton("Collapse");
collapse.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Collection picked = new HashSet(vv.getPickedVertexState().getPicked());
if(picked.size() > 1) {
Graph inGraph = layout.getGraph();
Graph clusterGraph = collapser.getClusterGraph(inGraph, picked);
Graph g = collapser.collapse(layout.getGraph(), clusterGraph);
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/RadialTreeLensDemo.java | 228 |
| edu/uci/ics/jung/samples/TreeCollapseDemo.java | 285 |
}
/**
*
*/
private void createTree() {
graph.addVertex("V0");
graph.addEdge(edgeFactory.create(), "V0", "V1");
graph.addEdge(edgeFactory.create(), "V0", "V2");
graph.addEdge(edgeFactory.create(), "V1", "V4");
graph.addEdge(edgeFactory.create(), "V2", "V3");
graph.addEdge(edgeFactory.create(), "V2", "V5");
graph.addEdge(edgeFactory.create(), "V4", "V6");
graph.addEdge(edgeFactory.create(), "V4", "V7");
graph.addEdge(edgeFactory.create(), "V3", "V8");
graph.addEdge(edgeFactory.create(), "V6", "V9");
graph.addEdge(edgeFactory.create(), "V4", "V10");
graph.addVertex("A0");
graph.addEdge(edgeFactory.create(), "A0", "A1");
graph.addEdge(edgeFactory.create(), "A0", "A2");
graph.addEdge(edgeFactory.create(), "A0", "A3");
graph.addVertex("B0");
graph.addEdge(edgeFactory.create(), "B0", "B1");
graph.addEdge(edgeFactory.create(), "B0", "B2");
graph.addEdge(edgeFactory.create(), "B1", "B4");
graph.addEdge(edgeFactory.create(), "B2", "B3");
graph.addEdge(edgeFactory.create(), "B2", "B5");
graph.addEdge(edgeFactory.create(), "B4", "B6");
graph.addEdge(edgeFactory.create(), "B4", "B7");
graph.addEdge(edgeFactory.create(), "B3", "B8");
graph.addEdge(edgeFactory.create(), "B6", "B9");
}
/**
* a demo class that will create a vertex shape that is either a
* polygon or star. The number of sides corresponds to the number
* of vertices that were collapsed into the vertex represented by
* this shape.
*
* @author Tom Nelson
*
* @param <V>
*/
class ClusterVertexShapeFunction<V> extends EllipseVertexShapeTransformer<V>
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/L2RTreeLayoutDemo.java | 248 |
| edu/uci/ics/jung/samples/RadialTreeLensDemo.java | 228 |
}
private void createTree() {
graph.addVertex("V0");
graph.addEdge(edgeFactory.create(), "V0", "V1");
graph.addEdge(edgeFactory.create(), "V0", "V2");
graph.addEdge(edgeFactory.create(), "V1", "V4");
graph.addEdge(edgeFactory.create(), "V2", "V3");
graph.addEdge(edgeFactory.create(), "V2", "V5");
graph.addEdge(edgeFactory.create(), "V4", "V6");
graph.addEdge(edgeFactory.create(), "V4", "V7");
graph.addEdge(edgeFactory.create(), "V3", "V8");
graph.addEdge(edgeFactory.create(), "V6", "V9");
graph.addEdge(edgeFactory.create(), "V4", "V10");
graph.addVertex("A0");
graph.addEdge(edgeFactory.create(), "A0", "A1");
graph.addEdge(edgeFactory.create(), "A0", "A2");
graph.addEdge(edgeFactory.create(), "A0", "A3");
graph.addVertex("B0");
graph.addEdge(edgeFactory.create(), "B0", "B1");
graph.addEdge(edgeFactory.create(), "B0", "B2");
graph.addEdge(edgeFactory.create(), "B1", "B4");
graph.addEdge(edgeFactory.create(), "B2", "B3");
graph.addEdge(edgeFactory.create(), "B2", "B5");
graph.addEdge(edgeFactory.create(), "B4", "B6");
graph.addEdge(edgeFactory.create(), "B4", "B7");
graph.addEdge(edgeFactory.create(), "B3", "B8");
graph.addEdge(edgeFactory.create(), "B6", "B9");
}
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/ImageEdgeLabelDemo.java | 128 |
| edu/uci/ics/jung/samples/VertexImageShaperDemo.java | 374 |
}
/**
* create some vertices
* @param count how many to create
* @return the Vertices in an array
*/
private void createGraph(int vertexCount) {
for (int i = 0; i < vertexCount; i++) {
graph.addVertex(i);
}
int j=0;
graph.addEdge(j++, 0, 1, EdgeType.DIRECTED);
graph.addEdge(j++, 3, 0, EdgeType.DIRECTED);
graph.addEdge(j++, 0, 4, EdgeType.DIRECTED);
graph.addEdge(j++, 4, 5, EdgeType.DIRECTED);
graph.addEdge(j++, 5, 3, EdgeType.DIRECTED);
graph.addEdge(j++, 2, 1, EdgeType.DIRECTED);
graph.addEdge(j++, 4, 1, EdgeType.DIRECTED);
graph.addEdge(j++, 8, 2, EdgeType.DIRECTED);
graph.addEdge(j++, 3, 8, EdgeType.DIRECTED);
graph.addEdge(j++, 6, 7, EdgeType.DIRECTED);
graph.addEdge(j++, 7, 5, EdgeType.DIRECTED);
graph.addEdge(j++, 0, 9, EdgeType.DIRECTED);
graph.addEdge(j++, 9, 8, EdgeType.DIRECTED);
graph.addEdge(j++, 7, 6, EdgeType.DIRECTED);
graph.addEdge(j++, 6, 5, EdgeType.DIRECTED);
graph.addEdge(j++, 4, 2, EdgeType.DIRECTED);
graph.addEdge(j++, 5, 4, EdgeType.DIRECTED);
graph.addEdge(j++, 4, 10, EdgeType.DIRECTED);
graph.addEdge(j++, 10, 4, EdgeType.DIRECTED);
}
/**
* this class exists only to provide settings to turn on/off shapes and image fill
* in this demo.
* In a real application, use DefaultVertexIconTransformer instead.
*
*/
public static class DemoVertexIconTransformer<V> extends DefaultVertexIconTransformer<V>
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/L2RTreeLayoutDemo.java | 138 |
| edu/uci/ics/jung/samples/TreeLayoutDemo.java | 134 |
rings = new Rings();
Container content = getContentPane();
final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
content.add(panel);
final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse();
vv.setGraphMouse(graphMouse);
JComboBox modeBox = graphMouse.getModeComboBox();
modeBox.addItemListener(graphMouse.getModeListener());
graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);
final ScalingControl scaler = new CrossoverScalingControl();
JButton plus = new JButton("+");
plus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv, 1.1f, vv.getCenter());
}
});
JButton minus = new JButton("-");
minus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv, 1/1.1f, vv.getCenter());
}
});
JToggleButton radial = new JToggleButton("Radial");
radial.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if(e.getStateChange() == ItemEvent.SELECTED) {
LayoutTransition<String,Integer> lt =
new LayoutTransition<String,Integer>(vv, treeLayout, radialLayout);
Animator animator = new Animator(lt);
animator.start();
vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
vv.addPreRenderPaintable(rings);
} else {
LayoutTransition<String,Integer> lt =
new LayoutTransition<String,Integer>(vv, radialLayout, treeLayout);
Animator animator = new Animator(lt);
animator.start();
vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/DrawnIconVertexDemo.java | 180 |
| edu/uci/ics/jung/samples/LensVertexImageShaperDemo.java | 386 |
graph.addEdge(new Double(Math.random()), v[4], v[1], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[8], v[2], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[3], v[8], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[6], v[7], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[7], v[5], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[0], v[9], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[9], v[8], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[7], v[6], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[6], v[5], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[4], v[2], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[5], v[4], EdgeType.DIRECTED);
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/DrawnIconVertexDemo.java | 109 |
| edu/uci/ics/jung/samples/UnicodeLabelDemo.java | 87 |
vertexIconShapeFunction.setIconMap(vertexIconFunction.getIconMap());
vv.getRenderContext().setVertexFillPaintTransformer(new PickableVertexPaintTransformer<Integer>(vv.getPickedVertexState(), Color.white, Color.yellow));
vv.getRenderContext().setEdgeDrawPaintTransformer(new PickableEdgePaintTransformer<Number>(vv.getPickedEdgeState(), Color.black, Color.lightGray));
vv.setBackground(Color.white);
// add my listener for ToolTips
vv.setVertexToolTipTransformer(new ToStringLabeller<Integer>());
// create a frome to hold the graph
final JFrame frame = new JFrame();
Container content = frame.getContentPane();
final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
content.add(panel);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final ModalGraphMouse gm = new DefaultModalGraphMouse<Integer,Number>();
vv.setGraphMouse(gm);
final ScalingControl scaler = new CrossoverScalingControl();
JButton plus = new JButton("+");
plus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv, 1.1f, vv.getCenter());
}
});
JButton minus = new JButton("-");
minus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv, 1/1.1f, vv.getCenter());
}
});
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/TreeCollapseDemo.java | 144 |
| edu/uci/ics/jung/samples/TreeLayoutDemo.java | 130 |
vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
// add a listener for ToolTips
vv.setVertexToolTipTransformer(new ToStringLabeller());
vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray));
rings = new Rings();
Container content = getContentPane();
final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
content.add(panel);
final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse();
vv.setGraphMouse(graphMouse);
JComboBox modeBox = graphMouse.getModeComboBox();
modeBox.addItemListener(graphMouse.getModeListener());
graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);
final ScalingControl scaler = new CrossoverScalingControl();
JButton plus = new JButton("+");
plus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv, 1.1f, vv.getCenter());
}
});
JButton minus = new JButton("-");
minus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv, 1/1.1f, vv.getCenter());
}
});
JToggleButton radial = new JToggleButton("Radial");
radial.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if(e.getStateChange() == ItemEvent.SELECTED) {
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/LensVertexImageShaperDemo.java | 191 |
| edu/uci/ics/jung/samples/VertexImageShaperDemo.java | 198 |
ps.addItemListener(new PickWithIconListener<Number>(vertexIconTransformer));
vv.addPostRenderPaintable(new VisualizationViewer.Paintable(){
int x;
int y;
Font font;
FontMetrics metrics;
int swidth;
int sheight;
String str = "Thank You, slashdot.org, for the images!";
public void paint(Graphics g) {
Dimension d = vv.getSize();
if(font == null) {
font = new Font(g.getFont().getName(), Font.BOLD, 20);
metrics = g.getFontMetrics(font);
swidth = metrics.stringWidth(str);
sheight = metrics.getMaxAscent()+metrics.getMaxDescent();
x = (d.width-swidth)/2;
y = (int)(d.height-sheight*1.5);
}
g.setFont(font);
Color oldColor = g.getColor();
g.setColor(Color.lightGray);
g.drawString(str, x, y);
g.setColor(oldColor);
}
public boolean useTransform() {
return false;
}
});
// add a listener for ToolTips
vv.setVertexToolTipTransformer(new ToStringLabeller<Number>());
Container content = getContentPane();
final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
content.add(panel);
final DefaultModalGraphMouse<Number,Number> graphMouse = new DefaultModalGraphMouse<Number,Number>();
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/GraphZoomScrollPaneDemo.java | 162 |
| edu/uci/ics/jung/samples/WorldMapGraphDemo.java | 177 |
final AbstractModalGraphMouse graphMouse = new DefaultModalGraphMouse();
vv.setGraphMouse(graphMouse);
vv.addKeyListener(graphMouse.getModeKeyListener());
vv.setToolTipText("<html><center>Type 'p' for Pick mode<p>Type 't' for Transform mode");
final ScalingControl scaler = new CrossoverScalingControl();
// vv.scaleToLayout(scaler);
JButton plus = new JButton("+");
plus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv, 1.1f, vv.getCenter());
}
});
JButton minus = new JButton("-");
minus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv, 1/1.1f, vv.getCenter());
}
});
JButton reset = new JButton("reset");
reset.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).setToIdentity();
vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW).setToIdentity();
}});
JPanel controls = new JPanel();
controls.add(plus);
controls.add(minus);
controls.add(reset);
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/PluggableRendererDemo.java | 584 |
| edu/uci/ics/jung/samples/VertexLabelPositionDemo.java | 133 |
gzsp.setCorner(menubar);
JComboBox cb = new JComboBox();
cb.addItem(Renderer.VertexLabel.Position.N);
cb.addItem(Renderer.VertexLabel.Position.NE);
cb.addItem(Renderer.VertexLabel.Position.E);
cb.addItem(Renderer.VertexLabel.Position.SE);
cb.addItem(Renderer.VertexLabel.Position.S);
cb.addItem(Renderer.VertexLabel.Position.SW);
cb.addItem(Renderer.VertexLabel.Position.W);
cb.addItem(Renderer.VertexLabel.Position.NW);
cb.addItem(Renderer.VertexLabel.Position.N);
cb.addItem(Renderer.VertexLabel.Position.CNTR);
cb.addItem(Renderer.VertexLabel.Position.AUTO);
cb.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
Renderer.VertexLabel.Position position =
(Renderer.VertexLabel.Position)e.getItem();
vv.getRenderer().getVertexLabelRenderer().setPosition(position);
vv.repaint();
}});
cb.setSelectedItem(Renderer.VertexLabel.Position.SE);
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/L2RTreeLayoutDemo.java | 138 |
| edu/uci/ics/jung/samples/TreeCollapseDemo.java | 148 |
rings = new Rings();
Container content = getContentPane();
final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
content.add(panel);
final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse();
vv.setGraphMouse(graphMouse);
JComboBox modeBox = graphMouse.getModeComboBox();
modeBox.addItemListener(graphMouse.getModeListener());
graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);
final ScalingControl scaler = new CrossoverScalingControl();
JButton plus = new JButton("+");
plus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv, 1.1f, vv.getCenter());
}
});
JButton minus = new JButton("-");
minus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv, 1/1.1f, vv.getCenter());
}
});
JToggleButton radial = new JToggleButton("Radial");
radial.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if(e.getStateChange() == ItemEvent.SELECTED) {
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/L2RTreeLayoutDemo.java | 71 |
| edu/uci/ics/jung/samples/TreeLayoutDemo.java | 69 |
public class TreeLayoutDemo extends JApplet {
/**
* the graph
*/
Forest<String,Integer> graph;
Factory<DirectedGraph<String,Integer>> graphFactory =
new Factory<DirectedGraph<String,Integer>>() {
public DirectedGraph<String, Integer> create() {
return new DirectedSparseMultigraph<String,Integer>();
}
};
Factory<Tree<String,Integer>> treeFactory =
new Factory<Tree<String,Integer>> () {
public Tree<String, Integer> create() {
return new DelegateTree<String,Integer>(graphFactory);
}
};
Factory<Integer> edgeFactory = new Factory<Integer>() {
int i=0;
public Integer create() {
return i++;
}};
Factory<String> vertexFactory = new Factory<String>() {
int i=0;
public String create() {
return "V"+i++;
}};
/**
* the visual component and renderer for the graph
*/
VisualizationViewer<String,Integer> vv;
VisualizationServer.Paintable rings;
String root;
TreeLayout<String,Integer> treeLayout;
RadialTreeLayout<String,Integer> radialLayout;
public TreeLayoutDemo() {
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/ImageEdgeLabelDemo.java | 99 |
| edu/uci/ics/jung/samples/LensVertexImageShaperDemo.java | 231 |
vv.setGraphMouse(graphMouse);
final ScalingControl scaler = new CrossoverScalingControl();
JButton plus = new JButton("+");
plus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv, 1.1f, vv.getCenter());
}
});
JButton minus = new JButton("-");
minus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv, 1/1.1f, vv.getCenter());
}
});
JComboBox modeBox = graphMouse.getModeComboBox();
JPanel modePanel = new JPanel();
modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
modePanel.add(modeBox);
JPanel scaleGrid = new JPanel(new GridLayout(1,0));
scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom"));
JPanel controls = new JPanel();
scaleGrid.add(plus);
scaleGrid.add(minus);
controls.add(scaleGrid);
controls.add(modePanel);
content.add(controls, BorderLayout.SOUTH);
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/BalloonLayoutDemo.java | 75 |
| edu/uci/ics/jung/samples/TreeCollapseDemo.java | 73 |
public class TreeCollapseDemo extends JApplet {
/**
* the graph
*/
Forest<String,Integer> graph;
Factory<DirectedGraph<String,Integer>> graphFactory =
new Factory<DirectedGraph<String,Integer>>() {
public DirectedGraph<String, Integer> create() {
return new DirectedSparseMultigraph<String,Integer>();
}
};
Factory<Tree<String,Integer>> treeFactory =
new Factory<Tree<String,Integer>> () {
public Tree<String, Integer> create() {
return new DelegateTree<String,Integer>(graphFactory);
}
};
Factory<Integer> edgeFactory = new Factory<Integer>() {
int i=0;
public Integer create() {
return i++;
}};
Factory<String> vertexFactory = new Factory<String>() {
int i=0;
public String create() {
return "V"+i++;
}};
/**
* the visual component and renderer for the graph
*/
VisualizationViewer<String,Integer> vv;
VisualizationServer.Paintable rings;
String root;
TreeLayout<String,Integer> layout;
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/BalloonLayoutDemo.java | 75 |
| edu/uci/ics/jung/samples/TreeLayoutDemo.java | 69 |
public class L2RTreeLayoutDemo extends JApplet {
/**
* the graph
*/
Forest<String,Integer> graph;
Factory<DirectedGraph<String,Integer>> graphFactory =
new Factory<DirectedGraph<String,Integer>>() {
public DirectedGraph<String, Integer> create() {
return new DirectedSparseMultigraph<String,Integer>();
}
};
Factory<Tree<String,Integer>> treeFactory =
new Factory<Tree<String,Integer>> () {
public Tree<String, Integer> create() {
return new DelegateTree<String,Integer>(graphFactory);
}
};
Factory<Integer> edgeFactory = new Factory<Integer>() {
int i=0;
public Integer create() {
return i++;
}};
Factory<String> vertexFactory = new Factory<String>() {
int i=0;
public String create() {
return "V"+i++;
}};
/**
* the visual component and renderer for the graph
*/
VisualizationViewer<String,Integer> vv;
VisualizationServer.Paintable rings;
String root;
TreeLayout<String,Integer> treeLayout;
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/VertexCollapseDemo.java | 284 |
| edu/uci/ics/jung/samples/VertexCollapseDemoWithLayouts.java | 315 |
controls.add(jcb);
content.add(controls, BorderLayout.SOUTH);
}
/**
* a demo class that will create a vertex shape that is either a
* polygon or star. The number of sides corresponds to the number
* of vertices that were collapsed into the vertex represented by
* this shape.
*
* @author Tom Nelson
*
* @param <V>
*/
class ClusterVertexShapeFunction<V> extends EllipseVertexShapeTransformer<V> {
ClusterVertexShapeFunction() {
setSizeTransformer(new ClusterVertexSizeFunction<V>(20));
}
@Override
public Shape transform(V v) {
if(v instanceof Graph) {
int size = ((Graph)v).getVertexCount();
if (size < 8) {
int sides = Math.max(size, 3);
return factory.getRegularPolygon(v, sides);
}
else {
return factory.getRegularStar(v, size);
}
}
return super.transform(v);
}
}
/**
* A demo class that will make vertices larger if they represent
* a collapsed collection of original vertices
* @author Tom Nelson
*
* @param <V>
*/
class ClusterVertexSizeFunction<V> implements Transformer<V,Integer> {
int size;
public ClusterVertexSizeFunction(Integer size) {
this.size = size;
}
public Integer transform(V v) {
if(v instanceof Graph) {
return 30;
}
return size;
}
}
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/AddNodeDemo.java | 49 |
| edu/uci/ics/jung/samples/AnimatingAddNodeDemo.java | 55 |
public class AnimatingAddNodeDemo extends javax.swing.JApplet {
/**
*
*/
private static final long serialVersionUID = -5345319851341875800L;
private Graph<Number,Number> g = null;
private VisualizationViewer<Number,Number> vv = null;
private AbstractLayout<Number,Number> layout = null;
Timer timer;
boolean done;
protected JButton switchLayout;
public static final int EDGE_LENGTH = 100;
@Override
public void init() {
//create a graph
Graph<Number,Number> ig = Graphs.<Number,Number>synchronizedDirectedGraph(new DirectedSparseMultigraph<Number,Number>());
ObservableGraph<Number,Number> og = new ObservableGraph<Number,Number>(ig);
og.addGraphEventListener(new GraphEventListener<Number,Number>() {
public void handleGraphEvent(GraphEvent<Number, Number> evt) {
System.err.println("got "+evt);
}});
this.g = og;
//create a graphdraw
layout = new FRLayout<Number,Number>(g);
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/SubLayoutDemo.java | 140 |
| edu/uci/ics/jung/samples/VertexCollapseDemoWithLayouts.java | 161 |
}});
/**
* the regular graph mouse for the normal view
*/
final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse();
vv.setGraphMouse(graphMouse);
Container content = getContentPane();
GraphZoomScrollPane gzsp = new GraphZoomScrollPane(vv);
content.add(gzsp);
JComboBox modeBox = graphMouse.getModeComboBox();
modeBox.addItemListener(graphMouse.getModeListener());
graphMouse.setMode(ModalGraphMouse.Mode.PICKING);
final ScalingControl scaler = new CrossoverScalingControl();
JButton plus = new JButton("+");
plus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv, 1.1f, vv.getCenter());
}
});
JButton minus = new JButton("-");
minus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv, 1/1.1f, vv.getCenter());
}
});
JButton collapse = new JButton("Collapse");
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/ImageEdgeLabelDemo.java | 92 |
| edu/uci/ics/jung/samples/VertexImageShaperDemo.java | 231 |
vv.setVertexToolTipTransformer(new ToStringLabeller<Number>());
Container content = getContentPane();
final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
content.add(panel);
final DefaultModalGraphMouse<Number,Number> graphMouse = new DefaultModalGraphMouse<Number,Number>();
vv.setGraphMouse(graphMouse);
vv.addKeyListener(graphMouse.getModeKeyListener());
final ScalingControl scaler = new CrossoverScalingControl();
JButton plus = new JButton("+");
plus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv, 1.1f, vv.getCenter());
}
});
JButton minus = new JButton("-");
minus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv, 1/1.1f, vv.getCenter());
}
});
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/GraphFromGraphMLDemo.java | 144 |
| edu/uci/ics/jung/samples/GraphZoomScrollPaneDemo.java | 236 |
graph.addEdge(new Double(Math.random()), v[5], v[4], EdgeType.DIRECTED);
}
/**
* A nested class to demo the GraphMouseListener finding the
* right vertices after zoom/pan
*/
static class TestGraphMouseListener<V> implements GraphMouseListener<V> {
public void graphClicked(V v, MouseEvent me) {
System.err.println("Vertex "+v+" was clicked at ("+me.getX()+","+me.getY()+")");
}
public void graphPressed(V v, MouseEvent me) {
System.err.println("Vertex "+v+" was pressed at ("+me.getX()+","+me.getY()+")");
}
public void graphReleased(V v, MouseEvent me) {
System.err.println("Vertex "+v+" was released at ("+me.getX()+","+me.getY()+")");
}
}
/**
* a driver for this demo
*/
public static void main(String[] args)
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/MinimumSpanningTreeDemo.java | 240 |
| edu/uci/ics/jung/samples/TwoModelDemo.java | 145 |
final ScalingControl scaler = new CrossoverScalingControl();
JButton plus = new JButton("+");
plus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv1, 1.1f, vv1.getCenter());
}
});
JButton minus = new JButton("-");
minus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv1, 1/1.1f, vv1.getCenter());
}
});
JPanel zoomPanel = new JPanel(new GridLayout(1,2));
zoomPanel.setBorder(BorderFactory.createTitledBorder("Zoom"));
JPanel modePanel = new JPanel();
modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
gm1.getModeComboBox().addItemListener(gm2.getModeListener());
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/TreeCollapseDemo.java | 338 |
| edu/uci/ics/jung/samples/VertexCollapseDemo.java | 303 |
@Override
public Shape transform(V v) {
if(v instanceof Graph) {
int size = ((Graph)v).getVertexCount();
if (size < 8) {
int sides = Math.max(size, 3);
return factory.getRegularPolygon(v, sides);
}
else {
return factory.getRegularStar(v, size);
}
}
return super.transform(v);
}
}
/**
* A demo class that will make vertices larger if they represent
* a collapsed collection of original vertices
* @author Tom Nelson
*
* @param <V>
*/
class ClusterVertexSizeFunction<V> implements Transformer<V,Integer> {
int size;
public ClusterVertexSizeFunction(Integer size) {
this.size = size;
}
public Integer transform(V v) {
if(v instanceof Graph) {
return 30;
}
return size;
}
}
/**
* a driver for this demo
*/
public static void main(String[] args) {
JFrame f = new JFrame();
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/L2RTreeLayoutDemo.java | 119 |
| edu/uci/ics/jung/samples/TreeLayoutDemo.java | 117 |
public TreeLayoutDemo() {
// create a simple graph for the demo
graph = new DelegateForest<String,Integer>();
createTree();
treeLayout = new TreeLayout<String,Integer>(graph);
radialLayout = new RadialTreeLayout<String,Integer>(graph);
radialLayout.setSize(new Dimension(600,600));
vv = new VisualizationViewer<String,Integer>(treeLayout, new Dimension(600,600));
vv.setBackground(Color.white);
vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line());
vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
// add a listener for ToolTips
vv.setVertexToolTipTransformer(new ToStringLabeller());
vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray));
rings = new Rings();
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/TreeCollapseDemo.java | 338 |
| edu/uci/ics/jung/samples/VertexCollapseDemoWithLayouts.java | 334 |
@Override
public Shape transform(V v) {
if(v instanceof Graph) {
int size = ((Graph)v).getVertexCount();
if (size < 8) {
int sides = Math.max(size, 3);
return factory.getRegularPolygon(v, sides);
}
else {
return factory.getRegularStar(v, size);
}
}
return super.transform(v);
}
}
/**
* A demo class that will make vertices larger if they represent
* a collapsed collection of original vertices
* @author Tom Nelson
*
* @param <V>
*/
class ClusterVertexSizeFunction<V> implements Transformer<V,Integer> {
int size;
public ClusterVertexSizeFunction(Integer size) {
this.size = size;
}
public Integer transform(V v) {
if(v instanceof Graph) {
return 30;
}
return size;
}
}
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/VertexCollapseDemo.java | 267 |
| edu/uci/ics/jung/samples/VertexCollapseDemoWithLayouts.java | 296 |
jcb.setSelectedItem(FRLayout.class);
JPanel controls = new JPanel();
JPanel zoomControls = new JPanel(new GridLayout(2,1));
zoomControls.setBorder(BorderFactory.createTitledBorder("Zoom"));
zoomControls.add(plus);
zoomControls.add(minus);
controls.add(zoomControls);
JPanel collapseControls = new JPanel(new GridLayout(3,1));
collapseControls.setBorder(BorderFactory.createTitledBorder("Picked"));
collapseControls.add(collapse);
collapseControls.add(expand);
collapseControls.add(compressEdges);
collapseControls.add(expandEdges);
collapseControls.add(reset);
controls.add(collapseControls);
controls.add(modeBox);
controls.add(help);
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/L2RTreeLayoutDemo.java | 146 |
| edu/uci/ics/jung/samples/VertexLabelAsShapeDemo.java | 121 |
content.add(gzsp);
JComboBox modeBox = graphMouse.getModeComboBox();
modeBox.addItemListener(graphMouse.getModeListener());
graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);
final ScalingControl scaler = new CrossoverScalingControl();
JButton plus = new JButton("+");
plus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv, 1.1f, vv.getCenter());
}
});
JButton minus = new JButton("-");
minus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv, 1/1.1f, vv.getCenter());
}
});
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/GraphZoomScrollPaneDemo.java | 166 |
| edu/uci/ics/jung/samples/ShowLayouts.java | 178 |
vv.setGraphMouse(graphMouse);
final ScalingControl scaler = new CrossoverScalingControl();
JButton plus = new JButton("+");
plus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv, 1.1f, vv.getCenter());
}
});
JButton minus = new JButton("-");
minus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv, 1/1.1f, vv.getCenter());
}
});
JButton reset = new JButton("reset");
reset.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/AnnotationsDemo.java | 132 |
| edu/uci/ics/jung/samples/ImageEdgeLabelDemo.java | 97 |
final DefaultModalGraphMouse<Number, Number> graphMouse = new DefaultModalGraphMouse<Number, Number>();
vv.setGraphMouse(graphMouse);
vv.addKeyListener(graphMouse.getModeKeyListener());
final ScalingControl scaler = new CrossoverScalingControl();
JButton plus = new JButton("+");
plus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv, 1.1f, vv.getCenter());
}
});
JButton minus = new JButton("-");
minus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv, 1/1.1f, vv.getCenter());
}
});
JComboBox modeBox = graphMouse.getModeComboBox();
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/LensDemo.java | 149 |
| edu/uci/ics/jung/samples/VertexLabelPositionDemo.java | 85 |
Dimension preferredSize = new Dimension(600,600);
final VisualizationModel<String,Number> visualizationModel =
new DefaultVisualizationModel<String,Number>(graphLayout, preferredSize);
vv = new VisualizationViewer<String,Number>(visualizationModel, preferredSize);
PickedState<String> ps = vv.getPickedVertexState();
PickedState<Number> pes = vv.getPickedEdgeState();
vv.getRenderContext().setVertexFillPaintTransformer(new PickableVertexPaintTransformer<String>(ps, Color.red, Color.yellow));
vv.getRenderContext().setEdgeDrawPaintTransformer(new PickableEdgePaintTransformer<Number>(pes, Color.black, Color.cyan));
vv.setBackground(Color.white);
vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.W);
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/BalloonLayoutDemo.java | 86 |
| edu/uci/ics/jung/samples/RadialTreeLensDemo.java | 85 |
return new DirectedSparseGraph<String,Integer>();
}
};
Factory<Tree<String,Integer>> treeFactory =
new Factory<Tree<String,Integer>> () {
public Tree<String, Integer> create() {
return new DelegateTree<String,Integer>(graphFactory);
}
};
Factory<Integer> edgeFactory = new Factory<Integer>() {
int i=0;
public Integer create() {
return i++;
}
};
Factory<String> vertexFactory = new Factory<String>() {
int i=0;
public String create() {
return "V"+i++;
}
};
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/EdgeLabelDemo.java | 311 |
| edu/uci/ics/jung/samples/UnicodeLabelDemo.java | 176 |
}
}
/**
* create some vertices
* @param count how many to create
* @return the Vertices in an array
*/
private Integer[] createVertices(int count) {
Integer[] v = new Integer[count];
for (int i = 0; i < count; i++) {
v[i] = new Integer(i);
graph.addVertex(v[i]);
}
return v;
}
/**
* create edges for this demo graph
* @param v an array of Vertices to connect
*/
void createEdges(Integer[] v) {
graph.addEdge(new Double(Math.random()), v[0], v[1], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[0], v[3], EdgeType.DIRECTED);
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/DrawnIconVertexDemo.java | 152 |
| edu/uci/ics/jung/samples/EdgeLabelDemo.java | 312 |
}
/**
* create some vertices
* @param count how many to create
* @return the Vertices in an array
*/
private Integer[] createVertices(int count) {
Integer[] v = new Integer[count];
for (int i = 0; i < count; i++) {
v[i] = new Integer(i);
graph.addVertex(v[i]);
}
return v;
}
/**
* create edges for this demo graph
* @param v an array of Vertices to connect
*/
void createEdges(Integer[] v) {
graph.addEdge(new Double(Math.random()), v[0], v[1], EdgeType.DIRECTED);
graph.addEdge(new Double(Math.random()), v[0], v[1], EdgeType.DIRECTED);
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/DrawnIconVertexDemo.java | 127 |
| edu/uci/ics/jung/samples/GraphFromGraphMLDemo.java | 121 |
vv.setToolTipText("<html><center>Type 'p' for Pick mode<p>Type 't' for Transform mode");
final ScalingControl scaler = new CrossoverScalingControl();
JButton plus = new JButton("+");
plus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv, 1.1f, vv.getCenter());
}
});
JButton minus = new JButton("-");
minus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv, 1/1.1f, vv.getCenter());
}
});
JPanel controls = new JPanel();
controls.add(plus);
controls.add(minus);
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/ImageEdgeLabelDemo.java | 97 |
| edu/uci/ics/jung/samples/VertexLabelPositionDemo.java | 110 |
final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse();
vv.setGraphMouse(graphMouse);
vv.addKeyListener(graphMouse.getModeKeyListener());
final ScalingControl scaler = new CrossoverScalingControl();
JButton plus = new JButton("+");
plus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv, 1.1f, vv.getCenter());
}
});
JButton minus = new JButton("-");
minus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv, 1/1.1f, vv.getCenter());
}
});
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/GraphFromGraphMLDemo.java | 117 |
| edu/uci/ics/jung/samples/GraphZoomScrollPaneDemo.java | 163 |
vv.setGraphMouse(graphMouse);
vv.addKeyListener(graphMouse.getModeKeyListener());
vv.setToolTipText("<html><center>Type 'p' for Pick mode<p>Type 't' for Transform mode");
final ScalingControl scaler = new CrossoverScalingControl();
JButton plus = new JButton("+");
plus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv, 1.1f, vv.getCenter());
}
});
JButton minus = new JButton("-");
minus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv, 1/1.1f, vv.getCenter());
}
});
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/AnnotationsDemo.java | 132 |
| edu/uci/ics/jung/samples/VertexImageShaperDemo.java | 237 |
final DefaultModalGraphMouse<Number,Number> graphMouse = new DefaultModalGraphMouse<Number,Number>();
vv.setGraphMouse(graphMouse);
vv.addKeyListener(graphMouse.getModeKeyListener());
final ScalingControl scaler = new CrossoverScalingControl();
JButton plus = new JButton("+");
plus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv, 1.1f, vv.getCenter());
}
});
JButton minus = new JButton("-");
minus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv, 1/1.1f, vv.getCenter());
}
});
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/ShowLayouts.java | 214 |
| edu/uci/ics/jung/samples/VertexCollapseDemoWithLayouts.java | 283 |
});
Class[] combos = getCombos();
final JComboBox jcb = new JComboBox(combos);
// use a renderer to shorten the layout name presentation
jcb.setRenderer(new DefaultListCellRenderer() {
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
String valueString = value.toString();
valueString = valueString.substring(valueString.lastIndexOf('.')+1);
return super.getListCellRendererComponent(list, valueString, index, isSelected,
cellHasFocus);
}
});
jcb.addActionListener(new LayoutChooser(jcb, vv));
jcb.setSelectedItem(FRLayout.class);
JPanel controls = new JPanel();
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/RadialTreeLensDemo.java | 257 |
| edu/uci/ics/jung/samples/TreeCollapseDemo.java | 245 |
content.add(controls, BorderLayout.SOUTH);
}
class Rings implements VisualizationServer.Paintable {
Collection<Double> depths;
public Rings() {
depths = getDepths();
}
private Collection<Double> getDepths() {
Set<Double> depths = new HashSet<Double>();
Map<String,PolarPoint> polarLocations = radialLayout.getPolarLocations();
for(String v : graph.getVertices()) {
PolarPoint pp = polarLocations.get(v);
depths.add(pp.getRadius());
}
return depths;
}
public void paint(Graphics g) {
g.setColor(Color.lightGray);
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/GraphZoomScrollPaneDemo.java | 115 |
| edu/uci/ics/jung/samples/VertexImageShaperDemo.java | 212 |
font = new Font(g.getFont().getName(), Font.BOLD, 20);
metrics = g.getFontMetrics(font);
swidth = metrics.stringWidth(str);
sheight = metrics.getMaxAscent()+metrics.getMaxDescent();
x = (d.width-swidth)/2;
y = (int)(d.height-sheight*1.5);
}
g.setFont(font);
Color oldColor = g.getColor();
g.setColor(Color.lightGray);
g.drawString(str, x, y);
g.setColor(oldColor);
}
public boolean useTransform() {
return false;
}
});
// add a listener for ToolTips
vv.setVertexToolTipTransformer(new ToStringLabeller<Number>());
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/ShowLayouts.java | 258 |
| edu/uci/ics/jung/samples/VertexCollapseDemoWithLayouts.java | 418 |
private Class<? extends Layout>[] getCombos()
{
List<Class<? extends Layout>> layouts = new ArrayList<Class<? extends Layout>>();
layouts.add(KKLayout.class);
layouts.add(FRLayout.class);
layouts.add(CircleLayout.class);
layouts.add(SpringLayout.class);
layouts.add(SpringLayout2.class);
layouts.add(ISOMLayout.class);
return layouts.toArray(new Class[0]);
}
/**
* a driver for this demo
*/
public static void main(String[] args) {
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/AnnotationsDemo.java | 134 |
| edu/uci/ics/jung/samples/LensVertexImageShaperDemo.java | 231 |
vv.setGraphMouse(graphMouse);
final ScalingControl scaler = new CrossoverScalingControl();
JButton plus = new JButton("+");
plus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv, 1.1f, vv.getCenter());
}
});
JButton minus = new JButton("-");
minus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv, 1/1.1f, vv.getCenter());
}
});
JComboBox modeBox = graphMouse.getModeComboBox();
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/LensVertexImageShaperDemo.java | 325 |
| edu/uci/ics/jung/samples/VertexImageShaperDemo.java | 340 |
public static class VertexStringerImpl<V,S> implements Transformer<V,String> {
Map<V,String> map = new HashMap<V,String>();
boolean enabled = true;
public VertexStringerImpl(Map<V,String> map) {
this.map = map;
}
/* (non-Javadoc)
* @see edu.uci.ics.jung.graph.decorators.VertexStringer#getLabel(edu.uci.ics.jung.graph.Vertex)
*/
public String transform(V v) {
if(isEnabled()) {
return map.get(v);
} else {
return "";
}
}
/**
* @return Returns the enabled.
*/
public boolean isEnabled() {
return enabled;
}
/**
* @param enabled The enabled to set.
*/
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
}
/**
* create some vertices
* @param count how many to create
* @return the Vertices in an array
*/
private void createGraph(int vertexCount) {
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/LensVertexImageShaperDemo.java | 230 |
| edu/uci/ics/jung/samples/ShowLayouts.java | 177 |
final DefaultModalGraphMouse<Integer,Number> graphMouse = new DefaultModalGraphMouse<Integer,Number>();
vv.setGraphMouse(graphMouse);
final ScalingControl scaler = new CrossoverScalingControl();
JButton plus = new JButton("+");
plus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv, 1.1f, vv.getCenter());
}
});
JButton minus = new JButton("-");
minus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv, 1/1.1f, vv.getCenter());
}
});
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/DrawnIconVertexDemo.java | 127 |
| edu/uci/ics/jung/samples/VertexLabelAsShapeDemo.java | 125 |
graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);
final ScalingControl scaler = new CrossoverScalingControl();
JButton plus = new JButton("+");
plus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv, 1.1f, vv.getCenter());
}
});
JButton minus = new JButton("-");
minus.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(vv, 1/1.1f, vv.getCenter());
}
});
JPanel controls = new JPanel();
| |
| File | Line |
|---|---|
| edu/uci/ics/jung/samples/PluggableRendererDemo.java | 332 |
| edu/uci/ics/jung/samples/ShowLayouts.java | 142 |
Factory<Graph<Integer,Number>> graphFactory =
new Factory<Graph<Integer,Number>>() {
public Graph<Integer,Number> create() {
return new SparseMultigraph<Integer,Number>();
}
};
Factory<Integer> vertexFactory = new Factory<Integer>() {
int count;
public Integer create() {
return count++;
}};
Factory<Number> edgeFactory = new Factory<Number>() {
int count;
public Number create() {
return count++;
}};
| |