jfig.objects
Class LineWrapper

java.lang.Object
  extended byjfig.objects.LineWrapper

public class LineWrapper
extends java.lang.Object

draw attributed lines using AWT 1.0.

LineWrapper provides a wrapper for drawing of variable Width lines (depending on internal line width and zoom factor) for use by other editor objects.

Additionally, LineWrapper uses the timestamp information from the current viewport transformation and the last internal modification to decide whether a new world-coordinate -> screen-coordinate transformation is necessary.

Support for fat lines is currently done with filled polygons for each line part. This should probably use some better algorithm to get smooth corners.


Field Summary
(package private)  java.awt.Point anchor
           
(package private)  FigAttribs attribs
           
(package private)  java.awt.Point[][] dashes
           
(package private)  boolean debug
           
(package private)  int dx
           
(package private)  int dy
           
(package private)  java.awt.Polygon[] fillers
           
(package private)  boolean graphicsWasTranslated
           
(package private)  boolean is_closed
           
(package private)  int np
           
(package private)  java.awt.Point old_anchor
           
(package private)  FigObject parent
           
(package private)  boolean pen_down
           
(package private)  java.awt.Polygon[] polygons
           
(package private)  java.awt.Point sp
           
(package private)  int[] sx
           
(package private)  int[] sy
           
(package private)  long timestamp
           
(package private)  FigTrafo2D trafo
           
(package private)  int visible_linewidth
           
(package private)  java.awt.Point[] wcp
           
(package private)  java.awt.Point wp
           
(package private)  int[] xf
           
(package private)  int[] xp
           
(package private)  int[] yf
           
(package private)  int[] yp
           
 
Constructor Summary
LineWrapper(FigObject parent, FigTrafo2D trafo, java.awt.Point[] wcp, boolean closed)
          basic LineWrapper constructor.
 
Method Summary
(package private)  double build_dashes_segment(java.util.Vector DD, java.awt.Point P, java.awt.Point Q, double missingLength)
          build_dashes_segment(): Given the segment i ..
(package private)  void build_fillers()
          Create and construct the polygons to fill the space between adjacent polyline segments.
(package private)  void buildDashes()
          buildDashes(): build the array with the individual dash-lines from the lines world-coordinates in the wcp[] array.
 void buildScreenPoints()
          the transformation has changed for this line.
 int[] getScreenPointsX()
           
 int[] getScreenPointsY()
           
 long getTimestamp()
           
 void message(java.lang.String s)
           
 void paint(java.awt.Graphics g)
           
 void paintAWT11(java.awt.Graphics g)
          paint(): Check whether we the viewport transformation has changed.
 void paintDashes(java.awt.Graphics g)
          paintDashes(): this is a dashed/dotted line.
 void reset_debug()
          turn of the debug output
 void set_debug()
          activate debug output
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

wcp

java.awt.Point[] wcp

sx

int[] sx

sy

int[] sy

polygons

java.awt.Polygon[] polygons

fillers

java.awt.Polygon[] fillers

parent

FigObject parent

trafo

FigTrafo2D trafo

attribs

FigAttribs attribs

is_closed

boolean is_closed

dashes

java.awt.Point[][] dashes

pen_down

boolean pen_down

timestamp

long timestamp

graphicsWasTranslated

boolean graphicsWasTranslated

anchor

java.awt.Point anchor

old_anchor

java.awt.Point old_anchor

dx

int dx

dy

int dy

debug

boolean debug

visible_linewidth

int visible_linewidth

xp

int[] xp

yp

int[] yp

np

int np

xf

int[] xf

yf

int[] yf

wp

java.awt.Point wp

sp

java.awt.Point sp
Constructor Detail

LineWrapper

public LineWrapper(FigObject parent,
                   FigTrafo2D trafo,
                   java.awt.Point[] wcp,
                   boolean closed)
basic LineWrapper constructor. This allocates the internal array with the screen-coordinates of the line points.

Parameters:
parent - The FigObject that uses this LineWrapper
trafo - The current editor viewport transformation, needed for the wc->sc transformation
wcp - The Point[] array with the world-coords for the line.
closed - Whether this line should be closed (P_n+1 = P_0)
Method Detail

getTimestamp

public long getTimestamp()

set_debug

public void set_debug()
activate debug output


reset_debug

public void reset_debug()
turn of the debug output


getScreenPointsX

public int[] getScreenPointsX()

getScreenPointsY

public int[] getScreenPointsY()

build_fillers

void build_fillers()
Create and construct the polygons to fill the space between adjacent polyline segments. This should allow for different fill styles (round, bevel, ...). For performance reasons this function directly accesses the polygons[i] coordinate arrays xpoints[] and ypoints[].


buildScreenPoints

public void buildScreenPoints()
the transformation has changed for this line. Recalculate the screen coords sx[] and sy[] arrays and the minimum width in world-coords of a 2-pixel wide line.


buildDashes

void buildDashes()
buildDashes(): build the array with the individual dash-lines from the lines world-coordinates in the wcp[] array. A single dash-line is stored as an array Point[2], the whole dashed line consists of as many dash-lines as are needed. The length of the dashes is specified as attribs.dashLength, the gap between dashes as attribs.dashGap.


build_dashes_segment

double build_dashes_segment(java.util.Vector DD,
                            java.awt.Point P,
                            java.awt.Point Q,
                            double missingLength)
build_dashes_segment(): Given the segment i .. i+1 on the LineWrapper wcp[], built a dashed line representation of dashes with attribs. dashLength, where the first dash should only have missingLength (because a previous segment already has part of this dash...)


paintDashes

public void paintDashes(java.awt.Graphics g)
paintDashes(): this is a dashed/dotted line. Draw it.


paint

public void paint(java.awt.Graphics g)

paintAWT11

public void paintAWT11(java.awt.Graphics g)
paint(): Check whether we the viewport transformation has changed. If so, recalculate the wc -> sc transformation. Draw the line.

Currently only one-pixel wide lines are supported.


message

public void message(java.lang.String s)