Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
MultiCube
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lafabregue
MultiCube
Commits
fd114105
Commit
fd114105
authored
Jul 10, 2017
by
coman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pointer image and Zoom
parent
eb90488f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
171 additions
and
69 deletions
+171
-69
resources/icons/icon-pince.png
resources/icons/icon-pince.png
+0
-0
src/mustic/gui/dialog/classifier/ConstraintsSelectionDialog.java
...tic/gui/dialog/classifier/ConstraintsSelectionDialog.java
+171
-69
No files found.
resources/icons/icon-pince.png
0 → 100644
View file @
fd114105
46.3 KB
src/mustic/gui/dialog/classifier/ConstraintsSelectionDialog.java
View file @
fd114105
...
...
@@ -11,7 +11,6 @@ import java.awt.Frame;
import
java.awt.Graphics
;
import
java.awt.Graphics2D
;
import
java.awt.GridLayout
;
import
java.awt.LayoutManager
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionListener
;
import
java.awt.event.FocusEvent
;
...
...
@@ -32,9 +31,8 @@ import java.util.List;
import
java.util.Random
;
import
java.util.Vector
;
import
javax.imageio.ImageIO
;
import
javax.swing.BorderFactory
;
import
javax.swing.Box
;
import
javax.swing.BoxLayout
;
import
javax.swing.ImageIcon
;
import
javax.swing.JButton
;
import
javax.swing.JCheckBox
;
...
...
@@ -92,6 +90,8 @@ public class ConstraintsSelectionDialog extends JInternalFrame {
private
BufferedImage
imagePoints
=
null
;
private
BufferedImage
imageSource
=
null
;
private
BufferedImage
imageSourceTemp
=
null
;
private
JLabel
labelImage
;
...
...
@@ -144,17 +144,19 @@ public class ConstraintsSelectionDialog extends JInternalFrame {
/** Dialog for choosing colors for the constraints*/
JDialog
jd_colorsChooser
;
/** temporary constraints colors */
private
Color
mustLinkColorTemp
;
private
Color
cannotLinkColorTemp
;
private
Vector
<
Color
>
labelConstraintColorTemp
=
new
Vector
<
Color
>();
/** constraints colors */
private
Color
mustLinkColor
=
new
Color
(
124
,
252
,
0
);
private
Color
cannotLinkColor
=
new
Color
(
255
,
0
,
255
);
private
Vector
<
Color
>
labelConstraintColor
=
new
Vector
<
Color
>();
private
Vector
<
BufferedImage
>
imageLabelPixel
=
new
Vector
<
BufferedImage
>();
private
Vector
<
BufferedImage
>
imageLabelPixelTemp
=
new
Vector
<
BufferedImage
>();
/** temporary constraints colors */
private
Color
mustLinkColorTemp
;
private
Color
cannotLinkColorTemp
;
private
Vector
<
Color
>
labelConstraintColorTemp
=
new
Vector
<
Color
>();
/** constraints buttons */
private
JButton
jb_mustLinkChooseColor
=
new
JButton
();
private
JButton
jb_cannotLinkChooseColor
=
new
JButton
();
...
...
@@ -163,6 +165,21 @@ public class ConstraintsSelectionDialog extends JInternalFrame {
/** dynamic JPanel Colors of Label Constraints Classes*/
JPanel
labelColorConstraintPanel
=
new
JPanel
(
new
GridLayout
(
0
,
1
));
/** Images and constraints zoom */
/** Constraints images */
File
inputImage
=
new
File
(
getClass
().
getResource
(
"/icons/icon-pince.png"
).
getFile
());
private
BufferedImage
imagePixel
;
private
BufferedImage
imagePixelML
;
private
BufferedImage
imagePixelCL
;
private
BufferedImage
imagePixelMLTemp
;
private
BufferedImage
imagePixelCLTemp
;
private
BufferedImage
mNew
;
/** Constraints images construction */
private
int
classID
;
private
int
classIndex
;
/**
* Constructor to a dialog window to visualize and build a set of
...
...
@@ -211,8 +228,10 @@ public class ConstraintsSelectionDialog extends JInternalFrame {
-
(
int
)
((
labelImage
.
getWidth
()
-
(
labelImage
.
getIcon
().
getIconWidth
()))
/
2.0
))
/
mZoomRate
);
int
y
=
(
int
)
((
e
.
getY
()
-
(
int
)
((
labelImage
.
getHeight
()
-
(
labelImage
.
getIcon
().
getIconHeight
()))
/
2.0
))
/
mZoomRate
);
if
(
x
>=
0
&&
y
>=
0
&&
x
<
imageSource
.
getWidth
()
*
mZoomRate
&&
y
<
imageSource
.
getHeight
()
*
mZoomRate
)
{
if
(
x
>=
0
&&
y
>=
0
&&
x
<
imageSource
.
getWidth
()
/** mZoomRate*/
&&
y
<
imageSource
.
getHeight
()
/** mZoomRate*/
)
{
switch
(
currentStep
)
{
case
MustLink_step1:
case
CannotLink_step1:
...
...
@@ -277,7 +296,7 @@ public class ConstraintsSelectionDialog extends JInternalFrame {
});
panelButton
.
add
(
exportButton
);
otherComponentList
.
add
(
exportButton
);
JButton
constraintsColorChooser
=
new
JButton
(
"Constraints Colors"
/*
* Messages.getString(
...
...
@@ -292,7 +311,7 @@ public class ConstraintsSelectionDialog extends JInternalFrame {
}
});
panelButton
.
add
(
constraintsColorChooser
);
otherComponentList
.
add
(
constraintsColorChooser
);
initializeConstraintsColors
(
);
JScrollPane
jpane
=
new
JScrollPane
(
panelImage
);
jpane
.
setBorder
(
BorderFactory
.
createTitledBorder
(
Messages
.
getString
(
"ConstraintsSelectionDialog.7"
)));
//$NON-NLS-1$
...
...
@@ -307,13 +326,28 @@ public class ConstraintsSelectionDialog extends JInternalFrame {
setConstraints
(
data
.
getConstraints
(),
false
);
}
// initialize button colors
// add actions for the
// must-link and cannot link
// chooser color buttons
this
.
setContentPane
(
mainPanel
);
this
.
setTitle
(
Messages
.
getString
(
"ConstraintsSelectionDialog.8"
));
//$NON-NLS-1$
this
.
setVisible
(
true
);
}
/**
* Initialize button colors add actions for the
* must-link and cannot link chooser color buttons
*/
private
void
initializeConstraintsColors
()
{
try
{
imagePixel
=
ImageIO
.
read
(
inputImage
);
imagePixelML
=
ImageIO
.
read
(
inputImage
);
imagePixelCL
=
ImageIO
.
read
(
inputImage
);
}
catch
(
IOException
e1
)
{
e1
.
printStackTrace
();
}
jb_mustLinkChooseColor
.
setBackground
(
mustLinkColor
);
jb_cannotLinkChooseColor
.
setBackground
(
cannotLinkColor
);
changeColorPixel
(
imagePixelML
,
mustLinkColor
);
jb_mustLinkChooseColor
.
addActionListener
(
new
ActionListener
()
{
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
...
...
@@ -322,6 +356,7 @@ public class ConstraintsSelectionDialog extends JInternalFrame {
});
changeColorPixel
(
imagePixelCL
,
cannotLinkColor
);
jb_cannotLinkChooseColor
.
addActionListener
(
new
ActionListener
()
{
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
...
...
@@ -339,15 +374,21 @@ public class ConstraintsSelectionDialog extends JInternalFrame {
float
b
=
rand
.
nextFloat
();
labelConstraintColor
.
add
(
new
Color
(
r
,
g
,
b
));
labelConstraintColorTemp
.
add
(
new
Color
(
r
,
g
,
b
));
BufferedImage
copy
=
clone
(
imagePixel
);
imageLabelPixel
.
removeAllElements
();
changeColorPixelLabel
(
copy
,
0
,
labelConstraintColor
);
imageLabelPixel
.
add
(
copy
);
imageLabelPixelTemp
.
add
(
clone
(
imagePixel
));
imagePixelCLTemp
=
clone
(
imagePixel
);
imagePixelMLTemp
=
clone
(
imagePixel
);
jb_labelConstraintClassChooseColor
.
add
(
new
JButton
());
jb_labelConstraintClassChooseColor
.
get
(
0
).
putClientProperty
(
"index"
,
0
);
jb_labelConstraintClassChooseColor
.
get
(
0
).
setBackground
(
labelConstraintColor
.
get
(
0
));
createLabelColorConstraintsPanel
();
this
.
setContentPane
(
mainPanel
);
this
.
setTitle
(
Messages
.
getString
(
"ConstraintsSelectionDialog.8"
));
//$NON-NLS-1$
this
.
setVisible
(
true
);
}
protected
void
exportConstraints
()
{
...
...
@@ -396,8 +437,9 @@ public class ConstraintsSelectionDialog extends JInternalFrame {
e
.
printStackTrace
();
}
}
}
protected
void
importConstraints
()
{
try
{
...
...
@@ -447,7 +489,6 @@ public class ConstraintsSelectionDialog extends JInternalFrame {
classNameButtonPanel
.
add
(
new
JLabel
(
"Class "
+
labelClassesCount
+
":"
));
jb_labelConstraintClassChooseColor
.
get
(
labelClassesCount
-
1
).
addActionListener
(
new
ActionListener
()
{
public
void
actionPerformed
(
ActionEvent
event
)
{
JButton
lblClassColorButtonClicked
=
(
JButton
)
event
.
getSource
();
int
buttonIndex
=
(
int
)
lblClassColorButtonClicked
.
getClientProperty
(
"index"
);
chooseLabelClassColor
(
buttonIndex
);
...
...
@@ -490,29 +531,38 @@ public class ConstraintsSelectionDialog extends JInternalFrame {
clConstraintsPanel
.
add
(
jb_cannotLinkChooseColor
,
BorderLayout
.
CENTER
);
mlclConstraintsPanel
.
add
(
clConstraintsPanel
);
// button panel
JPanel
buttonPanel
=
new
JPanel
();
JButton
ok
=
new
JButton
(
"OK"
);
// update color changes on ok, update only fields that have changed
ok
.
addActionListener
(
new
ActionListener
()
{
@Override
public
void
actionPerformed
(
ActionEvent
event
)
{
if
(
mustLinkColorTemp
!=
null
&&
mustLinkColorTemp
!=
mustLinkColor
){
mustLinkColor
=
mustLinkColorTemp
;
changeColorPixel
(
imagePixelMLTemp
,
mustLinkColor
);
imagePixelML
=
imagePixelMLTemp
;
imagePixelMLTemp
=
ConstraintsSelectionDialog
.
this
.
clone
(
imagePixel
);
}
if
(
cannotLinkColorTemp
!=
null
&&
cannotLinkColorTemp
!=
cannotLinkColor
){
cannotLinkColor
=
cannotLinkColorTemp
;
changeColorPixel
(
imagePixelCLTemp
,
cannotLinkColor
);
imagePixelCL
=
imagePixelCLTemp
;
imagePixelCLTemp
=
ConstraintsSelectionDialog
.
this
.
clone
(
imagePixel
);
}
for
(
int
i
=
0
;
i
<
labelClassesCount
;
i
++){
if
(
labelConstraintColorTemp
.
get
(
i
)
!=
null
&&
labelConstraintColorTemp
.
get
(
i
)
!=
labelConstraintColor
.
get
(
i
)){
labelConstraintColor
.
set
(
i
,
labelConstraintColorTemp
.
get
(
i
));
jb_labelConstraintClassChooseColor
.
get
(
i
).
setBackground
(
labelConstraintColor
.
get
(
i
));
changeColorPixelLabel
(
imageLabelPixelTemp
.
get
(
i
),
i
,
labelConstraintColorTemp
);
imageLabelPixel
.
set
(
i
,
imageLabelPixelTemp
.
get
(
i
));
jb_labelConstraintClassChooseColor
.
get
(
i
).
setBackground
(
labelConstraintColor
.
get
(
i
));
}
}
}
imageLabelPixelTemp
=
new
Vector
<
BufferedImage
>();
for
(
int
i
=
0
;
i
<
labelClassesCount
;
i
++)
{
imageLabelPixelTemp
.
add
(
ConstraintsSelectionDialog
.
this
.
clone
(
imagePixel
));
}
jd_colorsChooser
.
dispose
();
}
});
...
...
@@ -538,7 +588,7 @@ public class ConstraintsSelectionDialog extends JInternalFrame {
jb_mustLinkChooseColor
.
setBackground
(
mustLinkColor
);
jb_cannotLinkChooseColor
.
setBackground
(
cannotLinkColor
);
buttonPanel
.
add
(
ok
);
buttonPanel
.
add
(
cancel
);
...
...
@@ -905,6 +955,8 @@ public class ConstraintsSelectionDialog extends JInternalFrame {
this
.
width
=
img
.
getWidth
();
this
.
imageSource
=
new
BufferedImage
(
img
.
getWidth
(),
img
.
getHeight
(),
BufferedImage
.
TYPE_INT_RGB
);
this
.
imagePoints
=
new
BufferedImage
(
img
.
getWidth
(),
img
.
getHeight
(),
BufferedImage
.
TYPE_INT_RGB
);
this
.
imageSourceTemp
=
new
BufferedImage
(
img
.
getWidth
(),
img
.
getHeight
(),
BufferedImage
.
TYPE_INT_RGB
);
double
data
[][][]
=
img
.
load
(
0
,
0
,
img
.
getWidth
(),
img
.
getHeight
());
double
[]
max
=
new
double
[
data
.
length
];
...
...
@@ -969,9 +1021,12 @@ public class ConstraintsSelectionDialog extends JInternalFrame {
imageSource
.
setRGB
(
x
,
y
,
pixel
);
imagePoints
.
setRGB
(
x
,
y
,
pixel
);
imageSourceTemp
.
setRGB
(
x
,
y
,
pixel
);
}
}
AffineTransform
trans
=
AffineTransform
.
getScaleInstance
(
this
.
mZoomRate
,
this
.
mZoomRate
);
AffineTransformOp
op
=
new
AffineTransformOp
(
trans
,
AffineTransformOp
.
TYPE_NEAREST_NEIGHBOR
);
mNew
=
op
.
filter
(
this
.
imagePoints
,
null
);
this
.
labelImage
.
setIcon
(
new
ImageIcon
(
this
.
imagePoints
));
this
.
image
=
img
;
displayPixels
();
...
...
@@ -1019,11 +1074,13 @@ public class ConstraintsSelectionDialog extends JInternalFrame {
// If a string was returned, say so.
if
((
s
!=
null
)
&&
(
s
.
length
()
>
0
))
{
int
classIndex
=
0
;
classIndex
=
0
;
BufferedImage
copy
;
if
(
s
.
equals
(
Messages
.
getString
(
"ConstraintsSelectionDialog.35"
)))
{
labelClassesCount
++;
//imageCounter = labelClassesCount;
classIndex
=
labelClassesCount
;
// generate a random color for label constraints of the same
// class
Random
rand
=
new
Random
();
...
...
@@ -1032,22 +1089,25 @@ public class ConstraintsSelectionDialog extends JInternalFrame {
float
b
=
rand
.
nextFloat
();
labelConstraintColor
.
add
(
new
Color
(
r
,
g
,
b
));
labelConstraintColorTemp
.
add
(
new
Color
(
r
,
g
,
b
));
// initialize button color linked to the new label class
// constraint
jb_labelConstraintClassChooseColor
.
add
(
new
JButton
());
jb_labelConstraintClassChooseColor
.
get
(
classIndex
-
1
).
putClientProperty
(
"index"
,
classIndex
-
1
);
jb_labelConstraintClassChooseColor
.
get
(
classIndex
-
1
)
.
setBackground
(
labelConstraintColor
.
get
(
classIndex
-
1
));
jb_labelConstraintClassChooseColor
.
get
(
classIndex
-
1
).
setBackground
(
labelConstraintColor
.
get
(
classIndex
-
1
));
createLabelColorConstraintsPanel
();
copy
=
clone
(
imagePixel
);
changeColorPixelLabel
(
copy
,
classIndex
-
1
,
labelConstraintColor
);
imageLabelPixel
.
add
(
copy
);
imageLabelPixelTemp
.
add
(
clone
(
imagePixel
));
}
else
{
classIndex
=
Integer
.
parseInt
(
s
);
}
constraints
.
add
(
new
LabelConstraint
(
index
,
classIndex
));
((
JTextArea
)
constraintsPanels
.
get
(
constraintsPanels
.
size
()
-
1
).
getComponent
(
3
))
.
setText
(
""
+
classIndex
);
}
currentStep
=
-
1
;
enableAllComponents
();
...
...
@@ -1067,44 +1127,46 @@ public class ConstraintsSelectionDialog extends JInternalFrame {
for
(
int
i
=
0
;
i
<
constraints
.
size
();
i
++)
{
if
(
constraints
.
get
(
i
)
instanceof
MustLinkConstraint
)
{
drawPixel
(((
MustLinkConstraint
)
constraints
.
get
(
i
)).
getFirstIndex
(),
mustLinkColor
/* constraintsColors.get(i) */
,
""
);
mustLinkColor
/* constraintsColors.get(i) */
,
""
,
imagePixelML
);
drawPixel
(((
MustLinkConstraint
)
constraints
.
get
(
i
)).
getSecondIndex
(),
mustLinkColor
/* constraintsColors.get(i) */
,
""
);
mustLinkColor
/* constraintsColors.get(i) */
,
""
,
imagePixelML
);
linkPixel
(((
MustLinkConstraint
)
constraints
.
get
(
i
)).
getFirstIndex
(),
((
MustLinkConstraint
)
constraints
.
get
(
i
)).
getSecondIndex
(),
mustLinkColor
/* constraintsColors.get(i) */
,
""
);
}
else
if
(
constraints
.
get
(
i
)
instanceof
CannotLinkConstraint
)
{
drawPixel
(((
CannotLinkConstraint
)
constraints
.
get
(
i
)).
getFirstIndex
(),
cannotLinkColor
/* constraintsColors.get(i) */
,
""
);
cannotLinkColor
/* constraintsColors.get(i) */
,
""
,
imagePixelCL
);
drawPixel
(((
CannotLinkConstraint
)
constraints
.
get
(
i
)).
getSecondIndex
(),
cannotLinkColor
/* constraintsColors.get(i) */
,
""
);
cannotLinkColor
/* constraintsColors.get(i) */
,
""
,
imagePixelCL
);
linkPixel
(((
CannotLinkConstraint
)
constraints
.
get
(
i
)).
getFirstIndex
(),
((
CannotLinkConstraint
)
constraints
.
get
(
i
)).
getSecondIndex
(),
cannotLinkColor
/* constraintsColors.get(i) */
,
""
);
}
else
if
(
constraints
.
get
(
i
)
instanceof
LabelConstraint
)
{
int
classID
=
((
LabelConstraint
)
constraints
.
get
(
i
)).
getClassID
();
drawPixel
(((
LabelConstraint
)
constraints
.
get
(
i
)).
getIndex
(),
labelConstraintColor
.
get
(
classID
-
1
)
/* constraintsColors.get(i) */
,
""
);
}
else
if
(
constraints
.
get
(
i
)
instanceof
LabelConstraint
)
{
classID
=
((
LabelConstraint
)
constraints
.
get
(
i
)).
getClassID
();
drawPixel
(((
LabelConstraint
)
constraints
.
get
(
i
)).
getIndex
(),
labelConstraintColor
.
get
(
classID
-
1
),
""
,
imageLabelPixel
.
get
(
classID
-
1
));
}
}
this
.
labelImage
.
setIcon
(
new
ImageIcon
(
mNew
));
/*if (previousIndex > 0) {
// it matches the last colour added
// TODO remove line
drawPixel(previousIndex, constraintsColors.get(constraintsColors.size() - 1), "");
}*/
this
.
doZoom
Op
();
//this.doZoomed
Op();
}
private
void
linkPixel
(
int
firstIndex
,
int
secondIndex
,
Color
c
,
String
name
)
{
Graphics2D
g
=
(
Graphics2D
)
this
.
imagePoints
.
getGraphics
();
Graphics2D
g
=
(
Graphics2D
)
mNew
.
getGraphics
();
g
.
setStroke
(
new
BasicStroke
(
1.0f
,
BasicStroke
.
CAP_BUTT
,
BasicStroke
.
JOIN_MITER
,
10.0f
,
new
float
[]
{
4
},
0.0f
));
g
.
setColor
(
c
);
int
x1
=
(
firstIndex
%
this
.
width
);
int
y1
=
(
firstIndex
/
this
.
width
);
int
x2
=
(
secondIndex
%
this
.
width
);
int
y2
=
(
secondIndex
/
this
.
width
);
int
x1
=
(
int
)
((
firstIndex
%
this
.
width
)*
mZoomRate
);
int
y1
=
(
int
)
((
firstIndex
/
this
.
width
)*
mZoomRate
);
int
x2
=
(
int
)
((
secondIndex
%
this
.
width
)*
mZoomRate
);
int
y2
=
(
int
)
((
secondIndex
/
this
.
width
)*
mZoomRate
);
g
.
drawString
(
name
,
x1
+
4
,
y1
-
4
);
// $NON-NLS-1$
g
.
drawLine
(
x1
,
y1
,
x2
,
y2
);
}
...
...
@@ -1168,7 +1230,6 @@ public class ConstraintsSelectionDialog extends JInternalFrame {
* temporary color and button indicating the chosen color for the class.
**/
private
void
chooseLabelClassColor
(
int
indexClass
)
{
Color
lblCColorTemp
=
JColorChooser
.
showDialog
(
this
.
jd_colorsChooser
,
"Label Class Color Chooser"
,
Color
.
red
);
//$NON-NLS-1$
this
.
labelConstraintColorTemp
.
set
(
indexClass
,
lblCColorTemp
);
...
...
@@ -1180,18 +1241,56 @@ public class ConstraintsSelectionDialog extends JInternalFrame {
}
/**
* Draw a cross a
*
* @brief Creates a clone of a BufferedImage
* @param image
* @return BufferedImage
*/
private
BufferedImage
clone
(
BufferedImage
image
)
{
BufferedImage
clone
=
new
BufferedImage
(
image
.
getWidth
(),
image
.
getHeight
(),
image
.
getType
());
Graphics2D
g2d
=
clone
.
createGraphics
();
g2d
.
drawImage
(
image
,
0
,
0
,
null
);
g2d
.
dispose
();
return
clone
;
}
/**
* @brief Draws an image
* @param index
*/
private
void
drawPixel
(
int
index
,
Color
c
,
String
name
)
{
Graphics
g
=
this
.
imagePoints
.
getGraphics
();
private
void
drawPixel
(
int
index
,
Color
c
,
String
name
,
BufferedImage
img
)
{
Graphics
g
=
mNew
.
getGraphics
();
g
.
setColor
(
c
);
int
x
=
(
in
dex
%
this
.
width
);
int
y
=
(
in
dex
/
this
.
width
);
int
x
=
(
in
t
)
((
index
%
this
.
width
)
*
mZoomRate
);
int
y
=
(
in
t
)
((
index
/
this
.
width
)*
mZoomRate
);
g
.
drawString
(
name
,
x
+
4
,
y
-
4
);
// $NON-NLS-1$
g
.
drawLine
(
x
-
7
,
y
,
x
+
7
,
y
);
g
.
drawLine
(
x
,
y
-
7
,
x
,
y
+
7
);
g
.
drawImage
(
img
,
x
-
23
,
y
-
35
,
100
,
100
,
null
);
}
/**
* @brief Changes the pixels color of an image
* @param img
* @param index
*/
private
void
changeColorPixelLabel
(
BufferedImage
img
,
int
index
,
Vector
<
Color
>
v
)
{
for
(
int
i
=
0
;
i
<
img
.
getWidth
();
i
++)
{
for
(
int
j
=
0
;
j
<
img
.
getHeight
();
j
++)
{
if
(
img
.
getRGB
(
i
,
j
)
==
new
Color
(
255
,
255
,
255
).
getRGB
())
{
Color
c
=
v
.
get
(
index
);
img
.
setRGB
(
i
,
j
,
c
.
getRGB
());
}
}
}
}
private
void
changeColorPixel
(
BufferedImage
img
,
Color
c
)
{
for
(
int
i
=
0
;
i
<
img
.
getWidth
();
i
++)
{
for
(
int
j
=
0
;
j
<
img
.
getHeight
();
j
++)
{
if
(
img
.
getRGB
(
i
,
j
)
==
new
Color
(
255
,
255
,
255
).
getRGB
())
{
img
.
setRGB
(
i
,
j
,
c
.
getRGB
());
}
}
}
}
// TODO check
...
...
@@ -1201,15 +1300,16 @@ public class ConstraintsSelectionDialog extends JInternalFrame {
cannotLinkColor
=
new
Color
(
255
,
0
,
255
);
labelConstraintColor
=
new
Vector
<
Color
>();
// constraintsColors = new Vector<Color>();
imageLabelPixel
=
new
Vector
<
BufferedImage
>();
}
private
void
doZoomOp
()
{
private
void
doZoom
ed
Op
()
{
AffineTransform
trans
=
AffineTransform
.
getScaleInstance
(
this
.
mZoomRate
,
this
.
mZoomRate
);
AffineTransformOp
op
=
new
AffineTransformOp
(
trans
,
AffineTransformOp
.
TYPE_NEAREST_NEIGHBOR
);
BufferedImage
mNew
=
op
.
filter
(
this
.
imagePoints
,
null
);
this
.
labelImage
.
setIcon
(
new
ImageIcon
(
mNew
));
mNew
=
op
.
filter
(
this
.
imagePoints
,
null
);
displayPixels
();
}
@SuppressWarnings
(
"unchecked"
)
public
Vector
<
Constraint
>
getConstraints
()
{
...
...
@@ -1238,6 +1338,7 @@ public class ConstraintsSelectionDialog extends JInternalFrame {
addConstraint
(
c
,
isImageRelated
);
}
displayPixels
();
}
protected
void
createMustLinkConstraint
()
{
...
...
@@ -1363,13 +1464,14 @@ public class ConstraintsSelectionDialog extends JInternalFrame {
public
void
zoomIn
()
{
this
.
mZoomRate
+=
this
.
mZoomStep
;
doZoom
Op
();
doZoomed
Op
();
}
public
void
zoomOut
()
{
if
(
this
.
mZoomRate
-
this
.
mZoomStep
>
0
)
{
this
.
mZoomRate
-=
this
.
mZoomStep
;
doZoomOp
();
doZoomedOp
();
}
else
System
.
out
.
println
(
Messages
.
getString
(
"ConstraintsSelectionDialog.29"
));
//$NON-NLS-1$
}
...
...
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