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
092b32e2
Commit
092b32e2
authored
Jul 24, 2017
by
coman
Browse files
Options
Browse Files
Download
Plain Diff
Merged choose color refactoring with zoombox modifications
parents
51990b8c
6fb33cca
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
247 additions
and
1981 deletions
+247
-1981
src/mustic/gui/dialog/classifier/ConstraintsColor.java
src/mustic/gui/dialog/classifier/ConstraintsColor.java
+211
-0
src/mustic/gui/dialog/classifier/ConstraintsSelectionDialog.java
...tic/gui/dialog/classifier/ConstraintsSelectionDialog.java
+36
-254
src/mustic/gui/dialog/classifier/ConstraintsSelectionDialog.java.orig
...ui/dialog/classifier/ConstraintsSelectionDialog.java.orig
+0
-1727
No files found.
src/mustic/gui/dialog/classifier/ConstraintsColor.java
0 → 100644
View file @
092b32e2
package
mustic.gui.dialog.classifier
;
import
java.awt.BorderLayout
;
import
java.awt.Color
;
import
java.awt.Dimension
;
import
java.awt.GridLayout
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionListener
;
import
java.util.Vector
;
import
javax.swing.BorderFactory
;
import
javax.swing.JButton
;
import
javax.swing.JColorChooser
;
import
javax.swing.JDialog
;
import
javax.swing.JLabel
;
import
javax.swing.JPanel
;
import
javax.swing.JScrollPane
;
import
javax.swing.ScrollPaneConstants
;
import
javax.swing.border.EtchedBorder
;
import
javax.swing.border.TitledBorder
;
/**
* Dialog that allows the user to change the color of the constraints
*/
public
class
ConstraintsColor
extends
JDialog
{
private
static
final
long
serialVersionUID
=
1L
;
/** 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
>();
/** constraints buttons */
private
JButton
jb_mustLinkChooseColor
=
new
JButton
();
private
JButton
jb_cannotLinkChooseColor
=
new
JButton
();
private
Vector
<
JButton
>
jb_labelConstraintClassChooseColor
=
new
Vector
<
JButton
>();
/** dynamic JPanel Colors of Label Constraints Classes*/
JPanel
labelColorConstraintPanel
=
new
JPanel
(
new
GridLayout
(
0
,
1
));
private
ConstraintsSelectionDialog
dialog
=
null
;
/**
* @brief Constructor dialog window that allows the user to change the color of the constraints
* @param d
* @param colorML
* @param colorCL
* @param colorVectorLabel
*/
public
ConstraintsColor
(
ConstraintsSelectionDialog
d
,
Color
colorML
,
Color
colorCL
,
Vector
<
Color
>
colorVectorLabel
)
{
this
.
dialog
=
d
;
this
.
mustLinkColor
=
colorML
;
this
.
cannotLinkColor
=
colorCL
;
this
.
labelConstraintColor
=
colorVectorLabel
;
//buttons action listeners that allow the user to choose the color of the constraint
jb_cannotLinkChooseColor
.
addActionListener
(
new
ActionListener
()
{
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
chooseCannotLinkColor
();
}
});
jb_mustLinkChooseColor
.
addActionListener
(
new
ActionListener
()
{
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
chooseMustLinkColor
();
}
});
// creates the panel for the label constraints
for
(
int
i
=
0
;
i
<
dialog
.
getClassCounter
();
i
++)
{
JButton
jb
=
new
JButton
();
jb_labelConstraintClassChooseColor
.
add
(
jb
);
jb_labelConstraintClassChooseColor
.
get
(
i
).
putClientProperty
(
"index"
,
i
);
jb_labelConstraintClassChooseColor
.
get
(
i
).
setBackground
(
labelConstraintColor
.
get
(
i
));
createLabelColorConstraintsPanel
(
i
);
}
this
.
setTitle
(
"Choose Constraints Colors"
);
chooseConstraintColors
();
}
/**
* Add the last created label constraint class name(number) and its color
* button to the panel labelColorConstraintPanel. The button allows user to
* choose the label constraint class color.
**/
protected
void
createLabelColorConstraintsPanel
(
int
index
)
{
JPanel
classNameButtonPanel
=
new
JPanel
(
new
GridLayout
(
1
,
2
));
classNameButtonPanel
.
setBorder
(
BorderFactory
.
createEmptyBorder
(
3
,
3
,
3
,
3
));
classNameButtonPanel
.
add
(
new
JLabel
(
"Class "
+
(
index
+
1
)
+
":"
));
jb_labelConstraintClassChooseColor
.
get
(
index
).
addActionListener
(
new
ActionListener
()
{
public
void
actionPerformed
(
ActionEvent
event
)
{
JButton
lblClassColorButtonClicked
=
(
JButton
)
event
.
getSource
();
int
buttonIndex
=
(
int
)
lblClassColorButtonClicked
.
getClientProperty
(
"index"
);
chooseLabelClassColor
(
buttonIndex
);
}
});
classNameButtonPanel
.
add
(
jb_labelConstraintClassChooseColor
.
get
(
index
));
labelColorConstraintPanel
.
add
(
classNameButtonPanel
);
}
/** Opens a JDialog for choosing the Constraints Colors*/
protected
void
chooseConstraintColors
()
{
JPanel
constraintsPanel
=
new
JPanel
(
new
BorderLayout
());
JPanel
mlConstraintsPanel
=
new
JPanel
();
JPanel
clConstraintsPanel
=
new
JPanel
();
JPanel
mlclConstraintsPanel
=
new
JPanel
(
new
GridLayout
(
2
,
1
));
JPanel
supportPanel
=
new
JPanel
(
new
BorderLayout
());
supportPanel
.
add
(
labelColorConstraintPanel
,
BorderLayout
.
NORTH
);
JScrollPane
lblConstraintsPane
=
new
JScrollPane
(
supportPanel
,
ScrollPaneConstants
.
VERTICAL_SCROLLBAR_ALWAYS
,
ScrollPaneConstants
.
HORIZONTAL_SCROLLBAR_NEVER
);
TitledBorder
lblcBorder
=
BorderFactory
.
createTitledBorder
(
BorderFactory
.
createEtchedBorder
(
EtchedBorder
.
LOWERED
),
"Label Constraints Color"
,
TitledBorder
.
LEFT
,
TitledBorder
.
TOP
);
lblConstraintsPane
.
setBorder
(
lblcBorder
);
// must-link constraints panel
mlConstraintsPanel
.
setLayout
(
new
BorderLayout
());
TitledBorder
mlcBorder
=
BorderFactory
.
createTitledBorder
(
BorderFactory
.
createEtchedBorder
(
EtchedBorder
.
LOWERED
),
"Must-Link Constraints Color"
,
TitledBorder
.
LEFT
,
TitledBorder
.
TOP
);
mlConstraintsPanel
.
setBorder
(
mlcBorder
);
mlConstraintsPanel
.
add
(
jb_mustLinkChooseColor
,
BorderLayout
.
CENTER
);
mlclConstraintsPanel
.
add
(
mlConstraintsPanel
);
// cannot-link constraints panel
clConstraintsPanel
.
setLayout
(
new
BorderLayout
());
TitledBorder
clcBorder
=
BorderFactory
.
createTitledBorder
(
BorderFactory
.
createEtchedBorder
(
EtchedBorder
.
LOWERED
),
"Cannot-Link Constraints Color"
,
TitledBorder
.
LEFT
,
TitledBorder
.
TOP
);
clConstraintsPanel
.
setBorder
(
clcBorder
);
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
)
{
dialog
.
setColorML
(
mustLinkColor
);
dialog
.
setColorCL
(
cannotLinkColor
);
dialog
.
setColorLabels
(
labelConstraintColor
);
ConstraintsColor
.
this
.
dispose
();
}
});
// exit dialog on cancel
JButton
cancel
=
new
JButton
(
"Cancel"
);
cancel
.
addActionListener
(
new
ActionListener
()
{
public
void
actionPerformed
(
ActionEvent
event
)
{
ConstraintsColor
.
this
.
dispose
();
}
});
jb_mustLinkChooseColor
.
setBackground
(
mustLinkColor
);
jb_cannotLinkChooseColor
.
setBackground
(
cannotLinkColor
);
buttonPanel
.
add
(
ok
);
buttonPanel
.
add
(
cancel
);
constraintsPanel
.
add
(
mlclConstraintsPanel
,
BorderLayout
.
NORTH
);
constraintsPanel
.
add
(
lblConstraintsPane
,
BorderLayout
.
CENTER
);
constraintsPanel
.
add
(
buttonPanel
,
BorderLayout
.
SOUTH
);
this
.
add
(
constraintsPanel
,
BorderLayout
.
CENTER
);
this
.
setPreferredSize
(
new
Dimension
(
270
,
270
));
this
.
pack
();
this
.
setLocationRelativeTo
(
null
);
this
.
setModal
(
true
);
this
.
setVisible
(
true
);
}
/**
* Color Chooser for Must-Link constraints\n Sets the temporary color and
* button indicating the chosen color.
*/
protected
void
chooseMustLinkColor
()
{
mustLinkColor
=
JColorChooser
.
showDialog
(
this
,
"Must-Link Color Chooser"
,
Color
.
red
);
this
.
jb_mustLinkChooseColor
.
setBackground
(
mustLinkColor
);
}
/**
* Color Chooser for Cannot-Link constraints\n Sets the temporary color and
* button indicating the chosen color.
**/
protected
void
chooseCannotLinkColor
()
{
this
.
cannotLinkColor
=
JColorChooser
.
showDialog
(
this
,
"Cannot-Link Color Chooser"
,
//$NON-NLS-1$
cannotLinkColor
);
this
.
jb_cannotLinkChooseColor
.
setBackground
(
cannotLinkColor
);
}
/**
* Color Chooser for a Label constraint of the class "classID" \n Sets the
* temporary color and button indicating the chosen color for the class.
**/
protected
void
chooseLabelClassColor
(
int
indexClass
)
{
Color
lblCColorTemp
=
JColorChooser
.
showDialog
(
this
,
"Label Class Color Chooser"
,
Color
.
red
);
//$NON-NLS-1$
this
.
labelConstraintColor
.
set
(
indexClass
,
lblCColorTemp
);
this
.
jb_labelConstraintClassChooseColor
.
get
(
indexClass
).
setBackground
(
lblCColorTemp
);
}
}
src/mustic/gui/dialog/classifier/ConstraintsSelectionDialog.java
View file @
092b32e2
...
...
@@ -7,7 +7,6 @@ import java.awt.Component;
import
java.awt.Cursor
;
import
java.awt.Dimension
;
import
java.awt.FlowLayout
;
import
java.awt.Frame
;
import
java.awt.Graphics
;
import
java.awt.Graphics2D
;
import
java.awt.GridLayout
;
...
...
@@ -40,10 +39,8 @@ import java.util.Vector;
import
javax.imageio.ImageIO
;
import
javax.swing.BorderFactory
;
import
javax.swing.ImageIcon
;
import
javax.swing.JButton
;
import
javax.swing.JCheckBox
;
import
javax.swing.JColorChooser
;
import
javax.swing.JDialog
;
import
javax.swing.JFileChooser
;
import
javax.swing.JInternalFrame
;
...
...
@@ -55,10 +52,6 @@ import javax.swing.JSlider;
import
javax.swing.JSplitPane
;
import
javax.swing.JTextArea
;
import
javax.swing.JTextField
;
import
javax.swing.ScrollPaneConstants
;
import
javax.swing.SwingConstants
;
import
javax.swing.border.EtchedBorder
;
import
javax.swing.border.TitledBorder
;
import
javax.swing.event.ChangeEvent
;
import
javax.swing.event.ChangeListener
;
...
...
@@ -87,7 +80,7 @@ import mustic.utils.io.CSVUtils;
*/
public
class
ConstraintsSelectionDialog
extends
JInternalFrame
implements
Zoomable
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
/** data related fields */
private
RawImage
image
=
null
;
...
...
@@ -104,7 +97,7 @@ public class ConstraintsSelectionDialog extends JInternalFrame implements Zoomab
/** Image displayed */
private
BufferedImage
mNew
=
null
;
/** Panel that contains the displayed image */
private
JPanel
displayPanel
=
null
;
...
...
@@ -165,21 +158,6 @@ public class ConstraintsSelectionDialog extends JInternalFrame implements Zoomab
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
();
private
Vector
<
JButton
>
jb_labelConstraintClassChooseColor
=
new
Vector
<
JButton
>();
/** dynamic JPanel Colors of Label Constraints Classes*/
JPanel
labelColorConstraintPanel
=
new
JPanel
(
new
GridLayout
(
0
,
1
));
/** Images and constraints zoom */
...
...
@@ -188,12 +166,12 @@ public class ConstraintsSelectionDialog extends JInternalFrame implements Zoomab
private
BufferedImage
imagePixel
;
private
BufferedImage
imagePixelML
;
private
BufferedImage
imagePixelCL
;
private
BufferedImage
imagePixelMLTemp
;
private
BufferedImage
imagePixelCLTemp
;
private
Vector
<
BufferedImage
>
imageLabelPixel
=
new
Vector
<
BufferedImage
>();
private
int
classID
;
private
JPanel
container
;
/**
* Constructor to a dialog window to visualize and build a set of
* constraints
...
...
@@ -225,7 +203,6 @@ public class ConstraintsSelectionDialog extends JInternalFrame implements Zoomab
this
.
displayPanel
.
addMouseWheelListener
(
new
MouseWheelListener
()
{
@Override
public
void
mouseWheelMoved
(
MouseWheelEvent
e
)
{
// zoom in zoom box
if
((
e
.
getModifiers
()
&
InputEvent
.
CTRL_MASK
)
==
InputEvent
.
CTRL_MASK
)
{
if
(
e
.
getUnitsToScroll
()
>
0
)
{
...
...
@@ -250,7 +227,6 @@ public class ConstraintsSelectionDialog extends JInternalFrame implements Zoomab
zoomIn
();
}
}
}
});
...
...
@@ -347,12 +323,11 @@ public class ConstraintsSelectionDialog extends JInternalFrame implements Zoomab
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
// action for color chooser
chooseConstraintColors
(
);
new
ConstraintsColor
(
ConstraintsSelectionDialog
.
this
,
mustLinkColor
,
cannotLinkColor
,
labelConstraintColor
);
displayPixels
();
}
});
panelButton
.
add
(
constraintsColorChooser
);
/** Displays or hides current constraints on the image */
check
=
new
JCheckBox
(
Messages
.
getString
(
"ConstraintsSelectionDialog.57"
));
//$NON-NLS-1$
check
.
addActionListener
(
new
ActionListener
()
{
...
...
@@ -374,6 +349,7 @@ public class ConstraintsSelectionDialog extends JInternalFrame implements Zoomab
JCheckBox
zoomBoxChkBox
=
new
JCheckBox
(
Messages
.
getString
(
"ConstraintsSelectionDialog.58"
));
// key listener for the keyJCheckBox
this
.
displayPanel
.
addKeyListener
(
new
KeyListener
()
{
@Override
...
...
@@ -452,27 +428,11 @@ public class ConstraintsSelectionDialog extends JInternalFrame implements Zoomab
e1
.
printStackTrace
();
}
jb_mustLinkChooseColor
.
setBackground
(
mustLinkColor
);
jb_cannotLinkChooseColor
.
setBackground
(
cannotLinkColor
);
// paints the image with the color of the mustlink and cannotlink
changeColorPixel
(
imagePixelML
,
mustLinkColor
);
jb_mustLinkChooseColor
.
addActionListener
(
new
ActionListener
()
{
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
chooseMustLinkColor
();
}
});
changeColorPixel
(
imagePixelCL
,
cannotLinkColor
);
jb_cannotLinkChooseColor
.
addActionListener
(
new
ActionListener
()
{
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
chooseCannotLinkColor
();
}
});
// initialize the color,
// button background and the
// initializes the color,
// panel containing the class name + it's button for the first label
// Constraint Class
Random
rand
=
new
Random
();
...
...
@@ -480,22 +440,10 @@ public class ConstraintsSelectionDialog extends JInternalFrame implements Zoomab
float
g
=
rand
.
nextFloat
();
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
();
}
...
...
@@ -596,139 +544,6 @@ public class ConstraintsSelectionDialog extends JInternalFrame implements Zoomab
}
/**
* Add the last created label constraint class name(number) and its color
* button to the panel labelColorConstraintPanel. The button allows user to
* choose the label constraint class color.
**/
protected
void
createLabelColorConstraintsPanel
()
{
JPanel
classNameButtonPanel
=
new
JPanel
(
new
GridLayout
(
1
,
2
));
classNameButtonPanel
.
setBorder
(
BorderFactory
.
createEmptyBorder
(
3
,
3
,
3
,
3
));
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
);
}
});
classNameButtonPanel
.
add
(
jb_labelConstraintClassChooseColor
.
get
(
labelClassesCount
-
1
));
labelColorConstraintPanel
.
add
(
classNameButtonPanel
);
}
/** Opens a JDialog for choosing the Constraints Colors **/
protected
void
chooseConstraintColors
()
{
jd_colorsChooser
=
new
JDialog
((
Frame
)
this
.
getTopLevelAncestor
(),
"Choose Constraints Colors"
,
true
);
jd_colorsChooser
.
getRootPane
().
setBorder
(
BorderFactory
.
createEmptyBorder
(
3
,
3
,
3
,
3
));
jd_colorsChooser
.
setLayout
(
new
BorderLayout
());
JPanel
constraintsPanel
=
new
JPanel
(
new
BorderLayout
());
JPanel
mlConstraintsPanel
=
new
JPanel
();
JPanel
clConstraintsPanel
=
new
JPanel
();
JPanel
mlclConstraintsPanel
=
new
JPanel
(
new
GridLayout
(
2
,
1
));
JPanel
supportPanel
=
new
JPanel
(
new
BorderLayout
());
supportPanel
.
add
(
labelColorConstraintPanel
,
BorderLayout
.
NORTH
);
JScrollPane
lblConstraintsPane
=
new
JScrollPane
(
supportPanel
,
ScrollPaneConstants
.
VERTICAL_SCROLLBAR_ALWAYS
,
ScrollPaneConstants
.
HORIZONTAL_SCROLLBAR_NEVER
);
TitledBorder
lblcBorder
=
BorderFactory
.
createTitledBorder
(
BorderFactory
.
createEtchedBorder
(
EtchedBorder
.
LOWERED
),
"Label Constraints Color"
,
TitledBorder
.
LEFT
,
TitledBorder
.
TOP
);
lblConstraintsPane
.
setBorder
(
lblcBorder
);
// must-link constraints panel
mlConstraintsPanel
.
setLayout
(
new
BorderLayout
());
TitledBorder
mlcBorder
=
BorderFactory
.
createTitledBorder
(
BorderFactory
.
createEtchedBorder
(
EtchedBorder
.
LOWERED
),
"Must-Link Constraints Color"
,
TitledBorder
.
LEFT
,
TitledBorder
.
TOP
);
mlConstraintsPanel
.
setBorder
(
mlcBorder
);
mlConstraintsPanel
.
add
(
jb_mustLinkChooseColor
,
BorderLayout
.
CENTER
);
mlclConstraintsPanel
.
add
(
mlConstraintsPanel
);
// cannot-link constraints panel
clConstraintsPanel
.
setLayout
(
new
BorderLayout
());
TitledBorder
clcBorder
=
BorderFactory
.
createTitledBorder
(
BorderFactory
.
createEtchedBorder
(
EtchedBorder
.
LOWERED
),
"Cannot-Link Constraints Color"
,
TitledBorder
.
LEFT
,
TitledBorder
.
TOP
);
clConstraintsPanel
.
setBorder
(
clcBorder
);
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
));
changeColorPixelLabel
(
imageLabelPixelTemp
.
get
(
i
),
i
,
labelConstraintColorTemp
);
imageLabelPixel
.
set
(
i
,
imageLabelPixelTemp
.
get
(
i
));
jb_labelConstraintClassChooseColor
.
get
(
i
).
setBackground
(
labelConstraintColor
.
get
(
i
));
}
}
// update Vector imageLabelPixelTemp with copies of the original map-image(imagePixel)
imageLabelPixelTemp
=
new
Vector
<
BufferedImage
>();
for
(
int
i
=
0
;
i
<
labelClassesCount
;
i
++)
{
imageLabelPixelTemp
.
add
(
ConstraintsSelectionDialog
.
this
.
clone
(
imagePixel
));
}
jd_colorsChooser
.
dispose
();
}
});
// exit dialog on cancel
JButton
cancel
=
new
JButton
(
"Cancel"
);
cancel
.
addActionListener
(
new
ActionListener
()
{
public
void
actionPerformed
(
ActionEvent
event
)
{
mustLinkColorTemp
=
mustLinkColor
;
cannotLinkColorTemp
=
cannotLinkColor
;
for
(
int
i
=
0
;
i
<
labelClassesCount
;
i
++){
labelConstraintColorTemp
.
set
(
i
,
labelConstraintColor
.
get
(
i
));
jb_labelConstraintClassChooseColor
.
get
(
i
).
setBackground
(
labelConstraintColor
.
get
(
i
));
}
jd_colorsChooser
.
dispose
();
}
});
jb_mustLinkChooseColor
.
setBackground
(
mustLinkColor
);
jb_cannotLinkChooseColor
.
setBackground
(
cannotLinkColor
);
buttonPanel
.
add
(
ok
);
buttonPanel
.
add
(
cancel
);
constraintsPanel
.
add
(
mlclConstraintsPanel
,
BorderLayout
.
NORTH
);
constraintsPanel
.
add
(
lblConstraintsPane
,
BorderLayout
.
CENTER
);
constraintsPanel
.
add
(
buttonPanel
,
BorderLayout
.
SOUTH
);
jd_colorsChooser
.
add
(
constraintsPanel
,
BorderLayout
.
CENTER
);
jd_colorsChooser
.
setPreferredSize
(
new
Dimension
(
270
,
270
));
jd_colorsChooser
.
pack
();
jd_colorsChooser
.
setLocationRelativeTo
(
null
);
jd_colorsChooser
.
setVisible
(
true
);
}
private
boolean
openFile
(
File
file
)
{
System
.
out
.
println
(
"__________________________________________________________________________________________\n"
);
//$NON-NLS-1$
...
...
@@ -1207,7 +1022,6 @@ public class ConstraintsSelectionDialog extends JInternalFrame implements Zoomab
if
(
s
.
equals
(
Messages
.
getString
(
"ConstraintsSelectionDialog.35"
)))
{
labelClassesCount
++;
classIndex
=
labelClassesCount
;
// generate a random color for label constraints of the same
// class
Random
rand
=
new
Random
(
new
Date
().
getTime
());
...
...
@@ -1215,21 +1029,10 @@ public class ConstraintsSelectionDialog extends JInternalFrame implements Zoomab
float
g
=
rand
.
nextFloat
();
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
));
createLabelColorConstraintsPanel
();
copy
=
clone
(
imagePixel
);
changeColorPixelLabel
(
copy
,
classIndex
-
1
,
labelConstraintColor
);
imageLabelPixel
.
add
(
copy
);
imageLabelPixelTemp
.
add
(
clone
(
imagePixel
));
}
else
{
classIndex
=
Integer
.
parseInt
(
s
);
...
...
@@ -1258,7 +1061,6 @@ public class ConstraintsSelectionDialog extends JInternalFrame implements Zoomab
if
(
constraintsPanels
.
size
()
>
0
)
((
JTextField
)
constraintsPanels
.
get
(
constraintsPanels
.
size
()
-
1
).
getComponent
(
1
)).
setText
(
""
+
index
);
}
private
void
displayPixels
()
{
...
...
@@ -1317,51 +1119,7 @@ public class ConstraintsSelectionDialog extends JInternalFrame implements Zoomab
}
}
/**
* Color Chooser for Must-Link constraints\n Sets the temporary color and
* button indicating the chosen color.
**/
private
void
chooseMustLinkColor
()
{
this
.
mustLinkColorTemp
=
JColorChooser
.
showDialog
(
this
.
jd_colorsChooser
,
"Must-Link Color Chooser"
,
//$NON-NLS-1$
mustLinkColorTemp
);
if
(
this
.
mustLinkColorTemp
!=
null
)
{
this
.
jb_mustLinkChooseColor
.
setBackground
(
mustLinkColorTemp
);
}
else
{
mustLinkColorTemp
=
mustLinkColor
;
}
}
/**
* Color Chooser for Cannot-Link constraints\n Sets the temporary color and
* button indicating the chosen color.
**/
private
void
chooseCannotLinkColor
()
{
this
.
cannotLinkColorTemp
=
JColorChooser
.
showDialog
(
this
.
jd_colorsChooser
,
"Cannot-Link Color Chooser"
,
//$NON-NLS-1$
cannotLinkColorTemp
);
if
(
this
.
cannotLinkColorTemp
!=
null
)
{
this
.
jb_cannotLinkChooseColor
.
setBackground
(
cannotLinkColorTemp
);
}
else
{
cannotLinkColorTemp
=
cannotLinkColor
;
}
}
/**
* Color Chooser for a Label constraint of the class "classID" \n Sets the
* 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
);
if
(
lblCColorTemp
!=
null
)
{
this
.
jb_labelConstraintClassChooseColor
.
get
(
indexClass
).
setBackground
(
lblCColorTemp
);
}
else
{
this
.
labelConstraintColorTemp
.
set
(
indexClass
,
labelConstraintColor
.
get
(
indexClass
));
}
}
/**
* @brief Creates a clone of a BufferedImage
...
...
@@ -1390,13 +1148,12 @@ public class ConstraintsSelectionDialog extends JInternalFrame implements Zoomab
}
}