Update of /cvsroot/xpg-xml/edu/iicm/xpg/transitions/latex
In directory usw-pr-cvs1:/tmp/cvs-serv29299/transitions/latex
Modified Files:
WriteHeaderTransition.java WriteSectHeaderTransition.java
Added Files:
WriteItemTransition.java WriteListHeaderTransition.java
WriteListTransition.java
Log Message:
another little example added
--- NEW FILE: WriteItemTransition.java ---
/***********************************************************************
*
* Copyright (c) 2001 IICM, Graz University of Technology
* Schiesstattgasse 4a, A-8010 Graz, Austria.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License (LGPL)
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
***********************************************************************/
package edu.iicm.xpg.transitions.simple;
import edu.iicm.xpg.statemachine.Transition;
import edu.iicm.xpg.statemachine.State;
import edu.iicm.xpg.statemachine.StateMachine;
import edu.iicm.xpg.statemachine.Input;
import edu.iicm.xpg.statemachine.XMLInput;
import edu.iicm.xpg.statemachine.DataObject;
import edu.iicm.xpg.statemachine.Const;
import edu.iicm.xpg.util.Debug;
import java.util.Vector;
import java.util.Enumeration;
//----------------------------------------------------------------------
/**
* @author Guenther Brand
* @version $Revision: 1.1 $
*/
public class WriteItemTransition implements Transition
{
//----------------------------------------------------------------------
/**
* @param input the input that triggered this transition
* @param from_state the start state for this transition
* @param to_state the destination state for this transition
* @param machine the state machine that this transition belongs to
* @param data user defined data
* @return
* @exception Exception whatever an implementation can throw
*/
public String transitionTriggered(Input input,State from_state,State to_state,
StateMachine machine,DataObject data)
throws Exception
{
StringBuffer result = (StringBuffer)data.getObject(Const.RESULT_BUFFER);
String item = data.getXMLElement().getValue().trim();
Vector list_items = (Vector)data.getObject("list_items");
if (list_items == null)
{
list_items = new Vector();
data.putObject("list_items", list_items);
}
list_items.add(item);
result.append("\\item " + item + "\n");
return(null);
}
}
--- NEW FILE: WriteListHeaderTransition.java ---
/***********************************************************************
*
* Copyright (c) 2001 IICM, Graz University of Technology
* Schiesstattgasse 4a, A-8010 Graz, Austria.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License (LGPL)
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
***********************************************************************/
package edu.iicm.xpg.transitions.latex;
import edu.iicm.xpg.statemachine.Transition;
import edu.iicm.xpg.statemachine.State;
import edu.iicm.xpg.statemachine.StateMachine;
import edu.iicm.xpg.statemachine.Input;
import edu.iicm.xpg.statemachine.XMLInput;
import edu.iicm.xpg.statemachine.DataObject;
import edu.iicm.xpg.statemachine.Const;
import edu.iicm.xpg.util.Debug;
import java.util.Vector;
import java.util.Enumeration;
//----------------------------------------------------------------------
/**
* @author Guenther Brand
* @version $Revision: 1.1 $
*/
public class WriteListHeaderTransition implements Transition
{
//----------------------------------------------------------------------
/**
* @param input the input that triggered this transition
* @param from_state the start state for this transition
* @param to_state the destination state for this transition
* @param machine the state machine that this transition belongs to
* @param data user defined data
* @return
* @exception Exception whatever an implementation can throw
*/
public String transitionTriggered(Input input,State from_state,State to_state,
StateMachine machine,DataObject data)
throws Exception
{
StringBuffer result = (StringBuffer)data.getObject(Const.RESULT_BUFFER);
Vector list_items = new Vector();
data.putObject("list_items", list_items);
result.append("\n\\begin{itemize}\n");
return(null);
}
}
--- NEW FILE: WriteListTransition.java ---
/***********************************************************************
*
* Copyright (c) 2001 IICM, Graz University of Technology
* Schiesstattgasse 4a, A-8010 Graz, Austria.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License (LGPL)
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
***********************************************************************/
package edu.iicm.xpg.transitions.simple;
import edu.iicm.xpg.statemachine.Transition;
import edu.iicm.xpg.statemachine.State;
import edu.iicm.xpg.statemachine.StateMachine;
import edu.iicm.xpg.statemachine.Input;
import edu.iicm.xpg.statemachine.XMLInput;
import edu.iicm.xpg.statemachine.DataObject;
import edu.iicm.xpg.statemachine.Const;
import edu.iicm.xpg.util.Debug;
import java.util.Vector;
import java.util.Enumeration;
//----------------------------------------------------------------------
/**
* @author Guenther Brand
* @version $Revision: 1.1 $
*/
public class WriteListTransition implements Transition
{
//----------------------------------------------------------------------
/**
* @param input the input that triggered this transition
* @param from_state the start state for this transition
* @param to_state the destination state for this transition
* @param machine the state machine that this transition belongs to
* @param data user defined data
* @return
* @exception Exception whatever an implementation can throw
*/
public String transitionTriggered(Input input,State from_state,State to_state,
StateMachine machine,DataObject data)
throws Exception
{
StringBuffer result = (StringBuffer)data.getObject(Const.RESULT_BUFFER);
Vector list_items = (Vector)data.removeObject("list_items");
String eval_attrib = data.getXMLElement().getAttributes().getValue("eval");
if (eval_attrib != null)
if (eval_attrib.equals("sum")) addListSum(result, list_items);
else if (eval_attrib.equals("avg")) addListAvg(result, list_items);
result.append("\\end{itemize}\n");
return(null);
}
protected void addListSum(StringBuffer result, Vector list_items)
{
try
{
float sum = 0;
for (int item=0; item < list_items.size(); item++)
{
float item_value =
(new Float((String)list_items.get(item))).floatValue();
sum += item_value;
}
result.append("\\item {\\b sum: " + sum + "}\n");
}
catch (NumberFormatException exc)
{
result.append("\\item {\\b sum: list contains no number item(s)}\n");
}
}
protected void addListAvg(StringBuffer result, Vector list_items)
{
try
{
float sum = 0;
for (int item=0; item < list_items.size(); item++)
{
float item_value =
(new Float((String)list_items.get(item))).floatValue();
sum += item_value;
}
result.append("\\item {\\b avg: " + sum / list_items.size() + "}\n");
}
catch (NumberFormatException exc)
{
result.append("\\item {\\b avg: list contains no number item(s)}\n");
}
}
}
Index: WriteHeaderTransition.java
===================================================================
RCS file: /cvsroot/xpg-xml/edu/iicm/xpg/transitions/latex/WriteHeaderTransition.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** WriteHeaderTransition.java 18 Mar 2002 06:45:54 -0000 1.1
--- WriteHeaderTransition.java 16 Apr 2002 06:55:02 -0000 1.2
***************
*** 31,34 ****
--- 31,36 ----
import edu.iicm.xpg.statemachine.Const;
+ import edu.iicm.xpg.util.Debug;
+
//----------------------------------------------------------------------
/**
***************
*** 61,66 ****
if (doc_title == null)
! System.err.println("Error (printing to form): document has no title");
!
html_form.append("\n\\title{" + doc_title + "}\n");
--- 63,72 ----
if (doc_title == null)
! {
! if (Debug.DEBUG)
! Debug.println(Debug.TRANSITION_LEVEL,
! "Error (printing to form): document has no title");
!
! }
html_form.append("\n\\title{" + doc_title + "}\n");
Index: WriteSectHeaderTransition.java
===================================================================
RCS file: /cvsroot/xpg-xml/edu/iicm/xpg/transitions/latex/WriteSectHeaderTransition.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** WriteSectHeaderTransition.java 21 Mar 2002 08:10:17 -0000 1.2
--- WriteSectHeaderTransition.java 16 Apr 2002 06:55:02 -0000 1.3
***************
*** 32,35 ****
--- 32,37 ----
import edu.iicm.xpg.statemachine.Const;
+ import edu.iicm.xpg.util.Debug;
+
import java.util.Vector;
import java.util.Enumeration;
***************
*** 37,41 ****
//----------------------------------------------------------------------
/**
! * @author Günther Brand
* @version $Revision$
*/
--- 39,43 ----
//----------------------------------------------------------------------
/**
! * @author Guenther Brand
* @version $Revision$
*/
***************
*** 61,75 ****
StringBuffer result = (StringBuffer)data.getObject(Const.RESULT_BUFFER);
String section_name =
! data.getXMLElement().getAttributes().getValue("name");
Integer sect_depth_obj = (Integer)data.removeObject("sect_depth");
int sect_depth;
if ( sect_depth_obj == null )
sect_depth = 0;
! else sect_depth= sect_depth_obj.intValue();
result.append("\n\\");
! for ( int depth = 0; depth < sect_depth; depth++ )
! result.append("sub");
! result.append("section{" + section_name + "}\n");
data.putObject("sect_depth", new Integer(++sect_depth) );
--- 63,90 ----
StringBuffer result = (StringBuffer)data.getObject(Const.RESULT_BUFFER);
String section_name =
! data.getXMLElement().getAttributes().getValue("title");
Integer sect_depth_obj = (Integer)data.removeObject("sect_depth");
int sect_depth;
if ( sect_depth_obj == null )
sect_depth = 0;
! else sect_depth = sect_depth_obj.intValue();
result.append("\n\\");
! String sect;
! switch (sect_depth)
! {
! case 0 : sect = "section"; break;
! case 1 : sect = "subsection"; break;
! case 2 : sect = "subsubsection"; break;
! case 3 : sect = "paragraph"; break;
! case 4 : sect = "subparagraph"; break;
! case 5 : sect = "subsubparagraph"; break;
! default:
! if (Debug.DEBUG)
! Debug.println(Debug.WARNING_LEVEL,
! "WriteSectHeaderTransition: illegal section depth!");
! return null;
! }
! result.append(sect + "{" + section_name + "}\n");
data.putObject("sect_depth", new Integer(++sect_depth) );
|