Started to render column groups. Added a sample data set with CVTs.

git-svn-id: http://google-refine.googlecode.com/svn/trunk@42 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
David Huynh 2010-02-05 01:27:14 +00:00
parent f8e15798e2
commit 93f0dfd63a
4 changed files with 331 additions and 29 deletions

View File

@ -15,15 +15,17 @@ import com.metaweb.gridworks.Jsonizable;
public class ColumnGroup implements Serializable, Jsonizable {
private static final long serialVersionUID = 2161780779920066118L;
final public int[] cellIndices; // must be in order from smallest to largest
final public int keyCellIndex; // could be -1 if there is no key cell
final public int startColumnIndex;
final public int columnSpan;
final public int keyColumnIndex; // could be -1 if there is no key cell
transient public ColumnGroup parentGroup;
transient public List<ColumnGroup> subgroups;
public ColumnGroup(int[] cellIndices, int keyCellIndex) {
this.cellIndices = cellIndices;
this.keyCellIndex = keyCellIndex;
public ColumnGroup(int startColumnIndex, int columnSpan, int keyColumnIndex) {
this.startColumnIndex = startColumnIndex;
this.columnSpan = columnSpan;
this.keyColumnIndex = keyColumnIndex;
internalInitialize();
}
@ -33,11 +35,9 @@ public class ColumnGroup implements Serializable, Jsonizable {
writer.object();
writer.key("cellIndices"); writer.array();
for (int i : cellIndices) {
writer.value(i);
}
writer.endArray();
writer.key("startColumnIndex"); writer.value(startColumnIndex);
writer.key("columnSpan"); writer.value(columnSpan);
writer.key("keyColumnIndex"); writer.value(keyColumnIndex);
if (subgroups != null && subgroups.size() > 0) {
writer.key("subgroups"); writer.array();
@ -51,19 +51,8 @@ public class ColumnGroup implements Serializable, Jsonizable {
}
public boolean contains(ColumnGroup g) {
for (int c : g.cellIndices) {
boolean has = false;
for (int d : cellIndices) {
if (c == d) {
has = true;
break;
}
}
if (!has) {
return false;
}
}
return true;
return (g.startColumnIndex >= startColumnIndex &&
g.startColumnIndex < startColumnIndex + columnSpan);
}
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {

View File

@ -104,10 +104,10 @@ public class ColumnModel implements Serializable, Jsonizable {
Collections.sort(_rootColumnGroups, new Comparator<ColumnGroup>() {
@Override
public int compare(ColumnGroup o1, ColumnGroup o2) {
int firstDiff = o1.cellIndices[0] - o2.cellIndices[0];
int firstDiff = o1.startColumnIndex - o2.startColumnIndex;
return firstDiff != 0 ?
firstDiff : // whichever group that starts first goes first
(o2.cellIndices.length - o1.cellIndices.length); // otherwise, the larger group goes first
(o2.columnSpan - o1.columnSpan); // otherwise, the larger group goes first
}
});

View File

@ -75,8 +75,9 @@ DataTableView.prototype.render = function() {
renderPageSize(i);
}
/*
* Data table
/*============================================================
* Data Table
*============================================================
*/
var tableDiv = $('<div></div>').addClass("data-table-container").css("width", container.width() + "px").appendTo(container);
@ -84,7 +85,82 @@ DataTableView.prototype.render = function() {
table.className = "data-table";
tableDiv.append(table);
var trHead = table.insertRow(0);
var columns = theProject.columnModel.columns;
var columnGroups = theProject.columnModel.columnGroups;
/*------------------------------------------------------------
* Column Group Headers
*------------------------------------------------------------
*/
var renderColumnKeys = function(keys) {
if (keys.length > 0) {
var tr = table.insertRow(table.rows.length);
tr.insertCell(0); // row index
for (var c = 0; c < columns.length; c++) {
var td = tr.insertCell(tr.cells.length);
for (var k = 0; k < keys.length; k++) {
if (c == keys[k]) {
$('<img />').attr("src", "images/down-arrow.png").appendTo(td);
break;
}
}
}
}
};
var renderColumnGroups = function(groups, keys) {
var nextLayer = [];
if (groups.length > 0) {
var tr = table.insertRow(table.rows.length);
tr.insertCell(0); // row index
for (var c = 0; c < columns.length; c++) {
var foundGroup = false;
for (var g = 0; g < groups.length; g++) {
var columnGroup = groups[g];
if (columnGroup.startColumnIndex == c) {
foundGroup = true;
break;
}
}
var td = tr.insertCell(tr.cells.length);
if (foundGroup) {
td.setAttribute("colspan", columnGroup.columnSpan);
td.style.background = "blue";
if (columnGroup.keyColumnIndex >= 0) {
keys.push(columnGroup.keyColumnIndex);
}
c += (columnGroup.columnSpan - 1);
nextLayer = nextLayer.concat(columnGroup.subgroups);
}
}
}
renderColumnKeys(keys);
if (nextLayer.length > 0) {
renderColumnGroups(nextLayer, []);
}
};
renderColumnGroups(
columnGroups,
[ theProject.columnModel.keyCellIndex ]
);
/*------------------------------------------------------------
* Column Headers with Menus
*------------------------------------------------------------
*/
var trHead = table.insertRow(table.rows.length);
var td = trHead.insertCell(trHead.cells.length);
$(td).addClass("column-header");
@ -118,11 +194,15 @@ DataTableView.prototype.render = function() {
}
};
var columns = theProject.columnModel.columns;
for (var i = 0; i < columns.length; i++) {
createColumnHeader(columns[i], i);
}
/*------------------------------------------------------------
* Data Cells
*------------------------------------------------------------
*/
var renderCell = function(cell, td) {
if (cell == null || cell.v == null) {
return;

233
tests/movies.tsv Normal file
View File

@ -0,0 +1,233 @@
name Directed by Performances - Actor Performances - Character Estimated budget - Currency Estimated budget - Amount Genres Initial release date Languages
Wayne's World Penelope Spheeris Mike Myers Wayne Campbell US$ 20000000 Comedy 2/14/1992 English Language
Dana Carvey Garth Algar Satire
Rob Lowe Buddy film
Tia Carrere
Lara Flynn Boyle Stacy
Chris Farley
Ed O'Neill
Robert Patrick
Alice Cooper
Wayne's World 2 Stephen Surjik Mike Myers Wayne Campbell Comedy 12/10/1993 English Language
Dana Carvey Garth Algar Buddy film
Christopher Walken
Tia Carrere
Chris Farley
Ted McGinley
Olivia d'Abo
Kevin Pollak
Ed O'Neill
Kim Basinger
Heather Locklear
Austin Powers: Goldmember Jay Roach Mike Myers Austin Powers Parody 7/26/2002 English Language
Beyoncé Foxxy Cleopatra Time travel
Seth Green Scott Evil Comedy
Michael York
Robert Wagner
Michael Caine
Verne Troyer
Gwyneth Paltrow Dixie Normous
Fred Savage
Aaron Himelstein
Mindy Sterling
Josh Zuckerman
Greg Grunberg
Tommy 'Tiny' Lister
Rob Lowe
Masi Oka
Nikki Schieler Ziering
Britney Spears
Tom Cruise Him/Herself
John Travolta
Danny DeVito
Katie Couric Prison Guard
Steven Spielberg
Austin Powers: International Man of Mystery Jay Roach Mike Myers Austin Powers Parody 5/2/1997 English Language
Elizabeth Hurley Time travel
Michael York Comedy
Mimi Rogers
Robert Wagner
Patrick Bristow
Fabiana Udenio
Elya Baskin
Paul Dillon
Lois Chiles
Christian Slater
Brian George
Cynthia Lamontagne
Cindy Margolis Fembot
Mindy Sterling
Joe Son
So I Married an Axe Murderer Thomas Schlamme Mike Myers Comedy 7/30/1993 English Language
Nancy Travis
Anthony LaPaglia
Amanda Plummer
Brenda Fricker
Michael G. Hagerty
Luenell Police Records Officer
Debi Mazar
Matt Doherty
Steven Wright
Charles Grodin
Patrick Bristow
Phil Hartman
Cintra Wilson
Michael Richards
Sheila Kelley
Alan Arkin
M. C. Brennan
Holly Lewis
Austin Powers: The Spy Who Shagged Me Jay Roach Mike Myers Austin Powers Parody 6/11/1999 English Language
Heather Graham Comedy German Language
Robert Wagner Time travel
Rob Lowe
Michael York
Verne Troyer
David Koechner
Muse Watson
Michael G. Hagerty
Kristen Johnston
Mindy Sterling
Gia Carides
Will Ferrell
Bree Turner
Scott Cooper
Shrek 2 Andrew Adamson John Lithgow Lord Farquaad US$ 125000000 Comedy 5/19/2004 English Language
Kelly Asbury Mike Myers Shrek Computer animation
Conrad Vernon Eddie Murphy Donkey Fantasy
Cameron Diaz Princess Fiona
Julie Andrews Queen
Antonio Banderas Puss in Boots
John Cleese King
Rupert Everett Prince Charming
Jennifer Saunders Fairy Godmother
Aron Warner Wolf
Kelly Asbury Page
Cody Cameron Pinocchio
Conrad Vernon Gingerbread Man
Christopher Knights Blind Mouse
Mark Moseley Mirror
Inglourious Basterds Quentin Tarantino Brad Pitt Lt. Aldo Raine US$ 70000000 War 8/21/2009 English Language
Mike Myers General Ed French Adventure German Language
Diane Kruger Bridget von Hammersmark Action French Language
Daniel Brühl Frederick Zoller Black comedy Italian Language
Til Schweiger Sgt. Hugo Stiglitz
B. J. Novak PFC Utivich
Michael Fassbender Lt. Archie Hicox
Julie Dreyfus Francesca Mondino
Maggie Cheung Madame Mimieux
Rod Taylor Winston Churchhill
Gedeon Burkhard
Christian Berkel Eric the Barkeeper
Samuel L. Jackson
Samm Levine PFC Hirschberg
Cloris Leachman Mrs. Himmelstein
Christoph Waltz Colonel Hans Landa
Ludger Pistor
Omar Doom PFC Omar Ulmer
Jana Pallaske
Enzo G. Castellari
Jacky Ido
Eli Roth
Mélanie Laurent
54 Mark Christopher Ryan Phillippe Shane O'Shea US$ 18000000 LGBT 8/28/1998 English Language
Salma Hayek Anita Randazzo Drama
Neve Campbell Julie Black
Mike Myers Steve Rubell
Sela Ward Billie Auster
Breckin Meyer Greg Randazzo
Sherry Stringfield Viv
Ellen Albertini Dow Disco Dottie
Cameron Mathison Atlanta
Noam Jenkins Romeo
Jay Goede Buck
Patrick Taylor Tarzan
Heather Matarazzo Grace O'Shea
Heidi Klum VIP Patron
Mark Ruffalo
Lauren Hutton
Skipp Sudduth
Michael York
Shrek the Third Raman Hui Mike Myers Shrek Comedy 5/18/2007 English Language
Chris Miller Cameron Diaz Princess Fiona Computer animation
Raman Hui Eddie Murphy Fantasy
Antonio Banderas
Julie Andrews
John Cleese
Rupert Everett
Justin Timberlake Artie
Regis Philbin
Seth Rogen Ship Captain
Eric Idle
Cheri Oteri
Edison Chen
View from the Top Bruno Barreto Gwyneth Paltrow Donna Jensen Romantic comedy 3/21/2003 English Language
Christina Applegate Comedy
Mark Ruffalo
Candice Bergen
Joshua Malina
Kelly Preston
Mike Myers
Rob Lowe
Marc Blucas
Pete's Meteor Brenda Fricker Drama 1998
Mike Myers
The Cat in the Hat Bo Welch Mike Myers The Cat in the Hat US$ 109000000 Musical 11/21/2003 English Language
Alec Baldwin Larry Quinn Fantasy
Kelly Preston Joan Walden
Dakota Fanning Sally Walden
Spencer Breslin Conrad Walden
Amy Hill
Sean Hayes The Fish
Shrek Andrew Adamson Mike Myers Shrek US$ 60000000 Parody 5/18/2001 English Language
Vicky Jenson Eddie Murphy Donkey Computer animation
Cameron Diaz Princess Fiona Comedy
John Lithgow Lord Farquaad Fantasy
Chris Farley
Conrad Vernon
Vincent Cassel
Val Bettin
Christopher Knights
The Thin Pink Line Joe Dietl Laura Kightlinger Satire 1998 English Language
Michael Irpino Janeane Garofalo Joyce Wintergarden-Dingle Indie
Margaret Cho Comedy
Jennifer Aniston Clove
David Schwimmer
Mike Myers
Will Ferrell
Shrek the Halls Gary Trousdale Eddie Murphy Animation 11/28/2007 English Language
Antonio Banderas Fantasy
Cameron Diaz Princess Fiona Short film
Mike Myers Adventure
Aron Warner Comedy
Conrad Vernon
Christopher Knights
Marissa Jaret Winokur
Shrek Ever After Mike Mitchell Cameron Diaz Princess Fiona Comedy 5/21/2010 English Language
Mike Mitchell Eric Idle Merlin Computer animation
Antonio Banderas Puss in Boots Fantasy
Eddie Murphy Donkey
Justin Timberlake Arthur Pendragon
Julie Andrews Queen Lillian
Mike Myers Shrek
Paul McCartney Rumpelstiltskin
Larry King Doris the Ugly Stepsister
The Love Guru Mike Myers Maurice Pitka US$ 62000000 Comedy 6/20/2008 English Language
Jessica Alba Jane Bullard
Justin Timberlake Jacques Grande
Romany Malco Darren Roanoke
Jessica Simpson
Ben Kingsley
Verne Troyer
Shrek Goes Fourth Cameron Diaz Princess Fiona Computer animation
Antonio Banderas Puss in Boots
Eddie Murphy Donkey
Mike Myers Shrek
View from the top Bruno Barreto Gwyneth Paltrow Romantic comedy 3/21/2003 English Language
Mike Myers
Rob Lowe
Christina Applegate
Kelly Preston
Candice Bergen
Mark Ruffalo
Joshua Malina
1 name Directed by Performances - Actor Performances - Character Estimated budget - Currency Estimated budget - Amount Genres Initial release date Languages
2 Wayne's World Penelope Spheeris Mike Myers Wayne Campbell US$ 20000000 Comedy 2/14/1992 English Language
3 Dana Carvey Garth Algar Satire
4 Rob Lowe Buddy film
5 Tia Carrere
6 Lara Flynn Boyle Stacy
7 Chris Farley
8 Ed O'Neill
9 Robert Patrick
10 Alice Cooper
11 Wayne's World 2 Stephen Surjik Mike Myers Wayne Campbell Comedy 12/10/1993 English Language
12 Dana Carvey Garth Algar Buddy film
13 Christopher Walken
14 Tia Carrere
15 Chris Farley
16 Ted McGinley
17 Olivia d'Abo
18 Kevin Pollak
19 Ed O'Neill
20 Kim Basinger
21 Heather Locklear
22 Austin Powers: Goldmember Jay Roach Mike Myers Austin Powers Parody 7/26/2002 English Language
23 Beyoncé Foxxy Cleopatra Time travel
24 Seth Green Scott Evil Comedy
25 Michael York
26 Robert Wagner
27 Michael Caine
28 Verne Troyer
29 Gwyneth Paltrow Dixie Normous
30 Fred Savage
31 Aaron Himelstein
32 Mindy Sterling
33 Josh Zuckerman
34 Greg Grunberg
35 Tommy 'Tiny' Lister
36 Rob Lowe
37 Masi Oka
38 Nikki Schieler Ziering
39 Britney Spears
40 Tom Cruise Him/Herself
41 John Travolta
42 Danny DeVito
43 Katie Couric Prison Guard
44 Steven Spielberg
45 Austin Powers: International Man of Mystery Jay Roach Mike Myers Austin Powers Parody 5/2/1997 English Language
46 Elizabeth Hurley Time travel
47 Michael York Comedy
48 Mimi Rogers
49 Robert Wagner
50 Patrick Bristow
51 Fabiana Udenio
52 Elya Baskin
53 Paul Dillon
54 Lois Chiles
55 Christian Slater
56 Brian George
57 Cynthia Lamontagne
58 Cindy Margolis Fembot
59 Mindy Sterling
60 Joe Son
61 So I Married an Axe Murderer Thomas Schlamme Mike Myers Comedy 7/30/1993 English Language
62 Nancy Travis
63 Anthony LaPaglia
64 Amanda Plummer
65 Brenda Fricker
66 Michael G. Hagerty
67 Luenell Police Records Officer
68 Debi Mazar
69 Matt Doherty
70 Steven Wright
71 Charles Grodin
72 Patrick Bristow
73 Phil Hartman
74 Cintra Wilson
75 Michael Richards
76 Sheila Kelley
77 Alan Arkin
78 M. C. Brennan
79 Holly Lewis
80 Austin Powers: The Spy Who Shagged Me Jay Roach Mike Myers Austin Powers Parody 6/11/1999 English Language
81 Heather Graham Comedy German Language
82 Robert Wagner Time travel
83 Rob Lowe
84 Michael York
85 Verne Troyer
86 David Koechner
87 Muse Watson
88 Michael G. Hagerty
89 Kristen Johnston
90 Mindy Sterling
91 Gia Carides
92 Will Ferrell
93 Bree Turner
94 Scott Cooper
95 Shrek 2 Andrew Adamson John Lithgow Lord Farquaad US$ 125000000 Comedy 5/19/2004 English Language
96 Kelly Asbury Mike Myers Shrek Computer animation
97 Conrad Vernon Eddie Murphy Donkey Fantasy
98 Cameron Diaz Princess Fiona
99 Julie Andrews Queen
100 Antonio Banderas Puss in Boots
101 John Cleese King
102 Rupert Everett Prince Charming
103 Jennifer Saunders Fairy Godmother
104 Aron Warner Wolf
105 Kelly Asbury Page
106 Cody Cameron Pinocchio
107 Conrad Vernon Gingerbread Man
108 Christopher Knights Blind Mouse
109 Mark Moseley Mirror
110 Inglourious Basterds Quentin Tarantino Brad Pitt Lt. Aldo Raine US$ 70000000 War 8/21/2009 English Language
111 Mike Myers General Ed French Adventure German Language
112 Diane Kruger Bridget von Hammersmark Action French Language
113 Daniel Brühl Frederick Zoller Black comedy Italian Language
114 Til Schweiger Sgt. Hugo Stiglitz
115 B. J. Novak PFC Utivich
116 Michael Fassbender Lt. Archie Hicox
117 Julie Dreyfus Francesca Mondino
118 Maggie Cheung Madame Mimieux
119 Rod Taylor Winston Churchhill
120 Gedeon Burkhard
121 Christian Berkel Eric the Barkeeper
122 Samuel L. Jackson
123 Samm Levine PFC Hirschberg
124 Cloris Leachman Mrs. Himmelstein
125 Christoph Waltz Colonel Hans Landa
126 Ludger Pistor
127 Omar Doom PFC Omar Ulmer
128 Jana Pallaske
129 Enzo G. Castellari
130 Jacky Ido
131 Eli Roth
132 Mélanie Laurent
133 54 Mark Christopher Ryan Phillippe Shane O'Shea US$ 18000000 LGBT 8/28/1998 English Language
134 Salma Hayek Anita Randazzo Drama
135 Neve Campbell Julie Black
136 Mike Myers Steve Rubell
137 Sela Ward Billie Auster
138 Breckin Meyer Greg Randazzo
139 Sherry Stringfield Viv
140 Ellen Albertini Dow Disco Dottie
141 Cameron Mathison Atlanta
142 Noam Jenkins Romeo
143 Jay Goede Buck
144 Patrick Taylor Tarzan
145 Heather Matarazzo Grace O'Shea
146 Heidi Klum VIP Patron
147 Mark Ruffalo
148 Lauren Hutton
149 Skipp Sudduth
150 Michael York
151 Shrek the Third Raman Hui Mike Myers Shrek Comedy 5/18/2007 English Language
152 Chris Miller Cameron Diaz Princess Fiona Computer animation
153 Raman Hui Eddie Murphy Fantasy
154 Antonio Banderas
155 Julie Andrews
156 John Cleese
157 Rupert Everett
158 Justin Timberlake Artie
159 Regis Philbin
160 Seth Rogen Ship Captain
161 Eric Idle
162 Cheri Oteri
163 Edison Chen
164 View from the Top Bruno Barreto Gwyneth Paltrow Donna Jensen Romantic comedy 3/21/2003 English Language
165 Christina Applegate Comedy
166 Mark Ruffalo
167 Candice Bergen
168 Joshua Malina
169 Kelly Preston
170 Mike Myers
171 Rob Lowe
172 Marc Blucas
173 Pete's Meteor Brenda Fricker Drama 1998
174 Mike Myers
175 The Cat in the Hat Bo Welch Mike Myers The Cat in the Hat US$ 109000000 Musical 11/21/2003 English Language
176 Alec Baldwin Larry Quinn Fantasy
177 Kelly Preston Joan Walden
178 Dakota Fanning Sally Walden
179 Spencer Breslin Conrad Walden
180 Amy Hill
181 Sean Hayes The Fish
182 Shrek Andrew Adamson Mike Myers Shrek US$ 60000000 Parody 5/18/2001 English Language
183 Vicky Jenson Eddie Murphy Donkey Computer animation
184 Cameron Diaz Princess Fiona Comedy
185 John Lithgow Lord Farquaad Fantasy
186 Chris Farley
187 Conrad Vernon
188 Vincent Cassel
189 Val Bettin
190 Christopher Knights
191 The Thin Pink Line Joe Dietl Laura Kightlinger Satire 1998 English Language
192 Michael Irpino Janeane Garofalo Joyce Wintergarden-Dingle Indie
193 Margaret Cho Comedy
194 Jennifer Aniston Clove
195 David Schwimmer
196 Mike Myers
197 Will Ferrell
198 Shrek the Halls Gary Trousdale Eddie Murphy Animation 11/28/2007 English Language
199 Antonio Banderas Fantasy
200 Cameron Diaz Princess Fiona Short film
201 Mike Myers Adventure
202 Aron Warner Comedy
203 Conrad Vernon
204 Christopher Knights
205 Marissa Jaret Winokur
206 Shrek Ever After Mike Mitchell Cameron Diaz Princess Fiona Comedy 5/21/2010 English Language
207 Mike Mitchell Eric Idle Merlin Computer animation
208 Antonio Banderas Puss in Boots Fantasy
209 Eddie Murphy Donkey
210 Justin Timberlake Arthur Pendragon
211 Julie Andrews Queen Lillian
212 Mike Myers Shrek
213 Paul McCartney Rumpelstiltskin
214 Larry King Doris the Ugly Stepsister
215 The Love Guru Mike Myers Maurice Pitka US$ 62000000 Comedy 6/20/2008 English Language
216 Jessica Alba Jane Bullard
217 Justin Timberlake Jacques Grande
218 Romany Malco Darren Roanoke
219 Jessica Simpson
220 Ben Kingsley
221 Verne Troyer
222 Shrek Goes Fourth Cameron Diaz Princess Fiona Computer animation
223 Antonio Banderas Puss in Boots
224 Eddie Murphy Donkey
225 Mike Myers Shrek
226 View from the top Bruno Barreto Gwyneth Paltrow Romantic comedy 3/21/2003 English Language
227 Mike Myers
228 Rob Lowe
229 Christina Applegate
230 Kelly Preston
231 Candice Bergen
232 Mark Ruffalo
233 Joshua Malina