Examples of DXFMLineStyle


Examples of org.kabeja.dxf.objects.DXFMLineStyle

import org.kabeja.math.MathUtils;


public class MLineConverter {
    public static DXFPolyline[] toDXFPolyline(DXFMLine mline) {
        DXFMLineStyle style = (DXFMLineStyle) mline.getDXFDocument()
                                                   .getDXFObjectByID(mline.getMLineStyleID());

        // style
        // .sortDXFMLineStyleElements(new
        // DXFMLineStyleElementDistanceComparator());

        // initialize polylines
        DXFPolyline[] pl = new DXFPolyline[style.getDXFMLineStyleLElementCount()];

        for (int x = 0; x < pl.length; x++) {
            DXFMLineStyleElement se = style.getDXFMLineStyleLElement(x);
            pl[x] = new DXFPolyline();
            pl[x].setDXFDocument(mline.getDXFDocument());
            pl[x].setLineType(se.getLineType());
            pl[x].setColor(se.getLineColor());

            if (mline.isClosed()) {
                pl[x].setFlags(1);
            }
        }

        Vector v = new Vector();
        Vector d = new Vector();
        ParametricLine l = new ParametricLine();
        ParametricLine miter = new ParametricLine();

        for (int i = 0; i < mline.getDXFMLineSegmentCount(); i++) {
            DXFMLineSegment seg = mline.getDXFMLineSegment(i);

            v = seg.getDirection();
            d = seg.getMiterDirection();
            miter.setStartPoint(seg.getStartPoint());
            miter.setDirectionVector(d);

            for (int x = 0; x < seg.getDXFMLineSegmentElementCount(); x++) {
                DXFMLineSegmentElement segEl = seg.getDXFMLineSegmentElement(x);
                double[] le = segEl.getLengthParameters();
                Point s = miter.getPointAt(le[0]);
                l.setStartPoint(s);
                l.setDirectionVector(v);
                pl[x].addVertex(new DXFVertex(l.getPointAt(le[1])));
            }
        }

        if (style.hasEndRoundCaps()) {
            Point p1 = pl[0].getVertex(pl[0].getVertexCount() - 1).getPoint();
            Point p2 = pl[pl.length - 1].getVertex(pl[pl.length - 1].getVertexCount() -
                    1).getPoint();
            Vector v1 = MathUtils.getVector(p1, p2);
            double distance = v1.getLength();
View Full Code Here

Examples of org.kabeja.dxf.objects.DXFMLineStyle

            super.parseCommonGroupCode(groupCode, value, this.style);
        }
    }

    public void startObject() {
        this.style = new DXFMLineStyle();
        this.processLineElement = false;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.