package gui;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Component;
import java.util.Enumeration;
import guicomponents.OneSetSelectionPanel;
import guicomponents.CompRepAnd2DAnd3DAndTableOptions;
import dao.PlotSweaveTag;
import dao.RObject;
import dao.RObjectViewportPlotSysch3D;
import dao.RObjectViewportPlotSyschFreq;
import dao.RObjectViewportTable;
import dao.TableSweaveTag;
import datastructures.ItemSet;
public class SystemCharacteristicsItemSelectionFrame extends JFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* Class variables
*
*/
private JButton cancel;
private JButton ok;
private GridBagLayout gbl;
private OneSetSelectionPanel osSelPanel;
private CompRepAnd2DAnd3DAndTableOptions compRep2d3dtabOptPanel;
public SystemCharacteristicsItemSelectionFrame() {
super.setTitle("System-Characteristics Test");
this.setIconImage(
new ImageIcon("./images/i16x16/isop_favicon.png").getImage());
osSelPanel = new OneSetSelectionPanel();
String rVarName = dao.Controller.fitRVarName("sysch");
compRep2d3dtabOptPanel = new CompRepAnd2DAnd3DAndTableOptions(
dao.Controller.fitName(rVarName + ".freq"),
dao.Controller.fitName(rVarName + ".plot3d"),
dao.Controller.fitName(rVarName + ".table")
);
// leftList.setFixedCellHeight(10);
// leftList.setFixedCellWidth(10);
cancel = new JButton("Cancel");
ok = new JButton("OK");
/* set Tooltips for each component
leftLabel.setToolTipText("This is only a test.");
rightLabel.setToolTipText("This is only a test.");
fuellLabel1.setToolTipText("This is only a test.");
fuellLabel2.setToolTipText("This is only a test.");
fuellLabel3.setToolTipText("This is only a test.");
fuellLabel4.setToolTipText("This is only a test.");
toRight.setToolTipText("This is only a test.");
toLeft.setToolTipText("This is only a test.");
onlyCompute.setToolTipText("This is only a test.");
computeAndReport.setToolTipText("This is only a test.");
onlyReport.setToolTipText("This is only a test.");
cancel.setToolTipText("This is only a test.");
rightList.setToolTipText("This is only a test.");
leftList.setToolTipText("This is only a testtest.");
sep.setToolTipText("This is only a test.");
chkLatex.setToolTipText("This is only a test.");
chkVerbose.setToolTipText("Das ist Verbose");
chk_n.setToolTipText("This is only a test.");
chk_p.setToolTipText("This is only a test.");
chk_g.setToolTipText("This is only a test.");
chk_s.setToolTipText("This is only a test.");
chk_ubas.setToolTipText("This is only a test.");
chk_i.setToolTipText("This is only a test.");
chk_c.setToolTipText("This is only a test.");
chk_nsq.setToolTipText("This is only a test.");
chk_z.setToolTipText("This is only a test."); */
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 i a w w
// r r r r i p p n n e e
// i i i i l a a s c i i
// d d d d l d d e h g g
// x y w h x y t o h h
// i e s r t t
// d i x y
// t g
// h h
// t
addComponent(this, gbl, osSelPanel, 0, 0, 4, 4, GridBagConstraints.HORIZONTAL, 0, 0, GridBagConstraints.CENTER, 0,0);
addComponent(this, gbl, compRep2d3dtabOptPanel,0, 4, 4, 13, GridBagConstraints.HORIZONTAL, 0, 0, GridBagConstraints.CENTER, 0,0);
addComponent(this, gbl, cancel, 3, 17,1, 1, GridBagConstraints.VERTICAL, 0, 0, GridBagConstraints.EAST, 0, 0);
addComponent(this, gbl, ok, 0, 17,1, 1, GridBagConstraints.VERTICAL, 0, 0, GridBagConstraints.CENTER, 0, 0);
cancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
btncancelClicked();
}
});
ok.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
btnOkClicked();
}
});
}
/**
* @param computeEnabled
* @param reportEnabled
*/
private void btncancelClicked() {
this.setVisible(false);
}
private void btnOkClicked() {
for (Enumeration<ItemSet> eis = osSelPanel.getItemSets(); eis.hasMoreElements(); ) {
ItemSet is = eis.nextElement();
String rVarName = dao.Controller.fitRVarName("sysch");
RObject sysch = new RObject(rVarName, "isop.sysch(" + is.getRString() + ")");
if (compRep2d3dtabOptPanel.getTablePanel().isSelected()) {
RObjectViewportTable syschtab = new RObjectViewportTable(compRep2d3dtabOptPanel.getTablePanel().getLabel(),
sysch);
TableSweaveTag tabswvtag;
if (compRep2d3dtabOptPanel.isInReport()) {
tabswvtag = new TableSweaveTag(syschtab);
tabswvtag.setLabel(compRep2d3dtabOptPanel.getTablePanel().getLabel());
tabswvtag.setCaption(compRep2d3dtabOptPanel.getTablePanel().getCaption());
tabswvtag.setDigits(compRep2d3dtabOptPanel.getTablePanel().getDigits());
} else tabswvtag = null;
dao.Controller.addTable(syschtab, compRep2d3dtabOptPanel.isEvaled(), compRep2d3dtabOptPanel.isEvaled(),
tabswvtag);
}
if (compRep2d3dtabOptPanel.getPlot3DPanel().isSelected()) {
RObjectViewportPlotSysch3D sysch3dPlot = new RObjectViewportPlotSysch3D(compRep2d3dtabOptPanel.getPlot3DPanel().getLabel(), sysch);
PlotSweaveTag tabswvtag;
if (compRep2d3dtabOptPanel.isInReport()) {
tabswvtag = new PlotSweaveTag(sysch3dPlot);
// tabswvtag.setCaption(compRep2d3dtabOptPanel.getTablePanel().getCaption());
} else tabswvtag = null;
dao.Controller.addPlot(sysch3dPlot, compRep2d3dtabOptPanel.isEvaled(), false,
false, tabswvtag);
}
if (compRep2d3dtabOptPanel.getFreqPanel().isSelected()) {
RObjectViewportPlotSyschFreq freqPlot = new RObjectViewportPlotSyschFreq( compRep2d3dtabOptPanel.getFreqPanel().getLabel(), sysch);
PlotSweaveTag tabswvtag;
if (compRep2d3dtabOptPanel.isInReport()) {
tabswvtag = new PlotSweaveTag(freqPlot);
// tabswvtag.setCaption(compRep2d3dtabOptPanel.getTablePanel().getCaption());
} else tabswvtag = null;
dao.Controller.addPlot(freqPlot,compRep2d3dtabOptPanel.isEvaled(), false,
false, tabswvtag);
}
}
this.setVisible(false);
}
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);
}
}