Java Code Examples for java.awt.geom.IllegalPathStateException

The following are top voted examples for showing how to use java.awt.geom.IllegalPathStateException. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: jdk8u-jdk   File: Path2DCopyConstructor.java   View source code 8 votes vote down vote up
static void testAddClose(Path2D pathA, boolean isEmpty) {
    try {
        addClose(pathA);
    }
    catch (IllegalPathStateException ipse) {
        if (isEmpty) {
            log("testAddClose: passed "
                + "(expected IllegalPathStateException catched).");
            return;
        } else {
            throw ipse;
        }
    }
    if (isEmpty) {
        throw new IllegalStateException("IllegalPathStateException not thrown !");
    }
    log("testAddClose: passed.");
}
 
Example 2
Project: openjdk-jdk10   File: Path2DCopyConstructor.java   View source code 7 votes vote down vote up
static void testAddLine(Path2D pathA, boolean isEmpty) {
    try {
        addLines(pathA);
    }
    catch (IllegalPathStateException ipse) {
        if (isEmpty) {
            log("testAddLine: passed "
                + "(expected IllegalPathStateException catched).");
            return;
        } else {
            throw ipse;
        }
    }
    if (isEmpty) {
        throw new IllegalStateException("IllegalPathStateException not thrown !");
    }
    log("testAddLine: passed.");
}
 
Example 3
Project: openjdk-jdk10   File: Path2DCopyConstructor.java   View source code 7 votes vote down vote up
static void testAddQuad(Path2D pathA, boolean isEmpty) {
    try {
        addQuads(pathA);
    }
    catch (IllegalPathStateException ipse) {
        if (isEmpty) {
            log("testAddQuad: passed "
                + "(expected IllegalPathStateException catched).");
            return;
        } else {
            throw ipse;
        }
    }
    if (isEmpty) {
        throw new IllegalStateException("IllegalPathStateException not thrown !");
    }
    log("testAddQuad: passed.");
}
 
Example 4
Project: openjdk-jdk10   File: Path2DCopyConstructor.java   View source code 7 votes vote down vote up
static void testAddCubic(Path2D pathA, boolean isEmpty) {
    try {
        addCubics(pathA);
    }
    catch (IllegalPathStateException ipse) {
        if (isEmpty) {
            log("testAddCubic: passed "
                + "(expected IllegalPathStateException catched).");
            return;
        } else {
            throw ipse;
        }
    }
    if (isEmpty) {
        throw new IllegalStateException("IllegalPathStateException not thrown !");
    }
    log("testAddCubic: passed.");
}
 
Example 5
Project: WebPLP   File: PLPProject.java   View source code 6 votes vote down vote up
/**
 * Validates the given file to be a directory, and throws an exception if the given
 * file is not a directory, or if the file is null.
 * 
 * @param projectDirectory
 *            File to validate
 */
private static void validateProjectDirectory(File projectDirectory)
{
	if (projectDirectory == null)
	{
		throw new IllegalArgumentException("Directory must be non-null");
	}
	// When creating project, the directory has not been created yet so always throws
	// error
	else
	{
		//moved this
		if (!projectDirectory.exists())
			projectDirectory.mkdir();
		
		if (!projectDirectory.isDirectory())
		
		{
			String path = projectDirectory.getAbsolutePath();
			String message = "Path must point to a directory. Found: " + path;
			throw new IllegalPathStateException(message);
		}
	}
}
 
Example 6
Project: jdk8u-jdk   File: Path2DCopyConstructor.java   View source code 6 votes vote down vote up
static void testAddLine(Path2D pathA, boolean isEmpty) {
    try {
        addLines(pathA);
    }
    catch (IllegalPathStateException ipse) {
        if (isEmpty) {
            log("testAddLine: passed "
                + "(expected IllegalPathStateException catched).");
            return;
        } else {
            throw ipse;
        }
    }
    if (isEmpty) {
        throw new IllegalStateException("IllegalPathStateException not thrown !");
    }
    log("testAddLine: passed.");
}
 
Example 7
Project: jdk8u-jdk   File: Path2DCopyConstructor.java   View source code 6 votes vote down vote up
static void testAddQuad(Path2D pathA, boolean isEmpty) {
    try {
        addQuads(pathA);
    }
    catch (IllegalPathStateException ipse) {
        if (isEmpty) {
            log("testAddQuad: passed "
                + "(expected IllegalPathStateException catched).");
            return;
        } else {
            throw ipse;
        }
    }
    if (isEmpty) {
        throw new IllegalStateException("IllegalPathStateException not thrown !");
    }
    log("testAddQuad: passed.");
}
 
Example 8
Project: jdk8u-jdk   File: Path2DCopyConstructor.java   View source code 6 votes vote down vote up
static void testAddCubic(Path2D pathA, boolean isEmpty) {
    try {
        addCubics(pathA);
    }
    catch (IllegalPathStateException ipse) {
        if (isEmpty) {
            log("testAddCubic: passed "
                + "(expected IllegalPathStateException catched).");
            return;
        } else {
            throw ipse;
        }
    }
    if (isEmpty) {
        throw new IllegalStateException("IllegalPathStateException not thrown !");
    }
    log("testAddCubic: passed.");
}
 
Example 9
Project: openjdk-jdk10   File: Path2DCopyConstructor.java   View source code 6 votes vote down vote up
static void testAddClose(Path2D pathA, boolean isEmpty) {
    try {
        addClose(pathA);
    }
    catch (IllegalPathStateException ipse) {
        if (isEmpty) {
            log("testAddClose: passed "
                + "(expected IllegalPathStateException catched).");
            return;
        } else {
            throw ipse;
        }
    }
    if (isEmpty) {
        throw new IllegalStateException("IllegalPathStateException not thrown !");
    }
    log("testAddClose: passed.");
}
 
Example 10
Project: openjdk9   File: Path2DCopyConstructor.java   View source code 6 votes vote down vote up
static void testAddLine(Path2D pathA, boolean isEmpty) {
    try {
        addLines(pathA);
    }
    catch (IllegalPathStateException ipse) {
        if (isEmpty) {
            log("testAddLine: passed "
                + "(expected IllegalPathStateException catched).");
            return;
        } else {
            throw ipse;
        }
    }
    if (isEmpty) {
        throw new IllegalStateException("IllegalPathStateException not thrown !");
    }
    log("testAddLine: passed.");
}
 
Example 11
Project: openjdk9   File: Path2DCopyConstructor.java   View source code 6 votes vote down vote up
static void testAddQuad(Path2D pathA, boolean isEmpty) {
    try {
        addQuads(pathA);
    }
    catch (IllegalPathStateException ipse) {
        if (isEmpty) {
            log("testAddQuad: passed "
                + "(expected IllegalPathStateException catched).");
            return;
        } else {
            throw ipse;
        }
    }
    if (isEmpty) {
        throw new IllegalStateException("IllegalPathStateException not thrown !");
    }
    log("testAddQuad: passed.");
}
 
Example 12
Project: openjdk9   File: Path2DCopyConstructor.java   View source code 6 votes vote down vote up
static void testAddCubic(Path2D pathA, boolean isEmpty) {
    try {
        addCubics(pathA);
    }
    catch (IllegalPathStateException ipse) {
        if (isEmpty) {
            log("testAddCubic: passed "
                + "(expected IllegalPathStateException catched).");
            return;
        } else {
            throw ipse;
        }
    }
    if (isEmpty) {
        throw new IllegalStateException("IllegalPathStateException not thrown !");
    }
    log("testAddCubic: passed.");
}
 
Example 13
Project: openjdk9   File: Path2DCopyConstructor.java   View source code 6 votes vote down vote up
static void testAddClose(Path2D pathA, boolean isEmpty) {
    try {
        addClose(pathA);
    }
    catch (IllegalPathStateException ipse) {
        if (isEmpty) {
            log("testAddClose: passed "
                + "(expected IllegalPathStateException catched).");
            return;
        } else {
            throw ipse;
        }
    }
    if (isEmpty) {
        throw new IllegalStateException("IllegalPathStateException not thrown !");
    }
    log("testAddClose: passed.");
}
 
Example 14
Project: jdk8u_jdk   File: Path2DCopyConstructor.java   View source code 6 votes vote down vote up
static void testAddLine(Path2D pathA, boolean isEmpty) {
    try {
        addLines(pathA);
    }
    catch (IllegalPathStateException ipse) {
        if (isEmpty) {
            log("testAddLine: passed "
                + "(expected IllegalPathStateException catched).");
            return;
        } else {
            throw ipse;
        }
    }
    if (isEmpty) {
        throw new IllegalStateException("IllegalPathStateException not thrown !");
    }
    log("testAddLine: passed.");
}
 
Example 15
Project: jdk8u_jdk   File: Path2DCopyConstructor.java   View source code 6 votes vote down vote up
static void testAddQuad(Path2D pathA, boolean isEmpty) {
    try {
        addQuads(pathA);
    }
    catch (IllegalPathStateException ipse) {
        if (isEmpty) {
            log("testAddQuad: passed "
                + "(expected IllegalPathStateException catched).");
            return;
        } else {
            throw ipse;
        }
    }
    if (isEmpty) {
        throw new IllegalStateException("IllegalPathStateException not thrown !");
    }
    log("testAddQuad: passed.");
}
 
Example 16
Project: jdk8u_jdk   File: Path2DCopyConstructor.java   View source code 6 votes vote down vote up
static void testAddCubic(Path2D pathA, boolean isEmpty) {
    try {
        addCubics(pathA);
    }
    catch (IllegalPathStateException ipse) {
        if (isEmpty) {
            log("testAddCubic: passed "
                + "(expected IllegalPathStateException catched).");
            return;
        } else {
            throw ipse;
        }
    }
    if (isEmpty) {
        throw new IllegalStateException("IllegalPathStateException not thrown !");
    }
    log("testAddCubic: passed.");
}
 
Example 17
Project: jdk8u_jdk   File: Path2DCopyConstructor.java   View source code 6 votes vote down vote up
static void testAddClose(Path2D pathA, boolean isEmpty) {
    try {
        addClose(pathA);
    }
    catch (IllegalPathStateException ipse) {
        if (isEmpty) {
            log("testAddClose: passed "
                + "(expected IllegalPathStateException catched).");
            return;
        } else {
            throw ipse;
        }
    }
    if (isEmpty) {
        throw new IllegalStateException("IllegalPathStateException not thrown !");
    }
    log("testAddClose: passed.");
}
 
Example 18
Project: lookaside_java-1.8.0-openjdk   File: Path2DCopyConstructor.java   View source code 6 votes vote down vote up
static void testAddLine(Path2D pathA, boolean isEmpty) {
    try {
        addLines(pathA);
    }
    catch (IllegalPathStateException ipse) {
        if (isEmpty) {
            log("testAddLine: passed "
                + "(expected IllegalPathStateException catched).");
            return;
        } else {
            throw ipse;
        }
    }
    if (isEmpty) {
        throw new IllegalStateException("IllegalPathStateException not thrown !");
    }
    log("testAddLine: passed.");
}
 
Example 19
Project: lookaside_java-1.8.0-openjdk   File: Path2DCopyConstructor.java   View source code 6 votes vote down vote up
static void testAddQuad(Path2D pathA, boolean isEmpty) {
    try {
        addQuads(pathA);
    }
    catch (IllegalPathStateException ipse) {
        if (isEmpty) {
            log("testAddQuad: passed "
                + "(expected IllegalPathStateException catched).");
            return;
        } else {
            throw ipse;
        }
    }
    if (isEmpty) {
        throw new IllegalStateException("IllegalPathStateException not thrown !");
    }
    log("testAddQuad: passed.");
}
 
Example 20
Project: lookaside_java-1.8.0-openjdk   File: Path2DCopyConstructor.java   View source code 6 votes vote down vote up
static void testAddCubic(Path2D pathA, boolean isEmpty) {
    try {
        addCubics(pathA);
    }
    catch (IllegalPathStateException ipse) {
        if (isEmpty) {
            log("testAddCubic: passed "
                + "(expected IllegalPathStateException catched).");
            return;
        } else {
            throw ipse;
        }
    }
    if (isEmpty) {
        throw new IllegalStateException("IllegalPathStateException not thrown !");
    }
    log("testAddCubic: passed.");
}
 
Example 21
Project: lookaside_java-1.8.0-openjdk   File: Path2DCopyConstructor.java   View source code 6 votes vote down vote up
static void testAddClose(Path2D pathA, boolean isEmpty) {
    try {
        addClose(pathA);
    }
    catch (IllegalPathStateException ipse) {
        if (isEmpty) {
            log("testAddClose: passed "
                + "(expected IllegalPathStateException catched).");
            return;
        } else {
            throw ipse;
        }
    }
    if (isEmpty) {
        throw new IllegalStateException("IllegalPathStateException not thrown !");
    }
    log("testAddClose: passed.");
}
 
Example 22
Project: cmoct-sourcecode   File: PolygonControler.java   View source code 5 votes vote down vote up
public double getArea(float scaleX, float scaleY)
{
	try
	{
		return GeomertyToolkit
				.getArea(GeomertyToolkit.toPath(points), scaleX, scaleY);
	} catch (IllegalPathStateException e)
	{
		return 0;
	}

}
 
Example 23
Project: cmoct-sourcecode   File: PolygonControler.java   View source code 5 votes vote down vote up
public double getLength(float scaleX, float scaleY)
{
	try
	{
		return GeomertyToolkit.getPathLength(GeomertyToolkit.toPath(points), scaleX, scaleY);
	}
	catch(IllegalPathStateException e)
	{
		return 0;
	}
}
 
Example 24
Project: swingx   File: Morphing2D.java   View source code 5 votes vote down vote up
/**
 * <p>Creates a new morphing shape. A morphing shape can be used to turn
 * one shape into another one. The transformation can be controlled by the
 * morph property.</p>
 *
 * @param startShape the shape to morph from
 * @param endShape   the shape to morph to
 *
 * @throws IllegalPathStateException if the shapes do not have the same
 *                                   winding rule
 * @see #getMorphing()
 * @see #setMorphing(double)
 */
public Morphing2D(Shape startShape, Shape endShape) {
    startGeometry = new Geometry(startShape);
    endGeometry = new Geometry(endShape);
    if (startGeometry.getWindingRule() != endGeometry.getWindingRule()) {
        throw new IllegalPathStateException("shapes must use same " +
                                            "winding rule");
    }
    double tvals0[] = startGeometry.getTvals();
    double tvals1[] = endGeometry.getTvals();
    double masterTvals[] = mergeTvals(tvals0, tvals1);
    startGeometry.setTvals(masterTvals);
    endGeometry.setTvals(masterTvals);
}
 
Example 25
Project: filthy-rich-clients   File: Morphing2D.java   View source code 5 votes vote down vote up
/**
 * <p>Creates a new morphing shape. A morphing shape can be used to turn
 * one shape into another one. The transformation can be controlled by the
 * morph property.</p>
 *
 * @param startShape the shape to morph from
 * @param endShape   the shape to morph to
 *
 * @throws IllegalPathStateException if the shapes do not have the same
 *                                   winding rule
 * @see #getMorphing()
 * @see #setMorphing(double)
 */
public Morphing2D(Shape startShape, Shape endShape) {
    startGeometry = new Geometry(startShape);
    endGeometry = new Geometry(endShape);
    if (startGeometry.getWindingRule() != endGeometry.getWindingRule()) {
        throw new IllegalPathStateException("shapes must use same " +
                                            "winding rule");
    }
    double tvals0[] = startGeometry.getTvals();
    double tvals1[] = endGeometry.getTvals();
    double masterTvals[] = mergeTvals(tvals0, tvals1);
    startGeometry.setTvals(masterTvals);
    endGeometry.setTvals(masterTvals);
}
 
Example 26
Project: aibench-project   File: Morphing2D.java   View source code 5 votes vote down vote up
/**
 * <p>Creates a new morphing shape. A morphing shape can be used to turn
 * one shape into another one. The transformation can be controlled by the
 * morph property.</p>
 *
 * @param startShape the shape to morph from
 * @param endShape   the shape to morph to
 *
 * @throws IllegalPathStateException if the shapes do not have the same
 *                                   winding rule
 * @see #getMorphing()
 * @see #setMorphing(double)
 */
public Morphing2D(Shape startShape, Shape endShape) {
    startGeometry = new Geometry(startShape);
    endGeometry = new Geometry(endShape);
    if (startGeometry.getWindingRule() != endGeometry.getWindingRule()) {
        throw new IllegalPathStateException("shapes must use same " +
                                            "winding rule");
    }
    double tvals0[] = startGeometry.getTvals();
    double tvals1[] = endGeometry.getTvals();
    double masterTvals[] = mergeTvals(tvals0, tvals1);
    startGeometry.setTvals(masterTvals);
    endGeometry.setTvals(masterTvals);
}
 
Example 27
Project: marlin-renderer   File: Path2D.java   View source code 5 votes vote down vote up
@Override
void needRoom(boolean needMove, int newCoords) {
    if ((numTypes == 0) && needMove) {
        throw new IllegalPathStateException("missing initial moveto "+
                                            "in path definition");
    }
    if (numTypes >= pointTypes.length) {
        pointTypes = expandPointTypes(pointTypes, 1);
    }
    if (numCoords > (floatCoords.length - newCoords)) {
        floatCoords = expandCoords(floatCoords, newCoords);
    }
}
 
Example 28
Project: marlin-renderer   File: Path2D.java   View source code 5 votes vote down vote up
@Override
void needRoom(boolean needMove, int newCoords) {
    if ((numTypes == 0) && needMove) {
        throw new IllegalPathStateException("missing initial moveto "+
                                            "in path definition");
    }
    if (numTypes >= pointTypes.length) {
        pointTypes = expandPointTypes(pointTypes, 1);
    }
    if (numCoords > (doubleCoords.length - newCoords)) {
        doubleCoords = expandCoords(doubleCoords, newCoords);
    }
}
 
Example 29
Project: onprom   File: Inheritance.java   View source code 4 votes vote down vote up
@Override
public Shape getShape() {
  Path2D shape = new Path2D.Float();
  int xDiff = Math.abs(getSuperclass().getCenterX() - getSubclass().getCenterX());
  int yDiff = Math.abs(getSuperclass().getCenterY() - getSubclass().getCenterY());
  if (xDiff > 2 * yDiff) {
    if (getSuperclass().getStartX() > getSubclass().getEndX()) {
      trianglePosition = Position.LEFT;
      shape.moveTo(getSuperclass().getStartX(), getSuperclass().getCenterY());
      shape.lineTo(getSuperclass().getStartX() - cos30,
        getSuperclass().getCenterY() - sin30);
      shape.lineTo(getSuperclass().getStartX() - cos30,
        getSuperclass().getCenterY() - sinNeg30);
      shape.lineTo(getSuperclass().getStartX(), getSuperclass().getCenterY());
    } else if (getSuperclass().getEndX() < getSubclass().getStartX()) {
      trianglePosition = Position.RIGHT;
      shape.moveTo(getSuperclass().getEndX(), getSuperclass().getCenterY());
      shape.lineTo(getSuperclass().getEndX() + cos30,
        getSuperclass().getCenterY() + sin30);
      shape.lineTo(getSuperclass().getEndX() + cos30,
        getSuperclass().getCenterY() + sinNeg30);
      shape.lineTo(getSuperclass().getEndX(), getSuperclass().getCenterY());
    }
  } else {
    if (getSuperclass().getStartY() > getSubclass().getEndY()) {
      trianglePosition = Position.TOP;
      shape.moveTo(getSuperclass().getCenterX(), getSuperclass().getStartY());
      shape.lineTo(getSuperclass().getCenterX() - sin30,
        getSuperclass().getStartY() - cos30);// 30°
      shape.lineTo(getSuperclass().getCenterX() - sinNeg30,
        getSuperclass().getStartY() - cosNeg30);// 30°
      shape.lineTo(getSuperclass().getCenterX(), getSuperclass().getStartY());
    } else {
      trianglePosition = Position.BOTTOM;
      shape.moveTo(getSuperclass().getCenterX(), getSuperclass().getEndY());
      shape.lineTo(getSuperclass().getCenterX() + sin30,
        getSuperclass().getEndY() + cos30);// 30°
      shape.lineTo(getSuperclass().getCenterX() + sinNeg30,
        getSuperclass().getEndY() + cosNeg30);// 30°
      shape.lineTo(getSuperclass().getCenterX(), getSuperclass().getEndY());
    }
  }
  try {
    shape.closePath();
  } catch (IllegalPathStateException e) {
    return super.getShape();
  }
  shape.append(super.getShape(), false);
  return shape;
}