package guicomponents;
import java.awt.Component;
import java.awt.Container;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.LayoutManager;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.JPanel;
import guicomponents.CompRepRadioButtonsPanel;
import guicomponents.TableOptionsPanel;
import guicomponents.Plot2DPanel;
import guicomponents.Plot3DPanel;
public class CompRepAnd2DAnd3DAndTableOptions extends JPanel {
/**
*
*/
private static final long serialVersionUID = 1L;
public CompRepRadioButtonsPanel compRepPanel;
public Plot2DPanel p2dPanel;
public Plot3DPanel p3dPanel;
public TableOptionsPanel tabOptPanel;
private GridBagLayout gbl;
public CompRepAnd2DAnd3DAndTableOptions(String labelFreq, String label3DPlot, String labelTabel) {
compRepPanel = new CompRepRadioButtonsPanel();
p2dPanel = new Plot2DPanel(labelFreq);
p3dPanel = new Plot3DPanel(label3DPlot);
tabOptPanel = new TableOptionsPanel(labelTabel);
gbl = new GridBagLayout();
this.setLayout(gbl);
// Z Z Z Z F
// e e e e ü
// l l l l l
// l l l l l
// s z w h v
// p e e o e
// a i i e r
// l l t h h
// t e e e a
// e l
// t
// e
// n
// g g g g f i i a w w
// r r r r i p p n e e
// i i i i l a a c i i
// d d d d l d d h g g
// x y w h x y o h h
// i e r t t
// d i x y
// t g
// h h
// t
addComponent(this, gbl, compRepPanel, 0, 0, 4, 1, GridBagConstraints.NONE, 0, 0, GridBagConstraints.LINE_START,0, 0);
addComponent(this, gbl, p2dPanel, 0, 1, 2, 3, GridBagConstraints.NONE, 0, 0, GridBagConstraints.LINE_START,0, 0);
addComponent(this, gbl, p3dPanel, 0, 5, 2, 3, GridBagConstraints.NONE, 0, 0, GridBagConstraints.LINE_START,0, 0);
addComponent(this, gbl, tabOptPanel, 0, 8, 2, 3, GridBagConstraints.NONE, 0, 0, GridBagConstraints.LINE_START,0, 0);
//Operations
compRepPanel.jrb_compute.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
p2dPanel.chk2DPlotCaption.setSelected(false);
p2dPanel.chk2DPlotCaption.setEnabled(false);
p2dPanel.txf2DPlotCaption.setEnabled(false);
p3dPanel.chk3dPlotCaption.setSelected(false);
p3dPanel.chk3dPlotCaption.setEnabled(false);
p3dPanel.txf3dPlotCaption.setEnabled(false);
tabOptPanel.chkCaption.setSelected(false);
tabOptPanel.chkCaption.setEnabled(false);
tabOptPanel.txfCaption.setEnabled(false);
tabOptPanel.chkDigits.setSelected(false);
tabOptPanel.chkDigits.setEnabled(false);
tabOptPanel.sprDigits.setEnabled(false);
}
});
compRepPanel.jrb_report.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if ( p2dPanel.chk2DPlot.isSelected() ){
p2dPanel.chk2DPlotCaption.setEnabled(true);
// p2dPanel.txf2DPlotCaption.setEnabled(true);
}
if ( p3dPanel.chk3dPlot.isSelected() ){
p3dPanel.chk3dPlotCaption.setEnabled(true);
// p3dPanel.txf3dPlotCaption.setEnabled(true);
}
if ( tabOptPanel.chkTable.isSelected() ){
tabOptPanel.chkCaption.setEnabled(true);
// tabOptPanel.txfCaption.setEnabled(true);
tabOptPanel.chkDigits.setEnabled(true);
// tabOptPanel.sprDigits.setEnabled(true);
}
}
});
compRepPanel.jrb_compAndRep.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
// p2dPanel.chk2DPlotCaption.setEnabled(p2dPanel.chk2DPlot.isSelected());
if ( p2dPanel.chk2DPlot.isSelected() ){
p2dPanel.chk2DPlotCaption.setEnabled(true);
// p2dPanel.txf2DPlotCaption.setEnabled(true);
}
if ( p3dPanel.chk3dPlot.isSelected() ){
p3dPanel.chk3dPlotCaption.setEnabled(true);
// p3dPanel.txf3dPlotCaption.setEnabled(true);
}
if ( tabOptPanel.chkTable.isSelected() ){
tabOptPanel.chkCaption.setEnabled(true);
// tabOptPanel.txfCaption.setEnabled(true);
tabOptPanel.chkDigits.setEnabled(true);
// tabOptPanel.sprDigits.setEnabled(true);
}
}
});
//2D-Plot
p2dPanel.chk2DPlot.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
p2dPanel.lbl2DPlotLabel.setEnabled(true);
p2dPanel.txf2DPlotLabel.setEnabled(true);
if (compRepPanel.jrb_compAndRep.isSelected() || compRepPanel.jrb_report.isSelected()){
p2dPanel.chk2DPlotCaption.setEnabled(true);
}
}
if (e.getStateChange() == ItemEvent.DESELECTED) {
p2dPanel.lbl2DPlotLabel.setEnabled(false);
p2dPanel.txf2DPlotLabel.setEnabled(false);
p2dPanel.chk2DPlotCaption.setSelected(false);
p2dPanel.chk2DPlotCaption.setEnabled(false);
p2dPanel.txf2DPlotCaption.setEnabled(false);
}
}
});
/*
p2dPanel.txf2DPlotCaption.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent fEvent) {
if (p2dPanel.txf2DPlotCaption.getText().equals("type caption here")) {
p2dPanel.txf2DPlotCaption.setText("");
}
}
public void focusLost(FocusEvent fEvent) {
;
}
});
p2dPanel.txf2DPlotLabel.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent fEvent) {
if (p2dPanel.txf2DPlotLabel.getText().equals("type label here")) {
p2dPanel.txf2DPlotLabel.setText("");
}
}
public void focusLost(FocusEvent fEvent) {
;
}
});
p2dPanel.txf2DPlotLabel.addMouseListener(new MouseListener() {
public void mousePressed(MouseEvent mEvent) {
;
}
public void mouseEntered(MouseEvent mEvent) {
;
}
public void mouseExited(MouseEvent mEvent) {
;
}
public void mouseClicked(MouseEvent mEvent) {
// chk2DPlot.setSelected(true);
// lbl2DPlotLabel.setEnabled(true);
// lbl2DPlotLabel.setSelected(true);
// txf2DPlotLabel.setEnabled(true);
}
public void mouseReleased(MouseEvent mEvent) {
;
}
});
p2dPanel.txf2DPlotCaption.addMouseListener(new MouseListener() {
public void mousePressed(MouseEvent mEvent) {
;
}
public void mouseEntered(MouseEvent mEvent) {
;
}
public void mouseExited(MouseEvent mEvent) {
;
}
public void mouseClicked(MouseEvent mEvent) {
p2dPanel.chk2DPlot.setSelected(true);
p2dPanel.chk2DPlotCaption.setEnabled(true);
p2dPanel.chk2DPlotCaption.setSelected(true);
p2dPanel.txf2DPlotCaption.setEnabled(true);
}
public void mouseReleased(MouseEvent mEvent) {
;
}
}); */
//3D-Plot
p3dPanel.chk3dPlot.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
boolean istEsAngekreuzt = (e.getStateChange() == ItemEvent.SELECTED);
p3dPanel.lbl3dPlotLabel.setEnabled( istEsAngekreuzt );
p3dPanel.txf3dPlotLabel.setEnabled( istEsAngekreuzt );
if ((e.getStateChange() == ItemEvent.SELECTED)) {
if (compRepPanel.jrb_compAndRep.isSelected() || compRepPanel.jrb_report.isSelected()){
p3dPanel.chk3dPlotCaption.setEnabled(true);
}
}
if (e.getStateChange() == ItemEvent.DESELECTED) {
p3dPanel.chk3dPlotCaption.setSelected(false);
p3dPanel.chk3dPlotCaption.setEnabled(false);
p3dPanel.txf3dPlotCaption.setEnabled(false);
}
}
});
/*
p3dPanel.txf3dPlotCaption.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent fEvent) {
if (p3dPanel.txf3dPlotCaption.getText().equals("type caption here")) {
p3dPanel.txf3dPlotCaption.setText("");
}
}
public void focusLost(FocusEvent fEvent) {
;
}
});
p3dPanel.txf3dPlotLabel.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent fEvent) {
if (p3dPanel.txf3dPlotLabel.getText().equals("type label here")) {
p3dPanel.txf3dPlotLabel.setText("");
}
}
public void focusLost(FocusEvent fEvent) {
;
}
});
p3dPanel.txf3dPlotLabel.addMouseListener(new MouseListener() {
public void mousePressed(MouseEvent mEvent) {
;
}
public void mouseEntered(MouseEvent mEvent) {
;
}
public void mouseExited(MouseEvent mEvent) {
;
}
public void mouseClicked(MouseEvent mEvent) {
// chk3dPlot.setSelected(true);
// lbl3dPlotLabel.setEnabled(true);
// lbl3dPlotLabel.setSelected(true);
// txf3dPlotLabel.setEnabled(true);
}
public void mouseReleased(MouseEvent mEvent) {
;
}
});
p3dPanel.txf3dPlotCaption.addMouseListener(new MouseListener() {
public void mousePressed(MouseEvent mEvent) {
;
}
public void mouseEntered(MouseEvent mEvent) {
;
}
public void mouseExited(MouseEvent mEvent) {
;
}
public void mouseClicked(MouseEvent mEvent) {
p3dPanel.chk3dPlot.setSelected(true);
p3dPanel.chk3dPlotCaption.setEnabled(true);
p3dPanel.chk3dPlotCaption.setSelected(true);
p3dPanel.txf3dPlotCaption.setEnabled(true);
}
public void mouseReleased(MouseEvent mEvent) {
;
}
}); */
//TableOptions
tabOptPanel.chkTable.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
tabOptPanel.lblLabel.setEnabled(true);
tabOptPanel.txfLabel.setEnabled(true);
if (compRepPanel.jrb_compAndRep.isSelected() || compRepPanel.jrb_report.isSelected()){
tabOptPanel.chkCaption.setEnabled(true);
tabOptPanel.chkDigits.setEnabled(true);
}
}
if (e.getStateChange() == ItemEvent.DESELECTED) {
tabOptPanel.lblLabel.setEnabled(false);
tabOptPanel.txfLabel.setEnabled(false);
tabOptPanel.chkCaption.setSelected(false);
tabOptPanel.chkCaption.setEnabled(false);
tabOptPanel.txfCaption.setEnabled(false);
tabOptPanel.chkDigits.setSelected(false);
tabOptPanel.chkDigits.setEnabled(false);
tabOptPanel.sprDigits.setEnabled(false);
}
}
});
/*
tabOptPanel.txfCaption.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent fEvent) {
if (compRepPanel.jrb_compAndRep.isSelected() || compRepPanel.jrb_report.isSelected()){
if (tabOptPanel.txfCaption.getText().equals("type caption here")) {
tabOptPanel.txfCaption.setText("");
}
}
}
public void focusLost(FocusEvent fEvent) {
;
}
});
tabOptPanel.txfLabel.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent fEvent) {
if (compRepPanel.jrb_compAndRep.isSelected() || compRepPanel.jrb_report.isSelected()){
if (tabOptPanel.txfLabel.getText().equals("type label here")) {
tabOptPanel.txfLabel.setText("");
}
}
}
public void focusLost(FocusEvent fEvent) {
;
}
});
tabOptPanel.txfLabel.addMouseListener(new MouseListener() {
public void mousePressed(MouseEvent mEvent) {
;
}
public void mouseEntered(MouseEvent mEvent) {
;
}
public void mouseExited(MouseEvent mEvent) {
;
}
public void mouseClicked(MouseEvent mEvent) {
if (compRepPanel.jrb_report.isSelected() || compRepPanel.jrb_compAndRep.isSelected()){
;
}
}
public void mouseReleased(MouseEvent mEvent) {
;
}
});
tabOptPanel.txfCaption.addMouseListener(new MouseListener() {
public void mousePressed(MouseEvent mEvent) {
;
}
public void mouseEntered(MouseEvent mEvent) {
;
}
public void mouseExited(MouseEvent mEvent) {
;
}
public void mouseClicked(MouseEvent mEvent) {
if (compRepPanel.jrb_report.isSelected() || compRepPanel.jrb_compAndRep.isSelected()){
tabOptPanel.chkCaption.setEnabled(true);
tabOptPanel.chkCaption.setSelected(true);
tabOptPanel.txfCaption.setEnabled(true);
}
}
public void mouseReleased(MouseEvent mEvent) {
;
}
});
tabOptPanel.sprDigits.addMouseListener(new MouseListener(){
public void mousePressed(MouseEvent mEvent){
;
}
public void mouseEntered(MouseEvent mEvent){
;
}
public void mouseExited(MouseEvent mEvent){
;
}
public void mouseClicked(MouseEvent mEvent){
tabOptPanel.chkDigits.setEnabled(true);
tabOptPanel.chkDigits.setSelected(true);
tabOptPanel.sprDigits.setEnabled(true);
}
public void mouseReleased(MouseEvent mEvent){
;
}
});
*/
// TODO Auto-generated constructor stub
}
public CompRepAnd2DAnd3DAndTableOptions(LayoutManager arg0) {
super(arg0);
// TODO Auto-generated constructor stub
}
public CompRepAnd2DAnd3DAndTableOptions(boolean arg0) {
super(arg0);
// TODO Auto-generated constructor stub
}
public CompRepAnd2DAnd3DAndTableOptions(LayoutManager arg0, boolean arg1) {
super(arg0, arg1);
// TODO Auto-generated constructor stub
}
private void addComponent(Container cont,
GridBagLayout gbl,
Component c,
int gridx, int gridy,
int gridwidth, int gridheight,
int fill,
int ipadx, int ipady,
/* Insets insets, */
int anchor,
double weightx, double weighty) {
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = gridx;
gbc.gridy = gridy; // Spalte/Reihe mit ganz links = 0 und ganz oben = 0
gbc.gridwidth = gridwidth;
gbc.gridheight = gridheight; // Anzahl Spalten/Reihen, die Komponente nutzt - DEFAULT = 1;
gbc.fill = fill; // entscheidet howto resize the component, wenn sie vergrößert wird = NONE , HORIZONTAL, VERTICAL, BOTH
gbc.ipadx = ipadx;
gbc.ipady = ipady; // interne Füllung (howmuch to add to the minimum weight/height of the component
// gbc.insets = insets; // externe Füllung (howmuch is the minimum space between component and the edges of its display area)
gbc.anchor = anchor; // used if component kleiner als seine display area (verschiedene Konstanten)
gbc.weightx = weightx;
gbc.weighty = weighty; // determines howto distribute space among columns and rows
gbl.setConstraints(c, gbc);
cont.add(c);
}
public Plot2DPanel getFreqPanel() {
// TODO Auto-generated method stub
return p2dPanel;
}
public Plot3DPanel getPlot3DPanel() {
// TODO Auto-generated method stub
return p3dPanel;
}
public TableOptionsPanel getTablePanel() {
// TODO Auto-generated method stub
return tabOptPanel;
}
public boolean isEvaled() {
// TODO Auto-generated method stub
return compRepPanel.isEvaled();
}
public boolean isInReport() {
// TODO Auto-generated method stub
return compRepPanel.isInReport();
}
}