Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F121955632
PanelImage.java
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Jul 15, 01:32
Size
1 KB
Mime Type
text/x-java
Expires
Thu, Jul 17, 01:32 (2 d)
Engine
blob
Format
Raw Data
Handle
27417776
Attached To
R2075 deconvolution
PanelImage.java
View Options
package
bilib.component
;
import
java.awt.Color
;
import
java.awt.Graphics
;
import
java.awt.Image
;
import
java.awt.image.BufferedImage
;
import
javax.swing.JPanel
;
import
deconvolutionlab.splash.ImageLoader
;
public
class
PanelImage
extends
JPanel
{
private
Image
image
;
private
int
w
=
-
1
;
private
int
h
=
-
1
;
public
PanelImage
()
{
super
();
}
public
PanelImage
(
String
filename
)
{
super
();
image
=
ImageLoader
.
get
(
filename
);
}
public
PanelImage
(
int
w
,
int
h
)
{
super
();
image
=
null
;
this
.
w
=
w
;
this
.
h
=
h
;
}
public
PanelImage
(
String
filename
,
int
w
,
int
h
)
{
super
();
image
=
ImageLoader
.
get
(
filename
);
this
.
w
=
w
;
this
.
h
=
h
;
}
public
void
setImage
(
BufferedImage
image
)
{
this
.
image
=
image
;
repaint
();
}
@Override
protected
void
paintComponent
(
Graphics
g
)
{
super
.
paintComponent
(
g
);
if
(
image
!=
null
)
{
if
(
w
<
0
)
g
.
drawImage
(
image
,
0
,
0
,
getWidth
(),
getHeight
(),
null
);
else
{
g
.
setColor
(
Color
.
WHITE
);
g
.
fillRect
(
0
,
0
,
getWidth
(),
getHeight
());
g
.
drawImage
(
image
,
(
getWidth
()-
w
)/
2
,
0
,
w
,
h
,
null
);
}
}
else
{
g
.
setColor
(
Color
.
DARK_GRAY
);
g
.
fillRect
(
0
,
0
,
getWidth
(),
getHeight
());
}
}
}
Event Timeline
Log In to Comment