|
iRex DR1000 Merger v0.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectit.andynaz.irex.dr1000.scribble.Stroke
public class Stroke
A stroke.
A stroke is made up of various points. Points can be added via the addPoint(int, int)
method and are memorized in a ordered list.
A stroke has also a width and a zoom level.
Nested Class Summary | |
---|---|
private class |
Stroke.Point
A point. |
Field Summary | |
---|---|
private List<Stroke.Point> |
lPoint
List of points. |
private int |
width
Width. |
private float |
zoom
Zoom level. |
Constructor Summary | |
---|---|
Stroke()
Create a stroke. |
Method Summary | |
---|---|
void |
addPoint(int x,
int y)
Add a point to this stroke. |
(package private) void |
draw(com.lowagie.text.pdf.PdfContentByte cb,
float xAdjust,
float yAdjust)
Draw the stroke. |
void |
setWidth(int width)
Set the width of this stroke. |
void |
setZoom(float zoom)
Set the zoom level of this stroke. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private List<Stroke.Point> lPoint
private float zoom
private int width
Constructor Detail |
---|
public Stroke()
Method Detail |
---|
public void setWidth(int width)
width
- the width of the stroke (must be positive)
IllegalArgumentException
- if width
is not positivepublic void setZoom(float zoom)
zoom
- the zoom level of the stroke (must be positive)
IllegalArgumentException
- if zoom
is not positivepublic void addPoint(int x, int y)
x
- 'x' coordinate of the point to addy
- 'y' coordinate of the point to addvoid draw(com.lowagie.text.pdf.PdfContentByte cb, float xAdjust, float yAdjust)
When being drawn on the PDF, all the points of the stroke are scaled and adapted for the iText library, which uses a different coordinate system as the one used by the iPDF library, as shown in the following picture.
At first are scaled with the zoom factor using (as explained here) the formulas
x 1 48 x x' = ---------- * ----------------- = ------ zoom/100 160/72 (1-1/16) zoom y 1 48 y y' = ---------- * ----------------- = ------ zoom/100 160/72 (1-1/16) zoomso the zoom factor has to be set with the
setZoom(float)
method
before calling the draw(com.lowagie.text.pdf.PdfContentByte,
float, float)
method).x' = xa + x y' = ya - ywhere
xa
and ya
are the
arguments of the method.
cb
- content of the PDFxAdjust
- value to correct the 'x' coordinate of all the points in
this strokeyAdjust
- value to correct the 'y' coordinate of all the points in
this stroke
ArithmeticException
- if the setZoom(float)
} method has not
been called
|
iRex DR1000 Merger v0.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |