jfig.commands
Class CreateDimensioningCommand

java.lang.Object
  extended byjfig.commands.Command
      extended byjfig.commands.CreateDimensioningCommand

public class CreateDimensioningCommand
extends Command

create a dimensioning annotation from two specified endpoints

CreateDimensioningCommand allows to easily create a dimensioning annotation in CAD-style for given coordinates. In order to avoid a new non-xfig-compatible object type, we create a compound object that includes the arrows, marker lines, text background rectangle, and text. Use the following properties to control the algorithm:

   jfig.commands.CreateDimensioningCommand.font           helvetica
   jfig.commands.CreateDimensioningCommand.fontsize       12
   jfig commands.CreateDimensioningCommand.format         %6.2g
   jfig commands.CreateDimensioningCommand.units          mm

   jfig.commands.CreateDimensioningCommand.color          black
   jfig.commands.CreateDimensioningCommand.arrowhead      2.0,6.0,1 // w l t
   jfig.commands.CreateDimensioningCommand.linewidth      1         // FIG units
   jfig.commands.CreateDimensioningCommand.markerlength   2.0       // mm
   jfig.commands.CreateDimensioningCommand.layer          200

   jfig.commands.CreateDimensioningCommand.outerArrowLimit 10       // mm
 
Markerlength is the length of the short marker lines orthogonal to the main dimensioning line, while linewidth (d) is the width of the dimensioning lines (in FIG units). The arrowheads are set to conform to the German DIN standards, i.e. length (5*d) and opening angle (15?), and arrowhead filled.

When the distance between the endpoints of the dimensioning is smaller than outerArrowLimit (default 10 millimeters), the dimensioning automagically uses 'outer' arrows instead of the single double-headed 'inner' arrow. Specify outerArrowLimit=0.0 to disable this.

You can also call the static createDimensioning( Point, Point ) method directly, e.g. to create dimensioning annotation in 'batch mode'.


Field Summary
protected  FigCompound dimensioning
           
protected  int n_points
           
protected  java.awt.Point P
           
protected  java.awt.Point Q
           
 
Fields inherited from class jfig.commands.Command
editor, objectCanvas, ready
 
Constructor Summary
CreateDimensioningCommand(FigBasicEditor editor, FigCanvas objectCanvas)
           
 
Method Summary
 void cancel()
          cancel the current editor command
static FigCompound createDimensioning(java.awt.Point P, java.awt.Point Q, FigTrafo2D trafo)
          according to 'Hoischen, Technisches Zeichnen, 23rd Edition, 1990' we need the following:
 void execute()
          execute the current editor command
 java.lang.String getDescription()
          one-line description of this command
static java.awt.Point[] getMarkerPoints(java.awt.Point origin, double dx, double dy, double norm, double len)
           
 FigObject[] getModifiedObjects()
          return an array-wrapped reference to the polyline object created by this command.
 void mousePressed(FigCanvasEvent evt)
          mousePressed: specify the start and end points for this dimensioning.
 java.lang.String toString()
          return a (possibly verbose) description of this Command object
 void undo()
          undo this command
 
Methods inherited from class jfig.commands.Command
isReady, message, notifyEditor, statusMessage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

P

protected java.awt.Point P

Q

protected java.awt.Point Q

dimensioning

protected FigCompound dimensioning

n_points

protected int n_points
Constructor Detail

CreateDimensioningCommand

public CreateDimensioningCommand(FigBasicEditor editor,
                                 FigCanvas objectCanvas)
Method Detail

getModifiedObjects

public FigObject[] getModifiedObjects()
return an array-wrapped reference to the polyline object created by this command. The polyline reference may be null.

Overrides:
getModifiedObjects in class Command

execute

public void execute()
Description copied from class: Command
execute the current editor command

This method is empty for class Command.

Overrides:
execute in class Command

cancel

public void cancel()
Description copied from class: Command
cancel the current editor command

cancel and cleanup the current command. Note that this method is empty for class Command, but might be implemented by subclasses.

Overrides:
cancel in class Command

undo

public void undo()
Description copied from class: Command
undo this command

Try to undo this command as far as possible. Don't try to undo() a command that has never been execute()d before. This method is empty for class Command.

Overrides:
undo in class Command

getMarkerPoints

public static java.awt.Point[] getMarkerPoints(java.awt.Point origin,
                                               double dx,
                                               double dy,
                                               double norm,
                                               double len)

createDimensioning

public static FigCompound createDimensioning(java.awt.Point P,
                                             java.awt.Point Q,
                                             FigTrafo2D trafo)
according to 'Hoischen, Technisches Zeichnen, 23rd Edition, 1990' we need the following:

let 'd' be the width of the line this dimensioning belongs to, where d is one of the norm widths, i.e. { 0.25, 0.35, 0.5, 0.7, 1.0 } millimeters. Then

  1. the line width of the dimensioning is (d/2)
  2. the dimensioning arrowhead is filled (or open with the line protruding)
  3. the arrowhead length should be approximately (5*d)
  4. the arrowhead opening angle should be approx. 15 degrees,
  5. this implies (arrowhead width) = (5*d)*tan(15 degrees)=(1.34*d)
  6. the orthogonal endpoint lines have width (d/2) and length (2.0 mm)
  7. the text label stating the actual dimension should be oriented top-to-left (readable from the bottom or right side)
  8. and is centered on top of the dimensioning line
  9. chains of dimensionings may use (filled/open) circles instead of arrowheads with a circle diameter of (1.5*d)
  10. if the arrowheads and label do not fit inside the given dimension, the arrowheads are oriented outside and the labeling is on the right.
At the moment, only double-arrowhead dimensionings are supported. Please feel free to add code for circles or chained single-arrowhead dimensionings. We always use the minimum linewidth (=1) for the dimensioning line(s) and arrows.


mousePressed

public void mousePressed(FigCanvasEvent evt)
mousePressed: specify the start and end points for this dimensioning. A right click cancels.

Overrides:
mousePressed in class Command

getDescription

public java.lang.String getDescription()
Description copied from class: Command
one-line description of this command

return a one-line desription of this command, e.g. to label the undo/redo buttons, if any

Overrides:
getDescription in class Command

toString

public java.lang.String toString()
Description copied from class: Command
return a (possibly verbose) description of this Command object

Overrides:
toString in class Command