Skip to content

Commit ca10165

Browse files
committed
Merge branch 'master' of github.com:CreativeCodingLab/TextAnnotationGraphs
2 parents a5d440b + 3d77bb8 commit ca10165

File tree

6 files changed

+168
-252
lines changed

6 files changed

+168
-252
lines changed

index.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@
8888
var wordpadding = 4; //x padding between the rects containing words
8989
//var topMargin = 0;
9090
var edgepadding = 10; //padding between left side of svg canvas and where first word can be placed, and padding between right side of svg canvas and where last word on a row can fit (before popping over to next row)
91+
var rowpadding = 30;
92+
9193
var hideLinkLinesPercentage = 3.0; //percentage at which links and arrows are hidden
9294
var hideLinkTextPercentage = 7.0; //percentage at which words are link words are hidden
9395

@@ -128,8 +130,8 @@
128130
var attachmentMargin = 0.1; //percentage value
129131

130132
var word2word_strategy = strategies.FARTHEST;
131-
var word2link_strategy = strategies.CLOSEST;
132-
var link2link_strategy = strategies.CLOSEST; //CLOSEST sometimes causes overlaps - need to be a bit more rigorous when assigning slots - don't assign any slots that have the potential to overlap (when dragged manually)? - or let the buyer beware that this could happen - they can always move out of the way - right now it won't automatically overlap, but won't prevent a user from doing it.
133+
var word2link_strategy = strategies.FARTHEST;
134+
var link2link_strategy = strategies.FARTHEST; //CLOSEST sometimes causes overlaps - need to be a bit more rigorous when assigning slots - don't assign any slots that have the potential to overlap (when dragged manually)? - or let the buyer beware that this could happen - they can always move out of the way - right now it won't automatically overlap, but won't prevent a user from doing it.
133135

134136
var rows = []; //list of Row object, each of those has a list of Word objects
135137

js/annotate.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ class Word {
124124
constructor(val, idx) {
125125
this.val = val;
126126
this.idx = idx;
127+
this.tag = null;
127128
this.h = 0; //num slots
128129
this.ww = 0;
129130
this.wh = 0;
@@ -145,8 +146,8 @@ class Word {
145146

146147
//variables created in first render...
147148
//this.row; //this is a row object, for row num do: this.row.idx
148-
this.rectSVG = null; //the actual svg element
149-
this.rect = null; //the bbox of the svg element
149+
this.aboveRect = null; //the actual svg element
150+
this.bbox = null; //the bbox of the svg element
150151
this.underneathRect = null; //not clickable, but solid rect on which other word parts are placed (text, handles, clickable rect)
151152
this.text = null; //the svg text
152153
this.tagtext = null; //the svg text for a tag
@@ -170,17 +171,20 @@ class Word {
170171
update() {
171172

172173
// console.log("\n***\nin update X = " + this.tempX + ", Y = " + this.tempY + ", W = " + this.tempW );
173-
this.rectSVG.x(this.tempX);
174-
this.rectSVG.width(this.tempW);
174+
this.aboveRect.x(this.tempX);
175+
this.aboveRect.width(this.tempW);
175176

176177
this.underneathRect.x(this.tempX);
177178
this.underneathRect.width(this.tempW);
178179

179-
this.rect = this.rectSVG.bbox();
180+
this.bbox = this.aboveRect.bbox();
180181

181182
this.text.x(this.tempX + (this.tempW/2) - (this.text.bbox().w / 2) );
182-
this.tagtext.x(this.tempX + (this.tempW/2) - (this.tagtext.bbox().w / 2) );
183-
183+
184+
if (this.tag != null) {
185+
this.tagtext.x(this.tempX + (this.tempW/2) - (this.tagtext.bbox().w / 2) );
186+
}
187+
184188
this.leftX = this.tempX;
185189
this.rightX = this.tempX + this.tempW;
186190

@@ -196,8 +200,9 @@ class Word {
196200
drawWord(this);
197201
}
198202

203+
199204
getMinWidth() {
200-
return Math.max(minWordWidth, this.tw);
205+
return Math.max(minWordWidth, this.maxtextw);
201206
}
202207

203208
/* must return a value less than row width - edgepaddings, else will try to reposition long words forever! */

0 commit comments

Comments
 (0)