Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
minerva
core
Commits
21b28450
Commit
21b28450
authored
May 10, 2019
by
Piotr Gawron
Browse files
drawing of glyphs implemented
parent
e4ea5135
Changes
27
Hide whitespace changes
Inline
Side-by-side
converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/BioEntityConverter.java
View file @
21b28450
...
...
@@ -72,6 +72,22 @@ public abstract class BioEntityConverter<T extends BioEntity> {
draw
(
bioEntity
,
graphics
,
params
,
new
ArrayList
<>());
}
/**
* This function draw {@link BioEntity} on the {@link Graphics2D} object.
*
* @param bioEntity
* {@link BioEntity} that should be drawn
* @param graphics
* where we want to draw bioEntity
* @param params
* visualization params (like, should the object be filled with solid
* color, etc.), for more information see {@link ConverterParams}
* @throws DrawingException
* thrown when there is a problem with drawing {@link BioEntity}
*
*/
protected
abstract
void
drawImpl
(
T
bioEntity
,
Graphics2D
graphics
,
ConverterParams
params
)
throws
DrawingException
;
/**
* This function draw representation of the alias on the graphics object.
*
...
...
@@ -90,7 +106,7 @@ public abstract class BioEntityConverter<T extends BioEntity> {
* thrown when there is a problem with drawing {@link BioEntity}
*
*/
p
ublic
abstract
void
draw
(
T
bioEntity
,
Graphics2D
graphics
,
ConverterParams
params
,
p
rotected
abstract
void
draw
(
T
bioEntity
,
Graphics2D
graphics
,
ConverterParams
params
,
List
<
ColorSchema
>
visualizedOverlaysColorSchemas
)
throws
DrawingException
;
...
...
converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/BioEntityConverterImpl.java
View file @
21b28450
...
...
@@ -199,4 +199,10 @@ public class BioEntityConverterImpl extends BioEntityConverter<BioEntity> {
}
}
@SuppressWarnings
(
"unchecked"
)
@Override
protected
void
drawImpl
(
BioEntity
bioEntity
,
Graphics2D
graphics
,
ConverterParams
params
)
throws
DrawingException
{
elementConverter
.
draw
(
bioEntity
,
graphics
,
params
);
}
}
converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/ElementConverter.java
View file @
21b28450
package
lcsb.mapviewer.converter.graphics.bioEntity.element
;
import
java.awt.Graphics2D
;
import
java.awt.Image
;
import
java.io.ByteArrayInputStream
;
import
java.io.IOException
;
import
javax.imageio.ImageIO
;
import
lcsb.mapviewer.converter.graphics.ConverterParams
;
import
lcsb.mapviewer.converter.graphics.DrawingException
;
import
lcsb.mapviewer.converter.graphics.bioEntity.BioEntityConverter
;
import
lcsb.mapviewer.model.map.layout.graphics.Glyph
;
import
lcsb.mapviewer.model.map.species.Element
;
/**
...
...
@@ -14,4 +24,37 @@ import lcsb.mapviewer.model.map.species.Element;
*/
public
abstract
class
ElementConverter
<
T
extends
Element
>
extends
BioEntityConverter
<
T
>
{
@Override
public
final
void
draw
(
T
bioEntity
,
Graphics2D
graphics
,
ConverterParams
params
)
throws
DrawingException
{
if
(
bioEntity
.
getGlyph
()
!=
null
)
{
drawGlyph
(
bioEntity
,
graphics
);
}
else
{
super
.
draw
(
bioEntity
,
graphics
,
params
);
}
}
/**
* Draws a {@link Glyph} for given bioEntity.
*
* @param bioEntity
* element that should be visualized as a {@link Glyph}
* @param graphics
* {@link Graphics2D} where we are drawing
* @throws DrawingException
* thrown when there is a problem with drawing
*/
private
void
drawGlyph
(
T
bioEntity
,
Graphics2D
graphics
)
throws
DrawingException
{
try
{
Image
img
=
ImageIO
.
read
(
new
ByteArrayInputStream
(
bioEntity
.
getGlyph
().
getFile
().
getFileContent
()));
graphics
.
drawImage
(
img
,
bioEntity
.
getX
().
intValue
(),
bioEntity
.
getY
().
intValue
(),
(
int
)
(
bioEntity
.
getX
()
+
bioEntity
.
getWidth
()),
(
int
)
(
bioEntity
.
getY
()
+
bioEntity
.
getHeight
()),
0
,
0
,
img
.
getWidth
(
null
),
img
.
getHeight
(
null
),
null
);
}
catch
(
IOException
e
)
{
throw
new
DrawingException
(
"Problem with processing glyph file: "
+
bioEntity
.
getGlyph
().
getFile
().
getOriginalFileName
(),
e
);
}
}
}
converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/BottomSquareCompartmentConverter.java
View file @
21b28450
...
...
@@ -45,7 +45,7 @@ public class BottomSquareCompartmentConverter extends CompartmentConverter<Botto
}
@Override
p
ublic
void
draw
(
final
BottomSquareCompartment
compartment
,
final
Graphics2D
graphics
,
final
ConverterParams
params
)
throws
DrawingException
{
p
rotected
void
draw
Impl
(
final
BottomSquareCompartment
compartment
,
final
Graphics2D
graphics
,
final
ConverterParams
params
)
throws
DrawingException
{
// keep the old values of colors and line
Color
oldColor
=
graphics
.
getColor
();
Stroke
oldStroke
=
graphics
.
getStroke
();
...
...
converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/CompartmentConverter.java
View file @
21b28450
...
...
@@ -179,7 +179,7 @@ public abstract class CompartmentConverter<T extends Compartment> extends Elemen
@Override
public
void
draw
(
T
alias
,
Graphics2D
graphics
,
ConverterParams
params
,
List
<
ColorSchema
>
visualizedLayoutsColorSchemas
)
throws
DrawingException
{
draw
(
alias
,
graphics
,
params
);
draw
Impl
(
alias
,
graphics
,
params
);
Color
oldColor
=
graphics
.
getColor
();
int
count
=
0
;
...
...
converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/LeftSquareCompartmentConverter.java
View file @
21b28450
...
...
@@ -45,7 +45,7 @@ public class LeftSquareCompartmentConverter extends CompartmentConverter<LeftSqu
}
@Override
p
ublic
void
draw
(
final
LeftSquareCompartment
compartment
,
final
Graphics2D
graphics
,
final
ConverterParams
params
)
throws
DrawingException
{
p
rotected
void
draw
Impl
(
final
LeftSquareCompartment
compartment
,
final
Graphics2D
graphics
,
final
ConverterParams
params
)
throws
DrawingException
{
// keep the old values of color and line type
Color
oldColor
=
graphics
.
getColor
();
Stroke
oldStroke
=
graphics
.
getStroke
();
...
...
converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/OvalCompartmentConverter.java
View file @
21b28450
...
...
@@ -48,7 +48,7 @@ public class OvalCompartmentConverter extends CompartmentConverter<OvalCompartme
}
@Override
p
ublic
void
draw
(
final
OvalCompartment
compartment
,
final
Graphics2D
graphics
,
final
ConverterParams
params
)
throws
DrawingException
{
p
rotected
void
draw
Impl
(
final
OvalCompartment
compartment
,
final
Graphics2D
graphics
,
final
ConverterParams
params
)
throws
DrawingException
{
// keep the old values of color and line type
Color
oldColor
=
graphics
.
getColor
();
Stroke
oldStroke
=
graphics
.
getStroke
();
...
...
converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/PathwayCompartmentConverter.java
View file @
21b28450
...
...
@@ -36,7 +36,7 @@ public class PathwayCompartmentConverter extends CompartmentConverter<PathwayCom
}
@Override
p
ublic
void
draw
(
final
PathwayCompartment
compartment
,
final
Graphics2D
graphics
,
final
ConverterParams
params
)
p
rotected
void
draw
Impl
(
final
PathwayCompartment
compartment
,
final
Graphics2D
graphics
,
final
ConverterParams
params
)
throws
DrawingException
{
// keep the old values of colors and line
Color
oldColor
=
graphics
.
getColor
();
...
...
converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/RightSquareCompartmentConverter.java
View file @
21b28450
...
...
@@ -45,7 +45,7 @@ public class RightSquareCompartmentConverter extends CompartmentConverter<RightS
}
@Override
p
ublic
void
draw
(
final
RightSquareCompartment
compartment
,
final
Graphics2D
graphics
,
final
ConverterParams
params
)
throws
DrawingException
{
p
rotected
void
draw
Impl
(
final
RightSquareCompartment
compartment
,
final
Graphics2D
graphics
,
final
ConverterParams
params
)
throws
DrawingException
{
// keep the old values of color and line type
Color
oldColor
=
graphics
.
getColor
();
Stroke
oldStroke
=
graphics
.
getStroke
();
...
...
converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/SquareCompartmentConverter.java
View file @
21b28450
...
...
@@ -61,7 +61,7 @@ public class SquareCompartmentConverter extends CompartmentConverter<SquareCompa
}
@Override
p
ublic
void
draw
(
final
SquareCompartment
compartment
,
final
Graphics2D
graphics
,
final
ConverterParams
params
)
throws
DrawingException
{
p
rotected
void
draw
Impl
(
final
SquareCompartment
compartment
,
final
Graphics2D
graphics
,
final
ConverterParams
params
)
throws
DrawingException
{
// keep the old values of color and line type
Color
oldColor
=
graphics
.
getColor
();
Stroke
oldStroke
=
graphics
.
getStroke
();
...
...
converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/compartment/TopSquareCompartmentConverter.java
View file @
21b28450
...
...
@@ -45,7 +45,7 @@ public class TopSquareCompartmentConverter extends CompartmentConverter<TopSquar
}
@Override
p
ublic
void
draw
(
final
TopSquareCompartment
compartment
,
final
Graphics2D
graphics
,
final
ConverterParams
params
)
throws
DrawingException
{
p
rotected
void
draw
Impl
(
final
TopSquareCompartment
compartment
,
final
Graphics2D
graphics
,
final
ConverterParams
params
)
throws
DrawingException
{
Color
oldColor
=
graphics
.
getColor
();
Stroke
oldStroke
=
graphics
.
getStroke
();
...
...
converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/AntisenseRnaConverter.java
View file @
21b28450
...
...
@@ -44,7 +44,7 @@ public class AntisenseRnaConverter extends SpeciesConverter<AntisenseRna> {
}
@Override
p
ublic
void
draw
(
final
AntisenseRna
antisenseRna
,
final
Graphics2D
graphics
,
final
ConverterParams
params
)
{
p
rotected
void
draw
Impl
(
final
AntisenseRna
antisenseRna
,
final
Graphics2D
graphics
,
final
ConverterParams
params
)
{
GeneralPath
path
=
getAntisenseRnaPath
(
antisenseRna
);
Color
c
=
graphics
.
getColor
();
graphics
.
setColor
(
antisenseRna
.
getColor
());
...
...
converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/ComplexConverter.java
View file @
21b28450
...
...
@@ -57,7 +57,7 @@ public class ComplexConverter extends SpeciesConverter<Complex> {
}
@Override
p
ublic
void
draw
(
final
Complex
alias
,
final
Graphics2D
graphics
,
final
ConverterParams
params
)
{
p
rotected
void
draw
Impl
(
final
Complex
alias
,
final
Graphics2D
graphics
,
final
ConverterParams
params
)
{
if
(
alias
.
getState
().
equalsIgnoreCase
(
"complexnoborder"
))
{
return
;
}
...
...
converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/DegradedConverter.java
View file @
21b28450
...
...
@@ -49,7 +49,7 @@ public class DegradedConverter extends SpeciesConverter<Degraded> {
}
@Override
p
ublic
void
draw
(
final
Degraded
degraded
,
final
Graphics2D
graphics
,
final
ConverterParams
params
)
{
p
rotected
void
draw
Impl
(
final
Degraded
degraded
,
final
Graphics2D
graphics
,
final
ConverterParams
params
)
{
double
diameter
=
getDiameter
(
degraded
);
double
x
=
getXCoord
(
degraded
,
diameter
);
double
y
=
getYCoord
(
degraded
);
...
...
converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/DrugConverter.java
View file @
21b28450
...
...
@@ -67,7 +67,7 @@ public class DrugConverter extends SpeciesConverter<Drug> {
}
@Override
p
ublic
void
draw
(
Drug
drug
,
final
Graphics2D
graphics
,
final
ConverterParams
params
)
{
p
rotected
void
draw
Impl
(
Drug
drug
,
final
Graphics2D
graphics
,
final
ConverterParams
params
)
{
Shape
a1
=
getDrugShape
(
drug
);
double
offset
=
OFFSET_BETWEEN_BORDERS
;
Shape
a2
=
new
RoundRectangle2D
.
Double
(
...
...
converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/GeneConverter.java
View file @
21b28450
...
...
@@ -43,7 +43,7 @@ public class GeneConverter extends SpeciesConverter<Gene> {
}
@Override
p
ublic
void
draw
(
final
Gene
gene
,
final
Graphics2D
graphics
,
final
ConverterParams
params
)
{
p
rotected
void
draw
Impl
(
final
Gene
gene
,
final
Graphics2D
graphics
,
final
ConverterParams
params
)
{
Shape
shape
=
getGeneShape
(
gene
);
Color
c
=
graphics
.
getColor
();
graphics
.
setColor
(
gene
.
getColor
());
...
...
converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/IonConverter.java
View file @
21b28450
...
...
@@ -42,7 +42,7 @@ public class IonConverter extends SpeciesConverter<Ion> {
}
@Override
p
ublic
void
draw
(
Ion
ion
,
final
Graphics2D
graphics
,
final
ConverterParams
params
)
{
p
rotected
void
draw
Impl
(
Ion
ion
,
final
Graphics2D
graphics
,
final
ConverterParams
params
)
{
double
diameter
=
getDiameter
(
ion
);
double
x
=
getXCoord
(
ion
,
diameter
);
double
y
=
getYCoord
(
ion
);
...
...
converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/PhenotypeConverter.java
View file @
21b28450
...
...
@@ -42,7 +42,7 @@ public class PhenotypeConverter extends SpeciesConverter<Phenotype> {
}
@Override
p
ublic
void
draw
(
Phenotype
phenotype
,
final
Graphics2D
graphics
,
final
ConverterParams
params
)
{
p
rotected
void
draw
Impl
(
Phenotype
phenotype
,
final
Graphics2D
graphics
,
final
ConverterParams
params
)
{
GeneralPath
path
=
getPhenotypePath
(
phenotype
);
Color
c
=
graphics
.
getColor
();
...
...
converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/ProteinConverter.java
View file @
21b28450
...
...
@@ -87,7 +87,7 @@ public class ProteinConverter extends SpeciesConverter<Protein> {
}
@Override
p
ublic
void
draw
(
final
Protein
protein
,
final
Graphics2D
graphics
,
final
ConverterParams
params
)
{
p
rotected
void
draw
Impl
(
final
Protein
protein
,
final
Graphics2D
graphics
,
final
ConverterParams
params
)
{
// Local variable setting the SBGN visualization
boolean
sbgnFormat
=
params
.
isSbgnFormat
();
...
...
converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/RnaConverter.java
View file @
21b28450
...
...
@@ -50,7 +50,7 @@ public class RnaConverter extends SpeciesConverter<Rna> {
}
@Override
p
ublic
void
draw
(
final
Rna
rna
,
final
Graphics2D
graphics
,
final
ConverterParams
params
)
{
p
rotected
void
draw
Impl
(
final
Rna
rna
,
final
Graphics2D
graphics
,
final
ConverterParams
params
)
{
GeneralPath
path
=
getRnaPath
(
rna
);
Color
c
=
graphics
.
getColor
();
graphics
.
setColor
(
rna
.
getColor
());
...
...
Prev
1
2
Next
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