Skip to content

Commit

Permalink
Unmerge codec packages from transcoder module, except for three classes
Browse files Browse the repository at this point in the history
This allows improved dependency granularity.
  • Loading branch information
carlosame committed Jul 11, 2024
1 parent 331be27 commit cf0fac2
Show file tree
Hide file tree
Showing 52 changed files with 94 additions and 97 deletions.
7 changes: 5 additions & 2 deletions MIGRATING_FROM_BATIK.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Batik:

- Improved conformance to the SVG and CSS specifications.

- Better user experience (_e.g._ the `codec`-`transcoder` merge).
- Better user experience (_e.g._ the `codec` classes that got merged into `transcoder`).

- A circularity with Apache FOP. To render PDF images, Batik uses FOP which in
turn uses Batik, so depending on FOP would imply mixing EchoSVG and Batik. See
Expand All @@ -26,7 +26,10 @@ Batik:

2) Class names that included the name "Batik" now have "EchoSVG".

3) The `codec` and `transcoder` modules were merged into one. See [issue #11](https://github.com/css4j/echosvg/issues/11).
3) The `codec`-`transcoder` circular dependency was removed in the following way:
a few classes from the `codec` module were moved to two new packages in
`transcoder` (that aren't exported by that module). Now `transcoder` explicitly
depends on `codec` (but not the other way around).

4) Tcl and Python 2.x scripting was removed (see issues [#12](https://github.com/css4j/echosvg/issues/12)
and [#13](https://github.com/css4j/echosvg/issues/13)). That scripting wasn't
Expand Down
13 changes: 13 additions & 0 deletions echosvg-codec/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
plugins {
id 'echosvg.java-conventions'
}

dependencies {
api project(':echosvg-awt-util')
}

description = 'io.sf.carte:echosvg-codec'

publishing.publications.maven(MavenPublication).pom {
description = "EchoSVG AWT image codecs"
}
44 changes: 44 additions & 0 deletions echosvg-codec/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* Licensed 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.
*/

/**
* AWT image codecs.
*
* @provides io.sf.carte.echosvg.ext.awt.image.spi.ImageWriter
* @provides io.sf.carte.echosvg.ext.awt.image.spi.RegistryEntry
*/
module io.sf.carte.echosvg.codec {

exports io.sf.carte.echosvg.ext.awt.image.codec.imageio;
exports io.sf.carte.echosvg.ext.awt.image.codec.png;
exports io.sf.carte.echosvg.ext.awt.image.codec.util;

requires transitive io.sf.carte.echosvg.awt;
requires io.sf.carte.echosvg.i18n;

provides io.sf.carte.echosvg.ext.awt.image.spi.ImageWriter
with io.sf.carte.echosvg.ext.awt.image.codec.imageio.ImageIOPNGImageWriter,
io.sf.carte.echosvg.ext.awt.image.codec.imageio.ImageIOTIFFImageWriter,
io.sf.carte.echosvg.ext.awt.image.codec.imageio.ImageIOJPEGImageWriter;

provides io.sf.carte.echosvg.ext.awt.image.spi.RegistryEntry
with io.sf.carte.echosvg.ext.awt.image.codec.png.PNGRegistryEntry,
io.sf.carte.echosvg.ext.awt.image.codec.imageio.ImageIOJPEGRegistryEntry,
io.sf.carte.echosvg.ext.awt.image.codec.imageio.ImageIOPNGRegistryEntry,
io.sf.carte.echosvg.ext.awt.image.codec.imageio.ImageIOTIFFRegistryEntry;

}
1 change: 0 additions & 1 deletion echosvg-ext/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
id 'echosvg.java-conventions'
id 'org.gradlex.extra-java-module-info'
}

dependencies {
Expand Down
1 change: 1 addition & 0 deletions echosvg-svggen/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {

dependencies {
api project(':echosvg-awt-util')
runtimeOnly project(':echosvg-codec')
}

description = 'io.sf.carte:echosvg-svggen'
Expand Down
1 change: 1 addition & 0 deletions echosvg-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ dependencies {
api project(':echosvg-swing')
implementation "io.sf.jclf:jclf-text:${jclfTextVersion}"
// Required by tests
implementation project(':echosvg-codec')
testImplementation testFixtures(project(':echosvg-util'))
testImplementation "org.junit.jupiter:junit-jupiter:${junitVersion}"
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
Expand Down
1 change: 1 addition & 0 deletions echosvg-test/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@
/*
* Required by tests.
*/
requires io.sf.carte.echosvg.codec;
requires io.sf.carte.echosvg.constants;
}
1 change: 1 addition & 0 deletions echosvg-transcoder/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
dependencies {
api project(':echosvg-bridge')
api project(':echosvg-svggen')
implementation project(':echosvg-codec')
implementation "io.sf.carte:css4j-awt:$css4jAwtVersion"
implementation "xml-apis:xml-apis:$xmlApisVersion"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
import java.awt.image.BufferedImage;
import java.awt.image.SinglePixelPackedSampleModel;
import java.io.OutputStream;
import java.lang.reflect.InvocationTargetException;

import io.sf.carte.echosvg.transcoder.TranscoderException;
import io.sf.carte.echosvg.transcoder.TranscoderOutput;
import io.sf.carte.echosvg.transcoder.TranscodingHints;
import io.sf.carte.echosvg.transcoder.image.resources.Messages;
import io.sf.carte.echosvg.transcoder.keys.FloatKey;
import io.sf.carte.echosvg.transcoder.keys.IntegerKey;
import io.sf.carte.echosvg.transcoder.png.PNGTranscoderInternalCodecWriteAdapter;

/**
* This class is an <code>ImageTranscoder</code> that produces a PNG image.
Expand Down Expand Up @@ -57,25 +57,6 @@ public BufferedImage createImage(int width, int height) {
return new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
}

private WriteAdapter getWriteAdapter(String className) {
WriteAdapter adapter;
try {
Class<?> clazz = Class.forName(className);
adapter = (WriteAdapter) clazz.getDeclaredConstructor().newInstance();
return adapter;
} catch (ClassNotFoundException e) {
return null;
} catch (InstantiationException e) {
return null;
} catch (IllegalAccessException e) {
return null;
} catch (NoSuchMethodException e) {
return null;
} catch (InvocationTargetException e) {
return null;
}
}

/**
* Writes the specified image to the specified output.
*
Expand Down Expand Up @@ -107,15 +88,9 @@ public void writeImage(BufferedImage img, TranscoderOutput output) throws Transc
forceTransparentWhite(img, sppsm);
}

WriteAdapter adapter = getWriteAdapter(
"io.sf.carte.echosvg.ext.awt.image.codec.png.PNGTranscoderInternalCodecWriteAdapter");
if (adapter == null) {
adapter = getWriteAdapter(
"io.sf.carte.echosvg.ext.awt.image.codec.imageio.PNGTranscoderImageIOWriteAdapter");
}
if (adapter == null) {
throw new TranscoderException("Could not write PNG file because no WriteAdapter is available");
}
WriteAdapter adapter = new PNGTranscoderInternalCodecWriteAdapter();
//WriteAdapter adapter = new io.sf.carte.echosvg.transcoder.imageio.PNGTranscoderImageIOWriteAdapter();

adapter.writeImage(this, img, output);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@

import java.awt.image.BufferedImage;
import java.awt.image.SinglePixelPackedSampleModel;
import java.lang.reflect.InvocationTargetException;

import io.sf.carte.echosvg.transcoder.TranscoderException;
import io.sf.carte.echosvg.transcoder.TranscoderOutput;
import io.sf.carte.echosvg.transcoder.TranscodingHints;
import io.sf.carte.echosvg.transcoder.imageio.TIFFTranscoderImageIOWriteAdapter;
import io.sf.carte.echosvg.transcoder.keys.StringKey;

/**
Expand Down Expand Up @@ -55,25 +55,6 @@ public BufferedImage createImage(int width, int height) {
return new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
}

private WriteAdapter getWriteAdapter(String className) {
WriteAdapter adapter;
try {
Class<?> clazz = Class.forName(className);
adapter = (WriteAdapter) clazz.getDeclaredConstructor().newInstance();
return adapter;
} catch (ClassNotFoundException e) {
return null;
} catch (InstantiationException e) {
return null;
} catch (IllegalAccessException e) {
return null;
} catch (NoSuchMethodException e) {
return null;
} catch (InvocationTargetException e) {
return null;
}
}

/**
* Writes the specified image to the specified output.
*
Expand All @@ -100,15 +81,8 @@ public void writeImage(BufferedImage img, TranscoderOutput output) throws Transc
forceTransparentWhite(img, sppsm);
}

WriteAdapter adapter = getWriteAdapter(
"io.sf.carte.echosvg.ext.awt.image.codec.tiff.TIFFTranscoderInternalCodecWriteAdapter");
if (adapter == null) {
adapter = getWriteAdapter(
"io.sf.carte.echosvg.ext.awt.image.codec.imageio.TIFFTranscoderImageIOWriteAdapter");
}
if (adapter == null) {
throw new TranscoderException("Could not write TIFF file because no WriteAdapter is availble");
}
WriteAdapter adapter = new TIFFTranscoderImageIOWriteAdapter();

adapter.writeImage(this, img, output);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
limitations under the License.
*/
package io.sf.carte.echosvg.ext.awt.image.codec.imageio;
package io.sf.carte.echosvg.transcoder.imageio;

import java.awt.image.BufferedImage;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
limitations under the License.
*/
package io.sf.carte.echosvg.ext.awt.image.codec.imageio;
package io.sf.carte.echosvg.transcoder.imageio;

import java.awt.image.BufferedImage;
import java.awt.image.DataBuffer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
limitations under the License.
*/
package io.sf.carte.echosvg.ext.awt.image.codec.png;
package io.sf.carte.echosvg.transcoder.png;

import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.OutputStream;

import io.sf.carte.echosvg.ext.awt.image.codec.png.PNGEncodeParam;
import io.sf.carte.echosvg.ext.awt.image.codec.png.PNGImageEncoder;
import io.sf.carte.echosvg.ext.awt.image.rendered.IndexImage;
import io.sf.carte.echosvg.transcoder.TranscoderException;
import io.sf.carte.echosvg.transcoder.TranscoderOutput;
Expand Down
20 changes: 1 addition & 19 deletions echosvg-transcoder/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@

/**
* SVG transcoder.
*
* @provides io.sf.carte.echosvg.ext.awt.image.spi.ImageWriter
* @provides io.sf.carte.echosvg.ext.awt.image.spi.RegistryEntry
*/
module io.sf.carte.echosvg.transcoder {
exports io.sf.carte.echosvg.transcoder;
Expand All @@ -31,26 +28,11 @@
exports io.sf.carte.echosvg.transcoder.wmf;
exports io.sf.carte.echosvg.transcoder.wmf.tosvg;

exports io.sf.carte.echosvg.ext.awt.image.codec.imageio;
exports io.sf.carte.echosvg.ext.awt.image.codec.png;
exports io.sf.carte.echosvg.ext.awt.image.codec.util;

requires transitive io.sf.carte.echosvg.bridge;
requires transitive io.sf.carte.echosvg.svggen;
requires io.sf.carte.echosvg.codec;
requires io.sf.carte.echosvg.i18n;
requires io.sf.carte.echosvg.xml;
requires io.sf.carte.xml.dtd;
requires io.sf.carte.css4j.awt;

provides io.sf.carte.echosvg.ext.awt.image.spi.ImageWriter
with io.sf.carte.echosvg.ext.awt.image.codec.imageio.ImageIOPNGImageWriter,
io.sf.carte.echosvg.ext.awt.image.codec.imageio.ImageIOTIFFImageWriter,
io.sf.carte.echosvg.ext.awt.image.codec.imageio.ImageIOJPEGImageWriter;

provides io.sf.carte.echosvg.ext.awt.image.spi.RegistryEntry
with io.sf.carte.echosvg.ext.awt.image.codec.png.PNGRegistryEntry,
io.sf.carte.echosvg.ext.awt.image.codec.imageio.ImageIOJPEGRegistryEntry,
io.sf.carte.echosvg.ext.awt.image.codec.imageio.ImageIOPNGRegistryEntry,
io.sf.carte.echosvg.ext.awt.image.codec.imageio.ImageIOTIFFRegistryEntry;

}
29 changes: 15 additions & 14 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,30 @@ pluginManagement {

rootProject.name = 'echosvg'

include(':echosvg-svggen')
include(':echosvg-ext')
include(':echosvg-dom')
include(':echosvg-xml')
include(':echosvg-bridge')
include(':echosvg-i18n')
include(':echosvg-constants')
include(':echosvg-svgpp')
include(':echosvg-xml')
include(':echosvg-util')
include(':echosvg-gui-util')
include(':echosvg-script')
include(':echosvg-anim')
include(':echosvg-awt-util')
include(':echosvg-gvt')
include(':echosvg-ext')
include(':echosvg-css')
include(':echosvg-svgrasterizer')
include(':echosvg-swing')
include(':echosvg-dom')
include(':echosvg-parser')
include(':echosvg-svg-dom')
include(':echosvg-anim')
include(':echosvg-bridge')
include(':echosvg-svggen')
include(':echosvg-script')
include(':echosvg-swing')
include(':echosvg-codec')
include(':echosvg-transcoder')
include(':echosvg-extension')
include(':echosvg-util')
include(':echosvg-svgpp')
include(':echosvg-ttf2svg')
include(':echosvg-slideshow')
include(':echosvg-parser')
include(':echosvg-gvt')
include(':echosvg-test-scripts')
include(':echosvg-test')
include(':echosvg-slideshow')
include(':echosvg-svgrasterizer')
include(':echosvg-all')

0 comments on commit cf0fac2

Please sign in to comment.