Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
minerva
core
Commits
ca1b6c27
Commit
ca1b6c27
authored
7 years ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
code for generating scale image
parent
1a31b6c4
No related branches found
No related tags found
1 merge request
!110
uploading of big data overlay gives proper error message
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/ConverterTest.java
+46
-0
46 additions, 0 deletions
...java/lcsb/mapviewer/converter/graphics/ConverterTest.java
with
46 additions
and
0 deletions
converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/ConverterTest.java
+
46
−
0
View file @
ca1b6c27
package
lcsb.mapviewer.converter.graphics
;
package
lcsb.mapviewer.converter.graphics
;
import
java.awt.Color
;
import
java.awt.Color
;
import
java.awt.Desktop
;
import
java.awt.Graphics2D
;
import
java.awt.image.BufferedImage
;
import
java.io.File
;
import
java.io.IOException
;
import
javax.imageio.ImageIO
;
import
org.junit.After
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Before
;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
org.junit.Test
;
import
lcsb.mapviewer.commands.ColorExtractor
;
import
lcsb.mapviewer.commands.ColorExtractor
;
...
@@ -37,4 +45,42 @@ public class ConverterTest {
...
@@ -37,4 +45,42 @@ public class ConverterTest {
}
}
}
}
@Test
@Ignore
(
"it's just code for generating scale"
)
public
void
testX
()
throws
IOException
{
BufferedImage
tmpBI
=
new
BufferedImage
(
900
,
100
,
BufferedImage
.
TYPE_INT_ARGB
);
Graphics2D
tmpGraphics
=
tmpBI
.
createGraphics
();
int
startX
=
10
;
int
startY
=
15
;
int
stepSize
=
40
;
int
height
=
25
;
tmpGraphics
.
setColor
(
Color
.
BLACK
);
for
(
int
i
=
0
;
i
<
21
;
i
++)
{
tmpGraphics
.
drawLine
(
startX
+
i
*
stepSize
,
height
+
startY
,
startX
+
i
*
stepSize
,
height
*
2
);
String
str
=
""
+((
double
)(
i
-
10
))/((
double
)(
10
));
tmpGraphics
.
drawString
(
str
,
startX
+
i
*
stepSize
,
height
*
2
+
startY
);
}
for
(
int
i
=
0
;
i
<
10
*
stepSize
;
i
++)
{
double
ratio
=
((
double
)
i
)
/
((
double
)
(
10
*
stepSize
));
tmpGraphics
.
setBackground
(
getColor
(
ratio
,
Color
.
BLUE
,
Color
.
WHITE
));
tmpGraphics
.
setColor
(
getColor
(
ratio
,
Color
.
BLUE
,
Color
.
WHITE
));
tmpGraphics
.
drawRect
(
startX
+
i
,
startY
,
1
,
height
);
}
for
(
int
i
=
0
;
i
<
10
*
stepSize
;
i
++)
{
double
ratio
=
((
double
)
i
)
/
((
double
)
(
10
*
stepSize
));
tmpGraphics
.
setBackground
(
getColor
(
ratio
,
Color
.
WHITE
,
Color
.
RED
));
tmpGraphics
.
setColor
(
getColor
(
ratio
,
Color
.
WHITE
,
Color
.
RED
));
tmpGraphics
.
drawRect
(
10
*
stepSize
+
startX
+
i
,
startY
,
1
,
height
);
}
ImageIO
.
write
(
tmpBI
,
"PNG"
,
new
File
(
"tmp.png"
));
Desktop
.
getDesktop
().
open
(
new
File
(
"tmp.png"
));
}
private
Color
getColor
(
double
d
,
Color
startColor
,
Color
endColor
)
{
return
new
Color
((
int
)
(
startColor
.
getRed
()
+
d
*
(
endColor
.
getRed
()
-
startColor
.
getRed
())),
//
(
int
)
(
startColor
.
getGreen
()
+
d
*
(
endColor
.
getGreen
()
-
startColor
.
getGreen
())),
//
(
int
)
(
startColor
.
getBlue
()
+
d
*
(
endColor
.
getBlue
()
-
startColor
.
getBlue
())));
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment