Class Attributes

java.lang.Object
org.gvsig.app.project.documents.layout.Attributes
All Implemented Interfaces:
Cloneable, org.gvsig.tools.persistence.Persistent

public class Attributes extends Object implements org.gvsig.tools.persistence.Persistent, Cloneable
Attributes of Layout.
Author:
Vicente Caballero Navarro, jldominguez
  • Field Details

  • Constructor Details

    • Attributes

      public Attributes()
      Create a new object of Attributes.
  • Method Details

    • isLandscape

      public boolean isLandscape()
      Returns:
    • isPortrait

      public boolean isPortrait()
      Returns:
    • setSelectedOptions

      public void setSelectedOptions(int typeSel, int units, boolean isLand, boolean margin, int resolution, double[] _area_tplr)
      Inserts the Layout's properties to print.
      Parameters:
      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).
    • getPaperSize

      public Size getPaperSize()
      Paper size, measured in centimeters. This field knows about orientation. Note that this size is always measured in centimeters, regardless the selected unit for the page. However, the user should be always presented measures in the selected unit.
      Returns:
      See Also:
    • setPaperSize

      public void setPaperSize(Size paperSize)
      Sets the paper size, measured in centimeters
      Parameters:
      paperSize -
    • getCustomPaperSize

      public Size getCustomPaperSize()
      Gets the last selected custom paper size. It will be equal to getPaperSize() when getType() is CUSTOM.
      Returns:
    • getPageFormat

      public PageFormat getPageFormat()
      Returns a PageFormat with the properties of printing.
      Returns:
      PageFormat
    • getArea

      public Rectangle2D getArea()
      Returns the printing area. The value returned changes if orientation changes (it "knows" about portrait/landscape)
      Returns:
      Rectangle Area.
    • getAreaInsets

      public double[] getAreaInsets()
    • setPageFormat

      public void setPageFormat(PageFormat pf)
      Inserts the attributes with a PageFormat.
      Parameters:
      pf - PageFormat.
    • toPrintRequestAttributeSet

      public PrintRequestAttributeSet toPrintRequestAttributeSet()
      Returns a PrintRequestAttributeSet with all properties to the PrintDialog.
      Returns:
      PrintRequestAttributesSet.
    • toDocAttributes

      public DocAttributeSet toDocAttributes()
    • toPrintAttributes

      public org.gvsig.compat.print.PrintAttributes toPrintAttributes()
    • toPrintAttributeSet

      public PrintRequestAttributeSet toPrintAttributeSet()
      Returns a PrintRequestAttributeSet with all properties to the PrintDialog.
      Returns:
      PrintRequestAttributesSet.
    • isMargin

      public boolean isMargin()
      Returns true if the margin should be used.
      Returns:
      True if margin should be used.
    • getResolution

      public int getResolution()
      Returns the resolution of properties to print.
      Returns:
      Resolution.
    • setResolution

      public void setResolution(int i)
      Inserts the resolution to apply at printing.
      Parameters:
      i - Type of resolution. The type of resolution can be: DRAFT: 27 dpi. NORMAL: 300 dpi. HIGH: 600 dpi.
    • toPrintQuality

      public static PrintQuality toPrintQuality(int quality)
      Converts print quality from Attributes format (HIGH, NORMAL, DRAFT) to PrintQuality format.
      Parameters:
      quality -
      Returns:
    • getAttributes

      public PrintRequestAttributeSet getAttributes()
      Returns attributes of PrintDialog.
      Returns:
      Attributes of printing.
    • getType

      public int getType()
      Returns the format of sheet.
      Returns:
      Format of sheet.
    • setHGridGrapCm

      public void setHGridGrapCm(double d)
      Inserts the number of units to define the coords X grid.
      Parameters:
      d - number of units to define the grid.
    • getHGridGapCm

      public double getHGridGapCm()
      Gets the grid gap for the x axis, in centimeters. The grip gap is the distance from one point to the next point in the snapping grid.
      Returns:
      Default grid gap for the x axis, measured in centimeters
    • getVGridGapCm

      public double getVGridGapCm()
      Gets the grid gap for the y axis, in centimeters. The grip gap is the distance from one point to the next point in the snapping grid.
      Returns:
      Default grid gap for the y axis, measured in centimeters
    • setVGridGrapCm

      public void setVGridGrapCm(double d)
      Inserts the number of units to define the coords X grid.
      Parameters:
      d - number of units to define the grid.
    • setIsLandScape

      public void setIsLandScape(boolean b)
      Inserts true if the sheet is horizontal or false if is vertical.
      Parameters:
      b - True if sheet is horizontal.
    • setType

      public void setType(int t)
      Sets the type of sheet to show. See PRINT, CUSTOM, A4, A3, A2, A1, A0.
      Parameters:
      t - Type of sheet.
    • setPaperSizeInUnits

      public void setPaperSizeInUnits(Size sizeInUnits)
      Sets the paper size, measured on the selected units
      Parameters:
      sizeInUnits -
      See Also:
    • getPaperSizeinUnits

      public Size getPaperSizeinUnits(boolean isLand, int type)
      Returns the size of sheet.
      Parameters:
      isLand - True if is horizontal and false if is vertical.
      type - Type of sheet.
      Returns:
      Size of sheet with these properties.
    • getUnit

      public int getUnit()
      Returns the type of unit in use (cm, mm, km, etc), codified as a position in the array returned by MapContext.getDistanceNames()
      Returns:
      Type of units.
      See Also:
      • setUnit(int)
      • MapContext.getDistanceNames()
      • MapContext.getDistanceTrans2Meter()
      • MapContext.getDistanceAbbr()
      • MapContext.getDistancePosition(String)
      • MapContext.getDistancePosition(String)
    • getSelTypeUnit

      @Deprecated public int getSelTypeUnit()
      Deprecated.
      Use getUnit() instead
      Returns:
    • getNameUnit

      public String getNameUnit()
      Returns the name of the selected units.
      Returns:
      String Name of units.
      See Also:
    • setUnit

      public 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(). By default is centimeters.
      Parameters:
      sel - Type of unit.
      See Also:
    • toUnits

      public double toUnits(double d)
      Returns a double in the unit of measure selected from the double in centimeters.
      Parameters:
      d - Distance in centimeters.
      Returns:
      Distance in the unit measure selected.
    • fromUnits

      public double fromUnits(double d)
      Returns a double in centimeters from the the unit of measure selected.
      Parameters:
      d - Distance in the unit measure selected.
      Returns:
      Distance in centimeters.
    • getPixXCm

      public double getPixXCm(Rectangle2D rect)
      Returns one centimeter in pixels on screen in this moment.
      Parameters:
      rect - Rectangle of sheet.
      Returns:
      Pixels from centimeter.
    • calculateGridGapX

      public 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. The grip gap is the distance from one point to the next point in the snapping grid.
      Parameters:
      rect - Rectangle of sheet, measured in pixels
    • calculateGridGapY

      public 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. The grip gap is the distance from one point to the next point in the snapping grid.
      Parameters:
      rect - Rectangle of sheet, measured in pixels
    • obtainRect

      public void obtainRect(boolean isPrint, Rectangle2D rect, int w, int h)
      Obtains the rectangle that represents the sheet with the characteristics that contains attributes
      Parameters:
      isPrint -
      rect - rectangle.
      w -
      h -
    • getRectangleLandscape

      public 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.
      Parameters:
      rect - Rectangle sheet.
      w - Width of Layout.
      h - Height of Layout.
      Returns:
      Rectangle modified.
    • getPaperSizeInUnits

      public Size getPaperSizeInUnits()
      Returns the size of sheet in the units of measure selected.
      Returns:
      Size of sheet.
    • getSizeInUnits

      @Deprecated public Size getSizeInUnits()
      Deprecated.
      Returns:
    • getRectanglePortrait

      public 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.
      Parameters:
      rect - Rectangle sheet.
      w - Width of Layout.
      h - Height of Layout.
      Returns:
      Rectangle modified.
    • setDefaultGridGap

      public static void setDefaultGridGap(double hGap, double vGap, String hUnitAbbr, String vUnitAbbr)
      Sets the default grid gap. The grip gap is the distance from one point to the next point in the snapping grid.
      Parameters:
      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()
    • getDefaultGridGap

      public static Point2D getDefaultGridGap()
      Gets the default grid gap, in centimeters. The grip gap is the distance from one point to the next point in the snapping grid.
      Returns:
      Default grid gap, measured in centimeters
    • getDistanceAbbrPosition

      public static int getDistanceAbbrPosition(String unitAbbr)
    • getVGridGapPx

      public double getVGridGapPx()
      Gets the grid gap for the y axis, in pixels. The grip gap is the distance from one point to the next point in the snapping grid.
      Returns:
      Number of pixels of each grid gap for the y axis
    • getHGridGapPx

      public double getHGridGapPx()
      Gets the grid gap for the x axis, in pixels. The grip gap is the distance from one point to the next point in the snapping grid.
      Returns:
      Number of pixels of each grid gap for the x axis
    • registerPersistent

      public static void registerPersistent()
    • loadFromState

      public void loadFromState(org.gvsig.tools.persistence.PersistentState state) throws org.gvsig.tools.persistence.exception.PersistenceException
      Specified by:
      loadFromState in interface org.gvsig.tools.persistence.Persistent
      Throws:
      org.gvsig.tools.persistence.exception.PersistenceException
    • saveToState

      public void saveToState(org.gvsig.tools.persistence.PersistentState state) throws org.gvsig.tools.persistence.exception.PersistenceException
      Specified by:
      saveToState in interface org.gvsig.tools.persistence.Persistent
      Throws:
      org.gvsig.tools.persistence.exception.PersistenceException
    • getConversionFactorToCm

      public static double getConversionFactorToCm(int unit)
      Gets the conversion factor from the specified unit to centimeters. If you have some distance measured in the specified unit, you can multiply it by this factor in order to convert the distance to cm.
      Parameters:
      unit - The source unit, codified as a position in the array MapContext.getDistanceNames()
      Returns:
      A conversion factor from the specified unit to cm
    • clone

      public Object clone()
      Overrides:
      clone in class Object