Commit 4cc311b8 authored by stram's avatar stram
Browse files

updating edge width

git-svn-id: https://dynaq.opendfki.de/repos/application/trunk@1052 8b50620d-ddf8-0310-9f5d-8b2f31fd9ac4
parent 6ca967f5
......@@ -44,6 +44,7 @@ import prefuse.Visualization;
import prefuse.action.ActionList;
import prefuse.action.RepaintAction;
import prefuse.action.assignment.ColorAction;
import prefuse.action.assignment.DataSizeAction;
import prefuse.action.assignment.SizeAction;
import prefuse.action.filter.VisibilityFilter;
import prefuse.activity.Activity;
......@@ -80,6 +81,8 @@ public class DynaQDocumentGraph extends JPanel implements ActionListener, Compon
JSlider slider;
JButton graph_button = null;
JButton save_button = null;
int initialEdgeWidth = 5;
int sliderActionCounter = 0;
private Rectangle2D rectangle;
private String baseTitle;
......@@ -270,9 +273,15 @@ public class DynaQDocumentGraph extends JPanel implements ActionListener, Compon
Node nextSource = next.getSourceNode();
Node nextTarget = next.getTargetNode();
Date nextDate = next.getDate(DATE);
if(((source==nextSource && target==nextTarget) || (source==nextTarget && target==nextSource))
&& (nextDate.before(date)) || nextDate.equals(date)){
return next;
if((source==nextSource && target==nextTarget) || (source==nextTarget && target==nextSource)){
if(nextDate.before(date)){
return next;
}
if(nextDate.equals(date)){
return next;
}
// && ((nextDate.before(date)) || nextDate.equals(date))){
}
}
return edge;
......@@ -282,25 +291,26 @@ public class DynaQDocumentGraph extends JPanel implements ActionListener, Compon
* updates the counter of one edge to the number of edges between two nodes for a given date or before
* all other edge counters are initialized to 0
*/
private void updateEdgeCounter(Graph graph, Date date){
//initializing the edge count
@SuppressWarnings("rawtypes")
Iterator edges = graph.edges();
while(edges.hasNext()){
Edge edge = (Edge) edges.next();
edge.setInt(EDGE_COUNT, 0);
}
//updating edge count for date
edges = graph.edges();
while(edges.hasNext()){
Edge edge = (Edge) edges.next();
Date edgeDate = edge.getDate(DATE);
if(edgeDate.before(date) || edgeDate.equals(date)){
Edge toUpdate = getSimilarEdge(graph,edge,date);
int count = toUpdate.getInt(EDGE_COUNT) + 3;
toUpdate.setInt(EDGE_COUNT, count);
private void updateEdgeCounter(Graph graph, int currentDate, DateSlider dslider){
//initializing the edge count
@SuppressWarnings("rawtypes")
Iterator edges = graph.edges();
while(edges.hasNext()){
Edge edge = (Edge) edges.next();
edge.setInt(EDGE_COUNT, initialEdgeWidth);
}
//updating edge count for date
edges = graph.edges();
while(edges.hasNext()){
Edge edge = (Edge) edges.next();
Date edgeDate = edge.getDate(DATE);
int thisDate = dslider.getInt(edgeDate);
if(thisDate<=currentDate){
Edge toUpdate = getSimilarEdge(graph,edge,dslider.getDate(currentDate));
int count = toUpdate.getInt(EDGE_COUNT) + 10;
toUpdate.setInt(EDGE_COUNT, count);
}
}
}
}
//finds the lowest and the highest values in the edge date property
......@@ -347,6 +357,21 @@ public class DynaQDocumentGraph extends JPanel implements ActionListener, Compon
}
}
private void setVisibleEdges(Graph graph, Visualization vis){
Iterator edges = graph.edges();
while(edges.hasNext()){
Edge edge = (Edge) edges.next();
// int edgeDate = (int) edge.get(UnderlyingGraph.NUM_DATE_EDGES);
VisualItem visualEdge = vis.getVisualItem("graph.edges", edge);
int edge_count = edge.getInt(EDGE_COUNT);
if(edge_count>initialEdgeWidth){
visualEdge.setVisible(true);
} else {
visualEdge.setVisible(false);
}
}
}
private Visualization getGraphVisualization(Graph graph){
Visualization vis = new Visualization();
vis.add("graph", graph);
......@@ -393,7 +418,7 @@ public class DynaQDocumentGraph extends JPanel implements ActionListener, Compon
// add the actions to the visualization
vis.putAction(COLOR, color);
vis.putAction(LAYOUT, layout);
vis.putAction(SIZE, size);
// vis.putAction(SIZE, size);
return vis;
}
......@@ -472,9 +497,7 @@ public class DynaQDocumentGraph extends JPanel implements ActionListener, Compon
display = getGraphDisplay(graph_visualization);
//eliminating multiple edges
Date[] lohiDates = getLowestHighestDate(graph.getNodes());
updateEdgeCounter(graph, lohiDates[1]);
//create dynamic visualization
AndPredicate dateFilter = new AndPredicate();
......@@ -499,14 +522,18 @@ public class DynaQDocumentGraph extends JPanel implements ActionListener, Compon
dateFilter.addExpressionListener(lstnr);
ActionList update = new ActionList();
update.add(new VisibilityFilter("graph.edges", dateFilter));
// update.add(new DataSizeAction("graph.edges", EDGE_COUNT));
update.add(new DataSizeAction("graph.edges", EDGE_COUNT));
graph_visualization.putAction(UPDATE, update);
//getting the slider
Date[] lohiDates = getLowestHighestDate(graph.getNodes());
final DateSlider dslider = new DateSlider(lohiDates);
graph = UnderlyingGraph.updateGraphDate(graph, dslider); //updating the date counter in the graph
slider = dslider.getSlider();
//eliminating multiple edges
updateEdgeCounter(graph, dslider.getInt(lohiDates[1]),dslider);
//adding a change listener to the slider that changes the visible nodes and edge width
slider.addChangeListener(new ChangeListener(){
public void stateChanged(ChangeEvent e){
......@@ -517,7 +544,8 @@ public class DynaQDocumentGraph extends JPanel implements ActionListener, Compon
if(edgeQ_date!=null){
NumberRangeModel edge_nrm_date = edgeQ_date.getNumberModel();
edge_nrm_date.setValueRange(source.getMinimum(), date, source.getMinimum(), date);
updateEdgeCounter(graph, dslider.getDate(date));
updateEdgeCounter(graph, date, dslider);
// setVisibleEdges(graph,graph_visualization);
}
if (!source.getValueIsAdjusting()) {
......@@ -546,7 +574,7 @@ public class DynaQDocumentGraph extends JPanel implements ActionListener, Compon
graph_visualization.run(COLOR);
graph_visualization.run(LAYOUT);
graph_visualization.run(SIZE);
// graph_visualization.run(SIZE);
graph_visualization.run(UPDATE);
this.revalidate();
......
......@@ -23,8 +23,8 @@ public class UnderlyingGraph {
private static final String CREATOR = "dc:creator";
static final String DATE = "date";
static final String NUM_DATE_EDGES = "num_date_edges";
static final String NUM_DATE_NODES = "num_date_nodes";
static final String NUM_DATE_EDGES = "num_date_edges"; //an int value of an edge for a node according to the DateSlider
static final String NUM_DATE_NODES = "num_date_nodes"; //an int value of a node for a node according to the DateSlider
static final String NAME = "name";
static final String DEGREE = "degree";
static final String EDGE_COUNT = "edge_count";
......
Supports Markdown
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