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
33b5a143
Commit
33b5a143
authored
May 10, 2019
by
Piotr Gawron
Browse files
problem with not drawing images on map upload fixed
parent
8373beb0
Changes
8
Hide whitespace changes
Inline
Side-by-side
converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/ElementConverter.java
View file @
33b5a143
...
...
@@ -43,7 +43,7 @@ public abstract class ElementConverter<T extends Element> extends BioEntityConve
* @throws DrawingException
* thrown when there is a problem with drawing
*/
pr
ivate
void
drawGlyph
(
T
bioEntity
,
Graphics2D
graphics
)
throws
DrawingException
{
pr
otected
void
drawGlyph
(
T
bioEntity
,
Graphics2D
graphics
)
throws
DrawingException
{
try
{
Image
img
=
ImageIO
.
read
(
new
ByteArrayInputStream
(
bioEntity
.
getGlyph
().
getFile
().
getFileContent
()));
graphics
.
drawImage
(
img
,
...
...
converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/CompartmentConverter.java
View file @
33b5a143
...
...
@@ -179,7 +179,14 @@ public abstract class CompartmentConverter<T extends Compartment> extends Elemen
@Override
public
void
draw
(
T
alias
,
Graphics2D
graphics
,
ConverterParams
params
,
List
<
ColorSchema
>
visualizedLayoutsColorSchemas
)
throws
DrawingException
{
drawImpl
(
alias
,
graphics
,
params
);
logger
.
debug
(
"Draw: "
+
alias
.
getElementId
());
if
(
alias
.
getGlyph
()
!=
null
)
{
logger
.
debug
(
"as glyph"
);
drawGlyph
(
alias
,
graphics
);
}
else
{
logger
.
debug
(
"without glyph"
);
drawImpl
(
alias
,
graphics
,
params
);
}
Color
oldColor
=
graphics
.
getColor
();
int
count
=
0
;
...
...
converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/SpeciesConverter.java
View file @
33b5a143
...
...
@@ -496,9 +496,16 @@ public abstract class SpeciesConverter<T extends Species> extends ElementConvert
}
@Override
public
void
draw
(
T
species
,
Graphics2D
graphics
,
ConverterParams
params
,
public
final
void
draw
(
T
species
,
Graphics2D
graphics
,
ConverterParams
params
,
List
<
ColorSchema
>
visualizedLayoutsColorSchemas
)
throws
DrawingException
{
drawImpl
(
species
,
graphics
,
params
);
logger
.
debug
(
"Draw: "
+
species
.
getElementId
());
if
(
species
.
getGlyph
()
!=
null
)
{
logger
.
debug
(
"as glyph"
);
drawGlyph
(
species
,
graphics
);
}
else
{
logger
.
debug
(
"without glyph"
);
drawImpl
(
species
,
graphics
,
params
);
}
Color
oldColor
=
graphics
.
getColor
();
int
count
=
0
;
...
...
converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/bioEntity/BioEntityConverterImplTest.java
View file @
33b5a143
package
lcsb.mapviewer.converter.graphics.bioEntity
;
import
static
org
.
mockito
.
Matchers
.
any
;
import
static
org
.
mockito
.
ArgumentMatchers
.
any
;
import
static
org
.
mockito
.
ArgumentMatchers
.
anyInt
;
import
static
org
.
mockito
.
ArgumentMatchers
.
nullable
;
import
static
org
.
mockito
.
Mockito
.
times
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
java.awt.Color
;
import
java.awt.Desktop
;
import
java.awt.Graphics2D
;
import
java.awt.Image
;
import
java.awt.geom.GeneralPath
;
import
java.awt.geom.Point2D
;
import
java.awt.image.BufferedImage
;
import
java.awt.image.ImageObserver
;
import
java.io.File
;
import
java.nio.file.Files
;
import
javax.imageio.ImageIO
;
import
org.junit.After
;
import
org.junit.AfterClass
;
...
...
@@ -17,7 +27,10 @@ import org.mockito.Mockito;
import
lcsb.mapviewer.commands.ColorExtractor
;
import
lcsb.mapviewer.converter.graphics.ConverterParams
;
import
lcsb.mapviewer.converter.graphics.GraphicsTestFunctions
;
import
lcsb.mapviewer.model.cache.UploadedFileEntry
;
import
lcsb.mapviewer.model.graphics.PolylineData
;
import
lcsb.mapviewer.model.map.layout.graphics.Glyph
;
import
lcsb.mapviewer.model.map.modifier.Catalysis
;
import
lcsb.mapviewer.model.map.reaction.Modifier
;
import
lcsb.mapviewer.model.map.reaction.Product
;
...
...
@@ -25,74 +38,103 @@ import lcsb.mapviewer.model.map.reaction.Reactant;
import
lcsb.mapviewer.model.map.reaction.Reaction
;
import
lcsb.mapviewer.model.map.species.GenericProtein
;
public
class
BioEntityConverterImplTest
{
public
class
BioEntityConverterImplTest
extends
GraphicsTestFunctions
{
ColorExtractor
colorExtractor
=
new
ColorExtractor
(
Color
.
RED
,
Color
.
GREEN
,
Color
.
BLUE
);
@AfterClass
public
static
void
tearDownAfterClass
()
throws
Exception
{
}
@Before
public
void
setUp
()
throws
Exception
{
}
@After
public
void
tearDown
()
throws
Exception
{
}
@Test
public
void
testDrawReactionWithSemanticZoomingAndReactantOff
()
throws
Exception
{
try
{
Graphics2D
graphics
=
Mockito
.
mock
(
Graphics2D
.
class
);
Reaction
reaction
=
createReaction
(
1.0
);
reaction
.
getReactants
().
get
(
0
).
getElement
().
setVisibilityLevel
(
"11"
);
BioEntityConverterImpl
rc
=
new
BioEntityConverterImpl
(
reaction
,
false
,
colorExtractor
);
rc
.
draw
(
reaction
,
graphics
,
new
ConverterParams
().
nested
(
true
).
level
(
10
));
verify
(
graphics
,
times
(
0
)).
draw
(
any
(
GeneralPath
.
class
));
}
catch
(
Exception
e
)
{
throw
e
;
}
}
ColorExtractor
colorExtractor
=
new
ColorExtractor
(
Color
.
RED
,
Color
.
GREEN
,
Color
.
BLUE
);
@Test
public
void
testDrawReactionWithSemanticZoomingAndProductOff
()
throws
Exception
{
try
{
Graphics2D
graphics
=
Mockito
.
mock
(
Graphics2D
.
class
);
@AfterClass
public
static
void
tearDownAfterClass
()
throws
Exception
{
}
Reaction
reaction
=
createReaction
(
1.0
);
reaction
.
getProducts
().
get
(
0
).
getElement
().
setVisibilityLevel
(
"11"
);
@Before
public
void
setUp
()
throws
Exception
{
}
BioEntityConverterImpl
rc
=
new
BioEntityConverterImpl
(
reaction
,
false
,
colorExtractor
);
rc
.
draw
(
reaction
,
graphics
,
new
ConverterParams
().
nested
(
true
).
level
(
10
));
@After
public
void
tearDown
()
throws
Exception
{
}
verify
(
graphics
,
times
(
0
)).
draw
(
any
(
GeneralPath
.
class
));
@Test
public
void
testDrawReactionWithSemanticZoomingAndReactantOff
()
throws
Exception
{
try
{
Graphics2D
graphics
=
Mockito
.
mock
(
Graphics2D
.
class
);
Reaction
reaction
=
createReaction
(
1.0
);
reaction
.
getReactants
().
get
(
0
).
getElement
().
setVisibilityLevel
(
"11"
);
}
catch
(
Exception
e
)
{
throw
e
;
}
}
BioEntityConverterImpl
rc
=
new
BioEntityConverterImpl
(
reaction
,
false
,
colorExtractor
);
rc
.
draw
(
reaction
,
graphics
,
new
ConverterParams
().
nested
(
true
).
level
(
10
));
@Test
public
void
testDrawAliasWithGlyph
()
throws
Exception
{
try
{
BufferedImage
bi
=
new
BufferedImage
(
200
,
200
,
BufferedImage
.
TYPE_INT_ARGB
);
Graphics2D
graphics
=
Mockito
.
spy
(
bi
.
createGraphics
());
verify
(
graphics
,
times
(
0
)).
draw
(
any
(
GeneralPath
.
class
));
GenericProtein
alias
=
createProtein
();
Glyph
glyph
=
new
Glyph
();
UploadedFileEntry
file
=
new
UploadedFileEntry
();
file
.
setOriginalFileName
(
"test"
);
byte
[]
fileContent
=
Files
.
readAllBytes
(
new
File
(
"testFiles/glyph.png"
).
toPath
());
}
catch
(
Exception
e
)
{
throw
e
;
}
}
file
.
setFileContent
(
fileContent
);
glyph
.
setFile
(
file
);
alias
.
setGlyph
(
glyph
);
BioEntityConverterImpl
converter
=
new
BioEntityConverterImpl
(
alias
,
false
,
colorExtractor
);
converter
.
draw
(
alias
,
graphics
,
new
ConverterParams
());
@Test
public
void
testDrawReactionWithSemanticZoomingAndProductOff
()
throws
Exception
{
try
{
Graphics2D
graphics
=
Mockito
.
mock
(
Graphics2D
.
class
);
Reaction
reaction
=
createReaction
(
1.0
);
reaction
.
getProducts
().
get
(
0
).
getElement
().
setVisibilityLevel
(
"11"
);
BioEntityConverterImpl
rc
=
new
BioEntityConverterImpl
(
reaction
,
false
,
colorExtractor
);
rc
.
draw
(
reaction
,
graphics
,
new
ConverterParams
().
nested
(
true
).
level
(
10
));
verify
(
graphics
,
times
(
1
)).
drawImage
(
any
(
Image
.
class
),
anyInt
(),
anyInt
(),
anyInt
(),
anyInt
(),
anyInt
(),
anyInt
(),
anyInt
(),
anyInt
(),
nullable
(
ImageObserver
.
class
));
verify
(
graphics
,
times
(
0
)).
draw
(
any
(
GeneralPath
.
class
));
}
catch
(
Exception
e
)
{
throw
e
;
}
}
}
catch
(
Exception
e
)
{
throw
e
;
}
}
private
Reaction
createReaction
(
double
lineWidth
)
{
Reaction
result
=
new
Reaction
();
private
Reaction
createReaction
(
double
lineWidth
)
{
Reaction
result
=
new
Reaction
();
Modifier
modifier
=
new
Catalysis
(
new
GenericProtein
(
"s1"
));
modifier
.
setLine
(
new
PolylineData
(
new
Point2D
.
Double
(
100
,
20
),
new
Point2D
.
Double
(
100
,
80
)));
modifier
.
getLine
().
setWidth
(
lineWidth
);
Modifier
modifier
=
new
Catalysis
(
new
GenericProtein
(
"s1"
));
modifier
.
setLine
(
new
PolylineData
(
new
Point2D
.
Double
(
100
,
20
),
new
Point2D
.
Double
(
100
,
80
)));
modifier
.
getLine
().
setWidth
(
lineWidth
);
Reactant
reactant
=
new
Reactant
(
new
GenericProtein
(
"s2"
));
reactant
.
setLine
(
new
PolylineData
(
new
Point2D
.
Double
(
90
,
90
),
new
Point2D
.
Double
(
10
,
90
)));
reactant
.
getLine
().
setWidth
(
lineWidth
);
Product
product
=
new
Product
(
new
GenericProtein
(
"s3"
));
product
.
setLine
(
new
PolylineData
(
new
Point2D
.
Double
(
200
,
90
),
new
Point2D
.
Double
(
110
,
90
)));
product
.
getLine
().
setWidth
(
lineWidth
);
result
.
addModifier
(
modifier
);
result
.
addProduct
(
product
);
result
.
addReactant
(
reactant
);
return
result
;
}
Reactant
reactant
=
new
Reactant
(
new
GenericProtein
(
"s2"
));
reactant
.
setLine
(
new
PolylineData
(
new
Point2D
.
Double
(
90
,
90
),
new
Point2D
.
Double
(
10
,
90
)));
reactant
.
getLine
().
setWidth
(
lineWidth
);
Product
product
=
new
Product
(
new
GenericProtein
(
"s3"
));
product
.
setLine
(
new
PolylineData
(
new
Point2D
.
Double
(
200
,
90
),
new
Point2D
.
Double
(
110
,
90
)));
product
.
getLine
().
setWidth
(
lineWidth
);
result
.
addModifier
(
modifier
);
result
.
addProduct
(
product
);
result
.
addReactant
(
reactant
);
return
result
;
}
}
converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/SpeciesConverterTest.java
View file @
33b5a143
...
...
@@ -33,6 +33,7 @@ import org.mockito.Mockito;
import
lcsb.mapviewer.commands.ColorExtractor
;
import
lcsb.mapviewer.converter.graphics.ConverterParams
;
import
lcsb.mapviewer.converter.graphics.GraphicsTestFunctions
;
import
lcsb.mapviewer.converter.graphics.geometry.ArrowTransformation
;
import
lcsb.mapviewer.model.cache.UploadedFileEntry
;
import
lcsb.mapviewer.model.map.layout.ColorSchema
;
...
...
@@ -49,7 +50,7 @@ import lcsb.mapviewer.model.map.species.field.RegulatoryRegion;
import
lcsb.mapviewer.model.map.species.field.Residue
;
import
lcsb.mapviewer.model.map.species.field.TranscriptionSite
;
public
class
SpeciesConverterTest
{
public
class
SpeciesConverterTest
extends
GraphicsTestFunctions
{
Logger
logger
=
Logger
.
getLogger
(
SpeciesConverterTest
.
class
);
ColorExtractor
colorExtractor
=
new
ColorExtractor
(
Color
.
RED
,
Color
.
GREEN
,
Color
.
BLUE
);
...
...
@@ -405,15 +406,4 @@ public class SpeciesConverterTest {
}
}
private
GenericProtein
createProtein
()
{
GenericProtein
protein
=
new
GenericProtein
(
"id"
);
protein
.
setName
(
"NAME_OF_THE_ELEMENT"
);
protein
.
setX
(
10
);
protein
.
setY
(
20
);
protein
.
setWidth
(
100
);
protein
.
setHeight
(
80
);
protein
.
setColor
(
Color
.
WHITE
);
return
protein
;
}
}
model/src/main/java/lcsb/mapviewer/model/map/layout/graphics/Glyph.java
View file @
33b5a143
...
...
@@ -73,7 +73,7 @@ public class Glyph implements Serializable {
*/
public
Glyph
(
Glyph
original
)
{
// we should reference to the same file
setFile
(
file
);
setFile
(
original
.
getFile
()
);
}
public
UploadedFileEntry
getFile
()
{
...
...
model/src/main/java/lcsb/mapviewer/model/map/species/Element.java
View file @
33b5a143
...
...
@@ -302,7 +302,9 @@ public abstract class Element implements BioEntity, Serializable, SbmlArgument {
this
.
formula
=
original
.
getFormula
();
setVisibilityLevel
(
original
.
getVisibilityLevel
());
setTransparencyLevel
(
original
.
getTransparencyLevel
());
setGlyph
(
new
Glyph
(
original
.
getGlyph
()));
if
(
original
.
getGlyph
()
!=
null
)
{
setGlyph
(
new
Glyph
(
original
.
getGlyph
()));
}
}
/**
...
...
model/src/test/java/lcsb/mapviewer/model/map/species/ElementTest.java
View file @
33b5a143
...
...
@@ -130,6 +130,18 @@ public class ElementTest extends ModelTestFunctions {
}
}
@Test
public
void
testCopyWithoutGlyph
()
{
try
{
GenericProtein
protein
=
new
GenericProtein
();
Element
copy
=
new
GenericProtein
(
protein
);
assertNull
(
copy
.
getGlyph
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
@Test
public
void
testIncreaseBorder
()
{
try
{
...
...
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