Methods Summary |
---|
public android.print.PrintAttributes | asLandscape()Gets a new print attributes instance which is in landscape orientation,
which is the media size is in landscape and all orientation dependent
attributes such as resolution and margins are properly adjusted.
if (!isPortrait()) {
return this;
}
PrintAttributes attributes = new PrintAttributes();
// Rotate the media size.
attributes.setMediaSize(getMediaSize().asLandscape());
// Rotate the resolution.
Resolution oldResolution = getResolution();
Resolution newResolution = new Resolution(
oldResolution.getId(),
oldResolution.getLabel(),
oldResolution.getVerticalDpi(),
oldResolution.getHorizontalDpi());
attributes.setResolution(newResolution);
// Do not rotate the physical margins.
attributes.setMinMargins(getMinMargins());
attributes.setColorMode(getColorMode());
return attributes;
|
public android.print.PrintAttributes | asPortrait()Gets a new print attributes instance which is in portrait orientation,
which is the media size is in portrait and all orientation dependent
attributes such as resolution and margins are properly adjusted.
if (isPortrait()) {
return this;
}
PrintAttributes attributes = new PrintAttributes();
// Rotate the media size.
attributes.setMediaSize(getMediaSize().asPortrait());
// Rotate the resolution.
Resolution oldResolution = getResolution();
Resolution newResolution = new Resolution(
oldResolution.getId(),
oldResolution.getLabel(),
oldResolution.getVerticalDpi(),
oldResolution.getHorizontalDpi());
attributes.setResolution(newResolution);
// Do not rotate the physical margins.
attributes.setMinMargins(getMinMargins());
attributes.setColorMode(getColorMode());
return attributes;
|
public void | clear()
mMediaSize = null;
mResolution = null;
mMinMargins = null;
mColorMode = 0;
|
static java.lang.String | colorModeToString(int colorMode)
switch (colorMode) {
case COLOR_MODE_MONOCHROME: {
return "COLOR_MODE_MONOCHROME";
}
case COLOR_MODE_COLOR: {
return "COLOR_MODE_COLOR";
}
default:
return "COLOR_MODE_UNKNOWN";
}
|
public void | copyFrom(android.print.PrintAttributes other)
mMediaSize = other.mMediaSize;
mResolution = other.mResolution;
mMinMargins = other.mMinMargins;
mColorMode = other.mColorMode;
|
public int | describeContents()
return 0;
|
static void | enforceValidColorMode(int colorMode)
if ((colorMode & VALID_COLOR_MODES) == 0 && Integer.bitCount(colorMode) == 1) {
throw new IllegalArgumentException("invalid color mode: " + colorMode);
}
|
public boolean | equals(java.lang.Object obj)
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
PrintAttributes other = (PrintAttributes) obj;
if (mColorMode != other.mColorMode) {
return false;
}
if (mMinMargins == null) {
if (other.mMinMargins != null) {
return false;
}
} else if (!mMinMargins.equals(other.mMinMargins)) {
return false;
}
if (mMediaSize == null) {
if (other.mMediaSize != null) {
return false;
}
} else if (!mMediaSize.equals(other.mMediaSize)) {
return false;
}
if (mResolution == null) {
if (other.mResolution != null) {
return false;
}
} else if (!mResolution.equals(other.mResolution)) {
return false;
}
return true;
|
public int | getColorMode()Gets the color mode.
return mColorMode;
|
public android.print.PrintAttributes$MediaSize | getMediaSize()Gets the media size.
return mMediaSize;
|
public android.print.PrintAttributes$Margins | getMinMargins()Gets the minimal margins. If the content does not fit
these margins it will be clipped.
These margins are physically imposed by the printer and they
are not rotated, i.e. they are the same for both portrait and
landscape. For example, a printer may not be able to print in a stripe
on both left and right sides of the page.
return mMinMargins;
|
public android.print.PrintAttributes$Resolution | getResolution()Gets the resolution.
return mResolution;
|
public int | hashCode()
final int prime = 31;
int result = 1;
result = prime * result + mColorMode;
result = prime * result + ((mMinMargins == null) ? 0 : mMinMargins.hashCode());
result = prime * result + ((mMediaSize == null) ? 0 : mMediaSize.hashCode());
result = prime * result + ((mResolution == null) ? 0 : mResolution.hashCode());
return result;
|
public boolean | isPortrait()Gets whether this print attributes are in portrait orientation,
which is the media size is in portrait and all orientation dependent
attributes such as resolution and margins are properly adjusted.
return mMediaSize.isPortrait();
|
public void | setColorMode(int colorMode)Sets the color mode.
enforceValidColorMode(colorMode);
mColorMode = colorMode;
|
public void | setMediaSize(android.print.PrintAttributes$MediaSize mediaSize)Sets the media size.
mMediaSize = mediaSize;
|
public void | setMinMargins(android.print.PrintAttributes$Margins margins)Sets the minimal margins. If the content does not fit
these margins it will be clipped.
These margins are physically imposed by the printer and they
are not rotated, i.e. they are the same for both portrait and
landscape. For example, a printer may not be able to print in a stripe
on both left and right sides of the page.
mMinMargins = margins;
|
public void | setResolution(android.print.PrintAttributes$Resolution resolution)Sets the resolution.
mResolution = resolution;
|
public java.lang.String | toString()
StringBuilder builder = new StringBuilder();
builder.append("PrintAttributes{");
builder.append("mediaSize: ").append(mMediaSize);
if (mMediaSize != null) {
builder.append(", orientation: ").append(mMediaSize.isPortrait()
? "portrait" : "landscape");
} else {
builder.append(", orientation: ").append("null");
}
builder.append(", resolution: ").append(mResolution);
builder.append(", minMargins: ").append(mMinMargins);
builder.append(", colorMode: ").append(colorModeToString(mColorMode));
builder.append("}");
return builder.toString();
|
public void | writeToParcel(android.os.Parcel parcel, int flags)
if (mMediaSize != null) {
parcel.writeInt(1);
mMediaSize.writeToParcel(parcel);
} else {
parcel.writeInt(0);
}
if (mResolution != null) {
parcel.writeInt(1);
mResolution.writeToParcel(parcel);
} else {
parcel.writeInt(0);
}
if (mMinMargins != null) {
parcel.writeInt(1);
mMinMargins.writeToParcel(parcel);
} else {
parcel.writeInt(0);
}
parcel.writeInt(mColorMode);
|