X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.g2d%2Fsrc%2Forg%2Fsimantics%2Fg2d%2Futils%2Fgeom%2FLineSegment.java;h=dec858851ba03223212500ef23b50a11556fe0b2;hb=27f08248fa2471dab6bce315387b9617fcfeb1ea;hp=6e52dfafbff37ebf189bee65aa7c8978dcf91608;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/utils/geom/LineSegment.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/utils/geom/LineSegment.java index 6e52dfafb..dec858851 100644 --- a/bundles/org.simantics.g2d/src/org/simantics/g2d/utils/geom/LineSegment.java +++ b/bundles/org.simantics.g2d/src/org/simantics/g2d/utils/geom/LineSegment.java @@ -1,114 +1,114 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.g2d.utils.geom; - -import java.awt.Rectangle; -import java.awt.Shape; -import java.awt.geom.AffineTransform; -import java.awt.geom.PathIterator; -import java.awt.geom.Point2D; -import java.awt.geom.Rectangle2D; -import java.util.Arrays; - -/** - * Describes a line segment, either linear, quadratic or cubic - * - * @author Toni Kalajainen - */ -public class LineSegment implements Shape { - private double line[]; - public LineSegment(double x0, double y0, double x1, double y1) - { - line = new double[] {x0, y0, x1, y1}; - } - public LineSegment(double x0, double y0, double x1, double y1, double x2, double y2) - { - line = new double[] {x0, y0, x1, y1, x2, y2}; - } - public LineSegment(double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3) - { - line = new double[] {x0, y0, x1, y1, x2, y2, x3, y3}; - } - public LineSegment(double data[]) - { - assert(data.length==4 || data.length==6 || data.length==8); - line = Arrays.copyOf(data, data.length); - } - public double[] getLine() { - return line; - } - public int getDegree() { - return (line.length-2)/2; - } - public Point2D getStartPos(Point2D pt) - { - if (pt==null) return new Point2D.Double(line[0], line[1]); - pt.setLocation(line[0], line[1]); - return pt; - } - public Point2D getEndPos(Point2D pt) - { - int p = line.length-2; - if (pt==null) return new Point2D.Double(line[p], line[p+1]); - pt.setLocation(line[p], line[p+1]); - return pt; - } - public void setData(double data[]) - { - assert(data.length==4 || data.length==6 || data.length==8); - line = Arrays.copyOf(data, data.length); - } - - - - @Override - public boolean contains(Point2D p) { - return false; - } - @Override - public boolean contains(Rectangle2D r) { - return false; - } - @Override - public boolean contains(double x, double y) { - return false; - } - @Override - public boolean contains(double x, double y, double w, double h) { - return false; - } - @Override - public Rectangle getBounds() { - return null; - } - @Override - public Rectangle2D getBounds2D() { - return null; - } - @Override - public PathIterator getPathIterator(AffineTransform at) { - return null; - } - @Override - public PathIterator getPathIterator(AffineTransform at, double flatness) { - return null; - } - @Override - public boolean intersects(Rectangle2D r) { - return false; - } - @Override - public boolean intersects(double x, double y, double w, double h) { - return false; - } -} - +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.g2d.utils.geom; + +import java.awt.Rectangle; +import java.awt.Shape; +import java.awt.geom.AffineTransform; +import java.awt.geom.PathIterator; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.util.Arrays; + +/** + * Describes a line segment, either linear, quadratic or cubic + * + * @author Toni Kalajainen + */ +public class LineSegment implements Shape { + private double line[]; + public LineSegment(double x0, double y0, double x1, double y1) + { + line = new double[] {x0, y0, x1, y1}; + } + public LineSegment(double x0, double y0, double x1, double y1, double x2, double y2) + { + line = new double[] {x0, y0, x1, y1, x2, y2}; + } + public LineSegment(double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3) + { + line = new double[] {x0, y0, x1, y1, x2, y2, x3, y3}; + } + public LineSegment(double data[]) + { + assert(data.length==4 || data.length==6 || data.length==8); + line = Arrays.copyOf(data, data.length); + } + public double[] getLine() { + return line; + } + public int getDegree() { + return (line.length-2)/2; + } + public Point2D getStartPos(Point2D pt) + { + if (pt==null) return new Point2D.Double(line[0], line[1]); + pt.setLocation(line[0], line[1]); + return pt; + } + public Point2D getEndPos(Point2D pt) + { + int p = line.length-2; + if (pt==null) return new Point2D.Double(line[p], line[p+1]); + pt.setLocation(line[p], line[p+1]); + return pt; + } + public void setData(double data[]) + { + assert(data.length==4 || data.length==6 || data.length==8); + line = Arrays.copyOf(data, data.length); + } + + + + @Override + public boolean contains(Point2D p) { + return false; + } + @Override + public boolean contains(Rectangle2D r) { + return false; + } + @Override + public boolean contains(double x, double y) { + return false; + } + @Override + public boolean contains(double x, double y, double w, double h) { + return false; + } + @Override + public Rectangle getBounds() { + return null; + } + @Override + public Rectangle2D getBounds2D() { + return null; + } + @Override + public PathIterator getPathIterator(AffineTransform at) { + return null; + } + @Override + public PathIterator getPathIterator(AffineTransform at, double flatness) { + return null; + } + @Override + public boolean intersects(Rectangle2D r) { + return false; + } + @Override + public boolean intersects(double x, double y, double w, double h) { + return false; + } +} +