Author: bobtarling Date: 2010-07-19 17:11:25-0700 New Revision: 18537 Modified: trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigAction.java trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/UMLActivityDiagram.java
Log: FigAction can now draw AcceptEventAction and SendSignalAction Modified: trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigAction.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigAction.java?view=diff&pathrev=18537&r1=18536&r2=18537 ============================================================================== --- trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigAction.java (original) +++ trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigAction.java 2010-07-19 17:11:25-0700 @@ -1,4 +1,4 @@ -/* $Id: FigAction.java bobtarling $ +/* $Id: $ ***************************************************************************** * Copyright (c) 2010 Contributors - see below * All rights reserved. This program and the accompanying materials @@ -14,10 +14,14 @@ package org.argouml.activity2.diagram; import java.awt.Dimension; +import java.awt.Polygon; import java.awt.Rectangle; + +import org.argouml.model.Model; import org.argouml.uml.diagram.DiagramSettings; import org.argouml.uml.diagram.ui.FigNodeModelElement; import org.tigris.gef.presentation.Fig; +import org.tigris.gef.presentation.FigPoly; import org.tigris.gef.presentation.FigRRect; public class FigAction extends FigNodeModelElement { @@ -41,18 +45,52 @@ @Override protected Fig createBigPortFig() { - return new FigRRect(X0, Y0, WIDTH, HEIGHT, LINE_COLOR, FILL_COLOR); + if (Model.getFacade().isASendSignalAction(getOwner())) { + final int[] xs = new int[6]; + final int[] ys = new int[6]; + + xs[0] = X0; ys[0] = Y0; + xs[1] = X0 + WIDTH - HEIGHT / 2; ys[1] = Y0; + xs[2] = X0 + WIDTH; ys[2] = Y0 + HEIGHT / 2; + xs[3] = X0 + WIDTH - HEIGHT / 2; ys[3] = Y0 + HEIGHT; + xs[4] = X0; ys[4] = Y0 + HEIGHT; + xs[5] = X0; ys[5] = Y0; + final FigPoly polyFig = new FigPoly(); + polyFig.setXs(xs); + polyFig.setYs(ys); + final Polygon p = new Polygon(xs, ys, 6); + polyFig.setPolygon(p); + return polyFig; + } else if (Model.getFacade().isAAcceptEventAction(getOwner())) { + final int[] xs = new int[6]; + final int[] ys = new int[6]; + + xs[0] = X0; ys[0] = Y0; + xs[1] = X0 + WIDTH; ys[1] = Y0; + xs[2] = X0 + WIDTH; ys[2] = Y0 + HEIGHT; + xs[3] = X0; ys[3] = Y0 + HEIGHT; + xs[4] = X0 + HEIGHT / 2; ys[4] = Y0 + HEIGHT / 2; + xs[5] = X0; ys[5] = Y0; + final FigPoly polyFig = new FigPoly(); + polyFig.setXs(xs); + polyFig.setYs(ys); + final Polygon p = new Polygon(xs, ys, 6); + polyFig.setPolygon(p); + return polyFig; + } else { + return new FigRRect(X0, Y0, WIDTH, HEIGHT, LINE_COLOR, FILL_COLOR); + } } @Override public Dimension getMinimumSize() { - Dimension stereoDim = getStereotypeFig().getMinimumSize(); - Dimension nameDim = getNameFig().getMinimumSize(); + final Dimension stereoDim = getStereotypeFig().getMinimumSize(); + final Dimension nameDim = getNameFig().getMinimumSize(); int w = Math.max(stereoDim.width, nameDim.width) + PADDING * 2; /* The stereoDim has height=2, even if it is empty, * hence the -2 below: */ - int h = stereoDim.height - 2 + nameDim.height + PADDING; + final int h = stereoDim.height - 2 + nameDim.height + PADDING; w = Math.max(w, h + 44); // the width needs to be > the height return new Dimension(w, h); } @@ -62,16 +100,44 @@ if (getNameFig() == null) { return; } - Rectangle oldBounds = getBounds(); + final Rectangle oldBounds = getBounds(); - Dimension stereoDim = getStereotypeFig().getMinimumSize(); - Dimension nameDim = getNameFig().getMinimumSize(); + final Dimension stereoDim = getStereotypeFig().getMinimumSize(); + final Dimension nameDim = getNameFig().getMinimumSize(); getNameFig().setBounds(x + PADDING, y + stereoDim.height, w - PADDING * 2, nameDim.height); getStereotypeFig().setBounds(x + PADDING, y, w - PADDING * 2, stereoDim.height); - getBigPort().setBounds(x, y, w, h); - ((FigRRect) getBigPort()).setCornerRadius(h); + final Fig bigPort = getBigPort(); + if (Model.getFacade().isASendSignalAction(getOwner())) { + final int[] xs = new int[6]; + final int[] ys = new int[6]; + xs[0] = x; ys[0] = y; + xs[1] = x + WIDTH - HEIGHT / 2; ys[1] = y; + xs[2] = x + WIDTH; ys[2] = y + HEIGHT / 2; + xs[3] = x + WIDTH - HEIGHT / 2; ys[3] = y + HEIGHT; + xs[4] = x; ys[4] = y + HEIGHT; + xs[5] = x; ys[5] = y; + final FigPoly polyFig = (FigPoly)bigPort; + final Polygon p = new Polygon(xs, ys, 6); + polyFig.setPolygon(p); + } else if (Model.getFacade().isAAcceptEventAction(getOwner())) { + final int[] xs = new int[6]; + final int[] ys = new int[6]; + + xs[0] = x; ys[0] = y; + xs[1] = x + WIDTH; ys[1] = y; + xs[2] = x + WIDTH; ys[2] = y + HEIGHT; + xs[3] = x; ys[3] = y + HEIGHT; + xs[4] = x + HEIGHT / 2; ys[4] = y + HEIGHT / 2; + xs[5] = x; ys[5] = y; + final FigPoly polyFig = (FigPoly)bigPort; + final Polygon p = new Polygon(xs, ys, 6); + polyFig.setPolygon(p); + } else { + getBigPort().setBounds(x, y, w, h); + ((FigRRect) getBigPort()).setCornerRadius(h); + } calcBounds(); updateEdges(); Modified: trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/UMLActivityDiagram.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/UMLActivityDiagram.java?view=diff&pathrev=18537&r1=18536&r2=18537 ============================================================================== --- trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/UMLActivityDiagram.java (original) +++ trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/UMLActivityDiagram.java 2010-07-19 17:11:25-0700 @@ -87,6 +87,9 @@ getCreateNodeAction(Model.getMetaTypes().getCallBehaviorAction(), "button.new-callbehavioraction"), getCreateNodeAction(Model.getMetaTypes().getCreateObjectAction(), "button.new-createobjectaction"), getCreateNodeAction(Model.getMetaTypes().getDestroyObjectAction(), "button.new-destroyobjectaction"), + getCreateNodeAction(Model.getMetaTypes().getAcceptEventAction(), "button.new-accepteventaction"), + getCreateNodeAction(Model.getMetaTypes().getSendSignalAction(), "button.new-sendsignalaction"), + getCreateNodeAction(Model.getMetaTypes().getDestroyObjectAction(), "button.new-destroyobjectaction"), }; return actions; } ------------------------------------------------------ http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2635435 To unsubscribe from this discussion, e-mail: [[email protected]].
