Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
minerva
core
Commits
ba171932
Commit
ba171932
authored
Oct 26, 2016
by
Piotr Gawron
Browse files
comments on submaps are centered correctly
parent
a3543194
Changes
4
Hide whitespace changes
Inline
Side-by-side
converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/ImageGenerators.java
View file @
ba171932
...
...
@@ -15,7 +15,6 @@ import lcsb.mapviewer.common.exception.InvalidStateException;
import
lcsb.mapviewer.converter.graphics.AbstractImageGenerator.Params
;
import
lcsb.mapviewer.model.map.model.Model
;
import
lcsb.mapviewer.model.map.model.ModelFullIndexed
;
import
lcsb.mapviewer.model.user.ConfigurationElementType
;
/**
* This class is a util class containing information about all currently
...
...
@@ -29,7 +28,7 @@ public class ImageGenerators {
* Default class logger.
*/
@SuppressWarnings
(
"unused"
)
private
final
Logger
logger
=
Logger
.
getLogger
(
ImageGenerators
.
class
);
private
final
Logger
logger
=
Logger
.
getLogger
(
ImageGenerators
.
class
);
/**
* List of {@link AbstractImageGenerator} classes available in the system.
*/
...
...
@@ -39,7 +38,7 @@ public class ImageGenerators {
* List of all possible objects extending {@link AbstractImageGenerator}
* interface that are available in the system.
*/
private
List
<
AbstractImageGenerator
>
generatorInstances
=
null
;
private
List
<
AbstractImageGenerator
>
generatorInstances
=
null
;
/**
* Default constructor.
...
...
@@ -51,17 +50,15 @@ public class ImageGenerators {
AbstractImageGenerator
.
Params
params
=
new
AbstractImageGenerator
.
Params
().
//
model
(
model
).
//
width
(
1
).
//
minColor
(
Color
.
WHITE
).
maxColor
(
Color
.
WHITE
).
height
(
1
);
minColor
(
Color
.
WHITE
).
maxColor
(
Color
.
WHITE
).
height
(
1
);
generatorInstances
=
new
ArrayList
<>();
generatorInstances
.
add
(
new
PngImageGenerator
(
params
));
generatorInstances
.
add
(
new
PdfImageGenerator
(
params
));
//
generatorInstances.add(new SvgImageGenerator(params));
//
generatorInstances.add(new JpgImageGenerator(params));
//
generatorInstances.add(new SvgImageGenerator(params));
//
generatorInstances.add(new JpgImageGenerator(params));
for
(
AbstractImageGenerator
abstractImageGenerator
:
generatorInstances
)
{
availableGenerators
.
add
(
new
Pair
<
String
,
Class
<?
extends
AbstractImageGenerator
>>(
abstractImageGenerator
.
getFormatName
(),
abstractImageGenerator
.
getClass
()));
availableGenerators
.
add
(
new
Pair
<
String
,
Class
<?
extends
AbstractImageGenerator
>>(
abstractImageGenerator
.
getFormatName
(),
abstractImageGenerator
.
getClass
()));
}
}
catch
(
DrawingException
e
)
{
...
...
service/src/main/java/lcsb/mapviewer/services/view/CommentView.java
View file @
ba171932
...
...
@@ -12,11 +12,11 @@ import lcsb.mapviewer.model.map.Comment;
*/
public
class
CommentView
extends
AbstractView
<
Comment
>
implements
Serializable
{
/**
*
*/
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
/**
* Author of the comment.
...
...
@@ -63,7 +63,10 @@ public class CommentView extends AbstractView<Comment> implements Serializable {
* details).
*/
private
String
zoom
;
/**
* Submap on which comment was placed.
*/
private
String
submap
;
/**
...
...
@@ -279,7 +282,8 @@ public class CommentView extends AbstractView<Comment> implements Serializable {
}
/**
* @param submap the submap to set
* @param submap
* the submap to set
* @see #submap
*/
public
void
setSubmap
(
String
submap
)
{
...
...
service/src/main/java/lcsb/mapviewer/services/view/CommentViewFactory.java
View file @
ba171932
...
...
@@ -7,6 +7,7 @@ import org.apache.log4j.Logger;
import
com.google.gson.Gson
;
import
lcsb.mapviewer.common.Configuration
;
import
lcsb.mapviewer.common.exception.InvalidArgumentException
;
import
lcsb.mapviewer.common.exception.NotImplementedException
;
import
lcsb.mapviewer.model.map.Comment
;
import
lcsb.mapviewer.model.map.model.Model
;
...
...
@@ -50,15 +51,22 @@ public class CommentViewFactory extends AbstractViewFactory<Comment, CommentView
return
result
;
}
result
.
setAuthor
(
(
comment
.
getName
())
)
;
result
.
setContent
(
(
comment
.
getContent
())
)
;
result
.
setEmail
(
(
comment
.
getEmail
())
)
;
result
.
setAuthor
(
comment
.
getName
());
result
.
setContent
(
comment
.
getContent
());
result
.
setEmail
(
comment
.
getEmail
());
result
.
setPinned
(
comment
.
isPinned
());
if
(
comment
.
isDeleted
())
{
result
.
setRemoved
(
"YES ("
+
comment
.
getRemoveReason
()
+
")"
);
}
else
{
result
.
setRemoved
(
"NO"
);
}
if
(
comment
.
getSubmodelData
()
!=
null
)
{
result
.
setSubmap
(
comment
.
getSubmodelData
().
getId
()
+
""
);
model
=
model
.
getSubmodelById
(
comment
.
getSubmodelData
().
getId
());
if
(
model
==
null
)
{
throw
new
InvalidArgumentException
(
"Cannot find submodel with id: "
+
comment
.
getSubmodelData
().
getId
());
}
}
String
title
=
""
;
Point2D
coordinates
=
null
;
...
...
@@ -88,9 +96,6 @@ public class CommentViewFactory extends AbstractViewFactory<Comment, CommentView
}
}
result
.
setTitle
(
title
);
if
(
comment
.
getSubmodelData
()
!=
null
)
{
result
.
setSubmap
(
comment
.
getSubmodelData
().
getId
()
+
""
);
}
if
(
coordinates
!=
null
)
{
result
.
setxCoord
(
coordinates
.
getX
());
result
.
setyCoord
(
coordinates
.
getY
());
...
...
service/src/test/java/lcsb/mapviewer/services/view/CommentViewFactoryTest.java
View file @
ba171932
package
lcsb.mapviewer.services.view
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
lcsb.mapviewer.services.ServiceTestFunctions
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
public
class
CommentViewFactoryTest
extends
ServiceTestFunctions
{
@Autowired
CommentViewFactory
commentViewFactory
;
@Before
public
void
setUp
()
throws
Exception
{
}
@After
public
void
tearDown
()
throws
Exception
{
}
@Test
public
void
testCreateEmpty
()
throws
Exception
{
try
{
Object
object
=
commentViewFactory
.
create
(
null
);
assertNotNull
(
object
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
@Test
public
void
testCreateGson
()
throws
Exception
{
try
{
CommentView
object
=
commentViewFactory
.
create
(
null
);
assertNotNull
(
commentViewFactory
.
createGson
(
object
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
}
package
lcsb.mapviewer.services.view
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
org.apache.log4j.Logger
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
lcsb.mapviewer.model.map.Comment
;
import
lcsb.mapviewer.model.map.model.Model
;
import
lcsb.mapviewer.model.map.model.ModelFullIndexed
;
import
lcsb.mapviewer.model.map.model.ModelSubmodelConnection
;
import
lcsb.mapviewer.model.map.model.SubmodelType
;
import
lcsb.mapviewer.model.map.species.GenericProtein
;
import
lcsb.mapviewer.model.map.species.Species
;
import
lcsb.mapviewer.services.ServiceTestFunctions
;
public
class
CommentViewFactoryTest
extends
ServiceTestFunctions
{
Logger
logger
=
Logger
.
getLogger
(
CommentViewFactoryTest
.
class
);
@Autowired
CommentViewFactory
commentViewFactory
;
@Before
public
void
setUp
()
throws
Exception
{
}
@After
public
void
tearDown
()
throws
Exception
{
}
@Test
public
void
testCreateEmpty
()
throws
Exception
{
try
{
Object
object
=
commentViewFactory
.
create
(
null
);
assertNotNull
(
object
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
@Test
public
void
testCreateGson
()
throws
Exception
{
try
{
CommentView
object
=
commentViewFactory
.
create
(
null
);
assertNotNull
(
commentViewFactory
.
createGson
(
object
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
@Test
public
void
testCreateOnSubmap
()
throws
Exception
{
try
{
Model
model
=
new
ModelFullIndexed
(
null
);
Model
submodel
=
new
ModelFullIndexed
(
null
);
submodel
.
setId
(
1
);
Species
species
=
new
GenericProtein
(
"id"
);
species
.
setId
(
23
);
species
.
setName
(
"ProteinName"
);
submodel
.
addElement
(
species
);
model
.
addSubmodelConnection
(
new
ModelSubmodelConnection
(
submodel
,
SubmodelType
.
UNKNOWN
));
Comment
comment
=
new
Comment
();
comment
.
setModel
(
model
);
comment
.
setSubmodel
(
submodel
);
comment
.
setTableName
(
species
.
getClass
());
comment
.
setTableId
(
species
.
getId
());
CommentView
object
=
commentViewFactory
.
create
(
comment
,
model
);
assertTrue
(
object
.
getTitle
().
contains
(
species
.
getName
()));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
}
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