use of com.ramussoft.pb.dfds.visual.DFDSRole in project ramus by Vitaliy-Yakovchuk.
the class MovingArea method copyDFDSVisual.
protected void copyDFDSVisual() {
startUserTransaction();
DFDSRole role = (DFDSRole) activeObject;
VisualPanelImpl panelImpl = new VisualPanelImpl(role);
Stream stream = role.getStream();
Row[] oRows = stream.getAdded();
for (Row row : dataPlugin.getRecChilds(dataPlugin.getBaseFunction(), true)) if (row instanceof Function) {
final Function f = (Function) row;
if (f.getType() == Function.TYPE_DFDS_ROLE && f.getElement().getId() != role.getFunction().getElement().getId()) {
long l = f.getLink();
if (l >= 0) {
Stream s = (Stream) dataPlugin.findRowByGlobalId(l);
if (s != null && s.getAdded() != null) {
Row[] rows = s.getAdded();
boolean b = false;
for (Row row2 : rows) if (row2 != null) {
if (b)
break;
for (Row row3 : oRows) if (row3.equals(row2)) {
panelImpl.copyTo(new VisualPanel() {
@Override
public void setForegroundA(Color foreground) {
f.setForeground(foreground);
}
@Override
public void setFontA(Font font) {
f.setFont(font);
}
@Override
public void setBoundsA(FRectangle bounds) {
f.setBounds(bounds);
}
@Override
public void setBackgroundA(Color background) {
f.setBackground(background);
}
@Override
public Color getForegroundA() {
return f.getForeground();
}
@Override
public Font getFontA() {
return f.getFont();
}
@Override
public FRectangle getBoundsA() {
return f.getBounds();
}
@Override
public Color getBackgroundA() {
return f.getBackground();
}
}, copyOptions.copyBK, copyOptions.copyFK, copyOptions.copyFont, copyOptions.copySize);
b = true;
break;
}
}
}
}
}
}
commitUserTransaction();
}
use of com.ramussoft.pb.dfds.visual.DFDSRole in project ramus by Vitaliy-Yakovchuk.
the class MovingArea method addIDEF0Object.
private IDEF0Object addIDEF0Object(final Function function) {
IDEF0Object movingFunction;
if (function.getType() < Function.TYPE_EXTERNAL_REFERENCE) {
if (DIAGRAM_TYPE_DFD == activeFunction.getDecompositionType())
movingFunction = new DFDFunction(this, function) {
/**
* @see com.ramussoft.pb.idef.visual.MovingText#onFocusGained(java.awt.event.FocusEvent)
*/
@Override
public void focusGained(boolean silent) {
super.focusGained(silent);
setActiveObject(this, silent);
}
@Override
public void focusLost() {
super.focusLost();
if (getActiveObject() == this)
setActiveObject(null);
}
};
else if (DIAGRAM_TYPE_DFDS == activeFunction.getDecompositionType())
movingFunction = new DFDSFunction(this, function) {
/**
* @see com.ramussoft.pb.idef.visual.MovingText#onFocusGained(java.awt.event.FocusEvent)
*/
@Override
public void focusGained(boolean silent) {
super.focusGained(silent);
setActiveObject(this, silent);
}
@Override
public void focusLost() {
super.focusLost();
if (getActiveObject() == this)
setActiveObject(null);
}
};
else
movingFunction = new MovingFunction(this, function) {
/**
* @see com.ramussoft.pb.idef.visual.MovingText#onFocusGained(java.awt.event.FocusEvent)
*/
@Override
public void focusGained(boolean silent) {
super.focusGained(silent);
setActiveObject(this, silent);
}
@Override
public void focusLost() {
super.focusLost();
if (getActiveObject() == this)
setActiveObject(null, false);
}
};
} else {
if (function.getType() == Function.TYPE_EXTERNAL_REFERENCE) {
movingFunction = new External(this, function) {
/**
* @see com.ramussoft.pb.idef.visual.MovingText#onFocusGained(java.awt.event.FocusEvent)
*/
@Override
public void focusGained(boolean silent) {
super.focusGained(silent);
setActiveObject(this);
}
@Override
public void focusLost() {
super.focusLost();
if (getActiveObject() == this)
setActiveObject(null);
}
};
} else if (function.getType() == Function.TYPE_DFDS_ROLE) {
movingFunction = new DFDSRole(this, function) {
/**
* @see com.ramussoft.pb.idef.visual.MovingText#onFocusGained(java.awt.event.FocusEvent)
*/
@Override
public void focusGained(boolean silent) {
super.focusGained(silent);
setActiveObject(this, silent);
}
@Override
public void focusLost() {
super.focusLost();
if (getActiveObject() == this)
setActiveObject(null, false);
}
};
} else {
// DATA STORE
movingFunction = new DataStore(this, function) {
/**
* @see com.ramussoft.pb.idef.visual.MovingText#onFocusGained(java.awt.event.FocusEvent)
*/
@Override
public void focusGained(boolean silent) {
super.focusGained(silent);
setActiveObject(this);
}
@Override
public void focusLost() {
super.focusLost();
if (getActiveObject() == this)
setActiveObject(null);
}
};
}
}
movingFunctions.put(function, movingFunction);
return movingFunction;
}
use of com.ramussoft.pb.dfds.visual.DFDSRole in project ramus by Vitaliy-Yakovchuk.
the class MovingArea method editActive.
/**
* Якщо виділений якийсь об’єкт, тоді з’являється діалогове вікно для роботи
* з його властивостями.
*/
@SuppressWarnings("unused")
public void editActive() {
if ((Metadata.EDUCATIONAL) && (Math.random() < 0.2d)) {
AttributePlugin plugin = panel.getFramework().findAttributePlugin(new AttributeType("Core", "Table", false));
if (!(plugin instanceof EmptyPlugin)) {
System.exit(233);
}
}
if ((activeObject instanceof MovingFunction) || (activeObject instanceof DFDFunction)) {
final IDEF0Object movingFunction = (IDEF0Object) activeObject;
// String text = movingFunction.getFunction().getName();
panel.getFunctionOptions().showModal(movingFunction);
/*
* if(!text.equals(movingFunction.getFunction().getName()))
* movingFunction.resetBounds();
*/
} else if (activeObject instanceof DFDSRole) {
panel.getDFDSRoleOptionsDialog().showModal((DFDSRole) activeObject);
} else if (activeObject instanceof DFDObject) {
panel.getDFDObjectOptionsDialog().showModal((DFDObject) activeObject);
} else if (activeObject instanceof MovingText)
panel.getTextOptionsDialog().showModal((MovingText) activeObject);
else if (activeObject instanceof PaintSector.Pin) {
panel.getArrowOptionsDialog().showModal(((PaintSector.Pin) activeObject).getSector(), this);
// setPanels();
}
repaintAsync();
}
use of com.ramussoft.pb.dfds.visual.DFDSRole in project ramus by Vitaliy-Yakovchuk.
the class DFDSRoleOptionsDialog method onOk.
@Override
protected void onOk() {
if (!isCanOk()) {
JOptionPane.showMessageDialog(this, ResourceLoader.getString("you_should_enter_name_or_at_least_on_added_elemen"));
return;
}
if (!isOkStreamName()) {
if (JOptionPane.showConfirmDialog(this, ResourceLoader.getString("you_entered_exists_stream_continue"), ResourceLoader.getString("warning"), JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) {
return;
}
}
DFDSRole role = (DFDSRole) object;
Journaled journaled = (Journaled) dataPlugin.getEngine();
journaled.startUserTransaction();
Function function = object.getFunction();
function.setFont(fontChooser.getSelFont());
function.setBackground(backgroundColorChooser.getColor());
function.setForeground(foregroundColorChooser.getColor());
role.setAlternativeText(sectorNameEditor.getAlternativeTextField().getText());
Stream stream = sectorRowsEditor.getStream();
if (stream == null) {
stream = sectorNameEditor.findStreamByName();
if (stream == null) {
stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
}
}
final String t = sectorNameEditor.getArrowName();
if (!t.equals("")) {
if (!t.equals(stream.getName()) && sectorNameEditor.findStreamByName(stream.getName()) != null) {
stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
}
}
if (t.equals("")) {
if (!stream.isEmptyName()) {
stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
stream.setEmptyName(true);
}
} else {
stream.setName(t);
}
stream.setRows(sectorRowsEditor.getRows());
role.setStream(stream, ReplaceStreamType.SIMPLE);
// sector.setStreamAddedByRefactor(false);
final Row[] rs = sectorRowsEditor.getRows();
role.setRows(rs);
if (rs != null) {
RectangleVisualOptions ops = new RectangleVisualOptions();
ops.bounds = function.getBounds();
ops.background = function.getBackground();
ops.font = function.getFont();
ops.foreground = function.getForeground();
for (Row row : rs) if (row != null) {
IDEF0Plugin.setDefaultRectangleVisualOptions(dataPlugin.getEngine(), row.getElement(), ops);
}
}
journaled.commitUserTransaction();
setVisible(false);
}
use of com.ramussoft.pb.dfds.visual.DFDSRole in project ramus by Vitaliy-Yakovchuk.
the class MovingArea method paintBackground.
public synchronized void paintBackground(final Graphics gr) {
final Graphics2D g = (Graphics2D) gr;
if (!isPrinting()) {
PStringBounder.FONT_CONTEXT = g.getFontRenderContext();
g.setColor(getBackground());
if (showNet) {
g.setColor(getBackground());
g.fillRect(0, 0, getSize().width, getSize().height);
g.setColor(Color.black);
drawNet(g, 0, 0, getSize().width, getSize().height);
} else {
g.setColor(getBackground());
g.fillRect(0, 0, getSize().width, getSize().height);
}
g.setColor(getForeground());
if (!DISABLE_RENDERING_HINTS && !isPrinting()) {
g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
}
} else {
}
g.drawLine(0, 0, 0, getIntOrdinate(CLIENT_HEIGHT));
g.drawLine(getIntOrdinate(CLIENT_WIDTH) - 1, 0, getIntOrdinate(CLIENT_WIDTH) - 1, getIntOrdinate(CLIENT_HEIGHT));
final Stroke s = g.getStroke();
for (final MovingText element : panels) if (!(element instanceof DFDSRole) && !(element instanceof MovingLabel))
element.paint(g, this);
for (final MovingText element : panels) if (element instanceof DFDSRole && !(element instanceof MovingLabel))
element.paint(g, this);
g.setStroke(s);
Iterator<PaintSector> iterator = refactor.getSectors().iterator();
while (iterator.hasNext()) {
try {
iterator.next().paint(g, this);
} catch (Exception exception) {
iterator.remove();
}
}
g.setStroke(s);
for (final MovingText element : panels) if (element instanceof MovingLabel)
element.paint(g, this);
if (hPageCountSize > 1) {
g.setStroke(new BasicStroke(0.7f, 1, 1, 2, new float[] { (float) getIDoubleOrdinate(6), (float) getIDoubleOrdinate(10) }, (float) getIDoubleOrdinate(10)));
double x = getIDoubleOrdinate(CLIENT_WIDTH) / hPageCountSize;
double px = x;
for (int i = 0; i < hPageCountSize; i++) {
g.draw(new Line2D.Double(x, 0, x, getIDoubleOrdinate(CLIENT_HEIGHT - 2)));
x += px;
}
}
}
Aggregations