Search in sources :

Example 1 with PStringBounder

use of com.ramussoft.pb.print.PStringBounder 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");
    }
}
Also used : MovingArea(com.ramussoft.pb.idef.visual.MovingArea) PStringBounder(com.ramussoft.pb.print.PStringBounder) SectorRefactor(com.ramussoft.pb.idef.elements.SectorRefactor) MovingLabel(com.ramussoft.pb.idef.visual.MovingLabel) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) FloatPoint(com.dsoft.pb.types.FloatPoint) Point(com.ramussoft.pb.idef.elements.Point) FloatPoint(com.dsoft.pb.types.FloatPoint) Crosspoint(com.ramussoft.pb.Crosspoint) Point(com.ramussoft.pb.idef.elements.Point)

Aggregations

FloatPoint (com.dsoft.pb.types.FloatPoint)1 Crosspoint (com.ramussoft.pb.Crosspoint)1 PaintSector (com.ramussoft.pb.idef.elements.PaintSector)1 Point (com.ramussoft.pb.idef.elements.Point)1 SectorRefactor (com.ramussoft.pb.idef.elements.SectorRefactor)1 MovingArea (com.ramussoft.pb.idef.visual.MovingArea)1 MovingLabel (com.ramussoft.pb.idef.visual.MovingLabel)1 PStringBounder (com.ramussoft.pb.print.PStringBounder)1