Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
minerva
core
Commits
03f5960f
Commit
03f5960f
authored
Mar 16, 2017
by
Piotr Gawron
Browse files
min/max color values are retrieved via api
parent
3ad87a2f
Changes
9
Hide whitespace changes
Inline
Side-by-side
frontend-js/src/main/js/ConfigurationType.js
View file @
03f5960f
...
...
@@ -5,6 +5,8 @@ var ConfigurationType = {
LOGO_IMG
:
"
LOGO_IMG
"
,
LOGO_LINK
:
"
LOGO_LINK
"
,
LEGEND_FILES
:
"
LEGEND_FILES
"
,
MIN_COLOR_VAL
:
"
MIN_COLOR_VAL
"
,
MAX_COLOR_VAL
:
"
MAX_COLOR_VAL
"
,
};
module
.
exports
=
ConfigurationType
;
frontend-js/src/main/js/Functions.js
View file @
03f5960f
...
...
@@ -159,47 +159,53 @@ Functions.isDomElement = function(o) {
};
Functions
.
overlayToColor
=
function
(
elementOverlay
)
{
/* jslint bitwise: true */
if
(
elementOverlay
===
null
||
elementOverlay
===
undefined
)
{
throw
new
Error
(
"
elementOverlay cannot be null!
"
);
}
else
if
(
elementOverlay
.
color
!==
undefined
&&
elementOverlay
.
color
!==
null
)
{
return
this
.
intToColorString
(
elementOverlay
.
color
.
value
);
}
else
if
(
elementOverlay
.
value
!==
undefined
&&
elementOverlay
.
value
!==
null
)
{
var
ratio
=
0
;
var
color
;
if
(
elementOverlay
.
value
<
0
)
{
ratio
=
-
elementOverlay
.
value
;
color
=
ServerConnector
.
getMinOverlayColorInt
();
var
self
=
this
;
return
new
Promise
(
function
(
resolve
,
reject
)
{
/* jslint bitwise: true */
if
(
elementOverlay
===
null
||
elementOverlay
===
undefined
)
{
reject
(
"
elementOverlay cannot be null!
"
);
}
else
if
(
elementOverlay
.
color
!==
undefined
&&
elementOverlay
.
color
!==
null
)
{
resolve
(
self
.
intToColorString
(
elementOverlay
.
color
.
value
));
}
else
if
(
elementOverlay
.
value
!==
undefined
&&
elementOverlay
.
value
!==
null
)
{
var
ratio
=
0
;
var
promiseColor
=
null
;
if
(
elementOverlay
.
value
<
0
)
{
ratio
=
-
elementOverlay
.
value
;
promiseColor
=
ServerConnector
.
getMinOverlayColorInt
();
}
else
{
ratio
=
elementOverlay
.
value
;
promiseColor
=
ServerConnector
.
getMaxOverlayColorInt
();
}
return
promiseColor
.
then
(
function
(
color
)
{
ratio
=
1
-
ratio
;
var
MAX_RED
=
0xFF0000
;
var
MAX_GREEN
=
0x00FF00
;
var
MAX_BLUE
=
0x0000FF
;
var
red
=
color
&
MAX_RED
;
red
=
red
+
(
MAX_RED
-
red
)
*
ratio
;
red
=
parseInt
(
red
);
red
=
red
&
0xFF0000
;
var
green
=
color
&
MAX_GREEN
;
green
=
green
+
(
MAX_GREEN
-
green
)
*
ratio
;
green
=
parseInt
(
green
);
green
=
green
&
MAX_GREEN
;
var
blue
=
color
&
MAX_BLUE
;
blue
=
blue
+
(
MAX_BLUE
-
blue
)
*
ratio
;
blue
=
parseInt
(
blue
);
blue
=
blue
&
MAX_BLUE
;
color
=
red
|
green
|
blue
;
resolve
(
self
.
intToColorString
(
color
));
});
}
else
{
ratio
=
elementOverlay
.
value
;
color
=
ServerConnector
.
getMaxOverlayColorInt
();
reject
(
"
elementOverlay doesn't have neither color nor value set!
"
);
}
ratio
=
1
-
ratio
;
var
MAX_RED
=
0xFF0000
;
var
MAX_GREEN
=
0x00FF00
;
var
MAX_BLUE
=
0x0000FF
;
var
red
=
color
&
MAX_RED
;
red
=
red
+
(
MAX_RED
-
red
)
*
ratio
;
red
=
parseInt
(
red
);
red
=
red
&
0xFF0000
;
var
green
=
color
&
MAX_GREEN
;
green
=
green
+
(
MAX_GREEN
-
green
)
*
ratio
;
green
=
parseInt
(
green
);
green
=
green
&
MAX_GREEN
;
var
blue
=
color
&
MAX_BLUE
;
blue
=
blue
+
(
MAX_BLUE
-
blue
)
*
ratio
;
blue
=
parseInt
(
blue
);
blue
=
blue
&
MAX_BLUE
;
color
=
red
|
green
|
blue
;
return
this
.
intToColorString
(
color
);
}
else
{
throw
new
Error
(
"
elementOverlay doesn't have neither color nor value set!
"
);
}
});
};
Functions
.
getElementByName
=
function
(
element
,
name
)
{
...
...
@@ -219,5 +225,4 @@ Functions.getElementByName = function(element, name) {
return
undefined
;
};
module
.
exports
=
Functions
;
frontend-js/src/main/js/ServerConnector.js
View file @
03f5960f
...
...
@@ -61,25 +61,43 @@ ServerConnector.updateReferenceGenomeData = function(organismId, type, version,
};
ServerConnector
.
getMinOverlayColorInt
=
function
()
{
var
color
=
document
.
getElementById
(
"
overlayConfigForm:userMinColor
"
).
value
;
if
(
color
===
""
)
{
color
=
document
.
getElementById
(
"
overlayConfigForm:systemMinColor
"
).
value
;
}
color
=
parseInt
(
color
,
16
);
/* jslint bitwise: true */
color
=
(
color
&
0xFFFFFF
);
return
color
;
var
self
=
this
;
return
new
Promise
(
function
(
resolve
,
reject
){
var
userColor
;
return
self
.
getLoggedUser
().
then
(
function
(
user
){
userColor
=
user
.
getMinColor
();
return
self
.
getConfigurationParam
(
ConfigurationType
.
MIN_COLOR_VAL
);
}).
then
(
function
(
systemMinColor
){
var
color
=
userColor
;
if
(
userColor
===
null
||
userColor
===
undefined
||
userColor
===
""
)
{
color
=
systemMinColor
;
}
color
=
parseInt
(
color
,
16
);
/* jslint bitwise: true */
color
=
(
color
&
0xFFFFFF
);
resolve
(
color
);
})
});
};
ServerConnector
.
getMaxOverlayColorInt
=
function
()
{
var
color
=
document
.
getElementById
(
"
overlayConfigForm:userMaxColor
"
).
value
;
if
(
color
===
""
)
{
color
=
document
.
getElementById
(
"
overlayConfigForm:systemMaxColor
"
).
value
;
}
color
=
parseInt
(
color
,
16
);
/* jslint bitwise: true */
color
=
(
color
&
0xFFFFFF
);
return
color
;
var
self
=
this
;
return
new
Promise
(
function
(
resolve
,
reject
){
var
userColor
;
return
self
.
getLoggedUser
().
then
(
function
(
user
){
userColor
=
user
.
getMaxColor
();
return
self
.
getConfigurationParam
(
ConfigurationType
.
MAX_COLOR_VAL
);
}).
then
(
function
(
systemMaxColor
){
var
color
=
userColor
;
if
(
userColor
===
null
||
userColor
===
undefined
||
userColor
===
""
)
{
color
=
systemMaxColor
;
}
color
=
parseInt
(
color
,
16
);
/* jslint bitwise: true */
color
=
(
color
&
0xFFFFFF
);
resolve
(
color
);
})
});
};
ServerConnector
.
readFile
=
function
(
url
)
{
...
...
frontend-js/src/main/js/map/data/User.js
View file @
03f5960f
...
...
@@ -11,6 +11,8 @@ function User(javaObject) {
this
.
setEmail
(
javaObject
.
email
);
this
.
setRemoved
(
javaObject
.
removed
);
this
.
setPrivileges
(
javaObject
.
privileges
);
this
.
setMinColor
(
javaObject
.
minColor
);
this
.
setMaxColor
(
javaObject
.
maxColor
);
}
User
.
prototype
.
setLogin
=
function
(
login
)
{
...
...
@@ -53,6 +55,22 @@ User.prototype.getRemoved = function() {
return
this
.
_removed
;
};
User
.
prototype
.
setMinColor
=
function
(
minColor
)
{
this
.
_minColor
=
minColor
;
};
User
.
prototype
.
getMinColor
=
function
()
{
return
this
.
_minColor
;
};
User
.
prototype
.
setMaxColor
=
function
(
maxColor
)
{
this
.
_maxColor
=
maxColor
;
};
User
.
prototype
.
getMaxColor
=
function
()
{
return
this
.
_maxColor
;
};
User
.
prototype
.
setPrivileges
=
function
(
privileges
)
{
this
.
_privileges
=
privileges
;
};
...
...
frontend-js/src/main/js/map/overlay/AliasOverlay.js
View file @
03f5960f
"
use strict
"
;
/* exported logger */
var
logger
=
require
(
'
../../logger
'
);
var
functions
=
require
(
'
../../Functions
'
);
var
AbstractOverlayElement
=
require
(
'
./AbstractOverlayElement
'
);
...
...
@@ -107,9 +110,14 @@ AliasOverlay.create = function(layoutAlias, aliasData, map, startX, endX) {
fillOpacity
:
0.8
,
strokeWeight
:
1
,
map
:
map
.
getGoogleMap
(),
fillColor
:
functions
.
overlayToColor
(
layoutAlias
),
bounds
:
bounds
});
functions
.
overlayToColor
(
layoutAlias
).
then
(
function
(
color
){
rectangle
.
setOptions
({
fillColor
:
color
,
});
});
var
result
=
new
AliasOverlay
(
rectangle
,
map
,
aliasData
);
return
result
;
};
...
...
frontend-js/src/test/js/Functions-test.js
View file @
03f5960f
...
...
@@ -176,38 +176,38 @@ describe('functions', function() {
var
overlay
=
{
value
:
0.5
,
};
var
colorString
=
functions
.
overlayToColor
(
overlay
);
// check the format of the html color
assert
.
equal
(
colorString
.
charAt
(
0
),
"
#
"
);
assert
.
equal
(
colorString
.
length
,
7
);
return
functions
.
overlayToColor
(
overlay
).
then
(
function
(
colorString
)
{
// check the format of the html color
assert
.
equal
(
colorString
.
charAt
(
0
),
"
#
"
);
assert
.
equal
(
colorString
.
length
,
7
);
});
});
it
(
'
overlayToColor 2
'
,
function
()
{
var
overlay
=
{
value
:
-
0.5
,
};
var
colorString
=
functions
.
overlayToColor
(
overlay
);
// check the format of the html color
assert
.
equal
(
colorString
.
charAt
(
0
),
"
#
"
);
assert
.
equal
(
colorString
.
length
,
7
);
return
functions
.
overlayToColor
(
overlay
).
then
(
function
(
colorString
)
{
// check the format of the html color
assert
.
equal
(
colorString
.
charAt
(
0
),
"
#
"
);
assert
.
equal
(
colorString
.
length
,
7
);
});
});
it
(
'
overlayToColor with invalid arg
'
,
function
()
{
try
{
functions
.
overlayToColor
(
null
);
assert
.
ok
(
false
);
}
catch
(
exception
)
{
assert
.
ok
(
exception
.
message
.
indexOf
(
"
cannot be null
"
)
>=
0
);
}
return
functions
.
overlayToColor
(
null
).
then
(
function
(
colorString
)
{
throw
new
Error
(
'
Promise was unexpectedly fulfilled. Result:
'
+
colorString
);
},
function
rejected
(
error
)
{
assert
.
ok
(
error
.
indexOf
(
"
cannot be null
"
)
>=
0
);
});
});
it
(
'
overlayToColor with invalid arg 2
'
,
function
()
{
try
{
functions
.
overlayToColor
({});
assert
.
ok
(
null
);
}
catch
(
exception
)
{
assert
.
ok
(
exception
.
message
.
indexOf
(
"
elementOverlay doesn't have neither color nor value set
"
)
>=
0
);
}
return
functions
.
overlayToColor
({}).
then
(
function
(
colorString
)
{
throw
new
Error
(
'
Promise was unexpectedly fulfilled. Result:
'
+
colorString
);
},
function
rejected
(
error
)
{
assert
.
ok
(
error
.
indexOf
(
"
elementOverlay doesn't have neither color nor value set
"
)
>=
0
);
});
});
it
(
'
bound with null params
'
,
function
()
{
...
...
frontend-js/src/test/js/ServerConnector-mock.js
View file @
03f5960f
...
...
@@ -19,14 +19,6 @@ ServerConnectorMock.init = function() {
};
ServerConnectorMock
.
init
();
ServerConnectorMock
.
getMaxOverlayColorInt
=
function
()
{
return
0xFF0000
;
};
ServerConnectorMock
.
getMinOverlayColorInt
=
function
()
{
return
0x00FF00
;
};
ServerConnectorMock
.
readFile
=
function
(
url
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
if
(
url
.
indexOf
(
"
http
"
)
===
0
)
{
...
...
frontend-js/src/test/js/google-map-mock.js
View file @
03f5960f
...
...
@@ -262,6 +262,10 @@ var google = {
this
.
setMap
=
function
(
map
)
{
this
.
options
.
map
=
map
;
};
this
.
setOptions
=
function
(
options
)
{
for
(
var
attrname
in
options
)
this
.
options
[
attrname
]
=
options
[
attrname
];
};
},
Size
:
function
()
{
return
{};
...
...
web/src/main/webapp/index.xhtml
View file @
03f5960f
...
...
@@ -182,13 +182,6 @@ function initMap(){
<p:contextMenu
id=
"selectionContextMenu"
model=
"#{exportMB.imageExportMenu}"
/>
</h:form>
<h:form
id=
"overlayConfigForm"
>
<h:inputHidden
id=
"userMinColor"
value=
"#{userMB.loggedUser.minColor}"
/>
<h:inputHidden
id=
"userMaxColor"
value=
"#{userMB.loggedUser.maxColor}"
/>
<h:inputHidden
id=
"systemMinColor"
value=
"#{configurationMB.minColor}"
/>
<h:inputHidden
id=
"systemMaxColor"
value=
"#{configurationMB.maxColor}"
/>
</h:form>
<h:form
id=
"accessReferenceGenomeForm"
>
<p:remoteCommand
name=
"_sendReferenceGenomeDetailRequest"
actionListener=
"#{referenceGenomeMB.requestJavasciptGenomeDetails}"
/>
</h:form>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment