Πέμπτη 25 Ιανουαρίου 2018

Programming notes

26//3/2025 
...still learning !!!
    public static void techo(String s,Object ... args){
        int i=0;
        while(i<args.length){
            System.out.println(i+" : "+args[i]);
            ++i;
        }
    }
    public static void main(String[] args) {
        //new JHerosOfHistory();
        techo("f",0);
        techo("f",0,1,3);
        techo("f",0,1,2,3,"as much ");
    }
(
how much times i need and didnt knew writing code like 
    public Vect(E e0){this();
        super.add(e0);
    }
    public Vect(E e0,E e1){this();
        super.add(e0);super.add(e1);
    }
    public Vect(E e0,E e1,E e2){this();
        super.add(e0);super.add(e1);super.add(e2);
    }
)hahhahahhaha

Now solved as 
    public Vect(E ... oar) {
        this();
        if(oar!=null){
            int i=0,l=oar.length;
            super.ensureCapacity(l);
            while(i<l){
                super.add(oar[i]);
                ++i;
            }
        }
    }






15/10/21
public class Thr extends Thread{
    public volatile boolean keeprun=true;
    public boolean paused=true;
    public long slwork=1000;
    public long slbig=mday;
    public void run(){
        while(keeprun){
            if(paused){
                slbig();
            }
            else{
                worksimple();
                slwork();
            }
        }
    }

}
Volatile otherwise fucked up !!!!!!!!!!!!!!!!!!!!!!!
when from somewhere i execute
somethread.keeprun=false;/////will not 'break'.....if not volatile
http://tutorials.jenkov.com/java-concurrency/volatile.html

-------------------------------------------

    static double a=1,b=2;
    static long counter=0;
    static int st=0;//no volatile and only ++counter seems giving
    3.145.893.960 about processor speed =3Ghertz but does not break from 
while(st<5)

  //static volatile int st=0;//making it volatile will give ~582.862.710 increasements per second
  diladi speed / 5,3 !!!!!!
    public static void main(String[] args) { 
        Thread multiplier=new Thread(){
            public void run(){
                while(st<5){//while(true) instead of local boolean also gives /5 time
                    ++counter;
                    //a*=b;
                    //a=System.currentTimeMillis();
                }
            }
        };
        long prevc=0;
        multiplier.start();
        while(true){
            ++st;
            System.out.println(counter+" dif:  "+(counter-prevc));
            prevc=counter;
            Thr.slep(1000);
        }
    }
--------------------------------------

1/10/2021















System.setProperty("sun.awt.noerasebackground","true");



















Note: Using the static import language feature, you don't have to write Math in front of every math function:

import static java.lang.Math.*;
This allows you to invoke the Math class methods by their simple names. For example:
cos(angle);

1\7/18

//
/**/
package jbuilder;
import java.io.Serializable;
public abstract class MinJavaFileMaxKeywordsClassShow extends Object implements Serializable{
    strictfp interface classSubfile1{}
    protected enum classSubfile2{name;}
    final native long bitsFlash()throws IllegalArgumentException;
    private transient volatile boolean ProcessorRunFlag=

((this instanceof MinJavaFileMaxKeywordsClassShow));
   
    static void b(){
        String ss="!\"%&\\()*+-./:;<=>?[]{|},'";
        byte i=0;
        short j=0;
        int k=0;       
        float m=0;
        double n=0;
        assert (k<n) ;
        try{
            do{ 
                for(;;){
                    switch(k){
                        case  0 :
                        default :
                        if(true){
                            synchronized(ss){
                                continue;
                            }
                        }
                    }       
                    break;
                }
            }while(false);
           
        }catch(Exception e){
            throw new IllegalArgumentException();
        }
        finally{
        }
        return;
    }
}  

"How many pins are there in processor?


Intel 8086 came in DIP and had 40 pins.
Original Pentium came in PGA and had 273 pins.
Opteron 6000 series server CPUs come in LGA and have 1974 pads.
Intel LGA 2011 Xeon / Core i7 chips come in LGA and have 2011 pads.
AMD AM4 CPUs will come in PGA and have 1331 pins.
 "


public class A extends Object{
   
}

class B extends A {
    Boolean b;
}
class C extends A{
    Character c;
}
class D extends A{
    Double d;
}
class E extends A{
   
}
public class Oktadion {
    public static void main(String[] args) {
        System.out.println(""+Long.MAX_VALUE);
    }
    private dion ar[]=new dion[8];
}
class Tetradion {
    private dion ar[]=new dion[4];
}
class on{}
class mhon{
    private on ar[]=new on[0];
}
class monon{
    private on ar[]=new on[1];
}
class dion{
    private on ar[]=new on[2];
}
class trion{
    private on ar[]=new on[3];
}
class ennon{
    private on ar[]=new on[9];
}

///////////////////////////////////////////////////

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package jan;

import java.util.Enumeration;
import java.util.Iterator;
import java.util.StringTokenizer;
import java.util.Vector;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeNode;

/**
 *
 * @author jimakoskx
 */
public class Dyn extends java.lang.Object implements
        TreeNode
{
   
    public static void main(String[] args) {
       
        Dyn test=new Dyn();

       
        test.addObject("V_2");
        test.addObject("V_3");
        test.addObject("V_4");
        test.debugln();
       
       
       
       
       

       
       
        System.out.println("Removed/Founded at: "+test.removeObject("V_35"));
        test.debugln();
       
        test.jfrDebug();

    }

   
    protected int childCounts=0;
    private Vector<Object> v;
    public Dyn(){
        this(Thread.currentThread());
    }
    public Dyn(Object userObject){
        super();
        v=new Vector<Object>();
        v.add("null");
        v.add(userObject);
    }

   
    /**
     * clear the programming (after userObject) objects from vector<br>
     * one by one<br>
     * better if we have v.removeRange(int,int)<br>
     * ram overheading by arrays ?...?
     */
    public void removeAllObjects(){
        //heavy
        int i=getSize();
        int l=childCounts+2;
        while(i>0){
            --i;
            v.remove(l);
            //System.out.println(v.remove(l)+" Removed:OP"+i);
        }
        //System.out.println("Lefted : "+v.size());
    }
    /**
     * System.out.println("Removed/Founded at: "+test.removeObject("V_35"));
     * @param searchIf
     * @return the index on virtual vector,if founded or -1
     */
    public int removeObject(Object searchIf){
        int i=childCounts+2;
        int l=v.size();
        while(i<l){
            if(v.get(i) ==  searchIf){
                v.remove(i);
                i-=childCounts;
                i-=2;
                return i;
            }
            ++i;
        }
        return -1;
       
    }
    /**
     * v.remove(childCounts+2+IndexAfterUserObject);
     * @param IndexAfterUserObject
     */
    public void removeObject(int IndexAfterUserObject){
        v.remove(childCounts+2+IndexAfterUserObject);
    }
    /**
     * v.add(afterOnlineCurrentLast);
     * @param afterOnlineCurrentLast
     */
    public void addObject(Object afterOnlineCurrentLast){
        v.add(afterOnlineCurrentLast);
    }
    /**
     *
     * @return v.size()-childCounts-2;
     */
    public int getSize(){
        return v.size()-childCounts-2;
    }
    /**
     *
     * @return v.size();
     */
    public int getRealSize(){
        return v.size();
    }
   
    /**
     *
     * @param timesAfterUserObject
     * @return v.get(timesAfterUserObject + childCounts + 2);
     */
    public Object getObject(int timesAfterUserObject){
        timesAfterUserObject+=2;
        timesAfterUserObject+=childCounts;
        return v.get(timesAfterUserObject);
    }
   
    /**
     * v.setElementAt(timesAfterUserObject + childCounts + 2);
     * @param newUserObject
     * @param timesAfterUserObject
     */
    public void setObject(Object newUserObject,int timesAfterUserObject){
        timesAfterUserObject+=2;
        timesAfterUserObject+=childCounts;
        v.setElementAt(newUserObject,timesAfterUserObject);
    }
    /**
     *
     * @return the required from overriders class type
     */
    public Dyn cr(){return new Dyn();}
   
   
    /**
     *
     * @return the UserObject v.get(childCounts+1);
     */
    public Object uo(){return v.get(childCounts+1);}
    /**
     * sets the UserObject <br>
     * v.setElementAt(newUserObject, childCounts+1);
     * @param newUserObject
     */
    public void uo(Object newUserObject){v.setElementAt(newUserObject, childCounts+1);}

    /**
     *
     * @return Parent at  (Dyn)v.get(childCounts);
     */
    public Dyn par(){return (Dyn)v.get(childCounts);}
    /**
     * sets the Parent at v.setElementAt(newPar, childCounts);
     * @param newPar
     */
    public void par(Dyn newPar){v.setElementAt(newPar, childCounts);}
   
    /**
     *
     * @return Last Child at  (Dyn)v.get(childCounts-1);
     */
    public Dyn last(){return (Dyn)v.get(childCounts-1);}
    /**
     * sets the Last at v.setElementAt(newPar, childCounts-1);
     * @param newLast
     */
    public void last(Dyn newLast){v.setElementAt(newLast, childCounts-1);}
   
   
    /**
     *
     * @return number of Children Nodes
     */
    public int chc(){return childCounts;}
    /**
     *
     * @param i
     * @return children Node on i
     */
    public Dyn chi(int i){return (Dyn)v.get(i);}
    /**
     * replaces child Node on index<br>
     * set null the parent of old one
     * @param newChild
     * @param index
     */
    public void chi(Dyn newChild,int index){
        Dyn old=(Dyn)v.get(index);
        old.par(null);
        v.setElementAt(newChild, index);
    }
   
    /**
     *
     * @param newChild
     */
    public void addChild(Dyn newChild){
        v.insertElementAt(newChild, childCounts);
        ++childCounts;
        newChild.par(this);
    }
    /**
     *
     * @param newChild
     * @param index
     */
    public void insertChild(Dyn newChild,int index){
        v.insertElementAt(newChild, index);
        ++childCounts;
        newChild.par(this);
    }
    /**
     *
     * @param index
     * @return the removed and without parent node
     */
    public Dyn removeChild(int index){
        Dyn out=(Dyn)v.remove(index);
        --childCounts;
        out.par(null);//???
        return out;
    }
    /**
     * if(v.get(i) == node)
     * @param node
     * @return index of the removed if founded or -1
     */
    public int removeChild(TreeNode node) {
        int i=0;
        while(i<childCounts){
            if(v.get(i) == node){
                removeChild(i);
                return i;
            }
            ++i;
        }
        return -1;
    }
    /**
     * Would be better if we could use directlly the Vector array<br>
     * v.removeRange(int,int) not allowed here to use..<br>
     * removing one by one.(io overloads)
     */
    public void removeAllChildren(){
        while(childCounts>0){
            ((Dyn)v.remove(0)).par(null);
            --childCounts;
        }
    }
   
   
    @Override
    public TreeNode getChildAt(int childIndex) {return chi(childIndex);}

    @Override
    public int getChildCount() {return childCounts;}

    @Override
    public TreeNode getParent() {return (Dyn)v.get(childCounts);}

    @Override
    public int getIndex(TreeNode node) {
        int i=0;
        while(i<childCounts){
            if(v.get(i) == node){return i;}
            ++i;
        }
        return -1;
    }

    @Override
    public boolean getAllowsChildren() {return true;}

    @Override
    public boolean isLeaf() {return childCounts==0;}

    @Override
    public Enumeration children() {
        return null;
    }
   
   
   
   
   
   
   
   
   
   
   
   
    public Dyn crad(Object uo){Dyn out=cr();out.uo(uo);addChild(out);return out;}
    public Dyn cradr(Object uo){crad(uo);return this;}
   
    public int cradChildren(Object[] it){
        int out=0,i=0;
        while(i<it.length){
            crad(it[i]);
            ++i;
            ++out;
        }
        return out;
    }
    public int cradChildren(Vector it){
        int out=0,i=0;int l=it.size();
        while(i<l){
            crad(it.get(i));
            ++i;
            ++out;
        }
        return out;
    }
    public int cradChildren(DefaultMutableTreeNode it){
        int out=0,i=0;int l=it.getChildCount();
        while(i<l){
            crad(((DefaultMutableTreeNode)it.getChildAt(i)).getUserObject());
            ++i;
            ++out;
        }
        return out;
    }
    public int cradChildren(Iterator it){
        int out=0;
        while(it.hasNext()){
            crad(it.next());
            ++out;
        }
        return out;
    }
    public int cradChildren(StringTokenizer it){
        int out=0;
        while(it.hasMoreTokens()){
            crad(it.nextToken());
            ++out;
        }
        return out;
    }
   
   
   
   
   
   
   
   
    public Dyn cradDeep(Object[] it){
        int i=0;Dyn itnode=this;
        while(i<it.length){
            itnode=itnode.crad(it[i]);
            ++i;
        }
        return itnode;
    }
    public Dyn cradDeep(Vector it){
        int i=0;Dyn itnode=this;int l=it.size();
        while(i<l){
            itnode=itnode.crad(it.get(i));
            ++i;
        }
        return itnode;
    }
    public Dyn cradDeep(DefaultMutableTreeNode it){
        int i=0;Dyn itnode=this;int l=it.getChildCount();
        while(i<l){
            itnode=itnode.crad(((DefaultMutableTreeNode)it.getChildAt(i)).getUserObject());
            ++i;
        }
        return itnode;
    }

    public Dyn cradDeep(Iterator it){
        Dyn itnode=this;
        while(it.hasNext()){
            itnode=itnode.crad(it.next());
        }
        return itnode;
    }
    public Dyn cradDeep(StringTokenizer it){
        Dyn itnode=this;
        while(it.hasMoreTokens()){
            itnode=itnode.crad(it.nextToken());
        }
        return itnode;
    }
   
    public static final String classOpen="{";
    public static final String classClose="}";
    public static final String space=" ";
   
    public void oln(String str){System.out.println(""+str);}
    public void olntr(){
        olntr(new StringBuffer());
    }
    public void olntr(StringBuffer carryingReference){
        oln(carryingReference+""+uo()+classOpen);
        int l=getChildCount();
        if(l>0){
            int i=0;
           
            carryingReference.append(' ');
            while(i<l){chi(i).olntr(carryingReference);++i;}
            l=carryingReference.length();
            i=l-1;
            carryingReference.delete(i, l);
        }
        oln(classClose);
    }















    // BINARY SERACH
    public int sbdecode(int index){++index;index=-index;return index;}
    public int sbencode(int index){index=-index;--index;return index;}
    public int sbi(Comparable toCompare){
        int lo = 0,hi = getChildCount() - 1,mid; int d;

        while (lo <= hi) {mid = lo + (hi - lo) / 2;
            d=toCompare.compareTo(chi(mid).uo());
            if(d<0){ hi = mid - 1;}
            else if (d>0){lo = mid + 1;}
            else {return mid;}
        }
        return sbencode(lo);
    }
   
    public Dyn sb(Comparable findOrAdd){
        int ioi=sbi(findOrAdd);
        if(ioi>-1){return chi(ioi);}
        return null;
    }

    public Dyn sbin(Comparable findOrAdd){
        int ioi=sbi(findOrAdd);
        if(ioi>-1){
            return chi(ioi);
        }
        else{
            Dyn out=cr();
            out.uo(findOrAdd);
            insertChild(out,sbdecode(ioi));
            return out;
        }
    }
   
    public Dyn sbinr(Comparable findOrAdd){sbin(findOrAdd);return this;}
   
   
   
   
   
   
    public int sbinChildren(Iterator it){
        int out=0;
        while(it.hasNext()){sbin((Comparable)it.next());++out;}
        return out;
    }
    public int sbinChildren(StringTokenizer it){
        int out=0;
        while(it.hasMoreTokens()){sbin(it.nextToken());++out;}
        return out;
    }
    public int sbinChildren(Object[] it){
        int out=0;
        while(out<it.length){sbin((Comparable)it[out]);++out;}
        return out;
    }
    public Dyn sbinDeep(Iterator it){
        Dyn itnode=this;
        while(it.hasNext()){itnode=itnode.sbin((Comparable)it.next());}
        return itnode;
    }
    public Dyn sbinDeep(StringTokenizer it){
        Dyn itnode=this;
        while(it.hasMoreTokens()){itnode=itnode.sbin(it.nextToken());}
        return itnode;
    }

    public Dyn sbinDeep(Object[] it){
        int i=0;
        Dyn itnode=this;
        while(i<it.length){
            itnode=itnode.sbin((Comparable)it[i]);
            ++i;
        }
        return itnode;
    }
    public Dyn sbinDeep(Vector it){
        int i=0;
        int l=it.size();
        Dyn itnode=this;
        while(i<l){
            itnode=itnode.sbin((Comparable)it.get(i));
            ++i;
        }
        return itnode;
    }
    public JTree jtr(){
        return new JTree((TreeNode)this);
    }
    public JList jl(){
        return new JList(v);
    }
   
    public JFrame jfr(){
        JFrame jfr=new JFrame();
        jfr.setTitle(toShortDebugString());
        JMenuBar jmb=new JMenuBar();
        jfr.setJMenuBar(jmb);
        jmb.add(new JMenu("File"));
        jfr.setBounds(123,123,323,323);
        jfr.getContentPane().add(new JScrollPane(jtr()));
        jfr.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        jfr.setVisible(true);
        return jfr;
    }
    public JFrame jfrDebug(){
        JFrame jfr=new JFrame();
        jfr.setTitle(toShortDebugString());
        JMenuBar jmb=new JMenuBar();
        jfr.setJMenuBar(jmb);
        jmb.add(new JMenu("File"));
        jfr.setBounds(123,123,323,323);
        JSplitPane jspl=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,new JScrollPane(jl()),new JScrollPane(jtr()));
        jspl.setResizeWeight(0.3);
        jfr.getContentPane().add(jspl);
        jfr.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        jfr.setVisible(true);
        jspl.setDividerLocation(0.3);
        return jfr;
    }
    public String toString(){
        return uo().toString();
    }
    public void debugln(){
        System.out.println(""+toDebugString());
    }
    public String toShortDebugString(){
        Object uo=uo();
        String out=uo+" - "+uo.getClass().getSimpleName()+"["+getSize()+"{"+chc();
        return out;
    }
    public String toDebugString(){
        Object uo=uo();
        String out="---------------";
        out+="\n"+uo+" - "+uo.getClass();
        out+="\nObjects:  "+getSize();
        out+="\nChildren: "+chc();
        out+="\nReal Size: "+getRealSize();
       
       
        out+="\n";
        return out;
    }
    public String toSuperString(){return super.toString();}
       
   
}




//////////////////////////////////////////////////////


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package jcore;

import java.awt.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.StringTokenizer;
import java.util.Vector;
import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;

/**
 *
 * @author jimakoskx
 */
public class Dmtn extends DefaultMutableTreeNode{
    public static void main(String[] args) {
        Dmtn t=new Dmtn("root");
        t.loadClassPathAndClass(t.getClass());
        int i=0;
        while(i<0){
            t.jfr().setTitle(i+"");
            ++i;
        }
        t.jfr().setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
    public static final long jimClassId=0;

    static int counter=0;
    public Dmtn() {
        System.out.println(counter+getClass().getName()+"()");
        ++counter;
    }

    public Dmtn(int y) {System.out.println("testing temp public Dmtn(int y)");}
    public Dmtn(Object userObject) {
        super(userObject);
        System.out.println(counter+getClass().getName()+"() "+userObject);
        ++counter;
       
    }
    public static final String tag_StringHierarchyAssuptionCancelling="*";
    public Dmtn store(String varName,Object varValue){
        return this.sbin(varName).sbin(tag_StringHierarchyAssuptionCancelling).crad(varValue);
    }
   
    //CASTOR
    public String [] args(){return (String[])userObject;}
    public int nint(){return ((Integer)userObject).intValue();}
        public int nintss(){int out=((Integer)userObject).intValue();userObject=out+1;return out;}
        public int nssint(){int out=((Integer)userObject).intValue()+1;userObject=out;return out;}
    public Dmtn link(){return (Dmtn)userObject;}
    public Comparable comp(){return (Comparable)userObject;}
    public Class klass(){return (Class)userObject;}
    public Constructor cons(){return (Constructor)userObject;}
    public Field fild(){return (Field)userObject;}
    public Method meth(){return (Method)userObject;}
    public Vector vect(){return (Vector)userObject;}
    public StringBuffer sbuf(){return (StringBuffer)userObject;}

    //
   
    //general creation as STATIC
    public Dmtn cr(){return new Dmtn();}
    public BufferedReader criobr(){return new BufferedReader(new InputStreamReader(System.in));}
    public Constructor[]crCons(Class cl){return cl.getDeclaredConstructors();}
    public Field[]crFilds(Class cl){return cl.getDeclaredFields();}
    public Method[]crMeths(Class cl){return cl.getDeclaredMethods();}
   
    //TREE FUNCTIONS
    public Dmtn dmtn(int index){return (Dmtn)getChildAt(index);}
    public Dmtn crad(Object uo){Dmtn out=cr();out.setUserObject(uo);add(out);return out;}
    public Dmtn cradr(Object uo){crad(uo);return this;}
    public void oln(String str){System.out.println(""+str);}
    public void olntr(){
        oln(userObject+"{");
        int l=getChildCount();
        if(l>0){
            int i=0;
            while(i<l){dmtn(i).olntr();++i;}
        }
        oln("}");
    }
   
    // BINARY SERACH
    public int sbdecode(int index){++index;index=-index;return index;}
    public int sbencode(int index){index=-index;--index;return index;}
    public int sbi(Comparable toCompare){
        int lo = 0,hi = getChildCount() - 1,mid; int d;
        while (lo <= hi) {mid = lo + (hi - lo) / 2;
            d=toCompare.compareTo(dmtn(mid).comp());
            if(d<0){ hi = mid - 1;}
            else if (d>0){lo = mid + 1;}
            else {return mid;}
        }return sbencode(lo);
    }   
   
    public Dmtn sb(Comparable findOrAdd){
        int ioi=sbi(findOrAdd);
        if(ioi>-1){return (Dmtn)dmtn(ioi);}
        return null;
    }
    public Dmtn sbin(Comparable findOrAdd){
        int ioi=sbi(findOrAdd);
        if(ioi>-1){
            return (Dmtn)dmtn(ioi);
        }
        else{
            Dmtn out=cr();
            out.setUserObject(findOrAdd);
            insert(out,sbdecode(ioi));
            return out;
        }
    }
    public Dmtn sbinr(Comparable findOrAdd){sbin(findOrAdd);return this;}
   
   
   
   
   
    public JTree jtr(){JTree out=new JTree(this);return out;}
    public JScrollPane jscr(){return new JScrollPane(jtr());}
    public JPanel jp(){JPanel out=new JPanel();out.setLayout(new BorderLayout());out.add(BorderLayout.CENTER,jscr());return out;}
    private static int jfrxloc=0,jfryloc=0;
    public JFrame jfr(){
        JFrame out=new JFrame();out.setTitle("def Viewer of : "+this.getClass().getSimpleName()+" "+this);
        out.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        Dimension dim=Toolkit.getDefaultToolkit().getScreenSize();
        out.setBounds(jfrxloc,jfryloc,dim.width/2,dim.height/2);
        out.getContentPane().add(jp());
        jfrxloc+=33;if(jfrxloc>dim.width/2){jfrxloc=0;}
        jfryloc+=2;if(jfryloc>dim.height/2){jfryloc=0;}
       
       
        out.setVisible(true);
        return out;
    }
   
   
    public Dmtn cll(boolean fixIfNotFound){
        if(fixIfNotFound){return sbin("cll");}
        else{return sb("cll");}
    }
    public Dmtn cll(){return sbin("cll");}
    public Dmtn loadClassPathAndClass(Class cl){
        String cln=cl.getName();
        StringTokenizer stok=new StringTokenizer(cln,".");
        String tok;
        Dmtn it=cll();
        while(stok.hasMoreElements()){
            tok=stok.nextToken();
            it=it.sbin(tok);
        }
        if(it.getChildCount()>0){
            if(it.dmtn(0).userObject instanceof Class){
                System.out.println("Already loaded or same exactly package name class ");
                return it;
            }
        }
       
        it.loadClass(cl);
        return it;
    }
    public Dmtn loadClass(Class cl){
        Dmtn it=crad(cl);
        it.sbin("[assinges]");
        it.sbin("cons");
        it.sbin("fild");
        it.sbin("meth");
        it.loadConstructors();
        it.loadFilds();
        it.loadMethods();
        return it;
    }
    public Dmtn loadedClass(Class cl){
        Dmtn it=cll(false);
        if(it!=null){
            String cln=cl.getName();
            StringTokenizer stok=new StringTokenizer(cln,".");
            String tok;
            while(stok.hasMoreElements()&& it!=null){
                tok=stok.nextToken();
                it=it.sb(tok);
            }
            if(it.getChildCount()>0){
                if(it.dmtn(0).userObject instanceof Class){
                    return it;
                }
            }
        }
        return null;
    }
   
  
    //refering to as if userobject instance pf class
    public Dmtn loadConstructors(){
        Constructor ar[]=crCons(klass());
        Dmtn quick=sbin("cons");
        if(ar.length>0 && quick.getChildCount()==0){
            int i=0;
            while(i<ar.length){
                Class ps[]=ar[i].getParameterTypes();
                quick.sbin(ps.length).crad(ar[i]);
                ++i;
            }
            quick.pullUpFirstLevel();
        }
        else{
            System.out.println("0 or Already loaded constructors "+klass());
        }
        return quick;
    } 
    public Dmtn loadFilds(){
        Field ar[]=crFilds(klass());
        Dmtn quick=sbin("fild");
        if(ar.length>0 && quick.getChildCount()==0){
            int i=0;
            while(i<ar.length){
                quick.sbin(ar[i].getName()).crad(ar[i]);
                ++i;
            }
        }
        else{
            System.out.println("0 or Already loaded fields "+klass());
        }
        return quick;
    }
    public Dmtn loadMethods(Integer temp){
        return null;
    }
    public Dmtn loadMethods(){
        Method ar[]=crMeths(klass());
        Dmtn quick=sbin("meth");
        if(ar.length>0 && quick.getChildCount()==0){
            int i=0;
            while(i<ar.length){
                Class ps[]=ar[i].getParameterTypes();
                quick.sbin(ar[i].getName()).sbin(ps.length).crad(ar[i]);
                ++i;
            }
            i=0;
            int l=quick.getChildCount();
            Dmtn ch;
            while(i<l){
                ch=quick.dmtn(i);
                ch.pullUpFirstLevel();
                ++i;
            }
        }
        else{
            System.out.println("0 or Already loaded methods "+klass());
        }
        return quick;
    } 

   
    void pullUpFirstLevel(){
        int l=getChildCount();
        if(l>0){
            Dmtn quickGotheringEggonia=cr();
            int i=0;
            int j,jl;
            Dmtn ch;
            while(i<l){
                ch=dmtn(i);
                jl=ch.getChildCount();
                j=0;
                while(j<jl){
                    quickGotheringEggonia.add(ch.dmtn(0));
                    ++j;
                }
                ++i;
            }
            removeAllChildren();
            l=quickGotheringEggonia.getChildCount();
            i=0;
            while(i<l){
                add(quickGotheringEggonia.dmtn(0));
                ++i;
            }
            //System.out.println("Eggonia being children:"+i);
        }
       
    }

}

Τρίτη 27 Ιουνίου 2017

ΟΙΩΝΟΣΚΟΠΙΑ - Αμφίδρομη Επικοινωνία -Μυστήρια - Μύστες

ΟΙΩΝΟΣΚΟΠΙΑ και ΜΥΗΣΗ στα Αρχαία Μυστηρια

1)Εισαγωγικώς.
Αν γνωρίζαμε το μοντελο δημιουργειας τοτε θα ειχαμε τις απαντησεις.
Συνεπως πρωτευων ειναι οτι ΔΕΝ ξερουμε τι ειμαστε.
Για ορθη κριση ξεκιναμε απο εκει.
Αν δε ξεκινησεις απο αυτο τοτε απλως εχεις αυξημενες πιθανοτητες ανεπιτυχους κρισεως.

α)ΟΙΩΝΟΣΚΟΠΙΑ(τροπος και υποκειμενα)
β)ΒΙΟΛΟΓΙΑ

με το πρωτο επιτυγχανεται επικοινωνια με το ΜΕΓΑΛΟ
και με το "δευτερο" επιτυγχανεται επικοινωνια με το ΜΙΚΡΟ

Και δε ξερουμε αν το μικρο ειναι ιδιο με το μεγαλο.

Το ολο θεμα σχετιζεται με την αποδοση του συστηματος.

Γιατι εφοσον υπαρχει συστημα αναμεσα σε μικρο και μεγαλο (συστημα)
θα υπαρχουν και στοχοι.

Η ΣΥΛΛΗΨΗ της εννοιας αυτου του συστηματος "δημιουργει" τη λεξη ΕΝ.

Για αυτο το λογο καμια ΜΑ ΚΑΜΙΑ διαδεδομενη θρησκεια δεν ειναι απολύτως ψευδης.
Γιατι ολες προσεγγιζουν το ΣΥΣΤΗΜΑ αυτο.

Τωρα πως ειναι δυνατον ελληνες αναζητητες να ΜΗΝ λαμβανουν υποψην αλλες (ολες) θρησκειες αυτο μαλλον ειναι θεμα και συγκιριων αλλα και εγκεφαλων.

Και υπαρχουν και οι θρησκειες της ινδιας,κινας,αμερικης
για τις οποιες ΟΛΩΣ τυχαιως ξεχνατε να ΤΣΑΚΩΝΕΣΤΕ.

2)Κυρίως
Ακούμε ότι στα αρχαία χρόνια υπήρχε διαδικασία μυησεως (ελευσινια μυστηρια κτλ)
Ποια ειναι τα μυστικα και γιατι είναι μυστικα?


Το μυστικό είναι οτι υπάρχει θεος.
Ο θεός αυτός μπορει να ρίχνει 
α)κεραυνούς,αστραπές,βροντές
β)ανέμους (ριπές ανέμου)
γ)πεφτάστερα (μεγάλο ύψος) και φωτεινές δέσμες (χαμηλό ύψος)
δ).... και αρκετά αλλα.

Το θέμα εδώ δεν είναι πως θα ονομάσουμε τον θεό αυτον που έχει τετοιες δυναμεις.
Το βασικο που πρεπει να καταλαβει ο αναγνωστης ειναι οτι η ΟΝΤΟΤΗΤΑ αυτη
εχει τη δυναμη να σας δείξει την ύπαρξή της ,,,, και στην αυτη περιπτωση
ομιλουμε για αμφίδρομη επικοινωνια


Όμως κάθε οντότητα δεν είναι απαραίτητο να "συνομιλει" με όλους.
Αυτό το λέω γιατι αν ενας άνθρωπος , εν μέσω καταιγίδας
κοιτωντας ψηλα σκεφτεί ή πει
-"Δία είσαι εδω?"
και ΔΕΝ λαβει κεραυνό (σημαδι απαντησης)
αυτο δε παει να πει οτι ο Διας δεν υπαρχει .


Είναι στη θέληση του Διός το σε ποιον θα απαντησει και κατα συνεπεια σε ποιον θα γινει φανερος.

Και δεν ειμαι εγω αυτος που θα κρινω αν εσεις ειστε υποψηφιοι προς επικοινωνια με τον θεο.
Δηλαδη εσεις θα πειραματισθείτε και θα δειτε μονοι σας.

Σημασία έχει να γνωρίζετε τι εστι ΟΙΩΝΟΣΚΟΠΙΑ.
Οι οιωνοι είναι οι απαντησεις του θεου σε ερωτηματα-σκεψεις δικα σας.


Το τι θα βγει απο ολο αυτο ειναι, απο κει και επειτα, δικη σας ευθυνη.
Καποιος μπορει να πεθανει απο τη χαρα του οταν καταλαβει οτι υπαρχει θεος
καποιος απο τον φοβο του 
καποιος μπορει να νιωσει τρελος
και πολλα αλλα μπορει να συμβουν.

Σιγουρα λοιπον χρειαζεται πνευματική νοητικη αλλα και σωματικη  δυναμη 
σε οσους επιχειρησουν 
να επικοινωνησουν με τον θεο μεσω οιωνων.

Και σιγουρα πολλοι θα τρέξουν να κατηγορησουν οτι ολα αυτα θεοσημεια ειναι τυχαια
ΟΤΑΝ τα δικα τους πειραματα αποτυχουν.
Αυτο δε πρεπει να πτοησει εκεινους που επετυχαν και καταφεραν να δουν τη συναφεια.

Για αυτο το λογο αλλωστε υπηρχε διαδικασια μυησεως.
Επειδη δεν ειμαστε ολοι οι ανθρωποι στο ιδιο επιπεδο.


3)εν κατακλειδα

Μερικοί άνθρωποι καταφερνουν να επικοινωνουν με την οντοτητα 
που δυναται να ριχνει κατα βουληση κεραυνους,ανεμους κτλ.
Αμφιβαλλω για την ορθοτητα της λεξης αλλα ας πουμε αυτους ΧΡΙΣΜΕΝΟΥΣ.

Θέλω να σταθω στα πεφταστερα.
Εχουμε μαθει οτι εινια αστεροιδεις που συγκρουονται.
Μερικοι απο εσας που θα καταφερετε επικοινωνια με αυτά
θα πεσετε απο τα συννεφα οταν συνειδητοποησουμε το ολο ψεμα.
Δεν υπαρχει δηλαδη αστεροιδης που τυχαιως συγκρουεται .
Υπάρχει μια οντοτητα ,ο θεος, που μπορει να ριξει οσους και οποτε θελει.

Δεν θα σταθω καθολου στο τροπο "συνομιλίας" σας με τον θεο.
Ειναι δικη σας ευθυνη.
Απλώς θα τονίσω οτι αν ας πουμε σας βγει μια "κακη" σκεψη 
την ωρα που διεξαγετε επικοινωνια με τον θεο
νιωστε λιγο ανετα
εφοσον ως ανθρωποι ειμαστε αδυνατοι ,μικροι και θνητοί.

Καλή δύναμη σε όλους τους ελληνες ανθρώπους.
ΟΙ+ΩΝ+ΟΣ+ΚΟΠ+ΕΥ+Ω


4)ΚΡΟΝΟΣ , μαντείο δελφών, πυθία κ.α.
 δευτερεύων μάθημα μυήσεως.....

Σύνταγμα της ελλάδος 27 Μάη 2008 ,,, Άρθρο 4 παράγραφος 7.
7.Τίτλοι ευγένειας ή διάκρισης ούτε απονέμονται
ούτε ΑΝΑΓΝΩΡΊΖΟΝΤΑΙ σε Έλληνες πολίτες


"εις οιωνός άριστος αμύνεσθαι περί πάτρης" ??????? !!!!!!!!!!!!! ?????????
 
----------------------------------------------ΤΕΛΟΣ ΔΙΑΛΕΞΗΣ ----------------------------------------














9/11/20
οχι οτι θα προλαβω αλλα....να και περιπου ενα προγραμματακι
στη γλωσσα της Ιάβας για τη γλωσσα τη δικη μου!!!! 























June 28 2017

Busted , Volunteer to spread "knowledge" on 2000!
Phylosophers-Scientiests of the earth.!!!!
Hiding GOD ......... playing the dog and doc!











Παρασκευή 28 Απριλίου 2017

To not forget my stupid practice in Java for quick search

From now on always Hash.

 l=1000000;//number for testing speed on load and search

TN loaded
MAP loaded
Tabl loaded
Tn founded : 476
Map founded : 476
Table founded : 476

TN Load: 48061     Search: 1256 millis !!!!!!!!!!!!!!!!!!!!!!!! XXXXXXXXX
MAP Load: 2655     Search: 83
millis asychronized
TABLE Load: 1928     Search: 94 millis sychronized

I knew for my bad load time but didnt knew for my bad search time.
I discovered together with a test on reflection.
Reflection test on calling method meth(float f){}.invoke()
instead of using a interface meth(float f);

came bad for reflection.
About 6 times up the reflection execution

------------------------------------------------

Just for my history .




/*
 * Tsoukalas I. Dimitrios
 * jimakoskx@{hotmail.com,facebook.com,gmail.com,blogspot.com}
 */
package jel.lib.dd.tr;


import java.io.PrintStream;
import java.lang.reflect.Array;
import java.util.Comparator;
import java.util.Iterator;
import java.util.StringTokenizer;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.MutableTreeNode;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;





/**
 *
 * @author zojimis
 */
public class Tn extends Dmtn{
   
    public static void main(String[] args) {
        Tn t=new Tn("start test");
        String ar[]={"1","2"};
       
        t.fad(1);
        t.fad(4);
        t.fad(7);
       
        int ind=t.ioi(-9);
        System.out.println(""+ind);
        if(ind<0){
            System.out.println("Decoded="+t._x_de_code_(ind));
        }
    }

    public Tn(){
        super();
        //System.out.println("C:Tn()");
    }
    public Tn(Object uo){
        super(uo);
        //System.out.println("C:Tn(Object)");
       
    }
    public Tn(Object uo,boolean allowsChild){
        super(uo,allowsChild);
        //System.out.println("C:Tn(Object , boolean)");
       
    }
    public Tn cr(Object uo){return new Tn(uo);}
    public Tn tn(int index){return (Tn)getChildAt(index);}

   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
    public double comp(Tn other){
        //System.out.println("Comparing "+other.getClass()+"\nwith "+getClass());
        return ((Comparable)userObject).compareTo((Comparable)other.userObject);
        //return userObject.toString().compareTo(other.getUserObject().toString());
        //return ((Integer)getUserObject()).intValue()-((Integer)other.getUserObject()).intValue();
    }
   
    /**
     * ++index;index=-index;
     * @param index
     * @return
     */
    public int _x_de_code_(int index){
        //System.out.print("Decoding:"+index);
        ++index;
        index=-index;
        //System.out.println("......as :"+index);
        return index;
    }
    /**
     * index=-index;--index;
     * @param index
     * @return
     */
    public int _x_en_code_(int index){
        //System.out.print("Encoding:"+index);
        index=-index;
        --index;
        //System.out.println("......as :"+index);
        return index;
    }
    /**
     * IN TESTING MODE YET
     *
     * Index Or Insertion index (decoded)
     * toCompare.comp(it);
     * @param toCompare
     * @return
     */
    public int ioi(Tn toCompare){//steps=0;
        int lo = 0,hi = getChildCount() - 1,mid;double d;Tn it;
        while (lo <= hi) {mid = lo + (hi - lo) / 2;
            it=(Tn)getChildAt(mid);
            //System.out.println(toCompare.getClass().getSimpleName()+"comp("+it.getClass().getSimpleName());
            d=toCompare.comp(it);
            if(d<0.0){hi = mid - 1;}
            else if (d>0.0){lo = mid + 1;}
            else {return mid;}//++steps;
        }return _x_en_code_(lo);
    }
    /**
     * Index Or Insertion index (decoded)
     * toCompare.compareTo(it.userObject);
     * @param toCompare
     * @return
     */
    public int ioi(Comparable toCompare){
        int lo = 0,hi = getChildCount() - 1,mid; double d;Tn it;
        while (lo <= hi) {mid = lo + (hi - lo) / 2;
            it=(Tn)getChildAt(mid);d=toCompare.compareTo(it.userObject);
            if(d<0.0){ hi = mid - 1;}
            else if (d>0.0){lo = mid + 1;}
            else {return mid;}
        }return _x_en_code_(lo);
    }


   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
  ///////////////  ADDING FUNCTIONS 
   
   
   
   
   
    //Node compare mode
    public Tn nfad(Tn toCompareOrAddIfNotFounded){
        //System.out.println(""+getChildCount());
        int binarySearch=Tn.this.ioi(toCompareOrAddIfNotFounded);
        if(binarySearch>-1){ return ((Tn)getChildAt(binarySearch));}
        else{
            super.insert(toCompareOrAddIfNotFounded, _x_de_code_(binarySearch));
            return toCompareOrAddIfNotFounded;
        }
    }
    ///////////............................................more
   
   
   
   
   
   
   
   
   
    //UserObjects as Comparables Search mode
    public Tn f(Comparable toCompareOrCreateAddIfNotFounded){
        int binarySearch=ioi(toCompareOrCreateAddIfNotFounded);
        if(binarySearch>-1){return ((Tn)getChildAt(binarySearch));}
        else{return null;}
    }
    public Tn fad(Comparable toCompareOrCreateAddIfNotFounded){
        int binarySearch=ioi(toCompareOrCreateAddIfNotFounded);
        if(binarySearch>-1){return ((Tn)getChildAt(binarySearch));}
        else{
            Tn nn=(Tn)cr(toCompareOrCreateAddIfNotFounded);
            super.insert(nn, _x_de_code_(binarySearch));
            return nn;
        }
    }
    public Tn fadmIn(Iterator<Comparable> toCompareOrCreateAddIfNotFounded){
        Tn out=this;
        while(toCompareOrCreateAddIfNotFounded.hasNext()){
            Tn newn=out.fad(toCompareOrCreateAddIfNotFounded.next());
            out=newn;
        }
        return out;
    }

    public Tn fadmInCharactersAsStrings(String toCompareOrCreateAddIfNotFounded,String resetOnRootChars,String addBeforeReset){
        Tn out=this;
        int i=0;
        int l=toCompareOrCreateAddIfNotFounded.length();
        char ch;
        while(i<l){
            ch=toCompareOrCreateAddIfNotFounded.charAt(i);
            if(resetOnRootChars.contains(ch+"")){
                out.fad(addBeforeReset);
                out=this;
            }
            else{
                Tn newn=out.fad(ch+"");
                out=newn;     
            }
            ++i;
        }
        return out;
    }
    public Tn fadmIn(StringTokenizer toCompareOrCreateAddIfNotFounded){
        Tn out=this;
        while(toCompareOrCreateAddIfNotFounded.hasMoreTokens()){
            Tn newn=out.fad(toCompareOrCreateAddIfNotFounded.nextToken());
            out=newn;
        }
        return out;
    }
    public Tn fadmInByStringsOfArray(Object array){
        Tn out=this;
        int i=0;
        int l=Array.getLength(array);
        while(i<l){
            out=out.fad(Array.get(array, i)+"");
            ++i;
        }
        return out;
    }
   
   
    public Tn fadm(Iterator<Comparable> toCompareOrCreateAddIfNotFounded){
        Tn out=this;
        while(toCompareOrCreateAddIfNotFounded.hasNext()){
            out=fad(toCompareOrCreateAddIfNotFounded.next());
        }
        return out;
    }
    public Tn fadm(StringTokenizer toCompareOrCreateAddIfNotFounded){
        Tn out=this;
        while(toCompareOrCreateAddIfNotFounded.hasMoreTokens()){
            out=fad(toCompareOrCreateAddIfNotFounded.nextToken());
        }
        return out;
    }
    public Tn fadmByStringsOfArray(Object array){
        Tn out=this;
        int i=0;
        int l=Array.getLength(array);
        while(i<l){
            out=fad(Array.get(array, i)+"");
            ++i;
        }
        return out;
    }
   
   
   
   
   

}

Τετάρτη 26 Απριλίου 2017

Java3d Yaw Pitch Roll Transform Rotation Aircraft Sim




package jel.j3d;

import com.sun.j3d.utils.geometry.ColorCube;
import com.sun.j3d.utils.geometry.Cone;
import com.sun.j3d.utils.universe.SimpleUniverse;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.media.j3d.Appearance;
import javax.media.j3d.BranchGroup;
import javax.media.j3d.ColoringAttributes;
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import javax.vecmath.Color3f;
import javax.vecmath.Quat4d;
import javax.vecmath.Vector3d;

/**
 *
 * @author Jex
 *
 * This is my first minimum implementation for a simple YAW PITCH ROLL program in java3d<br>
 * I got the rotation algoritm idea from https://luckytoilet.wordpress.com/category/programming/ <br>https://en.wikipedia.org/wiki/Euler_angles
 *
 * Next version will be to decrease computations.
 * Tested on Java 3D 1.5.1(x64)<br>
 * (right hand 3d system)<br>
 * jdk-jre 8 update 131<br>
 * Windows 7, April 2017<br>
 * jimakoskx@hotmail.com
 *
 *
 *
 */
public class YawPitchRollRegulator {
    static YawPitchRollRegulator ClassShower=new YawPitchRollRegulator();
    static TransformGroup rotInitialtg=new TransformGroup();
    static TransformGroup postg=new TransformGroup();
    static TransformGroup rottg=new TransformGroup();
    static TransformGroup followtg=new TransformGroup();
    static Vector3d pos=new Vector3d();
   
    public static void main(String[] args) {
        //using above statics that can be deleted
        postg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
        rottg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
        rotInitialtg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
        followtg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
       
       
        System.setProperty("sun.awt.noerasebackground", "true");
        SimpleUniverse su=new SimpleUniverse();
       
       
        Appearance appear=new Appearance();
        appear.setColoringAttributes(new ColoringAttributes(new Color3f(0,0,1),ColoringAttributes.NICEST));
        Cone movingCone=new Cone(0.5f,0.3f,appear);
        Transform3D initialRotationOfCone=new Transform3D();
        initialRotationOfCone.rotX(-Math.PI/2);
        rotInitialtg.setTransform(initialRotationOfCone);
       
       
        double ccr=0.2;
        ColorCube followerCube=new ColorCube(ccr);
        Transform3D initialPosOfCube=new Transform3D();
        initialPosOfCube.setTranslation(new Vector3d(0,0,ccr*2));
        followtg.setTransform(initialPosOfCube);
        ColorCube cc2=new ColorCube(ccr/2);
       
       
       
        BranchGroup bgMovingContent=new BranchGroup();
        bgMovingContent.addChild(postg);
            postg.addChild(rottg);
                rottg.addChild(rotInitialtg);
                rotInitialtg.addChild(movingCone);
                rottg.addChild(followtg);
                    followtg.addChild(followerCube);
       
       
       
       

        su.getCanvas().addKeyListener(new KeyListener() {
            @Override
            public void keyPressed(KeyEvent e) {
                int keyCode=e.getKeyCode();
                boolean iSControl=e.isControlDown();
                double st=0.1;
                if(keyCode==KeyEvent.VK_UP){
                    if(iSControl){pos.y+=st;Transform3D ntr=new Transform3D();ntr.setTranslation(pos);postg.setTransform(ntr);}
                    else{
                        ClassShower.addPitch();
                        rottg.setTransform(ClassShower.trans);
                    }
                }
                else if(keyCode==KeyEvent.VK_DOWN){
                    if(iSControl){pos.y-=st;Transform3D ntr=new Transform3D();ntr.setTranslation(pos);postg.setTransform(ntr);}
                    else{
                        ClassShower.addPitchMinus();
                        rottg.setTransform(ClassShower.trans);
                    }
                }
                else if(keyCode==KeyEvent.VK_LEFT){
                    if(iSControl){pos.x-=st;Transform3D ntr=new Transform3D();ntr.setTranslation(pos);postg.setTransform(ntr);}
                    else{
                        ClassShower.addRoll();
                        rottg.setTransform(ClassShower.trans);
                    }
                }
                else if(keyCode==KeyEvent.VK_RIGHT){
                    if(iSControl){pos.x+=st;Transform3D ntr=new Transform3D();ntr.setTranslation(pos);postg.setTransform(ntr);}
                    else{
                        ClassShower.addRollMinnus();
                        rottg.setTransform(ClassShower.trans);
                    }
                }
                else if(keyCode==KeyEvent.VK_A){//down
                    if(iSControl){pos.z-=st;Transform3D ntr=new Transform3D();ntr.setTranslation(pos);postg.setTransform(ntr);}
                    else{
                        ClassShower.addYaw();
                        rottg.setTransform(ClassShower.trans);
                    }
                }
                else if(keyCode==KeyEvent.VK_Z){//up
                    if(iSControl){pos.z+=st;Transform3D ntr=new Transform3D();ntr.setTranslation(pos);postg.setTransform(ntr);}
                    else{
                        ClassShower.addYawMinus();
                        rottg.setTransform(ClassShower.trans);
                    }
                }
                else if(keyCode==KeyEvent.VK_ENTER){ClassShower.resetYawPitchRoll(0,0,0);rottg.setTransform(ClassShower.trans);}
                else if(keyCode==KeyEvent.VK_SPACE){//move
                    Point3d v=new Point3d(0,0,-0.2);
                    ClassShower.trans.transform(v);
                    pos.add(v);
                    Transform3D ntr=new Transform3D();ntr.setTranslation(pos);postg.setTransform(ntr);
                }
           



}
            public void keyTyped(KeyEvent e) {}
            public void keyReleased(KeyEvent e) {}
           
        });
       
        su.getViewingPlatform().setNominalViewingTransform();
        su.addBranchGraph(bgMovingContent);
        su.getCanvas().requestFocus();
    }
   
    //Delete all above!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   
   
    /**
     * Yaw Pitch Roll Values divided by 2
     */
    public double x,y,z;
    /**
     * helping for speed (not allocating)
     */
    double dx,dy,dz;
    /**
     * The main Quad that holds the Total Yaw Pitch Roll values
     */
    public Quat4d q;
    /**
     * When you want to add a certain amount we have this items (not allocating)
     */
    public Quat4d qx,qy,qz;
    /**
     * More quicker if we have the steps ready and just execute one Quad multiplication
     */
    public Quat4d qxAdd,qyAdd,qzAdd;
    public Quat4d qxMinus,qyMinus,qzMinus;
    /**
     * Every time that you change the values you must call from your code<br>
     * setTransform(trans)  .... (refresh)
     */
    public Transform3D trans;
   
    /**
     * Constructs with zero Yaw Pitch Roll and with the default Step degrees
     */
    public YawPitchRollRegulator(){
        trans=new Transform3D();
        q=new Quat4d(0,0,0,1);
        qx=new Quat4d(0,0,0,1);
        qy=new Quat4d(0,0,0,1);
        qz=new Quat4d(0,0,0,1);
        qxAdd=new Quat4d(0,0,0,1);
        qyAdd=new Quat4d(0,0,0,1);
        qzAdd=new Quat4d(0,0,0,1);
        qxMinus=new Quat4d(0,0,0,1);
        qyMinus=new Quat4d(0,0,0,1);
        qzMinus=new Quat4d(0,0,0,1);
       
        resetYawPitchRoll(0,0,0);
        //ensuring Minus step is set
        setAddStepsForYawPitchRoll(Math.toRadians(2),Math.toRadians(5), Math.toRadians(10));
       
    }
    //helping fnctions
    public double pitch(){return x;}
    public double yaw(){return y;}
    public double roll(){return z;}
    public double pitchDegrees(){return Math.toDegrees(x);}
    public double yawDegrees(){return Math.toDegrees(y);}
    public double rollDegrees(){return Math.toDegrees(z);}
   
    public String toString(){
        String out=getClass().getSimpleName()+" Yaw( "+yawDegrees()+" ) , Pitch( "+pitchDegrees()+" ) , Roll( "+rollDegrees()+" )";
        return out;
    }
    //Thread thr=new Thread("Avoiding Overflows on the Air !"){public void start(){setDaemon(true);super.start();}public void run(){while(true){checkOverflows();try{sleep(1000*20);}catch(InterruptedException inter){}}}};
    /*void checkOverflows(){
        System.out.println("Checking overflows");
        x%=Rad360;y%=Rad360;z%=Rad360;
        //??????????????
    }*/
   
    /**
     * If you want to change all values use this
     * @param newYaw
     * @param newPitch
     * @param newRoll
     */
    public void resetYawPitchRoll(double newYaw,double newPitch,double newRoll){
        x=newPitch;
        y=newYaw;
        z=newRoll;
        //Shall we avoid overflows here or in a Thread? Here we want speed
        //x%=Rad360;y%=Rad360;z%=Rad360;
        //System.out.println("Yaw:"+Math.toDegrees(y));
        //System.out.println("Pitch:"+Math.toDegrees(x));
        //System.out.println("Roll:"+Math.toDegrees(z));
       
       
        x/=2;
        y/=2;
        z/=2;
       
       
        //now we reset the total Quat
        q.set(0,0,0,1);
       
        //now set the current Quat for each axis
        qx.w=Math.cos(x);
        qx.x=Math.sin(x);

        qy.w=Math.cos(y);
        qy.y=Math.sin(y);
       
        qz.w=Math.cos(z);
        qz.z=Math.sin(z);
       
        //Result of all angles in main quat
        //THIS ORDER MUST NOT BE CHANGED !!!!!!!!!!!!!!
        q.mul(qx);
        q.mul(qy);
        q.mul(qz);
       
        //next version try speed up all multiplications
        trans.set(q);
       
    }
   
    /**
     * Adding (or subtracts if negative) those Radians to the current Yaw,Pitch,Roll radians
     * @param difYaw
     * @param difPitch
     * @param difRoll
     */
    public void addYawPitchRoll(double difYaw,double difPitch,double difRoll){
        dx=difPitch;
        dy=difYaw;
        dz=difRoll;

        dx/=2;
        dy/=2;
        dz/=2;
        x+=dx;
        y+=dy;
        z+=dz;
        //now set the STEP -dif  Quat for each axis
        qx.w=Math.cos(dx);
        qx.x=Math.sin(dx);

        qy.w=Math.cos(dy);
        qy.y=Math.sin(dy);
       
        qz.w=Math.cos(dz);
        qz.z=Math.sin(dz);
       
        //Multipling new values with the existing MAIN QUAD
        //THIS ORDER MUST NOT BE CHANGED !!!!!!!!!!!!!!
        q.mul(qx);
        q.mul(qy);
        q.mul(qz);
       
        //next version try speed all multiplications
        trans.set(q);
       
    }
    public void addYaw(double difYaw){
        dy=difYaw;
        dy/=2;
        y+=dy;
        qy.w=Math.cos(dy);
        qy.y=Math.sin(dy);
        q.mul(qy);
        trans.set(q);
       
    }   
    public void addPitch(double difPitch){
        dx=difPitch;
        dx/=2;
        x+=dx;
        qx.w=Math.cos(dx);
        qx.x=Math.sin(dx);
        q.mul(qx);
        trans.set(q);
    }
    public void addRoll(double difRoll){
        dz=difRoll;
        dz/=2;
        z+=dz;
        qz.w=Math.cos(dz);
        qz.z=Math.sin(dz);
        q.mul(qz);
        trans.set(q);
    }
    public void addYaw(){
        y+=dy;
        q.mul(qyAdd);
        trans.set(q); 
    }   
    public void addPitch(){
        x+=dx;
        q.mul(qxAdd);
        trans.set(q);
    }
    public void addRoll(){
        z+=dz;
        q.mul(qzAdd);
        trans.set(q);
    }
    public void addYawMinus(){
        y-=dy;
        q.mul(qyMinus);
        trans.set(q); 
    }   
    public void addPitchMinus(){
        x-=dx;
        q.mul(qxMinus);
        trans.set(q);
    }
    public void addRollMinnus(){
        z-=dz;
        q.mul(qzMinus);
        trans.set(q);
    }
    public void setAddStepsForYawPitchRoll(double difYaw,double difPitch,double difRoll){
        dx=difPitch;
        dy=difYaw;
        dz=difRoll;
        dx/=2;
        dy/=2;
        dz/=2;
        //preparing Adding steps
        qxAdd.w=Math.cos(dx);
        qxAdd.x=Math.sin(dx);
        qyAdd.w=Math.cos(dy);
        qyAdd.y=Math.sin(dy);
        qzAdd.w=Math.cos(dz);
        qzAdd.z=Math.sin(dz);
       
        //preparing the Minus steps
        qxMinus.w=Math.cos(-dx);
        qxMinus.x=Math.sin(-dx);
        qyMinus.w=Math.cos(-dy);
        qyMinus.y=Math.sin(-dy);
        qzMinus.w=Math.cos(-dz);
        qzMinus.z=Math.sin(-dz);
       
       
       
    }


}