import java.awt.Color;
import java.awt.event.AdjustmentEvent;
import java.awt.event.AdjustmentListener;
import javax.swing.JPanel;
import javax.swing.JScrollBar;
import javax.swing.JSlider;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
public class EEGReformat {
//private EEG aEEG = null;
String[][] ReformKanal;
IReformat aReformat;
/*public EEGReformat(){
//this.aEEG = aEEG;
//ReformKanal = new String [32][32];
}*/
public void Such_Algo_M(EEG aEEG, String knot1, String knot2, int id1, int id2,String[] ReformCanal, int[] ReformCanalIndex, String[] ReformOperation)
{
for (int i = 0; i< aEEG.getkanalnumber(); i++){
if (knot1.equalsIgnoreCase(aEEG.getKnoten1(i)))
{
//System.out.println(i);
for (int j = 0; j< aEEG.getkanalnumber(); j++){
if (knot2.equalsIgnoreCase(aEEG.getKnoten1(j))) // A Anfang, B Anfang
{
//System.out.println(j);
if (aEEG.getKnoten2(i).equalsIgnoreCase(aEEG.getKnoten2(j)))
{
//addMPanel(aEEG, knot1, knot2, ReformCanal, ReformCanalIndex, ReformOperation, i, j, id1, id2, "Reformat_1");
System.out.println("Reformat_1");
System.out.println(i+"-"+j+": "+knot1 +" - " + knot2);
ReformCanalIndex[id1]=i+1;
ReformCanalIndex[id1+1]=j+1;
ReformCanal[id2]= aEEG.getKnoten1(i) +" - " + aEEG.getKnoten1(j);
ReformOperation[id2]="Reformat_1";
break;
}
}
else if (knot2.equalsIgnoreCase(aEEG.getKnoten2(j))) //A Anfang, B End
{
System.out.println(j);
if (aEEG.getKnoten2(i).equalsIgnoreCase(aEEG.getKnoten2(j)))
{
//addMPanel(aEEG, knot1, knot2, ReformCanal, ReformCanalIndex,ReformOperation, i, j, id1, id2, "Reformat_2");
System.out.println("Reformat_2");
System.out.println(i+"-"+j+": "+knot1 +" - " + knot2);
ReformCanalIndex[id1]=i+1;
ReformCanalIndex[id1+1]=j+1;
ReformCanal[id2]= aEEG.getKnoten1(i) +" - " + aEEG.getKnoten2(j);
ReformOperation[id2]="Reformat_2";
break;
}}}
break;
}
else if (knot1.equalsIgnoreCase(aEEG.getKnoten2(i)))
{
System.out.println(i);
for (int j = 0; j< aEEG.getkanalnumber(); j++){
if (knot2.equalsIgnoreCase(aEEG.getKnoten1(j))) // A End, B Anfang
{
System.out.println(j);
if (aEEG.getKnoten2(i).equalsIgnoreCase(aEEG.getKnoten2(j)))
{
//addMPanel(aEEG, knot1, knot2, ReformCanal, ReformCanalIndex,ReformOperation, i, j, id1, id2, "Reformat_3");
System.out.println("Reformat_3");
System.out.println(i+"-"+j+": "+knot1 +" - " + knot2);
ReformCanalIndex[id1]=i+1;
ReformCanalIndex[id1+1]=j+1;
ReformCanal[id2]= aEEG.getKnoten2(i) +" - " + aEEG.getKnoten1(j);
ReformOperation[id2]="Reformat_3";
break;
}
//break;
}
else if (knot2.equalsIgnoreCase(aEEG.getKnoten2(j))) //A End, B End
{
System.out.println(j);
if (aEEG.getKnoten2(i).equalsIgnoreCase(aEEG.getKnoten2(j)))
{
//addMPanel(aEEG, knot1, knot2, ReformCanal, ReformCanalIndex,ReformOperation, i, j, id1, id2, "Reformat_4");
System.out.println("Reformat_4");
System.out.println(i+"-"+j+": "+knot1 +" - " + knot2);
ReformCanalIndex[id1]=i+1;
ReformCanalIndex[id1+1]=j+1;
ReformCanal[id2]= aEEG.getKnoten2(i) +" - " + aEEG.getKnoten2(j);
ReformOperation[id2]="Reformat_4";
break;
}}}
break;
}}}
public void Such_Algo_R(EEG aEEG, String knot1, String knot2, JPanel panel, JPanel rpanel, EPanel epanel)
{
for (int i = 0; i< aEEG.getkanalnumber(); i++){
if (knot1.equalsIgnoreCase(aEEG.getKnoten1(i)))
{
//System.out.println(i);
for (int j = 0; j< aEEG.getkanalnumber(); j++){
if (knot2.equalsIgnoreCase(aEEG.getKnoten1(j))) // A Anfang, B Anfang
{
//System.out.println(j);
if (aEEG.getKnoten2(i).equalsIgnoreCase(aEEG.getKnoten2(j)))
{
aReformat = new Reformat_1(aEEG);
addRPanel(aReformat, aEEG, knot1, knot2, rpanel, epanel, i, j, "Reformat_1");
break;
}
}
else if (knot2.equalsIgnoreCase(aEEG.getKnoten2(j))) //A Anfang, B End
{
System.out.println(j);
if (aEEG.getKnoten2(i).equalsIgnoreCase(aEEG.getKnoten2(j)))
{
if (aEEG.getKnoten2(i).equalsIgnoreCase(aEEG.getKnoten2(j)))
{
aReformat = new Reformat_2(aEEG);
addRPanel(aReformat, aEEG, knot1, knot2, rpanel, epanel, i, j, "Reformat_2");
break;
}}}}
break;
}
else if (knot1.equalsIgnoreCase(aEEG.getKnoten2(i)))
{
System.out.println(i);
for (int j = 0; j< aEEG.getkanalnumber(); j++){
if (knot2.equalsIgnoreCase(aEEG.getKnoten1(j))) // A End, B Anfang
{
System.out.println(j);
if (aEEG.getKnoten2(i).equalsIgnoreCase(aEEG.getKnoten2(j)))
{
if (aEEG.getKnoten2(i).equalsIgnoreCase(aEEG.getKnoten2(j)))
{
aReformat = new Reformat_3(aEEG);
addRPanel(aReformat, aEEG, knot1, knot2, rpanel, epanel, i, j, "Reformat_3");
break;
}
}
else if (knot2.equalsIgnoreCase(aEEG.getKnoten2(j))) //A End, B End
{
System.out.println(j);
if (aEEG.getKnoten2(i).equalsIgnoreCase(aEEG.getKnoten2(j)))
{
if (aEEG.getKnoten2(i).equalsIgnoreCase(aEEG.getKnoten2(j)))
{
aReformat = new Reformat_4(aEEG);
addRPanel(aReformat, aEEG, knot1, knot2, rpanel, epanel, i, j, "Reformat_4");
break;
}}}}}
break;
}}}
public void addRPanel(final IReformat aReformat,EEG aEEG, String knot1, String knot2, JPanel rpanel, EPanel epanel, int i, int j, String reformat_x)
{
System.out.println(knot1 +" - " + knot2);
System.out.println(reformat_x);
final JSlider vslider = createSlider(JSlider.VERTICAL, 1,10,1, 1,1,0,128,128);
vslider.addChangeListener(new ChangeListener()
{ public void stateChanged(ChangeEvent e){
System.out.println("Wert"+vslider.getValue());
((interface_DrawPanel) aReformat).HorizontalVergr(vslider.getValue());
}
});
final JScrollBar sb = new JScrollBar(JScrollBar.HORIZONTAL, 0,20 , 0, 20000);
sb.addAdjustmentListener(new AdjustmentListener(){
public void adjustmentValueChanged(AdjustmentEvent event) {
((interface_DrawPanel) aReformat).setXWert(event.getValue());
}
});
final JScrollBar sv = new JScrollBar(JScrollBar.VERTICAL, 0,20 , 0, 1000);
sv.addAdjustmentListener(new AdjustmentListener(){
public void adjustmentValueChanged(AdjustmentEvent event) {
((interface_DrawPanel) aReformat).setYWert(event.getValue());
}
});
((interface_DrawPanel) aReformat).setBackground(Color.black);
aReformat.setReformKanal(knot1, knot2, i+1,j+1);
aReformat.setKanal(1);
rpanel.add("Center", ((interface_DrawPanel) aReformat));
rpanel.add("South",sb);
rpanel.add("East",sv);
rpanel.add("West",vslider);
epanel.drawReformCanal(knot1, knot2);
epanel.setreform01(1);
}
public void addMPanel(EEG aEEG, String knot1, String knot2, String[] ReformCanal, int[] ReformCanalIndex, String[] ReformOperation, int i, int j, int id1, int id2,String reformat_x)
{
//System.out.println(knot1 +" - " + knot2);
System.out.println(reformat_x);
System.out.println(i+"-"+j+": "+knot1 +" - " + knot2);
ReformCanalIndex[id1]=i+1;
ReformCanalIndex[id1+1]=j+1;
ReformCanal[id2]= aEEG.getKnoten1(i) +" - " + aEEG.getKnoten1(j);
ReformOperation[id2]=reformat_x;
}
public JSlider createSlider(int orientation, int min, int max, int value, int majortsp, int minortsp, int c1,int c2,int c3 )
{
JSlider slider = new JSlider(orientation, min,max,value);
slider.setPaintTicks(true);
slider.setBackground(new Color(c1, c2, c3));
slider.setMajorTickSpacing(majortsp);
slider.setMinorTickSpacing(minortsp);
//slider.setPaintLabels( true );
slider.setSnapToTicks( true );
//slider.addChangeListener(this);
return slider;
}
/*
public void getReformKN(EEG aEEG, String fromKnot, String toKnot, int id1, int id2,String[] ReformCanal, int[] ReformCanalIndex)
{
for (int i = 0; i< aEEG.getkanalnumber(); i++){
if (fromKnot.equalsIgnoreCase(aEEG.getKnoten1(i)))
{
for (int j = 0; j< aEEG.getkanalnumber(); j++){
if (toKnot.equalsIgnoreCase(aEEG.getKnoten1(j)))
{
if (aEEG.getKnoten2(i).equalsIgnoreCase(aEEG.getKnoten2(j)))
{
System.out.println(i+"-"+j+fromKnot +" - " + toKnot);
ReformCanalIndex[id1]=i+1;
ReformCanalIndex[id1+1]=j+1;
ReformCanal[id2]= aEEG.getKnoten1(i) +" - " + aEEG.getKnoten1(j);
}}}}}}
public void getReformat(EEG aEEG, String knot1, String knot2, JPanel panel, ReformPanel_1 rpanel, EPanel epanel)
{
for (int i = 0; i< aEEG.getkanalnumber(); i++){
if (knot1.equalsIgnoreCase(aEEG.getKnoten1(i)))
{
System.out.println(i);
for (int j = 0; j< aEEG.getkanalnumber(); j++){
if (knot2.equalsIgnoreCase(aEEG.getKnoten1(j)))
{
System.out.println(j);
if (aEEG.getKnoten2(i).equalsIgnoreCase(aEEG.getKnoten2(j)))
{
System.out.println(knot1 +" - " + knot2);
JOptionPane.showMessageDialog(panel, "The new function between "+knot1+" and "+knot2+" will be calculated!");
rpanel.setReformKanal(knot1, knot2, i+1,j+1);
rpanel.setKanal(1);
//rpanel.getOperation(op);
epanel.drawReformCanal(knot1, knot2);
epanel.setreform01(1);
}
else {JOptionPane.showMessageDialog(panel, "It is impossible to get the reformating between the two points, please check it again! ");}
}
else if (j==aEEG.getkanalnumber() & !knot2.equalsIgnoreCase(aEEG.getKnoten1(j))){
JOptionPane.showMessageDialog(panel, "please try again!");
}
//else {System.out.println("no verbindung");}
}
}
else if (i==aEEG.getkanalnumber() & !knot1.equalsIgnoreCase(aEEG.getKnoten1(i))){
JOptionPane.showMessageDialog(panel, "please try again!");
}
}
} */
/*
public void BuildReformSchema(EEG aEEG, String fromKnot){
for (int i=0; i<kanalnumber; i++){
if(aEEG.getKnoten1(i).equalsIgnoreCase(fromKnot)){
for (int j=0; j<kanalnumber; j++){
if (aEEG.getKnoten2(i).equalsIgnoreCase(aEEG.getKnoten2(j)) &&
!aEEG.getKnoten2(i).equalsIgnoreCase(aEEG.getKnoten1(j)) &&
!aEEG.getKnoten1(i).equalsIgnoreCase(aEEG.getKnoten2(j)) &&
(j+1) < kanalnumber && !aEEG.getKnoten1(j).equalsIgnoreCase(aEEG.getKnoten1(j+1)) &&
(i+1) < kanalnumber && !aEEG.getKnoten1(i).equalsIgnoreCase(aEEG.getKnoten1(i+1)) &&
!aEEG.getKnoten1(i).equalsIgnoreCase(aEEG.getKnoten1(j))){
ReformKanal[i][0]=aEEG.getKnoten1(i);
ReformKanal[i][j+1]=aEEG.getKnoten1(j);
}
}
}
}
}*/
/*public void BuildReformSchema(EEG aEEG){
for (int i=0; i<aEEG.getkanalnumber(); i++){
for (int j=0; j<aEEG.getkanalnumber(); j++){
if (aEEG.getKnoten2(i).equalsIgnoreCase(aEEG.getKnoten2(j)) &&
!aEEG.getKnoten2(i).equalsIgnoreCase(aEEG.getKnoten1(j)) &&
!aEEG.getKnoten1(i).equalsIgnoreCase(aEEG.getKnoten2(j)) &&
(j+1) < aEEG.getkanalnumber() && !aEEG.getKnoten1(j).equalsIgnoreCase(aEEG.getKnoten1(j+1)) &&
(i+1) < aEEG.getkanalnumber() && !aEEG.getKnoten1(i).equalsIgnoreCase(aEEG.getKnoten1(i+1)) &&
!aEEG.getKnoten1(i).equalsIgnoreCase(aEEG.getKnoten1(j))){
ReformKanal[i][0]=aEEG.getKnoten1(i);
ReformKanal[i][j+1]=aEEG.getKnoten1(j);
//System.out.println("Kanal " + ": " + ReformKanal[i][j+1]);
}
}
}
for (int i=0; i<aEEG.getkanalnumber(); i++){
for (int j=0; j<aEEG.getkanalnumber(); j++){
System.out.println(i+"-"+j+": "+ReformKanal[i][j]);
}
}
}*/
}