Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Simonstrator
PeerfactSim.KOM
Commits
1a52704a
Commit
1a52704a
authored
Oct 11, 2016
by
Björn Richerzhagen
Browse files
Removed some resource-hungry map repainting
parent
701b08e7
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/topology/movement/modularosm/mapvisualization/ShowMapQuestMapViz.java
View file @
1a52704a
...
...
@@ -24,6 +24,7 @@ import java.awt.AlphaComposite;
import
java.awt.Graphics
;
import
java.awt.Graphics2D
;
import
java.awt.Image
;
import
java.awt.MediaTracker
;
import
java.awt.RenderingHints
;
import
java.awt.Toolkit
;
import
java.awt.image.BufferedImage
;
...
...
@@ -47,6 +48,8 @@ public class ShowMapQuestMapViz extends JComponent
private
String
mapType
;
private
String
mapQuestKey
;
private
BufferedImage
background
=
null
;
private
boolean
initialized
=
false
;
...
...
@@ -96,6 +99,24 @@ public class ShowMapQuestMapViz extends JComponent
}
}
initialized
=
true
;
// Create a media tracker and add the image to it. If we had several
// images to load, they could all be added to the same media tracker.
MediaTracker
tracker
=
new
MediaTracker
(
this
);
Image
image
=
Toolkit
.
getDefaultToolkit
().
getImage
(
tempImageFilePath
);
tracker
.
addImage
(
image
,
0
);
// Start downloading the image and wait until it finishes loading.
try
{
tracker
.
waitForAll
();
}
catch
(
InterruptedException
e
)
{
// help?
}
background
=
resize
(
Toolkit
.
getDefaultToolkit
().
getImage
(
tempImageFilePath
),
VisualizationInjector
.
getWorldX
(),
VisualizationInjector
.
getWorldY
());
}
}
...
...
@@ -109,11 +130,9 @@ public class ShowMapQuestMapViz extends JComponent
RenderingHints
.
VALUE_ANTIALIAS_ON
);
g2
.
setComposite
(
AlphaComposite
.
getInstance
(
AlphaComposite
.
SRC_OVER
,
0.6f
));
Image
imageToDraw
=
resize
(
Toolkit
.
getDefaultToolkit
().
getImage
(
tempImageFilePath
),
VisualizationInjector
.
getWorldX
(),
VisualizationInjector
.
getWorldY
());
g2
.
drawImage
(
imageToDraw
,
0
,
0
,
this
);
if
(
background
!=
null
)
{
g2
.
drawImage
(
background
,
0
,
0
,
this
);
}
}
public
void
setTempImageFilePath
(
String
tempImageFilePath
)
{
...
...
@@ -135,7 +154,7 @@ public class ShowMapQuestMapViz extends JComponent
* @param width
* @param height
*/
private
Image
resize
(
Image
originalImage
,
int
width
,
int
height
)
{
private
Buffered
Image
resize
(
Image
originalImage
,
int
width
,
int
height
)
{
int
type
=
BufferedImage
.
TYPE_INT_ARGB
;
BufferedImage
resizedImage
=
new
BufferedImage
(
width
,
height
,
type
);
Graphics2D
g
=
resizedImage
.
createGraphics
();
...
...
src/de/tud/kom/p2psim/impl/topology/views/VisualizationTopologyView.java
View file @
1a52704a
...
...
@@ -432,7 +432,7 @@ public class VisualizationTopologyView extends JFrame
Graphics2D
g2
=
(
Graphics2D
)
g
;
g2
.
setRenderingHint
(
RenderingHints
.
KEY_ANTIALIASING
,
RenderingHints
.
VALUE_ANTIALIAS_ON
);
paintPlayingFieldBorder
(
g2
);
//
paintPlayingFieldBorder(g2);
paintNodes
(
g2
);
super
.
paintComponent
(
g
);
}
...
...
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