public class Attributes extends Object implements Persistent, Cloneable
Constructor and Description |
---|
Attributes()
Create a new object of Attributes.
|
Modifier and Type | Method and Description |
---|---|
void |
calculateGridGapX(Rectangle2D rect)
Calculates the grid gap for the x axis, in pixels,
based on the paper width (in cm) and the width
of the rectangle of sheet in screen, measured in
pixels.
|
void |
calculateGridGapY(Rectangle2D rect)
Calculates the grid gap for the y axis, in pixels,
based on the paper height (in cm) and the height
of the rectangle of sheet in screen, measured in
pixels.
|
Object |
clone() |
double |
fromUnits(double d)
Returns a double in centimeters from the the unit of measure selected.
|
Rectangle2D |
getArea()
Returns the printing area.
|
double[] |
getAreaInsets() |
PrintRequestAttributeSet |
getAttributes()
Returns attributes of PrintDialog.
|
static double |
getConversionFactorToCm(int unit)
Gets the conversion factor from the specified unit to centimeters.
|
Size |
getCustomPaperSize()
Gets the last selected custom paper size.
|
static Point2D |
getDefaultGridGap()
Gets the default grid gap, in centimeters.
|
static int |
getDistanceAbbrPosition(String unitAbbr) |
double |
getHGridGapCm()
Gets the grid gap for the x axis, in centimeters.
|
double |
getHGridGapPx()
Gets the grid gap for the x axis, in pixels.
|
String |
getNameUnit()
Returns the name of the selected units.
|
PageFormat |
getPageFormat()
Returns a PageFormat with the properties of printing.
|
Size |
getPaperSize()
Paper size, measured in centimeters.
|
Size |
getPaperSizeInUnits()
Returns the size of sheet in the units of measure selected.
|
Size |
getPaperSizeinUnits(boolean isLand,
int type)
Returns the size of sheet.
|
double |
getPixXCm(Rectangle2D rect)
Returns one centimeter in pixels on screen in this moment.
|
Rectangle2D.Double |
getRectangleLandscape(Rectangle2D rect,
int w,
int h)
It obtains the rect that is adjusted to the size of the window,
to see the full extent of horizontal layout.
|
Rectangle2D.Double |
getRectanglePortrait(Rectangle2D rect,
int w,
int h)
It obtains the rect that is adjusted to the size of the window,
to see the full extent of vertical layout.
|
int |
getResolution()
Returns the resolution of properties to print.
|
int |
getSelTypeUnit()
Deprecated.
Use
getUnit() instead |
Size |
getSizeInUnits()
Deprecated.
Use
getPaperSizeInUnits() instead |
int |
getType()
Returns the format of sheet.
|
int |
getUnit()
Returns the type of unit in use (cm, mm, km, etc), codified as
a position in the array returned by
MapContext.getDistanceNames() |
double |
getVGridGapCm()
Gets the grid gap for the y axis, in centimeters.
|
double |
getVGridGapPx()
Gets the grid gap for the y axis, in pixels.
|
boolean |
isLandscape() |
boolean |
isMargin()
Returns true if the margin should be used.
|
boolean |
isPortrait() |
void |
loadFromState(PersistentState state)
Set the state of the object from the state passed as parameter.
|
void |
obtainRect(boolean isPrint,
Rectangle2D rect,
int w,
int h)
Obtains the rectangle that represents the sheet with the characteristics
that contains attributes
|
static void |
registerPersistent() |
void |
saveToState(PersistentState state)
Saves the internal state of the object on the provided
PersistentState object.
|
static void |
setDefaultGridGap(double hGap,
double vGap,
String hUnitAbbr,
String vUnitAbbr)
Sets the default grid gap.
|
void |
setHGridGrapCm(double d)
Inserts the number of units to define the coords X grid.
|
void |
setIsLandScape(boolean b)
Inserts true if the sheet is horizontal or false if is vertical.
|
void |
setPageFormat(PageFormat pf)
Inserts the attributes with a PageFormat.
|
void |
setPaperSize(Size paperSize)
Sets the paper size, measured in centimeters
|
void |
setPaperSizeInUnits(Size sizeInUnits)
Sets the paper size, measured on the selected units
|
void |
setResolution(int i)
Inserts the resolution to apply at printing.
|
void |
setSelectedOptions(int typeSel,
int units,
boolean isLand,
boolean margin,
int resolution,
double[] _area_tplr)
Inserts the Layout's properties to print.
|
void |
setType(int t)
Sets the type of sheet to show.
|
void |
setUnit(int sel)
Sets the type of unit that is used in the Layout, defined as an
integer indicating a position in the array
MapContext.getDistanceNames() . |
void |
setVGridGrapCm(double d)
Inserts the number of units to define the coords X grid.
|
DocAttributeSet |
toDocAttributes() |
PrintAttributes |
toPrintAttributes() |
PrintRequestAttributeSet |
toPrintAttributeSet()
Returns a PrintRequestAttributeSet with all properties to the
PrintDialog.
|
static PrintQuality |
toPrintQuality(int quality)
|
PrintRequestAttributeSet |
toPrintRequestAttributeSet()
Returns a PrintRequestAttributeSet with all properties to the
PrintDialog.
|
double |
toUnits(double d)
Returns a double in the unit of measure selected from the double in
centimeters.
|
public static final String PERSISTENCE_DEFINITION_NAME
public static final String DPI_FIELD
public static final String DPISCREEN_FIELD
public static final String TYPEUNIT_FIELD
public static final String NUMX_FIELD
public static final String NUMY_FIELD
public static final String UNITX_FIELD
public static final String UNITY_FIELD
public static final String HASMARGIN_FIELD
public static final String RESOLUTIONSEL_FIELD
public static final String TYPESEL_FIELD
public static final String SELTYPEUNIT_FIELD
public static final String SIZEPAPER_FIELD
public static final String AREA_FIELD
public static final String SIZEINUNITS_FIELD
public static final String ISLANDSEL_FIELD
public static final String DEGREES
public static final int HIGH
public static final int NORMAL
public static final int DRAFT
public static final double PULGADA
public static final Size STANDARD_LETTER_PAPER_SIZE
public static final Size STANDARD_FOLIO_PAPER_SIZE
public static final Size STANDARD_LEGAL_PAPER_SIZE
public static final Size STANDARD_TABLOID_PAPER_SIZE
public static final Size METRIC_A0_PAPER_SIZE
public static final Size METRIC_A1_PAPER_SIZE
public static final Size METRIC_A2_PAPER_SIZE
public static final Size METRIC_A3_PAPER_SIZE
public static final Size METRIC_A4_PAPER_SIZE
public static final Size METRIC_A5_PAPER_SIZE
public static final Size ANSI_ENG_A_PAPER_SIZE
public static final Size ANSI_ENG_B_PAPER_SIZE
public static final Size ANSI_ENG_C_PAPER_SIZE
public static final Size ANSI_ENG_D_PAPER_SIZE
public static final Size ANSI_ENG_E_PAPER_SIZE
public static final Size ANSI_ARCH_A_PAPER_SIZE
public static final Size ANSI_ARCH_B_PAPER_SIZE
public static final Size ANSI_ARCH_C_PAPER_SIZE
public static final Size ANSI_ARCH_D_PAPER_SIZE
public static final Size ANSI_ARCH_E_PAPER_SIZE
public static final int PRINT
public static final int CUSTOM
public static final int A0
public static final int A1
public static final int A2
public static final int A3
public static final int A4
public static int DPI
public static int DPISCREEN
public boolean isLandscape()
public boolean isPortrait()
public void setSelectedOptions(int typeSel, int units, boolean isLand, boolean margin, int resolution, double[] _area_tplr)
typeSel
- Type of sheet.units
- Units.isLand
- True if the sheet is horizontal.margin
- True if the sheet has margin.resolution
- Type of quality of resolution.area
- Printing area (top, bottom, left, right).public Size getPaperSize()
getUnit()
,
setUnit(int)
public void setPaperSize(Size paperSize)
paperSize
- public Size getCustomPaperSize()
getPaperSize()
when getType()
is
CUSTOM
.public PageFormat getPageFormat()
public Rectangle2D getArea()
public double[] getAreaInsets()
public void setPageFormat(PageFormat pf)
pf
- PageFormat.public PrintRequestAttributeSet toPrintRequestAttributeSet()
public DocAttributeSet toDocAttributes()
public PrintAttributes toPrintAttributes()
public PrintRequestAttributeSet toPrintAttributeSet()
public boolean isMargin()
public int getResolution()
public void setResolution(int i)
i
- Type of resolution.
The type of resolution can be:
DRAFT: 27 dpi.
NORMAL: 300 dpi.
HIGH: 600 dpi.public static PrintQuality toPrintQuality(int quality)
quality
- public PrintRequestAttributeSet getAttributes()
public int getType()
public void setHGridGrapCm(double d)
d
- number of units to define the grid.public double getHGridGapCm()
public double getVGridGapCm()
public void setVGridGrapCm(double d)
d
- number of units to define the grid.public void setIsLandScape(boolean b)
b
- True if sheet is horizontal.public void setType(int t)
t
- Type of sheet.public void setPaperSizeInUnits(Size sizeInUnits)
getUnit()
public Size getPaperSizeinUnits(boolean isLand, int type)
isLand
- True if is horizontal and false if is vertical.type
- Type of sheet.public int getUnit()
MapContext.getDistanceNames()
@Deprecated public int getSelTypeUnit()
getUnit()
insteadpublic String getNameUnit()
getUnit()
public void setUnit(int sel)
MapContext.getDistanceNames()
. By default is
centimeters.sel
- Type of unit.getUnit()
public double toUnits(double d)
d
- Distance in centimeters.public double fromUnits(double d)
d
- Distance in the unit measure selected.public double getPixXCm(Rectangle2D rect)
rect
- Rectangle of sheet.public void calculateGridGapX(Rectangle2D rect)
rect
- Rectangle of sheet, measured in pixelspublic void calculateGridGapY(Rectangle2D rect)
rect
- Rectangle of sheet, measured in pixelspublic void obtainRect(boolean isPrint, Rectangle2D rect, int w, int h)
rect
- rectangle.public Rectangle2D.Double getRectangleLandscape(Rectangle2D rect, int w, int h)
rect
- Rectangle sheet.w
- Width of Layout.h
- Height of Layout.public Size getPaperSizeInUnits()
@Deprecated public Size getSizeInUnits()
getPaperSizeInUnits()
insteadpublic Rectangle2D.Double getRectanglePortrait(Rectangle2D rect, int w, int h)
rect
- Rectangle sheet.w
- Width of Layout.h
- Height of Layout.public static void setDefaultGridGap(double hGap, double vGap, String hUnitAbbr, String vUnitAbbr)
hGap
- Horizontal distance.vGap
- Vertical distance.hUnitAbbr
- The abbreviation of the measure in which hGap has
been provided, codified as one of the abbreviations specified in
MapContext.getDistanceAbbr()
vUnitAbbr
- The abbreviation of the measure in which vGap has
been provided, codified as one of the abbreviations specified in
MapContext.getDistanceAbbr()
public static Point2D getDefaultGridGap()
public static int getDistanceAbbrPosition(String unitAbbr)
public double getVGridGapPx()
public double getHGridGapPx()
public static void registerPersistent()
public void loadFromState(PersistentState state) throws PersistenceException
Persistent
loadFromState
in interface Persistent
PersistenceException
public void saveToState(PersistentState state) throws PersistenceException
Persistent
saveToState
in interface Persistent
PersistenceException
public static double getConversionFactorToCm(int unit)
unit
- The source unit, codified as a position in the array
MapContext.getDistanceNames()