Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Genesys Backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
45
Issues
45
List
Boards
Labels
Service Desk
Milestones
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Genesys PGR
Genesys Backend
Commits
863a4da5
Commit
863a4da5
authored
Aug 04, 2014
by
igoshin
Committed by
Matija Obreza
Aug 06, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#13466 enabled colors
parent
c21cc935
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
269 additions
and
72 deletions
+269
-72
src/main/java/org/genesys2/server/service/MappingService.java
...main/java/org/genesys2/server/service/MappingService.java
+3
-1
src/main/java/org/genesys2/server/service/impl/MappingServiceImpl.java
.../org/genesys2/server/service/impl/MappingServiceImpl.java
+8
-2
src/main/java/org/genesys2/server/servlet/controller/ExplorerController.java
...enesys2/server/servlet/controller/ExplorerController.java
+1
-49
src/main/java/org/genesys2/server/servlet/controller/FilterSelectionBean.java
...nesys2/server/servlet/controller/FilterSelectionBean.java
+8
-2
src/main/java/org/genesys2/server/servlet/controller/MapFilterController.java
...nesys2/server/servlet/controller/MapFilterController.java
+72
-7
src/main/java/org/genesys2/server/servlet/model/MapFilter.java
...ain/java/org/genesys2/server/servlet/model/MapFilter.java
+17
-0
src/main/webapp/WEB-INF/decorator/css.jsp
src/main/webapp/WEB-INF/decorator/css.jsp
+2
-0
src/main/webapp/WEB-INF/decorator/footer.jsp
src/main/webapp/WEB-INF/decorator/footer.jsp
+2
-0
src/main/webapp/WEB-INF/jsp/accession/map.jsp
src/main/webapp/WEB-INF/jsp/accession/map.jsp
+29
-11
src/main/webapp/html/css/syronex-colorpicker.css
src/main/webapp/html/css/syronex-colorpicker.css
+24
-0
src/main/webapp/html/images/syronex-colorpicker.gif
src/main/webapp/html/images/syronex-colorpicker.gif
+0
-0
src/main/webapp/html/js/syronex-colorpicker.js
src/main/webapp/html/js/syronex-colorpicker.js
+103
-0
No files found.
src/main/java/org/genesys2/server/service/MappingService.java
View file @
863a4da5
...
...
@@ -16,6 +16,8 @@
package
org.genesys2.server.service
;
import
org.genesys2.server.servlet.model.MapFilter
;
import
java.io.IOException
;
public
interface
MappingService
{
...
...
@@ -26,7 +28,7 @@ public interface MappingService {
String
filteredGeoJson
(
String
string
,
Integer
limit
)
throws
IOException
;
byte
[]
getTile
(
String
jsonFilter
,
int
zoom
,
int
xtile
,
int
ytile
);
byte
[]
getTile
(
MapFilter
mapFilterm
,
String
jsonFilter
,
int
zoom
,
int
xtile
,
int
ytile
);
public
static
class
CoordUtil
{
public
static
double
tileToLon
(
int
zoom
,
int
xtile
)
{
...
...
src/main/java/org/genesys2/server/service/impl/MappingServiceImpl.java
View file @
863a4da5
...
...
@@ -29,6 +29,7 @@ import org.apache.commons.logging.Log;
import
org.apache.commons.logging.LogFactory
;
import
org.genesys2.server.service.GenesysFilterService
;
import
org.genesys2.server.service.MappingService
;
import
org.genesys2.server.servlet.model.MapFilter
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Cacheable
;
...
...
@@ -162,7 +163,7 @@ public class MappingServiceImpl implements MappingService {
@Override
@Cacheable
(
value
=
"tileserver"
,
key
=
"'tile-' + #zoom + '-' + #xtile + '-' + #ytile + '-' + #jsonFilter"
)
public
byte
[]
getTile
(
String
jsonFilter
,
final
int
zoom
,
final
int
xtile
,
final
int
ytile
)
{
public
byte
[]
getTile
(
final
MapFilter
mapFilter
,
String
jsonFilter
,
final
int
zoom
,
final
int
xtile
,
final
int
ytile
)
{
final
BufferedImage
bi
=
new
BufferedImage
(
256
,
256
,
BufferedImage
.
TYPE_INT_ARGB
);
ObjectNode
jsonTree
;
...
...
@@ -202,7 +203,12 @@ public class MappingServiceImpl implements MappingService {
for
(
int
i
=
-
pixelSize
/
2
;
i
<=
pixelSize
/
2
;
i
++)
{
for
(
int
j
=
-
pixelSize
/
2
;
j
<=
pixelSize
/
2
;
j
++)
{
if
(
longitude
+
i
>=
0
&&
latitude
+
j
>=
0
&&
longitude
+
i
<
256
&&
latitude
+
j
<
256
)
{
bi
.
setRGB
(
longitude
+
i
,
latitude
+
j
,
Color
.
yellow
.
getRGB
());
bi
.
setRGB
(
longitude
+
i
,
latitude
+
j
,
Color
.
yellow
.
getRGB
());
if
(
mapFilter
!=
null
){
bi
.
setRGB
(
longitude
+
i
,
latitude
+
j
,
Color
.
decode
(
mapFilter
.
getColor
()).
getRGB
());
}
}
}
}
...
...
src/main/java/org/genesys2/server/servlet/controller/ExplorerController.java
View file @
863a4da5
...
...
@@ -16,16 +16,12 @@
package
org.genesys2.server.servlet.controller
;
import
java.awt.Color
;
import
java.awt.image.BufferedImage
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.util.List
;
import
java.util.Map
;
import
javax.imageio.ImageIO
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.commons.lang.StringUtils
;
...
...
@@ -309,23 +305,7 @@ public class ExplorerController extends BaseController {
return
mappingService
.
filteredKml
(
jsonTree
.
toString
());
}
@RequestMapping
(
value
=
"/explore/tile/{zoom}/{x}/{y}"
,
produces
=
MediaType
.
IMAGE_PNG_VALUE
)
public
void
tile
(
@RequestParam
(
value
=
"filter"
,
required
=
true
)
String
jsonFilter
,
@PathVariable
(
"zoom"
)
int
zoom
,
@PathVariable
(
"x"
)
int
x
,
@PathVariable
(
"y"
)
int
y
,
@RequestParam
(
value
=
"color"
,
required
=
false
)
String
color
,
HttpServletResponse
response
)
{
try
{
byte
[]
image
=
mappingService
.
getTile
(
jsonFilter
,
zoom
,
x
,
y
);
image
=
changeColor
(
color
,
image
);
response
.
getOutputStream
().
write
(
image
,
0
,
image
.
length
);
}
catch
(
final
IOException
e
)
{
_logger
.
warn
(
e
.
getMessage
());
throw
new
RuntimeException
(
"Could not render image"
,
e
);
}
catch
(
final
Throwable
e
)
{
_logger
.
error
(
e
.
getMessage
(),
e
);
throw
new
ResourceNotFoundException
(
e
.
getMessage
());
}
}
/**
* Change color of the tile
...
...
@@ -334,34 +314,6 @@ public class ExplorerController extends BaseController {
* @param imageBytes
* @return
*/
private
byte
[]
changeColor
(
String
color
,
byte
[]
imageBytes
)
{
if
(
color
==
null
)
{
return
imageBytes
;
}
_logger
.
info
(
"Changing color to "
+
color
);
try
{
final
Color
newColor
=
Color
.
decode
(
color
);
if
(
newColor
.
equals
(
Color
.
yellow
))
{
return
imageBytes
;
}
final
MapColorsFilter
mcf
=
new
MapColorsFilter
(
Color
.
yellow
.
getRGB
(),
newColor
.
getRGB
());
final
ByteArrayInputStream
bios
=
new
ByteArrayInputStream
(
imageBytes
);
final
BufferedImage
image
=
mcf
.
filter
(
ImageIO
.
read
(
bios
),
null
);
final
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
ImageIO
.
write
(
image
,
"PNG"
,
baos
);
return
baos
.
toByteArray
();
}
catch
(
final
NumberFormatException
e
)
{
_logger
.
warn
(
"Cannot get color for "
+
color
);
return
imageBytes
;
}
catch
(
final
IOException
e
)
{
_logger
.
warn
(
e
.
getMessage
());
return
imageBytes
;
}
}
@RequestMapping
(
value
=
"/explore/geoJson"
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@ResponseBody
...
...
src/main/java/org/genesys2/server/servlet/controller/FilterSelectionBean.java
View file @
863a4da5
...
...
@@ -17,11 +17,17 @@ public class FilterSelectionBean implements Serializable {
private
final
List
<
MapFilter
>
filters
=
new
ArrayList
<>();
public
List
<
MapFilter
>
getFilters
(){
public
List
<
MapFilter
>
getFilters
()
{
return
filters
;
}
public
void
addFilter
(
MapFilter
filter
){
public
MapFilter
getFilter
(
String
title
)
{
MapFilter
mapFilter
=
new
MapFilter
();
mapFilter
.
setTitle
(
title
);
return
filters
.
get
(
filters
.
indexOf
(
mapFilter
));
}
public
void
addFilter
(
MapFilter
filter
)
{
filters
.
add
(
filter
);
}
}
src/main/java/org/genesys2/server/servlet/controller/MapFilterController.java
View file @
863a4da5
package
org.genesys2.server.servlet.controller
;
import
com.jhlabs.image.MapColorsFilter
;
import
org.apache.commons.lang.StringUtils
;
import
org.genesys2.server.service.MappingService
;
import
org.genesys2.server.servlet.model.MapFilter
;
import
org.genesys2.spring.ResourceNotFoundException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Scope
;
import
org.springframework.http.MediaType
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.*
;
import
javax.imageio.ImageIO
;
import
javax.servlet.http.HttpServletResponse
;
import
java.awt.*
;
import
java.awt.image.BufferedImage
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.util.List
;
@Controller
@Scope
(
"request"
)
@RequestMapping
(
"/filter"
)
public
class
MapFilterController
extends
BaseController
{
@Autowired
private
MappingService
mappingService
;
@Autowired
private
FilterSelectionBean
filterSelectionBean
;
@RequestMapping
(
value
=
"/get"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@RequestMapping
(
value
=
"/
filter/
get"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@ResponseBody
public
List
<
MapFilter
>
getMapFilters
()
{
return
filterSelectionBean
.
getFilters
();
}
@RequestMapping
(
value
=
"/save"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@RequestMapping
(
value
=
"/
filter/
save"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
void
saveMapFilter
(
@RequestBody
MapFilter
filter
)
{
filterSelectionBean
.
addFilter
(
filter
);
}
@RequestMapping
(
value
=
"/explore/tile/{zoom}/{x}/{y}"
,
produces
=
MediaType
.
IMAGE_PNG_VALUE
)
public
void
tile
(
@PathVariable
(
"zoom"
)
int
zoom
,
@PathVariable
(
"x"
)
int
x
,
@PathVariable
(
"y"
)
int
y
,
@RequestParam
(
value
=
"filter"
,
required
=
true
)
String
jsonFilter
,
@RequestParam
(
value
=
"color"
,
required
=
false
)
String
color
,
@RequestParam
(
value
=
"title"
,
required
=
false
)
String
title
,
HttpServletResponse
response
)
{
MapFilter
mapFilter
=
null
;
if
((
StringUtils
.
isNotBlank
(
title
)))
{
mapFilter
=
filterSelectionBean
.
getFilter
(
title
);
color
=
mapFilter
.
getColor
();
}
try
{
byte
[]
image
=
mappingService
.
getTile
(
mapFilter
,
jsonFilter
,
zoom
,
x
,
y
);
image
=
changeColor
(
color
,
image
);
response
.
getOutputStream
().
write
(
image
,
0
,
image
.
length
);
}
catch
(
final
IOException
e
)
{
_logger
.
warn
(
e
.
getMessage
());
throw
new
RuntimeException
(
"Could not render image"
,
e
);
}
catch
(
final
Throwable
e
)
{
_logger
.
error
(
e
.
getMessage
(),
e
);
throw
new
ResourceNotFoundException
(
e
.
getMessage
());
}
}
private
byte
[]
changeColor
(
String
color
,
byte
[]
imageBytes
)
{
if
(
color
==
null
)
{
return
imageBytes
;
}
_logger
.
info
(
"Changing color to "
+
color
);
try
{
final
Color
newColor
=
Color
.
decode
(
color
);
if
(
newColor
.
equals
(
Color
.
yellow
))
{
return
imageBytes
;
}
final
MapColorsFilter
mcf
=
new
MapColorsFilter
(
Color
.
yellow
.
getRGB
(),
newColor
.
getRGB
());
final
ByteArrayInputStream
bios
=
new
ByteArrayInputStream
(
imageBytes
);
final
BufferedImage
image
=
mcf
.
filter
(
ImageIO
.
read
(
bios
),
null
);
final
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
ImageIO
.
write
(
image
,
"PNG"
,
baos
);
return
baos
.
toByteArray
();
}
catch
(
final
NumberFormatException
e
)
{
_logger
.
warn
(
"Cannot get color for "
+
color
);
return
imageBytes
;
}
catch
(
final
IOException
e
)
{
_logger
.
warn
(
e
.
getMessage
());
return
imageBytes
;
}
}
}
src/main/java/org/genesys2/server/servlet/model/MapFilter.java
View file @
863a4da5
...
...
@@ -31,4 +31,21 @@ public class MapFilter implements Serializable {
public
void
setColor
(
String
color
)
{
this
.
color
=
color
;
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
return
true
;
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
return
false
;
MapFilter
mapFilter
=
(
MapFilter
)
o
;
if
(
title
!=
null
?
!
title
.
equals
(
mapFilter
.
title
)
:
mapFilter
.
title
!=
null
)
return
false
;
return
true
;
}
@Override
public
int
hashCode
()
{
return
title
!=
null
?
title
.
hashCode
()
:
0
;
}
}
src/main/webapp/WEB-INF/decorator/css.jsp
View file @
863a4da5
...
...
@@ -16,6 +16,7 @@
<link
href=
"
<c:url
value=
"/html/css/jquery-ui.css"
/>
"
rel=
"stylesheet"
/>
<link
href=
"
<c:url
value=
"/html/css/leaflet.css"
/>
"
rel=
"stylesheet"
/>
<link
href=
"
<c:url
value=
"/html/css/leaflet.locationfilter.css"
/>
"
rel=
"stylesheet"
/>
<link
href=
"
<c:url
value=
"/html/css/syronex-colorpicker.css"
/>
"
rel=
"stylesheet"
/>
<link
href=
"
<c:url
value=
"/html/css/genesys.css"
/>
"
rel=
"stylesheet"
/>
</c:when>
<c:otherwise>
...
...
@@ -26,5 +27,6 @@
<link
href=
"
<c:url
value=
"/html/css/custom.css"
/>
"
rel=
"stylesheet"
/>
<link
href=
"
<c:url
value=
"/html/css/responsive.css"
/>
"
rel=
"stylesheet"
/>
<link
href=
"
<c:url
value=
"/html/css/forza.css"
/>
"
rel=
"stylesheet"
/>
<link
href=
"
<c:url
value=
"/html/css/syronex-colorpicker.css"
/>
"
rel=
"stylesheet"
/>
</c:otherwise>
</c:choose>
src/main/webapp/WEB-INF/decorator/footer.jsp
View file @
863a4da5
...
...
@@ -53,6 +53,7 @@
<script
type=
"text/javascript"
src=
"
<c:url
value=
"/html/js/genesys.min.js"
/>
"
></script>
</c:when>
<c:when
test=
"
${
requestContext
.
theme
.
name
eq
'all'
}
"
>
<script
type=
"text/javascript"
src=
"
<c:url
value=
"/html/js/syronex-colorpicker.js"
/>
"
></script>
<script
type=
"text/javascript"
src=
"
<c:url
value=
"/html/js/jquery.js"
/>
"
></script>
<script
type=
"text/javascript"
src=
"
<c:url
value=
"/html/js/jquery-ui.js"
/>
"
></script>
<script
type=
"text/javascript"
src=
"
<c:url
value=
"/html/js/bootstrap.js"
/>
"
></script>
...
...
@@ -68,6 +69,7 @@
<script
type=
"text/javascript"
src=
"
<c:url
value=
"/html/js/leaflet.js"
/>
"
></script>
<script
type=
"text/javascript"
src=
"
<c:url
value=
"/html/js/leaflet.locationfilter.js"
/>
"
></script>
<script
type=
"text/javascript"
src=
"
<c:url
value=
"/html/js/crophub.js"
/>
"
></script>
<script
type=
"text/javascript"
src=
"
<c:url
value=
"/html/js/syronex-colorpicker.js"
/>
"
></script>
</c:otherwise>
</c:choose>
...
...
src/main/webapp/WEB-INF/jsp/accession/map.jsp
View file @
863a4da5
...
...
@@ -55,6 +55,7 @@
</div>
<div
class=
"modal-body"
>
<input
type=
"text"
class=
"form-control"
placeholder=
"
<spring:message
code=
"filter.enter.title"
/>
"
id=
"filter-title"
>
<div
href=
"#"
id=
"color"
></div>
</div>
<div
class=
"modal-footer"
>
<button
type=
"button"
class=
"btn btn-default"
data-dismiss=
"modal"
><spring:message
code=
"cancel"
/></button>
...
...
@@ -75,12 +76,20 @@
<content
tag=
"javascript"
>
<script
type=
"text/javascript"
>
jQuery
(
document
).
ready
(
function
()
{
var
color
=
null
;
$
(
'
#color
'
).
colorPicker
({
click
:
function
(
data
){
$
(
'
#output
'
).
html
(
data
);
color
=
data
;
}
});
$
(
"
#save-filter
"
).
on
(
"
click
"
,
function
(
event
)
{
event
.
preventDefault
();
var
title
=
$
(
"
#filter-title
"
).
val
();
var
filter
=
$
{
jsonFilter
};
var
color
=
"
red
"
;
$
.
ajax
({
url
:
"
/filter/save
"
,
...
...
@@ -108,10 +117,9 @@
dataType
:
"
json
"
,
contentType
:
'
application/json; charset=utf-8
'
,
success
:
function
(
data
)
{
console
.
log
(
data
)
$
.
each
(
data
,
function
(
idx
,
filter
)
{
var
li
=
"
<li><a href='#'>
"
+
filter
.
title
+
"
</a></li>
"
;
var
li
=
"
<li><a href='#'
class='saved-filter' fil='
"
+
filter
.
filter
+
"
'
>
"
+
filter
.
title
+
"
</a></li>
"
;
if
(
$
(
"
.dropdown-menu
"
).
is
(
"
:visible
"
))
{
$
(
"
.dropdown-menu
"
).
append
(
li
);
...
...
@@ -126,7 +134,7 @@
});
});
var
globalTitle
=
""
;
var
map
=
L
.
map
(
'
map
'
).
setView
([
20
,
0
],
2
);
L
.
tileLayer
(
'
https://otile{s}-s.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.png
'
,
{
attribution
:
"
MapQuest
"
,
...
...
@@ -134,7 +142,7 @@
subdomains
:
[
'
1
'
,
'
2
'
,
'
3
'
,
'
4
'
],
opacity
:
0.6
}).
addTo
(
map
);
L
.
tileLayer
(
"
{s}/explore/tile/{z}/{x}/{y}?filter=
"
+
'
${jsonFilter}
'
,
{
L
.
tileLayer
(
"
{s}/explore/tile/{z}/{x}/{y}?filter=
"
+
'
${jsonFilter}
'
+
"
&title=
"
+
globalTitle
,
{
attribution
:
"
<a href='${props.baseUrl}'>Genesys</a>
"
,
styleId
:
22677
,
subdomains
:
[
$
{
props
.
tileserverCdn
}]
...
...
@@ -142,17 +150,27 @@
$
(
"
#selectArea
"
).
hide
();
var
filterJson
=
$
{
jsonFilter
};
var
locationFilter
=
new
L
.
LocationFilter
({
adjustButton
:
false
,
bounds
:
map
.
getBounds
().
pad
(
-
0.1
)
}).
addTo
(
map
);
$
(
"
body
"
).
on
(
"
click
"
,
"
.saved-filter
"
,
function
(){
var
title
=
$
(
this
).
text
();
var
filter
=
$
(
this
).
attr
(
"
fil
"
);
globalTitle
=
title
;
L
.
tileLayer
(
"
{s}/explore/tile/{z}/{x}/{y}?filter=
"
+
filter
+
"
&title=
"
+
title
,
{
attribution
:
"
<a href='${props.baseUrl}'>Genesys</a>
"
,
styleId
:
22677
,
subdomains
:
[
$
{
props
.
tileserverCdn
}]
}).
addTo
(
map
);
});
var
locationFilter
=
new
L
.
LocationFilter
({
adjustButton
:
false
,
bounds
:
map
.
getBounds
().
pad
(
-
0.1
)
}).
addTo
(
map
);
locationFilter
.
on
(
"
change
"
,
function
(
e
)
{
// Do something when the bounds change.
// Bounds are available in `e.bounds`.
var
bounds
=
locationFilter
.
getBounds
();
var
bounds
=
locationFilter
.
getBounds
();
filterJson
.
latitude
=
[{
range
:[
bounds
.
getSouth
(),
bounds
.
getNorth
()]}];
filterJson
.
longitude
=
[{
range
:[
bounds
.
getWest
(),
bounds
.
getEast
()]}];
});
map
.
on
(
"
viewreset
"
,
function
()
{
if
(
locationFilter
.
isEnabled
())
return
;
...
...
@@ -161,7 +179,7 @@
});
locationFilter
.
on
(
"
enabled
"
,
function
()
{
// Do something when enabled.
var
bounds
=
locationFilter
.
getBounds
();
var
bounds
=
locationFilter
.
getBounds
();
filterJson
.
latitude
=
[{
range
:[
bounds
.
getSouth
(),
bounds
.
getNorth
()]}];
filterJson
.
longitude
=
[{
range
:[
bounds
.
getWest
(),
bounds
.
getEast
()]}];
$
(
"
#selectArea
"
).
show
();
...
...
src/main/webapp/html/css/syronex-colorpicker.css
0 → 100644
View file @
863a4da5
.jColorSelect
{
overflow
:
hidden
;
border
:
1px
solid
#d9dcdd
;
margin-top
:
5px
;
}
.jColorSelect
div
{
background
:
url(/html/images/syronex-colorpicker.gif)
no-repeat
;
float
:
left
;
width
:
42.6px
;
height
:
42.6px
;
cursor
:
pointer
;
overflow
:
hidden
;
border
:
1px
solid
#666666
;
margin
:
1px
;
}
.jColorSelect
.checkblk
{
cursor
:
default
;
background-position
:
right
top
;
}
.jColorSelect
.color
{
cursor
:
default
;
background-position
:
-100px
0
;
}
\ No newline at end of file
src/main/webapp/html/images/syronex-colorpicker.gif
0 → 100644
View file @
863a4da5
99 Bytes
src/main/webapp/html/js/syronex-colorpicker.js
0 → 100644
View file @
863a4da5
/**
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* (C) 2008 Syronex / J.M. Rosengard
* http://www.syronex.com/software/jquery-color-picker
*
* - Check mark is either black or white, depending on the darkness
* of the color selected.
* - Fixed a bug in the original plugin that led to problems when there is
* more than one colorPicker in a document.
*
* This is based on:
*
* jQuery colorSelect plugin 0.9
* http://plugins.jquery.com/project/colorPickerAgain
* Copyright (c) 2008 Otaku RzO (Renzo Galo Castro Jurado).
* (Original author URL & domain name no longer available.)
*
*/
(
function
(
$
)
{
$
.
fn
.
colorPicker
=
function
(
$$options
)
{
// Defaults
var
$defaults
=
{
color
:
new
Array
(
"
#FFFFFF
"
,
"
#EEEEEE
"
,
"
#FFFF88
"
,
"
#FF7400
"
,
"
#CDEB8B
"
,
"
#6BBA70
"
,
"
#006E2E
"
,
"
#C3D9FF
"
,
"
#4096EE
"
,
"
#356AA0
"
,
"
#FF0096
"
,
"
#B02B2C
"
),
defaultColor
:
0
,
columns
:
0
,
click
:
function
(
$color
){}
};
var
$settings
=
$
.
extend
({},
$defaults
,
$$options
);
// Iterate and reformat each matched element
return
this
.
each
(
function
()
{
var
$this
=
$
(
this
);
// build element specific options
var
o
=
$
.
meta
?
$
.
extend
({},
$settings
,
$this
.
data
())
:
$settings
;
var
$$oldIndex
=
typeof
(
o
.
defaultColor
)
==
'
number
'
?
o
.
defaultColor
:
-
1
;
var
_html
=
""
;
for
(
i
=
0
;
i
<
o
.
color
.
length
;
i
++
){
_html
+=
'
<div class="color" style="background-color:
'
+
o
.
color
[
i
]
+
'
;"></div>
'
;
if
(
$$oldIndex
==-
1
&&
o
.
defaultColor
==
o
.
color
[
i
])
$$oldIndex
=
i
;
}
$this
.
html
(
'
<div class="jColorSelect">
'
+
_html
+
'
</div>
'
);
var
$color
=
$this
.
children
(
'
.jColorSelect
'
).
children
(
'
div
'
);
// Subscribe to click event of each color box
$color
.
each
(
function
(
i
){
$
(
this
).
click
(
function
(){
if
(
$$oldIndex
==
i
)
return
;
if
(
$$oldIndex
>
-
1
){
cell
=
$color
.
eq
(
$$oldIndex
);
if
(
cell
.
hasClass
(
'
check
'
))
cell
.
removeClass
(
'
check
'
).
removeClass
(
'
checkblk
'
).
addClass
(
'
color
'
);
}
// Keep index
$$oldIndex
=
i
;
$
(
this
).
addClass
(
'
check
'
).
addClass
(
'
checkblk
'
).
removeClass
(
'
color
'
);
// Trigger user event
o
.
click
(
o
.
color
[
i
]);
});
});
// Simulate click for defaultColor
_tmp
=
$$oldIndex
;
$$oldIndex
=
-
1
;
$color
.
eq
(
_tmp
).
trigger
(
'
click
'
);
});
return
this
;
};
})(
jQuery
);
/**
* Return true if color is dark, false otherwise.
* (C) 2008 Syronex / J.M. Rosengard
**/
function
isdark
(
color
){
var
colr
=
parseInt
(
color
.
substr
(
1
),
16
);
return
(
colr
>>>
16
)
// R
+
((
colr
>>>
8
)
&
0x00ff
)
// G
+
(
colr
&
0x0000ff
)
// B
<
500
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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