/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Copyright (C) 2013 Marchand Eric <ricoh51@free.fr>
This file is part of Freegressi.
Freegressi is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Freegressi is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Freegressi. If not, see <http://www.gnu.org/licenses/>.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
package freegressi.graphics;
import freegressi.tableur.SpreadSheets;
import freegressi.tableur.Tableur;
/**
*
* @author marchand, 15 avr. 2013, 11:21:33
*/
public class JPanelAbscissa extends javax.swing.JPanel {
private final JDialogEditCurves jdec;
private boolean flag = false;
public JPanelAbscissa(JDialogEditCurves jdec, GraphicStyle graphicStyle) {
initComponents();
this.jdec = jdec;
Tableur sheet = SpreadSheets.getInstance().getActiveSheet();
jcbName.setModel(new javax.swing.DefaultComboBoxModel(sheet.donneTableauDeNoms()));
jcbPosition.setModel(new javax.swing.DefaultComboBoxModel(Position.getHorizontalPositionArray()));
// jcbName.setSelectedItem(graphicStyle.getaX1().getName());
// int pos = Position.getBinaryIndex(graphicStyle.getaX1().getAxisStyle().getPosition());
jcbName.setSelectedItem(graphicStyle.getAbscissa());
int pos = Position.getBinaryIndex(graphicStyle.getAbscissaPosition());
jcbPosition.setSelectedIndex(pos);
//name = jcbName.getSelectedItem().toString();
flag = true;
}
public String getAbscissaName(){
return jcbName.getSelectedItem().toString();
}
public Position getAbscissaPosition(){
return Position.getPosition(jcbPosition.getSelectedItem().toString());
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jcbName = new javax.swing.JComboBox();
jcbPosition = new javax.swing.JComboBox();
jcbName.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jcbNameActionPerformed(evt);
}
});
jcbPosition.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jcbPositionActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jcbName, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jcbPosition, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(54, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jcbName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jcbPosition, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
}// </editor-fold>//GEN-END:initComponents
private void jcbPositionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcbPositionActionPerformed
if (flag) {
//jdec.notifyPositionChanged(this);
jdec.notifyAbscissaPositionChanged(getAbscissaPosition());
}
}//GEN-LAST:event_jcbPositionActionPerformed
private void jcbNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcbNameActionPerformed
if (flag) {
String name = jcbName.getSelectedItem().toString();
jdec.notifyNameChanged( name, getAbscissaPosition());
}
}//GEN-LAST:event_jcbNameActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JComboBox jcbName;
private javax.swing.JComboBox jcbPosition;
// End of variables declaration//GEN-END:variables
}