Skip to content
Snippets Groups Projects
Commit 2c70d351 authored by Moemoea Fierin's avatar Moemoea Fierin
Browse files

[CLEANING] Added basic documentation on functions

- added FIXMEs for later checkups
- basic doc for Javadoc
parent d6a62926
No related branches found
No related tags found
1 merge request!287Resolve "Zoom on all diagrams"
...@@ -63,9 +63,9 @@ import java.util.Vector; ...@@ -63,9 +63,9 @@ import java.util.Vector;
* @author Ludovic APVRILLE * @author Ludovic APVRILLE
*/ */
public abstract class AvatarMethodologyDiagramReference extends TGCScalableWithInternalComponent implements SwallowTGComponent { public abstract class AvatarMethodologyDiagramReference extends TGCScalableWithInternalComponent implements SwallowTGComponent {
public String oldValue; public String oldValue;
protected int textX = 5; protected int textX = 5; //FIXME already extended from TGScalableComponent, should be textX = 5
protected int textY = 22; protected int textY = 22; //FIXME already extended from TGScalableComponent, should be textY = 22
protected int lineHeight = 30; protected int lineHeight = 30;
protected double dlineHeight = 0.0; protected double dlineHeight = 0.0;
//protected int reqType = 0; //protected int reqType = 0;
...@@ -127,9 +127,7 @@ public abstract class AvatarMethodologyDiagramReference extends TGCScalableWithI ...@@ -127,9 +127,7 @@ public abstract class AvatarMethodologyDiagramReference extends TGCScalableWithI
removable = false; removable = false;
userResizable = true; userResizable = true;
multieditable = true; multieditable = true;
oldValue = value; oldValue = value;
myImageIcon = IconManager.imgic5006; myImageIcon = IconManager.imgic5006;
...@@ -138,7 +136,12 @@ public abstract class AvatarMethodologyDiagramReference extends TGCScalableWithI ...@@ -138,7 +136,12 @@ public abstract class AvatarMethodologyDiagramReference extends TGCScalableWithI
actionOnAdd(); actionOnAdd();
} }
/*From abstract class ui.TGComponent: declaration of abstract method*/
/*
* InternalDrawing
* @param g
* */
@Override
public void internalDrawing(Graphics g) { public void internalDrawing(Graphics g) {
Font f = g.getFont(); Font f = g.getFont();
// Font fold = f; // Font fold = f;
...@@ -164,8 +167,6 @@ public abstract class AvatarMethodologyDiagramReference extends TGCScalableWithI ...@@ -164,8 +167,6 @@ public abstract class AvatarMethodologyDiagramReference extends TGCScalableWithI
displayText = currentFontSize >= minFontSize; displayText = currentFontSize >= minFontSize;
// int h = g.getFontMetrics().getHeight();
g.setColor(ColorManager.AVATAR_REQUIREMENT_TOP); g.setColor(ColorManager.AVATAR_REQUIREMENT_TOP);
g.fillRect(x, y, width, height); g.fillRect(x, y, width, height);
ColorManager.setColor(g, getState(), 0); ColorManager.setColor(g, getState(), 0);
...@@ -188,98 +189,17 @@ public abstract class AvatarMethodologyDiagramReference extends TGCScalableWithI ...@@ -188,98 +189,17 @@ public abstract class AvatarMethodologyDiagramReference extends TGCScalableWithI
drawLimitedString(g, value, x, y + size + 3, width, 1); drawLimitedString(g, value, x, y + size + 3, width, 1);
g.setFont(f); g.setFont(f);
} }
/*if (displayText) {
size = currentFontSize - 2;
g.setFont(myFont.deriveFont((float)(myFont.getSize() - 2)));
drawLimitedString(g, REQ_TYPE_STR[reqType], x, y + size, width, 1);
size += currentFontSize;
g.setFont(myFontB);
w = g.getFontMetrics().stringWidth(value);
drawLimitedString(g, value, x, y + size, width, 1);
}
if (verified) {
if (satisfied) {
Color tmp = g.getColor();
GraphicLib.setMediumStroke(g);
g.setColor(Color.green);
g.drawLine(x+width-2, y-6+lineHeight, x+width-6, y-2+lineHeight);
g.drawLine(x+width-6, y-3+lineHeight, x+width-8, y-6+lineHeight);
g.setColor(tmp);
GraphicLib.setNormalStroke(g);
} else {
//g.drawString("acc", x + width - 10, y+height-10);
Color tmp = g.getColor();
GraphicLib.setMediumStroke(g);
g.setColor(Color.red);
g.drawLine(x+width-2, y-2+lineHeight, x+width-8, y-8+lineHeight);
g.drawLine(x+width-8, y-2+lineHeight, x+width-2, y-8+lineHeight);
g.setColor(tmp);
GraphicLib.setNormalStroke(g);
}
}
g.setFont(myFont);
String texti = "Text";
String s ;
int i;
size = lineHeight + currentFontSize;
//ID
if (size < (height - 2)) {
drawLimitedString(g, "ID=" + id, x + textX, y + size, width, 0);
}
size += currentFontSize;
//text
for(i=0; i<texts.length; i++) {
if (size < (height - 2)) {
s = texts[i];
if (i == 0) {
s = texti + "=\"" + s;
}
if (i == (texts.length - 1)) {
s = s + "\"";
}
drawLimitedString(g, s, x + textX, y + size, width, 0);
}
size += currentFontSize;
}
// Type and risk
if (size < (height - 2)) {
drawLimitedString(g, "Kind=\"" + kind + "\"", x + textX, y + size, width, 0);
size += currentFontSize;
if (size < (height - 2)) {
drawLimitedString(g, "Risk=\"" + criticality + "\"", x + textX, y + size, width, 0);
size += currentFontSize;
if (size < (height - 2)) {
drawLimitedString(g, "Reference elements=\"" + referenceElements + "\"", x + textX, y + size, width, 0);
size += currentFontSize;
if (size < (height - 2)) {
if (reqType == SECURITY_REQ) {
drawLimitedString(g, "Targeted attacks=\"" + attackTreeNode + "\"", x + textX, y + size, width, 0);
}
if (reqType == SAFETY_REQ) {
drawLimitedString(g, "Violated action=\"" + violatedAction + "\"", x + textX, y + size, width, 0);
}
}
}
}
}
g.setFont(f);*/
} }
/*
* editOndoubleClick: permits edition of the element on double click
* by simply calling adddiagramReference
* @param frame
* @param _x
* @param _y
* @return boolean true
* */
@Override
public boolean editOndoubleClick(JFrame frame, int _x, int _y) { public boolean editOndoubleClick(JFrame frame, int _x, int _y) {
addDiagramReference(frame); addDiagramReference(frame);
return true; return true;
...@@ -338,8 +258,13 @@ public abstract class AvatarMethodologyDiagramReference extends TGCScalableWithI ...@@ -338,8 +258,13 @@ public abstract class AvatarMethodologyDiagramReference extends TGCScalableWithI
return editAttributes();*/ return editAttributes();*/
} }
/*
* Rescale: rescale the element with the help of a scaleFactor
* From abstract class TGScalableComponent
* @param scaleFactor
*
* */
@Override
public void rescale(double scaleFactor){ public void rescale(double scaleFactor){
dlineHeight = (lineHeight + dlineHeight) / oldScaleFactor * scaleFactor; dlineHeight = (lineHeight + dlineHeight) / oldScaleFactor * scaleFactor;
lineHeight = (int)(dlineHeight); lineHeight = (int)(dlineHeight);
...@@ -349,17 +274,27 @@ public abstract class AvatarMethodologyDiagramReference extends TGCScalableWithI ...@@ -349,17 +274,27 @@ public abstract class AvatarMethodologyDiagramReference extends TGCScalableWithI
super.rescale(scaleFactor); super.rescale(scaleFactor);
} }
/*
* isOnOnlyMe, Coming from Abstract Method From TGCWithInternalComponent (Abstract Class)
* @param x1
* @param y1
* @return TGComponent or null
* */
@Override
public TGComponent isOnOnlyMe(int x1, int y1) { public TGComponent isOnOnlyMe(int x1, int y1) {
if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { if (GraphicLib.isInRectangle(x1, y1, x, y, width, height))
return this; return this;
}
return null; return null;
} }
/*
* addActionToPopupMenu
* @param componentMenu
* @param menuAL
* @param x
* @param y
* */
public void addActionToPopupMenu(JPopupMenu componentMenu, ActionListener menuAL, int x, int y) { public void addActionToPopupMenu(JPopupMenu componentMenu, ActionListener menuAL, int x, int y) {
componentMenu.addSeparator(); componentMenu.addSeparator();
...@@ -370,6 +305,11 @@ public abstract class AvatarMethodologyDiagramReference extends TGCScalableWithI ...@@ -370,6 +305,11 @@ public abstract class AvatarMethodologyDiagramReference extends TGCScalableWithI
componentMenu.add(diagramReference); componentMenu.add(diagramReference);
} }
/*
* eventOnPopup
* @param e
* @return boolean true
* */
public boolean eventOnPopup(ActionEvent e) { public boolean eventOnPopup(ActionEvent e) {
// String s = e.getActionCommand(); // String s = e.getActionCommand();
...@@ -382,6 +322,10 @@ public abstract class AvatarMethodologyDiagramReference extends TGCScalableWithI ...@@ -382,6 +322,10 @@ public abstract class AvatarMethodologyDiagramReference extends TGCScalableWithI
return true; return true;
} }
/*
* addDiagramReference: permits to pop a new window???
* @param frame
* */
public void addDiagramReference(JFrame frame) { public void addDiagramReference(JFrame frame) {
JDialogManageListOfString jdmlos; JDialogManageListOfString jdmlos;
Vector<String> ignored; // Must be built from non selected TMLTaskDiagramPanel or TMLCompPanel Vector<String> ignored; // Must be built from non selected TMLTaskDiagramPanel or TMLCompPanel
...@@ -457,16 +401,23 @@ public abstract class AvatarMethodologyDiagramReference extends TGCScalableWithI ...@@ -457,16 +401,23 @@ public abstract class AvatarMethodologyDiagramReference extends TGCScalableWithI
public abstract void makeValidationInfos(AvatarMethodologyDiagramName dn); public abstract void makeValidationInfos(AvatarMethodologyDiagramName dn);
/*
* hasAvatarMethodologyDiagramName
* @param s
* @return boolean denoting if the string s is in the tgcomponent list
* */
public boolean hasAvatarMethodologyDiagramName(String s) { public boolean hasAvatarMethodologyDiagramName(String s) {
for(int i=0; i<nbInternalTGComponent; i++) { for (int i = 0; i < nbInternalTGComponent; i++)
if (tgcomponent[i].getValue().compareTo(s) == 0) { if (tgcomponent[i].getValue().compareTo(s) == 0)
return true; return true;
}
}
return false; return false;
} }
/*
* fillIgnoredSelectedFromInternalComponents
* @param ignored
* @param selected
* */
public void fillIgnoredSelectedFromInternalComponents(Vector<String> ignored, Vector<String>selected) { public void fillIgnoredSelectedFromInternalComponents(Vector<String> ignored, Vector<String>selected) {
// Get from mgui the list of all diagrams with type depends from the subclass // Get from mgui the list of all diagrams with type depends from the subclass
// If diagrams have the same name -> we do not see the difference // If diagrams have the same name -> we do not see the difference
...@@ -513,11 +464,23 @@ public abstract class AvatarMethodologyDiagramReference extends TGCScalableWithI ...@@ -513,11 +464,23 @@ public abstract class AvatarMethodologyDiagramReference extends TGCScalableWithI
} }
public abstract boolean isAValidPanelType(TURTLEPanel panel); public abstract boolean isAValidPanelType(TURTLEPanel panel);
/*
* Permits to know if tgc is an instance of AvatarMethodologyDiagramName
* @param tgc
* @return boolean
* */
public boolean acceptSwallowedTGComponent(TGComponent tgc) { public boolean acceptSwallowedTGComponent(TGComponent tgc) {
return tgc instanceof AvatarMethodologyDiagramName; return tgc instanceof AvatarMethodologyDiagramName;
} }
/*
* addSwallowedTGComponent
* @param tgc
* @param x
* @param y
* @return boolean
* */
public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) { public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) {
tgc.setFather(this); tgc.setFather(this);
addInternalComponent(tgc, 0); addInternalComponent(tgc, 0);
...@@ -525,12 +488,21 @@ public abstract class AvatarMethodologyDiagramReference extends TGCScalableWithI ...@@ -525,12 +488,21 @@ public abstract class AvatarMethodologyDiagramReference extends TGCScalableWithI
return true; return true;
} }
/*
* removeSwallowedTGComponent
* @param tgc
* */
public void removeSwallowedTGComponent(TGComponent tgc) { public void removeSwallowedTGComponent(TGComponent tgc) {
removeInternalComponent(tgc); removeInternalComponent(tgc);
} }
public abstract boolean makeCall(String diagramName, int index); public abstract boolean makeCall(String diagramName, int index);
/*
* openDiagram
* @param tabName
* @return boolean
* */
protected boolean openDiagram(String tabName) { protected boolean openDiagram(String tabName) {
if (!tdp.getMGUI().selectMainTab(tabName)) { if (!tdp.getMGUI().selectMainTab(tabName)) {
TraceManager.addDev("Diagram removed?"); TraceManager.addDev("Diagram removed?");
...@@ -539,12 +511,15 @@ public abstract class AvatarMethodologyDiagramReference extends TGCScalableWithI ...@@ -539,12 +511,15 @@ public abstract class AvatarMethodologyDiagramReference extends TGCScalableWithI
return true; return true;
} }
/*
* giveInformation
* @param info
*
* */
protected void giveInformation(String info) { protected void giveInformation(String info) {
tdp.getMGUI().setStatusBarText(info); tdp.getMGUI().setStatusBarText(info);
} }
/*public String getDiagramReferences() { /*public String getDiagramReferences() {
return referenceElements; return referenceElements;
}*/ }*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment