use of com.ramussoft.pb.Stream in project ramus by Vitaliy-Yakovchuk.
the class MovingArea method setActiveFunction.
/**
* Задає значення активного на блоку (того який являється базовим для
* решти).
*
* @param activeFunction Значення активної функції.
*/
public void setActiveFunction(final Function activeFunction) {
synchronized (backgroundPaintlock) {
bImage = null;
}
String size = activeFunction.getPageSize();
initSize(size);
if (panel != null) {
cancelAdding();
panel.setMovingAreaSize(zoom);
}
if (activeFunction.getType() >= Function.TYPE_EXTERNAL_REFERENCE)
return;
textPaintCache.clear();
if (activeFunction.getDecompositionType() == DIAGRAM_TYPE_DFDS) {
DropTarget dropTarget = new DropTarget();
this.setDropTarget(dropTarget);
try {
dropTarget.addDropTargetListener(new DropTargetAdapter() {
@Override
public void drop(DropTargetDropEvent event) {
if (event.getTransferable().isDataFlavorSupported(RowTreeTable.rowsListFlavor)) {
try {
event.acceptDrop(event.getSourceActions());
Rows rows = (Rows) event.getTransferable().getTransferData(RowTreeTable.rowsListFlavor);
FloatPoint point = toPoint(event.getLocation().x, event.getLocation().y);
Function owner = null;
for (MovingPanel panel : panels) if (panel instanceof DFDSFunction && panel.contain(point)) {
owner = ((DFDSFunction) panel).getFunction();
}
startUserTransaction();
Function function = createFunctionalObject(getDoubleOrdinate(event.getLocation().getX()), getDoubleOrdinate(event.getLocation().getY()), Function.TYPE_DFDS_ROLE, activeFunction);
RectangleVisualOptions ops = IDEF0Plugin.getDefaultRectangleVisualOptions(dataPlugin.getEngine(), rows.get(0).getElement());
if (ops != null) {
FRectangle rect = function.getBounds();
rect.setHeight(ops.bounds.getHeight());
rect.setWidth(ops.bounds.getWidth());
function.setBounds(rect);
function.setFont(ops.font);
function.setBackground(ops.background);
function.setForeground(ops.foreground);
}
Stream stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
Row[] rows2 = new Row[rows.size()];
for (int i = 0; i < rows2.length; i++) rows2[i] = dataPlugin.findRowByGlobalId(rows.get(i).getElementId());
stream.setRows(rows2);
function.setLink(stream.getElement().getId());
if (owner != null) {
function.setOwner(owner);
DFDSFunction function2 = findDFDSFunction(owner);
List<Function> roles = getRoles(function2);
if (!roles.contains(function))
roles.add(function);
if (function2 != null)
function2.justifyRoles(roles);
}
commitUserTransaction();
panel.getFrame().propertyChange(MChangeListener.RELOAD_FUNCTION_IN_TREE, activeFunction);
} catch (UnsupportedFlavorException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
} else
event.rejectDrop();
}
});
} catch (TooManyListenersException e) {
e.printStackTrace();
}
} else
this.setDropTarget(null);
if (rec)
return;
rec = true;
if (panel != null) {
boolean locked;
if (activeFunction.equals(lockedFunction))
locked = true;
else
locked = activeFunction.lock();
refactor.loadFromFunction(activeFunction, false);
if (!activeFunction.equals(lockedFunction)) {
if (lockedFunction != null)
lockedFunction.unlock();
if (locked)
lockedFunction = activeFunction;
else
lockedFunction = null;
}
panel.setMovingActiveFunction(activeFunction);
if (getState() == END_POINT_ADDING)
setState(START_POINT_ADDING);
if ((getState() == END_POINT_CHANGING) || (getState() == START_POINT_CHANGING) || (getState() == FUNCTION_ADDING_STATE) || (getState() == TEXT_ADDING_STATE))
cancelAdding();
} else
refactor.loadFromFunction(activeFunction, false);
boolean updateListeneres = this.activeFunction != activeFunction;
this.activeFunction = activeFunction;
if (panel != null) {
panel.getFrame().propertyChange(MChangeListener.REFRESH_FUNCTION_IN_TREE, activeFunction);
}
setPanels();
if (panel != null) {
setActiveObject(null);
final java.awt.Point mp = getMousePosition();
if (mp != null)
moveMoveListener.mouseMoved(new MouseEvent(this, 0, 0, 0, mp.x, mp.y, 0, false));
}
functionIndex = dataPlugin.indexOfFunction(activeFunction);
if (functionIndex < 0)
functionIndex = 0;
rec = false;
if (updateListeneres) {
ActiveFunctionEvent event = new ActiveFunctionEvent(activeFunction);
for (ActiveFunctionListener l : getActiveFunctionListeners()) l.activeFunctionChanged(event);
}
if (panel != null) {
panel.getFrame().refreshActions(panel);
}
}
use of com.ramussoft.pb.Stream in project ramus by Vitaliy-Yakovchuk.
the class HTMLHelper method getDiagram.
/*
*
* private static final int IMAGE_WIDTH = 850; private static final int
* IMAGE_HEIGHT = 738;
*/
public String getDiagram(final String sId, final String functionController, final String clasificatorController) {
if (sId == null)
return null;
final Row r = dataPlugin.findRowByGlobalId(GlobalId.convert(sId));
if (r instanceof Function) {
final Function function = (Function) r;
final int imageWidth = IMAGE_WIDTH;
final int imageHeight = IMAGE_HEIGHT;
final DiagramHolder htmlStream = new DiagramHolder();
htmlStream.println("<img border=0 width=" + imageWidth + " height=" + imageHeight + " src=\"" + functionController + "idef0/" + function.getGlobalId().toString() + "\" 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);
final SectorRefactor refactor = area.getRefactor();
for (int i = 0; i < childs.size(); i++) {
final Function fun = (Function) childs.get(i);
String where;
if (fun.isLeaf())
where = clasificatorController;
else
where = functionController + "index/";
htmlStream.print("<area shape=RECT coords=" + getAreaCoords(fun.getBounds(), area) + " href=\"" + where + fun.getGlobalId().toString() + "\"");
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=\"" + clasificatorController + stream.getGlobalId().toString() + "\"");
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=\"" + clasificatorController + stream.getGlobalId().toString() + "\"");
htmlStream.println(">");
}
}
htmlStream.println("<map>");
return htmlStream.toString();
}
return null;
}
use of com.ramussoft.pb.Stream in project ramus by Vitaliy-Yakovchuk.
the class FastMatrixProjection method initArrays.
private void initArrays(final Function parent) {
final Vector sectors = parent.getSectors();
final Vector childs = dataPlugin.getChilds(parent, true);
boolean dfd = parent.getDecompositionType() == MovingArea.DIAGRAM_TYPE_DFD;
Function child;
Sector sector;
Stream stream;
Vector v;
for (int i = 0; i < childs.size(); i++) {
child = (Function) childs.get(i);
v = lefts.get(child.getGlobalId());
if (isOk(child))
for (int j = 0; j < sectors.size(); j++) {
sector = (Sector) sectors.get(j);
stream = sector.getStream();
if (stream != null) {
if (dfd) {
if (type == MovingPanel.RIGHT) {
if (isEqualsStart(sector, child)) {
add(child, sector, stream, v, sector.getStart().getTunnelSoft() == Crosspoint.TUNNEL_SOFT);
}
} else {
if (type == MovingPanel.LEFT)
if (isEqualsEnd(sector, child, type)) {
add(child, sector, stream, v, sector.getEnd().getTunnelSoft() == Crosspoint.TUNNEL_SOFT);
}
}
} else {
if (type == MovingPanel.RIGHT) {
if (isEqualsStart(sector, child)) {
add(child, sector, stream, v, sector.getStart().getTunnelSoft() == Crosspoint.TUNNEL_SOFT);
}
} else if (isEqualsEnd(sector, child, type)) {
add(child, sector, stream, v, sector.getEnd().getTunnelSoft() == Crosspoint.TUNNEL_SOFT);
}
}
}
}
initArrays(child);
}
}
use of com.ramussoft.pb.Stream in project ramus by Vitaliy-Yakovchuk.
the class UserTemplate method createChilds.
public void createChilds(final Function function, final DataPlugin dataPlugin) {
Hashtable<Long, Long> trans = new Hashtable<Long, Long>();
final MovingArea ma = new MovingArea(dataPlugin);
ma.setDataPlugin(dataPlugin);
ma.setActiveFunction(function);
final SectorRefactor refactor = ma.getRefactor();
try {
final ByteArrayInputStream streamr = new ByteArrayInputStream(data);
final ObjectInputStream stream = new ObjectInputStream(streamr);
final MemoryData data = new MemoryData();
int l = DataLoader.readInteger(stream);
for (int i = 0; i < l; i++) {
final Function c = (Function) dataPlugin.createRow(function, true);
c.setName(functionNames.get(i));
if (i < functionTypes.size())
c.setType(functionTypes.get(i));
if (i < functionLinks.size()) {
Row r = dataPlugin.findRowByGlobalId(functionLinks.get(i));
if (r != null) {
if (r instanceof Stream) {
Stream st = (Stream) r;
Stream s = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
s.setAttachedStatus(st.getAttachedStatus());
s.setEmptyName(st.isEmptyName());
s.setRows(st.getAdded());
c.setLink(s.getElement().getId());
}
}
}
final long id = DataLoader.readLong(stream);
trans.put(id, c.getElement().getId());
c.setBounds(DataLoader.readFRectangle(stream));
c.setFont(DataLoader.readFont(stream, data));
c.setBackground(DataLoader.readColor(stream, data));
c.setForeground(DataLoader.readColor(stream, data));
}
// Read version of
final int ver = DataLoader.readInteger(stream);
// Paint
// Sector format
l = DataLoader.readInteger(stream);
HashMap<Sector, List<SectorPointPersistent>> pointsCache = new HashMap<Sector, List<SectorPointPersistent>>();
HashMap<Long, Long> pointIds = new HashMap<Long, Long>();
for (int i = 0; i < l; i++) {
final Sector s = dataPlugin.createSector();
s.setFunction(function);
final long id = DataLoader.readLong(stream);
trans.put(id, ((NSector) s).getElementId());
final byte[] va = DataLoader.readBytes(stream);
s.setVisualAttributes(va);
List<SectorPointPersistent> points = (List) stream.readObject();
pointsCache.put(s, points);
normalize(points, dataPlugin.getEngine(), pointIds);
s.setSectorPointPersistents(points);
s.setSectorProperties((SectorPropertiesPersistent) stream.readObject());
// final byte bs[] = DataLoader.readBytes(stream);
// final ByteArrayInputStream ba = new ByteArrayInputStream(bs);
final PaintSector ps = PaintSector.loadFromSector(ver, ma, data, dataPlugin, s);
refactor.addSector(ps);
Crosspoint c;
if (DataLoader.readBoolean(stream)) {
c = getCrosspoint(dataPlugin, trans, stream);
s.getStart().setCrosspointA(c);
}
loadBorder(s.getStart(), stream, trans, dataPlugin, refactor, ps, true);
s.getStart().commit();
if (DataLoader.readBoolean(stream)) {
c = getCrosspoint(dataPlugin, trans, stream);
s.getEnd().setCrosspointA(c);
}
loadBorder(s.getEnd(), stream, trans, dataPlugin, refactor, ps, false);
s.getEnd().commit();
if (DataLoader.readBoolean(stream)) {
int count = DataLoader.readInteger(stream);
List<Row> rows = new ArrayList<Row>();
for (int j = 0; j < count; j++) {
Row row = loadRow(stream, dataPlugin);
if (row != null)
rows.add(row);
}
if (rows.size() > 0) {
Stream stream2 = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
stream2.setRows(rows.toArray(new Row[rows.size()]));
((NSector) s).setThisStream(stream2);
}
}
}
setPoints(pointsCache);
refactor.saveToFunction();
} catch (final Exception e) {
e.printStackTrace();
}
}
use of com.ramussoft.pb.Stream in project ramus by Vitaliy-Yakovchuk.
the class DFDSRoleOptionsDialog method createFirstTab.
@Override
protected Component createFirstTab(JTabbedPane pane) {
sectorRowsEditor = new SectorRowsEditor(dataPlugin, framework, framework.getAccessRules());
sectorNameEditor = new SectorNameEditor(dataPlugin, framework, framework.getAccessRules()) {
@Override
protected void createReplacementPanel(JPanel ignoreMe) {
}
@Override
public Stream getStream() {
return sectorRowsEditor.getStream();
}
};
sectorNameEditor.box.setVisible(false);
sectorRowsEditor.setSectorNameEditor(sectorNameEditor);
pane.addTab(ResourceLoader.getString("name"), sectorRowsEditor);
return sectorNameEditor;
}
Aggregations