use of com.ramussoft.pb.Crosspoint in project ramus by Vitaliy-Yakovchuk.
the class IDLImporter method initCrosspoint.
private void initCrosspoint(NSectorBorder border, String sBorder, MovingArea area, PaintSector ps, boolean start, Arrowseg arrowseg) {
if (sBorder.indexOf("BOX") >= 0) {
String string = getLastWord(sBorder);
Box box = getBox(string);
int type = getType(string);
Crosspoint cp = dataPlugin.createCrosspoint();
border.setCrosspointA(cp);
border.setFunctionTypeA(type);
border.setFunctionA(box.function);
border.commit();
int i = 0;
while (Character.isDigit(string.charAt(i))) i++;
if (box.reference == null) {
area.getRefactor().createSectorOnIn(ps, start);
} else {
Hashtable<String, Crosspoint> h = getConnections(box.function);
h.put(string.substring(i), cp);
}
} else {
int pos = sBorder.indexOf("BORDER");
StringTokenizer st = new StringTokenizer(sBorder.substring(pos));
st.nextToken();
int type = -1;
if (st.hasMoreElements()) {
String string = st.nextToken();
type = getType(string);
Hashtable<String, Crosspoint> h = getConnections(getFunction());
Crosspoint cp = h.get(string);
if (cp == null)
cp = dataPlugin.createCrosspoint();
border.setCrosspointA(cp);
border.setBorderTypeA(type);
border.commit();
} else {
if (start) {
String sink = arrowseg.sink;
int index = sink.indexOf("BORDER");
if (index >= 0) {
StringTokenizer s = new StringTokenizer(sink.substring(index));
s.nextToken();
if (s.hasMoreTokens())
return;
}
type = ps.getPin(0).getWayType();
} else {
if (ps.getSector().getStart().getBorderType() >= 0)
return;
type = ps.getLastPin().getWayType();
}
Crosspoint cp = dataPlugin.createCrosspoint();
border.setCrosspointA(cp);
border.setBorderTypeA(type);
}
}
}
use of com.ramussoft.pb.Crosspoint in project ramus by Vitaliy-Yakovchuk.
the class MovingArea method removeLevel.
/**
* Метод, який видяляє рівень з функціонального блоку
*/
public void removeLevel() {
final Function f = ((MovingFunction) getActiveObject()).getFunction();
if (f.getChildCount() != 1) {
JOptionPane.showMessageDialog(this, ResourceLoader.getString("MovingArea.functionHaveNotOneChild"));
return;
}
Vector<Row> childs = dataPlugin.getChilds(f, true);
if (childs.size() != 1)
return;
final Function c = (Function) childs.get(0);
if (f.isLocked() || c.isLocked()) {
JOptionPane.showMessageDialog(this, ResourceLoader.getString("MovingArea.functionIsLocked"));
return;
}
if (!checkRemoveLevelFunction(c)) {
JOptionPane.showMessageDialog(this, ResourceLoader.getString("MovingArea.removingLevelSectorError"));
return;
}
if (JOptionPane.showConfirmDialog(this, ResourceLoader.getString("MovingArea.removingLevelWarning"), ResourceLoader.getString("warning"), JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION)
return;
f.lock();
c.lock();
startUserTransaction();
Vector<Sector> sectors = new Vector<Sector>(f.getSectors());
for (int i = 0; i < sectors.size(); i++) {
final Sector sector = sectors.get(i);
Crosspoint opp;
Crosspoint crosspoint;
if (c.equals(sector.getStart().getFunction())) {
opp = sector.getStart().getCrosspoint();
crosspoint = sector.getEnd().getCrosspoint();
} else {
opp = sector.getEnd().getCrosspoint();
crosspoint = sector.getStart().getCrosspoint();
}
Sector o = null;
final Sector[] os = opp.getOppozite(sector);
for (final Sector s : os) o = s;
class X {
int createState;
double createPos;
Stream stream;
byte[] visual;
int sBorderType;
int eBorderType;
}
X x = null;
if (o != null && (o.getStart().getCrosspoint() == null || o.getEnd().getCrosspoint() == null)) {
x = new X();
x.createState = o.getCreateState();
x.createPos = o.getCreatePos();
x.stream = o.getStream();
x.visual = o.getVisualAttributes();
x.sBorderType = o.getStart().getBorderType();
x.eBorderType = o.getEnd().getBorderType();
}
sector.remove();
if (x != null) {
o = dataPlugin.createSector();
o.setCreateState(x.createState, x.createPos);
((AbstractSector) o).setThisStream(x.stream);
o.setVisualAttributes(x.visual);
o.setFunction(c);
o.getStart().setBorderTypeA(x.sBorderType);
o.getEnd().setBorderTypeA(x.eBorderType);
o.getStart().commit();
o.getEnd().commit();
}
if (o != null) {
if (c.equals(sector.getStart().getFunction())) {
o.getEnd().setCrosspointA(crosspoint);
o.getEnd().commit();
} else {
o.getStart().setCrosspointA(crosspoint);
o.getEnd().commit();
}
}
}
sectors = new Vector<Sector>(c.getSectors());
for (int i = 0; i < sectors.size(); i++) {
final Sector sector = sectors.get(i);
sector.setFunction(f);
}
f.setSectorData(c.getSectorData());
c.setSectorData(new byte[0]);
childs = dataPlugin.getChilds(c, true);
for (int i = 0; i < childs.size(); i++) {
final Function c1 = (Function) childs.get(i);
c1.setParentRow(f);
}
c.unlock();
if (!dataPlugin.removeRow(c)) {
JOptionPane.showMessageDialog(this, ResourceLoader.getString("MovingArea.cantRemoveFunctionByRemovingLevel"));
}
f.unlock();
if (panel != null)
panel.getFrame().propertyChange(MChangeListener.RELOAD_FUNCTION_IN_TREE, dataPlugin.getBaseFunction());
commitUserTransaction();
}
use of com.ramussoft.pb.Crosspoint in project ramus by Vitaliy-Yakovchuk.
the class SectorRefactor method getStreamedSectors.
public void getStreamedSectors(final Sector sector, final Crosspoint point, final HashSet v, final boolean streamed) {
if (point == null)
return;
final Sector[] sectors = point.getOppozite(sector);
for (int i = 0; i < getSectorsCount(); i++) {
final PaintSector s = getSector(i);
if (isIn(s, sectors)) {
if (streamed)
if (sector.getStream() == null || !equalsStreams(sector.getStream(), s.getStream()))
continue;
if (!v.contains(s) && s.getFunction().equals(sector.getFunction())) {
v.add(s);
getStreamedSectors(s, v);
}
}
}
}
use of com.ramussoft.pb.Crosspoint in project ramus by Vitaliy-Yakovchuk.
the class SectorRefactor method createMiss.
private Sector createMiss(final PerspectivePoint point) {
if (point.functionType >= 0) {
point.crosspoint = getDataPlugin().createCrosspoint();
double inPos;
if (point.functionType == MovingPanel.LEFT || point.functionType == MovingPanel.RIGHT)
inPos = point.point.getY();
else
inPos = point.point.getX();
return createPartIn(point.crosspoint, point.function, point.functionType, inPos, point.type == TYPE_END);
} else if (point.borderType == -1) {
// Tochka na inshomu sektory
final PaintSector.Pin pin = point.pin;
final double x = point.x;
final double y = point.y;
double oX;
double oY;
double opX;
double opY;
final boolean start = point.type == TYPE_START;
if (start) {
oX = pointA.x;
oY = pointA.y;
opX = pointB.getX();
opY = pointB.getY();
} else {
opX = pointA.getX();
opY = pointA.getY();
oX = pointB.x;
oY = pointB.y;
}
final Point p = new Point();
if (pin.isNearStart(x, y) && pin.isFirst()) {
final Crosspoint crosspoint = pin.getSector().getStart();
if (crosspoint.isCanAddOut() && point.type == TYPE_START || crosspoint.isCanAddIn() && point.type == TYPE_END) {
final int type = pin.getStart().isCanConnected(opX, opY);
if (type >= 0) {
p.setType(type);
p.setXOrdinate(pin.getStart().getXOrdinate());
p.setYOrdinate(pin.getStart().getYOrdinate());
point.crosspoint = crosspoint;
point.point = p;
return null;
}
}
} else if (pin.isNearEnd(x, y) && pin.isEnd()) {
final Crosspoint crosspoint = pin.getSector().getEnd();
if (crosspoint.isCanAddOut() && point.type == TYPE_START || crosspoint.isCanAddIn() && point.type == TYPE_END) {
final int type = pin.getEnd().isCanConnected(opX, opY);
if (type >= 0) {
p.setType(type);
p.setXOrdinate(pin.getEnd().getXOrdinate());
p.setYOrdinate(pin.getEnd().getYOrdinate());
point.crosspoint = crosspoint;
point.point = p;
return null;
}
}
}
final PaintSector sector = pin.getSector();
final SplitSectorType sst = sector.splitSector(pin, new FloatPoint(point.x, point.y), oX, oY, opX, opY, start);
final PaintSector aSector = sst.paintSector;
point.crosspoint = sector.getEnd();
point.point = new Point(sector.getEndPoint().getXOrdinate(), sector.getEndPoint().getYOrdinate());
point.point.setType(sst.type);
tryRemoveText(aSector);
tryRemoveText(sector);
addSector(aSector);
} else {
// TOCHKA NA KRAU
createBorderPoints(point, function);
}
return null;
}
use of com.ramussoft.pb.Crosspoint in project ramus by Vitaliy-Yakovchuk.
the class SectorRefactor method createPartOut.
/**
* Метод свторює сектор зверху на функціональному блоці.
*
* @param point Точка на краю активного функціоналоноко блоку (констук якого
* показується).
* @param function Активний функціональний блок.
* @param functionType Край, на якому знаходиться тока.
*/
private Sector createPartOut(final Crosspoint point, final Function function, final int functionType, final double outPos, boolean start) {
if (functionType < 0) {
JOptionPane.showMessageDialog(null, "Не виправлена " + "помилка тунулювання.");
return null;
}
final Function par = (Function) function.getParent();
if (par == null)
return null;
// PerspectivePoint ppPoint = null;
final Sector sector = getDataPlugin().createSector();
sector.setFunction(par);
/* if (par.getDecompositionType() == MovingArea.DIAGRAM_TYPE_DFDS) {
ppPoint = new PerspectivePoint();
ppPoint.x = function.getBounds().getX() + outPos
/ movingArea.CLIENT_WIDTH * function.getBounds().getWidth();
ppPoint.y = outPos;
ppPoint.borderType = functionType;
createBorderPoints(ppPoint, par);
}*/
final Crosspoint op = getDataPlugin().createCrosspoint();
if (start) {
sector.getStart().setCrosspointA(point);
sector.getStart().setFunctionA(function);
sector.getStart().setFunctionTypeA(functionType);
sector.getEnd().setCrosspointA(op);
/*if (par.getDecompositionType() == MovingArea.DIAGRAM_TYPE_DFDS) {
sector.getEnd().setFunctionA(ppPoint.function);
sector.getEnd().setFunctionTypeA(
MovingPanel.getOpposite(functionType));
} else*/
sector.getEnd().setBorderTypeA(functionType);
} else {
sector.getEnd().setCrosspointA(point);
sector.getEnd().setFunctionA(function);
sector.getEnd().setFunctionTypeA(functionType);
sector.getStart().setCrosspointA(op);
/*if (par.getDecompositionType() == MovingArea.DIAGRAM_TYPE_DFDS) {
sector.getStart().setFunctionA(ppPoint.function);
sector.getStart().setFunctionTypeA(
MovingPanel.getOpposite(functionType));
} else*/
sector.getStart().setBorderTypeA(functionType);
}
sector.getStart().commit();
sector.getEnd().commit();
PaintSector.save(createOutPaintPart(sector, outPos), new DataLoader.MemoryData(), movingArea.getDataPlugin().getEngine());
return sector;
}
Aggregations