use of com.ramussoft.pb.idef.elements.Point in project ramus by Vitaliy-Yakovchuk.
the class IDLImporter method createSegment.
private void createSegment(Arrowseg seg, MovingArea area) {
SectorRefactor sr = area.getRefactor();
Sector s = plugin.createSector();
Function f = getFunction();
s.setFunction(f);
PaintSector ps = new PaintSector();
ps.setSector(s);
ps.setMovingArea(area);
sr.addSector(ps);
seg.sector = ps;
ArrayList<FloatPoint> list = new ArrayList<FloatPoint>();
StringTokenizer st = new StringTokenizer(seg.path, "() ");
while (st.hasMoreElements()) list.add(toPoint(st.nextToken()));
seg.pointsList = list;
String text = seg.getText();
if ((text != null) && (text.length() > 0)) {
s.setStream(getStream(text), ReplaceStreamType.CHILDREN);
if (seg.coordinates != null) {
MovingLabel label = new MovingLabel(area);
StringTokenizer st2 = new StringTokenizer(seg.coordinates, "()");
FloatPoint point = toPoint(st2.nextToken());
label.getBounds().setX(point.getX());
label.getBounds().setY(point.getY() - 10);
label.setText(text);
ps.setText(label);
if (seg.squiggleCoordinates != null) {
ps.setShowTilda(true);
}
}
if (seg.label.startsWith("{")) {
StringTokenizer st2 = new StringTokenizer(seg.label, " ");
st2.nextElement();
st2.nextElement();
try {
int font = Integer.parseInt(st2.nextToken());
if (font < uniqueFonts.size())
ps.setFont(uniqueFonts.get(font));
} catch (Exception e) {
}
int color = Integer.parseInt(st2.nextToken());
if (color < COLORS.length)
ps.setColor(COLORS[color]);
}
}
}
use of com.ramussoft.pb.idef.elements.Point in project ramus by Vitaliy-Yakovchuk.
the class IDEF0Object method setAddedSectorPosWC.
/**
* Метод організовує зміни в секторі, що виходить або входить в
* функціональний блок.
*
* @param oldRec Старі властивості розмірів функціонального блоку.
* @param sector Сектор прив’язаний до функціонального блоку.
*/
public boolean setAddedSectorPosWC(final FRectangle oldRec, final PaintSector sector, List<Ordinate> ordinates) {
boolean res = false;
final FRectangle currRec = function.getBounds();
if (function.equals(sector.getSector().getStart().getFunction())) {
final Point p = sector.getStartPoint();
if (!p.isMoveable(currRec.getRight(), Ordinate.TYPE_X)) {
sector.regeneratePoints();
addOrdinates(sector, ordinates);
}
double t = currRec.getY() + currRec.getHeight() * (p.getY() - oldRec.getY()) / oldRec.getHeight();
if (!p.isMoveable(t, Ordinate.TYPE_Y)) {
if (sector.getPinCount() == 1)
p.setYOrdinate(new Ordinate(Ordinate.TYPE_Y));
p.setY(t);
sector.regeneratePoints();
addOrdinates(sector, ordinates);
} else {
p.setY(t);
addOrdinate(ordinates, p.getYOrdinate());
}
if (sector.getSector().getStart().getFunctionType() == MovingPanel.RIGHT) {
p.setX(getX(t, false, currRec));
addOrdinate(ordinates, p.getXOrdinate());
} else if (sector.getSector().getStart().getFunctionType() == MovingPanel.LEFT) {
p.setX(getX(t, true, currRec));
addOrdinate(ordinates, p.getXOrdinate());
} else {
t = currRec.getX() + currRec.getWidth() * (p.getX() - oldRec.getX()) / oldRec.getWidth();
if (sector.getSector().getStart().getFunctionType() == MovingPanel.TOP) {
p.setY(getY(t, true, currRec));
} else {
p.setY(getY(t, false, currRec));
}
addOrdinate(ordinates, p.getYOrdinate());
if (!p.isMoveable(t, Ordinate.TYPE_X)) {
p.setXOrdinate(new Ordinate(Ordinate.TYPE_X));
p.setX(t);
sector.regeneratePoints();
addOrdinates(sector, ordinates);
} else {
p.setX(t);
addOrdinate(ordinates, p.getXOrdinate());
}
fixCuttedEnd(sector);
return true;
}
res = true;
fixCuttedEnd(sector);
}
if (function.equals(sector.getSector().getEnd().getFunction())) {
final Point p = sector.getEndPoint();
if (sector.getSector().getEnd().getFunctionType() == MovingPanel.LEFT) {
if (!p.isMoveable(currRec.getLeft(), Ordinate.TYPE_X)) {
sector.regeneratePoints();
addOrdinates(sector, ordinates);
}
final double t = currRec.getY() + currRec.getHeight() * (p.getY() - oldRec.getY()) / oldRec.getHeight();
p.setX(getX(t, true, currRec));
addOrdinate(ordinates, p.getXOrdinate());
if (!p.isMoveable(t, Ordinate.TYPE_Y)) {
if (sector.getPinCount() == 1)
p.setYOrdinate(new Ordinate(Ordinate.TYPE_Y));
p.setY(t);
sector.regeneratePoints();
addOrdinates(sector, ordinates);
} else {
p.setY(t);
addOrdinate(ordinates, p.getYOrdinate());
}
} else if (sector.getSector().getEnd().getFunctionType() == MovingPanel.RIGHT) {
if (!p.isMoveable(currRec.getLeft(), Ordinate.TYPE_X)) {
sector.regeneratePoints();
addOrdinates(sector, ordinates);
}
final double t = currRec.getY() + currRec.getHeight() * (p.getY() - oldRec.getY()) / oldRec.getHeight();
p.setX(getX(t, false, currRec));
addOrdinate(ordinates, p.getXOrdinate());
if (!p.isMoveable(t, Ordinate.TYPE_Y)) {
if (sector.getPinCount() == 1)
p.setYOrdinate(new Ordinate(Ordinate.TYPE_Y));
p.setY(t);
sector.regeneratePoints();
addOrdinates(sector, ordinates);
} else {
p.setY(t);
addOrdinate(ordinates, p.getYOrdinate());
}
} else {
final double t = currRec.getX() + currRec.getWidth() * (p.getX() - oldRec.getX()) / oldRec.getWidth();
if (sector.getSector().getEnd().getFunctionType() == MovingPanel.TOP) {
p.setY(getY(t, true, currRec));
if (!p.isMoveable(currRec.getTop(), Ordinate.TYPE_Y)) {
sector.regeneratePoints();
addOrdinates(sector, ordinates);
} else
addOrdinate(ordinates, p.getYOrdinate());
} else {
p.setY(getY(t, false, currRec));
if (!p.isMoveable(currRec.getBottom(), Ordinate.TYPE_Y)) {
sector.regeneratePoints();
addOrdinates(sector, ordinates);
} else
addOrdinate(ordinates, p.getYOrdinate());
}
if (!p.isMoveable(t, Ordinate.TYPE_X)) {
p.setXOrdinate(new Ordinate(Ordinate.TYPE_X));
p.setX(t);
sector.regeneratePoints();
addOrdinates(sector, ordinates);
} else {
p.setX(t);
addOrdinate(ordinates, p.getXOrdinate());
}
}
res = true;
fixCuttedStart(sector);
}
sector.tryRemovePin(movingArea);
return res;
}
use of com.ramussoft.pb.idef.elements.Point in project ramus by Vitaliy-Yakovchuk.
the class IDEF0Object method mouseMoved.
/*
* (non-Javadoc)
*
* @seecom.jason.clasificators.frames.idf.MovingPanel#mouseMoved(com.jason.
* clasificators.frames.idf.FloatPoint)
*/
@Override
public int mouseMoved(final FloatPoint point) {
super.mouseMoved(point);
int res;
if ((movingArea.getChangingState() == MovingArea.ARROW_CHANGING_STATE) && (movingArea.isOkForCross()))
res = getTriangle(point);
else
res = -1;
if (res != paintTriangle) {
paintTriangle = res;
movingArea.repaintAsync();
}
return paintTriangle;
}
use of com.ramussoft.pb.idef.elements.Point in project ramus by Vitaliy-Yakovchuk.
the class MovingArea method fillMovingArea.
private void fillMovingArea() {
final SectorRefactor.PerspectivePoint pp = new SectorRefactor.PerspectivePoint();
pp.x = mp.x;
pp.y = mp.y;
if (getPointChangingType() == SectorRefactor.TYPE_END) {
pp.borderType = MovingFunction.RIGHT;
PerspectivePoint point = refactor.getPoint(SectorRefactor.TYPE_START);
if (point != null)
pp.y = point.y;
} else {
pp.borderType = MovingFunction.LEFT;
PerspectivePoint point = refactor.getPoint(SectorRefactor.TYPE_END);
if (point != null)
pp.y = point.y;
}
int pointChangingType = getPointChangingType();
pp.type = pointChangingType;
refactor.setPoint(pp);
}
use of com.ramussoft.pb.idef.elements.Point in project ramus by Vitaliy-Yakovchuk.
the class DFDFunctionEllipse method getTriangle.
protected int getTriangle(final FloatPoint point) {
int res = -1;
FloatPoint l = getLocation();
for (int type = MovingPanel.RIGHT; type <= MovingPanel.TOP; type++) {
GeneralPath gp = getTrianglePath(type);
double y = point.getY() + l.getY();
double x = point.getX() + l.getX();
if (gp.contains(new Point2D.Double(x, y))) {
res = type;
break;
}
}
return res;
}
Aggregations