Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Linnea Samila
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit ed4fd0ed
authored
May 08, 2010
by
Tuukka Kivilahti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
select place via coordinates.
1 parent
87b56a89
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
112 additions
and
15 deletions
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/PlaceMapBean.java
code/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/beans/PlaceMapBeanLocal.java
code/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/beans/TestDataBeanLocal.java
code/LanBortalDatabase/src/fi/insomnia/bortal/model/EventMap.java
code/LanBortalWeb/WebContent/resources/tools/map/placeSelect.xhtml
code/LanBortalWeb/src/fi/insomnia/bortal/servlet/PlaceMap.java
code/LanBortalWeb/src/fi/insomnia/bortal/view/MapView.java
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/PlaceMapBean.java
View file @
ed4fd0e
...
...
@@ -30,7 +30,6 @@ public class PlaceMapBean implements PlaceMapBeanLocal {
public
PlaceMapBean
()
{
// TODO Auto-generated constructor stub
}
@EJB
private
PlaceFacade
placeFacade
;
@EJB
...
...
@@ -52,7 +51,7 @@ public class PlaceMapBean implements PlaceMapBeanLocal {
if
(
place
!=
null
)
{
map
=
place
.
getMap
();
}
else
{
map
=
eventMapFacade
.
find
(
eventId
,
mapId
);
map
=
eventMapFacade
.
find
(
eventId
,
mapId
);
}
BufferedImage
image
=
map
.
getMapWithPlaces
();
...
...
@@ -62,8 +61,9 @@ public class PlaceMapBean implements PlaceMapBeanLocal {
if
(
user
!=
null
)
{
for
(
PlaceGroup
uplacegroup
:
user
.
getPlaceGroups
())
{
for
(
Place
uplace
:
uplacegroup
.
getPlaces
())
for
(
Place
uplace
:
uplacegroup
.
getPlaces
())
{
uplace
.
drawOwnedPlace
(
image
);
}
}
}
}
...
...
@@ -75,4 +75,6 @@ public class PlaceMapBean implements PlaceMapBeanLocal {
ImageIO
.
write
(
image
,
filetype
,
outputStream
);
}
}
code/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/beans/PlaceMapBeanLocal.java
View file @
ed4fd0e
package
fi
.
insomnia
.
bortal
.
beans
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
javax.ejb.Local
;
import
fi.insomnia.bortal.model.Event
;
import
fi.insomnia.bortal.model.Place
;
@Local
public
interface
PlaceMapBeanLocal
{
void
printPlaceMapToStream
(
OutputStream
outputStream
,
String
filetype
,
Event
event
,
Integer
mapId
,
Integer
userId
,
Integer
placeId
)
throws
IOException
;
}
code/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/beans/TestDataBeanLocal.java
View file @
ed4fd0e
...
...
@@ -11,7 +11,6 @@ public interface TestDataBeanLocal {
Event
generateMetaData
();
void
generateTestPlaces
(
EventMap
map
);
}
code/LanBortalDatabase/src/fi/insomnia/bortal/model/EventMap.java
View file @
ed4fd0e
...
...
@@ -28,30 +28,24 @@ import javax.persistence.Version;
*/
@Entity
@Table
(
name
=
"maps"
)
@NamedQueries
(
{
@NamedQuery
(
name
=
"EventMap.findAll"
,
query
=
"SELECT e FROM EventMap e"
),
@NamedQuery
(
name
=
"EventMap.findByName"
,
query
=
"SELECT e FROM EventMap e WHERE e.name = :name"
)
})
@NamedQueries
({
@NamedQuery
(
name
=
"EventMap.findAll"
,
query
=
"SELECT e FROM EventMap e"
),
@NamedQuery
(
name
=
"EventMap.findByName"
,
query
=
"SELECT e FROM EventMap e WHERE e.name = :name"
)})
public
class
EventMap
implements
EventChildInterface
{
private
static
final
long
serialVersionUID
=
1L
;
@EmbeddedId
private
EventPk
id
;
@Lob
@Column
(
name
=
"map_data"
)
private
byte
[]
mapData
;
@Column
(
name
=
"map_name"
)
private
String
name
;
@OneToMany
(
cascade
=
CascadeType
.
ALL
,
mappedBy
=
"map"
)
private
List
<
Place
>
places
;
@ManyToOne
(
optional
=
false
)
@JoinColumn
(
name
=
"event_id"
,
referencedColumnName
=
"event_id"
,
insertable
=
false
,
updatable
=
false
,
nullable
=
false
)
private
Event
event
;
@Version
@Column
(
nullable
=
false
)
private
int
jpaVersionField
=
0
;
...
...
@@ -180,4 +174,19 @@ public class EventMap implements EventChildInterface {
return
event
;
}
public
Place
findPlace
(
int
x
,
int
y
)
{
for
(
Place
place
:
getPlaces
())
{
if
(
place
.
getMapX
()
<
x
&&
(
place
.
getMapX
()
+
place
.
getWidth
())
>
x
&&
place
.
getMapY
()
<
y
&&
(
place
.
getMapY
()
+
place
.
getHeight
())
>
y
)
{
return
place
;
}
}
return
null
;
}
}
code/LanBortalWeb/WebContent/resources/tools/map/placeSelect.xhtml
0 → 100644
View file @
ed4fd0e
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:composite=
"http://java.sun.com/jsf/composite"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
xmlns:tools=
"http://java.sun.com/jsf/composite/tools"
xmlns:role=
"http://java.sun.com/jsf/composite/tools/role"
>
<composite:interface>
</composite:interface>
<composite:implementation>
<h:form>
<h:commandButton
image=
"#{mapView.selectPlaceMapUrl}"
actionListener=
"#{mapView.placeSelectActionListener}"
/>
</h:form>
</composite:implementation>
</html>
code/LanBortalWeb/src/fi/insomnia/bortal/servlet/PlaceMap.java
View file @
ed4fd0e
...
...
@@ -4,6 +4,7 @@
*/
package
fi
.
insomnia
.
bortal
.
servlet
;
import
fi.insomnia.bortal.model.Place
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/view/MapView.java
0 → 100644
View file @
ed4fd0e
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package
fi
.
insomnia
.
bortal
.
view
;
import
fi.insomnia.bortal.model.EventMap
;
import
fi.insomnia.bortal.model.Place
;
import
java.util.Map
;
import
javax.faces.bean.ManagedBean
;
import
javax.faces.bean.SessionScoped
;
import
javax.faces.context.FacesContext
;
import
javax.faces.event.ActionEvent
;
/**
*
* @author tuukka
*/
@ManagedBean
(
name
=
"mapView"
)
@SessionScoped
public
class
MapView
{
private
EventMap
activeMap
;
/** Creates a new instance of MapView */
public
MapView
()
{
}
public
void
placeSelectActionListener
(
ActionEvent
e
)
{
FacesContext
context
=
FacesContext
.
getCurrentInstance
();
String
clientId
=
e
.
getComponent
().
getClientId
(
context
);
Map
requestParams
=
context
.
getExternalContext
().
getRequestParameterMap
();
int
x
=
new
Integer
((
String
)
requestParams
.
get
(
clientId
+
".x"
)).
intValue
();
int
y
=
new
Integer
((
String
)
requestParams
.
get
(
clientId
+
".y"
)).
intValue
();
Place
place
=
getActiveMap
().
findPlace
(
x
,
y
);
throw
new
UnsupportedOperationException
(
"We got place, but are doing nothing with it"
);
}
public
String
getSelectPlaceMapUrl
()
{
throw
new
UnsupportedOperationException
(
"Return map url"
);
}
/**
* @return the activeMap
*/
public
EventMap
getActiveMap
()
{
return
activeMap
;
}
/**
* @param activeMap the activeMap to set
*/
public
void
setActiveMap
(
EventMap
activeMap
)
{
this
.
activeMap
=
activeMap
;
}
}
Write
Preview
Markdown
is supported
Attach a file
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 post a comment