Fizzy / docs / ref / Dimension.md
Dimension
Contains a Double, and units of measure.
The basic metric units are : mm, cm, m and km. There are also imperial units : inch, ft, yard.
There are also "Dymanic" units "pt" (points), which are used for font sizes, and line widths. Points are dynamic, because if you change the scale factor for a document, then the point sizes will change in respect to the other units.
This dynamic nature is important when creating scale diagrams, such as floor plans.
Creation
To create a Dimension, just add the units after a number. e.g.
100mm or 10cm or 0.1m etc
Operators
Mathematical operators work as you might expect :
Left | Operator | Right | = | Comments |
---|---|---|---|---|
Dimension | + or - | Dimension | Dimension | |
Dimension | * or / | Double | Dimension | |
Dimension | * | Dimension | Area | |
Dimension | / | Dimension | Double |
Field
Name | Type | Comments |
---|---|---|
mm | Double | The number of millimeters |
cm | Double | The number of centimeters |
m | Double | The number of meters |
km | Double | The number of kilometers |
Methods
Name | Parameters | Return Type | Comments |
---|---|---|---|
toString | none | String | Converts to a string, but may be ugly for non integer values. |
format | String | String | Uses Java's DecimalFormat |
units | none | Units | |
toUnits | Units | Dimension | Converts to different units, keeping the same length. |
clamp | min : Dimension, max : Dimension | Dimension | |
min | other : Dimension | Dimension | The minimum of this and other |
max | other : Dimension | Dimension | The maximum of this and other |