Commit 7233b0d7 authored by lafabregue's avatar lafabregue

minor changes

parent 76bfd602
......@@ -17,3 +17,4 @@ local.properties
.settings/
.loadpath
*.hprof
*.log
......@@ -744,7 +744,7 @@ public class MainFrame extends JFrame {
customClassify();
}
});
// CSVMenu.add(customToDelete);
CSVMenu.add(customToDelete);
// menuItemResultToCSV = new JMenuItem(Messages.getString("MainFrame.305")); //$NON-NLS-1$
// menuItemResultToCSV.addActionListener(new ActionListener() {
......
......@@ -265,7 +265,7 @@ public class ImagePanel extends JPanel implements Zoomable, Observer, ImageDispl
public void mouseWheelMoved(java.awt.event.MouseWheelEvent e) {
// zoom in zoom box
if((e.getModifiers() & InputEvent.CTRL_MASK) == InputEvent.CTRL_MASK) {
if (e.getUnitsToScroll() > 0) {
if (e.getUnitsToScroll() < 0) {
displayPanel.zoomInBox();
} else {
displayPanel.zoomOutBox();
......@@ -502,6 +502,7 @@ public class ImagePanel extends JPanel implements Zoomable, Observer, ImageDispl
});
this.displayPanel.setFocusable(true);
this.requestFocusInWindow();
}
/**
......
......@@ -96,7 +96,7 @@ public class ImageResultPanel extends ResultPanel implements TreeSelectionListen
private ImageData imgData;
protected JInternalFrame jif_saveResult = new JInternalFrame();
protected JLayeredPane lpane = new JLayeredPane();
/** width of the screen image */
......@@ -129,8 +129,6 @@ public class ImageResultPanel extends ResultPanel implements TreeSelectionListen
private float opacityCluster = 1;
/** */
protected JPanel panelImage = new JPanel(new BorderLayout());
protected JPanel panelResSave = new JPanel();
/** offset between the panel and the actual displayed image */
......@@ -227,8 +225,8 @@ public class ImageResultPanel extends ResultPanel implements TreeSelectionListen
setListenerImage();
if (MainFrame.DEBUG_MODE)
System.out.println("updateImageColors from irp");
this.panelImage.add(displayPanel, BorderLayout.CENTER);
this.panelImage.setBackground(Color.CYAN);
// this.panelImage.add(displayPanel, BorderLayout.CENTER);
// this.panelImage.setBackground(Color.CYAN);
this.resultTabbedPane.addTab("Image Result", this.displayPanel);
this.resultTabbedPane.addTab("Historique", this.historique);
......@@ -349,6 +347,11 @@ public class ImageResultPanel extends ResultPanel implements TreeSelectionListen
// }
}
@Override
public void mouseEntered(MouseEvent e) {
displayPanel.requestFocusInWindow();
}
@Override
public void mousePressed(MouseEvent e) {
evaluatePopup(e);
......@@ -358,29 +361,31 @@ public class ImageResultPanel extends ResultPanel implements TreeSelectionListen
@Override
public void mouseReleased(MouseEvent e) {
evaluatePopup(e);
int translateX = (int) ((mousePressedCoordinates.x - e.getX())/mZoomRate);
int translateY = (int) ((mousePressedCoordinates.y - e.getY())/mZoomRate);
currentTopLeft.x += translateX;
currentTopLeft.y += translateY;
if (currentTopLeft.x + (int) (displayPanel.getWidth()/mZoomRate) > viewer.getRealImageWidth()) {
currentTopLeft.x = viewer.getRealImageWidth() - (int) (displayPanel.getWidth()/mZoomRate);
}
if (currentTopLeft.y + (int) (displayPanel.getHeight()/mZoomRate) > viewer.getRealImageHeight()) {
currentTopLeft.y = viewer.getRealImageHeight() - (int) (displayPanel.getHeight()/mZoomRate);
if (mousePressedCoordinates != null) {
int translateX = (int) ((mousePressedCoordinates.x - e.getX())/mZoomRate);
int translateY = (int) ((mousePressedCoordinates.y - e.getY())/mZoomRate);
currentTopLeft.x += translateX;
currentTopLeft.y += translateY;
if (currentTopLeft.x + (int) (displayPanel.getWidth()/mZoomRate) > viewer.getRealImageWidth()) {
currentTopLeft.x = viewer.getRealImageWidth() - (int) (displayPanel.getWidth()/mZoomRate);
}
if (currentTopLeft.y + (int) (displayPanel.getHeight()/mZoomRate) > viewer.getRealImageHeight()) {
currentTopLeft.y = viewer.getRealImageHeight() - (int) (displayPanel.getHeight()/mZoomRate);
}
if (currentTopLeft.x < 0)
currentTopLeft.x = 0;
if (currentTopLeft.y < 0)
currentTopLeft.y = 0;
viewer.getScreenImage(currentTopLeft.x, currentTopLeft.y, displayPanel.getWidth(),
displayPanel.getHeight(), mZoomRate, true);
updateImageView();
mousePressedCoordinates = null;
displayPanel.setAddedOffset(null);
}
if (currentTopLeft.x < 0)
currentTopLeft.x = 0;
if (currentTopLeft.y < 0)
currentTopLeft.y = 0;
viewer.getScreenImage(currentTopLeft.x, currentTopLeft.y, displayPanel.getWidth(),
displayPanel.getHeight(), mZoomRate, true);
updateImageView();
mousePressedCoordinates = null;
displayPanel.setAddedOffset(null);
}
});
......@@ -530,14 +535,54 @@ public class ImageResultPanel extends ResultPanel implements TreeSelectionListen
this.displayPanel.addMouseWheelListener(new MouseWheelListener() {
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
if (e.getUnitsToScroll() > 0) {
zoomOut();
// zoom in zoom box
if((e.getModifiers() & InputEvent.CTRL_MASK) == InputEvent.CTRL_MASK) {
if (e.getUnitsToScroll() <= 0) {
displayPanel.zoomInBox();
} else {
displayPanel.zoomOutBox();
}
}
else {
zoomIn();
// resize zoom box area
else if((e.getModifiers() & InputEvent.ALT_MASK) == InputEvent.ALT_MASK) {
if (e.getUnitsToScroll() > 0) {
displayPanel.increaseZoomBoxArea();
} else {
displayPanel.decreaseZoomBoxArea();
}
}
// zoom in the image
else {
if (e.getUnitsToScroll() > 0) {
zoomOut();
} else {
zoomIn();
}
}
}
});
// key listener for the ZoomBox
displayPanel.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
// enable zoom box
if(e.getKeyCode() == KeyEvent.VK_Z) {
displayPanel.setZoomBoxEnabled(!displayPanel.isZoomBoxEnabled());
}
}
@Override
public void keyReleased(KeyEvent e) {
}
});
this.displayPanel.setFocusable(true);
}
@Override
......@@ -1617,7 +1662,7 @@ public class ImageResultPanel extends ResultPanel implements TreeSelectionListen
double zoomOrigin = zoom*mZoomRate ;
BufferedImage subImage = viewer.getScreenImage(xo, yo, width, height, zoomOrigin, false);
return subImage;
return drawAllElements(subImage);
}
......
package mustic.gui.panels.classifier.components;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.*;
......@@ -12,7 +11,6 @@ import javax.swing.border.TitledBorder;
import jcl.data.Data;
import jcl.data.attribute.AttributeMultiDimSequence;
import jcl.evaluation.clustering.ClusteringEvaluation;
import jcl.learning.LearningParameters;
import jcl.learning.methods.multistrategy.samarah.*;
import mustic.gui.MainFrame;
......@@ -36,8 +34,9 @@ public class HybridClassificationPanel extends JPanel implements AgentListManage
private AgentDialog cd;
private Data data = null;
private Data data = null;
private HybridClassificationSubParametersPanel parametersPanel = null;
/** */
// JButton jButtonConfig = new JButton(new
// ImageIcon(getClass().getResource("/icons/icon_configure.png")));
......@@ -49,31 +48,12 @@ public class HybridClassificationPanel extends JPanel implements AgentListManage
private JButton jButtonDelAgent = new JButton(
new ImageIcon(getClass().getResource("/icons/icon_del_agent.png")));
JCheckBox jCheckBoxNbClasses = new JCheckBox();
JCheckBox jCheckBoxUnifiSimple = new JCheckBox("No refinement");
/** liste des agents d'apprentissage */
JList<String> jListAgents = new JList<String>();
/** */
JScrollPane jScrollPaneAgents = new JScrollPane();
JSlider jSliderPqPs = new JSlider();
JTextField jTextFieldNInf = new JTextField();
JTextField jTextFieldNSup = new JTextField();
JTextField jTextFieldPcr = new JTextField();
JTextField jTextFieldPrecision = new JTextField();
JSpinner pcrSpinner = new JSpinner();
JSpinner conflictSpinner = new JSpinner();
/** Nombre de classes recommande ou non */
boolean nbClass = false;
/** La classification hybride vue par cette interface */
private HybridClassification samarah = null;
......@@ -87,21 +67,6 @@ public class HybridClassificationPanel extends JPanel implements AgentListManage
/** barre d'outils */
JToolBar toolBar = new JToolBar();
/** Juste une unification sans raffinement */
boolean unification_simple = false;
private JSlider jSliderPePi = new JSlider();
private JSlider jSliderConstraints = new JSlider();
private JSpinner solutionTypeSpinner;
private JSpinner classRatioSpinner;
public final static String solutionTypeTooltip = "<html>Lorsque l'on supprime les petites classes dans le resultat unifiant on peut choisir de:<br><ul>"
+ "<li><b>0</b> : Pas de suppresion ni reclassement</li>"
+ "<li><b>1</b> : Ne reclasser que les objets des classes supprimees (deprecated)</li>"
+ "<li><b>2</b> : Classer les objets que si au moins une classe a ete supprimée</li>"
+ "<li><b>3</b> : Classer les objets des classes restantes</li></ul></html>";
private JSlider degradationSlider = new JSlider();
private JCheckBox unificationbCheckBox;
private JComboBox<String> criterionComboBox;
private JButton resetButton;
public HybridClassificationPanel() {
jbInit();
......@@ -248,177 +213,18 @@ public class HybridClassificationPanel extends JPanel implements AgentListManage
* </p>
*/
private void jbInit() {
Dimension inputDimension = new Dimension(60, 22);
conflictSpinner.setModel(new SpinnerNumberModel(0.90, 0.0, 1.0, 0.10));
conflictSpinner.setPreferredSize(inputDimension);
centerSpinnerText(conflictSpinner);
classRatioSpinner = new JSpinner(new SpinnerNumberModel(0.01, 0.0, 1.0, 0.01));
classRatioSpinner.setPreferredSize(inputDimension);
centerSpinnerText(classRatioSpinner);
pcrSpinner.setModel(new SpinnerNumberModel(0.2, 0.0, 1.0, 0.1));
pcrSpinner.setPreferredSize(inputDimension);
centerSpinnerText(pcrSpinner);
jCheckBoxNbClasses.setHorizontalAlignment(SwingConstants.LEADING);
jCheckBoxNbClasses.setText("Clusters Number Between ");
jCheckBoxNbClasses.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
jCheckBoxNbClasses_actionPerformed(e);
}
});
jTextFieldNSup.setEnabled(false);
jTextFieldNSup.setPreferredSize(inputDimension);
jTextFieldNSup.setHorizontalAlignment(SwingConstants.CENTER);
jTextFieldNInf.setEnabled(false);
jTextFieldNInf.setPreferredSize(inputDimension);
jTextFieldNInf.setHorizontalAlignment(SwingConstants.CENTER);
jSliderPqPs.setPaintTicks(true);
jSliderPqPs.setMinorTickSpacing(25);
jSliderPqPs.setPreferredSize(new Dimension(160, 20));
jSliderPqPs.setValue(50);
jSliderPePi.setPaintTicks(true);
jSliderPePi.setMinorTickSpacing(25);
jSliderPePi.setPreferredSize(new Dimension(160, 20));
jSliderPePi.setValue(66);
jSliderConstraints.setPaintTicks(true);
jSliderConstraints.setMinorTickSpacing(25);
jSliderConstraints.setPreferredSize(new Dimension(160, 20));
jSliderConstraints.setValue(0);
// we disable the constraints evaluation if none are available
if (data == null || data.getConstraints() == null) {
jSliderConstraints.setEnabled(false);
}
degradationSlider.setMinorTickSpacing(25);
degradationSlider.setPaintTicks(true);
degradationSlider.setValue(90);
degradationSlider.setPreferredSize(new Dimension(160, 20));
// Precisions Panels
solutionTypeSpinner = new JSpinner(new SpinnerNumberModel(3, 0, 3, 1));
solutionTypeSpinner.setPreferredSize(inputDimension);
solutionTypeSpinner.setToolTipText(solutionTypeTooltip);
centerSpinnerText(solutionTypeSpinner);
JPanel solutionTypePanel = new JPanel();
solutionTypePanel.add(new JLabel("Solution Type"));
solutionTypePanel.add(Box.createHorizontalStrut(60));
solutionTypePanel.add(solutionTypeSpinner);
JPanel reprensentativePanel = new JPanel();
reprensentativePanel.add(new JLabel("Representative Classes"));
reprensentativePanel.add(pcrSpinner);
JPanel classMinRatio = new JPanel();
classMinRatio.add(new JLabel("Class Minimal Ratio"));
classMinRatio.add(Box.createHorizontalStrut(25));
classMinRatio.add(classRatioSpinner);
JPanel conflictPanel = new JPanel();
conflictPanel.add(new JLabel("Conflict Sharpness"));
conflictPanel.add(Box.createHorizontalStrut(25));
conflictPanel.add(conflictSpinner);
JPanel precisionPanel = new JPanel();
precisionPanel.setLayout(new BoxLayout(precisionPanel, BoxLayout.Y_AXIS));
precisionPanel.add(solutionTypePanel);
precisionPanel.add(conflictPanel);
precisionPanel.add(classMinRatio);
precisionPanel.add(reprensentativePanel);
// Qualities panels
JPanel internQualityPanel = new JPanel();
internQualityPanel.add(new JLabel(" K-Intern : "));
internQualityPanel.add(new JLabel("Quality "));
internQualityPanel.add(jSliderPqPs);
internQualityPanel.add(new JLabel(" Similarity"));
JPanel gammaQualityPanel = new JPanel();
gammaQualityPanel.add(new JLabel("K-Int/Ext : "));
gammaQualityPanel.add(new JLabel("K-Extern "));
gammaQualityPanel.add(jSliderPePi);
gammaQualityPanel.add(new JLabel(" K-Intern"));
JPanel constraintsQualityPanel = new JPanel();
constraintsQualityPanel.add(new JLabel("Gamma : "));
constraintsQualityPanel.add(new JLabel("Constraints "));
constraintsQualityPanel.add(jSliderConstraints);
constraintsQualityPanel.add(new JLabel(" K-Int/Ext"));
JPanel degrapdationPanel = new JPanel();
degrapdationPanel.add(new JLabel("Degradation :"));
degrapdationPanel.add(new JLabel("None"));
degrapdationPanel.add(degradationSlider);
degrapdationPanel.add(new JLabel(" Full "));
JPanel qualityPanel = new JPanel();
qualityPanel.setLayout(new BoxLayout(qualityPanel, BoxLayout.Y_AXIS));
qualityPanel.add(internQualityPanel);
qualityPanel.add(gammaQualityPanel);
qualityPanel.add(constraintsQualityPanel);
qualityPanel.add(degrapdationPanel);
JSeparator separator = new JSeparator(JSeparator.VERTICAL);
separator.setPreferredSize(new Dimension(15, 120));
JSeparator separator2 = new JSeparator(JSeparator.VERTICAL);
separator2.setPreferredSize(new Dimension(15, 120));
JPanel jPanelNbClasses = new JPanel();
jPanelNbClasses.add(jCheckBoxNbClasses);
jPanelNbClasses.add(jTextFieldNInf);
jPanelNbClasses.add(new JLabel(" And "));
jPanelNbClasses.add(jTextFieldNSup);
criterionComboBox = new JComboBox<String>(ClusteringEvaluation.NAME);
((JLabel) criterionComboBox.getRenderer()).setHorizontalAlignment(SwingConstants.CENTER);
JPanel criterionPanel = new JPanel();
criterionPanel.add(new JLabel("Evaluation Criterion"));
criterionPanel.add(criterionComboBox);
unificationbCheckBox = new JCheckBox("Unification With Unclassified Objects");
JPanel unificationPanel = new JPanel();
unificationPanel.add(unificationbCheckBox);
resetButton = new JButton("Reset Default Values");
JPanel resetPanel = new JPanel();
resetPanel.add(resetButton);
JPanel evaluationPanel = new JPanel();
evaluationPanel.setLayout(new BoxLayout(evaluationPanel, BoxLayout.Y_AXIS));
evaluationPanel.add(jPanelNbClasses);
evaluationPanel.add(criterionPanel);
evaluationPanel.add(unificationPanel);
evaluationPanel.add(resetPanel);
// Parameters panel
JPanel jPanelParameters = new JPanel();
jPanelParameters.add(precisionPanel);
jPanelParameters.add(Box.createHorizontalStrut(10));
jPanelParameters.add(separator);
jPanelParameters.add(qualityPanel);
jPanelParameters.add(Box.createHorizontalStrut(10));
jPanelParameters.add(separator2);
jPanelParameters.add(evaluationPanel);
jListAgents.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
jScrollPaneAgents.setViewportView(jListAgents);
jScrollPaneAgents.setBorder(titledBorderAgents);
JPanel jPanelAgents = new JPanel(new BorderLayout());
jPanelAgents.add(jScrollPaneAgents, BorderLayout.CENTER);
jPanelAgents.add(toolBar, BorderLayout.EAST);
parametersPanel = new HybridClassificationSubParametersPanel(this.samarah);
setLayout(new BorderLayout());
this.add(jPanelAgents, BorderLayout.CENTER);
this.add(jPanelParameters, BorderLayout.SOUTH);
this.add(parametersPanel, BorderLayout.SOUTH);
toolBar.setFloatable(false);
toolBar.setOrientation(SwingConstants.VERTICAL);
......@@ -439,45 +245,6 @@ public class HybridClassificationPanel extends JPanel implements AgentListManage
jButtonDelAgent_actionPerformed(e);
}
});
resetButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
resetButtonAction();
}
});
}
public static void centerSpinnerText(JSpinner spinner) {
JSpinner.DefaultEditor spinnerEditor = (JSpinner.DefaultEditor) spinner.getEditor();
spinnerEditor.getTextField().setHorizontalAlignment(JTextField.CENTER);
}
/**
* Reset parameters value to defaults.
*/
public void resetButtonAction() {
int choice = JOptionPane.showConfirmDialog(this, "This action will overwrite values you changed. Do you want to continue ? ",
"Reset Confirmation", JOptionPane.YES_NO_OPTION);
if (choice != JOptionPane.YES_OPTION)
return;
conflictSpinner.setValue(0.90);
solutionTypeSpinner.setValue(3);
classRatioSpinner.setValue(0.01);
pcrSpinner.setValue(0.2);
jSliderPqPs.setValue(50);
jSliderPePi.setValue(66);
jSliderConstraints.setValue(0);
degradationSlider.setValue(90);
jTextFieldNInf.setEnabled(false);
jTextFieldNSup.setEnabled(false);
jCheckBoxNbClasses.setSelected(false);
nbClass = false;
criterionComboBox.setSelectedIndex(0);
unificationbCheckBox.setSelected(false);
}
/**
......@@ -490,6 +257,8 @@ public class HybridClassificationPanel extends JPanel implements AgentListManage
cd = new AgentDialog(this);
if (!this.selectData)
cd.classifierPanel.setTabbed();
cd.setLocationRelativeTo(this);
cd.setModal(true);
cd.setVisible(true);
}
......@@ -551,24 +320,6 @@ public class HybridClassificationPanel extends JPanel implements AgentListManage
}
}
/**
* <p>
* Selection de l'option nombre de classes impose.
* </p>
* @param e l'evenement ayant declenche l'action
*/
void jCheckBoxNbClasses_actionPerformed(ActionEvent e) {
this.nbClass = !this.nbClass;
if (this.nbClass) {
this.jTextFieldNSup.setEnabled(true);
this.jTextFieldNInf.setEnabled(true);
}
else {
this.jTextFieldNSup.setEnabled(false);
this.jTextFieldNInf.setEnabled(false);
}
}
@Override
public void removeAgent(int index) {
// TODO: gérer proprement la suppression d'un agent dans samarah
......@@ -599,72 +350,6 @@ public class HybridClassificationPanel extends JPanel implements AgentListManage
this.samarah.setData(data);
}
/**
* <p>
* Methode de mise-a-jour des parametres.
* </p>
*/
public void setParameters() {
// parametres pour le nombre de classes
int nInf = -1;
int nSup = -1;
if (nbClass)
try {
nInf = Integer.parseInt(jTextFieldNInf.getText());
nSup = Integer.parseInt(jTextFieldNSup.getText());
if (nInf < 0 || nSup < 0) {
nInf = -1;
nSup = -1;
jTextFieldNInf.setText("");
jTextFieldNSup.setText("");
}
else if (nInf > nSup) {
int tmp = nSup;
nSup = nInf;
nInf = tmp;
jTextFieldNInf.setText(String.valueOf(nInf));
jTextFieldNSup.setText(String.valueOf(nSup));
}
} catch (Exception ex) {
nInf = -1;
nSup = -1;
jTextFieldNInf.setText("");
jTextFieldNSup.setText("");
}
// parametre pour la precision des conflits
double minC = -1;
try {
minC = (double) conflictSpinner.getValue();
} catch (Exception ex) {
minC = -1;
}
// parametre pour les classes representatives
double pcr = (double) pcrSpinner.getValue();
// parametre qualite/similitude
double pq = jSliderPqPs.getValue() / 100.0;
double ps = 1.0 - pq;
double constraintsWgt = jSliderConstraints.getValue();
double kExtern = jSliderPePi.getValue() * ((100-constraintsWgt)/100);