Skip to content
Commits on Source (10)
environment:
AV_PROJECTS: 'c:\projects'
AV_BF_M2: 'c:\projects\m2'
AV_BF_SOURCE: 'c:\projects\bioformats'
# Note that only Oracle JDK is provided.
matrix:
- java: 11
build: maven
- java: 1.8
build: maven
- java: 1.8
build: ant
ant_version: 1.10.1
cache:
- '%AV_BF_M2% -> appveyor.yml'
os: 'Visual Studio 2015'
clone_folder: '%AV_BF_SOURCE%'
clone_depth: 5
platform: x64
init:
- git config --global core.autocrlf input
- if [%build%] == [ant] appveyor-retry cinst -y ant --version %ant_version%
- refreshenv
- 'if [%java%] == [1.8] set "JAVA_HOME=C:\Program Files\Java\jdk1.8.0"'
- 'if [%java%] == [11] set "JAVA_HOME=C:\Program Files\Java\jdk11"'
- PATH=%JAVA_HOME%\bin;%PATH%
- 'if [%build%] == [maven] set "MAVEN_OPTS=-Dmaven.repo.local=%AV_BF_M2%"'
- 'if [%build%] == [ant] set "ANT_OPTS=-Dmaven.repo.local=%AV_BF_M2%"'
build_script:
- tools\test-build %build%
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="components/autogen/src"/>
<classpathentry kind="src" path="components/formats-api/build/src"/>
<classpathentry kind="src" path="components/formats-api/src"/>
<classpathentry kind="src" path="components/formats-bsd/build/src"/>
......
.classpath
.idea
.project
.settings
.DS_Store
.idea
artifacts
build
components/*/utils/*.class
......@@ -14,3 +16,6 @@ testng.css
tools/*.jar
*.log
*.xpr
*.class
*.iml
.*.swp
......@@ -9,14 +9,17 @@ sudo: false
cache:
directories:
- $HOME/.m2
- downloads
addons:
apt_packages:
- git
jdk:
- openjdk11
- oraclejdk11
- openjdk8
- oraclejdk8
- openjdk7
env:
- BUILD=maven
......@@ -24,9 +27,15 @@ env:
matrix:
fast_finish: true
before_install:
- if [[ $BUILD == 'ant' ]]; then pip install --user flake8 Sphinx; fi
exclude:
- jdk: oraclejdk11
env: BUILD=ant
- jdk: openjdk11
env: BUILD=ant
- jdk: oraclejdk8
env: BUILD=ant
- jdk: openjdk8
env: BUILD=maven
script:
- ./tools/test-build $BUILD
......@@ -51,13 +51,6 @@ please ensure you read these.
The documentation hosted at
https://docs.openmicroscopy.org/bio-formats/ is built from the
`/docs/sphinx/` directory. Contributions are welcome but please follow the
style guidance from the
[Bio-Formats Documentation Repository](https://github.com/ome/bio-formats-documentation).
Contributions are welcome but please follow the style guidance from the
[OME Documentation Repository README](https://github.com/openmicroscopy/ome-documentation/blob/develop/README.rst#conventions-used).
Documentation for new supported formats is auto-generated - see
[Adding format/reader documentation pages](https://docs.openmicroscopy.org/latest/bio-formats/developers/format-documentation.html). If you need any assistance please
contact the [mailing list](https://www.openmicroscopy.org/support)
before embarking on such a change, or submit your new reader code and let one
of the main OME team deal with the documentation for you.
FROM openjdk:8
MAINTAINER ome-devel@lists.openmicroscopy.org.uk
# Installs Ant
ENV ANT_VERSION 1.9.4
RUN wget -q http://archive.apache.org/dist/ant/binaries/apache-ant-${ANT_VERSION}-bin.zip && \
unzip apache-ant-${ANT_VERSION}-bin.zip && \
mv apache-ant-${ANT_VERSION} /opt/ant && \
rm apache-ant-${ANT_VERSION}-bin.zip
RUN useradd -m bf
COPY . /opt/bioformats/
RUN chown -R bf /opt/bioformats
USER bf
WORKDIR /opt/bioformats
RUN /opt/ant/bin/ant clean jars tools
ENV TZ "Europe/London"
WORKDIR /opt/bioformats/components/test-suite
ENTRYPOINT ["/opt/ant/bin/ant", "test-automated", "-Dtestng.directory=/opt/data", "-Dtestng.configDirectory=/opt/config"]
......@@ -6,6 +6,8 @@ Bio-Formats is a standalone Java library for reading and writing life sciences
image file formats. It is capable of parsing both pixels and metadata for a
large number of formats, as well as writing to several formats.
If you are having an issue with Bio-Formats and need support, please see the
[support page](./SUPPORT.md).
Purpose
-------
......@@ -15,7 +17,6 @@ an open standard called the OME data model, particularly into the OME-TIFF
file format. See [About Bio-Formats](https://docs.openmicroscopy.org/latest/bio-formats/about/index.html)
for further information.
Supported formats
-----------------
......@@ -42,7 +43,6 @@ More information
For more information, see the [Bio-Formats web
site](https://www.openmicroscopy.org/bio-formats).
Pull request testing
--------------------
......@@ -57,7 +57,7 @@ following before submitting a pull request:
* test at least one file in each affected format, using the ```showinf```
command
* internal developers only: [run the data
tests](docs/sphinx/developers/commit-testing.rst)
tests](https://github.com/ome/bio-formats-documentation/blob/master/sphinx/developers/commit-testing.rst)
against directories corresponding to the affected format(s)
* make sure that your commits contain the correct authorship information and,
if necessary, a signed-off-by line
......
# Support for Bio-Formats
Full documentation is hosted at
https://docs.openmicroscopy.org/latest/bio-formats/
If you need to contact us for further assistance, please see the
[support page](https://www.openmicroscopy.org/support/) - our preferred
channels for support are our mailing lists and forums.
Before filing a bug report, please read and follow the
[guidance for bug reporting](https://docs.openmicroscopy.org/latest/bio-formats/about/bug-reporting.html).
You can submit files to our [QA system](http://qa.openmicroscopy.org.uk/qa/upload/)
or for large files (>2 GB), please write to the
[OME Users mailing list](http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-users)
and we will contact you privately with an FTP server address. If possible,
please submit a file we can make public for testing purposes. However, we will
keep files private on request.
\ No newline at end of file
......@@ -14,17 +14,8 @@ Type "ant -p" for a list of targets.
<!-- Convenient JDK version properties -->
<available property="jdk1.7+" classname="java.util.Objects"/>
<available property="jdk1.8+" classname="java.util.stream.IntStream"/>
<target name="javadoc-properties">
<if>
<isset property="jdk1.8+"/>
<then>
<property name="javadoc.doclint" value="-Xdoclint:none"/>
</then>
</if>
<property name="javadoc.doclint" value=""/>
</target>
<!-- Convenient platform properties -->
......
......@@ -112,6 +112,7 @@ Type "ant -p" for a list of targets.
<pathelement location="${test-classes.dir}"/>
<pathelement location="${test.dir}"/>
</classpath>
<sysproperty key="bioformats_can_do_upgrade_check" value="false"/>
<xmlfileset file="${testng.xml}"/>
<jvmarg value="-mx${testng.memory}"/>
</testng>
......@@ -127,7 +128,7 @@ Type "ant -p" for a list of targets.
<then>
<findbugs home="${findbugs.home}" jvmargs="-Xmx512m"
output="xml:withMessages" outputFile="${build.dir}/findbugs.xml"
excludeFilter="${root.dir}/excludebugs.xml" reportLevel="high"
excludeFilter="${root.dir}/excludebugs.xml" reportLevel="medium"
errorProperty="findbugsErrors"
warningsProperty="findbugsWarnings">
<auxClasspath refid="runtime.classpath"/>
......@@ -228,7 +229,7 @@ your FindBugs installation's lib directory. E.g.:
<fileset dir="${utils.dir}" includes="**/*.class"/>
</delete>
<javac debug="true" includeantruntime="false" fork="true"
deprecation="true" source="1.7" target="1.7"
deprecation="true" source="1.8" target="1.8"
encoding="UTF-8"
srcdir="${utils.dir}" includes="**/*.java"
classpath="${artifact.dir}/${component.jar}">
......@@ -249,11 +250,9 @@ your FindBugs installation's lib directory. E.g.:
<classpath refid="runtime.classpath"/>
<doctitle><![CDATA[<h1>Bio-Formats</h1>]]></doctitle>
<bottom><![CDATA[${copyright.begin} ${YEAR} ${copyright.end}]]></bottom>
<link href="http://docs.oracle.com/javase/7/docs/api/"/>
<link href="http://rsbweb.nih.gov/ij/developer/api/"/>
<link href="http://www.ssec.wisc.edu/visad-docs/javadoc/"/>
<!--<link href="http://www.jdocs.com/formlayout/1.0.4/api/"/>-->
<!--<link href="http://www.jdocs.com/looks/1.2.2/api/"/>-->
<link href="http://docs.oracle.com/javase/8/docs/api/"/>
<link href="https://imagej.net/developer/api/"
offline="true" packagelistLoc="${root.dir}/ant/package-list"/>
</javadoc>
</target>
......
ij
ij.gui
ij.io
ij.macro
ij.measure
ij.plugin
ij.plugin.filter
ij.plugin.frame
ij.plugin.tool
ij.process
ij.text
ij.util
......@@ -13,8 +13,7 @@ Type "ant -p" for a list of targets.
<!-- Global build targets -->
<target name="compile"
depends="compile-autogen,
compile-formats-gpl,
depends="compile-formats-gpl,
compile-bio-formats-plugins,
compile-formats-api,
compile-formats-bsd,
......@@ -25,7 +24,6 @@ Type "ant -p" for a list of targets.
<target name="jars"
depends="copy-jars,
jar-autogen,
jar-formats-gpl,
jar-bio-formats-plugins,
jar-formats-api,
......@@ -36,8 +34,7 @@ Type "ant -p" for a list of targets.
description="generate JAR files for software packages"/>
<target name="findbugs"
depends="findbugs-autogen,
findbugs-formats-gpl,
depends="findbugs-formats-gpl,
findbugs-bio-formats-plugins,
findbugs-formats-api,
findbugs-formats-bsd,
......@@ -47,7 +44,6 @@ Type "ant -p" for a list of targets.
<target name="clean"
depends="
clean-autogen,
clean-formats-gpl,
clean-bio-formats-plugins,
clean-formats-api,
......@@ -55,7 +51,6 @@ Type "ant -p" for a list of targets.
clean-bio-formats-tools,
clean-tests,
clean-turbojpeg,
clean-docs-sphinx,
clean-bundles"
description="remove build files for all components">
<delete dir="${artifact.dir}"/>
......@@ -63,8 +58,7 @@ Type "ant -p" for a list of targets.
</target>
<target name="test"
depends="test-autogen,
test-formats-gpl,
depends="test-formats-gpl,
test-bio-formats-plugins,
test-formats-api,
test-formats-bsd,
......@@ -89,19 +83,6 @@ Type "ant -p" for a list of targets.
<target name="docs-zip" depends="docs"/>
<target name="docs-sphinx"
description="generate the Sphinx HTML documentation">
<echo>----------=========== Sphinx HTML ===========----------</echo>
<ant dir="docs/sphinx" target="html"/>
<echo>----------=========== Sphinx MAN ===========----------</echo>
<ant dir="docs/sphinx" target="man"/>
</target>
<target name="clean-docs-sphinx"
description="remove build files for the Sphinx HTML documentation">
<ant dir="docs/sphinx" target="clean"/>
</target>
<target name="copy-jars" description="copy JARS (deprecated)"/>
<target name="testing-deps" depends="copy-jars"/>
......@@ -131,11 +112,6 @@ Type "ant -p" for a list of targets.
<ant dir="components/formats-api" target="formats-api.clean"/>
</target>
<target name="utils-formats-api" depends="jar-formats-api"
description="compile extra utilities for reader and writer APIs">
<ant dir="components/formats-api" target="formats-api.utils"/>
</target>
<target name="test-formats-api" depends="jar-formats-api, testing-deps"
description="compile and run tests for reader and writer APIs">
<ant dir="components/formats-api" target="test"/>
......@@ -253,37 +229,6 @@ Type "ant -p" for a list of targets.
<ant dir="components/formats-gpl" target="test"/>
</target>
<!-- Bio-Formats autogen -->
<target name="deps-autogen"
depends="copy-jars, jar-formats-api,jar-formats-bsd,jar-formats-gpl"/>
<target name="compile-autogen" depends="deps-autogen"
description="compile classes for Bio-Formats autogen">
<ant dir="components/autogen" target="autogen.compile"/>
</target>
<target name="jar-autogen" depends="deps-autogen"
description="generate JAR file for Bio-Formats autogen">
<ant dir="components/autogen" target="autogen.jar"/>
</target>
<target name="findbugs-autogen" depends="jar-autogen"
description="run findbugs on Bio-Formats autogen">
<ant dir="components/autogen" target="autogen.findbugs"/>
</target>
<target name="clean-autogen"
depends="clean-formats-api,clean-formats-bsd"
description="remove build files for Bio-Formats autogen">
<ant dir="components/autogen" target="autogen.clean"/>
</target>
<target name="test-autogen" depends="jar-autogen, testing-deps"
description="compile and run tests for Bio-Formats autogen">
<ant dir="components/autogen" target="test"/>
</target>
<!-- Bio-Formats Plugins for ImageJ -->
<target name="deps-bio-formats-plugins"
......@@ -445,8 +390,6 @@ Type "ant -p" for a list of targets.
prefix="bioformats/" excludes="DESCRIPTION.in"/>
<tarfileset file="${temp.file}" fullpath="bioformats/DESCRIPTION"/>
<tarfileset file="${root.dir}/LICENSE.txt" fullpath="bioformats/COPYING"/>
<tarfileset file="${root.dir}/docs/sphinx/about/whats-new.rst"
fullpath="bioformats/NEWS"/>
<tarfileset dir="${root.dir}/components/formats-gpl/matlab"
prefix="bioformats/inst/"/>
</tar>
......
......@@ -10,17 +10,6 @@ This build file handles the following components.
For more information on a component, see the
build.properties file in that component's subtree.
Formats code generator
Package for generating other code, including the Bio-Formats metadata API,
related documentation, Ice bindings, and Bio-Formats C++ bindings headers
-=-
JAR file: bf-autogen.jar
Path: components/autogen
Project deps: Bio-Formats, Formats Common
Library deps: Apache Velocity
Optional: (none)
License: GPL
Bio-Formats
A library for reading and writing popular microscopy file formats
-=-
......
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
#
# build.properties
#
# Ant properties file for Bio-Formats code generators.
# Download Apache Ant from http://ant.apache.org/.
# Type "ant -p" for a list of targets.
component.name = bf-autogen
component.jar = bf-autogen.jar
component.version = 1.0.0
component.java-version = 1.7
component.deprecation = true
component.resources-bin =
component.resources-text = *.txt \
**/*.vm \
*.sh
component.main-class = MetaSupportAutogen
component.meta-support-dir = ${root.dir}/components/formats-gpl
omexml.version=2016-06
filelist=src/format-pages.txt
<!--
build.xml
Ant build file for Bio-Formats code generators.
Download Apache Ant from http://ant.apache.org/.
Type "ant -p" for a list of targets.
-->
<project name="autogen" default="jar" basedir=".">
<description>Build file for Bio-Formats code generators</description>
<property name="root.dir" location="../.."/>
<import file="${root.dir}/ant/java.xml"/>
<property file="build.properties"/>
<target name="gen-metadata-ratings" depends="compile"
description="update format metadata ratings">
<java classname="MetadataRatings"
classpath="${classes.dir}" fork="true" failonerror="true">
<classpath refid="runtime.classpath"/>
<arg value="${src.dir}/format-pages.txt"/>
</java>
</target>
<target name="gen-format-pages" depends="compile"
description="generate Sphinx pages for each supported format">
<java classname="FormatPageAutogen"
classpath="${classes.dir}" fork="true" failonerror="true">
<classpath location="${root.dir}/ant/"/><!-- logback.xml -->
<classpath refid="runtime.classpath"/>
<arg value="${filelist}"/>
</java>
</target>
<target name="gen-structure-table" depends="compile"
description="generate dataset structure table">
<java classname="MakeDatasetStructureTable"
classpath="${classes.dir}" fork="true" failonerror="true">
<classpath location="${root.dir}/ant/"/><!-- logback.xml -->
<classpath refid="runtime.classpath"/>
<arg value="../../docs/sphinx/formats/dataset-table.rst"/>
</java>
</target>
<target name="gen-original-meta-support" depends="compile"
description="generate docs for Bio-Formats original metadata support">
<java classname="OriginalMetadataAutogen"
classpath="${classes.dir}" fork="true" failonerror="true">
<classpath location="${root.dir}/ant/"/><!-- logback.xml -->
<classpath refid="runtime.classpath"/>
<arg value="${filelist}"/>
</java>
</target>
<target name="gen-meta-support" depends="compile"
description="generate docs for Bio-Formats metadata support">
<exec executable="python">
<arg value="${src.dir}/gen-meta-support.py"/>
<arg value="${ome-model.version}"/>
</exec>
<if>
<isset property="omexml.version"/>
<then>
<java classname="${component.main-class}"
classpath="${classes.dir}"
fork="true" dir="${component.meta-support-dir}" failonerror="true">
<classpath location="${root.dir}/ant/"/><!-- logback.xml -->
<classpath refid="runtime.classpath"/>
<arg value="${omexml.version}"/>
</java>
</then>
<else>
<echo>
Please set the omexml.version property to match
the latest release of the OME-XML schema. E.g.:
ant -Domexml.version=2008-09 gen-meta-support
</echo>
</else>
</if>
</target>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>ome</groupId>
<artifactId>pom-bio-formats</artifactId>
<version>5.7.2</version>
<relativePath>../..</relativePath>
</parent>
<artifactId>bf-autogen</artifactId>
<name>Bio-Formats code generator</name>
<description>Package for generating other code, particularly the Bio-Formats metadata documentation.</description>
<url>https://www.openmicroscopy.org/bio-formats</url>
<inceptionYear>2007</inceptionYear>
<licenses>
<license>
<name>GNU General Public License v2+</name>
<url>http://www.gnu.org/licenses/gpl-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<dependencies>
<dependency>
<groupId>org.openmicroscopy</groupId>
<artifactId>ome-common</artifactId>
<version>${ome-common.version}</version>
</dependency>
<dependency>
<groupId>org.openmicroscopy</groupId>
<artifactId>ome-xml</artifactId>
<version>${ome-model.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>formats-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>formats-bsd</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>formats-gpl</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.6.4</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logback.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
<scope>runtime</scope>
</dependency>
</dependencies>
<properties>
<project.rootdir>${basedir}/../..</project.rootdir>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>MetaSupportAutogen</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
<configuration>
<licenseName>gpl_v2</licenseName>
<projectName>Bio-Formats autogen package for programmatically generating source code.</projectName>
</configuration>
</plugin>
</plugins>
</build>
<developers>
<developer>
<id>curtis</id>
<name>Curtis Rueden</name>
<email>ctrueden@wisc.edu</email>
<url>http://loci.wisc.edu/people/curtis-rueden</url>
<organization>UW-Madison LOCI</organization>
<organizationUrl>http://loci.wisc.edu/</organizationUrl>
<roles>
<role>architect</role>
<role>developer</role>
</roles>
<timezone>-6</timezone>
<properties>
<picUrl>http://loci.wisc.edu/files/loci/images/people/curtis-2010.jpg</picUrl>
</properties>
</developer>
<developer>
<id>melissa</id>
<name>Melissa Linkert</name>
<email>melissa@glencoesoftware.com</email>
<url>https://www.glencoesoftware.com/melissa-linkert.html</url>
<organization>Glencoe Software</organization>
<organizationUrl>http://glencoesoftware.com/</organizationUrl>
<roles>
<role>developer</role>
</roles>
<timezone>-6</timezone>
</developer>
</developers>
</project>
/*
* #%L
* Bio-Formats autogen package for programmatically generating source code.
* %%
* Copyright (C) 2007 - 2017 Open Microscopy Environment:
* - Board of Regents of the University of Wisconsin-Madison
* - Glencoe Software, Inc.
* - University of Dundee
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-2.0.html>.
* #L%
*/
import java.util.HashMap;
/**
* An entity is an object that contains a bundle of {@link Property} objects.
* It has a list of default attributes (key/value pairs),
* as well as a list of version overrides for those attributes.
*
* @see {EntityList}
*
* @author Curtis Rueden ctrueden at wisc.edu
*/
public class Entity {
// -- Fields --
/** The entity's attributes. */
protected HashMap<String, String> attrs;
/** The entity's properties. */
protected HashMap<String, Property> props =
new HashMap<String, Property>();
/** The entity's version overrides. */
protected HashMap<String, HashMap<String, String>> versions =
new HashMap<String, HashMap<String, String>>();
// -- Constructor --
/** Creates a new entity with the given attributes. */
public Entity(HashMap<String, String> attrs) {
this.attrs = attrs;
}
}
/*
* #%L
* Bio-Formats autogen package for programmatically generating source code.
* %%
* Copyright (C) 2007 - 2017 Open Microscopy Environment:
* - Board of Regents of the University of Wisconsin-Madison
* - Glencoe Software, Inc.
* - University of Dundee
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-2.0.html>.
* #L%
*/
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.StringTokenizer;
import loci.common.IniList;
import loci.common.IniParser;
import loci.common.IniTable;
/**
* An EntityList is a list of entities parsed from an INI-style resource,
* represented as a hierarchical tree structure. Here is a partial example:
* <pre>
* + entity list
* |--+ versions
* | |--+ 2003FC
* | | ...
* | |--+ 200706
* | | \- name = 200706
* | | \- class = OMEXML200706Metadata
* | | \- id = OMEXML200706Metadata.java
* | | \- basePackage = ome.xml.r200706
* | | \- subPackage = ome
* | | \- version = 2007-06
* | |--+ 200802
* | | ...
* | |...
* |--+ entities
* |--+ Image
* | ...
* |--+ Pixels
* | ...
* |--+ Dimensions
* | |--+ properties
* | | \- path = Image+/Pixels+
* | | \- description = A set of pixel dimensions in the metadata store.
* | |--+ entity version overrides
* | | |--+ 2003FC
* | | \- path = Image+/CA/Dimensions
* | |--+ properties
* | |--+ PhysicalSizeX
* | | |--+ properties
* | | | \- type = Float
* | | | \- description = Width of each pixel in microns.
* | | |--+ property version overrides
* | | |-+ 2003FC
* | | \- getter = getPixelSizeX
* | | \- setter = setPixelSizeX
* | |--+ PhysicalSizeY
* | | |--+ properties
* | | | \- type = Float
* | | | \- description = Height of each pixel in microns.
* | | |--+ property version overrides
* | | |-+ 2003FC
* | | \- getter = getPixelSizeY
* | | \- setter = setPixelSizeY
* | |--+ PhysicalSizeZ
* | | |--+ properties
* | | | \- type = Float
* | | | \- description = Distance between focal planes in microns.
* | | |--+ property version overrides
* | | |-+ 2003FC
* | | \- getter = getPixelSizeZ
* | | \- setter = setPixelSizeZ
* | |--+ TimeIncrement
* | | |--+ properties
* | | | \- type = Float
* | | | \- description = Distance between time points in seconds.
* | | |--+ property version overrides
* | | |-+ 2003FC
* | | \- getter = getPixelSizeT
* | | \- setter = setPixelSizeT
* | |--+ WaveStart
* | | |--+ properties
* | | | \- type = Integer
* | | | \- description = Starting wavelength in nanometers.
* | | |--+ property version overrides
* | | |-+ 2003FC
* | | \- available = false
* | |--+ WaveIncrement
* | |--+ properties
* | | \- type = Integer
* | | \- description = Distance between wavelengths in nanometers.
* | |--+ property version overrides
* | |-+ 2003FC
* | \- type = Float
* | \- getter = getPixelSizeC
* | \- setter = setPixelSizeC
* |...
* </pre>
*
* @author Curtis Rueden ctrueden at wisc.edu
*/
public class EntityList {
// -- Constants --
private static final boolean DEBUG = false;
// -- Fields --
/** List of versions and their details. */
protected HashMap<String, HashMap<String, String>> versions =
new HashMap<String, HashMap<String, String>>();
/** List of entities. */
protected HashMap<String, Entity> entities =
new HashMap<String, Entity>();
/** The active version. */
protected String ver;
/** The active entity. */
protected String ent;
/** The active property. */
protected String prop;
// -- Constructor --
/** Constructs an entity list. */
public EntityList(String versionPath, String entityPath) throws IOException {
// parse INI data
System.out.println("Parsing configuration data");
IniParser parser = new IniParser();
IniList versionList = parser.parseINI(versionPath, EntityList.class);
IniList entityList = parser.parseINI(entityPath, EntityList.class);
// convert unprocessed INI-style config data into
// hierarchical entity/property/version structure
// process list of versions
for (HashMap<String, String> attrs : versionList) {
String name = attrs.get(IniTable.HEADER_KEY);
versions.put(name, attrs);
}
// process list of entities
entities = new HashMap<String, Entity>();
for (HashMap<String, String> attrs : entityList) {
String name = attrs.get(IniTable.HEADER_KEY);
if (DEBUG) debug("-- Parsing entry '" + name + "' --");
// "entity" list actually contains attribute tables for entities,
// properties and version overrides; determine which kind this one is
StringTokenizer st = new StringTokenizer(name);
int num = st.countTokens();
switch (num) {
case 1:
// entity header
if (DEBUG) debug("Entry is an entity definition");
entities.put(name, new Entity(attrs));
System.out.println("\t" + name);
if (DEBUG) debug("Added entity '" + name + "'");
break;
case 2:
// property header, or entity version header
String t1 = st.nextToken();
String t2 = st.nextToken();
Entity entity = entities.get(t1);
if (entity == null) {
throw new IOException("bad entity name '" + t1 + "'");
}
attrs.put(IniTable.HEADER_KEY, t2);
if (DEBUG) debug("Reset header value to '" + t2 + "'");
HashMap<String, String> version = versions.get(t2);
if (version == null) {
// property header
if (DEBUG) debug("Entry is a property definition");
entity.props.put(t2, new Property(attrs));
if (DEBUG) {
debug("Added property '" + t2 + "' to entity '" + t1 + "'");
}
}
else {
// entity version header
if (DEBUG) debug("Entry is an entity version definition");
entity.versions.put(t2, attrs);
if (DEBUG) {
debug("Added version '" + t2 + "' to entity '" + t1 + "'");
}
}
break;
case 3:
// property version header
if (DEBUG) debug("Entry is a property version definition");
t1 = st.nextToken();
t2 = st.nextToken();
String t3 = st.nextToken();
entity = entities.get(t1);
if (entity == null) {
throw new IOException("bad entity name '" + t1 + "'");
}
Property prop = entity.props.get(t2);
if (prop == null) {
throw new IOException("bad property name '" +
t2 + "' for entity '" + t1 + "'");
}
attrs.put(IniTable.HEADER_KEY, t2);
if (DEBUG) debug("Reset header value to '" + t2 + "'");
prop.versions.put(t3, attrs);
if (DEBUG) {
debug("Added property '" + t2 +
"' to version '" + t3 + "' of entity '" + t1 + "'");
}
break;
default:
throw new IOException("bad token count for header '" + name + "'");
}
}
}
// -- EntityList API methods --
/** Sets the active version. */
public void setVersion(String version) {
ver = version;
}
/** Gets the active version. */
public String getVersion() {
return ver;
}
/** Sets the active entity. */
public void setEntity(String entity) {
ent = entity;
prop = null;
}
/** Gets the active entity. */
public String getEntity() {
return ent;
}
/** Sets the active property. */
public void setProperty(String property) {
prop = property;
}
/** Gets the active property. */
public String getProperty() {
return prop;
}
/** Gets list of versions in sorted order. */
public List<String> versions() {
List<String> list = new ArrayList<String>(versions.keySet());
Collections.sort(list);
return list;
}
/** Gets the list of entities in sorted order. */
public List<String> entities() {
List<String> list = new ArrayList<String>(entities.keySet());
Collections.sort(list);
return list;
}
/** Gets a sorted list of properties for the active entity. */
public List<String> props() {
if (ent == null) return null;
Entity e = entities.get(ent);
List<String> list = new ArrayList<String>(e.props.keySet());
Collections.sort(list);
return list;
}
/** Gets the attribute value for the header key. */
public String name() { return value(IniTable.HEADER_KEY); }
/**
* Queries the attribute value for the given key, for the active version,
* property and entity.
*/
public String value(String key) {
return value(key, ver, ent, prop);
}
/**
* Queries the attribute value for the given key, for a particular version of
* a particular property of a particular entity. The attribute value is
* obtained from an attributes table according to following order of
* precedence:
* <ol>
* <li>version override of the given property of the given entity</li>
* <li>default value of the given property of the given entity</li>
* <li>version override of the given entity</li>
* <li>default value of the given entity itself</li>
* <li>default value in the given version's attribute table</li>
* </ol>
* Returns null if the attribute is not found in any of the above tables.
*/
public String value(String key,
String version, String entity, String property)
{
Entity e = null;
Property p = null;
if (entity != null) e = entities.get(entity);
if (property != null && e != null) p = e.props.get(property);
String value = null;
// version override of the given property of the given entity
if (value == null && version != null && p != null) {
HashMap<String, String> attrs = p.versions.get(version);
if (attrs != null) value = attrs.get(key);
}
// default value of the given property of the given entity
if (value == null && p != null) value = p.attrs.get(key);
// version override of the given entity
if (value == null && version != null && e != null) {
HashMap<String, String> attrs = e.versions.get(version);
if (attrs != null) value = attrs.get(key);
}
// default value of the given entity itself
if (value == null && e != null) value = e.attrs.get(key);
// default value in the given version's attribute table
if (value == null && version != null) {
HashMap<String, String> attrs = versions.get(version);
if (attrs != null) value = attrs.get(key);
}
return value;
}
// -- Helper methods --
private void debug(String s) {
System.out.println("DEBUG: " + s);
}
}
/*
* #%L
* Bio-Formats autogen package for programmatically generating source code.
* %%
* Copyright (C) 2007 - 2017 Open Microscopy Environment:
* - Board of Regents of the University of Wisconsin-Madison
* - Glencoe Software, Inc.
* - University of Dundee
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-2.0.html>.
* #L%
*/
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Hashtable;
import loci.common.DataTools;
import loci.common.IniList;
import loci.common.IniParser;
import loci.common.IniTable;
import loci.formats.FormatException;
import loci.formats.ImageReader;
import loci.formats.UnknownFormatException;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;
/**
*
* @author Melissa Linkert melissa at glencoesoftware.com
*/
public class FormatPageAutogen {
// -- Constants --
private static final String TEMPLATE = "doc/FormatPage.vm";
private static final String TABLE_TEMPLATE = "doc/FormatTable.vm";
// -- Fields --
private IniList data;
// -- Constructor --
public FormatPageAutogen(String dataFile) throws FormatException, IOException
{
String file = DataTools.readFile(dataFile);
IniParser parser = new IniParser();
parser.setCommentDelimiter(null);
data = parser.parseINI(new BufferedReader(new StringReader(file)));
}
// -- API Methods --
public void writeFormatPages() throws Exception {
File doc = new File("../../docs/sphinx/formats/");
if (!doc.exists()) {
boolean success = doc.mkdir();
if (!success) {
throw new IOException("Could not create " + doc.getAbsolutePath());
}
}
VelocityEngine engine = VelocityTools.createEngine();
for (IniTable table : data) {
VelocityContext context = VelocityTools.createContext();
String format = table.get(IniTable.HEADER_KEY);
context.put("format", format);
if (table.containsKey("extensions")) {
context.put("extensions", table.get("extensions"));
}
if (table.containsKey("indexExtensions")) {
context.put("indexExtensions", table.get("indexExtensions"));
}
else if (table.containsKey("extensions")){
context.put("indexExtensions", table.get("extensions"));
}
context.put("owner", table.get("owner"));
context.put("developer", table.get("developer"));
context.put("bsd", table.get("bsd"));
context.put("export", table.get("export"));
context.put("pyramid", table.get("pyramid"));
if (table.containsKey("versions")) {
context.put("versions", table.get("versions"));
}
else {
context.put("versions", "");
}
context.put("pixelsRating", table.get("pixelsRating"));
context.put("metadataRating", table.get("metadataRating"));
context.put("opennessRating", table.get("opennessRating"));
context.put("presenceRating", table.get("presenceRating"));
context.put("utilityRating", table.get("utilityRating"));
context.put("reader", table.get("reader"));
context.put("writer", table.get("writer"));
context.put("mif", table.get("mif"));
context.put("notes", table.get("notes"));
context.put("privateSpecification", table.get("privateSpecification"));
context.put("options", table.get("options"));
context.put("readerextlink",
table.get("bsd").equals("no") ? "bfreader" : "bsd-reader");
context.put("writerextlink",
table.get("bsd").equals("no") ? "bfwriter" : "bsd-writer");
if (table.containsKey("software")) {
String[] software = table.get("software").split("\n");
context.put("software", software);
}
if (table.containsKey("weHave")) {
String[] weHave = table.get("weHave").split("\n");
context.put("weHave", weHave);
}
if (table.containsKey("weWant")) {
String[] weWant = table.get("weWant").split("\n");
context.put("weWant", weWant);
}
if (table.containsKey("samples")) {
String[] samples = table.get("samples").split("\n");
context.put("samples", samples);
}
if (table.containsKey("notes")) {
String[] notes = table.get("notes").split("\n");
context.put("notes", notes);
}
if (table.containsKey("reader")) {
String[] reader = table.get("reader").split(", ");
context.put("reader", reader);
}
String filename = getPageName(format, table.get("pagename"));
if (table.containsKey("metadataPage")) {
String page = table.get("metadataPage");
if (page.length() > 0) {
context.put("metadataPage", page.split(", "));
}
} else {
String[] page = {filename.substring(filename.indexOf(File.separator) + 1) + "-metadata"};
context.put("metadataPage", page);
}
VelocityTools.processTemplate(engine, context, TEMPLATE,
"../../docs/sphinx/" + filename + ".rst");
}
}
public void writeFormatTable() throws Exception {
File doc = new File("../../docs/sphinx/");
if (!doc.exists()) {
boolean success = doc.mkdir();
if (!success) {
throw new IOException("Could not create " + doc.getAbsolutePath());
}
}
VelocityEngine engine = VelocityTools.createEngine();
VelocityContext context = VelocityTools.createContext();
IniTable[] sortedTable = new IniTable[data.size()];
for (int i=0; i<data.size(); i++) {
IniTable table = data.get(i);
table.put("pagename",
getPageName(table.get(IniTable.HEADER_KEY), table.get("pagename")));
sortedTable[i] = table;
}
Arrays.sort(sortedTable, new Comparator<IniTable>() {
@Override
public int compare(IniTable t1, IniTable t2) {
String page1 = t1.get("pagename");
String page2 = t2.get("pagename");
return page1.compareTo(page2);
}
});
context.put("formats", sortedTable);
context.put("count", sortedTable.length);
VelocityTools.processTemplate(engine, context, TABLE_TEMPLATE,
"../../docs/sphinx/supported-formats.rst");
}
// -- Helper methods --
protected static String getPageName(String format, String pagename) {
String realPageName = pagename;
if (realPageName == null) {
realPageName = format.replaceAll("/", "");
realPageName = realPageName.replaceAll("\\(", "");
realPageName = realPageName.replaceAll("\\)", "");
realPageName = realPageName.replaceAll("\\.", "");
realPageName = realPageName.replaceAll("& ", "");
realPageName = realPageName.replaceAll(" ", "-");
realPageName = realPageName.toLowerCase();
}
realPageName = "formats/" + realPageName;
return realPageName;
}
// -- Main method --
public static void main(String[] args) throws Exception {
FormatPageAutogen autogen = new FormatPageAutogen(args[0]);
autogen.writeFormatPages();
autogen.writeFormatTable();
}
}