Skip to content

Commit

Permalink
Full support for ->includes/excludes Key/Value
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinlano authored Feb 18, 2025
1 parent a7cea57 commit fb7101e
Show file tree
Hide file tree
Showing 30 changed files with 640 additions and 70 deletions.
Binary file modified ATLFileFilter.class
Binary file not shown.
Binary file added Actor.class
Binary file not shown.
35 changes: 35 additions & 0 deletions Actor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import java.util.Vector;
import java.io.PrintWriter;

/******************************
* Copyright (c) 2003-2025 Kevin Lano
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
* *****************************/

public class Actor extends ModelElement
{ Vector dependenciesTo = new Vector(); // of Dependency to UseCase
Vector dependenciesFrom = new Vector(); // of Dependency from UseCase

public Actor(String nme)
{ super(nme); }

public void generateJava(PrintWriter out) { }

public void setType(Type t) { }

public Type getType()
{ return null; }

public void addParameter(Attribute att) { }

public Vector getParameters()
{ return new Vector(); }

public String saveData()
{ return ""; }

}
Binary file added ActorRectData.class
Binary file not shown.
154 changes: 154 additions & 0 deletions ActorRectData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
/*
* Classname : ActorRectData
*
* Version information : 1
*
* Date
*
* Description : Contains methods for
* drawing actors in use case diagrams
package: GUI
*/

/******************************
* Copyright (c) 2003-2025 Kevin Lano
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
* *****************************/

import java.awt.*;
import javax.swing.*;
import java.util.Vector;

class ActorRectData extends RectForm
{ private boolean features = false;

ActorRectData(int xx, int yy, Color cc, int rectcount)
{ super(" ",cc,xx,yy);
label = new String("Actor" + rectcount);

namex = xx + 5;
namey = yy + 15;
width = 50;
height = 50;
features = false;
}

public Object clone()
{ int cType = UCDArea.SENSOR; // default.
ActorRectData rd =
new ActorRectData(sourcex,sourcey,color,0);
rd.setName(label,namex,namey);
rd.setSize(width,height);
rd.setModelElement(modelElement);
return rd;
}

public VisualData getCDVisual()
{ ActorRectData rd = (ActorRectData) clone();
rd.showFeatures();
return rd;
}

void setName(String ss, int xpos, int ypos)
{ label = ss;
namex = xpos;
namey = ypos;
}

public void setSize(int wid, int high)
{ width = wid;
height = high;
}

private void adjustWidth(Graphics g)
{ // compare size of name and width of rectangle
FontMetrics fm = g.getFontMetrics();
int w1 = fm.stringWidth(label);
int w2 = fm.stringWidth(" <<actor>>");
int w = w2;
if (w1 > w2)
{ w = w1; }

if (w + (namex - sourcex) >= width)
{ width = w + (namex - sourcex) + 5; }
if (20 + (namey - sourcey) >= height)
{ height = 20 + (namey - sourcey) + 5; }
}

void drawData(Graphics2D g)
{ g.setFont(new Font("Serif", Font.BOLD, 18));
adjustWidth(g);
g.setColor(Color.black);
g.drawOval(sourcex, sourcey,width - 1, height - 1);
g.drawRect(sourcex, sourcey,width - 1, height - 1);
g.drawString(" <<actor>>",namex,namey);
g.drawString(label,namex,namey+20);
}


void drawData(Graphics g) // and <<active>>, <<interface>>
{ adjustWidth(g);
g.setColor(Color.black);
g.drawOval(sourcex, sourcey,width - 1, height - 1);
g.drawRect(sourcex, sourcey,width - 1, height - 1);
g.drawString(" <<actor>>",namex,namey);
g.drawString(label,namex,namey+20);
}

/* Returns true if (xx,yy), which is coordinate
of the start of a line,
* are found within rectangle */
boolean isUnder(int xx, int yy)
{ // get the end points of the rectangle
int endx = sourcex + width;
int endy = sourcey + height;

// Check that xx,yy is within start & end rectangle
if (xx <= endx && sourcex <= xx &&
yy <= endy && sourcey <= yy)
{ return true; }
else
{ return false; }
}

public boolean isUnderStart(int x, int y)
{ return false; }

public boolean isUnderEnd(int x, int y)
{ return false; }

public boolean isNearEnd(int x, int y)
{ return false; }

public void changePosition(int oldx, int oldy,
int x, int y)
{ sourcex = x;
sourcey = y;
namex = sourcex + 5;
namey = sourcey + 15;
}

private void showFeatures()
{ features = true; }

// Show all the attributes:
private void drawFeatures(Graphics g)
{ return; }

private void drawEntityFeatures(Graphics g,FontMetrics fm,int widest)
{ return; }

private void drawTypeFeatures(Graphics g,FontMetrics fm,int widest)
{ return; }

private void drawRequirementFeatures(Graphics g,FontMetrics fm,int widest)
{ return; }

}


Binary file modified Attribute.class
Binary file not shown.
21 changes: 15 additions & 6 deletions Attribute.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import javax.swing.JOptionPane;

/******************************
* Copyright (c) 2003--2024 Kevin Lano
* Copyright (c) 2003--2025 Kevin Lano
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
Expand All @@ -18,13 +18,18 @@
public class Attribute extends ModelElement
{ private Type type;
private Type elementType;
private int kind; // SEN, ACT, INTERNAL, DERIVED
private int kind;
// SEN = 2, ACT = 7, INTERNAL = 3, DERIVED = 5,
// SUMMARY = 8, PASSWORD = 11, HIDDEN = 13

private String initialValue = ""; // default is none
private Expression initialExpression = null;
private boolean unique = false; // true if a primary key
private boolean frozen = false; // a constant
private boolean instanceScope = true; // "static"
private int visibility = PRIVATE; // PRIVATE, PUBLIC, PROTECTED, PACKAGE
private int visibility = PRIVATE;
// PRIVATE = 1, PUBLIC = 0, PROTECTED = 2, PACKAGE = 3

private Entity entity = null; // owner
private boolean sorted = false; // for collection-valued attributes

Expand All @@ -34,7 +39,9 @@ public class Attribute extends ModelElement
private int lower = 1;
private int upper = 1; // 0 represents *
private String role1 = null; // for associations represented as properties
private int card1 = ModelElement.MANY;
private int card1 = ModelElement.MANY;
// MANY = 0, ONE = 1, ZEROONE = -1

private Vector parameters = new Vector();
private boolean isArray = false;

Expand Down Expand Up @@ -1755,7 +1762,9 @@ public boolean isAssignable()

public boolean needsControllerOp()
{ return !frozen &&
(kind == ModelElement.SEN || kind == ModelElement.INTERNAL); }
(kind == ModelElement.SEN ||
kind == ModelElement.INTERNAL);
}
// DERIVED are handled locally?

public void saveEMF(PrintWriter out)
Expand All @@ -1768,7 +1777,7 @@ else if (isIdentity())
{ out.println(" attribute " + getName() + " identity : " + getType() + ";"); }
else if (isDerived())
{ out.println(" attribute " + getName() + " derived : " + getType() + ";"); }
else
else
{ out.println(" attribute " + getName() + " : " + getType() + ";"); }
}

Expand Down
Binary file modified BSystemTypes.class
Binary file not shown.
62 changes: 56 additions & 6 deletions BSystemTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.io.*;

/******************************
* Copyright (c) 2003--2024 Kevin Lano
* Copyright (c) 2003--2025 Kevin Lano
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
Expand Down Expand Up @@ -5482,7 +5482,53 @@ public static String generateIntersectionMapOpCPP()
" for (int i = 1; i < se->size(); ++i)\n" +
" { res = UmlRsdsLib<_T>::intersectionMap(res, (*se)[i]); }\n" +
" return res;\n" +
" }\n";
" }\n\n";

res = res +
" static bool includesKey(map<string, _T>* m, string k)\n" +
" { if (m->find(k) == m->end())\n" +
" {\n" +
" return false;\n" +
" }\n" +
" return true;\n" +
" }\n\n";

res = res +
" static bool excludesKey(map<string, _T>* m, string k)\n" +
" { if (m->find(k) == m->end())\n" +
" {\n" +
" return true;\n" +
" }\n" +
" return false;\n" +
" }\n\n";

res = res +
" static bool includesValue(map<string, _T>* s, _T val)\n" +
" {\n" +
" for (auto iter = s->begin(); iter != s->end(); ++iter)\n" +
" {\n" +
" _T value = iter->second;\n" +
" if (val == value)\n" +
" {\n" +
" return true;\n" +
" }\n" +
" }\n" +
" return false;\n" +
" }\n\n";

res = res +
" static bool excludesValue(map<string, _T>* s, _T val)\n" +
" {\n" +
" for (auto iter = s->begin(); iter != s->end(); ++iter)\n" +
" {\n" +
" _T value = iter->second;\n" +
" if (val == value)\n" +
" {\n" +
" return false;\n" +
" }\n" +
" }\n" +
" return true;\n" +
" }\n\n";

return res;
}
Expand Down Expand Up @@ -11248,13 +11294,15 @@ public static String generateIntersectionMapOp()
res = res +
" public static boolean includesKey(Map m, Object key) \n" +
" { Object val = m.get(key); \n" +
" if (val == null) { return false; }\n" +
" if (val == null)\n" +
" { return false; }\n" +
" return true;\n" +
" }\n\n";
res = res +
" public static boolean excludesKey(Map m, Object key) \n" +
" { Object val = m.get(key); \n" +
" if (val == null) { return true; }\n" +
" if (val == null)\n" +
" { return true; }\n" +
" return false;\n" +
" }\n\n";
res = res +
Expand All @@ -11264,7 +11312,7 @@ public static String generateIntersectionMapOp()
" for (int x = 0; x < keys.size(); x++)\n" +
" { Object v = m.get(x);\n" +
" if (v != null && v.equals(val))\n" +
" { return true; }\n" +
" { return true; }\n" +
" } \n" +
" return false;\n" +
" }\n\n";
Expand All @@ -11275,7 +11323,7 @@ public static String generateIntersectionMapOp()
" for (int x = 0; x < keys.size(); x++)\n" +
" { Object v = m.get(x);\n" +
" if (v != null && v.equals(val))\n" +
" { return false; }\n" +
" { return false; }\n" +
" } \n" +
" return true;\n" +
" }\n\n";
Expand Down Expand Up @@ -11595,6 +11643,8 @@ public static String generateIntersectionMapOpJava7()
" return result;\n" +
" }\n\n";

/* No need for includesKey, excludesKey, includesValue, excludesValue as these are operations of java.util.Map */

return res;
}

Expand Down
Binary file modified BinaryExpression.class
Binary file not shown.
Loading

0 comments on commit fb7101e

Please sign in to comment.