Skip to content

Commit

Permalink
For #73 - Building on work by @rototor - creates a Java2D renderer fo…
Browse files Browse the repository at this point in the history
…r paged output.

For now, I’ve copied accross the files I needed to alter to the java2d
sub-module to avoid breaking things. Eventually we can get rid of all
Java2D and Swing code from the core.

Currently the renderer and builder in the sub-module are for paged
output only but I think we can combine both paged and continuous in the
one builder/renderer.
  • Loading branch information
danfickle committed Mar 5, 2017
1 parent ab8e436 commit b080c24
Show file tree
Hide file tree
Showing 19 changed files with 1,573 additions and 58 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.openhtmltopdf.outputdevice.helper;

import java.io.File;

import org.w3c.dom.Document;

public class BaseDocument {
public final String html;
public final Document document;
public final File file;
public final String uri;
public final String baseUri;

public BaseDocument(String baseUri, String html, Document document, File file, String uri) {
this.html = html;
this.document = document;
this.file = file;
this.uri = uri;
this.baseUri = baseUri;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.openhtmltopdf.outputdevice.helper;

import org.w3c.dom.Element;

import com.openhtmltopdf.extend.UserInterface;

public class NullUserInterface implements UserInterface {
public boolean isHover(Element e) {
return false;
}

public boolean isActive(Element e) {
return false;
}

public boolean isFocus(Element e) {
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.openhtmltopdf.outputdevice.helper;

public class PageDimensions {
public final Float w;
public final Float h;
public final boolean isSizeInches;

public PageDimensions(Float w, Float h, boolean isSizeInches) {
this.w = w;
this.h = h;
this.isSizeInches = isSizeInches;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.openhtmltopdf.outputdevice.helper;

import com.openhtmltopdf.bidi.BidiReorderer;
import com.openhtmltopdf.bidi.BidiSplitterFactory;
import com.openhtmltopdf.extend.FSTextBreaker;
import com.openhtmltopdf.extend.FSTextTransformer;

public class UnicodeImplementation {
public final BidiReorderer reorderer;
public final BidiSplitterFactory splitterFactory;
public final FSTextBreaker lineBreaker;
public final FSTextBreaker charBreaker;
public final FSTextTransformer toLowerTransformer;
public final FSTextTransformer toUpperTransformer;
public final FSTextTransformer toTitleTransformer;
public final boolean textDirection;

public UnicodeImplementation(BidiReorderer reorderer, BidiSplitterFactory splitterFactory,
FSTextBreaker lineBreaker, FSTextTransformer toLower, FSTextTransformer toUpper,
FSTextTransformer toTitle, boolean textDirection, FSTextBreaker charBreaker) {
this.reorderer = reorderer;
this.splitterFactory = splitterFactory;
this.lineBreaker = lineBreaker;
this.toLowerTransformer = toLower;
this.toUpperTransformer = toUpper;
this.toTitleTransformer = toTitle;
this.textDirection = textDirection;
this.charBreaker = charBreaker;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
*/
package com.openhtmltopdf.swing;

import com.openhtmltopdf.bidi.BidiReorderer;
import com.openhtmltopdf.css.parser.FSColor;
import com.openhtmltopdf.css.parser.FSRGBColor;
import com.openhtmltopdf.extend.*;
import com.openhtmltopdf.render.*;
import com.openhtmltopdf.simple.Java2DRendererBuilder;

import javax.swing.*;

import java.awt.*;
import java.awt.RenderingHints.Key;
import java.awt.font.GlyphVector;
Expand Down Expand Up @@ -330,4 +332,29 @@ public float getAbsoluteTransformOriginY() {
// TODO Auto-generated method stub
return 0;
}

public void setBidiReorderer(BidiReorderer _reorderer) {
// TODO Auto-generated method stub

}

public void setRenderingContext(RenderingContext result) {
// TODO Auto-generated method stub

}

public void setRoot(BlockBox _root) {
// TODO Auto-generated method stub

}

public void initializePage(Graphics2D graphics2d) {
// TODO Auto-generated method stub

}

public void finish(RenderingContext c, BlockBox _root) {
// TODO Auto-generated method stub

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.util.List;
import java.util.Map;

import com.openhtmltopdf.bidi.BidiReorderer;
import com.openhtmltopdf.extend.FSGlyphVector;
import com.openhtmltopdf.extend.FontContext;
import com.openhtmltopdf.extend.OutputDevice;
Expand Down Expand Up @@ -189,9 +190,9 @@ public void drawGlyphVector(OutputDevice outputDevice, FSGlyphVector fsGlyphVect
graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, fracHint);
}

/** {@inheritDoc} */
@Override
public void setup(FontContext fontContext) {
/** {@inheritDoc}
* @param bidiReorderer */
public void setup(FontContext fontContext, BidiReorderer bidiReorderer) {
//Uu.p("setup graphics called");
// ((Java2DFontContext)fontContext).getGraphics().setRenderingHint(
// RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_OFF );
Expand Down Expand Up @@ -470,5 +471,11 @@ public FSGlyphVector getGlyphVector(OutputDevice outputDevice, FSFont font, Stri

return new AWTFSGlyphVector(vector);
}

@Override
public void setup(FontContext context) {
// TODO Auto-generated method stub

}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* {{{ header & license
* Copyright (c) 2006 Wisconsin Court System
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* }}}
*/
package com.openhtmltopdf.java2d;

import java.awt.Graphics2D;

import com.openhtmltopdf.extend.FontContext;

public class Java2DFontContext implements FontContext {
private Graphics2D _graphics;

public Java2DFontContext(Graphics2D graphics) {
_graphics = graphics;
}

public Graphics2D getGraphics() {
return _graphics;
}
}
Loading

0 comments on commit b080c24

Please sign in to comment.