/*
 * int nativeCreate(int orientation, int artHandle)
 */
JNIEXPORT jint JNICALL Java_com_scriptographer_ai_PathText_nativeCreate(JNIEnv *env, jclass cls, jint orientation, jint artHandle) {
	AIArtHandle art = NULL;

	short paintOrder;
	AIArtHandle artInsert = Item_getInsertionPoint(&paintOrder);
	sAITextFrame->NewOnPathText(paintOrder, artInsert, (AITextOrientation) orientation, (AIArtHandle) artHandle, 0, -1, NULL, false, &art);
	if (art == NULL)
		throw new StringException("Unable to create text object. Please make sure there is an open document.");

	return (jint) art;
}
/*
 * int nativeCreate(int orientation, double x, double y)
 */
JNIEXPORT jint JNICALL Java_com_scriptographer_ai_PointText_nativeCreate(JNIEnv *env, jclass cls, jint orientation, jdouble x, jdouble y) {
	AIArtHandle art = NULL;
	try {
		AIRealPoint pt;
		gEngine->convertPoint(env, kArtboardCoordinates, x, y, &pt);
		
		short paintOrder;
		AIArtHandle artInsert = Item_getInsertionPoint(&paintOrder);
		sAITextFrame->NewPointText(paintOrder, artInsert, (AITextOrientation) orientation, pt, &art);
		if (art == NULL)
			throw new StringException("Unable to create text object. Please make sure there is an open document.");
		
	} EXCEPTION_CONVERT(env);
	return (jint) art;
}