use of com.ramussoft.pb.idef.visual.MovingLabel in project ramus by Vitaliy-Yakovchuk.
the class SectorRefactor method updatePageSize.
public void updatePageSize(boolean updateFonts, boolean updateZoom, double percent, Function function) {
if (updateZoom) {
function.setBounds(function.getBounds().zoom(percent));
}
if (updateFonts) {
Font font = function.getFont();
if (font != null) {
function.setFont(new Font(font.getName(), font.getStyle(), (int) (font.getSize() * percent)));
}
}
if (function.getChildCount() == 0)
return;
if (updateZoom) {
loadFromFunction(function, false);
for (MovingText text : texts) {
if (text instanceof IDEF0Object) {
} else {
// text.setBounds(text.getBounds().zoom(percent));
}
}
HashSet<Ordinate> ordinates = new HashSet<Ordinate>();
for (PaintSector paintSector : sectors) {
for (int i = 0; i < paintSector.getPointCount(); i++) {
Point point = paintSector.getPoint(i);
if (!ordinates.contains(point.getXOrdinate()))
ordinates.add(point.getXOrdinate());
if (!ordinates.contains(point.getYOrdinate()))
ordinates.add(point.getYOrdinate());
}
MovingLabel movingLabel = paintSector.getText();
if (movingLabel != null) {
movingLabel.setBounds(movingLabel.getBounds().zoom(percent));
Font font = movingLabel.getFont();
movingLabel.setFont(new Font(font.getName(), font.getStyle(), (int) (font.getSize() * percent)));
}
Font font = paintSector.getFont();
if (font != null) {
paintSector.setFont(new Font(font.getName(), font.getStyle(), (int) (font.getSize() * percent)));
paintSector.saveVisual();
}
}
for (Ordinate o : ordinates) {
o.setPosition(percent * o.getPosition());
}
for (PaintSector paintSector : sectors) {
for (int i = 0; i < paintSector.getPointCount(); i++) {
if (paintSector.getSector().getEnd().getBorderType() == Point.BOTTOM) {
Point point = paintSector.getEndPoint();
point.getYOrdinate().setPosition(movingArea.CLIENT_HEIGHT - 7);
} else if (paintSector.getSector().getStart().getBorderType() == Point.BOTTOM) {
Point point = paintSector.getStartPoint();
point.getYOrdinate().setPosition(movingArea.CLIENT_HEIGHT - 7);
}
if (paintSector.getSector().getEnd().getBorderType() == Point.TOP) {
Point point = paintSector.getEndPoint();
point.getYOrdinate().setPosition(7);
} else if (paintSector.getSector().getStart().getBorderType() == Point.TOP) {
Point point = paintSector.getStartPoint();
point.getYOrdinate().setPosition(7);
}
if (paintSector.getSector().getEnd().getBorderType() == Point.LEFT) {
Point point = paintSector.getEndPoint();
point.getXOrdinate().setPosition(7);
} else if (paintSector.getSector().getStart().getBorderType() == Point.LEFT) {
Point point = paintSector.getStartPoint();
point.getXOrdinate().setPosition(7);
}
if (paintSector.getSector().getEnd().getBorderType() == Point.RIGHT) {
Point point = paintSector.getEndPoint();
point.getXOrdinate().setPosition(movingArea.CLIENT_WIDTH - 7);
} else if (paintSector.getSector().getStart().getBorderType() == Point.RIGHT) {
Point point = paintSector.getStartPoint();
point.getXOrdinate().setPosition(movingArea.CLIENT_WIDTH - 7);
}
}
}
saveToFunction();
}
}
use of com.ramussoft.pb.idef.visual.MovingLabel in project ramus by Vitaliy-Yakovchuk.
the class IDLExporter method printSegments.
protected void printSegments(Function f) throws IOException {
MovingArea movingArea = new MovingArea(dataPlugin, f);
movingArea.setActiveFunction(f);
SectorRefactor sr = movingArea.getRefactor();
for (int i = 0; i < sr.getSectorsCount(); i++) {
PaintSector ps = sr.getSector(i);
writer.p1("ARROWSEG " + (i + 1));
writer.right();
writer.p1("SOURCE " + getName(ps.getSector().getStart(), f, ps.getSector(), sr, ps.getPoint(0)));
StringBuffer path = new StringBuffer();
path.append("PATH ");
for (int j = 0; j < ps.getPointCount(); j++) {
Point point = ps.getPoint(j);
path.append(toCoortinate(point.getX(), point.getY()));
}
writer.p1(path.toString());
String s = ps.getAlternativeText();
if ("".equals(s))
s = ps.getSector().getName();
if ((s != null) && (s.length() > 0)) {
MovingLabel text = ps.getText();
if (text != null) {
final PStringBounder nb = new PStringBounder(null);
nb.setFont(text.getFont());
final PStringBounder.Tokanizer tokanizer = nb.getTokanizer(s, text.getBounds().getWidth(), 0);
StringBuffer sb = new StringBuffer();
if (tokanizer.hasMoreData())
sb.append(tokanizer.getNext());
while (tokanizer.hasMoreData()) {
sb.append("<CR>");
sb.append(tokanizer.getNext());
}
writer.p2("LABEL {0}", "{LWI I 0 " + toByteTextIndex(text.getColor()) + " " + toByteTextIndex(text.getColor()) + " }" + sb.toString());
writer.p1("LABEL COORDINATES " + toCoortinate(ps.getText().getBounds().getX(), ps.getText().getBounds().getCenter().getY()));
if (ps.isShowTilda()) {
writer.p1("SQUIGGLE COORDINATES " + toCoortinate(ps.getTildaOPoint()) + " " + toCoortinate(ps.getTildaPoint()));
}
} else
writer.p2("LABEL {0}", s);
}
writer.p1("SINK " + getName(ps.getSector().getEnd(), f, ps.getSector(), sr, ps.getPoint(ps.getPointCount() - 1)));
writer.left();
writer.p1("ENDSEG");
}
}
use of com.ramussoft.pb.idef.visual.MovingLabel 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.visual.MovingLabel 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.visual.MovingLabel 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;
}
Aggregations