org.jpedal.external.ShapeTracker Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of OpenViewerFX Show documentation
Show all versions of OpenViewerFX Show documentation
Open Source (LGPL) JavaFX PDF Viewer for NetBeans plugin
/*
* ===========================================
* Java Pdf Extraction Decoding Access Library
* ===========================================
*
* Project Info: http://www.idrsolutions.com
* Help section for developers at http://www.idrsolutions.com/support/
*
* (C) Copyright 1997-2017 IDRsolutions and Contributors.
*
* This file is part of JPedal/JPDF2HTML5
*
@LICENSE@
*
* ---------------
* ShapeTracker.java
* ---------------
*/
package org.jpedal.external;
import java.awt.Shape;
import org.jpedal.color.PdfPaint;
/**
* allow user to recieve raw glyph data as generated
*/
public interface ShapeTracker {
/**
* pass user the low-level details
*
* @param tokenNumber actual token reached in stream (useful for working out if objects behind others
* @param type (Cmd.S, Cmd.s, Cmd.B, etc)... B,S and F comands with or without star and upper/lower case
* to define Fill, Stroke, etc
* @param currentShape - shape with unscaled, unrotated PDF co-ordinates
* @param nonstrokecolor - used for Fills
* @param strokecolor - used for stroking shape
*/
void addShape(int tokenNumber, int type, Shape currentShape, PdfPaint nonstrokecolor, PdfPaint strokecolor);
/* here is an example
private class TestShapeTracker implements ShapeTracker {
public void addShape(int tokenNumber, int type, Shape currentShape, PdfPaint nonstrokecolor, PdfPaint strokecolor) {
//use this to see type
//Cmd.getCommandAsString(type);
//print out details
if(type==Cmd.S || type==Cmd.s){ //use stroke color to draw line
System.out.println("-------Stroke-------PDF cmd="+Cmd.getCommandAsString(type));
System.out.println("tokenNumber="+tokenNumber+" "+currentShape.getBounds()+" stroke color="+strokecolor);
}else if(type==Cmd.F || type==Cmd.f || type==Cmd.Fstar || type==Cmd.fstar){ //uses fill color to fill shape
System.out.println("-------Fill-------PDF cmd="+Cmd.getCommandAsString(type));
System.out.println("tokenNumber="+tokenNumber+" "+currentShape.getBounds()+" fill color="+nonstrokecolor);
}else{ //not yet implemented (probably B which is S and F combo)
System.out.println("Not yet added");
System.out.println("tokenNumber="+tokenNumber+" "+currentShape.getBounds()+" type="+type+" "+Cmd.getCommandAsString(type));
}
}
}
/**/
}