Skip to content

Java2d fast renderer plus fix output device #521

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Aug 12, 2020
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ public class FSRGBColor implements FSColor {
public static final FSRGBColor GREEN = new FSRGBColor(0, 255, 0);
public static final FSRGBColor BLUE = new FSRGBColor(0, 0, 255);
public static final FSRGBColor BLACK = new FSRGBColor(0, 0, 0);
private int _red;
private int _green;
private int _blue;

private final int _red;
private final int _green;
private final int _blue;

public FSRGBColor(int red, int green, int blue) {
if (red < 0 || red > 255) {
throw new IllegalArgumentException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.openhtmltopdf.bidi.BidiReorderer;
import com.openhtmltopdf.bidi.SimpleBidiReorderer;
import com.openhtmltopdf.context.StyleReference;
import com.openhtmltopdf.css.style.CalculatedStyle;
import com.openhtmltopdf.css.style.CssContext;
import com.openhtmltopdf.css.value.FontSpecification;
import com.openhtmltopdf.extend.*;
Expand All @@ -45,7 +46,7 @@ public class RenderingContext implements CssContext, Cloneable {

private int pageNo;
private PageBox page;
private int shadowPageNumber;
private int shadowPageNumber = -1;

private Layer rootLayer;

Expand Down Expand Up @@ -74,7 +75,7 @@ public void setBaseURL(String url) {
}

public UserAgentCallback getUac() {
return sharedContext.getUac();
return sharedContext.getUserAgentCallback();
}

public String getBaseURL() {
Expand Down Expand Up @@ -142,6 +143,19 @@ public FSCanvas getCanvas() {
}

public Rectangle getFixedRectangle() {
if (!outputDevice.isPDF() && !isPaged()) {
return new Rectangle(
-this.page.getMarginBorderPadding(this, CalculatedStyle.LEFT),
-this.page.getTop() - this.page.getMarginBorderPadding(this, CalculatedStyle.TOP),
this.page.getContentWidth(this),
this.page.getContentHeight(this));
} else if (!outputDevice.isPDF() && isPaged()) {
return new Rectangle(
0, -this.page.getTop(),
this.page.getContentWidth(this),
this.page.getContentHeight(this));
}

Rectangle result;
if (! isPrint()) {
result = sharedContext.getFixedRectangle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ private void collectInline(CssContext c, Layer layer) {

public void collectFloats(CssContext c, Layer layer) {
for (int iflt = layer.getFloats().size() - 1; iflt >= 0; iflt--) {
BlockBox floater = (BlockBox) layer.getFloats().get(iflt);
BlockBox floater = layer.getFloats().get(iflt);

int pgStart = findStartPage(c, floater, layer.getCurrentTransformMatrix());
int pgEnd = findEndPage(c, floater, layer.getCurrentTransformMatrix());
Expand Down Expand Up @@ -396,9 +396,9 @@ public void collect(CssContext c, Layer layer, Box container, int pgStart, int p

BlockBox block = (BlockBox) container;

if (block.isNeedsClipOnPaint((RenderingContext) c)) {
if (block.isNeedsClipOnPaint(c)) {
// A box with overflow set to hidden.
ourClip = block.getChildrenClipEdge((RenderingContext) c);
ourClip = block.getChildrenClipEdge(c);
clipPages = new ArrayList<>();
}
}
Expand Down Expand Up @@ -497,7 +497,7 @@ private void addLineBoxToShadowPage(CssContext c, Layer layer, LineBox container
shadowPageResult.addInline(container);

// Recursively add all children of the line box to the inlines list.
((LineBox) container).addAllChildren(shadowPageResult._inlines, layer);
container.addAllChildren(shadowPageResult._inlines, layer);
}
}

Expand All @@ -513,7 +513,7 @@ private void addLineBoxToAll(CssContext c, Layer layer, LineBox container, int b
pageResult.addInline(container);

// Recursively add all children of the line box to the inlines list.
((LineBox) container).addAllChildren(pageResult._inlines, layer);
container.addAllChildren(pageResult._inlines, layer);
}

if (includeShadowPages && pageBox.shouldInsertPages()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private enum TransformYOrigin {
* This transform can be applied on top of other tranforms already in effect on the page.
*/
public static AffineTransform createPageCoordinatesTranform(RenderingContext c, Box box, PageBox page, int shadowPageNumber) {
TransformYOrigin yOrigin = c.getOutputDevice().isPDF() ? TransformYOrigin.PAGE_BOTTOM : TransformYOrigin.PAGE_TOP;
TransformYOrigin yOrigin = c.getOutputDevice().isPDF() ? TransformYOrigin.PAGE_BOTTOM : TransformYOrigin.DOCUMENT_TOP;

AffineTransform start = new AffineTransform();

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

import com.openhtmltopdf.extend.FSImage;
import com.openhtmltopdf.swing.AWTFSImage;
import com.openhtmltopdf.swing.MutableFSImage;

/**
* @author Administrator
*/
public class ImageResource extends AbstractResource {
private final String _imageUri;
private FSImage _img;
Expand All @@ -44,7 +40,7 @@ public FSImage getImage() {
}

public boolean isLoaded() {
return _img instanceof MutableFSImage ? ((MutableFSImage) _img).isLoaded() : true;
return true;
}

public String getImageUri() {
Expand All @@ -64,25 +60,3 @@ public boolean hasDimensions(final int width, final int height) {
}
}
}

/*
* $Id$
*
* $Log$
* Revision 1.6 2009/05/15 16:20:13 pdoubleya
* ImageResource now tracks the URI for the image that was created and handles mutable images.
*
* Revision 1.4 2007/04/11 21:09:06 pdoubleya
* Remove commented block
*
* Revision 1.3 2006/02/02 02:47:36 peterbrant
* Support non-AWT images
*
* Revision 1.2 2005/06/25 17:23:34 tobega
* first refactoring of UAC: ImageResource
*
* Revision 1.1 2005/02/03 20:39:35 pdoubleya
* Added to CVS.
*
*
*/

This file was deleted.

This file was deleted.

This file was deleted.

Loading