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

From InfoVis:Wiki
Jump to navigation Jump to search
 
(16 intermediate revisions by 3 users not shown)
Line 2: Line 2:




=Project TileMap=


==Authors==
[[Teaching:TUW - UE InfoVis WS 2006/07 - Gruppe 02|Gruppe 02 (Diesenreiter, Weixelbaumer, Felkel, Maier)]]


==Task Description==
Our task was to implement an application for visualizing time-dependent data, using the so called tilemap technique. For detailed information on this fascinating technique, you should visit our [[Teaching:TUW_-_UE_InfoVis_WS_2006/07_-_Gruppe_02_-_Aufgabe_3_-_Technique|Tilemap]] description. We were allowed to make use of the powerful java toolkit prefuse, which provides many of the needed functionalities.


=our prototype here=
==Implementation Details==
Our final prototype parses given input data (provided in .csv files), writes it into table structures and calculates useful information like the adequate week for each entry. Therefor additional columns get appended and are use for our labeling. The visual mapping was realized by dependence of the color of each tile on the given values. Finally we defined basic interaction like zooming and created a simple user interface to control scaling and bucket size of our visualization. Now the result is ready to be printed on screen.


==architecture==
==Screenshot==
[[Image:screen.jpg]]


===description===
==Used Toolkits==
===images===
* Prefuse Information Visualization Toolkit


==code==
==Links==
===class1===
* [[Teaching:TUW_-_UE_InfoVis_WS_2006/07_-_Gruppe_02|Gruppe 2]]
<pre>
* [[Teaching:TUW_-_UE_InfoVis_WS_2006/07_-_Gruppe_02_-_Aufgabe_3_-_Technique|Technique]]
//@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");
 
}
 
}
</pre>
 
===class2===
===class3===

Latest revision as of 02:00, 5 January 2007


Project TileMap[edit]

Authors[edit]

Gruppe 02 (Diesenreiter, Weixelbaumer, Felkel, Maier)

Task Description[edit]

Our task was to implement an application for visualizing time-dependent data, using the so called tilemap technique. For detailed information on this fascinating technique, you should visit our Tilemap description. We were allowed to make use of the powerful java toolkit prefuse, which provides many of the needed functionalities.

Implementation Details[edit]

Our final prototype parses given input data (provided in .csv files), writes it into table structures and calculates useful information like the adequate week for each entry. Therefor additional columns get appended and are use for our labeling. The visual mapping was realized by dependence of the color of each tile on the given values. Finally we defined basic interaction like zooming and created a simple user interface to control scaling and bucket size of our visualization. Now the result is ready to be printed on screen.

Screenshot[edit]

Used Toolkits[edit]

  • Prefuse Information Visualization Toolkit

Links[edit]