- execution\r
- debugging\r
- javadoc\r
- - junit compilation\r
- - junit execution\r
- - junit debugging\r
+ - test compilation\r
+ - test execution\r
+ - test debugging\r
- applet\r
- cleanup\r
\r
</and>\r
</condition>\r
<property name="run.jvmargs" value=""/>\r
+ <property name="run.jvmargs.ide" value=""/>\r
<property name="javac.compilerargs" value=""/>\r
<property name="work.dir" value="${basedir}"/>\r
<condition property="no.deps">\r
<property name="jar.index.metainf" value="${jar.index}"/>\r
<property name="copylibs.rebase" value="true"/>\r
<available file="${meta.inf.dir}/persistence.xml" property="has.persistence.xml"/>\r
+ <condition property="junit.available">\r
+ <or>\r
+ <available classname="org.junit.Test" classpath="${run.test.classpath}"/>\r
+ <available classname="junit.framework.Test" classpath="${run.test.classpath}"/>\r
+ </or>\r
+ </condition>\r
+ <condition property="testng.available">\r
+ <available classname="org.testng.annotations.Test" classpath="${run.test.classpath}"/>\r
+ </condition>\r
+ <condition property="junit+testng.available">\r
+ <and>\r
+ <istrue value="${junit.available}"/>\r
+ <istrue value="${testng.available}"/>\r
+ </and>\r
+ </condition>\r
+ <condition else="testng" property="testng.mode" value="mixed">\r
+ <istrue value="${junit+testng.available}"/>\r
+ </condition>\r
+ <condition else="" property="testng.debug.mode" value="-mixed">\r
+ <istrue value="${junit+testng.available}"/>\r
+ </condition>\r
</target>\r
<target name="-post-init">\r
<!-- Empty placeholder for easier customization. -->\r
</sequential>\r
</macrodef>\r
</target>\r
- <target name="-init-macrodef-junit">\r
+ <target if="${junit.available}" name="-init-macrodef-junit-init">\r
+ <condition else="false" property="nb.junit.batch" value="true">\r
+ <and>\r
+ <istrue value="${junit.available}"/>\r
+ <not>\r
+ <isset property="test.method"/>\r
+ </not>\r
+ </and>\r
+ </condition>\r
+ <condition else="false" property="nb.junit.single" value="true">\r
+ <and>\r
+ <istrue value="${junit.available}"/>\r
+ <isset property="test.method"/>\r
+ </and>\r
+ </condition>\r
+ </target>\r
+ <target if="${nb.junit.single}" name="-init-macrodef-junit-single" unless="${nb.junit.batch}">\r
<macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">\r
<attribute default="${includes}" name="includes"/>\r
<attribute default="${excludes}" name="excludes"/>\r
<attribute default="**" name="testincludes"/>\r
+ <attribute default="" name="testmethods"/>\r
+ <element name="customize" optional="true"/>\r
+ <sequential>\r
+ <property name="junit.forkmode" value="perTest"/>\r
+ <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" jvm="${platform.java}" showoutput="true" tempdir="${build.dir}">\r
+ <test methods="@{testmethods}" name="@{testincludes}" todir="${build.test.results.dir}"/>\r
+ <syspropertyset>\r
+ <propertyref prefix="test-sys-prop."/>\r
+ <mapper from="test-sys-prop.*" to="*" type="glob"/>\r
+ </syspropertyset>\r
+ <formatter type="brief" usefile="false"/>\r
+ <formatter type="xml"/>\r
+ <jvmarg value="-ea"/>\r
+ <customize/>\r
+ </junit>\r
+ </sequential>\r
+ </macrodef>\r
+ </target>\r
+ <target if="${nb.junit.batch}" name="-init-macrodef-junit-batch" unless="${nb.junit.single}">\r
+ <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">\r
+ <attribute default="${includes}" name="includes"/>\r
+ <attribute default="${excludes}" name="excludes"/>\r
+ <attribute default="**" name="testincludes"/>\r
+ <attribute default="" name="testmethods"/>\r
+ <element name="customize" optional="true"/>\r
<sequential>\r
<property name="junit.forkmode" value="perTest"/>\r
<junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" jvm="${platform.java}" showoutput="true" tempdir="${build.dir}">\r
<batchtest todir="${build.test.results.dir}"/>\r
- <classpath>\r
- <path path="${run.test.classpath}"/>\r
- </classpath>\r
<syspropertyset>\r
<propertyref prefix="test-sys-prop."/>\r
<mapper from="test-sys-prop.*" to="*" type="glob"/>\r
</syspropertyset>\r
<formatter type="brief" usefile="false"/>\r
<formatter type="xml"/>\r
- <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>\r
<jvmarg value="-ea"/>\r
- <jvmarg line="${run.jvmargs}"/>\r
+ <customize/>\r
+ </junit>\r
+ </sequential>\r
+ </macrodef>\r
+ </target>\r
+ <target depends="-init-macrodef-junit-init,-init-macrodef-junit-single, -init-macrodef-junit-batch" if="${junit.available}" name="-init-macrodef-junit"/>\r
+ <target if="${testng.available}" name="-init-macrodef-testng">\r
+ <macrodef name="testng" uri="http://www.netbeans.org/ns/j2se-project/3">\r
+ <attribute default="${includes}" name="includes"/>\r
+ <attribute default="${excludes}" name="excludes"/>\r
+ <attribute default="**" name="testincludes"/>\r
+ <attribute default="" name="testmethods"/>\r
+ <element name="customize" optional="true"/>\r
+ <sequential>\r
+ <condition else="" property="testng.methods.arg" value="@{testincludes}.@{testmethods}">\r
+ <isset property="test.method"/>\r
+ </condition>\r
+ <union id="test.set"/>\r
+ <taskdef classname="org.testng.TestNGAntTask" classpath="${run.test.classpath}" name="testng"/>\r
+ <testng classfilesetref="test.set" failureProperty="tests.failed" jvm="${platform.java}" methods="${testng.methods.arg}" mode="${testng.mode}" outputdir="${build.test.results.dir}" suitename="fwstk" testname="TestNG tests" workingDir="${work.dir}">\r
+ <xmlfileset dir="${build.test.classes.dir}" includes="@{testincludes}"/>\r
+ <propertyset>\r
+ <propertyref prefix="test-sys-prop."/>\r
+ <mapper from="test-sys-prop.*" to="*" type="glob"/>\r
+ </propertyset>\r
+ <customize/>\r
+ </testng>\r
+ </sequential>\r
+ </macrodef>\r
+ </target>\r
+ <target name="-init-macrodef-test-impl">\r
+ <macrodef name="test-impl" uri="http://www.netbeans.org/ns/j2se-project/3">\r
+ <attribute default="${includes}" name="includes"/>\r
+ <attribute default="${excludes}" name="excludes"/>\r
+ <attribute default="**" name="testincludes"/>\r
+ <attribute default="" name="testmethods"/>\r
+ <element implicit="true" name="customize" optional="true"/>\r
+ <sequential>\r
+ <echo>No tests executed.</echo>\r
+ </sequential>\r
+ </macrodef>\r
+ </target>\r
+ <target depends="-init-macrodef-junit" if="${junit.available}" name="-init-macrodef-junit-impl">\r
+ <macrodef name="test-impl" uri="http://www.netbeans.org/ns/j2se-project/3">\r
+ <attribute default="${includes}" name="includes"/>\r
+ <attribute default="${excludes}" name="excludes"/>\r
+ <attribute default="**" name="testincludes"/>\r
+ <attribute default="" name="testmethods"/>\r
+ <element implicit="true" name="customize" optional="true"/>\r
+ <sequential>\r
+ <j2seproject3:junit excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">\r
+ <customize/>\r
+ </j2seproject3:junit>\r
+ </sequential>\r
+ </macrodef>\r
+ </target>\r
+ <target depends="-init-macrodef-testng" if="${testng.available}" name="-init-macrodef-testng-impl">\r
+ <macrodef name="test-impl" uri="http://www.netbeans.org/ns/j2se-project/3">\r
+ <attribute default="${includes}" name="includes"/>\r
+ <attribute default="${excludes}" name="excludes"/>\r
+ <attribute default="**" name="testincludes"/>\r
+ <attribute default="" name="testmethods"/>\r
+ <element implicit="true" name="customize" optional="true"/>\r
+ <sequential>\r
+ <j2seproject3:testng excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">\r
+ <customize/>\r
+ </j2seproject3:testng>\r
+ </sequential>\r
+ </macrodef>\r
+ </target>\r
+ <target depends="-init-macrodef-test-impl,-init-macrodef-junit-impl,-init-macrodef-testng-impl" name="-init-macrodef-test">\r
+ <macrodef name="test" uri="http://www.netbeans.org/ns/j2se-project/3">\r
+ <attribute default="${includes}" name="includes"/>\r
+ <attribute default="${excludes}" name="excludes"/>\r
+ <attribute default="**" name="testincludes"/>\r
+ <attribute default="" name="testmethods"/>\r
+ <sequential>\r
+ <j2seproject3:test-impl excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">\r
+ <customize>\r
+ <classpath>\r
+ <path path="${run.test.classpath}"/>\r
+ </classpath>\r
+ <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>\r
+ <jvmarg line="${run.jvmargs}"/>\r
+ <jvmarg line="${run.jvmargs.ide}"/>\r
+ </customize>\r
+ </j2seproject3:test-impl>\r
+ </sequential>\r
+ </macrodef>\r
+ </target>\r
+ <target if="${junit.available}" name="-init-macrodef-junit-debug" unless="${nb.junit.batch}">\r
+ <macrodef name="junit-debug" uri="http://www.netbeans.org/ns/j2se-project/3">\r
+ <attribute default="${includes}" name="includes"/>\r
+ <attribute default="${excludes}" name="excludes"/>\r
+ <attribute default="**" name="testincludes"/>\r
+ <attribute default="" name="testmethods"/>\r
+ <element name="customize" optional="true"/>\r
+ <sequential>\r
+ <property name="junit.forkmode" value="perTest"/>\r
+ <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" jvm="${platform.java}" showoutput="true" tempdir="${build.dir}">\r
+ <test methods="@{testmethods}" name="@{testincludes}" todir="${build.test.results.dir}"/>\r
+ <syspropertyset>\r
+ <propertyref prefix="test-sys-prop."/>\r
+ <mapper from="test-sys-prop.*" to="*" type="glob"/>\r
+ </syspropertyset>\r
+ <formatter type="brief" usefile="false"/>\r
+ <formatter type="xml"/>\r
+ <jvmarg value="-ea"/>\r
+ <jvmarg line="${debug-args-line}"/>\r
+ <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>\r
+ <customize/>\r
</junit>\r
</sequential>\r
</macrodef>\r
</target>\r
- <target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile, -profile-init-check" name="profile-init"/>\r
- <target name="-profile-pre-init">\r
+ <target if="${nb.junit.batch}" name="-init-macrodef-junit-debug-batch">\r
+ <macrodef name="junit-debug" uri="http://www.netbeans.org/ns/j2se-project/3">\r
+ <attribute default="${includes}" name="includes"/>\r
+ <attribute default="${excludes}" name="excludes"/>\r
+ <attribute default="**" name="testincludes"/>\r
+ <attribute default="" name="testmethods"/>\r
+ <element name="customize" optional="true"/>\r
+ <sequential>\r
+ <property name="junit.forkmode" value="perTest"/>\r
+ <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" jvm="${platform.java}" showoutput="true" tempdir="${build.dir}">\r
+ <batchtest todir="${build.test.results.dir}"/>\r
+ <syspropertyset>\r
+ <propertyref prefix="test-sys-prop."/>\r
+ <mapper from="test-sys-prop.*" to="*" type="glob"/>\r
+ </syspropertyset>\r
+ <formatter type="brief" usefile="false"/>\r
+ <formatter type="xml"/>\r
+ <jvmarg value="-ea"/>\r
+ <jvmarg line="${debug-args-line}"/>\r
+ <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>\r
+ <customize/>\r
+ </junit>\r
+ </sequential>\r
+ </macrodef>\r
+ </target>\r
+ <target depends="-init-macrodef-junit-debug,-init-macrodef-junit-debug-batch" if="${junit.available}" name="-init-macrodef-junit-debug-impl">\r
+ <macrodef name="test-debug-impl" uri="http://www.netbeans.org/ns/j2se-project/3">\r
+ <attribute default="${includes}" name="includes"/>\r
+ <attribute default="${excludes}" name="excludes"/>\r
+ <attribute default="**" name="testincludes"/>\r
+ <attribute default="" name="testmethods"/>\r
+ <element implicit="true" name="customize" optional="true"/>\r
+ <sequential>\r
+ <j2seproject3:junit-debug excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">\r
+ <customize/>\r
+ </j2seproject3:junit-debug>\r
+ </sequential>\r
+ </macrodef>\r
+ </target>\r
+ <target if="${testng.available}" name="-init-macrodef-testng-debug">\r
+ <macrodef name="testng-debug" uri="http://www.netbeans.org/ns/j2se-project/3">\r
+ <attribute default="${main.class}" name="testClass"/>\r
+ <attribute default="" name="testMethod"/>\r
+ <element name="customize2" optional="true"/>\r
+ <sequential>\r
+ <condition else="-testclass @{testClass}" property="test.class.or.method" value="-methods @{testClass}.@{testMethod}">\r
+ <isset property="test.method"/>\r
+ </condition>\r
+ <condition else="-suitename fwstk -testname @{testClass} ${test.class.or.method}" property="testng.cmd.args" value="@{testClass}">\r
+ <matches pattern=".*\.xml" string="@{testClass}"/>\r
+ </condition>\r
+ <delete dir="${build.test.results.dir}" quiet="true"/>\r
+ <mkdir dir="${build.test.results.dir}"/>\r
+ <j2seproject3:debug classname="org.testng.TestNG" classpath="${debug.test.classpath}">\r
+ <customize>\r
+ <customize2/>\r
+ <jvmarg value="-ea"/>\r
+ <arg line="${testng.debug.mode}"/>\r
+ <arg line="-d ${build.test.results.dir}"/>\r
+ <arg line="-listener org.testng.reporters.VerboseReporter"/>\r
+ <arg line="${testng.cmd.args}"/>\r
+ </customize>\r
+ </j2seproject3:debug>\r
+ </sequential>\r
+ </macrodef>\r
+ </target>\r
+ <target depends="-init-macrodef-testng-debug" if="${testng.available}" name="-init-macrodef-testng-debug-impl">\r
+ <macrodef name="testng-debug-impl" uri="http://www.netbeans.org/ns/j2se-project/3">\r
+ <attribute default="${main.class}" name="testClass"/>\r
+ <attribute default="" name="testMethod"/>\r
+ <element implicit="true" name="customize2" optional="true"/>\r
+ <sequential>\r
+ <j2seproject3:testng-debug testClass="@{testClass}" testMethod="@{testMethod}">\r
+ <customize2/>\r
+ </j2seproject3:testng-debug>\r
+ </sequential>\r
+ </macrodef>\r
+ </target>\r
+ <target depends="-init-macrodef-junit-debug-impl" if="${junit.available}" name="-init-macrodef-test-debug-junit">\r
+ <macrodef name="test-debug" uri="http://www.netbeans.org/ns/j2se-project/3">\r
+ <attribute default="${includes}" name="includes"/>\r
+ <attribute default="${excludes}" name="excludes"/>\r
+ <attribute default="**" name="testincludes"/>\r
+ <attribute default="" name="testmethods"/>\r
+ <attribute default="${main.class}" name="testClass"/>\r
+ <attribute default="" name="testMethod"/>\r
+ <sequential>\r
+ <j2seproject3:test-debug-impl excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">\r
+ <customize>\r
+ <classpath>\r
+ <path path="${run.test.classpath}"/>\r
+ </classpath>\r
+ <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>\r
+ <jvmarg line="${run.jvmargs}"/>\r
+ <jvmarg line="${run.jvmargs.ide}"/>\r
+ </customize>\r
+ </j2seproject3:test-debug-impl>\r
+ </sequential>\r
+ </macrodef>\r
+ </target>\r
+ <target depends="-init-macrodef-testng-debug-impl" if="${testng.available}" name="-init-macrodef-test-debug-testng">\r
+ <macrodef name="test-debug" uri="http://www.netbeans.org/ns/j2se-project/3">\r
+ <attribute default="${includes}" name="includes"/>\r
+ <attribute default="${excludes}" name="excludes"/>\r
+ <attribute default="**" name="testincludes"/>\r
+ <attribute default="" name="testmethods"/>\r
+ <attribute default="${main.class}" name="testClass"/>\r
+ <attribute default="" name="testMethod"/>\r
+ <sequential>\r
+ <j2seproject3:testng-debug-impl testClass="@{testClass}" testMethod="@{testMethod}">\r
+ <customize2>\r
+ <syspropertyset>\r
+ <propertyref prefix="test-sys-prop."/>\r
+ <mapper from="test-sys-prop.*" to="*" type="glob"/>\r
+ </syspropertyset>\r
+ </customize2>\r
+ </j2seproject3:testng-debug-impl>\r
+ </sequential>\r
+ </macrodef>\r
+ </target>\r
+ <target depends="-init-macrodef-test-debug-junit,-init-macrodef-test-debug-testng" name="-init-macrodef-test-debug"/>\r
+ <!--\r
+ pre NB7.2 profiling section; consider it deprecated\r
+ -->\r
+ <target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile, -profile-init-check" if="profiler.info.jvmargs.agent" name="profile-init"/>\r
+ <target if="profiler.info.jvmargs.agent" name="-profile-pre-init">\r
<!-- Empty placeholder for easier customization. -->\r
<!-- You can override this target in the ../build.xml file. -->\r
</target>\r
- <target name="-profile-post-init">\r
+ <target if="profiler.info.jvmargs.agent" name="-profile-post-init">\r
<!-- Empty placeholder for easier customization. -->\r
<!-- You can override this target in the ../build.xml file. -->\r
</target>\r
- <target name="-profile-init-macrodef-profile">\r
+ <target if="profiler.info.jvmargs.agent" name="-profile-init-macrodef-profile">\r
<macrodef name="resolve">\r
<attribute name="name"/>\r
<attribute name="value"/>\r
</sequential>\r
</macrodef>\r
</target>\r
- <target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile" name="-profile-init-check">\r
+ <target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile" if="profiler.info.jvmargs.agent" name="-profile-init-check">\r
<fail unless="profiler.info.jvm">Must set JVM to use for profiling in profiler.info.jvm</fail>\r
<fail unless="profiler.info.jvmargs.agent">Must set profiler agent JVM arguments in profiler.info.jvmargs.agent</fail>\r
</target>\r
+ <!--\r
+ end of pre NB7.2 profiling section\r
+ -->\r
<target depends="-init-debug-args" name="-init-macrodef-nbjpda">\r
<macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">\r
<attribute default="${main.class}" name="name"/>\r
<jvmarg value="-Dfile.encoding=${runtime.encoding}"/>\r
<redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>\r
<jvmarg line="${run.jvmargs}"/>\r
+ <jvmarg line="${run.jvmargs.ide}"/>\r
<classpath>\r
<path path="@{classpath}"/>\r
</classpath>\r
<macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">\r
<attribute default="${main.class}" name="classname"/>\r
<attribute default="${run.classpath}" name="classpath"/>\r
+ <attribute default="jvm" name="jvm"/>\r
<element name="customize" optional="true"/>\r
<sequential>\r
<java classname="@{classname}" dir="${work.dir}" fork="true" jvm="${platform.java}">\r
<jvmarg value="-Dfile.encoding=${runtime.encoding}"/>\r
<redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>\r
<jvmarg line="${run.jvmargs}"/>\r
+ <jvmarg line="${run.jvmargs.ide}"/>\r
<classpath>\r
<path path="@{classpath}"/>\r
</classpath>\r
<path path="${run.classpath.without.build.classes.dir}"/>\r
<chainedmapper>\r
<flattenmapper/>\r
+ <filtermapper>\r
+ <replacestring from=" " to="%20"/>\r
+ </filtermapper>\r
<globmapper from="*" to="lib/*"/>\r
</chainedmapper>\r
</pathconvert>\r
<target depends="-init-ap-cmdline-properties,-init-ap-cmdline-supported" name="-init-ap-cmdline">\r
<property name="ap.cmd.line.internal" value=""/>\r
</target>\r
- <target depends="-pre-init,-init-private,-init-libraries,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar,-init-ap-cmdline" name="init"/>\r
+ <target depends="-pre-init,-init-private,-init-libraries,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-test,-init-macrodef-test-debug,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar,-init-ap-cmdline" name="init"/>\r
<!--\r
===================\r
COMPILATION SECTION\r
PROFILING SECTION\r
=================\r
-->\r
- <target depends="profile-init,compile" description="Profile a project in the IDE." if="netbeans.home" name="profile">\r
+ <!--\r
+ pre NB7.2 profiler integration\r
+ -->\r
+ <target depends="profile-init,compile" description="Profile a project in the IDE." if="profiler.info.jvmargs.agent" name="-profile-pre72">\r
+ <fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail>\r
<nbprofiledirect>\r
<classpath>\r
<path path="${run.classpath}"/>\r
</nbprofiledirect>\r
<profile/>\r
</target>\r
- <target depends="profile-init,compile-single" description="Profile a selected class in the IDE." if="netbeans.home" name="profile-single">\r
+ <target depends="profile-init,compile-single" description="Profile a selected class in the IDE." if="profiler.info.jvmargs.agent" name="-profile-single-pre72">\r
<fail unless="profile.class">Must select one file in the IDE or set profile.class</fail>\r
+ <fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail>\r
<nbprofiledirect>\r
<classpath>\r
<path path="${run.classpath}"/>\r
</nbprofiledirect>\r
<profile classname="${profile.class}"/>\r
</target>\r
- <!--\r
- =========================\r
- APPLET PROFILING SECTION\r
- =========================\r
- -->\r
- <target depends="profile-init,compile-single" if="netbeans.home" name="profile-applet">\r
+ <target depends="profile-init,compile-single" if="profiler.info.jvmargs.agent" name="-profile-applet-pre72">\r
+ <fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail>\r
<nbprofiledirect>\r
<classpath>\r
<path path="${run.classpath}"/>\r
</customize>\r
</profile>\r
</target>\r
- <!--\r
- =========================\r
- TESTS PROFILING SECTION\r
- =========================\r
- -->\r
- <target depends="profile-init,compile-test-single" if="netbeans.home" name="profile-test-single">\r
+ <target depends="profile-init,compile-test-single" if="profiler.info.jvmargs.agent" name="-profile-test-single-pre72">\r
+ <fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail>\r
<nbprofiledirect>\r
<classpath>\r
<path path="${run.test.classpath}"/>\r
<formatter type="xml"/>\r
</junit>\r
</target>\r
+ <!--\r
+ end of pre NB72 profiling section\r
+ -->\r
+ <target if="netbeans.home" name="-profile-check">\r
+ <condition property="profiler.configured">\r
+ <or>\r
+ <contains casesensitive="true" string="${run.jvmargs.ide}" substring="-agentpath:"/>\r
+ <contains casesensitive="true" string="${run.jvmargs.ide}" substring="-javaagent:"/>\r
+ </or>\r
+ </condition>\r
+ </target>\r
+ <target depends="-profile-check,-profile-pre72" description="Profile a project in the IDE." if="profiler.configured" name="profile" unless="profiler.info.jvmargs.agent">\r
+ <startprofiler/>\r
+ <antcall target="run"/>\r
+ </target>\r
+ <target depends="-profile-check,-profile-single-pre72" description="Profile a selected class in the IDE." if="profiler.configured" name="profile-single" unless="profiler.info.jvmargs.agent">\r
+ <fail unless="run.class">Must select one file in the IDE or set run.class</fail>\r
+ <startprofiler/>\r
+ <antcall target="run-single"/>\r
+ </target>\r
+ <target depends="-profile-test-single-pre72" description="Profile a selected test in the IDE." name="profile-test-single"/>\r
+ <target depends="-profile-check" description="Profile a selected test in the IDE." if="profiler.configured" name="profile-test" unless="profiler.info.jvmargs">\r
+ <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>\r
+ <startprofiler/>\r
+ <antcall target="test-single"/>\r
+ </target>\r
+ <target depends="-profile-check" description="Profile a selected class in the IDE." if="profiler.configured" name="profile-test-with-main">\r
+ <fail unless="run.class">Must select one file in the IDE or set run.class</fail>\r
+ <startprofiler/>\r
+ <antcal target="run-test-with-main"/>\r
+ </target>\r
+ <target depends="-profile-check,-profile-applet-pre72" if="profiler.configured" name="profile-applet" unless="profiler.info.jvmargs.agent">\r
+ <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>\r
+ <startprofiler/>\r
+ <antcall target="run-applet"/>\r
+ </target>\r
<!--\r
===============\r
JAVADOC SECTION\r
<target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>\r
<!--\r
=========================\r
- JUNIT COMPILATION SECTION\r
+ TEST COMPILATION SECTION\r
=========================\r
-->\r
<target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">\r
<target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>\r
<!--\r
=======================\r
- JUNIT EXECUTION SECTION\r
+ TEST EXECUTION SECTION\r
=======================\r
-->\r
<target depends="init" if="have.tests" name="-pre-test-run">\r
<mkdir dir="${build.test.results.dir}"/>\r
</target>\r
<target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">\r
- <j2seproject3:junit testincludes="**/*Test.java"/>\r
+ <j2seproject3:test testincludes="**/*Test.java"/>\r
</target>\r
<target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">\r
<fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>\r
</target>\r
<target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">\r
<fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>\r
- <j2seproject3:junit excludes="" includes="${test.includes}"/>\r
+ <j2seproject3:test excludes="" includes="${test.includes}" testincludes="${test.includes}"/>\r
</target>\r
<target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">\r
<fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>\r
</target>\r
<target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/>\r
+ <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single-method">\r
+ <fail unless="test.class">Must select some files in the IDE or set test.class</fail>\r
+ <fail unless="test.method">Must select some method in the IDE or set test.method</fail>\r
+ <j2seproject3:test excludes="" includes="${javac.includes}" testincludes="${test.class}" testmethods="${test.method}"/>\r
+ </target>\r
+ <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single-method" if="have.tests" name="-post-test-run-single-method">\r
+ <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>\r
+ </target>\r
+ <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single-method,-post-test-run-single-method" description="Run single unit test." name="test-single-method"/>\r
<!--\r
=======================\r
- JUNIT DEBUGGING SECTION\r
+ TEST DEBUGGING SECTION\r
=======================\r
-->\r
- <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">\r
+ <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-debug-start-debuggee-test">\r
<fail unless="test.class">Must select one file in the IDE or set test.class</fail>\r
- <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>\r
- <delete file="${test.report.file}"/>\r
- <mkdir dir="${build.test.results.dir}"/>\r
- <j2seproject3:debug classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" classpath="${ant.home}/lib/ant.jar:${ant.home}/lib/ant-junit.jar:${debug.test.classpath}">\r
- <customize>\r
- <syspropertyset>\r
- <propertyref prefix="test-sys-prop."/>\r
- <mapper from="test-sys-prop.*" to="*" type="glob"/>\r
- </syspropertyset>\r
- <arg value="${test.class}"/>\r
- <arg value="showoutput=true"/>\r
- <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>\r
- <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>\r
- </customize>\r
- </j2seproject3:debug>\r
+ <j2seproject3:test-debug excludes="" includes="${javac.includes}" testClass="${test.class}" testincludes="${javac.includes}"/>\r
+ </target>\r
+ <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-debug-start-debuggee-test-method">\r
+ <fail unless="test.class">Must select one file in the IDE or set test.class</fail>\r
+ <fail unless="test.method">Must select some method in the IDE or set test.method</fail>\r
+ <j2seproject3:test-debug excludes="" includes="${javac.includes}" testClass="${test.class}" testMethod="${test.method}" testincludes="${test.class}" testmethods="${test.method}"/>\r
</target>\r
<target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">\r
<j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>\r
</target>\r
<target depends="init,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>\r
+ <target depends="init,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test-method" name="debug-test-method"/>\r
<target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">\r
<j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>\r
</target>\r
<target name="-check-call-dep">\r
<property file="${call.built.properties}" prefix="already.built."/>\r
<condition property="should.call.dep">\r
- <not>\r
- <isset property="already.built.${call.subproject}"/>\r
- </not>\r
+ <and>\r
+ <not>\r
+ <isset property="already.built.${call.subproject}"/>\r
+ </not>\r
+ <available file="${call.script}"/>\r
+ </and>\r
</condition>\r
</target>\r
<target depends="-check-call-dep" if="should.call.dep" name="-maybe-call-dep">\r
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.\r
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.\r
nbproject/build-impl.xml.data.CRC32=1c2c8395\r
-nbproject/build-impl.xml.script.CRC32=daf71c18\r
-nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.50.1.46\r
+nbproject/build-impl.xml.script.CRC32=8b7167f5\r
+nbproject/build-impl.xml.stylesheet.CRC32=6ddba6b6@1.53.1.46\r
-config=Extract_texts\r
+config=Extract_Links\r
do.jar=true\r
javac.debug=true\r
javadoc.preview=true\r
-user.properties.file=C:\\Users\\Vincent\\.netbeans\\7.1\\build.properties\r
+user.properties.file=C:\\Users\\Vincent\\AppData\\Roaming\\NetBeans\\7.2\\build.properties\r
<?xml version="1.0" encoding="UTF-8"?>\r
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">\r
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>\r
+ <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>\r
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/1">\r
<file>file:/H:/Works/cubeExtranet/fluidbook/tools/fwstk/src/com/fluidbook/fwstk/Main.java</file>\r
- <file>file:/H:/Works/cubeExtranet/fluidbook/tools/fwstk/src/com/fluidbook/fwstk/TextsThread.java</file>\r
- <file>file:/H:/Works/cubeExtranet/fluidbook/tools/fwstk/src/com/fluidbook/fwstk/CustomStripper.java</file>\r
- <file>file:/H:/Works/cubeExtranet/fluidbook/tools/fwstk/src/cube/util/StringUtil.java</file>\r
- <file>file:/H:/Works/cubeExtranet/fluidbook/tools/fwstk/nbproject/build-impl.xml</file>\r
</open-files>\r
</project-private>\r
file.reference.bcmail-jdk16-146.jar=lib/bcmail-jdk16-146.jar\r
file.reference.bcprov-jdk16-146.jar=lib/bcprov-jdk16-146.jar\r
file.reference.commons-logging-1.1.1.jar=lib/commons-logging-1.1.1.jar\r
-file.reference.fontbox-1.6.0.jar=lib/fontbox-1.6.0.jar\r
+file.reference.fontbox-1.7.1.jar=lib\\fontbox-1.7.1.jar\r
file.reference.FWSTK_Resources.jar=../FWSTK_Resources/dist/FWSTK_Resources.jar\r
file.reference.Java-resources=../../../../Java/resources\r
-file.reference.jempbox-1.6.0.jar=lib/jempbox-1.6.0.jar\r
-file.reference.pdfbox-1.6.0.jar=lib/pdfbox-1.6.0.jar\r
+file.reference.jempbox-1.7.1.jar=lib\\jempbox-1.7.1.jar\r
+file.reference.pdfbox-1.7.1.jar=lib\\pdfbox-1.7.1.jar\r
file.reference.Works-Java=../../../../Java\r
includes=**\r
jar.archive.disabled=${jnlp.enabled}\r
${file.reference.bcmail-jdk16-146.jar}:\\r
${file.reference.commons-logging-1.1.1.jar}:\\r
${file.reference.FWSTK_Resources.jar}:\\r
- ${file.reference.fontbox-1.6.0.jar}:\\r
- ${file.reference.jempbox-1.6.0.jar}:\\r
- ${file.reference.pdfbox-1.6.0.jar}\r
+ ${file.reference.fontbox-1.7.1.jar}:\\r
+ ${file.reference.jempbox-1.7.1.jar}:\\r
+ ${file.reference.pdfbox-1.7.1.jar}\r
# Space-separated list of extra javac options\r
javac.compilerargs=\r
javac.deprecation=false\r
+++ /dev/null
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.pdfbox.pdfviewer;
-
-import java.awt.BasicStroke;
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
-import java.awt.geom.Area;
-import java.awt.RenderingHints;
-import java.awt.geom.AffineTransform;
-import java.awt.geom.GeneralPath;
-import java.awt.geom.Point2D;
-import java.awt.Image;
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-
-import java.util.Properties;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.pdfbox.pdmodel.PDPage;
-import org.apache.pdfbox.pdmodel.PDResources;
-import org.apache.pdfbox.pdmodel.common.PDMatrix;
-import org.apache.pdfbox.pdmodel.common.PDRectangle;
-import org.apache.pdfbox.pdmodel.font.PDFont;
-import org.apache.pdfbox.pdmodel.graphics.PDGraphicsState;
-import org.apache.pdfbox.pdmodel.graphics.PDShading;
-import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation;
-import org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary;
-import org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceStream;
-import org.apache.pdfbox.pdmodel.text.PDTextState;
-import org.apache.pdfbox.util.Matrix;
-import org.apache.pdfbox.util.PDFStreamEngine;
-import org.apache.pdfbox.util.ResourceLoader;
-import org.apache.pdfbox.util.TextPosition;
-import org.apache.pdfbox.cos.COSName;
-import org.apache.pdfbox.cos.COSDictionary;
-
-
-/**
- * This will paint a page in a PDF document to a graphics context.
- *
- * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
- * @version $Revision: 1.22 $
- */
-public class PageDrawer extends PDFStreamEngine
-{
-
- /**
- * Log instance.
- */
- private static final Log log = LogFactory.getLog(PageDrawer.class);
-
- private Graphics2D graphics;
- protected Dimension pageSize;
- protected PDPage page;
-
- private GeneralPath linePath = new GeneralPath();
-
- /**
- * Default constructor, loads properties from file.
- *
- * @throws IOException If there is an error loading properties from the file.
- */
- public PageDrawer() throws IOException
- {
- super( ResourceLoader.loadProperties(
- "org/apache/pdfbox/resources/PageDrawer.properties", true ) );
- }
-
- public PageDrawer(Properties properties) throws IOException {
- super(properties);
- }
-
- /**
- * This will draw the page to the requested context.
- *
- * @param g The graphics context to draw onto.
- * @param p The page to draw.
- * @param pageDimension The size of the page to draw.
- *
- * @throws IOException If there is an IO error while drawing the page.
- */
- public void drawPage( Graphics g, PDPage p, Dimension pageDimension ) throws IOException
- {
- graphics = (Graphics2D)g;
- page = p;
- pageSize = pageDimension;
- graphics.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
- graphics.setRenderingHint( RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON );
- // Only if there is some content, we have to process it.
- // Otherwise we are done here and we will produce an empty page
- if ( page.getContents() != null)
- {
- PDResources resources = page.findResources();
- processStream( page, resources, page.getContents().getStream() );
- }
-
- return;/*
- List annotations = page.getAnnotations();
- for( int i=0; i<annotations.size(); i++ )
- {
- PDAnnotation annot = (PDAnnotation)annotations.get( i );
- PDRectangle rect = annot.getRectangle();
- String appearanceName = annot.getAppearanceStream();
- PDAppearanceDictionary appearDictionary = annot.getAppearance();
- if( appearDictionary != null )
- {
- if( appearanceName == null )
- {
- appearanceName = "default";
- }
- Map appearanceMap = appearDictionary.getNormalAppearance();
- if (appearanceMap != null) {
- PDAppearanceStream appearance =
- (PDAppearanceStream)appearanceMap.get( appearanceName );
- if( appearance != null )
- {
- g.translate( (int)rect.getLowerLeftX(), (int)-rect.getLowerLeftY() );
- processSubStream( page, appearance.getResources(), appearance.getStream() );
- g.translate( (int)-rect.getLowerLeftX(), (int)+rect.getLowerLeftY() );
- }
- }
- }
- }*/
-
- }
-
- /**
- * You should override this method if you want to perform an action when a
- * text is being processed.
- *
- * @param text The text to process
- */
- protected void processTextPosition( TextPosition text )
- {
- try
- {
- switch(this.getGraphicsState().getTextState().getRenderingMode()) {
- case PDTextState.RENDERING_MODE_FILL_TEXT:
- graphics.setComposite( this.getGraphicsState().getNonStrokeJavaComposite() );
- graphics.setColor( this.getGraphicsState().getNonStrokingColor().getJavaColor() );
- break;
- case PDTextState.RENDERING_MODE_STROKE_TEXT:
- graphics.setComposite( this.getGraphicsState().getStrokeJavaComposite() );
- graphics.setColor( this.getGraphicsState().getStrokingColor().getJavaColor() );
- break;
- case PDTextState.RENDERING_MODE_NEITHER_FILL_NOR_STROKE_TEXT:
- //basic support for text rendering mode "invisible"
- Color nsc = this.getGraphicsState().getStrokingColor().getJavaColor();
- float[] components = {Color.black.getRed(),Color.black.getGreen(),Color.black.getBlue()};
- Color c = new Color(nsc.getColorSpace(),components,0f);
- graphics.setComposite( this.getGraphicsState().getStrokeJavaComposite() );
- graphics.setColor(c);
- break;
- default:
- // TODO : need to implement....
- log.debug("Unsupported RenderingMode "
- + this.getGraphicsState().getTextState().getRenderingMode()
- + " in PageDrawer.processTextPosition()."
- + " Using RenderingMode "
- + PDTextState.RENDERING_MODE_FILL_TEXT
- + " instead");
- graphics.setComposite( this.getGraphicsState().getNonStrokeJavaComposite() );
- graphics.setColor( this.getGraphicsState().getNonStrokingColor().getJavaColor() );
- }
-
- PDFont font = text.getFont();
- Matrix textPos = text.getTextPos().copy();
- float x = textPos.getXPosition();
- // the 0,0-reference has to be moved from the lower left (PDF) to the upper left (AWT-graphics)
- float y = pageSize.height - textPos.getYPosition();
- // Set translation to 0,0. We only need the scaling and shearing
- textPos.setValue(2, 0, 0);
- textPos.setValue(2, 1, 0);
- // because of the moved 0,0-reference, we have to shear in the opposite direction
- textPos.setValue(0, 1, (-1)*textPos.getValue(0, 1));
- textPos.setValue(1, 0, (-1)*textPos.getValue(1, 0));
- AffineTransform at = textPos.createAffineTransform();
- PDMatrix fontMatrix = font.getFontMatrix();
- at.scale(fontMatrix.getValue(0, 0) * 1000f, fontMatrix.getValue(1, 1) * 1000f);
- graphics.setClip(getGraphicsState().getCurrentClippingPath());
- // the fontSize is no longer needed as it is already part of the transformation
- // we should remove it from the parameter list in the long run
- font.drawString( text.getCharacter(), graphics, 1, at, x, y );
-
- System.out.println(text.getCharacter()+";"+y);
-
- }
- catch( IOException io )
- {
- io.printStackTrace();
- }
- }
-
- /**
- * Get the graphics that we are currently drawing on.
- *
- * @return The graphics we are drawing on.
- */
- public Graphics2D getGraphics()
- {
- return graphics;
- }
-
- /**
- * Get the page that is currently being drawn.
- *
- * @return The page that is being drawn.
- */
- public PDPage getPage()
- {
- return page;
- }
-
- /**
- * Get the size of the page that is currently being drawn.
- *
- * @return The size of the page that is being drawn.
- */
- public Dimension getPageSize()
- {
- return pageSize;
- }
-
- /**
- * Fix the y coordinate.
- *
- * @param y The y coordinate.
- * @return The updated y coordinate.
- */
- public double fixY( double y )
- {
- return pageSize.getHeight() - y;
- }
-
- /**
- * Get the current line path to be drawn.
- *
- * @return The current line path to be drawn.
- */
- public GeneralPath getLinePath()
- {
- return linePath;
- }
-
- /**
- * Set the line path to draw.
- *
- * @param newLinePath Set the line path to draw.
- */
- public void setLinePath(GeneralPath newLinePath)
- {
- if (linePath == null || linePath.getCurrentPoint() == null)
- {
- linePath = newLinePath;
- }
- else
- {
- linePath.append(newLinePath, false);
- }
- }
-
-
- /**
- * Fill the path.
- *
- * @param windingRule The winding rule this path will use.
- *
- * @throws IOException If there is an IO error while filling the path.
- */
- public void fillPath(int windingRule) throws IOException
- {
- graphics.setComposite(getGraphicsState().getNonStrokeJavaComposite());
- graphics.setColor( getGraphicsState().getNonStrokingColor().getJavaColor() );
- getLinePath().setWindingRule(windingRule);
- graphics.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF );
- graphics.setClip(getGraphicsState().getCurrentClippingPath());
- graphics.fill( getLinePath() );
- getLinePath().reset();
- }
-
-
- /**
- * This will set the current stroke.
- *
- * @param newStroke The current stroke.
- *
- */
- public void setStroke(BasicStroke newStroke)
- {
- getGraphics().setStroke( newStroke );
- }
-
- /**
- * This will return the current stroke.
- *
- * @return The current stroke.
- *
- */
- public BasicStroke getStroke()
- {
- return (BasicStroke)getGraphics().getStroke();
- }
-
- /**
- * Stroke the path.
- *
- * @throws IOException If there is an IO error while stroking the path.
- */
- public void strokePath() throws IOException
- {
- graphics.setComposite(getGraphicsState().getStrokeJavaComposite());
- graphics.setColor( getGraphicsState().getStrokingColor().getJavaColor() );
- graphics.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF );
- graphics.setClip(getGraphicsState().getCurrentClippingPath());
- GeneralPath path = getLinePath();
- graphics.draw( path );
- path.reset();
- }
-
- /**
- * Called when the color changed.
- * @param bStroking true for the stroking color, false for the non-stroking color
- * @throws IOException if an I/O error occurs
- */
- @Deprecated
- public void colorChanged(boolean bStroking) throws IOException
- {
- //logger().info("changing " + (bStroking ? "" : "non") + "stroking color");
- }
-
- //This code generalizes the code Jim Lynch wrote for AppendRectangleToPath
- /**
- * use the current transformation matrix to transform a single point.
- * @param x x-coordinate of the point to be transform
- * @param y y-coordinate of the point to be transform
- * @return the transformed coordinates as Point2D.Double
- */
- public java.awt.geom.Point2D.Double transformedPoint(double x, double y)
- {
- double[] position = {x,y};
- getGraphicsState().getCurrentTransformationMatrix().createAffineTransform().transform(
- position, 0, position, 0, 1);
- position[1] = fixY(position[1]);
- return new Point2D.Double(position[0],position[1]);
- }
-
- /**
- * Set the clipping Path.
- *
- * @param windingRule The winding rule this path will use.
- *
- */
- public void setClippingPath(int windingRule)
- {
- PDGraphicsState graphicsState = getGraphicsState();
- GeneralPath clippingPath = (GeneralPath)getLinePath().clone();
- clippingPath.setWindingRule(windingRule);
- // If there is already set a clipping path, we have to intersect the new with the existing one
- if (graphicsState.getCurrentClippingPath() != null)
- {
- Area currentArea = new Area(getGraphicsState().getCurrentClippingPath());
- Area newArea = new Area(clippingPath);
- currentArea.intersect(newArea);
- graphicsState.setCurrentClippingPath(currentArea);
- }
- else
- {
- graphicsState.setCurrentClippingPath(clippingPath);
- }
- getLinePath().reset();
- }
-
- /**
- * Draw the AWT image. Called by Invoke.
- * Moved into PageDrawer so that Invoke doesn't have to reach in here for Graphics as that breaks extensibility.
- *
- * @param awtImage The image to draw.
- * @param at The transformation to use when drawing.
- *
- */
- public void drawImage(Image awtImage, AffineTransform at){
- graphics.setComposite(getGraphicsState().getStrokeJavaComposite());
- graphics.setClip(getGraphicsState().getCurrentClippingPath());
- graphics.drawImage( awtImage, at, null );
- }
-
- /**
- * Fill with Shading. Called by SHFill operator.
- *
- * @param ShadingName The name of the Shading Dictionary to use for this fill instruction.
- *
- * @throws IOException If there is an IO error while shade-filling the path/clipping area.
- */
- public void SHFill(COSName ShadingName) throws IOException
- {
- PDShading Shading =FindShadingDictionary(ShadingName);
- log.info("Shading = " + Shading.toString());
-
- switch (Shading.getShadingType()){
- case 1:
- SHFill_Function(Shading);
- break;
- case 2:
- SHFill_Axial(Shading);
- break;
- case 3:
- SHFill_Radial(Shading);
- break;
- case 4:
- SHFill_FreeGourad(Shading);
- break;
- case 5:
- SHFill_LatticeGourad(Shading);
- break;
- case 6:
- SHFill_CoonsPatch(Shading);
- break;
- case 7:
- SHFill_TensorPatch(Shading);
- break;
-
- default:
- throw new IOException("Invalid ShadingType " + Shading.getShadingType() + " for Shading " + ShadingName);
- }
- }
-
- /**
- * Find the appropriate Shading Dictionary. This is its own private function as it is really not appropriate to override when deriving from PageDrawer.
- *
- * @param ShadingName The name of the Shading Dictionary to use for this fill instruction.
- *
- * @returns The PDShading object
- * @throws IOException If there is an IO error while attempting to find the appropriate PDShading object.
- */
- private PDShading FindShadingDictionary(COSName ShadingName) throws IOException
- {
-
- PDResources resources = (PDResources)page.getResources();
-
- COSDictionary AllShadings = (COSDictionary)(resources.getCOSDictionary().getDictionaryObject(COSName.SHADING));
-
- PDShading Shading = new PDShading(ShadingName, (COSDictionary)(AllShadings.getDictionaryObject(ShadingName)));
-
- return Shading;
-
- }
-
- /**
- * Fill with a Function-based gradient / shading.
- * If extending the class, override this and its siblings, not the public SHFill method.
- *
- * @param Shading The Shading Dictionary to use for this fill instruction.
- *
- * @throws IOException If there is an IO error while shade-filling the path/clipping area.
- */
- protected void SHFill_Function(PDShading Shading) throws IOException
- {
- throw new IOException("Not Implemented");
- }
-
- /**
- * Fill with an Axial Shading.
- * If extending the class, override this and its siblings, not the public SHFill method.
- *
- * @param Shading The Shading Dictionary to use for this fill instruction.
- *
- * @throws IOException If there is an IO error while shade-filling the path/clipping area.
- */
- protected void SHFill_Axial(PDShading Shading) throws IOException
- {
- throw new IOException("Not Implemented");
-
- }
-
- /**
- * Fill with a Radial gradient / shading.
- * If extending the class, override this and its siblings, not the public SHFill method.
- *
- * @param Shading The Shading Dictionary to use for this fill instruction.
- *
- * @throws IOException If there is an IO error while shade-filling the path/clipping area.
- */
- protected void SHFill_Radial(PDShading Shading) throws IOException
- {
- throw new IOException("Not Implemented");
- }
-
- /**
- * Fill with a Free-form Gourad-shaded triangle mesh.
- * If extending the class, override this and its siblings, not the public SHFill method.
- *
- * @param Shading The Shading Dictionary to use for this fill instruction.
- *
- * @throws IOException If there is an IO error while shade-filling the path/clipping area.
- */
- protected void SHFill_FreeGourad(PDShading Shading) throws IOException
- {
- throw new IOException("Not Implemented");
- }
-
- /**
- * Fill with a Lattice-form Gourad-shaded triangle mesh.
- * If extending the class, override this and its siblings, not the public SHFill method.
- *
- * @param Shading The Shading Dictionary to use for this fill instruction.
- *
- * @throws IOException If there is an IO error while shade-filling the path/clipping area.
- */
- protected void SHFill_LatticeGourad(PDShading Shading) throws IOException
- {
- throw new IOException("Not Implemented");
- }
-
- /**
- * Fill with a Coons patch mesh
- * If extending the class, override this and its siblings, not the public SHFill method.
- *
- * @param Shading The Shading Dictionary to use for this fill instruction.
- *
- * @throws IOException If there is an IO error while shade-filling the path/clipping area.
- */
- protected void SHFill_CoonsPatch(PDShading Shading) throws IOException
- {
- throw new IOException("Not Implemented");
- }
-
- /**
- * Fill with a Tensor-product patch mesh.
- * If extending the class, override this and its siblings, not the public SHFill method.
- *
- * @param Shading The Shading Dictionary to use for this fill instruction.
- *
- * @throws IOException If there is an IO error while shade-filling the path/clipping area.
- */
- protected void SHFill_TensorPatch(PDShading Shading) throws IOException
- {
- throw new IOException("Not Implemented");
- }
-}
+++ /dev/null
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.pdfbox.pdmodel.font;
-
-import java.awt.Font;
-import java.io.IOException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.pdfbox.cos.COSArray;
-import org.apache.pdfbox.cos.COSDictionary;
-import org.apache.pdfbox.cos.COSName;
-import org.apache.pdfbox.pdmodel.common.PDRectangle;
-
-/**
- * This is implementation of the Type0 Font.
- * See <a href="https://issues.apache.org/jira/browse/PDFBOX-605">PDFBOX-605</a>
- * for the related improvement issue.
- *
- * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
- * @version $Revision: 1.9 $
- */
-public class PDType0Font extends PDSimpleFont {
-
- /**
- * Log instance.
- */
- private static final Log log = LogFactory.getLog(PDType0Font.class);
- private COSArray descendantFontArray;
- private PDFont descendentFont;
- private COSDictionary descendantFontDictionary;
- private Font awtFont;
- private PDFontDescriptor fontDescriptor;
-
- /**
- * Constructor.
- */
- public PDType0Font() {
- super();
- font.setItem(COSName.SUBTYPE, COSName.TYPE0);
- }
-
- /**
- * Constructor.
- *
- * @param fontDictionary The font dictionary according to the PDF specification.
- */
- public PDType0Font(COSDictionary fontDictionary) {
- super(fontDictionary);
- descendantFontDictionary = (COSDictionary) getDescendantFonts().getObject(0);
- if (descendantFontDictionary != null) {
- try {
- descendentFont = PDFontFactory.createFont(descendantFontDictionary);
- } catch (IOException exception) {
- log.error("Error while creating the descendant font!");
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public Font getawtFont() throws IOException {
- if (awtFont == null) {
- if (descendentFont != null) {
- awtFont = ((PDSimpleFont) descendentFont).getawtFont();
- }
- if (awtFont == null) {
- awtFont = FontManager.getStandardFont();
- log.info("Using font " + awtFont.getName() + " instead of " + descendentFont.getFontDescriptor().getFontName());
- }
- }
- return awtFont;
- }
-
- /**
- * This will get the fonts bounding box.
- *
- * @return The fonts bounding box.
- *
- * @throws IOException If there is an error getting the bounding box.
- */
- public PDRectangle getFontBoundingBox() throws IOException {
- throw new RuntimeException("Not yet implemented");
- }
-
- /**
- * This will get the font width for a character.
- *
- * @param c The character code to get the width for.
- * @param offset The offset into the array.
- * @param length The length of the data.
- *
- * @return The width is in 1000 unit of text space, ie 333 or 777
- *
- * @throws IOException If an error occurs while parsing.
- */
- public float getFontWidth(byte[] c, int offset, int length) throws IOException {
- return descendentFont.getFontWidth(c, offset, length);
- }
-
- /**
- * This will get the font height for a character.
- *
- * @param c The character code to get the height for.
- * @param offset The offset into the array.
- * @param length The length of the data.
- *
- * @return The width is in 1000 unit of text space, ie 333 or 777
- *
- * @throws IOException If an error occurs while parsing.
- */
- public float getFontHeight(byte[] c, int offset, int length) throws IOException {
- return descendentFont.getFontHeight(c, offset, length);
- }
-
- /**
- * This will get the average font width for all characters.
- *
- * @return The width is in 1000 unit of text space, ie 333 or 777
- *
- * @throws IOException If an error occurs while parsing.
- */
- public float getAverageFontWidth() throws IOException {
- return descendentFont.getAverageFontWidth();
- }
-
- private COSArray getDescendantFonts() {
- if (descendantFontArray == null) {
- descendantFontArray = (COSArray) font.getDictionaryObject(COSName.DESCENDANT_FONTS);
- }
- return descendantFontArray;
- }
-
- /**
- * {@inheritDoc}
- */
- public PDFontDescriptor getFontDescriptor() {
- if (fontDescriptor == null) {
- fontDescriptor=super.getFontDescriptor();
- if(fontDescriptor==null){
- fontDescriptor=descendentFont.getFontDescriptor();
- }
- }
- return fontDescriptor;
- }
-
- /**
- * {@inheritDoc}
- */
- public float getFontWidth(int charCode) {
- return descendentFont.getFontWidth(charCode);
- }
-
- @Override
- public String encode(byte[] c, int offset, int length) throws IOException {
- if (hasToUnicode()) {
- return super.encode(c, offset, length);
- } else {
- int result = cmap.lookupCID(c, offset, length);
- if (result != -1) {
- return descendentFont.cmapEncoding(result, 2, true);
- }
- return null;
- }
- }
-}
+++ /dev/null
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.pdfbox.util;
-
-import java.io.IOException;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.Stack;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.pdfbox.cos.COSBase;
-import org.apache.pdfbox.cos.COSObject;
-import org.apache.pdfbox.cos.COSStream;
-import org.apache.pdfbox.exceptions.WrappedIOException;
-
-import org.apache.pdfbox.pdfparser.PDFStreamParser;
-import org.apache.pdfbox.pdmodel.PDPage;
-import org.apache.pdfbox.pdmodel.PDResources;
-
-import org.apache.pdfbox.pdmodel.common.PDMatrix;
-import org.apache.pdfbox.pdmodel.font.PDFont;
-import org.apache.pdfbox.pdmodel.font.PDType3Font;
-
-import org.apache.pdfbox.pdmodel.graphics.PDExtendedGraphicsState;
-import org.apache.pdfbox.pdmodel.graphics.PDGraphicsState;
-import org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace;
-import org.apache.pdfbox.pdmodel.graphics.xobject.PDXObject;
-
-import org.apache.pdfbox.util.operator.OperatorProcessor;
-
-/**
- * This class will run through a PDF content stream and execute certain operations
- * and provide a callback interface for clients that want to do things with the stream.
- * See the PDFTextStripper class for an example of how to use this class.
- *
- * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
- * @version $Revision: 1.38 $
- */
-public class PDFStreamEngine {
-
- /**
- * Log instance.
- */
- private static final Log log = LogFactory.getLog(PDFStreamEngine.class);
- /**
- * The PDF operators that are ignored by this engine.
- */
- private final Set<String> unsupportedOperators = new HashSet<String>();
- private static final byte[] SPACE_BYTES = {(byte) 32};
- private PDGraphicsState graphicsState = null;
- private Matrix textMatrix = null;
- private Matrix textLineMatrix = null;
- private Stack<PDGraphicsState> graphicsStack = new Stack<PDGraphicsState>();
- private Map<String, OperatorProcessor> operators = new HashMap<String, OperatorProcessor>();
- private Stack<StreamResources> streamResourcesStack = new Stack<StreamResources>();
- private PDPage page;
- private Map<String, PDFont> documentFontCache = new HashMap<String, PDFont>();
- private int validCharCnt;
- private int totalCharCnt;
- protected String currentString;
- protected String currentOperator;
- /**
- * Flag to skip malformed or otherwise unparseable input where possible.
- */
- private boolean forceParsing = false;
-
- /**
- * This is a simple internal class used by the Stream engine to handle the
- * resources stack.
- */
- private static class StreamResources {
-
- private Map<String, PDFont> fonts;
- private Map<String, PDColorSpace> colorSpaces;
- private Map<String, PDXObject> xobjects;
- private Map<String, PDExtendedGraphicsState> graphicsStates;
- private PDResources resources;
-
- private StreamResources() {
- }
- ;
-
- }
-
- /**
- * Constructor.
- */
- public PDFStreamEngine() {
- //default constructor
- validCharCnt = 0;
- totalCharCnt = 0;
-
- }
-
- /**
- * Constructor with engine properties. The property keys are all
- * PDF operators, the values are class names used to execute those
- * operators. An empty value means that the operator will be silently
- * ignored.
- *
- * @param properties The engine properties.
- *
- * @throws IOException If there is an error setting the engine properties.
- */
- public PDFStreamEngine(Properties properties) throws IOException {
- if (properties == null) {
- throw new NullPointerException("properties cannot be null");
- }
- Enumeration<?> names = properties.propertyNames();
- for (Object name : Collections.list(names)) {
- String operator = name.toString();
- String processorClassName = properties.getProperty(operator);
- if ("".equals(processorClassName)) {
- unsupportedOperators.add(operator);
- } else {
- try {
- Class<?> klass = Class.forName(processorClassName);
- OperatorProcessor processor =
- (OperatorProcessor) klass.newInstance();
- registerOperatorProcessor(operator, processor);
- } catch (Throwable e) {
- e.printStackTrace();
- }
- }
- }
- validCharCnt = 0;
- totalCharCnt = 0;
- }
-
- public void setCurrentString(String s) {
- currentString = s;
- }
-
- public void setCurrentOperator(String s) {
- currentOperator = s;
- }
-
- public boolean isForceParsing() {
- return forceParsing;
- }
-
- public void setForceParsing(boolean forceParsing) {
- this.forceParsing = forceParsing;
- }
-
- /**
- * Register a custom operator processor with the engine.
- *
- * @param operator The operator as a string.
- * @param op Processor instance.
- */
- public void registerOperatorProcessor(String operator, OperatorProcessor op) {
- op.setContext(this);
- operators.put(operator, op);
- }
-
- /**
- * This method must be called between processing documents. The
- * PDFStreamEngine caches information for the document between pages
- * and this will release the cached information. This only needs
- * to be called if processing a new document.
- *
- */
- public void resetEngine() {
- documentFontCache.clear();
- validCharCnt = 0;
- totalCharCnt = 0;
- }
-
- /**
- * This will process the contents of the stream.
- *
- * @param aPage The page.
- * @param resources The location to retrieve resources.
- * @param cosStream the Stream to execute.
- *
- *
- * @throws IOException if there is an error accessing the stream.
- */
- public void processStream(PDPage aPage, PDResources resources, COSStream cosStream) throws IOException {
- graphicsState = new PDGraphicsState(aPage.findCropBox());
- textMatrix = null;
- textLineMatrix = null;
- graphicsStack.clear();
- streamResourcesStack.clear();
-
- processSubStream(aPage, resources, cosStream);
- }
-
- /**
- * Process a sub stream of the current stream.
- *
- * @param aPage The page used for drawing.
- * @param resources The resources used when processing the stream.
- * @param cosStream The stream to process.
- *
- * @throws IOException If there is an exception while processing the stream.
- */
- public void processSubStream(
- PDPage aPage, PDResources resources, COSStream cosStream)
- throws IOException {
- page = aPage;
-
- if (resources != null) {
- StreamResources sr = new StreamResources();
- sr.fonts = resources.getFonts(documentFontCache);
- sr.colorSpaces = resources.getColorSpaces();
- sr.xobjects = resources.getXObjects();
- sr.graphicsStates = resources.getGraphicsStates();
- sr.resources = resources;
-
- streamResourcesStack.push(sr);
- try {
- processSubStream(cosStream);
- } finally {
- streamResourcesStack.pop();
- }
- } else {
- processSubStream(cosStream);
- }
- }
-
- private void processSubStream(COSStream cosStream) throws IOException {
- List<COSBase> arguments = new ArrayList<COSBase>();
- PDFStreamParser parser = new PDFStreamParser(cosStream, forceParsing);
- try {
- Iterator<Object> iter = parser.getTokenIterator();
-
- while (iter.hasNext()) {
- Object next = iter.next();
- if (log.isDebugEnabled()) {
- log.debug("processing substream token: " + next);
- }
- if (next instanceof COSObject) {
- arguments.add(((COSObject) next).getObject());
- } else if (next instanceof PDFOperator) {
- processOperator((PDFOperator) next, arguments);
- arguments = new ArrayList<COSBase>();
- } else {
- arguments.add((COSBase) next);
- }
- }
- } finally {
- parser.close();
- }
- }
-
- /**
- * A method provided as an event interface to allow a subclass to perform
- * some specific functionality when text needs to be processed.
- *
- * @param text The text to be processed.
- */
- protected void processTextPosition(TextPosition text) {
- //subclasses can override to provide specific functionality.
- }
-
- /**
- * A method provided as an event interface to allow a subclass to perform
- * some specific functionality on the string encoded by a glyph.
- *
- * @param str The string to be processed.
- */
- protected String inspectFontEncoding(String str) {
- return str;
- }
-
- /**
- * Process encoded text from the PDF Stream.
- * You should override this method if you want to perform an action when
- * encoded text is being processed.
- *
- * @param string The encoded text
- *
- * @throws IOException If there is an error processing the string
- */
- public void processEncodedText(byte[] string) throws IOException {
- /* Note on variable names. There are three different units being used
- * in this code. Character sizes are given in glyph units, text locations
- * are initially given in text units, and we want to save the data in
- * display units. The variable names should end with Text or Disp to
- * represent if the values are in text or disp units (no glyph units are saved).
- */
- final float fontSizeText = graphicsState.getTextState().getFontSize();
- final float horizontalScalingText = graphicsState.getTextState().getHorizontalScalingPercent() / 100f;
- //float verticalScalingText = horizontalScaling;//not sure if this is right but what else to do???
- final float riseText = graphicsState.getTextState().getRise();
- final float wordSpacingText = graphicsState.getTextState().getWordSpacing();
- final float characterSpacingText = graphicsState.getTextState().getCharacterSpacing();
-
- //We won't know the actual number of characters until
- //we process the byte data(could be two bytes each) but
- //it won't ever be more than string.length*2(there are some cases
- //were a single byte will result in two output characters "fi"
-
- final PDFont font = graphicsState.getTextState().getFont();
-
-
-
- // all fonts are providing the width/height of a character in thousandths of a unit of text space
- float fontMatrixXScaling = 1 / 1000f;
- float fontMatrixYScaling = 1 / 1000f;
- float glyphSpaceToTextSpaceFactor = 1 / 1000f;
- // expect Type3 fonts, those are providing the width of a character in glyph space units
-
- if (font instanceof PDType3Font) {
- PDMatrix fontMatrix = font.getFontMatrix();
- fontMatrixXScaling = fontMatrix.getValue(0, 0);
- fontMatrixYScaling = fontMatrix.getValue(1, 1);
- //This will typically be 1000 but in the case of a type3 font
- //this might be a different number
- glyphSpaceToTextSpaceFactor = 1f / fontMatrix.getValue(0, 0);
- }
- float spaceWidthText = 0;
- try {
- // to avoid crash as described in PDFBOX-614
- // lets see what the space displacement should be
- spaceWidthText = (font.getFontWidth(SPACE_BYTES, 0, 1) * glyphSpaceToTextSpaceFactor);
- } catch (Throwable exception) {
- exception.printStackTrace();
- }
-
- if (spaceWidthText == 0) {
- spaceWidthText = (font.getAverageFontWidth() * glyphSpaceToTextSpaceFactor);
- //The average space width appears to be higher than necessary
- //so lets make it a little bit smaller.
- spaceWidthText *= .80f;
- }
-
- float maxVerticalDisplacementText = 0;
-
- Matrix textStateParameters = new Matrix();
- textStateParameters.setValue(0, 0, fontSizeText * horizontalScalingText);
- textStateParameters.setValue(1, 1, fontSizeText);
- textStateParameters.setValue(2, 1, riseText);
-
- int pageRotation = page.findRotation();
- float pageHeight = page.findMediaBox().getHeight();
- float pageWidth = page.findMediaBox().getWidth();
-
- Matrix ctm = getGraphicsState().getCurrentTransformationMatrix();
- Matrix textXctm = new Matrix();
- Matrix textMatrixEnd = new Matrix();
- Matrix td = new Matrix();
- Matrix tempMatrix = new Matrix();
-
- int codeLength = 1;
- for (int i = 0; i < string.length; i += codeLength) {
- // Decode the value to a Unicode character
- codeLength = 1;
- String c = font.encode(string, i, codeLength);
- if (c == null && i + 1 < string.length) {
- //maybe a multibyte encoding
- codeLength++;
- c = font.encode(string, i, codeLength);
- }
-
- try {
- String currentChar = Character.toString(currentString.charAt(i));
- if (!currentChar.equals(c)) {
- if (c.toUpperCase().equals(currentChar)) {
- c = c.toUpperCase();
- }
- }
- } catch (NullPointerException e) {
- e.printStackTrace();
- } catch (StringIndexOutOfBoundsException e1) {
- e1.printStackTrace();
- }
-
-
- // the space width has to be transformed into display units
- float spaceWidthDisp = spaceWidthText * fontSizeText * horizontalScalingText * textMatrix.getValue(0, 0) * ctm.getValue(0, 0);
-
- //todo, handle horizontal displacement
- // get the width and height of this character in text units
- float characterHorizontalDisplacementText = font.getFontWidth(string, i, codeLength);
- float characterVerticalDisplacementText = font.getFontHeight(string, i, codeLength);
-
- // multiply the width/height with the scaling factor
- characterHorizontalDisplacementText = characterHorizontalDisplacementText * fontMatrixXScaling;
- characterVerticalDisplacementText = characterVerticalDisplacementText * fontMatrixYScaling;
-
- maxVerticalDisplacementText =
- Math.max(
- maxVerticalDisplacementText,
- characterVerticalDisplacementText);
-
- // PDF Spec - 5.5.2 Word Spacing
- //
- // Word spacing works the same was as character spacing, but applies
- // only to the space character, code 32.
- //
- // Note: Word spacing is applied to every occurrence of the single-byte
- // character code 32 in a string. This can occur when using a simple
- // font or a composite font that defines code 32 as a single-byte code.
- // It does not apply to occurrences of the byte value 32 in multiple-byte
- // codes.
- //
- // RDD - My interpretation of this is that only character code 32's that
- // encode to spaces should have word spacing applied. Cases have been
- // observed where a font has a space character with a character code
- // other than 32, and where word spacing (Tw) was used. In these cases,
- // applying word spacing to either the non-32 space or to the character
- // code 32 non-space resulted in errors consistent with this interpretation.
- //
- float spacingText = 0;
- if ((string[i] == 0x20) && codeLength == 1) {
- spacingText += wordSpacingText;
- }
- textXctm = textMatrix.multiply(ctm, textXctm);
- // Convert textMatrix to display units
- // We need to instantiate a new Matrix instance here as it is passed to the TextPosition constructor below.
- Matrix textMatrixStart = textStateParameters.multiply(textXctm);
-
- // TODO : tx should be set for horizontal text and ty for vertical text
- // which seems to be specified in the font (not the direction in the matrix).
- float tx = ((characterHorizontalDisplacementText) * fontSizeText) * horizontalScalingText;
- float ty = 0;
- // reset the matrix instead of creating a new one
- td.reset();
- td.setValue(2, 0, tx);
- td.setValue(2, 1, ty);
-
- // The text matrix gets updated after each glyph is placed. The updated
- // version will have the X and Y coordinates for the next glyph.
- // textMatrixEnd contains the coordinates of the end of the last glyph without
- // taking characterSpacingText and spacintText into account, otherwise it'll be
- // impossible to detect new words within text extraction
- tempMatrix = textStateParameters.multiply(td, tempMatrix);
- textMatrixEnd = tempMatrix.multiply(textXctm, textMatrixEnd);
- final float endXPosition = textMatrixEnd.getXPosition();
- final float endYPosition = textMatrixEnd.getYPosition();
-
- // add some spacing to the text matrix (see comment above)
- tx = ((characterHorizontalDisplacementText) * fontSizeText + characterSpacingText + spacingText) * horizontalScalingText;
- td.setValue(2, 0, tx);
- textMatrix = td.multiply(textMatrix, textMatrix);
-
- // determine the width of this character
- // XXX: Note that if we handled vertical text, we should be using Y here
- float startXPosition = textMatrixStart.getXPosition();
- float widthText = endXPosition - startXPosition;
-
- //there are several cases where one character code will
- //output multiple characters. For example "fi" or a
- //glyphname that has no mapping like "visiblespace"
- if (c != null) {
- validCharCnt++;
- } else {
- // PDFBOX-373: Replace a null entry with "?" so it is
- // not printed as "(null)"
- c = "?";
- }
- totalCharCnt++;
-
- c = mergeLigatures(c);
-
- float totalVerticalDisplacementDisp = maxVerticalDisplacementText * fontSizeText * textMatrix.getYScale();
-
- // process the decoded text
- processTextPosition(
- new TextPosition(
- pageRotation,
- pageWidth,
- pageHeight,
- textMatrixStart,
- endXPosition,
- endYPosition,
- totalVerticalDisplacementDisp,
- widthText,
- spaceWidthDisp,
- c,
- font,
- fontSizeText,
- (int) (fontSizeText * textMatrix.getXScale())));
-
- }
-
-
- }
-
- public String mergeLigatures(String c) {
- if (c.length() <= 1) {
- return c;
- }
- if (c.length() >= 2) {
-
- HashMap<String, String> ligatures = new HashMap<>();
- ligatures.put("AE", "\u00C6");
- ligatures.put("ae", "\u00E6");
- ligatures.put("OE", "\u0152");
- ligatures.put("oe", "\u0153");
- ligatures.put("IJ", "\u0132");
- ligatures.put("ij", "\u0133");
- ligatures.put("ff", "\ufb00");
- ligatures.put("fi", "\ufb01");
- ligatures.put("fl", "\ufb02");
- ligatures.put("ffi", "\ufb03");
- ligatures.put("ffl", "\ufb04");
-
- if (ligatures.containsKey(c)) {
- return ligatures.get(c);
- }
- }
-
-
- return c;
- }
-
- /**
- * This is used to handle an operation.
- *
- * @param operation The operation to perform.
- * @param arguments The list of arguments.
- *
- * @throws IOException If there is an error processing the operation.
- */
- public void processOperator(String operation, List<COSBase> arguments) throws IOException {
- try {
- PDFOperator oper = PDFOperator.getOperator(operation);
- processOperator(oper, arguments);
- } catch (IOException e) {
- //log.warn(e, e);
- }
- }
-
- /**
- * This is used to handle an operation.
- *
- * @param operator The operation to perform.
- * @param arguments The list of arguments.
- *
- * @throws IOException If there is an error processing the operation.
- */
- protected void processOperator(PDFOperator operator, List<COSBase> arguments) throws IOException {
- try {
- String operation = operator.getOperation();
- OperatorProcessor processor = (OperatorProcessor) operators.get(operation);
- if (processor != null) {
- processor.setContext(this);
- processor.process(operator, arguments);
- } else {
- if (!unsupportedOperators.contains(operation)) {
- //log.info("unsupported/disabled operation: " + operation);
- unsupportedOperators.add(operation);
- }
- }
- } catch (Exception e) {
- //log.warn(e, e);
- }
- }
-
- /**
- * @return Returns the colorSpaces.
- */
- public Map<String, PDColorSpace> getColorSpaces() {
- return streamResourcesStack.peek().colorSpaces;
- }
-
- /**
- * @return Returns the colorSpaces.
- */
- public Map<String, PDXObject> getXObjects() {
- return streamResourcesStack.peek().xobjects;
- }
-
- /**
- * @param value The colorSpaces to set.
- */
- public void setColorSpaces(Map<String, PDColorSpace> value) {
- streamResourcesStack.peek().colorSpaces = value;
- }
-
- /**
- * @return Returns the fonts.
- */
- public Map<String, PDFont> getFonts() {
- return streamResourcesStack.peek().fonts;
- }
-
- /**
- * @param value The fonts to set.
- */
- public void setFonts(Map<String, PDFont> value) {
- streamResourcesStack.peek().fonts = value;
- }
-
- /**
- * @return Returns the graphicsStack.
- */
- public Stack<PDGraphicsState> getGraphicsStack() {
- return graphicsStack;
- }
-
- /**
- * @param value The graphicsStack to set.
- */
- public void setGraphicsStack(Stack<PDGraphicsState> value) {
- graphicsStack = value;
- }
-
- /**
- * @return Returns the graphicsState.
- */
- public PDGraphicsState getGraphicsState() {
- return graphicsState;
- }
-
- /**
- * @param value The graphicsState to set.
- */
- public void setGraphicsState(PDGraphicsState value) {
- graphicsState = value;
- }
-
- /**
- * @return Returns the graphicsStates.
- */
- public Map<String, PDExtendedGraphicsState> getGraphicsStates() {
- return streamResourcesStack.peek().graphicsStates;
- }
-
- /**
- * @param value The graphicsStates to set.
- */
- public void setGraphicsStates(Map<String, PDExtendedGraphicsState> value) {
- ((StreamResources) streamResourcesStack.peek()).graphicsStates = value;
- }
-
- /**
- * @return Returns the textLineMatrix.
- */
- public Matrix getTextLineMatrix() {
- return textLineMatrix;
- }
-
- /**
- * @param value The textLineMatrix to set.
- */
- public void setTextLineMatrix(Matrix value) {
- textLineMatrix = value;
- }
-
- /**
- * @return Returns the textMatrix.
- */
- public Matrix getTextMatrix() {
- return textMatrix;
- }
-
- /**
- * @param value The textMatrix to set.
- */
- public void setTextMatrix(Matrix value) {
- textMatrix = value;
- }
-
- /**
- * @return Returns the resources.
- */
- public PDResources getResources() {
- return streamResourcesStack.peek().resources;
- }
-
- /**
- * Get the current page that is being processed.
- *
- * @return The page being processed.
- */
- public PDPage getCurrentPage() {
- return page;
- }
-
- /**
- * Get the total number of valid characters in the doc
- * that could be decoded in processEncodedText().
- * @return The number of valid characters.
- */
- public int getValidCharCnt() {
- return validCharCnt;
- }
-
- /**
- * Get the total number of characters in the doc
- * (including ones that could not be mapped).
- * @return The number of characters.
- */
- public int getTotalCharCnt() {
- return totalCharCnt;
- }
-}
+++ /dev/null
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.pdfbox.util.operator;
-
-import java.util.List;
-
-import org.apache.pdfbox.cos.COSBase;
-import org.apache.pdfbox.cos.COSString;
-import org.apache.pdfbox.util.PDFOperator;
-
-import java.io.IOException;
-
-/**
- * @author Huault : huault@free.fr
- * @version $Revision: 1.4 $
- */
-public class ShowText extends OperatorProcessor {
-
- /**
- * Tj show Show text.
- * @param operator The operator that is being executed.
- * @param arguments List
- *
- * @throws IOException If there is an error processing this operator.
- */
- public void process(PDFOperator operator, List<COSBase> arguments) throws IOException {
- COSString string = (COSString) arguments.get(0);
- context.setCurrentString(string.getString());
-
- context.processEncodedText(string.getBytes());
-
- }
-}
+++ /dev/null
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.pdfbox.util.operator;
-
-import java.util.List;
-
-import org.apache.pdfbox.util.Matrix;
-import org.apache.pdfbox.util.PDFOperator;
-import org.apache.pdfbox.cos.COSArray;
-import org.apache.pdfbox.cos.COSBase;
-import org.apache.pdfbox.cos.COSNumber;
-import java.io.IOException;
-import org.apache.pdfbox.cos.COSString;
-
-/**
- * @author Huault : huault@free.fr
- * @version $Revision: 1.6 $
- */
-public class ShowTextGlyph extends OperatorProcessor {
-
- /**
- * TJ Show text, allowing individual glyph positioning.
- * @param operator The operator that is being executed.
- * @param arguments List
- * @throws IOException If there is an error processing this operator.
- */
- public void process(PDFOperator operator, List<COSBase> arguments) throws IOException {
- COSArray array = (COSArray) arguments.get(0);
- int arraySize = array.size();
- float fontsize = context.getGraphicsState().getTextState().getFontSize();
- float horizontalScaling = context.getGraphicsState().getTextState().getHorizontalScalingPercent() / 100;
- for (int i = 0; i < arraySize; i++) {
- COSBase next = array.get(i);
- if (next instanceof COSNumber) {
- float adjustment = ((COSNumber) next).floatValue();
- Matrix adjMatrix = new Matrix();
- adjustment = -(adjustment / 1000) * horizontalScaling * fontsize;
- // TODO vertical writing mode
- adjMatrix.setValue(2, 0, adjustment);
- context.setTextMatrix(adjMatrix.multiply(context.getTextMatrix(), adjMatrix));
- } else if (next instanceof COSString) {
- context.setCurrentString(((COSString) next).getString());
- context.processEncodedText(((COSString) next).getBytes());
-
- } else {
- throw new IOException("Unknown type in array for TJ operation:" + next);
- }
- }
- }
-}
$limit = is_null($limit) ? '' : $this->con->limit($limit[0], $limit[1]);\r
\r
$sql = 'SELECT * FROM factures_vue WHERE ' . $where . ' ORDER BY ' . $orderby . ' ' . $sens . ' ' . $limit;\r
- fb($sql);\r
$r = $this->con->select($sql);\r
return $this->factory($r);\r
}\r
protected function preparePackage() {
parent::preparePackage();
-
- $compiler = wsHTML5Compiler::factory($this->book_id, null, true, $this->vdir);
+
+ $compiler = wsHTML5Compiler::factory($this->book_id, null, true, $this->vdir . '/www');
$compiler->compile();
+
+ unlink($this->vdir . '/www/indext.html');
+ unlink($this->vdir . '/www/indexu.html');
+ unlink($this->vdir . '/www/widget.html');
+ unlink($this->vdir . '/www/cache.appcache');
+ rmdir($this->vdir . '/data');
+
+ $this->makeCompileScripts();
+ }
+
+ protected function makeCompileScripts() {
+
+ $projectPath = '~/Documents/PhonegapApps/Fluidbook_' . $this->book_id;
+ $projectName = 'Fluidbook_' . $this->book_id;
+
+ $create = '#! /bin/sh' . "\n";
+ $create .='DIR="$( cd "$( dirname "$0" )" && pwd )"' . "\n";
+ $create .='rm -rf ' . $projectPath . "\n";
+ $create .= '~/Documents/Cordova/bin/create ' . $projectPath . ' com.fluidbook.ios.' . $this->book_id . ' ' . $projectName . "\n";
+ $create .='cp -R $DIR/www ' . $projectPath . "\n";
+ $create .='open ' . $projectPath . "\n";
+ file_put_contents($this->vdir . '/create', $create);
+ chmod($this->vdir . '/create', 0755);
+
+ $build = '#! /bin/sh' . "\n";
+ $build.=$projectPath . '/cordova/debug' . "\n";
+ file_put_contents($this->vdir . '/build', $build);
+ chmod($this->vdir . '/build', 0755);
}
public function makePackage($zip) {