Teaching:TUW - UE InfoVis WS 2006/07 - Gruppe 02 - Aufgabe 3 - Prototype: Difference between revisions

From InfoVis:Wiki
Jump to navigation Jump to search
Line 623: Line 623:
21.01.1978 00:00;3.176
21.01.1978 00:00;3.176
</pre>
</pre>
==Links==
* [[Teaching:TUW_-_UE_InfoVis_WS_2006/07_-_Gruppe_02|Gruppe 2]]

Revision as of 19:54, 18 December 2006




our prototype here

architecture

description

images

code

class1

//@author: simon diesenreiter (sd)
//@year: 2006
//@class InfoVisMain: main entry class for the project

import java.util.Date;
import java.text.SimpleDateFormat;
import prefuse.data.parser.DateTimeParser;
import prefuse.data.parser.DateParser;
import prefuse.data.parser.TimeParser;
import prefuse.data.parser.DoubleParser;
import prefuse.data.parser.DataParser;
import prefuse.data.parser.ParserFactory;
import prefuse.data.io.CSVTableReader;
import prefuse.data.io.TableReadListener;
import prefuse.data.Table;
import prefuse.data.io.DataIOException;
import prefuse.data.io.DelimitedTextTableReader;
import prefuse.data.Schema;

import prefuse.Visualization;

import prefuse.render.DefaultRendererFactory;

import prefuse.render.ShapeRenderer;

import java.io.FileInputStream;
import java.io.File;
import java.io.FileNotFoundException;

import java.util.Calendar;

//imports for step4: actions
import prefuse.action.layout.AxisLayout;
import prefuse.Constants;
import prefuse.visual.expression.VisiblePredicate;
import prefuse.action.assignment.ColorAction;
import prefuse.visual.VisualItem;
import prefuse.util.ColorLib;
import prefuse.action.assignment.DataShapeAction;
import prefuse.action.ActionList;
import prefuse.action.RepaintAction;
import prefuse.action.assignment.DataColorAction;
import java.awt.Color;
import prefuse.action.layout.AxisLabelLayout;

//imports for step5: display
import prefuse.Display;
import prefuse.controls.ZoomControl;
import prefuse.controls.PanControl;
import javax.swing.BorderFactory;
import prefuse.controls.ToolTipControl;

//imports for step6: launching the Application
import javax.swing.JFrame;

public class InfoVisMain {
	
	private static final String group = "data";
	private static final int tilesize = 10; //tilesize in pixel
	private static final int binsize = 5; //number of bins for color-coding
	private static boolean logFlag = false; // a flag for setting linear or logarithmic scale
	
	
	
	public static void main(String[] args){
		//-------basic output----------
		System.out.println("InfoVisMain.main(): started \n");	
		
		//1: read the data from a file*******************************************************************
		/*
		 * example file-entry: 
		 * column1: 01.01.1977  11:00:00 
		 * column2: 5,721
		 */
		
		//set up the Parser:
		
		SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
		SimpleDateFormat df = new SimpleDateFormat("dd.MM.yyyy");
		SimpleDateFormat tf = new SimpleDateFormat("HH:mm:ss");	
		
		DateTimeParser dateTimeParser = new DateTimeParser();
		DateParser dateParser = new DateParser(df);
		TimeParser timeParser = new TimeParser(tf);
		DoubleParser doubleParser = new DoubleParser();
		
		DataParser[] dP1 = new DataParser[]{dateParser, timeParser, doubleParser};
		ParserFactory pF1 = new ParserFactory(dP1);
		
		DataParser[] dP2 = new DataParser[]{dateTimeParser, doubleParser};
		ParserFactory pF2 = new ParserFactory(dP2);

		File file = new File("D:\\infovis_eclipse_workspace\\resources\\abfluss_mittersill_csv_1jahr.csv");
		
		DelimitedTextTableReader reader = new DelimitedTextTableReader("[;]", pF2);
		
		Table table = new Table();

		try{
//			System.out.println("InfoVisMain.main()1: reading file: " + file.getName());
			table = reader.readTable(file);
//			System.out.println("InfoVisMain.main()2: reading file: " + file.getName());
		}
		catch(DataIOException ex){
			System.out.println("InfoVisMain.main(): error reading the file: " + ex.getMessage());
		}
		
		table.addColumn("Tag", int.class);
		table.addColumn("Woche", int.class);
		table.addColumn("Jahr", int.class);
		
		//output: tableproperties (size, etc..)
		System.out.println("Table_properties: " + table.toString());
		
//		//output: table after reading from file
//		System.out.println("table after reading from file");
//		for(int i=0; i<table.getRowCount(); i++){
//			for (int j=0; j<table.getColumnCount(); j++){
//				System.out.print(table.get(i, j).toString() + "\t");
//			}
//			System.out.print("\n");
//		}

			for (int i=0; i<table.getRowCount(); i++){
				if(table.canGetDate(table.getColumnName(0))){
					Date tmpDate = table.getDate(i, 0);
					Calendar myCalendar = Calendar.getInstance();
					myCalendar.setTime(tmpDate);
//					System.out.println("Wochentag: " + myCalendar.get(Calendar.DAY_OF_WEEK));
//					System.out.println("Woche: " + myCalendar.get(Calendar.WEEK_OF_YEAR));
					table.setInt(i, "Tag", myCalendar.get(Calendar.DAY_OF_WEEK));
					table.setInt(i, "Woche", myCalendar.get(Calendar.WEEK_OF_YEAR));
					table.setInt(i, "Jahr", myCalendar.get(Calendar.YEAR));
					
				}
			}
			
			//output: table after adding extracolumns for weekday and week
			System.out.println("table after adding extracolumns for weekday, week and year");
			for(int i=0; i<table.getRowCount(); i++){
				for (int j=0; j<table.getColumnCount(); j++){
					System.out.print(table.get(i, j).toString() + "\t");
				}
				System.out.print("\n");
			}
	
		
		//2: create a Visualisation... *********************************************************************
		Visualization vis = new Visualization();
		vis.add(group, table);
		
//		 -- 3. the renderers and renderer factory ---------------------------
		ShapeRenderer myShapeR = new ShapeRenderer(tilesize);//create a default shapeRenderer with size tilesize
        DefaultRendererFactory rf = new DefaultRendererFactory(myShapeR);
        vis.setRendererFactory(rf);
        
        
        // -- 4. the processing actions --------------------------------------

        AxisLayout x_axis = new AxisLayout(group, "Woche", Constants.X_AXIS, VisiblePredicate.TRUE);
        vis.putAction("x", x_axis);
        
        AxisLayout y_axis = new AxisLayout(group, "Tag", Constants.Y_AXIS, VisiblePredicate.TRUE);
        vis.putAction("y", y_axis);
       
//        @todo: dayLabels funkt noch nicht
//        AxisLabelLayout dayLabels = new AxisLabelLayout("Tag", y_axis);
//        vis.putAction("dayLabel", dayLabels);
        
        int[] palette = ColorLib.getInterpolatedPalette(binsize, 
        					ColorLib.color(Color.BLUE), ColorLib.color(Color.RED));
        
        DataColorAction dataColor = new DataColorAction(group, "Abfluss", Constants.NUMERICAL, 
        					VisualItem.FILLCOLOR, palette);
        if(logFlag)dataColor.setScale(Constants.LOG_SCALE);
        vis.putAction("dataColor", dataColor);
        
        ActionList draw = new ActionList();
        draw.add(x_axis);
        draw.add(y_axis);
//        draw.add(dayLabels);
        draw.add(dataColor);
        draw.add(new RepaintAction());
        vis.putAction("draw", draw);
        
//      -- 5. the display and interactive controls -------------------------
        
        Display d = new Display(vis);
        d.setBorder(BorderFactory.createEmptyBorder(20,20,20,20));
        d.setSize(tilesize*53, tilesize*7); //size = (tilesize*weeks+offset, tilesize*days+offset) 
        d.setHighQuality(true);
        ToolTipControl ttc = new ToolTipControl(new String[] {"Datum", "Abfluss"});
        d.addControlListener(ttc);
        d.addControlListener(new ZoomControl());
        
// -- 6. launch the visualization -------------------------------------
        
        // create a new window to hold the visualization
        JFrame frame = new JFrame("T I L E M A P");
        // ensure application exits when window is closed
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.add(d);
        frame.pack();           // layout components in window
        frame.setVisible(true); // show the window
        vis.run("draw");

	}

}

class2

class3

example data

example data for class1 (InfoVisMain.java)

Copy that data and store it as .csv. For using it you have to change the path to the file in the sourcecode.

Datum;Abfluss
01.01.1977 11:00;5.721
02.01.1977 10:30;5.697
03.01.1977 10:00;5.767
04.01.1977 17:00;5.861
05.01.1977 16:30;5.697
06.01.1977 11:30;5.791
07.01.1977 18:30;5.697
08.01.1977 12:30;5.908
09.01.1977 12:00;5.861
10.01.1977 12:00;5.861
11.01.1977 18:00;5.837
12.01.1977 11:30;6.026
13.01.1977 19:30;5.955
14.01.1977 11:00;5.978
15.01.1977 20:30;5.837
16.01.1977 12:00;6.895
17.01.1977 11:30;6.073
18.01.1977 12:30;5.767
19.01.1977 19:30;6.263
20.01.1977 19:00;5.884
21.01.1977 09:00;6.359
22.01.1977 11:30;6.699
23.01.1977 14:30;5.837
24.01.1977 11:30;5.628
25.01.1977 19:30;5.791
26.01.1977 11:30;5.744
27.01.1977 09:30;5.651
28.01.1977 19:30;5.651
29.01.1977 20:00;6.192
30.01.1977 11:30;5.536
31.01.1977 20:30;5.767
01.02.1977 19:30;5.651
02.02.1977 11:30;6.073
03.02.1977 10:30;6.002
04.02.1977 09:30;6.994
05.02.1977 20:00;6.723
06.02.1977 11:30;7.168
07.02.1977 20:30;6.528
08.02.1977 18:00;6.192
09.02.1977 11:30;7.776
10.02.1977 19:30;7.118
11.02.1977 19:30;7.827
12.02.1977 09:30;7.47
13.02.1977 09:30;7.168
14.02.1977 20:00;6.383
15.02.1977 20:00;6.12
16.02.1977 20:00;6.263
17.02.1977 20:00;6.168
18.02.1977 20:00;5.861
19.02.1977 19:30;5.978
20.02.1977 19:30;6.383
21.02.1977 19:30;9.524
22.02.1977 12:30;7.956
23.02.1977 20:00;7.648
24.02.1977 23:59;8.257
25.02.1977 15:30;10.271
26.02.1977 00:00;9.21
27.02.1977 05:00;8.241
28.02.1977 00:00;6.26
01.03.1977 18:00;5.931
02.03.1977 19:30;5.791
03.03.1977 23:59;8.14
04.03.1977 23:59;17.646
05.03.1977 00:00;17.646
06.03.1977 00:00;11.894
07.03.1977 00:00;10.665
08.03.1977 21:00;10.327
09.03.1977 23:00;10.665
10.03.1977 23:59;10.892
11.03.1977 18:30;11.121
12.03.1977 13:00;10.58
13.03.1977 00:00;10.051
14.03.1977 00:00;9.343
15.03.1977 00:00;8.834
16.03.1977 23:59;8.537
17.03.1977 23:59;10.103
18.03.1977 21:30;12.287
19.03.1977 00:00;12.261
20.03.1977 00:00;10.515
21.03.1977 08:00;10.075
22.03.1977 20:30;10.215
23.03.1977 23:30;11.875
24.03.1977 23:59;13.962
25.03.1977 22:00;14.509
26.03.1977 22:30;15.615
27.03.1977 00:00;15.415
28.03.1977 07:00;18.082
29.03.1977 00:00;16.046
30.03.1977 00:00;13.017
31.03.1977 00:00;10.835
01.04.1977 19:00;10.355
02.04.1977 23:59;12.18
03.04.1977 23:59;13.403
04.04.1977 00:30;13.46
05.04.1977 08:30;12.495
06.04.1977 18:00;12.199
07.04.1977 19:00;11.525
08.04.1977 08:30;11.904
09.04.1977 18:00;11.322
10.04.1977 17:30;10.355
11.04.1977 17:30;10.131
12.04.1977 12:00;9.551
13.04.1977 19:30;10.636
14.04.1977 19:30;11.265
15.04.1977 08:30;10.187
16.04.1977 19:30;8.795
17.04.1977 18:30;10.75
18.04.1977 20:30;12.199
19.04.1977 20:00;12.764
20.04.1977 17:30;11.729
21.04.1977 19:00;12.555
22.04.1977 19:00;13.095
23.04.1977 23:59;16.529
24.04.1977 23:59;20.195
25.04.1977 00:30;20.203
26.04.1977 23:30;23.096
27.04.1977 23:00;28.672
28.04.1977 23:59;36.956
29.04.1977 23:59;56.898
30.04.1977 18:00;81.98
01.05.1977 19:30;77.065
02.05.1977 00:00;70.391
03.05.1977 00:00;51.984
04.05.1977 18:00;93.83
05.05.1977 00:00;86.578
06.05.1977 00:00;57.75
07.05.1977 00:00;37.338
08.05.1977 00:00;29.828
09.05.1977 00:00;28.286
10.05.1977 00:00;22.335
11.05.1977 23:59;23.215
12.05.1977 23:00;42.651
13.05.1977 00:00;41.681
14.05.1977 00:00;37.893
15.05.1977 00:00;30.726
16.05.1977 23:00;29.321
17.05.1977 21:30;32.223
18.05.1977 23:59;33.122
19.05.1977 23:59;99.935
20.05.1977 15:30;137.65
21.05.1977 00:00;110.665
22.05.1977 00:00;75.919
23.05.1977 22:00;59.25
24.05.1977 22:30;63.573
25.05.1977 21:00;76.096
26.05.1977 00:00;73.753
27.05.1977 00:00;67.312
28.05.1977 00:00;53.171
29.05.1977 23:59;52.495
30.05.1977 00:30;52.754
31.05.1977 02:00;50.759
01.06.1977 00:00;38.131
02.06.1977 23:59;36.169
03.06.1977 00:30;36.316
04.06.1977 00:00;30.803
05.06.1977 00:00;26.294
06.06.1977 23:59;29.861
07.06.1977 23:00;51.207
08.06.1977 22:00;63.087
09.06.1977 23:30;82.823
10.06.1977 22:00;109.493
11.06.1977 00:00;104.427
12.06.1977 00:00;90.078
13.06.1977 22:00;103.169
14.06.1977 23:59;120.391
15.06.1977 02:00;125.505
16.06.1977 10:00;85.915
17.06.1977 00:00;58.973
18.06.1977 23:59;74.687
19.06.1977 23:59;86.142
20.06.1977 01:30;86.383
21.06.1977 23:59;73.066
22.06.1977 01:00;73.583
23.06.1977 00:00;62.195
24.06.1977 20:00;54.91
25.06.1977 19:30;75.354
26.06.1977 23:59;94.717
27.06.1977 01:30;94.959
28.06.1977 00:00;64.193
29.06.1977 00:00;51.4
30.06.1977 11:30;62.741
01.07.1977 00:00;49.039
02.07.1977 23:59;48.14
03.07.1977 23:59;65.391
04.07.1977 23:59;72.606
05.07.1977 01:00;72.777
06.07.1977 01:30;62.05
07.07.1977 03:00;55.174
08.07.1977 23:59;54.91
09.07.1977 02:30;55.042
10.07.1977 15:00;65.953
11.07.1977 02:00;61.844
12.07.1977 01:00;55.57
13.07.1977 23:59;100.575
14.07.1977 01:00;115.434
15.07.1977 11:00;93.509
16.07.1977 23:59;70.042
17.07.1977 06:30;101.755
18.07.1977 00:00;65.251
19.07.1977 00:30;60.133
20.07.1977 23:59;73.238
21.07.1977 07:00;207.793
22.07.1977 00:00;76.599
23.07.1977 00:00;44.949
24.07.1977 22:00;47.228
25.07.1977 23:59;66.47
26.07.1977 04:30;85.993
27.07.1977 00:00;56.811
28.07.1977 00:00;40.869
29.07.1977 20:00;34.316
30.07.1977 23:59;40.194
31.07.1977 23:30;253.056
01.08.1977 05:30;271.508
02.08.1977 00:00;119.963
03.08.1977 00:00;54.623
04.08.1977 00:00;39.101
05.08.1977 20:30;82.898
06.08.1977 00:00;71.46
07.08.1977 06:00;68.654
08.08.1977 00:00;53.663
09.08.1977 00:00;49.738
10.08.1977 11:00;59.712
11.08.1977 00:00;46.09
12.08.1977 00:00;33.279
13.08.1977 23:59;38.364
14.08.1977 07:00;54.828
15.08.1977 00:00;34.25
16.08.1977 00:00;27.856
17.08.1977 23:59;35.97
18.08.1977 23:59;39.485
19.08.1977 10:30;45.281
20.08.1977 00:00;42.13
21.08.1977 23:59;41.287
22.08.1977 07:00;64.402
23.08.1977 00:00;43.641
24.08.1977 00:00;32.957
25.08.1977 00:00;27.529
26.08.1977 07:30;26.534
27.08.1977 00:00;25.876
28.08.1977 23:59;30.351
29.08.1977 23:59;42.718
30.08.1977 18:30;47.544
31.08.1977 00:00;47.182
01.09.1977 00:00;40.953
02.09.1977 00:00;31.879
03.09.1977 00:00;31.226
04.09.1977 23:00;47.976
05.09.1977 00:00;46.886
06.09.1977 00:00;30.996
07.09.1977 00:00;21.428
08.09.1977 23:59;25.908
09.09.1977 10:00;104.255
10.09.1977 00:00;44.71
11.09.1977 00:00;26.393
12.09.1977 07:00;25.501
13.09.1977 22:00;24.5
14.09.1977 00:00;24.053
15.09.1977 23:59;21.439
16.09.1977 00:00;21.439
17.09.1977 00:00;17.751
18.09.1977 20:30;16.759
19.09.1977 00:00;16.545
20.09.1977 00:00;16.018
21.09.1977 00:00;14.903
22.09.1977 00:00;14.601
23.09.1977 00:00;14.145
24.09.1977 22:30;14.043
25.09.1977 00:00;14.014
26.09.1977 00:00;13.582
27.09.1977 00:00;12.734
28.09.1977 00:00;12.527
29.09.1977 00:00;11.77
30.09.1977 21:00;11.496
01.10.1977 23:59;11.468
02.10.1977 23:59;12.19
03.10.1977 08:00;12.376
04.10.1977 00:00;12.092
05.10.1977 00:00;11.196
06.10.1977 23:59;10.693
07.10.1977 23:59;10.782
08.10.1977 23:59;13.122
09.10.1977 04:00;13.796
10.10.1977 23:59;13.217
11.10.1977 02:30;14.509
12.10.1977 00:00;12.641
13.10.1977 00:00;12.146
14.10.1977 23:59;11.612
15.10.1977 00:00;11.612
16.10.1977 00:00;10.018
17.10.1977 07:30;9.798
18.10.1977 00:00;9.615
19.10.1977 15:00;9.333
20.10.1977 00:00;9.067
21.10.1977 00:00;8.838
22.10.1977 00:00;8.531
23.10.1977 23:59;8.48
24.10.1977 23:59;8.937
25.10.1977 19:30;9.333
26.10.1977 00:00;9.238
27.10.1977 00:00;8.792
28.10.1977 09:00;9.524
29.10.1977 00:00;9.22
30.10.1977 00:00;8.862
31.10.1977 23:59;8.933
01.11.1977 06:30;9.198
02.11.1977 23:59;10.241
03.11.1977 05:30;11.758
04.11.1977 00:00;10.872
05.11.1977 00:00;8.886
06.11.1977 00:00;8.583
07.11.1977 00:00;8.075
08.11.1977 00:00;7.574
09.11.1977 21:00;6.945
10.11.1977 00:00;6.851
11.11.1977 00:00;6.527
12.11.1977 00:00;6.356
13.11.1977 18:00;7.044
14.11.1977 00:00;6.651
15.11.1977 10:30;6.48
16.11.1977 00:00;6.401
17.11.1977 00:00;6.311
18.11.1977 18:00;6.12
19.11.1977 00:00;6.026
20.11.1977 00:00;4.894
21.11.1977 23:59;4.754
22.11.1977 23:30;4.992
23.11.1977 00:00;4.989
24.11.1977 23:59;5.015
25.11.1977 23:59;5.767
26.11.1977 16:30;5.861
27.11.1977 00:00;5.843
28.11.1977 23:59;6.008
29.11.1977 01:00;6.026
30.11.1977 08:30;5.978
01.12.1977 08:30;5.978
02.12.1977 17:00;5.837
03.12.1977 00:00;5.397
04.12.1977 07:00;5.284
05.12.1977 23:59;5.444
06.12.1977 16:00;5.536
07.12.1977 00:00;4.849
08.12.1977 00:00;4.812
09.12.1977 20:30;5.744
10.12.1977 00:00;5.661
11.12.1977 00:00;5.318
12.12.1977 23:59;5.408
13.12.1977 11:00;6.504
14.12.1977 00:00;6.119
15.12.1977 20:00;5.861
16.12.1977 11:30;5.582
17.12.1977 16:00;5.559
18.12.1977 00:00;5.434
19.12.1977 13:30;5.536
20.12.1977 15:00;5.353
21.12.1977 13:00;5.721
22.12.1977 15:30;5.791
23.12.1977 00:00;5.692
24.12.1977 00:00;5.308
25.12.1977 23:59;5.914
26.12.1977 18:30;6.026
27.12.1977 00:00;5.696
28.12.1977 18:00;5.744
29.12.1977 00:00;5.537
30.12.1977 18:00;5.536
31.12.1977 00:00;4.925
01.01.1978 00:00;4.76
02.01.1978 23:59;4.545
03.01.1978 01:30;4.596
04.01.1978 18:30;4.381
05.01.1978 18:00;4.232
06.01.1978 00:00;3.96
07.01.1978 23:59;3.96
08.01.1978 23:59;3.96
09.01.1978 23:59;3.96
10.01.1978 23:59;3.96
11.01.1978 23:59;3.96
12.01.1978 23:59;3.96
13.01.1978 23:59;3.96
14.01.1978 15:30;4.106
15.01.1978 00:00;3.878
16.01.1978 11:30;4.127
17.01.1978 00:00;4.043
18.01.1978 00:00;3.585
19.01.1978 23:59;3.545
20.01.1978 06:30;3.553
21.01.1978 00:00;3.176


Links