use of com.ramussoft.pb.idef.elements.PaintSector.Pin in project ramus by Vitaliy-Yakovchuk.
the class SectorColorAttributePlugin method getAttributeEditor.
@Override
public AttributeEditor getAttributeEditor(final Engine engine, final AccessRules rules, final Element element, final Attribute attribute, AttributeEditor old) {
if (old != null)
old.close();
return new AbstractAttributeEditor() {
private PaintSector.Pin pin;
private JColorChooser component;
private Color color;
{
component = new JColorChooser();
}
@Override
public Object setValue(Object value) {
this.pin = (PaintSector.Pin) value;
color = pin.getSector().getColor();
component.setColor(color);
return value;
}
@Override
public Object getValue() {
return pin;
}
@Override
public void apply(Engine engine, Element element, Attribute attribute, Object value) {
SectorColorAttributePlugin.this.apply(component.getColor(), pin);
}
@Override
public JComponent getComponent() {
return component;
}
@Override
public boolean isSaveAnyway() {
return !color.equals(component.getColor());
}
};
}
use of com.ramussoft.pb.idef.elements.PaintSector.Pin in project ramus by Vitaliy-Yakovchuk.
the class HTTPParser method printIDEF0Model.
private void printIDEF0Model() throws IOException {
int imageWidth = IMAGE_WIDTH;
String s = (String) params.get("w");
if (s != null) {
try {
imageWidth = new Integer(s).intValue();
} catch (final Exception e) {
}
}
int imageHeight = IMAGE_HEIGHT;
s = (String) params.get("h");
if (s != null) {
try {
imageHeight = new Integer(s).intValue();
} catch (final Exception e) {
}
}
Row row = loadRowById();
Row old = row;
if (row == null || !(row instanceof Function)) {
printIDEF0Error();
return;
}
row = replaceIDEF0Row(row);
final Function function = (Function) row;
String functionType;
String name = function.getName();
int iFunctionType = function.getType();
Row ouner = null;
if (function.getParent() == null) {
final Enumeration e = function.children();
while (e.hasMoreElements()) {
final Function f = (Function) e.nextElement();
ouner = f.getOwner();
iFunctionType = f.getType();
name = f.getName();
if (ouner != null)
break;
}
} else
ouner = function.getOwner();
switch(iFunctionType) {
case Function.TYPE_PROCESS_KOMPLEX:
functionType = RES.getString("functionProcessKomplex");
break;
case Function.TYPE_PROCESS:
functionType = RES.getString("functionProcess");
break;
case Function.TYPE_PROCESS_PART:
functionType = RES.getString("functionProcessPart");
break;
case Function.TYPE_ACTION:
functionType = RES.getString("functionAction");
break;
case Function.TYPE_OPERATION:
functionType = RES.getString("functionOperation");
break;
default:
functionType = "";
break;
}
htmlTitle = functionType + " " + name;
printStartD();
if (printVersion) {
} else {
if (imageWidth != 800) {
htmlStream.print("<a href=\"" + fromLink + "idef0/index.html?id=" + function.getGlobalId().toString() + "&w=800&h=600\" style=\"color:rgb(0,0,0);\">");
htmlStream.print("800x600");
htmlStream.println("</a>");
}
if (imageWidth != 905) {
htmlStream.print("<a href=\"" + fromLink + "idef0/index.html?id=" + function.getGlobalId().toString() + "&w=905&h=700\" style=\"color:rgb(0,0,0);\">");
htmlStream.print("905x700");
htmlStream.println("</a>");
}
if (imageWidth != 1024) {
htmlStream.print("<a href=\"" + fromLink + "idef0/index.html?id=" + function.getGlobalId().toString() + "&w=1024&h=768\" style=\"color:rgb(0,0,0);\">");
htmlStream.print("1024x768");
htmlStream.println("</a>");
}
if (imageWidth != 1152) {
htmlStream.print("<a href=\"" + fromLink + "idef0/index.html?id=" + function.getGlobalId().toString() + "&w=1152&h=864\" style=\"color:rgb(0,0,0);\">");
htmlStream.print("1152x864");
htmlStream.println("</a>");
}
if (imageWidth != 1300) {
htmlStream.print("<a href=\"" + fromLink + "idef0/index.html?id=" + function.getGlobalId().toString() + "&w=1300&h=1000\" style=\"color:rgb(0,0,0);\">");
htmlStream.print("1300x1000");
htmlStream.println("</a>");
}
if (imageWidth != 1600) {
htmlStream.print("<a href=\"" + fromLink + "idef0/index.html?id=" + function.getGlobalId().toString() + "&w=1600&h=1200\" style=\"color:rgb(0,0,0);\">");
htmlStream.print("1600x1200");
htmlStream.println("</a>");
}
final Row parent = function.getParentRow();
htmlStream.println(RES.getString("functionType") + ": <b>" + functionType + "</b>");
if (parent != null) {
printStartATeg("idef0/index.html?id=" + parent.getGlobalId().toString());
htmlStream.println(RES.getString("oneLevelTop"));
printEndATeg();
// printStartATeg("idef0/index.html?id="
// + dataPlugin.getBaseFunction().getGlobalId().toString());
htmlStream.println(RES.getString("contents"));
printEndATeg();
}
if (ouner != null) {
printStartATeg("rows/index.html?id=" + ouner.getGlobalId().toString());
htmlStream.println(RES.getString("ouner") + ": " + ouner.getKod() + ". " + ouner.getName());
printEndATeg();
}
if (old == row) {
printStartATeg("rows/index.html?id=" + function.getGlobalId().toString());
htmlStream.println(RES.getString("element"));
printEndATeg();
}
Row top = row;
while (top.getParentRow() != null) {
top = top.getParentRow();
}
printStartATeg("fullmodel/index.html?id=" + top.getElement().getId());
htmlStream.println(RES.getString("ExpandedModel"));
printEndATeg();
}
htmlStream.print("<br>");
htmlStream.println("<img border=0 src=\"" + fromLink + "idef0/" + "model." + getImagesFormatName() + "?id=" + function.getGlobalId().toString() + "&w=" + imageWidth + "&h=" + imageHeight + "\" useMap=#M" + function.getGlobalId().toString() + ">");
htmlStream.println("<map name=M" + function.getGlobalId().toString() + ">");
final Vector childs = dataPlugin.getChilds(function, true);
final MovingArea area = PIDEF0painter.createMovingArea(new Dimension(imageWidth, imageHeight), dataPlugin, function);
final SectorRefactor refactor = area.getRefactor();
for (int i = 0; i < childs.size(); i++) {
final Function fun = (Function) childs.get(i);
Row row2 = dataPlugin.findRowByGlobalId(fun.getLink());
String where = "rows";
if ((row2 == null) && (fun.getType() < Function.TYPE_EXTERNAL_REFERENCE)) {
row2 = fun;
if (!fun.isLeaf())
where = "idef0";
}
if (row2 != null) {
htmlStream.print("<area shape=RECT coords=" + getAreaCoords(fun.getBounds(), area) + " href=\"" + fromLink + where + "/index.html?id=" + row2.getElement().getId() + "&w=" + imageWidth + "&h=" + imageHeight + (printVersion ? "&printVersion=true" : "") + "\"");
htmlStream.println(">");
}
}
refactor.loadFromFunction(function, false);
final int sc = refactor.getSectorsCount();
for (int i = 0; i < sc; i++) {
final PaintSector sector = refactor.getSector(i);
final Stream stream = sector.getStream();
final MovingLabel text = refactor.getSector(i).getText();
if (text != null && stream != null) {
htmlStream.print("<area shape=RECT coords=" + getAreaCoords(text.getBounds(), area) + " href=\"" + fromLink + "rows/index.html?id=" + stream.getGlobalId().toString() + "§orId=" + sector.getSector().getGlobalId() + "&w=" + imageWidth + "&h=" + imageHeight + "\"");
htmlStream.println(">");
}
final int l = sector.getPinCount();
for (int j = 0; j < l; j++) if (stream != null) {
final Pin pin = sector.getPin(j);
htmlStream.print("<area shape=RECT coords=" + getPinCoords(pin, area) + " href=\"" + fromLink + "rows/index.html?id=" + stream.getGlobalId().toString() + "§orId=" + sector.getSector().getGlobalId() + "&w=" + imageWidth + "&h=" + imageHeight + "\"");
htmlStream.println(">");
}
}
htmlStream.println("<map>");
printEndD();
}
use of com.ramussoft.pb.idef.elements.PaintSector.Pin in project ramus by Vitaliy-Yakovchuk.
the class LineStyleAttributePlugin method getTableCellEditor.
@Override
public TableCellEditor getTableCellEditor(final Engine engine, final AccessRules rules, final Attribute attribute) {
final JComboBox box = new JComboBox();
box.setRenderer(comboBoxRenderer);
for (Stroke stroke : LineStyleChooser.getStrokes()) {
box.addItem(stroke);
}
return new DefaultCellEditor(box) {
private Pin pin;
@Override
public boolean stopCellEditing() {
if (box.getSelectedItem() instanceof Stroke) {
((Journaled) engine).startUserTransaction();
apply((BasicStroke) box.getSelectedItem(), pin);
return super.stopCellEditing();
}
return false;
}
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
pin = (Pin) ((MetadataGetter) table).getMetadata();
return super.getTableCellEditorComponent(table, value, isSelected, row, column);
}
};
}
use of com.ramussoft.pb.idef.elements.PaintSector.Pin in project ramus by Vitaliy-Yakovchuk.
the class MovingArea method arrowCopyVisual.
public void arrowCopyVisual() {
startUserTransaction();
PaintSector.Pin pin = (PaintSector.Pin) activeObject;
Stream stream = pin.getSector().getStream();
Row[] oRows = stream.getAdded();
byte[] bs = pin.getSector().getSector().getVisualAttributes();
for (Sector f : dataPlugin.getAllSectors()) if (f.getStream() != null && f.getStream().getAdded() != null) {
Row[] rows = f.getStream().getAdded();
boolean b = false;
for (Row row2 : rows) if (row2 != null) {
if (b)
break;
for (Row row3 : oRows) if (row3.equals(row2)) {
f.setVisualAttributes(bs);
b = true;
break;
}
}
}
refactor.setUndoPoint();
}
use of com.ramussoft.pb.idef.elements.PaintSector.Pin in project ramus by Vitaliy-Yakovchuk.
the class MovingArea method processMouse.
/**
* Медод, який обробляє натискання на кнопці миші, якщо стан панелі
* відображення змінює певні атрибути, то вони змінюються.
*
* @param e Пораметри натискання миші.
*/
protected void processMouse(final MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON3)
return;
final int x = e.getX();
final int y = e.getY();
final double dX = getDoubleOrdinate(x);
final double dY = getDoubleOrdinate(y);
int type = Function.TYPE_OPERATION;
if (getState() == FUNCTION_ADDING_STATE && getActiveObject() == null) {
if (isOut(dX, LEFT_PART, CLIENT_WIDTH) || isOut(dY, TOP_PART, CLIENT_HEIGHT))
return;
if (!canAddOnContext()) {
JOptionPane.showMessageDialog(this, ResourceLoader.getString("you_can_not_add_more_then_one_f"));
return;
}
addInOutObject(dX, dY, type);
} else if (getState() == EXTERNAL_REFERENCE_ADDING_STATE && getActiveObject() == null) {
if (isOut(dX, LEFT_PART, CLIENT_WIDTH) || isOut(dY, TOP_PART, CLIENT_HEIGHT))
return;
addInOutObject(dX, dY, Function.TYPE_EXTERNAL_REFERENCE);
} else if (getState() == DATA_STORE_ADDING_STATE && getActiveObject() == null) {
if (isOut(dX, LEFT_PART, CLIENT_WIDTH) || isOut(dY, TOP_PART, CLIENT_HEIGHT))
return;
addInOutObject(dX, dY, Function.TYPE_DATA_STORE);
} else if (getState() == DFDS_ROLE_ADDING_STATE && getActiveObject() == null) {
if (isOut(dX, LEFT_PART, CLIENT_WIDTH) || isOut(dY, TOP_PART, CLIENT_HEIGHT))
return;
addInOutObject(dX, dY, Function.TYPE_DFDS_ROLE);
} else if (getChangingState() == ARROW_CHANGING_STATE) {
final PaintSector.Pin activePin = getPin(e.getX(), e.getY());
if (activePin == null)
addArrowToArea(dX, dY);
else {
PaintSector sector = activePin.getSector();
if ((sector.isPart()) && (sector.isSelEnd() || sector.isSelStart())) {
if (activeObject instanceof PaintSector.Pin) {
final PaintSector.Pin pin = (PaintSector.Pin) activeObject;
if (pin.getSector().isSelEnd() || pin.getSector().isSelStart()) {
setActiveObject(null);
refactor.setSector(pin.getSector());
if (pin.getSector().isSelEnd()) {
setState(END_POINT_CHANGING_ADD);
} else if (pin.getSector().isSelStart()) {
setState(START_POINT_CHANGING_ADD);
}
panel.getFramework().put(CURRENT_MOVING_AREA, this);
}
}
} else {
if (getPointChangingType() == SectorRefactor.TYPE_START) {
if (sector.isPart() && activePin.getSector().getStart() == null)
return;
} else {
if (activePin.getSector().isPart() && activePin.getSector().getEnd() == null)
return;
}
final SectorRefactor.PerspectivePoint pp = new SectorRefactor.PerspectivePoint();
pp.type = getPointChangingType();
pp.pin = activePin;
pp.x = getDoubleOrdinate(e.getX());
pp.y = getDoubleOrdinate(e.getY());
refactor.setPoint(pp);
doSector();
}
}
} else if (getChangingState() == TILDA_ADDING_STATE) {
final PaintSector.Pin activePin = getPin(e.getX(), e.getY());
if (activePin != null) {
startUserTransaction();
List<PaintSector> ps = activePin.getSector().setTildaPos(getDoubleOrdinate(e.getX()), getDoubleOrdinate(e.getY()));
for (PaintSector s : ps) PaintSector.save(s, new MemoryData(), dataPlugin.getEngine());
refactor.setUndoPoint();
}
} else if (getChangingState() == TEXT_ADDING_STATE) {
final MovingText text = createText();
cancelAdding();
refactor.addText(text);
text.setBounds(dX, dY, text.getBounds().getWidth(), text.getBounds().getHeight());
text.setFont(Options.getFont("DEFAULT_TEXT_FONT", new Font("Arial", 0, 10)));
text.setColor(Options.getColor("DEFAULT_TEXT_COLOR", Color.black));
startUserTransaction();
refactor.setUndoPoint();
} else {
if (activeObject instanceof PaintSector.Pin) {
final PaintSector.Pin pin = (PaintSector.Pin) activeObject;
if (pin.getSector().isSelEnd() || pin.getSector().isSelStart()) {
setActiveObject(null);
refactor.setSector(pin.getSector());
if (pin.getSector().isSelEnd()) {
setState(END_POINT_CHANGING);
} else if (pin.getSector().isSelStart()) {
setState(START_POINT_CHANGING);
}
panel.getFramework().put(CURRENT_MOVING_AREA, this);
}
}
}
}
Aggregations