Package samer.tools

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 using rel(dx,dy). The folling functions use only the primary current point:

    • marker();
    • pixel();
    • blob().
    Calling 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.

    • Field Detail

      • p0

        public java.awt.Point p0
      • p1

        public java.awt.Point p1
    • 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

      • 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)
      • rectify

        public Plotter.Pen rectify()
        this swaps xs and ys to make sure rectangles work
      • fill3DRect

        public Plotter.Pen fill3DRect(boolean outin)
      • pixel

        public Plotter.Pen pixel()
        pixel drawn as 1x1 filled rectangle
      • 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