Skip to content
Snippets Groups Projects
Commit ec402ca1 authored by Irina LEE's avatar Irina LEE
Browse files

add cluster in avatardd and test rotation in syscams component

parent 8b319c3b
No related branches found
No related tags found
1 merge request!72Syscams
......@@ -42,10 +42,13 @@ import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import ui.*;
import ui.syscams.SysCAMSComponentTaskDiagramPanel;
import ui.util.IconManager;
import javax.swing.*;
import java.awt.*;
import java.util.Vector;
/**
* Class ADDClusterNode
......@@ -61,6 +64,9 @@ public class ADDClusterNode extends ADDNode implements WithAttributes {
private int derivationx = 2;
private int derivationy = 3;
private String stereotype = "Cluster";
private int currentFontSize = -1;
private int textX = 15; // border for ports
public String oldValue;
private int index = 0;
......@@ -98,14 +104,13 @@ public class ADDClusterNode extends ADDNode implements WithAttributes {
nbInternalTGComponent = 0;
moveable = true;
multieditable = true;
editable = true;
removable = true;
userResizable = true;
name = tdp.findNodeName("Cluster");
value = "name";
// myImageIcon = IconManager.imgic8006;
}
public void internalDrawing(Graphics g) {
......@@ -167,7 +172,57 @@ public class ADDClusterNode extends ADDNode implements WithAttributes {
return index;
}
public boolean editOndoubleClick(JFrame frame) {
public boolean editOndoubleClick(JFrame frame, int _x, int _y) {
int i;
MainGUI mgui = getTDiagramPanel().getMainGUI();
Vector<TURTLEPanel> listPanel = mgui.getTabs();
// On the name ?
if (_y <= (y + currentFontSize + textX)) {
//TraceManager.addDev("Edit on double click x=" + _x + " y=" + _y);
oldValue = value;
String s = (String)JOptionPane.showInputDialog(frame, "Name:", "Setting component name",
JOptionPane.PLAIN_MESSAGE, IconManager.imgic100,
null,
getValue());
if ((s != null) && (s.length() > 0)) {
// Check whether this name is already in use, or not
if (!TAttribute.isAValidId(s, false, false)) {
JOptionPane.showMessageDialog(frame,
"Could not change the name of the component: the new name is not a valid name",
"Error",
JOptionPane.INFORMATION_MESSAGE);
return false;
}
// if (oldValue.compareTo(s) != 0) {
// if (((SysCAMSComponentTaskDiagramPanel)(tdp)).nameBlockTDFComponentInUse(oldValue, s)) {
// JOptionPane.showMessageDialog(frame,
// "Error: the name is already in use",
// "Name modification",
// JOptionPane.ERROR_MESSAGE);
// return false;
// }
// }
//TraceManager.addDev("Set value with change");
setComponentName(s);
setValueWithChange(s);
// isAttacker = s.contains("Attacker");
// rescaled = true;
//TraceManager.addDev("return true");
return true;
}
return false;
}
for (i = 0; i < listPanel.size(); i++) {
if (mgui.getTitleAt(listPanel.get(i)).equals("SystemC_AMS")) {
mgui.selectMainTab("SystemC_AMS");
}
}
return true;
}
......@@ -233,4 +288,4 @@ public class ADDClusterNode extends ADDNode implements WithAttributes {
attr += "index = " + index + "\n";
return attr;
}
}
}
\ No newline at end of file
......@@ -50,6 +50,7 @@ import ui.window.JDialogELNComponentResistor;
import javax.swing.*;
import java.awt.*;
import java.awt.geom.AffineTransform;
/**
* Class ELNComponentResistor
......@@ -118,7 +119,8 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent {
return myColor;
}
public void internalDrawing(Graphics g) {
public void internalDrawing(Graphics gr) {
Graphics2D g = (Graphics2D) gr;
Font f = g.getFont();
Font fold = f;
......@@ -156,11 +158,32 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent {
f = f.deriveFont(this.currentFontSize);
}
// Zoom is assumed to be computed
// Zoom is assumed to be computed
Color c = g.getColor();
int [] ptx = {x, x+width/4, x+width/4, x+3*width/4, x+3*width/4, x+width, x+3*width/4, x+3*width/4, x+width/4, x+width/4};
int [] pty = {y+height/2, y+height/2, y, y, y+height/2, y+height/2, y+height/2, y+height, y+height, y+height/2};
g.drawPolygon(ptx, pty, 10);
Polygon p = new Polygon(ptx, pty, 10);
g.drawPolygon(p);
//------------------
// Save the current transform of the graphics contexts.
AffineTransform saveTransform = g.getTransform();
// Create a identity affine transform, and apply to the Graphics2D context
AffineTransform identity = new AffineTransform();
g.setTransform(identity);
// Paint Shape (with identity transform), centered at (0, 0) as defined.
g.rotate(Math.toRadians(90));
g.setTransform(identity);
g.drawPolygon(p);
g.fill(p);
// Restore original transform before returning
g.setTransform(saveTransform);
//------------------
//------------------
g.setColor(c);
// Set font size
......
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