Class Plotter.Pen
- java.lang.Object
-
- samer.tools.Plotter.Pen
-
- Enclosing class:
- Plotter
public class Plotter.Pen extends java.lang.Object
This class provides a state based plotting environment (slightly inspired by Postscripts crazy reverse polish). There is are two current points: one for general use and another which serves as the other point for lines, rectangles and ellipses.
The primary current point can be set in absolute coordinates using
abs(x,y)
or moved relatively usingrel(dx,dy)
. The folling functions use only the primary current point:-
marker()
; -
pixel()
; -
blob()
.
move()
copies the the location of the primary current point to the secondary current point. The following functions use both the current points:-
line()
: line between both points; -
rect()
: empty rectangle bounding both points -
fillRect()
; -
fill3DRect(boolean inOrOut)
; -
ellipse()
; -
fillEllipse()
.
Some of the rectangle drawing commands only work if the primary current point is below and to the right (on the screen, that is) of the secondary. The
rectify
function swaps coordinates between the two points to make it so. It will screw up any line drawing though.
-
-
Constructor Summary
Constructors Constructor and Description Pen(java.awt.Graphics g)
A program can have several Pens, each with different colours, but the underlying Graphics has a single current Color.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description Plotter.Pen
abs(double x, double y)
Plotter.Pen
activate()
Plotter.Pen
blob()
draws the current blob image at the current pointboolean
clipped()
returns true if the last primary current point was clippedPlotter.Pen
ellipse()
Plotter.Pen
fill3DRect(boolean outin)
Plotter.Pen
fillEllipse()
Plotter.Pen
fillRect()
Plotter.Pen
line()
Plotter.Pen
lineto()
Plotter.Pen
lineto(double x, double y)
Plotter.Pen
marker()
Plotter.Pen
move()
Plotter.Pen
moveto(double x, double y)
Plotter.Pen
pixel()
pixel drawn as 1x1 filled rectanglePlotter.Pen
rect()
Plotter.Pen
rectify()
this swaps xs and ys to make sure rectangles workPlotter.Pen
rel(double x, double y)
Plotter.Pen
set(Plotter.Pen p)
copies position of given pen to primary current pointvoid
setBlobColor(java.awt.Color col)
sets the blob image to be pixel of a given colourvoid
setBlobImage(java.awt.Image i)
sets blob image to given imagevoid
setBlobImage(java.awt.Image i, int xhot, int yhot)
sets blob image with given hotspotPlotter.Pen
setColor(java.awt.Color c)
void
setMarkerSize(int r)
-
-
-
Constructor Detail
-
Pen
public Pen(java.awt.Graphics g)
A program can have several Pens, each with different colours, but the underlying Graphics has a single current Color. So, if you have multiple Pens, each pen must
activate()
its colour before drawing anything.
-
-
Method Detail
-
activate
public final Plotter.Pen activate()
-
setColor
public final Plotter.Pen setColor(java.awt.Color c)
-
setMarkerSize
public final void setMarkerSize(int r)
-
clipped
public final boolean clipped()
returns true if the last primary current point was clipped
-
abs
public final Plotter.Pen abs(double x, double y)
-
rel
public final Plotter.Pen rel(double x, double y)
-
set
public final Plotter.Pen set(Plotter.Pen p)
copies position of given pen to primary current point
-
move
public final Plotter.Pen move()
-
line
public final Plotter.Pen line()
-
rect
public Plotter.Pen rect()
-
fillRect
public Plotter.Pen fillRect()
-
rectify
public Plotter.Pen rectify()
this swaps xs and ys to make sure rectangles work
-
fill3DRect
public Plotter.Pen fill3DRect(boolean outin)
-
ellipse
public Plotter.Pen ellipse()
-
fillEllipse
public Plotter.Pen fillEllipse()
-
marker
public Plotter.Pen marker()
-
pixel
public Plotter.Pen pixel()
pixel drawn as 1x1 filled rectangle
-
lineto
public final Plotter.Pen lineto()
-
lineto
public final Plotter.Pen lineto(double x, double y)
-
moveto
public final Plotter.Pen moveto(double x, double y)
-
blob
public Plotter.Pen blob()
draws the current blob image at the current point
-
setBlobColor
public void setBlobColor(java.awt.Color col)
sets the blob image to be pixel of a given colour
-
setBlobImage
public void setBlobImage(java.awt.Image i)
sets blob image to given image
-
setBlobImage
public void setBlobImage(java.awt.Image i, int xhot, int yhot)
sets blob image with given hotspot
-
-