Skip to content
This repository was archived by the owner on Oct 18, 2018. It is now read-only.

Commit e4ffad3

Browse files
committed
Implement text highlight feature and close #16
1 parent 686c4e1 commit e4ffad3

File tree

3 files changed

+86
-11
lines changed

3 files changed

+86
-11
lines changed

src/main/webapp/app.controller.tools.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,16 @@
2121
$scope.selectPointTool = function ($event) {
2222
$rootScope.selectedDrawingTool = 'point';
2323
};
24+
$scope.selectTextHighlightTool = function ($event) {
25+
$rootScope.selectedDrawingTool = 'text-highlight';
26+
};
2427
$scope.selectUnderlineTool = function ($event) {
2528
$rootScope.selectedDrawingTool = 'underline';
2629
};
2730
$scope.selectStrikeoutTool = function ($event) {
2831
$rootScope.selectedDrawingTool = 'strikeout';
2932
};
30-
33+
3134
$scope.selectSelectTool();
3235
}
3336

src/main/webapp/app.directive.gdxAnnoPage.js

Lines changed: 78 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,17 @@
115115
currentObject.fillColor = 'black';
116116
currentObject.strokeWidth = 2;
117117
break;
118+
case 'text-highlight':
119+
textRowMouseDown = findRowUnderPoint($rootScope.docInfo, attrs.number, event.point);
120+
currentObject = new ps.Path.Rectangle(new ps.Rectangle(
121+
event.point.x,
122+
textRowMouseDown.lineTop,
123+
1,
124+
textRowMouseDown.lineHeight)
125+
);
126+
currentObject.fillColor = 'yellow';
127+
currentObject.opacity = 0.3;
128+
break;
118129
case 'underline':
119130
case 'strikeout':
120131
textRowMouseDown = findRowUnderPoint($rootScope.docInfo, attrs.number, event.point);
@@ -154,6 +165,7 @@
154165
currentObject.position.x += event.delta.x;
155166
currentObject.position.y += event.delta.y;
156167
break;
168+
case 'text-highlight':
157169
case 'underline':
158170
case 'strikeout':
159171
if (currentObject !== null) {
@@ -246,15 +258,26 @@
246258
width: currentObject.bounds.width,
247259
height: currentObject.bounds.height
248260
},
261+
penColor: 0x010101,
262+
penStyle: 1,
263+
penWidth: 2,
249264
type: 1
250265
};
251266
break;
252267
case 'pencil':
253-
ant.type = 4;
254-
ant.svgPath = extractSvgPathData(currentObject);
268+
ant = angular.merge({}, ant, {
269+
penColor: 0x010101,
270+
penStyle: 1,
271+
penWidth: 2,
272+
svgPath: extractSvgPathData(currentObject),
273+
type: 4
274+
});
255275
break;
256276
case 'point':
257277
ant = angular.merge({}, ant, {
278+
penColor: 0x010101,
279+
penStyle: 1,
280+
penWidth: 2,
258281
type: 2,
259282
box: {
260283
x: event.point.x,
@@ -265,11 +288,19 @@
265288
});
266289
break;
267290
case 'arrow':
268-
ant.type = 8;
269-
ant.svgPath = extractSvgPathData(currentObject);
291+
ant = angular.merge({}, ant, {
292+
penColor: 0x010101,
293+
penStyle: 1,
294+
penWidth: 2,
295+
svgPath: extractSvgPathData(currentObject),
296+
type: 8
297+
});
270298
break;
271299
case 'distance':
272300
ant = {
301+
penColor: 0x010101,
302+
penStyle: 1,
303+
penWidth: 2,
273304
type: 12,
274305
svgPath: extractSvgPathData(currentObject),
275306
fieldText: currentObject.children[3].content,
@@ -281,6 +312,7 @@
281312
}
282313
};
283314
break;
315+
case 'text-highlight':
284316
case 'underline':
285317
case 'strikeout':
286318
if (currentObject !== null) {
@@ -316,6 +348,22 @@
316348
});
317349
currentObject.remove();
318350
switch ($rootScope.selectedDrawingTool) {
351+
case 'text-highlight':
352+
currentObject = new ps.Path.Rectangle(new ps.Rectangle(
353+
currentObject.bounds.x,
354+
currentObject.bounds.y,
355+
currentObject.bounds.width,
356+
currentObject.bounds.height
357+
));
358+
currentObject.fillColor = 'yellow';
359+
currentObject.opacity = 0.3;
360+
ant = angular.merge({}, ant, {
361+
penColor: 0xffff01,
362+
penStyle: 1,
363+
penWidth: 2,
364+
type: 0
365+
});
366+
break;
319367
case 'underline':
320368
currentObject = new ps.Path.Line({
321369
from: [
@@ -328,7 +376,12 @@
328376
],
329377
strokeColor: 'black'
330378
});
331-
ant = angular.merge({}, ant, {type: 11});
379+
ant = angular.merge({}, ant, {
380+
penColor: 0x010101,
381+
penStyle: 1,
382+
penWidth: 2,
383+
type: 11
384+
});
332385
break;
333386
case 'strikeout':
334387
currentObject = new ps.Path.Line({
@@ -342,18 +395,20 @@
342395
],
343396
strokeColor: 'black'
344397
});
345-
ant = angular.merge({}, ant, {type: 3});
398+
ant = angular.merge({}, ant, {
399+
penColor: 0x010101,
400+
penStyle: 1,
401+
penWidth: 2,
402+
type: 3
403+
});
346404
break;
347405
}
348406
}
349407
break;
350408
}
351409

352-
if (ant.type) {
410+
if (typeof(ant.type) !== 'undefined') {
353411
ant = angular.merge({}, ant, {
354-
penColor: 0x010101,
355-
penStyle: 1,
356-
penWidth: 2,
357412
pageNumber: attrs.number
358413
});
359414
var a = new AnnotationAddFactory(ant);
@@ -373,6 +428,7 @@
373428

374429
ps.tool.onMouseMove = function (event) {
375430
switch ($rootScope.selectedDrawingTool) {
431+
case 'text-highlight':
376432
case 'underline':
377433
case 'strikeout':
378434
var r = findRowUnderPoint($rootScope.docInfo, attrs.number, event.point);
@@ -504,6 +560,18 @@
504560
distance.children[3].strokeWidth = 0.5;
505561
distance.name = item.annotation.guid;
506562
break;
563+
case 0:
564+
var shape = new ps.Rectangle(
565+
item.annotation.box.x,
566+
attrs.height - item.annotation.box.y,
567+
item.annotation.box.width,
568+
item.annotation.box.height
569+
);
570+
var path = new ps.Path.Rectangle(shape);
571+
path.fillColor = 'yellow';
572+
path.opacity = 0.3;
573+
path.name = item.annotation.guid;
574+
break;
507575
}
508576
})
509577
}

src/main/webapp/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ <h1>GroupDocs.Annotation for Java</h1>
8181
<md-icon>compare_arrows</md-icon>
8282
<md-tooltip>Distance</md-tooltip>
8383
</md-button>
84+
<md-button class="md-icon-button" aria-label="Text Highlight" ng-click="selectTextHighlightTool()">
85+
<md-icon>format_paint</md-icon>
86+
<md-tooltip>Text Highlight</md-tooltip>
87+
</md-button>
8488
<md-button class="md-icon-button" aria-label="Underline" ng-click="selectUnderlineTool()">
8589
<md-icon>format_underlined</md-icon>
8690
<md-tooltip>Underline</md-tooltip>

0 commit comments

Comments
 (0)