Author: mvw Date: 2008-01-19 05:56:09-0800 New Revision: 14058 Modified: trunk/src_new/org/argouml/persistence/PGMLStackParser.java trunk/src_new/org/argouml/uml/diagram/ui/ArgoModeCreateFigText.java
Log: Fix for issue 4951: Now the size and justification of the text area reload correctly. This also fixes a problem with the history of the TargetManager: by using ArgoFigText i.s.o. FigText, it can listen to a notification when the Fig is removed. Modified: trunk/src_new/org/argouml/persistence/PGMLStackParser.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/persistence/PGMLStackParser.java?view=diff&rev=14058&p1=trunk/src_new/org/argouml/persistence/PGMLStackParser.java&p2=trunk/src_new/org/argouml/persistence/PGMLStackParser.java&r1=14057&r2=14058 ============================================================================== --- trunk/src_new/org/argouml/persistence/PGMLStackParser.java (original) +++ trunk/src_new/org/argouml/persistence/PGMLStackParser.java 2008-01-19 05:56:09-0800 @@ -1,5 +1,5 @@ // $Id$ -// Copyright (c) 2005-2007 The Regents of the University of California. All +// Copyright (c) 2005-2008 The Regents of the University of California. All // Rights Reserved. Permission to use, copy, modify, and distribute this // software and its documentation without fee, and without a written // agreement is hereby granted, provided that the above copyright notice @@ -35,6 +35,10 @@ import java.util.StringTokenizer; import org.apache.log4j.Logger; +import org.argouml.gefext.ArgoFigCircle; +import org.argouml.gefext.ArgoFigPoly; +import org.argouml.gefext.ArgoFigRRect; +import org.argouml.gefext.ArgoFigRect; import org.argouml.uml.diagram.AttributesCompartmentContainer; import org.argouml.uml.diagram.ExtensionsCompartmentContainer; import org.argouml.uml.diagram.OperationsCompartmentContainer; @@ -44,23 +48,34 @@ import org.argouml.uml.diagram.activity.ui.FigPool; import org.argouml.uml.diagram.deployment.ui.FigMNodeInstance; import org.argouml.uml.diagram.deployment.ui.FigNodeInstance; +import org.argouml.uml.diagram.ui.ArgoFigText; import org.argouml.uml.diagram.ui.FigEdgeModelElement; import org.argouml.uml.diagram.ui.FigEdgePort; import org.tigris.gef.base.Diagram; import org.tigris.gef.persistence.pgml.Container; import org.tigris.gef.persistence.pgml.FigEdgeHandler; import org.tigris.gef.persistence.pgml.FigGroupHandler; +import org.tigris.gef.persistence.pgml.FigLineHandler; +import org.tigris.gef.persistence.pgml.FigPolyHandler; +import org.tigris.gef.persistence.pgml.FigTextHandler; import org.tigris.gef.persistence.pgml.HandlerStack; import org.tigris.gef.presentation.Fig; +import org.tigris.gef.presentation.FigCircle; import org.tigris.gef.presentation.FigEdge; import org.tigris.gef.presentation.FigGroup; +import org.tigris.gef.presentation.FigLine; import org.tigris.gef.presentation.FigNode; +import org.tigris.gef.presentation.FigPoly; +import org.tigris.gef.presentation.FigRRect; +import org.tigris.gef.presentation.FigText; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; /** - * The PGML Parser. + * The PGML Parser. <p> + * + * This replaces much of the identically named class from GEF. */ class PGMLStackParser extends org.tigris.gef.persistence.pgml.PGMLStackParser { @@ -112,6 +127,7 @@ throws SAXException { String href = attributes.getValue("href"); + Object elementInstance = null; Object owner = null; if (href != null) { @@ -136,6 +152,104 @@ if (qname.equals("private") && (container instanceof Container)) { return new PrivateHandler(this, (Container) container); } + + if (qname.equals("text")) { + if (elementInstance == null) { + elementInstance = new ArgoFigText(0, 0, 100, 100, true); + } + if (elementInstance instanceof FigText) { + FigText text = (FigText) elementInstance; + setAttrs(text, attributes); + if (container instanceof Container) { + ((Container) container).addObject(text); + } + String font = attributes.getValue("font"); + if (font != null && !font.equals("")) { + text.setFontFamily(font); + } + + String textsize = attributes.getValue("textsize"); + if (textsize != null && !textsize.equals("")) { + int textsizeInt = Integer.parseInt(textsize); + text.setFontSize(textsizeInt); + } + + String justification = attributes.getValue("justification"); + if (justification != null && !justification.equals("")) { + text.setJustificationByName(justification); + } + + return new FigTextHandler(this, text); + } + } + + if (qname.equals("path") || qname.equals("line")) { + if (elementInstance == null) { + elementInstance = new ArgoFigPoly(); + } + if (elementInstance instanceof FigLine) { + setAttrs((Fig) elementInstance, attributes); + if (container instanceof Container) { + ((Container) container).addObject(elementInstance); + } + return new FigLineHandler(this, (FigLine) elementInstance); + } + if (elementInstance instanceof FigPoly) { + setAttrs((Fig) elementInstance, attributes); + if (container instanceof Container) { + ((Container) container).addObject(elementInstance); + } + return new FigPolyHandler(this, (FigPoly) elementInstance); + } + } + + if (qname.equals("rectangle")) { + String cornerRadius = attributes.getValue("rounding"); + int rInt = -1; + if (cornerRadius != null && cornerRadius.length() > 0) { + rInt = Integer.parseInt(cornerRadius); + } + if (elementInstance == null) { + if (rInt >= 0) { + elementInstance = new ArgoFigRRect(0, 0, 80, 80); + } else { + elementInstance = new ArgoFigRect(0, 0, 80, 80); + } + } + if (elementInstance instanceof FigRRect && rInt >= 0) { + ((FigRRect) elementInstance).setCornerRadius(rInt); + } + if (elementInstance instanceof Fig) { + setAttrs((Fig) elementInstance, attributes); + if (container instanceof Container) { + ((Container) container).addObject(elementInstance); + } + return null; + } + } + + if (qname.equals("ellipse")) { + if (elementInstance == null) { + elementInstance = new ArgoFigCircle(0, 0, 50, 50); + } + if (elementInstance instanceof FigCircle) { + FigCircle f = (FigCircle) elementInstance; + setAttrs(f, attributes); + String rx = attributes.getValue("rx"); + String ry = attributes.getValue("ry"); + int rxInt = + (rx == null || rx.equals("")) ? 10 : Integer.parseInt(rx); + int ryInt = + (ry == null || ry.equals("")) ? 10 : Integer.parseInt(ry); + f.setBounds(f.getX() - rxInt, + f.getY() - ryInt, rxInt * 2, ryInt * 2); + if (container instanceof Container) { + ((Container) container).addObject(elementInstance); + } + + return null; + } + } DefaultHandler handler = super.getHandler(stack, container, uri, localname, qname, Modified: trunk/src_new/org/argouml/uml/diagram/ui/ArgoModeCreateFigText.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/ui/ArgoModeCreateFigText.java?view=diff&rev=14058&p1=trunk/src_new/org/argouml/uml/diagram/ui/ArgoModeCreateFigText.java&p2=trunk/src_new/org/argouml/uml/diagram/ui/ArgoModeCreateFigText.java&r1=14057&r2=14058 ============================================================================== --- trunk/src_new/org/argouml/uml/diagram/ui/ArgoModeCreateFigText.java (original) +++ trunk/src_new/org/argouml/uml/diagram/ui/ArgoModeCreateFigText.java 2008-01-19 05:56:09-0800 @@ -49,6 +49,6 @@ * event and the state of the parent Editor. */ public Fig createNewItem(MouseEvent e, int snapX, int snapY) { - return new ArgoFigText(snapX, snapY, 0, 0); + return new ArgoFigText(snapX, snapY, 0, 0, true); } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
