Inheritance diagram for Units:
Public Member Functions | |
Units (double val, String name) | |
Used when you want to create (and name) an anonymous unit. | |
Override boolean | equals (Object o) |
Check if the lengths match. | |
double | getConversionTo (Units destUnits) |
Units | getCopy () |
Returns a copy of this unit. | |
String | getUnitName () |
Units | getUnitsObjectOfSameLengthIn (Units destUnits) |
Gets a new Units object of the same type as destUnits, with the same physical length as this object. | |
Units | getUnitsObjectOfSameTypeWithValue (double val) |
Gets a new Units object of the same type as this unit, but with a new value. | |
double | getValue () |
double | getValueIn (Units destUnits) |
Gets the value in a new unit. | |
double | getValueInCentimeters () |
double | getValueInInches () |
This is a CONVENIENCE method. | |
double | getValueInMillimeters () |
double | getValueInPatternDots () |
CONVENIENCE method for converting this unit to PatternDots. | |
double | getValueInPixels () |
CONVENIENCE method for converting to Pixels. | |
double | getValueInPoints () |
CONVENIENCE method for converting this unit to Points. | |
Inches | toInches () |
Get an Inches object representing the same physical length. | |
Pixels | toPixels () |
Points | toPoints () |
Get a Points object representing the same physical length. | |
String | toString () |
Static Public Member Functions | |
static Units | add (Units a, Units b) |
static Units | subtract (Units a, Units b) |
Static Public Attributes | |
static final double | POINTS_PER_INCH = 72 |
Java handles everything in 1/72nd of an inch (1 point). | |
Protected Member Functions | |
Units (double val) | |
The only time you can set the value. | |
Units | clone () |
abstract double | getNumberOfUnitsInOneInch () |
This software is distributed under the BSD License.
Definition at line 14 of file Units.java.
Units | ( | double | val | ) | [protected] |
The only time you can set the value.
A Units object should be immutable.
val |
Definition at line 53 of file Units.java.
Units | ( | double | val, | |
String | name | |||
) |
Used when you want to create (and name) an anonymous unit.
This is useful in situations where you need a temporary unit.
val | ||
name |
Definition at line 65 of file Units.java.
a | ||
b |
Definition at line 27 of file Units.java.
References Units.getUnitsObjectOfSameTypeWithValue(), Units.getValue(), and Units.getValueIn().
Units clone | ( | ) | [protected] |
Definition at line 73 of file Units.java.
References Units.clone().
Referenced by Units.clone(), Size.clone(), Units.getUnitsObjectOfSameLengthIn(), and Units.getUnitsObjectOfSameTypeWithValue().
Override boolean equals | ( | Object | o | ) |
Check if the lengths match.
Definition at line 88 of file Units.java.
References Units.getValueIn().
Referenced by Sheet.addRegions(), and RegionID.equals().
double getConversionTo | ( | Units | destUnits | ) |
destUnits |
Definition at line 108 of file Units.java.
References Units.getNumberOfUnitsInOneInch().
Referenced by CompoundRegion.addChild(), RegionGroup.addRegion(), GraphicsUtils.getPointsWithConvertedUnits(), Units.getValueIn(), RegionRenderer.renderToG2D(), PolygonRenderer.renderToG2D(), ImageRenderer.renderToG2D(), and SheetRenderer.renderToJPEG().
Units getCopy | ( | ) |
Returns a copy of this unit.
WARNING: If you have a unit that depends on other factors, you should override this method. This is particularly true for Screen Pixels and Printer Dots.
TODO (Implement override for Pixels and PrinterDots)
Definition at line 120 of file Units.java.
References Units.getUnitsObjectOfSameLengthIn().
abstract double getNumberOfUnitsInOneInch | ( | ) | [protected, pure virtual] |
Implemented in Centimeters, Feet, Inches, Meters, Millimeters, PatternDots, Percentage, Pixels, Points, and PrinterDots.
Referenced by Units.getConversionTo(), and Percentage.getNumberOfUnitsInOneInch().
String getUnitName | ( | ) |
Definition at line 133 of file Units.java.
Referenced by Units.toString(), TextRegion.toString(), Region.toString(), PatternDots.toString(), ImageRegion.toString(), and CompoundRegion.toString().
Gets a new Units object of the same type as destUnits, with the same physical length as this object.
destUnits |
Definition at line 144 of file Units.java.
References Units.clone(), Units.getValueIn(), and Units.value.
Referenced by CompoundRegion.CompoundRegion(), Units.getCopy(), and RegionGroup.RegionGroup().
Units getUnitsObjectOfSameTypeWithValue | ( | double | val | ) |
Gets a new Units object of the same type as this unit, but with a new value.
val |
Definition at line 156 of file Units.java.
References Units.clone(), and Units.value.
Referenced by Units.add(), Region.getHeight(), Region.getOriginX(), Region.getOriginY(), Region.getUnscaledBoundsHeight(), Region.getUnscaledBoundsWidth(), Region.getWidth(), Percentage.Percentage(), PolygonalRegion.PolygonalRegion(), and Units.subtract().
double getValue | ( | ) |
Definition at line 165 of file Units.java.
Referenced by Units.add(), CompoundRegion.addChild(), Percentage.getNumberOfUnitsInOneInch(), PatternPackage.getPatternCoordinateOfOriginOfFile(), PercentageCoordinates.getPercentageInXDirection(), PercentageCoordinates.getPercentageInYDirection(), StreamedPatternCoordinates.getXVal(), BatchedPatternCoordinates.getXVal(), StreamedPatternCoordinates.getYVal(), BatchedPatternCoordinates.getYVal(), GestureHandler.handleEvent(), RegionID.hashCode(), ImageRegion.ImageRegion(), Percentage.Percentage(), Region.Region(), TextRenderer.renderToG2D(), PolygonRenderer.renderToG2D(), PatternLocationToSheetLocationMapping.setPatternInformationOfRegion(), Units.subtract(), TextRegion.TextRegion(), TextRegion.toString(), Percentage.toString(), PatternDots.toString(), and CompoundRegion.toString().
double getValueIn | ( | Units | destUnits | ) |
Gets the value in a new unit.
For example, you have a Units object that represents 2 Inches. You want to see what the value will be in Points. getConversionTo(new Points()) will return 72. 2 * 72 is 144.
destUnits |
Definition at line 178 of file Units.java.
References Units.getConversionTo().
Referenced by Units.add(), CompoundRegion.addChild(), RegionGroup.addRegion(), Units.equals(), Units.getUnitsObjectOfSameLengthIn(), Units.getValueInCentimeters(), Units.getValueInInches(), Units.getValueInMillimeters(), Units.getValueInPatternDots(), Units.getValueInPixels(), Units.getValueInPoints(), ImageRegion.ImageRegion(), Region.Region(), SheetRenderer.renderToJPEG(), InkRenderer.renderToJPEG(), Units.subtract(), and TextRegion.TextRegion().
double getValueInCentimeters | ( | ) |
double getValueInInches | ( | ) |
This is a CONVENIENCE method.
Yes, Yes... it's probably poor programming style to have the Units class be aware of its subclass (Inches). However, it makes code a lot more readable. Plus, if you implement your own Units class, you can use the generic method getValueIn(Units).
Definition at line 197 of file Units.java.
References Units.getValueIn().
Referenced by RegionGroup.getXOffsetInInches(), RegionGroup.getYOffsetInInches(), FlowPaperLayout.layout(), FlowPaperLayout.layoutRegionGroups(), and Units.toInches().
double getValueInMillimeters | ( | ) |
double getValueInPatternDots | ( | ) |
CONVENIENCE method for converting this unit to PatternDots.
Definition at line 213 of file Units.java.
References Units.getValueIn().
Referenced by TiledPatternGenerator.displayTilingInformation(), FlexiblePatternCoordinateConverter.FlexiblePatternCoordinateConverter(), TiledPatternGenerator.getPattern(), InkCollector.handleEvent(), PatternPackage.readPatternFromFile(), and InkCollector.setNotifyDistance().
double getValueInPixels | ( | ) |
CONVENIENCE method for converting to Pixels.
This uses the DEFAULT pixelsPerInch as specified by the configuration xml file. Unfortunately, Java cannot detect this value yet.
Definition at line 223 of file Units.java.
References Units.getValueIn().
Referenced by HandwritingRecognizer.handleEvent(), and Units.toPixels().
double getValueInPoints | ( | ) |
CONVENIENCE method for converting this unit to Points.
Definition at line 232 of file Units.java.
References Units.getValueIn().
Referenced by PDFPatternGenerator.renderPattern(), TextRenderer.renderToG2D(), SheetRenderer.renderToG2D(), PDFSheetRenderer.renderToG2D(), CompoundRenderer.renderToG2D(), SheetRenderer.renderToPDF(), SheetRenderer.renderToPDFContentLayers(), and Units.toPoints().
a | ||
b |
Definition at line 36 of file Units.java.
References Units.getUnitsObjectOfSameTypeWithValue(), Units.getValue(), and Units.getValueIn().
Inches toInches | ( | ) |
Get an Inches object representing the same physical length.
Definition at line 241 of file Units.java.
References Units.getValueInInches().
Pixels toPixels | ( | ) |
Points toPoints | ( | ) |
Get a Points object representing the same physical length.
Definition at line 258 of file Units.java.
References Units.getValueInPoints().
String toString | ( | ) |
Reimplemented in PatternDots, and Percentage.
Definition at line 265 of file Units.java.
References Units.getUnitName().
Referenced by PercentageCoordinates.toString(), and Coordinates.toString().
final double POINTS_PER_INCH = 72 [static] |
Java handles everything in 1/72nd of an inch (1 point).
We should do the same to be compatible.
Definition at line 20 of file Units.java.