Sunday, October 21, 2012

Java run with external jar



1. When classpath is used, jar command is ignored . So use "classpath" with class file and "cp" with jar file

2. NEVER FORGET TO PUT : even you use only 1 external jar. In some cases you will get compilation error if you don't put :

java  -classpath  /media/Data/eclipseWorkspace/myExternalJar/commons-math-1.2.jar:  com.cbrc.motifmap.CombinationOfTF

java  -cp /media/Data/eclipseWorkspace/myExternalJar/commons-math-1.2.jar:    -jar myJar.jar

java comparator sorted linked hash map treemap


////////////  inner class /////////////////


    class ValueComparator implements Comparator {

        LinkedHashMap  base;
        public ValueComparator(LinkedHashMap hMap) {
            this.base = hMap;
        }

        public int compare(Object a, Object b) {

            Myclass obj1 = (Myclass) base.get(a);
            Myclass obj2 = (Myclass) base.get(b);

            if( obj1.getRankDistance() > obj2.getRankDistance()    ) {
                return -1;
            }  else {
                return 1;
            }
        }

    }

    class Myclass
    {
        double rankDistance;
        DMFmotif  motif;
        public Myclass( double rankDistance, DMFmotif motif) {
            super();
            this.rankDistance = rankDistance;
            this.motif = motif;
        }
        public double getRankDistance() {
            return rankDistance;
        }
        public void setRankDistance(double rankDistance) {
            this.rankDistance = rankDistance;
        }
        public DMFmotif getMotif() {
            return motif;
        }
        public void setMotif(DMFmotif motif) {
            this.motif = motif;
        }


    }


//////////////////////////////////////////////// HASH MAP /////////////


LinkedHashMap lhMap = new LinkedHashMap();
ValueComparator vcomp =  new ValueComparator(lhMap);
TreeMap sorted_map = new TreeMap(vcomp);

        //         1. First insert valus into orig hashmap loop ....

        for(int i=0 ; i< vecDMFmotif.size() ; i++) {
            DMFmotif cur = vecDMFmotif.get(i);
            lhMap.put( cur.getId() ,    new Myclass(cur.getRankValue() ,cur )  ) ;


        }


        //         2.  // NOW SORTING IS DONE
        for (String key:lhMap.keySet()) {
            sorted_map.put(key, lhMap.get(key));
        }

        //         3. Write sorted values       
        Myclass inner;
        Set set = sorted_map.entrySet();
        Iterator i = set.iterator();
        while(i.hasNext()) {
            Map.Entry me = (Map.Entry)i.next();
            inner =  (Myclass)me.getValue()  ;

            System.out.println( inner.getRankDistance() + "\t"  +           inner.getMotif().getId() );             
        }    



Thursday, October 11, 2012

LATEX basic command


Float
  • 3 float Table, Figure, Picture
  • Caption can be given only to figure


tabular

  is just an array. Not float


\begin{table}
\begin{center}
\begin{tabular} { |r | r | r | c | } \hline
\multicolumn{4}{c}{this is header of table} \\ \hline
1 & 2 & 3 & 4 \\ \hline
\multicolumn{4}{c}{this is text} \\ \hline
\bf 4 & \it 5 & 6 & val \\ \hline \hline
\end{tabular}
\caption{mycaption}
\label{lbl:mylabel1}
\end{center}
\end{table}


Math environment

  • running text  $  write here $ 
  • centered & new line \[  ]\ 

\[
\left(
\begin{array}{cc}
a & b
\end{array}
\right)
\]
\[  2^{2^{\cdot{^2}}}  \]

Bibtex

.....
at end of document write
\bibliography{mybib.bib}

to cite
\cite{label1}
\cite{lab1}
\bibliography{1}
\bibliographystyle{plain} % alpha / unsrt / siam / ieeetr
\end{document}


Thursday, October 4, 2012

LATEX beamer tutorial

% This text is proprietary.
% It's a part of presentation made by myself.
% It may not used commercial.
% The noncommercial use such as private and study is free
% Dec 2007
% Author: Sascha Frank
% University Freiburg
% www.informatik.uni-freiburg.de/~frank/
%
%
\documentclass{beamer}
\setbeamertemplate{navigation symbols}{}


\usetheme{Warsaw}

\beamersetuncovermixins{\opaqueness<1>{25}}{\opaqueness<2 -="-">{15}}
\begin{document}
\title{Beamer Class Warsaw}
\author{Sascha Frank}
\date{\today}


\begin{frame}
\titlepage
\end{frame}

\begin{frame}\frametitle{Table of contents}\tableofcontents
\end{frame}


\section{Section no.1}
\begin{frame}\frametitle{Title}
Each frame should have a title.
\end{frame}
\subsection{Subsection no.1.1  }
\begin{frame}
Without title somethink is missing.
\end{frame}


\section{Section no. 2}
\subsection{Lists I}
\begin{frame}\frametitle{unnumbered lists}
\begin{itemize}
\item Introduction to  \LaTeX
\item Course 2
\item Termpapers and presentations with \LaTeX
\item Beamer class
\end{itemize}
\end{frame}

\begin{frame}\frametitle{lists with pause}
\begin{itemize}
\item Introduction to  \LaTeX \pause
\item Course 2 \pause
\item Termpapers and presentations with \LaTeX \pause
\item Beamer class
\end{itemize}
\end{frame}

\subsection{Lists II}
\begin{frame}\frametitle{numbered lists}
\begin{enumerate}
\item Introduction to  \LaTeX
\item Course 2
\item Termpapers and presentations with \LaTeX
\item Beamer class
\end{enumerate}
\end{frame}

\begin{frame}\frametitle{numbered lists with pause}
\begin{enumerate}
\item Introduction to  \LaTeX \pause
\item Course 2 \pause
\item Termpapers and presentations with \LaTeX \pause
\item Beamer class
\end{enumerate}
\end{frame}

\section{Section no.3}
\subsection{Tables}
\begin{frame}\frametitle{Tables}
\begin{tabular}{|c|c|c|}
\hline
\textbf{Date} & \textbf{Instructor} & \textbf{Title} \\
\hline
WS 04/05 & Sascha Frank & First steps with  \LaTeX  \\
\hline
SS 05 & Sascha Frank & \LaTeX \ Course serial \\
\hline
\end{tabular}
\end{frame}


\begin{frame}\frametitle{Tables with pause}
\begin{tabular}{c c c}
A & B & C \\
\pause
1 & 2 & 3 \\
\pause
A & B & C \\
\end{tabular}
\end{frame}


\section{Section no. 4}
\subsection{blocs}
\begin{frame}\frametitle{blocs}

\begin{block}{title of the bloc}
bloc text
\end{block}

\begin{exampleblock}{title of the bloc}
bloc text
\end{exampleblock}


\begin{alertblock}{title of the bloc}
bloc text
\end{alertblock}
\end{frame}

\section{Section no. 5}
\subsection{split screen}

\begin{frame}\frametitle{splitting screen}
\begin{columns}
\begin{column}{5cm}
\begin{itemize}
\item Beamer
\item Beamer Class
\item Beamer Class Latex
\end{itemize}
\end{column}
\begin{column}{5cm}
\begin{tabular}{|c|c|}
\hline
\textbf{Instructor} & \textbf{Title} \\
\hline
Sascha Frank &  \LaTeX \ Course 1 \\
\hline
Sascha Frank &  Course serial  \\
\hline
\end{tabular}
\end{column}
\end{columns}
\end{frame}

\subsection{Pictures}
\begin{frame}\frametitle{pictures in latex beamer class}
\begin{figure}
\includegraphics[scale=0.5]{PIC1.png}
\caption{show an example picture}
\end{figure}
\end{frame}

\subsection{joining picture and lists}

\begin{frame}
\frametitle{pictures and lists in beamer class}
\begin{columns}
\begin{column}{5cm}
\begin{itemize}
\item<1 -="-"> subject 1
\item<3 -="-"> subject 2
\item<5 -="-"> subject 3
\end{itemize}
\vspace{3cm}
\end{column}
\begin{column}{5cm}
\begin{overprint}
\includegraphics<2>{PIC1}
\includegraphics<4>{PIC2}
\includegraphics<6>{PIC3}
\end{overprint}
\end{column}
\end{columns}
\end{frame}


\subsection{pictures which need more space}
\begin{frame}[plain]
\frametitle{plain, or a way to get more space}
\begin{figure}
\includegraphics[scale=0.5]{PIC1}
\caption{show an example picture}
\end{figure}
\end{frame}



\end{document}