pfc-prolog-cvs Mailing List for pfc-prolix (Page 10)
Status: Beta
Brought to you by:
ivanfrade
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(77) |
Jun
(37) |
Jul
(152) |
Aug
(180) |
Sep
(45) |
Oct
|
Nov
|
Dec
|
---|
From: <iva...@us...> - 2003-07-30 20:12:51
|
Update of /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/prolix/web/servlets In directory sc8-pr-cvs1:/tmp/cvs-serv20789/src/org/asturlinux/frade/prolix/web/servlets Modified Files: TreeServlet.java Added Files: NodeDrawData.java SvgGenerator.java Log Message: Added auxiliar classes to draw svg in servlet --- NEW FILE: NodeDrawData.java --- package org.asturlinux.frade.prolix.web.servlets; import java.awt.Dimension; import java.awt.Point; public class NodeDrawData { public Dimension size; public Point origin; public NodeDrawData(Point originPoint, Dimension sizeBox) { origin = originPoint; size = sizeBox; } } --- NEW FILE: SvgGenerator.java --- package org.asturlinux.frade.prolix.web.servlets; import java.util.Iterator; import java.io.Writer; import java.io.IOException; //import java.io.FileWriter; //import java.io.FileReader; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.FactoryConfigurationError; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.*; import org.xml.sax.SAXException; import org.xml.sax.InputSource; import java.awt.Dimension; import java.awt.Point; import java.util.Vector; import java.io.StringWriter; import java.io.StringReader; import org.asturlinux.frade.prolix.web.servlets.NodeDrawData; public class SvgGenerator { /*************************** * Search methods ************************** */ /** * return nodes with "name" that have an "attribute" with defined "value" */ private Node[] search(Node root, String name, String attribute, String value) { Vector results = new Vector(); // Pass root element if (root.getNodeType() == Node.DOCUMENT_NODE) root = ((Document)root).getDocumentElement(); NodeList children = root.getChildNodes(); for ( int i = 0 ; i < children.getLength() ; i++) { Node currentNode = children.item(i); int nodeType = currentNode.getNodeType(); if (nodeType == Node.ELEMENT_NODE && currentNode.getNodeName().equals(name) && currentNode.hasAttributes()) { NamedNodeMap attMap = currentNode.getAttributes(); Node attrib = attMap.getNamedItem(attribute); if (attrib != null && attrib.getNodeValue().equals(value)) results.add(currentNode); } } //for //Not found return (Node [])results.toArray(new Node[results.size()]); } private Node searchNodeByNumber(Node root, String number) { if (root.getNodeType() == Node.DOCUMENT_NODE) root = ((Document)root).getDocumentElement(); NodeList children = root.getChildNodes(); for ( int i = 0 ; i < children.getLength() ; i++ ) { Node currentNode = children.item(i); int nodeType = currentNode.getNodeType(); if (nodeType == Node.ELEMENT_NODE && (currentNode.getNodeName().equals("node") || currentNode.getNodeName().equals("solution"))&& currentNode.hasAttributes()) { NamedNodeMap attMap = currentNode.getAttributes(); Node attribute = attMap.getNamedItem("number"); if (attribute != null && attribute.getNodeValue().equals(number)) return currentNode; } } // not found return null; } /** ******************************** * Draw methods * ******************************** */ public static final int marginX = 10; public static final int marginY = 5; public static final int nodeSizeX = 60; public static final int nodeSizeY = 40; private Dimension drawNode(Node raiz, String number, Point leftTopCorner, Writer output) { Node result = searchNodeByNumber(raiz,number); System.out.println("Looking for transitions"); Node[] result2 = search(raiz,"transition","origin",number); Dimension boundingBox = new Dimension(0,0); int childYBaseLine = leftTopCorner.y+marginY+nodeSizeY; //Vector childPoints = new Vector(); Vector childBoxes = new Vector(); for (int i = 0; i < result2.length ; i++) { String destiny = result2[i].getAttributes().getNamedItem("destiny").getNodeValue(); Point childPoint = new Point(leftTopCorner.x+ boundingBox.width, childYBaseLine); Dimension currentChildBoundingBox = drawNode(raiz,destiny,childPoint,output); childBoxes.add(new NodeDrawData(childPoint,currentChildBoundingBox)); boundingBox.width += currentChildBoundingBox.width + marginX; boundingBox.height = Math.max(boundingBox.height, currentChildBoundingBox.height); } boundingBox.width = Math.max(boundingBox.width, nodeSizeX); boundingBox.height += nodeSizeY + marginY; System.out.println("Aqui pinto la cajita"); Point nodePoint = new Point(boundingBox.width / 2 + leftTopCorner.x , leftTopCorner.y ); NodeDrawData[] destinations = (NodeDrawData[])childBoxes.toArray(new NodeDrawData[childBoxes.size()]); for (int i = 0; i < destinations.length ; i++) { imprimirTransicion(nodePoint,destinations[i],output); } imprimirNodo(result,nodePoint,output); return boundingBox; } private void imprimirTransicion(Point origen, NodeDrawData destino, Writer output) { try { output.write("<path d=\"M " + (origen.x + nodeSizeX/2) + " " + (origen.y+nodeSizeY) + " L " + (destino.origin.x + destino.size.width/2 + nodeSizeX/2) + " " + destino.origin.y + "\" \n"); output.write("id=\"" + origen.x*origen.y + "\"\n"); output.write("style=\"fill:none;fill-rule:evenodd;stroke:black;" + "stroke-opacity:1;stroke-width:0.5pt;stroke-linejoin:" + "miter;stroke-linecap:butt;fill-opacity:1;\"/>"); } catch (IOException e) { System.out.println("Error writing transition"); } } // And the refactoring winner is... private void imprimirNodo(Node node, Point leftTopPoint, Writer output) { // System.out.println("En el punto (" + leftTopPoint.x + "," // + leftTopPoint.y + ") imprimo el nodo " // + node.getAttributes().getNamedItem("number").getNodeValue()); try { output.write("<rect \n " + "width=\"" + nodeSizeX + "\" \n" + "height=\"" + nodeSizeY + "\" \n" + "x=\"" + leftTopPoint.x + "\" \n" + "y=\"" + leftTopPoint.y + "\" \n" + "id=\""+node.getAttributes().getNamedItem("number").getNodeValue()+"\" \n" + "style=\"fill:#00ca00;fill-opacity:1;\" " + "/> \n"); Node label = node.getAttributes().getNamedItem("label"); if (label != null) output.write("<text \n" + "x=\"" + (leftTopPoint.x + nodeSizeX/10) + "\" \n" + "y=\"" + (leftTopPoint.y + nodeSizeY/2 ) + "\" \n" + "id=\"text" + node.getAttributes().getNamedItem("number").getNodeValue() + "\">\n" + "<tspan id=\"" + node.getAttributes().getNamedItem("number").getNodeValue() + "\" >\n" + label.getNodeValue() + "</tspan>" + "</text>"); } catch (IOException e) { System.out.println("Error writing Node"); } } /** * Aux methods ***/ private void initWriter(Writer w) throws IOException { w.write("<?xml version=\"1.0\" " + "encoding=\"UTF-8\" standalone=\"no\"?>\n" + "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 20010904//EN\"\n" + "\"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\">\n"); w.write("<svg xmlns=\"http://www.w3.org/2000/svg\"\n " + " xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n " + " version=\"1\"\n " + " x=\"30\" y=\"30\">\n "); } private void finishWriter(Writer w) throws IOException { w.write("\n</svg>\n"); } /** ************************************* * Main method ** ************************************* */ public String transform(String xmlString) { try { //FileReader xmlFile = new FileReader("/home/ivan/pfc/documentos/salida-prolix-treexml.xml"); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); //Document document = builder.parse(new InputSource(xmlFile)); Document document = builder.parse(new InputSource(new StringReader(xmlString))); // Works with generic Writer. StringWriter svg = new StringWriter(); initWriter(svg); Dimension total = drawNode(document,"1",new Point(30,30),svg); System.out.println("Dimensiones totales: " + total.width + " " + total.height); finishWriter(svg); svg.close(); System.out.println("Pues no paso nada malo"); return svg.toString(); } catch (FactoryConfigurationError e) { // unable to get a document builder factory return null; } catch (ParserConfigurationException e) { // parser was unable to be configured return null; } catch (SAXException e) { // parsing error return null; } catch (IOException e) { System.out.println("I/O Error: File Not Exist or Problems with Writers"); return null; } } //public static void main(String argv[]) { // SvgGenerator on = new SvgGenerator(); // String cool = on.transform(); // System.out.println(cool); //} } Index: TreeServlet.java =================================================================== RCS file: /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/prolix/web/servlets/TreeServlet.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TreeServlet.java 27 Jul 2003 14:24:22 -0000 1.1 --- TreeServlet.java 30 Jul 2003 20:12:49 -0000 1.2 *************** *** 5,8 **** --- 5,9 ---- import javax.servlet.http.*; import org.asturlinux.frade.prolix.web.beans.CurrentStateBean; + import org.asturlinux.frade.prolix.web.servlets.SvgGenerator; public class TreeServlet extends HttpServlet *************** *** 17,35 **** CurrentStateBean bean = (CurrentStateBean)session.getAttribute("prologData"); ! // FIXME response.setContentType("image/svg+xml"); PrintWriter out = response.getWriter(); - // XML header - out.println("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"); - out.println("<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 20010904//EN\" \"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\">\n"); - - // SVG start - out.println("<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" version=\"1\" x=\"0\" y=\"0\" width=\"744.094\" height=\"1052.36\" id=\"svg101\">\n"); - - out.println("<defs id=\"defs103\" /> <rect width=\"244.357\" height=\"107.517\" x=\"87.9684\" y=\"120.549\" style=\"font-size:12;fill:#808080;fill-rule:evenodd;stroke-width:1pt;\" id=\"rect104\" />"); - out.println(bean.getCurrentResult()); - - // SVG stop - out.println("</svg> "); } } --- 18,27 ---- CurrentStateBean bean = (CurrentStateBean)session.getAttribute("prologData"); ! response.setContentType("image/svg+xml"); PrintWriter out = response.getWriter(); + SvgGenerator comeOn = new SvgGenerator(); + //FIXME Current Result can be null + out.println(comeOn.transform(bean.getCurrentResult())); } } |
From: <iva...@us...> - 2003-07-27 14:24:25
|
Update of /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/prolix/web/servlets In directory sc8-pr-cvs1:/tmp/cvs-serv5497/src/org/asturlinux/frade/prolix/web/servlets Added Files: TreeServlet.java Log Message: Added servlet dir and files to project --- NEW FILE: TreeServlet.java --- package org.asturlinux.frade.prolix.web.servlets; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import org.asturlinux.frade.prolix.web.beans.CurrentStateBean; public class TreeServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // locates session attribute HttpSession session = request.getSession(true); CurrentStateBean bean = (CurrentStateBean)session.getAttribute("prologData"); // FIXME response.setContentType("image/svg+xml"); PrintWriter out = response.getWriter(); // XML header out.println("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"); out.println("<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 20010904//EN\" \"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\">\n"); // SVG start out.println("<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" version=\"1\" x=\"0\" y=\"0\" width=\"744.094\" height=\"1052.36\" id=\"svg101\">\n"); out.println("<defs id=\"defs103\" /> <rect width=\"244.357\" height=\"107.517\" x=\"87.9684\" y=\"120.549\" style=\"font-size:12;fill:#808080;fill-rule:evenodd;stroke-width:1pt;\" id=\"rect104\" />"); out.println(bean.getCurrentResult()); // SVG stop out.println("</svg> "); } } |
From: <iva...@us...> - 2003-07-27 14:23:33
|
Update of /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/prolix/web/servlets In directory sc8-pr-cvs1:/tmp/cvs-serv5358/src/org/asturlinux/frade/prolix/web/servlets Log Message: Directory /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/prolix/web/servlets added to the repository |
From: <iva...@us...> - 2003-07-27 14:22:32
|
Update of /cvsroot/pfc-prolog/prolix/etc In directory sc8-pr-cvs1:/tmp/cvs-serv5217 Modified Files: servlet-mappings.xml servlets.xml Log Message: Registered servlet to draw tree Index: servlet-mappings.xml =================================================================== RCS file: /cvsroot/pfc-prolog/prolix/etc/servlet-mappings.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** servlet-mappings.xml 13 Jul 2003 16:30:37 -0000 1.1 --- servlet-mappings.xml 27 Jul 2003 14:22:30 -0000 1.2 *************** *** 5,6 **** --- 5,11 ---- <url-pattern>*.do</url-pattern> </servlet-mapping> + + <servlet-mapping> + <servlet-name>treeServlet</servlet-name> + <url-pattern>*.tree</url-pattern> + </servlet-mapping> Index: servlets.xml =================================================================== RCS file: /cvsroot/pfc-prolog/prolix/etc/servlets.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** servlets.xml 15 Jul 2003 15:04:38 -0000 1.2 --- servlets.xml 27 Jul 2003 14:22:30 -0000 1.3 *************** *** 27,28 **** --- 27,34 ---- <load-on-startup>2</load-on-startup> </servlet> + + <servlet> + <servlet-name>treeServlet</servlet-name> + <servlet-class>org.asturlinux.frade.prolix.web.servlets.TreeServlet</servlet-class> + + </servlet> \ No newline at end of file |
From: <iva...@us...> - 2003-07-27 14:20:02
|
Update of /cvsroot/pfc-prolog/prolix/web/css In directory sc8-pr-cvs1:/tmp/cvs-serv4740/css Added Files: prolix.css Log Message: Added css sheet --- NEW FILE: prolix.css --- /** * FIXME: GPL NOTE * */ body { background-color: #8ec984; color: black; } h1 { background-color: navy; color: red; } |
From: <iva...@us...> - 2003-07-27 14:19:05
|
Update of /cvsroot/pfc-prolog/prolix/web In directory sc8-pr-cvs1:/tmp/cvs-serv4576 Added Files: tree.jsp Log Message: added third page and css --- NEW FILE: tree.jsp --- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <!-- =========================================================== /** * * Copyright 2003 Ivan Frade * * This file is part of Prolix. * * Prolix is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Prolix 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Prolix; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * **/ ============================================================= --> <%@ page import="java.util.*,java.rmi.*,javax.naming.*,javax.rmi.*, java.io.*,javax.ejb.*, org.asturlinux.frade.prolix.ejb.interfaces.*, org.asturlinux.frade.prolix.interpreter.exceptions.*" %> <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %> <%@ taglib uri="http://java.sun.com/jstl/xml" prefix="x" %> <%@ taglib uri="ejbtags" prefix="ejb" %> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%> <jsp:useBean id="prologData" scope="session" class="org.asturlinux.frade.prolix.web.beans.CurrentStateBean" /> <!-- Obtain Home reference--> <ejb:useHome id="prolixHome" type="org.asturlinux.frade.prolix.ejb.interfaces.ProlixMainHome" location="org/asturlinux/frade/prolix/ejb/sessionjb/ProlixMain" /> <!-- Obtain Bean reference. If don't exist, create new one --> <ejb:useBean id="interpreter" type="org.asturlinux.frade.prolix.ejb.interfaces.ProlixMain" scope="session"> <ejb:createBean instance="<%= prolixHome.create() %>" /> </ejb:useBean> <html> <head> <title><bean:message key="title.resultGraphic"/></title> <link rel="stylesheet" href="/prolixjsp/css/prolix.css" type="text/css"/> </head> <body> <h1><bean:message key="title.resultGraphic"/></h1> <!-- FIXME Here the tree --> <jsp:getProperty name="prologData" property="currentResult" /> <img src="/prolixjsp/dibujo-sodipodi.xml" alt="Loading..."> <a href="/prolixjsp/view.tree">Ultimo recurso</a> <hr> <html:form action="/actions/resetProgram"> <html:submit><bean:message key="message.load.other.program"/></html:submit> </html:form> <a href="/prolixjsp/consult.jsp"> <bean:message key="message.load.other.consult"/> </a> <html:form action="/actions/solutions"> <html:hidden property="origin" value="tree" /> <html:submit><bean:message key="button.next.solution"/></html:submit> </html:form> <html:form action="/actions/step"> <html:submit><bean:message key="button.step"/></html:submit> </html:form> <a href="/prolixjsp/solutions.jsp"> <bean:message key="message.return.solutions.page"/> </a> </body> </html> |
From: <iva...@us...> - 2003-07-27 14:18:23
|
Update of /cvsroot/pfc-prolog/prolix/web/css In directory sc8-pr-cvs1:/tmp/cvs-serv4491/css Log Message: Directory /cvsroot/pfc-prolog/prolix/web/css added to the repository |
From: <iva...@us...> - 2003-07-27 14:17:55
|
Update of /cvsroot/pfc-prolog/prolix/web In directory sc8-pr-cvs1:/tmp/cvs-serv4348 Modified Files: consult.jsp program.jsp solutions.jsp Log Message: Updated jsp pages with css Index: consult.jsp =================================================================== RCS file: /cvsroot/pfc-prolog/prolix/web/consult.jsp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** consult.jsp 18 Jul 2003 16:32:11 -0000 1.18 --- consult.jsp 27 Jul 2003 14:17:53 -0000 1.19 *************** *** 57,61 **** <html> <head> ! <title>Program ready to consult</title> </head> --- 57,62 ---- <html> <head> ! <title><bean:message key="title.consult"/></title> ! <link rel="stylesheet" href="/prolixjsp/css/prolix.css" type="text/css"/> </head> *************** *** 64,68 **** <body bgcolor="#768FDD"> ! <h1>Prolix </h1> <table> --- 65,69 ---- <body bgcolor="#768FDD"> ! <h1><bean:message key="title.consult"/></h1> <table> *************** *** 79,83 **** <html:submit><bean:message key="button.load"/></html:submit> </html:form> ! <a href="/prolixjsp/program.jsp"><bean:message key="message.load.other.program"/></a> <html:errors/> </td> --- 80,87 ---- <html:submit><bean:message key="button.load"/></html:submit> </html:form> ! <a href="/prolixjsp/program.jsp"><bean:message key="message.edit.program"/></a><br/> ! <html:form action="/actions/resetProgram"> ! <html:submit><bean:message key="message.load.other.program"/></html:submit> ! </html:form> <html:errors/> </td> Index: program.jsp =================================================================== RCS file: /cvsroot/pfc-prolog/prolix/web/program.jsp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** program.jsp 17 Jul 2003 19:41:28 -0000 1.11 --- program.jsp 27 Jul 2003 14:17:53 -0000 1.12 *************** *** 29,33 **** org.asturlinux.frade.prolix.interpreter.exceptions.*" %> - <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %> <%@ taglib uri="http://java.sun.com/jstl/xml" prefix="x" %> --- 29,32 ---- *************** *** 54,67 **** <html> <head> ! <title>Prolix main</title> </head> ! <body bgcolor="#768FDD"> ! <h1>Prolix </h1> <hr align="left" size="1"> <html:form action="/actions/loadProgram"> <html:textarea property="program" rows="20" cols="60"> </html:textarea> <br> ! <html:submit><bean:message key="button.load"/></html:submit> ! <html:reset> <bean:message key="button.clear"/></html:reset> </html:form> <html:errors/> --- 53,68 ---- <html> <head> ! <title><bean:message key="title.main"/></title> ! <link rel="stylesheet" href="/prolixjsp/css/prolix.css" type="text/css"/> </head> ! <body> ! <h1><bean:message key="title.main"/></h1> <hr align="left" size="1"> <html:form action="/actions/loadProgram"> <html:textarea property="program" rows="20" cols="60"> + <!-- FIXME write program --> </html:textarea> <br> ! <html:submit><bean:message key="button.load"/></html:submit> ! <html:reset> <bean:message key="button.clear"/></html:reset> </html:form> <html:errors/> Index: solutions.jsp =================================================================== RCS file: /cvsroot/pfc-prolog/prolix/web/solutions.jsp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** solutions.jsp 17 Jul 2003 19:16:38 -0000 1.13 --- solutions.jsp 27 Jul 2003 14:17:53 -0000 1.14 *************** *** 60,67 **** <html> <head> ! <title>Prolix consultado</title> </head> <body bgcolor="#768FDD"> ! <h1>Prolix </h1> <hr align="left" size="10"> <%= programLoaded %> --- 60,68 ---- <html> <head> ! <title><bean:message key="title.resultText"/></title> ! <link rel="stylesheet" href="/prolixjsp/css/prolix.css" type="text/css"/> </head> <body bgcolor="#768FDD"> ! <h1><bean:message key="title.resultText"/></h1> <hr align="left" size="10"> <%= programLoaded %> *************** *** 86,89 **** --- 87,91 ---- <c:if test="${!prologData.noMoreSolutions}"> <html:form action="/actions/solutions"> + <html:hidden property="origin" value="solutions" /> <html:submit><bean:message key="button.next.solution"/></html:submit> </html:form> *************** *** 91,96 **** </c:if> ! <a href="/prolixjsp/program.jsp"><bean:message key="message.load.other.program"/></a> ! <a href="/prolixjsp/consult.jsp"><bean:message key="message.load.other.consult"/></a> </body> </html> --- 93,108 ---- </c:if> ! <html:form action="/actions/resetProgram"> ! <html:submit><bean:message key="message.load.other.program"/></html:submit> ! </html:form> ! ! <a href="/prolixjsp/consult.jsp"> ! <bean:message key="message.load.other.consult"/> ! </a> ! <br> ! <a href="/prolixjsp/tree.jsp"> ! <bean:message key="message.go.graphic.resolution"/> ! </a> ! </body> </html> |
From: <iva...@us...> - 2003-07-27 14:15:35
|
Update of /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/prolix/web/actions In directory sc8-pr-cvs1:/tmp/cvs-serv3987/prolix/web/actions Added Files: ResetProgramAction.java StepAction.java Log Message: Navigational classes to new page --- NEW FILE: ResetProgramAction.java --- /** * * Copyright 2003 Ivan Frade * * This file is part of Prolix. * * Prolix is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Prolix 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Prolix; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * **/ package org.asturlinux.frade.prolix.web.actions; import java.io.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; import java.security.*; import org.apache.struts.action.*; import org.apache.struts.util.*; import org.asturlinux.frade.prolix.web.beans.*; import org.asturlinux.frade.prolix.web.formbeans.*; /** * @struts.action name="resetProgramForm" * path="/actions/resetProgram" * scope="request" * input="/consult.jsp" * validate="false" * parameter="" * * @struts.action-forward name="success" * path="/program.jsp" */ public class ResetProgramAction extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // Auxiliar var HttpSession session = request.getSession(); Locale locale = getLocale(request); MessageResources messages = getResources(request); ActionErrors errors = new ActionErrors(); CurrentStateBean ib = (CurrentStateBean)session.getAttribute("prologData"); if (ib != null) ib.setCurrentProgram(""); LastConsultsBean lastConsults = (LastConsultsBean)session.getAttribute("oldConsults"); if (lastConsults != null) lastConsults.setLastConsults(new Vector()); return (mapping.findForward("success")); } } --- NEW FILE: StepAction.java --- /** * * Copyright 2003 Ivan Frade * * This file is part of Prolix. * * Prolix is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Prolix 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Prolix; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * **/ package org.asturlinux.frade.prolix.web.actions; import java.io.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; import java.security.*; import org.apache.struts.action.*; import org.apache.struts.util.*; import org.asturlinux.frade.prolix.web.beans.*; import org.asturlinux.frade.prolix.web.formbeans.*; import org.asturlinux.frade.prolix.ejb.interfaces.*; import org.asturlinux.frade.prolix.interpreter.exceptions.*; /** * @struts.action name="stepForm" * path="/actions/step" * scope="request" * input="/consult.jsp" * validate="true" * parameter="" * * @struts.action-forward name="success" * path="/tree.jsp" * * @struts.action-forward name="noProgram" * path="/program.jsp" * * @struts.action-forward name="noQuery" * path="/consult.jsp" * */ public class StepAction extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { ActionErrors errors = new ActionErrors(); Locale locale = getLocale(request); MessageResources messages = getResources(request); try { HttpSession session = request.getSession(); ProlixMain interpreter = (ProlixMain)session.getAttribute("interpreter"); String result = interpreter.step(); CurrentStateBean data = (CurrentStateBean)session.getAttribute("prologData"); if (data != null) { data.setCurrentResult(result); boolean test = interpreter.isLastSolution(); System.out.println("DEBUG: es la ultima solucion " + test); data.setNoMoreSolutions(test); // FIXME Aparent dont required code // session.setAttribute("prologData",data); } } catch (ProgramNotLoadedException pnle) { errors.add("solution",new ActionError("error.program.not.loaded")); return (mapping.findForward("noProgram")); } catch (QueryNotLoadedException qnle) { errors.add("solution",new ActionError("error.query.not.loaded")); return (mapping.findForward("noQuery")); } return (mapping.findForward("success")); } } |
From: <iva...@us...> - 2003-07-27 14:15:35
|
Update of /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/prolix/web/formbeans In directory sc8-pr-cvs1:/tmp/cvs-serv3987/prolix/web/formbeans Added Files: ResetProgramFormBean.java StepFormBean.java Log Message: Navigational classes to new page --- NEW FILE: ResetProgramFormBean.java --- /** * * Copyright 2003 Ivan Frade * * This file is part of Prolix. * * Prolix is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Prolix 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Prolix; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * **/ package org.asturlinux.frade.prolix.web.formbeans; import javax.servlet.http.HttpServletRequest; import org.apache.struts.action.*; /** * @struts:form name="resetProgramForm" */ public class ResetProgramFormBean extends ActionForm { /** * Redefined methods */ public void reset(ActionMapping mapping, HttpServletRequest request) { } public ActionErrors validate (ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); return errors; } } --- NEW FILE: StepFormBean.java --- /** * * Copyright 2003 Ivan Frade * * This file is part of Prolix. * * Prolix is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Prolix 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Prolix; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * **/ package org.asturlinux.frade.prolix.web.formbeans; import javax.servlet.http.HttpServletRequest; import org.apache.struts.action.*; /** * @struts:form name="stepForm" */ public class StepFormBean extends ActionForm { /** * Redefined methods */ public void reset(ActionMapping mapping, HttpServletRequest request) { } public ActionErrors validate (ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); return errors; } } |
From: <iva...@us...> - 2003-07-27 14:12:38
|
Update of /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/prolix/web/actions In directory sc8-pr-cvs1:/tmp/cvs-serv3587/prolix/web/actions Modified Files: SolutionAction.java Log Message: Added new page with visual resolution tree - Navigational classes Index: SolutionAction.java =================================================================== RCS file: /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/prolix/web/actions/SolutionAction.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** SolutionAction.java 17 Jul 2003 17:55:17 -0000 1.7 --- SolutionAction.java 27 Jul 2003 14:12:35 -0000 1.8 *************** *** 42,48 **** * parameter="" * ! * @struts.action-forward name="success" * path="/solutions.jsp" * * @struts.action-forward name="noProgram" * path="/program.jsp" --- 42,51 ---- * parameter="" * ! * @struts.action-forward name="successSolution" * path="/solutions.jsp" * + * @struts.action-forward name="successTree" + * path="/tree.jsp" + * * @struts.action-forward name="noProgram" * path="/program.jsp" *************** *** 65,73 **** Locale locale = getLocale(request); MessageResources messages = getResources(request); try { HttpSession session = request.getSession(); ProlixMain interpreter = (ProlixMain)session.getAttribute("interpreter"); ! String result = interpreter.step(); CurrentStateBean data = (CurrentStateBean)session.getAttribute("prologData"); if (data != null) --- 68,78 ---- Locale locale = getLocale(request); MessageResources messages = getResources(request); + String origin = ((SolutionsFormBean)form).getOrigin(); + try { HttpSession session = request.getSession(); ProlixMain interpreter = (ProlixMain)session.getAttribute("interpreter"); ! String result = interpreter.nextSolution(); CurrentStateBean data = (CurrentStateBean)session.getAttribute("prologData"); if (data != null) *************** *** 75,78 **** --- 80,85 ---- data.setCurrentResult(result); boolean test = interpreter.isLastSolution(); + System.out.println("DEBUG: es la ultima solucion " + + test); data.setNoMoreSolutions(test); // FIXME Aparent dont required code *************** *** 91,97 **** } ! return (mapping.findForward("success")); } - - } --- 98,105 ---- } ! if (origin.equals("tree")) ! return (mapping.findForward("successTree")); ! else ! return (mapping.findForward("successSolution")); } } |
From: <iva...@us...> - 2003-07-27 14:12:38
|
Update of /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/prolix/web/formbeans In directory sc8-pr-cvs1:/tmp/cvs-serv3587/prolix/web/formbeans Modified Files: SolutionsFormBean.java Log Message: Added new page with visual resolution tree - Navigational classes Index: SolutionsFormBean.java =================================================================== RCS file: /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/prolix/web/formbeans/SolutionsFormBean.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SolutionsFormBean.java 17 Jul 2003 17:55:17 -0000 1.3 --- SolutionsFormBean.java 27 Jul 2003 14:12:35 -0000 1.4 *************** *** 30,33 **** --- 30,53 ---- public class SolutionsFormBean extends ActionForm { + private String origin; + + + /** + * Gets the value of origin + * + * @return the value of origin + */ + public String getOrigin() { + return this.origin; + } + + /** + * Sets the value of origin + * + * @param argOrigin Value to assign to this.origin + */ + public void setOrigin(String argOrigin) { + this.origin = argOrigin; + } public void reset(ActionMapping mapping, HttpServletRequest request) *************** *** 36,40 **** public ActionErrors validate (ActionMapping mapping, ! HttpServletRequest request) { ActionErrors errors = null; --- 56,60 ---- public ActionErrors validate (ActionMapping mapping, ! HttpServletRequest request) { ActionErrors errors = null; |
From: <iva...@us...> - 2003-07-27 14:08:40
|
Update of /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/prolix/consoleclient In directory sc8-pr-cvs1:/tmp/cvs-serv2986/src/org/asturlinux/frade/prolix/consoleclient Modified Files: ConsoleClient.java Log Message: Updated console client with all new functionality Index: ConsoleClient.java =================================================================== RCS file: /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/prolix/consoleclient/ConsoleClient.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ConsoleClient.java 20 Jul 2003 19:02:31 -0000 1.9 --- ConsoleClient.java 27 Jul 2003 14:08:38 -0000 1.10 *************** *** 62,65 **** --- 62,66 ---- { System.out.println("ERROR: Naming Exception"); + ne.printStackTrace(); return; } |
From: <iva...@us...> - 2003-07-27 14:07:43
|
Update of /cvsroot/pfc-prolog/prolix/etc In directory sc8-pr-cvs1:/tmp/cvs-serv2811 Modified Files: WebClientResources.properties Log Message: Added new messages Index: WebClientResources.properties =================================================================== RCS file: /cvsroot/pfc-prolog/prolix/etc/WebClientResources.properties,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** WebClientResources.properties 18 Jul 2003 10:24:23 -0000 1.7 --- WebClientResources.properties 27 Jul 2003 14:07:40 -0000 1.8 *************** *** 12,15 **** --- 12,24 ---- button.clear=Limpiar button.next.solution=Siguiente solución + button.step=Avanzar un paso message.load.other.program=Cargar otro programa message.load.other.consult=Cargar otra consulta + message.edit.program=Modificar programa + message.return.solutions.page=Volver a la pagina de soluciones + message.go.graphic.resolution=Ir a resolucion gráfica + title.main=Prolix + title.consult=Prolix Consulta + title.resultText=Prolix Soluciones + title.resultGraphic=Prolix Arbol de resolucion + |
From: <iva...@us...> - 2003-07-27 14:06:12
|
Update of /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/prolix/web/actions In directory sc8-pr-cvs1:/tmp/cvs-serv2628/src/org/asturlinux/frade/prolix/web/actions Modified Files: LoadConsultAction.java Log Message: Reset result when load new consult Index: LoadConsultAction.java =================================================================== RCS file: /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/prolix/web/actions/LoadConsultAction.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** LoadConsultAction.java 18 Jul 2003 16:32:11 -0000 1.10 --- LoadConsultAction.java 27 Jul 2003 14:06:09 -0000 1.11 *************** *** 77,81 **** CurrentStateBean state = (CurrentStateBean)session.getAttribute("prologData"); if (state != null) ! state.setCurrentConsult(consult); // To remember last consults: --- 77,84 ---- CurrentStateBean state = (CurrentStateBean)session.getAttribute("prologData"); if (state != null) ! { ! state.setCurrentConsult(consult); ! state.setCurrentResult(null); ! } // To remember last consults: |
From: <iva...@us...> - 2003-07-27 14:03:08
|
Update of /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/prolix/ejb/sessionjb In directory sc8-pr-cvs1:/tmp/cvs-serv2127/src/org/asturlinux/frade/prolix/ejb/sessionjb Modified Files: TreeXmlVisitor.java Log Message: Now visitor generate xml including transitions Index: TreeXmlVisitor.java =================================================================== RCS file: /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/prolix/ejb/sessionjb/TreeXmlVisitor.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TreeXmlVisitor.java 21 Jul 2003 19:06:38 -0000 1.1 --- TreeXmlVisitor.java 27 Jul 2003 14:03:05 -0000 1.2 *************** *** 25,29 **** import org.asturlinux.frade.prolix.interpreter.interfaces.*; import java.io.Writer; ! public class TreeXmlVisitor extends TreeElementVisitor --- 25,31 ---- import org.asturlinux.frade.prolix.interpreter.interfaces.*; import java.io.Writer; ! import java.util.HashMap; ! import java.util.Collection; ! import java.util.Iterator; public class TreeXmlVisitor extends TreeElementVisitor *************** *** 32,35 **** --- 34,39 ---- private Writer _nodes; private Writer _transitions; + private HashMap _nodeKeyTable; + public TreeXmlVisitor(Writer nodes, Writer transitions) *************** *** 37,54 **** _nodes = nodes; _transitions = transitions; } ! public void visitTreeElement(TreeElement te) { _nodeCounter++; try { if (!te.isSolution()) { ! _nodes.write("<node number=\"" + _nodeCounter + "\" + label=\"" + te.getQuery() ! + "explored=\"" + te.isCompletlyExplored() + "\" /> \n"); } else { ! _nodes.write("<solution number=\"" + _nodeCounter + "\">\n"); --- 41,67 ---- _nodes = nodes; _transitions = transitions; + _nodeKeyTable = new HashMap(); } ! public void visitTreeElement(TreeElement te) { _nodeCounter++; + _nodeKeyTable.put(te,new Integer(_nodeCounter)); + writeNode(te); + } + + public void writeNode(TreeElement te) + { try { if (!te.isSolution()) { ! _nodes.write("\t<node number=\"" + _nodeCounter + "\" " ! + "label=\"" + te.getQuery() + "\" " ! + "explored=\"" ! + te.isCompletlyExplored() + "\" /> \n"); } else { ! _nodes.write("\t<solution number=\"" + _nodeCounter + "\">\n"); *************** *** 57,61 **** for (int i = 0; i < substArray.length;i++) { ! _nodes.write("<substitution " + "variable=\"" + substArray[i].getOriginalValue() --- 70,74 ---- for (int i = 0; i < substArray.length;i++) { ! _nodes.write("\t\t<substitution " + "variable=\"" + substArray[i].getOriginalValue() *************** *** 65,70 **** } ! _nodes.write("</solution>\n"); ! } } --- 78,91 ---- } ! _nodes.write("\t</solution>\n"); ! } ! if (te.getParent() != null) ! { ! // DEBUG ! TreeElement debug = te.getParent(); ! _transitions.write("\t<transition origin=\"" ! + _nodeKeyTable.get(debug) ! + "\" destiny=\"" + _nodeCounter ! + "\" />\n"); } } |
From: <iva...@us...> - 2003-07-27 13:59:54
|
Update of /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/prolix/ejb/sessionjb In directory sc8-pr-cvs1:/tmp/cvs-serv1546/src/org/asturlinux/frade/prolix/ejb/sessionjb Modified Files: ProlixMainBean.java Log Message: Added preorder traversal Index: ProlixMainBean.java =================================================================== RCS file: /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/prolix/ejb/sessionjb/ProlixMainBean.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** ProlixMainBean.java 21 Jul 2003 19:06:38 -0000 1.24 --- ProlixMainBean.java 27 Jul 2003 13:59:50 -0000 1.25 *************** *** 143,156 **** CheckSolutionVisitor visitor = new CheckSolutionVisitor(); ! TreeElement treeResult = prologCtx.step(); ! visitLastNode(treeResult,visitor); ! ! while (!visitor.getIsSolution()) { treeResult = prologCtx.step(); visitLastNode(treeResult,visitor); } ! ! return transformToSolutionXml(treeResult); } --- 143,156 ---- CheckSolutionVisitor visitor = new CheckSolutionVisitor(); ! TreeElement treeResult; ! do { treeResult = prologCtx.step(); visitLastNode(treeResult,visitor); } ! while (!visitor.getIsSolution() && !treeResult.isCompletlyExplored()); ! ! setLastSolution(treeResult.isCompletlyExplored()); ! return transformToTreeXml(treeResult); } *************** *** 183,186 **** --- 183,187 ---- private void setLastSolution(boolean newValue) { + System.out.println("DEBUG: setLastSolution " + newValue); lastSolution = newValue; } *************** *** 214,217 **** --- 215,222 ---- } + /** *************************************************** + * Transformation control + ** ***************************************************/ + private String transformToSolutionXml(TreeElement tree) *************** *** 234,238 **** // process recursively the tree ! visitInOrder(tree,visitor); // generate end tag --- 239,243 ---- // process recursively the tree ! visitPreOrder(tree,visitor); // generate end tag *************** *** 260,264 **** nodes.write("<tree completelyExplored=\"yes\">\n"); else ! nodes.write("<tree>\n"); --- 265,269 ---- nodes.write("<tree completelyExplored=\"yes\">\n"); else ! nodes.write("<tree completelyExplored=\"no\">\n"); *************** *** 267,271 **** // process recursively the tree ! visitInOrder(tree,visitor); // generate end tag --- 272,276 ---- // process recursively the tree ! visitPreOrder(tree,visitor); // generate end tag *************** *** 279,282 **** --- 284,293 ---- } + + + /** ************************************************ + * Paths + * ************************************************/ + /** *************** *** 288,293 **** // FIXME: Could be better not use recursivity TreeElement[] sons = tree.getNextLevelElements(); ! if (sons.length > 0) ! visitLastNode(sons[sons.length-1],visitor); else tree.accept(visitor); --- 299,311 ---- // FIXME: Could be better not use recursivity TreeElement[] sons = tree.getNextLevelElements(); ! ! // FIXME: dont must be required check if sons == null ! if ( sons != null ) ! { ! if ( sons.length > 0 ) ! visitLastNode(sons[sons.length-1],visitor); ! else ! tree.accept(visitor); ! } else tree.accept(visitor); *************** *** 299,303 **** * Apply visitor to all nodes in tree using inorder path */ ! private void visitInOrder(TreeElement tree, TreeElementVisitor visitor) { /** --- 317,321 ---- * Apply visitor to all nodes in tree using inorder path */ ! private void visitPostOrder(TreeElement tree, TreeElementVisitor visitor) { /** *************** *** 312,316 **** { for (int i = 0; i < sons.length; i++) ! visitInOrder(sons[i],visitor); } /** --- 330,334 ---- { for (int i = 0; i < sons.length; i++) ! visitPostOrder(sons[i],visitor); } /** *************** *** 322,325 **** --- 340,370 ---- } + public void visitPreOrder(TreeElement tree, TreeElementVisitor visitor) + { + /** + * recursive pattern + */ + + if (tree == null) + return; + + /** + * Node treatmet + */ + tree.accept(visitor); + + TreeElement[] sons = tree.getNextLevelElements(); + if (sons != null) //FIXME: Must not be required + { + for (int i = 0; i < sons.length; i++) + visitPreOrder(sons[i],visitor); + } + } + + /** ************************************** + * Activate - Pasivate Methods + * **************************************/ + + /** * No tag |
From: <iva...@us...> - 2003-07-27 13:40:18
|
Update of /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/dummy In directory sc8-pr-cvs1:/tmp/cvs-serv28131/src/org/asturlinux/frade/dummy Modified Files: PrologContextDummy.java Log Message: Updated dummy interpreter Index: PrologContextDummy.java =================================================================== RCS file: /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/dummy/PrologContextDummy.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PrologContextDummy.java 20 Jul 2003 19:01:03 -0000 1.2 --- PrologContextDummy.java 27 Jul 2003 13:40:15 -0000 1.3 *************** *** 30,34 **** { ! private int stepCounter = 1; private boolean loaded; --- 30,34 ---- { ! private int _stepCounter = 1; private boolean loaded; *************** *** 72,78 **** */ ! if (stepCounter == 1) { ! stepCounter++; return result; } --- 72,78 ---- */ ! if (_stepCounter == 1) { ! _stepCounter++; return result; } *************** *** 88,94 **** result.setNextLevelElements(resultSons); ! if (stepCounter == 2) { ! stepCounter++; return result; } --- 88,94 ---- result.setNextLevelElements(resultSons); ! if (_stepCounter == 2) { ! _stepCounter++; return result; } *************** *** 104,110 **** node1.setNextLevelElements(node1Sons); ! if (stepCounter == 3) { ! stepCounter++; return result; } --- 104,110 ---- node1.setNextLevelElements(node1Sons); ! if (_stepCounter == 3) { ! _stepCounter++; return result; } *************** *** 117,127 **** node3.setParent(node2); node3.setSolution(true); TreeElementDummy[] node2Sons = {node3}; node2.setNextLevelElements(node2Sons); ! if (stepCounter == 4) { ! stepCounter++; return result; } --- 117,128 ---- node3.setParent(node2); node3.setSolution(true); + node3.setCompletlyExplored(true); TreeElementDummy[] node2Sons = {node3}; node2.setNextLevelElements(node2Sons); ! if (_stepCounter == 4) { ! _stepCounter++; return result; } *************** *** 134,144 **** node4.setParent(node2); node4.setSolution(true); TreeElementDummy[] node2SonsNow = {node3,node4}; node2.setNextLevelElements(node2SonsNow); ! if (stepCounter == 5) { ! stepCounter++; return result; } --- 135,148 ---- node4.setParent(node2); node4.setSolution(true); + node4.setCompletlyExplored(true); TreeElementDummy[] node2SonsNow = {node3,node4}; node2.setNextLevelElements(node2SonsNow); + //FIXME now or next step? + node2.setCompletlyExplored(true); ! if (_stepCounter == 5) { ! _stepCounter++; return result; } *************** *** 154,160 **** node1.setNextLevelElements(node1SonsNow); ! if (stepCounter == 6) { ! stepCounter++; return result; } --- 158,164 ---- node1.setNextLevelElements(node1SonsNow); ! if (_stepCounter == 6) { ! _stepCounter++; return result; } *************** *** 167,177 **** node6.setParent(node5); node6.setSolution(true); TreeElementDummy[] node5Sons = {node6}; node5.setNextLevelElements(node5Sons); ! if (stepCounter == 7) { ! stepCounter++; return result; } --- 171,182 ---- node6.setParent(node5); node6.setSolution(true); + node6.setCompletlyExplored(true); TreeElementDummy[] node5Sons = {node6}; node5.setNextLevelElements(node5Sons); ! if (_stepCounter == 7) { ! _stepCounter++; return result; } *************** *** 185,195 **** node7.setParent(node5); node7.setSolution(true); TreeElementDummy[] node5SonsNow = {node6,node7}; node5.setNextLevelElements(node5SonsNow); ! ! if (stepCounter == 8) { ! stepCounter++; return result; } --- 190,202 ---- node7.setParent(node5); node7.setSolution(true); + node7.setCompletlyExplored(true); TreeElementDummy[] node5SonsNow = {node6,node7}; node5.setNextLevelElements(node5SonsNow); ! node5.setCompletlyExplored(true); ! ! if (_stepCounter == 8) { ! _stepCounter++; return result; } *************** *** 201,205 **** public void reset () { ! stepCounter = 1; } --- 208,212 ---- public void reset () { ! _stepCounter = 1; } |
From: <iva...@us...> - 2003-07-27 13:36:02
|
Update of /cvsroot/pfc-prolog/prolix In directory sc8-pr-cvs1:/tmp/cvs-serv27460 Modified Files: build.xml Log Message: Fixed build.xml: now main task only compiles Index: build.xml =================================================================== RCS file: /cvsroot/pfc-prolog/prolix/build.xml,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** build.xml 20 Jul 2003 15:18:27 -0000 1.42 --- build.xml 27 Jul 2003 13:35:58 -0000 1.43 *************** *** 453,457 **** webxml="${build.generate.web-conf}/WEB-INF/web.xml" basedir="${src.web.dir}" ! includes="**/*.jsp,**/*.tld,**/*.xslt" > <lib --- 453,457 ---- webxml="${build.generate.web-conf}/WEB-INF/web.xml" basedir="${src.web.dir}" ! includes="**/*.jsp,**/*.tld,**/*.xslt,css/prolix.css" > <lib *************** *** 516,521 **** ! <!-- FIXME Must copy interpreter and interpreter interfaces to ! to JBOSS_HOME/server/default/lib ? --> <target name="deploy-server" depends="jar"> <copy file="${dist.dir}/prolix-beans.jar" todir="${jboss.deploy}"/> --- 516,521 ---- ! <target name="deploy" depends="deploy-server,deploy-webclient"/> ! <target name="deploy-server" depends="jar"> <copy file="${dist.dir}/prolix-beans.jar" todir="${jboss.deploy}"/> *************** *** 541,548 **** <!-- =================================================================== --> ! <!-- Creates the client binary --> ! <!-- =================================================================== --> ! <target name="create-console-client" depends="jar"> <!-- Convert the given paths to Windows --> <pathconvert targetos="windows" property="jboss.home.on.windows" > --- 541,548 ---- <!-- =================================================================== --> ! <!-- Creates the client binary --> ! <!-- =================================================================== --> ! <target name="create-console-client"> <!-- Convert the given paths to Windows --> <pathconvert targetos="windows" property="jboss.home.on.windows" > *************** *** 587,592 **** <!-- =================================================================== --> ! <!-- FIXME: to a complete deploy, depends deploy-server too--> ! <target name="main" depends="deploy-webclient,create-console-client"> </target> --- 587,591 ---- <!-- =================================================================== --> ! <target name="main" depends="compile"> </target> |
From: <iva...@us...> - 2003-07-27 13:23:25
|
Update of /cvsroot/pfc-prolog/prolix/web/xsl In directory sc8-pr-cvs1:/tmp/cvs-serv25503/web/xsl Modified Files: solution.xslt Log Message: Updated xslt to number solutions Index: solution.xslt =================================================================== RCS file: /cvsroot/pfc-prolog/prolix/web/xsl/solution.xslt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** solution.xslt 19 Jul 2003 19:37:51 -0000 1.2 --- solution.xslt 27 Jul 2003 13:23:23 -0000 1.3 *************** *** 4,8 **** <xslt:template match="tree"> <xslt:apply-templates select="solution" /> ! <xslt:if test="@completelyExplored=yes"> <h2>No hay mas soluciones</h2> </xslt:if> --- 4,8 ---- <xslt:template match="tree"> <xslt:apply-templates select="solution" /> ! <xslt:if test="@completelyExplored='yes'"> <h2>No hay mas soluciones</h2> </xslt:if> *************** *** 10,14 **** <xslt:template match="solution"> ! <h2> Solucion <xslt:value-of select="@number"/> </h2> <xslt:if test="substitution" > <UL> --- 10,15 ---- <xslt:template match="solution"> ! <h2> Solucion <xslt:number level="single"/> </h2> ! <!-- <xslt:value-of select="@number"/> --> <xslt:if test="substitution" > <UL> |
From: <iva...@us...> - 2003-07-21 19:06:43
|
Update of /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/prolix/ejb/sessionjb In directory sc8-pr-cvs1:/tmp/cvs-serv14499/src/org/asturlinux/frade/prolix/ejb/sessionjb Modified Files: ProlixMainBean.java Added Files: TreeXmlVisitor.java Log Message: Added Visitor to generate complete XML. --- NEW FILE: TreeXmlVisitor.java --- /** * * Copyright 2003 Ivan Frade * * This file is part of Prolix. * * Prolix is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Prolix 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Prolix; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * **/ package org.asturlinux.frade.prolix.ejb.sessionjb; import org.asturlinux.frade.prolix.interpreter.interfaces.*; import java.io.Writer; public class TreeXmlVisitor extends TreeElementVisitor { private int _nodeCounter = 0; private Writer _nodes; private Writer _transitions; public TreeXmlVisitor(Writer nodes, Writer transitions) { _nodes = nodes; _transitions = transitions; } public void visitTreeElement(TreeElement te) { _nodeCounter++; try { if (!te.isSolution()) { _nodes.write("<node number=\"" + _nodeCounter + "\" + label=\"" + te.getQuery() + "explored=\"" + te.isCompletlyExplored() + "\" /> \n"); } else { _nodes.write("<solution number=\"" + _nodeCounter + "\">\n"); Substitution[] substArray = te.getSubstitutions(); for (int i = 0; i < substArray.length;i++) { _nodes.write("<substitution " + "variable=\"" + substArray[i].getOriginalValue() + "\" " + "value=\"" + substArray[i].getNewValue() + "\"" + "/>\n"); } _nodes.write("</solution>\n"); } } catch (java.io.IOException ex) { System.out.println ("Error: TreeXmlVisitor. Problems with StringWriters"); } } } Index: ProlixMainBean.java =================================================================== RCS file: /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/prolix/ejb/sessionjb/ProlixMainBean.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** ProlixMainBean.java 20 Jul 2003 17:55:01 -0000 1.23 --- ProlixMainBean.java 21 Jul 2003 19:06:38 -0000 1.24 *************** *** 152,156 **** } ! return transformToXml(treeResult); } --- 152,156 ---- } ! return transformToSolutionXml(treeResult); } *************** *** 170,174 **** // FIXME: cache results ! return transformToXml(treeResult); } --- 170,174 ---- // FIXME: cache results ! return transformToTreeXml(treeResult); } *************** *** 215,234 **** ! private String transformToXml(TreeElement tree) { Writer writer = new StringWriter(); try { // FIXME: generate appropiate xml headers (<?xml> and doctype) ! // generate opening tag if ( tree.isCompletlyExplored() ) ! writer.write("<tree completelyExplored=\"yes\">\n"); else ! writer.write("<tree>\n"); ! SimpleXmlVisitor visitor = ! new SimpleXmlVisitor(writer); // process recursively the tree --- 215,268 ---- ! private String transformToSolutionXml(TreeElement tree) { Writer writer = new StringWriter(); + try + { + + // FIXME: generate appropiate xml headers (<?xml> and doctype) + + // generate opening tag + if ( tree.isCompletlyExplored() ) + writer.write("<tree completelyExplored=\"yes\">\n"); + else + writer.write("<tree>\n"); + + SimpleXmlVisitor visitor = + new SimpleXmlVisitor(writer); + + // process recursively the tree + visitInOrder(tree,visitor); + + // generate end tag + writer.write("</tree>\n"); + + } + catch(java.io.IOException ex) + { + ex.printStackTrace(); + } + + return writer.toString(); + } + + private String transformToTreeXml(TreeElement tree) + { + Writer nodes = new StringWriter(); + Writer transitions = new StringWriter(); try { // FIXME: generate appropiate xml headers (<?xml> and doctype) ! // generate opening tag if ( tree.isCompletlyExplored() ) ! nodes.write("<tree completelyExplored=\"yes\">\n"); else ! nodes.write("<tree>\n"); ! ! TreeXmlVisitor visitor = ! new TreeXmlVisitor(nodes,transitions); // process recursively the tree *************** *** 236,247 **** // generate end tag ! writer.write("</tree>\n"); ! } catch(java.io.IOException ex) { ! ex.printStackTrace(); } - return writer.toString(); } --- 270,281 ---- // generate end tag ! transitions.write("</tree>\n"); ! nodes.write(transitions.toString()); } catch(java.io.IOException ex) { ! System.out.println("ERROR: ProlixMainBean - Something wrong with StringWriters"); } + return nodes.toString(); } |
From: <iva...@us...> - 2003-07-20 19:02:34
|
Update of /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/prolix/consoleclient In directory sc8-pr-cvs1:/tmp/cvs-serv18511/src/org/asturlinux/frade/prolix/consoleclient Modified Files: ConsoleClient.java Log Message: Added option in console client to execute an step or advance to next solution Index: ConsoleClient.java =================================================================== RCS file: /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/prolix/consoleclient/ConsoleClient.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ConsoleClient.java 14 Jul 2003 21:49:39 -0000 1.8 --- ConsoleClient.java 20 Jul 2003 19:02:31 -0000 1.9 *************** *** 1,2 **** --- 1,3 ---- + /** * *************** *** 41,47 **** private ProlixMain interpreter; - private String hardCodedProgram = "hermano(X,Y):=padre(X,Z),padre(Y,Z).padre(Felipe,JC).padre(Helena,JC)"; - private String hardCodedConsult = "hermano(X,Y)"; - public static void main(String args[]) { ConsoleClient console = new ConsoleClient(); --- 42,45 ---- *************** *** 57,63 **** // Obtain reference to home InitialContext ctx = new InitialContext(); - //Object o = ctx.lookup( "org/asturlinux/frade/prolix/ejb/sessionjb/ProlixMain" ); - //ProlixMainHome home = null; - // home = (ProlixMainHome)PortableRemoteObject.narrow(o, ProlixMainHome.class); ProlixMainHome home = (ProlixMainHome)ctx.lookup(ProlixMainHome.JNDI_NAME); // Create the interpreter bean --- 55,58 ---- *************** *** 85,88 **** --- 80,84 ---- "Get loaded consult", "Step", + "NextSolution", "Exit"}; *************** *** 103,109 **** case 4: getLoadedConsult(); break; ! case 5: gostep(); break; ! case 6: otherIteration = false; break; } --- 99,107 ---- case 4: getLoadedConsult(); break; ! case 5: goStep(); break; ! case 6: goNextSolution(); ! break; ! case 7: otherIteration = false; break; } *************** *** 131,135 **** { String input = new String(in.readLine()); ! interpreter.loadProgram(hardCodedProgram); } catch (LexicalException le) --- 129,133 ---- { String input = new String(in.readLine()); ! interpreter.loadProgram(input); } catch (LexicalException le) *************** *** 170,174 **** { String input = new String(in.readLine()); ! interpreter.loadConsult(hardCodedConsult); } catch (LexicalException le) --- 168,172 ---- { String input = new String(in.readLine()); ! interpreter.loadConsult(input); } catch (LexicalException le) *************** *** 206,210 **** } ! private void gostep() { try --- 204,208 ---- } ! private void goStep() { try *************** *** 226,229 **** --- 224,247 ---- } + private void goNextSolution() + { + try + { + System.out.println(interpreter.nextSolution()); + } + catch (ProgramNotLoadedException programNotLoaded) + { + System.out.println("Unable to execute a step if you don't load a program"); + } + catch (QueryNotLoadedException queryNotLoaded) + { + System.out.println("Unable to execute a step if you don't load a query"); + } + catch (RemoteException remote) + { + System.out.println("Remote exception doing an step"); + } + + } } |
From: <iva...@us...> - 2003-07-20 19:01:07
|
Update of /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/dummy In directory sc8-pr-cvs1:/tmp/cvs-serv18337/src/org/asturlinux/frade/dummy Modified Files: PrologContextDummy.java Log Message: Updated Dummy Interpreter - An step advance only one node - New consult or program reset dummy Index: PrologContextDummy.java =================================================================== RCS file: /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/dummy/PrologContextDummy.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PrologContextDummy.java 13 Jul 2003 20:46:25 -0000 1.1 --- PrologContextDummy.java 20 Jul 2003 19:01:03 -0000 1.2 *************** *** 40,43 **** --- 40,44 ---- System.out.println("loaded True"); loaded = true; + reset(); } *************** *** 47,50 **** --- 48,52 ---- System.out.println("asked True"); asked = true; + reset(); } *************** *** 70,73 **** --- 72,81 ---- */ + if (stepCounter == 1) + { + stepCounter++; + return result; + } + TreeElementDummy node1 = new TreeElementDummy("padre(Z,A),padre(Z,B)"); Substitution[] node1s = new Substitution[2]; *************** *** 77,80 **** --- 85,97 ---- node1.setParent(result); + TreeElementDummy[] resultSons = {node1}; + result.setNextLevelElements(resultSons); + + if (stepCounter == 2) + { + stepCounter++; + return result; + } + TreeElementDummy node2 = new TreeElementDummy("padre(JC,B)"); Substitution[] node2s = new Substitution[2]; *************** *** 84,87 **** --- 101,113 ---- node2.setParent(node1); + TreeElementDummy[] node1Sons = {node2}; + node1.setNextLevelElements(node1Sons); + + if (stepCounter == 3) + { + stepCounter++; + return result; + } + TreeElementDummy node3 = new TreeElementDummy(""); Substitution[] node3s = new Substitution[2]; *************** *** 95,111 **** node2.setNextLevelElements(node2Sons); ! TreeElementDummy[] node1Sons = {node2}; ! node1.setNextLevelElements(node1Sons); ! ! TreeElementDummy[] resultSons = {node1}; ! result.setNextLevelElements(resultSons); ! ! ! /** ! * Now have the first solution. ! * Depends the step, added more or less nodes to this structure ! */ ! ! if (stepCounter == 1) { stepCounter++; --- 121,125 ---- node2.setNextLevelElements(node2Sons); ! if (stepCounter == 4) { stepCounter++; *************** *** 124,128 **** node2.setNextLevelElements(node2SonsNow); ! if (stepCounter == 2) { stepCounter++; --- 138,142 ---- node2.setNextLevelElements(node2SonsNow); ! if (stepCounter == 5) { stepCounter++; *************** *** 137,140 **** --- 151,163 ---- node5.setParent(node1); + TreeElementDummy[] node1SonsNow = {node2,node5}; + node1.setNextLevelElements(node1SonsNow); + + if (stepCounter == 6) + { + stepCounter++; + return result; + } + TreeElementDummy node6 = new TreeElementDummy(""); Substitution[] node6s = new Substitution[2]; *************** *** 147,156 **** TreeElementDummy[] node5Sons = {node6}; node5.setNextLevelElements(node5Sons); - - TreeElementDummy[] node1SonsNow = {node2,node5}; - node1.setNextLevelElements(node1SonsNow); ! ! if (stepCounter == 3) { stepCounter++; --- 170,175 ---- TreeElementDummy[] node5Sons = {node6}; node5.setNextLevelElements(node5Sons); ! if (stepCounter == 7) { stepCounter++; *************** *** 170,174 **** node5.setNextLevelElements(node5SonsNow); ! if (stepCounter == 4) { stepCounter++; --- 189,193 ---- node5.setNextLevelElements(node5SonsNow); ! if (stepCounter == 8) { stepCounter++; *************** *** 178,181 **** --- 197,205 ---- result.setCompletlyExplored(true); return result; + } + + public void reset () + { + stepCounter = 1; } |
From: <iva...@us...> - 2003-07-20 17:55:07
|
Update of /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/prolix/ejb/sessionjb In directory sc8-pr-cvs1:/tmp/cvs-serv8802/src/org/asturlinux/frade/prolix/ejb/sessionjb Modified Files: ProlixMainBean.java Added Files: CheckSolutionVisitor.java Log Message: refactored step method - Added new visitor class - added method visitLastNode --- NEW FILE: CheckSolutionVisitor.java --- package org.asturlinux.frade.prolix.ejb.sessionjb; import org.asturlinux.frade.prolix.interpreter.interfaces.*; public class CheckSolutionVisitor extends TreeElementVisitor { private boolean _isSolution; public void visitTreeElement(TreeElement te) { _isSolution = te.isSolution(); } public boolean getIsSolution() { return _isSolution; } } Index: ProlixMainBean.java =================================================================== RCS file: /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/prolix/ejb/sessionjb/ProlixMainBean.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** ProlixMainBean.java 20 Jul 2003 15:18:27 -0000 1.22 --- ProlixMainBean.java 20 Jul 2003 17:55:01 -0000 1.23 *************** *** 134,137 **** --- 134,159 ---- } + + /** + * @ejb:interface-method + */ + public String nextSolution() + throws ProgramNotLoadedException, QueryNotLoadedException + { + CheckSolutionVisitor visitor = new CheckSolutionVisitor(); + + TreeElement treeResult = prologCtx.step(); + visitLastNode(treeResult,visitor); + + while (!visitor.getIsSolution()) + { + treeResult = prologCtx.step(); + visitLastNode(treeResult,visitor); + } + + return transformToXml(treeResult); + } + + /** * @ejb:interface-method *************** *** 211,215 **** // process recursively the tree ! recursiveInOrder(tree,visitor); // generate end tag --- 233,237 ---- // process recursively the tree ! visitInOrder(tree,visitor); // generate end tag *************** *** 224,228 **** } ! private void recursiveInOrder(TreeElement tree, SimpleXmlVisitor visitor) { /** --- 246,269 ---- } ! /** ! * Apply visitor to last node in tree ! */ ! private void visitLastNode(TreeElement tree, TreeElementVisitor visitor) ! { ! ! // FIXME: Could be better not use recursivity ! TreeElement[] sons = tree.getNextLevelElements(); ! if (sons.length > 0) ! visitLastNode(sons[sons.length-1],visitor); ! else ! tree.accept(visitor); ! ! return; ! } ! ! /** ! * Apply visitor to all nodes in tree using inorder path ! */ ! private void visitInOrder(TreeElement tree, TreeElementVisitor visitor) { /** *************** *** 237,241 **** { for (int i = 0; i < sons.length; i++) ! recursiveInOrder(sons[i],visitor); } /** --- 278,282 ---- { for (int i = 0; i < sons.length; i++) ! visitInOrder(sons[i],visitor); } /** |
From: <iva...@us...> - 2003-07-20 15:18:29
|
Update of /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/prolix/ejb/sessionjb In directory sc8-pr-cvs1:/tmp/cvs-serv13367/src/org/asturlinux/frade/prolix/ejb/sessionjb Modified Files: ProlixMainBean.java Log Message: Fixed bug when generated war Index: ProlixMainBean.java =================================================================== RCS file: /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/prolix/ejb/sessionjb/ProlixMainBean.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** ProlixMainBean.java 19 Jul 2003 19:37:51 -0000 1.21 --- ProlixMainBean.java 20 Jul 2003 15:18:27 -0000 1.22 *************** *** 234,240 **** TreeElement[] sons = tree.getNextLevelElements(); ! for (int i = 0; i < sons.length; i++) ! recursiveInOrder(sons[i],visitor); ! /** * node "treatment" using visitor pattern. --- 234,242 ---- TreeElement[] sons = tree.getNextLevelElements(); ! if (sons != null) //FIXME: Must not be required ! { ! for (int i = 0; i < sons.length; i++) ! recursiveInOrder(sons[i],visitor); ! } /** * node "treatment" using visitor pattern. |