Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DocExplore
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexander BURNETT
DocExplore
Commits
410bfb99
Commit
410bfb99
authored
6 years ago
by
aburn
Browse files
Options
Downloads
Patches
Plain Diff
Added image editor for ROIs in AT
parent
d3001bd5
Branches
Branches containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/org/interreg/docexplore/authoring/rois/ImageElement.java
+60
-53
60 additions, 53 deletions
src/org/interreg/docexplore/authoring/rois/ImageElement.java
with
60 additions
and
53 deletions
src/org/interreg/docexplore/authoring/rois/ImageElement.java
+
60
−
53
View file @
410bfb99
...
...
@@ -12,58 +12,65 @@ In this respect, the user's attention is drawn to the risks associated with load
The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms.
*/
package
org.interreg.docexplore.authoring.rois
;
import
java.awt.Color
;
import
java.awt.Dimension
;
package
org.interreg.docexplore.authoring.rois
;
import
java.awt.Color
;
import
java.awt.Dimension
;
import
java.awt.Graphics
;
import
java.awt.image.BufferedImage
;
import
javax.swing.JLabel
;
import
org.interreg.docexplore.manuscript.MetaData
;
@SuppressWarnings
(
"serial"
)
public
class
ImageElement
extends
InfoElement
{
BufferedImage
image
;
public
ImageElement
(
RegionSidePanel
editor
,
int
width
,
MetaData
md
)
throws
Exception
{
super
(
editor
,
md
);
image
=
md
.
getImage
();
JLabel
canvas
=
new
JLabel
()
{
public
void
paintComponent
(
Graphics
g
)
{
g
.
drawImage
(
image
,
0
,
0
,
getWidth
(),
getHeight
(),
0
,
0
,
image
.
getWidth
(),
image
.
getHeight
(),
null
);
}
};
import
java.awt.event.MouseAdapter
;
import
java.awt.event.MouseEvent
;
import
java.awt.image.BufferedImage
;
import
javax.swing.JLabel
;
import
org.interreg.docexplore.manuscript.MetaData
;
@SuppressWarnings
(
"serial"
)
public
class
ImageElement
extends
InfoElement
{
BufferedImage
image
;
public
ImageElement
(
RegionSidePanel
editor
,
int
width
,
MetaData
md
)
throws
Exception
{
super
(
editor
,
md
);
image
=
md
.
getImage
();
JLabel
canvas
=
new
JLabel
()
{
public
void
paintComponent
(
Graphics
g
)
{
g
.
drawImage
(
image
,
0
,
0
,
getWidth
(),
getHeight
(),
0
,
0
,
image
.
getWidth
(),
image
.
getHeight
(),
null
);
}
};
canvas
.
setPreferredSize
(
new
Dimension
(
width
,
(
image
.
getHeight
()*
width
)/
image
.
getWidth
()));
add
(
canvas
);
}
public
int
getReaderWidth
(
int
maxWidth
)
{
if
(
image
.
getWidth
()
>
maxWidth
)
return
maxWidth
;
int
minDim
=
maxWidth
/
3
;
if
(
image
.
getWidth
()
<
minDim
&&
image
.
getHeight
()
<
minDim
)
return
minDim
*
image
.
getWidth
()/
Math
.
max
(
image
.
getWidth
(),
image
.
getHeight
());
return
image
.
getWidth
();
}
public
int
getReaderHeight
(
int
width
)
{
return
image
.
getHeight
()*
width
/
image
.
getWidth
();
}
public
BufferedImage
getPreview
(
int
width
,
Color
back
)
{
int
iw
=
getReaderWidth
(
width
);
int
ih
=
getReaderHeight
(
iw
);
BufferedImage
res
=
new
BufferedImage
(
iw
,
ih
,
BufferedImage
.
TYPE_3BYTE_BGR
);
res
.
createGraphics
().
drawImage
(
image
,
0
,
0
,
iw
,
ih
,
0
,
0
,
image
.
getWidth
(),
image
.
getHeight
(),
null
);
return
res
;
}
}
canvas
.
addMouseListener
(
new
MouseAdapter
()
{
@Override
public
void
mouseClicked
(
MouseEvent
e
)
{
if
(
e
.
getButton
()
==
MouseEvent
.
BUTTON1
&&
e
.
getClickCount
()
==
2
)
editor
.
host
.
addDocument
(
md
,
editor
.
document
);
}});
add
(
canvas
);
}
public
int
getReaderWidth
(
int
maxWidth
)
{
if
(
image
.
getWidth
()
>
maxWidth
)
return
maxWidth
;
int
minDim
=
maxWidth
/
3
;
if
(
image
.
getWidth
()
<
minDim
&&
image
.
getHeight
()
<
minDim
)
return
minDim
*
image
.
getWidth
()/
Math
.
max
(
image
.
getWidth
(),
image
.
getHeight
());
return
image
.
getWidth
();
}
public
int
getReaderHeight
(
int
width
)
{
return
image
.
getHeight
()*
width
/
image
.
getWidth
();
}
public
BufferedImage
getPreview
(
int
width
,
Color
back
)
{
int
iw
=
getReaderWidth
(
width
);
int
ih
=
getReaderHeight
(
iw
);
BufferedImage
res
=
new
BufferedImage
(
iw
,
ih
,
BufferedImage
.
TYPE_3BYTE_BGR
);
res
.
createGraphics
().
drawImage
(
image
,
0
,
0
,
iw
,
ih
,
0
,
0
,
image
.
getWidth
(),
image
.
getHeight
(),
null
);
return
res
;
}
}
This diff is collapsed.
Click to expand it.
Preview
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!
Save comment
Cancel
Please
register
or
sign in
to comment